add external material dialog to Qt2

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2594 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2001-08-27 01:19:32 +00:00
parent f1dac2b3ea
commit 58dcb8523c
12 changed files with 903 additions and 8 deletions

View File

@ -1,3 +1,12 @@
2001-08-27 John Levon <moz@compsoc.man.ac.uk>
* Dialogs.C:
* Makefile.am:
* Makefile.dialogs:
* QExternal.[Ch]:
* QExternalDialog.[Ch]:
* ui/QExternalDialog.ui: add external dialog
2001-08-26 John Levon <moz@compsoc.man.ac.uk>
* Dialogs.C:

View File

@ -19,6 +19,7 @@
#include "QCitationDialog.h"
#include "QErrorDialog.h"
#include "QERTDialog.h"
#include "QExternalDialog.h"
#include "QIndexDialog.h"
#include "QRefDialog.h"
#include "QURLDialog.h"
@ -30,6 +31,7 @@
#include "QCitation.h"
#include "QError.h"
#include "QERT.h"
#include "QExternal.h"
#include "QIndex.h"
#include "QParagraph.h"
#include "QPrint.h"
@ -53,6 +55,7 @@
#include "controllers/ControlCitation.h"
#include "controllers/ControlError.h"
#include "controllers/ControlERT.h"
#include "controllers/ControlExternal.h"
#include "controllers/ControlIndex.h"
#include "controllers/ControlRef.h"
#include "controllers/ControlSplash.h"
@ -60,7 +63,6 @@
#if 0
#include "controllers/ControlButtons.h"
#include "controllers/ControlCitation.h"
#include "controllers/ControlExternal.h"
#include "controllers/ControlFloat.h"
#include "controllers/ControlGraphics.h"
#include "controllers/ControlInclude.h"
@ -96,6 +98,7 @@ Dialogs::Dialogs(LyXView * lv)
add(new GUICharacter<QCharacter, Qt2BC>(*lv, *this));
add(new GUIError<QError, Qt2BC>(*lv, *this));
add(new GUIERT<QERT, Qt2BC>(*lv, *this));
add(new GUIExternal<QExternal, Qt2BC>(*lv, *this));
add(new GUIIndex<QIndex, Qt2BC>(*lv, *this));
add(new GUIRef<QRef, Qt2BC>(*lv, *this));
add(new GUIUrl<QURL, Qt2BC>(*lv, *this));

View File

@ -58,7 +58,6 @@ int GUIRunTime::initApplication(int argc, char * argv[])
// I belive this is done in the wrong place, imo this should
// be done in lyx_gui.C similar to how/where xforms does it (Lgb)
static QApplication a(argc, argv);
return 0;
}

View File

@ -26,7 +26,6 @@ libqt2_la_OBJADD = \
../xforms/FormBaseDeprecated.lo \
../xforms/FormBrowser.lo \
../xforms/FormDocument.lo \
../xforms/FormExternal.lo \
../xforms/FormGraphics.lo \
../xforms/FormInclude.lo \
../xforms/FormIndex.lo \

View File

@ -9,6 +9,7 @@ DIALOGS = \
QDocument \
QError \
QERT \
QExternal \
QIndex \
QParagraph \
QPrint \
@ -36,6 +37,8 @@ DIALOGSOURCES = \
QError.C QErrorDialog.C \
QERT.h QERTDialog.h \
QERT.C QERTDialog.C \
QExternal.h QExternalDialog.h \
QExternal.C QExternalDialog.C \
QIndex.h QIndexDialog.h \
QIndex.C QIndexDialog.C \
QParagraph.h QParagraphDialog.h \
@ -64,6 +67,7 @@ MOCDIALOGS = \
QDocumentDialog_moc.C \
QErrorDialog_moc.C \
QERTDialog_moc.C \
QExternalDialog_moc.C \
QIndexDialog_moc.C \
QParagraphDialog_moc.C \
QPrintDialog_moc.C \
@ -91,6 +95,8 @@ UIDIALOGS = \
QErrorDialogBase.h \
QERTDialogBase.C \
QERTDialogBase.h \
QExternalDialogBase.C \
QExternalDialogBase.h \
QIndexDialogBase.h \
QIndexDialogBase.C \
QParagraphDialogBase.h \
@ -117,6 +123,7 @@ UIMOCDIALOGS = \
QDocumentDialogBase_moc.C \
QErrorDialogBase_moc.C \
QERTDialogBase_moc.C \
QExternalDialogBase_moc.C \
QIndexDialogBase_moc.C \
QParagraphDialogBase_moc.C \
QPrintDialogBase_moc.C \

View File

