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/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/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()); }