New inset dialog for InsetPrintIndex (only used with multiple indices)..

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29290 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2009-04-17 14:29:32 +00:00
parent 5c90e41382
commit d12426a340
14 changed files with 346 additions and 18 deletions

View File

@ -742,6 +742,7 @@ src_frontends_qt4_header_files = Split('''
GuiPhantom.h
GuiPrefs.h
GuiPrint.h
GuiPrintindex.h
GuiRef.h
GuiSearch.h
GuiSelection.h
@ -836,6 +837,7 @@ src_frontends_qt4_files = Split('''
GuiPhantom.cpp
GuiPrefs.cpp
GuiPrint.cpp
GuiPrintindex.cpp
GuiRef.cpp
GuiSearch.cpp
GuiSelection.cpp
@ -947,6 +949,7 @@ src_frontends_qt4_ui_files = Split('''
PrefUi.ui
PrefsUi.ui
PrintUi.ui
PrintindexUi.ui
RefUi.ui
SearchUi.ui
SendtoUi.ui

View File

@ -490,6 +490,8 @@ Menuset
Menu "context-indexprint"
IndicesListsContext
Separator
OptItem "Settings...|S" "inset-settings"
End
End

View File

@ -123,7 +123,8 @@ Menuset
OptItem "Phantom Settings...|h" "inset-settings phantom"
OptItem "Branch Settings...|B" "inset-settings branch"
OptItem "Box Settings...|x" "inset-settings box"
OptItem "Index Entry Settings...|C" "inset-settings inset"
OptItem "Index Entry Settings...|C" "inset-settings index"
OptItem "Index Settings...|C" "inset-settings index_print"
OptItem "Listings Settings...|g" "inset-settings listings"
# Hey, guess what's broken ? Surprise surprise, it's tabular stuff
# This is in the Table submenu instead for now.

View File

@ -2246,12 +2246,12 @@ void LyXAction::init()
* \var lyx::FuncCode lyx::LFUN_INSET_SETTINGS
* \li Action: Open the inset's properties dialog.
* \li Notion: Used for bibitem, bibtex, box, branch, citation, ert, external,
* float, graphics, href, include, index, label, listings, note, phantom,
* ref, space, tabular, vspace, wrap insets.
* float, graphics, href, include, index, index_print, label, listings,
* note, phantom, ref, space, tabular, vspace, wrap insets.
* \li Syntax: inset-settings <INSET>
* \li Params: <INSET>: <bibitem|bibtex|box|branch|citation|ert|external|float|
* graphics|href|include|index|label|listings|note|phantom|ref|
* space|tabular|vspace|wrap>.
* graphics|href|include|index|index_print|label|listings|
* note|phantom|ref|space|tabular|vspace|wrap>.
* \endvar
*/
{ LFUN_INSET_SETTINGS, "inset-settings", ReadOnly | AtPoint, Edit },

View File

@ -2017,6 +2017,8 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
code = INCLUDE_CODE;
else if (cmd.argument() == "index")
code = INDEX_CODE;
else if (cmd.argument() == "index_print")
code = INDEX_PRINT_CODE;
else if (cmd.argument() == "nomenclature")
code = NOMENCL_CODE;
else if (cmd.argument() == "label")

View File

@ -301,7 +301,7 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
case NOMENCL_CODE: {
InsetCommandParams icp(code);
InsetCommand::string2params(name, lyx::to_utf8(cmd.argument()), icp);
InsetCommand::string2params(name, to_utf8(cmd.argument()), icp);
return new InsetNomencl(icp);
}

View File

@ -0,0 +1,113 @@
/**
* \file GuiPrintindex.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Angus Leeming
* \author Martin Vermeer
* \author Jürgen Spitzmüller
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "GuiPrintindex.h"
#include "qt_helpers.h"
#include "Buffer.h"
#include "BufferParams.h"
#include "FuncRequest.h"
#include "IndicesList.h"
#include "insets/InsetCommand.h"
#include <QPushButton>
using namespace std;
namespace lyx {
namespace frontend {
GuiPrintindex::GuiPrintindex(GuiView & lv)
: GuiDialog(lv, "index_print", qt_("Index Settings")),
params_(insetCode("index_print"))
{
setupUi(this);
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(cancelPB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(indicesCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(okPB);
bc().setCancel(cancelPB);
}
void GuiPrintindex::change_adaptor()
{
changed();
}
void GuiPrintindex::updateContents()
{
typedef IndicesList::const_iterator const_iterator;
IndicesList const & indiceslist = buffer().params().indiceslist();
docstring const cur_index = params_["type"];
indicesCO->clear();
const_iterator const begin = indiceslist.begin();
const_iterator const end = indiceslist.end();
for (const_iterator it = begin; it != end; ++it)
indicesCO->addItem(toqstr(it->index()),
QVariant(toqstr(it->shortcut())));
int const pos = indicesCO->findData(toqstr(cur_index));
indicesCO->setCurrentIndex(pos);
}
void GuiPrintindex::applyView()
{
QString const index = indicesCO->itemData(
indicesCO->currentIndex()).toString();
params_["type"] = qstring_to_ucs4(index);
}
void GuiPrintindex::paramsToDialog(InsetCommandParams const & /*icp*/)
{
int const pos = indicesCO->findData(toqstr(params_["type"]));
indicesCO->setCurrentIndex(pos);
bc().setValid(isValid());
}
bool GuiPrintindex::initialiseParams(string const & data)
{
// The name passed with LFUN_INSET_APPLY is also the name
// used to identify the mailer.
InsetCommand::string2params("index_print", data, params_);
return true;
}
void GuiPrintindex::dispatchParams()
{
std::string const lfun = InsetCommand::params2string("index_print", params_);
dispatch(FuncRequest(getLfun(), lfun));
}
Dialog * createGuiPrintindex(GuiView & lv) { return new GuiPrintindex(lv); }
} // namespace frontend
} // namespace lyx
#include "moc_GuiPrintindex.cpp"

View File

@ -0,0 +1,58 @@
// -*- C++ -*-
/**
* \file GuiPrintindex.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Angus Leeming
* \author Martin Vermeer
* \author Jürgen Spitzmüller
*
* Full author contact details are available in file CREDITS.
*/
#ifndef GUIPRINTINDEX_H
#define GUIPRINTINDEX_H
#include "GuiDialog.h"
#include "ui_PrintindexUi.h"
#include "insets/InsetCommandParams.h"
namespace lyx {
namespace frontend {
class GuiPrintindex : public GuiDialog, public Ui::PrintindexUi
{
Q_OBJECT
public:
GuiPrintindex(GuiView & lv);
private Q_SLOTS:
void change_adaptor();
private:
/// Apply changes
void applyView();
/// Update dialog before showing it
void updateContents();
///
void paramsToDialog(InsetCommandParams const & icp);
///
bool initialiseParams(std::string const & data);
/// clean-up on hide.
void clearParams() { params_.clear(); }
///
void dispatchParams();
///
bool isBufferDependent() const { return true; }
///
InsetCommandParams params_;
};
} // namespace frontend
} // namespace lyx
#endif // GUIPRINTINDEX_H

View File

@ -2392,8 +2392,8 @@ namespace {
char const * const dialognames[] = {
"aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
"citation", "document", "errorlist", "ert", "external", "file", "findreplace",
"float", "graphics", "include", "index", "info", "nomenclature", "label",
"log", "mathdelimiter", "mathmatrix", "mathspace", "note", "paragraph",
"float", "graphics", "include", "index", "index_print", "info", "nomenclature",
"label", "log", "mathdelimiter", "mathmatrix", "mathspace", "note", "paragraph",
"phantom", "prefs", "print", "ref", "sendto", "space", "spellchecker",
"symbols", "tabular", "tabularcreate",
@ -2589,6 +2589,7 @@ Dialog * createGuiParagraph(GuiView & lv);
Dialog * createGuiPhantom(GuiView & lv);
Dialog * createGuiPreferences(GuiView & lv);
Dialog * createGuiPrint(GuiView & lv);
Dialog * createGuiPrintindex(GuiView & lv);
Dialog * createGuiRef(GuiView & lv);
Dialog * createGuiSearch(GuiView & lv);
Dialog * createGuiSearchAdv(GuiView & lv);
@ -2698,6 +2699,8 @@ Dialog * GuiView::build(string const & name)
#endif
if (name == "href")
return createGuiHyperlink(*this);
if (name == "index_print")
return createGuiPrintindex(*this);
if (name == "listings")
return createGuiListings(*this);
if (name == "toc")

View File

@ -105,6 +105,7 @@ SOURCEFILES = \
GuiPhantom.cpp \
GuiPrefs.cpp \
GuiPrint.cpp \
GuiPrintindex.cpp \
GuiRef.cpp \
GuiSearch.cpp \
GuiSelection.cpp \
@ -201,6 +202,7 @@ MOCHEADER = \
GuiPhantom.h \
GuiPrefs.h \
GuiPrint.h \
GuiPrintindex.h \
GuiRef.h \
GuiSearch.h \
GuiSelection.h \
@ -299,6 +301,7 @@ UIFILES = \
PrefsUi.ui \
PrefUi.ui \
PrintUi.ui \
PrintindexUi.ui \
RefUi.ui \
SearchUi.ui \
SendtoUi.ui \

View File

@ -0,0 +1,97 @@
<ui version="4.0" >
<class>PrintindexUi</class>
<widget class="QDialog" name="PrintindexUi" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>262</width>
<height>108</height>
</rect>
</property>
<property name="windowTitle" >
<string/>
</property>
<property name="sizeGripEnabled" >
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>71</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1" >
<widget class="QPushButton" name="okPB" >
<property name="text" >
<string>&amp;OK</string>
</property>
<property name="default" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3" >
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="indicesLA" >
<property name="text" >
<string>A&amp;vailable indices:</string>
</property>
<property name="buddy" >
<cstring>indicesCO</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="indicesCO" >
<property name="toolTip" >
<string>Select the index this entry should be listed in.</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="2" >
<widget class="QPushButton" name="cancelPB" >
<property name="text" >
<string>&amp;Cancel</string>
</property>
<property name="default" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>indicesCO</tabstop>
<tabstop>okPB</tabstop>
<tabstop>cancelPB</tabstop>
</tabstops>
<includes>
<include location="local" >qt_i18n.h</include>
</includes>
<resources/>
<connections/>
</ui>

View File

@ -55,7 +55,7 @@ static ParamInfo const & findInfo(InsetCode code, string const & cmdName)
case BIBTEX_CODE:
return InsetBibtex::findInfo(cmdName);
case CITE_CODE:
return InsetCitation::findInfo(cmdName);
return InsetCitation::findInfo(cmdName);
case FLOAT_LIST_CODE:
return InsetFloatList::findInfo(cmdName);
case HYPERLINK_CODE:
@ -65,7 +65,7 @@ static ParamInfo const & findInfo(InsetCode code, string const & cmdName)
case INDEX_PRINT_CODE:
return InsetPrintIndex::findInfo(cmdName);
case LABEL_CODE:
return InsetLabel::findInfo(cmdName);
return InsetLabel::findInfo(cmdName);
case NOMENCL_CODE:
return InsetNomencl::findInfo(cmdName);
case NOMENCL_PRINT_CODE:

View File

@ -400,21 +400,57 @@ docstring InsetPrintIndex::screenLabel() const
}
void InsetPrintIndex::doDispatch(Cursor & cur, FuncRequest & cmd)
{
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
InsetCommandParams p(INDEX_PRINT_CODE);
// FIXME UNICODE
InsetCommand::string2params("index_print",
to_utf8(cmd.argument()), p);
if (p.getCmdName().empty()) {
cur.noUpdate();
break;
}
setParam("type", p["type"]);
break;
}
default:
InsetCommand::doDispatch(cur, cmd);
break;
}
}
bool InsetPrintIndex::getStatus(Cursor & cur, FuncRequest const & cmd,
FuncStatus & status) const
{
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
InsetCommandParams p(INDEX_PRINT_CODE);
InsetCommand::string2params("index_print", to_utf8(cmd.argument()), p);
if (cmd.getArg(0) == "index_print"
&& cmd.getArg(1) == "InsetCommand") {
InsetCommandParams p(INDEX_PRINT_CODE);
InsetCommand::string2params("index_print",
to_utf8(cmd.argument()), p);
Buffer const & realbuffer = *buffer().masterBuffer();
IndicesList const & indiceslist =
realbuffer.params().indiceslist();
Index const * index = indiceslist.findShortcut(p["type"]);
status.setEnabled(index != 0);
status.setOnOff(p["type"] == getParam("type"));
return true;
}
}
case LFUN_INSET_DIALOG_UPDATE:
case LFUN_INSET_SETTINGS: {
Buffer const & realbuffer = *buffer().masterBuffer();
IndicesList const & indiceslist = realbuffer.params().indiceslist();
Index const * index = indiceslist.findShortcut(p["type"]);
status.setEnabled(index != 0);
status.setOnOff(p["type"] == getParam("type"));
status.setEnabled(realbuffer.params().use_indices);
return true;
}
}
default:
return InsetCommand::getStatus(cur, cmd, status);
@ -448,4 +484,12 @@ docstring InsetPrintIndex::contextMenu(BufferView const &, int, int) const
from_ascii("context-indexprint") : docstring();
}
Inset::EDITABLE InsetPrintIndex::editable() const
{
return buffer().masterBuffer()->params().use_indices ?
IS_EDITABLE : NOT_EDITABLE;
}
} // namespace lyx

View File

@ -103,6 +103,8 @@ public:
///
int latex(odocstream &, OutputParams const &) const;
///
void doDispatch(Cursor & cur, FuncRequest & cmd);
///
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
///
virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
@ -110,7 +112,7 @@ private:
/// Updates needed features for this inset.
void validate(LaTeXFeatures & features) const;
///
EDITABLE editable() const { return NOT_EDITABLE; }
EDITABLE editable() const;
///
DisplayType display() const { return AlignCenter; }
///