summaryrefslogtreecommitdiff
path: root/src/plugins/bookmarks
diff options
context:
space:
mode:
authordt <qtc-committer@nokia.com>2009-06-17 18:53:06 +0200
committerdt <qtc-committer@nokia.com>2009-06-17 19:06:22 +0200
commit69ff0eeb83d4503ec039806688dcad0df3ce541b (patch)
tree9e5f5f6e7afb48867ae0636f3a285adbed62d015 /src/plugins/bookmarks
parent2d65dec3e9eb9694b790372f05a91566696ea76a (diff)
downloadqt-creator-69ff0eeb83d4503ec039806688dcad0df3ce541b.tar.gz
Switching sessions didn't clear the bookmark list from old bookmarks.
Task-Nr: 255922
Diffstat (limited to 'src/plugins/bookmarks')
-rw-r--r--src/plugins/bookmarks/bookmarkmanager.cpp30
-rw-r--r--src/plugins/bookmarks/bookmarkmanager.h1
2 files changed, 29 insertions, 2 deletions
diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp
index feb285bdec..33adc3eb56 100644
--- a/src/plugins/bookmarks/bookmarkmanager.cpp
+++ b/src/plugins/bookmarks/bookmarkmanager.cpp
@@ -415,8 +415,34 @@ void BookmarkManager::updateBookmark(Bookmark *bookmark)
saveBookmarks();
}
+void BookmarkManager::removeAllBookmarks()
+{
+ if (m_bookmarksList.isEmpty())
+ return;
+ beginRemoveRows(QModelIndex(), 0, m_bookmarksList.size() - 1);
+
+ DirectoryFileBookmarksMap::const_iterator it, end;
+ end = m_bookmarksMap.constEnd();
+ for (it = m_bookmarksMap.constBegin(); it != end; ++it) {
+ FileNameBookmarksMap *files = it.value();
+ FileNameBookmarksMap::const_iterator jt, jend;
+ jend = files->constEnd();
+ for (jt = files->constBegin(); jt != jend; ++jt) {
+ delete jt.value();
+ }
+ files->clear();
+ delete files;
+ }
+ m_bookmarksMap.clear();
+ m_bookmarksList.clear();
+ endRemoveRows();
+}
+
void BookmarkManager::removeBookmark(Bookmark *bookmark)
{
+ int idx = m_bookmarksList.indexOf(bookmark);
+ beginRemoveRows(QModelIndex(), idx, idx);
+
const QFileInfo fi(bookmark->filePath() );
FileNameBookmarksMap *files = m_bookmarksMap.value(fi.path());
@@ -434,8 +460,7 @@ void BookmarkManager::removeBookmark(Bookmark *bookmark)
delete files;
}
- int idx = m_bookmarksList.indexOf(bookmark);
- beginRemoveRows(QModelIndex(), idx, idx);
+
m_bookmarksList.removeAt(idx);
endRemoveRows();
@@ -700,6 +725,7 @@ void BookmarkManager::saveBookmarks()
/* Loads the bookmarks from the session settings. */
void BookmarkManager::loadBookmarks()
{
+ removeAllBookmarks();
SessionManager *s = sessionManager();
if (!s)
return;
diff --git a/src/plugins/bookmarks/bookmarkmanager.h b/src/plugins/bookmarks/bookmarkmanager.h
index f04aa2c0c9..0c732daf7e 100644
--- a/src/plugins/bookmarks/bookmarkmanager.h
+++ b/src/plugins/bookmarks/bookmarkmanager.h
@@ -67,6 +67,7 @@ public:
~BookmarkManager();
void updateBookmark(Bookmark *bookmark);
void removeBookmark(Bookmark *bookmark); // Does not remove the mark
+ void removeAllBookmarks();
Bookmark *bookmarkForIndex(QModelIndex index);
enum State { NoBookMarks, HasBookMarks, HasBookmarksInDocument };