From 7d131e12b3fe4a4a322b62ccd44ad5f5a2278be5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Tue, 12 Sep 2000 15:13:19 +0000 Subject: [PATCH] Applied John's KDE patch git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1010 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 28 ++ src/frontends/gnome/GUIRunTime.C | 4 +- src/frontends/kde/FormCitation.C | 353 +++++++++++++++++++++++++ src/frontends/kde/FormCitation.h | 116 ++++++++ src/frontends/kde/FormIndex.C | 127 +++++++++ src/frontends/kde/FormIndex.h | 80 ++++++ src/frontends/kde/FormToc.C | 208 +++++++++++++++ src/frontends/kde/FormToc.h | 94 +++++++ src/frontends/kde/FormUrl.C | 10 +- src/frontends/kde/FormUrl.h | 4 +- src/frontends/kde/Makefile.am | 35 ++- src/frontends/kde/QtLyXView.h | 12 + src/frontends/kde/formcitationdialog.C | 173 ++++++++++++ src/frontends/kde/formcitationdialog.h | 118 +++++++++ src/frontends/kde/formindexdialog.C | 88 ++++++ src/frontends/kde/formindexdialog.h | 75 ++++++ src/frontends/kde/formtocdialog.C | 83 ++++++ src/frontends/kde/formtocdialog.h | 97 +++++++ src/frontends/kde/formurldialog.C | 12 +- src/frontends/kde/formurldialog.h | 12 +- src/frontends/xforms/GUIRunTime.C | 2 +- 21 files changed, 1702 insertions(+), 29 deletions(-) create mode 100644 src/frontends/kde/FormCitation.C create mode 100644 src/frontends/kde/FormCitation.h create mode 100644 src/frontends/kde/FormIndex.C create mode 100644 src/frontends/kde/FormIndex.h create mode 100644 src/frontends/kde/FormToc.C create mode 100644 src/frontends/kde/FormToc.h create mode 100644 src/frontends/kde/QtLyXView.h create mode 100644 src/frontends/kde/formcitationdialog.C create mode 100644 src/frontends/kde/formcitationdialog.h create mode 100644 src/frontends/kde/formindexdialog.C create mode 100644 src/frontends/kde/formindexdialog.h create mode 100644 src/frontends/kde/formtocdialog.C create mode 100644 src/frontends/kde/formtocdialog.h diff --git a/ChangeLog b/ChangeLog index 2c5b47c8db..1b094a750b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,31 @@ +2000-09-11 John Levon + + * src/frontends/kde/formurldialog.C + * src/frontends/kde/formurldialog.h + * src/frontends/kde/FormUrl.C + * src/frontends/kde/FormUrl.h: minor cleanups + + * src/frontends/kde/QtLyXView: wrapper to avoid Qt namespace mangling + + * src/frontends/kde/Makefile.am + * src/frontends/kde/FormToc.C + * src/frontends/kde/FormToc.h + * src/frontends/kde/FormCitation.C + * src/frontends/kde/FormCitation.h + * src/frontends/kde/FormIndex.C + * src/frontends/kde/FormIndex.h + * src/frontends/kde/formtocdialog.C + * src/frontends/kde/formtocdialog.h + * src/frontends/kde/formcitationdialog.C + * src/frontends/kde/formcitationdialog.h + * src/frontends/kde/formindexdialog.C + * src/frontends/kde/formindexdialog.h: new Toc,Citation,Index dialogs + +2000-09-12 Juergen Vigna + + * src/frontends/gnome/GUIRunTime.C (initApplication): make id + version + static strings. + 2000-09-11 Jean-Marc Lasgouttes * src/frontends/xforms/GUIRunTime.C (initApplication): use lyxerr, diff --git a/src/frontends/gnome/GUIRunTime.C b/src/frontends/gnome/GUIRunTime.C index 3caee52fe7..928301224d 100644 --- a/src/frontends/gnome/GUIRunTime.C +++ b/src/frontends/gnome/GUIRunTime.C @@ -63,8 +63,8 @@ int GUIRunTime::initApplication(int, char * argv[]) return 1; } - string app_id(PACKAGE); - string app_version(VERSION); + static string app_id(PACKAGE); + static string app_version(VERSION); static Gnome::Main a(app_id, app_version, 1, argv); static GLyxAppWin appWin; mainAppWin = &appWin; diff --git a/src/frontends/kde/FormCitation.C b/src/frontends/kde/FormCitation.C new file mode 100644 index 0000000000..76445d50fc --- /dev/null +++ b/src/frontends/kde/FormCitation.C @@ -0,0 +1,353 @@ +/* + * FormCitation.C + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + */ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include + +#include + +#include "Dialogs.h" +#include "FormCitation.h" +#include "gettext.h" +#include "buffer.h" +#include "LyXView.h" +#include "lyxfunc.h" +#include "formcitationdialog.h" + +using std::vector; +using std::pair; +using std::find; + +FormCitation::FormCitation(LyXView *v, Dialogs *d) + : dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0), + keys(0), chosenkeys(0) +{ + // 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->showCitation.connect(slot(this, &FormCitation::showCitation)); + d->createCitation.connect(slot(this, &FormCitation::createCitation)); +} + +FormCitation::~FormCitation() +{ + delete dialog_; +} + +void FormCitation::showCitation(InsetCommand * const inset) +{ + // FIXME: when could inset be 0 here ? + if (inset==0) + return; + + inset_ = inset; + readonly = lv_->buffer()->isReadonly(); + ih_ = inset_->hide.connect(slot(this,&FormCitation::hide)); + params = inset->params(); + + show(); +} + +void FormCitation::createCitation(string const & arg) +{ + // we could already be showing stuff, clear it out + if (inset_) + close(); + + readonly = lv_->buffer()->isReadonly(); + params.setFromString(arg); + show(); +} + +void FormCitation::updateButtons() +{ + bool iskey,ischosenkey; + + iskey = !selectedKey.empty(); + ischosenkey = !selectedChosenKey.empty(); + + dialog_->remove->setEnabled(ischosenkey); + dialog_->add->setEnabled(iskey); + dialog_->up->setEnabled(ischosenkey); + dialog_->down->setEnabled(ischosenkey); +} + +void FormCitation::updateChosenList() +{ + dialog_->chosen->setAutoUpdate(false); + dialog_->chosen->clear(); + + for (vector< string >::const_iterator iter = chosenkeys.begin(); + iter != chosenkeys.end(); ++iter) { + dialog_->chosen->insertItem(iter->c_str()); + } + dialog_->chosen->setAutoUpdate(true); + dialog_->chosen->update(); +} + +void FormCitation::updateAvailableList() +{ + dialog_->keys->setAutoUpdate(false); + dialog_->keys->clear(); + + for (vector< pair >::const_iterator iter = keys.begin(); + iter != keys.end(); ++iter) { + dialog_->keys->insertItem(iter->first.c_str()); + } + dialog_->keys->setAutoUpdate(true); + dialog_->keys->update(); +} + +void FormCitation::update() +{ + keys.clear(); + + vector < pair > ckeys = lv_->buffer()->getBibkeyList(); + + for (vector< pair >::const_iterator iter = ckeys.begin(); + iter != ckeys.end(); ++iter) { + keys.push_back(*iter); + } + + updateAvailableList(); + selectedKey.erase(); + + chosenkeys.clear(); + + string tmp, paramkeys(params.getContents()); + paramkeys = frontStrip(split(paramkeys, tmp, ',')); + + while (!tmp.empty()) { + chosenkeys.push_back(tmp); + paramkeys = frontStrip(split(paramkeys, tmp, ',')); + } + + updateChosenList(); + selectedChosenKey.erase(); + + dialog_->entry->setText(""); + + dialog_->after->setText(params.getOptions().c_str()); + + updateButtons(); + + if (readonly) { + dialog_->keys->setFocusPolicy(QWidget::NoFocus); + dialog_->chosen->setFocusPolicy(QWidget::NoFocus); + dialog_->after->setFocusPolicy(QWidget::NoFocus); + dialog_->buttonOk->setEnabled(false); + dialog_->buttonCancel->setText(_("Close")); + } else { + dialog_->keys->setFocusPolicy(QWidget::StrongFocus); + dialog_->chosen->setFocusPolicy(QWidget::StrongFocus); + dialog_->after->setFocusPolicy(QWidget::StrongFocus); + dialog_->buttonOk->setEnabled(true); + dialog_->buttonCancel->setText(_("Cancel")); + } +} + +void FormCitation::apply() +{ + if (readonly) + return; + + string contents; + + for (vector< string >::const_iterator iter = chosenkeys.begin(); + iter != chosenkeys.end(); ++iter) { + if (iter != chosenkeys.begin()) + contents += ", "; + contents += *iter; + } + + params.setContents(contents); + params.setOptions(dialog_->after->text()); + + if (inset_ != 0) { + if (params != inset_->params()) { + inset_->setParams(params); + lv_->view()->updateInset(inset_, true); + } + } else + lv_->getLyXFunc()->Dispatch(LFUN_CITATION_INSERT, params.getAsString().c_str()); +} + +void FormCitation::show() +{ + if (!dialog_) + dialog_ = new FormCitationDialog(this, 0, _("LyX: Citation Reference"), false); + + if (!dialog_->isVisible()) { + h_ = d_->hideBufferDependent.connect(slot(this, &FormCitation::hide)); + u_ = d_->updateBufferDependent.connect(slot(this, &FormCitation::update)); + } + + dialog_->raise(); + dialog_->setActiveWindow(); + + update(); + dialog_->show(); +} + +void FormCitation::close() +{ + h_.disconnect(); + u_.disconnect(); + ih_.disconnect(); + inset_ = 0; +} + +void FormCitation::hide() +{ + dialog_->hide(); + close(); +} + +void FormCitation::selectChosen() +{ + for (unsigned int i=0; i < dialog_->chosen->count(); ++i) { + if (dialog_->chosen->text(i)==selectedChosenKey) { + dialog_->chosen->setSelected(i,true); + dialog_->chosen->setTopItem(i); + break; + } + } +} + +void FormCitation::add() +{ + if (selectedKey.empty()) + return; + + for (vector< pair >::const_iterator iter = keys.begin(); + iter != keys.end(); ++iter) { + if (iter->first == selectedKey) { + chosenkeys.push_back(iter->first); + break; + } + } + + selectedChosenKey.erase(); + updateChosenList(); + updateButtons(); +} + +void FormCitation::remove() +{ + if (selectedChosenKey.empty()) + return; + + for (vector< string >::iterator iter = chosenkeys.begin(); + iter != chosenkeys.end(); ++iter) { + if (*iter==selectedChosenKey) { + chosenkeys.erase(iter); + break; + } + } + selectedChosenKey.erase(); + updateChosenList(); + updateButtons(); +} + +void FormCitation::up() +{ + if (selectedChosenKey.empty()) + return; + + // Qt will select the first one on redo, so we need this + string tmp = selectedChosenKey; + + for (vector< string >::iterator iter = chosenkeys.begin(); + iter != chosenkeys.end(); ++iter) { + if (*iter==selectedChosenKey && iter!=chosenkeys.begin()) { + string tmp = *iter; + chosenkeys.erase(iter); + chosenkeys.insert(iter-1,tmp); + break; + } + } + if (iter==chosenkeys.end()) + return; + + updateChosenList(); + selectedChosenKey=tmp; + selectChosen(); +} + +void FormCitation::down() +{ + if (selectedChosenKey.empty()) + return; + + // Qt will select the first one on redo, so we need this + string tmp = selectedChosenKey; + + for (vector< string >::iterator iter = chosenkeys.begin(); + iter != chosenkeys.end(); ++iter) { + if (*iter==selectedChosenKey && (iter+1)!=chosenkeys.end()) { + string tmp = *iter; + chosenkeys.erase(iter); + chosenkeys.insert(iter+1, tmp); + break; + } + } + if (iter==chosenkeys.end()) + return; + + updateChosenList(); + selectedChosenKey=tmp; + selectChosen(); +} + +void FormCitation::select_key(const char *key) +{ + selectedKey.erase(); + selectedKey = key; + + add(); +} + +void FormCitation::highlight_key(const char *key) +{ + selectedKey.erase(); + selectedKey = key; + + for (unsigned int i=0; i < keys.size(); i++) { + if (keys[i].first==key) { + dialog_->entry->setText(keys[i].second.c_str()); + break; + } + } + + updateButtons(); +} + +void FormCitation::highlight_chosen(const char *key) +{ + selectedChosenKey.erase(); + selectedChosenKey = key; + + unsigned int i; + for (i=0; i < keys.size(); i++) { + if (keys[i].first==key && keys[i].second.compare(dialog_->entry->text())) { + dialog_->entry->setText(keys[i].second.c_str()); + break; + } + } + + if (i==keys.size()) + dialog_->entry->setText(_("Key not found in references.")); + + updateButtons(); +} diff --git a/src/frontends/kde/FormCitation.h b/src/frontends/kde/FormCitation.h new file mode 100644 index 0000000000..29417f026e --- /dev/null +++ b/src/frontends/kde/FormCitation.h @@ -0,0 +1,116 @@ +/* FormCitation.h + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + */ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef FORMCITATION_H +#define FORMCITATION_H + +#include "DialogBase.h" +#include "support/lstrings.h" +#include "support/utility.hpp" +#include "insets/insetcommand.h" + +#include + +class Dialogs; +class LyXView; +class FormCitationDialog; + +class FormCitation : public DialogBase, public noncopyable { +public: + /**@name Constructors and Destructors */ + //@{ + /// + FormCitation(LyXView *, Dialogs *); + /// + ~FormCitation(); + //@} + + /// Apply changes + void apply(); + /// close the connections + void close(); + /// add a key + void add(); + /// remove a key + void remove(); + /// move a key up + void up(); + /// move a key down + void down(); + /// a key has been highlighted + void highlight_key(const char *key); + /// a chosen key has been highlighted + void highlight_chosen(const char *key); + /// a key has been double-clicked + void select_key(const char *key); + +private: + /// Create the dialog if necessary, update it and display it. + void show(); + /// Hide the dialog. + void hide(); + /// Update the dialog. + void update(); + + /// create a Citation inset + void createCitation(string const &); + /// edit a Citation inset + void showCitation(InsetCommand * const); + + /// update add,remove,up,down + void updateButtons(); + /// update the available keys list + void updateAvailableList(); + /// update the chosen keys list + void updateChosenList(); + /// select the currently chosen key + void selectChosen(); + + /// Real GUI implementation. + FormCitationDialog * 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. + Connection h_; + /// Update connection. + Connection u_; + /// Inset hide connection. + Connection ih_; + + /// available citation keys + std::vector > keys; + /// chosen citation keys + std::vector chosenkeys; + + /// currently selected key + string selectedKey; + + /// currently selected chosen key + string selectedChosenKey; +}; + +#endif diff --git a/src/frontends/kde/FormIndex.C b/src/frontends/kde/FormIndex.C new file mode 100644 index 0000000000..d5593a0395 --- /dev/null +++ b/src/frontends/kde/FormIndex.C @@ -0,0 +1,127 @@ +/* + * FormIndex.C + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + */ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include + +#include "Dialogs.h" +#include "FormIndex.h" +#include "gettext.h" +#include "buffer.h" +#include "LyXView.h" +#include "lyxfunc.h" +#include "formindexdialog.h" + +FormIndex::FormIndex(LyXView *v, Dialogs *d) + : dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0) +{ + // 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->showIndex.connect(slot(this, &FormIndex::showIndex)); + d->createIndex.connect(slot(this, &FormIndex::createIndex)); +} + +FormIndex::~FormIndex() +{ + delete dialog_; +} + +void FormIndex::showIndex(InsetCommand * const inset) +{ + // FIXME: when could inset be 0 here ? + if (inset==0) + return; + + inset_ = inset; + readonly = lv_->buffer()->isReadonly(); + ih_ = inset_->hide.connect(slot(this,&FormIndex::hide)); + params = inset->params(); + + show(); +} + +void FormIndex::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(); +} + +void FormIndex::update() +{ + dialog_->index->setText(params.getContents().c_str()); + + if (readonly) { + dialog_->index->setFocusPolicy(QWidget::NoFocus); + dialog_->buttonOk->setEnabled(false); + dialog_->buttonCancel->setText(_("Close")); + } else { + dialog_->index->setFocusPolicy(QWidget::StrongFocus); + dialog_->index->setFocus(); + dialog_->buttonOk->setEnabled(true); + dialog_->buttonCancel->setText(_("Cancel")); + } +} + +void FormIndex::apply() +{ + if (readonly) + return; + + params.setContents(dialog_->index->text()); + + 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 FormIndex::show() +{ + if (!dialog_) + dialog_ = new FormIndexDialog(this, 0, _("LyX: Index"), false); + + if (!dialog_->isVisible()) { + h_ = d_->hideBufferDependent.connect(slot(this, &FormIndex::hide)); + u_ = d_->updateBufferDependent.connect(slot(this, &FormIndex::update)); + } + + dialog_->raise(); + dialog_->setActiveWindow(); + + update(); + dialog_->show(); +} + +void FormIndex::close() +{ + h_.disconnect(); + u_.disconnect(); + ih_.disconnect(); + inset_ = 0; +} + +void FormIndex::hide() +{ + dialog_->hide(); + close(); +} diff --git a/src/frontends/kde/FormIndex.h b/src/frontends/kde/FormIndex.h new file mode 100644 index 0000000000..39fa9836f1 --- /dev/null +++ b/src/frontends/kde/FormIndex.h @@ -0,0 +1,80 @@ +/* FormIndex.h + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + */ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef FORMINDEX_H +#define FORMINDEX_H + +#include "DialogBase.h" +#include "LString.h" +#include "support/utility.hpp" +#include "insets/insetindex.h" + +class Dialogs; +class LyXView; +class FormIndexDialog; + +class FormIndex : public DialogBase, public noncopyable { +public: + /**@name Constructors and Destructors */ + //@{ + /// + FormIndex(LyXView *, Dialogs *); + /// + ~FormIndex(); + //@} + + /// 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(); + + /// create an Index inset + void createIndex(string const &); + /// edit an Index inset + void showIndex(InsetCommand * const); + + /// Real GUI implementation. + FormIndexDialog * 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. + Connection h_; + /// Update connection. + Connection u_; + /// Inset hide connection. + Connection ih_; +}; + +#endif diff --git a/src/frontends/kde/FormToc.C b/src/frontends/kde/FormToc.C new file mode 100644 index 0000000000..c636486347 --- /dev/null +++ b/src/frontends/kde/FormToc.C @@ -0,0 +1,208 @@ +/* + * FormToc.C + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + */ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include + +#include "formtocdialog.h" + +#include "Dialogs.h" +#include "FormToc.h" +#include "gettext.h" +#include "buffer.h" +#include "support/lstrings.h" +#include "QtLyXView.h" +#include "lyxfunc.h" +#include "debug.h" + +using std::vector; +using std::pair; + +FormToc::FormToc(LyXView *v, Dialogs *d) + : dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0), + toclist(0), type(Buffer::TOC_TOC) +{ + // 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->showTOC.connect(slot(this, &FormToc::showTOC)); + d->createTOC.connect(slot(this, &FormToc::createTOC)); +} + +FormToc::~FormToc() +{ + delete dialog_; +} + +void FormToc::showTOC(InsetCommand * const inset) +{ + // FIXME: when could inset be 0 here ? + if (inset==0) + return; + + inset_ = inset; + ih_ = inset_->hide.connect(slot(this,&FormToc::hide)); + params = inset->params(); + + show(); +} + +void FormToc::createTOC(string const & arg) +{ + if (inset_) + close(); + + params.setFromString(arg); + show(); +} + +void FormToc::updateToc() +{ + if (!lv_->view()->available()) { + toclist.clear(); + dialog_->tree->clear(); + return; + } + + vector< vector > tmp = + lv_->view()->buffer()->getTocList(); + + // Check if all elements are the same. + if (toclist.size() == tmp[type].size()) { + unsigned int i = 0; + for (; i < toclist.size(); ++i) { + if (toclist[i] != tmp[type][i]) + break; + } + if (i >= toclist.size()) + return; + } + + toclist = tmp[type]; + + dialog_->tree->clear(); + + + // FIXME: should do hierarchically. at each point we need to know + // id of item we've just inserted, id of most recent sibling, and + // id of parent + + dialog_->tree->setAutoUpdate(false); + for (vector< Buffer::TocItem >::const_iterator iter = toclist.begin(); + iter != toclist.end(); ++iter) { + dialog_->tree->insertItem((string(4*(*iter).depth,' ')+(*iter).str).c_str(), 0, -1, false); + } + dialog_->tree->setAutoUpdate(true); + dialog_->tree->update(); +} + +void FormToc::setType(Buffer::TocType toctype) +{ + type = toctype; + switch (type) { + case Buffer::TOC_TOC: + dialog_->setCaption(_("Table of Contents")); + break; + case Buffer::TOC_LOF: + dialog_->setCaption(_("List of Figures")); + break; + case Buffer::TOC_LOT: + dialog_->setCaption(_("List of Tables")); + break; + case Buffer::TOC_LOA: + dialog_->setCaption(_("List of Algorithms")); + break; + } +} + +void FormToc::update() +{ + if (params.getCmdName()=="tableofcontents") { + setType(Buffer::TOC_TOC); + dialog_->menu->setCurrentItem(0); + } else if (params.getCmdName()=="listoffigures") { + setType(Buffer::TOC_LOF); + dialog_->menu->setCurrentItem(1); + } else if (params.getCmdName()=="listoftables") { + setType(Buffer::TOC_LOT); + dialog_->menu->setCurrentItem(2); + } else { + setType(Buffer::TOC_LOA); + dialog_->menu->setCurrentItem(3); + } + + updateToc(); +} + +void FormToc::highlight(int index) +{ + if (!lv_->view()->available()) + return; + + // FIXME: frontStrip can go once it's hierarchical + string tmp(frontStrip(dialog_->tree->itemAt(index)->getText(),' ')); + + vector ::const_iterator iter = toclist.begin(); + for (; iter != toclist.end(); ++iter) { + if (iter->str==tmp) + break; + } + + if (iter==toclist.end()) { + lyxerr[Debug::GUI] << "Couldn't find highlighted TOC entry : " << tmp << endl; + return; + } + + lv_->getLyXFunc()->Dispatch(LFUN_GOTO_PARAGRAPH, tostr(iter->par->id()).c_str()); +} + +void FormToc::set_type(Buffer::TocType toctype) +{ + if (toctype==type) + return; + + setType(toctype); + updateToc(); +} + +void FormToc::show() +{ + if (!dialog_) + dialog_ = new FormTocDialog(this, 0, _("LyX: Table of Contents"), false); + + if (!dialog_->isVisible()) { + h_ = d_->hideBufferDependent.connect(slot(this, &FormToc::hide)); + u_ = d_->updateBufferDependent.connect(slot(this, &FormToc::update)); + } + + dialog_->raise(); + dialog_->setActiveWindow(); + + update(); + dialog_->show(); +} + +void FormToc::close() +{ + h_.disconnect(); + u_.disconnect(); + ih_.disconnect(); + inset_ = 0; +} + +void FormToc::hide() +{ + dialog_->hide(); + close(); +} diff --git a/src/frontends/kde/FormToc.h b/src/frontends/kde/FormToc.h new file mode 100644 index 0000000000..04575180fe --- /dev/null +++ b/src/frontends/kde/FormToc.h @@ -0,0 +1,94 @@ +/* FormToc.h + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + */ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef FORMTOC_H +#define FORMTOC_H + +#include "DialogBase.h" +#include "LString.h" +#include "support/utility.hpp" +#include "insets/insetcommand.h" +#include "buffer.h" + +class Dialogs; +class FormTocDialog; + +class FormToc : public DialogBase, public noncopyable { +public: + /**@name Constructors and Destructors */ + //@{ + /// + FormToc(LyXView *, Dialogs *); + /// + ~FormToc(); + //@} + + /// Highlighted an item + void highlight(int index); + /// Choose which type + void set_type(Buffer::TocType type); + /// Update the dialog. + void update(); + /// close the connections + void close(); + +private: + /// Create the dialog if necessary, update it and display it. + void show(); + /// Hide the dialog. + void hide(); + + /// create a Toc inset + void createTOC(string const &); + /// view a Toc inset + void showTOC(InsetCommand * const); + + /// hierarchical tree + int FormToc::doTree(vector < Buffer::TocItem>::const_iterator & , int, int, int); + /// update the Toc + void updateToc(void); + + /// set the type + void setType(Buffer::TocType); + + /// Real GUI implementation. + FormTocDialog * 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; + + /// Hide connection. + Connection h_; + /// Update connection. + Connection u_; + /// Inset hide connection. + Connection ih_; + + /// the toc list + std::vector toclist; + + /// type currently being shown + Buffer::TocType type; +}; + +#endif diff --git a/src/frontends/kde/FormUrl.C b/src/frontends/kde/FormUrl.C index fb0caefd0d..395a14daab 100644 --- a/src/frontends/kde/FormUrl.C +++ b/src/frontends/kde/FormUrl.C @@ -1,7 +1,7 @@ -# /* +/* * FormUrl.C - * (C) 2000 John Levon - * moz@compsoc.man.ac.uk + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk */ /*************************************************************************** @@ -76,14 +76,14 @@ void FormUrl::update() if (readonly) { dialog_->urlname->setFocusPolicy(QWidget::NoFocus); dialog_->url->setFocusPolicy(QWidget::NoFocus); - dialog_->buttonOk->hide(); + dialog_->buttonOk->setEnabled(false); dialog_->buttonCancel->setText(_("Close")); dialog_->htmlurl->setEnabled(false); } else { dialog_->urlname->setFocusPolicy(QWidget::StrongFocus); dialog_->url->setFocusPolicy(QWidget::StrongFocus); dialog_->url->setFocus(); - dialog_->buttonOk->show(); + dialog_->buttonOk->setEnabled(true); dialog_->buttonCancel->setText(_("Cancel")); dialog_->htmlurl->setEnabled(true); } diff --git a/src/frontends/kde/FormUrl.h b/src/frontends/kde/FormUrl.h index a63011d1ad..1e9614e9ce 100644 --- a/src/frontends/kde/FormUrl.h +++ b/src/frontends/kde/FormUrl.h @@ -1,6 +1,6 @@ /* FormUrl.h - * (C) 2000 John Levon - * moz@compsoc.man.ac.uk + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk */ /*************************************************************************** diff --git a/src/frontends/kde/Makefile.am b/src/frontends/kde/Makefile.am index f2ae6f3b82..8f955abb40 100644 --- a/src/frontends/kde/Makefile.am +++ b/src/frontends/kde/Makefile.am @@ -7,20 +7,19 @@ INCLUDES = -I${top_srcdir}/src/ -I${top_srcdir}/src/frontends/ \ # just to make sure, automake makes them BUILTSOURCES = formcopyrightdialog_moc.C \ - formurldialog_moc.C + formurldialog_moc.C \ + formindexdialog_moc.C \ + formcitationdialog_moc.C \ + formtocdialog_moc.C DISTCLEANFILES = $(BUILTSOURCES) *.orig *.rej *~ *.bak core libkde_la_OBJADD = \ - ../xforms/FormCitation.lo \ - ../xforms/form_citation.lo \ ../xforms/FormCommand.lo \ ../xforms/FormDocument.lo \ ../xforms/form_document.lo \ ../xforms/FormGraphics.lo \ ../xforms/form_graphics.lo \ - ../xforms/FormIndex.lo \ - ../xforms/form_index.lo \ ../xforms/FormPreferences.lo \ ../xforms/form_preferences.lo \ ../xforms/FormPrint.lo \ @@ -29,8 +28,6 @@ libkde_la_OBJADD = \ ../xforms/form_ref.lo \ ../xforms/FormTabular.lo \ ../xforms/form_tabular.lo \ - ../xforms/FormToc.lo \ - ../xforms/form_toc.lo \ ../xforms/input_validators.lo \ ../xforms/RadioButtonGroup.lo \ ../xforms/Toolbar_pimpl.lo \ @@ -52,6 +49,18 @@ libkde_la_SOURCES = \ FormUrl.h \ formurldialog.C \ formurldialog.h \ + FormIndex.C \ + FormIndex.h \ + formindexdialog.C \ + formindexdialog.h \ + FormCitation.C \ + FormCitation.h \ + formcitationdialog.C \ + formcitationdialog.h \ + FormToc.C \ + FormToc.h \ + formtocdialog.C \ + formtocdialog.h \ $(BUILTSOURCES) # These still have to be added. Sooner or later. ARRae-20000129 @@ -85,3 +94,15 @@ formcopyrightdialog_moc.C: formcopyrightdialog.h formurldialog.C: formurldialog_moc.C formurldialog_moc.C: formurldialog.h $(MOC) formurldialog.h -o formurldialog_moc.C + +formindexdialog.C: formindexdialog_moc.C +formindexdialog_moc.C: formindexdialog.h + $(MOC) formindexdialog.h -o formindexdialog_moc.C + +formcitationdialog.C: formcitationdialog_moc.C +formcitationdialog_moc.C: formcitationdialog.h + $(MOC) formcitationdialog.h -o formcitationdialog_moc.C + +formtocdialog.C: formtocdialog_moc.C +formtocdialog_moc.C: formtocdialog.h + $(MOC) formtocdialog.h -o formtocdialog_moc.C diff --git a/src/frontends/kde/QtLyXView.h b/src/frontends/kde/QtLyXView.h new file mode 100644 index 0000000000..d9081cbcc9 --- /dev/null +++ b/src/frontends/kde/QtLyXView.h @@ -0,0 +1,12 @@ +/* + * QtLyXView.h + * (C) 2000 LyX Team + * moz@compsoc.man.ac.uk + */ + +/* Qt 1.x has a messy namespace which conflicts with 'emit' in + * src/Timeout.h. This can go away when Qt 2.x happens. + */ + +#undef emit +#include "LyXView.h" diff --git a/src/frontends/kde/formcitationdialog.C b/src/frontends/kde/formcitationdialog.C new file mode 100644 index 0000000000..5002b09d3d --- /dev/null +++ b/src/frontends/kde/formcitationdialog.C @@ -0,0 +1,173 @@ +/* + * formcitationdialog.C + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + */ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "formcitationdialog.h" + +FormCitationDialog::FormCitationDialog(FormCitation *form, QWidget *parent, const char *name, bool, WFlags) + : QDialog(parent,name,false), form_(form) +{ + setCaption(name); + setMinimumWidth(500); + + // widgets + + labelchosen = new QLabel(this); + labelchosen->setText(_("Selected keys")); + labelchosen->setMinimumSize(labelchosen->sizeHint()); + labelchosen->setMaximumSize(labelchosen->sizeHint()); + + chosen = new QListBox(this); + + labelkeys = new QLabel(this); + labelkeys->setText(_("Available keys")); + labelkeys->setMinimumSize(labelkeys->sizeHint()); + labelkeys->setMaximumSize(labelkeys->sizeHint()); + + keys = new QListBox(this); + + labelentry = new QLabel(this); + labelentry->setText(_("Reference entry")); + labelentry->setMinimumSize(labelentry->sizeHint()); + labelentry->setMaximumSize(labelentry->sizeHint()); + + after = new QLineEdit(this); + after->setMinimumSize(after->sizeHint()); + + entry = new QMultiLineEdit(this); + entry->setReadOnly(true); + entry->setFixedVisibleLines(2); + + labelafter = new QLabel(this); + labelafter->setText(_("Text after")); + labelafter->setMargin(5); + labelafter->setMinimumSize(labelafter->sizeHint()); + labelafter->setMaximumSize(labelafter->sizeHint()); + + /* FIXME: icons */ + add = new QPushButton(this); + add->setText(_("&Add")); + add->setMinimumSize(add->sizeHint()); + add->setMaximumSize(add->sizeHint()); + + up = new QPushButton(this); + up->setText(_("&Up")); + up->setMinimumSize(up->sizeHint()); + up->setMaximumSize(up->sizeHint()); + + down = new QPushButton(this); + down->setText(_("&Down")); + down->setMinimumSize(down->sizeHint()); + down->setMaximumSize(down->sizeHint()); + + remove = new QPushButton(this); + remove->setText(_("&Remove")); + remove->setMinimumSize(remove->sizeHint()); + remove->setMaximumSize(remove->sizeHint()); + + buttonOk = new QPushButton(this); + buttonOk->setText(_("&OK")); + buttonOk->setDefault(true); + buttonOk->setMinimumSize(buttonOk->sizeHint()); + buttonOk->setMaximumSize(buttonOk->sizeHint()); + + buttonCancel = new QPushButton(this); + buttonCancel->setText(_("&Cancel")); + buttonCancel->setMinimumSize(buttonCancel->sizeHint()); + buttonCancel->setMaximumSize(buttonCancel->sizeHint()); + + // tooltips + + QToolTip::add(chosen,_("Keys currently selected")); + QToolTip::add(keys,_("Reference keys available")); + QToolTip::add(entry,_("Reference entry text")); + QToolTip::add(after,_("Text to place after citation")); + + // layouts + + topLayout = new QHBoxLayout(this,10); + + layout = new QVBoxLayout(); + topLayout->addLayout(layout); + layout->addSpacing(10); + + browserLayout = new QHBoxLayout(); + layout->addLayout(browserLayout,1); + + chosenLayout = new QVBoxLayout(); + browserLayout->addLayout(chosenLayout,1); + iconLayout = new QVBoxLayout(); + browserLayout->addLayout(iconLayout,0); + keysLayout = new QVBoxLayout(); + browserLayout->addLayout(keysLayout,1); + + chosenLayout->addWidget(labelchosen, 0, AlignLeft); + chosenLayout->addWidget(chosen, 1); + + iconLayout->addStretch(1); + iconLayout->addWidget(add,1); + iconLayout->addStretch(1); + iconLayout->addWidget(up,1); + iconLayout->addStretch(1); + iconLayout->addWidget(down,1); + iconLayout->addStretch(1); + iconLayout->addWidget(remove,1); + iconLayout->addStretch(1); + + keysLayout->addWidget(labelkeys, 0, AlignLeft); + keysLayout->addWidget(keys, 1); + + entryLayout = new QVBoxLayout(); + layout->addLayout(entryLayout); + + entryLayout->addWidget(labelentry, 0, AlignLeft); + entryLayout->addWidget(entry, 0); + + afterLayout = new QHBoxLayout(); + layout->addLayout(afterLayout); + + afterLayout->addWidget(labelafter, 0, AlignLeft); + afterLayout->addWidget(after, 1); + + buttonLayout = new QHBoxLayout(); + layout->addLayout(buttonLayout); + + buttonLayout->addStretch(1); + buttonLayout->addWidget(buttonOk, 1); + buttonLayout->addStretch(2); + buttonLayout->addWidget(buttonCancel, 1); + buttonLayout->addStretch(1); + + // connections + + connect(keys, SIGNAL(selected(const char *)), this, SLOT(select_key_adaptor(const char *))); + connect(keys, SIGNAL(highlighted(const char *)), this, SLOT(highlight_key_adaptor(const char *))); + connect(chosen, SIGNAL(highlighted(const char *)), this, SLOT(highlight_chosen_adaptor(const char *))); + connect(add, SIGNAL(clicked()), this, SLOT(add_adaptor())); + connect(up, SIGNAL(clicked()), this, SLOT(up_adaptor())); + connect(down, SIGNAL(clicked()), this, SLOT(down_adaptor())); + connect(remove, SIGNAL(clicked()), this, SLOT(remove_adaptor())); + connect(buttonOk, SIGNAL(clicked()), this, SLOT(apply_adaptor())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(close_adaptor())); +} + +void FormCitationDialog::closeEvent(QCloseEvent *e) +{ + form_->close(); + e->accept(); +} + +FormCitationDialog::~FormCitationDialog() +{ +} diff --git a/src/frontends/kde/formcitationdialog.h b/src/frontends/kde/formcitationdialog.h new file mode 100644 index 0000000000..0d1150a0e3 --- /dev/null +++ b/src/frontends/kde/formcitationdialog.h @@ -0,0 +1,118 @@ +/* + * formcitationdialog.h + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + */ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef FORMCITATIONDIALOG_H +#define FORMCITATIONDIALOG_H + +#include +#include + +// to connect apply() and hide() +#include "FormCitation.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +class FormCitationDialog : public QDialog { + Q_OBJECT +public: + FormCitationDialog(FormCitation *form, QWidget *parent=0, const char *name=0, + bool modal=false, WFlags f=0); + ~FormCitationDialog(); + + // widgets + + QLabel *labelchosen; + QListBox *chosen; + QLabel *labelkeys; + QListBox *keys; + QLabel *labelentry; + QMultiLineEdit *entry; + QLabel *labelafter; + QLineEdit *after; + QPushButton *add; + QPushButton *up; + QPushButton *down; + QPushButton *remove; + QPushButton *buttonOk; + QPushButton *buttonCancel; + +protected: + void closeEvent(QCloseEvent *e); + +private: + FormCitation *form_; + + // layouts + + QHBoxLayout *topLayout; + QVBoxLayout *layout; + QHBoxLayout *browserLayout; + QVBoxLayout *chosenLayout; + QVBoxLayout *iconLayout; + QVBoxLayout *keysLayout; + QVBoxLayout *entryLayout; + QHBoxLayout *afterLayout; + QHBoxLayout *buttonLayout; + +private slots: + void apply_adaptor(void) { + form_->apply(); + form_->close(); + hide(); + } + + void close_adaptor(void) { + form_->close(); + hide(); + } + + void add_adaptor(void) { + form_->add(); + } + + void up_adaptor(void) { + form_->up(); + } + + void down_adaptor(void) { + form_->down(); + } + + void remove_adaptor(void) { + form_->remove(); + } + + void select_key_adaptor(const char *key) { + form_->select_key(key); + } + + void highlight_key_adaptor(const char *key) { + form_->highlight_key(key); + } + + void highlight_chosen_adaptor(const char *key) { + form_->highlight_chosen(key); + } + +}; + +#endif diff --git a/src/frontends/kde/formindexdialog.C b/src/frontends/kde/formindexdialog.C new file mode 100644 index 0000000000..24a20c07da --- /dev/null +++ b/src/frontends/kde/formindexdialog.C @@ -0,0 +1,88 @@ +/* + * formindexdialog.C + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + */ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "formindexdialog.h" + +FormIndexDialog::FormIndexDialog(FormIndex *form, QWidget *parent, const char *name, bool, WFlags) + : QDialog(parent,name,false), form_(form) +{ + setCaption(name); + + // widgets + + index = new QLineEdit(this); + index->setMinimumSize(index->sizeHint()); + + labelindex = new QLabel(this); + labelindex->setText(_("Keyword :")); + labelindex->setMargin(5); + labelindex->setMinimumSize(labelindex->sizeHint()); + labelindex->setMaximumSize(labelindex->sizeHint()); + + buttonOk = new QPushButton(this); + buttonOk->setMinimumSize(buttonOk->sizeHint()); + buttonOk->setMaximumSize(buttonOk->sizeHint()); + buttonOk->setText(_("&OK")); + buttonOk->setDefault(true); + + buttonCancel = new QPushButton(this); + buttonCancel->setMinimumSize(buttonCancel->sizeHint()); + buttonCancel->setMaximumSize(buttonCancel->sizeHint()); + buttonCancel->setText(_("&Cancel")); + + // tooltips + + QToolTip::add(labelindex,_("Index entry")); + QToolTip::add(index,_("Index entry")); + + // layouts + + topLayout = new QHBoxLayout(this,10); + + layout = new QVBoxLayout(); + topLayout->addLayout(layout); + layout->addSpacing(10); + + indexLayout = new QHBoxLayout(); + layout->addLayout(indexLayout); + indexLayout->addWidget(labelindex, 0); + indexLayout->addWidget(index, 1); + + layout->addStretch(1); + + buttonLayout = new QHBoxLayout(); + + layout->addLayout(buttonLayout); + buttonLayout->addStretch(1); + buttonLayout->addWidget(buttonOk, 1); + buttonLayout->addStretch(2); + buttonLayout->addWidget(buttonCancel, 1); + buttonLayout->addStretch(1); + + // connections + + connect(buttonOk, SIGNAL(clicked()), this, SLOT(apply_adaptor())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(close_adaptor())); +} + +void FormIndexDialog::closeEvent(QCloseEvent *e) +{ + form_->close(); + e->accept(); +} + +FormIndexDialog::~FormIndexDialog() +{ +} diff --git a/src/frontends/kde/formindexdialog.h b/src/frontends/kde/formindexdialog.h new file mode 100644 index 0000000000..0e45829683 --- /dev/null +++ b/src/frontends/kde/formindexdialog.h @@ -0,0 +1,75 @@ +/* + * formindexdialog.h + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + */ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef FORMINDEXDIALOG_H +#define FORMINDEXDIALOG_H + +#include +#include + +// to connect apply() and hide() +#include "FormIndex.h" + +#include +#include +#include +#include +#include +#include + +class FormIndexDialog : public QDialog { + Q_OBJECT +public: + FormIndexDialog(FormIndex *form, QWidget *parent=0, const char *name=0, + bool modal=false, WFlags f=0); + ~FormIndexDialog(); + + // widgets + + QLabel *labelindex; + QLineEdit *index; + QPushButton *buttonOk; + QPushButton *buttonCancel; + + +protected: + void closeEvent(QCloseEvent *e); + +private: + FormIndex *form_; + + // layouts + + QHBoxLayout *topLayout; + QVBoxLayout *layout; + QHBoxLayout *indexLayout; + QHBoxLayout *buttonLayout; + +private slots: + /// adaptor to FormIndex::apply + void apply_adaptor(void) { + form_->apply(); + form_->close(); + hide(); + } + + /// adaptor to FormIndex::close + void close_adaptor(void) { + form_->close(); + hide(); + } +}; + +#endif diff --git a/src/frontends/kde/formtocdialog.C b/src/frontends/kde/formtocdialog.C new file mode 100644 index 0000000000..45b73f02c8 --- /dev/null +++ b/src/frontends/kde/formtocdialog.C @@ -0,0 +1,83 @@ +/* + * formtocdialog.C + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + */ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "formtocdialog.h" + +FormTocDialog::FormTocDialog(FormToc *form, QWidget *parent, const char *name, bool, WFlags) + : QDialog(parent,name,false), form_(form) +{ + setCaption(name); + setMinimumWidth(350); + + // widgets + + menu = new QComboBox(this); + menu->insertItem(_("Table of Contents")); + menu->insertItem(_("List of Figures")); + menu->insertItem(_("List of Tables")); + menu->insertItem(_("List of Algorithms")); + menu->setMinimumSize(menu->sizeHint()); + + tree = new KTreeList(this,"tree"); + tree->setMinimumHeight(200); + + buttonUpdate = new QPushButton(this); + buttonUpdate->setMinimumSize(buttonUpdate->sizeHint()); + buttonUpdate->setMaximumSize(buttonUpdate->sizeHint()); + buttonUpdate->setText(_("&Update")); + + buttonClose = new QPushButton(this); + buttonClose->setMinimumSize(buttonClose->sizeHint()); + buttonClose->setMaximumSize(buttonClose->sizeHint()); + buttonClose->setText(_("&Close")); + buttonClose->setDefault(true); + + // layouts + + topLayout = new QHBoxLayout(this,10); + + layout = new QVBoxLayout(); + topLayout->addLayout(layout); + layout->addSpacing(10); + + layout->addWidget(menu,0); + layout->addWidget(tree,1); + + buttonLayout = new QHBoxLayout(); + + layout->addLayout(buttonLayout); + buttonLayout->addStretch(1); + buttonLayout->addWidget(buttonUpdate, 1); + buttonLayout->addStretch(2); + buttonLayout->addWidget(buttonClose, 1); + buttonLayout->addStretch(1); + + // connections + + connect(tree, SIGNAL(highlighted(int)), this, SLOT(highlight_adaptor(int))); + connect(menu, SIGNAL(activated(int)), this, SLOT(activate_adaptor(int))); + connect(buttonUpdate, SIGNAL(clicked()), this, SLOT(update_adaptor())); + connect(buttonClose, SIGNAL(clicked()), this, SLOT(close_adaptor())); +} + +void FormTocDialog::closeEvent(QCloseEvent *e) +{ + form_->close(); + e->accept(); +} + +FormTocDialog::~FormTocDialog() +{ +} diff --git a/src/frontends/kde/formtocdialog.h b/src/frontends/kde/formtocdialog.h new file mode 100644 index 0000000000..3cd196df0f --- /dev/null +++ b/src/frontends/kde/formtocdialog.h @@ -0,0 +1,97 @@ +/* + * formtocdialog.h + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + */ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef FORMTOCDIALOG_H +#define FORMTOCDIALOG_H + +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include "FormToc.h" + +class FormTocDialog : public QDialog { + Q_OBJECT +public: + FormTocDialog(FormToc *form, QWidget *parent=0, const char *name=0, + bool modal=false, WFlags f=0); + ~FormTocDialog(); + + // widgets + + QComboBox *menu; + KTreeList *tree; + QPushButton *buttonUpdate; + QPushButton *buttonClose; + +protected: + void closeEvent(QCloseEvent *e); + +private: + FormToc *form_; + + // layouts + + QHBoxLayout *topLayout; + QVBoxLayout *layout; + QHBoxLayout *buttonLayout; + +private slots: + /// adaptor to FormToc::highlight + void highlight_adaptor(int index) { + form_->highlight(index); + } + + /// adaptor to FormToc::update + void update_adaptor(void) { + form_->update(); + } + + // adaptors to FormToc::set_type + void activate_adaptor(int index) { + switch (index) { + case 0: + form_->set_type(Buffer::TOC_TOC); + break; + case 1: + form_->set_type(Buffer::TOC_LOF); + break; + case 2: + form_->set_type(Buffer::TOC_LOT); + break; + case 3: + form_->set_type(Buffer::TOC_LOA); + break; + default: + lyxerr[Debug::GUI] << "Unknown TOC combo selection." << endl; + break; + } + } + + /// adaptor to FormToc::close + void close_adaptor(void) { + form_->close(); + hide(); + } +}; + +#endif diff --git a/src/frontends/kde/formurldialog.C b/src/frontends/kde/formurldialog.C index 5459772f93..609d2b21ad 100644 --- a/src/frontends/kde/formurldialog.C +++ b/src/frontends/kde/formurldialog.C @@ -1,7 +1,7 @@ /* * formurldialog.C - * (C) 2000 John Levon - * moz@compsoc.man.ac.uk + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk */ /*************************************************************************** @@ -48,13 +48,13 @@ FormUrlDialog::FormUrlDialog(FormUrl *form, QWidget *parent, const char *name, b buttonOk = new QPushButton(this); buttonOk->setMinimumSize(buttonOk->sizeHint()); buttonOk->setMaximumSize(buttonOk->sizeHint()); - buttonOk->setText(_("OK")); + buttonOk->setText(_("&OK")); buttonOk->setDefault(true); buttonCancel = new QPushButton(this); buttonCancel->setMinimumSize(buttonCancel->sizeHint()); buttonCancel->setMaximumSize(buttonCancel->sizeHint()); - buttonCancel->setText(_("Cancel")); + buttonCancel->setText(_("&Cancel")); // tooltips @@ -99,8 +99,8 @@ FormUrlDialog::FormUrlDialog(FormUrl *form, QWidget *parent, const char *name, b // connections - connect(buttonOk, SIGNAL(clicked()), this, SLOT(apply_gate())); - connect(buttonCancel, SIGNAL(clicked()), this, SLOT(close_gate())); + connect(buttonOk, SIGNAL(clicked()), this, SLOT(apply_adaptor())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(close_adaptor())); } void FormUrlDialog::closeEvent(QCloseEvent *e) diff --git a/src/frontends/kde/formurldialog.h b/src/frontends/kde/formurldialog.h index 3d1219054e..e67321b9fc 100644 --- a/src/frontends/kde/formurldialog.h +++ b/src/frontends/kde/formurldialog.h @@ -1,7 +1,7 @@ /* * formurldialog.h - * (C) 2000 John Levon - * moz@compsoc.man.ac.uk + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk */ /*************************************************************************** @@ -63,15 +63,15 @@ private: QHBoxLayout *buttonLayout; private slots: - /// gate to FormUrl::apply - void apply_gate(void) { + /// adaptor to FormUrl::apply + void apply_adaptor(void) { form_->apply(); form_->close(); hide(); } - /// gate to FormUrl::close - void close_gate(void) { + /// adaptor to FormUrl::close + void close_adaptor(void) { form_->close(); hide(); } diff --git a/src/frontends/xforms/GUIRunTime.C b/src/frontends/xforms/GUIRunTime.C index 7474250843..8e0dc35155 100644 --- a/src/frontends/xforms/GUIRunTime.C +++ b/src/frontends/xforms/GUIRunTime.C @@ -31,7 +31,7 @@ extern bool finished; static int const xforms_include_version = FL_INCLUDE_VERSION; -int GUIRunTime::initApplication(int argc, char * argv[]) +int GUIRunTime::initApplication(int , char **) { // Check the XForms version in the forms.h header against // the one in the libforms. If they don't match quit the -- 2.39.2