Bug fixes from Ugras Baran:

Following patch corrects some misbehavior in TOC dialog:

- When clicking on Toc insets, dialog switches to correct list.
- cursor goes to correct entry when clicked..
- some other fixes..


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15949 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2006-11-16 12:37:55 +00:00
parent 454bf36bc3
commit a6933a9b4e
4 changed files with 51 additions and 19 deletions

View File

@ -112,14 +112,24 @@ void QToc::goTo(QModelIndex const & index)
}
int QToc::getType()
{
return type_;
}
void QToc::update()
{
toc_models_.clear();
updateType();
updateToc();
}
void QToc::updateType()
{
QStringList type_list;
type_ = 0;
vector<string> const & types = getTypes();
if (types.empty()) {
type_model_.setStringList(type_list);
@ -127,8 +137,11 @@ void QToc::update()
return;
}
string const & selected_type = params().getCmdName();
lyxerr[Debug::GUI] << "selected_type " << selected_type << endl;
string selected_type ;
if(params()["type"].empty()) //Then plain toc...
selected_type = params().getCmdName();
else
selected_type = to_ascii(params()["type"]);
QString gui_names_;
for (size_t i = 0; i != types.size(); ++i) {
@ -142,15 +155,21 @@ void QToc::update()
<< "\ttoc_models_.size() " << toc_models_.size()
<< endl;
toc_models_.push_back(new TocModel(getContents(types[i])));
}
type_model_.setStringList(type_list);
}
void QToc::updateToc(int type)
void QToc::updateToc()
{
toc_models_[type] = new TocModel(getContents(getTypes()[type]));
toc_models_.clear();
vector<string> const & types = getTypes();
for (size_t i = 0; i != types.size(); ++i) {
toc_models_.push_back(new TocModel(getContents(types[i])));
}
}

View File

@ -32,8 +32,10 @@ public:
QToc(Dialog &);
void update();
void updateToc(int type);
///
void updateToc();
///
void updateType();
bool canOutline();
@ -47,6 +49,8 @@ public:
QModelIndex const getCurrentIndex();
///
void goTo(QModelIndex const & index);
///
int getType();
private:

View File

@ -79,7 +79,7 @@ void QTocDialog::on_closePB_clicked()
void QTocDialog::on_updatePB_clicked()
{
update();
form_->update();
}
@ -105,6 +105,7 @@ void QTocDialog::on_typeCO_activated(int value)
{
form_->setTocModel(value);
tocTV->setModel(form_->tocModel());
reconnectSelectionModel();
enableButtons();
}
@ -180,7 +181,7 @@ void QTocDialog::enableButtons(bool enable)
void QTocDialog::update()
{
form_->update();
form_->updateToc();
updateGui();
}
@ -197,6 +198,7 @@ void QTocDialog::updateGui()
}
typeCO->setModel(type_model);
typeCO->setCurrentIndex(form_->getType());
if (form_->tocModel())
tocTV->setModel(form_->tocModel());
@ -208,12 +210,7 @@ void QTocDialog::updateGui()
tocTV->header()->setVisible(false);
enableButtons();
connect(tocTV->selectionModel(),
SIGNAL(currentChanged(const QModelIndex &,
const QModelIndex &)),
this, SLOT(selectionChanged(const QModelIndex &,
const QModelIndex &)));
reconnectSelectionModel();
select(form_->getCurrentIndex());
lyxerr[Debug::GUI]
@ -224,6 +221,16 @@ void QTocDialog::updateGui()
}
void QTocDialog::reconnectSelectionModel()
{
connect(tocTV->selectionModel(),
SIGNAL(currentChanged(const QModelIndex &,
const QModelIndex &)),
this, SLOT(selectionChanged(const QModelIndex &,
const QModelIndex &)));
}
void QTocDialog::apply()
{
// Nothing to do here... for now.
@ -239,7 +246,7 @@ void QTocDialog::hide()
void QTocDialog::show()
{
update();
form_->update();
QDialog::show();
}

View File

@ -71,6 +71,8 @@ protected Q_SLOTS:
protected:
///
void enableButtons(bool enable = true);
/// Reconnects the selection model change signal when TOC changed.
void reconnectSelectionModel();
private: