mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
frontend cosmetics
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23516 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1e4f5ba47c
commit
e8f16a9bcb
@ -135,7 +135,7 @@ bool GuiToc::initialiseParams(string const & data)
|
|||||||
{
|
{
|
||||||
LYXERR(Debug::GUI, data);
|
LYXERR(Debug::GUI, data);
|
||||||
QString str = QString::fromUtf8(data.c_str());
|
QString str = QString::fromUtf8(data.c_str());
|
||||||
string new_type;
|
QString new_type;
|
||||||
if (str.contains("tableofcontents"))
|
if (str.contains("tableofcontents"))
|
||||||
new_type = "tableofcontents";
|
new_type = "tableofcontents";
|
||||||
else if (str.contains("floatlist")) {
|
else if (str.contains("floatlist")) {
|
||||||
@ -154,13 +154,13 @@ bool GuiToc::initialiseParams(string const & data)
|
|||||||
TocList::const_iterator it = tocs.begin();
|
TocList::const_iterator it = tocs.begin();
|
||||||
TocList::const_iterator end = tocs.end();
|
TocList::const_iterator end = tocs.end();
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
types_.push_back(it->first);
|
types_.push_back(toqstr(it->first));
|
||||||
type_names_.push_back(guiName(it->first));
|
type_names_.push_back(toqstr(guiName(it->first)));
|
||||||
toc_models_.push_back(new TocModel(it->second));
|
toc_models_.push_back(new TocModel(it->second));
|
||||||
}
|
}
|
||||||
|
|
||||||
int selected_type = -1;
|
int selected_type = -1;
|
||||||
for (size_t i = 0; i != types_.size(); ++i) {
|
for (int i = 0; i != types_.size(); ++i) {
|
||||||
if (new_type == types_[i]) {
|
if (new_type == types_[i]) {
|
||||||
selected_type = i;
|
selected_type = i;
|
||||||
break;
|
break;
|
||||||
@ -213,7 +213,7 @@ TocIterator GuiToc::currentTocItem(int type) const
|
|||||||
{
|
{
|
||||||
BOOST_ASSERT(bufferview());
|
BOOST_ASSERT(bufferview());
|
||||||
ParConstIterator it(bufferview()->cursor());
|
ParConstIterator it(bufferview()->cursor());
|
||||||
return buffer().masterBuffer()->tocBackend().item(types_[type], it);
|
return buffer().masterBuffer()->tocBackend().item(fromqstr(types_[type]), it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,9 +21,7 @@
|
|||||||
|
|
||||||
#include "TocBackend.h"
|
#include "TocBackend.h"
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QStringListModel>
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -80,8 +78,7 @@ public:
|
|||||||
TocList const & tocs() const;
|
TocList const & tocs() const;
|
||||||
|
|
||||||
/// Return the list of types available
|
/// Return the list of types available
|
||||||
std::vector<docstring> const & typeNames() const
|
QStringList const & typeNames() const { return type_names_; }
|
||||||
{ return type_names_; }
|
|
||||||
|
|
||||||
/// Return the first TocItem before the cursor
|
/// Return the first TocItem before the cursor
|
||||||
TocIterator currentTocItem(int type) const;
|
TocIterator currentTocItem(int type) const;
|
||||||
@ -97,9 +94,6 @@ public:
|
|||||||
///
|
///
|
||||||
void updateBackend();
|
void updateBackend();
|
||||||
|
|
||||||
std::vector<std::string> types_;
|
|
||||||
std::vector<docstring> type_names_;
|
|
||||||
|
|
||||||
/// Return the guiname from a given cmdName of the TOC param
|
/// Return the guiname from a given cmdName of the TOC param
|
||||||
docstring guiName(std::string const & type) const;
|
docstring guiName(std::string const & type) const;
|
||||||
|
|
||||||
@ -109,6 +103,11 @@ public:
|
|||||||
void dispatchParams();
|
void dispatchParams();
|
||||||
///
|
///
|
||||||
bool isBufferDependent() const { return true; }
|
bool isBufferDependent() const { return true; }
|
||||||
|
|
||||||
|
///
|
||||||
|
QStringList types_;
|
||||||
|
///
|
||||||
|
QStringList type_names_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
@ -213,8 +213,8 @@ void TocWidget::updateView()
|
|||||||
|
|
||||||
void TocWidget::updateGui(int selected_type)
|
void TocWidget::updateGui(int selected_type)
|
||||||
{
|
{
|
||||||
vector<docstring> const & type_names = form_.typeNames();
|
QStringList const & type_names = form_.typeNames();
|
||||||
if (type_names.empty()) {
|
if (type_names.isEmpty()) {
|
||||||
enableControls(false);
|
enableControls(false);
|
||||||
typeCO->clear();
|
typeCO->clear();
|
||||||
tocTV->setModel(new QStandardItemModel);
|
tocTV->setModel(new QStandardItemModel);
|
||||||
@ -225,10 +225,8 @@ void TocWidget::updateGui(int selected_type)
|
|||||||
QString const current_text = typeCO->currentText();
|
QString const current_text = typeCO->currentText();
|
||||||
typeCO->blockSignals(true);
|
typeCO->blockSignals(true);
|
||||||
typeCO->clear();
|
typeCO->clear();
|
||||||
for (size_t i = 0; i != type_names.size(); ++i) {
|
for (int i = 0; i != type_names.size(); ++i)
|
||||||
QString item = toqstr(type_names[i]);
|
typeCO->addItem(type_names[i]);
|
||||||
typeCO->addItem(item);
|
|
||||||
}
|
|
||||||
if (selected_type != -1)
|
if (selected_type != -1)
|
||||||
typeCO->setCurrentIndex(selected_type);
|
typeCO->setCurrentIndex(selected_type);
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user