re-add tab create dialog

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2603 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2001-08-28 04:17:49 +00:00
parent db7cd3524d
commit 150430ecb9
8 changed files with 133 additions and 147 deletions

View File

@ -1,3 +1,14 @@
2001-08-28 John Levon <moz@compsoc.man.ac.uk>
* Dialogs.C:
* QTabularCreate.[Ch]:
* QTabularCreate.h:
* QTabularCreateDialog.C:
* QTabularCreateDialog.h:
* ui/Makefile.am:
* ui/QTabularCreateDialog.ui: bring back
tabcreate
2001-08-28 John Levon <moz@compsoc.man.ac.uk> 2001-08-28 John Levon <moz@compsoc.man.ac.uk>
* ui/QCharacterDialog.ui: * ui/QCharacterDialog.ui:

View File

@ -24,6 +24,7 @@
#include "QIncludeDialog.h" #include "QIncludeDialog.h"
#include "QIndexDialog.h" #include "QIndexDialog.h"
#include "QRefDialog.h" #include "QRefDialog.h"
#include "QTabularCreateDialog.h"
#include "QThesaurusDialog.h" #include "QThesaurusDialog.h"
#include "QURLDialog.h" #include "QURLDialog.h"
@ -67,6 +68,7 @@
#include "controllers/ControlIndex.h" #include "controllers/ControlIndex.h"
#include "controllers/ControlRef.h" #include "controllers/ControlRef.h"
#include "controllers/ControlSplash.h" #include "controllers/ControlSplash.h"
#include "controllers/ControlTabularCreate.h"
#include "controllers/ControlThesaurus.h" #include "controllers/ControlThesaurus.h"
#include "controllers/ControlUrl.h" #include "controllers/ControlUrl.h"
#if 0 #if 0
@ -81,7 +83,6 @@
#include "controllers/ControlRef.h" #include "controllers/ControlRef.h"
#include "controllers/ControlSearch.h" #include "controllers/ControlSearch.h"
#include "controllers/ControlSpellchecker.h" #include "controllers/ControlSpellchecker.h"
#include "controllers/ControlTabularCreate.h"
#include "controllers/ControlToc.h" #include "controllers/ControlToc.h"
#include "controllers/ControlVCLog.h" #include "controllers/ControlVCLog.h"
#endif #endif
@ -109,6 +110,7 @@ Dialogs::Dialogs(LyXView * lv)
add(new GUIInclude<QInclude, Qt2BC>(*lv, *this)); add(new GUIInclude<QInclude, Qt2BC>(*lv, *this));
add(new GUIIndex<QIndex, Qt2BC>(*lv, *this)); add(new GUIIndex<QIndex, Qt2BC>(*lv, *this));
add(new GUIRef<QRef, Qt2BC>(*lv, *this)); add(new GUIRef<QRef, Qt2BC>(*lv, *this));
add(new GUITabularCreate<QTabularCreate, Qt2BC>(*lv, *this));
add(new GUIThesaurus<QThesaurus, Qt2BC>(*lv, *this)); add(new GUIThesaurus<QThesaurus, Qt2BC>(*lv, *this));
add(new GUIUrl<QURL, Qt2BC>(*lv, *this)); add(new GUIUrl<QURL, Qt2BC>(*lv, *this));

View File

@ -8,66 +8,39 @@
#include <config.h> #include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "ControlTabularCreate.h"
#include "QTabularCreateDialog.h" #include "QTabularCreateDialog.h"
#include "Dialogs.h"
#include "QTabularCreate.h" #include "QTabularCreate.h"
#include "Qt2BC.h"
#include "gettext.h" #include "gettext.h"
#include "QtLyXView.h" #include "debug.h"
#include "lyxfunc.h"
#include "BufferView.h"
#include "insets/insettabular.h"
#include "support/lstrings.h"
using SigC::slot; #include <qspinbox.h>
#include <qpushbutton.h>
QTabularCreate::QTabularCreate(LyXView *v, Dialogs *d) typedef Qt2CB<ControlTabularCreate, Qt2DB<QTabularCreateDialog> > base_class;
: dialog_(0), lv_(v), d_(d), h_(0)
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()) controller().params().first = dialog_->rowsSB->value();
return; controller().params().second = dialog_->columnsSB->value();
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();
} }

View File

@ -10,43 +10,32 @@
#ifndef QTABULARCREATE_H #ifndef QTABULARCREATE_H
#define QTABULARCREATE_H #define QTABULARCREATE_H
#include "DialogBase.h" #ifdef __GNUG__
#include "LString.h" #pragma interface
#include "boost/utility.hpp" #endif
class Dialogs; #include "Qt2Base.h"
class LyXView;
class ControlTabularCreate;
class QTabularCreateDialog; class QTabularCreateDialog;
class QTabularCreate : public DialogBase { ///
class QTabularCreate
: public Qt2CB<ControlTabularCreate, Qt2DB<QTabularCreateDialog> >
{
public: public:
QTabularCreate(LyXView *, Dialogs *); ///
~QTabularCreate(); friend class QTabularCreateDialog;
///
/// create the table QTabularCreate(ControlTabularCreate &);
void apply(int rows, int cols);
/// close the connections
void close();
private: private:
/// Create the dialog if necessary, update it and display it. /// Apply changes
void show(); virtual void apply();
/// Hide the dialog. /// update
void hide(); virtual void update_contents() {};
/// build the dialog
/// Real GUI implementation. virtual void build_dialog();
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_;
}; };
#endif // QTABULARCREATE_H #endif // QTABULARCREATE_H

