#include <cplusplus/OverviewModel.h>
#include <QtCore/QDebug>
-#include <QtGui/QVBoxLayout>
#include <QtCore/QTimer>
+#include <QtGui/QVBoxLayout>
+#include <QtGui/QMenu>
using namespace CppEditor::Internal;
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)
Q_OBJECT
public:
CppOutlineTreeView(QWidget *parent);
+
+ void contextMenuEvent(QContextMenuEvent *event);
};
class CppOutlineFilterModel : public QSortFilterProxyModel
#include "qmloutlinemodel.h"
#include <utils/annotateditemdelegate.h>
+#include <QtGui/QMenu>
namespace QmlJSEditor {
namespace Internal {
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
Q_OBJECT
public:
explicit QmlJSOutlineTreeView(QWidget *parent = 0);
+
+ void contextMenuEvent(QContextMenuEvent *event);
+
+private slots:
+ void collapseAllExceptRoot();
};
} // namespace Internal