From 150430ecb9b3d9789e9767c9f6a12338689f766a Mon Sep 17 00:00:00 2001 From: John Levon Date: Tue, 28 Aug 2001 04:17:49 +0000 Subject: [PATCH] re-add tab create dialog git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2603 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/ChangeLog | 11 +++ src/frontends/qt2/Dialogs.C | 4 +- src/frontends/qt2/QTabularCreate.C | 71 +++++------------ src/frontends/qt2/QTabularCreate.h | 53 +++++------- src/frontends/qt2/QTabularCreateDialog.C | 47 +++-------- src/frontends/qt2/QTabularCreateDialog.h | 8 +- src/frontends/qt2/ui/Makefile.am | 2 +- src/frontends/qt2/ui/QTabularCreateDialog.ui | 84 ++++++++++++++------ 8 files changed, 133 insertions(+), 147 deletions(-) diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index ed2caa3e2c..6e5b236536 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,14 @@ +2001-08-28 John Levon + + * Dialogs.C: + * QTabularCreate.[Ch]: + * QTabularCreate.h: + * QTabularCreateDialog.C: + * QTabularCreateDialog.h: + * ui/Makefile.am: + * ui/QTabularCreateDialog.ui: bring back + tabcreate + 2001-08-28 John Levon * ui/QCharacterDialog.ui: diff --git a/src/frontends/qt2/Dialogs.C b/src/frontends/qt2/Dialogs.C index 3c313d843d..bc43d2d9b6 100644 --- a/src/frontends/qt2/Dialogs.C +++ b/src/frontends/qt2/Dialogs.C @@ -24,6 +24,7 @@ #include "QIncludeDialog.h" #include "QIndexDialog.h" #include "QRefDialog.h" +#include "QTabularCreateDialog.h" #include "QThesaurusDialog.h" #include "QURLDialog.h" @@ -67,6 +68,7 @@ #include "controllers/ControlIndex.h" #include "controllers/ControlRef.h" #include "controllers/ControlSplash.h" +#include "controllers/ControlTabularCreate.h" #include "controllers/ControlThesaurus.h" #include "controllers/ControlUrl.h" #if 0 @@ -81,7 +83,6 @@ #include "controllers/ControlRef.h" #include "controllers/ControlSearch.h" #include "controllers/ControlSpellchecker.h" -#include "controllers/ControlTabularCreate.h" #include "controllers/ControlToc.h" #include "controllers/ControlVCLog.h" #endif @@ -109,6 +110,7 @@ Dialogs::Dialogs(LyXView * lv) add(new GUIInclude(*lv, *this)); add(new GUIIndex(*lv, *this)); add(new GUIRef(*lv, *this)); + add(new GUITabularCreate(*lv, *this)); add(new GUIThesaurus(*lv, *this)); add(new GUIUrl(*lv, *this)); diff --git a/src/frontends/qt2/QTabularCreate.C b/src/frontends/qt2/QTabularCreate.C index fe85d879c0..bb989feff6 100644 --- a/src/frontends/qt2/QTabularCreate.C +++ b/src/frontends/qt2/QTabularCreate.C @@ -8,66 +8,39 @@ #include +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "ControlTabularCreate.h" #include "QTabularCreateDialog.h" -#include "Dialogs.h" #include "QTabularCreate.h" +#include "Qt2BC.h" #include "gettext.h" -#include "QtLyXView.h" -#include "lyxfunc.h" -#include "BufferView.h" -#include "insets/insettabular.h" -#include "support/lstrings.h" +#include "debug.h" -using SigC::slot; +#include +#include -QTabularCreate::QTabularCreate(LyXView *v, Dialogs *d) - : dialog_(0), lv_(v), d_(d), h_(0) +typedef Qt2CB > base_class; + +QTabularCreate::QTabularCreate(ControlTabularCreate & c) + : base_class(c, _("Insert table")) { - d->showTabularCreate.connect(slot(this, &QTabularCreate::show)); } -QTabularCreate::~QTabularCreate() +void QTabularCreate::build_dialog() { - delete dialog_; + dialog_.reset(new QTabularCreateDialog(this)); + + bc().setOK(dialog_->okPB); + bc().setCancel(dialog_->closePB); } - -void QTabularCreate::apply(int rows, int cols) + +void QTabularCreate::apply() { - if (!lv_->view()->available()) - return; - - string tmp = tostr(rows) + " " + tostr(cols); - lv_->getLyXFunc()->dispatch(LFUN_INSET_TABULAR, tmp); -} - - -void QTabularCreate::show() -{ - if (!dialog_) - dialog_ = new QTabularCreateDialog(this, 0, _("LyX: Insert Table")); - - if (!dialog_->isVisible()) { - h_ = d_->hideBufferDependent.connect(slot(this, &QTabularCreate::hide)); - } - - dialog_->raise(); - dialog_->setActiveWindow(); - - update(); - dialog_->show(); -} - - -void QTabularCreate::close() -{ - h_.disconnect(); -} - - -void QTabularCreate::hide() -{ - dialog_->hide(); - close(); + controller().params().first = dialog_->rowsSB->value(); + controller().params().second = dialog_->columnsSB->value(); } diff --git a/src/frontends/qt2/QTabularCreate.h b/src/frontends/qt2/QTabularCreate.h index c6406ce163..b242267614 100644 --- a/src/frontends/qt2/QTabularCreate.h +++ b/src/frontends/qt2/QTabularCreate.h @@ -10,43 +10,32 @@ #ifndef QTABULARCREATE_H #define QTABULARCREATE_H -#include "DialogBase.h" -#include "LString.h" -#include "boost/utility.hpp" +#ifdef __GNUG__ +#pragma interface +#endif -class Dialogs; -class LyXView; +#include "Qt2Base.h" + +class ControlTabularCreate; class QTabularCreateDialog; -class QTabularCreate : public DialogBase { -public: - QTabularCreate(LyXView *, Dialogs *); - ~QTabularCreate(); +/// +class QTabularCreate + : public Qt2CB > +{ +public: + /// + friend class QTabularCreateDialog; + /// + QTabularCreate(ControlTabularCreate &); - /// create the table - void apply(int rows, int cols); - /// close the connections - void close(); - private: - /// Create the dialog if necessary, update it and display it. - void show(); - /// Hide the dialog. - void hide(); - - /// Real GUI implementation. - QTabularCreateDialog * 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_; - - /// Hide connection. - SigC::Connection h_; + /// Apply changes + virtual void apply(); + /// update + virtual void update_contents() {}; + /// build the dialog + virtual void build_dialog(); }; #endif // QTABULARCREATE_H diff --git a/src/frontends/qt2/QTabularCreateDialog.C b/src/frontends/qt2/QTabularCreateDialog.C index 19dc39a458..46e7b573b7 100644 --- a/src/frontends/qt2/QTabularCreateDialog.C +++ b/src/frontends/qt2/QTabularCreateDialog.C @@ -18,52 +18,29 @@ #include #include #include "emptytable.h" -#include -#include -#include -QTabularCreateDialog::QTabularCreateDialog(QTabularCreate * form, QWidget * parent, const char * name, bool modal, WFlags fl) - : QTabularCreateDialogBase(parent, name, modal, fl), +QTabularCreateDialog::QTabularCreateDialog(QTabularCreate * form) + : QTabularCreateDialogBase(0, 0, false, 0), form_(form) { - setCaption(name); table->setMinimumSize(100,100); - rows->setValue(5); - columns->setValue(5); - QToolTip::add(table, _("Drag with left mouse button to resize")); + rowsSB->setValue(5); + columnsSB->setValue(5); + + connect(okPB, SIGNAL(clicked()), + form_, SLOT(slotOK())); + connect(closePB, SIGNAL(clicked()), + form_, SLOT(slotClose())); } -QTabularCreateDialog::~QTabularCreateDialog() +void QTabularCreateDialog::columnsChanged(int nr_cols) { - // no need to delete child widgets, Qt does it all for us -} - - -void QTabularCreateDialog::insert_tabular() -{ - form_->apply((rows->text()).toInt(), (columns->text()).toInt()); - form_->close(); - hide(); -} - - -void QTabularCreateDialog::cancel_adaptor() -{ - form_->close(); - hide(); -} - - -void QTabularCreateDialog::colsChanged(int nr_cols) -{ - if (nr_cols != (columns->text()).toInt()) - columns->setValue(nr_cols); + form_->changed(); } void QTabularCreateDialog::rowsChanged(int nr_rows) { - if (nr_rows != (rows->text()).toInt()) - rows->setValue(nr_rows); + form_->changed(); } diff --git a/src/frontends/qt2/QTabularCreateDialog.h b/src/frontends/qt2/QTabularCreateDialog.h index 015b234157..43ab65138e 100644 --- a/src/frontends/qt2/QTabularCreateDialog.h +++ b/src/frontends/qt2/QTabularCreateDialog.h @@ -9,6 +9,7 @@ #ifndef QTABULARCREATEDIALOG_H #define QTABULARCREATEDIALOG_H + #include "ui/QTabularCreateDialogBase.h" class QTabularCreate; @@ -17,13 +18,10 @@ class QTabularCreateDialog : public QTabularCreateDialogBase { Q_OBJECT public: - QTabularCreateDialog(QTabularCreate * form, QWidget * parent = 0, const char * name = 0, bool modal = FALSE, WFlags fl = 0); - ~QTabularCreateDialog(); + QTabularCreateDialog(QTabularCreate * form); protected slots: - void insert_tabular(); - void cancel_adaptor(); - virtual void colsChanged(int); + virtual void columnsChanged(int); virtual void rowsChanged(int); private: diff --git a/src/frontends/qt2/ui/Makefile.am b/src/frontends/qt2/ui/Makefile.am index 3586fcef8e..69c9afaff2 100644 --- a/src/frontends/qt2/ui/Makefile.am +++ b/src/frontends/qt2/ui/Makefile.am @@ -3,7 +3,7 @@ DISTCLEANFILES= *.orig *.rej *~ *.bak core MAINTAINERCLEANFILES = $(srcdir)/Makefile.in noinst_LTLIBRARIES = libqt2ui.la BOOST_INCLUDES = -I$(top_srcdir)/boost -INCLUDES = -I${top_srcdir}/src/ -I${top_srcdir}/src/frontends/ \ +INCLUDES = -I${top_srcdir}/src/ -I${top_srcdir}/src/frontends/ -I$(top_srcdir)/src/frontends/qt2/ \ ${SIGC_CFLAGS} ${FRONTEND_INCLUDES} $(BOOST_INCLUDES) \ -I$(top_srcdir)/src/frontends/controllers DEFINES += -DQT_CLEAN_NAMESPACE diff --git a/src/frontends/qt2/ui/QTabularCreateDialog.ui b/src/frontends/qt2/ui/QTabularCreateDialog.ui index 088f8f95a0..35c850cf64 100644 --- a/src/frontends/qt2/ui/QTabularCreateDialog.ui +++ b/src/frontends/qt2/ui/QTabularCreateDialog.ui @@ -13,8 +13,8 @@ 0 0 - 245 - 235 + 281 + 311 @@ -23,7 +23,7 @@ caption - Form1 + Insert table @@ -57,14 +57,22 @@ text - Rows: + &Rows: + + + buddy + rowsSB + + + toolTip + Number of rows QSpinBox name - rows + rowsSB minValue @@ -74,6 +82,14 @@ maxValue 511 + + buttonSymbols + PlusMinus + + + toolTip + Number of rows + QLabel @@ -83,14 +99,22 @@ text - Columns: + &Columns: + + + buddy + columnsSB + + + toolTip + Number of columns QSpinBox name - columns + columnsSB minValue @@ -100,6 +124,14 @@ maxValue 511 + + buttonSymbols + PlusMinus + + + toolTip + Number of columns + @@ -130,6 +162,10 @@ name table + + toolTip + Resize this to the correct table dimensions + QLayoutWidget @@ -171,22 +207,22 @@ QPushButton name - insertPB + okPB text - &Insert + &OK QPushButton name - cancelPB + closePB text - &Cancel + Close @@ -196,7 +232,7 @@ EmptyTable -
../emptytable.h
+
emptytable.h
-1 -1 @@ -223,40 +259,40 @@ table rowsChanged(int) - rows + rowsSB setValue(int) table colsChanged(int) - columns + columnsSB setValue(int) - rows + rowsSB valueChanged(int) table setNumberRows(int) - columns + columnsSB valueChanged(int) table setNumberColumns(int) - insertPB - clicked() + rowsSB + valueChanged(int) QTabularCreateDialogBase - insert_tabular() + rowsChanged(int) - cancelPB - clicked() + columnsSB + valueChanged(int) QTabularCreateDialogBase - cancel_adaptor() + columnsChanged(int) - insert_tabular() - cancel_adaptor() + columnsChanged(int) + rowsChanged(int)