mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Fix bug #6672 (part 2): Add tooltips to the outliner.
At some point we should implement that the tooltips are only shown when they are not completely shown in the outliner. However, this requires extending the QTreeView class. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34287 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
acff67f259
commit
c6c0559be0
@ -503,14 +503,16 @@ void Changes::addToToc(DocIterator const & cdit, Buffer const & buffer) const
|
||||
Toc::iterator it = change_list.item(0, author);
|
||||
if (it == change_list.end()) {
|
||||
change_list.push_back(TocItem(dit, 0, author));
|
||||
change_list.push_back(TocItem(dit, 1, str));
|
||||
change_list.push_back(TocItem(dit, 1, str,
|
||||
support::wrapParas(str, 4)));
|
||||
continue;
|
||||
}
|
||||
for (++it; it != change_list.end(); ++it) {
|
||||
if (it->depth() == 0 && it->str() != author)
|
||||
break;
|
||||
}
|
||||
change_list.insert(it, TocItem(dit, 1, str));
|
||||
change_list.insert(it, TocItem(dit, 1, str,
|
||||
support::wrapParas(str, 4)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,8 +44,8 @@ namespace lyx {
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TocItem::TocItem(DocIterator const & dit, int d, docstring const & s)
|
||||
: dit_(dit), depth_(d), str_(s)
|
||||
TocItem::TocItem(DocIterator const & dit, int d, docstring const & s,
|
||||
docstring const & t) : dit_(dit), depth_(d), str_(s), tooltip_(t)
|
||||
{
|
||||
}
|
||||
|
||||
@ -68,6 +68,12 @@ docstring const & TocItem::str() const
|
||||
}
|
||||
|
||||
|
||||
docstring const & TocItem::tooltip() const
|
||||
{
|
||||
return tooltip_;
|
||||
}
|
||||
|
||||
|
||||
docstring const TocItem::asString() const
|
||||
{
|
||||
return docstring(4 * depth_, ' ') + str_;
|
||||
|
@ -42,7 +42,8 @@ public:
|
||||
///
|
||||
TocItem(DocIterator const & dit,
|
||||
int depth,
|
||||
docstring const & s
|
||||
docstring const & s,
|
||||
docstring const & t = docstring()
|
||||
);
|
||||
///
|
||||
~TocItem() {}
|
||||
@ -53,6 +54,8 @@ public:
|
||||
///
|
||||
docstring const & str() const;
|
||||
///
|
||||
docstring const & tooltip() const;
|
||||
///
|
||||
docstring const asString() const;
|
||||
///
|
||||
DocIterator const & dit() const;
|
||||
@ -69,6 +72,9 @@ protected:
|
||||
|
||||
/// Full item string
|
||||
docstring str_;
|
||||
|
||||
/// The tooltip string
|
||||
docstring tooltip_;
|
||||
};
|
||||
|
||||
|
||||
|
@ -148,6 +148,7 @@ void TocModel::updateItem(DocIterator const & dit)
|
||||
QModelIndex index = modelIndex(dit);
|
||||
TocItem const & toc_item = tocItem(index);
|
||||
model_->setData(index, toqstr(toc_item.str()), Qt::DisplayRole);
|
||||
model_->setData(index, toqstr(toc_item.tooltip()), Qt::ToolTipRole);
|
||||
}
|
||||
|
||||
|
||||
@ -177,6 +178,7 @@ void TocModel::reset(Toc const & toc)
|
||||
QModelIndex top_level_item = model_->index(current_row, 0);
|
||||
model_->setData(top_level_item, toqstr(item.str()), Qt::DisplayRole);
|
||||
model_->setData(top_level_item, index, Qt::UserRole);
|
||||
model_->setData(top_level_item, toqstr(item.tooltip()), Qt::ToolTipRole);
|
||||
|
||||
LYXERR(Debug::GUI, "Toc: at depth " << item.depth()
|
||||
<< ", added item " << item.str());
|
||||
@ -218,6 +220,7 @@ void TocModel::populate(unsigned int & index, QModelIndex const & parent)
|
||||
child_item = model_->index(current_row, 0, parent);
|
||||
model_->setData(child_item, toqstr(item.str()), Qt::DisplayRole);
|
||||
model_->setData(child_item, index, Qt::UserRole);
|
||||
model_->setData(child_item, toqstr(item.tooltip()), Qt::ToolTipRole);
|
||||
populate(index, child_item);
|
||||
if (index >= end)
|
||||
break;
|
||||
|
@ -286,7 +286,7 @@ void InsetBranch::addToToc(DocIterator const & cpit)
|
||||
|
||||
Toc & toc = buffer().tocBackend().toc("branch");
|
||||
docstring const str = params_.branch + ": " + text().getPar(0).asString();
|
||||
toc.push_back(TocItem(pit, 0, str));
|
||||
toc.push_back(TocItem(pit, 0, str, toolTipText()));
|
||||
// Proceed with the rest of the inset.
|
||||
InsetCollapsable::addToToc(cpit);
|
||||
}
|
||||
|
@ -128,11 +128,7 @@ docstring InsetCollapsable::toolTip(BufferView const & bv, int x, int y) const
|
||||
if (x > xo(bv) + dim.wid || y > yo(bv) + dim.des || isOpen(bv))
|
||||
return docstring();
|
||||
|
||||
OutputParams rp(&buffer().params().encoding());
|
||||
odocstringstream ods;
|
||||
InsetText::plaintext(ods, rp);
|
||||
docstring const content_tip = ods.str();
|
||||
return support::wrapParas(content_tip, 4);
|
||||
return toolTipText();
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,7 +67,7 @@ void InsetFoot::addToToc(DocIterator const & cpit)
|
||||
Toc & toc = buffer().tocBackend().toc("footnote");
|
||||
docstring str;
|
||||
str = custom_label_ + ": " + text().getPar(0).asString();
|
||||
toc.push_back(TocItem(pit, 0, str));
|
||||
toc.push_back(TocItem(pit, 0, str, toolTipText()));
|
||||
// Proceed with the rest of the inset.
|
||||
InsetFootlike::addToToc(cpit);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ void InsetMarginal::addToToc(DocIterator const & cpit)
|
||||
Toc & toc = buffer().tocBackend().toc("marginalnote");
|
||||
docstring str;
|
||||
str = text().getPar(0).asString();
|
||||
toc.push_back(TocItem(pit, 0, str));
|
||||
toc.push_back(TocItem(pit, 0, str, toolTipText()));
|
||||
// Proceed with the rest of the inset.
|
||||
InsetFootlike::addToToc(cpit);
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ void InsetNote::addToToc(DocIterator const & cpit)
|
||||
docstring str;
|
||||
str = notetranslator_loc().find(params_.type) + from_ascii(": ")
|
||||
+ text().getPar(0).asString();
|
||||
toc.push_back(TocItem(pit, 0, str));
|
||||
toc.push_back(TocItem(pit, 0, str, toolTipText()));
|
||||
// Proceed with the rest of the inset.
|
||||
InsetCollapsable::addToToc(cpit);
|
||||
}
|
||||
|
@ -721,7 +721,8 @@ void InsetText::addToToc(DocIterator const & cdit)
|
||||
// insert this into the table of contents
|
||||
if (tocstring.empty())
|
||||
tocstring = par.asString(AS_STR_LABEL | AS_STR_INSETS);
|
||||
toc.push_back(TocItem(dit, toclevel - min_toclevel, tocstring));
|
||||
toc.push_back(TocItem(dit, toclevel - min_toclevel,
|
||||
tocstring, tocstring));
|
||||
}
|
||||
|
||||
// And now the list of changes.
|
||||
@ -818,6 +819,18 @@ docstring InsetText::contextMenu(BufferView const &, int, int) const
|
||||
}
|
||||
|
||||
|
||||
docstring InsetText::toolTipText() const
|
||||
{
|
||||
OutputParams rp(&buffer().params().encoding());
|
||||
odocstringstream ods;
|
||||
// do not remove InsetText::, otherwise there
|
||||
// will be no tooltip text for InsetNotes
|
||||
InsetText::plaintext(ods, rp);
|
||||
docstring const content_tip = ods.str();
|
||||
return support::wrapParas(content_tip, 4);
|
||||
}
|
||||
|
||||
|
||||
InsetCaption const * InsetText::getCaptionInset() const
|
||||
{
|
||||
ParagraphList::const_iterator pit = paragraphs().begin();
|
||||
|
@ -190,6 +190,8 @@ public:
|
||||
bool insertCompletion(Cursor & cur, docstring const & s, bool finished);
|
||||
///
|
||||
void completionPosAndDim(Cursor const &, int & x, int & y, Dimension & dim) const;
|
||||
/// returns the text to be used as tooltip
|
||||
docstring toolTipText() const;
|
||||
|
||||
///
|
||||
virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
|
||||
|
Loading…
Reference in New Issue
Block a user