Changeset View
Changeset View
Standalone View
Standalone View
addons/project/kateprojectinfoviewcodeanalysis.cpp
Show All 17 Lines | |||||
18 | * Boston, MA 02110-1301, USA. | 18 | * Boston, MA 02110-1301, USA. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "kateprojectinfoviewcodeanalysis.h" | 21 | #include "kateprojectinfoviewcodeanalysis.h" | ||
22 | #include "kateprojectpluginview.h" | 22 | #include "kateprojectpluginview.h" | ||
23 | #include "kateprojectcodeanalysistool.h" | 23 | #include "kateprojectcodeanalysistool.h" | ||
24 | #include "tools/kateprojectcodeanalysisselector.h" | 24 | #include "tools/kateprojectcodeanalysisselector.h" | ||
25 | 25 | | |||
26 | #include <QVBoxLayout> | | |||
27 | #include <QHBoxLayout> | | |||
28 | #include <QFileInfo> | 26 | #include <QFileInfo> | ||
27 | #include <QHBoxLayout> | ||||
28 | #include <QVBoxLayout> | ||||
29 | #include <QToolTip> | ||||
29 | 30 | | |||
30 | #include <klocalizedstring.h> | 31 | #include <klocalizedstring.h> | ||
31 | #include <kmessagewidget.h> | 32 | #include <kmessagewidget.h> | ||
32 | 33 | | |||
33 | KateProjectInfoViewCodeAnalysis::KateProjectInfoViewCodeAnalysis(KateProjectPluginView *pluginView, KateProject *project) | 34 | KateProjectInfoViewCodeAnalysis::KateProjectInfoViewCodeAnalysis(KateProjectPluginView *pluginView, KateProject *project) | ||
34 | : QWidget() | 35 | : QWidget() | ||
35 | , m_pluginView(pluginView) | 36 | , m_pluginView(pluginView) | ||
36 | , m_project(project) | 37 | , m_project(project) | ||
Show All 21 Lines | 45 | { | |||
58 | m_treeView->setModel(m_model); | 59 | m_treeView->setModel(m_model); | ||
59 | delete m; | 60 | delete m; | ||
60 | 61 | | |||
61 | m_treeView->setSortingEnabled(true); | 62 | m_treeView->setSortingEnabled(true); | ||
62 | m_treeView->sortByColumn(1, Qt::AscendingOrder); | 63 | m_treeView->sortByColumn(1, Qt::AscendingOrder); | ||
63 | m_treeView->sortByColumn(2, Qt::AscendingOrder); | 64 | m_treeView->sortByColumn(2, Qt::AscendingOrder); | ||
64 | 65 | | |||
65 | /** | 66 | /** | ||
66 | * attach model to code analysis selector | 67 | * Connect selection change callback | ||
68 | * and attach model to code analysis selector | ||||
67 | */ | 69 | */ | ||
70 | connect(m_toolSelector, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), | ||||
71 | this, &KateProjectInfoViewCodeAnalysis::slotToolSelectionChanged); | ||||
68 | m_toolSelector->setModel(KateProjectCodeAnalysisSelector::model(this)); | 72 | m_toolSelector->setModel(KateProjectCodeAnalysisSelector::model(this)); | ||
69 | 73 | | |||
70 | /** | 74 | /** | ||
71 | * layout widget | 75 | * layout widget | ||
72 | */ | 76 | */ | ||
73 | QVBoxLayout *layout = new QVBoxLayout; | 77 | QVBoxLayout *layout = new QVBoxLayout; | ||
74 | layout->setSpacing(0); | 78 | layout->setSpacing(0); | ||
75 | layout->addWidget(m_treeView); | 79 | // top: selector and buttons... | ||
76 | QHBoxLayout *hlayout = new QHBoxLayout; | 80 | QHBoxLayout *hlayout = new QHBoxLayout; | ||
77 | layout->addLayout(hlayout); | 81 | layout->addLayout(hlayout); | ||
78 | hlayout->setSpacing(0); | 82 | hlayout->setSpacing(0); | ||
79 | hlayout->addStretch(); | | |||
80 | hlayout->addWidget(m_toolSelector); | 83 | hlayout->addWidget(m_toolSelector); | ||
84 | auto infoButton = new QPushButton(QIcon::fromTheme(QStringLiteral("documentinfo")), QString(), this); | ||||
85 | infoButton->setFocusPolicy(Qt::FocusPolicy::TabFocus); | ||||
86 | connect(infoButton, &QPushButton::clicked, this, | ||||
87 | [this]() { | ||||
88 | QToolTip::showText(QCursor::pos(), m_toolInfoText); | ||||
89 | }); | ||||
90 | hlayout->addWidget(infoButton); | ||||
81 | hlayout->addWidget(m_startStopAnalysis); | 91 | hlayout->addWidget(m_startStopAnalysis); | ||
92 | hlayout->addStretch(); | ||||
93 | // below: result list... | ||||
94 | layout->addWidget(m_treeView); | ||||
82 | setLayout(layout); | 95 | setLayout(layout); | ||
83 | 96 | | |||
84 | /** | 97 | /** | ||
85 | * connect needed signals | 98 | * connect needed signals | ||
86 | */ | 99 | */ | ||
87 | connect(m_startStopAnalysis, &QPushButton::clicked, this, &KateProjectInfoViewCodeAnalysis::slotStartStopClicked); | 100 | connect(m_startStopAnalysis, &QPushButton::clicked, this, &KateProjectInfoViewCodeAnalysis::slotStartStopClicked); | ||
88 | connect(m_treeView, &QTreeView::clicked, this, &KateProjectInfoViewCodeAnalysis::slotClicked); | 101 | connect(m_treeView, &QTreeView::clicked, this, &KateProjectInfoViewCodeAnalysis::slotClicked); | ||
89 | } | 102 | } | ||
90 | 103 | | |||
91 | KateProjectInfoViewCodeAnalysis::~KateProjectInfoViewCodeAnalysis() | 104 | KateProjectInfoViewCodeAnalysis::~KateProjectInfoViewCodeAnalysis() | ||
92 | { | 105 | { | ||
93 | } | 106 | } | ||
94 | 107 | | |||
108 | void KateProjectInfoViewCodeAnalysis::slotToolSelectionChanged(int) | ||||
109 | { | ||||
110 | m_analysisTool = m_toolSelector->currentData(Qt::UserRole + 1).value<KateProjectCodeAnalysisTool*>(); | ||||
111 | m_toolInfoText = i18n("The selected tool will be run on all project files which match this list of file extensions:<br/><b>%1</b>", | ||||
dhaumann: Why are there leading spaces in the label? Usually, spacing is up to the QStyle. | |||||
gregormi: Fixed by using a button which is much less obstrusive | |||||
112 | m_analysisTool->fileExtensions()); | ||||
113 | } | ||||
114 | | ||||
95 | void KateProjectInfoViewCodeAnalysis::slotStartStopClicked() | 115 | void KateProjectInfoViewCodeAnalysis::slotStartStopClicked() | ||
96 | { | 116 | { | ||
97 | /** | 117 | /** | ||
98 | * get files for the external tool | 118 | * get files for the external tool | ||
99 | */ | 119 | */ | ||
100 | m_analysisTool = m_toolSelector->currentData(Qt::UserRole + 1).value<KateProjectCodeAnalysisTool*>(); | 120 | m_analysisTool = m_toolSelector->currentData(Qt::UserRole + 1).value<KateProjectCodeAnalysisTool*>(); | ||
101 | m_analysisTool->setProject(m_project); | 121 | m_analysisTool->setProject(m_project); | ||
102 | 122 | | |||
Show All 20 Lines | |||||
123 | } | 143 | } | ||
124 | 144 | | |||
125 | if (!m_analyzer->waitForStarted()) { | 145 | if (!m_analyzer->waitForStarted()) { | ||
126 | m_messageWidget = new KMessageWidget(); | 146 | m_messageWidget = new KMessageWidget(); | ||
127 | m_messageWidget->setCloseButtonVisible(true); | 147 | m_messageWidget->setCloseButtonVisible(true); | ||
128 | m_messageWidget->setMessageType(KMessageWidget::Warning); | 148 | m_messageWidget->setMessageType(KMessageWidget::Warning); | ||
129 | m_messageWidget->setWordWrap(false); | 149 | m_messageWidget->setWordWrap(false); | ||
130 | m_messageWidget->setText(m_analysisTool->notInstalledMessage()); | 150 | m_messageWidget->setText(m_analysisTool->notInstalledMessage()); | ||
131 | static_cast<QVBoxLayout *>(layout())->insertWidget(0, m_messageWidget); | 151 | static_cast<QVBoxLayout *>(layout())->addWidget(m_messageWidget); | ||
132 | m_messageWidget->animatedShow(); | 152 | m_messageWidget->animatedShow(); | ||
133 | return; | 153 | return; | ||
134 | } | 154 | } | ||
135 | /** | 155 | /** | ||
136 | * write files list and close write channel | 156 | * write files list and close write channel | ||
137 | */ | 157 | */ | ||
138 | const QString stdinMessage = m_analysisTool->stdinMessages(); | 158 | const QString stdinMessage = m_analysisTool->stdinMessages(); | ||
139 | if (!stdinMessage.isEmpty()) { | 159 | if (!stdinMessage.isEmpty()) { | ||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | 237 | if (exitCode == 0) { | |||
218 | m_messageWidget->setMessageType(KMessageWidget::Information); | 238 | m_messageWidget->setMessageType(KMessageWidget::Information); | ||
219 | m_messageWidget->setText(i18n("Analysis finished.")); | 239 | m_messageWidget->setText(i18n("Analysis finished.")); | ||
220 | } else { | 240 | } else { | ||
221 | // unfortunately, output was eaten by slotReadyRead() | 241 | // unfortunately, output was eaten by slotReadyRead() | ||
222 | // TODO: get stderr output, show it here | 242 | // TODO: get stderr output, show it here | ||
223 | m_messageWidget->setMessageType(KMessageWidget::Warning); | 243 | m_messageWidget->setMessageType(KMessageWidget::Warning); | ||
224 | m_messageWidget->setText(i18n("Analysis failed!")); | 244 | m_messageWidget->setText(i18n("Analysis failed!")); | ||
225 | } | 245 | } | ||
226 | static_cast<QVBoxLayout*>(layout ())->insertWidget(0, m_messageWidget); | 246 | static_cast<QVBoxLayout*>(layout ())->addWidget(m_messageWidget); | ||
227 | m_messageWidget->animatedShow (); | 247 | m_messageWidget->animatedShow (); | ||
228 | } | 248 | } |
Why are there leading spaces in the label? Usually, spacing is up to the QStyle.