Mercurial > hg > octave-lyh
changeset 15465:ded4ce76ee7a
save and restore the list of recently visited directories
* main-window.cc: added the contents of the combo-box with the actual and recently
visited directories to read_setting and write_settings
author | Torsten <ttl@justmail.de> |
---|---|
date | Mon, 01 Oct 2012 22:16:18 +0200 |
parents | 930117c97760 |
children | 049e8bbff782 |
files | libgui/src/main-window.cc |
diffstat | 1 files changed, 21 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/main-window.cc +++ b/libgui/src/main-window.cc @@ -203,14 +203,13 @@ void main_window::current_working_directory_has_changed (const QString& directory) { - if (_current_directory_combo_box->count () > 31) - { - _current_directory_combo_box->removeItem (0); + int index = _current_directory_combo_box->findText (directory); + if ( index >= 0 ) // directory already in list -> remove it + { + _current_directory_combo_box->removeItem (index); } - _current_directory_combo_box->addItem (directory); - int index = _current_directory_combo_box->findText (directory); - _current_directory_combo_box->setCurrentIndex (index); - + _current_directory_combo_box->insertItem (0,directory); // add (on top) + _current_directory_combo_box->setCurrentIndex (0); // top is actual _files_dock_widget->set_current_directory (directory); } @@ -411,6 +410,12 @@ } settings->endGroup(); restoreGeometry (settings->value ("MainWindow/geometry").toByteArray ()); + // restore the list of the last directories + QStringList curr_dirs = settings->value ("MainWindow/current_directory_list").toStringList (); + for (int i=0; i < curr_dirs.size (); i++) + { + _current_directory_combo_box->addItem (curr_dirs.at (i)); + } emit settings_changed (); } @@ -436,6 +441,13 @@ } settings->endGroup(); + // write the list of recent used directories + QStringList curr_dirs; + for (int i=0; i<_current_directory_combo_box->count (); i++) + { + curr_dirs.append (_current_directory_combo_box->itemText (i)); + } + settings->setValue ("MainWindow/current_directory_list",curr_dirs); settings->sync (); } @@ -460,7 +472,8 @@ _current_directory_combo_box->setFixedWidth (300); _current_directory_combo_box->setEditable (true); _current_directory_combo_box->setInsertPolicy (QComboBox::InsertAtTop); - _current_directory_combo_box->setMaxVisibleItems (14); + _current_directory_combo_box->setMaxVisibleItems (16); + _current_directory_combo_box->setMaxCount (16); _current_directory_tool_button = new QToolButton (this); _current_directory_tool_button->setIcon (QIcon(":/actions/icons/search.png"));