}
+int QToc::getTocDepth()
+{
+ return toc_models_[type_]->modelDepth();
+}
+
+
QStandardItemModel * QToc::tocModel()
{
lyxerr[Debug::GUI]
void goTo(QModelIndex const & index);
///
int getType();
+ ///
+ int getTocDepth();
private:
{
if (depth == depth_)
return;
+ setTreeDepth(depth);
+}
+
- depth_ = depth;
+void QTocDialog::setTreeDepth(int depth)
+{
+ if(depth!=-1)
+ depth_ = depth;
// tocTV->expandAll(); //expanding and then collapsing is probably better, but my qt 4.1.2 doesn't have expandAll()..
QModelIndexList indices =
form_->tocModel()->match(form_->tocModel()->index(0,0),
Qt::DisplayRole, "*", -1,
Qt::MatchWildcard|Qt::MatchRecursive);
Q_FOREACH (QModelIndex index, indices) { // I had to use Q_FOREACH instead of foreach
- if(getIndexDepth(index) < depth) // because compile flag -DQT_NO_KEYWORDS doesn't allow me..
+ if(getIndexDepth(index) < depth_) // because compile flag -DQT_NO_KEYWORDS doesn't allow me..
tocTV->expand(index);
else
tocTV->collapse(index);
enableButtons();
reconnectSelectionModel();
+ depthSL->setMaximum(form_->getTocDepth());
+ setTreeDepth();
select(form_->getCurrentIndex());
lyxerr[Debug::GUI]
void reconnectSelectionModel();
///
int getIndexDepth(QModelIndex const & index, int depth = -1);
+ ///
+ void setTreeDepth(int depth = -1);
private:
using std::vector;
using std::string;
using std::make_pair;
+using std::max;
+using std::min;
namespace lyx {
namespace frontend {
if (toc.empty())
return;
-
int current_row;
QModelIndex top_level_item;
TocIterator end = toc.end();
insertColumns(0, 1);
+ maxdepth_ = 0;
+ mindepth_ = INT_MAX;
while (iter != end) {
if (iter->isValid()) {
+ maxdepth_ = max(maxdepth_, iter->depth());
+ mindepth_ = min(mindepth_, iter->depth());
current_row = rowCount();
insertRows(current_row, 1);
top_level_item = QStandardItemModel::index(current_row, 0);
QModelIndex const & parent)
{
int curdepth = iter->depth() + 1;
+
int current_row;
QModelIndex child_item;
return;
}
+ maxdepth_ = max(maxdepth_, iter->depth());
+ mindepth_ = min(mindepth_, iter->depth());
current_row = rowCount(parent);
insertRows(current_row, 1, parent);
child_item = QStandardItemModel::index(current_row, 0, parent);
}
+int TocModel::modelDepth()
+{
+ return maxdepth_ - mindepth_;
+}
+
} // namespace frontend
} // namespace lyx
TocIterator const tocIterator(QModelIndex const & index) const;
///
QModelIndex const modelIndex(TocIterator const & it) const;
+ ///
+ int modelDepth();
private:
///
TocMap toc_map_;
///
ModelMap model_map_;
+ ///
+ int maxdepth_;
+ int mindepth_;
};
} // namespace frontend
<number>1</number>
</property>
<property name="value" >
- <number>1</number>
+ <number>2</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>