1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-24 12:46:35 +01:00

Remember last folder to save newly added bookmarks.

This commit is contained in:
nowrep 2012-02-04 22:47:55 +01:00
parent e28f8cf58a
commit f65c565f06
4 changed files with 30 additions and 8 deletions

View File

@ -560,6 +560,7 @@ void BookmarksManager::insertBookmark(const QUrl &url, const QString &title, con
while (query.next()) {
combo->addItem(style()->standardIcon(QStyle::SP_DirIcon), query.value(0).toString());
}
combo->setCurrentIndex(combo->findText(BookmarksModel::toTranslatedFolder(m_bookmarksModel->lastFolder())));
label->setText(tr("Choose name and location of this bookmark."));
edit->setText(title);
@ -605,6 +606,7 @@ void BookmarksManager::insertAllTabs()
while (query.next()) {
combo->addItem(style()->standardIcon(QStyle::SP_DirIcon), query.value(0).toString());
}
combo->setCurrentIndex(combo->findText(BookmarksModel::toTranslatedFolder(m_bookmarksModel->lastFolder())));
label->setText(tr("Choose folder for bookmarks:"));
dialog->setWindowTitle(tr("Bookmark All Tabs"));

View File

@ -36,20 +36,30 @@ BookmarksModel::BookmarksModel(QObject* parent)
void BookmarksModel::loadSettings()
{
Settings settings;
settings.beginGroup("Web-Browser-Settings");
settings.beginGroup("Bookmarks");
m_showMostVisited = settings.value("showMostVisited", true).toBool();
m_lastFolder = settings.value("LastFolder", "unsorted").toString();
settings.endGroup();
}
void BookmarksModel::setShowingMostVisited(bool state)
{
Settings settings;
settings.beginGroup("Web-Browser-Settings");
settings.beginGroup("Bookmarks");
settings.setValue("showMostVisited", state);
settings.endGroup();
m_showMostVisited = state;
}
void BookmarksModel::setLastFolder(const QString &folder)
{
Settings settings;
settings.beginGroup("Bookmarks");
settings.setValue("lastFolder", folder);
settings.endGroup();
m_lastFolder = folder;
}
bool BookmarksModel::isBookmarked(const QUrl &url)
{
QSqlQuery query;
@ -152,13 +162,19 @@ bool BookmarksModel::saveBookmark(const QUrl &url, const QString &title, const Q
bookmark.image = image;
bookmark.inSubfolder = isSubfolder(bookmark.folder);
setLastFolder(folder);
emit bookmarkAdded(bookmark);
mApp->sendMessages(Qz::AM_BookmarksChanged, true);
return true;
}
bool BookmarksModel::saveBookmark(WebView* view, const QString &folder)
bool BookmarksModel::saveBookmark(WebView* view, QString folder)
{
if (folder.isEmpty()) {
folder = m_lastFolder;
}
return saveBookmark(view->url(), view->title(), view->icon(), folder);
}

View File

@ -60,13 +60,16 @@ public:
inline bool isShowingMostVisited() { return m_showMostVisited; }
void setShowingMostVisited(bool state);
QString lastFolder() { return m_lastFolder; }
void setLastFolder(const QString &folder);
bool isBookmarked(const QUrl &url);
int bookmarkId(const QUrl &url);
int bookmarkId(const QUrl &url, const QString &title, const QString &folder);
Bookmark getBookmark(int id);
bool saveBookmark(const QUrl &url, const QString &title, const QIcon &icon, const QString &folder = "unsorted");
bool saveBookmark(WebView* view, const QString &folder = "unsorted");
bool saveBookmark(WebView* view, QString folder = QString());
bool removeBookmark(int id);
bool removeBookmark(const QUrl &url);
@ -105,6 +108,7 @@ public slots:
private:
bool m_showMostVisited;
QString m_lastFolder;
};
typedef BookmarksModel::Bookmark Bookmark;

View File

@ -152,20 +152,20 @@ QString SpeedDial::initialScript()
m_regenerateScript = false;
m_initialScript.clear();
QStringList entries = m_allPages.split("\";");
const QStringList &entries = m_allPages.split("\";");
foreach(const QString & entry, entries) {
if (entry.isEmpty()) {
continue;
}
QStringList tmp = entry.split("\"|");
const QStringList &tmp = entry.split("\"|");
if (tmp.count() != 2) {
continue;
}
QString url = tmp.at(0).mid(5);
QString title = tmp.at(1).mid(7);
const QString &url = tmp.at(0).mid(5);
const QString &title = tmp.at(1).mid(7);
QString imgSource = m_thumbnailsDir + QCryptographicHash::hash(url.toUtf8(), QCryptographicHash::Md4).toHex() + ".png";