Commit 19476fb7 authored by Christian Kandeler's avatar Christian Kandeler

Adapt to API change in mainline Creator.

Change-Id: If1028fcf28373d99394d081c98e5cbc46aca81c5
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent 2946364c
......@@ -21,19 +21,12 @@
#include "clangstaticanalyzerlogfilereader.h"
#include "clangstaticanalyzerutils.h"
#include <coreplugin/coreconstants.h>
#include <utils/qtcassert.h>
#include <QAction>
#include <QApplication>
#include <QClipboard>
#include <QContextMenuEvent>
#include <QCoreApplication>
#include <QDebug>
#include <QFileInfo>
#include <QLabel>
#include <QMenu>
#include <QVBoxLayout>
using namespace Analyzer;
......@@ -203,32 +196,6 @@ DetailedErrorDelegate::SummaryLineInfo ClangStaticAnalyzerDiagnosticDelegate::su
return info;
}
void ClangStaticAnalyzerDiagnosticDelegate::copy()
{
QTC_ASSERT(m_detailsIndex.isValid(), return);
const Diagnostic diagnostic = m_detailsIndex.data(Qt::UserRole).value<Diagnostic>();
QTC_ASSERT(diagnostic.isValid(), return);
// Create summary
QString clipboardText = diagnostic.category + QLatin1String(": ") + diagnostic.type;
if (diagnostic.type != diagnostic.description)
clipboardText += QLatin1String(": ") + diagnostic.description;
clipboardText += QLatin1Char('\n');
// Create explaining steps
int explainingStepNumber = 1;
foreach (const ExplainingStep &explainingStep, diagnostic.explainingSteps) {
clipboardText += createExplainingStepString(explainingStep,
explainingStepNumber++,
/*withMarkup=*/ false,
/*withAbsolutePath=*/ true) + QLatin1Char('\n');
}
clipboardText.chop(1); // Remove \n
QApplication::clipboard()->setText(clipboardText);
}
QWidget *ClangStaticAnalyzerDiagnosticDelegate::createDetailsWidget(const QFont &font,
const QModelIndex &index,
QWidget *parent) const
......@@ -269,31 +236,38 @@ QWidget *ClangStaticAnalyzerDiagnosticDelegate::createDetailsWidget(const QFont
return widget;
}
QString ClangStaticAnalyzerDiagnosticDelegate::textualRepresentation() const
{
QTC_ASSERT(m_detailsIndex.isValid(), return QString());
const Diagnostic diagnostic = m_detailsIndex.data(Qt::UserRole).value<Diagnostic>();
QTC_ASSERT(diagnostic.isValid(), return QString());
// Create summary
QString clipboardText = diagnostic.category + QLatin1String(": ") + diagnostic.type;
if (diagnostic.type != diagnostic.description)
clipboardText += QLatin1String(": ") + diagnostic.description;
clipboardText += QLatin1Char('\n');
// Create explaining steps
int explainingStepNumber = 1;
foreach (const ExplainingStep &explainingStep, diagnostic.explainingSteps) {
clipboardText += createExplainingStepString(explainingStep,
explainingStepNumber++,
/*withMarkup=*/ false,
/*withAbsolutePath=*/ true) + QLatin1Char('\n');
}
clipboardText.chop(1); // Remove \n
return clipboardText;
}
ClangStaticAnalyzerDiagnosticView::ClangStaticAnalyzerDiagnosticView(QWidget *parent)
: Analyzer::DetailedErrorView(parent)
{
ClangStaticAnalyzerDiagnosticDelegate *delegate
= new ClangStaticAnalyzerDiagnosticDelegate(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, &ClangStaticAnalyzerDiagnosticDelegate::copy);
addAction(m_copyAction);
}
void ClangStaticAnalyzerDiagnosticView::contextMenuEvent(QContextMenuEvent *e)
{
if (selectionModel()->selectedRows().isEmpty())
return;
QMenu menu;
menu.addAction(m_copyAction);
menu.exec(e->globalPos());
}
} // namespace Internal
......
......@@ -30,11 +30,6 @@ class ClangStaticAnalyzerDiagnosticView : public Analyzer::DetailedErrorView
public:
ClangStaticAnalyzerDiagnosticView(QWidget *parent = 0);
private:
void contextMenuEvent(QContextMenuEvent *e);
QAction *m_copyAction;
};
class ClangStaticAnalyzerDiagnosticDelegate : public Analyzer::DetailedErrorDelegate
......@@ -43,11 +38,11 @@ public:
ClangStaticAnalyzerDiagnosticDelegate(QListView *parent);
SummaryLineInfo summaryInfo(const QModelIndex &index) const;
void copy();
private:
QWidget *createDetailsWidget(const QFont &font, const QModelIndex &index,
QWidget *parent) const;
QString textualRepresentation() const Q_DECL_OVERRIDE;
};
} // namespace Internal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment