John, please have a look at this.
It stores and invokes the QMathMatrix dialog as if it were any other,
cleaning up the existing memory leak.
I quite like the fact that QMath and QMathMatrix both derive from
ControlMath2. It suggests that the GUI-implementation of the math panel
really is independent of the controller.
Would you like me to create new files QMathMatrix.[Ch] rather than store two
classes, QMath and QMathMatrix, in QMath.[Ch]?
Clearly, it is trivial to extend this to QDelimiterDialog also.
Defining LFUN_DIALOG_SHOW opens up the possibility of getting rid of a
multitude of other LFUNs. These ones at least:
LFUN_DIALOG_PREFERENCES
LFUN_FORKS_SHOW
LFUN_HELP_ABOUTLYX
LFUN_HELP_TEXINFO
LFUN_LATEX_LOG
LFUN_LAYOUT_CHARACTER
LFUN_LAYOUT_DOCUMENT
LFUN_LAYOUT_PREAMBLE
LFUN_MATH_PANEL
LFUN_MENUPRINT
LFUN_MENUSEARCH
LFUN_SPELLCHECK
LFUN_VC_HISTORY
--
Angus
Index: src/LyXAction.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.C,v
retrieving revision 1.171
diff -u -p -r1.171 LyXAction.C
--- src/LyXAction.C 11 Jun 2003 11:01:32 -0000 1.171
+++ src/LyXAction.C 12 Jun 2003 22:55:09 -0000
@@ -313,6 +313,7 @@ void LyXAction::init()
{ LFUN_REJECT_CHANGE, "reject-change", Noop },
{ LFUN_ACCEPT_ALL_CHANGES, "accept-all-changes", Noop },
{ LFUN_REJECT_ALL_CHANGES, "reject-all-changes", Noop },
+ { LFUN_DIALOG_SHOW, "dialog-show", Noop },
{ LFUN_DIALOG_SHOW_NEW_INSET, "dialog-show-new-inset", Noop },
{ LFUN_DIALOG_SHOW_NEXT_INSET, "dialog-show-next-inset", Noop },
{ LFUN_DIALOG_UPDATE, "dialog-update", Noop },
Index: src/lfuns.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lfuns.h,v
retrieving revision 1.13
diff -u -p -r1.13 lfuns.h
--- src/lfuns.h 11 Jun 2003 11:01:33 -0000 1.13
+++ src/lfuns.h 12 Jun 2003 22:55:10 -0000
@@ -321,18 +321,19 @@ enum kb_action {
LFUN_REJECT_ALL_CHANGES, // Levon 20021016
LFUN_INSERT_BIBITEM, // André 14 Feb 2003
// 245
+ LFUN_DIALOG_SHOW,
LFUN_DIALOG_SHOW_NEW_INSET,
LFUN_DIALOG_SHOW_NEXT_INSET,
LFUN_DIALOG_UPDATE,
LFUN_DIALOG_HIDE,
- LFUN_DIALOG_DISCONNECT_INSET,
// 250
+ LFUN_DIALOG_DISCONNECT_INSET,
LFUN_INSET_APPLY,
LFUN_INSET_INSERT,
LFUN_INSET_MODIFY,
LFUN_INSET_DIALOG_UPDATE,
- LFUN_INSET_SETTINGS,
// 255
+ LFUN_INSET_SETTINGS,
LFUN_PARAGRAPH_APPLY,
LFUN_PARAGRAPH_UPDATE,
LFUN_EXTERNAL_EDIT,
Index: src/lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.452
diff -u -p -r1.452 lyxfunc.C
--- src/lyxfunc.C 12 Jun 2003 11:09:52 -0000 1.452
+++ src/lyxfunc.C 12 Jun 2003 22:55:11 -0000
@@ -1408,6 +1408,10 @@ void LyXFunc::dispatch(FuncRequest const
owner->getDialogs().showMathPanel();
break;
+ case LFUN_DIALOG_SHOW:
+ owner->getDialogs().show(argument);
+ break;
+
case LFUN_DIALOG_SHOW_NEW_INSET: {
string const & name = argument;
string data;
Index: src/frontends/Dialogs.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/Dialogs.C,v
retrieving revision 1.24
diff -u -p -r1.24 Dialogs.C
--- src/frontends/Dialogs.C 6 Jun 2003 08:06:23 -0000 1.24
+++ src/frontends/Dialogs.C 12 Jun 2003 22:55:11 -0000
@@ -95,6 +95,7 @@ void Dialogs::show(string const & name,
if (!dialog)
return;
+ // FIXME! Should check that the dialog is NOT an inset dialog.
dialog->show(data);
}
@@ -105,6 +106,7 @@ void Dialogs::show(string const & name,
if (!dialog)
return;
+ // FIXME! Should check that the dialog IS an inset dialog.
dialog->show(data);
open_insets_[name] = inset;
}
Index: src/frontends/controllers/ControlMath2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlMath2.C,v
retrieving revision 1.1
diff -u -p -r1.1 ControlMath2.C
--- src/frontends/controllers/ControlMath2.C 12 Jun 2003 14:21:03 -0000 1.1
+++ src/frontends/controllers/ControlMath2.C 12 Jun 2003 22:55:11 -0000
@@ -63,3 +63,9 @@ void ControlMath2::dispatchToggleDisplay
kernel().dispatch(FuncRequest(LFUN_MATH_DISPLAY));
}
+
+void ControlMath2::showDialog(string const & name) const
+{
+ kernel().dispatch(FuncRequest(LFUN_DIALOG_SHOW, name));
+}
+
Index: src/frontends/controllers/ControlMath2.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlMath2.h,v
retrieving revision 1.1
diff -u -p -r1.1 ControlMath2.h
--- src/frontends/controllers/ControlMath2.h 12 Jun 2003 14:21:03 -0000 1.1
+++ src/frontends/controllers/ControlMath2.h 12 Jun 2003 22:55:11 -0000
@@ -41,6 +41,8 @@ public:
void dispatchDelim(string const & str) const;
/// switch between display and inline
void dispatchToggleDisplay() const;
+ /// a request to launch dialog \param name.
+ void showDialog(string const & name) const;
};
Index: src/frontends/qt2/Dialogs.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/Dialogs.C,v
retrieving revision 1.86
diff -u -p -r1.86 Dialogs.C
--- src/frontends/qt2/Dialogs.C 12 Jun 2003 14:21:04 -0000 1.86
+++ src/frontends/qt2/Dialogs.C 12 Jun 2003 22:55:12 -0000
@@ -82,8 +82,8 @@ namespace {
char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes",
"character", "citation", "error", "errorlist", "ert", "external", "file",
-"float", "graphics", "include", "index", "label", "log", "math", "minipage",
-"paragraph", "ref", "tabular", "tabularcreate",
+"float", "graphics", "include", "index", "label", "log", "math", "mathmatrix",
+"minipage", "paragraph", "ref", "tabular", "tabularcreate",
#ifdef HAVE_LIBAIKSAURUS
"thesaurus",
@@ -197,6 +197,10 @@ Dialog * Dialogs::build(string const & n
} else if (name == "math") {
dialog->setController(new ControlMath2(*dialog));
dialog->setView(new QMath(*dialog));
+ dialog->bc().bp(new IgnorantPolicy);
+ } else if (name == "mathmatrix") {
+ dialog->setController(new ControlMath2(*dialog));
+ dialog->setView(new QMathMatrix(*dialog));
dialog->bc().bp(new IgnorantPolicy);
} else if (name == "minipage") {
dialog->setController(new ControlMinipage(*dialog));
Index: src/frontends/qt2/QMath.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QMath.C,v
retrieving revision 1.12
diff -u -p -r1.12 QMath.C
--- src/frontends/qt2/QMath.C 12 Jun 2003 14:21:04 -0000 1.12
+++ src/frontends/qt2/QMath.C 12 Jun 2003 22:55:12 -0000
@@ -14,18 +14,33 @@
#include "gettext.h"
#include "ControlMath2.h"
#include "QMathDialog.h"
+#include "QMathMatrixDialog.h"
#include "QMath.h"
-typedef QController<ControlMath2, QView<QMathDialog> > base_class;
+typedef QController<ControlMath2, QView<QMathDialog> > math_base;
QMath::QMath(Dialog & parent)
- : base_class(parent, _("LyX: Math Panel"))
+ : math_base(parent, _("LyX: Math Panel"))
{}
void QMath::build_dialog()
{
dialog_.reset(new QMathDialog(this));
+}
+
+
+typedef QController<ControlMath2, QView<QMathMatrixDialog> > matrix_base;
+
+
+QMathMatrix::QMathMatrix(Dialog & parent)
+ : matrix_base(parent, _("LyX: Insert Matrix"))
+{}
+
+
+void QMathMatrix::build_dialog()
+{
+ dialog_.reset(new QMathMatrixDialog(this));
}
Index: src/frontends/qt2/QMath.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QMath.h,v
retrieving revision 1.11
diff -u -p -r1.11 QMath.h
--- src/frontends/qt2/QMath.h 12 Jun 2003 14:21:04 -0000 1.11
+++ src/frontends/qt2/QMath.h 12 Jun 2003 22:55:12 -0000
@@ -17,12 +17,26 @@
class ControlMath2;
class QMathDialog;
+class QMathMatrixDialog;
class QMath : public QController<ControlMath2, QView<QMathDialog> > {
public:
friend class QMathDialog;
QMath(Dialog &);
+
+private:
+ virtual void apply() {}
+ virtual void update_contents() {}
+ /// Build the dialog.
+ virtual void build_dialog();
+};
+
+class QMathMatrix : public QController<ControlMath2, QView<QMathMatrixDialog> > {
+public:
+ friend class QMathMatrixDialog;
+
+ QMathMatrix(Dialog &);
private:
virtual void apply() {}
Index: src/frontends/qt2/QMathDialog.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QMathDialog.C,v
retrieving revision 1.27
diff -u -p -r1.27 QMathDialog.C
--- src/frontends/qt2/QMathDialog.C 12 Jun 2003 14:21:04 -0000 1.27
+++ src/frontends/qt2/QMathDialog.C 12 Jun 2003 22:55:13 -0000
@@ -235,9 +235,7 @@ void QMathDialog::functionSelected(const
void QMathDialog::matrixClicked()
{
- // FIXME: leak?
- QMathMatrixDialog * d = new QMathMatrixDialog(form_);
- d->show();
+ form_->controller().showDialog("mathmatrix");
}
Index: src/frontends/qt2/QMathMatrixDialog.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QMathMatrixDialog.C,v
retrieving revision 1.8
diff -u -p -r1.8 QMathMatrixDialog.C
--- src/frontends/qt2/QMathMatrixDialog.C 12 Jun 2003 14:21:04 -0000 1.8
+++ src/frontends/qt2/QMathMatrixDialog.C 12 Jun 2003 22:55:13 -0000
@@ -31,7 +31,7 @@ static char h_align_str[80] = "c";
static char v_align_c[] = "tcb";
-QMathMatrixDialog::QMathMatrixDialog(QMath * form)
+QMathMatrixDialog::QMathMatrixDialog(QMathMatrix * form)
: QMathMatrixDialogBase(0, 0, false, 0),
form_(form)
{
Index: src/frontends/qt2/QMathMatrixDialog.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QMathMatrixDialog.h,v
retrieving revision 1.2
diff -u -p -r1.2 QMathMatrixDialog.h
--- src/frontends/qt2/QMathMatrixDialog.h 13 Feb 2003 16:52:53 -0000 1.2
+++ src/frontends/qt2/QMathMatrixDialog.h 12 Jun 2003 22:55:13 -0000
@@ -17,12 +17,12 @@
#include "ui/QMathMatrixDialogBase.h"
-class QMath;
+class QMathMatrix;
class QMathMatrixDialog : public QMathMatrixDialogBase {
Q_OBJECT
public:
- QMathMatrixDialog(QMath * form);
+ QMathMatrixDialog(QMathMatrix * form);
public slots:
void slotOK();
void slotClose();
@@ -31,7 +31,7 @@ protected slots:
virtual void rowsChanged(int);
virtual void change_adaptor();
private:
- QMath * form_;
+ QMathMatrix * form_;
};
#endif // QMATHMATRIXDIALOG_H