index dialog, citation fixes, finish about dialog

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2563 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2001-08-21 01:14:54 +00:00
parent 32ef0d04c4
commit b30963b60e
15 changed files with 341 additions and 266 deletions

View File

@ -1,3 +1,22 @@
2001-08-21 John Levon <moz@compsoc.man.ac.uk>
* Dialogs.C: add QIndex
* ui/Makefile.am:
* Makefile.am: fix build
* ui/QAboutDialog.ui:
* QAbout.C: finish dialog
* ui/QCitationDialog.ui:
* QCitationDialog.C: BC fixes
* ui/QIndexDialog.ui:
* QIndex.h:
* QIndex.C:
* QIndexDialog.h:
* QIndexDialog.C: got index dialog working
2001-08-19 John Levon <moz@compsoc.man.ac.uk>
* all files: enormous naming re-jig and tidy

View File

@ -19,6 +19,7 @@
#include "QAbout.h"
#include "QCharacter.h"
#include "QCitation.h"
#include "QIndex.h"
#include "QParagraph.h"
#include "QPrint.h"
#include "QSearch.h"
@ -38,8 +39,9 @@
#include "../xforms/FormTabular.h"
// the controllers
#include "controllers/ControlCitation.h"
#include "controllers/ControlAboutlyx.h"
#include "controllers/ControlCitation.h"
#include "controllers/ControlIndex.h"
#include "controllers/ControlSplash.h"
#if 0
#include "controllers/ControlCopyright.h"
@ -56,7 +58,6 @@
#include "controllers/ControlFloat.h"
#include "controllers/ControlGraphics.h"
#include "controllers/ControlInclude.h"
#include "controllers/ControlIndex.h"
#include "controllers/ControlLabel.h"
#include "controllers/ControlLog.h"
#include "controllers/ControlMinipage.h"
@ -85,6 +86,7 @@ Dialogs::Dialogs(LyXView * lv)
// dialogs that have been converted to new scheme
add(new GUICitation<QCitation, qt2BC>(*lv, *this));
add(new GUIAboutlyx<QAbout, qt2BC>(*lv, *this));
add(new GUIIndex<QIndex, qt2BC>(*lv, *this));
// reduce the number of connections needed in
// dialogs by a simple connection here.

View File

@ -13,11 +13,12 @@ DISTCLEANFILES = $(BUILTSOURCES) *.orig *.rej *~ *.bak core
include Makefile.dialogs
libqt2_la_DEPENDENCIES = ui/libqt2ui.la moc/libqt2moc.la
libqt2_la_DEPENDENCIES = ui/libqt2ui.la moc/libqt2moc.la ui/moc/libqt2uimoc.la
libqt2_la_OBJADD = \
ui/libqt2ui.la \
moc/libqt2moc.la \
ui/moc/libqt2uimoc.la \
../controllers/ButtonControllerBase.lo \
../xforms/combox.lo \
../xforms/Color.lo \

View File

@ -8,11 +8,15 @@
#include <config.h>
#include "support/lstrings.h"
#include "Lsstream.h"
#include "debug.h"
#include "gettext.h"
#include "QAboutDialog.h"
#include <qlabel.h>
#include <qpushbutton.h>
#include <qtextview.h>
#include "QtLyXView.h"
#include "ButtonControllerBase.h"
@ -37,6 +41,27 @@ void QAbout::build()
dialog_->copyrightLA->setText(controller().getCopyright().c_str());
dialog_->licenseLA->setText(controller().getLicense().c_str());
dialog_->disclaimerLA->setText(controller().getDisclaimer().c_str());
dialog_->versionLA->setText(controller().getVersion().c_str());
stringstream in;
controller().getCredits(in);
istringstream ss(in.str().c_str());
string s;
string out;
while (getline(ss, s)) {
if (prefixIs(s, "@b"))
out += "<b>" + s.substr(2) + "</b>";
else if (prefixIs(s, "@i"))
out += "<i>" + s.substr(2) + "</i>";
else
out += s;
out += "<br>";
}
dialog_->creditsTV->setText(out.c_str());
// Manage the cancel/close button
bc().setCancel(dialog_->closePB);

View File

