Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
flatpak-qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marco Bubke
flatpak-qt-creator
Commits
e2ff5591
Commit
e2ff5591
authored
15 years ago
by
con
Browse files
Options
Downloads
Patches
Plain Diff
Make open documents view keyboard navigation work.
parent
96b938e3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/coreplugin/editormanager/openeditorsview.cpp
+36
-5
36 additions, 5 deletions
src/plugins/coreplugin/editormanager/openeditorsview.cpp
src/plugins/coreplugin/editormanager/openeditorsview.h
+5
-0
5 additions, 0 deletions
src/plugins/coreplugin/editormanager/openeditorsview.h
with
41 additions
and
5 deletions
src/plugins/coreplugin/editormanager/openeditorsview.cpp
+
36
−
5
View file @
e2ff5591
...
...
@@ -100,7 +100,6 @@ OpenEditorsWidget::OpenEditorsWidget()
setWindowTitle
(
tr
(
"Open Documents"
));
setWindowIcon
(
QIcon
(
Constants
::
ICON_DIR
));
setFocusProxy
(
m_ui
.
editorList
);
m_ui
.
editorList
->
setFocusPolicy
(
Qt
::
NoFocus
);
m_ui
.
editorList
->
viewport
()
->
setAttribute
(
Qt
::
WA_Hover
);
m_ui
.
editorList
->
setItemDelegate
((
m_delegate
=
new
OpenEditorsDelegate
(
this
)));
m_ui
.
editorList
->
header
()
->
hide
();
...
...
@@ -110,13 +109,14 @@ OpenEditorsWidget::OpenEditorsWidget()
m_ui
.
editorList
->
setAttribute
(
Qt
::
WA_MacShowFocusRect
,
false
);
EditorManager
*
em
=
EditorManager
::
instance
();
m_ui
.
editorList
->
setModel
(
em
->
openedEditorsModel
());
m_ui
.
editorList
->
setSelectionMode
(
QAbstractItemView
::
No
Selection
);
m_ui
.
editorList
->
setSelectionMode
(
QAbstractItemView
::
Single
Selection
);
m_ui
.
editorList
->
setSelectionBehavior
(
QAbstractItemView
::
SelectRows
);
m_ui
.
editorList
->
header
()
->
setStretchLastSection
(
false
);
m_ui
.
editorList
->
header
()
->
setResizeMode
(
0
,
QHeaderView
::
Stretch
);
m_ui
.
editorList
->
header
()
->
setResizeMode
(
1
,
QHeaderView
::
Fixed
);
m_ui
.
editorList
->
header
()
->
resizeSection
(
1
,
16
);
m_ui
.
editorList
->
setContextMenuPolicy
(
Qt
::
CustomContextMenu
);
m_ui
.
editorList
->
installEventFilter
(
this
);
connect
(
em
,
SIGNAL
(
currentEditorChanged
(
Core
::
IEditor
*
)),
this
,
SLOT
(
updateCurrentItem
(
Core
::
IEditor
*
)));
...
...
@@ -146,11 +146,29 @@ void OpenEditorsWidget::updateCurrentItem(Core::IEditor *editor)
m_ui
.
editorList
->
scrollTo
(
m_ui
.
editorList
->
currentIndex
());
}
bool
OpenEditorsWidget
::
eventFilter
(
QObject
*
obj
,
QEvent
*
event
)
{
if
(
obj
==
m_ui
.
editorList
&&
event
->
type
()
==
QEvent
::
KeyPress
&&
m_ui
.
editorList
->
currentIndex
().
isValid
())
{
QKeyEvent
*
ke
=
static_cast
<
QKeyEvent
*>
(
event
);
if
((
ke
->
key
()
==
Qt
::
Key_Return
||
ke
->
key
()
==
Qt
::
Key_Enter
)
&&
ke
->
modifiers
()
==
0
)
{
activateEditor
(
m_ui
.
editorList
->
currentIndex
());
return
true
;
}
else
if
((
ke
->
key
()
==
Qt
::
Key_Delete
||
ke
->
key
()
==
Qt
::
Key_Backspace
)
&&
ke
->
modifiers
()
==
0
)
{
closeEditor
(
m_ui
.
editorList
->
currentIndex
());
}
}
return
false
;
}
void
OpenEditorsWidget
::
handlePressed
(
const
QModelIndex
&
index
)
{
if
(
index
.
column
()
==
0
)
{
m_ui
.
editorList
->
selectionModel
()
->
select
(
index
,
QItemSelectionModel
::
ClearAndSelect
|
QItemSelectionModel
::
Rows
);
EditorManager
::
instance
()
->
activateEditor
(
index
);
activateEditor
(
index
);
}
else
if
(
index
.
column
()
==
1
)
{
m_delegate
->
pressedIndex
=
index
;
}
...
...
@@ -159,7 +177,7 @@ void OpenEditorsWidget::handlePressed(const QModelIndex &index)
void
OpenEditorsWidget
::
handleClicked
(
const
QModelIndex
&
index
)
{
if
(
index
.
column
()
==
1
)
{
// the funky close button
EditorManager
::
instance
()
->
closeEditor
(
index
);
closeEditor
(
index
);
// work around a bug in itemviews where the delegate wouldn't get the QStyle::State_MouseOver
QPoint
cursorPos
=
QCursor
::
pos
();
...
...
@@ -169,6 +187,19 @@ void OpenEditorsWidget::handleClicked(const QModelIndex &index)
}
}
void
OpenEditorsWidget
::
activateEditor
(
const
QModelIndex
&
index
)
{
m_ui
.
editorList
->
selectionModel
()
->
select
(
index
,
QItemSelectionModel
::
ClearAndSelect
|
QItemSelectionModel
::
Rows
);
EditorManager
::
instance
()
->
activateEditor
(
index
);
}
void
OpenEditorsWidget
::
closeEditor
(
const
QModelIndex
&
index
)
{
EditorManager
::
instance
()
->
closeEditor
(
index
);
// work around selection changes
updateCurrentItem
(
EditorManager
::
instance
()
->
currentEditor
());
}
void
OpenEditorsWidget
::
contextMenuRequested
(
QPoint
pos
)
{
const
QModelIndex
index
=
m_ui
.
editorList
->
indexAt
(
pos
);
...
...
This diff is collapsed.
Click to expand it.
src/plugins/coreplugin/editormanager/openeditorsview.h
+
5
−
0
View file @
e2ff5591
...
...
@@ -67,6 +67,8 @@ public:
OpenEditorsWidget
();
~
OpenEditorsWidget
();
bool
eventFilter
(
QObject
*
obj
,
QEvent
*
event
);
private
slots
:
void
handleClicked
(
const
QModelIndex
&
);
void
handlePressed
(
const
QModelIndex
&
);
...
...
@@ -74,6 +76,9 @@ private slots:
void
contextMenuRequested
(
QPoint
pos
);
private:
void
activateEditor
(
const
QModelIndex
&
index
);
void
closeEditor
(
const
QModelIndex
&
index
);
Ui
::
OpenEditorsView
m_ui
;
QWidget
*
m_widget
;
OpenEditorsDelegate
*
m_delegate
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment