+2001-08-21 John Levon <moz@compsoc.man.ac.uk>
+
+ * Dialogs.C: add QIndex
+
+ * ui/Makefile.am:
+ * Makefile.am: fix build
+
+ * ui/QAboutDialog.ui:
+ * QAbout.C: finish dialog
+
+ * ui/QCitationDialog.ui:
+ * QCitationDialog.C: BC fixes
+
+ * ui/QIndexDialog.ui:
+ * QIndex.h:
+ * QIndex.C:
+ * QIndexDialog.h:
+ * QIndexDialog.C: got index dialog working
+
2001-08-19 John Levon <moz@compsoc.man.ac.uk>
* all files: enormous naming re-jig and tidy
#include "QAbout.h"
#include "QCharacter.h"
#include "QCitation.h"
+#include "QIndex.h"
#include "QParagraph.h"
#include "QPrint.h"
#include "QSearch.h"
#include "../xforms/FormTabular.h"
// the controllers
-#include "controllers/ControlCitation.h"
#include "controllers/ControlAboutlyx.h"
+#include "controllers/ControlCitation.h"
+#include "controllers/ControlIndex.h"
#include "controllers/ControlSplash.h"
#if 0
#include "controllers/ControlCopyright.h"
#include "controllers/ControlFloat.h"
#include "controllers/ControlGraphics.h"
#include "controllers/ControlInclude.h"
-#include "controllers/ControlIndex.h"
#include "controllers/ControlLabel.h"
#include "controllers/ControlLog.h"
#include "controllers/ControlMinipage.h"
// dialogs that have been converted to new scheme
add(new GUICitation<QCitation, qt2BC>(*lv, *this));
add(new GUIAboutlyx<QAbout, qt2BC>(*lv, *this));
+ add(new GUIIndex<QIndex, qt2BC>(*lv, *this));
// reduce the number of connections needed in
// dialogs by a simple connection here.
include Makefile.dialogs
-libqt2_la_DEPENDENCIES = ui/libqt2ui.la moc/libqt2moc.la
+libqt2_la_DEPENDENCIES = ui/libqt2ui.la moc/libqt2moc.la ui/moc/libqt2uimoc.la
libqt2_la_OBJADD = \
ui/libqt2ui.la \
moc/libqt2moc.la \
+ ui/moc/libqt2uimoc.la \
../controllers/ButtonControllerBase.lo \
../xforms/combox.lo \
../xforms/Color.lo \
#include <config.h>
+#include "support/lstrings.h"
+#include "Lsstream.h"
+#include "debug.h"
#include "gettext.h"
#include "QAboutDialog.h"
#include <qlabel.h>
#include <qpushbutton.h>
+#include <qtextview.h>
#include "QtLyXView.h"
#include "ButtonControllerBase.h"
dialog_->copyrightLA->setText(controller().getCopyright().c_str());
dialog_->licenseLA->setText(controller().getLicense().c_str());
dialog_->disclaimerLA->setText(controller().getDisclaimer().c_str());
+ dialog_->versionLA->setText(controller().getVersion().c_str());
+
+ stringstream in;
+ controller().getCredits(in);
+ istringstream ss(in.str().c_str());
+
+ string s;
+ string out;
+
+ while (getline(ss, s)) {
+ if (prefixIs(s, "@b"))
+ out += "<b>" + s.substr(2) + "</b>";
+ else if (prefixIs(s, "@i"))
+ out += "<i>" + s.substr(2) + "</i>";
+ else
+ out += s;
+ out += "<br>";
+ }
+
+ dialog_->creditsTV->setText(out.c_str());
+
// Manage the cancel/close button
bc().setCancel(dialog_->closePB);
bc().refresh();
form_->setBibButtons(QCitation::OFF);
form_->setCiteButtons(QCitation::ON);
+ form_->changed();
}
form_->setBibButtons(QCitation::ON);
form_->setCiteButtons(QCitation::OFF);
+ form_->changed();
}
citeLB->setSelected(sel - 1, true);
form_->citekeys.insert(it - 1, tmp);
form_->setCiteButtons(QCitation::ON);
+ form_->changed();
}
citeLB->setSelected(sel + 1, true);
form_->citekeys.insert(it + 1, tmp);
form_->setCiteButtons(QCitation::ON);
+ form_->changed();
}
void QCitationDialog::slotCitationStyleSelected( int )
{
+ form_->changed();
}
void QCitationDialog::slotTextBeforeReturn()
{
+ form_->changed();
}
void QCitationDialog::slotTextAfterReturn()
{
+ form_->changed();
}
#include "BufferView.h"
#include "Dialogs.h"
+#include "qt2BC.h"
#include "QIndex.h"
#include "gettext.h"
#include "buffer.h"
#include <qlineedit.h>
#include <qpushbutton.h>
-QIndex::QIndex(LyXView *v, Dialogs *d)
- : dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0)
+typedef Qt2CB<ControlIndex, Qt2DB<QIndexDialog> > base_class;
+
+QIndex::QIndex(ControlIndex & c)
+ : base_class(c, _("Index"))
{
- d->showIndex.connect(slot(this, &QIndex::showIndex));
- d->createIndex.connect(slot(this, &QIndex::createIndex));
}
QIndex::~QIndex()
{
- delete dialog_;
}
-void QIndex::showIndex(InsetCommand * const inset)
+void QIndex::build()
{
- // FIXME: when could inset be 0 here ?
- if (inset==0)
- return;
-
- inset_ = inset;
- readonly = lv_->buffer()->isReadonly();
- //FIXME ih_ = inset_->hide.connect(slot(this,&QIndex::hide));
- params = inset->params();
-
- show();
-}
+ dialog_.reset(new QIndexDialog(this));
-
-void QIndex::createIndex(string const & arg)
-{
- // we could already be showing a URL, clear it out
- if (inset_)
- close();
-
- readonly = lv_->buffer()->isReadonly();
- params.setFromString(arg);
- show();
+ bc().setOK(dialog_->okPB);
+ bc().setCancel(dialog_->cancelPB);
+ bc().addReadOnly(dialog_->keywordED);
}
void QIndex::update()
{
- dialog_->keywordED->setText(params.getContents().c_str());
+ dialog_->keywordED->setText(controller().params().getContents().c_str());
if (readonly) {
dialog_->keywordED->setFocusPolicy(QWidget::NoFocus);
if (readonly)
return;
- params.setContents(dialog_->keywordED->text().latin1());
-
- if (inset_ != 0) {
- if (params != inset_->params()) {
- inset_->setParams(params);
- lv_->view()->updateInset(inset_, true);
- }
- } else
- lv_->getLyXFunc()->dispatch(LFUN_INDEX_INSERT, params.getAsString().c_str());
-}
-
-
-void QIndex::show()
-{
- if (!dialog_)
- dialog_ = new QIndexDialog(this, 0, _("LyX: Index"), false);
-
- if (!dialog_->isVisible()) {
- h_ = d_->hideBufferDependent.connect(slot(this, &QIndex::hide));
- //u_ = d_->updateBufferDependent.connect(slot(this, &QIndex::update));
- }
-
- dialog_->raise();
- dialog_->setActiveWindow();
-
- update();
- dialog_->show();
-}
-
-
-void QIndex::close()
-{
- h_.disconnect();
- u_.disconnect();
- ih_.disconnect();
- inset_ = 0;
-}
-
-
-void QIndex::hide()
-{
- dialog_->hide();
- close();
+ controller().params().setContents(dialog_->keywordED->text().latin1());
}
#ifndef QINDEX_H
#define QINDEX_H
-#include "DialogBase.h"
+#include "Qt2Base.h"
+#include "ControlIndex.h"
#include "LString.h"
#include "boost/utility.hpp"
-#include "insets/insetindex.h"
class Dialogs;
class LyXView;
class QIndexDialog;
-class QIndex : public DialogBase {
-public:
- QIndex(LyXView *, Dialogs *);
- ~QIndex();
+class QIndex :
+ public Qt2CB<ControlIndex, Qt2DB<QIndexDialog> > {
- /// Apply changes
- void apply();
- /// close the connections
- void close();
+ friend class QIndexDialog;
+public:
+ QIndex(ControlIndex &);
+ ~QIndex();
private:
- /// Create the dialog if necessary, update it and display it.
- void show();
- /// Hide the dialog.
- void hide();
- /// Update the dialog.
- void update();
+ /// Apply changes
+ virtual void apply();
+ /// update
+ virtual void update();
+ /// build the dialog
+ virtual void build();
/// create an Index inset
void createIndex(string const &);
/// edit an Index inset
void showIndex(InsetCommand * const);
- /// Real GUI implementation.
- QIndexDialog * dialog_;
-
- /// the LyXView we belong to
- LyXView * lv_;
-
- /** Which Dialogs do we belong to?
- Used so we can get at the signals we have to connect to.
- */
- Dialogs * d_;
- /// pointer to the inset if any
- InsetCommand * inset_;
- /// insets params
- InsetCommandParams params;
/// is the inset we are reading from a readonly buffer ?
bool readonly;
-
- /// Hide connection.
- SigC::Connection h_;
- /// Update connection.
- SigC::Connection u_;
- /// Inset hide connection.
- SigC::Connection ih_;
};
#endif // QINDEX_H
#include "Dialogs.h"
#include "QIndex.h"
-QIndexDialog::QIndexDialog(QIndex * form, QWidget * parent, const char * name, bool modal, WFlags fl)
- : QIndexDialogBase(parent, name, modal, fl),
+QIndexDialog::QIndexDialog(QIndex * form)
+ : QIndexDialogBase(0, 0, false, 0),
form_(form)
{
}
}
-void QIndexDialog::apply_adaptor()
+void QIndexDialog::ok_adaptor()
{
- form_->apply();
- form_->close();
+ form_->slotOK();
hide();
}
void QIndexDialog::close_adaptor()
{
- form_->close();
+ form_->slotCancel();
hide();
}
void QIndexDialog::closeEvent(QCloseEvent *e)
{
- form_->close();
+ form_->slotWMHide();
e->accept();
}
{ Q_OBJECT
public:
- QIndexDialog(QIndex * form, QWidget * parent = 0, const char * name = 0, bool modal = FALSE, WFlags fl = 0);
+ QIndexDialog(QIndex * form);
~QIndexDialog();
public slots:
- void apply_adaptor();
+ void ok_adaptor();
void close_adaptor();
protected:
build();
}
+ form()->setMinimumSize(form()->sizeHint());
+
update(); // make sure its up-to-date
if (form()->isVisible()) {
form()->raise();
} else {
- form()->setCaption( title_ );
+ form()->setCaption(title_);
form()->show();
}
}
void Qt2Base::hide()
{
- if (form() && form()->isVisible() )
+ if (form() && form()->isVisible())
form()->hide();
}
-// PENDING(kalle) Handle this with QValidator?
-// void Qt2Base::InputCB(FL_OBJECT * ob, long data)
-// {
-// bc().input(input(ob, data));
-// }
-
-
-ButtonPolicy::SMInput Qt2Base::input(QWidget*, long)
+void Qt2Base::changed()
{
- return ButtonPolicy::SMI_VALID;
+ bc().valid();
}
-
void Qt2Base::slotWMHide()
{
CancelButton();
#include <qfont.h>
#include <qobject.h>
-#include <boost/smart_ptr.hpp>
-
#ifdef __GNUG__
#pragma interface
#endif
#include "ButtonPolicies.h"
#include "ControlButtons.h"
+#include <boost/smart_ptr.hpp>
+
class qt2BC;
/** This class is an Qt2 GUI base class.
/// Create the dialog if necessary, update it and display it.
void show();
+ /// the dialog has changed contents
+ virtual void changed();
+
protected slots:
// dialog closed from WM
void slotWMHide();
private:
/// Pointer to the actual instantiation of xform's form
virtual QDialog* form() const = 0;
- /** Filter the inputs on callback from xforms
- Return true if inputs are valid. */
- virtual ButtonPolicy::SMInput input(QWidget*, long);
private:
/// dialog title, displayed by WM.
DISTCLEANFILES = $(UIDIALOGS) *.orig *.rej *~ *.bak core
-libqt2ui_la_DEPENDENCIES = moc/libqt2uimoc.la
-libqt2ui_la_OBJADD = moc/libqt2uimoc.la
-
libqt2ui_la_SOURCES = $(UIDIALOGS)
%Base.h: %.ui
<rect>
<x>0</x>
<y>0</y>
- <width>464</width>
+ <width>448</width>
<height>454</height>
</rect>
</property>
<number>6</number>
</property>
<widget>
- <class>QLabel</class>
+ <class>QTabWidget</class>
<property stdset="1">
<name>name</name>
- <cstring>copyrightLA</cstring>
- </property>
- <property stdset="1">
- <name>frameShape</name>
- <enum>Box</enum>
- </property>
- <property stdset="1">
- <name>frameShadow</name>
- <enum>Sunken</enum>
- </property>
- <property stdset="1">
- <name>margin</name>
- <number>6</number>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>LyX is Copyright (C) 1995 by Matthias Ettrich,
-1995-2001 by LyX Team</string>
- </property>
- <property stdset="1">
- <name>alignment</name>
- <set>AlignCenter</set>
- </property>
- <property>
- <name>hAlign</name>
- </property>
- </widget>
- <widget>
- <class>QLabel</class>
- <property stdset="1">
- <name>name</name>
- <cstring>licenseLA</cstring>
- </property>
- <property stdset="1">
- <name>sizePolicy</name>
- <sizepolicy>
- <hsizetype>5</hsizetype>
- <vsizetype>5</vsizetype>
- </sizepolicy>
- </property>
- <property stdset="1">
- <name>frameShape</name>
- <enum>Box</enum>
- </property>
- <property stdset="1">
- <name>frameShadow</name>
- <enum>Sunken</enum>
- </property>
- <property stdset="1">
- <name>margin</name>
- <number>6</number>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</string>
- </property>
- <property stdset="1">
- <name>alignment</name>
- <set>WordBreak|AlignCenter</set>
- </property>
- <property>
- <name>hAlign</name>
- </property>
- <property>
- <name>wordwrap</name>
- </property>
- </widget>
- <widget>
- <class>QLabel</class>
- <property stdset="1">
- <name>name</name>
- <cstring>disclaimerLA</cstring>
- </property>
- <property stdset="1">
- <name>sizePolicy</name>
- <sizepolicy>
- <hsizetype>5</hsizetype>
- <vsizetype>5</vsizetype>
- </sizepolicy>
- </property>
- <property stdset="1">
- <name>minimumSize</name>
- <size>
- <width>0</width>
- <height>0</height>
- </size>
- </property>
- <property stdset="1">
- <name>frameShape</name>
- <enum>Box</enum>
- </property>
- <property stdset="1">
- <name>frameShadow</name>
- <enum>Sunken</enum>
- </property>
- <property stdset="1">
- <name>margin</name>
- <number>6</number>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>LyX is distributed in the hope that it will be
-useful, but WITHOUT ANY WARRANTY,
-without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A
-PARTICULAR PURPOSE. See the GNU General
-Public License for more details.
-You should have received a copy of the GNU
-General Public License along with this program;
-if not, write to the Free Software Foundation, Inc.,
-675 Mass Ave, Cambridge, MA 02139, USA.</string>
- </property>
- <property stdset="1">
- <name>alignment</name>
- <set>WordBreak|AlignCenter</set>
- </property>
- <property>
- <name>hAlign</name>
- </property>
- <property>
- <name>wordwrap</name>
+ <cstring>tab</cstring>
</property>
+ <widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>versiontab</cstring>
+ </property>
+ <attribute>
+ <name>title</name>
+ <string>Version</string>
+ </attribute>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>11</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>versionLA</cstring>
+ </property>
+ <property stdset="1">
+ <name>frameShape</name>
+ <enum>Box</enum>
+ </property>
+ <property stdset="1">
+ <name>frameShadow</name>
+ <enum>Sunken</enum>
+ </property>
+ <property stdset="1">
+ <name>margin</name>
+ <number>6</number>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Version goes here</string>
+ </property>
+ <property stdset="1">
+ <name>alignment</name>
+ <set>AlignCenter</set>
+ </property>
+ <property>
+ <name>hAlign</name>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>creditstab</cstring>
+ </property>
+ <attribute>
+ <name>title</name>
+ <string>Credits</string>
+ </attribute>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>11</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QTextView</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>creditsTV</cstring>
+ </property>
+ <property stdset="1">
+ <name>textFormat</name>
+ <enum>RichText</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string></string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>copyrighttab</cstring>
+ </property>
+ <attribute>
+ <name>title</name>
+ <string>Copyright</string>
+ </attribute>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>11</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>copyrightLA</cstring>
+ </property>
+ <property stdset="1">
+ <name>frameShape</name>
+ <enum>Box</enum>
+ </property>
+ <property stdset="1">
+ <name>frameShadow</name>
+ <enum>Sunken</enum>
+ </property>
+ <property stdset="1">
+ <name>margin</name>
+ <number>6</number>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Copyright notice goes here</string>
+ </property>
+ <property stdset="1">
+ <name>alignment</name>
+ <set>AlignCenter</set>
+ </property>
+ <property>
+ <name>hAlign</name>
+ </property>
+ </widget>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>disclaimerLA</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>minimumSize</name>
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>frameShape</name>
+ <enum>Box</enum>
+ </property>
+ <property stdset="1">
+ <name>frameShadow</name>
+ <enum>Sunken</enum>
+ </property>
+ <property stdset="1">
+ <name>margin</name>
+ <number>6</number>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Warranty goes here</string>
+ </property>
+ <property stdset="1">
+ <name>alignment</name>
+ <set>WordBreak|AlignCenter</set>
+ </property>
+ <property>
+ <name>hAlign</name>
+ </property>
+ <property>
+ <name>wordwrap</name>
+ </property>
+ </widget>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>licenseLA</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>frameShape</name>
+ <enum>Box</enum>
+ </property>
+ <property stdset="1">
+ <name>frameShadow</name>
+ <enum>Sunken</enum>
+ </property>
+ <property stdset="1">
+ <name>margin</name>
+ <number>6</number>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>GPL goes here</string>
+ </property>
+ <property stdset="1">
+ <name>alignment</name>
+ <set>WordBreak|AlignCenter</set>
+ </property>
+ <property>
+ <name>hAlign</name>
+ </property>
+ <property>
+ <name>wordwrap</name>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
</widget>
<widget>
<class>QPushButton</class>
<rect>
<x>0</x>
<y>0</y>
- <width>487</width>
+ <width>483</width>
<height>585</height>
</rect>
</property>
<name>wordWrap</name>
<enum>WidgetWidth</enum>
</property>
+ <property stdset="1">
+ <name>readOnly</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>NoFocus</enum>
+ </property>
<property>
<name>toolTip</name>
<string>Reference entry text</string>
<sender>okPB</sender>
<signal>clicked()</signal>
<receiver>QIndexDialogBase</receiver>
- <slot>apply_adaptor()</slot>
+ <slot>ok_adaptor()</slot>
</connection>
<connection>
<sender>cancelPB</sender>
<receiver>QIndexDialogBase</receiver>
<slot>close_adaptor()</slot>
</connection>
- <slot access="public">apply_adaptor()</slot>
+ <slot access="public">ok_adaptor()</slot>
<slot access="public">close_adaptor()</slot>
</connections>
</UI>