+2001-08-24 John Levon <moz@compsoc.man.ac.uk>
+
+ * Dialogs.C: include the right files
+
+ * QCitation.C: closePB not cancelPB
+
+ * QCitationDialog.C:
+ * QCitationDialog.h:
+ * ui/QCitationDialog.ui: small fixes
+
+ * QIndex.h:
+ * QIndex.C:
+ * QIndexDialog.C:
+ * QIndexDialog.h:
+ * ui/QIndexDialog.ui: more fixes
+
+ * Qt2Base.h:
+ * Qt2Base.C: add reset() to workaround problem.
+
+ * README: update
+
+ * Makefile.am:
+ * Timeout_pimpl.h:
+ * Timeout_pimpl.C: add the timer
+
2001-08-23 John Levon <moz@compsoc.man.ac.uk>
* Dialogs.C:
#endif
// the dialog definitions
-#include "QCitationDialog.h"
#include "QAboutDialog.h"
+#include "QCitationDialog.h"
+#include "QIndexDialog.h"
// the controller interface
#include "QAbout.h"
../xforms/MathsSymbols.lo \
../xforms/Menubar_pimpl.lo \
../xforms/RadioButtonGroup.lo \
- ../xforms/Timeout_pimpl.lo \
../xforms/Toolbar_pimpl.lo \
../xforms/bmtable.lo \
../xforms/form_bibitem.lo \
GUIRunTime.C \
FileDialog.C \
FileDialog_private.C \
+ Timeout_pimpl.h \
+ Timeout_pimpl.C \
Qt2Base.C \
Qt2Base.h \
Qt2BC.C \
{
dialog_.reset(new QAboutDialog());
connect(dialog_.get()->closePB, SIGNAL(clicked()),
- this, SLOT(slotCancel()));
+ this, SLOT(slotClose()));
dialog_->copyrightLA->setText(controller().getCopyright().c_str());
dialog_->licenseLA->setText(controller().getLicense().c_str());
#include "QCitationDialog.h"
#include "QCitation.h"
-
+
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qlineedit.h>
#include "QtLyXView.h"
#include "Qt2BC.h"
#include "ControlCitation.h"
+#include "debug.h"
#include "gettext.h"
#include "support/lstrings.h"
#include "helper_funcs.h"
// Manage the ok, apply, restore and cancel/close buttons
bc().setOK(dialog_->okPB);
bc().setApply(dialog_->applyPB);
- bc().setCancel(dialog_->cancelPB);
+ bc().setCancel(dialog_->closePB);
bc().setRestore(dialog_->restorePB);
bc().addReadOnly(dialog_->addPB);
bc().addReadOnly(dialog_->upPB);
bc().addReadOnly(dialog_->downPB);
bc().addReadOnly(dialog_->citationStyleCO);
- bc().addReadOnly(dialog_->textBeforeED);
+ // add when enabled !
+ //bc().addReadOnly(dialog_->textBeforeED);
bc().addReadOnly(dialog_->textAfterED);
}
setBibButtons(OFF);
setCiteButtons(OFF);
- dialog_->textAfterED->setText( controller().params().getOptions().c_str());
+ dialog_->textAfterED->setText(controller().params().getOptions().c_str());
+
+ reset();
}
class ControlCitation;
class QCitationDialog;
-class QCitation : public Qt2CB<ControlCitation, Qt2DB<QCitationDialog> > {
+class QCitation : public Qt2CB<ControlCitation, Qt2DB<QCitationDialog> >
+{
friend class QCitationDialog;
public:
/// Update dialog before/whilst showing it.
virtual void update();
- void updateBrowser(QListBox*, std::vector<string> const &) const;
+ void updateBrowser(QListBox *, std::vector<string> const &) const;
///
void setBibButtons(State) const;
///
*/
#include <config.h>
-
+
+#include "gettext.h"
+
#include "QCitationDialog.h"
#include "Dialogs.h"
-#include "QCitation.h"
#include "controllers/ControlCitation.h"
#include <qcheckbox.h>
+#include <qcombobox.h>
#include <qlineedit.h>
#include <qlistbox.h>
#include <qmultilineedit.h>
#include <qpushbutton.h>
-
+
#include "QtLyXView.h"
#include <algorithm>
using std::find;
using std::max;
-QCitationDialog::QCitationDialog(QCitation * form, QWidget * parent, const char * name, bool modal, WFlags fl)
- : QCitationDialogBase(parent, name, modal, fl),
+QCitationDialog::QCitationDialog(QCitation * form)
+ : QCitationDialogBase(0, 0, false, 0),
form_(form)
{
- connect(okPB, SIGNAL(clicked()),
- form, SLOT(slotOK()));
- connect(cancelPB, SIGNAL(clicked()),
- form, SLOT(slotCancel()));
connect(restorePB, SIGNAL(clicked()),
form, SLOT(slotRestore()));
+ connect(okPB, SIGNAL(clicked()),
+ form, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()),
form, SLOT(slotApply()));
+ connect(closePB, SIGNAL(clicked()),
+ form, SLOT(slotClose()));
connect(searchED, SIGNAL(returnPressed()),
- form, SLOT(slotNextClicked()));
+ this, SLOT(slotNextClicked()));
+
+ textBeforeED->setText(_("Not yet supported"));
+ textBeforeED->setReadOnly(true);
+ textBeforeED->setFocusPolicy(QWidget::NoFocus);
+ citationStyleCO->setEnabled(false);
+ citationStyleCO->setFocusPolicy(QWidget::NoFocus);
}
-
+
QCitationDialog::~QCitationDialog()
{
}
-void QCitationDialog::slotBibSelected( int sel )
+void QCitationDialog::slotBibSelected(int sel)
+{
+ slotBibHighlighted(sel);
+
+ if (form_->controller().isReadonly())
+ return;
+
+ slotAddClicked();
+}
+
+
+void QCitationDialog::slotBibHighlighted(int sel)
{
biblio::InfoMap const & theMap = form_->controller().bibkeysInfo();
}
-void QCitationDialog::slotCiteSelected(int sel)
+void QCitationDialog::slotCiteHighlighted(int sel)
{
biblio::InfoMap const & theMap = form_->controller().bibkeysInfo();
// Highlight the selected browser_cite key in browser_bib
vector<string>::const_iterator cit =
- std::find(form_->bibkeys.begin(),
+ std::find(form_->bibkeys.begin(),
form_->bibkeys.end(), form_->citekeys[sel]);
if (cit != form_->bibkeys.end()) {
{
int const sel = citeLB->currentItem();
- // FIXME: why ?
+ // FIXME: why ?
if (sel < 0 || sel >= (int)form_->citekeys.size()) {
return;
}
{
int const sel = citeLB->currentItem();
- // FIXME: ?
+ // FIXME: ?
if (sel < 0 || sel >= (int)form_->citekeys.size() - 1) {
return;
}
int const top = max(found - 5, 1);
bibLB->setTopItem(top);
bibLB->setSelected(found, true);
- slotBibSelected(0);
-}
-
-
-void QCitationDialog::slotCitationStyleSelected( int )
-{
- form_->changed();
-}
-
-
-void QCitationDialog::slotTextBeforeReturn()
-{
- form_->changed();
-}
-
-
-void QCitationDialog::slotTextAfterReturn()
-{
- form_->changed();
+ slotBibHighlighted(0);
}
#ifndef QCITATIONDIALOG_H
#define QCITATIONDIALOG_H
-class QCitation;
-
#include <config.h>
#include "support/lstrings.h"
#include "ui/QCitationDialogBase.h"
+#include "QCitation.h"
#include "controllers/biblio.h"
class QCitationDialog : public QCitationDialogBase
{ Q_OBJECT
public:
- QCitationDialog(QCitation * form, QWidget * parent = 0, const char * name = 0, bool modal = FALSE, WFlags fl = 0);
+ QCitationDialog(QCitation * form);
~QCitationDialog();
protected slots:
+ virtual void slotBibHighlighted(int sel);
virtual void slotBibSelected(int sel);
- virtual void slotCiteSelected(int sel);
+ virtual void slotCiteHighlighted(int sel);
virtual void slotAddClicked();
virtual void slotDelClicked();
virtual void slotUpClicked();
virtual void slotDownClicked();
virtual void slotPreviousClicked();
virtual void slotNextClicked();
- virtual void slotCitationStyleSelected(int);
- virtual void slotTextBeforeReturn();
- virtual void slotTextAfterReturn();
+ virtual void changed_adaptor() {
+ form_->changed();
+ }
+
private:
void doFind(biblio::Direction dir);
#include <config.h>
#include "QIndexDialog.h"
+#include "ControlIndex.h"
#include "QtLyXView.h"
#include "BufferView.h"
}
-QIndex::~QIndex()
-{
-}
-
-
void QIndex::build()
{
dialog_.reset(new QIndexDialog(this));
bc().setOK(dialog_->okPB);
- bc().setCancel(dialog_->cancelPB);
+ bc().setCancel(dialog_->closePB);
bc().addReadOnly(dialog_->keywordED);
}
void QIndex::update()
{
dialog_->keywordED->setText(controller().params().getContents().c_str());
+ reset();
}
#define QINDEX_H
#include "Qt2Base.h"
-#include "ControlIndex.h"
-#include "LString.h"
-#include "boost/utility.hpp"
-class Dialogs;
-class LyXView;
+class ControlIndex;
class QIndexDialog;
class QIndex :
- public Qt2CB<ControlIndex, Qt2DB<QIndexDialog> > {
-
+ public Qt2CB<ControlIndex, Qt2DB<QIndexDialog> >
+{
friend class QIndexDialog;
public:
QIndex(ControlIndex &);
- ~QIndex();
+
private:
/// Apply changes
virtual void apply();
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);
};
#endif // QINDEX_H
#include "Dialogs.h"
#include "QIndex.h"
+#include <qwidget.h>
+#include <qpushbutton.h>
+
QIndexDialog::QIndexDialog(QIndex * form)
: QIndexDialogBase(0, 0, false, 0),
form_(form)
{
+ connect(okPB, SIGNAL(clicked()),
+ form, SLOT(slotOK()));
+ connect(closePB, SIGNAL(clicked()),
+ form, SLOT(slotClose()));
}
}
-void QIndexDialog::ok_adaptor()
-{
- form_->slotOK();
- hide();
-}
-
-
-void QIndexDialog::close_adaptor()
-{
- form_->slotCancel();
- hide();
-}
-
-
void QIndexDialog::change_adaptor()
{
form_->changed();
QIndexDialog(QIndex * form);
~QIndexDialog();
-public slots:
- virtual void ok_adaptor();
- virtual void close_adaptor();
+protected slots:
virtual void change_adaptor();
-
+
protected:
virtual void closeEvent(QCloseEvent * e);
void QRef::update()
{
+ // FIXME: needs updating
+
dialog_->referenceED->setText(params.getContents().c_str());
dialog_->nameED->setText(params.getOptions().c_str());
#endif
#include "Qt2BC.h"
+#include "debug.h"
#include <qbutton.h>
#endif
#include <qdialog.h>
+#include <qapplication.h>
+#include "debug.h"
#include "QtLyXView.h"
#include "Dialogs.h"
#include "Qt2Base.h"
#include "Qt2BC.h"
#include "support/LAssert.h"
-#include <stdio.h>
-
-
Qt2Base::Qt2Base(ControlButtons & c, QString const & t)
: ViewBC<Qt2BC>(c), title_(t)
{}
}
+void Qt2Base::reset()
+{
+ qApp->processEvents();
+}
+
+
void Qt2Base::hide()
{
if (form() && form()->isVisible())
}
-
void Qt2Base::slotApply()
{
ApplyButton();
}
-void Qt2Base::slotCancel()
+void Qt2Base::slotClose()
{
CancelButton();
}
{
RestoreButton();
}
-
-
-// PENDING(kalle) How to handle this?
-// extern "C" void C_Qt2BaseInputCB(FL_OBJECT * ob, long d)
-// {
-// GetForm(ob)->InputCB(ob, d);
-// }
/// Build the dialog
virtual void build() = 0;
/// Hide the dialog.
- void hide();
+ virtual void hide();
/// Create the dialog if necessary, update it and display it.
- void show();
+ virtual void show();
+ /// reset after an update
+ virtual void reset();
/// the dialog has changed contents
virtual void changed();
/// is the dialog currently valid ?
virtual bool isValid();
-
+
protected slots:
// dialog closed from WM
void slotWMHide();
- // Apply button clicked
- void slotApply();
-
+ // Restore button clicked
+ void slotRestore();
+
// OK button clicked
void slotOK();
- // Cancel button clicked
- void slotCancel();
+ // Apply button clicked
+ void slotApply();
- // Restore button clicked
- void slotRestore();
+ // Close button clicked
+ void slotClose();
private:
/// Pointer to the actual instantiation of xform's form
class Qt2DB: public Qt2Base
{
protected:
- ///
Qt2DB(ControlButtons &, const QString&);
+
/// Pointer to the actual instantiation of the Qt dialog
virtual QDialog* form() const;
/// Real GUI implementation.
boost::scoped_ptr<Dialog> dialog_;
+
};
This file contains some do's and dont's for the Qt2 frontend.
+General rules
+-------------
+
+Every editable field that affects the state of the dialog contents
+from LyX's point of view should connect its xxxChanged() signal to
+a the dialog's changed_adaptor() slot, which in turn should call
+form_->changed(). If you are using a more complicated thing anyway,
+then remember to call form_->changed() at the end (if it has changed !)
+
+Every non-trivial widget should have a tooltip. If you don't know
+what to write, write "FIXME", and it can fixed later.
+
+If necessary, you should override Qt2Base::isValid() for determining the validity
+of the current dialog's contents.
+
+OK/Apply/Restore/Close should be connected in the derived class's constructor
+to call form_->slotOK() etc. Refer to close/cancel as close in the source.
+
+Every overridden update() must call reset() to ensure the beginning state of the dialog
+is correct !
+
Don't #undef emit - #include "QtLyXView.h" instead
Naming conventions
widget types :
CB - check box
-CO -
+CO - combo box
ED - line edit
LA - label
ML -
Dialog Maintainer MVC conversion
----------------------------------------------
Character Edwin
-Citation Kalle Done ?
-Document Kalle In progress (Not yet prepared)
+Citation Kalle Done
+Document Kalle Waiting for MVC
Index Kalle Done
-Paragraph Edwin Not yet prepared
+Paragraph Edwin Waiting for MVC
Print Edwin
Ref Kalle
Search Edwin
Splash Edwin
-Tabular Not yet prepared
+Tabular Waiting for MVC
TabularCreate Edwin
Toc Kalle
Url Kalle
--- /dev/null
+/**
+ * \file Timeout_pimpl.C
+ * Copyright 2001 LyX Team
+ * Read COPYING
+ *
+ * \author John Levon
+ */
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+
+#include "Timeout_pimpl.h"
+#include "debug.h"
+
+using std::endl;
+
+Timeout::Pimpl::Pimpl(Timeout * owner)
+ : owner_(owner), timeout_id(-1)
+{
+}
+
+
+void Timeout::Pimpl::timerEvent(QTimerEvent *)
+{
+ owner_->emit();
+}
+
+
+void Timeout::Pimpl::reset()
+{
+ killTimers();
+ timeout_id = -1;
+}
+
+
+void Timeout::Pimpl::start()
+{
+ if (timeout_id != -1)
+ lyxerr << "Timeout::start: already running!" << endl;
+ timeout_id = startTimer(owner_->timeout_ms);
+}
+
+
+void Timeout::Pimpl::stop()
+{
+ if (timeout_id != -1)
+ reset();
+}
--- /dev/null
+/**
+ * \file Timeout_pimpl.h
+ * Copyright 2001 LyX Team
+ * Read COPYING
+ *
+ * \author John Levon
+ */
+#ifndef TIMEOUTPIMPL_H
+#define TIMEOUTPIMPL_H
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "frontends/Timeout.h"
+
+#include <sigc++/signal_system.h>
+
+#include <qobject.h>
+// stupid Qt
+#undef emit
+
+/**
+ * This class executes the callback when the timeout expires
+ * using Qt mechanisms
+ */
+struct Timeout::Pimpl : QObject {
+public:
+ ///
+ Pimpl(Timeout * owner_);
+ /// start the timer
+ void start();
+ /// stop the timer
+ void stop();
+ /// reset
+ void reset();
+
+protected:
+ /// slot
+ virtual void timerEvent(QTimerEvent *);
+private:
+ /// the owning timer
+ Timeout * owner_;
+ /// xforms id
+ int timeout_id;
+};
+
+#endif
emptytable_moc.C \
Qt2Base_moc.C \
$(MOCDIALOGS)
- #$(patsubst, %, %Dialog_moc.C, $(DIALOGS))
DISTCLEANFILES = $(libqt2moc_la_SOURCES) *.orig *.rej *~ *.bak core
%_moc.C: ../%.h
$(MOC) -o $@ $<
-
<rect>
<x>0</x>
<y>0</y>
- <width>483</width>
+ <width>439</width>
<height>585</height>
</rect>
</property>
</property>
<property stdset="1">
<name>default</name>
+ <bool>false</bool>
+ </property>
+ <property stdset="1">
+ <name>autoDefault</name>
<bool>true</bool>
</property>
</widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
- <cstring>cancelPB</cstring>
+ <cstring>closePB</cstring>
</property>
<property stdset="1">
<name>text</name>
<receiver>QCitationDialogBase</receiver>
<slot>slotDownClicked()</slot>
</connection>
- <connection>
- <sender>restorePB</sender>
- <signal>clicked()</signal>
- <receiver>QCitationDialogBase</receiver>
- <slot>slotRestoreClicked()</slot>
- </connection>
<connection>
<sender>previousPB</sender>
<signal>clicked()</signal>
<slot>slotNextClicked()</slot>
</connection>
<connection>
- <sender>citationStyleCO</sender>
- <signal>activated(int)</signal>
+ <sender>upPB</sender>
+ <signal>clicked()</signal>
<receiver>QCitationDialogBase</receiver>
- <slot>slotCitationStyleSelected(int)</slot>
+ <slot>slotUpClicked()</slot>
</connection>
<connection>
<sender>textBeforeED</sender>
- <signal>returnPressed()</signal>
+ <signal>textChanged(const QString&)</signal>
<receiver>QCitationDialogBase</receiver>
- <slot>slotTextBeforeReturn()</slot>
+ <slot>changed_adaptor()</slot>
</connection>
<connection>
<sender>textAfterED</sender>
- <signal>returnPressed()</signal>
+ <signal>textChanged(const QString&)</signal>
<receiver>QCitationDialogBase</receiver>
- <slot>slotTextAfterReturn()</slot>
+ <slot>changed_adaptor()</slot>
</connection>
<connection>
- <sender>bibLB</sender>
+ <sender>citationStyleCO</sender>
+ <signal>textChanged(const QString&)</signal>
+ <receiver>QCitationDialogBase</receiver>
+ <slot>changed_adaptor()</slot>
+ </connection>
+ <connection>
+ <sender>citeLB</sender>
<signal>highlighted(int)</signal>
<receiver>QCitationDialogBase</receiver>
- <slot>slotBibSelected(int)</slot>
+ <slot>slotCiteHighlighted(int)</slot>
</connection>
<connection>
<sender>citeLB</sender>
+ <signal>selected(int)</signal>
+ <receiver>QCitationDialogBase</receiver>
+ <slot>slotBibHighlighted(int)</slot>
+ </connection>
+ <connection>
+ <sender>bibLB</sender>
<signal>highlighted(int)</signal>
<receiver>QCitationDialogBase</receiver>
- <slot>slotCiteSelected(int)</slot>
+ <slot>slotBibHighlighted(int)</slot>
</connection>
<connection>
- <sender>upPB</sender>
- <signal>clicked()</signal>
+ <sender>bibLB</sender>
+ <signal>selected(int)</signal>
<receiver>QCitationDialogBase</receiver>
- <slot>slotUpClicked()</slot>
+ <slot>slotBibSelected(int)</slot>
</connection>
+ <slot access="public">changed_adaptor()</slot>
+ <slot access="public">slotBibSelected(int)</slot>
<slot access="protected">slotAddClicked()</slot>
- <slot access="protected">slotBibSelected(int)</slot>
- <slot access="protected">slotCitationStyleSelected(int)</slot>
- <slot access="protected">slotCiteSelected(int)</slot>
+ <slot access="public">slotBibHighlighted(int)</slot>
+ <slot access="public">slotCiteHighlighted(int)</slot>
<slot access="protected">slotDelClicked()</slot>
<slot access="protected">slotDownClicked()</slot>
- <slot access="protected">slotUpClicked()</slot>
<slot access="protected">slotNextClicked()</slot>
<slot access="protected">slotPreviousClicked()</slot>
- <slot access="protected">slotRestoreClicked()</slot>
<slot access="protected">slotSearchTypeSelected(bool)</slot>
- <slot access="protected">slotTextAfterReturn()</slot>
- <slot access="protected">slotTextBeforeReturn()</slot>
+ <slot access="protected">slotUpClicked()</slot>
</connections>
</UI>
<rect>
<x>0</x>
<y>0</y>
- <width>208</width>
+ <width>204</width>
<height>82</height>
</rect>
</property>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
- <cstring>cancelPB</cstring>
+ <cstring>closePB</cstring>
</property>
<property stdset="1">
<name>text</name>
</vbox>
</widget>
<connections>
- <connection>
- <sender>okPB</sender>
- <signal>clicked()</signal>
- <receiver>QIndexDialogBase</receiver>
- <slot>ok_adaptor()</slot>
- </connection>
- <connection>
- <sender>cancelPB</sender>
- <signal>clicked()</signal>
- <receiver>QIndexDialogBase</receiver>
- <slot>close_adaptor()</slot>
- </connection>
<connection>
<sender>keywordED</sender>
<signal>textChanged(const QString&)</signal>
<receiver>QIndexDialogBase</receiver>
<slot>change_adaptor()</slot>
</connection>
- <slot access="public">close_adaptor()</slot>
<slot access="public">change_adaptor()</slot>
- <slot access="public">ok_adaptor()</slot>
</connections>
</UI>