aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/valgrind/memcheckerrorview.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@theqtcompany.com>2015-02-11 16:12:58 +0100
committerChristian Kandeler <christian.kandeler@theqtcompany.com>2015-02-12 10:23:45 +0000
commitd9408156d12b625cc4db2187cb1a3a48e1414f78 (patch)
tree1fbe48002fa74c2825feade11db2250178f1bd90 /src/plugins/valgrind/memcheckerrorview.cpp
parent875d8890826a7939351c3b23b2eaddb090289834 (diff)
Analyzer: Put more common code into the DetailedError* base classes.
Namely: - The "copy" action and the corresponding "slot". - The context menu. Plus an infrastructure for adding new common and custom actions. Change-Id: I4bf8b28b4ad60b4022abbfc0b401c3b832b94560 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Diffstat (limited to 'src/plugins/valgrind/memcheckerrorview.cpp')
-rw-r--r--src/plugins/valgrind/memcheckerrorview.cpp57
1 files changed, 20 insertions, 37 deletions
diff --git a/src/plugins/valgrind/memcheckerrorview.cpp b/src/plugins/valgrind/memcheckerrorview.cpp
index f64c8e583b5..85c0ece2157 100644
--- a/src/plugins/valgrind/memcheckerrorview.cpp
+++ b/src/plugins/valgrind/memcheckerrorview.cpp
@@ -41,7 +41,6 @@
#include "xmlprotocol/modelhelpers.h"
#include "xmlprotocol/suppression.h"
-#include <coreplugin/coreconstants.h>
#include <coreplugin/editormanager/editormanager.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
@@ -52,12 +51,7 @@
#include <QDebug>
#include <QAction>
-#include <QApplication>
-#include <QClipboard>
-#include <QContextMenuEvent>
#include <QLabel>
-#include <QListView>
-#include <QMenu>
#include <QPainter>
#include <QScrollBar>
#include <QSortFilterProxyModel>
@@ -77,13 +71,12 @@ class MemcheckErrorDelegate : public Analyzer::DetailedErrorDelegate
public:
explicit MemcheckErrorDelegate(QListView *parent);
- void copy();
-
SummaryLineInfo summaryInfo(const QModelIndex &index) const;
private:
QWidget *createDetailsWidget(const QFont &font, const QModelIndex &errorIndex,
QWidget *parent) const;
+ QString textualRepresentation() const Q_DECL_OVERRIDE;
};
static QString makeFrameName(const Frame &frame, const QString &relativeTo,
@@ -261,9 +254,9 @@ Analyzer::DetailedErrorDelegate::SummaryLineInfo MemcheckErrorDelegate::summaryI
return info;
}
-void MemcheckErrorDelegate::copy()
+QString MemcheckErrorDelegate::textualRepresentation() const
{
- QTC_ASSERT(m_detailsIndex.isValid(), return);
+ QTC_ASSERT(m_detailsIndex.isValid(), return QString());
QString content;
QTextStream stream(&content);
@@ -283,7 +276,7 @@ void MemcheckErrorDelegate::copy()
}
stream.flush();
- QApplication::clipboard()->setText(content);
+ return content;
}
MemcheckErrorView::MemcheckErrorView(QWidget *parent)
@@ -293,14 +286,6 @@ MemcheckErrorView::MemcheckErrorView(QWidget *parent)
MemcheckErrorDelegate *delegate = new MemcheckErrorDelegate(this);
setItemDelegate(delegate);
- m_copyAction = new QAction(this);
- m_copyAction->setText(tr("Copy"));
- m_copyAction->setIcon(QIcon(QLatin1String(Core::Constants::ICON_COPY)));
- m_copyAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C));
- m_copyAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
- connect(m_copyAction, &QAction::triggered, delegate, &MemcheckErrorDelegate::copy);
- addAction(m_copyAction);
-
m_suppressAction = new QAction(this);
m_suppressAction->setText(tr("Suppress Error"));
m_suppressAction->setIcon(QIcon(QLatin1String(":/qmldesigner/images/eye_crossed.png")));
@@ -332,30 +317,28 @@ void MemcheckErrorView::settingsChanged(ValgrindBaseSettings *settings)
m_settings = settings;
}
-void MemcheckErrorView::contextMenuEvent(QContextMenuEvent *e)
+void MemcheckErrorView::suppressError()
+{
+ SuppressionDialog::maybeShow(this);
+}
+
+QList<QAction *> MemcheckErrorView::customActions() const
{
+ QList<QAction *> actions;
const QModelIndexList indizes = selectionModel()->selectedRows();
- if (indizes.isEmpty())
- return;
+ QTC_ASSERT(!indizes.isEmpty(), return actions);
- QList<Error> errors;
+ bool hasErrors = false;
foreach (const QModelIndex &index, indizes) {
Error error = model()->data(index, ErrorListModel::ErrorRole).value<Error>();
- if (!error.suppression().isNull())
- errors << error;
+ if (!error.suppression().isNull()) {
+ hasErrors = true;
+ break;
+ }
}
-
- QMenu menu;
- menu.addAction(m_copyAction);
- menu.addSeparator();
- menu.addAction(m_suppressAction);
- m_suppressAction->setEnabled(!errors.isEmpty());
- menu.exec(e->globalPos());
-}
-
-void MemcheckErrorView::suppressError()
-{
- SuppressionDialog::maybeShow(this);
+ m_suppressAction->setEnabled(hasErrors);
+ actions << m_suppressAction;
+ return actions;
}
} // namespace Internal