mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 19:25:39 +00:00
Fix loop when opening TOC widget in an empty document, basically by Richard Heck.
* src/frontends/qt4/TocWidget.[Ch]: - rename enableButtons to enableControls and include slider enabling/disabling - only set slider if there is some content git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17835 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
840ee198e2
commit
8874db5f22
@ -129,39 +129,39 @@ void TocWidget::on_typeCO_activated(int value)
|
||||
|
||||
void TocWidget::on_moveUpPB_clicked()
|
||||
{
|
||||
enableButtons(false);
|
||||
enableControls(false);
|
||||
QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
|
||||
if (!list.isEmpty()) {
|
||||
enableButtons(false);
|
||||
enableControls(false);
|
||||
form_->goTo(typeCO->currentIndex(), list[0]);
|
||||
form_->outlineUp();
|
||||
enableButtons(true);
|
||||
enableControls(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TocWidget::on_moveDownPB_clicked()
|
||||
{
|
||||
enableButtons(false);
|
||||
enableControls(false);
|
||||
QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
|
||||
if (!list.isEmpty()) {
|
||||
enableButtons(false);
|
||||
enableControls(false);
|
||||
form_->goTo(typeCO->currentIndex(), list[0]);
|
||||
form_->outlineDown();
|
||||
enableButtons(true);
|
||||
enableControls(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TocWidget::on_moveInPB_clicked()
|
||||
{
|
||||
enableButtons(false);
|
||||
enableControls(false);
|
||||
QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
|
||||
if (!list.isEmpty()) {
|
||||
enableButtons(false);
|
||||
enableControls(false);
|
||||
form_->goTo(typeCO->currentIndex(), list[0]);
|
||||
form_->outlineIn();
|
||||
enableButtons(true);
|
||||
enableControls(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,10 +170,10 @@ void TocWidget::on_moveOutPB_clicked()
|
||||
{
|
||||
QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
|
||||
if (!list.isEmpty()) {
|
||||
enableButtons(false);
|
||||
enableControls(false);
|
||||
form_->goTo(typeCO->currentIndex(), list[0]);
|
||||
form_->outlineOut();
|
||||
enableButtons(true);
|
||||
enableControls(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@ void TocWidget::select(QModelIndex const & index)
|
||||
}
|
||||
|
||||
|
||||
void TocWidget::enableButtons(bool enable)
|
||||
void TocWidget::enableControls(bool enable)
|
||||
{
|
||||
updatePB->setEnabled(enable);
|
||||
|
||||
@ -205,6 +205,8 @@ void TocWidget::enableButtons(bool enable)
|
||||
moveDownPB->setEnabled(enable);
|
||||
moveInPB->setEnabled(enable);
|
||||
moveOutPB->setEnabled(enable);
|
||||
|
||||
depthSL->setEnabled(enable);
|
||||
}
|
||||
|
||||
|
||||
@ -220,11 +222,10 @@ void TocWidget::updateGui()
|
||||
{
|
||||
QStringListModel * type_model = form_->typeModel();
|
||||
if (type_model->stringList().isEmpty()) {
|
||||
enableButtons(false);
|
||||
enableControls(false);
|
||||
typeCO->setModel(type_model);
|
||||
tocTV->setModel(new QStandardItemModel);
|
||||
tocTV->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
depthSL->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -242,20 +243,22 @@ void TocWidget::updateGui()
|
||||
|
||||
void TocWidget::setTocModel(size_t type)
|
||||
{
|
||||
bool buttons_enabled = false;
|
||||
bool controls_enabled = false;
|
||||
QStandardItemModel * toc_model = form_->tocModel(type);
|
||||
if (toc_model) {
|
||||
buttons_enabled = toc_model->rowCount() > 0;
|
||||
controls_enabled = toc_model->rowCount() > 0;
|
||||
tocTV->setModel(toc_model);
|
||||
tocTV->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
}
|
||||
|
||||
enableButtons(buttons_enabled);
|
||||
enableControls(controls_enabled);
|
||||
|
||||
reconnectSelectionModel();
|
||||
depthSL->setEnabled(true);
|
||||
depthSL->setMaximum(form_->getTocDepth(type));
|
||||
depthSL->setValue(depth_);
|
||||
|
||||
if (controls_enabled) {
|
||||
depthSL->setMaximum(form_->getTocDepth(type));
|
||||
depthSL->setValue(depth_);
|
||||
}
|
||||
|
||||
LYXERR(Debug::GUI) << "In TocWidget::updateGui()" << endl;
|
||||
|
||||
|
@ -51,7 +51,7 @@ protected Q_SLOTS:
|
||||
|
||||
protected:
|
||||
///
|
||||
void enableButtons(bool enable = true);
|
||||
void enableControls(bool enable = true);
|
||||
///
|
||||
int getIndexDepth(QModelIndex const & index, int depth = -1);
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user