@ -140,6 +140,7 @@ void QCitationDialog::slotAddClicked()
form_->setBibButtons(QCitation::OFF);
form_->setCiteButtons(QCitation::ON);
form_->changed();
}
@ -158,6 +159,7 @@ void QCitationDialog::slotDelClicked()
form_->setBibButtons(QCitation::ON);
form_->setCiteButtons(QCitation::OFF);
form_->changed();
}
@ -181,6 +183,7 @@ void QCitationDialog::slotUpClicked()
citeLB->setSelected(sel - 1, true);
form_->citekeys.insert(it - 1, tmp);
form_->setCiteButtons(QCitation::ON);
form_->changed();
}
@ -204,6 +207,7 @@ void QCitationDialog::slotDownClicked()
citeLB->setSelected(sel + 1, true);
form_->citekeys.insert(it + 1, tmp);
form_->setCiteButtons(QCitation::ON);
form_->changed();
}
@ -264,14 +268,17 @@ void QCitationDialog::doFind(biblio::Direction const dir)
void QCitationDialog::slotCitationStyleSelected( int )
{
form_->changed();
}
void QCitationDialog::slotTextBeforeReturn()
{
form_->changed();
}
void QCitationDialog::slotTextAfterReturn()
{
form_->changed();
}

View File

@ -13,6 +13,7 @@
#include "BufferView.h"
#include "Dialogs.h"
#include "qt2BC.h"
#include "QIndex.h"
#include "gettext.h"
#include "buffer.h"
@ -21,50 +22,32 @@
#include <qlineedit.h>
#include <qpushbutton.h>
QIndex::QIndex(LyXView *v, Dialogs *d)
: dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0)
typedef Qt2CB<ControlIndex, Qt2DB<QIndexDialog> > base_class;
QIndex::QIndex(ControlIndex & c)
: base_class(c, _("Index"))
{
d->showIndex.connect(slot(this, &QIndex::showIndex));
d->createIndex.connect(slot(this, &QIndex::createIndex));
}
QIndex::~QIndex()
{
delete dialog_;
}
void QIndex::showIndex(InsetCommand * const inset)
void QIndex::build()
{
// FIXME: when could inset be 0 here ?
if (inset==0)
return;
dialog_.reset(new QIndexDialog(this));
inset_ = inset;
readonly = lv_->buffer()->isReadonly();
//FIXME ih_ = inset_->hide.connect(slot(this,&QIndex::hide));
params = inset->params();
show();
}
void QIndex::createIndex(string const & arg)
{
// we could already be showing a URL, clear it out
if (inset_)
close();
readonly = lv_->buffer()->isReadonly();
params.setFromString(arg);
show();
bc().setOK(dialog_->okPB);
bc().setCancel(dialog_->cancelPB);
bc().addReadOnly(dialog_->keywordED);
}
void QIndex::update()
{
dialog_->keywordED->setText(params.getContents().c_str());
dialog_->keywordED->setText(controller().params().getContents().c_str());
if (readonly) {
dialog_->keywordED->setFocusPolicy(QWidget::NoFocus);
@ -84,47 +67,5 @@ void QIndex::apply()
if (readonly)
return;
params.setContents(dialog_->keywordED->text().latin1());
if (inset_ != 0) {
if (params != inset_->params()) {
inset_->setParams(params);
lv_->view()->updateInset(inset_, true);
}
} else
lv_->getLyXFunc()->dispatch(LFUN_INDEX_INSERT, params.getAsString().c_str());
}
void QIndex::show()
{
if (!dialog_)
dialog_ = new QIndexDialog(this, 0, _("LyX: Index"), false);
if (!dialog_->isVisible()) {
h_ = d_->hideBufferDependent.connect(slot(this, &QIndex::hide));
//u_ = d_->updateBufferDependent.connect(slot(this, &QIndex::update));
}
dialog_->raise();
dialog_->setActiveWindow();
update();
dialog_->show();
}
void QIndex::close()
{
h_.disconnect();
u_.disconnect();
ih_.disconnect();
inset_ = 0;
}
void QIndex::hide()
{
dialog_->hide();
close();
controller().params().setContents(dialog_->keywordED->text().latin1());
}

View File

@ -11,61 +11,38 @@
#ifndef QINDEX_H
#define QINDEX_H
#include "DialogBase.h"
#include "Qt2Base.h"
#include "ControlIndex.h"
#include "LString.h"
#include "boost/utility.hpp"
#include "insets/insetindex.h"
class Dialogs;
class LyXView;
class QIndexDialog;
class QIndex : public DialogBase {
class QIndex :
public Qt2CB<ControlIndex, Qt2DB<QIndexDialog> > {
friend class QIndexDialog;
public:
QIndex(LyXView *, Dialogs *);
QIndex(ControlIndex &);
~QIndex();
/// Apply changes
void apply();
/// close the connections
void close();
private:
/// Create the dialog if necessary, update it and display it.
void show();
/// Hide the dialog.
void hide();
/// Update the dialog.
void update();
/// Apply changes
virtual void apply();
/// update
virtual void update();
/// build the dialog
virtual void build();
/// create an Index inset
void createIndex(string const &);
/// edit an Index inset
void showIndex(InsetCommand * const);
/// Real GUI implementation.
QIndexDialog * 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_;
/// pointer to the inset if any
InsetCommand * inset_;
/// insets params
InsetCommandParams params;
/// is the inset we are reading from a readonly buffer ?
bool readonly;
/// Hide connection.
SigC::Connection h_;
/// Update connection.
SigC::Connection u_;
/// Inset hide connection.
SigC::Connection ih_;
};
#endif // QINDEX_H

View File

@ -10,8 +10,8 @@
#include "Dialogs.h"
#include "QIndex.h"
QIndexDialog::QIndexDialog(QIndex * form, QWidget * parent, const char * name, bool modal, WFlags fl)
: QIndexDialogBase(parent, name, modal, fl),
QIndexDialog::QIndexDialog(QIndex * form)
: QIndexDialogBase(0, 0, false, 0),
form_(form)
{
}
@ -22,23 +22,22 @@ QIndexDialog::~QIndexDialog()
}
void QIndexDialog::apply_adaptor()
void QIndexDialog::ok_adaptor()
{
form_->apply();
form_->close();
form_->slotOK();
hide();
}
void QIndexDialog::close_adaptor()
{
form_->close();
form_->slotCancel();
hide();
}
void QIndexDialog::closeEvent(QCloseEvent *e)
{
form_->close();
form_->slotWMHide();
e->accept();
}

View File

@ -19,11 +19,11 @@ class QIndexDialog : public QIndexDialogBase
{ Q_OBJECT
public:
QIndexDialog(QIndex * form, QWidget * parent = 0, const char * name = 0, bool modal = FALSE, WFlags fl = 0);
QIndexDialog(QIndex * form);
~QIndexDialog();
public slots:
void apply_adaptor();
void ok_adaptor();
void close_adaptor();
protected:

View File

@ -38,12 +38,14 @@ void Qt2Base::show()
build();
}
form()->setMinimumSize(form()->sizeHint());
update(); // make sure its up-to-date
if (form()->isVisible()) {
form()->raise();
} else {
form()->setCaption( title_ );
form()->setCaption(title_);
form()->show();
}
}
@ -51,25 +53,17 @@ void Qt2Base::show()
void Qt2Base::hide()
{
if (form() && form()->isVisible() )
if (form() && form()->isVisible())
form()->hide();
}
// PENDING(kalle) Handle this with QValidator?
// void Qt2Base::InputCB(FL_OBJECT * ob, long data)
// {
// bc().input(input(ob, data));
// }
ButtonPolicy::SMInput Qt2Base::input(QWidget*, long)
void Qt2Base::changed()
{
return ButtonPolicy::SMI_VALID;
bc().valid();
}
void Qt2Base::slotWMHide()
{
CancelButton();

View File

@ -21,8 +21,6 @@ class QDialog;
#include <qfont.h>
#include <qobject.h>
#include <boost/smart_ptr.hpp>
#ifdef __GNUG__
#pragma interface
#endif
@ -32,6 +30,8 @@ class QDialog;
#include "ButtonPolicies.h"
#include "ControlButtons.h"
#include <boost/smart_ptr.hpp>
class qt2BC;
/** This class is an Qt2 GUI base class.
@ -53,6 +53,9 @@ protected:
/// Create the dialog if necessary, update it and display it.
void show();
/// the dialog has changed contents
virtual void changed();
protected slots:
// dialog closed from WM
void slotWMHide();
@ -72,9 +75,6 @@ protected slots:
private:
/// Pointer to the actual instantiation of xform's form
virtual QDialog* form() const = 0;
/** Filter the inputs on callback from xforms
Return true if inputs are valid. */
virtual ButtonPolicy::SMInput input(QWidget*, long);
private:
/// dialog title, displayed by WM.

View File

@ -14,9 +14,6 @@ include ../Makefile.dialogs
DISTCLEANFILES = $(UIDIALOGS) *.orig *.rej *~ *.bak core
libqt2ui_la_DEPENDENCIES = moc/libqt2uimoc.la
libqt2ui_la_OBJADD = moc/libqt2uimoc.la
libqt2ui_la_SOURCES = $(UIDIALOGS)
%Base.h: %.ui

View File

@ -11,7 +11,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>464</width>
<width>448</width>
<height>454</height>
</rect>
</property>
@ -19,6 +19,118 @@
<name>caption</name>
<string>About LyX</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>QTabWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tab</cstring>
</property>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>versiontab</cstring>
</property>
<attribute>
<name>title</name>
<string>Version</string>
</attribute>
<vbox>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>versionLA</cstring>
</property>
<property stdset="1">
<name>frameShape</name>
<enum>Box</enum>
</property>
<property stdset="1">
<name>frameShadow</name>
<enum>Sunken</enum>
</property>
<property stdset="1">
<name>margin</name>
<number>6</number>
</property>
<property stdset="1">
<name>text</name>
<string>Version goes here</string>
</property>
<property stdset="1">
<name>alignment</name>
<set>AlignCenter</set>
</property>
<property>
<name>hAlign</name>
</property>
</widget>
</vbox>
</widget>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>creditstab</cstring>
</property>
<attribute>
<name>title</name>
<string>Credits</string>
</attribute>
<vbox>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QTextView</class>
<property stdset="1">
<name>name</name>
<cstring>creditsTV</cstring>
</property>
<property stdset="1">
<name>textFormat</name>
<enum>RichText</enum>
</property>
<property stdset="1">
<name>text</name>
<string></string>
</property>
</widget>
</vbox>
</widget>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>copyrighttab</cstring>
</property>
<attribute>
<name>title</name>
<string>Copyright</string>
</attribute>
<vbox>
<property stdset="1">
<name>margin</name>
@ -48,8 +160,7 @@
</property>
<property stdset="1">
<name>text</name>
<string>LyX is Copyright (C) 1995 by Matthias Ettrich,
1995-2001 by LyX Team</string>
<string>Copyright notice goes here</string>
</property>
<property stdset="1">
<name>alignment</name>
@ -59,46 +170,6 @@
<name>hAlign</name>
</property>
</widget>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>licenseLA</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>5</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>frameShape</name>
<enum>Box</enum>
</property>
<property stdset="1">
<name>frameShadow</name>
<enum>Sunken</enum>
</property>
<property stdset="1">
<name>margin</name>
<number>6</number>
</property>
<property stdset="1">
<name>text</name>
<string>This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</string>
</property>
<property stdset="1">
<name>alignment</name>
<set>WordBreak|AlignCenter</set>
</property>
<property>
<name>hAlign</name>
</property>
<property>
<name>wordwrap</name>
</property>
</widget>
<widget>
<class>QLabel</class>
<property stdset="1">
@ -133,16 +204,7 @@
</property>
<property stdset="1">
<name>text</name>
<string>LyX is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY,
without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU
General Public License along with this program;
if not, write to the Free Software Foundation, Inc.,
675 Mass Ave, Cambridge, MA 02139, USA.</string>
<string>Warranty goes here</string>
</property>
<property stdset="1">
<name>alignment</name>
@ -155,6 +217,49 @@ if not, write to the Free Software Foundation, Inc.,
<name>wordwrap</name>
</property>
</widget>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>licenseLA</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>5</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>frameShape</name>
<enum>Box</enum>
</property>
<property stdset="1">
<name>frameShadow</name>
<enum>Sunken</enum>
</property>
<property stdset="1">
<name>margin</name>
<number>6</number>
</property>
<property stdset="1">
<name>text</name>
<string>GPL goes here</string>
</property>
<property stdset="1">
<name>alignment</name>
<set>WordBreak|AlignCenter</set>
</property>
<property>
<name>hAlign</name>
</property>
<property>
<name>wordwrap</name>
</property>
</widget>
</vbox>
</widget>
</widget>
<widget>
<class>QPushButton</class>
<property stdset="1">

View File

@ -11,7 +11,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>487</width>
<width>483</width>
<height>585</height>
</rect>
</property>
@ -252,6 +252,14 @@
<name>wordWrap</name>
<enum>WidgetWidth</enum>
</property>
<property stdset="1">
<name>readOnly</name>
<bool>true</bool>
</property>
<property stdset="1">
<name>focusPolicy</name>
<enum>NoFocus</enum>
</property>
<property>
<name>toolTip</name>
<string>Reference entry text</string>

View File

@ -146,7 +146,7 @@
<sender>okPB</sender>
<signal>clicked()</signal>
<receiver>QIndexDialogBase</receiver>
<slot>apply_adaptor()</slot>
<slot>ok_adaptor()</slot>
</connection>
<connection>
<sender>cancelPB</sender>
@ -154,7 +154,7 @@
<receiver>QIndexDialogBase</receiver>
<slot>close_adaptor()</slot>
</connection>
<slot access="public">apply_adaptor()</slot>
<slot access="public">ok_adaptor()</slot>
<slot access="public">close_adaptor()</slot>
</connections>
</UI>