View File

@ -18,52 +18,29 @@
#include <qpushbutton.h> #include <qpushbutton.h>
#include <qspinbox.h> #include <qspinbox.h>
#include "emptytable.h" #include "emptytable.h"
#include <qpainter.h>
#include <qtableview.h>
#include <qtooltip.h>
QTabularCreateDialog::QTabularCreateDialog(QTabularCreate * form, QWidget * parent, const char * name, bool modal, WFlags fl) QTabularCreateDialog::QTabularCreateDialog(QTabularCreate * form)
: QTabularCreateDialogBase(parent, name, modal, fl), : QTabularCreateDialogBase(0, 0, false, 0),
form_(form) form_(form)
{ {
setCaption(name);
table->setMinimumSize(100,100); table->setMinimumSize(100,100);
rows->setValue(5); rowsSB->setValue(5);
columns->setValue(5); columnsSB->setValue(5);
QToolTip::add(table, _("Drag with left mouse button to resize"));
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 form_->changed();
}
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);
} }
void QTabularCreateDialog::rowsChanged(int nr_rows) void QTabularCreateDialog::rowsChanged(int nr_rows)
{ {
if (nr_rows != (rows->text()).toInt()) form_->changed();
rows->setValue(nr_rows);
} }

View File

@ -9,6 +9,7 @@
#ifndef QTABULARCREATEDIALOG_H #ifndef QTABULARCREATEDIALOG_H
#define QTABULARCREATEDIALOG_H #define QTABULARCREATEDIALOG_H
#include "ui/QTabularCreateDialogBase.h" #include "ui/QTabularCreateDialogBase.h"
class QTabularCreate; class QTabularCreate;
@ -17,13 +18,10 @@ class QTabularCreateDialog : public QTabularCreateDialogBase
{ Q_OBJECT { Q_OBJECT
public: public:
QTabularCreateDialog(QTabularCreate * form, QWidget * parent = 0, const char * name = 0, bool modal = FALSE, WFlags fl = 0); QTabularCreateDialog(QTabularCreate * form);
~QTabularCreateDialog();
protected slots: protected slots:
void insert_tabular(); virtual void columnsChanged(int);
void cancel_adaptor();
virtual void colsChanged(int);
virtual void rowsChanged(int); virtual void rowsChanged(int);
private: private:

View File

@ -3,7 +3,7 @@ DISTCLEANFILES= *.orig *.rej *~ *.bak core
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
noinst_LTLIBRARIES = libqt2ui.la noinst_LTLIBRARIES = libqt2ui.la
BOOST_INCLUDES = -I$(top_srcdir)/boost 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) \ ${SIGC_CFLAGS} ${FRONTEND_INCLUDES} $(BOOST_INCLUDES) \
-I$(top_srcdir)/src/frontends/controllers -I$(top_srcdir)/src/frontends/controllers
DEFINES += -DQT_CLEAN_NAMESPACE DEFINES += -DQT_CLEAN_NAMESPACE

View File

@ -13,8 +13,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>245</width> <width>281</width>
<height>235</height> <height>311</height>
</rect> </rect>
</property> </property>
<property stdset="1"> <property stdset="1">
@ -23,7 +23,7 @@
</property> </property>
<property stdset="1"> <property stdset="1">
<name>caption</name> <name>caption</name>
<string>Form1</string> <string>Insert table</string>
</property> </property>
<vbox> <vbox>
<property stdset="1"> <property stdset="1">
@ -57,14 +57,22 @@
</property> </property>
<property stdset="1"> <property stdset="1">
<name>text</name> <name>text</name>
<string>Rows:</string> <string>&amp;Rows:</string>
</property>
<property>
<name>buddy</name>
<cstring>rowsSB</cstring>
</property>
<property>
<name>toolTip</name>
<string>Number of rows</string>
</property> </property>
</widget> </widget>
<widget> <widget>
<class>QSpinBox</class> <class>QSpinBox</class>
<property stdset="1"> <property stdset="1">
<name>name</name> <name>name</name>
<cstring>rows</cstring> <cstring>rowsSB</cstring>
</property> </property>
<property stdset="1"> <property stdset="1">
<name>minValue</name> <name>minValue</name>
@ -74,6 +82,14 @@
<name>maxValue</name> <name>maxValue</name>
<number>511</number> <number>511</number>
</property> </property>
<property stdset="1">
<name>buttonSymbols</name>
<enum>PlusMinus</enum>
</property>
<property>
<name>toolTip</name>
<string>Number of rows</string>
</property>
</widget> </widget>
<widget> <widget>
<class>QLabel</class> <class>QLabel</class>
@ -83,14 +99,22 @@
</property> </property>
<property stdset="1"> <property stdset="1">
<name>text</name> <name>text</name>
<string>Columns:</string> <string>&amp;Columns:</string>
</property>
<property>
<name>buddy</name>
<cstring>columnsSB</cstring>
</property>
<property>
<name>toolTip</name>
<string>Number of columns</string>
</property> </property>
</widget> </widget>
<widget> <widget>
<class>QSpinBox</class> <class>QSpinBox</class>
<property stdset="1"> <property stdset="1">
<name>name</name> <name>name</name>
<cstring>columns</cstring> <cstring>columnsSB</cstring>
</property> </property>
<property stdset="1"> <property stdset="1">
<name>minValue</name> <name>minValue</name>
@ -100,6 +124,14 @@
<name>maxValue</name> <name>maxValue</name>
<number>511</number> <number>511</number>
</property> </property>
<property stdset="1">
<name>buttonSymbols</name>
<enum>PlusMinus</enum>
</property>
<property>
<name>toolTip</name>
<string>Number of columns</string>
</property>
</widget> </widget>
<spacer> <spacer>
<property> <property>
@ -130,6 +162,10 @@
<name>name</name> <name>name</name>
<cstring>table</cstring> <cstring>table</cstring>
</property> </property>
<property>
<name>toolTip</name>
<string>Resize this to the correct table dimensions</string>
</property>
</widget> </widget>
<widget> <widget>
<class>QLayoutWidget</class> <class>QLayoutWidget</class>
@ -171,22 +207,22 @@
<class>QPushButton</class> <class>QPushButton</class>
<property stdset="1"> <property stdset="1">
<name>name</name> <name>name</name>
<cstring>insertPB</cstring> <cstring>okPB</cstring>
</property> </property>
<property stdset="1"> <property stdset="1">
<name>text</name> <name>text</name>
<string>&amp;Insert</string> <string>&amp;OK</string>
</property> </property>
</widget> </widget>
<widget> <widget>
<class>QPushButton</class> <class>QPushButton</class>
<property stdset="1"> <property stdset="1">
<name>name</name> <name>name</name>
<cstring>cancelPB</cstring> <cstring>closePB</cstring>
</property> </property>
<property stdset="1"> <property stdset="1">
<name>text</name> <name>text</name>
<string>&amp;Cancel</string> <string>Close</string>
</property> </property>
</widget> </widget>
</hbox> </hbox>
@ -196,7 +232,7 @@
<customwidgets> <customwidgets>
<customwidget> <customwidget>
<class>EmptyTable</class> <class>EmptyTable</class>
<header location="local">../emptytable.h</header> <header location="local">emptytable.h</header>
<sizehint> <sizehint>
<width>-1</width> <width>-1</width>
<height>-1</height> <height>-1</height>
@ -223,40 +259,40 @@
<connection> <connection>
<sender>table</sender> <sender>table</sender>
<signal>rowsChanged(int)</signal> <signal>rowsChanged(int)</signal>
<receiver>rows</receiver> <receiver>rowsSB</receiver>
<slot>setValue(int)</slot> <slot>setValue(int)</slot>
</connection> </connection>
<connection> <connection>
<sender>table</sender> <sender>table</sender>
<signal>colsChanged(int)</signal> <signal>colsChanged(int)</signal>
<receiver>columns</receiver> <receiver>columnsSB</receiver>
<slot>setValue(int)</slot> <slot>setValue(int)</slot>
</connection> </connection>
<connection> <connection>
<sender>rows</sender> <sender>rowsSB</sender>
<signal>valueChanged(int)</signal> <signal>valueChanged(int)</signal>
<receiver>table</receiver> <receiver>table</receiver>
<slot>setNumberRows(int)</slot> <slot>setNumberRows(int)</slot>
</connection> </connection>
<connection> <connection>
<sender>columns</sender> <sender>columnsSB</sender>
<signal>valueChanged(int)</signal> <signal>valueChanged(int)</signal>
<receiver>table</receiver> <receiver>table</receiver>
<slot>setNumberColumns(int)</slot> <slot>setNumberColumns(int)</slot>
</connection> </connection>
<connection> <connection>
<sender>insertPB</sender> <sender>rowsSB</sender>
<signal>clicked()</signal> <signal>valueChanged(int)</signal>
<receiver>QTabularCreateDialogBase</receiver> <receiver>QTabularCreateDialogBase</receiver>
<slot>insert_tabular()</slot> <slot>rowsChanged(int)</slot>
</connection> </connection>
<connection> <connection>
<sender>cancelPB</sender> <sender>columnsSB</sender>
<signal>clicked()</signal> <signal>valueChanged(int)</signal>
<receiver>QTabularCreateDialogBase</receiver> <receiver>QTabularCreateDialogBase</receiver>
<slot>cancel_adaptor()</slot> <slot>columnsChanged(int)</slot>
</connection> </connection>
<slot access="protected">insert_tabular()</slot> <slot access="public">columnsChanged(int)</slot>
<slot access="protected">cancel_adaptor()</slot> <slot access="public">rowsChanged(int)</slot>
</connections> </connections>
</UI> </UI>