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

View File

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

View File

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