@ -18,6 +18,7 @@
#include "Dialogs.h"
#include "ControlBibtex.h"
#include "gettext.h"
#include "debug.h"
#include "support/filetools.h"
@ -40,10 +41,12 @@ void QBibtexDialog::change_adaptor()
void QBibtexDialog::browsePressed()
{
string file(QFileDialog::getOpenFileName(QString::null,
_("BibTeX style files (*.bst)"), this, 0, _("Select a BibTeX style")).latin1());
if (!file.empty()) {
styleED->setText(ChangeExtension(OnlyFilename(file), "").c_str());
QString file = QFileDialog::getOpenFileName(QString::null,
_("BibTeX style files (*.bst)"), this, 0, _("Select a BibTeX style"));
lyxerr << "HELLO" << std::endl;
if (!file.isNull()) {
lyxerr << "MONKEYS" << std::endl;
styleED->setText(ChangeExtension(OnlyFilename(file.latin1()), "").c_str());
form_->changed();
}
}

View File

@ -0,0 +1,90 @@
/**
* \file QExternal.C
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#include <vector>
#include "LString.h"
#include "QExternalDialog.h"
#include "ControlExternal.h"
#include "QExternal.h"
#include "Qt2BC.h"
#include "gettext.h"
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qcombobox.h>
#include <qtextview.h>
typedef Qt2CB<ControlExternal, Qt2DB<QExternalDialog> > base_class;
QExternal::QExternal(ControlExternal & c)
: base_class(c, _("External"))
{
}
void QExternal::build_dialog()
{
dialog_.reset(new QExternalDialog(this));
bc().setOK(dialog_->okPB);
bc().setApply(dialog_->applyPB);
bc().setCancel(dialog_->closePB);
bc().addReadOnly(dialog_->externalCO);
bc().addReadOnly(dialog_->fileED);
bc().addReadOnly(dialog_->browsePB);
std::vector<string> templates(controller().getTemplates());
for (std::vector<string>::const_iterator cit = templates.begin();
cit != templates.end(); ++cit) {
dialog_->externalCO->insertItem(cit->c_str(), -1);
}
}
void QExternal::update_contents()
{
InsetExternal::Params const & params = controller().params();
dialog_->fileED->setText(params.filename.c_str());
dialog_->paramsED->setText(params.parameters.c_str());
dialog_->externalCO->setCurrentItem(controller().getTemplateNumber(params.templ.lyxName));
dialog_->externalTV->setText(controller().params().templ.helpText.c_str());
isValid();
}
string const & QExternal::helpText()
{
controller().params().templ = controller().getTemplate(dialog_->externalCO->currentItem() + 1);
return controller().params().templ.helpText;
}
void QExternal::apply()
{
controller().params().filename =
string(dialog_->fileED->text().latin1());
controller().params().parameters =
string(dialog_->paramsED->text().latin1());
controller().params().templ = controller().getTemplate(dialog_->externalCO->currentItem() + 1);
}
bool QExternal::isValid()
{
bool const valid = !string(dialog_->fileED->text()).empty();
dialog_->viewPB->setEnabled(valid);
dialog_->editPB->setEnabled(valid);
dialog_->updatePB->setEnabled(valid);
return valid;
}

View File

@ -0,0 +1,41 @@
// -*- C++ -*-
/**
* \file QExternal.h
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#ifndef QEXTERNAL_H
#define QEXTERNAL_H
#include "Qt2Base.h"
class ControlExternal;
class QExternalDialog;
class QExternal :
public Qt2CB<ControlExternal, Qt2DB<QExternalDialog> >
{
friend class QExternalDialog;
public:
QExternal(ControlExternal &);
protected:
virtual bool isValid();
private:
/// Apply changes
virtual void apply();
/// update
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
/// get the right helptext
string const & helpText();
};
#endif // QEXTERNAL_H

View File

@ -0,0 +1,86 @@
/**
* \file QExternalDialog.C
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#include <qwidget.h>
#include <qpushbutton.h>
#include <qfiledialog.h>
#include <qcombobox.h>
#include <qtextview.h>
#include "gettext.h"
#include "QExternalDialog.h"
#include "ControlExternal.h"
#include "Dialogs.h"
#include "QExternal.h"
QExternalDialog::QExternalDialog(QExternal * form)
: QExternalDialogBase(0, 0, false, 0),
form_(form)
{
connect(okPB, SIGNAL(clicked()),
form, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()),
form, SLOT(slotClose()));
}
void QExternalDialog::change_adaptor()
{
form_->changed();
}
void QExternalDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
e->accept();
}
void QExternalDialog::editClicked()
{
form_->changed();
form_->controller().editExternal();
}
void QExternalDialog::viewClicked()
{
form_->changed();
form_->controller().viewExternal();
}
void QExternalDialog::updateClicked()
{
form_->changed();
form_->controller().updateExternal();
}
void QExternalDialog::browseClicked()
{
string file(QFileDialog::getOpenFileName(QString::null,
_("External material (*)"), this, 0, _("Select external material")).latin1());
if (!file.empty()) {
fileED->setText(file.c_str());
form_->changed();
}
}
void QExternalDialog::templateChanged()
{
externalTV->setText(form_->helpText().c_str());
updatePB->setEnabled(!form_->controller().params().templ.automaticProduction);
form_->changed();
}

View File

@ -0,0 +1,39 @@
/**
* \file QExternalDialog.h
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#ifndef QEXTERNALDIALOG_H
#define QEXTERNALDIALOG_H
#include <config.h>
#include "ui/QExternalDialogBase.h"
class QExternal;
class QExternalDialog : public QExternalDialogBase
{ Q_OBJECT
public:
QExternalDialog(QExternal * form);
protected slots:
virtual void change_adaptor();
virtual void editClicked();
virtual void viewClicked();
virtual void updateClicked();
virtual void browseClicked();
virtual void templateChanged();
protected:
virtual void closeEvent(QCloseEvent * e);
private:
QExternal * form_;
};
#endif // QEXTERNALDIALOG_H

View File

@ -11,7 +11,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>368</width>
<width>360</width>
<height>236</height>
</rect>
</property>

View File

@ -0,0 +1,619 @@
<!DOCTYPE UI><UI>
<class>QExternalDialogBase</class>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>QExternalDialogBase</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>417</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>External Material</string>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout14</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout5</cstring>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>templateLA</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Template</string>
</property>
<property>
<name>buddy</name>
<cstring>externalCO</cstring>
</property>
<property>
<name>toolTip</name>
<string>Available templates</string>
</property>
</widget>
<widget>
<class>QComboBox</class>
<property stdset="1">
<name>name</name>
<cstring>externalCO</cstring>
</property>
<property>
<name>toolTip</name>
<string>Available templates</string>
</property>
</widget>
</vbox>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer3_2</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</hbox>
</widget>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout11</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QTextView</class>
<property stdset="1">
<name>name</name>
<cstring>externalTV</cstring>
</property>
<property>
<name>toolTip</name>
<string>LaTeX error messages</string>
</property>
</widget>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout9</cstring>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>editPB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Edit file</string>
</property>
<property>
<name>toolTip</name>
<string>Edit the file externally</string>
</property>
</widget>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>viewPB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;View file</string>
</property>
<property>
<name>toolTip</name>
<string>View the file</string>
</property>
</widget>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>updatePB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Update</string>
</property>
<property>
<name>toolTip</name>
<string>Update the material</string>
</property>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer2</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</vbox>
</widget>
</hbox>
</widget>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout23</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout21</cstring>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout6</cstring>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>fileLA</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;File</string>
</property>
<property>
<name>buddy</name>
<cstring>fileED</cstring>
</property>
<property>
<name>toolTip</name>
<string>Filename</string>
</property>
</widget>
<widget>
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>fileED</cstring>
</property>
<property>
<name>toolTip</name>
<string>Filename</string>
</property>
</widget>
</vbox>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer5</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Minimum</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</vbox>
</widget>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout20</cstring>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>browsePB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Browse ...</string>
</property>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer4</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Minimum</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</vbox>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer2_2</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</hbox>
</widget>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout16</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout12</cstring>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>paramsLA</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Parameters</string>
</property>
<property>
<name>buddy</name>
<cstring>paramsED</cstring>
</property>
<property>
<name>toolTip</name>
<string>Parameters</string>
</property>
</widget>
<widget>
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>paramsED</cstring>
</property>
<property>
<name>toolTip</name>
<string>Parameters</string>
</property>
</widget>
</vbox>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer1</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</hbox>
</widget>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout2</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<spacer>
<property>
<name>name</name>
<cstring>Spacer3</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>okPB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;OK</string>
</property>
<property stdset="1">
<name>default</name>
<bool>true</bool>
</property>
</widget>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>applyPB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Apply</string>
</property>
<property stdset="1">
<name>default</name>
<bool>true</bool>
</property>
</widget>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>closePB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Close</string>
</property>
<property stdset="1">
<name>default</name>
<bool>true</bool>
</property>
</widget>
</hbox>
</widget>
</vbox>
</widget>
<connections>
<connection>
<sender>updatePB</sender>
<signal>clicked()</signal>
<receiver>QExternalDialogBase</receiver>
<slot>updateClicked()</slot>
</connection>
<connection>
<sender>viewPB</sender>
<signal>clicked()</signal>
<receiver>QExternalDialogBase</receiver>
<slot>viewClicked()</slot>
</connection>
<connection>
<sender>editPB</sender>
<signal>clicked()</signal>
<receiver>QExternalDialogBase</receiver>
<slot>editClicked()</slot>
</connection>
<connection>
<sender>externalCO</sender>
<signal>activated(const QString&amp;)</signal>
<receiver>QExternalDialogBase</receiver>
<slot>templateChanged()</slot>
</connection>
<connection>
<sender>fileED</sender>
<signal>textChanged(const QString&amp;)</signal>
<receiver>QExternalDialogBase</receiver>
<slot>change_adaptor()</slot>
</connection>
<connection>
<sender>browsePB</sender>
<signal>clicked()</signal>
<receiver>QExternalDialogBase</receiver>
<slot>browseClicked()</slot>
</connection>
<connection>
<sender>paramsED</sender>
<signal>textChanged(const QString&amp;)</signal>
<receiver>QExternalDialogBase</receiver>
<slot>change_adaptor()</slot>
</connection>
<slot access="public">browseClicked()</slot>
<slot access="public">change_adaptor()</slot>
<slot access="public">editClicked()</slot>
<slot access="public">templateChanged()</slot>
<slot access="public">updateClicked()</slot>
<slot access="public">viewClicked()</slot>
</connections>
</UI>