tested except for the changed event; refs #116

This commit is contained in:
Marc Wäckerlin
2012-04-18 09:40:57 +00:00
parent 60af8e2687
commit 9802fa5b1d
3 changed files with 43 additions and 12 deletions

View File

@@ -155,6 +155,8 @@ class Browser: public QMainWindow, protected Ui::Browser {
actionAddBookmark, SLOT(setDisabled(bool))));
assert(connect(_editbookmarks.get(), SIGNAL(endEdit(bool)),
actionAddBookmark, SLOT(setEnabled(bool))));
assert(connect(_editbookmarks.get(), SIGNAL(accepted()),
SLOT(saveBookmarks())));
} else {
QLineEdit* label(new QLineEdit(_toolbar));
_url = label;
@@ -596,6 +598,7 @@ class Browser: public QMainWindow, protected Ui::Browser {
QAction* a(_bookmarks->addAction(url->currentText()));
a->setData(url->currentText());
connect(a, SIGNAL(triggered(bool)), SLOT(loadFromHistory()));
saveBookmarks();
}
}
@@ -858,13 +861,18 @@ class Browser: public QMainWindow, protected Ui::Browser {
}
void saveBookmarks() {
LOG<<"Saving Bookmarks ...";
QStringList urls;
if (qobject_cast<QComboBox*>(_url))
for (int i(0); i<qobject_cast<QComboBox*>(_url)->count(); ++i)
urls<<qobject_cast<QComboBox*>(_url)->itemText(i);
if (!(_bookmarkfile.writeable() && _bookmarkfile.write(urls))
&& _settings())
if (_bookmarkfile.writeable()) {
LOG<<"write to bookmark file";
_bookmarkfile.write(urls);
} else if (_settings()) {
LOG<<"write to settings";
_settings()->setValue("Window/Urls", urls);
} else LOG<<"bookmarks not saved";
}
void loadWin() {
@@ -885,9 +893,15 @@ class Browser: public QMainWindow, protected Ui::Browser {
}
void loadBookmarks() {
QStringList urls(_bookmarkfile.readable()
?_bookmarkfile.read()
:_settings()->value("Window/Urls").toStringList());
LOG<<"Loading Bookmarks ...";
QStringList urls;
if (_bookmarkfile.readable()) {
LOG<<"load from file";
urls = _bookmarkfile.read();
} else if (_settings()) {
LOG<<"load from settings";
urls = _settings()->value("Window/Urls").toStringList();
}
if (qobject_cast<QComboBox*>(_url)) {
qobject_cast<QComboBox*>(_url)->clear();
qobject_cast<QComboBox*>(_url)->addItems(urls);