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
Tobias Hunger
qt-creator
Commits
32f69b9b
Commit
32f69b9b
authored
Dec 20, 2010
by
Kai Koehne
Browse files
Outline: Add context menu for collapsing/expanding tree
Task-number: QTCREATORBUG-2976
parent
befd304c
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/plugins/cppeditor/cppoutline.cpp
View file @
32f69b9b
...
...
@@ -8,8 +8,9 @@
#include
<cplusplus/OverviewModel.h>
#include
<QtCore/QDebug>
#include
<QtGui/QVBoxLayout>
#include
<QtCore/QTimer>
#include
<QtGui/QVBoxLayout>
#include
<QtGui/QMenu>
using
namespace
CppEditor
::
Internal
;
...
...
@@ -25,6 +26,21 @@ CppOutlineTreeView::CppOutlineTreeView(QWidget *parent) :
setExpandsOnDoubleClick
(
false
);
}
void
CppOutlineTreeView
::
contextMenuEvent
(
QContextMenuEvent
*
event
)
{
if
(
!
event
)
return
;
QMenu
contextMenu
;
contextMenu
.
addAction
(
tr
(
"Expand All"
),
this
,
SLOT
(
expandAll
()));
contextMenu
.
addAction
(
tr
(
"Collapse All"
),
this
,
SLOT
(
collapseAll
()));
contextMenu
.
exec
(
event
->
globalPos
());
event
->
accept
();
}
CppOutlineFilterModel
::
CppOutlineFilterModel
(
CPlusPlus
::
OverviewModel
*
sourceModel
,
QObject
*
parent
)
:
QSortFilterProxyModel
(
parent
),
m_sourceModel
(
sourceModel
)
...
...
src/plugins/cppeditor/cppoutline.h
View file @
32f69b9b
...
...
@@ -17,6 +17,8 @@ class CppOutlineTreeView : public Utils::NavigationTreeView
Q_OBJECT
public:
CppOutlineTreeView
(
QWidget
*
parent
);
void
contextMenuEvent
(
QContextMenuEvent
*
event
);
};
class
CppOutlineFilterModel
:
public
QSortFilterProxyModel
...
...
src/plugins/qmljseditor/qmljsoutlinetreeview.cpp
View file @
32f69b9b
...
...
@@ -2,6 +2,7 @@
#include
"qmloutlinemodel.h"
#include
<utils/annotateditemdelegate.h>
#include
<QtGui/QMenu>
namespace
QmlJSEditor
{
namespace
Internal
{
...
...
@@ -26,5 +27,31 @@ QmlJSOutlineTreeView::QmlJSOutlineTreeView(QWidget *parent) :
setItemDelegateForColumn
(
0
,
itemDelegate
);
}
void
QmlJSOutlineTreeView
::
contextMenuEvent
(
QContextMenuEvent
*
event
)
{
if
(
!
event
)
return
;
QMenu
contextMenu
;
contextMenu
.
addAction
(
tr
(
"Expand All"
),
this
,
SLOT
(
expandAll
()));
contextMenu
.
addAction
(
tr
(
"Collapse All"
),
this
,
SLOT
(
collapseAllExceptRoot
()));
contextMenu
.
exec
(
event
->
globalPos
());
event
->
accept
();
}
void
QmlJSOutlineTreeView
::
collapseAllExceptRoot
()
{
if
(
!
model
())
return
;
const
QModelIndex
rootElementIndex
=
model
()
->
index
(
0
,
0
,
rootIndex
());
int
rowCount
=
model
()
->
rowCount
(
rootElementIndex
);
for
(
int
i
=
0
;
i
<
rowCount
;
++
i
)
{
collapse
(
model
()
->
index
(
i
,
0
,
rootElementIndex
));
}
}
}
// namespace Internal
}
// namespace QmlJSEditor
src/plugins/qmljseditor/qmljsoutlinetreeview.h
View file @
32f69b9b
...
...
@@ -11,6 +11,11 @@ class QmlJSOutlineTreeView : public Utils::NavigationTreeView
Q_OBJECT
public:
explicit
QmlJSOutlineTreeView
(
QWidget
*
parent
=
0
);
void
contextMenuEvent
(
QContextMenuEvent
*
event
);
private
slots
:
void
collapseAllExceptRoot
();
};
}
// namespace Internal
...
...
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