mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-03 14:13:58 +00:00
ref dialog, more updates (BC stuff should now be OK along with the coming
controllers/ patch) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2586 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
3796da5d05
commit
20f2690c6d
@ -1,3 +1,20 @@
|
||||
2001-08-26 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* Dialogs.C:
|
||||
* QRef.[Ch]:
|
||||
* ui/QRefDialog.ui: add Ref dialog back
|
||||
|
||||
* QAbout.[Ch]:
|
||||
* QCitation.[Ch]:
|
||||
* QDocument.[Ch]:
|
||||
* QIndex.[Ch]:
|
||||
* QURL.[Ch]:
|
||||
* Qt2Base.h: protect build() with updating_ too
|
||||
|
||||
* QCitationDialog.C: use Qt2Base::readOnly
|
||||
|
||||
* README: update
|
||||
|
||||
2001-08-25 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* Dialogs.C: add URL
|
||||
|
@ -15,15 +15,16 @@
|
||||
#include "QAboutDialog.h"
|
||||
#include "QCitationDialog.h"
|
||||
#include "QIndexDialog.h"
|
||||
#include "QRefDialog.h"
|
||||
#include "QURLDialog.h"
|
||||
|
||||
// the controller interface
|
||||
#include "QAbout.h"
|
||||
#include "QCharacter.h"
|
||||
#include "QCitation.h"
|
||||
#include "QIndex.h"
|
||||
#include "QParagraph.h"
|
||||
#include "QPrint.h"
|
||||
#include "QRef.h"
|
||||
#include "QSearch.h"
|
||||
#include "QSplash.h"
|
||||
#include "QTabularCreate.h"
|
||||
@ -45,6 +46,7 @@
|
||||
#include "controllers/ControlAboutlyx.h"
|
||||
#include "controllers/ControlCitation.h"
|
||||
#include "controllers/ControlIndex.h"
|
||||
#include "controllers/ControlRef.h"
|
||||
#include "controllers/ControlSplash.h"
|
||||
#include "controllers/ControlUrl.h"
|
||||
#if 0
|
||||
@ -90,6 +92,7 @@ Dialogs::Dialogs(LyXView * lv)
|
||||
add(new GUICitation<QCitation, Qt2BC>(*lv, *this));
|
||||
add(new GUIAboutlyx<QAbout, Qt2BC>(*lv, *this));
|
||||
add(new GUIIndex<QIndex, Qt2BC>(*lv, *this));
|
||||
add(new GUIRef<QRef, Qt2BC>(*lv, *this));
|
||||
add(new GUIUrl<QURL, Qt2BC>(*lv, *this));
|
||||
|
||||
// reduce the number of connections needed in
|
||||
|
@ -32,7 +32,7 @@ QAbout::QAbout(ControlAboutlyx & c)
|
||||
}
|
||||
|
||||
|
||||
void QAbout::build()
|
||||
void QAbout::build_dialog()
|
||||
{
|
||||
dialog_.reset(new QAboutDialog());
|
||||
connect(dialog_.get()->closePB, SIGNAL(clicked()),
|
||||
|
@ -30,7 +30,7 @@ private:
|
||||
/// not needed
|
||||
virtual void update_contents() {}
|
||||
// build the dialog
|
||||
virtual void build();
|
||||
virtual void build_dialog();
|
||||
};
|
||||
|
||||
#endif // FORMABOUT_H
|
||||
|
@ -65,7 +65,7 @@ void QCitation::hide()
|
||||
}
|
||||
|
||||
|
||||
void QCitation::build()
|
||||
void QCitation::build_dialog()
|
||||
{
|
||||
dialog_.reset(new QCitationDialog(this));
|
||||
|
||||
|
@ -42,7 +42,7 @@ private:
|
||||
/// Set the Params variable for the Controller.
|
||||
virtual void apply();
|
||||
/// Build the dialog.
|
||||
virtual void build();
|
||||
virtual void build_dialog();
|
||||
/// Hide the dialog.
|
||||
virtual void hide();
|
||||
/// Update dialog before/whilst showing it.
|
||||
|
@ -62,7 +62,7 @@ void QCitationDialog::slotBibSelected(int sel)
|
||||
{
|
||||
slotBibHighlighted(sel);
|
||||
|
||||
if (form_->controller().isReadonly())
|
||||
if (form_->readOnly())
|
||||
return;
|
||||
|
||||
slotAddClicked();
|
||||
@ -98,7 +98,7 @@ void QCitationDialog::slotBibHighlighted(int sel)
|
||||
citeLB->setTopItem(n);
|
||||
}
|
||||
|
||||
if (!form_->controller().isReadonly()) {
|
||||
if (!form_->readOnly()) {
|
||||
if (cit != form_->citekeys.end()) {
|
||||
form_->setBibButtons(QCitation::OFF);
|
||||
form_->setCiteButtons(QCitation::ON);
|
||||
@ -119,7 +119,7 @@ void QCitationDialog::slotCiteHighlighted(int sel)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!form_->controller().isReadonly()) {
|
||||
if (!form_->readOnly()) {
|
||||
form_->setBibButtons(QCitation::OFF);
|
||||
form_->setCiteButtons(QCitation::ON);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ QDocument::QDocument(ControlDocument & c)
|
||||
#endif
|
||||
|
||||
|
||||
void QDocument::build()
|
||||
void QDocument::build_dialog()
|
||||
{
|
||||
int n;
|
||||
|
||||
|
@ -71,7 +71,7 @@ private:
|
||||
/// Pointer to the actual instantiation of the ButtonController.
|
||||
virtual Qt2BC & bc();
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
virtual void build_dialog();
|
||||
// /// Filter the inputs
|
||||
// virtual bool input( FL_OBJECT *, long );
|
||||
/// Update the dialog.
|
||||
|
@ -10,15 +10,9 @@
|
||||
|
||||
#include "QIndexDialog.h"
|
||||
#include "ControlIndex.h"
|
||||
#include "QtLyXView.h"
|
||||
#include "BufferView.h"
|
||||
|
||||
#include "Dialogs.h"
|
||||
#include "Qt2BC.h"
|
||||
#include "QIndex.h"
|
||||
#include "Qt2BC.h"
|
||||
#include "gettext.h"
|
||||
#include "buffer.h"
|
||||
#include "lyxfunc.h"
|
||||
|
||||
#include <qlineedit.h>
|
||||
#include <qpushbutton.h>
|
||||
@ -31,7 +25,7 @@ QIndex::QIndex(ControlIndex & c)
|
||||
}
|
||||
|
||||
|
||||
void QIndex::build()
|
||||
void QIndex::build_dialog()
|
||||
{
|
||||
dialog_.reset(new QIndexDialog(this));
|
||||
|
||||
|
@ -33,7 +33,7 @@ private:
|
||||
/// update
|
||||
virtual void update_contents();
|
||||
/// build the dialog
|
||||
virtual void build();
|
||||
virtual void build_dialog();
|
||||
};
|
||||
|
||||
#endif // QINDEX_H
|
||||
|
@ -8,135 +8,132 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include "QRefDialog.h"
|
||||
|
||||
#include "QtLyXView.h"
|
||||
#include "BufferView.h"
|
||||
#include "Dialogs.h"
|
||||
#include "ControlRef.h"
|
||||
#include "QRef.h"
|
||||
#include "Qt2BC.h"
|
||||
#include "gettext.h"
|
||||
#include "buffer.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "debug.h"
|
||||
#include "insets/insetref.h"
|
||||
|
||||
#include <qpushbutton.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qcheckbox.h>
|
||||
#include <qlistbox.h>
|
||||
#include <qcombobox.h>
|
||||
#include <qcheckbox.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qtooltip.h>
|
||||
|
||||
using std::endl;
|
||||
|
||||
QRef::QRef(LyXView *v, Dialogs *d)
|
||||
: dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0),
|
||||
sort(0), gotowhere(GOTOREF), type(REF), refs(0)
|
||||
typedef Qt2CB<ControlRef, Qt2DB<QRefDialog> > base_class;
|
||||
|
||||
QRef::QRef(ControlRef & c)
|
||||
: base_class(c, _("Cross Reference")),
|
||||
sort_(false), at_ref_(false)
|
||||
{
|
||||
// let the dialog be shown
|
||||
// This is a permanent connection so we won't bother
|
||||
// storing a copy because we won't be disconnecting.
|
||||
d->showRef.connect(slot(this, &QRef::showRef));
|
||||
d->createRef.connect(slot(this, &QRef::createRef));
|
||||
}
|
||||
|
||||
|
||||
QRef::~QRef()
|
||||
void QRef::build_dialog()
|
||||
{
|
||||
delete dialog_;
|
||||
dialog_.reset(new QRefDialog(this));
|
||||
|
||||
bc().setOK(dialog_->okPB);
|
||||
bc().setCancel(dialog_->closePB);
|
||||
bc().addReadOnly(dialog_->refsLB);
|
||||
bc().addReadOnly(dialog_->sortCB);
|
||||
bc().addReadOnly(dialog_->nameED);
|
||||
bc().addReadOnly(dialog_->referenceED);
|
||||
bc().addReadOnly(dialog_->typeCO);
|
||||
}
|
||||
|
||||
|
||||
void QRef::showRef(InsetCommand * const inset)
|
||||
void QRef::update_contents()
|
||||
{
|
||||
// FIXME: when could inset be 0 here ?
|
||||
if (inset==0)
|
||||
return;
|
||||
dialog_->referenceED->setText(controller().params().getContents().c_str());
|
||||
dialog_->nameED->setText(controller().params().getOptions().c_str());
|
||||
|
||||
inset_ = inset;
|
||||
readonly = lv_->buffer()->isReadonly();
|
||||
//ih_ = inset_->hide.connect(slot(this,&QRef::hide));
|
||||
params = inset->params();
|
||||
dialog_->typeCO->setCurrentItem(InsetRef::getType(controller().params().getCmdName()));
|
||||
|
||||
show();
|
||||
}
|
||||
dialog_->nameED->setReadOnly(!nameAllowed() && !readOnly());
|
||||
|
||||
dialog_->typeCO->setEnabled(!typeAllowed() && !readOnly());
|
||||
if (!typeAllowed())
|
||||
dialog_->typeCO->setCurrentItem(0);
|
||||
|
||||
void QRef::createRef(string const & arg)
|
||||
{
|
||||
if (inset_)
|
||||
close();
|
||||
dialog_->sortCB->setChecked(sort_);
|
||||
|
||||
readonly = lv_->buffer()->isReadonly();
|
||||
params.setFromString(arg);
|
||||
show();
|
||||
}
|
||||
|
||||
|
||||
void QRef::select(const char *text)
|
||||
{
|
||||
highlight(text);
|
||||
goto_ref();
|
||||
}
|
||||
|
||||
|
||||
void QRef::highlight(const char *text)
|
||||
{
|
||||
if (gotowhere==GOTOBACK)
|
||||
goto_ref();
|
||||
|
||||
dialog_->gotoPB->setEnabled(true);
|
||||
if (!readonly) {
|
||||
dialog_->typeCO->setEnabled(true);
|
||||
dialog_->referenceED->setText(text);
|
||||
dialog_->okPB->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QRef::set_sort(bool on)
|
||||
{
|
||||
if (on!=sort) {
|
||||
sort=on;
|
||||
dialog_->refsLB->clear();
|
||||
updateRefs();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QRef::goto_ref()
|
||||
void QRef::apply()
|
||||
{
|
||||
controller().params().setCmdName(InsetRef::getName(dialog_->typeCO->currentItem()));
|
||||
controller().params().setContents(dialog_->referenceED->text().latin1());
|
||||
controller().params().setOptions(dialog_->nameED->text().latin1());
|
||||
}
|
||||
|
||||
|
||||
bool QRef::nameAllowed()
|
||||
{
|
||||
return controller().docType() != ControlRef::LATEX &&
|
||||
controller().docType() != ControlRef::LITERATE;
|
||||
}
|
||||
|
||||
|
||||
bool QRef::typeAllowed()
|
||||
{
|
||||
return controller().docType() == ControlRef::LINUXDOC ||
|
||||
controller().docType() == ControlRef::DOCBOOK;
|
||||
}
|
||||
|
||||
|
||||
void QRef::setGoBack()
|
||||
{
|
||||
switch (gotowhere) {
|
||||
case GOTOREF:
|
||||
lv_->getLyXFunc()->dispatch(LFUN_REF_GOTO, dialog_->referenceED->text().latin1());
|
||||
gotowhere=GOTOBACK;
|
||||
dialog_->gotoPB->setText(_("&Go back"));
|
||||
break;
|
||||
case GOTOBACK:
|
||||
//FIXME lv_->getLyXFunc()->dispatch(LFUN_REF_BACK);
|
||||
gotowhere=GOTOREF;
|
||||
dialog_->gotoPB->setText(_("&Goto reference"));
|
||||
break;
|
||||
}
|
||||
QToolTip::remove(dialog_->gotoPB);
|
||||
QToolTip::add(dialog_->gotoPB, _("Go back"));
|
||||
}
|
||||
|
||||
|
||||
void QRef::updateRefs()
|
||||
void QRef::setGotoRef()
|
||||
{
|
||||
// list will be re-done, should go back if necessary
|
||||
if (gotowhere==GOTOBACK) {
|
||||
//FIXME lv_->getLyXFunc()->dispatch(LFUN_REF_BACK);
|
||||
gotowhere = GOTOREF;
|
||||
dialog_->gotoPB->setText(_("&Goto reference"));
|
||||
}
|
||||
dialog_->gotoPB->setText(_("&Go to reference"));
|
||||
QToolTip::remove(dialog_->gotoPB);
|
||||
QToolTip::add(dialog_->gotoPB, _("Go to reference"));
|
||||
}
|
||||
|
||||
|
||||
void QRef::gotoRef()
|
||||
{
|
||||
string ref(dialog_->referenceED->text());
|
||||
|
||||
if (at_ref_) {
|
||||
// go back
|
||||
setGotoRef();
|
||||
controller().gotoBookmark();
|
||||
} else {
|
||||
// go to the ref
|
||||
setGoBack();
|
||||
controller().gotoRef(ref);
|
||||
}
|
||||
at_ref_ = !at_ref_;
|
||||
}
|
||||
|
||||
|
||||
void QRef::redoRefs()
|
||||
{
|
||||
dialog_->refsLB->setAutoUpdate(false);
|
||||
|
||||
// need this because Qt will send a highlight() here for
|
||||
// the first item inserted
|
||||
string tmp(dialog_->referenceED->text());
|
||||
|
||||
for (std::vector< string >::const_iterator iter = refs.begin();
|
||||
iter != refs.end(); ++iter) {
|
||||
if (sort)
|
||||
for (std::vector<string>::const_iterator iter = refs_.begin();
|
||||
iter != refs_.end(); ++iter) {
|
||||
if (sort_)
|
||||
dialog_->refsLB->inSort(iter->c_str());
|
||||
else
|
||||
dialog_->refsLB->insertItem(iter->c_str());
|
||||
@ -145,7 +142,7 @@ void QRef::updateRefs()
|
||||
dialog_->referenceED->setText(tmp.c_str());
|
||||
|
||||
for (unsigned int i = 0; i < dialog_->refsLB->count(); ++i) {
|
||||
if (!strcmp(dialog_->referenceED->text(),dialog_->refsLB->text(i)))
|
||||
if (!compare(tmp.c_str(), dialog_->refsLB->text(i).latin1()))
|
||||
dialog_->refsLB->setCurrentItem(i);
|
||||
}
|
||||
|
||||
@ -154,134 +151,14 @@ void QRef::updateRefs()
|
||||
}
|
||||
|
||||
|
||||
void QRef::do_ref_update()
|
||||
void QRef::updateRefs()
|
||||
{
|
||||
refs.clear();
|
||||
refs_.clear();
|
||||
if (at_ref_)
|
||||
gotoRef();
|
||||
dialog_->refsLB->clear();
|
||||
refs = lv_->buffer()->getLabelList();
|
||||
if (!refs.empty())
|
||||
dialog_->sortCB->setEnabled(true);
|
||||
updateRefs();
|
||||
}
|
||||
|
||||
|
||||
void QRef::update()
|
||||
{
|
||||
// FIXME: needs updating
|
||||
|
||||
dialog_->referenceED->setText(params.getContents().c_str());
|
||||
dialog_->nameED->setText(params.getOptions().c_str());
|
||||
|
||||
if (params.getCmdName()=="pageref") {
|
||||
type = PAGEREF;
|
||||
dialog_->typeCO->setCurrentItem(1);
|
||||
} else if (params.getCmdName()=="vref") {
|
||||
type = VREF;
|
||||
dialog_->typeCO->setCurrentItem(2);
|
||||
} else if (params.getCmdName()=="vpageref") {
|
||||
type = VPAGEREF;
|
||||
dialog_->typeCO->setCurrentItem(3);
|
||||
} else if (params.getCmdName()=="prettyref") {
|
||||
type = PRETTYREF;
|
||||
dialog_->typeCO->setCurrentItem(4);
|
||||
} else {
|
||||
type = REF;
|
||||
dialog_->typeCO->setCurrentItem(0);
|
||||
}
|
||||
|
||||
dialog_->gotoPB->setText(_("&Goto reference"));
|
||||
|
||||
gotowhere = GOTOREF;
|
||||
|
||||
dialog_->sortCB->setChecked(sort);
|
||||
|
||||
do_ref_update();
|
||||
|
||||
dialog_->gotoPB->setEnabled(params.getContents()!="");
|
||||
dialog_->okPB->setEnabled(params.getContents()!="");
|
||||
|
||||
dialog_->typeCO->setEnabled(!readonly);
|
||||
dialog_->sortCB->setEnabled(!readonly);
|
||||
dialog_->refsLB->setEnabled(!readonly);
|
||||
dialog_->okPB->setEnabled(!readonly);
|
||||
dialog_->updatePB->setEnabled(!readonly);
|
||||
if (readonly)
|
||||
dialog_->cancelPB->setText(_("&Close"));
|
||||
else
|
||||
dialog_->cancelPB->setText(_("&Cancel"));
|
||||
}
|
||||
|
||||
|
||||
void QRef::apply()
|
||||
{
|
||||
if (readonly)
|
||||
return;
|
||||
|
||||
if (!lv_->view()->available())
|
||||
return;
|
||||
|
||||
switch (dialog_->typeCO->currentItem()) {
|
||||
case 0:
|
||||
params.setCmdName("ref");
|
||||
break;
|
||||
case 1:
|
||||
params.setCmdName("pageref");
|
||||
break;
|
||||
case 2:
|
||||
params.setCmdName("vref");
|
||||
break;
|
||||
case 3:
|
||||
params.setCmdName("vpageref");
|
||||
break;
|
||||
case 4:
|
||||
params.setCmdName("prettyref");
|
||||
break;
|
||||
default:
|
||||
lyxerr[Debug::GUI] << "Unknown Ref Type" << endl;
|
||||
}
|
||||
|
||||
params.setContents(dialog_->referenceED->text().latin1());
|
||||
params.setOptions(dialog_->nameED->text().latin1());
|
||||
|
||||
if (inset_ != 0) {
|
||||
if (params != inset_->params()) {
|
||||
inset_->setParams(params);
|
||||
lv_->view()->updateInset(inset_, true);
|
||||
}
|
||||
} else
|
||||
lv_->getLyXFunc()->dispatch(LFUN_REF_INSERT, params.getAsString().c_str());
|
||||
}
|
||||
|
||||
|
||||
void QRef::show()
|
||||
{
|
||||
if (!dialog_)
|
||||
dialog_ = new QRefDialog(this, 0, _("LyX: Cross Reference"), false);
|
||||
|
||||
if (!dialog_->isVisible()) {
|
||||
h_ = d_->hideBufferDependent.connect(slot(this, &QRef::hide));
|
||||
//u_ = d_->updateBufferDependent.connect(slot(this, &QRef::update));
|
||||
}
|
||||
|
||||
dialog_->raise();
|
||||
dialog_->setActiveWindow();
|
||||
|
||||
update();
|
||||
dialog_->show();
|
||||
}
|
||||
|
||||
|
||||
void QRef::close()
|
||||
{
|
||||
h_.disconnect();
|
||||
u_.disconnect();
|
||||
ih_.disconnect();
|
||||
inset_ = 0;
|
||||
}
|
||||
|
||||
|
||||
void QRef::hide()
|
||||
{
|
||||
dialog_->hide();
|
||||
close();
|
||||
refs_ = controller().getLabelList();
|
||||
dialog_->sortCB->setEnabled(!refs_.empty());
|
||||
dialog_->refsLB->setEnabled(!refs_.empty());
|
||||
redoRefs();
|
||||
}
|
||||
|
@ -1,104 +1,68 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file QRef.h
|
||||
* Copyright 2001 the LyX Team
|
||||
* Read the file COPYING
|
||||
*
|
||||
* \author John Levon <moz@compsoc.man.ac.uk>
|
||||
* \author Kalle Dalheimer <kalle@klaralvdalens-datakonsult.se>
|
||||
* \author John Levon
|
||||
*/
|
||||
|
||||
#ifndef QREF_H
|
||||
#define QREF_H
|
||||
|
||||
#include "DialogBase.h"
|
||||
#include <config.h>
|
||||
#include <vector>
|
||||
#include "LString.h"
|
||||
#include "boost/utility.hpp"
|
||||
#include "insets/insetcommand.h"
|
||||
|
||||
class Dialogs;
|
||||
class LyXView;
|
||||
#include "Qt2Base.h"
|
||||
|
||||
class ControlRef;
|
||||
class QRefDialog;
|
||||
|
||||
class QRef : public DialogBase {
|
||||
public:
|
||||
QRef(LyXView *, Dialogs *);
|
||||
~QRef();
|
||||
class QRef :
|
||||
public Qt2CB<ControlRef, Qt2DB<QRefDialog> >
|
||||
{
|
||||
friend class QRefDialog;
|
||||
|
||||
/// double-click a ref
|
||||
void select(const char *);
|
||||
/// highlight a ref
|
||||
void highlight(const char *);
|
||||
/// set sort
|
||||
void set_sort(bool);
|
||||
/// goto a ref (or back)
|
||||
void goto_ref();
|
||||
/// update dialog
|
||||
void update();
|
||||
/// update just the refs
|
||||
void do_ref_update();
|
||||
/// Apply changes
|
||||
void apply();
|
||||
/// close the connections
|
||||
void close();
|
||||
public:
|
||||
QRef(ControlRef & c);
|
||||
|
||||
private:
|
||||
enum Type {
|
||||
REF, PAGEREF, VREF, VPAGEREF, PRETTYREF
|
||||
};
|
||||
/// apply changes
|
||||
virtual void apply();
|
||||
/// build dialog
|
||||
virtual void build_dialog();
|
||||
/// update dialog
|
||||
virtual void update_contents();
|
||||
|
||||
enum GotoType {
|
||||
GOTOREF, GOTOBACK
|
||||
};
|
||||
/// is name allowed for this ?
|
||||
bool nameAllowed();
|
||||
|
||||
/// Create the dialog if necessary, update it and display it.
|
||||
void show();
|
||||
/// Hide the dialog.
|
||||
void hide();
|
||||
/// is type allowed for this ?
|
||||
bool typeAllowed();
|
||||
|
||||
/// create a Reference inset
|
||||
void createRef(string const &);
|
||||
/// edit a Reference inset
|
||||
void showRef(InsetCommand * const);
|
||||
/// go to current reference
|
||||
void gotoRef();
|
||||
|
||||
/// update the keys list
|
||||
void updateRefs(void);
|
||||
/// set go back button
|
||||
void setGoBack();
|
||||
|
||||
/// Real GUI implementation.
|
||||
QRefDialog * dialog_;
|
||||
/// set goto ref button
|
||||
void setGotoRef();
|
||||
|
||||
/// the LyXView we belong to
|
||||
LyXView * lv_;
|
||||
/// re-enter references
|
||||
void redoRefs();
|
||||
|
||||
/** 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;
|
||||
/// update references
|
||||
void updateRefs();
|
||||
|
||||
/// Hide connection.
|
||||
SigC::Connection h_;
|
||||
/// Update connection.
|
||||
SigC::Connection u_;
|
||||
/// Inset hide connection.
|
||||
SigC::Connection ih_;
|
||||
/// sort or not persistent state
|
||||
bool sort_;
|
||||
|
||||
/// to sort or not to sort
|
||||
bool sort;
|
||||
/// at a reference ?
|
||||
bool at_ref_;
|
||||
|
||||
/// where to go
|
||||
GotoType gotowhere;
|
||||
|
||||
/// current type
|
||||
Type type;
|
||||
|
||||
/// available references
|
||||
std::vector< string > refs;
|
||||
/// the references
|
||||
std::vector<string> refs_;
|
||||
};
|
||||
|
||||
#endif // QREF_H
|
||||
|
@ -4,72 +4,83 @@
|
||||
* Read the file COPYING
|
||||
*
|
||||
* \author Kalle Dalheimer <kalle@klaralvdalens-datakonsult.se>
|
||||
* \author John Levon <moz@compsoc.man.ac.uk>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <qpushbutton.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qcombobox.h>
|
||||
#include <qlistbox.h>
|
||||
|
||||
#include "QRefDialog.h"
|
||||
#include "ControlRef.h"
|
||||
#include "Dialogs.h"
|
||||
#include "QRef.h"
|
||||
#include "debug.h"
|
||||
|
||||
QRefDialog::QRefDialog(QRef * form, QWidget * parent, const char * name, bool modal, WFlags fl)
|
||||
: QRefDialogBase(parent, name, modal, fl),
|
||||
QRefDialog::QRefDialog(QRef * form)
|
||||
: QRefDialogBase(0, 0, false, 0),
|
||||
form_(form)
|
||||
{
|
||||
connect(okPB, SIGNAL(clicked()),
|
||||
form_, SLOT(slotOK()));
|
||||
connect(closePB, SIGNAL(clicked()),
|
||||
form_, SLOT(slotClose()));
|
||||
}
|
||||
|
||||
|
||||
QRefDialog::~QRefDialog()
|
||||
void QRefDialog::changed_adaptor()
|
||||
{
|
||||
form_->changed();
|
||||
}
|
||||
|
||||
|
||||
void QRefDialog::apply_adaptor()
|
||||
void QRefDialog::gotoClicked()
|
||||
{
|
||||
form_->apply();
|
||||
form_->close();
|
||||
hide();
|
||||
form_->gotoRef();
|
||||
}
|
||||
|
||||
|
||||
void QRefDialog::goto_adaptor()
|
||||
void QRefDialog::refHighlighted(const QString & sel)
|
||||
{
|
||||
form_->goto_ref();
|
||||
if (form_->readOnly())
|
||||
return;
|
||||
|
||||
referenceED->setText(sel);
|
||||
if (form_->at_ref_)
|
||||
form_->gotoRef();
|
||||
gotoPB->setEnabled(true);
|
||||
if (form_->typeAllowed())
|
||||
typeCO->setEnabled(true);
|
||||
if (form_->nameAllowed())
|
||||
nameED->setEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
void QRefDialog::highlight_adaptor(const QString & sel)
|
||||
void QRefDialog::refSelected(const QString & sel)
|
||||
{
|
||||
form_->highlight(sel);
|
||||
form_->gotoRef();
|
||||
}
|
||||
|
||||
|
||||
void QRefDialog::close_adaptor()
|
||||
void QRefDialog::sortToggled(bool on)
|
||||
{
|
||||
form_->close();
|
||||
hide();
|
||||
form_->sort_ = on;
|
||||
refsLB->clear();
|
||||
form_->redoRefs();
|
||||
}
|
||||
|
||||
|
||||
void QRefDialog::select_adaptor(const QString & sel)
|
||||
void QRefDialog::updateClicked()
|
||||
{
|
||||
form_->select(sel);
|
||||
form_->updateRefs();
|
||||
}
|
||||
|
||||
|
||||
void QRefDialog::sort_adaptor(bool sort)
|
||||
{
|
||||
form_->set_sort(sort);
|
||||
}
|
||||
|
||||
|
||||
void QRefDialog::update_adaptor()
|
||||
{
|
||||
form_->do_ref_update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void QRefDialog::closeEvent(QCloseEvent * e)
|
||||
{
|
||||
form_->close();
|
||||
form_->slotWMHide();
|
||||
e->accept();
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Read the file COPYING
|
||||
*
|
||||
* \author Kalle Dalheimer <kalle@klaralvdalens-datakonsult.se>
|
||||
* \author John Levon <moz@compsoc.man.ac.uk>
|
||||
*/
|
||||
|
||||
#ifndef QREFDIALOG_H
|
||||
@ -19,17 +20,15 @@ class QRefDialog : public QRefDialogBase
|
||||
{ Q_OBJECT
|
||||
|
||||
public:
|
||||
QRefDialog(QRef * form, QWidget * parent = 0, const char * name = 0, bool modal = FALSE, WFlags fl = 0);
|
||||
~QRefDialog();
|
||||
QRefDialog(QRef * form);
|
||||
|
||||
public slots:
|
||||
void apply_adaptor();
|
||||
void goto_adaptor();
|
||||
void highlight_adaptor(const QString &);
|
||||
void close_adaptor();
|
||||
void select_adaptor(const QString &);
|
||||
void sort_adaptor(bool);
|
||||
void update_adaptor();
|
||||
void changed_adaptor();
|
||||
void gotoClicked();
|
||||
void refHighlighted(const QString &);
|
||||
void refSelected(const QString &);
|
||||
void sortToggled(bool);
|
||||
void updateClicked();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent * e);
|
||||
|
@ -27,7 +27,7 @@ QURL::QURL(ControlUrl & c)
|
||||
}
|
||||
|
||||
|
||||
void QURL::build()
|
||||
void QURL::build_dialog()
|
||||
{
|
||||
dialog_.reset(new QURLDialog(this));
|
||||
|
||||
|
@ -28,7 +28,7 @@ private:
|
||||
/// apply dialog
|
||||
virtual void apply();
|
||||
/// build dialog
|
||||
virtual void build();
|
||||
virtual void build_dialog();
|
||||
/// update dialog
|
||||
virtual void update_contents();
|
||||
};
|
||||
|
@ -35,9 +35,6 @@ void Qt2BC::setButtonEnabled(QButton * obj, bool enabled)
|
||||
|
||||
void Qt2BC::setWidgetEnabled(QWidget * obj, bool enabled)
|
||||
{
|
||||
lyxerr << "Qt2BC: setting "
|
||||
<< obj << " to " << enabled << std::endl;
|
||||
|
||||
// yuck, rtti, but the user comes first
|
||||
if (obj->inherits("QLineEdit")) {
|
||||
QLineEdit * le(static_cast<QLineEdit*>(obj));
|
||||
|
@ -65,8 +65,6 @@ bool Qt2Base::isValid()
|
||||
|
||||
void Qt2Base::changed()
|
||||
{
|
||||
lyxerr << "got changed() during updating:" << updating_ << std::endl;
|
||||
|
||||
if (updating_)
|
||||
return;
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include "ViewBase.h"
|
||||
#include "LString.h"
|
||||
#include "debug.h"
|
||||
#include "ButtonPolicies.h"
|
||||
#include "ControlButtons.h"
|
||||
|
||||
@ -46,8 +47,8 @@ public:
|
||||
virtual ~Qt2Base() {}
|
||||
|
||||
protected:
|
||||
/// Build the dialog
|
||||
virtual void build() = 0;
|
||||
/// build the actual dialog
|
||||
virtual void build_dialog() = 0;
|
||||
/// Hide the dialog.
|
||||
virtual void hide();
|
||||
/// Create the dialog if necessary, update it and display it.
|
||||
@ -99,8 +100,12 @@ protected:
|
||||
/// update the dialog
|
||||
virtual void update();
|
||||
|
||||
/// Build the dialog
|
||||
virtual void build();
|
||||
|
||||
/// Pointer to the actual instantiation of the Qt dialog
|
||||
virtual QDialog * form() const;
|
||||
|
||||
/// Real GUI implementation.
|
||||
boost::scoped_ptr<Dialog> dialog_;
|
||||
|
||||
@ -125,11 +130,8 @@ void Qt2DB<Dialog>::update()
|
||||
{
|
||||
form()->setUpdatesEnabled(false);
|
||||
|
||||
// this is tricky. First we process pending events
|
||||
// as a result of the bc() state change (if any).
|
||||
// then we lock out any bc() changes as a result of
|
||||
// "innocent" updates during update_contents()
|
||||
// then we enable normal behaviour again.
|
||||
// protect the BC from unwarranted state transitions
|
||||
|
||||
qApp->processEvents();
|
||||
updating_ = true;
|
||||
update_contents();
|
||||
@ -141,9 +143,27 @@ void Qt2DB<Dialog>::update()
|
||||
}
|
||||
|
||||
|
||||
template <class Dialog>
|
||||
void Qt2DB<Dialog>::build()
|
||||
{
|
||||
// protect the BC from unwarranted state transitions
|
||||
|
||||
qApp->processEvents();
|
||||
updating_ = true;
|
||||
build_dialog();
|
||||
qApp->processEvents();
|
||||
updating_ = false;
|
||||
}
|
||||
|
||||
|
||||
template <class Controller, class Base>
|
||||
class Qt2CB: public Base
|
||||
{
|
||||
public:
|
||||
bool readOnly() const {
|
||||
return controller().isReadonly();
|
||||
}
|
||||
|
||||
protected:
|
||||
///
|
||||
Qt2CB(ControlButtons &, const QString&);
|
||||
|
@ -19,7 +19,9 @@ of the current dialog's contents.
|
||||
OK/Apply/Restore/Close should be connected in the derived class's constructor
|
||||
to call form_->slotOK() etc. Refer to close/cancel as close in the source.
|
||||
|
||||
Override update_contents() to update the dialog, not update()
|
||||
Override update_contents() to update the dialog, not update(), and build_dialog(),
|
||||
not build(). Only these functions may change dialog widgets that may emit changed()
|
||||
during initialisation, to prevent the button controller from changing its state.
|
||||
|
||||
Never call buttoncontroller functions directly from dialogs. In general, you
|
||||
should use Qt2Base::changed() in all circumstances. However, if you must call
|
||||
@ -58,10 +60,10 @@ Document Kalle Waiting for MVC
|
||||
Index Kalle Done
|
||||
Paragraph Edwin Waiting for MVC
|
||||
Print Edwin
|
||||
Ref Kalle
|
||||
Ref Kalle Done
|
||||
Search Edwin
|
||||
Splash Edwin
|
||||
Tabular Waiting for MVC
|
||||
TabularCreate Edwin
|
||||
Toc Kalle
|
||||
Url Kalle
|
||||
Url Kalle Done
|
||||
|
@ -11,7 +11,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>417</width>
|
||||
<width>401</width>
|
||||
<height>277</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -49,6 +49,10 @@
|
||||
<name>name</name>
|
||||
<cstring>refsLB</cstring>
|
||||
</property>
|
||||
<property>
|
||||
<name>toolTip</name>
|
||||
<string>Available references</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget>
|
||||
<class>QLayoutWidget</class>
|
||||
@ -96,6 +100,10 @@
|
||||
<name>text</name>
|
||||
<string>&Update</string>
|
||||
</property>
|
||||
<property>
|
||||
<name>toolTip</name>
|
||||
<string>Update the reference list</string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer>
|
||||
<property>
|
||||
@ -130,7 +138,7 @@
|
||||
</property>
|
||||
<property>
|
||||
<name>toolTip</name>
|
||||
<string>Sort references in alphabetical order ?</string>
|
||||
<string>Sort references in alphabetical order</string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer>
|
||||
@ -383,6 +391,10 @@
|
||||
<name>text</name>
|
||||
<string>&Goto reference</string>
|
||||
</property>
|
||||
<property>
|
||||
<name>toolTip</name>
|
||||
<string>Move the document cursor</string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer>
|
||||
<property>
|
||||
@ -439,11 +451,11 @@
|
||||
<class>QPushButton</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>cancelPB</cstring>
|
||||
<cstring>closePB</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>&Cancel</string>
|
||||
<string>&Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</hbox>
|
||||
@ -453,54 +465,65 @@
|
||||
</hbox>
|
||||
</widget>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>typeCO</sender>
|
||||
<signal>activated(int)</signal>
|
||||
<receiver>QRefDialogBase</receiver>
|
||||
<slot>changed_adaptor()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>referenceED</sender>
|
||||
<signal>textChanged(const QString&)</signal>
|
||||
<receiver>QRefDialogBase</receiver>
|
||||
<slot>changed_adaptor()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>nameED</sender>
|
||||
<signal>textChanged(const QString&)</signal>
|
||||
<receiver>QRefDialogBase</receiver>
|
||||
<slot>changed_adaptor()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>refsLB</sender>
|
||||
<signal>highlighted(const QString&)</signal>
|
||||
<receiver>QRefDialogBase</receiver>
|
||||
<slot>highlight_adaptor(const QString&)</slot>
|
||||
<slot>refHighlighted(const QString&)</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>refsLB</sender>
|
||||
<signal>selected(const QString&)</signal>
|
||||
<receiver>QRefDialogBase</receiver>
|
||||
<slot>select_adaptor(const QString&)</slot>
|
||||
<slot>refSelected(const QString&)</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>refsLB</sender>
|
||||
<signal>highlighted(const QString&)</signal>
|
||||
<receiver>QRefDialogBase</receiver>
|
||||
<slot>changed_adaptor()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>sortCB</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>QRefDialogBase</receiver>
|
||||
<slot>sort_adaptor(bool)</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>updatePB</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>QRefDialogBase</receiver>
|
||||
<slot>update_adaptor()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>okPB</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>QRefDialogBase</receiver>
|
||||
<slot>apply_adaptor()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>cancelPB</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>QRefDialogBase</receiver>
|
||||
<slot>close_adaptor()</slot>
|
||||
<slot>sortToggled(bool)</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>gotoPB</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>QRefDialogBase</receiver>
|
||||
<slot>goto_adaptor()</slot>
|
||||
<slot>gotoClicked()</slot>
|
||||
</connection>
|
||||
<slot access="public">apply_adaptor()</slot>
|
||||
<slot access="public">goto_adaptor()</slot>
|
||||
<slot access="public">highlight_adaptor(const QString&)</slot>
|
||||
<slot access="public">close_adaptor()</slot>
|
||||
<slot access="public">select_adaptor(const QString&)</slot>
|
||||
<slot access="public">sort_adaptor(bool)</slot>
|
||||
<slot access="public">update_adaptor()</slot>
|
||||
<connection>
|
||||
<sender>updatePB</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>QRefDialogBase</receiver>
|
||||
<slot>updateClicked()</slot>
|
||||
</connection>
|
||||
<slot access="public">changed_adaptor()</slot>
|
||||
<slot access="public">gotoClicked()</slot>
|
||||
<slot access="public">refHighlighted(const QString&)</slot>
|
||||
<slot access="public">refSelected(const QString&)</slot>
|
||||
<slot access="public">sortToggled(bool)</slot>
|
||||
<slot access="public">updateClicked()</slot>
|
||||
</connections>
|
||||
</UI>
|
||||
|
Loading…
Reference in New Issue
Block a user