forked from qt-creator/qt-creator
Insert new bookmarks after the "current" bookmark
Makes it more useful as a navigation instrument. If new bookmarks are always added to the end of the list, the "previous" bookmark will have nothing to do with the context of the bookmark that was previously the "current" one. Task-number: QTCREATORBUG-20061 Change-Id: I0ea38391750371dec80872206d97f4934a37f7b4 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -455,7 +455,10 @@ void BookmarkManager::toggleBookmark(const FileName &fileName, int lineNumber)
|
|||||||
// Add a new bookmark if no bookmark existed on this line
|
// Add a new bookmark if no bookmark existed on this line
|
||||||
Bookmark *mark = new Bookmark(lineNumber, this);
|
Bookmark *mark = new Bookmark(lineNumber, this);
|
||||||
mark->updateFileName(fileName.toString());
|
mark->updateFileName(fileName.toString());
|
||||||
addBookmark(mark);
|
const QModelIndex currentIndex = selectionModel()->currentIndex();
|
||||||
|
const int insertionIndex = currentIndex.isValid() ? currentIndex.row() + 1
|
||||||
|
: m_bookmarksList.size();
|
||||||
|
insertBookmark(insertionIndex, mark);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkManager::updateBookmark(Bookmark *bookmark)
|
void BookmarkManager::updateBookmark(Bookmark *bookmark)
|
||||||
@@ -731,23 +734,30 @@ Bookmark *BookmarkManager::findBookmark(const FileName &filePath, int lineNumber
|
|||||||
Utils::equal(&Bookmark::lineNumber, lineNumber));
|
Utils::equal(&Bookmark::lineNumber, lineNumber));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Adds a bookmark to the internal data structures. The 'userset' parameter
|
void BookmarkManager::insertBookmark(int idx, Bookmark *bookmark, bool userset)
|
||||||
* determines whether action status should be updated and whether the bookmarks
|
|
||||||
* should be saved to the session settings.
|
|
||||||
*/
|
|
||||||
void BookmarkManager::addBookmark(Bookmark *bookmark, bool userset)
|
|
||||||
{
|
{
|
||||||
beginInsertRows(QModelIndex(), m_bookmarksList.size(), m_bookmarksList.size());
|
idx = qBound(0, idx, m_bookmarksList.size());
|
||||||
|
beginInsertRows(QModelIndex(), idx, idx);
|
||||||
|
|
||||||
m_bookmarksMap[FileName::fromString(bookmark->fileName())].append(bookmark);
|
m_bookmarksMap[FileName::fromString(bookmark->fileName())].append(bookmark);
|
||||||
m_bookmarksList.append(bookmark);
|
m_bookmarksList.insert(idx, bookmark);
|
||||||
|
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
if (userset) {
|
if (userset) {
|
||||||
updateActionStatus();
|
updateActionStatus();
|
||||||
saveBookmarks();
|
saveBookmarks();
|
||||||
}
|
}
|
||||||
selectionModel()->setCurrentIndex(index(m_bookmarksList.size()-1 , 0, QModelIndex()), QItemSelectionModel::Select | QItemSelectionModel::Clear);
|
selectionModel()->setCurrentIndex(index(idx, 0, QModelIndex()),
|
||||||
|
QItemSelectionModel::Select | QItemSelectionModel::Clear);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Adds a bookmark to the internal data structures. The 'userset' parameter
|
||||||
|
* determines whether action status should be updated and whether the bookmarks
|
||||||
|
* should be saved to the session settings.
|
||||||
|
*/
|
||||||
|
void BookmarkManager::addBookmark(Bookmark *bookmark, bool userset)
|
||||||
|
{
|
||||||
|
insertBookmark(m_bookmarksList.size(), bookmark, userset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Adds a new bookmark based on information parsed from the string. */
|
/* Adds a new bookmark based on information parsed from the string. */
|
||||||
|
@@ -110,6 +110,7 @@ private:
|
|||||||
void documentPrevNext(bool next);
|
void documentPrevNext(bool next);
|
||||||
|
|
||||||
Bookmark *findBookmark(const Utils::FileName &filePath, int lineNumber);
|
Bookmark *findBookmark(const Utils::FileName &filePath, int lineNumber);
|
||||||
|
void insertBookmark(int index, Bookmark *bookmark, bool userset = true);
|
||||||
void addBookmark(Bookmark *bookmark, bool userset = true);
|
void addBookmark(Bookmark *bookmark, bool userset = true);
|
||||||
void addBookmark(const QString &s);
|
void addBookmark(const QString &s);
|
||||||
static QString bookmarkToString(const Bookmark *b);
|
static QString bookmarkToString(const Bookmark *b);
|
||||||
|
Reference in New Issue
Block a user