diff --git a/app/plasma/runner/kdevelopsessions.cpp b/app/plasma/runner/kdevelopsessions.cpp index 463b3f489b..1d62f44bf7 100644 --- a/app/plasma/runner/kdevelopsessions.cpp +++ b/app/plasma/runner/kdevelopsessions.cpp @@ -1,183 +1,183 @@ /* * Copyright 2008,2011 Sebastian Kügler * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kdevelopsessions.h" #include #include #include #include #include #include #include #include #include #include #include K_EXPORT_PLASMA_RUNNER(kdevelopsessions, KDevelopSessions) bool kdevelopsessions_runner_compare_sessions(const Session &s1, const Session &s2) { QCollator c; return c.compare(s1.name, s2.name) < 0; } KDevelopSessions::KDevelopSessions(QObject *parent, const QVariantList& args) : Plasma::AbstractRunner(parent, args) { setObjectName(QStringLiteral("KDevelop Sessions")); setIgnoredTypes(Plasma::RunnerContext::File | Plasma::RunnerContext::Directory | Plasma::RunnerContext::NetworkLocation); m_icon = QIcon::fromTheme(QStringLiteral("kdevelop")); loadSessions(); // listen for changes to the list of kdevelop sessions KDirWatch *historyWatch = new KDirWatch(this); const QStringList sessiondirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("kdevelop/sessions"), QStandardPaths::LocateDirectory); for (const QString& dir : sessiondirs) { historyWatch->addDir(dir); } connect(historyWatch, &KDirWatch::dirty, this, &KDevelopSessions::loadSessions); connect(historyWatch, &KDirWatch::created, this, &KDevelopSessions::loadSessions); connect(historyWatch, &KDirWatch::deleted, this, &KDevelopSessions::loadSessions); Plasma::RunnerSyntax s(QStringLiteral(":q:"), i18n("Finds KDevelop sessions matching :q:.")); s.addExampleQuery(QStringLiteral("kdevelop :q:")); addSyntax(s); setDefaultSyntax(Plasma::RunnerSyntax(QStringLiteral("kdevelop"), i18n("Lists all the KDevelop editor sessions in your account."))); } KDevelopSessions::~KDevelopSessions() = default; QStringList findSessions() { const QStringList sessionDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("kdevelop/sessions"), QStandardPaths::LocateDirectory); QStringList sessionrcs; for (const QString& dir : sessionDirs) { QDir d(dir); Q_FOREACH(const QString& sessionDir, d.entryList(QDir::Dirs)) { QDir sd(d.absoluteFilePath(sessionDir)); QString path(sd.filePath(QStringLiteral("sessionrc"))); if(QFile::exists(path)) { sessionrcs += path; } } } return sessionrcs; } void KDevelopSessions::loadSessions() { m_sessions.clear(); // Switch kdevelop session: -u // Should we add a match for this option or would that clutter the matches too much? const QStringList list = findSessions(); m_sessions.reserve(list.size()); for (const QString& sessionfile : list) { Session session; - session.id = sessionfile.section('/', -2, -2); + session.id = sessionfile.section(QLatin1Char('/'), -2, -2); KConfig cfg(sessionfile, KConfig::SimpleConfig); KConfigGroup group = cfg.group(QString()); session.name = group.readEntry("SessionPrettyContents"); m_sessions << session; } std::sort(m_sessions.begin(), m_sessions.end(), kdevelopsessions_runner_compare_sessions); } void KDevelopSessions::match(Plasma::RunnerContext &context) { if (m_sessions.isEmpty()) { return; } QString term = context.query(); if (term.length() < 3) { return; } bool listAll = false; if (term.startsWith(QStringLiteral("kdevelop"), Qt::CaseInsensitive)) { if (term.trimmed().compare(QStringLiteral("kdevelop"), Qt::CaseInsensitive) == 0) { listAll = true; term.clear(); } else if (term.at(8) == QLatin1Char(' ') ) { term.remove(QStringLiteral("kdevelop"), Qt::CaseInsensitive); term = term.trimmed(); } else { term.clear(); } } if (term.isEmpty() && !listAll) { return; } foreach (const Session &session, m_sessions) { if (!context.isValid()) { return; } if (listAll || (!term.isEmpty() && session.name.contains(term, Qt::CaseInsensitive))) { Plasma::QueryMatch match(this); if (listAll) { // All sessions listed, but with a low priority match.setType(Plasma::QueryMatch::ExactMatch); match.setRelevance(0.8); } else { if (session.name.compare(term, Qt::CaseInsensitive) == 0) { // parameter to kdevelop matches session exactly, bump it up! match.setType(Plasma::QueryMatch::ExactMatch); match.setRelevance(1.0); } else { // fuzzy match of the session in "kdevelop $session" match.setType(Plasma::QueryMatch::PossibleMatch); match.setRelevance(0.8); } } match.setIcon(m_icon); match.setData(session.id); match.setText(session.name); match.setSubtext(i18n("Open KDevelop Session")); context.addMatch(match); } } } void KDevelopSessions::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) { Q_UNUSED(context) QString sessionId = match.data().toString(); if (sessionId.isEmpty()) { qWarning() << "No KDevelop session id in match!"; return; } qDebug() << "Open KDevelop session" << sessionId; const QStringList args = {QStringLiteral("--open-session"), sessionId}; KToolInvocation::kdeinitExec(QStringLiteral("kdevelop"), args); } #include "kdevelopsessions.moc" diff --git a/plugins/cppcheck/config/projectconfigpage.ui b/plugins/cppcheck/config/projectconfigpage.ui index 28d7c378c1..0724068eec 100644 --- a/plugins/cppcheck/config/projectconfigpage.ui +++ b/plugins/cppcheck/config/projectconfigpage.ui @@ -1,396 +1,396 @@ cppcheck::ProjectConfigPage 0 0 443 502 0 0 0 Checks Check for unused functions. It is recommend to only enable this when the whole program is scanned Unused function false Allow that Cppcheck reports even though the analysis is inconclusive. There are false positives with this option. Each result must be carefully investigated before you know if it is good or bad. Inconclusive analysis Enable information messages Information false Warn if there are missing includes. For detailed information use 'check-config' Missing include false Enable performance messages Performance false <p>Force checking of files that have a lot of configurations. Error is printed if such a file is found so there is no reason to use this by default. If used together with '--max-configs=', the last option is the one that is effective.<br/><br/>Be careful with using this option - it can dramatically slow checking.</p> Force checking Enable portability messages Portability false Enable all coding style checks. All messages with the severities 'style', 'performance' and 'portability' are enabled. Style false Check Cppcheck configuration. The normal code analysis is disabled by this flag. Check config - Include directories + Include Directories Add 'project' include directories to cppcheck arguments. This option adds only paths related with project's root and build directories. Use 'project' include dirs false false <p>Add other, 'system' include directories to cppcheck arguments.<br/><br/>Be careful with using this option - it can dramatically slow checking.</p> Use 'system' include dirs true false &Ignored includes: kcfg_ignoredIncludes <html> <p>Defines semicolon-separated list of ignored include directories.</p> <p>You can use the following placeholders:</p> <p><b><tt>%p</tt></b> - Gets replaced by the URL of the project's root directory.</p> <p><b><tt>%b</tt></b> - Gets replaced by the URL of the project's build directory.</p> </html> Qt::Vertical 20 40 - Extra parameters + Extra Parameters QLayout::SetDefaultConstraint Ex&tra parameters: kcfg_extraParameters <html> <p>Defines additional parameters for cppcheck (see documentation).</p> <p>You can use the following placeholders:</p> <p><b><tt>%p</tt></b> - Gets replaced by the URL of the project's root directory.</p> <p><b><tt>%b</tt></b> - Gets replaced by the URL of the project's build directory.</p> </html> Qt::Vertical 20 40 0 0 - Command line + Command Line Break lines true true true true false KMessageWidget::Error KFilterProxySearchLine QWidget
kfilterproxysearchline.h
KMessageWidget QFrame
kmessagewidget.h
tabWidget kcfg_checkStyle kcfg_checkPerformance kcfg_checkPortability kcfg_checkInformation kcfg_checkUnusedFunction kcfg_checkMissingInclude kcfg_inconclusiveAnalysis kcfg_forceCheck kcfg_checkConfig kcfg_useProjectIncludes kcfg_useSystemIncludes kcfg_ignoredIncludes kcfg_extraParameters commandLineBreaks commandLine kcfg_useProjectIncludes toggled(bool) kcfg_useSystemIncludes setEnabled(bool) 226 58 665 58
diff --git a/plugins/debuggercommon/tests/test_miparser.cpp b/plugins/debuggercommon/tests/test_miparser.cpp index 0261d6986b..0581da897c 100644 --- a/plugins/debuggercommon/tests/test_miparser.cpp +++ b/plugins/debuggercommon/tests/test_miparser.cpp @@ -1,221 +1,221 @@ /* This file is part of KDevelop * * Copyright 2018 Friedrich W. H. Kossebau * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "test_miparser.h" // SUT #include // Qt #include struct ResultData { QString name; QVariant value; }; struct ResultRecordData { uint32_t token; QString reason; QVector results; QVariant toVariant() { return QVariant::fromValue(*this); } }; Q_DECLARE_METATYPE(ResultRecordData) struct AsyncRecordData { int subkind; QString reason; QVector results; QVariant toVariant() { return QVariant::fromValue(*this); } }; Q_DECLARE_METATYPE(AsyncRecordData) struct StreamRecordData { int subkind; QString message; QVariant toVariant() { return QVariant::fromValue(*this); } }; Q_DECLARE_METATYPE(StreamRecordData) void TestMIParser::testParseLine_data() { QTest::addColumn("line"); QTest::addColumn("recordKind"); QTest::addColumn("recordData"); // prompt QTest::newRow("gdpprompt") << QByteArray("(gdb)") << (int)KDevMI::MI::Record::Prompt << QVariant(); // result records QTest::newRow("done") << QByteArray("^done") << (int)KDevMI::MI::Record::Result << ResultRecordData{0, "done", {}}.toVariant(); QTest::newRow("doneWToken") << QByteArray("11^done") << (int)KDevMI::MI::Record::Result << ResultRecordData{11, "done", {}}.toVariant(); QTest::newRow("runningWToken") << QByteArray("25^running") << (int)KDevMI::MI::Record::Result << ResultRecordData{25, "running", {}}.toVariant(); // Out-of-band records QTest::newRow("stopreply") << QByteArray("*stop,reason=\"stop\",address=\"0x123\",source=\"a.c:123\"") << (int)KDevMI::MI::Record::Async << AsyncRecordData{KDevMI::MI::AsyncRecord::Exec, "stop", {{"reason", "stop"}, {"address", "0x123"}, {"source", "a.c:123"}}}.toVariant(); QTest::newRow("threadgroupadded") << QByteArray("=thread-group-added,id=\"i1\"") << (int)KDevMI::MI::Record::Async << AsyncRecordData{KDevMI::MI::AsyncRecord::Notify, "thread-group-added", {{"id", "i1"}}}.toVariant(); QTest::newRow("symbolfilereply") << QByteArray("*breakpoint,nr=\"3\",address=\"0x123\",source=\"a.c:123\"") << (int)KDevMI::MI::Record::Async << AsyncRecordData{KDevMI::MI::AsyncRecord::Exec, "breakpoint", {{"nr", "3"}, {"address", "0x123"}, {"source", "a.c:123"}}}.toVariant(); // breakpoint creation records QTest::newRow("breakreply") << QByteArray("&\"break /path/to/some/file.cpp:28\\n\"") << (int)KDevMI::MI::Record::Stream << StreamRecordData{KDevMI::MI::StreamRecord::Log, "break /path/to/some/file.cpp:28\n"}.toVariant(); QTest::newRow("breakreply2") << QByteArray("~\"Breakpoint 1 at 0x400ab0: file /path/to/some/file.cpp, line 28.\\n\"") << (int)KDevMI::MI::Record::Stream << StreamRecordData{KDevMI::MI::StreamRecord::Console, "Breakpoint 1 at 0x400ab0: file /path/to/some/file.cpp, line 28.\n"}.toVariant(); QTest::newRow("breakreply3") << QByteArray("=breakpoint-created,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x0000000000400ab0\",func=\"main(int, char**)\",file=\"/path/to/some/file.cpp\",fullname=\"/path/to/some/file.cpp\",line=\"28\",thread-groups=[\"i1\"],times=\"0\",original-location=\"/path/to/some/file.cpp:28\"}") << (int)KDevMI::MI::Record::Async << AsyncRecordData{KDevMI::MI::AsyncRecord::Notify, "breakpoint-created", {{"bkpt", QVariantMap{ {"number", "1"}, {"type", "breakpoint"}, {"disp", "keep"}, {"enabled", "y"}, {"addr", "0x0000000000400ab0"}, {"func", "main(int, char**)"}, {"file", "/path/to/some/file.cpp"}, {"fullname", "/path/to/some/file.cpp"}, {"line", "28"}, {"thread-groups", QVariantList{"i1"}}, {"times", "0"}, {"original-location", "/path/to/some/file.cpp:28"}}}}}.toVariant(); } void TestMIParser::doTestResult(const KDevMI::MI::Value& actualValue, const QVariant& expectedValue) { if (expectedValue.type() == QVariant::String) { QCOMPARE((int)actualValue.kind, (int)KDevMI::MI::Value::StringLiteral); QCOMPARE(actualValue.literal(), expectedValue.toString()); } else if (expectedValue.type() == QVariant::List) { QCOMPARE(actualValue.kind, KDevMI::MI::Value::List); const auto expectedList = expectedValue.toList(); QCOMPARE(actualValue.size(), expectedList.size()); for (int i = 0; i < expectedList.size(); ++i) { doTestResult(actualValue[i], expectedList[i]); } } else if (expectedValue.type() == QVariant::Map) { QCOMPARE(actualValue.kind, KDevMI::MI::Value::Tuple); const auto expectedMap = expectedValue.toMap(); for (auto it = expectedMap.begin(), end = expectedMap.end(); it != end; ++it) { const auto& expectedMapField = it.key(); QVERIFY(actualValue.hasField(expectedMapField)); const auto& expectedMapValue = it.value(); doTestResult(actualValue[expectedMapField], expectedMapValue); } } else { QFAIL("Using unexpected QVariant type"); } } void TestMIParser::testParseLine() { QFETCH(QByteArray, line); QFETCH(int, recordKind); QFETCH(QVariant, recordData); KDevMI::MI::MIParser m_parser; KDevMI::MI::FileSymbol file; file.contents = line; std::unique_ptr record(m_parser.parse(&file)); - QVERIFY(record); + QVERIFY(record != nullptr); QCOMPARE((int)record->kind, recordKind); switch(recordKind) { case KDevMI::MI::Record::Result: { const auto& resultRecord = static_cast(*record); const auto resultData = recordData.value(); QCOMPARE(resultRecord.token, resultData.token); QCOMPARE(resultRecord.reason, resultData.reason); for (const auto& result : resultData.results) { QVERIFY(resultRecord.hasField(result.name)); doTestResult(resultRecord[result.name], result.value); } break; } case KDevMI::MI::Record::Async: { const auto& asyncRecord = static_cast(*record); const auto asyncData = recordData.value(); QCOMPARE((int)asyncRecord.subkind, asyncData.subkind); QCOMPARE(asyncRecord.reason, asyncData.reason); for (const auto& result : asyncData.results) { QVERIFY(asyncRecord.hasField(result.name)); doTestResult(asyncRecord[result.name], result.value); } break; } case KDevMI::MI::Record::Stream: { const auto& streamRecord = static_cast(*record); const auto streamData = recordData.value(); QCOMPARE((int)streamRecord.subkind, streamData.subkind); QCOMPARE(streamRecord.message, streamData.message); break; } case KDevMI::MI::Record::Prompt: break; } } QTEST_GUILESS_MAIN(TestMIParser) diff --git a/plugins/filemanager/bookmarkhandler.cpp b/plugins/filemanager/bookmarkhandler.cpp index c0de1f6f1a..0cdc4516f5 100644 --- a/plugins/filemanager/bookmarkhandler.cpp +++ b/plugins/filemanager/bookmarkhandler.cpp @@ -1,74 +1,74 @@ /* This file is part of the KDE project Copyright (C) xxxx KFile Authors Copyright (C) 2002 Anders Lund Copyright (C) 2009 Dominik Haumann Copyright (C) 2007 Mirko Stocker Copyright (C) 2012 Niko Sams This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "bookmarkhandler.h" #include "filemanager.h" #include "kdevfilemanagerplugin.h" #include "debug.h" #include #include #include BookmarkHandler::BookmarkHandler( FileManager *parent, QMenu* kpopupmenu ) : QObject( parent ), KBookmarkOwner(), m_parent( parent ), m_menu( kpopupmenu ) { setObjectName( QStringLiteral( "BookmarkHandler" ) ); QUrl bookmarksPath = KDevelop::ICore::self()->activeSession()->pluginDataArea(parent->plugin()); - bookmarksPath.setPath(bookmarksPath.path() + "fsbookmarks.xml"); + bookmarksPath.setPath(bookmarksPath.path() + QLatin1String("fsbookmarks.xml")); qCDebug(PLUGIN_FILEMANAGER) << bookmarksPath; KBookmarkManager *manager = KBookmarkManager::managerForFile( bookmarksPath.toLocalFile(), QStringLiteral( "kdevplatform" ) ); manager->setUpdate( true ); m_bookmarkMenu = new KBookmarkMenu( manager, this, m_menu, parent->actionCollection() ); //remove shortcuts as they might conflict with others (eg. Ctrl+B) foreach (QAction *action, parent->actionCollection()->actions()) { action->setShortcut(QKeySequence()); } } BookmarkHandler::~BookmarkHandler() { delete m_bookmarkMenu; } QUrl BookmarkHandler::currentUrl() const { return m_parent->dirOperator()->url(); } QString BookmarkHandler::currentTitle() const { return currentUrl().toDisplayString(); } void BookmarkHandler::openBookmark( const KBookmark & bm, Qt::MouseButtons, Qt::KeyboardModifiers ) { emit openUrl(bm.url()); } diff --git a/plugins/ghprovider/CMakeLists.txt b/plugins/ghprovider/CMakeLists.txt index 102fcd86b1..0740394260 100644 --- a/plugins/ghprovider/CMakeLists.txt +++ b/plugins/ghprovider/CMakeLists.txt @@ -1,28 +1,27 @@ add_definitions(-DTRANSLATION_DOMAIN=\"kdevghprovider\") -set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) add_subdirectory(icons) set(kdevghprovider_PART_SRCS ghlineedit.cpp ghprovidermodel.cpp ghproviderplugin.cpp ghproviderwidget.cpp ghresource.cpp ghaccount.cpp ghdialog.cpp ) ecm_qt_declare_logging_category(kdevghprovider_PART_SRCS HEADER debug.h IDENTIFIER GHPROVIDER CATEGORY_NAME "kdevelop.plugins.ghprovider" ) kdevplatform_add_plugin(kdevghprovider JSON kdevghprovider.json SOURCES ${kdevghprovider_PART_SRCS}) target_link_libraries(kdevghprovider KF5::KIOWidgets KDev::Interfaces KDev::Vcs KDev::OutputView KDev::Util ) diff --git a/plugins/standardoutputview/standardoutputview.cpp b/plugins/standardoutputview/standardoutputview.cpp index cb94401d5f..26e8113176 100644 --- a/plugins/standardoutputview/standardoutputview.cpp +++ b/plugins/standardoutputview/standardoutputview.cpp @@ -1,305 +1,305 @@ /* KDevelop Standard OutputView * * Copyright 2006-2007 Andreas Pakulat * Copyright 2007 Dukju Ahn * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ #include "standardoutputview.h" #include "outputwidget.h" #include "toolviewdata.h" #include "debug.h" #include #include #include #include #include #include #include #include #include #include #include class OutputViewFactory : public KDevelop::IToolViewFactory{ public: explicit OutputViewFactory(const ToolViewData* data): m_data(data) {} QWidget* create(QWidget *parent = nullptr) override { return new OutputWidget( parent, m_data ); } Qt::DockWidgetArea defaultPosition() override { return Qt::BottomDockWidgetArea; } void viewCreated( Sublime::View* view ) override { m_data->views << view; } QString id() const override { //NOTE: id must be unique, see e.g. https://bugs.kde.org/show_bug.cgi?id=287093 - return "org.kdevelop.OutputView." + QString::number(m_data->toolViewId); + return QStringLiteral("org.kdevelop.OutputView.%1").arg(m_data->toolViewId); } private: const ToolViewData *m_data; }; StandardOutputView::StandardOutputView(QObject *parent, const QVariantList &) : KDevelop::IPlugin(QStringLiteral("kdevstandardoutputview"), parent) { setXMLFile(QStringLiteral("kdevstandardoutputview.rc")); connect(KDevelop::ICore::self()->uiController()->controller(), &Sublime::Controller::aboutToRemoveView, this, &StandardOutputView::removeSublimeView); } void StandardOutputView::removeSublimeView( Sublime::View* v ) { foreach (ToolViewData* d, m_toolViews) { if( d->views.contains(v) ) { if( d->views.count() == 1 ) { m_toolViews.remove(d->toolViewId); m_ids.removeAll( d->toolViewId ); delete d; } else { d->views.removeAll(v); } } } } StandardOutputView::~StandardOutputView() { } int StandardOutputView::standardToolView( KDevelop::IOutputView::StandardToolView view ) { if( m_standardViews.contains( view ) ) { return m_standardViews.value( view ); } int ret = -1; switch( view ) { case KDevelop::IOutputView::BuildView: { ret = registerToolView( i18nc("@title:window", "Build"), KDevelop::IOutputView::HistoryView, QIcon::fromTheme(QStringLiteral("run-build")), KDevelop::IOutputView::AddFilterAction ); break; } case KDevelop::IOutputView::RunView: { ret = registerToolView( i18nc("@title:window", "Run"), KDevelop::IOutputView::MultipleView, QIcon::fromTheme(QStringLiteral("system-run")), KDevelop::IOutputView::AddFilterAction ); break; } case KDevelop::IOutputView::DebugView: { ret = registerToolView( i18nc("@title:window", "Debug"), KDevelop::IOutputView::MultipleView, QIcon::fromTheme(QStringLiteral("debug-step-into")), KDevelop::IOutputView::AddFilterAction ); break; } case KDevelop::IOutputView::TestView: { ret = registerToolView( i18nc("@title:window", "Test"), KDevelop::IOutputView::HistoryView, QIcon::fromTheme(QStringLiteral("system-run"))); break; } case KDevelop::IOutputView::VcsView: { ret = registerToolView( i18nc("@title:window", "Version Control"), KDevelop::IOutputView::HistoryView, QIcon::fromTheme(QStringLiteral("system-run"))); break; } } Q_ASSERT(ret != -1); m_standardViews[view] = ret; return ret; } int StandardOutputView::registerToolView( const QString& title, KDevelop::IOutputView::ViewType type, const QIcon& icon, Options option, const QList& actionList ) { // try to reuse existing tool view foreach (ToolViewData* d, m_toolViews) { if ( d->type == type && d->title == title ) { return d->toolViewId; } } // register new tool view const int newid = m_ids.isEmpty() ? 0 : (m_ids.last() + 1); qCDebug(PLUGIN_STANDARDOUTPUTVIEW) << "Registering view" << title << "with type:" << type << "id:" << newid; ToolViewData* tvdata = new ToolViewData( this ); tvdata->toolViewId = newid; tvdata->type = type; tvdata->title = title; tvdata->icon = icon; tvdata->plugin = this; tvdata->option = option; tvdata->actionList = actionList; core()->uiController()->addToolView( title, new OutputViewFactory( tvdata ) ); m_ids << newid; m_toolViews[newid] = tvdata; return newid; } int StandardOutputView::registerOutputInToolView( int toolViewId, const QString& title, KDevelop::IOutputView::Behaviours behaviour ) { if (!m_toolViews.contains(toolViewId)) return -1; int newid; if( m_ids.isEmpty() ) { newid = 0; } else { newid = m_ids.last()+1; } m_ids << newid; m_toolViews.value(toolViewId)->addOutput(newid, title, behaviour); return newid; } void StandardOutputView::raiseOutput(int outputId) { foreach (int _id, m_toolViews.keys()) { if (m_toolViews.value(_id)->outputdata.contains(outputId)) { foreach (Sublime::View* v, m_toolViews.value(_id)->views) { if( v->hasWidget() ) { OutputWidget* w = qobject_cast( v->widget() ); w->raiseOutput( outputId ); v->requestRaise(); } } } } } void StandardOutputView::setModel( int outputId, QAbstractItemModel* model ) { int tvid = -1; foreach (int _id, m_toolViews.keys()) { if (m_toolViews.value( _id)->outputdata.contains(outputId)) { tvid = _id; break; } } if( tvid == -1 ) qCDebug(PLUGIN_STANDARDOUTPUTVIEW) << "Trying to set model on unknown view-id:" << outputId; else { m_toolViews.value(tvid)->outputdata.value(outputId)->setModel(model); } } void StandardOutputView::setDelegate( int outputId, QAbstractItemDelegate* delegate ) { int tvid = -1; foreach (int _id, m_toolViews.keys()) { if (m_toolViews.value(_id)->outputdata.contains(outputId)) { tvid = _id; break; } } if( tvid == -1 ) qCDebug(PLUGIN_STANDARDOUTPUTVIEW) << "Trying to set model on unknown view-id:" << outputId; else { m_toolViews.value(tvid)->outputdata.value(outputId)->setDelegate(delegate); } } void StandardOutputView::removeToolView(int toolViewId) { if (m_toolViews.contains(toolViewId)) { ToolViewData* td = m_toolViews.value(toolViewId); foreach( Sublime::View* view, td->views ) { if( view->hasWidget() ) { OutputWidget* outputWidget = qobject_cast( view->widget() ); foreach( int outid, td->outputdata.keys() ) { outputWidget->removeOutput( outid ); } } foreach( Sublime::Area* area, KDevelop::ICore::self()->uiController()->controller()->allAreas() ) { area->removeToolView( view ); } } delete td; m_toolViews.remove(toolViewId); emit toolViewRemoved(toolViewId); } } OutputWidget* StandardOutputView::outputWidgetForId( int outputId ) const { for (ToolViewData* td : m_toolViews) { if( td->outputdata.contains( outputId ) ) { foreach( Sublime::View* view, td->views ) { if( view->hasWidget() ) return qobject_cast( view->widget() ); } } } return nullptr; } void StandardOutputView::scrollOutputTo( int outputId, const QModelIndex& idx ) { OutputWidget* widget = outputWidgetForId( outputId ); if( widget ) widget->scrollToIndex( idx ); } void StandardOutputView::removeOutput( int outputId ) { foreach (ToolViewData* td, m_toolViews) { if( td->outputdata.contains( outputId ) ) { foreach( Sublime::View* view, td->views ) { if( view->hasWidget() ) qobject_cast( view->widget() )->removeOutput( outputId ); } td->outputdata.remove( outputId ); } } } void StandardOutputView::setTitle(int outputId, const QString& title) { OutputWidget* widget = outputWidgetForId(outputId); if (widget) { widget->setTitle(outputId, title); } } diff --git a/plugins/welcomepage/uihelper.cpp b/plugins/welcomepage/uihelper.cpp index 955bdb4ee7..8ced94a74a 100644 --- a/plugins/welcomepage/uihelper.cpp +++ b/plugins/welcomepage/uihelper.cpp @@ -1,86 +1,86 @@ /* This file is part of KDevelop Copyright 2010 Aleix Pol Gonzalez This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "uihelper.h" #include "debug.h" #include #include #include #include #include #include #include using namespace KDevelop; UiHelper::UiHelper(QObject* parent): QObject(parent) {} QAction* findActionRec(const QStringList& path, const QList& actions) { QStringList newPath = path; QString current = newPath.takeFirst(); for (QAction* a : actions) { if(a->objectName() == current) { if(newPath.isEmpty()) return a; else if(a->menu()) return findActionRec(newPath, a->menu()->actions()); else qCDebug(PLUGIN_WELCOMEPAGE) << "shouldn't get here:" << path; } } qWarning() << "error: action path not found: " << path; return nullptr; } QAction* UiHelper::retrieveMenuAction(const QString& menuPath) { QMenuBar* m = ICore::self()->uiController()->activeMainWindow()->menuBar(); - - QAction* a=findActionRec(menuPath.split('/'), m->actions()); + + QAction* a = findActionRec(menuPath.split(QLatin1Char('/')), m->actions()); return a; } void UiHelper::setArea(const QString& name) { ICore::self()->uiController()->switchToArea(name, IUiController::ThisWindow); } void UiHelper::raiseToolView(const QString& id) { const QList views = ICore::self()->uiController()->activeArea()->toolViews(); for (Sublime::View* v : views) { QWidget* w=v->widget(); if(w && id==w->objectName()) ICore::self()->uiController()->raiseToolView(w); } } void UiHelper::showMenu(const QString& name) { QAction* action = retrieveMenuAction(name); Q_ASSERT(action); Q_ASSERT(action->menu()); action->menu()->popup(QCursor::pos()); }