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>
* ui/QCharacterDialog.ui:

View File

@ -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<QInclude, Qt2BC>(*lv, *this));
add(new GUIIndex<QIndex, 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 GUIUrl<QURL, Qt2BC>(*lv, *this));

View File

@ -8,66 +8,39 @@
#include <config.h>
#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 <qspinbox.h>
#include <qpushbutton.h>
QTabularCreate::QTabularCreate(LyXView *v, Dialogs *d)
: dialog_(0), lv_(v), d_(d), h_(0)
typedef Qt2CB<ControlTabularCreate, Qt2DB<QTabularCreateDialog> > 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();
}

View File

@ -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 {
///
class QTabularCreate
: public Qt2CB<ControlTabularCreate, Qt2DB<QTabularCreateDialog> >
{
public:
QTabularCreate(LyXView *, Dialogs *);
~QTabularCreate();
/// create the table
void apply(int rows, int cols);
/// close the connections
void close();
///
friend class QTabularCreateDialog;
///
QTabularCreate(ControlTabularCreate &);
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

View File

@ -18,52 +18,29 @@
#include <qpushbutton.h>
#include <qspinbox.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)
: 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();
}

View File

@ -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:

View File

@ -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

View File

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