Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
96b495e4
Commit
96b495e4
authored
Sep 28, 2009
by
dt
Browse files
On jumping to invalid bookmarks, delete them.
For next/prev try the next/prev one then.
parent
a2bfa610
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/plugins/bookmarks/bookmarkmanager.cpp
View file @
96b495e4
...
...
@@ -279,7 +279,10 @@ void BookmarkView::setModel(QAbstractItemModel *model)
void
BookmarkView
::
gotoBookmark
(
const
QModelIndex
&
index
)
{
static_cast
<
BookmarkManager
*>
(
model
())
->
gotoBookmark
(
index
);
BookmarkManager
*
bm
=
static_cast
<
BookmarkManager
*>
(
model
());
Bookmark
*
bk
=
bm
->
bookmarkForIndex
(
index
);
if
(
!
bm
->
gotoBookmark
(
bk
))
bm
->
removeBookmark
(
bk
);
}
////
...
...
@@ -479,15 +482,14 @@ Bookmark *BookmarkManager::bookmarkForIndex(QModelIndex index)
return
m_bookmarksList
.
at
(
index
.
row
());
}
void
BookmarkManager
::
gotoBookmark
(
const
QModelIndex
&
idx
)
{
gotoBookmark
(
m_bookmarksList
.
at
(
idx
.
row
()));
}
void
BookmarkManager
::
gotoBookmark
(
Bookmark
*
bookmark
)
bool
BookmarkManager
::
gotoBookmark
(
Bookmark
*
bookmark
)
{
TextEditor
::
BaseTextEditor
::
openEditorAt
(
bookmark
->
filePath
(),
bookmark
->
lineNumber
());
if
(
!
TextEditor
::
BaseTextEditor
::
openEditorAt
(
bookmark
->
filePath
(),
bookmark
->
lineNumber
()))
{
// Could not open editor
return
false
;
}
return
true
;
}
void
BookmarkManager
::
nextInDocument
()
...
...
@@ -546,12 +548,22 @@ void BookmarkManager::next()
QModelIndex
current
=
selectionModel
()
->
currentIndex
();
if
(
!
current
.
isValid
())
return
;
int
row
=
current
.
row
()
+
1
;
if
(
row
==
m_bookmarksList
.
size
())
row
=
0
;
QModelIndex
newIndex
=
current
.
sibling
(
row
,
current
.
column
());
selectionModel
()
->
setCurrentIndex
(
newIndex
,
QItemSelectionModel
::
Select
|
QItemSelectionModel
::
Clear
);
gotoBookmark
(
newIndex
);
int
row
=
current
.
row
();
++
row
;
while
(
true
)
{
if
(
row
==
m_bookmarksList
.
size
())
row
=
0
;
Bookmark
*
bk
=
m_bookmarksList
.
at
(
row
);
if
(
gotoBookmark
(
bk
))
{
QModelIndex
newIndex
=
current
.
sibling
(
row
,
current
.
column
());
selectionModel
()
->
setCurrentIndex
(
newIndex
,
QItemSelectionModel
::
Select
|
QItemSelectionModel
::
Clear
);
return
;
}
removeBookmark
(
bk
);
if
(
m_bookmarksList
.
isEmpty
())
// No bookmarks anymore ...
return
;
}
}
void
BookmarkManager
::
prev
()
...
...
@@ -559,13 +571,22 @@ void BookmarkManager::prev()
QModelIndex
current
=
selectionModel
()
->
currentIndex
();
if
(
!
current
.
isValid
())
return
;
int
row
=
current
.
row
();
if
(
row
==
0
)
row
=
m_bookmarksList
.
size
();
--
row
;
QModelIndex
newIndex
=
current
.
sibling
(
row
,
current
.
column
());
selectionModel
()
->
setCurrentIndex
(
newIndex
,
QItemSelectionModel
::
Select
|
QItemSelectionModel
::
Clear
);
gotoBookmark
(
newIndex
);
while
(
true
)
{
if
(
row
==
0
)
row
=
m_bookmarksList
.
size
();
--
row
;
Bookmark
*
bk
=
m_bookmarksList
.
at
(
row
);
if
(
gotoBookmark
(
bk
))
{
QModelIndex
newIndex
=
current
.
sibling
(
row
,
current
.
column
());
selectionModel
()
->
setCurrentIndex
(
newIndex
,
QItemSelectionModel
::
Select
|
QItemSelectionModel
::
Clear
);
return
;
}
removeBookmark
(
bk
);
if
(
m_bookmarksList
.
isEmpty
())
return
;
}
}
TextEditor
::
ITextEditor
*
BookmarkManager
::
currentTextEditor
()
const
...
...
src/plugins/bookmarks/bookmarkmanager.h
View file @
96b495e4
...
...
@@ -80,8 +80,6 @@ public:
int
columnCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
=
Qt
::
DisplayRole
)
const
;
void
gotoBookmark
(
const
QModelIndex
&
);
// this QItemSelectionModel is shared by all views
QItemSelectionModel
*
selectionModel
()
const
;
...
...
@@ -101,6 +99,7 @@ public slots:
void
prev
();
void
moveUp
();
void
moveDown
();
bool
gotoBookmark
(
Bookmark
*
bookmark
);
signals:
void
updateActions
(
int
state
);
...
...
@@ -108,7 +107,6 @@ signals:
private
slots
:
void
updateActionStatus
();
void
gotoBookmark
(
Bookmark
*
bookmark
);
void
loadBookmarks
();
private:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment