diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 7ccb03f9d0..fd9b2d087b 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,22 @@ +2001-08-21 John Levon + + * 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 * all files: enormous naming re-jig and tidy diff --git a/src/frontends/qt2/Dialogs.C b/src/frontends/qt2/Dialogs.C index 27178b705d..9b4e8e3058 100644 --- a/src/frontends/qt2/Dialogs.C +++ b/src/frontends/qt2/Dialogs.C @@ -19,6 +19,7 @@ #include "QAbout.h" #include "QCharacter.h" #include "QCitation.h" +#include "QIndex.h" #include "QParagraph.h" #include "QPrint.h" #include "QSearch.h" @@ -38,8 +39,9 @@ #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" @@ -56,7 +58,6 @@ #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" @@ -85,6 +86,7 @@ Dialogs::Dialogs(LyXView * lv) // dialogs that have been converted to new scheme add(new GUICitation(*lv, *this)); add(new GUIAboutlyx(*lv, *this)); + add(new GUIIndex(*lv, *this)); // reduce the number of connections needed in // dialogs by a simple connection here. diff --git a/src/frontends/qt2/Makefile.am b/src/frontends/qt2/Makefile.am index f0ad5edcb4..afbd48adde 100644 --- a/src/frontends/qt2/Makefile.am +++ b/src/frontends/qt2/Makefile.am @@ -13,11 +13,12 @@ DISTCLEANFILES = $(BUILTSOURCES) *.orig *.rej *~ *.bak core 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 \ diff --git a/src/frontends/qt2/QAbout.C b/src/frontends/qt2/QAbout.C index f78298ca66..c2de642c35 100644 --- a/src/frontends/qt2/QAbout.C +++ b/src/frontends/qt2/QAbout.C @@ -8,11 +8,15 @@ #include +#include "support/lstrings.h" +#include "Lsstream.h" +#include "debug.h" #include "gettext.h" #include "QAboutDialog.h" #include #include +#include #include "QtLyXView.h" #include "ButtonControllerBase.h" @@ -37,7 +41,28 @@ void QAbout::build() 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 += "" + s.substr(2) + ""; + else if (prefixIs(s, "@i")) + out += "" + s.substr(2) + ""; + else + out += s; + out += "
"; + } + + dialog_->creditsTV->setText(out.c_str()); + // Manage the cancel/close button bc().setCancel(dialog_->closePB); bc().refresh(); diff --git a/src/frontends/qt2/QCitationDialog.C b/src/frontends/qt2/QCitationDialog.C index bb0e07c516..70e6e8254e 100644 --- a/src/frontends/qt2/QCitationDialog.C +++ b/src/frontends/qt2/QCitationDialog.C @@ -140,6 +140,7 @@ void QCitationDialog::slotAddClicked() form_->setBibButtons(QCitation::OFF); form_->setCiteButtons(QCitation::ON); + form_->changed(); } @@ -158,6 +159,7 @@ void QCitationDialog::slotDelClicked() form_->setBibButtons(QCitation::ON); form_->setCiteButtons(QCitation::OFF); + form_->changed(); } @@ -181,6 +183,7 @@ void QCitationDialog::slotUpClicked() citeLB->setSelected(sel - 1, true); form_->citekeys.insert(it - 1, tmp); form_->setCiteButtons(QCitation::ON); + form_->changed(); } @@ -204,6 +207,7 @@ void QCitationDialog::slotDownClicked() citeLB->setSelected(sel + 1, true); form_->citekeys.insert(it + 1, tmp); form_->setCiteButtons(QCitation::ON); + form_->changed(); } @@ -264,14 +268,17 @@ void QCitationDialog::doFind(biblio::Direction const dir) void QCitationDialog::slotCitationStyleSelected( int ) { + form_->changed(); } void QCitationDialog::slotTextBeforeReturn() { + form_->changed(); } void QCitationDialog::slotTextAfterReturn() { + form_->changed(); } diff --git a/src/frontends/qt2/QIndex.C b/src/frontends/qt2/QIndex.C index 5769ececd8..a59c75ddce 100644 --- a/src/frontends/qt2/QIndex.C +++ b/src/frontends/qt2/QIndex.C @@ -13,6 +13,7 @@ #include "BufferView.h" #include "Dialogs.h" +#include "qt2BC.h" #include "QIndex.h" #include "gettext.h" #include "buffer.h" @@ -21,50 +22,32 @@ #include #include -QIndex::QIndex(LyXView *v, Dialogs *d) - : dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0) +typedef Qt2CB > 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; + dialog_.reset(new QIndexDialog(this)); - inset_ = inset; - readonly = lv_->buffer()->isReadonly(); - //FIXME ih_ = inset_->hide.connect(slot(this,&QIndex::hide)); - params = inset->params(); - - show(); -} - - -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); @@ -84,47 +67,5 @@ void QIndex::apply() 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()); } diff --git a/src/frontends/qt2/QIndex.h b/src/frontends/qt2/QIndex.h index 6611b05e7e..f0f71d2871 100644 --- a/src/frontends/qt2/QIndex.h +++ b/src/frontends/qt2/QIndex.h @@ -11,61 +11,38 @@ #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 > { - /// 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 diff --git a/src/frontends/qt2/QIndexDialog.C b/src/frontends/qt2/QIndexDialog.C index b426076dd1..287151e323 100644 --- a/src/frontends/qt2/QIndexDialog.C +++ b/src/frontends/qt2/QIndexDialog.C @@ -10,8 +10,8 @@ #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) { } @@ -22,23 +22,22 @@ QIndexDialog::~QIndexDialog() } -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(); } diff --git a/src/frontends/qt2/QIndexDialog.h b/src/frontends/qt2/QIndexDialog.h index 559bc3ff67..302e4acf2b 100644 --- a/src/frontends/qt2/QIndexDialog.h +++ b/src/frontends/qt2/QIndexDialog.h @@ -19,11 +19,11 @@ class QIndexDialog : public QIndexDialogBase { 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: diff --git a/src/frontends/qt2/Qt2Base.C b/src/frontends/qt2/Qt2Base.C index 202833ca96..29b0c4975b 100644 --- a/src/frontends/qt2/Qt2Base.C +++ b/src/frontends/qt2/Qt2Base.C @@ -38,12 +38,14 @@ void Qt2Base::show() 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(); } } @@ -51,25 +53,17 @@ void Qt2Base::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(); diff --git a/src/frontends/qt2/Qt2Base.h b/src/frontends/qt2/Qt2Base.h index 4d90123f0c..cf697c0bdc 100644 --- a/src/frontends/qt2/Qt2Base.h +++ b/src/frontends/qt2/Qt2Base.h @@ -21,8 +21,6 @@ class QDialog; #include #include -#include - #ifdef __GNUG__ #pragma interface #endif @@ -32,6 +30,8 @@ class QDialog; #include "ButtonPolicies.h" #include "ControlButtons.h" +#include + class qt2BC; /** This class is an Qt2 GUI base class. @@ -53,6 +53,9 @@ protected: /// 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(); @@ -72,9 +75,6 @@ protected slots: 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. diff --git a/src/frontends/qt2/ui/Makefile.am b/src/frontends/qt2/ui/Makefile.am index b0c410899f..9c16857411 100644 --- a/src/frontends/qt2/ui/Makefile.am +++ b/src/frontends/qt2/ui/Makefile.am @@ -14,9 +14,6 @@ include ../Makefile.dialogs 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 diff --git a/src/frontends/qt2/ui/QAboutDialog.ui b/src/frontends/qt2/ui/QAboutDialog.ui index 5c33605f2d..004a193f04 100644 --- a/src/frontends/qt2/ui/QAboutDialog.ui +++ b/src/frontends/qt2/ui/QAboutDialog.ui @@ -11,7 +11,7 @@ 0 0 - 464 + 448 454 @@ -29,131 +29,236 @@ 6 - QLabel + QTabWidget name - copyrightLA - - - frameShape - Box - - - frameShadow - Sunken - - - margin - 6 - - - text - LyX is Copyright (C) 1995 by Matthias Ettrich, -1995-2001 by LyX Team - - - alignment - AlignCenter - - - hAlign - - - - QLabel - - name - licenseLA - - - sizePolicy - - 5 - 5 - - - - frameShape - Box - - - frameShadow - Sunken - - - margin - 6 - - - text - 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. - - - alignment - WordBreak|AlignCenter - - - hAlign - - - wordwrap - - - - QLabel - - name - disclaimerLA - - - sizePolicy - - 5 - 5 - - - - minimumSize - - 0 - 0 - - - - frameShape - Box - - - frameShadow - Sunken - - - margin - 6 - - - text - 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. - - - alignment - WordBreak|AlignCenter - - - hAlign - - - wordwrap + tab + + QWidget + + name + versiontab + + + title + Version + + + + margin + 11 + + + spacing + 6 + + + QLabel + + name + versionLA + + + frameShape + Box + + + frameShadow + Sunken + + + margin + 6 + + + text + Version goes here + + + alignment + AlignCenter + + + hAlign + + + + + + QWidget + + name + creditstab + + + title + Credits + + + + margin + 11 + + + spacing + 6 + + + QTextView + + name + creditsTV + + + textFormat + RichText + + + text + + + + + + + QWidget + + name + copyrighttab + + + title + Copyright + + + + margin + 11 + + + spacing + 6 + + + QLabel + + name + copyrightLA + + + frameShape + Box + + + frameShadow + Sunken + + + margin + 6 + + + text + Copyright notice goes here + + + alignment + AlignCenter + + + hAlign + + + + QLabel + + name + disclaimerLA + + + sizePolicy + + 5 + 5 + + + + minimumSize + + 0 + 0 + + + + frameShape + Box + + + frameShadow + Sunken + + + margin + 6 + + + text + Warranty goes here + + + alignment + WordBreak|AlignCenter + + + hAlign + + + wordwrap + + + + QLabel + + name + licenseLA + + + sizePolicy + + 5 + 5 + + + + frameShape + Box + + + frameShadow + Sunken + + + margin + 6 + + + text + GPL goes here + + + alignment + WordBreak|AlignCenter + + + hAlign + + + wordwrap + + + + QPushButton diff --git a/src/frontends/qt2/ui/QCitationDialog.ui b/src/frontends/qt2/ui/QCitationDialog.ui index deef689c91..4ecabcd6b6 100644 --- a/src/frontends/qt2/ui/QCitationDialog.ui +++ b/src/frontends/qt2/ui/QCitationDialog.ui @@ -11,7 +11,7 @@ 0 0 - 487 + 483 585 @@ -252,6 +252,14 @@ wordWrap WidgetWidth + + readOnly + true + + + focusPolicy + NoFocus + toolTip Reference entry text diff --git a/src/frontends/qt2/ui/QIndexDialog.ui b/src/frontends/qt2/ui/QIndexDialog.ui index e26fa3dc00..4617a069bd 100644 --- a/src/frontends/qt2/ui/QIndexDialog.ui +++ b/src/frontends/qt2/ui/QIndexDialog.ui @@ -146,7 +146,7 @@ okPB clicked() QIndexDialogBase - apply_adaptor() + ok_adaptor() cancelPB @@ -154,7 +154,7 @@ QIndexDialogBase close_adaptor() - apply_adaptor() + ok_adaptor() close_adaptor()