diff --git a/debugger/framestack/framestackwidget.h b/debugger/framestack/framestackwidget.h index 78ec2c796d..09f900f917 100644 --- a/debugger/framestack/framestackwidget.h +++ b/debugger/framestack/framestackwidget.h @@ -1,70 +1,70 @@ /* * This file is part of KDevelop * * Copyright 1999 John Birch * Copyright 2007 Hamish Rodda * Copyright 2009 Niko Sams * * 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. */ #ifndef KDEVPLATFORM_FRAMESTACKWIDGET_H #define KDEVPLATFORM_FRAMESTACKWIDGET_H #include #include #include class QMenu; class QTreeView; class QModelIndex; class QListView; namespace KDevelop { class IDebugController; class KDEVPLATFORMDEBUGGER_EXPORT FramestackWidget : public AutoOrientedSplitter { Q_OBJECT public: - explicit FramestackWidget( IDebugController* controller, QWidget *parent=0 ); + explicit FramestackWidget( IDebugController* controller, QWidget *parent=nullptr ); ~FramestackWidget() override; Q_SIGNALS: void requestRaise(); private Q_SLOTS: void currentSessionChanged(KDevelop::IDebugSession* session); void setThreadShown(const QModelIndex& current); void checkFetchMoreFrames(); void currentThreadChanged(int); void currentFrameChanged(int); void frameSelectionChanged(const QModelIndex& current); void frameContextMenuRequested(const QPoint &pos); void copySelection(); void selectAll(); void sessionStateChanged(KDevelop::IDebugSession::DebuggerState state); private: IDebugSession *m_session; QListView *m_threadsListView; QWidget *m_threadsWidget; QTreeView *m_framesTreeView; QMenu *m_framesContextMenu; }; } #endif // KDEVPLATFORM_FRAMESTACKWIDGET_H diff --git a/debugger/util/pathmappings.h b/debugger/util/pathmappings.h index 2ea94564ef..ef49e46fae 100644 --- a/debugger/util/pathmappings.h +++ b/debugger/util/pathmappings.h @@ -1,67 +1,67 @@ /* * This file is part of KDevelop * * Copyright 2009 Niko Sams * * 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. */ #ifndef KDEVPLATFORM_PATHMAPPINGSWIDGET_H #define KDEVPLATFORM_PATHMAPPINGSWIDGET_H #include #include #include #include class QTableView; namespace KDevelop { class KDEVPLATFORMDEBUGGER_EXPORT PathMappings { public: static const QString pathMappingsEntry; static const QString pathMappingRemoteEntry; static const QString pathMappingLocalEntry; static QUrl convertToLocalUrl(const KConfigGroup &config, const QUrl& remoteUrl); static QUrl convertToRemoteUrl(const KConfigGroup &config, const QUrl& localUrl); }; class KDEVPLATFORMDEBUGGER_EXPORT PathMappingsWidget : public QWidget { Q_OBJECT public: - explicit PathMappingsWidget(QWidget* parent = 0); + explicit PathMappingsWidget(QWidget* parent = nullptr); void loadFromConfiguration(const KConfigGroup& cfg); void saveToConfiguration(KConfigGroup cfg) const; Q_SIGNALS: void changed(); private Q_SLOTS: void deletePath(); private: QTableView *m_pathMappingTable; }; } #endif diff --git a/debugger/util/treeitem.h b/debugger/util/treeitem.h index a5540ae31d..38bfdc4c97 100644 --- a/debugger/util/treeitem.h +++ b/debugger/util/treeitem.h @@ -1,128 +1,128 @@ /* * This file is part of KDevelop * * Copyright 2008 Vladimir Prus * * 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. */ #ifndef KDEVPLATFORM_TREEITEM_H #define KDEVPLATFORM_TREEITEM_H #include #include #include #include #include #include #include namespace KDevelop { class TreeModel; class KDEVPLATFORMDEBUGGER_EXPORT TreeItem: public QObject { Q_OBJECT public: ~TreeItem() override; // FIXME: should be protected public: // Methods that the derived classes should implement /** Fetches more children, and adds them by calling appendChild. The amount of children to fetch is up to the implementation. After fetching, should call setHasMore. */ virtual void fetchMoreChildren()=0; virtual void setColumn(int index, const QVariant& data) { Q_UNUSED(index); Q_UNUSED(data); } void emitAllChildrenFetched(); protected: // Interface for derived classes /** Creates a tree item with the specified data. FIXME: do we actually have to have the model pointer. */ - TreeItem(TreeModel* model, TreeItem *parent = 0); + TreeItem(TreeModel* model, TreeItem *parent = nullptr); /** Set the data to be shown for the item itself. */ void setData(const QVector &data); /** Adds a new child and notifies the interested parties. Clears the "hasMore" flag. */ void appendChild(TreeItem *child, bool initial = false); void insertChild(int position, TreeItem *child, bool initial = false); void removeChild(int index); void removeSelf(); void deleteChildren(); /** Report change in data of this item. */ void reportChange(); void reportChange(int column); /** Clears all children. */ void clear(); /** Sets a flag that tells if we have some more children that are not fetched yet. */ void setHasMore(bool more); void setHasMoreInitial(bool more); TreeModel* model() { return model_; } bool isExpanded() const { return expanded_; } Q_SIGNALS: void expanded(); void collapsed(); void allChildrenFetched(); protected: // Backend implementation of Model/View friend class TreeModel; TreeItem *child(int row); int childCount() const; int columnCount() const; virtual QVariant data(int column, int role) const; int row() const; TreeItem *parent(); bool hasMore() const { return more_; } void setExpanded(bool b); virtual void clicked() {} virtual QVariant icon(int column) const; protected: QVector childItems; QVector itemData; TreeItem *parentItem; TreeModel *model_; bool more_; TreeItem *ellipsis_; bool expanded_; }; } #endif diff --git a/debugger/util/treemodel.h b/debugger/util/treemodel.h index e3d5148ca0..326a8e5904 100644 --- a/debugger/util/treemodel.h +++ b/debugger/util/treemodel.h @@ -1,90 +1,90 @@ /* * This file is part of KDevelop * * Copyright 2008 Vladimir Prus * * 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. */ #ifndef KDEVPLATFORM_TREEMODEL_H #define KDEVPLATFORM_TREEMODEL_H #include #include #include #include #include #include namespace KDevelop { class TreeItem; class KDEVPLATFORMDEBUGGER_EXPORT TreeModel : public QAbstractItemModel { Q_OBJECT public: - explicit TreeModel(const QVector& headers, QObject *parent = 0); + explicit TreeModel(const QVector& headers, QObject *parent = nullptr); void setRootItem(TreeItem *item); ~TreeModel() override; void expanded(const QModelIndex &index); void collapsed(const QModelIndex &index); void clicked(const QModelIndex &index); void setEditable(bool); TreeItem* root() const; enum { ItemRole = Qt::UserRole, }; public: // QAbstractItemModel overrides QVariant data(const QModelIndex &index, int role) const override; Qt::ItemFlags flags(const QModelIndex &index) const override; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; QModelIndex parent(const QModelIndex &index) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; bool setData(const QModelIndex& index, const QVariant& value, int role) override; Q_SIGNALS: void itemChildrenReady(); public: TreeItem* itemForIndex(const QModelIndex& index) const; QModelIndex indexForItem(TreeItem *item, int column) const; using QAbstractItemModel::beginInsertRows; using QAbstractItemModel::endInsertRows; using QAbstractItemModel::beginRemoveRows; using QAbstractItemModel::endRemoveRows; using QAbstractItemModel::dataChanged; private: QVector headers_; TreeItem *root_; }; } #endif diff --git a/debugger/variable/variablecollection.h b/debugger/variable/variablecollection.h index ad6dbd0d15..237776e5a6 100644 --- a/debugger/variable/variablecollection.h +++ b/debugger/variable/variablecollection.h @@ -1,254 +1,254 @@ /* * KDevelop Debugger Support * * Copyright 2007 Hamish Rodda * Copyright 2008 Vladimir Prus * Copyright 2009 Niko Sams * * 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. */ #ifndef KDEVPLATFORM_VARIABLECOLLECTION_H #define KDEVPLATFORM_VARIABLECOLLECTION_H #include #include #include #include #include #include #include "../util/treemodel.h" #include "../util/treeitem.h" #include "../../interfaces/idocument.h" #include "../interfaces/idebugsession.h" #include "../../interfaces/idebugcontroller.h" namespace GDBDebugger { class GdbTest; } namespace KDevelop { class VariableToolTip; class KDEVPLATFORMDEBUGGER_EXPORT Variable : public TreeItem { Q_OBJECT friend class GDBDebugger::GdbTest; public: protected: Variable(TreeModel* model, TreeItem* parent, const QString& expression, const QString& display = {}); public: enum format_t { Natural, Binary, Octal, Decimal, Hexadecimal }; static format_t str2format(const QString& str); static QString format2str(format_t format); QString expression() const; bool inScope() const; void setInScope(bool v); void setValue(const QString &v); QString value() const; void setType(const QString& type); QString type() const; void setTopLevel(bool v); void setShowError(bool v); bool showError(); using TreeItem::setHasMore; using TreeItem::setHasMoreInitial; using TreeItem::appendChild; using TreeItem::deleteChildren; using TreeItem::isExpanded; using TreeItem::parent; using TreeItem::model; ~Variable() override; /* Connects this variable to debugger, fetching the current value and otherwise preparing this variable to be displayed everywhere. The attempt may fail, for example if the expression is invalid. Calls slot 'callbackMethod' in 'callback' to notify of the result. The slot should be taking 'bool ok' parameter. */ - virtual void attachMaybe(QObject *callback = 0, const char *callbackMethod = 0) = 0; + virtual void attachMaybe(QObject *callback = nullptr, const char *callbackMethod = nullptr) = 0; virtual bool canSetFormat() const { return false; } void setFormat(format_t format); format_t format() const { return m_format; } virtual void formatChanged(); // get/set 'changed' state, if the variable changed it will be highlighted bool isChanged() const { return changed_; } void setChanged(bool c); void resetChanged(); public slots: void die(); protected: bool topLevel() const { return topLevel_; } private: // TreeItem overrides QVariant data(int column, int role) const override; private: bool isPotentialProblematicValue() const; QString expression_; bool inScope_; bool topLevel_; bool changed_; bool showError_; format_t m_format; }; class KDEVPLATFORMDEBUGGER_EXPORT TooltipRoot : public TreeItem { Q_OBJECT public: explicit TooltipRoot(TreeModel* model) : TreeItem(model) {} void init(Variable *var) { appendChild(var); } void fetchMoreChildren() override {} }; class KDEVPLATFORMDEBUGGER_EXPORT Watches : public TreeItem { Q_OBJECT friend class GDBDebugger::GdbTest; public: Watches(TreeModel* model, TreeItem* parent); Variable* add(const QString& expression); void reinstall(); Variable *addFinishResult(const QString& convenienceVarible); void removeFinishResult(); void resetChanged(); using TreeItem::childCount; friend class VariableCollection; friend class IVariableController; private: QVariant data(int column, int role) const override; void fetchMoreChildren() override {} Variable* finishResult_; }; class KDEVPLATFORMDEBUGGER_EXPORT Locals : public TreeItem { Q_OBJECT public: Locals(TreeModel* model, TreeItem* parent, const QString &name); QList updateLocals(QStringList locals); void resetChanged(); using TreeItem::deleteChildren; using TreeItem::setHasMore; friend class VariableCollection; friend class IVariableController; private: void fetchMoreChildren() override {} }; class KDEVPLATFORMDEBUGGER_EXPORT VariablesRoot : public TreeItem { Q_OBJECT public: explicit VariablesRoot(TreeModel* model); Watches *watches() const { return watches_; } Locals *locals(const QString &name = QStringLiteral("Locals")); QHash allLocals() const; void fetchMoreChildren() override {} void resetChanged(); private: Watches *watches_; QHash locals_; }; class VariableProvider : public KTextEditor::TextHintProvider { public: explicit VariableProvider(VariableCollection* collection); QString textHint(KTextEditor::View* view, const KTextEditor::Cursor& position) override; private: VariableCollection* m_collection; }; class KDEVPLATFORMDEBUGGER_EXPORT VariableCollection : public TreeModel { Q_OBJECT public: enum Column { NameColumn, ValueColumn, TypeColumn }; explicit VariableCollection(IDebugController* parent); ~VariableCollection() override; VariablesRoot* root() const { return universe_; } Watches* watches() const { return universe_->watches(); } Locals* locals(const QString &name = i18n("Locals")) const { return universe_->locals(name); } QHash allLocals() const { return universe_->allLocals(); } public Q_SLOTS: void variableWidgetShown(); void variableWidgetHidden(); private Q_SLOTS: - void updateAutoUpdate(KDevelop::IDebugSession* session = 0); + void updateAutoUpdate(KDevelop::IDebugSession* session = nullptr); void textDocumentCreated( KDevelop::IDocument*); void viewCreated(KTextEditor::Document*, KTextEditor::View*); private: VariablesRoot* universe_; QPointer activeTooltip_; bool m_widgetVisible; friend class VariableProvider; VariableProvider m_textHintProvider; }; } #endif diff --git a/debugger/variable/variablewidget.h b/debugger/variable/variablewidget.h index 16ce290d2b..e4c6a421a7 100644 --- a/debugger/variable/variablewidget.h +++ b/debugger/variable/variablewidget.h @@ -1,119 +1,119 @@ /*************************************************************************** begin : Sun Aug 8 1999 copyright : (C) 1999 by John Birch email : jbb@kdevelop.org ***************************************************************************/ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef KDEVPLATFORM_VARIABLEWIDGET_H #define KDEVPLATFORM_VARIABLEWIDGET_H #include #include #include #include #include "../util/treeview.h" #include "variablecollection.h" class KHistoryComboBox; class QSortFilterProxyModel; namespace KDevelop { class IDebugController; class TreeModel; class VariableTree; class AbstractVariableItem; class KDEVPLATFORMDEBUGGER_EXPORT VariableWidget : public QWidget { Q_OBJECT public: - explicit VariableWidget( IDebugController *controller, QWidget *parent=0 ); + explicit VariableWidget( IDebugController *controller, QWidget *parent=nullptr ); Q_SIGNALS: void requestRaise(); void addWatchVariable(const QString& indent); void evaluateExpression(const QString& indent); public Q_SLOTS: void slotAddWatch(const QString &ident); protected: void showEvent(QShowEvent* e) override; void hideEvent(QHideEvent* e) override; private: VariableTree *varTree_; KHistoryComboBox *watchVarEditor_; VariablesRoot *variablesRoot_; QSortFilterProxyModel *m_proxy; }; /***************************************************************************/ /***************************************************************************/ /***************************************************************************/ class VariableTree : public KDevelop::AsyncTreeView { Q_OBJECT public: VariableTree(IDebugController *controller, VariableWidget *parent, QSortFilterProxyModel *proxy); ~VariableTree() override; VariableCollection* collection() const; private: void setupActions(); void contextMenuEvent(QContextMenuEvent* event) override; Variable *selectedVariable() const; private slots: void changeVariableFormat(int); void watchDelete(); void copyVariableValue(); void stopOnChange(); #if 0 Q_SIGNALS: void toggleWatchpoint(const QString &varName); protected: virtual void contextMenuEvent(QContextMenuEvent* event); virtual void keyPressEvent(QKeyEvent* e); virtual void showEvent(QShowEvent* event); private: // helper functions void handleAddressComputed(const GDBMI::ResultRecord& r); void updateCurrentFrame(); void copyToClipboard(AbstractVariableItem* item); QMenu* activePopup_; QAction* toggleWatch_; #endif private: QAction *m_contextMenuTitle; QMenu *m_formatMenu; QAction *m_watchDelete; QAction *m_copyVariableValue; QAction *m_stopOnChange; QSignalMapper *m_signalMapper; QSortFilterProxyModel *m_proxy; TreeModel *m_model; }; } #endif diff --git a/documentation/documentationview.h b/documentation/documentationview.h index 5f7f6d8bb1..14a420aaaa 100644 --- a/documentation/documentationview.h +++ b/documentation/documentationview.h @@ -1,100 +1,100 @@ /* Copyright 2009 Aleix Pol Gonzalez Copyright 2010 Benjamin Port 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. */ #ifndef KDEVPLATFORM_DOCUMENTATIONVIEW_H #define KDEVPLATFORM_DOCUMENTATIONVIEW_H #include #include #include #include #include "documentationexport.h" namespace KDevelop { class IPlugin; class DocumentationFindWidget; } class QModelIndex; class QLineEdit; class ProvidersModel; class QComboBox; class KDEVPLATFORMDOCUMENTATION_EXPORT DocumentationView : public QWidget { Q_OBJECT public: DocumentationView(QWidget* parent, ProvidersModel* m); void showDocumentation(const KDevelop::IDocumentation::Ptr& doc); public slots: void initialize(); void addHistory(const KDevelop::IDocumentation::Ptr& doc); void emptyHistory(); void browseForward(); void browseBack(); void changedSelection(); void changedProvider(int); void changeProvider(const QModelIndex &); void showHome(); private: void updateView(); KToolBar* mActions; QAction* mForward; QAction* mBack; QAction* mFind; QLineEdit* mIdentifiers; QList< KDevelop::IDocumentation::Ptr > mHistory; QList< KDevelop::IDocumentation::Ptr >::iterator mCurrent; QComboBox* mProviders; ProvidersModel* mProvidersModel; KDevelop::DocumentationFindWidget* mFindDoc; }; class KDEVPLATFORMDOCUMENTATION_EXPORT ProvidersModel : public QAbstractListModel { Q_OBJECT public: - explicit ProvidersModel(QObject* parent = 0); + explicit ProvidersModel(QObject* parent = nullptr); QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; int rowCount(const QModelIndex& idx = QModelIndex()) const override; QList providers(); KDevelop::IDocumentationProvider* provider(int pos) const; int rowForProvider(KDevelop::IDocumentationProvider* provider); public slots: void unloaded(KDevelop::IPlugin* p); void loaded(KDevelop::IPlugin* p); void reloadProviders(); private: void removeProviders(const QList &provider); QList mProviders; signals: void providersChanged(); }; #endif // KDEVPLATFORM_DOCUMENTATIONVIEW_H diff --git a/documentation/standarddocumentationview.h b/documentation/standarddocumentationview.h index ba45442716..3f42975203 100644 --- a/documentation/standarddocumentationview.h +++ b/documentation/standarddocumentationview.h @@ -1,61 +1,61 @@ /* * This file is part of KDevelop * Copyright 2010 Aleix Pol Gonzalez * * 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 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. */ #ifndef KDEVPLATFORM_STANDARDDOCUMENTATIONVIEW_H #define KDEVPLATFORM_STANDARDDOCUMENTATIONVIEW_H #include #include "documentationexport.h" #include "documentationfindwidget.h" #include namespace KDevelop { /** * The standard documentation view, based on QWebView. */ class KDEVPLATFORMDOCUMENTATION_EXPORT StandardDocumentationView : public QWebView { Q_OBJECT public: - explicit StandardDocumentationView(DocumentationFindWidget* findWidget, QWidget* parent = 0 ); + explicit StandardDocumentationView(DocumentationFindWidget* findWidget, QWidget* parent = nullptr ); void setDocumentation(const IDocumentation::Ptr& doc); public slots: /** * Search for @p text in the documentation view. */ void search(const QString& text, KDevelop::DocumentationFindWidget::FindOptions options); /** * Updates the contents, in case it was initialized with a documentation instance, * doesn't change anything otherwise * * @sa setDocumentation(IDocumentation::Ptr) */ void update(); private: IDocumentation::Ptr m_doc; }; } #endif // KDEVPLATFORM_STANDARDDOCUMENTATIONVIEW_H diff --git a/interfaces/icore.h b/interfaces/icore.h index f7fa836e3a..0278085868 100644 --- a/interfaces/icore.h +++ b/interfaces/icore.h @@ -1,154 +1,154 @@ /* This file is part of KDevelop Copyright 2007 Alexander Dymo Copyright 2007 Kris Wong This library 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 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. */ #ifndef KDEVPLATFORM_ICORE_H #define KDEVPLATFORM_ICORE_H #include #include "interfacesexport.h" #include "isessionlock.h" class KAboutData; namespace KParts { class PartManager; } /** * The KDevelop namespace contains all classes provided by the KDevelop * platform libraries. */ namespace KDevelop { class IUiController; class IPluginController; class IProjectController; class ILanguageController; class IDocumentController; class ISessionController; class IRunController; class ISourceFormatterController; class ISession; class ISelectionController; class IDocumentationController; class IDebugController; class IPartController; class IDashboardController; class ITestController; /** * ICore is the container class for all the various objects in use by * KDevelop. If access is needed to a particular controller, then this class * should be used. * * ICore can provide the user with instances of the following things: * - the main window(s) * - the document controller(s) * - the plugin controller * - the project controller * - the language controller * - the KPart manager * * When an object is provided to ICore so it can be used later, ICore * will take ownership of the object and upon application shutdown will take * responsibility for deleting the objects stored by ICore. */ class KDEVPLATFORMINTERFACES_EXPORT ICore: public QObject { Q_OBJECT public: ~ICore() override; /** @return the static ICore instance */ static ICore *self(); /** @return ui controller */ Q_SCRIPTABLE virtual KDevelop::IUiController *uiController() = 0; /** @return plugin controller */ Q_SCRIPTABLE virtual KDevelop::IPluginController *pluginController() = 0; /** @return project controller */ Q_SCRIPTABLE virtual KDevelop::IProjectController *projectController() = 0; /** @return language controller */ Q_SCRIPTABLE virtual KDevelop::ILanguageController *languageController() = 0; /** @return part manager */ Q_SCRIPTABLE virtual KDevelop::IPartController *partController() = 0; /** @return document controller */ Q_SCRIPTABLE virtual KDevelop::IDocumentController *documentController() = 0; /** @return run controller */ Q_SCRIPTABLE virtual KDevelop::IRunController *runController() = 0; /** @return the active session */ Q_SCRIPTABLE virtual KDevelop::ISession *activeSession() = 0; /** @return the session lock for the active session */ Q_SCRIPTABLE virtual KDevelop::ISessionLock::Ptr activeSessionLock() = 0; /** @return the sourceformatter controller */ Q_SCRIPTABLE virtual KDevelop::ISourceFormatterController *sourceFormatterController() = 0; /** @return the selection controller */ Q_SCRIPTABLE virtual KDevelop::ISelectionController* selectionController() = 0; /** @return the documentation controller */ Q_SCRIPTABLE virtual KDevelop::IDocumentationController* documentationController() = 0; /** @return the debug controller */ Q_SCRIPTABLE virtual KDevelop::IDebugController* debugController() = 0; /** @return the test controller */ Q_SCRIPTABLE virtual KDevelop::ITestController* testController() = 0; /** @return the about data of the framework, different from the main about data which is created by the application */ virtual KAboutData aboutData() const = 0; /** @return true if the application is currently being shut down */ virtual bool shuttingDown() const = 0; Q_SIGNALS: /** Emitted when the initialization of the core components has been completed */ void initializationCompleted(); /** * Emitted immediately before tearing down the session and UI. Useful when performing any last minute * preparations such as saving settings. */ void aboutToShutdown(); /** * Emitted when the teardown of the core components has been completed. */ void shutdownCompleted(); protected: - ICore(QObject *parent = 0); + ICore(QObject *parent = nullptr); static ICore *m_self; }; } #endif diff --git a/interfaces/idebugcontroller.h b/interfaces/idebugcontroller.h index c18bd54bd8..170e15215a 100644 --- a/interfaces/idebugcontroller.h +++ b/interfaces/idebugcontroller.h @@ -1,65 +1,65 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2009 Niko Sams * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_IDEBUGCONTROLLER_H #define KDEVPLATFORM_IDEBUGCONTROLLER_H #include #include "interfacesexport.h" namespace KDevelop { class VariableCollection; class BreakpointModel; class FrameStackModel; class IDebugSession; /** Top level debugger object. Exists as long as KDevelop exists and holds some global debugger state, like breakpoints. Also holds the IDebugSession for the specific application that is being debugged. */ class KDEVPLATFORMINTERFACES_EXPORT IDebugController : public QObject { Q_OBJECT public: - explicit IDebugController(QObject *parent = 0); + explicit IDebugController(QObject *parent = nullptr); ~IDebugController() override; /** Each plugin using the debugger actions needs to call this function to setup the gui */ virtual void initializeUi() = 0; virtual void addSession(IDebugSession* session) = 0; /** Return the current debug session. At present, only one session may be active at a time. */ virtual IDebugSession *currentSession() = 0; virtual BreakpointModel *breakpointModel() = 0; virtual VariableCollection *variableCollection() = 0; Q_SIGNALS: void currentSessionChanged(KDevelop::IDebugSession* session); }; } #endif diff --git a/interfaces/idocumentcontroller.h b/interfaces/idocumentcontroller.h index b189d58c06..a95bd4656d 100644 --- a/interfaces/idocumentcontroller.h +++ b/interfaces/idocumentcontroller.h @@ -1,233 +1,233 @@ /*************************************************************************** * Copyright 2007 Alexander Dymo * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_IDOCUMENTCONTROLLER_H #define KDEVPLATFORM_IDOCUMENTCONTROLLER_H #include #include #include #include #include #include "interfacesexport.h" #include "idocument.h" namespace KTextEditor { class View; } namespace KDevelop { class ICore; class KDEVPLATFORMINTERFACES_EXPORT IDocumentFactory { public: virtual ~IDocumentFactory() {} virtual IDocument* create(const QUrl&, ICore* ) = 0; }; /** * * Allows to access the open documents and also open new ones * * @class IDocumentController */ class KDEVPLATFORMINTERFACES_EXPORT IDocumentController: public QObject { Q_OBJECT public: enum DocumentActivation { DefaultMode = 0, /**Activate document and create a view if no other flags passed.*/ DoNotActivate = 1, /**Don't activate the Document.*/ DoNotCreateView = 2, /**Don't create and show the view for the Document.*/ DoNotFocus = 4 /**Don't change the keyboard focus.*/ }; Q_DECLARE_FLAGS(DocumentActivationParams, DocumentActivation) explicit IDocumentController(QObject *parent); /** * Finds the first document object corresponding to a given url. * * @param url The Url of the document. * @return The corresponding document, or null if not found. */ Q_SCRIPTABLE virtual KDevelop::IDocument* documentForUrl( const QUrl & url ) const = 0; /// @return The list of all open documents Q_SCRIPTABLE virtual QList openDocuments() const = 0; /** * Returns the curently active or focused document. * * @return The active document. */ Q_SCRIPTABLE virtual KDevelop::IDocument* activeDocument() const = 0; Q_SCRIPTABLE virtual void activateDocument( KDevelop::IDocument * document, const KTextEditor::Range& range = KTextEditor::Range::invalid() ) = 0; virtual void registerDocumentForMimetype( const QString&, KDevelop::IDocumentFactory* ) = 0; Q_SCRIPTABLE virtual bool saveAllDocuments(KDevelop::IDocument::DocumentSaveMode mode = KDevelop::IDocument::Default) = 0; Q_SCRIPTABLE virtual bool saveSomeDocuments(const QList& list, KDevelop::IDocument::DocumentSaveMode mode = KDevelop::IDocument::Default) = 0; Q_SCRIPTABLE virtual bool saveAllDocumentsForWindow(KParts::MainWindow* mw, IDocument::DocumentSaveMode mode, bool currentAreaOnly = false) = 0; /// Opens a text document containing the @p data text. Q_SCRIPTABLE virtual KDevelop::IDocument* openDocumentFromText( const QString& data ) = 0; virtual IDocumentFactory* factory(const QString& mime) const = 0; Q_SCRIPTABLE virtual KTextEditor::Document* globalTextEditorInstance()=0; /** * @returns the KTextEditor::View of the current document, in case it is a text document */ virtual KTextEditor::View* activeTextDocumentView() const = 0; public Q_SLOTS: /** * Opens a new or existing document. * * @param url The full Url of the document to open. * @param range The location information, if applicable. * @param activate Indicates whether to fully activate the document. */ KDevelop::IDocument* openDocument( const QUrl &url, const KTextEditor::Cursor& cursor, - DocumentActivationParams activationParams = 0, + DocumentActivationParams activationParams = nullptr, const QString& encoding = {}); /** * Opens a new or existing document. * * @param url The full Url of the document to open. * @param range The range of text to select, if applicable. * @param activate Indicates whether to fully activate the document * @param buddy Optional buddy document. If 0, the registered IBuddyDocumentFinder * for the URL's mimetype will be queried to find a fitting buddy. * If a buddy was found (or passed) @p url will be opened next * to its buddy. * * @return The opened document */ virtual KDevelop::IDocument* openDocument( const QUrl &url, const KTextEditor::Range& range = KTextEditor::Range::invalid(), - DocumentActivationParams activationParams = 0, + DocumentActivationParams activationParams = nullptr, const QString& encoding = {}, - IDocument* buddy = 0) = 0; + IDocument* buddy = nullptr) = 0; /** * Opens a document from the IDocument instance. * * @param doc The IDocument to add * @param range The location information, if applicable. * @param activationParams Indicates whether to fully activate the document. * @param buddy Optional buddy document. If 0, the registered IBuddyDocumentFinder * for the Documents mimetype will be queried to find a fitting buddy. * If a buddy was found (or passed) @p url will be opened next * to its buddy. */ virtual Q_SCRIPTABLE bool openDocument(IDocument* doc, const KTextEditor::Range& range = KTextEditor::Range::invalid(), - DocumentActivationParams activationParams = 0, - IDocument* buddy = 0) = 0; + DocumentActivationParams activationParams = nullptr, + IDocument* buddy = nullptr) = 0; /** * Opens a new or existing document. * * @param url The full Url of the document to open. * @param prefName The name of the preferred KPart to open that document */ virtual KDevelop::IDocument* openDocument( const QUrl &url, const QString& prefname ) = 0; virtual bool closeAllDocuments() = 0; Q_SIGNALS: /// Emitted when the document has been activated. void documentActivated( KDevelop::IDocument* document ); /** * Emitted whenever the active cursor jumps from one document+cursor to another, * as e.g. caused by a call to openDocument(..). * * This is also emitted when a document is only activated. Then previousDocument is zero. */ void documentJumpPerformed( KDevelop::IDocument* newDocument, KTextEditor::Cursor newCursor, KDevelop::IDocument* previousDocument, KTextEditor::Cursor previousCursor); /// Emitted when a document has been saved. void documentSaved( KDevelop::IDocument* document ); /** * Emitted when a document has been opened. * * NOTE: The document may not be loaded from disk/network at this point. * NOTE: No views exist for the document at the time this signal is emitted. */ void documentOpened( KDevelop::IDocument* document ); /** * Emitted when a document has been loaded. * * NOTE: No views exist for the document at the time this signal is emitted. */ void documentLoaded( KDevelop::IDocument* document ); /** * Emitted when a text document has been loaded, and the text document created. * * NOTE: no views exist for the document at the time this signal is emitted. */ void textDocumentCreated( KDevelop::IDocument* document ); /// Emitted when a document has been closed. void documentClosed( KDevelop::IDocument* document ); /** * This is emitted when the document state(the relationship * between the file in the editor and the file stored on disk) changes. */ void documentStateChanged( KDevelop::IDocument* document ); /// This is emitted when the document content changed. void documentContentChanged( KDevelop::IDocument* document ); /** * Emitted when a document has been loaded, but before documentLoaded(..) is emitted. * * This allows parts of kdevplatform to prepare data-structures that can be used by other parts * during documentLoaded(..). */ void documentLoadedPrepare( KDevelop::IDocument* document ); /// Emitted when a document url has changed. void documentUrlChanged( KDevelop::IDocument* document ); friend class IDocument; }; } // namespace KDevelop Q_DECLARE_OPERATORS_FOR_FLAGS(KDevelop::IDocumentController::DocumentActivationParams) #endif diff --git a/interfaces/ilanguagecontroller.h b/interfaces/ilanguagecontroller.h index da34e9ff01..bd58b33e3f 100644 --- a/interfaces/ilanguagecontroller.h +++ b/interfaces/ilanguagecontroller.h @@ -1,84 +1,84 @@ /*************************************************************************** * Copyright 2007 Alexander Dymo * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_ILANGUAGECONTROLLER_H #define KDEVPLATFORM_ILANGUAGECONTROLLER_H #include #include #include #include "interfacesexport.h" namespace KDevelop { class ILanguageSupport; class BackgroundParser; class ICompletionSettings; class StaticAssistantsManager; class ProblemModelSet; /** * @class ILanguageController */ class KDEVPLATFORMINTERFACES_EXPORT ILanguageController: public QObject { Q_OBJECT public: - explicit ILanguageController(QObject *parent = 0); + explicit ILanguageController(QObject *parent = nullptr); /** * @return the currently active languages loaded for the currently active file. * * The list is empty if the file's language is unsupported. */ Q_SCRIPTABLE virtual QList activeLanguages() = 0; /** *@return the language for given @p name. */ Q_SCRIPTABLE virtual ILanguageSupport* language(const QString &name) const = 0; /** * @return the languages that support the MIME type of @p url. * @warning If this is called from within the foreground thread, * the language support is loaded if required. * If it is called from a background thread, it can not * be loaded, and thus zero will be returned. */ Q_SCRIPTABLE virtual QList languagesForUrl(const QUrl &url) = 0; /** @return All languages currently loaded */ Q_SCRIPTABLE virtual QList loadedLanguages() const = 0; /** @return the background parser used to parse source files */ Q_SCRIPTABLE virtual BackgroundParser *backgroundParser() const = 0; /** @return The global code assistant manager (manages assistants such as the RenameAssistant) */ Q_SCRIPTABLE virtual StaticAssistantsManager *staticAssistantsManager() const = 0; /** Access to the completion settings */ Q_SCRIPTABLE virtual ICompletionSettings *completionSettings() const = 0; virtual ProblemModelSet* problemModelSet() const = 0; }; } #endif diff --git a/interfaces/iplugincontroller.h b/interfaces/iplugincontroller.h index b51a9e0cd9..1acfc48451 100644 --- a/interfaces/iplugincontroller.h +++ b/interfaces/iplugincontroller.h @@ -1,199 +1,199 @@ /* This file is part of the KDE project Copyright 2004, 2007 Alexander Dymo Copyright 2006 Matt Rogers Copyright 2007 Andreas Pakulat Based on code from Kopete Copyright 2002-2003 Martijn Klingens This library 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 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. */ #ifndef KDEVPLATFORM_IPLUGINCONTROLLER_H #define KDEVPLATFORM_IPLUGINCONTROLLER_H #include #include #include #include "iplugin.h" #include "interfacesexport.h" class QExtensionManager; namespace KDevelop { class ProfileEngine; /** * The KDevelop plugin controller. * The Plugin controller is responsible for querying, loading and unloading * available plugins. * * Most of the time if you want to get at a plugin you should be using * extensionForPlugin with the extension interface name. If you need to get at * the actual \c IPlugin* pointer to connect signals/slots you should use * \c pluginForExtension() and then the IPlugin's extension member function to get * at the extension interface if necessary. * * If you have the need to load a specific plugin for a given extension both * functions have an optional second parameter that allows one to specify the * name of the plugin as declared in the \c .desktop file under the * \c X-KDE-PluginInfo-Name property. This should be used only very seldomly in * real code and is mostly meant for testing and for implementation in the * shell as it makes the code dependent on the plugin name which may change and * also the actual plugin implementation so users cannot exchange one plugin * with another also implementing the same interface. * */ class KDEVPLATFORMINTERFACES_EXPORT IPluginController : public QObject { Q_OBJECT public: /** * \brief Indicates the plugin type * This is used to determine how the plugin is loaded */ enum PluginType { Global = 0, ///< Indicates that the plugin is loaded at startup Project ///< Indicates that the plugin is loaded with the first opened project }; - explicit IPluginController( QObject* parent = 0 ); + explicit IPluginController( QObject* parent = nullptr ); ~IPluginController() override; /** * Get the plugin info for a loaded plugin */ virtual KPluginMetaData pluginInfo(const IPlugin*) const = 0; /** * Find the KPluginMetaData structure for the given @p pluginId. */ virtual KPluginMetaData infoForPluginId(const QString &pluginId) const = 0; /** * Get a list of currently loaded plugins */ Q_SCRIPTABLE virtual QList loadedPlugins() const = 0; /** * @brief Unloads the plugin specified by @p plugin * * @param plugin The name of the plugin as specified by the * X-KDE-PluginInfo-Name key of the .desktop file for the plugin */ Q_SCRIPTABLE virtual bool unloadPlugin( const QString & plugin ) = 0; /** * @brief Loads the plugin specified by @p pluginName * * @param pluginName the name of the plugin, as given in the X-KDE-PluginInfo-Name property * @returns a pointer to the plugin instance or 0 */ Q_SCRIPTABLE virtual IPlugin* loadPlugin( const QString & pluginName ) = 0; /** * Retrieve a plugin which supports the given extension interface. * * All already loaded plugins will be queried and the first one to support the extension interface * will be returned. Any plugin can be an extension, only the "ServiceTypes=..." entry is * required in .desktop file for that plugin. * * If no already-loaded plugin was found, we try to load a plugin for the given extension. * * If no plugin was found, a nullptr will be returned. * * @param extension The extension interface. Can be empty if you want to find a plugin by name or other constraint. * @param pluginName The name of the plugin to load if multiple plugins for the extension exist, corresponds to the X-KDE-PluginInfo-Name * @param constraints A map of constraints on other plugin info properties. * @return A KDevelop extension plugin for given service type or 0 if no plugin supports it */ Q_SCRIPTABLE virtual IPlugin *pluginForExtension(const QString &extension, const QString& pluginName = {}, const QVariantMap& constraints = QVariantMap()) = 0; /** * Retrieve a list of plugins which supports the given extension interface. * All already loaded plugins will be queried and the first one to support the extension interface * will be returned. Any plugin can be an extension, only the "ServiceTypes=..." entry is * required in .desktop file for that plugin. * @param extension The extension interface * @param constraints A map of constraints on other plugin info properties. * @return A KDevelop extension plugin for given service type or 0 if no plugin supports it */ virtual QList allPluginsForExtension(const QString &extension, const QVariantMap& constraints = QVariantMap()) = 0; /** * Retrieve the plugin which supports given extension interface and * returns a pointer to the extension interface. * * All already loaded plugins will be queried and the first one to support the extension interface * will be returned. Any plugin can be an extension, only "ServiceTypes=..." entry is * required in .desktop file for that plugin. * @param extension The extension interface * @param pluginName The name of the plugin to load if multiple plugins for the extension exist, corresponds to the X-KDE-PluginInfo-Name * @return Pointer to the extension interface or 0 if no plugin supports it */ template Extension* extensionForPlugin( const QString &extension = {}, const QString &pluginName = {}) { QString ext; if( extension.isEmpty() ) { ext = qobject_interface_iid(); } else { ext = extension; } IPlugin *plugin = pluginForExtension(ext, pluginName); if (plugin) { return plugin->extension(); } return 0L; } /** * Query for plugin information on KDevelop plugins implementing the given extension. * * The service version is checked for automatically and the only serviceType * searched for is "KDevelop/Plugin" * * @param extension The extension that should be implemented by the plugin, i.e. listed in X-KDevelop-Interfaces. * @param constraints A map of constraints on other plugin info properties. * @return The list of plugin offers. */ virtual QVector queryExtensionPlugins(const QString &extension, const QVariantMap& constraints = QVariantMap()) const = 0; virtual QList queryPluginsForContextMenuExtensions( KDevelop::Context* context ) const = 0; Q_SIGNALS: void loadingPlugin( const QString& ); void pluginLoaded( KDevelop::IPlugin* ); void unloadingPlugin( KDevelop::IPlugin* ); /** * This signal is emitted whenever a plugin is unloaded. * @note: that you shouldn't use the pointer anymore * except for comparing it against against other pointers. The plugin instance can already have been completely * deleted when this signal is emitted. */ void pluginUnloaded( KDevelop::IPlugin* ); private: friend class IPlugin; }; } #endif diff --git a/interfaces/iproject.h b/interfaces/iproject.h index 0cc853b195..a83eb4b590 100644 --- a/interfaces/iproject.h +++ b/interfaces/iproject.h @@ -1,183 +1,183 @@ /* This file is part of the KDE project Copyright 2001 Matthias Hoelzer-Kluepfel Copyright 2001-2002 Bernd Gehrmann Copyright 2002-2003 Roberto Raggi Copyright 2002 Simon Hausmann Copyright 2003 Jens Dagerbo Copyright 2003 Mario Scalas Copyright 2003-2004 Alexander Dymo Copyright 2006 Matt Rogers Copyright 2007 Andreas Pakulat This library 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 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. */ #ifndef KDEVPLATFORM_IPROJECT_H #define KDEVPLATFORM_IPROJECT_H #include #include #include #include "interfacesexport.h" class KJob; template class QList; template class QSet; namespace KDevelop { class IPlugin; class IProjectFileManager; class IBuildSystemManager; class Path; class ProjectBaseItem; class ProjectFileItem; class ProjectFolderItem; class IndexedString; /** * \brief Object which represents a KDevelop project * * Provide better descriptions */ class KDEVPLATFORMINTERFACES_EXPORT IProject : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kdevelop.Project") Q_PROPERTY(QString projectName READ name CONSTANT) public: /** * Constructs a project. * * @param parent The parent object for the plugin. */ - explicit IProject(QObject *parent = 0); + explicit IProject(QObject *parent = nullptr); /// Destructor. ~IProject() override; /** * Get the file manager for the project * * @return the file manager for the project, if one exists; otherwise null */ Q_SCRIPTABLE virtual IProjectFileManager* projectFileManager() const = 0; /** * Get the build system manager for the project * * @return the build system manager for the project, if one exists; otherwise null */ Q_SCRIPTABLE virtual IBuildSystemManager* buildSystemManager() const = 0; /** * Get the plugin that manages the project * This can be used to get other interfaces like IBuildSystemManager */ Q_SCRIPTABLE virtual IPlugin* managerPlugin() const = 0; /** * Get the version control plugin for this project * This may return 0 if the project is not under version control * or version control has been disabled for this project */ Q_SCRIPTABLE virtual IPlugin* versionControlPlugin() const = 0; /** * With this the top-level project item can be retrieved */ Q_SCRIPTABLE virtual ProjectFolderItem* projectItem() const = 0; /** * @return all items with the corresponding @p path */ Q_SCRIPTABLE virtual QList itemsForPath( const IndexedString& path ) const = 0; /** * @return all file items with the corresponding @p file path */ Q_SCRIPTABLE virtual QList filesForPath( const IndexedString& file ) const = 0; /** * @return all folder items with the corresponding @p folder path */ Q_SCRIPTABLE virtual QList foldersForPath( const IndexedString& folder ) const = 0; /** * @return the path to the project file */ virtual Path projectFile() const = 0; /** Get the url of the project file.*/ virtual KSharedConfigPtr projectConfiguration() const = 0; virtual void addToFileSet( ProjectFileItem* item ) = 0; virtual void removeFromFileSet( ProjectFileItem* item ) = 0; virtual QSet fileSet() const = 0; /** Returns whether the project is ready to be used or not. A project won't be ready for use when it's being reloaded or still loading */ virtual bool isReady() const=0; /** * @brief Get the project path * @return The canonical absolute directory of the project. */ virtual Path path() const = 0; /** Returns the name of the project. */ virtual Q_SCRIPTABLE QString name() const = 0; /** * @brief Check if the project contains an item with the given @p path. * * @param path the path to check * * @return true if the path @a path is a part of the project. */ virtual Q_SCRIPTABLE bool inProject(const IndexedString &path) const = 0; /** * @brief Tells the project what job is reloading it * * It's useful so that we can tell whether the project manager is busy or not. */ virtual void setReloadJob(KJob* job) = 0; Q_SIGNALS: /** * Gets emitted whenever a file was added to the project. */ void fileAddedToSet( KDevelop::ProjectFileItem* item ); /** * Gets emitted whenever a file was removed from the project. */ void fileRemovedFromSet( KDevelop::ProjectFileItem* item ); public Q_SLOTS: /** Make the model to reload */ virtual void reloadModel() = 0; /** This method is invoked when the project needs to be closed. */ virtual void close() = 0; }; } #endif diff --git a/interfaces/iprojectcontroller.h b/interfaces/iprojectcontroller.h index 0f0df2cf45..171576bdcc 100644 --- a/interfaces/iprojectcontroller.h +++ b/interfaces/iprojectcontroller.h @@ -1,208 +1,208 @@ /* This file is part of KDevelop Copyright 2006 Adam Treat Copyright 2007 Andreas Pakulat This library 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 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. */ #ifndef KDEVPLATFORM_IPROJECTCONTROLLER_H #define KDEVPLATFORM_IPROJECTCONTROLLER_H #include #include #include #include "interfacesexport.h" class QItemSelectionModel; namespace KDevelop { class IProject; class ProjectBuildSetModel; class ProjectModel; class ProjectBaseItem; class ProjectChangesModel; /** * @class IProjectController */ class KDEVPLATFORMINTERFACES_EXPORT IProjectController : public QObject { Q_OBJECT public: - explicit IProjectController( QObject *parent = 0 ); + explicit IProjectController( QObject *parent = nullptr ); ~IProjectController() override; Q_SCRIPTABLE virtual KDevelop::IProject* projectAt( int ) const = 0; Q_SCRIPTABLE virtual int projectCount() const = 0; Q_SCRIPTABLE virtual QList projects() const = 0; /** * Provides access to the model representing the open projects * @returns the model containing the projects and their items */ Q_SCRIPTABLE virtual ProjectModel* projectModel() = 0; /** * @returns an instance to the model that keeps track of the state * of the files per project. */ Q_SCRIPTABLE virtual ProjectChangesModel* changesModel() = 0; Q_SCRIPTABLE virtual ProjectBuildSetModel* buildSetModel() = 0; /** * Find an open project using the name of the project * @param name the name of the project to be found * @returns the project or null if no project with that name is open */ Q_SCRIPTABLE virtual KDevelop::IProject* findProjectByName( const QString& name ) = 0; /** * Finding an open project for a given file or folder in the project * @param url the url of a file/folder belonging to an open project * @returns the first open project containing the url or null if no such * project can be found */ Q_SCRIPTABLE virtual IProject* findProjectForUrl( const QUrl& url ) const = 0; /** * Checks whether the given project name is used already or not. The project * controller supports only 1 project with a given name to be open at any time * @param name the name of the project to be opened or created * @returns whether the name is already used for an open project */ Q_SCRIPTABLE virtual bool isProjectNameUsed( const QString& name ) const = 0; virtual QUrl projectsBaseDirectory() const = 0; enum FormattingOptions { FormatHtml, FormatPlain }; /** * Returns a pretty short representation of the base path of the url, considering the currently loaded projects: * When the file is part of a currently loaded project, that projects name is shown as prefix instead of the * the full file path. * The returned path always has a training slash. * @param format formatting used for the string */ Q_SCRIPTABLE virtual QString prettyFilePath(const QUrl& url, FormattingOptions format = FormatHtml) const = 0; /** * Returns a pretty short representation of the given url, considering the currently loaded projects: * When the file is part of a currently loaded project, that projects name is shown as prefix instead of the * the full file path. * @param format formatting used for the string */ Q_SCRIPTABLE virtual QString prettyFileName(const QUrl& url, FormattingOptions format = FormatHtml) const = 0; /** * @returns whether project files should be parsed or not */ static bool parseAllProjectSources(); public Q_SLOTS: /** * Tries finding a project-file for the given source-url and opens it. * If no .kdev4 project file is found, the user is asked to import a project. */ virtual void openProjectForUrl( const QUrl &sourceUrl ) = 0; /** * open the project from the given kdev4 project file. This only reads * the file and starts creating the project model from it. The opening process * is finished once @ref projectOpened signal is emitted. * @param url a kdev4 project file top open * @returns true if the given project could be opened, false otherwise */ virtual void openProject( const QUrl & url = QUrl() ) = 0; /** * close the given project. Closing the project is done in steps and * the @ref projectClosing and @ref projectClosed signals are emitted. Only when * the latter signal is emitted it is guaranteed that the project has been closed. * The @ref IProject object will be deleted after the closing has finished. * @returns true if the project could be closed, false otherwise */ virtual void closeProject( IProject* ) = 0; /** * Close all projects * * This usually calls closeProject() on all controlled projects * @sa closeProject() */ virtual void closeAllProjects() = 0; virtual void configureProject( IProject* ) = 0; /// Schedules all files of the @p project for reparsing by @see BackgroundParser virtual void reparseProject( IProject* project, bool ForceUpdate = false ) = 0; // virtual void changeCurrentProject( KDevelop::ProjectBaseItem* ) = 0; Q_SIGNALS: /** * Emitted right before a project is started to be loaded. * * At this point all sanity checks have been done, so the project * is really going to be loaded. Will be followed by @ref projectOpened signal * when loading completes or by @ref projectOpeningAborted if there are errors during loading * or it is aborted. * * @param project the project that is about to be opened. */ void projectAboutToBeOpened( KDevelop::IProject* project ); /** * emitted after a project is completely opened and the project model * has been populated. * @param project the project that has been opened. */ void projectOpened( KDevelop::IProject* project ); /** * emitted when starting to close a project that has been completely loaded before * (the @ref projectOpened signal has been emitted). * @param project the project that is going to be closed. */ void projectClosing( KDevelop::IProject* project ); /** * emitted when a project has been closed completely. * The project object is still valid, the deletion will be done * delayed during the next run of the event loop. * @param project the project that has been closed. */ void projectClosed( KDevelop::IProject* project ); /** * emitted when a project could not be loaded correctly or loading was aborted. * @ref project contents may not be initialized properly. * @param project the project which loading has been aborted. */ void projectOpeningAborted( KDevelop::IProject* project ); /** * emitted whenever the project configuration dialog accepted * changes * @param project the project whose configuration has changed */ void projectConfigurationChanged( KDevelop::IProject* project ); }; } #endif diff --git a/interfaces/iprojectprovider.h b/interfaces/iprojectprovider.h index 8b54a3fd3d..b2d29c8438 100644 --- a/interfaces/iprojectprovider.h +++ b/interfaces/iprojectprovider.h @@ -1,70 +1,70 @@ /* This file is part of KDevelop * * Copyright 2010 Aleix Pol Gonzalez * * 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. */ #ifndef KDEVPLATFORM_IPROJECTPROVIDER_H #define KDEVPLATFORM_IPROJECTPROVIDER_H #include #include #include "interfacesexport.h" class QUrl; namespace KDevelop { class VcsLocationWidget; class VcsLocation; class VcsJob; class KDEVPLATFORMINTERFACES_EXPORT IProjectProviderWidget : public QWidget { Q_OBJECT public: - explicit IProjectProviderWidget(QWidget* parent = 0); + explicit IProjectProviderWidget(QWidget* parent = nullptr); /** * @returns a job that will create a working copy given the current state of the widget. * * @param destinationDirectory where the project will be downloaded. */ virtual VcsJob* createWorkingCopy(const QUrl & destinationDirectory) = 0; /** @returns whether we have a correct location in the widget. */ virtual bool isCorrect() const = 0; signals: void changed(const QString& name); }; class KDEVPLATFORMINTERFACES_EXPORT IProjectProvider { public: virtual ~IProjectProvider(); virtual QString name() const = 0; virtual IProjectProviderWidget* providerWidget(QWidget* parent) = 0; }; } Q_DECLARE_INTERFACE( KDevelop::IProjectProvider, "org.kdevelop.IProjectProvider" ) #endif diff --git a/interfaces/iruncontroller.h b/interfaces/iruncontroller.h index 2c2fb380a4..1dc12e7710 100644 --- a/interfaces/iruncontroller.h +++ b/interfaces/iruncontroller.h @@ -1,167 +1,167 @@ /* This file is part of KDevelop Copyright 2007-2008 Hamish Rodda This library 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 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. */ #ifndef KDEVPLATFORM_IRUNCONTROLLER_H #define KDEVPLATFORM_IRUNCONTROLLER_H #include #include #include "interfacesexport.h" class KJob; namespace KDevelop { class IProject; class ILaunchMode; class ILaunchConfiguration; class LaunchConfigurationType; /** * The main controller for running processes. */ class KDEVPLATFORMINTERFACES_EXPORT IRunController : public KJobTrackerInterface { Q_OBJECT Q_ENUMS(State) public: ///Constructor. explicit IRunController(QObject *parent); /** * Interrogate the current managed jobs */ Q_SCRIPTABLE virtual QList currentJobs() const = 0; /** * An enumeration of the possible states for the run controller. */ enum State { Idle /**< No processes are currently running */, Running /**< processes are currently running */ }; /** * Get a list of all launch modes that the app knows * @returns a list of registered launch modes */ virtual QList launchModes() const = 0; /** * Get a list of all available launch configurations */ virtual QList launchConfigurations() const = 0; /** * Get a specific launch mode based using its \a id * @param id the identifier of the launchmode to get * @returns launch mode for the given id or 0 if no such mode is known */ virtual ILaunchMode* launchModeForId( const QString& id ) const = 0; /** * add @p mode to the list of registered launch modes * @param mode the mode to be registered */ virtual void addLaunchMode( ILaunchMode* mode ) = 0; /** * remove @p mode from the list of registered launch modes * @param mode the mode to be unregistered */ virtual void removeLaunchMode( ILaunchMode* mode ) = 0; /** * Get a list of all configuration types that are registered * @returns a list of run configuration types */ virtual QList launchConfigurationTypes() const = 0; /** * Adds @p type to the list of known run config types * @param type the new run configuration type */ virtual void addConfigurationType( LaunchConfigurationType* type ) = 0; /** * Removes @p type from the list of known run config types * @param type run configuration type that should be removed */ virtual void removeConfigurationType( LaunchConfigurationType* type ) = 0; /** * Executes the default launch in the given mode * @param runMode the launch mode to start with */ virtual void executeDefaultLaunch( const QString& runMode ) = 0; virtual KJob* execute(const QString& launchMode, ILaunchConfiguration* launch) = 0; /** * tries to find a launch config type for the given @p id * @param id the id of the launch configuration type to search * @returns the launch configuration type if found, or 0 otherwise */ virtual LaunchConfigurationType* launchConfigurationTypeForId( const QString& id ) = 0; /** * Creates a new launch configuration in the given project or in the session if no project * was provided using the given launch configuration type and launcher. The configuration * is also added to the list of configurations in the runcontroller. * * @param type the launch configuration type to be used for the new config * @param launcher the mode and id of the launcher to be used in the config * @param project the project in which the launch configuration should be stored * @param name the name of the new launch configuration, if this is empty a new default name will be generated * @returns a new launch configuration */ virtual ILaunchConfiguration* createLaunchConfiguration( LaunchConfigurationType* type, const QPair& launcher, - KDevelop::IProject* project = 0, + KDevelop::IProject* project = nullptr, const QString& name = QString() ) = 0; public Q_SLOTS: /** * Request for all running processes to be killed. */ virtual void stopAllProcesses() = 0; Q_SIGNALS: /** * Notify that the state of the run controller has changed to \a {state}. */ void runStateChanged(State state); /** * Notify that a new job has been registered. */ void jobRegistered(KJob* job); /** * Notify that a job has been unregistered. */ void jobUnregistered(KJob* job); }; } #endif // KDEVPLATFORM_IRUNCONTROLLER_H diff --git a/interfaces/isession.h b/interfaces/isession.h index 3192a9d22d..8b60757905 100644 --- a/interfaces/isession.h +++ b/interfaces/isession.h @@ -1,77 +1,77 @@ /* This file is part of KDevelop Copyright 2008 Andreas Pakulat This library 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 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. */ #ifndef KDEVPLATFORM_ISESSION_H #define KDEVPLATFORM_ISESSION_H #include "interfacesexport.h" #include #include #include class QUuid; class QString; namespace KDevelop { class IPlugin; /** * @class ISession */ class KDEVPLATFORMINTERFACES_EXPORT ISession : public QObject { Q_OBJECT public: - explicit ISession( QObject* parent = 0 ); + explicit ISession( QObject* parent = nullptr ); ~ISession() override; /** * A short string nicely identifying the session, including contained projects * * The string is empty if the session is empty and has no name. */ virtual QString description() const = 0; virtual QString name() const = 0; virtual QList containedProjects() const = 0; virtual void setContainedProjects( const QList& projects ) = 0; virtual QUrl pluginDataArea( const IPlugin* ) = 0; virtual KSharedConfigPtr config() = 0; virtual QUuid id() const = 0; /** * Mark session as temporary. It will then be deleted on close. * * This is mainly useful for unit tests etc. */ virtual void setTemporary(bool temp) = 0; virtual bool isTemporary() const = 0; Q_SIGNALS: void sessionUpdated( KDevelop::ISession* session ); }; } Q_DECLARE_METATYPE( KDevelop::ISession* ) #endif diff --git a/interfaces/isourceformatter.h b/interfaces/isourceformatter.h index bfbc6d1c79..e90e67a45b 100644 --- a/interfaces/isourceformatter.h +++ b/interfaces/isourceformatter.h @@ -1,231 +1,231 @@ /* This file is part of KDevelop Copyright (C) 2008 Cédric Pasteur This library 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 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. */ #ifndef KDEVPLATFORM_ISOURCEFORMATTER_H #define KDEVPLATFORM_ISOURCEFORMATTER_H #include #include #include #include "interfacesexport.h" class QUrl; namespace KDevelop { class KDEVPLATFORMINTERFACES_EXPORT SourceFormatterStyle { public: struct MimeHighlightPair { QString mimeType; QString highlightMode; }; typedef QVector MimeList; SourceFormatterStyle(); explicit SourceFormatterStyle( const QString& name ); void setContent( const QString& content ); void setCaption( const QString& caption ); QString content() const; QString caption() const; QString name() const; QString description() const; void setDescription( const QString& desc ); bool usePreview() const; void setUsePreview(bool use); void setMimeTypes( const MimeList& types ); void setMimeTypes( const QStringList& types ); /// Provides the possibility to the item to return a better-suited /// code sample. If empty, the default is used. QString overrideSample() const; void setOverrideSample( const QString& sample ); MimeList mimeTypes() const; /// mime types as a QVariantList, type and mode separated by | in strings QVariant mimeTypesVariant() const; bool supportsLanguage(const QString& language) const; /// get the language / highlight mode for a given @p mime QString modeForMimetype(const QMimeType& mime) const; /// Copy content, mime types and code sample from @p other. void copyDataFrom(SourceFormatterStyle *other); private: bool m_usePreview; QString m_name; QString m_caption; QString m_content; QString m_description; QString m_overrideSample; MimeList m_mimeTypes; }; /** * @brief An object describing a style associated with a plugin * which can deal with this style. */ struct SourceFormatterStyleItem { QString engine; SourceFormatterStyle style; }; typedef QVector SourceFormatterItemList; /** * @short A widget to edit a style * A plugin should inherit this widget to create a widget to * edit a style. * @author Cédric Pasteur */ class KDEVPLATFORMINTERFACES_EXPORT SettingsWidget : public QWidget { Q_OBJECT public: - explicit SettingsWidget(QWidget *parent = 0); + explicit SettingsWidget(QWidget *parent = nullptr); ~SettingsWidget() override; /** This function is called after the creation of the dialog. * it should initialise the widgets with the values corresponding to * the predefined style \arg name if it's not empty, or * to the string \arg content. */ virtual void load(const SourceFormatterStyle&) = 0; /** \return A string representing the state of the config. */ virtual QString save() = 0; Q_SIGNALS: /** Emits this signal when a setting was changed and the preview * needs to be updated. \arg text is the text that will be shown in the * editor. One might want to show different text * according to the different pages shown in the widget. * Text should already be formatted. */ void previewTextChanged(const QString &text); }; /** * @short An interface for a source beautifier * An example of a plugin using an external executable to do * the formatting can be found in kdevelop/plugins/formatters/indent_plugin.cpp. * @author Cédric Pasteur */ class KDEVPLATFORMINTERFACES_EXPORT ISourceFormatter { public: virtual ~ISourceFormatter(); /** \return The name of the plugin. This should contain only * ASCII chars and no spaces. This will be used internally to identify * the plugin. */ virtual QString name() = 0; /** \return A caption describing the plugin. */ virtual QString caption() = 0; /** \return A more complete description of the plugin. * The string should be written in Rich text. It can eg contain * a link to the project homepage. */ virtual QString description() = 0; /** Formats using the current style. * @param text The text to format * @param url The URL to which the text belongs (its contents must not be changed). * @param leftContext The context at the left side of the text. If it is in another line, it must end with a newline. * @param rightContext The context at the right side of the text. If it is in the next line, it must start with a newline. * * If the source-formatter cannot work correctly with the context, it will just return the input text. */ virtual QString formatSource(const QString &text, const QUrl& url, const QMimeType &mime, const QString& leftContext = QString(), const QString& rightContext = QString()) = 0; /** * Format with the given style, this is mostly for the kcm to format the preview text * Its a bit of a hassle that this needs to be public API, but I can't find a better way * to do this. */ virtual QString formatSourceWithStyle( SourceFormatterStyle, const QString& text, const QUrl& url, const QMimeType &mime, const QString& leftContext = QString(), const QString& rightContext = QString() ) = 0; /** \return A map of predefined styles (a key and a caption for each type) */ virtual QList predefinedStyles() = 0; /** \return The widget to edit a style. */ virtual SettingsWidget* editStyleWidget(const QMimeType &mime) = 0; /** \return The text used in the config dialog to preview the current style. */ virtual QString previewText(const SourceFormatterStyle& style, const QMimeType &mime) = 0; struct Indentation { Indentation() : indentationTabWidth(0), indentWidth(0) { } // If this indentation is really valid bool isValid() const { return indentationTabWidth != 0 || indentWidth != 0; } // The length of one tab used for indentation. // Zero if unknown, -1 if tabs should not be used for indentation int indentationTabWidth; // The number of columns that equal one indentation level. // If this is zero, the default should be used. int indentWidth; }; /** \return The indentation of the style applicable for the given url. */ virtual Indentation indentation(const QUrl& url) = 0; /** \return A string representing the map. Values are written in the form * key=value and separated with ','. */ static QString optionMapToString(const QMap &map); /** \return A map corresponding to the string, that was created with * \ref optionMapToString. */ static QMap stringToOptionMap(const QString &option); /** \return A message to display when an executable needed by a * plugin is missing. This should be returned as description * if a needed executable is not found. */ static QString missingExecutableMessage(const QString &name); }; } Q_DECLARE_INTERFACE(KDevelop::ISourceFormatter, "org.kdevelop.ISourceFormatter") Q_DECLARE_TYPEINFO(KDevelop::SourceFormatterStyle::MimeHighlightPair, Q_MOVABLE_TYPE); #endif // KDEVPLATFORM_ISOURCEFORMATTER_H // kate: indent-mode cstyle; space-indent off; tab-width 4; diff --git a/interfaces/isourceformattercontroller.h b/interfaces/isourceformattercontroller.h index 2e2b3eb65b..5c09710ba0 100644 --- a/interfaces/isourceformattercontroller.h +++ b/interfaces/isourceformattercontroller.h @@ -1,71 +1,71 @@ /* This file is part of KDevelop Copyright 2009 Andreas Pakulat Copyright (C) 2008 Cédric Pasteur This library 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 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. */ #ifndef KDEVPLATFORM_ISOURCEFORMATTERCONTROLLER_H #define KDEVPLATFORM_ISOURCEFORMATTERCONTROLLER_H #include #include #include "interfacesexport.h" class QUrl; namespace KDevelop { class ISourceFormatter; class SourceFormatterStyle; /** \short An interface to the controller managing all source formatter plugins */ class KDEVPLATFORMINTERFACES_EXPORT ISourceFormatterController : public QObject { Q_OBJECT public: - explicit ISourceFormatterController(QObject *parent = 0); + explicit ISourceFormatterController(QObject *parent = nullptr); ~ISourceFormatterController() override; /** \return The formatter corresponding to the language * of the document corresponding to the \arg url. */ virtual ISourceFormatter* formatterForUrl(const QUrl &url) = 0; /** Loads and returns a source formatter for this mime type. * The language is then activated and the style is loaded. * The source formatter is then ready to use on a file. */ virtual ISourceFormatter* formatterForMimeType(const QMimeType &mime) = 0; /** \return Whether this mime type is supported by any plugin. */ virtual bool isMimeTypeSupported(const QMimeType &mime) = 0; virtual KDevelop::SourceFormatterStyle styleForMimeType( const QMimeType& mime ) = 0; ///Set whether or not source formatting is disabled with \arg disable virtual void disableSourceFormatting(bool disable) = 0; ///\return Whether or not source formatting is enabled virtual bool sourceFormattingEnabled() = 0; }; } #endif // KDEVPLATFORM_ISOURCEFORMATTERCONTROLLER_H // kate: indent-mode cstyle; space-indent off; tab-width 4 = 0; diff --git a/interfaces/itestcontroller.h b/interfaces/itestcontroller.h index 71d6a34afc..66dd5259ce 100644 --- a/interfaces/itestcontroller.h +++ b/interfaces/itestcontroller.h @@ -1,141 +1,141 @@ /* This file is part of KDevelop Copyright 2012 Miha Čančula This library 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 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. */ #ifndef KDEVPLATFORM_ITESTCONTROLLER_H #define KDEVPLATFORM_ITESTCONTROLLER_H #include "interfacesexport.h" #include #include #include #include class KJob; namespace KDevelop { struct TestResult; class IProject; class ITestSuite; /** * The result of a single unit test run **/ struct KDEVPLATFORMINTERFACES_EXPORT TestResult { /** * Enumeration of possible test case results **/ enum TestCaseResult { NotRun, ///< The test case was not selected for running. Skipped, ///< The test case was skipped. Passed, ///< The test case was run and passed. Failed, ///< The test case was run and failed. ExpectedFail, ///< The test case was expected to fail, and did. UnexpectedPass, ///< The test case was expected to fail, but passed. Error, ///< There was an error while trying to run the test case. }; /** * The individual results of all test cases. **/ QHash testCaseResults; /** * The total result of the entire suite. * * This is usually the worst outcome of the individual test cases, * but can be different especially when dealing with errors. */ TestCaseResult suiteResult; }; class KDEVPLATFORMINTERFACES_EXPORT ITestController : public QObject { Q_OBJECT public: - explicit ITestController(QObject* parent = 0); + explicit ITestController(QObject* parent = nullptr); ~ITestController() override; /** * Add a new test suite. * * No ownership is taken, the caller stays responsible for the suite. * * If a suite with the same project and same name exists, the old one will be removed and deleted. */ virtual void addTestSuite(ITestSuite* suite) = 0; /** * Remove a test suite from the controller. * * This does not delete the test suite. */ virtual void removeTestSuite(ITestSuite* suite) = 0; /** * Returns the list of all known test suites. */ virtual QList testSuites() const = 0; /** * Find a test suite in @p project with @p name. */ virtual ITestSuite* findTestSuite(IProject* project, const QString& name) const = 0; /** * Return the list of all test suites in @p project. */ virtual QList testSuitesForProject(IProject* project) const = 0; /** * Notify the controller that a test run for @p suite was finished with result @p result */ virtual void notifyTestRunFinished(ITestSuite* suite, const KDevelop::TestResult& result) = 0; /** * Notify the controller that a test run for @p suite was started */ virtual void notifyTestRunStarted(KDevelop::ITestSuite* suite, const QStringList& test_cases) = 0; Q_SIGNALS: /** * Emitted whenever a new test suite gets added. */ void testSuiteAdded(KDevelop::ITestSuite* suite) const; /** * Emitted whenever a test suite gets removed. */ void testSuiteRemoved(KDevelop::ITestSuite* suite) const; /** * Emitted after a test suite was run. */ void testRunFinished(KDevelop::ITestSuite* suite, const KDevelop::TestResult& result) const; /** * Emitted when a test suite starts. */ void testRunStarted(KDevelop::ITestSuite* suite, const QStringList& test_cases) const; }; } Q_DECLARE_INTERFACE( KDevelop::ITestController, "org.kdevelop.ITestController") #endif // KDEVPLATFORM_ITESTCONTROLLER_H diff --git a/interfaces/launchconfigurationpage.h b/interfaces/launchconfigurationpage.h index 97028ee486..73b8106951 100644 --- a/interfaces/launchconfigurationpage.h +++ b/interfaces/launchconfigurationpage.h @@ -1,89 +1,89 @@ /* This file is part of KDevelop Copyright 2009 Andreas Pakulat This library 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 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. */ #ifndef KDEVPLATFORM_LAUNCHCONFIGURATIONPAGE_H #define KDEVPLATFORM_LAUNCHCONFIGURATIONPAGE_H #include "interfacesexport.h" #include class KConfigGroup; namespace KDevelop { class IProject; /** * Provides a configuration page for a launch configuration, the interface * allows the actual dialog to easily load/save the configuration and show some title/icon */ class KDEVPLATFORMINTERFACES_EXPORT LaunchConfigurationPage : public QWidget { Q_OBJECT public: explicit LaunchConfigurationPage( QWidget* parent ); /** * Allows the page to load values from an existing launch configuration * @param cfg the configuration to load from */ - virtual void loadFromConfiguration( const KConfigGroup& cfg, KDevelop::IProject* project = 0 ) = 0; + virtual void loadFromConfiguration( const KConfigGroup& cfg, KDevelop::IProject* project = nullptr ) = 0; /** * Allows the page to save values to an existing launch configuration * @param cfg the configuration to save to */ - virtual void saveToConfiguration( KConfigGroup, KDevelop::IProject* project = 0 ) const = 0; + virtual void saveToConfiguration( KConfigGroup, KDevelop::IProject* project = nullptr ) const = 0; /** * A title for displaying in the GUI * @returns the title of the page */ virtual QString title() const = 0; /** * an icon for the GUI * @returns an icon suitable for display in the GUI */ virtual QIcon icon() const = 0; Q_SIGNALS: void changed(); }; /** * A simple factory class to create certain launch config pages * this is used to create config pages only when they're needed */ class KDEVPLATFORMINTERFACES_EXPORT LaunchConfigurationPageFactory { public: virtual ~LaunchConfigurationPageFactory() {} /** * create a new launch config page widget using the given @p parent * @param parent the parent widget to be used * @returns a new launch config page */ virtual LaunchConfigurationPage* createWidget( QWidget* parent ) = 0; }; } #endif diff --git a/interfaces/launchconfigurationtype.h b/interfaces/launchconfigurationtype.h index dff392e556..e1efbf38b4 100644 --- a/interfaces/launchconfigurationtype.h +++ b/interfaces/launchconfigurationtype.h @@ -1,152 +1,152 @@ /* This file is part of KDevelop Copyright 2009 Andreas Pakulat This library 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 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. */ #ifndef KDEVPLATFORM_LAUNCHCONFIGURATIONTYPE_H #define KDEVPLATFORM_LAUNCHCONFIGURATIONTYPE_H #include "interfacesexport.h" #include #include class QMenu; class QIcon; class QUrl; class KConfigGroup; namespace KDevelop { class IProject; class ILaunchConfiguration; class ProjectBaseItem; class ILauncher; class LaunchConfigurationPageFactory; /** * Launch configuration types are used to be able to create * new launch configurations. Each launch configuration has a * specific type, which specifies which launchers can be used * for the configuration as well as which config pages are needed * to setup the launch configuration */ class KDEVPLATFORMINTERFACES_EXPORT LaunchConfigurationType : public QObject { Q_OBJECT public: LaunchConfigurationType(); ~LaunchConfigurationType() override; /** * Provide a unique identifier for the type * among other things this will be used to create a config group in launch * configurations for the pages of this config type * @returns a unique identifier for this launch configuration type */ virtual QString id() const = 0; /** * Provide a user visible name for the type * @returns a translatable string for the type */ virtual QString name() const = 0; /** * Add @p starter to this configuration type * @param starter the launcher that can start configurations of this type */ void addLauncher( ILauncher* starter ); /** * remove @p starter from this configuration type * @param starter the launcher that should not start configurations of this type */ void removeLauncher( ILauncher* starter ); /** * Access all launchers that are usable with this type * @returns a list of launchers that can be used with configurations of this type */ QList launchers() const; /** * Convenience method to access a launcher given its @p id * @param id the id of the launcher to be found * @returns the launcher with the given id or 0 if there's no such launcher in this configuration type */ ILauncher* launcherForId( const QString& id ); /** * Provide a list of widgets to configure a launch configuration for this type * @returns a list of factories to create config pages from. */ virtual QList configPages() const = 0; /** * Provide an icon for this launch configuration type * @returns an icon to be used for representing launch configurations of this type */ virtual QIcon icon() const = 0; /** * Check whether this launch configuration type can launch the given project item * @param item the project tree item to test * @returns true if this configuration type can launch the given item, false otherwise */ virtual bool canLaunch( KDevelop::ProjectBaseItem* item ) const = 0; /** * Configure the given launch configuration to execute the selected item * @param config the configuration to setup * @param item the item to launch */ virtual void configureLaunchFromItem( KConfigGroup config, KDevelop::ProjectBaseItem* item ) const = 0; /** * Configure the given launch configuration to execute the selected item * @param config the configuration to setup * @param item the item to launch */ virtual void configureLaunchFromCmdLineArguments( KConfigGroup config, const QStringList &args ) const = 0; /** * Check whether this launch configuration type can launch the given file * @param file the file to test launchability * @returns true if this configuration type can launch the given file, false otherwise */ virtual bool canLaunch( const QUrl& file ) const = 0; /** * Returns a menu that will be added to the UI where the interface will be * able to add any suggestion it needs, like default targets. */ - virtual QMenu* launcherSuggestions() { return 0; } + virtual QMenu* launcherSuggestions() { return nullptr; } signals: void signalAddLaunchConfiguration(KDevelop::ILaunchConfiguration* launch); private: class LaunchConfigurationTypePrivate* const d; }; } #endif diff --git a/language/assistant/staticassistantsmanager.cpp b/language/assistant/staticassistantsmanager.cpp index 215a0d9b10..755789246b 100644 --- a/language/assistant/staticassistantsmanager.cpp +++ b/language/assistant/staticassistantsmanager.cpp @@ -1,315 +1,321 @@ /* Copyright 2009 David Nolden Copyright 2014 Kevin Funk 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 "staticassistantsmanager.h" #include "util/debug.h" #include #include #include #include #include #include #include #include #include #include #include #include using namespace KDevelop; using namespace KTextEditor; struct StaticAssistantsManager::Private { Private(StaticAssistantsManager* qq) : q(qq) { connect(DUChain::self(), &DUChain::updateReady, q, [this] (const IndexedString& url, const ReferencedTopDUContext& topContext) { updateReady(url, topContext); }); } void eventuallyStartAssistant(); void startAssistant(KDevelop::IAssistant::Ptr assistant); void checkAssistantForProblems(KDevelop::TopDUContext* top); void documentLoaded(KDevelop::IDocument*); void textInserted(Document* document, const Cursor& cursor, const QString& text); void textRemoved(Document* document, const Range& cursor, const QString& removedText); void updateReady(const IndexedString& document, const ReferencedTopDUContext& topContext); void documentActivated(KDevelop::IDocument*); void cursorPositionChanged(KTextEditor::View*, const KTextEditor::Cursor&); void timeout(); StaticAssistantsManager* q; QPointer m_currentView; KTextEditor::Cursor m_assistantStartedAt; KDevelop::IndexedString m_currentDocument; QExplicitlySharedDataPointer m_activeAssistant; QList m_registeredAssistants; bool m_activeProblemAssistant = false; QTimer* m_timer; SafeDocumentPointer m_eventualDocument; KTextEditor::Range m_eventualRange; QString m_eventualRemovedText; QMetaObject::Connection m_cursorPositionChangeConnection; }; StaticAssistantsManager::StaticAssistantsManager(QObject* parent) : QObject(parent) , d(new Private(this)) { d->m_timer = new QTimer(this); d->m_timer->setSingleShot(true); d->m_timer->setInterval(400); connect(d->m_timer, &QTimer::timeout, this, [&] { d->timeout(); }); connect(KDevelop::ICore::self()->documentController(), &IDocumentController::documentLoaded, this, [&] (IDocument* document) { d->documentLoaded(document); }); connect(KDevelop::ICore::self()->documentController(), &IDocumentController::documentActivated, this, [&] (IDocument* doc) { d->documentActivated(doc); }); foreach (IDocument* document, ICore::self()->documentController()->openDocuments()) { d->documentLoaded(document); } } StaticAssistantsManager::~StaticAssistantsManager() { } QExplicitlySharedDataPointer StaticAssistantsManager::activeAssistant() { return d->m_activeAssistant; } void StaticAssistantsManager::registerAssistant(const StaticAssistant::Ptr assistant) { if (d->m_registeredAssistants.contains(assistant)) return; d->m_registeredAssistants << assistant; } void StaticAssistantsManager::unregisterAssistant(const StaticAssistant::Ptr assistant) { d->m_registeredAssistants.removeOne(assistant); } QList StaticAssistantsManager::registeredAssistants() const { return d->m_registeredAssistants; } void StaticAssistantsManager::Private::documentLoaded(IDocument* document) { if (document->textDocument()) { connect(document->textDocument(), &Document::textInserted, q, [&] (Document* document, const Cursor& cursor, const QString& text) { textInserted(document, cursor, text); }); connect(document->textDocument(), &Document::textRemoved, q, [&] (Document* document, const Range& range, const QString& removedText) { textRemoved(document, range, removedText); }); } } void StaticAssistantsManager::hideAssistant() { d->m_activeAssistant = QExplicitlySharedDataPointer(); d->m_activeProblemAssistant = false; emit activeAssistantChanged(); } void StaticAssistantsManager::Private::textInserted(Document* document, const Cursor& cursor, const QString& text) { m_eventualDocument = document; m_eventualRange = Range(cursor, text.size()); m_eventualRemovedText.clear(); QMetaObject::invokeMethod(q, "eventuallyStartAssistant", Qt::QueuedConnection); } void StaticAssistantsManager::Private::textRemoved(Document* document, const Range& range, const QString& removedText) { m_eventualDocument = document; m_eventualRange = range; m_eventualRemovedText = removedText; QMetaObject::invokeMethod(q, "eventuallyStartAssistant", Qt::QueuedConnection); } void StaticAssistantsManager::Private::eventuallyStartAssistant() { if (!m_eventualDocument) { return; } View* view = ICore::self()->documentController()->activeTextDocumentView(); if (!view) { return; } if (view->document() != m_eventualDocument) { qWarning(LANGUAGE) << "Active view does not belong to document of last observed change!"; return; } auto language = ICore::self()->languageController()->languagesForUrl(m_eventualDocument.data()->url()).value(0); if (!language) { return; } qCDebug(LANGUAGE) << "Trying to find assistants for language" << language->name(); foreach (const auto& assistant, m_registeredAssistants) { if (assistant->supportedLanguage() != language) continue; // notify assistant about editor changes assistant->textChanged(view, m_eventualRange, m_eventualRemovedText); if (assistant->isUseful()) { startAssistant(IAssistant::Ptr(assistant.data())); break; } } // optimize, esp. for setText() calls as done in e.g. reformat source // only start the assitant once for multiple textRemoved/textInserted signals m_eventualDocument.clear(); m_eventualRange = Range::invalid(); m_eventualRemovedText.clear(); } void StaticAssistantsManager::Private::startAssistant(IAssistant::Ptr assistant) { if (assistant == m_activeAssistant) { return; } + qCDebug(LANGUAGE()) << "Starting assistant:" << assistant->title(); + if (m_activeAssistant) { m_activeAssistant->doHide(); } if (!m_currentView) return; m_activeAssistant = assistant; if (m_activeAssistant) { connect(m_activeAssistant.data(), &IAssistant::hide, q, &StaticAssistantsManager::hideAssistant, Qt::UniqueConnection); ICore::self()->uiController()->popUpAssistant(IAssistant::Ptr(m_activeAssistant.data())); m_assistantStartedAt = m_currentView.data()->cursorPosition(); } emit q->activeAssistantChanged(); } void StaticAssistantsManager::Private::updateReady(const IndexedString& url, const ReferencedTopDUContext& topContext) { + if (ICore::self()->shuttingDown()) { + return; + } + if (url != m_currentDocument) { return; } if (m_activeAssistant) { if (m_activeProblemAssistant) { m_activeAssistant->doHide(); //Hide the assistant, as we will create a new one if the problem is still there } else { return; } } DUChainReadLocker lock(DUChain::lock(), 300); if (!lock.locked()) { return; } if (topContext) { checkAssistantForProblems(topContext); } } void StaticAssistantsManager::Private::cursorPositionChanged(View*, const Cursor& pos) { if (m_activeAssistant && m_assistantStartedAt.isValid() && abs(m_assistantStartedAt.line() - pos.line()) >= 1) { m_activeAssistant->doHide(); } m_timer->start(); } void StaticAssistantsManager::Private::documentActivated(IDocument* doc) { if (doc) { m_currentDocument = IndexedString(doc->url()); } if (m_currentView) { QObject::disconnect(m_cursorPositionChangeConnection); m_currentView.clear(); } m_currentView = ICore::self()->documentController()->activeTextDocumentView(); if (m_currentView) { m_cursorPositionChangeConnection = connect(m_currentView.data(), &View::cursorPositionChanged, q, [&] (View* v, const Cursor& pos) { cursorPositionChanged(v, pos); }); } } void StaticAssistantsManager::Private::checkAssistantForProblems(TopDUContext* top) { foreach (ProblemPointer problem, top->problems()) { if (m_currentView && m_currentView.data()->cursorPosition().line() == problem->range().start.line) { IAssistant::Ptr solution = problem->solutionAssistant(); if(solution) { startAssistant(solution); m_activeProblemAssistant = true; break; } } } } void StaticAssistantsManager::Private::timeout() { if (!m_activeAssistant && m_currentView) { DUChainReadLocker lock(DUChain::lock(), 300); if (!lock.locked()) { return; } TopDUContext* top = DUChainUtils::standardContextForUrl(m_currentDocument.toUrl()); if (top) { checkAssistantForProblems(top); } } } #include "moc_staticassistantsmanager.cpp" diff --git a/language/assistant/staticassistantsmanager.h b/language/assistant/staticassistantsmanager.h index 46fd8e8b7b..3862422d63 100644 --- a/language/assistant/staticassistantsmanager.h +++ b/language/assistant/staticassistantsmanager.h @@ -1,79 +1,79 @@ /* Copyright 2009 David Nolden Copyright 2014 Kevin Funk 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. */ #ifndef KDEVPLATFORM_STATICASSISTANTSMANAGER_H #define KDEVPLATFORM_STATICASSISTANTSMANAGER_H #include #include #include "staticassistant.h" #include #include #include #include class QTimer; typedef QPointer SafeDocumentPointer; namespace KDevelop { class IDocument; class DUContext; class TopDUContext; /** * @brief Class managing instances of StaticAssistant * * Invokes the appropriate methods on registered StaticAssistant instances, such as StaticAssistant::textChanged * * @sa StaticAssistant::textChanged */ class KDEVPLATFORMLANGUAGE_EXPORT StaticAssistantsManager : public QObject { Q_OBJECT public: - explicit StaticAssistantsManager(QObject* parent = 0); + explicit StaticAssistantsManager(QObject* parent = nullptr); ~StaticAssistantsManager() override; QExplicitlySharedDataPointer activeAssistant(); void registerAssistant(const StaticAssistant::Ptr assistant); void unregisterAssistant(const StaticAssistant::Ptr assistant); QList registeredAssistants() const; public slots: void hideAssistant(); signals: void activeAssistantChanged(); private: struct Private; QScopedPointer const d; Q_PRIVATE_SLOT(d, void eventuallyStartAssistant()) }; } #endif // KDEVPLATFORM_STATICASSISTANTSMANAGER_H diff --git a/language/backgroundparser/backgroundparser.cpp b/language/backgroundparser/backgroundparser.cpp index eecbfbbed8..736e376b22 100644 --- a/language/backgroundparser/backgroundparser.cpp +++ b/language/backgroundparser/backgroundparser.cpp @@ -1,831 +1,842 @@ /* * This file is part of KDevelop * * Copyright 2006 Adam Treat * Copyright 2007 Kris Wong * Copyright 2007-2008 David Nolden * * 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 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 "backgroundparser.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "util/debug.h" #include "parsejob.h" #include const bool separateThreadForHighPriority = true; /** * Elides string in @p path, e.g. "VEEERY/LONG/PATH" -> ".../LONG/PATH" * - probably much faster than QFontMetrics::elidedText() * - we dont need a widget context * - takes path separators into account * * @p width Maximum number of characters * * TODO: Move to kdevutil? */ static QString elidedPathLeft(const QString& path, int width) { static const QChar separator = QDir::separator(); static const QString placeholder = QStringLiteral("..."); if (path.size() <= width) { return path; } int start = (path.size() - width) + placeholder.size(); int pos = path.indexOf(separator, start); if (pos == -1) { pos = start; // no separator => just cut off the path at the beginning } Q_ASSERT(path.size() - pos >= 0 && path.size() - pos <= width); QStringRef elidedText = path.rightRef(path.size() - pos); QString result = placeholder; result.append(elidedText); return result; } namespace { /** * @return true if @p url is non-empty, valid and has a clean path, false otherwise. */ inline bool isValidURL(const KDevelop::IndexedString& url) { if (url.isEmpty()) { return false; } QUrl original = url.toUrl(); if (!original.isValid() || original.isRelative() || original.fileName().isEmpty()) { qCWarning(LANGUAGE) << "INVALID URL ENCOUNTERED:" << url << original; return false; } QUrl cleaned = original.adjusted(QUrl::NormalizePathSegments); return original == cleaned; } } namespace KDevelop { class BackgroundParserPrivate { public: BackgroundParserPrivate(BackgroundParser *parser, ILanguageController *languageController) :m_parser(parser), m_languageController(languageController), m_shuttingDown(false), m_mutex(QMutex::Recursive) { parser->d = this; //Set this so we can safely call back BackgroundParser from within loadSettings() m_timer.setSingleShot(true); m_delay = 500; m_threads = 1; m_doneParseJobs = 0; m_maxParseJobs = 0; m_neededPriority = BackgroundParser::WorstPriority; ThreadWeaver::setDebugLevel(true, 1); QObject::connect(&m_timer, &QTimer::timeout, m_parser, &BackgroundParser::parseDocuments); } void startTimerThreadSafe() { QMetaObject::invokeMethod(m_parser, "startTimer", Qt::QueuedConnection); } ~BackgroundParserPrivate() { - // Release dequeued jobs - QHashIterator it = m_parseJobs; - while (it.hasNext()) { - it.next(); - delete it.value(); - } } // Non-mutex guarded functions, only call with m_mutex acquired. void parseDocumentsInternal() { if(m_shuttingDown) return; // Create delayed jobs, that is, jobs for documents which have been changed // by the user. QList jobs; // Before starting a new job, first wait for all higher-priority ones to finish. // That way, parse job priorities can be used for dependency handling. int bestRunningPriority = BackgroundParser::WorstPriority; foreach (const ThreadWeaver::QObjectDecorator* decorator, m_parseJobs) { const ParseJob* parseJob = dynamic_cast(decorator->job()); Q_ASSERT(parseJob); if (parseJob->respectsSequentialProcessing() && parseJob->parsePriority() < bestRunningPriority) { bestRunningPriority = parseJob->parsePriority(); } } bool done = false; for (QMap >::Iterator it1 = m_documentsForPriority.begin(); it1 != m_documentsForPriority.end(); ++it1 ) { if(it1.key() > m_neededPriority) break; //The priority is not good enough to be processed right now for(QSet::Iterator it = it1.value().begin(); it != it1.value().end();) { //Only create parse-jobs for up to thread-count * 2 documents, so we don't fill the memory unnecessarily if(m_parseJobs.count() >= m_threads+1 || (m_parseJobs.count() >= m_threads && !separateThreadForHighPriority) ) break; if(m_parseJobs.count() >= m_threads && it1.key() > BackgroundParser::NormalPriority && !specialParseJob) break; //The additional parsing thread is reserved for higher priority parsing // When a document is scheduled for parsing while it is being parsed, it will be parsed // again once the job finished, but not now. if (m_parseJobs.contains(*it) ) { ++it; continue; } Q_ASSERT(m_documents.contains(*it)); const DocumentParsePlan& parsePlan = m_documents[*it]; // If the current job requires sequential processing, but not all jobs with a better priority have been // completed yet, it will not be created now. if ( parsePlan.sequentialProcessingFlags() & ParseJob::RequiresSequentialProcessing && parsePlan.priority() > bestRunningPriority ) { ++it; continue; } qCDebug(LANGUAGE) << "creating parse-job" << *it << "new count of active parse-jobs:" << m_parseJobs.count() + 1; const QString elidedPathString = elidedPathLeft(it->str(), 70); emit m_parser->showMessage(m_parser, i18n("Parsing: %1", elidedPathString)); ThreadWeaver::QObjectDecorator* decorator = createParseJob(*it, parsePlan.features(), parsePlan.notifyWhenReady(), parsePlan.priority()); if(m_parseJobs.count() == m_threads+1 && !specialParseJob) specialParseJob = decorator; //This parse-job is allocated into the reserved thread if (decorator) { ParseJob* parseJob = dynamic_cast(decorator->job()); parseJob->setSequentialProcessingFlags(parsePlan.sequentialProcessingFlags()); jobs.append(ThreadWeaver::JobPointer(decorator)); // update the currently best processed priority, if the created job respects sequential processing if ( parsePlan.sequentialProcessingFlags() & ParseJob::RespectsSequentialProcessing && parsePlan.priority() < bestRunningPriority) { bestRunningPriority = parsePlan.priority(); } } // Remove all mentions of this document. foreach(const DocumentParseTarget& target, parsePlan.targets) { if (target.priority != it1.key()) { m_documentsForPriority[target.priority].remove(*it); } } m_documents.remove(*it); it = it1.value().erase(it); --m_maxParseJobs; //We have added one when putting the document into m_documents if(!m_documents.isEmpty()) { // Only try creating one parse-job at a time, else we might iterate through thousands of files // without finding a language-support, and block the UI for a long time. // If there are more documents to parse, instantly re-try. QMetaObject::invokeMethod(m_parser, "parseDocuments", Qt::QueuedConnection); done = true; break; } } if ( done ) break; } // Ok, enqueueing is fine because m_parseJobs contains all of the jobs now foreach (const ThreadWeaver::JobPointer& job, jobs) m_weaver.enqueue(job); m_parser->updateProgressBar(); //We don't hide the progress-bar in updateProgressBar, so it doesn't permanently flash when a document is reparsed again and again. if(m_doneParseJobs == m_maxParseJobs || (m_neededPriority == BackgroundParser::BestPriority && m_weaver.queueLength() == 0)) { emit m_parser->hideProgress(m_parser); } } ThreadWeaver::QObjectDecorator* createParseJob(const IndexedString& url, TopDUContext::Features features, const QList >& notifyWhenReady, int priority = 0) { ///FIXME: use IndexedString in the other APIs as well! Esp. for createParseJob! QUrl qUrl = url.toUrl(); auto languages = m_languageController->languagesForUrl(qUrl); foreach (const auto language, languages) { if(!language) { qCWarning(LANGUAGE) << "got zero language for" << qUrl; continue; } ParseJob* job = language->createParseJob(url); if (!job) { continue; // Language part did not produce a valid ParseJob. } job->setParsePriority(priority); job->setMinimumFeatures(features); job->setNotifyWhenReady(notifyWhenReady); ThreadWeaver::QObjectDecorator* decorator = new ThreadWeaver::QObjectDecorator(job); QObject::connect(decorator, &ThreadWeaver::QObjectDecorator::done, m_parser, &BackgroundParser::parseComplete); QObject::connect(decorator, &ThreadWeaver::QObjectDecorator::failed, m_parser, &BackgroundParser::parseComplete); QObject::connect(job, &ParseJob::progress, m_parser, &BackgroundParser::parseProgress, Qt::QueuedConnection); m_parseJobs.insert(url, decorator); ++m_maxParseJobs; // TODO more thinking required here to support multiple parse jobs per url (where multiple language plugins want to parse) return decorator; } if(languages.isEmpty()) qCDebug(LANGUAGE) << "found no languages for url" << qUrl; else qCDebug(LANGUAGE) << "could not create parse-job for url" << qUrl; //Notify that we failed typedef QPointer Notify; foreach(const Notify& n, notifyWhenReady) if(n) QMetaObject::invokeMethod(n.data(), "updateReady", Qt::QueuedConnection, Q_ARG(KDevelop::IndexedString, url), Q_ARG(KDevelop::ReferencedTopDUContext, ReferencedTopDUContext())); return nullptr; } void loadSettings() { ///@todo re-load settings when they have been changed! Q_ASSERT(ICore::self()->activeSession()); KConfigGroup config(ICore::self()->activeSession()->config(), "Background Parser"); // stay backwards compatible KConfigGroup oldConfig(KSharedConfig::openConfig(), "Background Parser"); #define BACKWARDS_COMPATIBLE_ENTRY(entry, default) \ config.readEntry(entry, oldConfig.readEntry(entry, default)) m_delay = BACKWARDS_COMPATIBLE_ENTRY("Delay", 500); m_timer.setInterval(m_delay); m_threads = 0; - m_parser->setThreadCount(BACKWARDS_COMPATIBLE_ENTRY("Number of Threads", QThread::idealThreadCount())); + + bool maxThreadsOverrideOk; + const int maxThreadsOverride = qgetenv("KDEV_BACKGROUNDPARSER_MAXTHREADS").toInt(&maxThreadsOverrideOk); + if (maxThreadsOverrideOk) { + m_parser->setThreadCount(maxThreadsOverride); + } else { + m_parser->setThreadCount(BACKWARDS_COMPATIBLE_ENTRY("Number of Threads", QThread::idealThreadCount())); + } resume(); if (BACKWARDS_COMPATIBLE_ENTRY("Enabled", true)) { m_parser->enableProcessing(); } else { m_parser->disableProcessing(); } } void suspend() { + qCDebug(LANGUAGE) << "Suspending background parser"; + bool s = m_weaver.state()->stateId() == ThreadWeaver::Suspended || m_weaver.state()->stateId() == ThreadWeaver::Suspending; if (s) { // Already suspending + qCWarning(LANGUAGE) << "Already suspended or suspending"; return; } m_timer.stop(); m_weaver.suspend(); } void resume() { bool s = m_weaver.state()->stateId() == ThreadWeaver::Suspended || m_weaver.state()->stateId() == ThreadWeaver::Suspending; if (m_timer.isActive() && !s) { // Not suspending return; } m_timer.start(m_delay); m_weaver.resume(); } BackgroundParser *m_parser; ILanguageController* m_languageController; //Current parse-job that is executed in the additional thread QPointer specialParseJob; QTimer m_timer; int m_delay; int m_threads; bool m_shuttingDown; struct DocumentParseTarget { QPointer notifyWhenReady; int priority; TopDUContext::Features features; ParseJob::SequentialProcessingFlags sequentialProcessingFlags; bool operator==(const DocumentParseTarget& rhs) const { return notifyWhenReady == rhs.notifyWhenReady && priority == rhs.priority && features == rhs.features; } }; struct DocumentParsePlan { QSet targets; ParseJob::SequentialProcessingFlags sequentialProcessingFlags() const { //Pick the strictest possible flags ParseJob::SequentialProcessingFlags ret = ParseJob::IgnoresSequentialProcessing; foreach(const DocumentParseTarget &target, targets) { ret |= target.sequentialProcessingFlags; } return ret; } int priority() const { //Pick the best priority int ret = BackgroundParser::WorstPriority; foreach(const DocumentParseTarget &target, targets) { if(target.priority < ret) { ret = target.priority; } } return ret; } TopDUContext::Features features() const { //Pick the best features TopDUContext::Features ret = (TopDUContext::Features)0; foreach(const DocumentParseTarget &target, targets) { ret = (TopDUContext::Features) (ret | target.features); } return ret; } QList > notifyWhenReady() const { QList > ret; foreach(const DocumentParseTarget &target, targets) if(target.notifyWhenReady) ret << target.notifyWhenReady; return ret; } }; // A list of documents that are planned to be parsed, and their priority QHash m_documents; // The documents ordered by priority QMap > m_documentsForPriority; // Currently running parse jobs QHash m_parseJobs; // A change tracker for each managed document QHash m_managed; // The url for each managed document. Those may temporarily differ from the real url. QHash m_managedTextDocumentUrls; // Projects currently in progress of loading QSet m_loadingProjects; ThreadWeaver::Queue m_weaver; QMutex m_mutex; int m_maxParseJobs; int m_doneParseJobs; QHash m_jobProgress; int m_neededPriority; //The minimum priority needed for processed jobs }; inline uint qHash(const BackgroundParserPrivate::DocumentParseTarget& target) { return target.features * 7 + target.priority * 13 + target.sequentialProcessingFlags * 17 + reinterpret_cast(target.notifyWhenReady.data()); }; BackgroundParser::BackgroundParser(ILanguageController *languageController) : QObject(languageController), d(new BackgroundParserPrivate(this, languageController)) { Q_ASSERT(ICore::self()->documentController()); connect(ICore::self()->documentController(), &IDocumentController::documentLoaded, this, &BackgroundParser::documentLoaded); connect(ICore::self()->documentController(), &IDocumentController::documentUrlChanged, this, &BackgroundParser::documentUrlChanged); connect(ICore::self()->documentController(), &IDocumentController::documentClosed, this, &BackgroundParser::documentClosed); connect(ICore::self(), &ICore::aboutToShutdown, this, &BackgroundParser::aboutToQuit); bool connected = QObject::connect(ICore::self()->projectController(), &IProjectController::projectAboutToBeOpened, this, &BackgroundParser::projectAboutToBeOpened); Q_ASSERT(connected); connected = QObject::connect(ICore::self()->projectController(), &IProjectController::projectOpened, this, &BackgroundParser::projectOpened); Q_ASSERT(connected); connected = QObject::connect(ICore::self()->projectController(), &IProjectController::projectOpeningAborted, this, &BackgroundParser::projectOpeningAborted); Q_ASSERT(connected); Q_UNUSED(connected); } void BackgroundParser::aboutToQuit() { d->m_shuttingDown = true; } BackgroundParser::~BackgroundParser() { delete d; } QString BackgroundParser::statusName() const { return i18n("Background Parser"); } void BackgroundParser::loadSettings() { d->loadSettings(); } void BackgroundParser::parseProgress(KDevelop::ParseJob* job, float value, QString text) { Q_UNUSED(text) d->m_jobProgress[job] = value; updateProgressBar(); } void BackgroundParser::revertAllRequests(QObject* notifyWhenReady) { QMutexLocker lock(&d->m_mutex); for(QHash::iterator it = d->m_documents.begin(); it != d->m_documents.end(); ) { d->m_documentsForPriority[it.value().priority()].remove(it.key()); foreach ( const BackgroundParserPrivate::DocumentParseTarget& target, (*it).targets ) { if ( notifyWhenReady && target.notifyWhenReady.data() == notifyWhenReady ) { (*it).targets.remove(target); } } if((*it).targets.isEmpty()) { it = d->m_documents.erase(it); --d->m_maxParseJobs; continue; } d->m_documentsForPriority[it.value().priority()].insert(it.key()); ++it; } } void BackgroundParser::addDocument(const IndexedString& url, TopDUContext::Features features, int priority, QObject* notifyWhenReady, ParseJob::SequentialProcessingFlags flags) { // qCDebug(LANGUAGE) << "BackgroundParser::addDocument" << url.toUrl(); Q_ASSERT(isValidURL(url)); QMutexLocker lock(&d->m_mutex); { BackgroundParserPrivate::DocumentParseTarget target; target.priority = priority; target.features = features; target.sequentialProcessingFlags = flags; target.notifyWhenReady = QPointer(notifyWhenReady); QHash::iterator it = d->m_documents.find(url); if (it != d->m_documents.end()) { //Update the stored plan d->m_documentsForPriority[it.value().priority()].remove(url); it.value().targets << target; d->m_documentsForPriority[it.value().priority()].insert(url); }else{ // qCDebug(LANGUAGE) << "BackgroundParser::addDocument: queuing" << cleanedUrl; d->m_documents[url].targets << target; d->m_documentsForPriority[d->m_documents[url].priority()].insert(url); ++d->m_maxParseJobs; //So the progress-bar waits for this document } d->startTimerThreadSafe(); } } void BackgroundParser::removeDocument(const IndexedString& url, QObject* notifyWhenReady) { Q_ASSERT(isValidURL(url)); QMutexLocker lock(&d->m_mutex); if(d->m_documents.contains(url)) { d->m_documentsForPriority[d->m_documents[url].priority()].remove(url); foreach(const BackgroundParserPrivate::DocumentParseTarget& target, d->m_documents[url].targets) { if(target.notifyWhenReady.data() == notifyWhenReady) { d->m_documents[url].targets.remove(target); } } if(d->m_documents[url].targets.isEmpty()) { d->m_documents.remove(url); --d->m_maxParseJobs; }else{ //Insert with an eventually different priority d->m_documentsForPriority[d->m_documents[url].priority()].insert(url); } } } void BackgroundParser::parseDocuments() { if (!d->m_loadingProjects.empty()) { startTimer(); return; } QMutexLocker lock(&d->m_mutex); d->parseDocumentsInternal(); } void BackgroundParser::parseComplete(const ThreadWeaver::JobPointer& job) { auto decorator = dynamic_cast(job.data()); Q_ASSERT(decorator); ParseJob* parseJob = dynamic_cast(decorator->job()); Q_ASSERT(parseJob); emit parseJobFinished(parseJob); { QMutexLocker lock(&d->m_mutex); d->m_parseJobs.remove(parseJob->document()); d->m_jobProgress.remove(parseJob); ++d->m_doneParseJobs; updateProgressBar(); } //Continue creating more parse-jobs QMetaObject::invokeMethod(this, "parseDocuments", Qt::QueuedConnection); } void BackgroundParser::disableProcessing() { setNeededPriority(BestPriority); } void BackgroundParser::enableProcessing() { setNeededPriority(WorstPriority); } int BackgroundParser::priorityForDocument(const IndexedString& url) const { Q_ASSERT(isValidURL(url)); QMutexLocker lock(&d->m_mutex); return d->m_documents[url].priority(); } bool BackgroundParser::isQueued(const IndexedString& url) const { Q_ASSERT(isValidURL(url)); QMutexLocker lock(&d->m_mutex); return d->m_documents.contains(url); } int BackgroundParser::queuedCount() const { QMutexLocker lock(&d->m_mutex); return d->m_documents.count(); } bool BackgroundParser::isIdle() const { QMutexLocker lock(&d->m_mutex); return d->m_documents.isEmpty() && d->m_weaver.isIdle(); } void BackgroundParser::setNeededPriority(int priority) { QMutexLocker lock(&d->m_mutex); d->m_neededPriority = priority; d->startTimerThreadSafe(); } +void BackgroundParser::abortAllJobs() +{ + qCDebug(LANGUAGE) << "Aborting all parse jobs"; + + d->m_weaver.requestAbort(); +} + void BackgroundParser::suspend() { d->suspend(); emit hideProgress(this); } void BackgroundParser::resume() { d->resume(); updateProgressBar(); } void BackgroundParser::updateProgressBar() { if (d->m_doneParseJobs >= d->m_maxParseJobs) { if(d->m_doneParseJobs > d->m_maxParseJobs) { qCDebug(LANGUAGE) << "m_doneParseJobs larger than m_maxParseJobs:" << d->m_doneParseJobs << d->m_maxParseJobs; } d->m_doneParseJobs = 0; d->m_maxParseJobs = 0; } else { float additionalProgress = 0; for(QHash::const_iterator it = d->m_jobProgress.constBegin(); it != d->m_jobProgress.constEnd(); ++it) additionalProgress += *it; emit showProgress(this, 0, d->m_maxParseJobs*1000, (additionalProgress + d->m_doneParseJobs)*1000); } } ParseJob* BackgroundParser::parseJobForDocument(const IndexedString& document) const { Q_ASSERT(isValidURL(document)); QMutexLocker lock(&d->m_mutex); auto decorator = d->m_parseJobs.value(document); return decorator ? dynamic_cast(decorator->job()) : nullptr; } void BackgroundParser::setThreadCount(int threadCount) { if (d->m_threads != threadCount) { d->m_threads = threadCount; d->m_weaver.setMaximumNumberOfThreads(d->m_threads+1); //1 Additional thread for high-priority parsing } } int BackgroundParser::threadCount() const { return d->m_threads; } void BackgroundParser::setDelay(int miliseconds) { if (d->m_delay != miliseconds) { d->m_delay = miliseconds; d->m_timer.setInterval(d->m_delay); } } QList< IndexedString > BackgroundParser::managedDocuments() { QMutexLocker l(&d->m_mutex); return d->m_managed.keys(); } DocumentChangeTracker* BackgroundParser::trackerForUrl(const KDevelop::IndexedString& url) const { if (url.isEmpty()) { // this happens e.g. when setting the final location of a problem that is not // yet associated with a top ctx. return 0; } Q_ASSERT(isValidURL(url)); QMutexLocker l(&d->m_mutex); return d->m_managed.value(url, 0); } void BackgroundParser::documentClosed(IDocument* document) { QMutexLocker l(&d->m_mutex); if(document->textDocument()) { KTextEditor::Document* textDocument = document->textDocument(); if(!d->m_managedTextDocumentUrls.contains(textDocument)) return; // Probably the document had an invalid url, and thus it wasn't added to the background parser Q_ASSERT(d->m_managedTextDocumentUrls.contains(textDocument)); IndexedString url(d->m_managedTextDocumentUrls[textDocument]); Q_ASSERT(d->m_managed.contains(url)); qCDebug(LANGUAGE) << "removing" << url.str() << "from background parser"; delete d->m_managed[url]; d->m_managedTextDocumentUrls.remove(textDocument); d->m_managed.remove(url); } } void BackgroundParser::documentLoaded( IDocument* document ) { QMutexLocker l(&d->m_mutex); if(document->textDocument() && document->textDocument()->url().isValid()) { KTextEditor::Document* textDocument = document->textDocument(); IndexedString url(document->url()); // Some debugging because we had issues with this if(d->m_managed.contains(url) && d->m_managed[url]->document() == textDocument) { qCDebug(LANGUAGE) << "Got redundant documentLoaded from" << document->url() << textDocument; return; } qCDebug(LANGUAGE) << "Creating change tracker for " << document->url(); Q_ASSERT(!d->m_managed.contains(url)); Q_ASSERT(!d->m_managedTextDocumentUrls.contains(textDocument)); d->m_managedTextDocumentUrls[textDocument] = url; d->m_managed.insert(url, new DocumentChangeTracker(textDocument)); }else{ qCDebug(LANGUAGE) << "NOT creating change tracker for" << document->url(); } } void BackgroundParser::documentUrlChanged(IDocument* document) { documentClosed(document); // Only call documentLoaded if the file wasn't renamed to a filename that is already tracked. if(document->textDocument() && !d->m_managed.contains(IndexedString(document->textDocument()->url()))) documentLoaded(document); } void BackgroundParser::startTimer() { d->m_timer.start(d->m_delay); } void BackgroundParser::projectAboutToBeOpened(IProject* project) { d->m_loadingProjects.insert(project); } void BackgroundParser::projectOpened(IProject* project) { d->m_loadingProjects.remove(project); } void BackgroundParser::projectOpeningAborted(IProject* project) { d->m_loadingProjects.remove(project); } } Q_DECLARE_TYPEINFO(KDevelop::BackgroundParserPrivate::DocumentParseTarget, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(KDevelop::BackgroundParserPrivate::DocumentParsePlan, Q_MOVABLE_TYPE); diff --git a/language/backgroundparser/backgroundparser.h b/language/backgroundparser/backgroundparser.h index 1fcbdfaa9b..bf22d38d70 100644 --- a/language/backgroundparser/backgroundparser.h +++ b/language/backgroundparser/backgroundparser.h @@ -1,233 +1,237 @@ /* * This file is part of KDevelop * * Copyright 2006 Adam Treat * Copyright 2007 Kris Wong * Copyright 2007-2008 David Nolden * * 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 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. */ #ifndef KDEVPLATFORM_BACKGROUNDPARSER_H #define KDEVPLATFORM_BACKGROUNDPARSER_H #include #include #include #include #include #include #include #include "parsejob.h" class QMutex; namespace ThreadWeaver { class Job; class QObjectDecorator; class Weaver; } namespace KDevelop { class DocumentChangeTracker; class IDocument; class IProject; class ILanguageController; class ParseJob; class ParserDependencyPolicy; /** * This class handles the creation of parse jobs for given file URLs. * * For performance reasons you must always use clean, canonical URLs. If you do not do that, * issues might arise (and the debug build will assert). */ class KDEVPLATFORMLANGUAGE_EXPORT BackgroundParser : public QObject, public IStatus { Q_OBJECT Q_INTERFACES( KDevelop::IStatus ) public: explicit BackgroundParser(ILanguageController *languageController); ~BackgroundParser() override; QString statusName() const override; enum { BestPriority = -10000, ///Best possible job-priority. No jobs should actually have this. NormalPriority = 0, ///Standard job-priority. This priority is used for parse-jobs caused by document-editing/opening. ///There is an additional parsing-thread reserved for jobs with this and better priority, to improve responsiveness. InitialParsePriority = 10000, ///Priority used when adding file on project loading WorstPriority = 100000 ///Worst possible job-priority. }; /** * Queries the background parser as to whether there is currently * a parse job for @p document, and if so, returns it. * * This may not contain all of the parse jobs that are intended * unless you call in from your job's ThreadWeaver::Job::aboutToBeQueued() * function. */ Q_SCRIPTABLE ParseJob* parseJobForDocument(const IndexedString& document) const; /** * Set how many ThreadWeaver threads the background parser should set up and use. */ Q_SCRIPTABLE void setThreadCount(int threadCount); /** * Return how many ThreadWeaver threads the background parser should set up and use. */ Q_SCRIPTABLE int threadCount() const; /** * Set the delay in miliseconds before the background parser starts parsing. */ Q_SCRIPTABLE void setDelay(int miliseconds); /** * Returns all documents that were added through addManagedTopRange. This is typically the currently * open documents. */ Q_SCRIPTABLE QList managedDocuments(); /** * Returns the tracker for the given url if the document is being tracked, else returns zero. * This function is thread-safe, but the returned object also isn't, so you must not use it * when you're in a background thread without the foreground lock acquired. * */ DocumentChangeTracker* trackerForUrl(const IndexedString& url) const; Q_SIGNALS: /** * Emitted whenever a document parse-job has finished. * The job contains the du-chain(if one was created) etc. * * The job is deleted after this signal has been emitted. Receivers should not hold * references to it. * * Note that if you want to be get updated for all DUChain updates, use * DUChain::updateReady instead, as a single ParseJob may update multiple * DUChain top contexts. * * @sa DUChain::updateReady */ void parseJobFinished(KDevelop::ParseJob* job); // Implementations of IStatus signals void clearMessage( KDevelop::IStatus* ) override; void showMessage( KDevelop::IStatus*, const QString & message, int timeout = 0) override; void hideProgress( KDevelop::IStatus* ) override; void showProgress( KDevelop::IStatus*, int minimum, int maximum, int value) override; void showErrorMessage( const QString&, int ) override; public Q_SLOTS: + /** + * Aborts all parse jobs + */ + void abortAllJobs(); /** * Suspends execution of the background parser */ void suspend(); /** * Resumes execution of the background parser */ void resume(); ///Reverts all requests that were made for the given notification-target. ///priorities and requested features will be reverted as well. ///When @p notifyWhenReady is set to a nullptr, all requests will be reverted. void revertAllRequests(QObject* notifyWhenReady); /** * Queues up the @p url to be parsed. * @p features The minimum features that should be computed for this top-context * @p priority A value that manages the order of parsing. Documents with lowest priority are parsed first. * @param notifyReady An optional pointer to a QObject that should contain a slot * "void updateReady(KDevelop::IndexedString url, KDevelop::ReferencedTopDUContext topContext)". * The notification is guaranteed to be called once for each call to addDocument. The given top-context * may be invalid if the update failed. */ - void addDocument(const IndexedString& url, TopDUContext::Features features = TopDUContext::VisibleDeclarationsAndContexts, int priority = 0, QObject* notifyWhenReady = 0, ParseJob::SequentialProcessingFlags flags = ParseJob::IgnoresSequentialProcessing); + void addDocument(const IndexedString& url, TopDUContext::Features features = TopDUContext::VisibleDeclarationsAndContexts, int priority = 0, QObject* notifyWhenReady = nullptr, ParseJob::SequentialProcessingFlags flags = ParseJob::IgnoresSequentialProcessing); /** * Removes the @p url that is registered for the given notification from the url. * * @param notifyWhenReady Notifier the document was added with. */ - void removeDocument(const IndexedString& url, QObject* notifyWhenReady = 0); + void removeDocument(const IndexedString& url, QObject* notifyWhenReady = nullptr); /** * Forces the current queue to be parsed. */ void parseDocuments(); void updateProgressBar(); ///Disables processing for all jobs that have a worse priority than @param priority ///This can be used to temporarily limit the processing to only the most important jobs. ///To only enable processing for important jobs, call setNeededPriority(0). ///This should only be used to temporarily alter the processing. A progress-bar ///will still be shown for the not yet processed jobs. void setNeededPriority(int priority); ///Disables all processing of new jobs, equivalent to setNeededPriority(BestPriority) void disableProcessing(); ///Enables all processing of new jobs, equivalent to setNeededPriority(WorstPriority) void enableProcessing(); ///Returns true if the given url is queued for parsing bool isQueued(const IndexedString& url) const; ///Retrieve the current priority for the given URL. ///You need to check whether @param url is queued before calling this function. int priorityForDocument(const IndexedString& url) const; ///Returns the number of queued jobs (not yet running nor submitted to ThreadWeaver) int queuedCount() const; ///Returns true if there are no jobs running nor queued anywhere bool isIdle() const; void documentClosed(KDevelop::IDocument*); void documentLoaded(KDevelop::IDocument*); void documentUrlChanged(KDevelop::IDocument*); void loadSettings(); protected Q_SLOTS: void parseComplete(const ThreadWeaver::JobPointer& job); void parseProgress(KDevelop::ParseJob*, float value, QString text); void startTimer(); void aboutToQuit(); private: friend class BackgroundParserPrivate; class BackgroundParserPrivate *d; private Q_SLOTS: /// Tracking of projects in state of loading. void projectAboutToBeOpened(KDevelop::IProject* project); void projectOpened(KDevelop::IProject* project); void projectOpeningAborted(KDevelop::IProject* project); }; } #endif diff --git a/language/backgroundparser/tests/test_backgroundparser.cpp b/language/backgroundparser/tests/test_backgroundparser.cpp index 9ecdd97789..0075ce4c63 100644 --- a/language/backgroundparser/tests/test_backgroundparser.cpp +++ b/language/backgroundparser/tests/test_backgroundparser.cpp @@ -1,301 +1,328 @@ /* * This file is part of KDevelop * * Copyright 2012 by Sven Brauch * Copyright 2012 by Milian Wolff * * 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 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 "test_backgroundparser.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include "testlanguagesupport.h" #include "testparsejob.h" QTEST_MAIN(TestBackgroundparser) #define QVERIFY_RETURN(statement, retval) \ do { if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__)) return retval; } while (0) using namespace KDevelop; JobPlan::JobPlan() { } void JobPlan::addJob(const JobPrototype& job) { m_jobs << job; } void JobPlan::clear() { m_jobs.clear(); m_finishedJobs.clear(); m_createdJobs.clear(); } void JobPlan::parseJobCreated(ParseJob* job) { // e.g. for the benchmark if (m_jobs.isEmpty()) { return; } TestParseJob* testJob = dynamic_cast(job); Q_ASSERT(testJob); qDebug() << "assigning propierties for created job" << testJob->document().toUrl(); testJob->duration_ms = jobForUrl(testJob->document()).m_duration; m_createdJobs.append(testJob->document()); } bool JobPlan::runJobs(int timeoutMS) { // add parse jobs foreach(const JobPrototype& job, m_jobs) { ICore::self()->languageController()->backgroundParser()->addDocument( job.m_url, TopDUContext::Empty, job.m_priority, this, job.m_flags ); } ICore::self()->languageController()->backgroundParser()->parseDocuments(); QElapsedTimer t; t.start(); while ( !t.hasExpired(timeoutMS) && m_jobs.size() != m_finishedJobs.size() ) { QTest::qWait(50); } QVERIFY_RETURN(m_jobs.size() == m_createdJobs.size(), false); QVERIFY_RETURN(m_finishedJobs.size() == m_jobs.size(), false); // verify they're started in the right order int currentBestPriority = BackgroundParser::BestPriority; foreach ( const IndexedString& url, m_createdJobs ) { const JobPrototype p = jobForUrl(url); QVERIFY_RETURN(p.m_priority >= currentBestPriority, false); currentBestPriority = p.m_priority; } return true; } JobPrototype JobPlan::jobForUrl(const IndexedString& url) { foreach(const JobPrototype& job, m_jobs) { if (job.m_url == url) { return job; } } return JobPrototype(); } void JobPlan::updateReady(const IndexedString& url, const ReferencedTopDUContext& /*context*/) { qDebug() << "update ready on " << url.toUrl(); const JobPrototype job = jobForUrl(url); QVERIFY(job.m_url.toUrl().isValid()); if (job.m_flags & ParseJob::RequiresSequentialProcessing) { // ensure that all jobs that respect sequential processing // with lower priority have been run foreach(const JobPrototype& otherJob, m_jobs) { if (otherJob.m_url == job.m_url) { continue; } if (otherJob.m_flags & ParseJob::RespectsSequentialProcessing && otherJob.m_priority < job.m_priority) { QVERIFY(m_finishedJobs.contains(otherJob.m_url)); } } } QVERIFY(!m_finishedJobs.contains(job.m_url)); m_finishedJobs << job.m_url; } void TestBackgroundparser::initTestCase() { AutoTestShell::init(); TestCore* core = TestCore::initialize(Core::NoUi); DUChain::self()->disablePersistentStorage(); TestLanguageController* langController = new TestLanguageController(core); core->setLanguageController(langController); langController->backgroundParser()->setThreadCount(4); - TestLanguageSupport* testLang = new TestLanguageSupport(); + auto testLang = new TestLanguageSupport(this); connect(testLang, &TestLanguageSupport::parseJobCreated, &m_jobPlan, &JobPlan::parseJobCreated); langController->addTestLanguage(testLang, QStringList() << QStringLiteral("text/plain")); const auto languages = langController->languagesForUrl(QUrl::fromLocalFile(QStringLiteral("/foo.txt"))); QCOMPARE(languages.size(), 1); QCOMPARE(languages.first(), testLang); } void TestBackgroundparser::cleanupTestCase() { TestCore::shutdown(); } void TestBackgroundparser::init() { m_jobPlan.clear(); } +void TestBackgroundparser::testShutdownWithRunningJobs() +{ + m_jobPlan.clear(); + // prove that background parsing happens with sequential flags although there is a high-priority + // foreground thread (active document being edited, ...) running all the time. + + // the long-running high-prio job + m_jobPlan.addJob(JobPrototype(QUrl::fromLocalFile(QStringLiteral("/test_fgt_hp.txt")), + -500, ParseJob::IgnoresSequentialProcessing, 1000)); + + // add parse jobs + foreach(const JobPrototype& job, m_jobPlan.m_jobs) { + ICore::self()->languageController()->backgroundParser()->addDocument( + job.m_url, TopDUContext::Empty, job.m_priority, this, job.m_flags + ); + } + + ICore::self()->languageController()->backgroundParser()->parseDocuments(); + QTest::qWait(50); + + // shut down with running jobs, make sure we don't crash + cleanupTestCase(); + + // restart again to restore invariant (core always running in test functions) + initTestCase(); +} + void TestBackgroundparser::testParseOrdering_foregroundThread() { m_jobPlan.clear(); // prove that background parsing happens with sequential flags although there is a high-priority // foreground thread (active document being edited, ...) running all the time. // the long-running high-prio job m_jobPlan.addJob(JobPrototype(QUrl::fromLocalFile(QStringLiteral("/test_fgt_hp.txt")), -500, ParseJob::IgnoresSequentialProcessing, 630)); // several small background jobs for ( int i = 0; i < 10; i++ ) { m_jobPlan.addJob(JobPrototype(QUrl::fromLocalFile("/test_fgt_lp__" + QString::number(i) + ".txt"), i, ParseJob::FullSequentialProcessing, 40)); } // not enough time if the small jobs run after the large one QVERIFY(m_jobPlan.runJobs(700)); } void TestBackgroundparser::testParseOrdering_noSequentialProcessing() { m_jobPlan.clear(); for ( int i = 0; i < 20; i++ ) { // create jobs with no sequential processing, and different priorities m_jobPlan.addJob(JobPrototype(QUrl::fromLocalFile("/test_nsp1__" + QString::number(i) + ".txt"), i, ParseJob::IgnoresSequentialProcessing, i)); } for ( int i = 0; i < 8; i++ ) { // create a few more jobs with the same priority m_jobPlan.addJob(JobPrototype(QUrl::fromLocalFile("/test_nsp2__" + QString::number(i) + ".txt"), 10, ParseJob::IgnoresSequentialProcessing, i)); } QVERIFY(m_jobPlan.runJobs(1000)); } void TestBackgroundparser::testParseOrdering_lockup() { m_jobPlan.clear(); for ( int i = 3; i > 0; i-- ) { // add 3 jobs which do not care about sequential processing, at 4 threads it should take no more than 1s to process them m_jobPlan.addJob(JobPrototype(QUrl::fromLocalFile("/test" + QString::number(i) + ".txt"), i, ParseJob::IgnoresSequentialProcessing, 200)); } // add one job which requires sequential processing with high priority m_jobPlan.addJob(JobPrototype(QUrl::fromLocalFile(QStringLiteral("/test_hp.txt")), -200, ParseJob::FullSequentialProcessing, 200)); // verify that the low-priority nonsequential jobs are run simultaneously with the other one. QVERIFY(m_jobPlan.runJobs(700)); } void TestBackgroundparser::testParseOrdering_simple() { m_jobPlan.clear(); for ( int i = 20; i > 0; i-- ) { // the job with priority i should be at place i in the finished list // (lower priority value -> should be parsed first) ParseJob::SequentialProcessingFlags flags = ParseJob::FullSequentialProcessing; m_jobPlan.addJob(JobPrototype(QUrl::fromLocalFile("/test" + QString::number(i) + ".txt"), i, flags)); } // also add a few jobs which ignore the processing for ( int i = 0; i < 5; ++i ) { m_jobPlan.addJob(JobPrototype(QUrl::fromLocalFile("/test2-" + QString::number(i) + ".txt"), BackgroundParser::NormalPriority, ParseJob::IgnoresSequentialProcessing)); } QVERIFY(m_jobPlan.runJobs(1000)); } void TestBackgroundparser::benchmark() { const int jobs = 10000; QVector jobUrls; jobUrls.reserve(jobs); for ( int i = 0; i < jobs; ++i ) { jobUrls << IndexedString("/test" + QString::number(i) + ".txt"); } QBENCHMARK { foreach ( const IndexedString& url, jobUrls ) { ICore::self()->languageController()->backgroundParser()->addDocument(url); } ICore::self()->languageController()->backgroundParser()->parseDocuments(); while ( ICore::self()->languageController()->backgroundParser()->queuedCount() ) { QTest::qWait(50); } } } void TestBackgroundparser::benchmarkDocumentChanges() { KTextEditor::Editor* editor = KTextEditor::Editor::instance(); QVERIFY(editor); KTextEditor::Document* doc = editor->createDocument(this); QVERIFY(doc); QTemporaryFile file; QVERIFY(file.open()); doc->saveAs(QUrl::fromLocalFile(file.fileName())); DocumentChangeTracker tracker(doc); doc->setText(QStringLiteral("hello world")); // required for proper benchmark results doc->createView(0); QBENCHMARK { for ( int i = 0; i < 5000; i++ ) { { KTextEditor::Document::EditingTransaction t(doc); doc->insertText(KTextEditor::Cursor(0, 0), QStringLiteral("This is a test line.\n")); } QApplication::processEvents(); } } doc->clear(); doc->save(); } diff --git a/language/backgroundparser/tests/test_backgroundparser.h b/language/backgroundparser/tests/test_backgroundparser.h index 64b5c189d5..2ce0ea4e42 100644 --- a/language/backgroundparser/tests/test_backgroundparser.h +++ b/language/backgroundparser/tests/test_backgroundparser.h @@ -1,111 +1,113 @@ /* * This file is part of KDevelop * * Copyright 2012 by Sven Brauch * Copyright 2012 by Milian Wolff * * 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 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. */ #ifndef KDEVPLATFORM_TEST_BACKGROUNDPARSER_H #define KDEVPLATFORM_TEST_BACKGROUNDPARSER_H #include #include #include #include #include "testlanguagesupport.h" class JobPrototype { public: JobPrototype() : m_priority(0) , m_duration(0) , m_flags(ParseJob::IgnoresSequentialProcessing) { } JobPrototype(const QUrl& url, int priority, ParseJob::SequentialProcessingFlags flags, int duration = 0) : m_url(url) , m_priority(priority) , m_duration(duration) , m_flags(flags) { Q_ASSERT(url.isValid()); } IndexedString m_url; int m_priority; int m_duration; ParseJob::SequentialProcessingFlags m_flags; }; Q_DECLARE_TYPEINFO(JobPrototype, Q_MOVABLE_TYPE); class TestParseJob; class JobPlan : public QObject { Q_OBJECT public: JobPlan(); void addJob(const JobPrototype& job); bool runJobs(int timeoutMS); void clear(); JobPrototype jobForUrl(const IndexedString& url); private slots: void updateReady(const KDevelop::IndexedString& url, const KDevelop::ReferencedTopDUContext& context); void parseJobCreated(KDevelop::ParseJob*); private: friend class TestBackgroundparser; QVector m_jobs; QVector m_finishedJobs; QVector m_createdJobs; }; class TestBackgroundparser : public QObject { Q_OBJECT private slots: void initTestCase(); void cleanupTestCase(); void init(); + void testShutdownWithRunningJobs(); + void testParseOrdering_simple(); void testParseOrdering_lockup(); void testParseOrdering_foregroundThread(); void testParseOrdering_noSequentialProcessing(); void benchmark(); void benchmarkDocumentChanges(); private: JobPlan m_jobPlan; }; #endif // KDEVPLATFORM_TEST_BACKGROUNDPARSER_H diff --git a/language/backgroundparser/tests/testlanguagesupport.h b/language/backgroundparser/tests/testlanguagesupport.h index c7b98bcff5..bb85bf00b3 100644 --- a/language/backgroundparser/tests/testlanguagesupport.h +++ b/language/backgroundparser/tests/testlanguagesupport.h @@ -1,43 +1,45 @@ /* * This file is part of KDevelop * * Copyright 2012 by Sven Brauch * * 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 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. */ #ifndef KDEVPLATFORM_TESTLANGUAGESUPPORT_H #define KDEVPLATFORM_TESTLANGUAGESUPPORT_H #include "language/interfaces/ilanguagesupport.h" #include using namespace KDevelop; class TestLanguageSupport : public QObject, public KDevelop::ILanguageSupport { Q_OBJECT Q_INTERFACES(KDevelop::ILanguageSupport) public: + using QObject::QObject; + KDevelop::ParseJob* createParseJob(const IndexedString& url) override; QString name() const override; signals: void parseJobCreated(KDevelop::ParseJob* job); }; #endif diff --git a/language/codegen/applychangeswidget.h b/language/codegen/applychangeswidget.h index 3bd94f419a..3a91223737 100644 --- a/language/codegen/applychangeswidget.h +++ b/language/codegen/applychangeswidget.h @@ -1,69 +1,69 @@ /* Copyright 2008 Aleix Pol * Copyright 2009 Ramón Zarazúa * * 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. */ #ifndef KDEVPLATFORM_APPLYCHANGESWIDGET_H #define KDEVPLATFORM_APPLYCHANGESWIDGET_H #include #include namespace KTextEditor { class Document; } namespace KDevelop { class IndexedString; class ApplyChangesWidgetPrivate; class KDEVPLATFORMLANGUAGE_EXPORT ApplyChangesWidget : public QDialog { Q_OBJECT public: - explicit ApplyChangesWidget(QWidget* parent=0); + explicit ApplyChangesWidget(QWidget* parent=nullptr); ~ApplyChangesWidget() override; void setInformation(const QString& info); bool hasDocuments() const; KTextEditor::Document* document() const; ///@param modified may be an artifial code representation (@ref KDevelop::InsertArtificialCodeRepresentation) void addDocuments(const IndexedString & original); ///This will save all the modified files into their originals bool applyAllChanges(); ///Update the comparison view fo @p index, in case changes have been done directly to the opened document. ///@param index the index to update, -1 for current index void updateDiffView(int index = -1); public Q_SLOTS: ///Called to signal a change to the currently viewed index void indexChanged(int); private: ApplyChangesWidgetPrivate * d; }; } #endif diff --git a/language/codegen/basicrefactoring.h b/language/codegen/basicrefactoring.h index 8eec1faea9..6ef5f94770 100644 --- a/language/codegen/basicrefactoring.h +++ b/language/codegen/basicrefactoring.h @@ -1,162 +1,162 @@ /* This file is part of KDevelop * * Copyright 2014 Miquel Sabaté * * 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 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. */ #ifndef BASICREFACTORING_H_ #define BASICREFACTORING_H_ #include #include #include #include #include class CppLanguageSupport; namespace KDevelop { class ContextMenuExtension; class IndexedDeclaration; class Context; class Declaration; class DUContext; /** * A widget that show the uses that it has collected for * the given declaration. */ class KDEVPLATFORMLANGUAGE_EXPORT BasicRefactoringCollector : public UsesWidget::UsesWidgetCollector { Q_OBJECT public: explicit BasicRefactoringCollector(const IndexedDeclaration &decl); QVector allUsingContexts() const; protected: /// Process the uses for the given TopDUContext. void processUses(KDevelop::ReferencedTopDUContext topContext) override; private: QVector m_allUsingContexts; }; /// The base class for Refactoring classes from Language plugins. class KDEVPLATFORMLANGUAGE_EXPORT BasicRefactoring : public QObject { Q_OBJECT public: - explicit BasicRefactoring(QObject *parent = NULL); + explicit BasicRefactoring(QObject *parent = nullptr); /// Update the context menu with the "Rename" action. virtual void fillContextMenu(KDevelop::ContextMenuExtension &extension, KDevelop::Context *context); struct NameAndCollector { QString newName; QSharedPointer collector; }; /** * @return Suggestion for new filename based on the current file's name @p current and new identifer @p newName */ virtual QString newFileName(const QUrl& current, const QString& newName); /** * Add the change(s) related to renaming @p file to @p newName to @p changes and return the result. * * @param current The URL for the file you want to rename. * @param newName The new name of the file *without* the file extension. * @param changes The change set to add the rename changes to. */ virtual KDevelop::DocumentChangeSet::ChangeResult addRenameFileChanges(const QUrl& current, const QString& newName, KDevelop::DocumentChangeSet* changes); virtual bool shouldRenameUses(Declaration* declaration) const; /** * @return true if the declaration's file should be renamed if the declaration * was renamed. */ virtual bool shouldRenameFile(KDevelop::Declaration* declaration); public slots: void executeRenameAction(); protected: /** * Apply the changes to the uses that can be found inside the given * context and its children. * NOTE: the DUChain must be locked. */ virtual DocumentChangeSet::ChangeResult applyChanges(const QString &oldName, const QString &newName, DocumentChangeSet &changes, DUContext *context, int usedDeclarationIndex); /** * Apply the changes to the given declarations. * NOTE: the DUChain must be locked. */ virtual DocumentChangeSet::ChangeResult applyChangesToDeclarations(const QString &oldName, const QString &newName, DocumentChangeSet &changes, const QList &declarations); /** * Get the declaration under the current position of the cursor. * * @param allowUse Set to false if the declarations to be returned * cannot come from uses. */ virtual IndexedDeclaration declarationUnderCursor(bool allowUse = true); /** * Start the renaming of a declaration. * This function retrieves the new name for declaration @p decl and if approved renames all instances of it. */ virtual void startInteractiveRename(const KDevelop::IndexedDeclaration &decl); /** * Asks user to input a new name for @p declaration * @return new name or empty string if user changed his mind or new name contains inappropriate symbols (e.g. spaces, points, braces e.t.c) and the collector used for collecting information about @p declaration. * NOTE: unlock the DUChain before calling this. */ virtual BasicRefactoring::NameAndCollector newNameForDeclaration(const KDevelop::DeclarationPointer& declaration); /** * Renames all declarations collected by @p collector from @p oldName to @p newName * @param apply - if changes should be applied immediately * @return all changes if @p apply is false and empty set otherwise. */ DocumentChangeSet renameCollectedDeclarations(KDevelop::BasicRefactoringCollector* collector, const QString& replacementName, const QString& originalName, bool apply = true); /** * @returns true if we can show the interactive rename widget for the * given declaration. The default implementation just returns true. */ virtual bool acceptForContextMenu(const Declaration *decl); }; } // End of namespace KDevelop #endif /* BASICREFACTORING_H_ */ diff --git a/language/codegen/templatesmodel.h b/language/codegen/templatesmodel.h index 0c30036bec..f15848c061 100644 --- a/language/codegen/templatesmodel.h +++ b/language/codegen/templatesmodel.h @@ -1,122 +1,122 @@ /* This file is part of KDevelop Copyright 2007 Alexander Dymo Copyright 2012 Miha Čančula This library 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 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. */ #ifndef KDEVPLATFORM_TEMPLATESMODEL_H #define KDEVPLATFORM_TEMPLATESMODEL_H #include #include namespace KDevelop { class TemplatesModelPrivate; /** * @brief A convenience class for loading templates using .kdevtemplate files * * It loads template archives, extracts and stores their description files, and * displays them as a three-level tree structure. * * The locations for loading and storing files are determined by the typePrefix. * We use QStandardPaths with the GenericData type and create a filter string as such: * \li templates: typePrefix "/templates/" * \li descriptions: typePrefix "/template_descriptions/" * \li previews: typePrefix "/template_previews/" * * @sa ITemplateProvider::templatesModel() **/ class KDEVPLATFORMLANGUAGE_EXPORT TemplatesModel : public QStandardItemModel { Q_OBJECT public: /** * Extra roles for template-specific properties * @sa Qt::ItemDataRole **/ enum TemplateRole { DescriptionFileRole = Qt::UserRole + 1, ///< Template description file name IconNameRole = Qt::UserRole + 2, ///< Template icon name CommentRole = Qt::UserRole + 3, ///< Template comment ArchiveFileRole = Qt::UserRole + 4 ///< Template archive file name }; /** * Creates a new templates model * * @param typePrefix the type prefix used to determine resource locations. * @param parent parent object, defaults to 0. **/ - explicit TemplatesModel(const QString& typePrefix, QObject* parent = 0); + explicit TemplatesModel(const QString& typePrefix, QObject* parent = nullptr); /** * Destructor * **/ ~TemplatesModel() override; /** * Reloads all found templates **/ virtual void refresh(); /** * Loads template @p fileName and save it to the template storage directory. * * If the file is an archive, the whole archive will be copied. * If the file has a .desktop or .kdevtemplate suffix, the contents * of its containing directory will be archived and saved. **/ QString loadTemplateFile(const QString& fileName); /** * Finds the model index of the template file @p fileName. * * For convenience, this function returns the found template index, as well as all of its ancestors. * The indexes are ordered from the top-level ancestor to the actual index of the template. * This is useful for managing selection when multiple views display different level of the model. * * @param fileName the template file name **/ QModelIndexList templateIndexes(const QString& fileName) const; /** * Returns the type prefix used to find a template resource. **/ QString typePrefix() const; /** * The model will include @p path during the search for template archives * * @param path Path to a directory that contains normal user data. The template model will search for a kdevappwizard/templates (or your model name prefix) directory * inside @p path and will use them. Please note that the path has to end with a '/'. */ void addDataPath(const QString &path); private: TemplatesModelPrivate* const d; }; } #endif // KDEVPLATFORM_TEMPLATESMODEL_H diff --git a/language/codegen/utilities.h b/language/codegen/utilities.h index 0b6da79e0c..00f9e62d19 100644 --- a/language/codegen/utilities.h +++ b/language/codegen/utilities.h @@ -1,74 +1,74 @@ /* Copyright 2009 Ramón Zarazúa 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 #include #ifndef KDEVPLATFORM_CODEGEN_UTILITIES_H #define KDEVPLATFORM_CODEGEN_UTILITIES_H namespace KDevelop { class IndexedString; class DUContext; class Declaration; namespace CodeGenUtils { /*! * A validator object that verifies if a string would be an acceptable identifier * If inserted into the given context, including if it conflicts with any other identifier */ class KDEVPLATFORMLANGUAGE_EXPORT IdentifierValidator : public QValidator { Q_OBJECT public: explicit IdentifierValidator( DUContext * context); - ~IdentifierValidator(); + ~IdentifierValidator() override; - virtual State validate(QString & input, int &) const override; + State validate(QString & input, int &) const override; private: DUContext * m_context; }; /** * @brief Search for the file that contains the implementation of a specified type * * Search for the file that contains the implementation of @p targetClass. For languages that * allow implementation of a type through multiple files, the file with the most implementations of * class methods will be chosen, if a tie is found, then the file with the most uses will be chosen. * Else the file that contains the declaration is chosen. * * @note If called with a Forward declaration, the real declaration will be searched for. * * @return The file that matched best */ KDEVPLATFORMLANGUAGE_EXPORT IndexedString fetchImplementationFileForClass(const Declaration & targetClass); } } #endif //KDEVPLATFORM_CODEGEN_UTILITIES_H diff --git a/language/duchain/duchain.h b/language/duchain/duchain.h index 24dbda635e..56162d4ef4 100644 --- a/language/duchain/duchain.h +++ b/language/duchain/duchain.h @@ -1,315 +1,315 @@ /* This file is part of KDevelop Copyright 2006-2008 Hamish Rodda Copyright 2007-2008 David Nolden 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. */ #ifndef KDEVPLATFORM_DUCHAIN_H #define KDEVPLATFORM_DUCHAIN_H #include #include "topducontext.h" #include "parsingenvironment.h" class QUrl; namespace KDevelop { class IDocument; class TopDUContext; class DUChainLock; class ParsingEnvironmentManager; class ParsingEnvironment; class ParsingEnvironmentFile; typedef QExplicitlySharedDataPointer ParsingEnvironmentFilePointer; class Definitions; class Uses; /** * \short Holds references to all top level source file contexts. * * The DUChain is a global static class which manages the definition-use * chains. It performs the following functions: * \li registers chains with addDocumentChain() and deregisters with removeDocumentChain() * \li allows querying for existing chains * \li watches text editors, registering and deregistering them with the BackgroundParser when files * are opened and closed. */ class KDEVPLATFORMLANGUAGE_EXPORT DUChain : public QObject { Q_OBJECT public: /** * Initializes common static item repositories. * Must be called once for multi threaded applications to work reliably. */ static void initialize(); /** * Return a list of all chains available */ Q_SCRIPTABLE QList allChains() const; /** * Makes sure the standard-context for the given url is up-to-date. * This may trigger a parsing in background, so a QObject can be given that will be notified * asyonchronously once the update is ready. * If the context is already up to date, the given QObject is notified directly. * * @param document Document to update * @param features The requested features. If you want to force a full update of the context, give TopDUContext::ForceUpdate. * If you want to force an update including all imports, use TopDUContext::ForceUpdateRecursive. * @param notifyReady An optional pointer to a QObject that should contain a slot * "void updateReady(KDevelop::IndexedString url, KDevelop::ReferencedTopDUContext topContext)". * The notification is guaranteed to be called once for each call to updateContextForUrl. The given top-context * may be invalid if the update failed. A queued connection is used if a re-parse has to be done. The duchain * will _not_ be locked when updateReady is called. * @param priority An optional priority for the job. The lower the value, the higher it's priority. * @note The duchain must _not_ be locked when this is called! */ - Q_SCRIPTABLE void updateContextForUrl(const IndexedString& document, TopDUContext::Features minFeatures, QObject* notifyReady = 0, int priority = 1) const; + Q_SCRIPTABLE void updateContextForUrl(const IndexedString& document, TopDUContext::Features minFeatures, QObject* notifyReady = nullptr, int priority = 1) const; /** * Convenience-function similar to updateContextForUrl that blocks this thread until the update of the given document is ready, * and returns the top-context. * @param document The document to update * @param features The requested features. If you want to force a full update of the context, give TopDUContext::ForceUpdate. * If you want to force an update including all imports, use TopDUContext::ForceUpdateRecursive. * @return The up-to-date top-context, or zero if the update failed * * @note The duchain must _not_ be locked when this is called! * */ KDevelop::ReferencedTopDUContext waitForUpdate(const KDevelop::IndexedString& document, KDevelop::TopDUContext::Features minFeatures, bool proxyContext = false); /** * Return any chain for the given document * If available, the version accepting IndexedString should be used instead of this, for performance reasons. * When no fitting chain is in memory, one may be loaded from disk. * * @note The duchain must be at least read-locked locked when this is called! * */ Q_SCRIPTABLE TopDUContext* chainForDocument(const QUrl& document, bool proxyContext = false) const; Q_SCRIPTABLE TopDUContext* chainForDocument(const IndexedString& document, bool proxyContext = false) const; /** * Return all chains for the given document that are currently in memory. * This does not load any chains from disk. * */ Q_SCRIPTABLE QList chainsForDocument(const QUrl& document) const; /** * Return all chains for the given document that are currently in memory. * This does not load any chains from disk. * Should be preferred over the QUrl version. * */ Q_SCRIPTABLE QList chainsForDocument(const IndexedString& document) const; /** * Find a chain that fits into the given environment. If no fitting chain is found, 0 is returned. * When no fitting chain is in memory, one may be loaded from disk. * @param proxyContext If this is true, only contexts are found that have an ParsingEnvironmentFile that has the proxy-flag set. Else, only content-contexts will be returned. * * @note The duchain must be at least read-locked locked when this is called! * */ Q_SCRIPTABLE TopDUContext* chainForDocument(const QUrl& document, const ParsingEnvironment* environment, bool proxyContext = false) const; /** * Find a chain that fits into the given environment. If no fitting chain is found, 0 is returned. * When no fitting chain is in memory, one may be loaded from disk. * @param proxyContext If this is true, only contexts are found that have an ParsingEnvironmentFile that has the proxy-flag set. Else, only content-contexts will be returned. * * Prefer this over the QUrl version. * * @note The duchain must be at least read-locked locked when this is called! * */ Q_SCRIPTABLE TopDUContext* chainForDocument(const IndexedString& document, const ParsingEnvironment* environment, bool proxyContext = false) const; /** * Find the environment-file of a chain that fits into the given environment. If no fitting chain is found, 0 is returned. * When no fitting chain is in memory, one may be loaded from disk. * * This should be preferred over chainForDocument when only the environment-info is needed, because the TopDUContext is not loaded in this function. * ** @param proxyContext If this is true, only contexts are found that have an ParsingEnvironmentFile that has the proxy-flag set. Else, only content-contexts will be returned. * * Prefer this over the QUrl version. * * @note The duchain must be at least read-locked locked when this is called! * */ Q_SCRIPTABLE ParsingEnvironmentFilePointer environmentFileForDocument(const IndexedString& document, const ParsingEnvironment* environment, bool proxyContext = false) const; Q_SCRIPTABLE ParsingEnvironmentFilePointer environmentFileForDocument(IndexedTopDUContext topContext) const; /** * Returns the list of the environment-infos of all versions of the given document. */ Q_SCRIPTABLE QList allEnvironmentFiles(const IndexedString& document); ///Returns the top-context that has the given index assigned, or zero if it doesn't exist. @see TopDUContext::ownIndex ///The duchain must be read-locked when this is called ///This function is inlined because it is called in a very high frequency Q_SCRIPTABLE inline TopDUContext* chainForIndex(uint index) { if(m_deleted) - return 0; + return nullptr; { QMutexLocker lock(&chainsByIndexLock); if(chainsByIndex.size() > index) { TopDUContext* top = chainsByIndex[index]; if(top) return top; } } //Load the top-context return loadChain(index); } ///Returns the url for the given top-context index if available. This does have some cost, so avoid it when possible. Q_SCRIPTABLE IndexedString urlForIndex(uint index) const; /// Only used for debugging at the moment Q_SCRIPTABLE QList documents() const; /// Only used for debugging at the moment /// Prefer that over the QUrl version for performance reasons Q_SCRIPTABLE QList indexedDocuments() const; /** * Registers a new definition-use \a chain for the given \a document. */ Q_SCRIPTABLE void addDocumentChain(TopDUContext* chain); /// Returns true if the global duchain instance has already been deleted Q_SCRIPTABLE static bool deleted(); /// Returns the global static instance. Q_SCRIPTABLE static DUChain* self(); /// Returns the structure that manages mapping between definitions and declarations Q_SCRIPTABLE static Definitions* definitions(); /// Returns the structure that manages mapping between declarations, and which top level contexts contain uses of them. static Uses* uses(); /** * Retrieve the read write lock for the entire definition-use chain. * To call non-const methods, you must be holding a write lock. * * Evaluations made prior to holding a lock (including which objects * exist) must be verified once the lock is held, as they may have changed * or been deleted. * * \threadsafe */ Q_SCRIPTABLE static DUChainLock* lock(); /// Returns whether the top-context with the given index is currently loaded in memory Q_SCRIPTABLE bool isInMemory(uint topContextIndex) const; /** * Changes the environment attached to the given top-level context, and updates the management-structures to reflect that * */ Q_SCRIPTABLE void updateContextEnvironment( TopDUContext* context, ParsingEnvironmentFile* file ); ///Allocates a new identity for a new top-context, no lock needed. The returned value is never zero static uint newTopContextIndex(); ///If you call this, the persistent disk-storage structure will stay unaffected, and no duchain cleanup will be done. ///Call this from within tests. void disablePersistentStorage(bool disable = true); ///Stores the whole duchain and all its repositories in the current state to disk ///The duchain must not be locked in any way void storeToDisk(); ///Compares the whole duchain and all its repositories in the current state to disk ///When the comparison fails, debug-output will show why ///The duchain must not be locked when calling this ///@return true If the current memory state equals the disk state, else false bool compareToDisk(); Q_SIGNALS: ///Is emitted when the declaration has been selected somewhere in the user-interface, for example in the completion-list void declarationSelected(const KDevelop::DeclarationPointer& decl); /** * This signal is emitted whenever the DUChain data associated with @p url was updated. * * You can connect to this signal to get notified when the DUChain for a given file was updated. */ void updateReady(const KDevelop::IndexedString& url, const KDevelop::ReferencedTopDUContext& topContext); public Q_SLOTS: ///Removes the given top-context from the duchain, and deletes it. void removeDocumentChain(KDevelop::TopDUContext* document); ///Emits the declarationSelected signal, so other parties can notice it. void emitDeclarationSelected(const KDevelop::DeclarationPointer& decl); /** * Call this after you have modified the DUChain data associated with the file @p url. * * This triggers an emit of the @c updateReady signal. */ void emitUpdateReady(const KDevelop::IndexedString& url, const KDevelop::ReferencedTopDUContext& topContext); /** * Shutdown and cleanup the DUChain. */ void shutdown(); private Q_SLOTS: void documentActivated(KDevelop::IDocument* doc); void documentLoadedPrepare(KDevelop::IDocument* document); void documentRenamed(KDevelop::IDocument* document); void documentClosed(KDevelop::IDocument*); private: TopDUContext* loadChain(uint index); //These two are exported here so that the extremely frequently called chainForIndex(..) can be inlined static bool m_deleted; static std::vector chainsByIndex; static QMutex chainsByIndexLock; /// Increases the reference-count for the given top-context. The result: It will not be unloaded. /// Do this to prevent KDevelop from unloading a top-context that you plan to use. Don't forget calling unReferenceToContext again, /// else the top-context will stay in memory for ever. void refCountUp(TopDUContext* top); /// Decreases the reference-count for the given top-context. When it reaches zero, KDevelop is free to unload it at any time, /// also invalidating all the contained declarations and contexts. void refCountDown(TopDUContext* top); void addToEnvironmentManager( TopDUContext * chain ); void removeFromEnvironmentManager( TopDUContext * chain ); DUChain(); ~DUChain() override; friend class DUChainPrivate; friend class ReferencedTopDUContext; }; } #endif // KDEVPLATFORM_DUCHAIN_H diff --git a/language/duchain/ducontext.h b/language/duchain/ducontext.h index c5171fc433..3930bac2f3 100644 --- a/language/duchain/ducontext.h +++ b/language/duchain/ducontext.h @@ -1,951 +1,951 @@ /* This file is part of KDevelop Copyright 2006 Hamish Rodda Copyright 2007-2009 David Nolden 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. */ #ifndef KDEVPLATFORM_DUCONTEXT_H #define KDEVPLATFORM_DUCONTEXT_H #include #include #include #include #include #include "identifier.h" #include "duchainbase.h" #include "types/abstracttype.h" #include "duchainpointer.h" #include "declarationid.h" #include "indexedducontext.h" class QWidget; namespace KDevelop { class Declaration; class DUChain; class Use; class TopDUContext; class DUContext; class DUContextData; class KDEVPLATFORMLANGUAGE_EXPORT DUChainVisitor { public: virtual void visit(DUContext* context) = 0; virtual void visit(Declaration* declaration) = 0; virtual ~DUChainVisitor(); }; typedef DUChainPointer DUContextPointer; /** * A single context in source code, represented as a node in a * directed acyclic graph. * * Access to context objects must be serialised by holding the * chain lock, ie. DUChain::lock(). * * NOTE: A du-context can be freely edited as long as it's parent-context is zero. * In the moment the parent-context is set, the context may only be edited when it * is allowed to edited it's top-level context(@see TopLevelContext::inDUChain() * * @todo change child relationships to a linked list within the context? */ class KDEVPLATFORMLANGUAGE_EXPORT DUContext : public DUChainBase { friend class Use; friend class Declaration; friend class DeclarationData; friend class DUContextData; friend class DUContextDynamicData; friend class Definition; friend class VisibleDeclarationIterator; public: /** * Constructor. No convenience methods, as the initialisation order is important, * * @param anonymous Whether the context should be added as an anonymous context to the parent. That way the context can never be found through any of the parent's member-functions. * * If the parent is in the symbol table and the context is not anonymous, it will also be added to the symbol table. You nead a write-lock to the DUChain then */ - explicit DUContext(const RangeInRevision& range, DUContext* parent = 0, bool anonymous = false); + explicit DUContext(const RangeInRevision& range, DUContext* parent = nullptr, bool anonymous = false); explicit DUContext(DUContextData&); /** * Destructor. Will delete all child contexts which are defined within * the same file as this context. */ ~DUContext() override; enum ContextType : quint8 { Global /**< A context that declares functions, namespaces or classes */, Namespace /**< A context that declares namespace members */, Class /**< A context that declares class members */, Function /**< A context that declares function-arguments */, Template /**< A context that declares template-parameters */, Enum /**< A context that contains a list of enumerators */, Helper /**< A helper context. This context is treated specially during search: * when searching within the imports of a context, and that context's parent * is a context of type DUContext::Helper, then the upwards search is continued * into that helper(The decision happens in shouldSearchInParent) */, Other /**< Represents executable code, like for example within a compound-statement */ }; enum SearchFlag { NoSearchFlags = 0 /**< Searching for everything */, InImportedParentContext = 1 /**< Internal, do not use from outside */, OnlyContainerTypes = 2 /**< Not implemented yet */, DontSearchInParent = 4 /**< IF this flag is set, findDeclarations(..) will not search for the identifier in parent-contexts(which does not include imported parent-contexts) */, NoUndefinedTemplateParams = 8 /**< For languages that support templates(like C++). If this is set, the search should fail as soon as undefined template-parameters are involved. */, DirectQualifiedLookup = 16 /**< When this flag is used, the searched qualified identifier should NOT be split up into it's components and looked up one by one. Currently only plays a role in C++ specific parts. */, NoFiltering = 32 /**< Should be set when no filtering at all is wished, not even filtering that is natural for the underlying language(For example in C++, constructors are filtered out be default) */, OnlyFunctions = 64 /**< When this is given, only function-declarations are returned. In case of C++, this also means that constructors can be retrieved, while normally they are filtered out. */, NoImportsCheck = 128 /**< With this parameter, a global search will return all matching items, from all contexts, not only from imported ones. */, NoSelfLookUp = 256 /**< With this parameter, the special-treatment during search that allows finding the context-class by its name is disabled. */, DontResolveAliases = 512 /**< Disables the resolution of alias declarations in the returned list*/, LastSearchFlag = 1024 }; Q_DECLARE_FLAGS(SearchFlags, SearchFlag) ContextType type() const; void setType(ContextType type); /** * If this context was opened by a declaration or definition, this returns that item. * * The returned declaration/definition will have this context set as @c internalContext() */ Declaration* owner() const; /** * Sets the declaration/definition, and also updates it's internal context (they are strictly paired together). * * The declaration has to be part of the same top-context. */ void setOwner(Declaration* decl); /** * Calculate the depth of this context, from the top level context in the file. */ int depth() const; /** * Find the top context. */ TopDUContext* topContext() const override; /** * Visits all duchain objects in the whole duchain. * * Classes that hold a unique link to duchain objects like instantiations * have to pass the visitor over to those classes. * */ virtual void visit(DUChainVisitor& visitor); /** * Find the context which most specifically covers @a position. * * The search is recursive, so the most specific context is found. * * @param includeRightBorder When this is true, contexts will also be found that * have the position on their right border. * * @warning This uses the ranges in the local revision of the document (at last parsing time). * Use DUChainBase::transformToLocalRevision to transform the cursor into that revision first. */ DUContext* findContextAt(const CursorInRevision& position, bool includeBorders = false) const; /** * Find a child declaration that has a rang that covers the given @a position. * * The search is local, not recursive. * * @warning This uses the ranges in the local revision of the document (at last parsing time). * Use DUChainBase::transformToLocalRevision to transform the cursor into that revision first. */ Declaration* findDeclarationAt(const CursorInRevision& position) const; /** * Find the context which most specifically covers @a range. * * @warning This uses the ranges in the local revision of the document (at last parsing time). * Use DUChainBase::transformToLocalRevision to transform the cursor into that revision first. */ DUContext* findContextIncluding(const RangeInRevision& range) const; /** * Calculate the fully qualified scope identifier. */ QualifiedIdentifier scopeIdentifier(bool includeClasses = false) const; /** * Returns true if this context has the same scope identifier as the given one. * * @note This is much more efficient than computing the identifiers through @c scopeIdentifier(..) * and comparing them */ bool equalScopeIdentifier(const DUContext* rhs) const; /** * Scope identifier, used to qualify the identifiers occurring in each context. * * This is the part relative to the parent context. */ QualifiedIdentifier localScopeIdentifier() const; /** * Same as @c localScopeIdentifier(), but faster. */ IndexedQualifiedIdentifier indexedLocalScopeIdentifier() const; /** * Scope identifier, used to qualify the identifiers occurring in each context * This must not be called once this context has children. */ void setLocalScopeIdentifier(const QualifiedIdentifier& identifier); /** * Returns whether this context is listed in the symbol table (Namespaces and classes) */ bool inSymbolTable() const; /** * Move this object into/out of the symbol table. * * @note You need to have a duchain write lock, unless this is a TopDUContext. */ void setInSymbolTable(bool inSymbolTable); /** * Returns the immediate parent context of this context. */ DUContext* parentContext() const; /** * Represents an imported parent context. */ struct KDEVPLATFORMLANGUAGE_EXPORT Import { /** * @note DUChain must be read-locked when this is called */ Import(DUContext* context, const DUContext* importer, const CursorInRevision& position = CursorInRevision::invalid()); Import() : position(CursorInRevision::invalid()) { } Import(const DeclarationId& id, const CursorInRevision& position = CursorInRevision::invalid()); bool operator==(const Import& rhs) const { return m_context == rhs.m_context && m_declaration == rhs.m_declaration; } /** * @param topContext The top-context from where to start searching. * This is important to find the correct imports * in the case of templates or similar structures. */ DUContext* context(const TopDUContext* topContext, bool instantiateIfRequired = true) const; /** * Returns the top-context index, if this import is not a specialization import. */ uint topContextIndex() const { return m_context.topContextIndex(); } IndexedDUContext indexedContext() const { return m_context; } /** * Returns true if this import is direct. * * That is, the import is not referred to by its identifier, * but rather directly by its index. */ bool isDirect() const; /** * If this import is indirect, returns the imported declaration-id */ DeclarationId indirectDeclarationId() const { return m_declaration; } CursorInRevision position; private: //Either we store m_declaration, or m_context. That way we can resolve specialized contexts. ///@todo Compress using union DeclarationId m_declaration; IndexedDUContext m_context; }; /** * Returns the list of imported parent contexts for this context. * * @warning The list may contain objects that are not valid any more, * i.e. data() returns zero, @see addImportedParentContext) * @warning The import structure may contain loops if this is a TopDUContext, * so be careful when traversing the tree. * @note This is expensive. */ virtual QVector importedParentContexts() const; /** * If the given context is directly imported into this one, and * @c addImportedParentContext(..) was called with a valid cursor, * this will return that position. Otherwise an invalid cursor is returned. */ virtual CursorInRevision importPosition(const DUContext* target) const; /** * Returns true if this context imports @param origin at any depth, else false. */ virtual bool imports(const DUContext* origin, const CursorInRevision& position = CursorInRevision::invalid()) const; /** * Adds an imported context. * * @param anonymous If this is true, the import will not be registered at the imported context. * This allows du-chain contexts importing without having a write-lock. * @param position Position where the context is imported. This is mainly important in C++ with included files. * * If the context is already imported, only the position is updated. * * @note Be sure to have set the text location first, so that the chain is sorted correctly. */ virtual void addImportedParentContext(DUContext* context, const CursorInRevision& position = CursorInRevision::invalid(), bool anonymous = false, bool temporary = false); /** * Adds an imported context, which may be indirect. * * @warning This is only allowed if this context is _NOT_ a top-context. * @warning When using this mechanism, this context will not be registered as importer to the other one. * @warning The given import _must_ be indirect. * * @return true if the import was already imported before, else false. */ bool addIndirectImport(const DUContext::Import& import); /** * Removes a child context. */ virtual void removeImportedParentContext(DUContext* context); /** * Clear all imported parent contexts. */ virtual void clearImportedParentContexts(); /** * If this is set to true, all declarations that are added to this context * will also be visible in the parent-context. * * They will be visible in the parent using @c findDeclarations(...) and * @c findLocalDeclarations(...), but will not be in the list of @c localDeclarations(...). */ void setPropagateDeclarations(bool propagate); bool isPropagateDeclarations() const; /** * Returns the list of contexts importing this context. * * @note Very expensive, since the importers top-contexts need to be loaded. */ virtual QVector importers() const; /** * Returns the list of indexed importers. * * Cheap, because nothing needs to be loaded. */ KDevVarLengthArray indexedImporters() const; /** * Returns the list of immediate child contexts for this context. * * @note This is expensive. */ QVector childContexts() const; /** * Clears and deletes all child contexts recursively. * * This will not cross file boundaries. */ void deleteChildContextsRecursively(); /** * Resort the child contexts by their range. * * You must call this when you manually change the range of child contexts in a way * that could break the internal range sorting. */ void resortChildContexts(); /** * Returns true if this declaration is accessible through the du-chain, * and thus cannot be edited without a du-chain write lock */ virtual bool inDUChain() const; /** * Retrieve the context which is specialized with the given * @a specialization as seen from the given @a topContext. * * @param specialization the specialization index (see DeclarationId) * @param topContext the top context representing the perspective from which to specialize. * if @p topContext is zero, only already existing specializations are returned, * and if none exists, zero is returned. * @param upDistance upwards distance in the context-structure of the * given specialization-info. This allows specializing children. */ virtual DUContext* specialize(const IndexedInstantiationInformation& specialization, const TopDUContext* topContext, int upDistance = 0); /** * Searches for and returns a declaration with a given @a identifier in this context, which * is currently active at the given text @a position, with the given type @a dataType. * In fact, only items are returned that are declared BEFORE that position. * * @param identifier the identifier of the definition to search for * @param location the text position to search for * @param topContext the top-context from where a completion is triggered. * This is needed so delayed types (templates in C++) can be resolved in the correct context. * @param type the type to match, or null for no type matching. * * @returns the requested declaration if one was found, otherwise null. * * @warning this may return declarations which are not in this tree, you may need to lock them too... */ QList findDeclarations(const QualifiedIdentifier& identifier, const CursorInRevision& position = CursorInRevision::invalid(), const AbstractType::Ptr& dataType = AbstractType::Ptr(), - const TopDUContext* topContext = 0, + const TopDUContext* topContext = nullptr, SearchFlags flags = NoSearchFlags) const; /** * Searches for and returns a declaration with a given @a identifier in this context, which * is currently active at the given text @a position. * * @param identifier the identifier of the definition to search for * @param topContext the top-context from where a completion is triggered. * This is needed so delayed types(templates in C++) can be resolved in the correct context. * @param location the text position to search for * * @returns the requested declaration if one was found, otherwise null. * * @warning this may return declarations which are not in this tree, you may need to lock them too... * * @overload */ QList findDeclarations(const IndexedIdentifier& identifier, const CursorInRevision& position = CursorInRevision::invalid(), - const TopDUContext* topContext = 0, + const TopDUContext* topContext = nullptr, SearchFlags flags = NoSearchFlags) const; /** * Prefer the version above for speed reasons. */ QList findDeclarations(const Identifier& identifier, const CursorInRevision& position = CursorInRevision::invalid(), - const TopDUContext* topContext = 0, + const TopDUContext* topContext = nullptr, SearchFlags flags = NoSearchFlags) const; /** * Returns the type of any @a identifier defined in this context, or * null if one is not found. * * Does not search imported parent-contexts(like base-classes). */ QList findLocalDeclarations(const IndexedIdentifier& identifier, const CursorInRevision& position = CursorInRevision::invalid(), - const TopDUContext* topContext = 0, + const TopDUContext* topContext = nullptr, const AbstractType::Ptr& dataType = AbstractType::Ptr(), SearchFlags flags = NoSearchFlags) const; /** * Prefer the version above for speed reasons. */ QList findLocalDeclarations(const Identifier& identifier, const CursorInRevision& position = CursorInRevision::invalid(), - const TopDUContext* topContext = 0, + const TopDUContext* topContext = nullptr, const AbstractType::Ptr& dataType = AbstractType::Ptr(), SearchFlags flags = NoSearchFlags) const; /** * Clears all local declarations. * * Does not delete the declaration; the caller assumes ownership. */ QVector clearLocalDeclarations(); /** * Clears all local declarations. * * Deletes these declarations, as the context has ownership. */ void deleteLocalDeclarations(); /** * Returns all local declarations * * @param source A source-context that is needed to instantiate template-declarations in some cases. * If it is zero, that signalizes that missing members should not be instantiated. */ - virtual QVector localDeclarations(const TopDUContext* source = 0) const; + virtual QVector localDeclarations(const TopDUContext* source = nullptr) const; /** * Resort the local declarations by their range. * * You must call this when you manually change the range of declarations in a way * that could break the internal range sorting. */ void resortLocalDeclarations(); /** * Searches for the most specific context for the given cursor @a position in the given @a url. * * @param location the text position to search for * @param parent the parent context to search from (this is mostly an internal detail, but if you only * want to search in a subbranch of the chain, you may specify the parent here) * * @returns the requested context if one was found, otherwise null. */ - DUContext* findContext(const CursorInRevision& position, DUContext* parent = 0) const; + DUContext* findContext(const CursorInRevision& position, DUContext* parent = nullptr) const; /** * Iterates the tree to see if the provided @a context is a subcontext of this context. * * @returns true if @a context is a subcontext, otherwise false. */ bool parentContextOf(DUContext* context) const; /** * Return a list of all reachable declarations for a given cursor @a position in a given @a url. * * @param location the text position to search for * @param topContext the top-context from where a completion is triggered. * This is needed so delayed types(templates in C++) can be resolved * in the correct context. * @param searchInParents should declarations from parent-contexts be listed? * If false, only declarations from this and imported contexts will be returned. * * The returned declarations are paired together with their inheritance-depth, * which is the count of steps to into other contexts that were needed to find the declaration. * Declarations reached through a namespace- or global-context are offsetted by 1000. * * This also includes Declarations from sub-contexts that were propagated upwards * using @c setPropagateDeclarations(true). * * @returns the requested declarations, if any were active at that location. * Declarations propagated into this context(@c setPropagateDeclarations) are included. */ QList< QPair > allDeclarations(const CursorInRevision& position, const TopDUContext* topContext, bool searchInParents = true) const; /** * Delete and remove all slaves (uses, declarations, definitions, contexts) that are not in the given set. */ void cleanIfNotEncountered(const QSet& encountered); /** * Uses: * A "Use" represents any position in a document where a Declaration is used literally. * For efficiency, since there can be many many uses, they are managed efficiently by * TopDUContext and DUContext. In TopDUContext, the used declarations are registered * and assigned a "Declaration-Index" while calling TopDUContext::indexForUsedDeclaration. * From such a declaration-index, the declaration can be retrieved back by calling * @c TopDUContext::usedDeclarationForIndex. * * The actual uses are stored within DUContext, where each use consists of a range and * the declaration-index of the used declaration. * */ /** * Return a vector of all uses which occur in this context. * * To get the actual declarations, use @c TopDUContext::usedDeclarationForIndex(..) * with the declarationIndex. */ const Use* uses() const; /** * Returns the count of uses that can be accessed through @c uses() */ int usesCount() const; /** * Determines whether the given declaration has uses or not */ static bool declarationHasUses(Declaration* decl); /** * Find the use which encompasses @a position, if one exists. * @return The local index of the use, or -1 */ int findUseAt(const CursorInRevision& position) const; /** * @note The change must not break the ordering */ void changeUseRange(int useIndex, const RangeInRevision& range); /** * Assigns the declaration represented by @param declarationIndex * to the use with index @param useIndex. */ void setUseDeclaration(int useIndex, int declarationIndex); /** * Creates a new use of the declaration given through @param declarationIndex. * The index must be retrieved through @c TopDUContext::indexForUsedDeclaration(..). * * @param range The range of the use * @param insertBefore A hint where in the vector of uses to insert the use. * Must be correct so the order is preserved(ordered by position), * or -1 to automatically choose the position. * * @return Local index of the created use */ int createUse(int declarationIndex, const RangeInRevision& range, int insertBefore = -1); /** * Deletes the use number @param index. * * @param index is the position in the vector of uses, not a used declaration index. */ void deleteUse(int index); /** * Clear and delete all uses in this context. */ virtual void deleteUses(); /** * Recursively delete all uses in this context and all its child-contexts */ virtual void deleteUsesRecursively(); /** * Can be specialized by languages to create a navigation/information-widget. * * Ideally, the widget would be based on @c KDevelop::QuickOpenEmbeddedWidgetInterface * for user-interaction within the quickopen list. * * The returned widget will be owned by the caller. * * @param decl A member-declaration of this context the navigation-widget should be created for. * Zero to create a widget for this context. * @param topContext Top-context from where the navigation-widget is triggered. * In C++, this is needed to resolve forward-declarations. * @param htmlPrefix Html-formatted text that should be prepended before any information shown by this widget * @param htmlSuffix Html-formatted text that should be appended to any information shown by this widget * * Can return zero which disables the navigation widget. * * If you setProperty("DoNotCloseOnCursorMove", true) on the widget returned, * then the widget will not close when the cursor moves in the document, which * enables you to change the document contents from the widget without immediately closing the widget. */ - virtual QWidget* createNavigationWidget(Declaration* decl = 0, TopDUContext* topContext = 0, + virtual QWidget* createNavigationWidget(Declaration* decl = nullptr, TopDUContext* topContext = nullptr, const QString& htmlPrefix = QString(), const QString& htmlSuffix = QString()) const; enum { Identity = 2 }; /** * Represents multiple qualified identifiers in a way that is better * to manipulate and allows applying namespace-aliases or -imports easily. * * A SearchItem generally represents a tree of identifiers, and represents * all the qualified identifiers that can be constructed by walking * along the tree starting at an arbitrary root-node into the depth using the "next" pointers. * * The insertion order in the hierarchy determines the order of the represented list. */ struct KDEVPLATFORMLANGUAGE_EXPORT SearchItem : public QSharedData { typedef QExplicitlySharedDataPointer Ptr; typedef KDevVarLengthArray PtrList; /** * Constructs a representation of the given @param id qualified identifier, * starting at its index @param start. * * @param nextItem is set as next item to the last item in the chain */ SearchItem(const QualifiedIdentifier& id, const Ptr& nextItem = Ptr(), int start = 0); /** * Constructs a representation of the given @param id qualified identifier, * starting at its index @param start. * * @param nextItem is set as next item to the last item in the chain */ SearchItem(const QualifiedIdentifier& id, const PtrList& nextItems, int start = 0); SearchItem(bool explicitlyGlobal, const IndexedIdentifier& id, const PtrList& nextItems); SearchItem(bool explicitlyGlobal, const IndexedIdentifier& id, const Ptr& nextItem); bool isEmpty() const; bool hasNext() const; /** * Appends the given item to every item that can be reached from this item, * and not only to the end items. * * The effect to search is that the given item is searched with all prefixes * contained in this earch-item prepended. * * @warning This changes all contained sub-nodes, but they can be shared with * other SearchItem trees. You should not use this on SearchItem trees * that have shared nodes with other trees. * * @note These functions ignore explicitly global items. */ void addToEachNode(const Ptr& item); void addToEachNode(const PtrList& items); /** * Returns true if the given identifier matches one of the identifiers * represented by this SearchItem. Does not respect the explicitlyGlobal flag */ bool match(const QualifiedIdentifier& id, int offset = 0) const; /** * @note expensive */ QList toList(const QualifiedIdentifier& prefix = QualifiedIdentifier()) const; void addNext(const Ptr& other); bool isExplicitlyGlobal; IndexedIdentifier identifier; PtrList next; }; ///@todo Should be protected, moved here temporarily until I have figured ///out why the gcc 4.1.3 fails in cppducontext.h:212, which should work (within kdevelop) /// Declaration search implementation /** * This is a more complex interface to the declaration search engine. * * Always prefer @c findDeclarations(..) when possible. * * Advantage of this interface: * - You can search multiple identifiers at one time. * However, those should be aliased identifiers for one single item, because * search might stop as soon as one item is found. * - The source top-context is needed to correctly resolve template-parameters * * @param position A valid position, if in doubt use textRange().end() * * @warning @p position must be valid! * * @param depth Depth of the search in parents. This is used to prevent endless * recursions in endless import loops. * * * @return whether the search was successful. If it is false, it had to be stopped * for special reasons (like some flags) */ typedef QList DeclarationList; virtual bool findDeclarationsInternal(const SearchItem::PtrList& identifiers, const CursorInRevision& position, const AbstractType::Ptr& dataType, DeclarationList& ret, const TopDUContext* source, SearchFlags flags, uint depth ) const; /** * Returns the qualified identifier @p id with all aliases (for example namespace imports) applied * * @example: If the namespace 'Foo' is imported, and id is 'Bar', * then the returned list is 'Bar' and 'Foo::Bar' */ QList fullyApplyAliases(const QualifiedIdentifier& id, const TopDUContext* source) const; protected: /** * After one scope was searched, this function is asked whether more * results should be collected. Override it, for example to collect overloaded functions. * * The default-implementation returns true as soon as decls is not empty. */ virtual bool foundEnough( const DeclarationList& decls , SearchFlags flags ) const; /** * Merges definitions and their inheritance-depth up all branches of the * definition-use chain into one hash. * * This includes declarations propagated from sub-contexts. * * @param hadUrls is used to count together all contexts that already were * visited, so they are not visited again. */ virtual void mergeDeclarationsInternal(QList< QPair >& definitions, const CursorInRevision& position, QHash& hadContexts, const TopDUContext* source, bool searchInParents = true, int currentDepth = 0) const; void findLocalDeclarationsInternal(const Identifier& identifier, const CursorInRevision & position, const AbstractType::Ptr& dataType, DeclarationList& ret, const TopDUContext* source, SearchFlags flags ) const; virtual void findLocalDeclarationsInternal(const IndexedIdentifier& identifier, const CursorInRevision & position, const AbstractType::Ptr& dataType, DeclarationList& ret, const TopDUContext* source, SearchFlags flags ) const; /** * Applies namespace-imports and namespace-aliases and returns * possible absolute identifiers that need to be searched. * * @param targetIdentifiers will be filled with all identifiers that should * be searched for, instead of identifier. * @param onlyImports if this is true, namespace-aliases will not be respected, * but only imports. This is faster. */ void applyAliases(const SearchItem::PtrList& identifiers, SearchItem::PtrList& targetIdentifiers, const CursorInRevision& position, bool canBeNamespace, bool onlyImports = false) const; /** * Applies the aliases that need to be applied when moving the search * from this context up to the parent-context. * * The default-implementation adds a set of identifiers with the own local * identifier prefixed, if this is a namespace. * * For C++, this is needed when searching out of a namespace, so the item * can be found within that namespace in another place. */ virtual void applyUpwardsAliases(SearchItem::PtrList& identifiers, const TopDUContext* source) const; - DUContext(DUContextData& dd, const RangeInRevision& range, DUContext* parent = 0, bool anonymous = false); + DUContext(DUContextData& dd, const RangeInRevision& range, DUContext* parent = nullptr, bool anonymous = false); /** * Just uses the data from the given context. Doesn't copy or change anything, * and the data will not be deleted on this contexts destruction. */ DUContext(DUContext& useDataFrom); /** * Whether this context, or any of its parent contexts, has been inserte * anonymously into the du-chain * * @see DUContext::DUContext */ bool isAnonymous() const; /** * This is called whenever the search needs to do the decision whether it * should be continued in the parent context. * * It is not called when the DontSearchInParent flag is set. Else this should * be overridden to do language-specific logic. * * The default implementation returns false if the flag InImportedParentContext is set. */ virtual bool shouldSearchInParent(SearchFlags flags) const; private: void rebuildDynamicData(DUContext* parent, uint ownIndex) override; friend class TopDUContext; friend class IndexedDUContext; friend class LocalIndexedDUContext; friend class TopDUContextDynamicData; DUCHAIN_DECLARE_DATA(DUContext) class DUContextDynamicData* m_dynamicData; }; /** * This is the identifier that can be used to search namespace-import declarations, * and should be used to store namespace-imports. * * It is stored statically for performance-reasons, so it doesn't need to be * constructed every time it is used. * * @see NamespaceAliasDeclaration. */ KDEVPLATFORMLANGUAGE_EXPORT const Identifier& globalImportIdentifier(); /** * This is the identifier that can be used to search namespace-alias declarations. * * It is stored statically for performance-reasons, so it doesn't need to be * constructed every time it is used. * * @see NamespaceAliasDeclaration. */ KDEVPLATFORMLANGUAGE_EXPORT const Identifier& globalAliasIdentifier(); /** * This is the identifier that can be used to search namespace-import declarations, * and should be used to store namespace-imports. * * It is stored statically for performance-reasons, so it doesn't need to be * constructed every time it is used. * * @see NamespaceAliasDeclaration. */ KDEVPLATFORMLANGUAGE_EXPORT const IndexedIdentifier& globalIndexedImportIdentifier(); /** * This is the identifier that can be used to search namespace-alias declarations. * * It is stored statically for performance-reasons, so it doesn't need to be * constructed every time it is used. * * @see NamespaceAliasDeclaration. */ KDEVPLATFORMLANGUAGE_EXPORT const IndexedIdentifier& globalIndexedAliasIdentifier(); /** * Collects all uses of the given @param declarationIndex */ KDEVPLATFORMLANGUAGE_EXPORT QList allUses(DUContext* context, int declarationIndex, bool noEmptyRanges = false); } Q_DECLARE_TYPEINFO(KDevelop::DUContext::Import, Q_MOVABLE_TYPE); KDEVPLATFORMLANGUAGE_EXPORT QDebug operator<<(QDebug dbg, const KDevelop::DUContext::Import& import); #endif // KDEVPLATFORM_DUCONTEXT_H diff --git a/language/duchain/identifier.h b/language/duchain/identifier.h index 26c5b303b9..f97f26787f 100644 --- a/language/duchain/identifier.h +++ b/language/duchain/identifier.h @@ -1,465 +1,465 @@ /* This file is part of KDevelop Copyright 2006 Hamish Rodda Copyright 2007-2008 David Nolden 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. */ #ifndef KDEVPLATFORM_IDENTIFIER_H #define KDEVPLATFORM_IDENTIFIER_H #include #include #include #include #include #include //We use shared d-pointers, which is even better than a d-pointer, but krazy probably won't get it, so exclude the test. //krazy:excludeall=dpointer namespace KDevelop { class IndexedTypeIdentifier; class Identifier; class QualifiedIdentifier; template class QualifiedIdentifierPrivate; template class IdentifierPrivate; class IndexedString; /** * A helper-class to store an identifier by index in a type-safe way. * * The difference to Identifier is that this class only stores the index of an identifier that is in the repository, without any dynamic * abilities or access to the contained data. * * This class does "disk reference counting" * * @warning Do not use this after QCoreApplication::aboutToQuit() has been emitted, items that are not disk-referenced will be invalid at that point. */ class KDEVPLATFORMLANGUAGE_EXPORT IndexedIdentifier : public ReferenceCountManager { public: IndexedIdentifier(); explicit IndexedIdentifier(const Identifier& id); IndexedIdentifier(const IndexedIdentifier& rhs); IndexedIdentifier(IndexedIdentifier&& rhs) Q_DECL_NOEXCEPT; IndexedIdentifier& operator=(const Identifier& id); IndexedIdentifier& operator=(const IndexedIdentifier& rhs); IndexedIdentifier& operator=(IndexedIdentifier&& rhs) Q_DECL_NOEXCEPT; ~IndexedIdentifier(); bool operator==(const IndexedIdentifier& rhs) const; bool operator!=(const IndexedIdentifier& rhs) const; bool operator==(const Identifier& id) const; bool isEmpty() const; Identifier identifier() const; operator Identifier() const; uint getIndex() const { return index; } private: unsigned int index; }; /** * A helper-class to store an identifier by index in a type-safe way. * * The difference to QualifiedIdentifier is that this class only stores the index of an identifier that is in the repository, without any dynamic * abilities or access to the contained data. * * This class does "disk reference counting" * * @warning Do not use this after QCoreApplication::aboutToQuit() has been emitted, items that are not disk-referenced will be invalid at that point. */ class KDEVPLATFORMLANGUAGE_EXPORT IndexedQualifiedIdentifier : public ReferenceCountManager { public: IndexedQualifiedIdentifier(); IndexedQualifiedIdentifier(const QualifiedIdentifier& id); IndexedQualifiedIdentifier(const IndexedQualifiedIdentifier& rhs); IndexedQualifiedIdentifier(IndexedQualifiedIdentifier&& rhs) Q_DECL_NOEXCEPT; IndexedQualifiedIdentifier& operator=(const QualifiedIdentifier& id); IndexedQualifiedIdentifier& operator=(const IndexedQualifiedIdentifier& id); IndexedQualifiedIdentifier& operator=(IndexedQualifiedIdentifier&& rhs) Q_DECL_NOEXCEPT; ~IndexedQualifiedIdentifier(); bool operator==(const IndexedQualifiedIdentifier& rhs) const; bool operator==(const QualifiedIdentifier& id) const; bool operator<(const IndexedQualifiedIdentifier& rhs) const { return index < rhs.index; } bool isValid() const; bool isEmpty() const; QualifiedIdentifier identifier() const; operator QualifiedIdentifier() const; uint getIndex() const { return index; } private: uint index; }; /** * Represents a single unqualified identifier */ class KDEVPLATFORMLANGUAGE_EXPORT Identifier { friend class QualifiedIdentifier; public: /** * @param start The position in the given string where to start searching for the identifier. (optional) * @param takenRange If this is nonzero, it will be filled with the length of the range from the beginning * of the given string, that was used to construct this identifier. (optional) * * @warning The identifier is parsed in a C++-similar way, and the result may not be what you expect. * If you want to prevent that parsing, use the constructor that takes IndexedString. */ - explicit Identifier(const QString& str, uint start = 0, uint* takenRange = 0); + explicit Identifier(const QString& str, uint start = 0, uint* takenRange = nullptr); /** * Preferred constructor, use this if you already have an IndexedString available. This does not decompose the given string. */ explicit Identifier(const IndexedString& str); Identifier(const Identifier& rhs); explicit Identifier(uint index); Identifier(); Identifier(Identifier&& rhs) Q_DECL_NOEXCEPT; ~Identifier(); Identifier& operator=(const Identifier& rhs); Identifier& operator=(Identifier&& rhs) Q_DECL_NOEXCEPT; static Identifier unique(int token); bool isUnique() const; int uniqueToken() const; /** * If \a token is non-zero, turns this Identifier into the special per-document unique identifier. * * This is used e.g. for anonymous namespaces. * * Pass a token which is specific to the document to allow correct equality comparison. */ void setUnique(int token); const IndexedString identifier() const; void setIdentifier(const QString& identifier); /** * Should be preferred over the other version */ void setIdentifier(const IndexedString& identifier); uint hash() const; /** * Comparison ignoring the template-identifiers */ bool nameEquals(const Identifier& rhs) const; /** * @warning This is expensive. */ IndexedTypeIdentifier templateIdentifier(int num) const; uint templateIdentifiersCount() const; void appendTemplateIdentifier(const IndexedTypeIdentifier& identifier); void clearTemplateIdentifiers(); void setTemplateIdentifiers(const QList& templateIdentifiers); QString toString() const; bool operator==(const Identifier& rhs) const; bool operator!=(const Identifier& rhs) const; bool isEmpty() const; /** * @return a unique index within the global identifier repository for this identifier. * * If the identifier isn't in the repository yet, it is added to the repository. */ uint index() const; bool inRepository() const; private: void makeConstant() const; void prepareWrite(); //Only one of the following pointers is valid at a given time mutable uint m_index; //Valid if cd is valid union { mutable IdentifierPrivate* dd; //Dynamic, owned by this identifier mutable const IdentifierPrivate* cd; //Constant, owned by the repository }; }; /** * Represents a qualified identifier * * QualifiedIdentifier has it's hash-values stored, so using the hash-values is very efficient. */ class KDEVPLATFORMLANGUAGE_EXPORT QualifiedIdentifier { public: explicit QualifiedIdentifier(const QString& id, bool isExpression = false); explicit QualifiedIdentifier(const Identifier& id); QualifiedIdentifier(const QualifiedIdentifier& id); explicit QualifiedIdentifier(uint index); QualifiedIdentifier(); QualifiedIdentifier(QualifiedIdentifier&& rhs) Q_DECL_NOEXCEPT; ~QualifiedIdentifier(); QualifiedIdentifier& operator=(const QualifiedIdentifier& rhs); QualifiedIdentifier& operator=(QualifiedIdentifier&& rhs) Q_DECL_NOEXCEPT; /** * Append @p id to this qualified identifier. */ void push(const IndexedIdentifier& id); /** * Append @p id to this qualified identifier. * * NOTE: If you have an indexed identifier available, use the above method instead. */ void push(const Identifier& id); /** * Append all identifiers of @p id to this qualified identifier. */ void push(const QualifiedIdentifier& id); /** * Pops one identifier from back: */ void pop(); void clear(); bool isEmpty() const; int count() const; Identifier first() const; IndexedIdentifier indexedFirst() const; Identifier last() const; IndexedIdentifier indexedLast() const; Identifier top() const; Identifier at(int i) const; IndexedIdentifier indexedAt(int i) const; /** * @param pos Position where to start the copy. * @param len If this is -1, the whole following part will be returned. */ QualifiedIdentifier mid(int pos, int len = -1) const; /** * Copy the leftmost \a len number of identifiers. * * @param len The number of identifiers to copy, or if negative, the number of identifiers to omit from the right */ inline QualifiedIdentifier left(int len) const { return mid(0, len > 0 ? len : count() + len); } ///@todo Remove this flag bool explicitlyGlobal() const; void setExplicitlyGlobal(bool eg); bool isQualified() const; /** * A flag that can be set by setIsExpression */ bool isExpression() const; /** * Set the expression-flag, that can be retrieved by isExpression(). * This flag is not respected while creating the hash-value and while operator==() comparison. * It is respected while isSame(..) comparison. */ void setIsExpression(bool); QString toString(bool ignoreExplicitlyGlobal = false) const; QStringList toStringList() const; QualifiedIdentifier operator+(const QualifiedIdentifier& rhs) const; QualifiedIdentifier& operator+=(const QualifiedIdentifier& rhs); /** * Nicer interfaces to merge */ QualifiedIdentifier operator+(const Identifier& rhs) const; QualifiedIdentifier& operator+=(const Identifier& rhs); QualifiedIdentifier operator+(const IndexedIdentifier& rhs) const; QualifiedIdentifier& operator+=(const IndexedIdentifier& rhs); /** * @return a QualifiedIdentifier with this one appended to the other. * * It is explicitly global if either this or base is. */ QualifiedIdentifier merge(const QualifiedIdentifier& base) const; /** * The comparison-operators do not respect explicitlyGlobal and isExpression, they only respect the real scope. * This is for convenient use in hash-tables etc. */ bool operator==(const QualifiedIdentifier& rhs) const; bool operator!=(const QualifiedIdentifier& rhs) const; bool beginsWith(const QualifiedIdentifier& other) const; uint index() const; /** * @return true if this qualified identifier is already in the persistent identifier repository */ bool inRepository() const; /** * The hash does not respect explicitlyGlobal, only the real scope. */ uint hash() const; protected: bool sameIdentifiers(const QualifiedIdentifier& rhs) const; void makeConstant() const; void prepareWrite(); mutable uint m_index; union { mutable QualifiedIdentifierPrivate* dd; mutable const QualifiedIdentifierPrivate* cd; }; }; /** * Extends IndexedQualifiedIdentifier by: * - Arbitrary count of pointer-poperators with cv-qualifiers * - Reference operator * All the properties set here are respected in the hash value. */ class KDEVPLATFORMLANGUAGE_EXPORT IndexedTypeIdentifier { public: /** * Variables like pointerDepth, isReference, etc. are not parsed from the string, so this parsing is quite limited. */ explicit IndexedTypeIdentifier(const IndexedQualifiedIdentifier& identifier = IndexedQualifiedIdentifier()); explicit IndexedTypeIdentifier(const QString& identifer, bool isExpression = false); bool isReference() const; void setIsReference(bool); bool isRValue() const; void setIsRValue(bool); bool isConstant() const; void setIsConstant(bool); bool isVolatile() const; void setIsVolatile(bool); IndexedQualifiedIdentifier identifier() const ; void setIdentifier(const IndexedQualifiedIdentifier& id); /** * @return the pointer depth. Example for C++: "char*" has pointer-depth 1, "char***" has pointer-depth 3 */ int pointerDepth() const; /** * Sets the pointer-depth to the specified count. * * When the pointer-depth is increased, the "isConstPointer" values for new depths will be initialized with false. * * For efficiency-reasons the maximum currently is 23. */ void setPointerDepth(int); /** * Whether the target of pointer 'depthNumber' is constant */ bool isConstPointer(int depthNumber) const; void setIsConstPointer(int depthNumber, bool constant); QString toString(bool ignoreExplicitlyGlobal = false) const; uint hash() const; /** * The comparison-operators do not respect explicitlyGlobal and isExpression, they only respect the real scope. * This is for convenient use in hash-tables etc. */ bool operator==(const IndexedTypeIdentifier& rhs) const; bool operator!=(const IndexedTypeIdentifier& rhs) const; private: IndexedQualifiedIdentifier m_identifier; // The overall number of bits shared by these bit-fields should not exceed 32, // so that we don't waste space. IndexedTypeIdentifer should be as compact as possible. bool m_isConstant : 1; bool m_isReference : 1; bool m_isRValue : 1; bool m_isVolatile : 1; uint m_pointerDepth : 5; uint m_pointerConstMask : 23; }; KDEVPLATFORMLANGUAGE_EXPORT uint qHash(const IndexedTypeIdentifier& id); KDEVPLATFORMLANGUAGE_EXPORT uint qHash(const QualifiedIdentifier& id); KDEVPLATFORMLANGUAGE_EXPORT uint qHash(const Identifier& id); inline uint qHash(const IndexedIdentifier& id) { return id.getIndex(); } inline uint qHash(const IndexedQualifiedIdentifier& id) { return id.getIndex(); } } Q_DECLARE_TYPEINFO(KDevelop::IndexedQualifiedIdentifier, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(KDevelop::IndexedIdentifier, Q_MOVABLE_TYPE); Q_DECLARE_METATYPE(KDevelop::IndexedQualifiedIdentifier) Q_DECLARE_METATYPE(KDevelop::IndexedIdentifier) Q_DECLARE_TYPEINFO(KDevelop::QualifiedIdentifier, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(KDevelop::Identifier, Q_MOVABLE_TYPE); Q_DECLARE_METATYPE(KDevelop::QualifiedIdentifier) Q_DECLARE_METATYPE(KDevelop::Identifier) /** * {q,k}Debug() stream operator: Writes the Identifier to the debug output. */ KDEVPLATFORMLANGUAGE_EXPORT QDebug operator<<(QDebug s, const KDevelop::Identifier& identifier); /** * {q,k}Debug() stream operator: Writes the QualifiedIdentifier to the debug output. */ KDEVPLATFORMLANGUAGE_EXPORT QDebug operator<<(QDebug s, const KDevelop::QualifiedIdentifier& identifier); #endif // KDEVPLATFORM_IDENTIFIER_H diff --git a/language/duchain/navigation/abstractdeclarationnavigationcontext.h b/language/duchain/navigation/abstractdeclarationnavigationcontext.h index a63e6ff374..de59c7a3a6 100644 --- a/language/duchain/navigation/abstractdeclarationnavigationcontext.h +++ b/language/duchain/navigation/abstractdeclarationnavigationcontext.h @@ -1,95 +1,95 @@ /* Copyright 2007 David Nolden 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. */ #ifndef KDEVPLATFORM_ABSTRACTDECLARATIONNAVIGATIONCONTEXT_H #define KDEVPLATFORM_ABSTRACTDECLARATIONNAVIGATIONCONTEXT_H #include "abstractnavigationcontext.h" #include "../declaration.h" #include "../duchainpointer.h" #include "../types/abstracttype.h" namespace KDevelop { class IdentifiedType; class Identifier; class QualifiedIdentifier; class KDEVPLATFORMLANGUAGE_EXPORT AbstractDeclarationNavigationContext : public AbstractNavigationContext { Q_OBJECT public: - AbstractDeclarationNavigationContext( DeclarationPointer decl, KDevelop::TopDUContextPointer topContext, AbstractNavigationContext* previousContext = 0 ); + AbstractDeclarationNavigationContext( DeclarationPointer decl, KDevelop::TopDUContextPointer topContext, AbstractNavigationContext* previousContext = nullptr ); - virtual QString name() const override; + QString name() const override; DeclarationPointer declaration() const; ///Execute an action. For example "show_uses" shows the uses of the declaration. ///Returns the context pointer for the new state. - virtual NavigationContextPointer executeKeyAction(QString key) override; + NavigationContextPointer executeKeyAction(QString key) override; protected: - virtual QString html(bool shorten = false) override; + QString html(bool shorten = false) override; DeclarationPointer m_declaration; ///Should returns a stripped version of the declarations qualified identifier, with all implicit/redundant parts removed virtual QualifiedIdentifier prettyQualifiedIdentifier(DeclarationPointer decl) const; ///Returns a stripped version of the declarations identifier, using prettyQualifiedIdentifier Identifier prettyIdentifier(DeclarationPointer decl) const; /// @return String version of the qualified identifier of @p decl, '' on an invalid QID QString prettyQualifiedName(DeclarationPointer decl) const; /** * Return a rich-text version of the identifier @p identifier representing the declaration @p decl * * @note In case @p declaration is deprecated, the resulting string will get a special formatting */ QString identifierHighlight(const QString& identifier, const DeclarationPointer& decl) const; static QString stringFromAccess(Declaration::AccessPolicy access); static QString stringFromAccess(DeclarationPointer decl); QString declarationName( DeclarationPointer decl ) const; static QStringList declarationDetails(DeclarationPointer decl); ///This can be used for example to resolve typedefs within the type. ///All types that are visualized in the navigation-context are/should be mangled through this. ///The default-implementation returns the original type. virtual AbstractType::Ptr typeToShow(AbstractType::Ptr type); ///Print the function-signature in a way that return-type and argument can be jumped to virtual void htmlFunction(); ///Navigation for additional less important links, like what function was overloaded etc. virtual void htmlAdditionalNavigation(); virtual void htmlClass(); virtual void htmlIdentifiedType(AbstractType::Ptr type, const IdentifiedType* idType); ///Creates and registers a link for the given type that jumps to its declaration and to the template-argument declarations virtual void eventuallyMakeTypeLinks( KDevelop::AbstractType::Ptr type ); ///Creates a link that triggers a recomputation of this context with m_fullBackwardSearch set to true void createFullBackwardSearchLink(QString string); bool m_fullBackwardSearch; }; } #endif diff --git a/language/duchain/navigation/abstractincludenavigationcontext.h b/language/duchain/navigation/abstractincludenavigationcontext.h index b5effb943d..ac6e59dae3 100644 --- a/language/duchain/navigation/abstractincludenavigationcontext.h +++ b/language/duchain/navigation/abstractincludenavigationcontext.h @@ -1,80 +1,80 @@ /* Copyright 2007 David Nolden 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. */ #ifndef KDEVPLATFORM_ABSTRACTINCLUDENAVIGATIONCONTEXT_H #define KDEVPLATFORM_ABSTRACTINCLUDENAVIGATIONCONTEXT_H #include "abstractnavigationcontext.h" #include "../../util/includeitem.h" #include "../../duchain/parsingenvironment.h" #include namespace KDevelop { /** * Abstract navigation context for file includes. * * Example usage: * \code * namespace LANG { * class IncludeNavigationContext : public AbstractIncludeNavigationContext * { * public: * IncludeNavigationContext(const IncludeItem& item, TopDuContextPointer topContext) * : AbstractIncludeNavigationContext(item, topContext, KDevelop::LANGParsingEnvironment) {} * protected: * virtual void getFileInfo(KDevelop::TopDUContext* duchain) * { * // write language dependent stuff via modifyHtml() * } * }; * } * \endcode */ class KDEVPLATFORMLANGUAGE_EXPORT AbstractIncludeNavigationContext : public AbstractNavigationContext { Q_OBJECT public: AbstractIncludeNavigationContext(const IncludeItem& item, TopDUContextPointer topContext, const ParsingEnvironmentType& type); - virtual QString html(bool shorten) override; - virtual QString name() const override; + QString html(bool shorten) override; + QString name() const override; protected: /// Overwrite this to add language dependent information for a given file. /// By default only "included by" and "includes" /// NOTE: You should always append a newline (
) if you write anything. virtual void getFileInfo(KDevelop::TopDUContext* duchain); ///Should return true if this declaration should be shown, and false if not ///The duchain is locked when this is called virtual bool filterDeclaration(Declaration* decl); private: /// Only environments with this type will be considered ParsingEnvironmentType m_type; ///@param first must initially be true typedef QPair IdentifierPair; void addDeclarationsFromContext(KDevelop::DUContext* ctx, bool& first, QList& addedDeclarations, const QString& indent = {} ); IncludeItem m_item; }; } #endif // KDEVPLATFORM_ABSTRACTINCLUDENAVIGATIONCONTEXT_H diff --git a/language/duchain/navigation/abstractnavigationcontext.h b/language/duchain/navigation/abstractnavigationcontext.h index 4d4c9015b2..ce581c5d78 100644 --- a/language/duchain/navigation/abstractnavigationcontext.h +++ b/language/duchain/navigation/abstractnavigationcontext.h @@ -1,191 +1,191 @@ /* Copyright 2007 David Nolden 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. */ #ifndef KDEVPLATFORM_ABSTRACTNAVIGATIONCONTEXT_H #define KDEVPLATFORM_ABSTRACTNAVIGATIONCONTEXT_H #include #include #include "../indexeddeclaration.h" #include "navigationaction.h" namespace KDevelop { /** A helper-class for elegant colorization of html-strings . * * Initialize it with a html-color like "990000". and colorize strings * using operator() */ struct KDEVPLATFORMLANGUAGE_EXPORT Colorizer { enum FormattingFlag { Nothing = 0x0, Bold = 0x1, Italic = 0x2, Fixed = 0x4 }; Q_DECLARE_FLAGS(Formatting, FormattingFlag) Colorizer(const QString& color, Formatting formatting = Nothing) : m_color(color), m_formatting(formatting) { } QString operator()(const QString& str) const; QString m_color; Formatting m_formatting; }; class AbstractNavigationContext; typedef QExplicitlySharedDataPointer NavigationContextPointer; class KDEVPLATFORMLANGUAGE_EXPORT AbstractNavigationContext : public QObject, public QSharedData { Q_OBJECT public: - explicit AbstractNavigationContext( KDevelop::TopDUContextPointer topContext = KDevelop::TopDUContextPointer(), AbstractNavigationContext* previousContext = 0 ); + explicit AbstractNavigationContext( KDevelop::TopDUContextPointer topContext = KDevelop::TopDUContextPointer(), AbstractNavigationContext* previousContext = nullptr ); - virtual ~AbstractNavigationContext() { + ~AbstractNavigationContext() override { } void nextLink(); void previousLink(); void up(); void down(); void setPrefixSuffix( const QString& prefix, const QString& suffix ); NavigationContextPointer accept(); NavigationContextPointer back(); NavigationContextPointer accept(IndexedDeclaration decl); NavigationContextPointer acceptLink(const QString& link); NavigationAction currentAction() const; virtual QString name() const = 0; ///Here the context can return html to be displayed. virtual QString html(bool shorten = false); ///Here the context can return a widget to be displayed. ///The widget stays owned by this navigation-context. ///The widget may have a signal "navigateDeclaration(KDevelop::IndexedDeclaration)". ///If that signal is emitted, the new declaration is navigated in the navigation-wdiget. virtual QWidget* widget() const; ///Whether the widget returned by widget() should take the maximum possible spsace. ///The default implementation returns true. virtual bool isWidgetMaximized() const; ///Returns whether this context's string has already been computed, and is up to date. ///After clear() was called, this returns false again. bool alreadyComputed() const; void setTopContext(TopDUContextPointer context); TopDUContextPointer topContext() const; NavigationContextPointer executeLink(QString link); NavigationContextPointer execute(const NavigationAction& action); Q_SIGNALS: void contentsChanged(); protected: /// Returns the html font-size prefix (aka. or similar) for the given mode QString fontSizePrefix(bool shorten) const; /// Returns the html font-size suffix (aka. or similar) for the given mode QString fontSizeSuffix(bool shorten) const; virtual void setPreviousContext(AbstractNavigationContext* previous); struct TextHandler { TextHandler(AbstractNavigationContext* c) : context(c) { } void operator+=(const QString& str) const { context->addHtml(str); } AbstractNavigationContext* context; }; ///Override this to execute own key-actions using NavigationAction virtual NavigationContextPointer executeKeyAction(QString key); ///Adds given the text to currentHtml() void addHtml(QString html); ///Returns the html text being built in its current state QString currentHtml() const; ///Returns a convenience object that allows writing "modifyHtml() += "Hallo";" TextHandler modifyHtml() { return TextHandler(this); } //Clears the computed html and links void clear(); void addExternalHtml( const QString& text ); ///Creates and registers a link to the given declaration, labeled by the given name virtual void makeLink( const QString& name, DeclarationPointer declaration, NavigationAction::Type actionType ); ///Creates a link that executes the given action and adds it to the current context void makeLink( const QString& name, QString targetId, const NavigationAction& action); ///Creates a link that executes the given action and returns it QString createLink(const QString& name, QString targetId, const NavigationAction& action); int m_selectedLink; //The link currently selected NavigationAction m_selectedLinkAction; //Target of the currently selected link NavigationContextPointer registerChild(DeclarationPointer /*declaration*/); NavigationContextPointer registerChild( AbstractNavigationContext* context ); QList m_children; //Useed to keep alive all children until this is deleted bool m_shorten; int m_currentLine; //A counter used while building the html-code to count the used links. int m_linkCount; //Something else than -1 if the current position is represented by a line-number, not a link. int m_currentPositionLine; QMap m_links; QMap m_linkLines; //Holds the line for each link QMap m_intLinks; AbstractNavigationContext* m_previousContext; QString m_prefix, m_suffix; KDevelop::TopDUContextPointer m_topContext; virtual QString declarationKind(DeclarationPointer decl); static const Colorizer typeHighlight; static const Colorizer errorHighlight; static const Colorizer labelHighlight; static const Colorizer codeHighlight; static const Colorizer propertyHighlight; static const Colorizer navigationHighlight; static const Colorizer importantHighlight; static const Colorizer commentHighlight; static const Colorizer nameHighlight; private: QString m_currentText; //Here the text is built }; } Q_DECLARE_OPERATORS_FOR_FLAGS(KDevelop::Colorizer::Formatting); #endif diff --git a/language/duchain/navigation/problemnavigationcontext.h b/language/duchain/navigation/problemnavigationcontext.h index c1bc01cc2e..02bac5fb93 100644 --- a/language/duchain/navigation/problemnavigationcontext.h +++ b/language/duchain/navigation/problemnavigationcontext.h @@ -1,49 +1,49 @@ /* Copyright 2009 David Nolden 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. */ #ifndef KDEVPLATFORM_PROBLEMNAVIGATIONCONTEXT_H #define KDEVPLATFORM_PROBLEMNAVIGATIONCONTEXT_H #include #include #include #include namespace KDevelop { class KDEVPLATFORMLANGUAGE_EXPORT ProblemNavigationContext : public AbstractNavigationContext { Q_OBJECT public: explicit ProblemNavigationContext(const IProblem::Ptr& problem); - ~ProblemNavigationContext(); + ~ProblemNavigationContext() override; - virtual QString name() const override; - virtual QString html(bool shorten = false) override; - virtual QWidget* widget() const override; - virtual bool isWidgetMaximized() const override; + QString name() const override; + QString html(bool shorten = false) override; + QWidget* widget() const override; + bool isWidgetMaximized() const override; private: IProblem::Ptr m_problem; QPointer m_widget; }; } #endif // KDEVPLATFORM_PROBLEMNAVIGATIONCONTEXT_H diff --git a/language/duchain/navigation/usesnavigationcontext.h b/language/duchain/navigation/usesnavigationcontext.h index 2863068da7..5bc283b46e 100644 --- a/language/duchain/navigation/usesnavigationcontext.h +++ b/language/duchain/navigation/usesnavigationcontext.h @@ -1,43 +1,43 @@ /* Copyright 2008 David Nolden 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. */ #ifndef KDEVPLATFORM_USESNAVIGATIONCONTEXT_H #define KDEVPLATFORM_USESNAVIGATIONCONTEXT_H #include "abstractnavigationwidget.h" #include namespace KDevelop { class UsesWidget; class KDEVPLATFORMLANGUAGE_EXPORT UsesNavigationContext : public AbstractNavigationContext { Q_OBJECT public: - explicit UsesNavigationContext( KDevelop::IndexedDeclaration declaration, AbstractNavigationContext* previousContext = 0 ); + explicit UsesNavigationContext( KDevelop::IndexedDeclaration declaration, AbstractNavigationContext* previousContext = nullptr ); - ~UsesNavigationContext(); + ~UsesNavigationContext() override; - virtual QString name() const override; - virtual QWidget* widget() const override; - virtual QString html(bool shorten) override; + QString name() const override; + QWidget* widget() const override; + QString html(bool shorten) override; private: KDevelop::IndexedDeclaration m_declaration; UsesWidget* m_widget; }; } #endif diff --git a/language/duchain/navigation/useswidget.h b/language/duchain/navigation/useswidget.h index 67eec70fd3..3cead532d2 100644 --- a/language/duchain/navigation/useswidget.h +++ b/language/duchain/navigation/useswidget.h @@ -1,161 +1,161 @@ /* Copyright 2008 David Nolden 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. */ #ifndef KDEVPLATFORM_USESWIDGET_H #define KDEVPLATFORM_USESWIDGET_H #include #include #include #include #include #include #include "usescollector.h" #include class QLabel; class QToolButton; class QVBoxLayout; class QHBoxLayout; class QBoxLayout; class QPushButton; class QProgressBar; namespace KDevelop { class CodeRepresentation; class IndexedDeclaration; ///A widget representing one use of a Declaration in a speicific context class KDEVPLATFORMLANGUAGE_EXPORT OneUseWidget : public QWidget { Q_OBJECT public: OneUseWidget(IndexedDeclaration declaration, IndexedString document, KTextEditor::Range range, const CodeRepresentation& code); ~OneUseWidget() override; private slots: void jumpTo(); private: void resizeEvent ( QResizeEvent * event ) override; PersistentMovingRange::Ptr m_range; IndexedDeclaration m_declaration; IndexedString m_document; QString m_sourceLine; QLabel* m_label; QLabel* m_icon; QHBoxLayout* m_layout; }; class KDEVPLATFORMLANGUAGE_EXPORT NavigatableWidgetList : public QScrollArea { Q_OBJECT public: explicit NavigatableWidgetList(bool allowScrolling = false, uint maxHeight = 0, bool vertical = true); ~NavigatableWidgetList() override; void addItem(QWidget* widget, int pos = -1); - void addHeaderItem(QWidget* widget, Qt::Alignment alignment = 0); + void addHeaderItem(QWidget* widget, Qt::Alignment alignment = nullptr); ///Whether items were added to this list using addItem(..) bool hasItems() const; ///Deletes all items that were added using addItem void deleteItems(); QList items() const; void setShowHeader(bool show); protected: QBoxLayout* m_itemLayout; QVBoxLayout* m_layout; private: QHBoxLayout* m_headerLayout; bool m_allowScrolling, m_useArrows; }; class KDEVPLATFORMLANGUAGE_EXPORT ContextUsesWidget : public NavigatableWidgetList { Q_OBJECT public: ContextUsesWidget(const CodeRepresentation& code, QList usedDeclaration, IndexedDUContext context); Q_SIGNALS: void navigateDeclaration(KDevelop::IndexedDeclaration); private Q_SLOTS: void linkWasActivated(QString); private: IndexedDUContext m_context; }; class KDEVPLATFORMLANGUAGE_EXPORT DeclarationWidget : public NavigatableWidgetList { Q_OBJECT public: DeclarationWidget(const KDevelop::CodeRepresentation& code, const KDevelop::IndexedDeclaration& declaration); }; /** * Represents the uses of a declaration within one top-context */ class KDEVPLATFORMLANGUAGE_EXPORT TopContextUsesWidget : public NavigatableWidgetList { Q_OBJECT public: TopContextUsesWidget(IndexedDeclaration declaration, QList localDeclarations, IndexedTopDUContext topContext); void setExpanded(bool); int usesCount() const; private slots: void labelClicked(); private: IndexedTopDUContext m_topContext; IndexedDeclaration m_declaration; QLabel* m_icon; QLabel* m_toggleButton; QList m_allDeclarations; int m_usesCount; }; /** * A widget that allows browsing through all the uses of a declaration, and also through all declarations of it. */ class KDEVPLATFORMLANGUAGE_EXPORT UsesWidget : public NavigatableWidgetList { Q_OBJECT public: ///This class can be overridden to do additional processing while the uses-widget shows the uses. struct KDEVPLATFORMLANGUAGE_EXPORT UsesWidgetCollector : public UsesCollector { public: void setWidget(UsesWidget* widget ); UsesWidgetCollector(IndexedDeclaration decl); void processUses(KDevelop::ReferencedTopDUContext topContext) override; void maximumProgress(uint max) override; void progress(uint processed, uint total) override; UsesWidget* m_widget; }; QSize sizeHint () const override; ///@param customCollector allows specifying an own subclass of UsesWidgetCollector. explicit UsesWidget(const IndexedDeclaration& declaration, QSharedPointer customCollector = {}); ~UsesWidget() override; void setAllExpanded(bool expanded); unsigned int countAllUses() const; Q_SIGNALS: void navigateDeclaration(KDevelop::IndexedDeclaration); private: const QString headerLineText() const; QLabel* m_headerLine; QSharedPointer m_collector; QProgressBar* m_progressBar; public slots: void headerLinkActivated(QString linkName); void redrawHeaderLine(); }; } #endif diff --git a/language/editor/persistentmovingrangeprivate.h b/language/editor/persistentmovingrangeprivate.h index 160797005a..91f25bc0c8 100644 --- a/language/editor/persistentmovingrangeprivate.h +++ b/language/editor/persistentmovingrangeprivate.h @@ -1,68 +1,68 @@ /* Copyright 2010 David Nolden 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. */ #ifndef KDEVPLATFORM_PERSISTENTMOVINGRANGEPRIVATE_H #define KDEVPLATFORM_PERSISTENTMOVINGRANGEPRIVATE_H #include #include #include #include "documentrange.h" #include #include namespace KDevelop { class PersistentMovingRangePrivate : public QObject { Q_OBJECT public: - PersistentMovingRangePrivate() : m_valid(false), m_shouldExpand(false), m_movingRange(0), m_tracker(0), m_zDepth(0) { + PersistentMovingRangePrivate() : m_valid(false), m_shouldExpand(false), m_movingRange(nullptr), m_tracker(nullptr), m_zDepth(0) { moveToThread(QApplication::instance()->thread()); } void connectTracker(); void disconnectTracker(); bool m_valid; bool m_shouldExpand; KTextEditor::Range m_range; IndexedString m_document; KTextEditor::Attribute::Ptr m_attribte; KTextEditor::MovingRange* m_movingRange; DocumentChangeTracker* m_tracker; float m_zDepth; void updateRangeFromMoving() { if(m_movingRange) { m_range = m_movingRange->toRange(); } } private Q_SLOTS: void aboutToDeleteMovingInterfaceContent(); void aboutToInvalidateMovingInterfaceContent(); }; } #endif // KDEVPLATFORM_PERSISTENTMOVINGRANGEPRIVATE_H diff --git a/language/highlighting/colorcache.h b/language/highlighting/colorcache.h index b75c211990..7096e5df38 100644 --- a/language/highlighting/colorcache.h +++ b/language/highlighting/colorcache.h @@ -1,182 +1,182 @@ /* * This file is part of KDevelop * * Copyright 2009 Milian Wolff * * 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 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. */ #ifndef KDEVPLATFORM_COLORCACHE_H #define KDEVPLATFORM_COLORCACHE_H #include #include #include #include #include namespace KTextEditor { class Document; class View; } namespace KDevelop { class CodeHighlightingColors; class IDocument; /** * A singleton which holds the global default colors, adapted to the current color scheme */ class KDEVPLATFORMLANGUAGE_EXPORT ColorCache : public QObject { Q_OBJECT public: ~ColorCache() override; /// access the global color cache static ColorCache* self(); /// adapt a given foreground color to the current color scheme /// @p ratio between 0 and 255 where 0 gives @see m_foregroundColor /// and 255 gives @p color /// /// @note if you are looking for a background color, simply setting an alpha /// value should work. QColor blend(QColor color, uchar ratio) const; /// adapt a given background color to the current color scheme /// @p ratio between 0 and 255 where 0 gives @see m_foregroundColor /// and 255 gives @p color /// /// @note if you are looking for a background color, simply setting an alpha /// value should work. QColor blendBackground(QColor color, uchar ratio) const; /// blend a color for local colorization according to the user settings /// @see blend() QColor blendLocalColor(QColor color) const; /// blend a color for global colorization according to the user settings /// @see blend() QColor blendGlobalColor(QColor color) const; /// access the default colors CodeHighlightingColors* defaultColors() const; /** * @returns a primary color if @p num less primaryColorCount and a supplementary color if @p num >= primaryColorCount and < validColorCount * @see validColorCount() * @see primaryColorCount() */ QColor generatedColor(uint num) const; /** * @returns the number of primary and supplementary colors * * @see generatedColor() * @see primaryColorCount() */ uint validColorCount() const; /** * @returns number of primary colors * * When you run out of primary colors use supplementary colors */ uint primaryColorCount() const; /// access the foreground color QColor foregroundColor() const; signals: /// will be emitted whenever the colors got changed /// @see update() void colorsGotChanged(); private slots: /// if necessary, adapt to the colors of this document void slotDocumentActivated(); /// settings got changed, update to the settings of the sender void slotViewSettingsChanged(); /// will regenerate colors from global KDE color scheme void updateColorsFromScheme(); /// will regenerate colors with the proper intensity settings void updateColorsFromSettings(); /// regenerate colors and emits @p colorsGotChanged() /// and finally triggers a rehighlight of the opened documents void updateInternal(); bool tryActiveDocument(); private: - ColorCache(QObject *parent = 0); + ColorCache(QObject *parent = nullptr); static ColorCache* m_self; /// get @p totalGeneratedColors colors from the color wheel and adapt them to the current color scheme void generateColors(); /// calls @c updateInternal() delayed to prevent double loading of language plugins. void update(); /// try to access the KatePart settings for the given doc or fallback to the global KDE scheme /// and update the colors if necessary /// @see generateColors(), updateColorsFromScheme() void updateColorsFromView(KTextEditor::View* view); /// the default colors for the different types CodeHighlightingColors* m_defaultColors; /// the generated colors QList m_colors; uint m_validColorCount; uint m_primaryColorCount; /// Maybe make this configurable: An offset where to start stepping through the color wheel uint m_colorOffset; /// the text color for the current color scheme QColor m_foregroundColor; /// the editor background color color for the current color scheme QColor m_backgroundColor; /// How generated colors for local variables should be mixed with the foreground color. /// Between 0 and 255, where 255 means only foreground color, and 0 only the chosen color. uchar m_localColorRatio; /// How global colors (i.e. for types, uses, etc.) should be mixed with the foreground color. /// Between 0 and 255, where 255 means only foreground color, and 0 only the chosen color. uchar m_globalColorRatio; /// Whether declarations have to be rendered with a bold style or not. bool m_boldDeclarations; /// The view we are listening to for setting changes. QPointer m_view; }; } #endif // KDEVPLATFORM_COLORCACHE_H // kate: space-indent on; indent-width 2; replace-trailing-space-save on; show-tabs on; tab-indents on; tab-width 2; diff --git a/outputview/outputdelegate.h b/outputview/outputdelegate.h index f2046b0033..248fa2b985 100644 --- a/outputview/outputdelegate.h +++ b/outputview/outputdelegate.h @@ -1,57 +1,57 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright (C) 2007 Andreas Pakulat * * Copyright (C) 2012 Morten Danielsen Volden mvolden2@gmail.com * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_OUTPUTDELEGATE_H #define KDEVPLATFORM_OUTPUTDELEGATE_H #include "outputviewexport.h" #include #include namespace KDevelop { struct OutputDelegatePrivate { OutputDelegatePrivate(); KStatefulBrush errorBrush; KStatefulBrush warningBrush; KStatefulBrush informationBrush; KStatefulBrush builtBrush; }; class KDEVPLATFORMOUTPUTVIEW_EXPORT OutputDelegate : public QItemDelegate { Q_OBJECT public: - explicit OutputDelegate( QObject* parent = 0 ); - virtual ~OutputDelegate(); + explicit OutputDelegate( QObject* parent = nullptr ); + ~OutputDelegate() override; void paint( QPainter*, const QStyleOptionViewItem&, const QModelIndex& ) const override; private: OutputDelegatePrivate* const d; }; } #endif diff --git a/outputview/outputexecutejob.h b/outputview/outputexecutejob.h index 0831ed777c..b861e63ad0 100644 --- a/outputview/outputexecutejob.h +++ b/outputview/outputexecutejob.h @@ -1,256 +1,256 @@ /* This file is part of KDevelop C opyright 2012 Ivan Shapoval*ov This library 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 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. */ #ifndef KDEVPLATFORM_OUTPUTEXECUTEJOB_H #define KDEVPLATFORM_OUTPUTEXECUTEJOB_H #include "outputjob.h" #include "outputmodel.h" #include #include class KProcess; namespace KDevelop { class ProcessLineMaker; class OutputExecuteJobPrivate; class KDEVPLATFORMOUTPUTVIEW_EXPORT OutputExecuteJob : public OutputJob { Q_OBJECT public: enum JobStatus { JobRunning = 0, /**< The job is running */ JobSucceeded = 1, /**< The job has succeeded */ JobCanceled = 2, /**< The job has been cancelled */ JobFailed = 3, /**< The job has failed */ JobNotStarted = 4 /**< The job hasn't been started so far */ }; enum { InvalidWorkingDirectoryError = OutputJob::UserDefinedError, UserDefinedError }; enum JobProperty { AppendProcessString = 0x001, /**< Whether to append a process string to the user-specified job name */ NeedWorkingDirectory = 0x002, /**< Whether to require a non-empty working directory to be provided */ CheckWorkingDirectory = 0x004, /**< Whether to check that the working directory actually exists (and not to create it if needed) */ PortableMessages = 0x008, /**< Whether to set LC_MESSAGES=C in the process' environment */ DisplayStdout = 0x010, /**< Whether to pass process' stdout to the output model */ DisplayStderr = 0x020, /**< Whether to pass process' stderr to the output model */ NoSilentOutput = 0x040, /**< Whether to call \ref startOutput() only if verbosity is \ref OutputJob::Verbose */ PostProcessOutput = 0x080, /**< Whether to connect line maker's signals to \ref postProcessStdout() and \ref postProcessStderr() */ IsBuilderHint = 0x100, /**< Whether to use builder-specific messages to talk to user (e. g. "build directory" instead of "working directory" */ }; Q_FLAGS(JobProperty JobProperties) Q_DECLARE_FLAGS(JobProperties, JobProperty) - OutputExecuteJob( QObject* parent = 0, OutputJobVerbosity verbosity = OutputJob::Verbose ); + OutputExecuteJob( QObject* parent = nullptr, OutputJobVerbosity verbosity = OutputJob::Verbose ); ~OutputExecuteJob() override; /** * Get the job's status (associated with the process). * * @returns The job's status. * @see JobStatus */ JobStatus status() const; /** * Get the job's output model. * * @returns The job's output model, downcasted to \ref OutputModel */ OutputModel* model() const; /** * Returns a working directory for the job's process. * * @returns URL which has been set through \ref setWorkingDirectory(); empty URL if unset. */ virtual QUrl workingDirectory() const; /** * Set a working directory for the job's process. * Effective if \ref workingDirectory() hasn't been overridden. * * @param directory a valid local directory URL, or an empty URL to unset. */ void setWorkingDirectory( const QUrl& directory ); /** * Get process' command line. * * @returns The command line for the process, with first element in list being the program path. */ virtual QStringList commandLine() const; /** * Append an element to the command line argument list for this process. * If no executable is set yet, it will be set instead. * Effective if \ref commandLine() hasn't been overridden. * * @param argument the argument to add */ OutputExecuteJob& operator<<( const QString& argument ); /** * Append a list of elements to the command line argument list for this process. * If no executable is set yet, it will be set from the first argument in given list. * Effective if \ref commandLine() hasn't been overridden. * * @param arguments the arguments to add */ OutputExecuteJob& operator<<( const QStringList& arguments ); /** * Get the privilege escalation command ("su", "sudo", etc.) used for the job's process. * * @returns The privilege escalation command name and arguments; empty list if not set. */ virtual QStringList privilegedExecutionCommand() const; /** * Set the privilege escalation command ("su", "sudo", etc.) which will be used for the job's process. * Effective if \ref privilegedExecutionCommand() hasn't been overridden. * * @param command The privilege escalation command's name and arguments; empty list to unset. * @see privilegedCommand */ void setPrivilegedExecutionCommand( const QStringList& command ); /** * A convenience function to set the job name. * * Calls \ref setTitle() and \ref setObjectName(). * * @note If you need the command-line to be appended to the job name, * make sure that it is already configured upon calling this function. * * @param name The name to set; empty string to use default (process string). */ void setJobName( const QString& name ); /** * Set one of the standard filtering strategies for the output model. */ void setFilteringStrategy( OutputModel::OutputFilterStrategy strategy ); /** * Set the filtering strategy for the output model. */ void setFilteringStrategy(IFilterStrategy* filterStrategy); /** * Get the current properties of the job. * * @note Default-set properties are: \ref DisplayStdout. */ virtual JobProperties properties() const; /** * Set properties of the job. * Effective if \ref properties() hasn't been overridden. * * @param properties Which flags to add to the job. * @param override Whether to assign instead of doing bitwise OR. * @see JobProperties, properties(), unsetProperties() */ void setProperties( JobProperties properties, bool override = false ); /** * Unset properties of the job. * * @param properties Which flags to remove from the job * @see JobProperties, properties(), setProperties() */ void unsetProperties( JobProperties properties ); /** * Add a variable to the job's process environment. * * The variables added with this method override ones from the system environment and * the global environment profile, but are overridden by "PortableMessages" property. * * @param name The name of a variable to add * @param value The value of a variable to add; empty string to unset. */ void addEnvironmentOverride( const QString& name, const QString& value ); /** * Remove a variable from the override set. * * @param name The name of a variable to remove. * @note This does not force a variable to empty value; this is to undo the overriding itself. */ void removeEnvironmentOverride( const QString& name ); /** * Get the global environment profile name for the job's process. * * @returns The environment profile name to use in the job's process; empty if unset. */ virtual QString environmentProfile() const; /** * Set the environment profile name for the job's process. * Effective if \ref environmentProfile() hasn't been overridden. * * @param profile The name of profile to set. */ void setEnvironmentProfile( const QString& profile ); void start() override; protected: bool doKill() override; protected slots: // Redefine these functions if you want to post-process the output somehow // before it hits the output model. // Default implementations for either function call "model()->appendLines( lines );". // Do the same if you need the output to be visible. virtual void postProcessStdout( const QStringList& lines ); virtual void postProcessStderr( const QStringList& lines ); // Redefine these functions if you want to handle process' exit codes in a special manner. // One possible usage is in "cvs diff" job which returns 1 on success. virtual void childProcessExited( int exitCode, QProcess::ExitStatus exitStatus ); virtual void childProcessError( QProcess::ProcessError processError ); private: friend class OutputExecuteJobPrivate; OutputExecuteJobPrivate* d; Q_PRIVATE_SLOT(d, void childProcessStdout()); Q_PRIVATE_SLOT(d, void childProcessStderr()); }; } // namespace KDevelop Q_DECLARE_OPERATORS_FOR_FLAGS(KDevelop::OutputExecuteJob::JobProperties); #endif // KDEVPLATFORM_OUTPUTEXECUTEJOB_H diff --git a/outputview/outputjob.h b/outputview/outputjob.h index f60d63d49b..5c9524c3a4 100644 --- a/outputview/outputjob.h +++ b/outputview/outputjob.h @@ -1,109 +1,109 @@ /* This file is part of KDevelop Copyright 2007-2008 Hamish Rodda This library 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 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. */ #ifndef KDEVPLATFORM_OUTPUTJOB_H #define KDEVPLATFORM_OUTPUTJOB_H #include #include #include #include #include class QStandardItemModel; class QItemDelegate; namespace KDevelop { class KDEVPLATFORMOUTPUTVIEW_EXPORT OutputJob : public KJob { Q_OBJECT public: enum { FailedShownError = UserDefinedError + 100 //job failed and failure is shown in OutputView }; enum OutputJobVerbosity { Silent, Verbose }; - OutputJob(QObject* parent = 0, OutputJobVerbosity verbosity = OutputJob::Verbose); + OutputJob(QObject* parent = nullptr, OutputJobVerbosity verbosity = OutputJob::Verbose); void startOutput(); OutputJobVerbosity verbosity() const; void setVerbosity(OutputJobVerbosity verbosity); QAbstractItemModel* model() const; /// Set the \a title for this job's output tab. If not set, will default to the job's objectName(). void setTitle(const QString& title); protected: void setStandardToolView(IOutputView::StandardToolView standard); void setToolTitle(const QString& title); void setToolIcon(const QIcon& icon); void setViewType(IOutputView::ViewType type); void setBehaviours(IOutputView::Behaviours behaviours); void setKillJobOnOutputClose(bool killJobOnOutputClose); /** * Sets the model for the view that shows this jobs output. * * The view takes ownership of the model, but it is safe to * use the model while the job is running. * * NOTE: Do not reuse the same model for different jobs. */ void setModel(QAbstractItemModel* model); /** * Sets the delegate for the view that shows this jobs output. * * The view takes ownership of the delegate, but it is safe to * use the delegate while the job is running. * * NOTE: Do not reuse the same delegate for different jobs. */ void setDelegate(QAbstractItemDelegate* delegate); int outputId() const; private Q_SLOTS: void outputViewRemoved(int , int id); private: int m_standardToolView; QString m_title, m_toolTitle; QIcon m_toolIcon; IOutputView::ViewType m_type; IOutputView::Behaviours m_behaviours; bool m_killJobOnOutputClose; OutputJobVerbosity m_verbosity; int m_outputId; QPointer m_outputModel; QAbstractItemDelegate* m_outputDelegate; }; } #endif diff --git a/outputview/outputmodel.h b/outputview/outputmodel.h index 7bd3eee495..9878b51ffc 100644 --- a/outputview/outputmodel.h +++ b/outputview/outputmodel.h @@ -1,96 +1,96 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * Copyright (C) 2012 Morten Danielsen Volden mvolden2@gmail.com * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_OUTPUTMODEL_H #define KDEVPLATFORM_OUTPUTMODEL_H #include "outputviewexport.h" #include "ioutputviewmodel.h" #include "ifilterstrategy.h" #include #include namespace KDevelop { struct FilteredItem; struct OutputModelPrivate; class KDEVPLATFORMOUTPUTVIEW_EXPORT OutputModel : public QAbstractListModel, public KDevelop::IOutputViewModel { Q_OBJECT public: enum CustomRoles { OutputItemTypeRole = Qt::UserRole + 1 }; enum OutputFilterStrategy { NoFilter, CompilerFilter, ScriptErrorFilter, NativeAppErrorFilter, StaticAnalysisFilter }; - explicit OutputModel( const QUrl& builddir , QObject* parent = 0 ); - explicit OutputModel( QObject* parent = 0 ); + explicit OutputModel( const QUrl& builddir , QObject* parent = nullptr ); + explicit OutputModel( QObject* parent = nullptr ); ~OutputModel() override; /// IOutputViewModel interfaces void activate( const QModelIndex& index ) override; QModelIndex firstHighlightIndex() override; QModelIndex nextHighlightIndex( const QModelIndex ¤t ) override; QModelIndex previousHighlightIndex( const QModelIndex ¤t ) override; QModelIndex lastHighlightIndex() override; /// QAbstractItemModel interfaces QVariant data( const QModelIndex&, int = Qt::DisplayRole ) const override; int rowCount( const QModelIndex& = QModelIndex() ) const override; QVariant headerData( int, Qt::Orientation, int = Qt::DisplayRole ) const override; void setFilteringStrategy(const OutputFilterStrategy& currentStrategy); void setFilteringStrategy(IFilterStrategy* filterStrategy); public Q_SLOTS: void appendLine( const QString& ); void appendLines( const QStringList& ); void ensureAllDone(); signals: /// If the current filter strategy supports it, reports progress information void progress(const KDevelop::IFilterStrategy::Progress& progress); void allDone(); private: OutputModelPrivate* const d; friend struct OutputModelPrivate; }; } Q_DECLARE_METATYPE( KDevelop::OutputModel::OutputFilterStrategy ) #endif diff --git a/outputview/tests/test_outputmodel.h b/outputview/tests/test_outputmodel.h index 69c8c87588..90f96a0dbd 100644 --- a/outputview/tests/test_outputmodel.h +++ b/outputview/tests/test_outputmodel.h @@ -1,40 +1,40 @@ /* This file is part of KDevelop Copyright 2012 Milian Wolff Copyright (C) 2012 Morten Danielsen Volden mvolden2@gmail.com 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, see . */ #ifndef KDEVPLATFORM_TEST_OUTPUTMODEL_H #define KDEVPLATFORM_TEST_OUTPUTMODEL_H #include namespace KDevelop { class OutputModel; class TestOutputModel : public QObject { Q_OBJECT public: - explicit TestOutputModel(QObject* parent = 0); + explicit TestOutputModel(QObject* parent = nullptr); private slots: void bench(); void bench_data(); }; } #endif // KDEVPLATFORM_TEST_OUTPUTMODEL_H diff --git a/plugins/appwizard/projectvcspage.h b/plugins/appwizard/projectvcspage.h index 2cd448f5c4..c95b861678 100644 --- a/plugins/appwizard/projectvcspage.h +++ b/plugins/appwizard/projectvcspage.h @@ -1,69 +1,69 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_PROJECTVCSPAGE_H #define KDEVPLATFORM_PLUGIN_PROJECTVCSPAGE_H #include #include "appwizardpagewidget.h" #include namespace Ui { class ProjectVcsPage; } namespace KDevelop { class IPluginController; class VcsImportMetadataWidget; } class QUrl; class ProjectVcsPage : public AppWizardPageWidget { Q_OBJECT public: - explicit ProjectVcsPage( KDevelop::IPluginController*, QWidget* parent = 0 ); + explicit ProjectVcsPage( KDevelop::IPluginController*, QWidget* parent = nullptr ); ~ProjectVcsPage() override; bool shouldContinue() override; signals: void valid(); void invalid(); public slots: void setSourceLocation( const QUrl& ); void vcsTypeChanged(int); void validateData(); public: QString pluginName() const; QUrl source() const; KDevelop::VcsLocation destination() const; QString commitMessage() const; private: QList importWidgets; QList > vcsPlugins; Ui::ProjectVcsPage* m_ui; }; #endif //kate: space-indent on; indent-width 4; replace-tabs on; auto-insert-doxygen on; indent-mode cstyle; diff --git a/plugins/bazaar/bzrannotatejob.h b/plugins/bazaar/bzrannotatejob.h index 48a7f16ef9..01ed446bc8 100644 --- a/plugins/bazaar/bzrannotatejob.h +++ b/plugins/bazaar/bzrannotatejob.h @@ -1,75 +1,75 @@ /*************************************************************************** * Copyright 2013-2014 Maciej Poleski * * * * 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) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * 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, see . * ***************************************************************************/ #ifndef BAZAAR_BZRANNOTATEJOB_H #define BAZAAR_BZRANNOTATEJOB_H #include #include #include #include #include #include #include class QDir; namespace KDevelop { class DVcsJob; } class BzrAnnotateJob : public KDevelop::VcsJob { Q_OBJECT public: - explicit BzrAnnotateJob(const QDir& workingDir, const QString& revisionSpec, const QUrl& localLocation, KDevelop::IPlugin* parent = 0, OutputJobVerbosity verbosity = OutputJob::Verbose); + explicit BzrAnnotateJob(const QDir& workingDir, const QString& revisionSpec, const QUrl& localLocation, KDevelop::IPlugin* parent = nullptr, OutputJobVerbosity verbosity = OutputJob::Verbose); QVariant fetchResults() override; void start() override; JobStatus status() const override; KDevelop::IPlugin* vcsPlugin() const override; protected: bool doKill() override; private slots: void parseBzrAnnotateOutput(KDevelop::DVcsJob* job); void parseNextLine(); void prepareCommitInfo(std::size_t revision); void parseBzrLog(KDevelop::DVcsJob* job); private: QDir m_workingDir; QString m_revisionSpec; QUrl m_localLocation; KDevelop::IPlugin* m_vcsPlugin; JobStatus m_status; QPointer m_job; QStringList m_outputLines; int m_currentLine; QHash m_commits; QVariantList m_results; }; #endif // BAZAAR_BZRANNOTATEJOB_H diff --git a/plugins/bazaar/copyjob.h b/plugins/bazaar/copyjob.h index 8404b23349..34685dd112 100644 --- a/plugins/bazaar/copyjob.h +++ b/plugins/bazaar/copyjob.h @@ -1,65 +1,65 @@ /*************************************************************************** * Copyright 2013-2014 Maciej Poleski * * * * 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) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * 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, see . * ***************************************************************************/ #ifndef BAZAAR_COPYJOB_H #define BAZAAR_COPYJOB_H #include #include #include namespace KIO { class Job; } class BazaarPlugin; class CopyJob : public KDevelop::VcsJob { Q_OBJECT public: - CopyJob(const QUrl& localLocationSrc, const QUrl& localLocationDstn, BazaarPlugin* parent = 0, OutputJobVerbosity verbosity = OutputJob::Verbose); + CopyJob(const QUrl& localLocationSrc, const QUrl& localLocationDstn, BazaarPlugin* parent = nullptr, OutputJobVerbosity verbosity = OutputJob::Verbose); KDevelop::IPlugin* vcsPlugin() const override; KDevelop::VcsJob::JobStatus status() const override; QVariant fetchResults() override; void start() override; protected: bool doKill() override; private slots: void finish(KJob*); void addToVcs(KIO::Job* job, const QUrl& from, const QUrl& to, const QDateTime& mtime, bool directory, bool renamed); private: BazaarPlugin* m_plugin; QUrl m_source; QUrl m_destination; JobStatus m_status; QPointer m_job; }; #endif // BAZAAR_COPYJOB_H diff --git a/plugins/bazaar/diffjob.h b/plugins/bazaar/diffjob.h index 2d25e794d7..9ac06e7662 100644 --- a/plugins/bazaar/diffjob.h +++ b/plugins/bazaar/diffjob.h @@ -1,62 +1,62 @@ /*************************************************************************** * Copyright 2013-2014 Maciej Poleski * * * * 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) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * 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, see . * ***************************************************************************/ #ifndef BAZAAR_DIFFJOB_H #define BAZAAR_DIFFJOB_H #include #include namespace KDevelop { class DVcsJob; } class QDir; class BazaarPlugin; class DiffJob : public KDevelop::VcsJob { Q_OBJECT public: - DiffJob(const QDir& workingDir, const QString& revisionSpecRange, const QUrl& fileOrDirectory, BazaarPlugin* parent = 0, OutputJobVerbosity verbosity = OutputJob::Silent); + DiffJob(const QDir& workingDir, const QString& revisionSpecRange, const QUrl& fileOrDirectory, BazaarPlugin* parent = nullptr, OutputJobVerbosity verbosity = OutputJob::Silent); KDevelop::IPlugin* vcsPlugin() const override; KDevelop::VcsJob::JobStatus status() const override; QVariant fetchResults() override; void start() override; protected: bool doKill() override; private slots: void prepareResult(KJob*); private: BazaarPlugin* m_plugin; QVariant m_result; JobStatus m_status; QPointer m_job; }; #endif // BAZAAR_DIFFJOB_H diff --git a/plugins/contextbrowser/browsemanager.cpp b/plugins/contextbrowser/browsemanager.cpp index 1a94126b6d..0d8f6cb494 100644 --- a/plugins/contextbrowser/browsemanager.cpp +++ b/plugins/contextbrowser/browsemanager.cpp @@ -1,322 +1,322 @@ /* * This file is part of KDevelop * * Copyright 2008 David Nolden * * 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 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 "browsemanager.h" #include #include #include #include #include #include #include #include #include #include "contextbrowserview.h" #include #include #include #include #include #include #include #include #include #include #include #include #include "contextbrowser.h" #include "debug.h" using namespace KDevelop; using namespace KTextEditor; EditorViewWatcher::EditorViewWatcher(QObject* parent) : QObject(parent) { connect(ICore::self()->documentController(), &IDocumentController::textDocumentCreated, this, &EditorViewWatcher::documentCreated); foreach(KDevelop::IDocument* document, ICore::self()->documentController()->openDocuments()) documentCreated(document); } void EditorViewWatcher::documentCreated( KDevelop::IDocument* document ) { KTextEditor::Document* textDocument = document->textDocument(); if(textDocument) { connect(textDocument, &Document::viewCreated, this, &EditorViewWatcher::viewCreated); foreach(KTextEditor::View* view, textDocument->views()) { Q_ASSERT(view->parentWidget()); addViewInternal(view); } } } void EditorViewWatcher::addViewInternal(KTextEditor::View* view) { m_views << view; viewAdded(view); connect(view, &View::destroyed, this, &EditorViewWatcher::viewDestroyed); } void EditorViewWatcher::viewAdded(KTextEditor::View*) { } void EditorViewWatcher::viewDestroyed(QObject* view) { m_views.removeAll(static_cast(view)); } void EditorViewWatcher::viewCreated(KTextEditor::Document* /*doc*/, KTextEditor::View* view) { Q_ASSERT(view->parentWidget()); addViewInternal(view); } QList EditorViewWatcher::allViews() { return m_views; } void BrowseManager::eventuallyStartDelayedBrowsing() { avoidMenuAltFocus(); - if(m_browsingByKey && m_browingStartedInView) - emit startDelayedBrowsing(m_browingStartedInView); + if(m_browsingByKey && m_browsingStartedInView) + emit startDelayedBrowsing(m_browsingStartedInView); } BrowseManager::BrowseManager(ContextBrowserPlugin* controller) : QObject(controller) , m_plugin(controller) , m_browsingByKey(0) , m_watcher(this) { m_delayedBrowsingTimer = new QTimer(this); m_delayedBrowsingTimer->setSingleShot(true); connect(m_delayedBrowsingTimer, &QTimer::timeout, this, &BrowseManager::eventuallyStartDelayedBrowsing); foreach(KTextEditor::View* view, m_watcher.allViews()) viewAdded(view); } KTextEditor::View* viewFromWidget(QWidget* widget) { if(!widget) return 0; KTextEditor::View* view = qobject_cast(widget); if(view) return view; else return viewFromWidget(widget->parentWidget()); } BrowseManager::JumpLocation BrowseManager::determineJumpLoc(KTextEditor::Cursor textCursor, const QUrl& viewUrl) const { // @todo find out why this is needed, fix the code in kate if (textCursor.column() > 0) { textCursor.setColumn(textCursor.column() - 1); } // Step 1: Look for a special language object(Macro, included header, etc.) for (const auto& language: ICore::self()->languageController()->languagesForUrl(viewUrl)) { auto jumpTo = language->specialLanguageObjectJumpCursor(viewUrl, textCursor); if (jumpTo.first.isValid() && jumpTo.second.isValid()) { return {jumpTo}; } } // Step 2: Look for a declaration/use DUChainReadLocker lock; // Jump to definition by default, unless a definition itself was selected, // in which case jump to declaration. if (auto selectedDeclaration = DUChainUtils::itemUnderCursor(viewUrl, textCursor)) { auto jumpDestination = selectedDeclaration; if (selectedDeclaration->isDefinition()) { // A definition was clicked directly - jump to declaration instead. if (auto declaration = DUChainUtils::declarationForDefinition(selectedDeclaration)) { jumpDestination = declaration; } } else if (selectedDeclaration == DUChainUtils::declarationForDefinition(selectedDeclaration)) { // Clicked the declaration - jump to definition if (auto definition = FunctionDefinition::definition(selectedDeclaration)) { jumpDestination = definition; } } return {{jumpDestination->url().toUrl(), jumpDestination->rangeInCurrentRevision().start()}}; } return {}; } bool BrowseManager::eventFilter(QObject * watched, QEvent * event) { QWidget* widget = qobject_cast(watched); Q_ASSERT(widget); QKeyEvent* keyEvent = dynamic_cast(event); const int browseKey = Qt::Key_Control; const int magicModifier = Qt::Key_Alt; KTextEditor::View* view = viewFromWidget(widget); //Eventually start key-browsing if(keyEvent && (keyEvent->key() == browseKey || keyEvent->key() == magicModifier) && !m_browsingByKey && keyEvent->type() == QEvent::KeyPress) { m_delayedBrowsingTimer->start(300); // always start the timer, to get consistent behavior regarding the ALT key and the menu activation m_browsingByKey = keyEvent->key(); if(!view) { return false; } if(keyEvent->key() == magicModifier) { if(dynamic_cast(view) && dynamic_cast(view)->isCompletionActive()) { //Completion is active. avoidMenuAltFocus(); }else{ - m_browingStartedInView = view; + m_browsingStartedInView = view; } } } if(!view) { return false; } QFocusEvent* focusEvent = dynamic_cast(event); //Eventually stop key-browsing if((keyEvent && m_browsingByKey && keyEvent->key() == m_browsingByKey && keyEvent->type() == QEvent::KeyRelease) || (focusEvent && focusEvent->lostFocus())) { m_browsingByKey = 0; emit stopDelayedBrowsing(); } QMouseEvent* mouseEvent = dynamic_cast(event); if(mouseEvent) { if (mouseEvent->type() == QEvent::MouseButtonPress && mouseEvent->button() == Qt::XButton1) { m_plugin->historyPrevious(); return true; } if (mouseEvent->type() == QEvent::MouseButtonPress && mouseEvent->button() == Qt::XButton2) { m_plugin->historyNext(); return true; } } if(!m_browsingByKey) { resetChangedCursor(); return false; } if(mouseEvent) { KTextEditor::View* iface = dynamic_cast(view); if(!iface) { qCDebug(PLUGIN_CONTEXTBROWSER) << "Update kdelibs for the browsing-mode to work"; return false; } QPoint coordinatesInView = widget->mapTo(view, mouseEvent->pos()); KTextEditor::Cursor textCursor = iface->coordinatesToCursor(coordinatesInView); if (textCursor.isValid()) { JumpLocation jumpTo = determineJumpLoc(textCursor, view->document()->url()); if (jumpTo.isValid()) { if(mouseEvent->button() == Qt::LeftButton) { if(mouseEvent->type() == QEvent::MouseButtonPress) { m_buttonPressPosition = textCursor; // view->setCursorPosition(textCursor); // return false; }else if(mouseEvent->type() == QEvent::MouseButtonRelease && textCursor == m_buttonPressPosition) { ICore::self()->documentController()->openDocument(jumpTo.url, jumpTo.cursor); // event->accept(); // return true; } }else if(mouseEvent->type() == QEvent::MouseMove) { //Make the cursor a "hand" setHandCursor(widget); return false; } } } resetChangedCursor(); } return false; } void BrowseManager::resetChangedCursor() { QMap, QCursor> cursors = m_oldCursors; m_oldCursors.clear(); for(QMap, QCursor>::iterator it = cursors.begin(); it != cursors.end(); ++it) if(it.key()) it.key()->setCursor(QCursor(Qt::IBeamCursor)); } void BrowseManager::setHandCursor(QWidget* widget) { if(m_oldCursors.contains(widget)) return; //Nothing to do m_oldCursors[widget] = widget->cursor(); widget->setCursor(QCursor(Qt::PointingHandCursor)); } void BrowseManager::avoidMenuAltFocus() { // send an invalid key event to the main menu bar. The menu bar will // stop listening when observing another key than ALT between the press // and the release. QKeyEvent event1(QEvent::KeyPress, 0, Qt::NoModifier); QApplication::sendEvent(ICore::self()->uiController()->activeMainWindow()->menuBar(), &event1); QKeyEvent event2(QEvent::KeyRelease, 0, Qt::NoModifier); QApplication::sendEvent(ICore::self()->uiController()->activeMainWindow()->menuBar(), &event2); } void BrowseManager::applyEventFilter(QWidget* object, bool install) { if(install) object->installEventFilter(this); else object->removeEventFilter(this); foreach(QObject* child, object->children()) if(qobject_cast(child)) applyEventFilter(qobject_cast(child), install); } void BrowseManager::viewAdded(KTextEditor::View* view) { applyEventFilter(view, true); //We need to listen for cursorPositionChanged, to clear the shift-detector. The problem: Kate listens for the arrow-keys using shortcuts, //so those keys are not passed to the event-filter // can't use new signal/slot syntax here, these signals are only defined in KateView // TODO: should we really depend on kate internals here? connect(view, SIGNAL(navigateLeft()), m_plugin, SLOT(navigateLeft())); connect(view, SIGNAL(navigateRight()), m_plugin, SLOT(navigateRight())); connect(view, SIGNAL(navigateUp()), m_plugin, SLOT(navigateUp())); connect(view, SIGNAL(navigateDown()), m_plugin, SLOT(navigateDown())); connect(view, SIGNAL(navigateAccept()), m_plugin, SLOT(navigateAccept())); connect(view, SIGNAL(navigateBack()), m_plugin, SLOT(navigateBack())); } void Watcher::viewAdded(KTextEditor::View* view) { m_manager->viewAdded(view); } Watcher::Watcher(BrowseManager* manager) : EditorViewWatcher(manager), m_manager(manager) { foreach(KTextEditor::View* view, allViews()) m_manager->applyEventFilter(view, true); } diff --git a/plugins/contextbrowser/browsemanager.h b/plugins/contextbrowser/browsemanager.h index d33fcb145a..efe39cdf07 100644 --- a/plugins/contextbrowser/browsemanager.h +++ b/plugins/contextbrowser/browsemanager.h @@ -1,121 +1,121 @@ /* * This file is part of KDevelop * * Copyright 2008 David Nolden * * 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 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. */ #ifndef KDEVPLATFORM_PLUGIN_BROWSEMANAGER_H #define KDEVPLATFORM_PLUGIN_BROWSEMANAGER_H #include #include #include #include #include #include #include class QWidget; namespace KTextEditor { class View; class Document; } namespace KDevelop { class IDocument; } class EditorViewWatcher : public QObject { Q_OBJECT public: ///@param sameWindow If this is true, only views that are child of the same window as the given widget are registered - explicit EditorViewWatcher(QObject* parent = 0); + explicit EditorViewWatcher(QObject* parent = nullptr); QList allViews(); private: ///Called for every added view. Reimplement this to catch them. virtual void viewAdded(KTextEditor::View*); private slots: void viewDestroyed(QObject* view); void viewCreated(KTextEditor::Document*, KTextEditor::View*); void documentCreated( KDevelop::IDocument* document ); private: void addViewInternal(KTextEditor::View* view); QList m_views; }; class ContextBrowserPlugin; class BrowseManager; class Watcher : public EditorViewWatcher { Q_OBJECT public: explicit Watcher(BrowseManager* manager); void viewAdded(KTextEditor::View*) override; private: BrowseManager* m_manager; }; /** * Integrates the context-browser with the editor views, by listening for navigation events, and implementing html-like source browsing */ class BrowseManager : public QObject { Q_OBJECT public: explicit BrowseManager(ContextBrowserPlugin* controller); void viewAdded(KTextEditor::View* view); //Installs/uninstalls the event-filter void applyEventFilter(QWidget* object, bool install); Q_SIGNALS: //Emitted when browsing was started using the magic-modifier void startDelayedBrowsing(KTextEditor::View* view); void stopDelayedBrowsing(); private slots: void eventuallyStartDelayedBrowsing(); private: struct JumpLocation { QUrl url; KTextEditor::Cursor cursor; JumpLocation(const QPair& pair = {}) : url(pair.first) , cursor(pair.second) {} bool isValid() const { return url.isValid() && cursor.isValid(); } }; void resetChangedCursor(); JumpLocation determineJumpLoc(KTextEditor::Cursor textCursor, const QUrl& viewUrl) const; void setHandCursor(QWidget* widget); void avoidMenuAltFocus(); bool eventFilter(QObject * watched, QEvent * event) override ; ContextBrowserPlugin* m_plugin; int m_browsingByKey; //Whether the browsing was started because of a key Watcher m_watcher; //Maps widgets to their previously set cursors QMap, QCursor> m_oldCursors; QTimer* m_delayedBrowsingTimer; - QPointer m_browingStartedInView; + QPointer m_browsingStartedInView; KTextEditor::Cursor m_buttonPressPosition; }; #endif diff --git a/plugins/cvs/checkoutdialog.h b/plugins/cvs/checkoutdialog.h index e49c397d61..b02bcbd596 100644 --- a/plugins/cvs/checkoutdialog.h +++ b/plugins/cvs/checkoutdialog.h @@ -1,42 +1,42 @@ /*************************************************************************** * Copyright 2007 Robert Gruber * * * * 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. * * * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_CHECKOUTDIALOG_H #define KDEVPLATFORM_PLUGIN_CHECKOUTDIALOG_H #include #include #include #include "ui_checkoutdialog.h" class CvsPlugin; /** * Allows the user to define from where to checkout * @author Robert Gruber */ class CheckoutDialog : public QDialog, private Ui::CheckoutDialogBase { Q_OBJECT public: - explicit CheckoutDialog(CvsPlugin* plugin, QWidget *parent=0); + explicit CheckoutDialog(CvsPlugin* plugin, QWidget *parent=nullptr); ~CheckoutDialog() override; public slots: void accept() override; void jobFinished(KJob* job); private: CvsPlugin* m_plugin; }; #endif diff --git a/plugins/cvs/commitdialog.h b/plugins/cvs/commitdialog.h index d8d674c2c1..5eba361288 100644 --- a/plugins/cvs/commitdialog.h +++ b/plugins/cvs/commitdialog.h @@ -1,37 +1,37 @@ /*************************************************************************** * Copyright 2007 Robert Gruber * * * * 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. * * * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_COMMITDIALOG_H #define KDEVPLATFORM_PLUGIN_COMMITDIALOG_H #include #include #include "ui_commitdialog.h" /** * Allows to enter text which can them be used as * parameter for @code cvs commit @endcode * @author Robert Gruber */ class CommitDialog : public QDialog, private Ui::CommitDialogBase { Q_OBJECT public: - explicit CommitDialog(QDialog *parent = 0); + explicit CommitDialog(QDialog *parent = nullptr); ~CommitDialog() override; /** * @return The text entered by the user */ QString message() { return textedit->toPlainText(); } }; #endif diff --git a/plugins/cvs/cvsgenericoutputview.h b/plugins/cvs/cvsgenericoutputview.h index 435d9a9fa1..5c40b08584 100644 --- a/plugins/cvs/cvsgenericoutputview.h +++ b/plugins/cvs/cvsgenericoutputview.h @@ -1,42 +1,42 @@ /*************************************************************************** * Copyright 2007 Robert Gruber * * * * 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. * * * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_CVSGENERICOUTPUTVIEW_H #define KDEVPLATFORM_PLUGIN_CVSGENERICOUTPUTVIEW_H #include #include #include "ui_cvsgenericoutputview.h" class CvsPlugin; class CvsJob; /** * Shows plain text. * * Text can either be added directly by calling appendText(). * * Or by connecting a job's result() signal to slotJobFinished(). * * @author Robert Gruber */ class CvsGenericOutputView : public QWidget, private Ui::CvsGenericOutputViewBase { Q_OBJECT public: - explicit CvsGenericOutputView(CvsJob* job = 0, QWidget* parent = 0); + explicit CvsGenericOutputView(CvsJob* job = nullptr, QWidget* parent = nullptr); ~CvsGenericOutputView() override; public slots: void appendText(const QString& text); void slotJobFinished(KJob* job); }; #endif diff --git a/plugins/cvs/cvsjob.h b/plugins/cvs/cvsjob.h index 54a7755015..d7391eb932 100644 --- a/plugins/cvs/cvsjob.h +++ b/plugins/cvs/cvsjob.h @@ -1,60 +1,60 @@ /*************************************************************************** * This file was partly taken from cervisia's cvsservice * * Copyright 2002-2003 Christian Loose * * * * Adapted for KDevelop * * Copyright 2007 Robert Gruber * * * * 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. * * * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_CVSJOB_H #define KDEVPLATFORM_PLUGIN_CVSJOB_H #include #include #include /** * This class is capable of running our cvs commands * Connect to Kjob::result(KJob*) to be notified when the job finished. * @author Robert Gruber */ class CvsJob : public KDevelop::DVcsJob { Q_OBJECT public: - explicit CvsJob(const QDir& workingDir, KDevelop::IPlugin* parent=0, KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose); + explicit CvsJob(const QDir& workingDir, KDevelop::IPlugin* parent=nullptr, KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose); - explicit CvsJob(KDevelop::IPlugin* parent = 0, KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose); + explicit CvsJob(KDevelop::IPlugin* parent = nullptr, KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose); ~CvsJob() override; /** * @return The command that is executed when calling start() */ QString cvsCommand(); void clear(); void setDirectory(const QString& directory); QString getDirectory(); void setRSH(const QString& rsh); void setServer(const QString& server); /** * Call this method to start this job. * @note Default communication mode is KProcess::AllOutput. * @see Use setCommunicationMode() to override the default communication mode. */ void start() override; private: class CvsJobPrivate* const d; }; #endif diff --git a/plugins/cvs/cvsproxy.h b/plugins/cvs/cvsproxy.h index fda23fdef6..666cba2822 100644 --- a/plugins/cvs/cvsproxy.h +++ b/plugins/cvs/cvsproxy.h @@ -1,108 +1,108 @@ /*************************************************************************** * Copyright 2007 Robert Gruber * * * * 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. * * * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_CVSPROXY_H #define KDEVPLATFORM_PLUGIN_CVSPROXY_H #include #include #include class CvsJob; namespace KDevelop { class IPlugin; } /** * This proxy acts as a single point of entry for most of the common cvs commands. * It is very easy to use, as the caller does not have to deal which the CvsJob class directly. * All the command line generation and job handling is done internally. The caller gets a CvsJob * object returned from the proxy and can then call it's start() method. * * Here is and example of how to user the proxy: * @code * CvsJob* job = proxy->editors( repo, urls ); * if ( job ) { * connect(job, SIGNAL( result(KJob*) ), * this, SIGNAL( jobFinished(KJob*) )); * job->start(); * } * @endcode * * @note All actions that take a QList also need an url to the repository which * must be a common base directory to all files from the QList. * Actions that just take a single QUrl don't need a repository, the cvs command will be * called directly in the directory of the given file * * @author Robert Gruber */ class CvsProxy : public QObject { Q_OBJECT public: - explicit CvsProxy(KDevelop::IPlugin* parent = 0); + explicit CvsProxy(KDevelop::IPlugin* parent = nullptr); ~CvsProxy() override; bool isValidDirectory(QUrl dirPath) const; bool isVersionControlled(QUrl filePath) const; CvsJob* import(const QUrl &directory, const QString & server, const QString& repositoryName, const QString& vendortag, const QString& releasetag, const QString& message); CvsJob* log(const QUrl &file, const KDevelop::VcsRevision& rev); CvsJob* diff(const QUrl &url, const KDevelop::VcsRevision& revA, const KDevelop::VcsRevision& revB, const QString& diffOptions=QString()); CvsJob* annotate(const QUrl &url, const KDevelop::VcsRevision& rev); CvsJob* edit(const QString& repo, const QList& files); CvsJob* unedit(const QString& repo, const QList& files); CvsJob* editors(const QString& repo, const QList& files); CvsJob* commit(const QString& repo, const QList& files, const QString& message); CvsJob* add(const QString& repo, const QList& files, bool recursiv = true, bool binary = false); CvsJob* remove(const QString& repo, const QList& files); CvsJob* update(const QString& repo, const QList& files, const KDevelop::VcsRevision& rev, const QString& updateOptions, bool resursive = true, bool pruneDirs = true, bool createDirs = true); CvsJob* checkout(const QUrl &targetDir, const QString & server, const QString& module, const QString& checkoutOptions=QString(), const QString& revision=QString(), bool recursive = true, bool pruneDirs = true); CvsJob* status(const QString & repo, const QList & files, bool recursive=false, bool taginfo=false); private: bool addFileList(CvsJob* job, const QString& repository, const QList& urls); QString convertVcsRevisionToString(const KDevelop::VcsRevision& rev); QString convertRevisionToPrevious(const KDevelop::VcsRevision& rev); enum RequestedOperation { NormalOperation, Import, CheckOut }; bool prepareJob(CvsJob* job, const QString& repository, enum RequestedOperation op = CvsProxy::NormalOperation); KDevelop::IPlugin* vcsplugin; }; #endif diff --git a/plugins/cvs/editorsview.h b/plugins/cvs/editorsview.h index 56be9c0e70..5d3a1059f5 100644 --- a/plugins/cvs/editorsview.h +++ b/plugins/cvs/editorsview.h @@ -1,77 +1,77 @@ /*************************************************************************** * Copyright 2007 Robert Gruber * * * * 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. * * * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_EDITORSVIEW_H #define KDEVPLATFORM_PLUGIN_EDITORSVIEW_H #include #include #include #include "ui_editorsview.h" class CvsPlugin; class CvsJob; /** * This is a helper class for the EditorsView::parseOutput() method. * It holds information about a single locker of a file. * @see EditorsView::parseOutput() */ class CvsLocker { public: QString user; QString date; QString machine; QString localrepo; }; /** * Shows the output from @code cvs editors @endcode in a nice way. * Create a CvsJob by calling CvsProxy::editors() and connect the job's * result(KJob*) signal to EditorsView::slotJobFinished(KJob* job) * @author Robert Gruber */ class EditorsView : public QWidget, private Ui::EditorsViewBase { Q_OBJECT public: - explicit EditorsView(CvsJob* job=0, QWidget *parent = 0); + explicit EditorsView(CvsJob* job=nullptr, QWidget *parent = nullptr); ~EditorsView() override; /** * Parses the output generated by a @code cvs editors @endcode command and * fills the given QMultiMap with all files and their lockers found in the output. * @param jobOutput Pass in the plain output of a @code cvs editors @endcode job * @param editorsInfo This QMultiMap will be filled with information about which files * are locked by whom. The key of the map is the filename. For each * filename a list of CvsLocker objects will be created, depending * on how many people are editing the file. * If editorsInfo.size() is zero, this means that no information was * found in the given @p jobOutput. */ static void parseOutput(const QString& jobOutput, QMultiMap& editorsInfo); private slots: /** * Connect a job's result() signal to this slot. When called, the output from the job * will be passed to the parseOutput() method and any found locker information will be * displayed. * @note If you pass a CvsJob object to the ctor, it's result() signal * will automatically be connected to this slot. */ void slotJobFinished(KJob* job); private: QString m_output; }; #endif diff --git a/plugins/cvs/importdialog.h b/plugins/cvs/importdialog.h index 83e2d7d44f..ce1c044e2c 100644 --- a/plugins/cvs/importdialog.h +++ b/plugins/cvs/importdialog.h @@ -1,44 +1,44 @@ /*************************************************************************** * Copyright 2007 Robert Gruber * * * * 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. * * * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_IMPORTDIALOG_H #define KDEVPLATFORM_PLUGIN_IMPORTDIALOG_H #include #include #include class ImportMetadataWidget; class CvsPlugin; /** * Asks the user for all options needed to import an existing directory into * a CVS repository * @author Robert Gruber */ class ImportDialog : public QDialog { Q_OBJECT public: - ImportDialog(CvsPlugin *plugin, const QUrl &url, QWidget* parent=0); + ImportDialog(CvsPlugin *plugin, const QUrl &url, QWidget* parent=nullptr); ~ImportDialog() override; public slots: void accept() override; void jobFinished(KJob* job); private: QUrl m_url; CvsPlugin* m_plugin; ImportMetadataWidget* m_widget; }; #endif diff --git a/plugins/cvs/importmetadatawidget.h b/plugins/cvs/importmetadatawidget.h index 259b882e40..fbfc4c3d03 100644 --- a/plugins/cvs/importmetadatawidget.h +++ b/plugins/cvs/importmetadatawidget.h @@ -1,49 +1,49 @@ /*************************************************************************** * Copyright 2007 Robert Gruber * * Copyright 2007 Andreas Pakulat * * * * 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. * * * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_IMPORTMETADATAWIDGET_H #define KDEVPLATFORM_PLUGIN_IMPORTMETADATAWIDGET_H #include #include "ui_importmetadatawidget.h" class CvsPlugin; namespace KDevelop { class VcsLocation; } /** * Asks the user for all options needed to import an existing directory into * a CVS repository * @author Robert Gruber */ class ImportMetadataWidget : public KDevelop::VcsImportMetadataWidget, private Ui::ImportMetadataWidget { Q_OBJECT public: - explicit ImportMetadataWidget(QWidget* parent=0); + explicit ImportMetadataWidget(QWidget* parent=nullptr); ~ImportMetadataWidget() override; QUrl source() const override; KDevelop::VcsLocation destination() const override; QString message() const override; void setSourceLocation( const KDevelop::VcsLocation& ) override; void setSourceLocationEditable( bool ) override; bool hasValidData() const override; private: Ui::ImportMetadataWidget* m_ui; }; #endif diff --git a/plugins/documentswitcher/documentswitchertreeview.h b/plugins/documentswitcher/documentswitchertreeview.h index c72f15ee8d..0b4e3c2355 100644 --- a/plugins/documentswitcher/documentswitchertreeview.h +++ b/plugins/documentswitcher/documentswitchertreeview.h @@ -1,39 +1,39 @@ /*************************************************************************** * Copyright 2009 Andreas Pakulat * * * * 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 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. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_DOCUMENTSWITCHERTREEVIEW_H #define KDEVPLATFORM_PLUGIN_DOCUMENTSWITCHERTREEVIEW_H #include class DocumentSwitcherPlugin; class DocumentSwitcherTreeView : public QListView { Q_OBJECT public: explicit DocumentSwitcherTreeView( DocumentSwitcherPlugin* ); protected: -virtual void keyPressEvent(QKeyEvent* event) override; -virtual void keyReleaseEvent(QKeyEvent* ) override; +void keyPressEvent(QKeyEvent* event) override; +void keyReleaseEvent(QKeyEvent* ) override; private: DocumentSwitcherPlugin* plugin; }; #endif // KDEVPLATFORM_PLUGIN_DOCUMENTSWITCHERTREEVIEW_H diff --git a/plugins/documentview/kdevdocumentmodel.h b/plugins/documentview/kdevdocumentmodel.h index 510001f6fd..0c88bc07de 100644 --- a/plugins/documentview/kdevdocumentmodel.h +++ b/plugins/documentview/kdevdocumentmodel.h @@ -1,106 +1,106 @@ /* This file is part of KDevelop Copyright 2005 Adam Treat Copyright 2013 Sebastian Kügler This library 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 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. */ #ifndef KDEVPLATFORM_PLUGIN_KDEVDOCUMENTMODEL_H #define KDEVPLATFORM_PLUGIN_KDEVDOCUMENTMODEL_H #include #include #include #include #include class KDevDocumentItem; class KDevCategoryItem; class KDevFileItem; class KDevDocumentItem: public QStandardItem { public: explicit KDevDocumentItem( const QString &name ); ~KDevDocumentItem() override; virtual KDevCategoryItem *categoryItem() const { - return 0; + return nullptr; } virtual KDevFileItem *fileItem() const { - return 0; + return nullptr; } QIcon icon() const; KDevelop::IDocument::DocumentState documentState() const; void setDocumentState( KDevelop::IDocument::DocumentState state ); const QUrl url() const; void setUrl(const QUrl &url); protected: QString m_fileIcon; private: QUrl m_url; KDevelop::IDocument::DocumentState m_documentState; }; class KDevCategoryItem: public KDevDocumentItem { public: explicit KDevCategoryItem( const QString &name ); ~KDevCategoryItem() override; KDevCategoryItem *categoryItem() const override { return const_cast( this ); } QList fileList() const; KDevFileItem* file( const QUrl &url ) const; }; class KDevFileItem: public KDevDocumentItem { public: explicit KDevFileItem( const QUrl &url ); ~KDevFileItem() override; KDevFileItem *fileItem() const override { return const_cast( this ); } }; class KDevDocumentModel: public QStandardItemModel { Q_OBJECT public: - explicit KDevDocumentModel( QObject *parent = 0 ); + explicit KDevDocumentModel( QObject *parent = nullptr ); ~KDevDocumentModel() override; QList categoryList() const; KDevCategoryItem* category( const QString& category ) const; }; #endif // KDEVPLATFORM_PLUGIN_KDEVDOCUMENTMODEL_H diff --git a/plugins/documentview/kdevdocumentviewdelegate.h b/plugins/documentview/kdevdocumentviewdelegate.h index 575f71a617..86b401e4db 100644 --- a/plugins/documentview/kdevdocumentviewdelegate.h +++ b/plugins/documentview/kdevdocumentviewdelegate.h @@ -1,36 +1,36 @@ /* This file is part of KDevelop Copyright 2005 Adam Treat This library 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 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. */ #ifndef KDEVPLATFORM_PLUGIN_KDEVDOCUMENTVIEWDELEGATE_H #define KDEVPLATFORM_PLUGIN_KDEVDOCUMENTVIEWDELEGATE_H #include class QTreeView; class KDevDocumentViewDelegate: public QItemDelegate { Q_OBJECT public: - explicit KDevDocumentViewDelegate( QObject *parent = 0 ); + explicit KDevDocumentViewDelegate( QObject *parent = nullptr ); ~KDevDocumentViewDelegate() override; void paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const override; }; #endif // KDEVPLATFORM_PLUGIN_KDEVCLASSVIEWDELEGATE_H diff --git a/plugins/execute/nativeappconfig.h b/plugins/execute/nativeappconfig.h index 0f1bdef1c4..792067dada 100644 --- a/plugins/execute/nativeappconfig.h +++ b/plugins/execute/nativeappconfig.h @@ -1,94 +1,94 @@ /* This file is part of KDevelop Copyright 2009 Andreas Pakulat This library 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 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. */ #ifndef KDEVPLATFORM_PLUGIN_NATIVEAPPCONFIGTYPE_H #define KDEVPLATFORM_PLUGIN_NATIVEAPPCONFIGTYPE_H #include #include #include #include #include "ui_nativeappconfig.h" //TODO: Split the page into two, one concerning executable/arguments/behaviour the other for dependencies class NativeAppConfigPage : public KDevelop::LaunchConfigurationPage, Ui::NativeAppPage { Q_OBJECT public: explicit NativeAppConfigPage( QWidget* parent ); - void loadFromConfiguration( const KConfigGroup& cfg, KDevelop::IProject* project = 0 ) override; - void saveToConfiguration( KConfigGroup cfg, KDevelop::IProject* project = 0 ) const override; + void loadFromConfiguration( const KConfigGroup& cfg, KDevelop::IProject* project = nullptr ) override; + void saveToConfiguration( KConfigGroup cfg, KDevelop::IProject* project = nullptr ) const override; QString title() const override; QIcon icon() const override; private slots: void activateDeps( int ); }; class NativeAppLauncher : public KDevelop::ILauncher { public: NativeAppLauncher(); QList< KDevelop::LaunchConfigurationPageFactory* > configPages() const override; QString description() const override; QString id() override; QString name() const override; KJob* start(const QString& launchMode, KDevelop::ILaunchConfiguration* cfg) override; QStringList supportedModes() const override; }; class NativeAppPageFactory : public KDevelop::LaunchConfigurationPageFactory { public: NativeAppPageFactory(); KDevelop::LaunchConfigurationPage* createWidget(QWidget* parent) override; }; /** * A specific configuration to start a launchable, this could be a native * compiled application, or some script file or byte-compiled file or something else * Provides access to the various configured informations, as well as its type and a name */ class NativeAppConfigType : public KDevelop::LaunchConfigurationType { Q_OBJECT public: NativeAppConfigType(); ~NativeAppConfigType() override; QString id() const override; QString name() const override; QList configPages() const override; QIcon icon() const override; bool canLaunch( KDevelop::ProjectBaseItem* item ) const override; bool canLaunch( const QUrl& file ) const override; void configureLaunchFromItem ( KConfigGroup cfg, KDevelop::ProjectBaseItem* item ) const override; void configureLaunchFromCmdLineArguments ( KConfigGroup cfg, const QStringList& args ) const override; QMenu* launcherSuggestions() override; private: QList factoryList; public slots: void suggestionTriggered(); }; #endif diff --git a/plugins/execute/projecttargetscombobox.h b/plugins/execute/projecttargetscombobox.h index 1265e2402d..cabd61d92b 100644 --- a/plugins/execute/projecttargetscombobox.h +++ b/plugins/execute/projecttargetscombobox.h @@ -1,43 +1,43 @@ /* 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 as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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. */ #ifndef KDEVPLATFORM_PLUGIN_PROJECTTARGETSCOMBOBOX_H #define KDEVPLATFORM_PLUGIN_PROJECTTARGETSCOMBOBOX_H #include #include namespace KDevelop { class ProjectFolderItem; } class ProjectTargetsComboBox : public QComboBox { Q_OBJECT public: - explicit ProjectTargetsComboBox(QWidget* parent = 0); + explicit ProjectTargetsComboBox(QWidget* parent = nullptr); void setBaseItem(KDevelop::ProjectFolderItem* item, bool exec); void setCurrentItemPath(const QStringList& str); QStringList currentItemPath() const; }; #endif // KDEVPLATFORM_PLUGIN_PROJECTTARGETSCOMBOBOX_H diff --git a/plugins/executescript/scriptappconfig.h b/plugins/executescript/scriptappconfig.h index dae32587e0..77edc8aac8 100644 --- a/plugins/executescript/scriptappconfig.h +++ b/plugins/executescript/scriptappconfig.h @@ -1,90 +1,90 @@ /* This file is part of KDevelop Copyright 2009 Andreas Pakulat Copyright 2009 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 as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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. */ #ifndef KDEVPLATFORM_PLUGIN_SCRIPTAPPCONFIGTYPE_H #define KDEVPLATFORM_PLUGIN_SCRIPTAPPCONFIGTYPE_H #include #include #include #include #include "ui_scriptappconfig.h" class ExecuteScriptPlugin; class ScriptAppConfigPage : public KDevelop::LaunchConfigurationPage, Ui::ScriptAppPage { Q_OBJECT public: explicit ScriptAppConfigPage( QWidget* parent ); - void loadFromConfiguration( const KConfigGroup& cfg, KDevelop::IProject* project = 0 ) override; - void saveToConfiguration( KConfigGroup cfg, KDevelop::IProject* project = 0 ) const override; + void loadFromConfiguration( const KConfigGroup& cfg, KDevelop::IProject* project = nullptr ) override; + void saveToConfiguration( KConfigGroup cfg, KDevelop::IProject* project = nullptr ) const override; QString title() const override; QIcon icon() const override; }; class ScriptAppLauncher : public KDevelop::ILauncher { public: explicit ScriptAppLauncher( ExecuteScriptPlugin* ); QList< KDevelop::LaunchConfigurationPageFactory* > configPages() const override; QString description() const override; QString id() override; QString name() const override; KJob* start(const QString& launchMode, KDevelop::ILaunchConfiguration* cfg) override; QStringList supportedModes() const override; private: ExecuteScriptPlugin* m_plugin; }; class ScriptAppPageFactory : public KDevelop::LaunchConfigurationPageFactory { public: ScriptAppPageFactory(); KDevelop::LaunchConfigurationPage* createWidget(QWidget* parent) override; }; /** * A specific configuration to start a launchable, this could be a native * compiled application, or some script file or byte-compiled file or something else * Provides access to the various configured informations, as well as its type and a name */ class ScriptAppConfigType : public KDevelop::LaunchConfigurationType { Q_OBJECT public: ScriptAppConfigType(); ~ScriptAppConfigType() override; QString id() const override; QString name() const override; QList configPages() const override; QIcon icon() const override; bool canLaunch( const QUrl& file ) const override; bool canLaunch(KDevelop::ProjectBaseItem* item) const override; void configureLaunchFromItem(KConfigGroup config, KDevelop::ProjectBaseItem* item) const override; void configureLaunchFromCmdLineArguments(KConfigGroup config, const QStringList& args) const override; private: QList factoryList; }; #endif diff --git a/plugins/externalscript/editexternalscript.h b/plugins/externalscript/editexternalscript.h index 12329f244a..7972bc163d 100644 --- a/plugins/externalscript/editexternalscript.h +++ b/plugins/externalscript/editexternalscript.h @@ -1,49 +1,49 @@ /* This plugin is part of KDevelop. Copyright (C) 2010 Milian Wolff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef KDEVPLATFORM_PLUGIN_EDITEXTERNALSCRIPT_H #define KDEVPLATFORM_PLUGIN_EDITEXTERNALSCRIPT_H #include #include "ui_editexternalscript.h" class ExternalScriptItem; class EditExternalScript : public QDialog, private Ui::EditExternalScriptBase { Q_OBJECT public: - explicit EditExternalScript( ExternalScriptItem* item, QWidget* parent = 0, Qt::WindowFlags flags = 0 ); + explicit EditExternalScript( ExternalScriptItem* item, QWidget* parent = nullptr, Qt::WindowFlags flags = nullptr ); ~EditExternalScript() override; private slots: void save(); void validate(); private: ExternalScriptItem* m_item; }; #endif // KDEVPLATFORM_PLUGIN_EDITEXTERNALSCRIPT_H // kate: indent-mode cstyle; space-indent on; indent-width 2; replace-tabs on; diff --git a/plugins/externalscript/externalscriptview.h b/plugins/externalscript/externalscriptview.h index 6795ab4122..db23d771d9 100644 --- a/plugins/externalscript/externalscriptview.h +++ b/plugins/externalscript/externalscriptview.h @@ -1,72 +1,72 @@ /* This plugin is part of KDevelop. Copyright (C) 2010 Milian Wolff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef KDEVPLATFORM_PLUGIN_EXTERNALSCRIPTVIEW_H #define KDEVPLATFORM_PLUGIN_EXTERNALSCRIPTVIEW_H #include #include "ui_externalscriptview.h" class ExternalScriptItem; class QAction; class QSortFilterProxyModel; class ExternalScriptPlugin; class ExternalScriptView : public QWidget, Ui::ExternalScriptViewBase { Q_OBJECT public: - explicit ExternalScriptView( ExternalScriptPlugin* plugin, QWidget* parent = 0 ); + explicit ExternalScriptView( ExternalScriptPlugin* plugin, QWidget* parent = nullptr ); ~ExternalScriptView() override; /// @return Currently selected script item. ExternalScriptItem* currentItem() const; /// @return Item for @p index. ExternalScriptItem* itemForIndex(const QModelIndex& index) const; private slots: void contextMenu ( const QPoint& pos ); void addScript(); void removeScript(); void editScript(); /// disables or enables available actions based on the currently selected item void validateActions(); protected: /// insert snippet on double click bool eventFilter( QObject* obj, QEvent* event ) override; private: ExternalScriptPlugin* m_plugin; QSortFilterProxyModel* m_model; QAction* m_addScriptAction; QAction* m_editScriptAction; QAction* m_removeScriptAction; }; #endif // KDEVPLATFORM_PLUGIN_EXTERNALSCRIPTVIEW_H // kate: indent-mode cstyle; space-indent on; indent-width 2; replace-tabs on; diff --git a/plugins/filemanager/bookmarkhandler.h b/plugins/filemanager/bookmarkhandler.h index e9f552fa9b..6989c8ac34 100644 --- a/plugins/filemanager/bookmarkhandler.h +++ b/plugins/filemanager/bookmarkhandler.h @@ -1,61 +1,61 @@ /* This file is part of the KDE project Copyright (C) xxxx KFile Authors Copyright (C) 2002 Anders Lund Copyright (C) 2007 Mirko Stocker Copyright (C) 2009 Dominik Haumann 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. */ #ifndef KDEVPLATFORM_PLUGIN_BOOKMARKHANDLER_H #define KDEVPLATFORM_PLUGIN_BOOKMARKHANDLER_H #include #include #include class FileManager; class BookmarkHandler : public QObject, public KBookmarkOwner { Q_OBJECT public: - explicit BookmarkHandler( FileManager *parent, QMenu *kpopupmenu = 0 ); + explicit BookmarkHandler( FileManager *parent, QMenu *kpopupmenu = nullptr ); ~BookmarkHandler() override; // KBookmarkOwner interface: QUrl currentUrl() const override; QString currentTitle() const override; QMenu *menu() const { return m_menu; } void openBookmark( const KBookmark &, Qt::MouseButtons, Qt::KeyboardModifiers ) override; Q_SIGNALS: void openUrl( const QUrl& url ); private: FileManager *m_parent; QMenu *m_menu; KBookmarkMenu *m_bookmarkMenu; }; #endif // KDEVPLATFORM_PLUGIN_BOOKMARKHANDLER_H diff --git a/plugins/filemanager/filemanager.h b/plugins/filemanager/filemanager.h index 0a61d260c6..10f8f6a08c 100644 --- a/plugins/filemanager/filemanager.h +++ b/plugins/filemanager/filemanager.h @@ -1,68 +1,68 @@ /*************************************************************************** * Copyright 2006 Alexander Dymo * * Copyright 2006 Andreas Pakulat * * * * 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 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. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_FILEMANAGER_H #define KDEVPLATFORM_PLUGIN_FILEMANAGER_H #include #include #include #include class KActionCollection; class QAction; class QString; class QMenu; class KDevFileManagerPlugin; class BookmarkHandler; class FileManager: public QWidget { Q_OBJECT public: FileManager(KDevFileManagerPlugin *plugin, QWidget* parent); - ~FileManager(); + ~FileManager() override; QList toolBarActions() const; KActionCollection* actionCollection() const; KDirOperator* dirOperator() const; KDevFileManagerPlugin* plugin() const; private slots: void fileCreated(KJob *job); void openFile(const KFileItem&); void gotoUrl(const QUrl&); void updateNav( const QUrl& url ); void syncCurrentDocumentDirectory(); void fillContextMenu(KFileItem item, QMenu *menu); void createNewFile(); private: void setupActions(); QList tbActions; QAction* newFileAction; QList contextActions; KDirOperator* dirop; KUrlNavigator* urlnav; BookmarkHandler *m_bookmarkHandler; KActionCollection *m_actionCollection; KDevFileManagerPlugin *m_plugin; }; #endif diff --git a/plugins/filetemplates/templateoptionspage.h b/plugins/filetemplates/templateoptionspage.h index 84939a3e0f..898e1b88ca 100644 --- a/plugins/filetemplates/templateoptionspage.h +++ b/plugins/filetemplates/templateoptionspage.h @@ -1,83 +1,83 @@ /* This file is part of KDevelop Copyright 2012 Miha Čančula This library 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 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. */ #ifndef KDEVPLATFORM_PLUGIN_TEMPLATEOPTIONSPAGE_H #define KDEVPLATFORM_PLUGIN_TEMPLATEOPTIONSPAGE_H #include #include namespace KDevelop { class TemplateRenderer; class SourceFileTemplate; class TemplateClassAssistant; /** * @brief Shows a page for configuring options specified by a class template * * Templates can include a file that specify configuration options. * These can be set by the user before creating the class and are passed to the template. * * @sa SourceFileTemplate::customOptions() **/ class TemplateOptionsPage : public QWidget { Q_OBJECT Q_PROPERTY(QVariantHash templateOptions READ templateOptions) public: /** * @brief Create a new template options page * * @param parent the parent template class assistant * @param f window flags, passed to QWidget **/ - explicit TemplateOptionsPage(QWidget* parent, Qt::WindowFlags f = 0); + explicit TemplateOptionsPage(QWidget* parent, Qt::WindowFlags f = nullptr); /** * Destructor **/ ~TemplateOptionsPage() override; /** * Parses the XML-formatted .kcfg file contents and creates the UI for setting template options. * * @param contents the file contents **/ void load(const SourceFileTemplate& fileTemplate, TemplateRenderer* renderer); /** * @property templateOptions * * The user-set options. Keys are the options' names, and values are their values. * **/ QVariantHash templateOptions() const; private: class TemplateOptionsPagePrivate* const d; }; } #endif // KDEVPLATFORM_PLUGIN_TEMPLATEOPTIONSPAGE_H diff --git a/plugins/filetemplates/templatepreview.h b/plugins/filetemplates/templatepreview.h index 80f53aab62..90cdbf70e5 100644 --- a/plugins/filetemplates/templatepreview.h +++ b/plugins/filetemplates/templatepreview.h @@ -1,79 +1,79 @@ /* * This file is part of KDevelop * Copyright 2012 Milian Wolff * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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, see . */ #ifndef KDEVPLATFORM_PLUGIN_TEMPLATEPREVIEW_H #define KDEVPLATFORM_PLUGIN_TEMPLATEPREVIEW_H #include #include #include namespace KTextEditor { class Document; class View; } /** * A renderer that adds some common variables for previewing purposes. */ class TemplatePreviewRenderer : public KDevelop::TemplateRenderer { public: TemplatePreviewRenderer(); ~TemplatePreviewRenderer() override; }; /** * A KTextEditor::View wrapper to show a preview of a template. */ class TemplatePreview : public QWidget { Q_OBJECT public: - explicit TemplatePreview(QWidget* parent, Qt::WindowFlags f = 0); + explicit TemplatePreview(QWidget* parent, Qt::WindowFlags f = nullptr); ~TemplatePreview() override; /** * Set the template contents which will be rendered. * * @p text the template contents * @p isProject set to true if the contents resemble a project template * @return an error message, or an empty string if everything worked */ QString setText(const QString& text, bool isProject = false, KDevelop::TemplateRenderer::EmptyLinesPolicy policy = KDevelop::TemplateRenderer::TrimEmptyLines); /** * @return The read-only document. */ KTextEditor::Document* document() const; private: Q_DISABLE_COPY(TemplatePreview) QHash m_variables; QScopedPointer m_preview; KTextEditor::View* m_view; }; #endif // KDEVPLATFORM_PLUGIN_TEMPLATEPREVIEW_H diff --git a/plugins/filetemplates/templatepreviewtoolview.h b/plugins/filetemplates/templatepreviewtoolview.h index 576e0e38aa..f711eaa734 100644 --- a/plugins/filetemplates/templatepreviewtoolview.h +++ b/plugins/filetemplates/templatepreviewtoolview.h @@ -1,72 +1,72 @@ /* * This file is part of KDevelop * Copyright 2012 Miha Čančula * * This library 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 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. */ #ifndef KDEVPLATFORM_PLUGIN_TEMPLATEPREVIEWTOOLVIEW_H #define KDEVPLATFORM_PLUGIN_TEMPLATEPREVIEWTOOLVIEW_H #include #include namespace KTextEditor { class Document; } namespace KDevelop { class IDocument; } namespace Ui { class TemplatePreviewToolView; } class FileTemplatesPlugin; class TemplatePreview; class TemplatePreviewToolView : public QWidget { Q_OBJECT public: - explicit TemplatePreviewToolView(FileTemplatesPlugin* plugin, QWidget* parent, Qt::WindowFlags f = 0); + explicit TemplatePreviewToolView(FileTemplatesPlugin* plugin, QWidget* parent, Qt::WindowFlags f = nullptr); ~TemplatePreviewToolView() override; private: Ui::TemplatePreviewToolView* ui; KTextEditor::Document* m_original; FileTemplatesPlugin* m_plugin; KDevelop::TemplateRenderer::EmptyLinesPolicy m_policy; private slots: void sourceTextChanged(const QString& text); protected: void showEvent(QShowEvent*) override; public slots: void documentActivated(KDevelop::IDocument* document); void documentChanged(KTextEditor::Document* textDocument); void documentClosed(KDevelop::IDocument* document); void selectedRendererChanged(); }; #endif // KDEVPLATFORM_PLUGIN_TEMPLATEPREVIEWTOOLVIEW_H diff --git a/plugins/filetemplates/templateselectionpage.h b/plugins/filetemplates/templateselectionpage.h index e5eba22dab..a040613368 100644 --- a/plugins/filetemplates/templateselectionpage.h +++ b/plugins/filetemplates/templateselectionpage.h @@ -1,73 +1,73 @@ /* This file is part of KDevelop Copyright 2012 Miha Čančula This library 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 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. */ #ifndef KDEVPLATFORM_PLUGIN_TEMPLATESELECTIONPAGE_H #define KDEVPLATFORM_PLUGIN_TEMPLATESELECTIONPAGE_H #include class QModelIndex; namespace KDevelop { class TemplateClassAssistant; /** * An assistant page for selecting a class template **/ class TemplateSelectionPage : public QWidget { Q_OBJECT Q_PROPERTY(QString selectedTemplate READ selectedTemplate) public: - explicit TemplateSelectionPage (TemplateClassAssistant* parent, Qt::WindowFlags f = 0); + explicit TemplateSelectionPage (TemplateClassAssistant* parent, Qt::WindowFlags f = nullptr); ~TemplateSelectionPage() override; /** * @property selectedTemplate * * The class template, selected by the user. * This property stores the full path to the template description (.desktop) file **/ QString selectedTemplate() const; QSize minimumSizeHint() const override; public Q_SLOTS: /** * Saves the selected template setting into the current project's configuration. * * If the assistant's base URL does not point to any project, this function does nothing. */ void saveConfig(); private: class TemplateSelectionPagePrivate* const d; Q_PRIVATE_SLOT(d, void currentTemplateChanged(const QModelIndex& index)) Q_PRIVATE_SLOT(d, void getMoreClicked()) Q_PRIVATE_SLOT(d, void loadFileClicked()) }; } #endif // KDEVPLATFORM_PLUGIN_TEMPLATESELECTIONPAGE_H diff --git a/plugins/filetemplates/testcasespage.h b/plugins/filetemplates/testcasespage.h index 22ce8cc7fc..0ff4488a82 100644 --- a/plugins/filetemplates/testcasespage.h +++ b/plugins/filetemplates/testcasespage.h @@ -1,72 +1,72 @@ /* * This file is part of KDevelop * Copyright 2012 Miha Čančula * * 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 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. */ #ifndef KDEVPLATFORM_PLUGIN_TESTCASESWIDGET_H #define KDEVPLATFORM_PLUGIN_TESTCASESWIDGET_H #include class KEditListWidget; namespace KDevelop { /** * Assistant page for specifying the list of test cases * */ class TestCasesPage : public QWidget { Q_OBJECT Q_PROPERTY(QStringList testCases READ testCases WRITE setTestCases) public: - explicit TestCasesPage(QWidget* parent = 0, Qt::WindowFlags f = 0); + explicit TestCasesPage(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); ~TestCasesPage() override; /** * The name of the new test, as set by the user */ QString name() const; /** * Returns the list of test case names */ QStringList testCases() const; /** * Sets the current list of test case names to @p testCases */ void setTestCases(const QStringList& testCases); Q_SIGNALS: void isValid(bool valid); private: class TestCasesPagePrivate* const d; private Q_SLOTS: void identifierChanged(const QString& identifier); }; } #endif // KDEVPLATFORM_PLUGIN_TESTCASESWIDGET_H diff --git a/plugins/genericprojectmanager/genericmanager.h b/plugins/genericprojectmanager/genericmanager.h index 93985f6592..a7f2d9535e 100644 --- a/plugins/genericprojectmanager/genericmanager.h +++ b/plugins/genericprojectmanager/genericmanager.h @@ -1,33 +1,33 @@ /* This file is part of KDevelop CopyRight 2010 Milian Wolff Copyright 2004,2005 Roberto Raggi This library 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 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. */ #ifndef KDEVPLATFORM_PLUGIN_GENERICMANAGER_H #define KDEVPLATFORM_PLUGIN_GENERICMANAGER_H #include class GenericProjectManager: public KDevelop::AbstractFileManagerPlugin { Q_OBJECT public: - explicit GenericProjectManager( QObject* parent = 0, const QVariantList& args = QVariantList() ); + explicit GenericProjectManager( QObject* parent = nullptr, const QVariantList& args = QVariantList() ); }; #endif // KDEVPLATFORM_PLUGIN_GENERICIMPORTER_H diff --git a/plugins/git/gitjob.h b/plugins/git/gitjob.h index ff6d8fe32a..ff2fb83505 100644 --- a/plugins/git/gitjob.h +++ b/plugins/git/gitjob.h @@ -1,35 +1,35 @@ /* * This file is part of KDevelop * Copyright 2010 Aleix Pol Gonzalez * * 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 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. */ #ifndef KDEVPLATFORM_PLUGIN_GITJOB_H #define KDEVPLATFORM_PLUGIN_GITJOB_H #include class GitJob : public KDevelop::DVcsJob { Q_OBJECT public: - explicit GitJob(const QDir& workingDir, KDevelop::IPlugin* parent = 0, KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose); + explicit GitJob(const QDir& workingDir, KDevelop::IPlugin* parent = nullptr, KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose); }; #endif // KDEVPLATFORM_PLUGIN_GITJOB_H diff --git a/plugins/git/stashmanagerdialog.h b/plugins/git/stashmanagerdialog.h index 7aaa8c9b95..3997af9530 100644 --- a/plugins/git/stashmanagerdialog.h +++ b/plugins/git/stashmanagerdialog.h @@ -1,68 +1,68 @@ /* * This file is part of KDevelop * Copyright 2010 Aleix Pol Gonzalez * * 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 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. */ #ifndef KDEVPLATFORM_PLUGIN_STASHMANAGERDIALOG_H #define KDEVPLATFORM_PLUGIN_STASHMANAGERDIALOG_H #include #include #include class KJob; namespace Ui { class StashManager; } class GitPlugin; class StashManagerDialog : public QDialog { Q_OBJECT public: explicit StashManagerDialog(const QDir& stashed, GitPlugin* plugin, QWidget* parent); ~StashManagerDialog() override; public slots: void showStash(); void applyClicked(); void branchClicked(); void popClicked(); void dropClicked(); void stashesFound(); private: QString selection() const; void runStash(const QStringList& arguments); Ui::StashManager* m_ui; QWidget* m_mainWidget; GitPlugin* m_plugin; QDir m_dir; }; class StashModel : public QStandardItemModel { Q_OBJECT public: - explicit StashModel(const QDir& dir, GitPlugin* git, QObject* parent = 0); + explicit StashModel(const QDir& dir, GitPlugin* git, QObject* parent = nullptr); private slots: void stashListReady(KJob*); }; #endif // KDEVPLATFORM_PLUGIN_STASHMANAGERDIALOG_H diff --git a/plugins/grepview/grepdialog.h b/plugins/grepview/grepdialog.h index 741146ba23..10542e093c 100644 --- a/plugins/grepview/grepdialog.h +++ b/plugins/grepview/grepdialog.h @@ -1,80 +1,80 @@ /*************************************************************************** * Copyright 1999-2001 by Bernd Gehrmann and the KDevelop Team * * bernd@kdevelop.org * * Copyright 2007 Dukju Ahn * * Copyright 2010 Julien Desgats * * * * 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. * * * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_GREPDIALOG_H #define KDEVPLATFORM_PLUGIN_GREPDIALOG_H #include #include #include "ui_grepwidget.h" class KConfig; class KUrlRequester; class GrepViewPlugin; class QLineEdit; class GrepDialog : public QDialog, private Ui::GrepWidget { Q_OBJECT public: - explicit GrepDialog( GrepViewPlugin * plugin, QWidget *parent=0 ); + explicit GrepDialog( GrepViewPlugin * plugin, QWidget *parent=nullptr ); ~GrepDialog() override; void setPattern(const QString &pattern); void setEnableProjectBox(bool enable); QString patternString() const; QString templateString() const; QString replacementTemplateString() const; QString filesString() const; QString excludeString() const; bool useProjectFilesFlag() const; bool regexpFlag() const; bool caseSensitiveFlag() const; int depthValue() const; public Q_SLOTS: void startSearch(); ///Sets directory(ies)/files to search in. Also it can be semicolon separated list of directories/files or one of special strings: allOpenFilesString, allOpenProjectsString void setSearchLocations(const QString &dir); private Q_SLOTS: void templateTypeComboActivated(int); void patternComboEditTextChanged( const QString& ); void directoryChanged(const QString &dir); QMenu* createSyncButtonMenu(); void addUrlToMenu(QMenu* ret, const QUrl& url); void addStringToMenu(QMenu* ret, QString string); void synchronizeDirActionTriggered(bool); ///Opens the dialog to select a directory to search in, and inserts it into Location(s) field. void selectDirectoryDialog(); private: // Returns the chosen directories or files (only the top directories, not subfiles) QList< QUrl > getDirectoryChoice() const; // Returns whether the given url is a subfile/subdirectory of one of the chosen directories/files // This is slow, so don't call it too often bool isPartOfChoice(QUrl url) const; GrepViewPlugin * m_plugin; }; #endif diff --git a/plugins/grepview/grepjob.h b/plugins/grepview/grepjob.h index 7a12eb4264..3ef99efbdc 100644 --- a/plugins/grepview/grepjob.h +++ b/plugins/grepview/grepjob.h @@ -1,123 +1,123 @@ /*************************************************************************** * Copyright 1999-2001 by Bernd Gehrmann * * bernd@kdevelop.org * * Copyright 2008 by Hamish Rodda * * rodda@kde.org * * Copyright 2010 Silvère Lestang * * Copyright 2010 Julien Desgats * * * * 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. * * * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_GREPJOB_H #define KDEVPLATFORM_PLUGIN_GREPJOB_H #include #include #include #include #include "grepfindthread.h" #include "grepoutputmodel.h" namespace KDevelop { class IProject; class ProcessLineMaker; } class QRegExp; class GrepViewPlugin; class FindReplaceTest; //FIXME: this is useful only for tests class GrepJob : public KJob, public KDevelop::IStatus { Q_OBJECT Q_INTERFACES( KDevelop::IStatus ) friend class GrepViewPlugin; friend class FindReplaceTest; private: ///Job can only be instanciated by plugin - explicit GrepJob( QObject *parent = 0 ); + explicit GrepJob( QObject *parent = nullptr ); public: void setOutputModel(GrepOutputModel * model); void setPatternString(const QString& patternString); void setTemplateString(const QString &templateString); void setReplacementTemplateString(const QString &replTmplString); void setFilesString(const QString &filesString); void setExcludeString(const QString &excludeString); void setDirectoryChoice(const QList &choice); void setDepth(int depth); void setRegexpFlag(bool regexpFlag); void setCaseSensitive(bool caseSensitive); void setProjectFilesFlag(bool projectFilesFlag); void start() override; QString statusName() const override; protected: bool doKill() override; // GrepOutputModel* model() const; private Q_SLOTS: void slotFindFinished(); void testFinishState(KJob *job); Q_SIGNALS: void clearMessage( KDevelop::IStatus* ) override; void showMessage( KDevelop::IStatus*, const QString & message, int timeout = 0) override; void showErrorMessage(const QString & message, int timeout = 0) override; void hideProgress( KDevelop::IStatus* ) override; void showProgress( KDevelop::IStatus*, int minimum, int maximum, int value) override; void foundMatches( const QString& filename, const GrepOutputItem::List& matches); private: Q_INVOKABLE void slotWork(); QString m_patternString; QRegExp m_regExp; QString m_regExpSimple; GrepOutputModel *m_outputModel; enum { WorkCollectFiles, WorkGrep, WorkIdle, WorkCancelled } m_workState; QList m_fileList; int m_fileIndex; QPointer m_findThread; QString m_errorMessage; QString m_templateString; QString m_replacementTemplateString; QString m_filesString; QString m_excludeString; QList m_directoryChoice; bool m_useProjectFilesFlag; bool m_regexpFlag; bool m_caseSensitiveFlag; int m_depthValue; bool m_findSomething; }; //FIXME: this function is used externally only for tests, find a way to keep it // static for a regular compilation GrepOutputItem::List grepFile(const QString &filename, const QRegExp &re); #endif diff --git a/plugins/grepview/grepoutputdelegate.h b/plugins/grepview/grepoutputdelegate.h index ac17219448..53d11c1711 100644 --- a/plugins/grepview/grepoutputdelegate.h +++ b/plugins/grepview/grepoutputdelegate.h @@ -1,43 +1,43 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright (C) 2007 Andreas Pakulat * * Copyright 2010 Julien Desgats * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_GREPOUTPUTDELEGATE_H #define KDEVPLATFORM_PLUGIN_GREPOUTPUTDELEGATE_H #include class GrepOutputDelegate : public QStyledItemDelegate { Q_OBJECT public: explicit GrepOutputDelegate(QObject* parent); - virtual ~GrepOutputDelegate(); + ~GrepOutputDelegate() override; static GrepOutputDelegate* self(); void paint(QPainter*, const QStyleOptionViewItem&, const QModelIndex&) const override; - virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; + QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; private: static GrepOutputDelegate* m_self; QColor blendColor(QColor color1, QColor color2, double blend) const; }; #endif diff --git a/plugins/grepview/grepoutputmodel.h b/plugins/grepview/grepoutputmodel.h index 46450a33e2..2862966f4a 100644 --- a/plugins/grepview/grepoutputmodel.h +++ b/plugins/grepview/grepoutputmodel.h @@ -1,112 +1,112 @@ /*************************************************************************** * Copyright 1999-2001 Bernd Gehrmann and the KDevelop Team * * bernd@kdevelop.org * * Copyright 2007 Dukju Ahn * * Copyright 2010 Silvère Lestang * * Copyright 2010 Julien Desgats * * * * 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. * * * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_GREPOUTPUTMODEL_H #define KDEVPLATFORM_PLUGIN_GREPOUTPUTMODEL_H #include #include #include class QModelIndex; class QRegExp; namespace KDevelop { class IStatus; } class GrepOutputItem : public QStandardItem { public: typedef QList List; GrepOutputItem(KDevelop::DocumentChangePointer change, const QString& text, bool checkable); GrepOutputItem(const QString &filename, const QString &text, bool checkable); ~GrepOutputItem() override; QString filename() const ; int lineNumber() const ; KDevelop::DocumentChangePointer change() const ; bool isText() const ; /// Recursively apply check state to children void propagateState() ; /// Check children to determine current state void refreshState() ; QVariant data ( int role = Qt::UserRole + 1 ) const override; private: KDevelop::DocumentChangePointer m_change; }; Q_DECLARE_METATYPE(GrepOutputItem::List) class GrepOutputModel : public QStandardItemModel { Q_OBJECT public: - explicit GrepOutputModel( QObject *parent = 0 ); + explicit GrepOutputModel( QObject *parent = nullptr ); ~GrepOutputModel() override; void setRegExp(const QRegExp& re); void setReplacementTemplate(const QString &tmpl); /// applies replacement on given text QString replacementFor(const QString &text); void clear(); // resets file & match counts bool hasResults(); QModelIndex previousItemIndex(const QModelIndex ¤tIdx) const; QModelIndex nextItemIndex(const QModelIndex ¤tIdx) const; const GrepOutputItem *getRootItem() const; void makeItemsCheckable(bool checkable); bool itemsCheckable() const; public Q_SLOTS: void appendOutputs( const QString &filename, const GrepOutputItem::List &lines ); void activate( const QModelIndex &idx ); void doReplacements(); void setReplacement(const QString &repl); //receive status message from GrepJob, and store it void showMessageSlot( KDevelop::IStatus*, const QString& message ); //emit stored message as signal 'showMessage' to GrepOutputView. //called when user selects a search with the combobox void showMessageEmit(); Q_SIGNALS: void showMessage( KDevelop::IStatus*, const QString& message ); void showErrorMessage(const QString & message, int timeout = 0); private: void makeItemsCheckable(bool checkable, GrepOutputItem* item); QRegExp m_regExp; QString m_replacement; QString m_replacementTemplate; QString m_finalReplacement; bool m_finalUpToDate; /// says if m_finalReplacement is up to date or must be regenerated GrepOutputItem *m_rootItem; int m_fileCount; int m_matchCount; QString m_savedMessage; KDevelop::IStatus *m_savedIStatus; bool m_itemsCheckable; private slots: void updateCheckState(QStandardItem*); }; #endif diff --git a/plugins/grepview/grepoutputview.h b/plugins/grepview/grepoutputview.h index 9b7d4fca50..e06b0ba952 100644 --- a/plugins/grepview/grepoutputview.h +++ b/plugins/grepview/grepoutputview.h @@ -1,101 +1,101 @@ /************************************************************************** * Copyright 2010 Silvère Lestang * * Copyright 2010 Julien Desgats * * * * 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. * * * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_GREPOUTPUTVIEW_H #define KDEVPLATFORM_PLUGIN_GREPOUTPUTVIEW_H #include #include #include "ui_grepoutputview.h" namespace KDevelop { class IStatus; } class QModelIndex; class GrepViewPlugin; class GrepOutputModel; class GrepOutputDelegate; class GrepOutputViewFactory: public KDevelop::IToolViewFactory { public: explicit GrepOutputViewFactory(GrepViewPlugin* plugin); - QWidget* create(QWidget* parent = 0) override; + QWidget* create(QWidget* parent = nullptr) override; Qt::DockWidgetArea defaultPosition() override; QString id() const override; private: GrepViewPlugin* m_plugin; }; class GrepOutputView : public QWidget, Ui::GrepOutputView, public KDevelop::IToolViewActionListener { Q_OBJECT Q_INTERFACES(KDevelop::IToolViewActionListener) public: enum MessageType { Information, Error }; GrepOutputView(QWidget* parent, GrepViewPlugin* plugin); ~GrepOutputView() override; GrepOutputModel* model(); /** * This causes the creation of a new model, the old one is kept in model history. * Oldest models are deleted if needed. * @return pointer to the new model */ GrepOutputModel* renewModel(const QString& name, const QString& description); void setMessage(const QString& msg, MessageType type = Information); public Q_SLOTS: void showErrorMessage( const QString& errorMessage ); void showMessage( KDevelop::IStatus*, const QString& message ); void updateApplyState(const QModelIndex &topLeft, const QModelIndex &bottomRight); void changeModel(int index); void replacementTextChanged(QString); Q_SIGNALS: void outputViewIsClosed(); private: static const int HISTORY_SIZE; QAction* m_next; QAction* m_prev; QAction* m_collapseAll; QAction* m_expandAll; QAction* m_clearSearchHistory; QLabel* m_statusLabel; GrepViewPlugin *m_plugin; private slots: void selectPreviousItem() override; void selectNextItem() override; void collapseAllItems(); void expandAllItems(); void onApply(); void showDialog(); void expandElements( const QModelIndex & parent ); void rowsRemoved(); void clearSearchHistory(); void modelSelectorContextMenu(const QPoint& pos); void updateScrollArea(); void updateCheckable(); }; #endif // KDEVPLATFORM_PLUGIN_GREPOUTPUTVIEW_H diff --git a/plugins/konsole/kdevkonsoleview.h b/plugins/konsole/kdevkonsoleview.h index 378571e91f..075fd89181 100644 --- a/plugins/konsole/kdevkonsoleview.h +++ b/plugins/konsole/kdevkonsoleview.h @@ -1,41 +1,41 @@ /*************************************************************************** * Copyright 2003, 2006 Adam Treat * * Copyright 2007 Andreas Pakulat * * * * 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. * * * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_KDEVKONSOLEVIEW_H #define KDEVPLATFORM_PLUGIN_KDEVKONSOLEVIEW_H #include #include class KDevKonsoleViewPlugin; class KDevKonsoleView : public QWidget { Q_OBJECT public: - explicit KDevKonsoleView( KDevKonsoleViewPlugin* plugin, QWidget *parent = 0 ); + explicit KDevKonsoleView( KDevKonsoleViewPlugin* plugin, QWidget *parent = nullptr ); ~KDevKonsoleView() override; public slots: void setDirectory( const QUrl &dirUrl ); protected: bool eventFilter( QObject *obj, QEvent *e ) override; private : class KDevKonsoleViewPrivate* const d; Q_PRIVATE_SLOT( d, void _k_slotTerminalClosed() ) }; #endif diff --git a/plugins/outlineview/outlinemodel.h b/plugins/outlineview/outlinemodel.h index b9ca8a6ce8..b935048638 100644 --- a/plugins/outlineview/outlinemodel.h +++ b/plugins/outlineview/outlinemodel.h @@ -1,60 +1,60 @@ /* * KDevelop outline view * Copyright 2010, 2015 Alex Richardson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include #include #include #include class OutlineNode; namespace KDevelop { class IDocument; class DUContext; class TopDUContext; class Declaration; } class OutlineModel : public QAbstractItemModel { Q_OBJECT Q_DISABLE_COPY(OutlineModel) public: - explicit OutlineModel(QObject* parent = 0); + explicit OutlineModel(QObject* parent = nullptr); ~OutlineModel() override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; int columnCount(const QModelIndex& parent = QModelIndex()) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override; QModelIndex parent(const QModelIndex& child) const override; bool hasChildren(const QModelIndex& parent = QModelIndex()) const override; Qt::ItemFlags flags(const QModelIndex& index) const override; public slots: void activate(const QModelIndex& realIndex); private slots: void rebuildOutline(KDevelop::IDocument* doc); private: std::unique_ptr m_rootNode; KDevelop::IDocument* m_lastDoc; KDevelop::IndexedString m_lastUrl; }; diff --git a/plugins/patchreview/patchreview.h b/plugins/patchreview/patchreview.h index 899f82e9ac..d8aebde56e 100644 --- a/plugins/patchreview/patchreview.h +++ b/plugins/patchreview/patchreview.h @@ -1,130 +1,130 @@ /*************************************************************************** Copyright 2006 David Nolden ***************************************************************************/ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_PATCHREVIEW_H #define KDEVPLATFORM_PLUGIN_PATCHREVIEW_H #include #include #include #include class PatchHighlighter; class PatchReviewToolViewFactory; class QTimer; namespace KDevelop { class IDocument; } namespace Sublime { class Area; } namespace Diff2 { class KompareModelList; class DiffModel; } namespace Kompare { struct Info; } class DiffSettings; class PatchReviewPlugin; class PatchReviewPlugin : public KDevelop::IPlugin, public KDevelop::IPatchReview { Q_OBJECT Q_INTERFACES( KDevelop::IPatchReview ) public : explicit PatchReviewPlugin( QObject *parent, const QVariantList & = QVariantList() ); ~PatchReviewPlugin() override; void unload() override; KDevelop::IPatchSource::Ptr patch() const { return m_patch; } Diff2::KompareModelList* modelList() const { return m_modelList.data(); } void seekHunk( bool forwards, const QUrl& file = QUrl() ); void setPatch( KDevelop::IPatchSource* patch ); void startReview( KDevelop::IPatchSource* patch, ReviewMode mode ) override; void finishReview( QList< QUrl > selection ); QUrl urlForFileModel( const Diff2::DiffModel* model ); QAction* finishReviewAction() const { return m_finishReview; } Q_SIGNALS: void startingNewReview(); void patchChanged(); public Q_SLOTS : //Does parts of the review-starting that are problematic to do directly in startReview, as they may open dialogs etc. void updateReview(); void cancelReview(); void clearPatch( QObject* patch ); void notifyPatchChanged(); void highlightPatch(); void updateKompareModel(); void forceUpdate(); void areaChanged(Sublime::Area* area); private Q_SLOTS : void documentClosed( KDevelop::IDocument* ); void textDocumentCreated( KDevelop::IDocument* ); void documentSaved( KDevelop::IDocument* ); void closeReview(); private: void switchToEmptyReviewArea(); /// Makes sure that this working set is active only in the @p area, and that its name starts with "review". void setUniqueEmptyWorkingSet(Sublime::Area* area); - void addHighlighting( const QUrl& file, KDevelop::IDocument* document = 0 ); + void addHighlighting( const QUrl& file, KDevelop::IDocument* document = nullptr ); void removeHighlighting( const QUrl& file = QUrl() ); KDevelop::IPatchSource::Ptr m_patch; QTimer* m_updateKompareTimer; PatchReviewToolViewFactory* m_factory; QAction* m_finishReview; #if 0 void determineState(); #endif QPointer< DiffSettings > m_diffSettings; QScopedPointer< Kompare::Info > m_kompareInfo; QScopedPointer< Diff2::KompareModelList > m_modelList; typedef QMap< QUrl, QPointer< PatchHighlighter > > HighlightMap; HighlightMap m_highlighters; friend class PatchReviewToolView; // to access slot exporterSelected(); }; #endif // kate: space-indent on; indent-width 2; tab-width 2; replace-tabs on diff --git a/plugins/patchreview/patchreviewtoolview.h b/plugins/patchreview/patchreviewtoolview.h index 97e40c5381..609da8e806 100644 --- a/plugins/patchreview/patchreviewtoolview.h +++ b/plugins/patchreview/patchreviewtoolview.h @@ -1,111 +1,111 @@ /*************************************************************************** Copyright 2006-2009 David Nolden ***************************************************************************/ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_PATCHREVIEWTOOLVIEW_H #define KDEVPLATFORM_PLUGIN_PATCHREVIEWTOOLVIEW_H #include #include #include #include #include namespace Sublime { class Area; } namespace KDevelop { class IDocument; } namespace KParts { class Part; } namespace Purpose { class Menu; } class QStandardItem; class KJob; class PatchReviewPlugin; class LocalPatchSource; class QModelIndex; class QSortFilterProxyModel; class PatchReviewToolView : public QWidget { Q_OBJECT public: PatchReviewToolView( QWidget* parent, PatchReviewPlugin* plugin ); ~PatchReviewToolView() override; signals: void dialogClosed( PatchReviewToolView* ); void stateChanged( PatchReviewToolView* ); private slots: void startingNewReview(); void fileDoubleClicked( const QModelIndex& i ); void nextHunk(); void prevHunk(); void prevFile(); void nextFile(); void seekFile(bool forwards); void patchChanged(); void slotAppliedChanged( int newState ); void finishReview(); void runTests(); void selectAll(); void deselectAll(); void fileItemChanged( QStandardItem* item ); private: void resizeEvent(QResizeEvent*) override; - void activate( const QUrl& url, KDevelop::IDocument* buddy = 0 ) const; + void activate( const QUrl& url, KDevelop::IDocument* buddy = nullptr ) const; void kompareModelChanged(); void showEditDialog(); ///Fills the editor views from m_editingPatch void fillEditFromPatch(); /// Retrieve the patch from plugin and perform all necessary casts LocalPatchSource* GetLocalPatchSource(); Ui_EditPatch m_editPatch; QTime m_lastDataTime; QString m_lastTerminalData; QPointer< KParts::Part > m_konsolePart; /// Whether the set of checked URLs should be reset on the next update bool m_resetCheckedUrls; PatchReviewPlugin* m_plugin; QPointer< QWidget > m_customWidget; QAction* m_selectAllAction; QAction* m_deselectAllAction; Purpose::Menu* m_exportMenu; class PatchFilesModel* m_fileModel; QSortFilterProxyModel* m_fileSortProxyModel; public slots: void documentActivated( KDevelop::IDocument* ); void customContextMenuRequested(const QPoint& p); void testJobResult(KJob* job); void testJobPercent(KJob* job, ulong percent); }; #endif // KDEVPLATFORM_PLUGIN_PATCHREVIEWTOOLVIEW_H diff --git a/plugins/problemreporter/problemsview.h b/plugins/problemreporter/problemsview.h index 19c1bb73fe..0602f0a6e9 100644 --- a/plugins/problemreporter/problemsview.h +++ b/plugins/problemreporter/problemsview.h @@ -1,90 +1,90 @@ /* * Copyright 2015 Laszlo Kis-Adam * * 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 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. */ #ifndef PROBLEMSVIEW_H #define PROBLEMSVIEW_H #include #include class ProblemTreeView; namespace KDevelop { struct ModelData; /** * @brief Provides a tabbed view for models in the ProblemModelSet. * * Also provides a toolbar for actions for the models and shows the number of messages in each tab's text. * When the load() method is called it looks up the models in the ProblemModelSet. * For each model it creates a treeview, which is then added to the tabbed view and a new tab. * The tab's text will be the name of the model + the number of items in the treeview. * * TODO: According to apol this should NOT be a QMainWindow, * because updating the widget's actions should be sufficient to update the * toolbar of the toolviiew */ class ProblemsView : public QMainWindow, public IToolViewActionListener { Q_OBJECT Q_INTERFACES(KDevelop::IToolViewActionListener) public: - explicit ProblemsView(QWidget* parent = NULL); + explicit ProblemsView(QWidget* parent = nullptr); ~ProblemsView() override; /// Load all the current models and create tabs for them void load(); public Q_SLOTS: /// Triggered when a new model is added to the ModelSet void onModelAdded(const ModelData& data); /// Triggered when a model is removed from the ModelSet void onModelRemoved(const QString& name); /// Triggered when the user (or program) selects a new tab void onCurrentChanged(int idx); /// Triggered when a view changes (happens when the model data changes) void onViewChanged(); void selectNextItem() override; void selectPreviousItem() override; private: ProblemTreeView* currentView() const; /// Create a view for the model and add to the tabbed widget void addModel(const ModelData& data); /// Update the toolbar with the widget's actions void updateToolBar(); /// Update the tab's text (name + number of problems in that tab) void updateTab(int idx, int rows); QToolBar* m_toolBar; QTabWidget* m_tabWidget; }; } #endif diff --git a/plugins/projectfilter/comboboxdelegate.h b/plugins/projectfilter/comboboxdelegate.h index 9868fb836f..7b31f07cc8 100644 --- a/plugins/projectfilter/comboboxdelegate.h +++ b/plugins/projectfilter/comboboxdelegate.h @@ -1,60 +1,60 @@ /* * This file is part of KDevelop * Copyright 2013 Milian Wolff * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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, see . */ #ifndef COMBOBOXDELEGATE_H #define COMBOBOXDELEGATE_H #include namespace KDevelop { class ComboBoxDelegate : public QStyledItemDelegate { Q_OBJECT public: struct Item { Item() {} Item(const QString& text, const QVariant& data) : text(text) , data(data) {} QString text; QVariant data; }; - explicit ComboBoxDelegate(const QVector& items, QObject* parent = 0); + explicit ComboBoxDelegate(const QVector& items, QObject* parent = nullptr); ~ComboBoxDelegate() override; QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override; void setEditorData(QWidget* editor, const QModelIndex& index) const override; void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override; private: QVector m_items; }; } Q_DECLARE_TYPEINFO(KDevelop::ComboBoxDelegate::Item, Q_MOVABLE_TYPE); #endif // COMBOBOXDELEGATE_H diff --git a/plugins/projectfilter/filtermodel.h b/plugins/projectfilter/filtermodel.h index c260895f4b..0017f05064 100644 --- a/plugins/projectfilter/filtermodel.h +++ b/plugins/projectfilter/filtermodel.h @@ -1,73 +1,73 @@ /* * This file is part of KDevelop * Copyright 2013 Milian Wolff * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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, see . */ #ifndef FILTERMODEL_H #define FILTERMODEL_H #include #include "filter.h" namespace KDevelop { class FilterModel : public QAbstractTableModel { Q_OBJECT public: - explicit FilterModel(QObject* parent = 0); + explicit FilterModel(QObject* parent = nullptr); ~FilterModel() override; SerializedFilters filters() const; void setFilters(const SerializedFilters& filters); void moveFilterUp(int row); void moveFilterDown(int row); int rowCount(const QModelIndex& parent = QModelIndex()) const override; int columnCount(const QModelIndex& parent = QModelIndex()) const override; Qt::DropActions supportedDropActions() const override; Qt::ItemFlags flags(const QModelIndex& index) const override; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override; bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()) override; QMap< int, QVariant > itemData(const QModelIndex& index) const override; bool setItemData(const QModelIndex& index, const QMap< int, QVariant >& roles) override; enum Columns { Pattern, Targets, Inclusive, NUM_COLUMNS }; private: SerializedFilters m_filters; // workaround a strange behavior in Qt when we try to drop after the last item in the list bool m_ignoredLastInsert; }; } #endif // FILTERMODEL_H diff --git a/plugins/projectfilter/projectfilterprovider.h b/plugins/projectfilter/projectfilterprovider.h index 9f1ac4bdb6..f2eac9fd69 100644 --- a/plugins/projectfilter/projectfilterprovider.h +++ b/plugins/projectfilter/projectfilterprovider.h @@ -1,67 +1,67 @@ /* This file is part of KDevelop Copyright 2013 Milian Wolff This library 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 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. */ #ifndef KDEVPLATFORM_PLUGIN_PROJECTFILTERPROVIDER_H #define KDEVPLATFORM_PLUGIN_PROJECTFILTERPROVIDER_H #include #include #include "projectfilter.h" #include namespace KDevelop { class ProjectFilterProvider: public IPlugin, public IProjectFilterProvider { Q_OBJECT Q_INTERFACES( KDevelop::IProjectFilterProvider ) public: - explicit ProjectFilterProvider( QObject* parent = 0, const QVariantList& args = QVariantList() ); + explicit ProjectFilterProvider( QObject* parent = nullptr, const QVariantList& args = QVariantList() ); QSharedPointer createFilter(IProject* project) const override; ContextMenuExtension contextMenuExtension(Context* context) override; int perProjectConfigPages() const override; ConfigPage* perProjectConfigPage(int number, const ProjectConfigOptions& options, QWidget* parent) override; signals: void filterChanged(KDevelop::IProjectFilterProvider*, KDevelop::IProject*); public slots: void updateProjectFilters(KDevelop::IProject* project); private slots: void projectClosing(KDevelop::IProject*); void projectAboutToBeOpened(KDevelop::IProject*); void addFilterFromContextMenu(); private: QHash > m_filters; }; } #endif // KDEVPLATFORM_PLUGIN_PROJECTFILTERPROVIDER_H diff --git a/plugins/projectmanagerview/projectbuildsetwidget.h b/plugins/projectmanagerview/projectbuildsetwidget.h index 07a9838009..2b4f88faff 100644 --- a/plugins/projectmanagerview/projectbuildsetwidget.h +++ b/plugins/projectmanagerview/projectbuildsetwidget.h @@ -1,68 +1,68 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_PROJECTBUILDSETWIDGET_H #define KDEVPLATFORM_PLUGIN_PROJECTBUILDSETWIDGET_H #include #include class QTreeView; class QToolButton; class ProjectManagerViewPlugin; class QStringListModel; class ProjectManagerView; namespace KDevelop { class ProjectBaseItem; } namespace Ui { class ProjectBuildSetWidget; } class ProjectBuildSetWidget : public QWidget { Q_OBJECT public: - explicit ProjectBuildSetWidget( QWidget* parent = 0 ); + explicit ProjectBuildSetWidget( QWidget* parent = nullptr ); ~ProjectBuildSetWidget() override; void setProjectView( ProjectManagerView* view ); public slots: void selectionChanged(); private slots: void addItems(); void removeItems(); void moveUp(); void moveDown(); void moveToBottom(); void moveToTop(); void showContextMenu( const QPoint& p ); private: ProjectManagerView* m_view; Ui::ProjectBuildSetWidget* m_ui; }; #endif //kate: space-indent on; indent-width 4; replace-tabs on; auto-insert-doxygen on; indent-mode cstyle; diff --git a/plugins/projectmanagerview/projectmodelitemdelegate.h b/plugins/projectmanagerview/projectmodelitemdelegate.h index e89a2288ec..854a88d563 100644 --- a/plugins/projectmanagerview/projectmodelitemdelegate.h +++ b/plugins/projectmanagerview/projectmodelitemdelegate.h @@ -1,41 +1,41 @@ /* This file is part of KDevelop Copyright 2013 Aleix Pol This library 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 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. */ #ifndef KDEVPLATFORM_PLUGIN_PROJECTMODELITEMDELEGATE_H #define KDEVPLATFORM_PLUGIN_PROJECTMODELITEMDELEGATE_H #include class ProjectModelItemDelegate : public QItemDelegate { Q_OBJECT public: - explicit ProjectModelItemDelegate(QObject* parent = 0); + explicit ProjectModelItemDelegate(QObject* parent = nullptr); void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; void drawDisplay(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text) const override; private: void drawBranchName(QPainter* painter, const QStyleOptionViewItem& option, const QRect& rect, const QString& branchName) const; void drawStyledBackground(QPainter* painter, const QStyleOptionViewItem& option) const; }; #endif // KDEVPLATFORM_PLUGIN_PROJECTMODELITEMDELEGATE_H diff --git a/plugins/projectmanagerview/projecttreeview.h b/plugins/projectmanagerview/projecttreeview.h index 36e4e375c2..3fe0f49f2f 100644 --- a/plugins/projectmanagerview/projecttreeview.h +++ b/plugins/projectmanagerview/projecttreeview.h @@ -1,82 +1,82 @@ /* This file is part of KDevelop Copyright 2005 Roberto Raggi Copyright 2007 Andreas Pakulat This library 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 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. */ #ifndef KDEVPLATFORM_PLUGIN_PROJECTTREEVIEW_H #define KDEVPLATFORM_PLUGIN_PROJECTTREEVIEW_H #include #include class QAbstractProxyModel; class QAction; class QItemSelectionModel; class QMouseEvent; namespace KDevelop { class IProject; class ProjectModel; class ProjectBaseItem; class ProjectFolderItem; class ProjectFileItem; class ProjectTargetItem; class ProjectBaseItem; class NavigationToolTip; class Path; } class ProjectTreeView: public QTreeView { Q_OBJECT public: - explicit ProjectTreeView( QWidget *parent = 0 ); + explicit ProjectTreeView( QWidget *parent = nullptr ); ~ProjectTreeView() override; static QModelIndex mapFromSource(const QAbstractProxyModel* proxy, const QModelIndex& sourceIdx); bool event(QEvent* event) override; Q_SIGNALS: void activate( const KDevelop::Path &url ); protected Q_SLOTS: void slotActivated( const QModelIndex &index ); void popupContextMenu( const QPoint &pos ); void openProjectConfig(); void saveState(); - void restoreState(KDevelop::IProject* project = 0); + void restoreState(KDevelop::IProject* project = nullptr); void aboutToShutdown(); protected: void keyPressEvent(QKeyEvent *event) override; void dropEvent(QDropEvent* event) override; void drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const override; private: QModelIndex mapFromItem(const KDevelop::ProjectBaseItem* item); KDevelop::ProjectBaseItem* itemAtPos(QPoint pos); KDevelop::IProject* m_ctxProject; QPointer m_tooltip; QPersistentModelIndex m_idx; }; #endif // KDEVPLATFORM_PLUGIN_PROJECTTREEVIEW_H diff --git a/plugins/projectmanagerview/vcsoverlayproxymodel.h b/plugins/projectmanagerview/vcsoverlayproxymodel.h index 1b857f0b3e..39b91d76a6 100644 --- a/plugins/projectmanagerview/vcsoverlayproxymodel.h +++ b/plugins/projectmanagerview/vcsoverlayproxymodel.h @@ -1,54 +1,54 @@ /* This file is part of KDevelop Copyright 2008 Aleix Pol This library 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 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. */ #ifndef KDEVPLATFORM_PLUGIN_VCSOVERLAYPROXYMODEL_H #define KDEVPLATFORM_PLUGIN_VCSOVERLAYPROXYMODEL_H #include #include class QUrl; namespace KDevelop { class IProject; class VcsJob; } class VcsOverlayProxyModel : public QIdentityProxyModel { Q_OBJECT public: enum Roles { VcsStatusRole = KDevelop::ProjectModel::LastRole }; - explicit VcsOverlayProxyModel(QObject* parent = 0); + explicit VcsOverlayProxyModel(QObject* parent = nullptr); QVariant data(const QModelIndex& proxyIndex, int role = Qt::DisplayRole) const override; private slots: void addProject(KDevelop::IProject* p); void removeProject(KDevelop::IProject* p); void repositoryBranchChanged(const QUrl& url); void branchNameReady(KDevelop::VcsJob* job); private: QModelIndex indexFromProject(QObject* project); QHash m_branchName; }; #endif // KDEVPLATFORM_PLUGIN_VCSOVERLAYPROXYMODEL_H diff --git a/plugins/quickopen/actionsquickopenprovider.h b/plugins/quickopen/actionsquickopenprovider.h index 80da0c4ff0..022090b2e4 100644 --- a/plugins/quickopen/actionsquickopenprovider.h +++ b/plugins/quickopen/actionsquickopenprovider.h @@ -1,44 +1,44 @@ /* * This file is part of KDevelop * * Copyright 2015 Aleix Pol Gonzalez * * 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 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. */ #ifndef KDEVPLATFORM_PLUGIN_ACTIONSPROVIDER_H #define KDEVPLATFORM_PLUGIN_ACTIONSPROVIDER_H #include #include class ActionsQuickOpenProvider : public KDevelop::QuickOpenDataProviderBase { Q_OBJECT public: ActionsQuickOpenProvider(); - virtual KDevelop::QuickOpenDataPointer data(uint row) const override; - virtual uint unfilteredItemCount() const override; - virtual uint itemCount() const override; - virtual void reset() override; - virtual void setFilterText(const QString& text) override; + KDevelop::QuickOpenDataPointer data(uint row) const override; + uint unfilteredItemCount() const override; + uint itemCount() const override; + void reset() override; + void setFilterText(const QString& text) override; private: QVector m_results; }; #endif // KDEVPLATFORM_PLUGIN_ACTIONSPROVIDER_H diff --git a/plugins/quickopen/declarationlistquickopen.h b/plugins/quickopen/declarationlistquickopen.h index 7d45c52ebc..7ad79a271b 100644 --- a/plugins/quickopen/declarationlistquickopen.h +++ b/plugins/quickopen/declarationlistquickopen.h @@ -1,44 +1,44 @@ /* This file is part of the KDE libraries Copyright (C) 2008 David Nolden 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. */ #ifndef KDEVPLATFORM_PLUGIN_DECLARATION_LIST_QUICKOPEN_H #define KDEVPLATFORM_PLUGIN_DECLARATION_LIST_QUICKOPEN_H #include "duchainitemquickopen.h" namespace KDevelop { class IQuickOpen; } class DeclarationListDataProvider : public DUChainItemDataProvider { Q_OBJECT public: DeclarationListDataProvider( KDevelop::IQuickOpen* quickopen, const QList& items, bool openDefinitions = false ); - virtual void reset() override; + void reset() override; private: QList m_items; }; #endif diff --git a/plugins/quickopen/documentationquickopenprovider.h b/plugins/quickopen/documentationquickopenprovider.h index 50a782556a..0f3b398f34 100644 --- a/plugins/quickopen/documentationquickopenprovider.h +++ b/plugins/quickopen/documentationquickopenprovider.h @@ -1,44 +1,44 @@ /* * This file is part of KDevelop * * Copyright 2013 Aleix Pol Gonzalez * * 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 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. */ #ifndef KDEVPLATFORM_PLUGIN_DOCUMENTATIONPROVIDER_H #define KDEVPLATFORM_PLUGIN_DOCUMENTATIONPROVIDER_H #include #include class DocumentationQuickOpenProvider : public KDevelop::QuickOpenDataProviderBase { Q_OBJECT public: DocumentationQuickOpenProvider(); - virtual KDevelop::QuickOpenDataPointer data(uint row) const override; - virtual uint unfilteredItemCount() const override; - virtual uint itemCount() const override; - virtual void reset() override; - virtual void setFilterText(const QString& text) override; + KDevelop::QuickOpenDataPointer data(uint row) const override; + uint unfilteredItemCount() const override; + uint itemCount() const override; + void reset() override; + void setFilterText(const QString& text) override; private: QVector m_results; }; #endif // KDEVPLATFORM_PLUGIN_DOCUMENTATIONPROVIDER_H diff --git a/plugins/quickopen/duchainitemquickopen.h b/plugins/quickopen/duchainitemquickopen.h index bf7a472094..fe96265f87 100644 --- a/plugins/quickopen/duchainitemquickopen.h +++ b/plugins/quickopen/duchainitemquickopen.h @@ -1,103 +1,103 @@ /* This file is part of the KDE libraries Copyright (C) 2007 David Nolden 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. */ #ifndef DUCHAIN_ITEM_QUICKOPEN #define DUCHAIN_ITEM_QUICKOPEN #include #include #include #include namespace KDevelop { class IQuickOpen; } struct DUChainItem { DUChainItem() : m_noHtmlDestription(false) { } KDevelop::IndexedDeclaration m_item; QString m_text; QString m_project; bool m_noHtmlDestription; }; Q_DECLARE_TYPEINFO(DUChainItem, Q_MOVABLE_TYPE); class DUChainItemData : public KDevelop::QuickOpenDataBase { public: explicit DUChainItemData( const DUChainItem& item, bool openDefinition = false ); - virtual QString text() const override; - virtual QString htmlDescription() const override; - virtual QList highlighting() const override; + QString text() const override; + QString htmlDescription() const override; + QList highlighting() const override; bool execute( QString& filterText ) override; - virtual bool isExpandable() const override; - virtual QWidget* expandingWidget() const override; + bool isExpandable() const override; + QWidget* expandingWidget() const override; - virtual QIcon icon() const override; + QIcon icon() const override; private: DUChainItem m_item; bool m_openDefinition; }; /** * A QuickOpenDataProvider that presents a list of declarations. * The declarations need to be set using setItems(..) in a re-implemented reset() function. * */ class DUChainItemDataProvider : public KDevelop::QuickOpenDataProviderBase, public KDevelop::Filter { Q_OBJECT public: typedef KDevelop::Filter Base; /// When openDefinitions is true, the definitions will be opened if available on execute(). explicit DUChainItemDataProvider( KDevelop::IQuickOpen* quickopen, bool openDefinitions = false ); - virtual void setFilterText( const QString& text ) override; - virtual uint itemCount() const override; - virtual uint unfilteredItemCount() const override; - virtual KDevelop::QuickOpenDataPointer data( uint row ) const override; + void setFilterText( const QString& text ) override; + uint itemCount() const override; + uint unfilteredItemCount() const override; + KDevelop::QuickOpenDataPointer data( uint row ) const override; - virtual void reset() override; + void reset() override; protected: //Override to create own DUChainItemData derived classes DUChainItemData* createData( const DUChainItem& item ) const; //Reimplemented from Base<..> - virtual QString itemText( const DUChainItem& data ) const override; + QString itemText( const DUChainItem& data ) const override; KDevelop::IQuickOpen* m_quickopen; private: bool m_openDefinitions; }; #endif diff --git a/plugins/quickopen/expandingtree/expandingdelegate.h b/plugins/quickopen/expandingtree/expandingdelegate.h index adb84c6c19..f1f3186192 100644 --- a/plugins/quickopen/expandingtree/expandingdelegate.h +++ b/plugins/quickopen/expandingtree/expandingdelegate.h @@ -1,93 +1,93 @@ /* This file is part of the KDE libraries and the Kate part. * * Copyright (C) 2006 Hamish Rodda * Copyright (C) 2007 David Nolden * * This library 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 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. */ #ifndef KDEVPLATFORM_PLUGIN_EXPANDINGDELEGATE_H #define KDEVPLATFORM_PLUGIN_EXPANDINGDELEGATE_H #include #include #include #include class KateRenderer; class KateCompletionWidget; class KateDocument; class KateTextLine; class ExpandingWidgetModel; class QVariant; class QStyleOptionViewItem; /** * This is a delegate that cares, together with ExpandingWidgetModel, about embedded widgets in tree-view. * */ class ExpandingDelegate : public QItemDelegate { Q_OBJECT public: - explicit ExpandingDelegate(ExpandingWidgetModel* model, QObject* parent = 0L); + explicit ExpandingDelegate(ExpandingWidgetModel* model, QObject* parent = nullptr); // Overridden to create highlighting for current index void paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const override; // Returns the basic size-hint as reported by QItemDelegate QSize basicSizeHint( const QModelIndex& index ) const; ExpandingWidgetModel* model() const; protected: //Called right before paint to allow last-minute changes to the style virtual void adjustStyle( const QModelIndex& index, QStyleOptionViewItem & option ) const; void drawDisplay ( QPainter * painter, const QStyleOptionViewItem & option, const QRect & rect, const QString & text ) const override; QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const override; bool editorEvent ( QEvent * event, QAbstractItemModel * model, const QStyleOptionViewItem & option, const QModelIndex & index ) override; virtual void drawBackground ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const; void drawDecoration(QPainter* painter, const QStyleOptionViewItem& option, const QRect& rect, const QPixmap& pixmap) const override; //option can be changed virtual QList createHighlighting(const QModelIndex& index, QStyleOptionViewItem& option) const; void adjustRect(QRect& rect) const; /** * Creates a list of FormatRanges as should be returned by createHighlighting from a list of QVariants as described in the kde header ktexteditor/codecompletionmodel.h * */ QList highlightingFromVariantList(const QList& customHighlights) const; //Called when an item was expanded/unexpanded and the height changed virtual void heightChanged() const; //Initializes the style options from the index void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const; mutable int m_currentColumnStart; //Text-offset for custom highlighting, will be applied to m_cachedHighlights(Only highlights starting after this will be used). Shoult be zero of the highlighting is not taken from kate. mutable QList m_currentColumnStarts; mutable QList m_cachedHighlights; mutable Qt::Alignment m_cachedAlignment; mutable QColor m_backgroundColor; mutable QModelIndex m_currentIndex; private: ExpandingWidgetModel* m_model; }; #endif // KDEVPLATFORM_PLUGIN_EXPANDINGDELEGATE_H diff --git a/plugins/quickopen/projectitemquickopen.h b/plugins/quickopen/projectitemquickopen.h index 7da59c3f71..f80ba6511e 100644 --- a/plugins/quickopen/projectitemquickopen.h +++ b/plugins/quickopen/projectitemquickopen.h @@ -1,85 +1,85 @@ /* This file is part of the KDE libraries Copyright (C) 2007 David Nolden 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. */ #ifndef PROJECT_ITEM_QUICKOPEN #define PROJECT_ITEM_QUICKOPEN #include "duchainitemquickopen.h" #include #include struct CodeModelViewItem { CodeModelViewItem() { } CodeModelViewItem(const KDevelop::IndexedString& file, const KDevelop::QualifiedIdentifier& id) : m_file(file) , m_id(id) { } KDevelop::IndexedString m_file; KDevelop::QualifiedIdentifier m_id; }; Q_DECLARE_TYPEINFO(CodeModelViewItem, Q_MOVABLE_TYPE); typedef QMap > AddedItems; class ProjectItemDataProvider : public KDevelop::QuickOpenDataProviderBase { Q_OBJECT public: enum ItemTypes { NoItems = 0, Classes = 1, Functions = 2, AllItemTypes = Classes + Functions }; explicit ProjectItemDataProvider( KDevelop::IQuickOpen* quickopen ); - virtual void enableData( const QStringList& items, const QStringList& scopes ) override; + void enableData( const QStringList& items, const QStringList& scopes ) override; - virtual void setFilterText( const QString& text ) override; + void setFilterText( const QString& text ) override; virtual QList data( uint start, uint end ) const; - virtual void reset() override; + void reset() override; - virtual uint itemCount() const override; - virtual uint unfilteredItemCount() const override; + uint itemCount() const override; + uint unfilteredItemCount() const override; static QStringList supportedItemTypes(); private: KDevelop::QuickOpenDataPointer data( uint pos ) const override; ItemTypes m_itemTypes; KDevelop::IQuickOpen* m_quickopen; QSet m_files; QVector m_currentItems; QString m_currentFilter; QVector m_filteredItems; //Maps positions to the additional items behind those positions //Here additional inserted items are stored, that are not represented in m_filteredItems. //This is needed at least to also show overloaded function declarations mutable AddedItems m_addedItems; }; #endif diff --git a/plugins/quickopen/tests/bench_quickopen.h b/plugins/quickopen/tests/bench_quickopen.h index dc664d2d23..253928e7d1 100644 --- a/plugins/quickopen/tests/bench_quickopen.h +++ b/plugins/quickopen/tests/bench_quickopen.h @@ -1,46 +1,46 @@ /* * Copyright Milian Wolff * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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, see . */ #ifndef KDEVPLATFORM_PLUGIN_BENCH_QUICKOPEN_H #define KDEVPLATFORM_PLUGIN_BENCH_QUICKOPEN_H #include "quickopentestbase.h" class BenchQuickOpen : public QuickOpenTestBase { Q_OBJECT public: - explicit BenchQuickOpen(QObject* parent = 0); + explicit BenchQuickOpen(QObject* parent = nullptr); private: void getData(); private slots: void benchProjectFileFilter_addRemoveProject(); void benchProjectFileFilter_addRemoveProject_data(); void benchProjectFileFilter_reset(); void benchProjectFileFilter_reset_data(); void benchProjectFileFilter_setFilter(); void benchProjectFileFilter_setFilter_data(); void benchProjectFileFilter_providerData(); void benchProjectFileFilter_providerData_data(); void benchProjectFileFilter_providerDataIcon(); void benchProjectFileFilter_providerDataIcon_data(); }; #endif // KDEVPLATFORM_PLUGIN_BENCH_QUICKOPEN_H diff --git a/plugins/quickopen/tests/quickopentestbase.h b/plugins/quickopen/tests/quickopentestbase.h index f40a849c63..f71f464afc 100644 --- a/plugins/quickopen/tests/quickopentestbase.h +++ b/plugins/quickopen/tests/quickopentestbase.h @@ -1,82 +1,82 @@ /* * Copyright Milian Wolff * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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, see . */ #ifndef KDEVPLATFORM_PLUGIN_QUICKOPENTESTBASE_H #define KDEVPLATFORM_PLUGIN_QUICKOPENTESTBASE_H #include #include #include #include #include #include "../duchainitemquickopen.h" #include "../projectfilequickopen.h" class QuickOpenTestBase : public QObject { Q_OBJECT public: - explicit QuickOpenTestBase(KDevelop::TestCore::Setup setup, QObject* parent = 0); + explicit QuickOpenTestBase(KDevelop::TestCore::Setup setup, QObject* parent = nullptr); private slots: void initTestCase(); void cleanupTestCase(); void cleanup(); protected: KDevelop::TestCore* core; KDevelop::TestCore::Setup setup; KDevelop::TestProjectController* projectController; }; class PathTestFilter : public KDevelop::PathFilter { public: KDevelop::Path itemPath(const QString& data) const { return KDevelop::Path(data); } }; KDevelop::TestProject* getProjectWithFiles(int files); template T* createChild(KDevelop::ProjectFolderItem* parent, const QString& childName) { return new T(childName, parent); } QStringList items(const ProjectFileDataProvider& provider); class TestFilter : public KDevelop::Filter { public: QString itemText(const DUChainItem &data) const override { return data.m_text; }; }; Q_DECLARE_METATYPE(QList) #endif // KDEVPLATFORM_PLUGIN_QUICKOPENTESTBASE_H diff --git a/plugins/quickopen/tests/test_quickopen.h b/plugins/quickopen/tests/test_quickopen.h index 171aa6daa8..fd0ac0aebd 100644 --- a/plugins/quickopen/tests/test_quickopen.h +++ b/plugins/quickopen/tests/test_quickopen.h @@ -1,42 +1,42 @@ /* * Copyright Milian Wolff * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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, see . */ #ifndef KDEVPLATFORM_PLUGIN_TEST_QUICKOPEN_H #define KDEVPLATFORM_PLUGIN_TEST_QUICKOPEN_H #include "quickopentestbase.h" class TestQuickOpen : public QuickOpenTestBase { Q_OBJECT public: - explicit TestQuickOpen(QObject* parent = 0); + explicit TestQuickOpen(QObject* parent = nullptr); private slots: void testSorting(); void testSorting_data(); void testAbbreviations(); void testAbbreviations_data(); void testDuchainFilter(); void testDuchainFilter_data(); void testProjectFileFilter(); }; #endif // KDEVPLATFORM_PLUGIN_TEST_QUICKOPEN_H diff --git a/plugins/standardoutputview/standardoutputview.h b/plugins/standardoutputview/standardoutputview.h index fbc29f3581..be55333e71 100644 --- a/plugins/standardoutputview/standardoutputview.h +++ b/plugins/standardoutputview/standardoutputview.h @@ -1,94 +1,94 @@ /* 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. */ #ifndef KDEVPLATFORM_PLUGIN_STANDARDOUTPUTVIEW_H #define KDEVPLATFORM_PLUGIN_STANDARDOUTPUTVIEW_H #include #include #include template class QList; class QAbstractItemModel; class QString; class QModelIndex; class QAbstractItemDelegate; class OutputWidget; class ToolViewData; /** @author Andreas Pakulat */ namespace Sublime { class View; } class StandardOutputView : public KDevelop::IPlugin, public KDevelop::IOutputView { Q_OBJECT Q_INTERFACES( KDevelop::IOutputView ) public: - explicit StandardOutputView(QObject *parent = 0, const QVariantList &args = QVariantList()); + explicit StandardOutputView(QObject *parent = nullptr, const QVariantList &args = QVariantList()); ~StandardOutputView() override; int standardToolView( KDevelop::IOutputView::StandardToolView view ) override; int registerToolView( const QString& title, KDevelop::IOutputView::ViewType type = KDevelop::IOutputView::OneView, const QIcon& icon = QIcon(), KDevelop::IOutputView::Options option = ShowItemsButton, const QList& actionList = QList()) override; int registerOutputInToolView( int toolviewId, const QString& title, KDevelop::IOutputView::Behaviours behaviour = KDevelop::IOutputView::AllowUserClose ) override; void raiseOutput( int id ) override; void setModel( int outputId, QAbstractItemModel* model ) override; void setDelegate( int outputId, QAbstractItemDelegate* delegate ) override; OutputWidget* outputWidgetForId( int outputId ) const; void removeToolView( int toolviewId ) override; void removeOutput( int outputId ) override; void scrollOutputTo( int outputId, const QModelIndex& idx ) override; void setTitle(int outputId, const QString& title) override; public Q_SLOTS: void removeSublimeView( Sublime::View* ); Q_SIGNALS: void activated( const QModelIndex& ); void outputRemoved( int toolviewId, int outputId ); void toolViewRemoved( int toolviewId ); private: QMap toolviews; QList ids; QMap standardViews; }; #endif // KDEVPLATFORM_PLUGIN_STANDARDOUTPUTVIEW_H diff --git a/plugins/subversion/svnaddjob_p.h b/plugins/subversion/svnaddjob_p.h index 8709c3f3c9..09fdf02f37 100644 --- a/plugins/subversion/svnaddjob_p.h +++ b/plugins/subversion/svnaddjob_p.h @@ -1,44 +1,44 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_SVNADDJOB_P_H #define KDEVPLATFORM_PLUGIN_SVNADDJOB_P_H #include "svninternaljobbase.h" class SvnInternalAddJob : public SvnInternalJobBase { Q_OBJECT public: - explicit SvnInternalAddJob( SvnJobBase* parent = 0 ); + explicit SvnInternalAddJob( SvnJobBase* parent = nullptr ); void setLocations( const QList& ); void setRecursive( bool ); bool recursive() const; QList locations() const; protected: void run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread* thread) override; private: QList m_locations; bool m_recursive; }; #endif diff --git a/plugins/subversion/svnblamejob_p.h b/plugins/subversion/svnblamejob_p.h index ca0846b8b6..0488d7324b 100644 --- a/plugins/subversion/svnblamejob_p.h +++ b/plugins/subversion/svnblamejob_p.h @@ -1,59 +1,59 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_SVNBLAMEJOB_P_H #define KDEVPLATFORM_PLUGIN_SVNBLAMEJOB_P_H #include "svninternaljobbase.h" #include #include namespace KDevelop { class VcsAnnotationLine; } class QUrl; class SvnInternalBlameJob : public SvnInternalJobBase { Q_OBJECT public: - explicit SvnInternalBlameJob( SvnJobBase* parent = 0 ); + explicit SvnInternalBlameJob( SvnJobBase* parent = nullptr ); void setLocation( const QUrl &location ); void setEndRevision( const KDevelop::VcsRevision& rev ); void setStartRevision( const KDevelop::VcsRevision& rev ); QUrl location() const; KDevelop::VcsRevision startRevision() const; KDevelop::VcsRevision endRevision() const; signals: void blameLine( const KDevelop::VcsAnnotationLine& ); protected: void run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread* thread) override; private: QUrl m_location; KDevelop::VcsRevision m_startRevision; KDevelop::VcsRevision m_endRevision; }; #endif diff --git a/plugins/subversion/svncatjob_p.h b/plugins/subversion/svncatjob_p.h index 75c1f63847..da2d3aa5bb 100644 --- a/plugins/subversion/svncatjob_p.h +++ b/plugins/subversion/svncatjob_p.h @@ -1,53 +1,53 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_SVNCATJOB_P_H #define KDEVPLATFORM_PLUGIN_SVNCATJOB_P_H #include "svninternaljobbase.h" #include #include class SvnInternalCatJob : public SvnInternalJobBase { Q_OBJECT public: - explicit SvnInternalCatJob( SvnJobBase* parent = 0 ); + explicit SvnInternalCatJob( SvnJobBase* parent = nullptr ); void setSource( const KDevelop::VcsLocation& ); void setSrcRevision( const KDevelop::VcsRevision& ); void setPegRevision( const KDevelop::VcsRevision& ); KDevelop::VcsLocation source() const; KDevelop::VcsRevision srcRevision() const; KDevelop::VcsRevision pegRevision() const; signals: void gotContent( const QString& ); protected: void run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread* thread) override; private: KDevelop::VcsLocation m_source; KDevelop::VcsRevision m_srcRevision; KDevelop::VcsRevision m_pegRevision; }; #endif diff --git a/plugins/subversion/svncheckoutjob_p.h b/plugins/subversion/svncheckoutjob_p.h index 9a0933dc37..20dab76f2f 100644 --- a/plugins/subversion/svncheckoutjob_p.h +++ b/plugins/subversion/svncheckoutjob_p.h @@ -1,49 +1,49 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_SVNCHECKOUTJOB_P_H #define KDEVPLATFORM_PLUGIN_SVNCHECKOUTJOB_P_H #include "svninternaljobbase.h" #include class SvnInternalCheckoutJob : public SvnInternalJobBase { Q_OBJECT public: - explicit SvnInternalCheckoutJob( SvnJobBase* parent = 0 ); + explicit SvnInternalCheckoutJob( SvnJobBase* parent = nullptr ); void setMapping(const KDevelop::VcsLocation & sourceRepository, const QUrl &destinationDirectory, KDevelop::IBasicVersionControl::RecursionMode recursion); bool isValid() const; KDevelop::VcsLocation source() const; QUrl destination() const; KDevelop::IBasicVersionControl::RecursionMode recursion() const; protected: void run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread* thread) override; private: KDevelop::VcsLocation m_sourceRepository; QUrl m_destinationDirectory; KDevelop::IBasicVersionControl::RecursionMode m_recursion; }; #endif diff --git a/plugins/subversion/svnclient.h b/plugins/subversion/svnclient.h index 25d7b63ff5..77388bf7a5 100644 --- a/plugins/subversion/svnclient.h +++ b/plugins/subversion/svnclient.h @@ -1,71 +1,71 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_SVNCLIENT_H #define KDEVPLATFORM_PLUGIN_SVNCLIENT_H #include #include #include "kdevsvncpp/path.hpp" #include "kdevsvncpp/revision.hpp" #include "kdevsvncpp/client.hpp" #include namespace KDevelop { class VcsAnnotationLine; } class SvnClient : public QObject, public svn::Client { Q_OBJECT public: - explicit SvnClient( svn::Context* = 0 ); + explicit SvnClient( svn::Context* = nullptr ); QString diff( const svn::Path& src, const svn::Revision& srcRev, const svn::Path& dst, const svn::Revision& dstRev, const bool recurse, const bool ignoreAncestry, const bool noDiffDeleted, const bool ignoreContentType ) throw (svn::ClientException); QString diff( const svn::Path& src, const svn::Revision& pegRev, const svn::Revision& srcRev, const svn::Revision& dstRev, const bool recurse, const bool ignoreAncestry, const bool noDiffDeleted, const bool ignoreContentType ) throw (svn::ClientException); void log( const char* path, const svn::Revision& start, const svn::Revision& end, int limit, bool discoverChangedPaths = false, bool strictNodeHistory = true ) throw (svn::ClientException); void emitLogEventReceived( const KDevelop::VcsEvent& ); signals: void logEventReceived( const KDevelop::VcsEvent& ); private: svn::Context* m_ctxt; }; #endif diff --git a/plugins/subversion/svncommitjob_p.h b/plugins/subversion/svncommitjob_p.h index 95bad2982e..7f9b24ab7a 100644 --- a/plugins/subversion/svncommitjob_p.h +++ b/plugins/subversion/svncommitjob_p.h @@ -1,56 +1,56 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 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 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_SVNCOMMITJOB_P_H #define KDEVPLATFORM_PLUGIN_SVNCOMMITJOB_P_H #include #include #include "svninternaljobbase.h" class SvnJobBase; class SvnInternalCommitJob : public SvnInternalJobBase { Q_OBJECT public: - explicit SvnInternalCommitJob( SvnJobBase* parent = 0 ); + explicit SvnInternalCommitJob( SvnJobBase* parent = nullptr ); void setRecursive( bool ); void setCommitMessage( const QString& ); void setUrls( const QList& ); void setKeepLock( bool ); QList urls() const; QString commitMessage() const; bool recursive() const; bool keepLock() const; protected: void run(ThreadWeaver::JobPointer job, ThreadWeaver::Thread* thread) override; private: QList m_urls; bool m_recursive; bool m_keepLock; }; #endif diff --git a/plugins/subversion/svncopyjob_p.h b/plugins/subversion/svncopyjob_p.h index 5929859d36..5f1a555523 100644 --- a/plugins/subversion/svncopyjob_p.h +++ b/plugins/subversion/svncopyjob_p.h @@ -1,44 +1,44 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_SVNCOPYJOB_P_H #define KDEVPLATFORM_PLUGIN_SVNCOPYJOB_P_H #include "svninternaljobbase.h" class SvnInternalCopyJob : public SvnInternalJobBase { Q_OBJECT public: - explicit SvnInternalCopyJob( SvnJobBase* parent = 0 ); + explicit SvnInternalCopyJob( SvnJobBase* parent = nullptr ); void setSourceLocation( const QUrl& ); void setDestinationLocation( const QUrl& ); QUrl sourceLocation() const; QUrl destinationLocation() const; protected: void run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread* thread) override; private: QUrl m_sourceLocation; QUrl m_destinationLocation; }; #endif diff --git a/plugins/subversion/svndiffjob_p.h b/plugins/subversion/svndiffjob_p.h index 9195732f6b..f2926a676c 100644 --- a/plugins/subversion/svndiffjob_p.h +++ b/plugins/subversion/svndiffjob_p.h @@ -1,71 +1,71 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_SVNDIFFJOB_P_H #define KDEVPLATFORM_PLUGIN_SVNDIFFJOB_P_H #include "svninternaljobbase.h" #include #include class SvnInternalDiffJob : public SvnInternalJobBase { Q_OBJECT public: - explicit SvnInternalDiffJob( SvnJobBase* parent = 0 ); + explicit SvnInternalDiffJob( SvnJobBase* parent = nullptr ); void setSource( const KDevelop::VcsLocation& ); void setDestination( const KDevelop::VcsLocation& ); void setSrcRevision( const KDevelop::VcsRevision& ); void setDstRevision( const KDevelop::VcsRevision& ); void setPegRevision( const KDevelop::VcsRevision& ); void setRecursive( bool ); void setIgnoreAncestry( bool ); void setIgnoreContentType( bool ); void setNoDiffOnDelete( bool ); bool recursive() const; bool ignoreAncestry() const; bool ignoreContentType() const; bool noDiffOnDelete() const; KDevelop::VcsLocation source() const; KDevelop::VcsLocation destination() const; KDevelop::VcsRevision srcRevision() const; KDevelop::VcsRevision dstRevision() const; KDevelop::VcsRevision pegRevision() const; signals: void gotDiff( const QString& ); protected: void run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread* thread) override; private: KDevelop::VcsLocation m_source; KDevelop::VcsLocation m_destination; KDevelop::VcsRevision m_srcRevision; KDevelop::VcsRevision m_dstRevision; KDevelop::VcsRevision m_pegRevision; bool m_recursive; bool m_ignoreAncestry; bool m_ignoreContentType; bool m_noDiffOnDelete; }; #endif diff --git a/plugins/subversion/svnimportjob_p.h b/plugins/subversion/svnimportjob_p.h index a7fdaa4c86..4430f75f0c 100644 --- a/plugins/subversion/svnimportjob_p.h +++ b/plugins/subversion/svnimportjob_p.h @@ -1,46 +1,46 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_SVNIMPORTJOB_P_H #define KDEVPLATFORM_PLUGIN_SVNIMPORTJOB_P_H #include "svninternaljobbase.h" #include class SvnImportInternalJob : public SvnInternalJobBase { Q_OBJECT public: - explicit SvnImportInternalJob( SvnJobBase* parent = 0 ); + explicit SvnImportInternalJob( SvnJobBase* parent = nullptr ); void setMapping( const QUrl &sourceDirectory, const KDevelop::VcsLocation & destinationRepository); void setMessage( const QString& ); QString message() const; bool isValid() const; QUrl source() const; protected: void run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread* thread) override; private: QUrl m_sourceDirectory; KDevelop::VcsLocation m_destinationRepository; QString m_message; }; #endif diff --git a/plugins/subversion/svninfojob_p.h b/plugins/subversion/svninfojob_p.h index 1459fef1e8..6a2df8896e 100644 --- a/plugins/subversion/svninfojob_p.h +++ b/plugins/subversion/svninfojob_p.h @@ -1,45 +1,45 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_SVNINFOJOB_P_H #define KDEVPLATFORM_PLUGIN_SVNINFOJOB_P_H #include "svninternaljobbase.h" #include "svninfojob.h" class SvnInternalInfoJob : public SvnInternalJobBase { Q_OBJECT public: - explicit SvnInternalInfoJob( SvnJobBase* parent = 0 ); + explicit SvnInternalInfoJob( SvnJobBase* parent = nullptr ); void setLocation( const QUrl& ); QUrl location() const; signals: void gotInfo( const SvnInfoHolder& ); protected: void run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread* thread) override; private: QUrl m_location; }; #endif diff --git a/plugins/subversion/svninternaljobbase.h b/plugins/subversion/svninternaljobbase.h index 5ef8e7a0b8..7ab71f926a 100644 --- a/plugins/subversion/svninternaljobbase.h +++ b/plugins/subversion/svninternaljobbase.h @@ -1,129 +1,129 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 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 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_SVNINTERNALJOBBASE_H #define KDEVPLATFORM_PLUGIN_SVNINTERNALJOBBASE_H #include #include #include #include extern "C" { #include } #include "kdevsvncpp/context_listener.hpp" namespace KDevelop { class VcsRevision; } namespace svn { class Context; class Revision; } class SvnJobBase; class QMutex; class QSemaphore; class SvnInternalJobBase : public QObject, public ThreadWeaver::Job, public svn::ContextListener { Q_OBJECT public: - explicit SvnInternalJobBase( SvnJobBase* parent = 0 ); + explicit SvnInternalJobBase( SvnJobBase* parent = nullptr ); ~SvnInternalJobBase() override; bool success() const override; bool contextGetLogin( const std::string& realm, std::string& username, std::string& password, bool& maySave ) override; void contextNotify( const char* path, svn_wc_notify_action_t action, svn_node_kind_t kind, const char* mimetype, svn_wc_notify_state_t contentState, svn_wc_notify_state_t propState, svn_revnum_t rev ) override; bool contextCancel() override; bool contextGetLogMessage( std::string& msg ) override; svn::ContextListener::SslServerTrustAnswer contextSslServerTrustPrompt( const svn::ContextListener::SslServerTrustData& data, apr_uint32_t& acceptedFailures ) override; bool contextSslClientCertPrompt( std::string& cert ) override; bool contextSslClientCertPwPrompt( std::string& pw, const std::string& realm, bool& maySave ) override; void initBeforeRun(); void kill(); bool wasKilled(); QString errorMessage() const; svn::Context* m_ctxt; QSemaphore m_guiSemaphore; QString m_login_username; QString m_login_password; bool m_maySave; QString m_commitMessage; svn::ContextListener::SslServerTrustAnswer m_trustAnswer; static svn::Revision createSvnCppRevisionFromVcsRevision( const KDevelop::VcsRevision& ); signals: void needLogin( const QString& ); void showNotification( const QString&, const QString& ); void needCommitMessage(); void needSslServerTrust( const QStringList&, const QString&, const QString&, const QString&, const QString&, const QString&, const QString& ); void needSslClientCert( const QString& ); void needSslClientCertPassword( const QString& ); /** This signal is emitted when this job is being processed by a thread. */ void started(); /** This signal is emitted when the job has been finished (no matter if it succeeded or not). */ void done(); /** This job has failed. * * This signal is emitted when success() returns false after the job is executed. */ void failed(); protected: void defaultBegin(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; void defaultEnd(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; mutable QMutex m_mutex; mutable QMutex m_killMutex; bool m_success; void setErrorMessage( const QString& ); private: bool sendFirstDelta; bool killed; QString m_errorMessage; }; #endif diff --git a/plugins/subversion/svnlocationwidget.h b/plugins/subversion/svnlocationwidget.h index 6b8c5f0eba..a1559456c5 100644 --- a/plugins/subversion/svnlocationwidget.h +++ b/plugins/subversion/svnlocationwidget.h @@ -1,26 +1,26 @@ /*************************************************************************** * Copyright 2010 Aleix Pol Gonzalez * * * * 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. * * * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_SVNLOCATIONWIDGET_H #define KDEVPLATFORM_PLUGIN_SVNLOCATIONWIDGET_H #include class SvnLocationWidget : public KDevelop::StandardVcsLocationWidget { Q_OBJECT public: - explicit SvnLocationWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - virtual KDevelop::VcsLocation location() const override; - virtual bool isCorrect() const override; + explicit SvnLocationWidget(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); + KDevelop::VcsLocation location() const override; + bool isCorrect() const override; }; #endif // KDEVPLATFORM_PLUGIN_SVNLOCATIONWIDGET_H diff --git a/plugins/subversion/svnlogjob_p.h b/plugins/subversion/svnlogjob_p.h index 968bf21a5e..4f9d3f4e2d 100644 --- a/plugins/subversion/svnlogjob_p.h +++ b/plugins/subversion/svnlogjob_p.h @@ -1,57 +1,57 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_SVNLOGJOB_P_H #define KDEVPLATFORM_PLUGIN_SVNLOGJOB_P_H #include "svninternaljobbase.h" #include #include class SvnInternalLogJob : public SvnInternalJobBase { Q_OBJECT public: - explicit SvnInternalLogJob( SvnJobBase* parent = 0 ); + explicit SvnInternalLogJob( SvnJobBase* parent = nullptr ); void setLocation( const QUrl &location ); void setLimit( int limit ); void setEndRevision( const KDevelop::VcsRevision& rev ); void setStartRevision( const KDevelop::VcsRevision& rev ); QUrl location() const; KDevelop::VcsRevision startRevision() const; KDevelop::VcsRevision endRevision() const; int limit() const; signals: void logEvent( const KDevelop::VcsEvent& ); protected: void run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread* thread) override; private: QUrl m_location; int m_limit; KDevelop::VcsRevision m_startRevision; KDevelop::VcsRevision m_endRevision; }; #endif diff --git a/plugins/subversion/svnmovejob_p.h b/plugins/subversion/svnmovejob_p.h index 49d88fa1d6..994701ef8e 100644 --- a/plugins/subversion/svnmovejob_p.h +++ b/plugins/subversion/svnmovejob_p.h @@ -1,47 +1,47 @@ /*************************************************************************** * This file is part of KDevelop * * Moveright 2007 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_SVNMOVEJOB_P_H #define KDEVPLATFORM_PLUGIN_SVNMOVEJOB_P_H #include "svninternaljobbase.h" class SvnInternalMoveJob : public SvnInternalJobBase { Q_OBJECT public: - explicit SvnInternalMoveJob( SvnJobBase* parent = 0 ); + explicit SvnInternalMoveJob( SvnJobBase* parent = nullptr ); void setSourceLocation( const QUrl& ); void setDestinationLocation( const QUrl& ); void setForce( bool ); QUrl sourceLocation() const; QUrl destinationLocation() const; bool force() const; protected: void run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread* thread) override; private: QUrl m_sourceLocation; QUrl m_destinationLocation; bool m_force; }; #endif diff --git a/plugins/subversion/svnremovejob_p.h b/plugins/subversion/svnremovejob_p.h index 353f572b2b..3a7a40fd89 100644 --- a/plugins/subversion/svnremovejob_p.h +++ b/plugins/subversion/svnremovejob_p.h @@ -1,47 +1,47 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_SVNREMOVEJOB_P_H #define KDEVPLATFORM_PLUGIN_SVNREMOVEJOB_P_H #include "svninternaljobbase.h" class SvnInternalRemoveJob : public SvnInternalJobBase { Q_OBJECT public: - explicit SvnInternalRemoveJob( SvnJobBase* parent = 0 ); + explicit SvnInternalRemoveJob( SvnJobBase* parent = nullptr ); void setLocations( const QList& ); void setForce( bool ); QList locations() const; bool force() const; protected: void run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread* thread) override; private: QList m_locations; bool m_force; }; #endif diff --git a/plugins/subversion/svnrevertjob_p.h b/plugins/subversion/svnrevertjob_p.h index 5494e365c6..dcabad8ea9 100644 --- a/plugins/subversion/svnrevertjob_p.h +++ b/plugins/subversion/svnrevertjob_p.h @@ -1,44 +1,44 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_SVNREVERTJOB_P_H #define KDEVPLATFORM_PLUGIN_SVNREVERTJOB_P_H #include "svninternaljobbase.h" class SvnInternalRevertJob : public SvnInternalJobBase { Q_OBJECT public: - explicit SvnInternalRevertJob( SvnJobBase* parent = 0 ); + explicit SvnInternalRevertJob( SvnJobBase* parent = nullptr ); void setLocations( const QList& ); void setRecursive( bool ); bool recursive() const; QList locations() const; protected: void run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread* thread) override; private: QList m_locations; bool m_recursive; }; #endif diff --git a/plugins/subversion/svnssldialog.h b/plugins/subversion/svnssldialog.h index b092f8ca41..f5f9ad2800 100644 --- a/plugins/subversion/svnssldialog.h +++ b/plugins/subversion/svnssldialog.h @@ -1,36 +1,36 @@ /*************************************************************************** * 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. * * * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_SVN_SSLDIALOG_H #define KDEVPLATFORM_PLUGIN_SVN_SSLDIALOG_H #include #include class SvnSSLTrustDialog: public QDialog { Q_OBJECT public: - explicit SvnSSLTrustDialog( QWidget *parent = 0 ); + explicit SvnSSLTrustDialog( QWidget *parent = nullptr ); ~SvnSSLTrustDialog() override; void setCertInfos( const QString& hostname, const QString& fingerPrint, const QString& validfrom, const QString& validuntil, const QString& issuerName, const QString& realm, const QStringList& failures ); bool useTemporarily(); private slots: void buttonClicked(QAbstractButton *button); private: class SvnSSLTrustDialogPrivate *d; QDialogButtonBox *buttonBox; }; #endif diff --git a/plugins/subversion/svnstatusjob_p.h b/plugins/subversion/svnstatusjob_p.h index 7974fe5c53..488f98d4e0 100644 --- a/plugins/subversion/svnstatusjob_p.h +++ b/plugins/subversion/svnstatusjob_p.h @@ -1,51 +1,51 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_SVNSTATUSJOB_P_H #define KDEVPLATFORM_PLUGIN_SVNSTATUSJOB_P_H #include "svninternaljobbase.h" #include #include #include class SvnInternalStatusJob : public SvnInternalJobBase { Q_OBJECT public: - explicit SvnInternalStatusJob( SvnJobBase* parent = 0 ); + explicit SvnInternalStatusJob( SvnJobBase* parent = nullptr ); void setLocations( const QList& ); void setRecursive( bool ); bool recursive() const; QList locations() const; signals: void gotNewStatus( const KDevelop::VcsStatusInfo& ); protected: void run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread* thread) override; private: QList m_locations; bool m_recursive; }; #endif diff --git a/plugins/subversion/svnupdatejob_p.h b/plugins/subversion/svnupdatejob_p.h index d57b84062c..11e85d124b 100644 --- a/plugins/subversion/svnupdatejob_p.h +++ b/plugins/subversion/svnupdatejob_p.h @@ -1,50 +1,50 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_SVNUPDATEJOB_P_H #define KDEVPLATFORM_PLUGIN_SVNUPDATEJOB_P_H #include "svninternaljobbase.h" class SvnInternalUpdateJob : public SvnInternalJobBase { Q_OBJECT public: - explicit SvnInternalUpdateJob( SvnJobBase* parent = 0 ); + explicit SvnInternalUpdateJob( SvnJobBase* parent = nullptr ); void setLocations( const QList& ); void setRecursive( bool ); void setRevision( const KDevelop::VcsRevision& ); void setIgnoreExternals( bool ); bool recursive() const; QList locations() const; KDevelop::VcsRevision revision() const; bool ignoreExternals() const; protected: void run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread* thread) override; private: QList m_locations; bool m_recursive; bool m_ignoreExternals; KDevelop::VcsRevision m_revision; }; #endif diff --git a/plugins/testview/testview.h b/plugins/testview/testview.h index b4efbc27f3..b745dedc0a 100644 --- a/plugins/testview/testview.h +++ b/plugins/testview/testview.h @@ -1,71 +1,71 @@ /* This file is part of KDevelop Copyright 2012 Miha Čančula 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; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KDEVPLATFORM_PLUGIN_TESTVIEW_H #define KDEVPLATFORM_PLUGIN_TESTVIEW_H #include #include #include class QSortFilterProxyModel; class QStandardItem; class TestViewPlugin; class QStandardItemModel; namespace KDevelop { class ITestSuite; } class TestView : public QWidget { Q_OBJECT public: - explicit TestView(TestViewPlugin* plugin, QWidget* parent = 0); + explicit TestView(TestViewPlugin* plugin, QWidget* parent = nullptr); ~TestView() override; public slots: void runSelectedTests(); void showSource(); void addTestSuite(KDevelop::ITestSuite* suite); void removeTestSuite(KDevelop::ITestSuite* suite); void updateTestSuite(KDevelop::ITestSuite* suite, const KDevelop::TestResult& result); void notifyTestCaseStarted(KDevelop::ITestSuite* suite, const QStringList& test_cases); QStandardItem* addProject(KDevelop::IProject* project); void removeProject(KDevelop::IProject* project); void doubleClicked(const QModelIndex& index); QList contextMenuActions(); private: void changeFilter(const QString &newFilter); TestViewPlugin* m_plugin; QStandardItemModel* m_model; QTreeView* m_tree; QSortFilterProxyModel* m_filter; QList m_contextMenuActions; QIcon iconForTestResult(KDevelop::TestResult::TestCaseResult result); QStandardItem* itemForSuite(KDevelop::ITestSuite* suite); QStandardItem* itemForProject(KDevelop::IProject* project); }; #endif // KDEVPLATFORM_PLUGIN_TESTVIEW_H diff --git a/plugins/vcschangesview/vcschangesview.cpp b/plugins/vcschangesview/vcschangesview.cpp index 16cbb344a5..5956218836 100644 --- a/plugins/vcschangesview/vcschangesview.cpp +++ b/plugins/vcschangesview/vcschangesview.cpp @@ -1,176 +1,180 @@ /* * This file is part of KDevelop * Copyright 2010 Aleix Pol Gonzalez * * 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 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 "vcschangesview.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "vcschangesviewplugin.h" using namespace KDevelop; VcsChangesView::VcsChangesView(VcsProjectIntegrationPlugin* plugin, QWidget* parent) : QTreeView(parent) { setRootIsDecorated(false); setEditTriggers(QAbstractItemView::NoEditTriggers); setSelectionMode(ContiguousSelection); setContextMenuPolicy(Qt::CustomContextMenu); setTextElideMode(Qt::ElideLeft); setWordWrap(true); setWindowIcon(QIcon::fromTheme(QStringLiteral("exchange-positions"), windowIcon())); connect(this, &VcsChangesView::customContextMenuRequested, this, &VcsChangesView::popupContextMenu); foreach(QAction* action, plugin->actionCollection()->actions()) addAction(action); QAction* action = plugin->actionCollection()->action(QStringLiteral("locate_document")); connect(action, &QAction::triggered, this, &VcsChangesView::selectCurrentDocument); connect(this, &VcsChangesView::doubleClicked, this, &VcsChangesView::openSelected); } static void appendActions(QMenu* menu, const QList& actions) { menu->addSeparator(); menu->addActions(actions); } void VcsChangesView::popupContextMenu( const QPoint &pos ) { QList urls; QList projects; QModelIndexList selectionIdxs = selectedIndexes(); if(selectionIdxs.isEmpty()) return; foreach(const QModelIndex& idx, selectionIdxs) { if(idx.column()==0) { if(idx.parent().isValid()) urls += idx.data(KDevelop::VcsFileChangesModel::VcsStatusInfoRole).value().url(); else { - projects += ICore::self()->projectController()->findProjectByName(idx.data(ProjectChangesModel::ProjectNameRole).toString()); - Q_ASSERT(projects.last()); + IProject* project = ICore::self()->projectController()->findProjectByName(idx.data(ProjectChangesModel::ProjectNameRole).toString()); + if (project) { + projects += project; + } else { + qWarning() << "Couldn't find a project for project: " << idx.data(ProjectChangesModel::ProjectNameRole).toString(); + } } } } QPointer menu = new QMenu; QAction* refreshAction = menu->addAction(QIcon::fromTheme(QStringLiteral("view-refresh")), i18n("Refresh")); QList extensions; if(!urls.isEmpty()) { KDevelop::FileContext context(urls); extensions = ICore::self()->pluginController()->queryPluginsForContextMenuExtensions( &context ); } else { QList items; foreach(IProject* p, projects) items += p->projectItem(); KDevelop::ProjectItemContextImpl context(items); extensions = ICore::self()->pluginController()->queryPluginsForContextMenuExtensions( &context ); } QList buildActions; QList vcsActions; QList extActions; QList projectActions; QList fileActions; QList runActions; foreach( const ContextMenuExtension& ext, extensions ) { buildActions += ext.actions(ContextMenuExtension::BuildGroup); fileActions += ext.actions(ContextMenuExtension::FileGroup); projectActions += ext.actions(ContextMenuExtension::ProjectGroup); vcsActions += ext.actions(ContextMenuExtension::VcsGroup); extActions += ext.actions(ContextMenuExtension::ExtensionGroup); runActions += ext.actions(ContextMenuExtension::RunGroup); } appendActions(menu, buildActions); appendActions(menu, runActions ); appendActions(menu, fileActions); appendActions(menu, vcsActions); appendActions(menu, extActions); appendActions(menu, projectActions); if ( !menu->isEmpty() ) { QAction* res = menu->exec( mapToGlobal( pos ) ); if(res == refreshAction) { if(!urls.isEmpty()) emit reload(urls); else emit reload(projects); } } delete menu; } void VcsChangesView::selectCurrentDocument() { IDocument* doc = ICore::self()->documentController()->activeDocument(); if(!doc) return; QUrl url = doc->url(); IProject* p = ICore::self()->projectController()->findProjectForUrl(url); QModelIndex idx = (p ? model()->match(model()->index(0, 0), ProjectChangesModel::UrlRole, url, 1, Qt::MatchExactly).value(0) : QModelIndex()); if(idx.isValid()) { expand(idx.parent()); setCurrentIndex(idx); } else collapseAll(); } void VcsChangesView::setModel(QAbstractItemModel* model) { connect(model, &QAbstractItemModel::rowsInserted, this, &VcsChangesView::expand); QTreeView::setModel(model); } void VcsChangesView::openSelected(const QModelIndex& index) { if(!index.parent().isValid()) //then it's a project return; QModelIndex idx = index.sibling(index.row(), 1); VcsStatusInfo info = idx.data(ProjectChangesModel::VcsStatusInfoRole).value(); QUrl url = info.url(); ICore::self()->documentController()->openDocument(url); } diff --git a/plugins/vcschangesview/vcschangesview.h b/plugins/vcschangesview/vcschangesview.h index fb5ad4382b..166474dc75 100644 --- a/plugins/vcschangesview/vcschangesview.h +++ b/plugins/vcschangesview/vcschangesview.h @@ -1,48 +1,48 @@ /* * This file is part of KDevelop * Copyright 2010 Aleix Pol Gonzalez * * 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 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. */ #ifndef KDEVPLATFORM_PLUGIN_VCSCHANGESVIEW_H #define KDEVPLATFORM_PLUGIN_VCSCHANGESVIEW_H #include class VcsProjectIntegrationPlugin; class QUrl; namespace KDevelop { class IProject; } class VcsChangesView : public QTreeView { Q_OBJECT public: - explicit VcsChangesView(VcsProjectIntegrationPlugin* plugin, QWidget* parent = 0); + explicit VcsChangesView(VcsProjectIntegrationPlugin* plugin, QWidget* parent = nullptr); void setModel(QAbstractItemModel* model) override; public slots: void popupContextMenu( const QPoint &pos ); void selectCurrentDocument(); void openSelected(const QModelIndex& idx); signals: void reload(const QList& p); void reload(const QList& p); }; #endif // KDEVPLATFORM_PLUGIN_VCSCHANGESVIEW_H diff --git a/plugins/welcomepage/declarative/icoreobject.h b/plugins/welcomepage/declarative/icoreobject.h index 60ae507762..0e179228e3 100644 --- a/plugins/welcomepage/declarative/icoreobject.h +++ b/plugins/welcomepage/declarative/icoreobject.h @@ -1,38 +1,38 @@ /************************************************************************************* * Copyright (C) 2012 by Aleix Pol * * * * 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 * *************************************************************************************/ #ifndef KDEVPLATFORM_PLUGIN_CURRENTPROJECT_H #define KDEVPLATFORM_PLUGIN_CURRENTPROJECT_H #include namespace KDevelop { class ICore; } class ICoreObject : public QObject { Q_OBJECT Q_PROPERTY(QObject* self READ self CONSTANT) public: - explicit ICoreObject(QObject* parent = 0); + explicit ICoreObject(QObject* parent = nullptr); QObject* self() const; }; #endif // KDEVPLATFORM_PLUGIN_CURRENTPROJECT_H diff --git a/plugins/welcomepage/sessionsmodel.h b/plugins/welcomepage/sessionsmodel.h index e2d28ac93a..22b50d0f3d 100644 --- a/plugins/welcomepage/sessionsmodel.h +++ b/plugins/welcomepage/sessionsmodel.h @@ -1,43 +1,43 @@ /* 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. */ #ifndef SESSIONSMODEL_H #define SESSIONSMODEL_H #include #include class SessionsModel : public QAbstractListModel { Q_OBJECT public: enum Roles { Uuid = Qt::UserRole+1, Projects, ProjectNames, VisibleIdentifier }; - explicit SessionsModel(QObject* parent = 0); + explicit SessionsModel(QObject* parent = nullptr); QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override; QHash< int, QByteArray > roleNames() const override; Q_SCRIPTABLE void loadSession(const QString& nameOrId) const; private: KDevelop::SessionInfos m_sessions; private slots: void sessionDeleted(const QString& id); }; #endif // SESSIONSMODEL_H diff --git a/plugins/welcomepage/welcomepageview.h b/plugins/welcomepage/welcomepageview.h index 2810a52f34..79f54189bc 100644 --- a/plugins/welcomepage/welcomepageview.h +++ b/plugins/welcomepage/welcomepageview.h @@ -1,42 +1,42 @@ /* This file is part of KDevelop Copyright 2011 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. */ #ifndef WELCOMEPAGEVIEW_H #define WELCOMEPAGEVIEW_H #include namespace Sublime { class Area; } namespace KDevelop { class IProject; } class WelcomePageWidget : public QQuickWidget { Q_OBJECT public: - explicit WelcomePageWidget(const QList< KDevelop::IProject* >& projects, QWidget* parent = 0); + explicit WelcomePageWidget(const QList< KDevelop::IProject* >& projects, QWidget* parent = nullptr); public slots: void areaChanged(Sublime::Area* a); }; #endif // WELCOMEPAGEVIEW_H diff --git a/project/abstractfilemanagerplugin.h b/project/abstractfilemanagerplugin.h index d29ab8c096..7bfabaf958 100644 --- a/project/abstractfilemanagerplugin.h +++ b/project/abstractfilemanagerplugin.h @@ -1,149 +1,149 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2010-2012 Milian Wolff * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_ABSTRACTGENERICMANAGER_H #define KDEVPLATFORM_ABSTRACTGENERICMANAGER_H #include "projectexport.h" #include "interfaces/iprojectfilemanager.h" #include #include class KDirWatch; namespace KDevelop { class FileManagerListJob; /** * This class can be used as a common base for file managers. * * It supports remote files using KIO and uses KDirWatch to synchronize with on-disk changes. */ class KDEVPLATFORMPROJECT_EXPORT AbstractFileManagerPlugin : public IPlugin, public virtual IProjectFileManager { Q_OBJECT Q_INTERFACES( KDevelop::IProjectFileManager ) public: - explicit AbstractFileManagerPlugin( const QString& componentName, QObject *parent = 0, + explicit AbstractFileManagerPlugin( const QString& componentName, QObject *parent = nullptr, const QVariantList &args = QVariantList() ); ~AbstractFileManagerPlugin() override; // // IProjectFileManager interface // Features features() const override; ProjectFolderItem* addFolder( const Path& folder, ProjectFolderItem *parent ) override; ProjectFileItem* addFile( const Path& file, ProjectFolderItem *parent ) override; bool removeFilesAndFolders( const QList &items ) override; bool moveFilesAndFolders(const QList< ProjectBaseItem* >& items, ProjectFolderItem* newParent) override; bool copyFilesAndFolders(const Path::List& items, ProjectFolderItem* newParent) override; bool renameFolder(ProjectFolderItem* folder, const Path& newPath) override; bool renameFile(ProjectFileItem* file, const Path& newPath) override; QList parse( ProjectFolderItem *item ) override; ProjectFolderItem *import( IProject *project ) override; bool reload(ProjectFolderItem* item) override; KJob* createImportJob(ProjectFolderItem* item) override; protected: // // AbstractFileManagerPlugin interface // /** * Filter interface making it possible to hide files and folders from a project. * * The default implementation will query all IProjectFilter plugins and ask them * whether a given url should be included or not. * * @return True when @p path should belong to @p project, false otherwise. */ virtual bool isValid(const Path& path, const bool isFolder, IProject* project) const; /** * Customization hook enabling you to create custom FolderItems if required. * * The default implementation will return a simple @c ProjectFolderItem */ virtual ProjectFolderItem* createFolderItem( IProject* project, const Path& path, - ProjectBaseItem* parent = 0); + ProjectBaseItem* parent = nullptr); /** * Customization hook enabling you to create custom FileItems if required. * * The default implementation will return a simple @c ProjectFileItem */ virtual ProjectFileItem* createFileItem( IProject* project, const Path& path, ProjectBaseItem* parent); /** * @return the @c KDirWatch for the given @p project. */ KDirWatch* projectWatcher( IProject* project ) const; /** * Sets a list of filenames to ignore when importing a project * the filter is applied to files and folders, so both will be ignored. * * The filenames are matched via QString::operator==(), so no wildcard or * regex-matching for now * * This can be used for things like VCS-folders/files or other things a * plugin might want to hide. */ void setImportFileNameFilter( const QStringList& filterNames ); private: struct Private; // friend class Private; Private* const d; Q_PRIVATE_SLOT(d, KJob* eventuallyReadFolder( ProjectFolderItem* item )) Q_PRIVATE_SLOT(d, void addJobItems(FileManagerListJob* job, ProjectFolderItem* baseItem, const KIO::UDSEntryList& entries)) Q_PRIVATE_SLOT(d, void deleted(const QString &path)) Q_PRIVATE_SLOT(d, void created(const QString &path)) Q_PRIVATE_SLOT(d, void projectClosing(KDevelop::IProject* project)) Q_PRIVATE_SLOT(d, void jobFinished(KJob* job)) Q_SIGNALS: void reloadedFileItem(KDevelop::ProjectFileItem* file); void reloadedFolderItem(KDevelop::ProjectFolderItem* folder); void folderAdded(KDevelop::ProjectFolderItem* folder); void folderRemoved(KDevelop::ProjectFolderItem* folder); void folderRenamed(const KDevelop::Path& oldFolder, KDevelop::ProjectFolderItem* newFolder); void fileAdded(KDevelop::ProjectFileItem* file); void fileRemoved(KDevelop::ProjectFileItem* file); void fileRenamed(const KDevelop::Path& oldFile, KDevelop::ProjectFileItem* newFile); }; } #endif // KDEVPLATFORM_ABSTRACTGENERICMANAGER_H diff --git a/project/builderjob.h b/project/builderjob.h index ecc77aaa47..1f534d1b25 100644 --- a/project/builderjob.h +++ b/project/builderjob.h @@ -1,121 +1,121 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_BUILDERJOB_H #define KDEVPLATFORM_BUILDERJOB_H #include #include "projectexport.h" #include class KConfigGroup; namespace KDevelop { class ProjectBaseItem; class IProject; /** * Allows to build a list of project items or projects sequentially, where * failing to build one item in the list will fail the whole job. */ class KDEVPLATFORMPROJECT_EXPORT BuilderJob : public ExecuteCompositeJob { Q_OBJECT public: /** * Defines what action to do on the Project builder */ enum BuildType { Build /**< Build the selected items */, Prune /**< Prune the selected items */, Configure /**< Configure the selected items */, Install /**< Install the selected items */, Clean /**< Clean the selected items */ }; /** * Creates a Builder job */ BuilderJob(); ~BuilderJob() override; /** * Allows to easily schedule building a couple of @p items using the * method identified by @p type * * @param type the build method to use * @param items the project items to add */ void addItems( BuildType type, const QList& items ); /** * Allows to easily schedule building a couple of @p projects using the * method identified by @p type * * @param type the build method to use * @param projects the projects to add */ void addProjects( BuildType type, const QList& projects ); /** * Allows to add a single @p item to the end of the list. The item will be * built using the method identified by @p type * * @param item The item to add to the list * @param type The build method to be used for the item */ void addItem( BuildType type, ProjectBaseItem* item ); /** * Allows to add a custom @p job to the end of the list. The build method specified by @p type * and (optionally) an item specified by @p item are needed to create a human-readable job name. * * @param type The build method which is represented by the @p job * @param job The job to add to the list * @param item The item which is build by the @p job */ - void addCustomJob( BuildType type, KJob* job, ProjectBaseItem* item = 0 ); + void addCustomJob( BuildType type, KJob* job, ProjectBaseItem* item = nullptr ); /** * Updates the job's name. * * Shall be called before registering this job in the run controller, but after * adding all required tasks to the job. */ void updateJobName(); /** * Starts this job */ void start() override; private: class BuilderJobPrivate* const d; friend class BuilderJobPrivate; }; } #endif diff --git a/project/interfaces/iprojectbuilder.h b/project/interfaces/iprojectbuilder.h index 6d8fe9eb31..285ec217b3 100644 --- a/project/interfaces/iprojectbuilder.h +++ b/project/interfaces/iprojectbuilder.h @@ -1,127 +1,133 @@ /* This file is part of KDevelop Copyright 2004 Roberto Raggi Copyright 2007 Andreas Pakulat This library 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 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. */ #ifndef KDEVPLATFORM_IPROJECTBUILDER_H #define KDEVPLATFORM_IPROJECTBUILDER_H #include #include #include class KJob; namespace KDevelop { class IProject; class ProjectBaseItem; /** @author Roberto Raggi @short IProjectBuilder Base class for the Project Builders -Describes a Project Builder to KDevelop's Project Manager. +Provides an interface that will bre useful to perform tasks upon projects, +inspired on the unix-style way to build projects: + +configure -> make -> make install + +It will provide a job for each of the tasks and a signal to make sure it +completed successfully. */ class KDEVPLATFORMPROJECT_EXPORT IProjectBuilder { public: virtual ~IProjectBuilder(); /** * Installs the given project @p item, exact behaviour depends * on the implementation. * * @param specificPrefix defines where the project will be installed. */ virtual KJob* install(ProjectBaseItem* item, const QUrl &specificPrefix = {}) = 0; /** * Builds the given project @p item, exact behaviour depends * on the implementation */ virtual KJob* build(ProjectBaseItem *item) = 0; /** * Cleans the given project @p item, exact behaviour depends * on the implementation. The cleaning should only include * output files, like C/C++ object files, binaries, files * that the builder needs shouldn't be removed. */ virtual KJob* clean(ProjectBaseItem *item) = 0; /** * Configures the given @p project, exact behaviour depends * on the implementation. After calling this a build() call should * succeed (given the code doesn't have errors). * * This function is optional, the default implementation does nothing. */ virtual KJob* configure(IProject* project); /** * Prunes the given @p project, exact behaviour depends * on the implementation. Additionally to what clean() does this may * also remove files used for the builder (or a "subbuilder"), for example * generated Makefiles in QMake/CMake/Automake projects * * This function is optional, the default implementation does nothing. */ virtual KJob* prune(IProject* project); /** * Provide access to the builders related to the @p project. * The list returned by this method is used to select the appropriate config pages for a project. * This method may safely return an empty list, as does the default implementation. */ virtual QList additionalBuilderPlugins( IProject* project ) const; Q_SIGNALS: /** * Emitted when the build for the given item was finished */ void built(ProjectBaseItem *dom); /** * Emitted when the install for the given item was finished */ void installed(ProjectBaseItem*); /** * Emitted when the clean for the given item was finished */ void cleaned(ProjectBaseItem*); /** * Emitted when any of the scheduled actions for the given item was failed */ void failed(ProjectBaseItem *dom); /** * Emitted when the configure for the given item was finished */ void configured(IProject*); /** * Emitted when the pruning for the given item was finished */ void pruned(IProject*); }; } Q_DECLARE_INTERFACE( KDevelop::IProjectBuilder, "org.kdevelop.IProjectBuilder" ) #endif diff --git a/project/projectfiltermanager.h b/project/projectfiltermanager.h index acd9c3c0d2..99bbc939d6 100644 --- a/project/projectfiltermanager.h +++ b/project/projectfiltermanager.h @@ -1,100 +1,100 @@ /* This file is part of KDevelop Copyright 2013 Milian Wolff This library 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 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. */ #ifndef KDEVPLATFORM_PROJECTFILTERMANAGER_H #define KDEVPLATFORM_PROJECTFILTERMANAGER_H #include "projectexport.h" #include #include #include namespace KDevelop { class IProjectFilter; class IProjectFilterProvider; class IPlugin; class IProject; class Path; /** * @short A helper class to manage project filtering in file managers. * * Use this class in implementations of IProjectFileManager to simplify * the management of IProjectFilter instances for projects managed by * your file manager. * * NOTE: This interface is _not_ threadsafe. But you can use filtersForProject() * to implement thread safe filtering. * * @author Milian Wolff */ class KDEVPLATFORMPROJECT_EXPORT ProjectFilterManager : public QObject { Q_OBJECT public: - explicit ProjectFilterManager(QObject* parent = 0); + explicit ProjectFilterManager(QObject* parent = nullptr); ~ProjectFilterManager() override; /** * @copydoc IProjectFilter::isValid */ bool isValid(const Path& path, bool isFolder, IProject* project) const; /** * Manage the filters of the given project. */ void add(IProject* project); /** * Remove the managed filters of the given project. */ void remove(IProject* project); /** * TODO: remove this once the cmake manager got cleaned up to not need this * anymore. * * @return true if the project is managed, false otherwise. */ bool isManaged(IProject* project) const; /** * @return the current list of project filters for a given managed project. * * This can be used to implement a thread safe project filtering */ QVector > filtersForProject(IProject* project) const; private: struct Private; QScopedPointer d; Q_PRIVATE_SLOT(d, void pluginLoaded( KDevelop::IPlugin* ) ) Q_PRIVATE_SLOT(d, void unloadingPlugin( KDevelop::IPlugin* ) ) Q_PRIVATE_SLOT(d, void filterChanged( KDevelop::IProjectFilterProvider*, KDevelop::IProject* ) ) }; } #endif // KDEVPLATFORM_PROJECTFILTERMANAGER_H diff --git a/project/projectitemlineedit.h b/project/projectitemlineedit.h index 833fb7fb79..6183815694 100644 --- a/project/projectitemlineedit.h +++ b/project/projectitemlineedit.h @@ -1,84 +1,84 @@ /*************************************************************************** * Copyright 2008 Aleix Pol * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PROJECTITEMLINEEDIT_H #define KDEVPLATFORM_PROJECTITEMLINEEDIT_H #include #include "projectexport.h" namespace KDevelop { class ProjectModel; class ProjectBaseItem; class IProject; } class ProjectItemValidator; class ProjectItemCompleter; class KDEVPLATFORMPROJECT_EXPORT ProjectItemLineEdit : public QLineEdit { Q_OBJECT public: - explicit ProjectItemLineEdit(QWidget* parent=0); + explicit ProjectItemLineEdit(QWidget* parent=nullptr); /** * Sets this lineedit to show the given @p path, eventually removing * parts from the beginning if a base item is set * @note This should be preferred over using setText() */ void setItemPath( const QStringList& path ); /** * Generates a path from the content of the lineedit, including * the base item if present * @returns a path identifying the item selected in this lineedit */ QStringList itemPath() const; /** * Sets @p item as the base item for this lineedit, the user * then doesn't need to specify the path leading to this item * and can just start typing the name of one of the subitems */ void setBaseItem( KDevelop::ProjectBaseItem* item ); /** * @returns the currently used base item */ KDevelop::ProjectBaseItem* baseItem() const; KDevelop::ProjectBaseItem* currentItem() const; void setSuggestion(KDevelop::IProject* project); public slots: bool selectItemDialog(); private slots: void showCtxMenu(const QPoint& p); private: KDevelop::ProjectBaseItem* m_base; ProjectItemCompleter* m_completer; ProjectItemValidator* m_validator; KDevelop::IProject* m_suggestion; }; #endif diff --git a/project/projectmodel.h b/project/projectmodel.h index f67b2d69c6..19f43d772b 100644 --- a/project/projectmodel.h +++ b/project/projectmodel.h @@ -1,492 +1,492 @@ /* This file is part of KDevelop Copyright 2005 Roberto Raggi Copyright 2007 Andreas Pakulat Copyright 2007 Aleix Pol This library 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 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. */ #ifndef KDEVPLATFORM_PROJECTMODEL_H #define KDEVPLATFORM_PROJECTMODEL_H #include #include #include "projectexport.h" #include template struct QPair; template class QList; namespace KDevelop { class IProject; class ProjectFolderItem; class ProjectBuildFolderItem; class ProjectFileItem; class ProjectTargetItem; class ProjectExecutableTargetItem; class ProjectLibraryTargetItem; class ProjectModel; class IndexedString; class Path; /** * Base class to implement the visitor pattern for the project item tree. * * Feel free to subclass it and add overloads for the methods corresponding * to the items you are interested in. * * Start visiting using one of the visit methods. */ class KDEVPLATFORMPROJECT_EXPORT ProjectVisitor { public: ProjectVisitor(); virtual ~ProjectVisitor(); /** * Visit the whole project model tree. */ virtual void visit( ProjectModel* ); /** * Visit the tree starting from the project root item. */ virtual void visit( IProject* ); /** * Visit the folder and anything it contains. */ virtual void visit( ProjectFolderItem* ); /** * Visit the file. */ virtual void visit( ProjectFileItem* ); /** * Visit the build folder and anything it contains. */ virtual void visit( ProjectBuildFolderItem* ); /** * Visit the target and all children it may contain. */ virtual void visit( ProjectExecutableTargetItem* ); /** * Visit the target and all children it may contain. */ virtual void visit( ProjectLibraryTargetItem* ); }; /** * Interface that allows a developer to implement the three basic types of * items you would see in a multi-project * \li Folder * \li Project * \li Custom Target * \li Library Target * \li Executable Target * \li File */ class KDEVPLATFORMPROJECT_EXPORT ProjectBaseItem { public: - ProjectBaseItem( IProject*, const QString &name, ProjectBaseItem *parent = 0 ); + ProjectBaseItem( IProject*, const QString &name, ProjectBaseItem *parent = nullptr ); virtual ~ProjectBaseItem(); enum ProjectItemType { BaseItem = 0 /** item is a base item */, BuildFolder = 1 /** item is a buildable folder */, Folder = 2 /** item is a folder */, ExecutableTarget = 3 /** item is an executable target */, LibraryTarget = 4 /** item is a library target */, Target = 5 /** item is a target */, File = 6 /** item is a file */, CustomProjectItemType = 100 /** type which should be used as base for custom types */ }; enum RenameStatus { RenameOk = 0, ExistingItemSameName = 1, ProjectManagerRenameFailed = 2, InvalidNewName = 3 }; /** @returns Returns the project that the item belongs to. */ IProject* project() const; /** @returns If this item is a folder, it returns a pointer to the folder, otherwise returns a 0 pointer. */ virtual ProjectFolderItem *folder() const; /** @returns If this item is a target, it returns a pointer to the target, otherwise returns a 0 pointer. */ virtual ProjectTargetItem *target() const; /** @returns If this item is a file, it returns a pointer to the file, otherwise returns a 0 pointer. */ virtual ProjectFileItem *file() const; /** @returns If this item is a file, it returns a pointer to the file, otherwise returns a 0 pointer. */ virtual ProjectExecutableTargetItem *executable() const; /** @returns Returns a list of the folders that have this object as the parent. */ QList folderList() const; /** @returns Returns a list of the targets that have this object as the parent. */ QList targetList() const; /** @returns Returns a list of the files that have this object as the parent. */ QList fileList() const; virtual bool lessThan( const KDevelop::ProjectBaseItem* ) const; static bool pathLessThan(KDevelop::ProjectBaseItem* item1, KDevelop::ProjectBaseItem* item2); /** @returns the @p row item in the list of children of this item or 0 if there is no such child. */ ProjectBaseItem* child( int row ) const; /** @returns the list of children of this item. */ QList children() const; /** @returns a valid QModelIndex for usage with the model API for this item. */ QModelIndex index() const; /** @returns The parent item if this item has one, else it return 0. */ virtual ProjectBaseItem* parent() const; /** @returns the displayed text of this item. */ QString text() const; /** @returns the row in the list of children of this items parent, or -1. */ int row() const; /** @returns the number of children of this item, or 0 if there are none. */ int rowCount() const; /** @returns the model to which this item belongs, or 0 if its not associated to a model. */ ProjectModel* model() const; /** * Adds a new child item to this item. */ void appendRow( ProjectBaseItem* item ); /** * Removes and deletes the item at the given @p row if there is one. */ void removeRow( int row ); /** * Removes and deletes the @p count items after the given @p row if there is one. */ void removeRows( int row, int count ); /** * Returns and removes the item at the given @p row if there is one. */ ProjectBaseItem* takeRow( int row ); /** @returns RTTI info, allows one to know the type of item */ virtual int type() const; /** @returns a string to pass to QIcon::fromTheme() as icon-name suitable to represent this item. */ virtual QString iconName() const; /** * Set the path of this item. * * @note This function never renames the item in the project manager or * on the filesystem, it only changes the path and possibly the text nothing else. */ virtual void setPath( const Path& ); /** * @returns the path of this item. */ Path path() const; /** * @returns the basename of this items path (if any) * * Convenience function, returns the same as @c text() for most items. */ QString baseName() const; /** * Renames the item to the new name. * @returns status information whether the renaming succeeded. */ virtual RenameStatus rename( const QString& newname ); bool isProjectRoot() const; /** * Default flags: Qt::ItemIsEnabled | Qt::ItemIsSelectable * * @returns the flags supported by the item */ virtual Qt::ItemFlags flags(); /** * Sets what flags should be returned by ::flags() method. */ void setFlags(Qt::ItemFlags flags); protected: /** * Allows to change the displayed text of this item. * * Most items assume text == baseName so this is *not* public. * * @param text the new text */ void setText( const QString& text ); class ProjectBaseItemPrivate* const d_ptr; ProjectBaseItem( ProjectBaseItemPrivate& dd ); void setRow( int row ); void setModel( ProjectModel* model ); private: Q_DECLARE_PRIVATE(ProjectBaseItem) friend class ProjectModel; }; /** * Implementation of the ProjectBaseItem interface that is specific to a * folder */ class KDEVPLATFORMPROJECT_EXPORT ProjectFolderItem: public ProjectBaseItem { public: /** * Create a new ProjectFolderItem with the given @p path and an optional @p parent * in the given @p project. */ - ProjectFolderItem( IProject* project, const Path& path, ProjectBaseItem* parent = 0 ); + ProjectFolderItem( IProject* project, const Path& path, ProjectBaseItem* parent = nullptr ); /** * Create a child ProjectFolderItem of @p parent with @p name. * * The path is set automatically. */ ProjectFolderItem( const QString& name, ProjectBaseItem *parent ); ~ProjectFolderItem() override; void setPath(const Path& ) override; ProjectFolderItem *folder() const override; ///Reimplemented from QStandardItem int type() const override; /** * Get the folder name, equal to path().fileName() or text(). */ QString folderName() const; /** @returns Returns whether this folder directly contains the specified file or folder. */ bool hasFileOrFolder(const QString& name) const; QString iconName() const override; RenameStatus rename(const QString& newname) override; private: void propagateRename( const Path& newBase ) const; }; /** * Folder which contains buildable targets as part of a buildable project */ class KDEVPLATFORMPROJECT_EXPORT ProjectBuildFolderItem: public ProjectFolderItem { public: /** * Create a new ProjectBuildFolderItem with the given @p path with the optional * parent @p parent in the given @p project. */ - ProjectBuildFolderItem( IProject* project, const Path &path, ProjectBaseItem* parent = 0 ); + ProjectBuildFolderItem( IProject* project, const Path &path, ProjectBaseItem* parent = nullptr ); /** * Create a child ProjectBuildFolderItem of @p parent with @p name. * * The path is set automatically. */ ProjectBuildFolderItem( const QString &name, ProjectBaseItem *parent ); ///Reimplemented from QStandardItem int type() const override; QString iconName() const override; }; /** * Object which represents a target in a build system. * * This object contains all properties specific to a target. */ class KDEVPLATFORMPROJECT_EXPORT ProjectTargetItem: public ProjectBaseItem { public: - ProjectTargetItem( IProject*, const QString &name, ProjectBaseItem *parent = 0 ); + ProjectTargetItem( IProject*, const QString &name, ProjectBaseItem *parent = nullptr ); ///Reimplemented from QStandardItem int type() const override; ProjectTargetItem *target() const override; QString iconName() const override; void setPath(const Path& path ) override; }; /** * Object which represents an executable target in a build system. * * This object contains all properties specific to an executable. */ class KDEVPLATFORMPROJECT_EXPORT ProjectExecutableTargetItem: public ProjectTargetItem { public: - ProjectExecutableTargetItem( IProject*, const QString &name, ProjectBaseItem *parent = 0 ); + ProjectExecutableTargetItem( IProject*, const QString &name, ProjectBaseItem *parent = nullptr ); ProjectExecutableTargetItem *executable() const override; int type() const override; virtual QUrl builtUrl() const=0; virtual QUrl installedUrl() const=0; }; /** * Object which represents a library target in a build system. * * This object contains all properties specific to a library. */ class KDEVPLATFORMPROJECT_EXPORT ProjectLibraryTargetItem: public ProjectTargetItem { public: - ProjectLibraryTargetItem(IProject* project, const QString &name, ProjectBaseItem *parent = 0 ); + ProjectLibraryTargetItem(IProject* project, const QString &name, ProjectBaseItem *parent = nullptr ); int type() const override; }; /** * Object which represents a file. */ class KDEVPLATFORMPROJECT_EXPORT ProjectFileItem: public ProjectBaseItem { public: /** * Create a new ProjectFileItem with the given @p path and an optional @p parent * in the given @p project. */ - ProjectFileItem( IProject* project, const Path& path, ProjectBaseItem* parent = 0 ); + ProjectFileItem( IProject* project, const Path& path, ProjectBaseItem* parent = nullptr ); /** * Create a child ProjectFileItem of @p parent with the given @p name. * * The path is set automatically. */ ProjectFileItem( const QString& name, ProjectBaseItem *parent ); ~ProjectFileItem() override; ///Reimplemented from QStandardItem int type() const override; ProjectFileItem *file() const override; /** * @returns the file name, equal to path().fileName() or text() */ QString fileName() const; void setPath( const Path& ) override; QString iconName() const override; RenameStatus rename(const QString& newname) override; /** * @return the items indexed path, which is often required for performant * lookups or memory efficient storage. */ IndexedString indexedPath() const; }; /** * Class providing some convenience methods for accessing the project model * @todo: maybe switch to QAbstractItemModel, would make the implementation * for at least the checkbox-behaviour easier */ class KDEVPLATFORMPROJECT_EXPORT ProjectModel: public QAbstractItemModel { Q_OBJECT public: enum Roles { ProjectRole = Qt::UserRole+1 , ProjectItemRole , UrlRole , LastRole }; - explicit ProjectModel( QObject *parent = 0 ); + explicit ProjectModel( QObject *parent = nullptr ); ~ProjectModel() override; void clear(); void appendRow( ProjectBaseItem* item ); void removeRow( int row ); ProjectBaseItem* takeRow( int row ); ProjectBaseItem* itemAt( int row ) const; QList topItems() const; QModelIndex pathToIndex(const QStringList& tofetch) const; QStringList pathFromIndex(const QModelIndex& index) const; QModelIndex indexFromItem( const ProjectBaseItem* item ) const; ProjectBaseItem* itemFromIndex( const QModelIndex& ) const; int columnCount( const QModelIndex& parent = QModelIndex() ) const override; QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override; QModelIndex parent( const QModelIndex& child ) const override; int rowCount( const QModelIndex& parent = QModelIndex() ) const override; QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; bool insertColumns(int column, int count, const QModelIndex& parent = QModelIndex()) override; bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()) override; Qt::ItemFlags flags(const QModelIndex& index) const override; Qt::DropActions supportedDropActions() const override; /** * @return all items for the given indexed path. */ QList itemsForPath(const IndexedString& path) const; /** * Returns the first item for the given indexed path. */ ProjectBaseItem* itemForPath(const IndexedString& path) const; private: class ProjectModelPrivate* const d; friend class ProjectBaseItem; }; KDEVPLATFORMPROJECT_EXPORT QStringList joinProjectBasePath( const QStringList& partialpath, KDevelop::ProjectBaseItem* item ); KDEVPLATFORMPROJECT_EXPORT QStringList removeProjectBasePath( const QStringList& fullpath, KDevelop::ProjectBaseItem* item ); } Q_DECLARE_METATYPE(KDevelop::ProjectBaseItem*) Q_DECLARE_METATYPE(KDevelop::ProjectFolderItem*) Q_DECLARE_METATYPE(KDevelop::ProjectFileItem*) Q_DECLARE_METATYPE(KDevelop::ProjectLibraryTargetItem*) Q_DECLARE_METATYPE(KDevelop::ProjectExecutableTargetItem*) Q_DECLARE_METATYPE(KDevelop::ProjectTargetItem*) Q_DECLARE_METATYPE(KDevelop::ProjectBuildFolderItem*) Q_DECLARE_METATYPE(QList) #endif // KDEVPLATFORM_PROJECTMODEL_H diff --git a/project/tests/projectmodelperformancetest.h b/project/tests/projectmodelperformancetest.h index a7be335318..1238ec7f40 100644 --- a/project/tests/projectmodelperformancetest.h +++ b/project/tests/projectmodelperformancetest.h @@ -1,52 +1,52 @@ /*************************************************************************** * Copyright 2010 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVELOP_PROJECT_PROJECTMODELPERFORMANCETEST_INCLUDED #define KDEVELOP_PROJECT_PROJECTMODELPERFORMANCETEST_INCLUDED #include #include namespace KDevelop { class ProjectModel; class ProjectBaseItem; } class QTreeView; class ProjectModelPerformanceTest : public QWidget { Q_OBJECT public: - ProjectModelPerformanceTest(QWidget* parent = 0); + ProjectModelPerformanceTest(QWidget* parent = nullptr); ~ProjectModelPerformanceTest() override; private slots: void init(); void addSmallTree(); void addBigTree(); void addBigTreeDelayed(); void addItemDelayed(); private: QStack currentParent; int originalWidth; KDevelop::ProjectModel* model; QTreeView* view; }; #endif diff --git a/shell/assistantpopup.cpp b/shell/assistantpopup.cpp index cfc6f5a22e..f5e08a12dd 100644 --- a/shell/assistantpopup.cpp +++ b/shell/assistantpopup.cpp @@ -1,380 +1,381 @@ /* Copyright 2009 David Nolden Copyright 2012 Milian Wolff Copyright 2014 Sven Brauch Copyright 2014 Kevin Funk 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 "assistantpopup.h" #include "sublime/holdupdates.h" #include "util/kdevstringhandler.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace KDevelop; namespace { const int ASSISTANT_MODIFIER = #ifdef Q_OS_MAC Qt::CTRL; #else Qt::ALT; #endif const int ASSISTANT_MOD_KEY = #ifdef Q_OS_MAC Qt::Key_Control; #else Qt::Key_Alt; #endif QWidget* findByClassname(const KTextEditor::View* view, const QString& klass) { auto children = view->findChildren(); foreach ( auto child, children ) { if ( child->metaObject()->className() == klass ) { return child; } } return nullptr; }; /** * @brief Get the geometry of the inner part (with the text) of the KTextEditor::View being used. */ QRect textWidgetGeometry(const KTextEditor::View *view) { // Subtract the width of the right scrollbar int scrollbarWidth = 0; if ( auto scrollbar = findByClassname(view, QStringLiteral("KateScrollBar")) ) { scrollbarWidth = scrollbar->width(); } // Subtract the width of the bottom scrollbar int bottomScrollbarWidth = 0; if ( auto bottom = findByClassname(view, QStringLiteral("QScrollBar")) ) { bottomScrollbarWidth = bottom->height(); } auto geom = view->geometry(); geom.adjust(0, 0, -scrollbarWidth, -bottomScrollbarWidth); return geom; } } AssistantPopupConfig::AssistantPopupConfig(QObject *parent) : QObject(parent) , m_active(false) { } void AssistantPopupConfig::setColorsFromView(QObject *view) { auto iface = dynamic_cast(view); Q_ASSERT(iface); m_foreground = iface->configValue(QStringLiteral("line-number-color")).value(); m_background = iface->configValue(QStringLiteral("icon-border-color")).value(); m_highlight = iface->configValue(QStringLiteral("folding-marker-color")).value(); if ( KColorUtils::luma(m_background) < 0.3 ) { m_foreground = KColorUtils::lighten(m_foreground, 0.7); } const float lumaDiff = KColorUtils::luma(m_highlight) - KColorUtils::luma(m_background); if ( qAbs(lumaDiff) < 0.5 ) { m_highlight = QColor::fromHsv(m_highlight.hue(), qMin(255, m_highlight.saturation() + 80), lumaDiff > 0 ? qMin(255, m_highlight.value() + 120) : qMax(80, m_highlight.value() - 40)); } emit colorsChanged(); } bool AssistantPopupConfig::isActive() const { return m_active; } void AssistantPopupConfig::setActive(bool active) { if (m_active == active) { return; } m_active = active; emit activeChanged(m_active); } void AssistantPopupConfig::setViewSize(const QSize& size) { if (size != m_viewSize) { m_viewSize = size; emit viewSizeChanged(size); } } void AssistantPopupConfig::setTitle(const QString& title) { if (m_title == title) { return; } m_title = title; emit titleChanged(m_title); } void AssistantPopupConfig::setModel(const QList& model) { if (m_model == model) { return; } qDeleteAll( m_model ); m_model = model; emit modelChanged(model); } AssistantPopup::AssistantPopup() // main window as parent to use maximal space available in worst case : QQuickWidget(ICore::self()->uiController()->activeMainWindow()) , m_config(new AssistantPopupConfig(this)) , m_firstLayoutCompleted(false) { setAttribute(Qt::WA_ShowWithoutActivating); rootContext()->setContextProperty(QStringLiteral("config"), m_config); setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kdevelop/assistantpopup.qml")))); if (!rootObject()) { qWarning() << "Failed to load assistant markup! The assistant will not work."; } else { connect(rootObject(), &QQuickItem::widthChanged, this, &AssistantPopup::updateLayout); connect(rootObject(), &QQuickItem::heightChanged, this, &AssistantPopup::updateLayout); } for (int i = Qt::Key_0; i <= Qt::Key_9; ++i) { m_shortcuts.append(new QShortcut(ASSISTANT_MODIFIER + i, this)); } setActive(false); connect(qApp, &QApplication::applicationStateChanged, this, [this]{ setActive(false); }); } void AssistantPopup::reset(KTextEditor::View* view, const IAssistant::Ptr& assistant) { setView(view); setAssistant(assistant); updateState(); } void AssistantPopup::setView(KTextEditor::View* view) { if (m_view == view) { return; } setActive(false); if (m_view) { m_view->removeEventFilter(this); disconnect(m_view.data(), &KTextEditor::View::verticalScrollPositionChanged, this, &AssistantPopup::updatePosition); } m_view = view; m_config->setViewSize(m_view ? m_view->size() : QSize()); if (m_view) { m_view->installEventFilter(this); connect(m_view.data(), &KTextEditor::View::verticalScrollPositionChanged, this, &AssistantPopup::updatePosition); } } void AssistantPopup::setAssistant(const IAssistant::Ptr& assistant) { if (m_assistant == assistant) { return; } if (m_assistant) { disconnect(m_assistant.data(), &IAssistant::hide, this, &AssistantPopup::hideAssistant); disconnect(m_assistant.data(), &IAssistant::actionsChanged, this, &AssistantPopup::updateState); } m_assistant = assistant; if (m_assistant) { connect(m_assistant.data(), &IAssistant::hide, this, &AssistantPopup::hideAssistant); connect(m_assistant.data(), &IAssistant::actionsChanged, this, &AssistantPopup::updateState); } else { hide(); } } void AssistantPopup::setActive(bool active) { m_config->setActive(active); foreach (auto shortcut, m_shortcuts) { shortcut->setEnabled(active); } } bool AssistantPopup::eventFilter(QObject* object, QEvent* event) { Q_UNUSED(object); if (!m_view || (object != m_view.data())) return false; if (event->type() == QEvent::Resize) { updateLayout(); } else if (event->type() == QEvent::Hide) { executeHideAction(); } else if (event->type() == QEvent::KeyPress) { auto keyEvent = static_cast(event); if (keyEvent->modifiers() == ASSISTANT_MODIFIER) { setActive(true); } if (keyEvent->key() == Qt::Key_Escape) { executeHideAction(); } } else if (event->type() == QEvent::KeyRelease) { auto keyEvent = static_cast(event); if (keyEvent->modifiers() == ASSISTANT_MODIFIER || keyEvent->key() == ASSISTANT_MOD_KEY) { setActive(false); } } return false; } void AssistantPopup::updatePosition(KTextEditor::View* view, const KTextEditor::Cursor& newPos) { static const int MARGIN = 12; if (newPos.isValid() && newPos.line() == 0) { // the position is not going to change; don't waste time return; } auto editorGeometry = textWidgetGeometry(view); const auto startCursorCoordinate = view->cursorToCoordinate(KTextEditor::Cursor(0, 0)); // algorithm for popup positioning: // if we are scrolled to the top: show at bottom // else: // if: current cursor position is in upper half => show at bottom // else: show at top const bool showAtBottom = startCursorCoordinate.y() == 0 ? true : view->cursorPositionCoordinates().y() < view->height()/2; const QPoint targetLocation = showAtBottom ? parentWidget()->mapFromGlobal(view->mapToGlobal(editorGeometry.bottomRight() + QPoint(-width() - MARGIN, -MARGIN - height()))) : parentWidget()->mapFromGlobal(view->mapToGlobal(editorGeometry.topRight() + QPoint(-width() - MARGIN, MARGIN))); if (pos() == targetLocation) { return; } Sublime::HoldUpdates hold(ICore::self()->uiController()->activeMainWindow()); move(targetLocation); } IAssistant::Ptr AssistantPopup::assistant() const { return m_assistant; } void AssistantPopup::executeHideAction() { if ( isVisible() ) { m_assistant->doHide(); } } void AssistantPopup::hideAssistant() { reset(nullptr, {}); // indirectly calls hide() } void AssistantPopup::updateLayout() { - if ( !m_view ) { + auto root = rootObject(); + if (!m_view || !root) { return; } m_config->setViewSize(m_view->size()); // https://bugreports.qt.io/browse/QTBUG-44876 - resize(rootObject()->width(), rootObject()->height()); + resize(root->width(), root->height()); updatePosition(m_view, KTextEditor::Cursor::invalid()); // HACK: QQuickWidget is corrupted due to above resize on the first show if (!m_firstLayoutCompleted) { hide(); show(); m_firstLayoutCompleted = true; } } void AssistantPopup::updateState() { if (!m_assistant || m_assistant->actions().isEmpty() || !m_view) { hide(); return; } auto curShortcut = m_shortcuts.constBegin(); auto hideAction = new QAction(i18n("Hide"), this); connect(*curShortcut, &QShortcut::activated, hideAction, &QAction::trigger); connect(hideAction, &QAction::triggered, this, &AssistantPopup::executeHideAction); QList items; foreach (IAssistantAction::Ptr action, m_assistant->actions()) { QAction* asQAction = action->toKAction(); items << asQAction; asQAction->setParent(this); //For some reason, QAction's setShortcut does nothing, so we manage with QShortcut if (++curShortcut != m_shortcuts.constEnd()) { connect(*curShortcut, &QShortcut::activated, asQAction, &QAction::trigger); } connect(action.data(), SIGNAL(executed(IAssistantAction*)), hideAction, SLOT(trigger())); } items << hideAction; auto view = ICore::self()->documentController()->activeTextDocumentView(); m_config->setColorsFromView(view); m_config->setModel(items); m_config->setTitle(m_assistant->title()); setActive(false); show(); } diff --git a/shell/assistantpopup.h b/shell/assistantpopup.h index 82f4feaf2e..b192a17ebc 100644 --- a/shell/assistantpopup.h +++ b/shell/assistantpopup.h @@ -1,134 +1,134 @@ /* Copyright 2009 David Nolden Copyright 2012 Milian Wolff Copyright 2014 Sven Brauch Copyright 2014 Kevin Funk 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. */ #ifndef KDEVPLATFORM_ASSISTANTPOPUP_H #define KDEVPLATFORM_ASSISTANTPOPUP_H #include #include #include namespace KTextEditor { class View; class Cursor; } class AssistantPopupConfig : public QObject { Q_OBJECT Q_PROPERTY(QColor foreground READ foreground NOTIFY colorsChanged) Q_PROPERTY(QColor background READ background NOTIFY colorsChanged) Q_PROPERTY(QColor highlight READ highlight NOTIFY colorsChanged) Q_PROPERTY(QString title READ title NOTIFY titleChanged) Q_PROPERTY(QList model READ model NOTIFY modelChanged) Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged) Q_PROPERTY(QSize viewSize READ viewSize WRITE setViewSize NOTIFY viewSizeChanged) public: - explicit AssistantPopupConfig(QObject *parent = 0); + explicit AssistantPopupConfig(QObject *parent = nullptr); QColor foreground() const { return m_foreground; } QColor background() const { return m_background; } QColor highlight() const { return m_highlight; } QSize viewSize() const { return m_viewSize; }; void setViewSize(const QSize &size); QString title() const { return m_title; } void setTitle(const QString& title); QList model() const { return m_model; } void setModel(const QList& model); void setColorsFromView(QObject *view); bool isActive() const; void setActive(bool active); signals: void colorsChanged(); void titleChanged(const QString& title); void modelChanged(const QList& model); void activeChanged(bool active); void viewSizeChanged(const QSize& size); private: QColor m_foreground; QColor m_background; QColor m_highlight; QString m_title; QList m_model; bool m_active; QSize m_viewSize; }; Q_DECLARE_METATYPE(AssistantPopupConfig*) class AssistantPopup : public QQuickWidget { Q_OBJECT public: typedef QExplicitlySharedDataPointer Ptr; /** * The current main window will be used as parent widget for the popup. * This is to make use of the maximal space available and prevent any lines * in e.g. the editor to be hidden by the popup. */ AssistantPopup(); /** * Reset this popup for view @p view and show assistant @p assistant * * @p view The widget below which the assistant should be shown. */ void reset(KTextEditor::View *view, const KDevelop::IAssistant::Ptr &assistant); KDevelop::IAssistant::Ptr assistant() const; private slots: void updatePosition(KTextEditor::View* view, const KTextEditor::Cursor& newPos); void updateState(); void updateLayout(); void executeHideAction(); void hideAssistant(); protected: bool eventFilter(QObject* object, QEvent* event) override; private: void setView(KTextEditor::View* view); void setAssistant(const KDevelop::IAssistant::Ptr& assistant); void setActive( bool active ); KDevelop::IAssistant::Ptr m_assistant; QPointer m_view; AssistantPopupConfig* m_config; QList m_shortcuts; bool m_firstLayoutCompleted; }; #endif // KDEVPLATFORM_ASSISTANTPOPUP_H diff --git a/shell/completionsettings.h b/shell/completionsettings.h index 31ac38167a..66a05b18ce 100644 --- a/shell/completionsettings.h +++ b/shell/completionsettings.h @@ -1,75 +1,75 @@ /*************************************************************************** * Copyright 2008 David Nolden * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_COMPLETIONSETTINGS_H #define KDEVPLATFORM_COMPLETIONSETTINGS_H #include #include #include namespace KDevelop { class CompletionSettings : public KDevelop::ICompletionSettings { Q_OBJECT public: - virtual CompletionLevel completionLevel() const override; + CompletionLevel completionLevel() const override; - virtual bool automaticCompletionEnabled() const override; + bool automaticCompletionEnabled() const override; void emitChanged() { emit settingsChanged(this); } - virtual int localColorizationLevel() const override; + int localColorizationLevel() const override; - virtual int globalColorizationLevel() const override; + int globalColorizationLevel() const override; - virtual bool highlightSemanticProblems() const override; + bool highlightSemanticProblems() const override; - virtual bool highlightProblematicLines() const override; + bool highlightProblematicLines() const override; - virtual bool boldDeclarations() const override; + bool boldDeclarations() const override; - virtual bool showMultiLineSelectionInformation() const override; + bool showMultiLineSelectionInformation() const override; - virtual int minFilesForSimplifiedParsing() const override; + int minFilesForSimplifiedParsing() const override; - virtual QStringList todoMarkerWords() const override; + QStringList todoMarkerWords() const override; static CompletionSettings& self(); private: CompletionSettings(); const CompletionLevel m_level; const bool m_automatic; const bool m_highlightSemanticProblems; const bool m_highlightProblematicLines; const bool m_showMultiLineInformation; const bool m_boldDeclarations; const int m_localColorizationLevel; const int m_globalColorizationLevel; const int m_minFilesForSimplifiedParsing; const QString m_todoMarkerWords; const KConfigGroup m_languageGroup; }; } #endif diff --git a/shell/configdialog.h b/shell/configdialog.h index f927bb5fb2..cdc48f13c9 100644 --- a/shell/configdialog.h +++ b/shell/configdialog.h @@ -1,89 +1,89 @@ /* * This file is part of KDevelop * Copyright 2014 Alex Richardson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #ifndef KDEVPLATFORM_CONFIGDIALOG_H #define KDEVPLATFORM_CONFIGDIALOG_H #include namespace KDevelop { class ConfigPage; class IPlugin; /** * This class is meant to be used to show the global config dialog and the per-project config dialog. * * This used to be handled by KSettings::Dialog, but since we are no longer using KCMs for config widgets, * we use this class instead. * * TODO: check if we can share this with Kate */ class ConfigDialog : public KPageDialog { Q_OBJECT public: - explicit ConfigDialog(const QVector& pages, QWidget* parent = 0, Qt::WindowFlags flags = 0); + explicit ConfigDialog(const QVector& pages, QWidget* parent = nullptr, Qt::WindowFlags flags = nullptr); public Q_SLOTS: /** * Remove a config page */ void removeConfigPage(ConfigPage* page); /** * Add a new config page. * @param page the new page to add * @param next if this parameter is passed the new page will be before it, otherwise * it will be inserted as the last config page. */ void addConfigPage(ConfigPage* page, ConfigPage* next = nullptr); /** * Add a new sub config page * @param parentPage the parent page * @param page the page to add */ void addSubConfigPage(ConfigPage* parentPage, ConfigPage* page); Q_SIGNALS: void configSaved(ConfigPage* page); protected: void closeEvent(QCloseEvent* event) override; private: KPageWidgetItem* itemForPage(ConfigPage* page) const; int checkForUnsavedChanges(KPageWidgetItem* current, KPageWidgetItem* before); void applyChanges(ConfigPage* page); void removePagesForPlugin(IPlugin* plugin); void addConfigPageInternal(KPageWidgetItem* item, ConfigPage* page); void onPageChanged(); private: // we have to use QPointer since KPageDialog::removePage() also removes all child pages QList> m_pages; // TODO: use a QVector once we depend on Qt 5.4 bool m_currentPageHasChanges = false; bool m_currentlyApplyingChanges = false; }; } #endif // KDEVPLATFORM_CONFIGDIALOG_H diff --git a/shell/core.cpp b/shell/core.cpp index e48cf91f5e..7ccaef6381 100644 --- a/shell/core.cpp +++ b/shell/core.cpp @@ -1,613 +1,618 @@ /*************************************************************************** * Copyright 2007 Alexander Dymo * * Copyright 2007 Kris Wong * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "core.h" #include "core_p.h" #include #include #include +#include #include #include "mainwindow.h" #include "sessioncontroller.h" #include "uicontroller.h" #include "plugincontroller.h" #include "projectcontroller.h" #include "partcontroller.h" #include "languagecontroller.h" #include "documentcontroller.h" #include "runcontroller.h" #include "session.h" #include "documentationcontroller.h" #include "sourceformattercontroller.h" #include "progresswidget/progressmanager.h" #include "selectioncontroller.h" #include "debugcontroller.h" #include "kdevplatform_version.h" #include "workingsetcontroller.h" #include "testcontroller.h" #include "debug.h" #include #include #include #include namespace { void shutdownGracefully(int sig) { static volatile std::sig_atomic_t handlingSignal = 0; if ( !handlingSignal ) { handlingSignal = 1; qCDebug(SHELL) << "signal " << sig << " received, shutting down gracefully"; QCoreApplication* app = QCoreApplication::instance(); if (QApplication* guiApp = qobject_cast(app)) { guiApp->closeAllWindows(); } app->quit(); return; } // re-raise signal with default handler and trigger program termination std::signal(sig, SIG_DFL); std::raise(sig); } void installSignalHandler() { #ifdef SIGHUP std::signal(SIGHUP, shutdownGracefully); #endif #ifdef SIGINT std::signal(SIGINT, shutdownGracefully); #endif #ifdef SIGTERM std::signal(SIGTERM, shutdownGracefully); #endif } } namespace KDevelop { Core *Core::m_self = 0; KAboutData createAboutData() { KAboutData aboutData( QStringLiteral("kdevplatform"), i18n("KDevelop Platform"), QStringLiteral(KDEVPLATFORM_VERSION_STRING), i18n("Development Platform for IDE-like Applications"), KAboutLicense::LGPL_V2, i18n( "Copyright 2004-2015, The KDevelop developers" ), QString(), QStringLiteral("http://www.kdevelop.org") ); aboutData.addAuthor( i18n("Andreas Pakulat"), i18n( "Architecture, VCS Support, Project Management Support, QMake Projectmanager" ), QStringLiteral("apaku@gmx.de") ); aboutData.addAuthor( i18n("Alexander Dymo"), i18n( "Architecture, Sublime UI, Ruby support" ), QStringLiteral("adymo@kdevelop.org") ); aboutData.addAuthor( i18n("David Nolden"), i18n( "Definition-Use Chain, C++ Support" ), QStringLiteral("david.nolden.kdevelop@art-master.de") ); aboutData.addAuthor( i18n("Aleix Pol Gonzalez"), i18n( "Co-Maintainer, CMake Support, Run Support, Kross Support" ), QStringLiteral("aleixpol@kde.org") ); aboutData.addAuthor( i18n("Vladimir Prus"), i18n( "GDB integration" ), QStringLiteral("ghost@cs.msu.su") ); aboutData.addAuthor( i18n("Hamish Rodda"), i18n( "Text editor integration, definition-use chain" ), QStringLiteral("rodda@kde.org") ); aboutData.addCredit( i18n("Matt Rogers"), QString(), QStringLiteral("mattr@kde.org")); aboutData.addCredit( i18n("Cédric Pasteur"), i18n("astyle and indent support"), QStringLiteral("cedric.pasteur@free.fr") ); aboutData.addCredit( i18n("Evgeniy Ivanov"), i18n("Distributed VCS, Git, Mercurial"), QStringLiteral("powerfox@kde.ru") ); //Veritas is outside in playground currently. //aboutData.addCredit( i18n("Manuel Breugelmanns"), i18n( "Veritas, QTest integraton"), "mbr.nxi@gmail.com" ); aboutData.addCredit( i18n("Robert Gruber") , i18n( "SnippetPart, debugger and usability patches" ), QStringLiteral("rgruber@users.sourceforge.net") ); aboutData.addCredit( i18n("Dukju Ahn"), i18n( "Subversion plugin, Custom Make Manager, Overall improvements" ), QStringLiteral("dukjuahn@gmail.com") ); aboutData.addAuthor( i18n("Niko Sams"), i18n( "GDB integration, Webdevelopment Plugins" ), QStringLiteral("niko.sams@gmail.com") ); aboutData.addAuthor( i18n("Milian Wolff"), i18n( "Co-Maintainer, Generic manager, Webdevelopment Plugins, Snippets, Performance" ), QStringLiteral("mail@milianw.de") ); return aboutData; } CorePrivate::CorePrivate(Core *core): m_aboutData( createAboutData() ), m_core(core), m_cleanedUp(false), m_shuttingDown(false) { } bool CorePrivate::initialize(Core::Setup mode, QString session ) { m_mode=mode; qCDebug(SHELL) << "Creating controllers"; emit m_core->startupProgress(0); if( !sessionController ) { sessionController = new SessionController(m_core); } if( !workingSetController && !(mode & Core::NoUi) ) { workingSetController = new WorkingSetController(); } qCDebug(SHELL) << "Creating ui controller"; if( !uiController ) { uiController = new UiController(m_core); } emit m_core->startupProgress(10); qCDebug(SHELL) << "Creating plugin controller"; if( !pluginController ) { pluginController = new PluginController(m_core); const auto pluginInfos = pluginController->allPluginInfos(); if (pluginInfos.isEmpty()) { QMessageBox::critical(nullptr, i18n("Could not find any plugins"), i18n("

Could not find any plugins during startup.
" "Please make sure QT_PLUGIN_PATH is set correctly.

" "Refer to this article for more information."), QMessageBox::Abort, QMessageBox::Abort); qWarning() << "Could not find any plugins, aborting"; return false; } } if( !partController && !(mode & Core::NoUi)) { partController = new PartController(m_core, uiController.data()->defaultMainWindow()); } emit m_core->startupProgress(20); if( !projectController ) { projectController = new ProjectController(m_core); } if( !documentController ) { documentController = new DocumentController(m_core); } if( !languageController ) { // Must be initialized after documentController, because the background parser depends // on the document controller. languageController = new LanguageController(m_core); } emit m_core->startupProgress(25); if( !runController ) { runController = new RunController(m_core); } if( !sourceFormatterController ) { sourceFormatterController = new SourceFormatterController(m_core); } emit m_core->startupProgress(30); if ( !progressController) { progressController = ProgressManager::instance(); } if( !selectionController ) { selectionController = new SelectionController(m_core); } emit m_core->startupProgress(35); if( !documentationController && !(mode & Core::NoUi) ) { documentationController = new DocumentationController(m_core); } if( !debugController ) { debugController = new DebugController(m_core); } emit m_core->startupProgress(40); if( !testController ) { testController = new TestController(m_core); } emit m_core->startupProgress(47); qCDebug(SHELL) << "Done creating controllers"; qCDebug(SHELL) << "Initializing controllers"; sessionController.data()->initialize( session ); if( !sessionController.data()->activeSessionLock() ) { return false; } emit m_core->startupProgress(55); // TODO: Is this early enough, or should we put the loading of the session into // the controller construct DUChain::initialize(); if (!(mode & Core::NoUi)) { uiController.data()->initialize(); } languageController.data()->initialize(); if (partController) { partController.data()->initialize(); } projectController.data()->initialize(); documentController.data()->initialize(); emit m_core->startupProgress(63); /* This is somewhat messy. We want to load the areas before loading the plugins, so that when each plugin is loaded we know if an area wants some of the tool view from that plugin. OTOH, loading of areas creates documents, and some documents might require that a plugin is already loaded. Probably, the best approach would be to plugins to just add tool views to a list of available tool view, and then grab those tool views when loading an area. */ qCDebug(SHELL) << "Initializing plugin controller (loading session plugins)"; pluginController.data()->initialize(); emit m_core->startupProgress(78); qCDebug(SHELL) << "Initializing working set controller"; if(!(mode & Core::NoUi)) { workingSetController.data()->initialize(); /* Need to do this after everything else is loaded. It's too hard to restore position of views, and toolbars, and whatever that are not created yet. */ uiController.data()->loadAllAreas(KSharedConfig::openConfig()); uiController.data()->defaultMainWindow()->show(); } emit m_core->startupProgress(90); qCDebug(SHELL) << "Initializing remaining controllers"; runController.data()->initialize(); sourceFormatterController.data()->initialize(); selectionController.data()->initialize(); if (documentationController) { documentationController.data()->initialize(); } emit m_core->startupProgress(95); debugController.data()->initialize(); testController.data()->initialize(); installSignalHandler(); qCDebug(SHELL) << "Done initializing controllers"; if (partController) { // check features of kate and report to user if it does not fit KTextEditor::Document* doc = partController.data()->createTextPart(); if ( !qobject_cast< KTextEditor::MovingInterface* >(doc) ) { KMessageBox::error(QApplication::activeWindow(), i18n("The installed Kate version does not support the MovingInterface which is crucial for " "KDevelop starting from version 4.2.\n\n" "To use KDevelop with KDE SC prior to 4.6, where the SmartInterface is used instead " "of the MovingInterface, you need KDevelop 4.1 or lower.")); delete doc; return false; } delete doc; } emit m_core->startupProgress(100); return true; } CorePrivate::~CorePrivate() { delete selectionController.data(); delete projectController.data(); delete languageController.data(); delete pluginController.data(); delete uiController.data(); delete partController.data(); delete documentController.data(); delete runController.data(); delete sessionController.data(); delete sourceFormatterController.data(); delete documentationController.data(); delete debugController.data(); delete workingSetController.data(); delete testController.data(); selectionController.clear(); projectController.clear(); languageController.clear(); pluginController.clear(); uiController.clear(); partController.clear(); documentController.clear(); runController.clear(); sessionController.clear(); sourceFormatterController.clear(); documentationController.clear(); debugController.clear(); workingSetController.clear(); testController.clear(); } bool Core::initialize(QObject* splash, Setup mode, const QString& session ) { if (m_self) return true; m_self = new Core(); if (splash) { // can't use new signal/slot syntax here, we don't know the class that splash has at runtime connect(m_self, SIGNAL(startupProgress(int)), splash, SLOT(progress(int))); } bool ret = m_self->d->initialize(mode, session); if( splash ) { QTimer::singleShot( 200, splash, SLOT(deleteLater()) ); } if(ret) emit m_self->initializationCompleted(); return ret; } Core *KDevelop::Core::self() { return m_self; } Core::Core(QObject *parent) : ICore(parent) { d = new CorePrivate(this); connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &Core::shutdown); } Core::Core(CorePrivate* dd, QObject* parent) : ICore(parent), d(dd) { connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &Core::shutdown); } Core::~Core() { qCDebug(SHELL); //Cleanup already called before mass destruction of GUI delete d; m_self = 0; } Core::Setup Core::setupFlags() const { return d->m_mode; } void Core::shutdown() { qCDebug(SHELL); if (!d->m_shuttingDown) { cleanup(); deleteLater(); } qCDebug(SHELL) << "Shutdown done"; } bool Core::shuttingDown() const { return d->m_shuttingDown; } void Core::cleanup() { qCDebug(SHELL); d->m_shuttingDown = true; emit aboutToShutdown(); if (!d->m_cleanedUp) { + // first of all: stop background jobs + d->languageController->backgroundParser()->abortAllJobs(); + d->languageController->backgroundParser()->suspend(); + d->debugController.data()->cleanup(); d->selectionController.data()->cleanup(); // Save the layout of the ui here, so run it first d->uiController.data()->cleanup(); if (d->workingSetController) d->workingSetController.data()->cleanup(); /* Must be called before projectController.data()->cleanup(). */ // Closes all documents (discards, as already saved if the user wished earlier) d->documentController.data()->cleanup(); d->runController.data()->cleanup(); if (d->partController) { d->partController->cleanup(); } d->projectController.data()->cleanup(); d->sourceFormatterController.data()->cleanup(); d->pluginController.data()->cleanup(); d->sessionController.data()->cleanup(); d->testController.data()->cleanup(); //Disable the functionality of the language controller d->languageController.data()->cleanup(); DUChain::self()->shutdown(); } d->m_cleanedUp = true; emit shutdownCompleted(); } KAboutData Core::aboutData() const { return d->m_aboutData; } IUiController *Core::uiController() { return d->uiController.data(); } ISession* Core::activeSession() { return sessionController()->activeSession(); } ISessionLock::Ptr Core::activeSessionLock() { return sessionController()->activeSessionLock(); } SessionController *Core::sessionController() { return d->sessionController.data(); } UiController *Core::uiControllerInternal() { return d->uiController.data(); } IPluginController *Core::pluginController() { return d->pluginController.data(); } PluginController *Core::pluginControllerInternal() { return d->pluginController.data(); } IProjectController *Core::projectController() { return d->projectController.data(); } ProjectController *Core::projectControllerInternal() { return d->projectController.data(); } IPartController *Core::partController() { return d->partController.data(); } PartController *Core::partControllerInternal() { return d->partController.data(); } ILanguageController *Core::languageController() { return d->languageController.data(); } LanguageController *Core::languageControllerInternal() { return d->languageController.data(); } IDocumentController *Core::documentController() { return d->documentController.data(); } DocumentController *Core::documentControllerInternal() { return d->documentController.data(); } IRunController *Core::runController() { return d->runController.data(); } RunController *Core::runControllerInternal() { return d->runController.data(); } ISourceFormatterController* Core::sourceFormatterController() { return d->sourceFormatterController.data(); } SourceFormatterController* Core::sourceFormatterControllerInternal() { return d->sourceFormatterController.data(); } ProgressManager *Core::progressController() { return d->progressController.data(); } ISelectionController* Core::selectionController() { return d->selectionController.data(); } IDocumentationController* Core::documentationController() { return d->documentationController.data(); } DocumentationController* Core::documentationControllerInternal() { return d->documentationController.data(); } IDebugController* Core::debugController() { return d->debugController.data(); } DebugController* Core::debugControllerInternal() { return d->debugController.data(); } ITestController* Core::testController() { return d->testController.data(); } TestController* Core::testControllerInternal() { return d->testController.data(); } WorkingSetController* Core::workingSetControllerInternal() { return d->workingSetController.data(); } QString Core::version() { return QStringLiteral(KDEVPLATFORM_VERSION_STRING); } } diff --git a/shell/debugcontroller.h b/shell/debugcontroller.h index e3f8a1726d..a1b8cd44ee 100644 --- a/shell/debugcontroller.h +++ b/shell/debugcontroller.h @@ -1,123 +1,123 @@ /* This file is part of KDevelop * * Copyright 1999-2001 John Birch * Copyright 2001 by Bernd Gehrmann * Copyright 2007 Hamish Rodda * Copyright 2009 Niko Sams * * 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. */ #ifndef KDEVPLATFORM_DEBUGCONTROLLER_H #define KDEVPLATFORM_DEBUGCONTROLLER_H #include #include #include #include #include "../interfaces/idebugcontroller.h" #include "../debugger/interfaces/idebugsession.h" class QAction; namespace Sublime { class Area; } namespace KParts { class Part; } namespace KDevelop { class Context; class ContextMenuExtension; class DebugController : public IDebugController, public KXMLGUIClient { Q_OBJECT public: - explicit DebugController(QObject *parent = 0); + explicit DebugController(QObject *parent = nullptr); ~DebugController() override; void initialize(); void cleanup(); /// Must be called by debugger plugin that needs debugger actions and toolviews. void initializeUi() override; void addSession(IDebugSession* session) override; IDebugSession* currentSession() override; ContextMenuExtension contextMenuExtension( Context* context ); BreakpointModel* breakpointModel() override; VariableCollection* variableCollection() override; private Q_SLOTS: //void restartDebugger(); void stopDebugger(); void interruptDebugger(); void run(); void runToCursor(); void jumpToCursor(); void stepOver(); void stepIntoInstruction(); void stepInto(); void stepOverInstruction(); void stepOut(); void toggleBreakpoint(); void debuggerStateChanged(KDevelop::IDebugSession::DebuggerState state); void showStepInSource(const QUrl &file, int line); void clearExecutionPoint(); void partAdded(KParts::Part* part); void areaChanged(Sublime::Area* newArea); Q_SIGNALS: void raiseFramestackViews(); private: void setupActions(); void updateDebuggerState(KDevelop::IDebugSession::DebuggerState state, KDevelop::IDebugSession* session); static const QPixmap* executionPointPixmap(); QAction* m_continueDebugger; //QAction* m_restartDebugger; QAction* m_stopDebugger; QAction* m_interruptDebugger; QAction* m_runToCursor; QAction* m_jumpToCursor; QAction* m_stepOver; QAction* m_stepIntoInstruction; QAction* m_stepInto; QAction* m_stepOverInstruction; QAction* m_stepOut; QAction* m_toggleBreakpoint; QPointer m_currentSession; BreakpointModel *m_breakpointModel; VariableCollection *m_variableCollection; bool m_uiInitialized; }; } #endif diff --git a/shell/documentationcontroller.cpp b/shell/documentationcontroller.cpp index 35ba81e1bd..791776138c 100644 --- a/shell/documentationcontroller.cpp +++ b/shell/documentationcontroller.cpp @@ -1,234 +1,233 @@ /* Copyright 2009 Aleix Pol Gonzalez Copyright 2010 Benjamin Port 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 "documentationcontroller.h" #include "debug.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace KDevelop; namespace { /** * Return a "more useful" declaration that documentation providers can look-up * * @code * QPoint point; * ^-- cursor here * @endcode * * In this case, this method returns a Declaration pointer to the *type* * instead of a pointer to the instance, which is more useful when looking for help * * @return A more appropriate Declaration pointer or the given parameter @p decl */ Declaration* usefulDeclaration(Declaration* decl) { if (!decl) return nullptr; // First: Attempt to find the declaration of a definition decl = DUChainUtils::declarationForDefinition(decl); // Convenience feature: Retrieve the type declaration of instances, // it makes no sense to pass the declaration pointer of instances of types if (decl->kind() == Declaration::Instance) { AbstractType::Ptr type = TypeUtils::targetTypeKeepAliases(decl->abstractType(), decl->topContext()); IdentifiedType* idType = dynamic_cast(type.data()); Declaration* idDecl = idType ? idType->declaration(decl->topContext()) : 0; if (idDecl) { decl = idDecl; } } return decl; } } class DocumentationViewFactory: public KDevelop::IToolViewFactory { - public: - DocumentationViewFactory() - : mProvidersModel(0) - {} - - QWidget* create( QWidget *parent = 0 ) override - { - return new DocumentationView( parent, providers() ); - } - - Qt::DockWidgetArea defaultPosition() override { return Qt::RightDockWidgetArea; } - QString id() const override { return QStringLiteral("org.kdevelop.DocumentationView"); } - - private: - ProvidersModel* providers() { - if(!mProvidersModel) - mProvidersModel = new ProvidersModel; +public: + DocumentationViewFactory() + {} - return mProvidersModel; + QWidget* create(QWidget *parent = nullptr) override + { + if (!m_providersModel) { + m_providersModel.reset(new ProvidersModel); } + return new DocumentationView(parent, m_providersModel.data()); + } - ProvidersModel* mProvidersModel; + Qt::DockWidgetArea defaultPosition() override { return Qt::RightDockWidgetArea; } + QString id() const override { return QStringLiteral("org.kdevelop.DocumentationView"); } + +private: + QScopedPointer m_providersModel; }; DocumentationController::DocumentationController(Core* core) : m_factory(new DocumentationViewFactory) { m_showDocumentation = core->uiController()->activeMainWindow()->actionCollection()->addAction(QStringLiteral("showDocumentation")); m_showDocumentation->setText(i18n("Show Documentation")); m_showDocumentation->setIcon(QIcon::fromTheme(QStringLiteral("documentation"))); connect(m_showDocumentation, &QAction::triggered, this, &DocumentationController::doShowDocumentation); } +DocumentationController::~DocumentationController() +{ +} + void DocumentationController::initialize() { if(!documentationProviders().isEmpty() && !(Core::self()->setupFlags() & Core::NoUi)) { - Core::self()->uiController()->addToolView( i18n("Documentation"), m_factory ); + Core::self()->uiController()->addToolView(i18n("Documentation"), m_factory); } } void KDevelop::DocumentationController::doShowDocumentation() { KTextEditor::View* view = ICore::self()->documentController()->activeTextDocumentView(); if(!view) return; KDevelop::DUChainReadLocker lock( DUChain::lock() ); Declaration* decl = usefulDeclaration(DUChainUtils::itemUnderCursor(view->document()->url(), KTextEditor::Cursor(view->cursorPosition()))); auto documentation = documentationForDeclaration(decl); if (documentation) { showDocumentation(documentation); } } KDevelop::ContextMenuExtension KDevelop::DocumentationController::contextMenuExtension ( Context* context ) { ContextMenuExtension menuExt; DeclarationContext* ctx = dynamic_cast(context); if(ctx) { DUChainReadLocker lock(DUChain::lock()); if(!ctx->declaration().data()) return menuExt; auto doc = documentationForDeclaration(ctx->declaration().data()); if (doc) { menuExt.addAction(ContextMenuExtension::ExtensionGroup, m_showDocumentation);; } } return menuExt; } IDocumentation::Ptr DocumentationController::documentationForDeclaration(Declaration* decl) { if (!decl) return {}; foreach (IDocumentationProvider* doc, documentationProviders()) { qCDebug(SHELL) << "Documentation provider found:" << doc; auto ret = doc->documentationForDeclaration(decl); qCDebug(SHELL) << "Documentation proposed: " << ret.data(); if (ret) { return ret; } } return {}; } QList< IDocumentationProvider* > DocumentationController::documentationProviders() const { QList plugins=ICore::self()->pluginController()->allPluginsForExtension(QStringLiteral("org.kdevelop.IDocumentationProvider")); QList pluginsProvider=ICore::self()->pluginController()->allPluginsForExtension(QStringLiteral("org.kdevelop.IDocumentationProviderProvider")); QList ret; foreach(IPlugin* p, pluginsProvider) { IDocumentationProviderProvider *docProvider=p->extension(); if (!docProvider) { qWarning() << "plugin" << p << "does not implement ProviderProvider extension, rerun kbuildsycoca5"; continue; } ret.append(docProvider->providers()); } foreach(IPlugin* p, plugins) { IDocumentationProvider *doc=p->extension(); if (!doc) { qWarning() << "plugin" << p << "does not implement Provider extension, rerun kbuildsycoca5"; continue; } ret.append(doc); } return ret; } void KDevelop::DocumentationController::showDocumentation(const IDocumentation::Ptr& doc) { QWidget* w = ICore::self()->uiController()->findToolView(i18n("Documentation"), m_factory, KDevelop::IUiController::CreateAndRaise); if(!w) { qWarning() << "Could not add documentation toolview"; return; } DocumentationView* view = dynamic_cast(w); if( !view ) { qWarning() << "Could not cast toolview" << w << "to DocumentationView class!"; return; } view->showDocumentation(doc); } void DocumentationController::changedDocumentationProviders() { emit providersChanged(); } diff --git a/shell/documentationcontroller.h b/shell/documentationcontroller.h index 815777074a..0721570474 100644 --- a/shell/documentationcontroller.h +++ b/shell/documentationcontroller.h @@ -1,62 +1,63 @@ /* Copyright 2009 Aleix Pol Gonzalez Copyright 2010 Benjamin Port 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. */ #ifndef KDEVPLATFORM_DOCUMENTATIONCONTROLLER_H #define KDEVPLATFORM_DOCUMENTATIONCONTROLLER_H #include class DocumentationViewFactory; class QAction; namespace KDevelop { class Core; class Context; class ContextMenuExtension; class DocumentationController : public IDocumentationController { Q_OBJECT public: explicit DocumentationController(Core* core); + ~DocumentationController() override; void initialize(); QList documentationProviders() const override; IDocumentation::Ptr documentationForDeclaration(Declaration* declaration) override; void showDocumentation(const IDocumentation::Ptr& doc) override; ContextMenuExtension contextMenuExtension( Context* context ); public slots: void changedDocumentationProviders() override; private slots: void doShowDocumentation(); private: DocumentationViewFactory* m_factory; QAction* m_showDocumentation; }; } #endif // KDEVPLATFORM_DOCUMENTATIONCONTROLLER_H diff --git a/shell/documentcontroller.h b/shell/documentcontroller.h index 3e49f7933c..b28c129a72 100644 --- a/shell/documentcontroller.h +++ b/shell/documentcontroller.h @@ -1,183 +1,183 @@ /* This document is part of the KDE project Copyright 2002 Matthias Hoelzer-Kluepfel Copyright 2002 Bernd Gehrmann Copyright 2003 Roberto Raggi Copyright 2003 Hamish Rodda Copyright 2003 Harald Fernengel Copyright 2003 Jens Dagerbo Copyright 2005 Adam Treat Copyright 2004-2007 Alexander Dymo Copyright 2007 Andreas Pakulat This library 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 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 document COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KDEVPLATFORM_DOCUMENTCONTROLLER_H #define KDEVPLATFORM_DOCUMENTCONTROLLER_H #include #include #include "shellexport.h" namespace KTextEditor { class View; } namespace Sublime { class Document; class Area; class AreaIndex; } namespace KDevelop { class ProjectFileItem; class IProject; class MainWindow; /** * \short Interface to control open documents. * The document controller manages open documents in the IDE. * Open documents are usually editors, GUI designers, html documentation etc. * * Please note that this interface gives access to documents and not to their views. * It is possible that more than 1 view is shown in KDevelop for a document. */ class KDEVPLATFORMSHELL_EXPORT DocumentController: public IDocumentController { Q_OBJECT Q_CLASSINFO( "D-Bus Interface", "org.kdevelop.DocumentController" ) public: /**Constructor. @param parent The parent object.*/ - explicit DocumentController( QObject *parent = 0 ); + explicit DocumentController( QObject *parent = nullptr ); ~DocumentController() override; /**Finds the first document object corresponding to a given url. @param url The Url of the document. @return The corresponding document, or null if not found.*/ IDocument* documentForUrl( const QUrl & url ) const override; /**@return The list of open documents*/ QList openDocuments() const override; /**Refers to the document currently active or focused. @return The active document.*/ IDocument* activeDocument() const override; KTextEditor::View* activeTextDocumentView() const override; void activateDocument( IDocument * document, const KTextEditor::Range& range = KTextEditor::Range::invalid() ) override; void registerDocumentForMimetype( const QString&, KDevelop::IDocumentFactory* ) override; /// Request the document controller to save all documents. /// If the \a mode is not IDocument::Silent, ask the user which documents to save. /// Returns false if the user cancels the save dialog. bool saveAllDocuments(IDocument::DocumentSaveMode mode) override; bool saveAllDocumentsForWindow(KParts::MainWindow* mw, IDocument::DocumentSaveMode mode, bool currentAreaOnly = false) override; void initialize(); void cleanup(); virtual QStringList documentTypes() const; QString documentType(Sublime::Document* document) const; using IDocumentController::openDocument; /**checks that url is an url of empty document*/ static bool isEmptyDocumentUrl(const QUrl &url); static QUrl nextEmptyDocumentUrl(); IDocumentFactory* factory(const QString& mime) const override; bool openDocument(IDocument* doc, const KTextEditor::Range& range = KTextEditor::Range::invalid(), - DocumentActivationParams activationParams = 0, - IDocument* buddy = 0) override; + DocumentActivationParams activationParams = nullptr, + IDocument* buddy = nullptr) override; KTextEditor::Document* globalTextEditorInstance() override; public Q_SLOTS: /**Opens a new or existing document. @param url The full Url of the document to open. If it is empty, a dialog to choose the document will be opened. @param range The location information, if applicable. @param activationParams Indicates whether to fully activate the document. @param buddy The buddy document @return The opened document */ Q_SCRIPTABLE IDocument* openDocument( const QUrl &url, const KTextEditor::Range& range = KTextEditor::Range::invalid(), - DocumentActivationParams activationParams = 0, + DocumentActivationParams activationParams = nullptr, const QString& encoding = {}, - IDocument* buddy = 0 ) override; + IDocument* buddy = nullptr ) override; Q_SCRIPTABLE IDocument* openDocumentFromText( const QString& data ) override; KDevelop::IDocument* openDocument( const QUrl &url, const QString& prefname ) override; virtual void closeDocument( const QUrl &url ); void fileClose(); void slotSaveAllDocuments(); bool closeAllDocuments() override; void closeAllOtherDocuments(); void reloadAllDocuments(); // DBUS-compatible versions of openDocument virtual Q_SCRIPTABLE bool openDocumentSimple( QString url, int line = -1, int column = 0 ); // Opens a list of documents, with optional split-view separators, like: "file1 / [ file2 - fil3 ]" (see kdevplatform_shell_environment.sh) virtual Q_SCRIPTABLE bool openDocumentsSimple( QStringList urls ); virtual Q_SCRIPTABLE bool openDocumentFromTextSimple( QString text ); // If 'target' is empty, returns the currently active document, or // the currently selected project-item if no document is active. // If 'target' is "[selection]", returns the path of the currently active selection. // If 'target' is the name of a project, returns the root-path of that project. // Whenever the returned path corresponds to a directory, a '/.' suffix is appended. Q_SCRIPTABLE QString activeDocumentPath(QString target = {}) const; // Returns all open documents in the current area Q_SCRIPTABLE QStringList activeDocumentPaths() const; void vcsAnnotateCurrentDocument(); private Q_SLOTS: virtual void slotOpenDocument(const QUrl &url); void notifyDocumentClosed(Sublime::Document* doc); private: bool openDocumentsWithSplitSeparators( Sublime::AreaIndex* index, QStringList urlsWithSeparators, bool& isFirstView ); QList visibleDocumentsInWindow(MainWindow* mw) const; QList documentsExclusivelyInWindow(MainWindow* mw, bool currentAreaOnly = false) const; QList modifiedDocuments(const QList& list) const; bool saveSomeDocuments(const QList& list, IDocument::DocumentSaveMode mode) override; void setupActions(); Q_PRIVATE_SLOT(d, void removeDocument(Sublime::Document*)) Q_PRIVATE_SLOT(d, void chooseDocument()) Q_PRIVATE_SLOT(d, void changeDocumentUrl(KDevelop::IDocument*)) friend struct DocumentControllerPrivate; struct DocumentControllerPrivate *d; }; } #endif diff --git a/shell/environmentconfigurebutton.h b/shell/environmentconfigurebutton.h index c0b54c8c74..bef97018cd 100644 --- a/shell/environmentconfigurebutton.h +++ b/shell/environmentconfigurebutton.h @@ -1,61 +1,61 @@ /* This file is part of KDevelop Copyright 2010 Milian Wolff This library 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 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. */ #ifndef KDEVPLATFORM_ENVIRONMENTCONFIGUREBUTTON_H #define KDEVPLATFORM_ENVIRONMENTCONFIGUREBUTTON_H #include "shellexport.h" #include namespace KDevelop { class EnvironmentSelectionWidget; /** * A tool button that shows a dialog to configure the environment settings. * You want to place that next to an @c EnvironmentSelectionWidget and pass * that one along. This button will automatically update the selection widget * if required then. */ class KDEVPLATFORMSHELL_EXPORT EnvironmentConfigureButton : public QPushButton { Q_OBJECT public: - explicit EnvironmentConfigureButton(QWidget* parent = 0); + explicit EnvironmentConfigureButton(QWidget* parent = nullptr); ~EnvironmentConfigureButton() override; void setSelectionWidget(EnvironmentSelectionWidget* widget); signals: /** * Gets emitted whenever the dialog was acceppted * and the env settings might have changed. */ void environmentConfigured(); private: class EnvironmentConfigureButtonPrivate* const d; friend class EnvironmentConfigureButtonPrivate; }; } #endif // KDEVPLATFORM_ENVIRONMENTCONFIGUREBUTTON_H diff --git a/shell/launchconfiguration.h b/shell/launchconfiguration.h index 2c0d7f7cf3..8d80a0f670 100644 --- a/shell/launchconfiguration.h +++ b/shell/launchconfiguration.h @@ -1,102 +1,102 @@ /* This file is part of KDevelop Copyright 2009 Andreas Pakulat This library 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 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. */ #ifndef KDEVPLATFORM_LAUNCHCONFIGURATION_H #define KDEVPLATFORM_LAUNCHCONFIGURATION_H #include #include #include "shellexport.h" class QString; namespace KDevelop { class LaunchConfigurationType; class IProject; /** * @copydoc KDevelop::ILaunchConfiguration */ class KDEVPLATFORMSHELL_EXPORT LaunchConfiguration : public QObject, public ILaunchConfiguration { Q_OBJECT public: - explicit LaunchConfiguration( KConfigGroup, IProject* = 0, QObject* = 0 ); + explicit LaunchConfiguration( KConfigGroup, IProject* = nullptr, QObject* = nullptr ); ~LaunchConfiguration() override; static QString LaunchConfigurationNameEntry(); static QString LaunchConfigurationTypeEntry(); /** * Change the name of this launch configuration * @param name the new name for the launch configuration */ void setName( const QString& name ); /** * Changes the type of this launch configuration. Note that * this removes all existing config values from this configuration * @param type the id of the new type */ void setType( const QString& typeId ); /** * @copydoc KDevelop::ILaunchConfiguration::config() */ const KConfigGroup config() const override; /** * @copydoc KDevelop::ILaunchConfiguration::type() */ LaunchConfigurationType* type() const override; /** * @copydoc KDevelop::ILaunchConfiguration::name() */ QString name() const override; /** * @copydoc KDevelop::ILaunchConfiguration::project() */ IProject* project() const override; void save(); QString configGroupName() const; QString launcherForMode( const QString& mode ) const; void setLauncherForMode( const QString& mode, const QString& id ); KConfigGroup config() override; signals: void nameChanged( LaunchConfiguration* ); void typeChanged( LaunchConfigurationType* ); private: KConfigGroup baseGroup; IProject* m_project; LaunchConfigurationType* m_type; }; } #endif diff --git a/shell/launchconfigurationdialog.h b/shell/launchconfigurationdialog.h index cb269b229d..5759b3aea9 100644 --- a/shell/launchconfigurationdialog.h +++ b/shell/launchconfigurationdialog.h @@ -1,168 +1,168 @@ /* This file is part of KDevelop Copyright 2009 Andreas Pakulat This library 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 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. */ #ifndef KDEVPLATFORM_LAUNCHCONFIGURATIONDIALOG_H #define KDEVPLATFORM_LAUNCHCONFIGURATIONDIALOG_H #include #include #include #include #include #include "ui_launchconfigurationdialog.h" class QItemSelection; namespace Ui { class LaunchConfigTypePage; } namespace KDevelop { class ILauncher; class LaunchConfigurationPageFactory; class ILaunchMode; class LaunchConfigurationType; class LaunchConfiguration; class LaunchConfigurationPage; class ILaunchConfiguration; class IProject; class LaunchConfigurationModelDelegate : public QStyledItemDelegate { Q_OBJECT public: using QStyledItemDelegate::QStyledItemDelegate; QWidget* createEditor ( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const override; void setEditorData ( QWidget* editor, const QModelIndex& index ) const override; void setModelData ( QWidget* editor, QAbstractItemModel* model, const QModelIndex& index ) const override; }; class LaunchConfigurationsModel : public QAbstractItemModel { Q_OBJECT public: - explicit LaunchConfigurationsModel(QObject* parent = 0); + explicit LaunchConfigurationsModel(QObject* parent = nullptr); int columnCount(const QModelIndex& parent = QModelIndex()) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; QModelIndex parent(const QModelIndex& child) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; Qt::ItemFlags flags(const QModelIndex& index) const override; bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; void createConfiguration( const QModelIndex& ); void deleteConfiguration( const QModelIndex& index ); LaunchConfiguration* configForIndex( const QModelIndex& ) const; ILaunchMode* modeForIndex( const QModelIndex& idx ) const; QModelIndex indexForConfig( LaunchConfiguration* ) const; void addConfiguration(KDevelop::ILaunchConfiguration* launch, const QModelIndex& idx); KDevelop::IProject* projectForIndex(const QModelIndex& idx); private: class TreeItem { public: - TreeItem() : parent(0) {} + TreeItem() : parent(nullptr) {} virtual ~TreeItem() {} TreeItem* parent; int row; QList children; }; class ProjectItem : public TreeItem { public: IProject* project; }; class LaunchItem : public TreeItem { public: LaunchConfiguration* launch; }; class LaunchModeItem : public TreeItem { public: ILaunchMode* mode; }; class GenericPageItem : public TreeItem { public: QString text; }; void addItemForLaunchConfig( LaunchConfiguration* l ); void addLaunchModeItemsForLaunchConfig ( KDevelop::LaunchConfigurationsModel::LaunchItem* l ); QList topItems; public: ProjectItem* findItemForProject( IProject* ); }; class LaunchConfigPagesContainer : public QWidget { Q_OBJECT public: - explicit LaunchConfigPagesContainer( const QList &, QWidget* parent = 0 ); + explicit LaunchConfigPagesContainer( const QList &, QWidget* parent = nullptr ); void setLaunchConfiguration( LaunchConfiguration* ); void save(); signals: void changed(); private: LaunchConfiguration* config; QList pages; }; class LaunchConfigurationDialog : public QDialog, public Ui::LaunchConfigurationDialog { Q_OBJECT public: - explicit LaunchConfigurationDialog(QWidget* parent = 0 ); + explicit LaunchConfigurationDialog(QWidget* parent = nullptr ); QSize sizeHint() const override; private slots: void deleteConfiguration(); void createConfiguration(); void addConfiguration(KDevelop::ILaunchConfiguration*); void selectionChanged(QItemSelection,QItemSelection); void modelChanged(QModelIndex,QModelIndex); void pageChanged(); void saveConfig(); void updateNameLabel( LaunchConfiguration* l ); void createEmptyLauncher(); void launchModeChanged(int index); private: void saveConfig( const QModelIndex& ); LaunchConfigurationsModel* model; QMap typeWidgets; QMap launcherWidgets; bool currentPageChanged; private slots: void doTreeContextMenu(QPoint point); void renameSelected(); }; } #endif diff --git a/shell/loadedpluginsdialog.h b/shell/loadedpluginsdialog.h index ba4a201e91..ce04565824 100644 --- a/shell/loadedpluginsdialog.h +++ b/shell/loadedpluginsdialog.h @@ -1,32 +1,32 @@ /************************************************************************** * Copyright 2009 Andreas Pakulat class LoadedPluginsDialog : public QDialog { Q_OBJECT public: - explicit LoadedPluginsDialog( QWidget* parent = 0 ); + explicit LoadedPluginsDialog( QWidget* parent = nullptr ); }; #endif // KDEVPLATFORM_LOADEDPLUGINSDIALOG_H diff --git a/shell/mainwindow.h b/shell/mainwindow.h index f58ed98dab..8340064ee7 100644 --- a/shell/mainwindow.h +++ b/shell/mainwindow.h @@ -1,118 +1,118 @@ /* This file is part of the KDevelop project Copyright 2003 Falk Brettschneider Copyright 2003 John Firebaugh Copyright 2003 Amilcar do Carmo Lucas Copyright 2004, 2007 Alexander Dymo Copyright 2006 Adam Treat This library 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 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. */ #ifndef KDEVPLATFORM_MAINWINDOW_H #define KDEVPLATFORM_MAINWINDOW_H #include #include #include "shellexport.h" namespace KTextEditor { class View; } namespace KTextEditorIntegration { class MainWindow; } namespace KDevelop { class IDocument; /** KDevelop main window. Provides methods to control the main window of an application. */ class KDEVPLATFORMSHELL_EXPORT MainWindow: public Sublime::MainWindow { friend class UiController; Q_OBJECT Q_CLASSINFO( "D-Bus Interface", "org.kdevelop.MainWindow" ) public: - explicit MainWindow( Sublime::Controller *parent = 0, Qt::WindowFlags flags = KDE_DEFAULT_WINDOWFLAGS ); + explicit MainWindow( Sublime::Controller *parent = nullptr, Qt::WindowFlags flags = KDE_DEFAULT_WINDOWFLAGS ); ~MainWindow() override; /*! @p status must implement KDevelop::IStatus */ void registerStatus(QObject* status); KTextEditorIntegration::MainWindow *kateWrapper() const; public Q_SLOTS: /*! Shows an error message in the status bar. @p message The message @p timeout The timeout in milliseconds how long to show the message */ void showErrorMessage(const QString& message, int timeout); virtual Q_SCRIPTABLE void ensureVisible(); virtual Q_SCRIPTABLE QString windowTitle() { return Sublime::MainWindow::windowTitle(); } void setVisible( bool visible ) override; void configureShortcuts(); void loadSettings() override; Q_SIGNALS: void finishedLoading(); protected: //FIXME DOCUMENT!!! queryClose() must call all of the Core cleanup() methods! bool queryClose() override; //reimplemented from KXMLGUIBuilder to support visible menubar separators QAction *createCustomElement(QWidget *parent, int index, const QDomElement &element) override; virtual void initialize(); virtual void cleanup(); void initializeStatusBar() override; void dragEnterEvent( QDragEnterEvent* ) override; void dropEvent( QDropEvent* ) override; void applyMainWindowSettings(const KConfigGroup& config) override; void createGUI(KParts::Part* part); protected Q_SLOTS: void tabContextMenuRequested(Sublime::View* , QMenu* ) override; void tabToolTipRequested(Sublime::View* view, Sublime::Container* container, int tab) override; void dockBarContextMenuRequested(Qt::DockWidgetArea, const QPoint&) override; void newTabRequested() override; private Q_SLOTS: void updateCaption(); void updateActiveDocumentConnection(IDocument* document); void updateTabColor(IDocument* doc); void updateAllTabColors(); void shortcutsChanged(); private: void initializeCorners(); class MainWindowPrivate *d; friend class MainWindowPrivate; }; } #endif diff --git a/shell/openprojectdialog.h b/shell/openprojectdialog.h index cb0e699364..7aeae56030 100644 --- a/shell/openprojectdialog.h +++ b/shell/openprojectdialog.h @@ -1,75 +1,75 @@ /*************************************************************************** * Copyright (C) 2008 by Andreas Pakulat #include #include class KPageWidgetItem; namespace KIO { class Job; } namespace KDevelop { class ProjectSourcePage; class OpenProjectPage; class OpenProjectDialog : public KAssistantDialog { Q_OBJECT public: - OpenProjectDialog( bool fetch, const QUrl& startUrl, QWidget* parent = 0 ); + OpenProjectDialog( bool fetch, const QUrl& startUrl, QWidget* parent = nullptr ); /** * Return a QUrl pointing to the project's .kdev file. */ QUrl projectFileUrl() const; /** * Return a QUrl pointing to the file, that was selected by the user. * Unlike projectFileUrl(), this can be a .kdev file, as well * as build system file (e.g. CMakeLists.txt). */ QUrl selectedUrl() const; QString projectName() const; QString projectManager() const; private slots: void validateSourcePage( bool ); void validateOpenUrl( const QUrl& ); void validateProjectName( const QString& ); void validateProjectManager( const QString& ); void storeFileList(KIO::Job*, const KIO::UDSEntryList&); void openPageAccepted(); private: void validateProjectInfo(); QUrl m_url; QUrl m_selected; QString m_projectName; QString m_projectManager; KPageWidgetItem* sourcePage; KPageWidgetItem* openPage; KPageWidgetItem* projectInfoPage; QStringList m_fileList; KDevelop::OpenProjectPage* openPageWidget; KDevelop::ProjectSourcePage* sourcePageWidget; }; } #endif diff --git a/shell/openprojectpage.h b/shell/openprojectpage.h index d85aaec421..93deb49634 100644 --- a/shell/openprojectpage.h +++ b/shell/openprojectpage.h @@ -1,53 +1,53 @@ /*************************************************************************** * Copyright (C) 2008 by Andreas Pakulat #include class QUrl; class KFileWidget; namespace KDevelop { class OpenProjectPage : public QWidget { Q_OBJECT public: - explicit OpenProjectPage( const QUrl& startUrl, QWidget* parent = 0 ); + explicit OpenProjectPage( const QUrl& startUrl, QWidget* parent = nullptr ); QMap projectFilters() const; void setUrl(const QUrl& url); signals: void urlSelected(const QUrl&); void accepted(); protected: void showEvent(QShowEvent*) override; private slots: void highlightFile(const QUrl&); void opsEntered(const QUrl& item); void comboTextChanged(const QString&); void dirChanged(const QUrl& url); private: QUrl getAbsoluteUrl(const QString&) const; KFileWidget* fileWidget; QMap m_projectFilters; }; } #endif diff --git a/shell/partdocument.h b/shell/partdocument.h index 3696b86bdb..212a59691b 100644 --- a/shell/partdocument.h +++ b/shell/partdocument.h @@ -1,88 +1,88 @@ /*************************************************************************** * Copyright 2007 Alexander Dymo * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PARTDOCUMENT_H #define KDEVPLATFORM_PARTDOCUMENT_H #include #include #include "shellexport.h" namespace KParts { class Part; } namespace KDevelop { /** The generic document which represents KParts. This document is used by shell when more specific document classes are incapable of loading the url. This document loads one KPart (read-only or read-write) per view and sets part widget to be a view widget. */ class KDEVPLATFORMSHELL_EXPORT PartDocument: public Sublime::UrlDocument, public KDevelop::IDocument { Q_OBJECT public: PartDocument(const QUrl &url, ICore* core, const QString& preferredPart = QString() ); ~PartDocument() override; QUrl url() const override; void setUrl(const QUrl& newUrl); - QWidget *createViewWidget(QWidget *parent = 0) override; + QWidget *createViewWidget(QWidget *parent = nullptr) override; KParts::Part *partForView(QWidget *view) const override; QMimeType mimeType() const override; KTextEditor::Document* textDocument() const override; bool save(DocumentSaveMode mode = Default) override; void reload() override; ///Closes and deletes the document. Asks the user before if needed. bool close(DocumentSaveMode mode = Default) override; bool isActive() const override; DocumentState state() const override; void setPrettyName(QString name) override; void activate(Sublime::View *activeView, KParts::MainWindow *mainWindow) override; KTextEditor::Cursor cursorPosition() const override; void setCursorPosition(const KTextEditor::Cursor &cursor) override; void setTextSelection(const KTextEditor::Range &range) override; //Overridden from Sublime::Document bool closeDocument(bool silent) override; bool askForCloseFeedback() override; protected: /** Gives us access to the KParts */ QMap partForView() const; /** Lets us override the createViewWidget method safely */ void addPartForView(QWidget* widget, KParts::Part* part); private: class PartDocumentPrivate * const d; }; } #endif diff --git a/shell/problemmodel.h b/shell/problemmodel.h index be962be9bc..4bbfea5efa 100644 --- a/shell/problemmodel.h +++ b/shell/problemmodel.h @@ -1,186 +1,186 @@ /* * KDevelop Problem Reporter * * Copyright 2007 Hamish Rodda * Copyright 2015 Laszlo Kis-Adam * * 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 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. */ #ifndef PROBLEMMODEL_H #define PROBLEMMODEL_H #include #include #include #include struct ProblemModelPrivate; namespace KDevelop { class IDocument; class ProblemStore; /** * @brief Wraps a ProblemStore and adds the QAbstractItemModel interface, so the it can be used in a model/view architecture. * * By default ProblemModel instantiates a FilteredProblemStore, with the following features on: * \li ScopeFilter * \li SeverityFilter * \li Grouping * \li CanByPassScopeFilter * * Has to following columns: * \li Error * \li Source * \li File * \li Line * \li Column * \li LastColumn * * Possible ProblemModel features * \li NoFeatures * \li CanDoFullUpdate * \li CanShowImports * \li ScopeFilter * \li SeverityFilter * \li Grouping * \li CanByPassScopeFilter * * Scope, severity, grouping, imports can be set using the slots named after these features. * * Usage example: * @code * IProblem::Ptr problem(new DetectedProblem); * problem->setDescription(QStringLiteral("Problem")); * ProblemModel *model = new ProblemModel(nullptr); * model->addProblem(problem); * model->rowCount(); // returns 1 * QModelIndex idx = model->index(0, 0); * model->data(index); // "Problem" * @endcode * */ class KDEVPLATFORMSHELL_EXPORT ProblemModel : public QAbstractItemModel { Q_OBJECT public: /// List of supportable features enum FeatureCode { NoFeatures = 0, /// No features :( CanDoFullUpdate = 1, /// Reload/Reparse problems CanShowImports = 2, /// Show problems from imported files. E.g.: Header files in C/C++ ScopeFilter = 4, /// Filter problems by scope. E.g.: current document, open documents, etc SeverityFilter = 8, /// Filter problems by severity. E.g.: hint, warning, error, etc Grouping = 16, /// Can group problems CanByPassScopeFilter = 32 /// Can bypass scope filter }; Q_DECLARE_FLAGS(Features, FeatureCode) - explicit ProblemModel(QObject *parent, ProblemStore *store = NULL); + explicit ProblemModel(QObject *parent, ProblemStore *store = nullptr); ~ProblemModel() override; enum Columns { Error, Source, File, Line, Column, LastColumn }; enum Roles { ProblemRole = Qt::UserRole + 1, SeverityRole }; int columnCount(const QModelIndex & parent = QModelIndex()) const override; QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const override; QModelIndex parent(const QModelIndex & index) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; int rowCount(const QModelIndex & parent = QModelIndex()) const override; QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; IProblem::Ptr problemForIndex(const QModelIndex& index) const; /// Adds a new problem to the model void addProblem(const IProblem::Ptr &problem); /// Clears the problems, then adds a new set of them void setProblems(const QVector &problems); /// Clears the problems void clearProblems(); /// Retrieve the supported features Features features() const; /// Set the supported features void setFeatures(Features features); public slots: /// Show imports virtual void setShowImports(bool){} /// Sets the scope filter. Uses int to be able to use QSignalMapper virtual void setScope(int scope); /// Sets the severity filter. Uses int to be able to use QSignalMapper virtual void setSeverity(int severity);///old-style severity filtering virtual void setSeverities(KDevelop::IProblem::Severities severities);///new-style severity filtering void setGrouping(int grouping); /** * Force a full problem update. * E.g.: Reparse the source code. * Obviously it doesn't make sense for run-time problem checkers. */ virtual void forceFullUpdate(){} protected slots: /// Triggered when problems change virtual void onProblemsChanged(){} private slots: /// Triggered when the current document changes virtual void setCurrentDocument(IDocument* doc); virtual void closedDocument(IDocument* doc); /// Triggered before the problems are rebuilt void onBeginRebuild(); /// Triggered once the problems have been rebuilt void onEndRebuild(); protected: ProblemStore *store() const; private: QScopedPointer d; }; Q_DECLARE_OPERATORS_FOR_FLAGS(ProblemModel::Features) } #endif // PROBLEMMODEL_H diff --git a/shell/progresswidget/overlaywidget.h b/shell/progresswidget/overlaywidget.h index b22412d960..d2402739c9 100644 --- a/shell/progresswidget/overlaywidget.h +++ b/shell/progresswidget/overlaywidget.h @@ -1,60 +1,60 @@ /*************************************************************************** * Copyright (c) 2004 David Faure * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_OVERLAYWIDGET_H #define KDEVPLATFORM_OVERLAYWIDGET_H #include class QResizeEvent; class QEvent; namespace KDevelop { /** * This is a widget that can align itself with another one, without using a layout, * so that it can actually be on top of other widgets. * Currently the only supported type of alignment is "right aligned, on top of the other widget". */ class OverlayWidget : public QWidget { Q_OBJECT public: - OverlayWidget( QWidget* alignWidget, QWidget* parent, const char* name = 0 ); + OverlayWidget( QWidget* alignWidget, QWidget* parent, const char* name = nullptr ); ~OverlayWidget() override; QWidget * alignWidget() { return mAlignWidget; } void setAlignWidget( QWidget * alignWidget ); protected: void resizeEvent( QResizeEvent* ev ) override; bool eventFilter( QObject* o, QEvent* e) override; private: void reposition(); private: QWidget * mAlignWidget; }; } // namespace #endif /* OVERLAYWIDGET_H */ diff --git a/shell/progresswidget/progressdialog.h b/shell/progresswidget/progressdialog.h index d46ead5ddf..dad9c0ff66 100644 --- a/shell/progresswidget/progressdialog.h +++ b/shell/progresswidget/progressdialog.h @@ -1,139 +1,139 @@ /*************************************************************************** * Copyright (c) 2004 Till Adam * * based on imapprogressdialog.cpp ,which is * * Copyright (c) 2002-2003 Klar�vdalens Datakonsult AB * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PROGRESSDIALOG_H #define KDEVPLATFORM_PROGRESSDIALOG_H #include "overlaywidget.h" #include #include #include class QProgressBar; class QFrame; class QLabel; class QPushButton; namespace KDevelop { class ProgressItem; class TransactionItem; class SSLLabel; class TransactionItemView : public QScrollArea { Q_OBJECT public: - explicit TransactionItemView( QWidget * parent = 0, const char * name = 0 ); + explicit TransactionItemView( QWidget * parent = nullptr, const char * name = nullptr ); ~TransactionItemView() override {} TransactionItem *addTransactionItem( ProgressItem *item, bool first ); QSize sizeHint() const override; QSize minimumSizeHint() const override; public Q_SLOTS: void slotItemCompleted(TransactionItem * item); protected: void resizeEvent ( QResizeEvent *event ) override; private: QWidget *mBigBox; }; class TransactionItem : public QWidget { Q_OBJECT public: TransactionItem( QWidget *parent, ProgressItem *item, bool first ); ~TransactionItem() override; void hideHLine(); void setProgress( int progress ); void setLabel( const QString & ); // the given text is interpreted as RichText, so you might need to // Qt::escape() it before passing void setStatus( const QString & ); void setTotalSteps( int totalSteps ); ProgressItem *item() const { return mItem; } void addSubTransaction( ProgressItem *item ); // The progressitem is deleted immediately, we take 5s to go out, // so better not use mItem during this time. - void setItemComplete() { mItem = 0; } + void setItemComplete() { mItem = nullptr; } public Q_SLOTS: void slotItemCanceled(); protected: QProgressBar *mProgress; QPushButton *mCancelButton; QLabel *mItemLabel; QLabel *mItemStatus; QFrame *mFrame; ProgressItem *mItem; }; class ProgressDialog : public OverlayWidget { Q_OBJECT public: - ProgressDialog( QWidget *alignWidget, QWidget *parent, const char *name = 0 ); + ProgressDialog( QWidget *alignWidget, QWidget *parent, const char *name = nullptr ); ~ProgressDialog() override; void setVisible( bool b ) override; public Q_SLOTS: void slotToggleVisibility(); protected Q_SLOTS: void slotTransactionAdded( KDevelop::ProgressItem *item ); void slotTransactionCompleted( KDevelop::ProgressItem *item ); void slotTransactionCanceled( KDevelop::ProgressItem *item ); void slotTransactionProgress( KDevelop::ProgressItem *item, unsigned int progress ); void slotTransactionStatus( KDevelop::ProgressItem *item, const QString & ); void slotTransactionLabel( KDevelop::ProgressItem *item, const QString & ); void slotTransactionUsesBusyIndicator( KDevelop::ProgressItem *, bool ); void slotClose(); void slotShow(); void slotHide(); Q_SIGNALS: void visibilityChanged( bool ); protected: void closeEvent( QCloseEvent * ) override; TransactionItemView *mScrollView; QMap mTransactionsToListviewItems; bool mWasLastShown; }; } // namespace KDevelop #endif // __KDevelop_PROGRESSDIALOG_H__ diff --git a/shell/progresswidget/progressmanager.h b/shell/progresswidget/progressmanager.h index 62f9e8232c..440e35f5fe 100644 --- a/shell/progresswidget/progressmanager.h +++ b/shell/progresswidget/progressmanager.h @@ -1,479 +1,479 @@ /*************************************************************************** * (C) 2004 Till Adam * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_PROGRESSMANAGER_H #define KDEVPLATFORM_PROGRESSMANAGER_H #include #include #include #include #include #include namespace Akonadi { class AgentInstance; } namespace KDevelop { class ProgressItem; class ProgressManager; typedef QMap ProgressItemMap; class ProgressItem : public QObject { Q_OBJECT friend class ProgressManager; public: /** * @return The id string which uniquely identifies the operation * represented by this item. */ const QString &id() const { return mId; } /** * @return The parent item of this one, if there is one. */ ProgressItem *parent() const { return mParent.data(); } /** * @return The user visible string to be used to represent this item. */ const QString &label() const { return mLabel; } /** * @param v Set the user visible string identifying this item. */ void setLabel( const QString &v ); /** * @return The string to be used for showing this item's current status. */ const QString &status() const { return mStatus; } /** * Set the string to be used for showing this item's current status. * @param v The status string. */ void setStatus( const QString &v ); /** * @return Whether this item can be canceled. */ bool canBeCanceled() const { return mCanBeCanceled; } /** * @return Whether this item uses secure communication * (Account uses ssl, for example.). */ bool usesCrypto() const { return mUsesCrypto; } /** * Set whether this item uses crypted communication, so listeners * can display a nice crypto icon. * @param v The value. */ void setUsesCrypto( bool v ); /** * @return whether this item uses a busy indicator instead of real progress display */ bool usesBusyIndicator() const { return mUsesBusyIndicator; } /** * Sets whether this item uses a busy indicator instead of real progress for its progress bar. * If it uses a busy indicator, you are still responsible for calling setProgress() from time to * time to update the busy indicator. */ void setUsesBusyIndicator( bool useBusyIndicator ); /** * @return The current progress value of this item in percent. */ unsigned int progress() const { return mProgress; } /** * Set the progress (percentage of completion) value of this item. * @param v The percentage value. */ void setProgress( unsigned int v ); /** * Tell the item it has finished. This will emit progressItemCompleted() * result in the destruction of the item after all slots connected to this * signal have executed. This is the only way to get rid of an item and * needs to be called even if the item is canceled. Don't use the item * after this has been called on it. */ void setComplete(); /** * Reset the progress value of this item to 0 and the status string to * the empty string. */ void reset() { setProgress( 0 ); setStatus( QString() ); mCompleted = 0; } void cancel(); // Often needed values for calculating progress. void setTotalItems( unsigned int v ) { mTotal = v; } unsigned int totalItems() const { return mTotal; } void setCompletedItems( unsigned int v ) { mCompleted = v; } void incCompletedItems( unsigned int v = 1 ) { mCompleted += v; } unsigned int completedItems() const { return mCompleted; } /** * Recalculate progress according to total/completed items and update. */ void updateProgress() { setProgress( mTotal? mCompleted * 100 / mTotal : 0 ); } void addChild( ProgressItem *kiddo ); void removeChild( ProgressItem *kiddo ); bool canceled() const { return mCanceled; } void setBusy( bool busy ); Q_SIGNALS: /** * Emitted when a new ProgressItem is added. * @param The ProgressItem that was added. */ void progressItemAdded( KDevelop::ProgressItem * ); /** * Emitted when the progress value of an item changes. * @param The item which got a new value. * @param The value, for convenience. */ void progressItemProgress( KDevelop::ProgressItem *, unsigned int ); /** * Emitted when a progress item was completed. The item will be * deleted afterwards, so slots connected to this are the last * chance to work with this item. * @param The completed item. */ void progressItemCompleted( KDevelop::ProgressItem * ); /** * Emitted when an item was canceled. It will _not_ go away immediately, * only when the owner sets it complete, which will usually happen. Can be * used to visually indicate the canceled status of an item. Should be used * by the owner of the item to make sure it is set completed even if it is * canceled. There is a ProgressManager::slotStandardCancelHandler which * simply sets the item completed and can be used if no other work needs to * be done on cancel. * @param The canceled item; */ void progressItemCanceled( KDevelop::ProgressItem * ); /** * Emitted when the status message of an item changed. Should be used by * progress dialogs to update the status message for an item. * @param The updated item. * @param The new message. */ void progressItemStatus( KDevelop::ProgressItem *, const QString & ); /** * Emitted when the label of an item changed. Should be used by * progress dialogs to update the label of an item. * @param The updated item. * @param The new label. */ void progressItemLabel( KDevelop::ProgressItem *, const QString & ); /** * Emitted when the crypto status of an item changed. Should be used by * progress dialogs to update the crypto indicator of an item. * @param The updated item. * @param The new state. */ void progressItemUsesCrypto( KDevelop::ProgressItem *, bool ); /** * Emitted when the busy indicator state of an item changes. Should be used * by progress dialogs so that they can adjust the display of the progress bar * to the new mode. * @param item The updated item * @param value True if the item uses a busy indicator now, false otherwise */ void progressItemUsesBusyIndicator( KDevelop::ProgressItem *item, bool value ); protected: /* Only to be used by our good friend the ProgressManager */ ProgressItem( ProgressItem *parent, const QString &id, const QString &label, const QString &status, bool isCancellable, bool usesCrypto ); ~ProgressItem() override; private: QString mId; QString mLabel; QString mStatus; QPointer mParent; bool mCanBeCanceled; unsigned int mProgress; ProgressItemMap mChildren; unsigned int mTotal; unsigned int mCompleted; bool mWaitingForKids; bool mCanceled; bool mUsesCrypto; bool mUsesBusyIndicator; bool mCompletedCalled; }; struct ProgressManagerPrivate; /** * The ProgressManager singleton keeps track of all ongoing transactions * and notifies observers (progress dialogs) when their progress percent value * changes, when they are completed (by their owner), and when they are canceled. * Each ProgressItem emits those signals individually and the singleton * broadcasts them. Use the ::createProgressItem() statics to acquire an item * and then call ->setProgress( int percent ) on it every time you want to * update the item and ->setComplete() when the operation is done. This will * delete the item. Connect to the item's progressItemCanceled() signal to be * notified when the user cancels the transaction using one of the observing * progress dialogs or by calling item->cancel() in some other way. The owner * is responsible for calling setComplete() on the item, even if it is canceled. * Use the standardCancelHandler() slot if that is all you want to do on cancel. * * Note that if you request an item with a certain id and there is already * one with that id, there will not be a new one created but the existing * one will be returned. This is convenient for accessing items that are * needed regularly without the to store a pointer to them or to add child * items to parents by id. */ class ProgressManager : public QObject { Q_OBJECT friend struct ProgressManagerPrivate; public: ~ProgressManager() override; /** * @return The singleton instance of this class. */ static ProgressManager *instance(); /** * Use this to acquire a unique id number which can be used to discern * an operation from all others going on at the same time. Use that * number as the id string for your progressItem to ensure it is unique. * @return */ static QString getUniqueID() { return QString::number( ++uID ); } /** * Creates a ProgressItem with a unique id and the given label. * This is the simplest way to acquire a progress item. It will not * have a parent and will be set to be cancellable and not using crypto. */ static ProgressItem *createProgressItem( const QString &label ) { - return instance()->createProgressItemImpl( 0, getUniqueID(), label, + return instance()->createProgressItemImpl( nullptr, getUniqueID(), label, QString(), true, false ); } /** * Creates a new progressItem with the given parent, id, label and initial * status. * * @param parent Specify an already existing item as the parent of this one. * @param id Used to identify this operation for cancel and progress info. * @param label The text to be displayed by progress handlers * @param status Additional text to be displayed for the item. * @param canBeCanceled can the user cancel this operation? * @param usesCrypto does the operation use secure transports (SSL) * Cancelling the parent will cancel the children as well (if they can be * canceled) and ongoing children prevent parents from finishing. * @return The ProgressItem representing the operation. */ static ProgressItem *createProgressItem( ProgressItem *parent, const QString &id, const QString &label, const QString &status = QString(), bool canBeCanceled = true, bool usesCrypto = false ) { return instance()->createProgressItemImpl( parent, id, label, status, canBeCanceled, usesCrypto ); } /** * Use this version if you have the id string of the parent and want to * add a subjob to it. */ static ProgressItem *createProgressItem( const QString &parent, const QString &id, const QString &label, const QString &status = QString(), bool canBeCanceled = true, bool usesCrypto = false ) { return instance()->createProgressItemImpl( parent, id, label, status, canBeCanceled, usesCrypto ); } /** * Version without a parent. */ static ProgressItem *createProgressItem( const QString &id, const QString &label, const QString &status = QString(), bool canBeCanceled = true, bool usesCrypto = false ) { - return instance()->createProgressItemImpl( 0, id, label, status, + return instance()->createProgressItemImpl( nullptr, id, label, status, canBeCanceled, usesCrypto ); } /** * Version for Akonadi agents. * This connects all the proper signals so that you do not have to * worry about updating the progress or reacting to progressItemCanceled(). */ static ProgressItem *createProgressItem( ProgressItem *parent, const Akonadi::AgentInstance &agent, const QString &id, const QString &label, const QString &status = QString(), bool canBeCanceled = true, bool usesCrypto = false ) { return instance()->createProgressItemForAgent( parent, agent, id, label, status, canBeCanceled, usesCrypto ); } /** * @return true when there are no more progress items. */ bool isEmpty() const { return mTransactions.isEmpty(); } /** * @return the only top level progressitem when there's only one. * Returns 0 if there is no item, or more than one top level item. * Since this is used to calculate the overall progress, it will also return * 0 if there is an item which uses a busy indicator, since that will invalidate * the overall progress. */ ProgressItem *singleItem() const; /** * Ask all listeners to show the progress dialog, because there is * something that wants to be shown. */ static void emitShowProgressDialog() { instance()->emitShowProgressDialogImpl(); } Q_SIGNALS: /** @see ProgressItem::progressItemAdded() */ void progressItemAdded( KDevelop::ProgressItem * ); /** @see ProgressItem::progressItemProgress() */ void progressItemProgress( KDevelop::ProgressItem *, unsigned int ); /** @see ProgressItem::progressItemCompleted() */ void progressItemCompleted( KDevelop::ProgressItem * ); /** @see ProgressItem::progressItemCanceled() */ void progressItemCanceled( KDevelop::ProgressItem * ); /** @see ProgressItem::progressItemStatus() */ void progressItemStatus( KDevelop::ProgressItem *, const QString & ); /** @see ProgressItem::progressItemLabel() */ void progressItemLabel( KDevelop::ProgressItem *, const QString & ); /** @see ProgressItem::progressItemUsesCrypto() */ void progressItemUsesCrypto( KDevelop::ProgressItem *, bool ); /** @see ProgressItem::progressItemUsesBusyIndicator */ void progressItemUsesBusyIndicator( KDevelop::ProgressItem*, bool ); /** * Emitted when an operation requests the listeners to be shown. * Use emitShowProgressDialog() to trigger it. */ void showProgressDialog(); public Q_SLOTS: /** * Calls setCompleted() on the item, to make sure it goes away. * Provided for convenience. * @param item the canceled item. */ void slotStandardCancelHandler( KDevelop::ProgressItem *item ); /** * Aborts all running jobs. Bound to "Esc" */ void slotAbortAll(); private Q_SLOTS: void slotTransactionCompleted( KDevelop::ProgressItem *item ); private: ProgressManager(); // prevent unsolicited copies ProgressManager( const ProgressManager & ); virtual ProgressItem *createProgressItemImpl( ProgressItem *parent, const QString &id, const QString &label, const QString &status, bool cancellable, bool usesCrypto ); virtual ProgressItem *createProgressItemImpl( const QString &parent, const QString &id, const QString &label, const QString &status, bool cancellable, bool usesCrypto ); ProgressItem *createProgressItemForAgent( ProgressItem *parent, const Akonadi::AgentInstance &instance, const QString &id, const QString &label, const QString &status, bool cancellable, bool usesCrypto ); void emitShowProgressDialogImpl(); QHash< QString, ProgressItem* > mTransactions; static unsigned int uID; }; } #endif // __KDevelop_PROGRESSMANAGER_H__ diff --git a/shell/project.h b/shell/project.h index 41a2c92b4d..673a25fda2 100644 --- a/shell/project.h +++ b/shell/project.h @@ -1,142 +1,142 @@ /* This file is part of the KDE project Copyright 2001 Matthias Hoelzer-Kluepfel Copyright 2001-2002 Bernd Gehrmann Copyright 2002-2003 Roberto Raggi Copyright 2002 Simon Hausmann Copyright 2003 Jens Dagerbo Copyright 2003 Mario Scalas Copyright 2003-2004 Alexander Dymo Copyright 2006 Matt Rogers Copyright 2007 Andreas Pakulat This library 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 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. */ #ifndef KDEVPLATFORM_SHELLPROJECT_H #define KDEVPLATFORM_SHELLPROJECT_H #include #include #include "shellexport.h" template class QList; class KJob; namespace KDevelop { class IProjectFileManager; class IBuildSystemManager; class ProjectFileItem; class PersistentHash; /** * \brief Object which represents a KDevelop project * * Provide better descriptions */ class KDEVPLATFORMSHELL_EXPORT Project : public IProject { Q_OBJECT public: /** * Constructs a project. * * @param parent The parent object for the plugin. */ - explicit Project(QObject *parent = 0); + explicit Project(QObject *parent = nullptr); ~Project() override; QList< ProjectBaseItem* > itemsForPath(const IndexedString& path) const override; QList< ProjectFileItem* > filesForPath(const IndexedString& file) const override; QList< ProjectFolderItem* > foldersForPath(const IndexedString& folder) const override; QString projectTempFile() const; QString developerTempFile() const; Path developerFile() const; void reloadModel() override; Path projectFile() const override; KSharedConfigPtr projectConfiguration() const override; void addToFileSet( ProjectFileItem* file ) override; void removeFromFileSet( ProjectFileItem* file ) override; QSet fileSet() const override; bool isReady() const override; Path path() const override; Q_SCRIPTABLE QString name() const override; public Q_SLOTS: /** * @brief Open a project * * This method opens a project and starts the process of loading the * data for the project from disk. * * @param projectFile The path pointing to the location of the project * file to load * * The project name is taken from the Name key in the project file in * the 'General' group */ bool open(const Path &projectFile); void close() override; IProjectFileManager* projectFileManager() const override; IBuildSystemManager* buildSystemManager() const override; IPlugin* versionControlPlugin() const override; IPlugin* managerPlugin() const override; /** * Set the manager plugin for the project. */ void setManagerPlugin( IPlugin* manager ); ProjectFolderItem* projectItem() const override; /** * Check if the url specified by @a url is part of the project. * @a url can be either a relative url (to the project directory) or * an absolute url. * * @param url the url to check * * @return true if the url @a url is a part of the project. */ bool inProject(const IndexedString &url) const override; void setReloadJob(KJob* job) override; signals: /** * Internal signal to make IProjectController::projectAboutToOpen useful. */ void aboutToOpen(KDevelop::IProject*); private: Q_PRIVATE_SLOT(d, void importDone(KJob*)) Q_PRIVATE_SLOT(d, void reloadDone(KJob*)) class ProjectPrivate* const d; }; } // namespace KDevelop #endif diff --git a/shell/projectinfopage.h b/shell/projectinfopage.h index f78f4bbba3..92183be6e6 100644 --- a/shell/projectinfopage.h +++ b/shell/projectinfopage.h @@ -1,43 +1,43 @@ /*************************************************************************** * Copyright (C) 2008 by Andreas Pakulat namespace Ui { class ProjectInfoPage; } namespace KDevelop { class ProjectInfoPage : public QWidget { Q_OBJECT public: - explicit ProjectInfoPage( QWidget* parent = 0 ); + explicit ProjectInfoPage( QWidget* parent = nullptr ); ~ProjectInfoPage() override; void setProjectName( const QString& ); void setProjectManager( const QString& ); signals: void projectNameChanged( const QString& ); void projectManagerChanged( const QString& ); private slots: void changeProjectManager( int ); private: Ui::ProjectInfoPage* page_ui; }; } #endif diff --git a/shell/projectsourcepage.h b/shell/projectsourcepage.h index e1d13938a9..a45ee19e68 100644 --- a/shell/projectsourcepage.h +++ b/shell/projectsourcepage.h @@ -1,65 +1,65 @@ /*************************************************************************** * Copyright (C) 2010 by Aleix Pol Gonzalez * * * * 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. * * * ***************************************************************************/ #ifndef KDEVPLATFORM_PROJECTSOURCEPAGE_H #define KDEVPLATFORM_PROJECTSOURCEPAGE_H #include class KJob; class QUrl; namespace Ui { class ProjectSourcePage; } namespace KDevelop { class VcsJob; class IProjectProvider; class IProjectProviderWidget; class IPlugin; class IBasicVersionControl; class VcsLocationWidget; class ProjectSourcePage : public QWidget { Q_OBJECT public: - explicit ProjectSourcePage(const QUrl& initial, QWidget* parent = 0); + explicit ProjectSourcePage(const QUrl& initial, QWidget* parent = nullptr); ~ProjectSourcePage() override; QUrl workingDir() const; private slots: void setSourceIndex(int index); void checkoutVcsProject(); void projectReceived(KJob* job); void reevaluateCorrection(); void progressChanged(KJob*, unsigned long); void infoMessage(KJob*, const QString& text, const QString& rich); void locationChanged(); void projectChanged(const QString& name); signals: void isCorrect(bool); private: void setStatus(const QString& message); void clearStatus(); KDevelop::IBasicVersionControl* vcsPerIndex(int index); KDevelop::IProjectProvider* providerPerIndex(int index); KDevelop::VcsJob* jobPerCurrent(); Ui::ProjectSourcePage* m_ui; QList m_plugins; KDevelop::VcsLocationWidget* m_locationWidget; KDevelop::IProjectProviderWidget* m_providerWidget; }; } #endif // KDEVPLATFORM_PROJECTSOURCEPAGE_H diff --git a/shell/runcontroller.h b/shell/runcontroller.h index 1da8853d1d..09c2e28ff8 100644 --- a/shell/runcontroller.h +++ b/shell/runcontroller.h @@ -1,166 +1,166 @@ /* This file is part of KDevelop Copyright 2007-2008 Hamish Rodda This library 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 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. */ #ifndef KDEVPLATFORM_RUNCONTROLLER_H #define KDEVPLATFORM_RUNCONTROLLER_H #include #include #include #include #include "shellexport.h" class QStyleOptionViewItem; class QPainter; class QModelIndex; class KStatefulBrush; namespace KDevelop { class Context; class ContextMenuExtension; class IPlugin; class IProject; class LaunchConfiguration; class LaunchConfigurationType; class KDEVPLATFORMSHELL_EXPORT RunController : public IRunController { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kdevelop.RunController") public: explicit RunController(QObject *parent); ~RunController() override; void registerJob(KJob *job) override; void unregisterJob(KJob *job) override; QList currentJobs() const override; KJob* execute(const QString& launchMode, ILaunchConfiguration* launch) override; QList launchModes() const override; /** * @copydoc IRunController::addLaunchMode */ void addLaunchMode( ILaunchMode* mode ) override; /** * @copydoc IRunController::removeLaunchMode */ void removeLaunchMode( ILaunchMode* mode ) override; /** * @copydoc IRunController::launchModeForId() */ KDevelop::ILaunchMode* launchModeForId(const QString& id) const override; void initialize(); void cleanup(); QItemDelegate* delegate() const; void addLaunchConfiguration( LaunchConfiguration* l ); void removeLaunchConfiguration( LaunchConfiguration* l ); QList launchConfigurationsInternal() const; QList launchConfigurations() const override; /** * @copydoc IRunController::launchConfigurationTypes() */ QList launchConfigurationTypes() const override; /** * @copydoc IRunController::addConfigurationType() */ void addConfigurationType( LaunchConfigurationType* type ) override; /** * @copydoc IRunController::removeConfigurationType() */ void removeConfigurationType( LaunchConfigurationType* type ) override; /** * Find the launch configuration type for the given @p id. * @returns the launch configuration type having the id, or 0 if no such type is known */ LaunchConfigurationType* launchConfigurationTypeForId( const QString& ) override; ILaunchConfiguration* createLaunchConfiguration ( LaunchConfigurationType* type, const QPair& launcher, - IProject* project = 0, + IProject* project = nullptr, const QString& name = QString() ) override; void setDefaultLaunch(ILaunchConfiguration* l); LaunchConfiguration* defaultLaunch() const; ContextMenuExtension contextMenuExtension( KDevelop::Context* ctx ); public Q_SLOTS: Q_SCRIPTABLE void executeDefaultLaunch(const QString& runMode) override; Q_SCRIPTABLE void stopAllProcesses() override; protected Q_SLOTS: void finished(KJob *job) override; void suspended(KJob *job) override; void resumed(KJob *job) override; private Q_SLOTS: void slotRefreshProject(KDevelop::IProject* project); void slotExecute(); void slotDebug(); void slotProfile(); void slotProjectOpened(KDevelop::IProject* project); void slotProjectClosing(KDevelop::IProject* project); void slotKillJob(); void launchChanged(LaunchConfiguration*); void jobDestroyed(QObject* job); void jobPercentChanged(); private: void setupActions(); void checkState(); void removeLaunchConfigurationInternal( LaunchConfiguration* l ); Q_PRIVATE_SLOT(d, void configureLaunches()) Q_PRIVATE_SLOT(d, void launchAs(int)) class RunControllerPrivate; RunControllerPrivate* const d; }; class RunDelegate : public QItemDelegate { Q_OBJECT public: - explicit RunDelegate( QObject* = 0 ); + explicit RunDelegate( QObject* = nullptr ); void paint(QPainter*, const QStyleOptionViewItem&, const QModelIndex&) const override; private: KStatefulBrush runProviderBrush; KStatefulBrush errorBrush; }; } #endif diff --git a/shell/session.h b/shell/session.h index ed35660b60..918baffa7e 100644 --- a/shell/session.h +++ b/shell/session.h @@ -1,90 +1,90 @@ /* This file is part of KDevelop Copyright 2008 Andreas Pakulat This library 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 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. */ #ifndef KDEVPLATFORM_SESSION_H #define KDEVPLATFORM_SESSION_H #include "shellexport.h" #include #include #include #include #include namespace KDevelop { struct SessionInfo { QString name; QUuid uuid; QString description; QList projects; QString path; KSharedConfigPtr config; }; using SessionInfos = QVector; class KDEVPLATFORMSHELL_EXPORT Session : public ISession { Q_OBJECT public: static const QString cfgSessionNameEntry; static const QString cfgSessionDescriptionEntry; static const QString cfgSessionProjectsEntry; static const QString cfgSessionOptionsGroup; - explicit Session( const QString& id, QObject * parent = 0 ); + explicit Session( const QString& id, QObject * parent = nullptr ); ~Session() override; QUrl pluginDataArea( const IPlugin* ) override; KSharedConfigPtr config() override; QList containedProjects() const override; void setContainedProjects( const QList& projects ) override; QString name() const override; void setName( const QString& ); QUuid id() const override; QString description() const override; bool isTemporary() const override; void setTemporary(bool temp) override; QString path() const; /** * Generates a @ref SessionInfo by a session @p id. * @param mkdir Whether to create a session directory if one does not exist. */ static SessionInfo parse( const QString& id, bool mkdir = false ); private: class SessionPrivate* const d; friend class SessionPrivate; }; } Q_DECLARE_METATYPE( KDevelop::Session* ) #endif diff --git a/shell/sessioncontroller.h b/shell/sessioncontroller.h index c7e45a5f4f..b6dc806336 100644 --- a/shell/sessioncontroller.h +++ b/shell/sessioncontroller.h @@ -1,181 +1,181 @@ /* This file is part of KDevelop Copyright 2008 Andreas Pakulat Copyright 2013 Milian Wolff This library 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 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. */ #ifndef KDEVPLATFORM_SESSIONCONTROLLER_H #define KDEVPLATFORM_SESSIONCONTROLLER_H #include "shellexport.h" #include "session.h" #include #include #include namespace KDevelop { struct SessionRunInfo { SessionRunInfo() : isRunning(false) , holderPid(-1) {} bool operator==(const SessionRunInfo& o) const { return isRunning == o.isRunning && holderPid == o.holderPid && holderApp == o.holderApp && holderHostname == o.holderHostname; } bool operator!=(const SessionRunInfo& o) const { return !(operator==(o)); } // if this is true, this session is currently running in an external process bool isRunning; // if the session is running, this contains the PID of its process qint64 holderPid; // if the session is running, this contains the name of its process QString holderApp; // if the session is running, this contains the host name where the process runs QString holderHostname; }; struct TryLockSessionResult { TryLockSessionResult(const ISessionLock::Ptr& _lock) : lock(_lock) {} TryLockSessionResult(const SessionRunInfo& _runInfo) : runInfo(_runInfo) {} // if this is non-null then the session was locked ISessionLock::Ptr lock; // otherwise this contains information about who is locking the session SessionRunInfo runInfo; }; class KDEVPLATFORMSHELL_EXPORT SessionController : public QObject, public KXMLGUIClient { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kdevelop.SessionController") public: - explicit SessionController( QObject *parent = 0 ); + explicit SessionController( QObject *parent = nullptr ); ~SessionController() override; void initialize( const QString& session ); void cleanup(); /// Returns whether the given session can be locked (i. e., is not locked currently). /// @param doLocking whether to really lock the session or just "dry-run" the locking process static TryLockSessionResult tryLockSession(const QString& id); /** * @return true when the given session is currently running, false otherwise */ static bool isSessionRunning(const QString& id); /** * @return information about whether the session @p id is running */ static SessionRunInfo sessionRunInfo(const QString& id); /// The application should call this on startup to tell the /// session-controller about the received arguments. /// Some of them may need to be passed to newly opened sessions. static void setArguments(int argc, char** argv); ///Finds a session by its name or by its UUID Session* session( const QString& nameOrId ) const; virtual ISession* activeSession() const; ISessionLock::Ptr activeSessionLock() const; QList sessionNames() const; Session* createSession( const QString& name ); QList sessions() const; void loadDefaultSession( const QString& session ); void startNewSession(); void loadSession( const QString& nameOrId ); void deleteSession( const ISessionLock::Ptr& lock ); static void deleteSessionFromDisk( const ISessionLock::Ptr& lock ); QString cloneSession( const QString& nameOrid ); /** * Path to session directory for the session with the given @p sessionId. */ static QString sessionDirectory( const QString& sessionId ); static QString cfgSessionGroup(); static QString cfgActiveSessionEntry(); static QT_DEPRECATED QList availableSessionInfo(); // use availableSessionInfos() static SessionInfos availableSessionInfos(); /** * Shows a dialog where the user can choose the session * @param headerText an additional text that will be shown at the top in a label * @param onlyRunning whether only currently running sessions should be shown * @return UUID on success, empty string in any other case */ static QString showSessionChooserDialog(QString headerText = QString(), bool onlyRunning = false); /// Should be called if session to be opened is locked. /// It attempts to bring existing instance's window up via a DBus call; if that succeeds, empty string is returned. /// Otherwise (if the app did not respond) it shows a dialog where the user may choose /// 1) to force-remove the lockfile and continue, /// 2) to select another session via \ref showSessionChooserDialog, /// 3) to quit the current (starting-up) instance. /// @param sessionName session name (for the message) /// @param sessionId current session GUID (to return if user chooses force-removal) /// @param runInfo the run information about the session /// @return new session GUID to try or an empty string if application startup shall be aborted static QString handleLockedSession( const QString& sessionName, const QString& currentSessionId, const SessionRunInfo& runInfo ); void plugActions(); void emitQuitSession() { emit quitSession(); } public Q_SLOTS: // Returns the pretty name of the currently active session (used in the shell integration) virtual Q_SCRIPTABLE QString sessionName(); // Returns the directory associated to the active session (used in the shell integration) virtual Q_SCRIPTABLE QString sessionDir(); Q_SIGNALS: void sessionLoaded( ISession* ); void sessionDeleted( const QString& id); void quitSession(); private: Q_PRIVATE_SLOT( d, void newSession() ) Q_PRIVATE_SLOT( d, void configureSessions() ) Q_PRIVATE_SLOT( d, void deleteCurrentSession() ) Q_PRIVATE_SLOT( d, void renameSession() ) Q_PRIVATE_SLOT( d, void loadSessionFromAction( QAction* ) ) class SessionControllerPrivate* const d; }; } #endif diff --git a/shell/sessiondialog.h b/shell/sessiondialog.h index 9d01a4a32c..478b1ff3ac 100644 --- a/shell/sessiondialog.h +++ b/shell/sessiondialog.h @@ -1,76 +1,76 @@ /* This file is part of KDevelop Copyright 2008 Andreas Pakulat This library 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 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. */ #ifndef KDEVPLATFORM_SESSIONDIALOG_H #define KDEVPLATFORM_SESSIONDIALOG_H #include #include namespace Ui { class SessionDialog; } class QModelIndex; class QItemSelection; class QVariant; namespace KDevelop { class Session; class SessionModel : public QAbstractListModel { Q_OBJECT public: - explicit SessionModel( QObject* parent = 0 ); + explicit SessionModel( QObject* parent = nullptr ); int rowCount( const QModelIndex& = QModelIndex() ) const override; QVariant data( const QModelIndex&, int = Qt::DisplayRole ) const override; QVariant headerData( int, Qt::Orientation, int = Qt::DisplayRole ) const override; bool setData( const QModelIndex&, const QVariant&, int = Qt::DisplayRole ) override; Qt::ItemFlags flags( const QModelIndex& ) const override; void deleteSessions( const QList& ); void activateSession( const QModelIndex& ); void addSession(); void cloneSession( const QModelIndex& ); }; class SessionDialog : public QDialog { Q_OBJECT public: - explicit SessionDialog( QWidget* = 0 ); + explicit SessionDialog( QWidget* = nullptr ); ~SessionDialog() override; private Q_SLOTS: void createSession(); void deleteSession(); void activateSession(); void cloneSession(); void enableButtons( const QModelIndex&, const QModelIndex& ); void enableButtons( const QItemSelection&, const QItemSelection& ); void enableButtons(); private: Ui::SessionDialog* m_ui; SessionModel* m_model; }; } #endif diff --git a/shell/settings/editstyledialog.h b/shell/settings/editstyledialog.h index 36330fb982..926280ffe2 100644 --- a/shell/settings/editstyledialog.h +++ b/shell/settings/editstyledialog.h @@ -1,72 +1,72 @@ /* This file is part of KDevelop * Copyright (C) 2008 Cédric Pasteur 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; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KDEVPLATFORM_EDITSTYLEDIALOG_H #define KDEVPLATFORM_EDITSTYLEDIALOG_H #include #include #include #include "ui_editstyledialog.h" namespace KTextEditor { class Document; class View; } namespace KDevelop { class ISourceFormatter; class SettingsWidget; class SourceFormatterStyle; } /** \short A simple dialog to add preview around a \ref SettingsWidget */ class EditStyleDialog : public QDialog { Q_OBJECT public: EditStyleDialog(KDevelop::ISourceFormatter* formatter, const QMimeType& mime, - const KDevelop::SourceFormatterStyle&, QWidget* parent = 0); + const KDevelop::SourceFormatterStyle&, QWidget* parent = nullptr); ~EditStyleDialog() override; /** \return The string representing the style given by the \ref SettingsWidget. */ QString content(); protected: void init(); public slots: void updatePreviewText(const QString &text); private: KDevelop::ISourceFormatter* m_sourceFormatter; KTextEditor::View* m_view; KTextEditor::Document* m_document; KDevelop::SettingsWidget* m_settingsWidget; QMimeType m_mimeType; QWidget* m_content; Ui::EditStyle m_ui; KDevelop::SourceFormatterStyle m_style; }; #endif // KDEVPLATFORM_EDITSTYLEDIALOG_H diff --git a/shell/settings/environmentwidget.h b/shell/settings/environmentwidget.h index fdc80670e4..97f1e0b4b4 100644 --- a/shell/settings/environmentwidget.h +++ b/shell/settings/environmentwidget.h @@ -1,80 +1,80 @@ /* This file is part of KDevelop Copyright 2006 Adam Treat Copyright 2007 Dukju Ahn This library 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 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. */ #ifndef KDEVPLATFORM_ENVIRONMENTWIDGET_H #define KDEVPLATFORM_ENVIRONMENTWIDGET_H #include #include "ui_environmentwidget.h" class KConfig; class QSortFilterProxyModel; namespace KDevelop { class EnvironmentGroupModel; /** * @short Environment variable setting widget. * This class manages a EnvironmentGroupList and allows one to change the variables and add/remove groups * * @sa EnvPreferences */ class EnvironmentWidget: public QWidget { Q_OBJECT public: - explicit EnvironmentWidget( QWidget *parent = 0 ); + explicit EnvironmentWidget( QWidget *parent = nullptr ); void loadSettings( KConfig* config ); void saveSettings( KConfig* config ); void defaults( KConfig* config ); void setActiveGroup( const QString& group ); Q_SIGNALS: void changed(); private Q_SLOTS: void handleVariableInserted(int column, const QVariant& value); void deleteButtonClicked(); void batchModeEditButtonClicked(); void addGroupClicked(); void cloneGroupClicked(); void removeGroupClicked(); void activeGroupChanged( int ); void enableDeleteButton(); void setAsDefault(); void enableButtons( const QString& ); private: Ui::EnvironmentWidget ui; EnvironmentGroupModel* groupModel; QSortFilterProxyModel* proxyModel; }; } #endif diff --git a/shell/settings/sourceformattersettings.h b/shell/settings/sourceformattersettings.h index 2448bc0d62..e1e2e25a05 100644 --- a/shell/settings/sourceformattersettings.h +++ b/shell/settings/sourceformattersettings.h @@ -1,98 +1,98 @@ /* This file is part of KDevelop * Copyright (C) 2008 Cédric Pasteur 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; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KDEVPLATFORM_SOURCEFORMATTERSETTINGS_H #define KDEVPLATFORM_SOURCEFORMATTERSETTINGS_H #include #include #include #include "sourceformattercontroller.h" #include "ui_sourceformattersettings.h" class QListWidgetItem; namespace KTextEditor { class Document; class View; } namespace KDevelop { class ISourceFormatter; class SourceFormatterStyle; } struct LanguageSettings { LanguageSettings(); QList mimetypes; QSet formatters; // weak pointers to selected formatter and style, no ownership KDevelop::SourceFormatter* selectedFormatter; // Should never be zero KDevelop::SourceFormatterStyle* selectedStyle; // TODO: can this be zero? Assume that not }; /** \short The settings modulefor the Source formatter plugin. * It supports predefined and custom styles. A live preview of the style * is shown on the right side of the page.s */ class SourceFormatterSettings : public KDevelop::ConfigPage, public Ui::SourceFormatterSettingsUI { Q_OBJECT public: - explicit SourceFormatterSettings(QWidget* parent = 0); + explicit SourceFormatterSettings(QWidget* parent = nullptr); ~SourceFormatterSettings() override; QString name() const override; QString fullName() const override; QIcon icon() const override; public slots: void reset() override; void apply() override; void defaults() override; private slots: void deleteStyle(); void editStyle(); void newStyle(); void selectLanguage( int ); void selectFormatter( int ); void selectStyle( int ); void styleNameChanged( QListWidgetItem* ); void somethingChanged(); private: void updatePreview(); QListWidgetItem* addStyle( const KDevelop::SourceFormatterStyle& s ); void enableStyleButtons(); // Language name -> language settings typedef QMap LanguageMap; LanguageMap languages; // formatter name -> formatter. Formatters owned by this typedef QMap FormatterMap; FormatterMap formatters; KTextEditor::Document* m_document; KTextEditor::View* m_view; }; #endif // KDEVPLATFORM_SOURCEFORMATTERSETTINGS_H diff --git a/shell/settings/templateconfig.h b/shell/settings/templateconfig.h index c509b8f681..d8bcb31082 100644 --- a/shell/settings/templateconfig.h +++ b/shell/settings/templateconfig.h @@ -1,49 +1,49 @@ /* * This file is part of KDevelop * Copyright 2012 Miha Čančula * * 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. */ #ifndef KDEVPLATFORM_TEMPLATECONFIG_H #define KDEVPLATFORM_TEMPLATECONFIG_H #include namespace Ui { class TemplateConfig; } class TemplateConfig : public KDevelop::ConfigPage { Q_OBJECT public: - explicit TemplateConfig(QWidget* parent = 0); + explicit TemplateConfig(QWidget* parent = nullptr); ~TemplateConfig() override; QString name() const override; QString fullName() const override; QIcon icon() const override; void reset() override; void apply() override; void defaults() override; private: Ui::TemplateConfig* ui; }; #endif // KDEVPLATFORM_PLUGIN_TEMPLATECONFIG_H diff --git a/shell/settings/templatepage.h b/shell/settings/templatepage.h index 25706f7fb7..f988e098a8 100644 --- a/shell/settings/templatepage.h +++ b/shell/settings/templatepage.h @@ -1,56 +1,56 @@ /* * This file is part of KDevelop * Copyright 2012 Miha Čančula * * 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. */ #ifndef KDEVPLATFORM_TEMPLATEPAGE_H #define KDEVPLATFORM_TEMPLATEPAGE_H #include class QModelIndex; namespace KDevelop { class ITemplateProvider; } namespace Ui { class TemplatePage; } class TemplatePage : public QWidget { Q_OBJECT public: - explicit TemplatePage(KDevelop::ITemplateProvider* provider, QWidget* parent = 0); + explicit TemplatePage(KDevelop::ITemplateProvider* provider, QWidget* parent = nullptr); ~TemplatePage() override; private slots: void loadFromFile(); void getMoreTemplates(); void shareTemplates(); void currentIndexChanged(const QModelIndex& index); void extractTemplate(); private: KDevelop::ITemplateProvider* m_provider; Ui::TemplatePage* ui; }; #endif // KDEVPLATFORM_TEMPLATEPAGE_H diff --git a/shell/settings/uipreferences.h b/shell/settings/uipreferences.h index 0f4845a015..328be87269 100644 --- a/shell/settings/uipreferences.h +++ b/shell/settings/uipreferences.h @@ -1,54 +1,54 @@ /* KDevelop * * Copyright 2007 Andreas Pakulat * * 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. */ #ifndef KDEVPLATFORM_UIPREFERENCES_H #define KDEVPLATFORM_UIPREFERENCES_H #include "configpage.h" namespace Ui{ class UiConfig; } /** @author Andreas Pakulat */ class UiPreferences : public KDevelop::ConfigPage { Q_OBJECT public: explicit UiPreferences(QWidget* parent = nullptr); - ~UiPreferences(); + ~UiPreferences() override; - virtual QString name() const override; - virtual QString fullName() const override; - virtual QIcon icon() const override; + QString name() const override; + QString fullName() const override; + QIcon icon() const override; public Q_SLOTS: // need to customize behaviour - virtual void apply() override; + void apply() override; private: Ui::UiConfig* m_uiconfigUi; }; #endif diff --git a/shell/sourceformattercontroller.h b/shell/sourceformattercontroller.h index 2fe72f5e41..5146c660a1 100644 --- a/shell/sourceformattercontroller.h +++ b/shell/sourceformattercontroller.h @@ -1,165 +1,165 @@ /* This file is part of KDevelop Copyright 2009 Andreas Pakulat Copyright (C) 2008 Cédric Pasteur This library 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 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. */ #ifndef KDEVPLATFORM_SOURCEFORMATTERCONTROLLER_H #define KDEVPLATFORM_SOURCEFORMATTERCONTROLLER_H #include #include #include #include #include #include #include #include #include #include "shellexport.h" namespace KTextEditor { class Document; } class QAction; namespace KDevelop { class Context; class ContextMenuExtension; class ProjectBaseItem; class IDocument; class ISourceFormatter; class IPlugin; struct SourceFormatter { KDevelop::ISourceFormatter* formatter; // style name -> style. style objects owned by this typedef QMap StyleMap; StyleMap styles; // Get a list of supported mime types from the style map. QSet supportedMimeTypes() const { QSet supported; for ( auto style: styles ) { foreach ( auto& item, style->mimeTypes() ) { supported.insert(item.mimeType); } } return supported; } ~SourceFormatter() { qDeleteAll(styles); }; }; /** \short A singleton class managing all source formatter plugins */ class KDEVPLATFORMSHELL_EXPORT SourceFormatterController : public ISourceFormatterController, public KXMLGUIClient { Q_OBJECT public: static QString kateModeLineConfigKey(); static QString kateOverrideIndentationConfigKey(); static QString styleCaptionKey(); static QString styleContentKey(); static QString styleMimeTypesKey(); static QString styleSampleKey(); - explicit SourceFormatterController(QObject *parent = 0); + explicit SourceFormatterController(QObject *parent = nullptr); ~SourceFormatterController() override; void initialize(); void cleanup(); //----------------- Public API defined in interfaces ------------------- /** \return The formatter corresponding to the language * of the document corresponding to the \arg url. */ ISourceFormatter* formatterForUrl(const QUrl &url) override; /** Loads and returns a source formatter for this mime type. * The language is then activated and the style is loaded. * The source formatter is then ready to use on a file. */ ISourceFormatter* formatterForMimeType(const QMimeType& mime) override; /** \return Whether this mime type is supported by any plugin. */ bool isMimeTypeSupported(const QMimeType& mime) override; /** * @brief Instantiate a Formatter for the given plugin and load its configuration. * * @param ifmt The ISourceFormatter interface of the plugin * @return KDevelop::SourceFormatter* the SourceFormatter instance for the plugin, including config items */ SourceFormatter* createFormatterForPlugin(KDevelop::ISourceFormatter* ifmt) const; /** * @brief Find the first formatter which supports a given mime type. */ ISourceFormatter* findFirstFormatterForMimeType(const QMimeType& mime) const; KDevelop::ContextMenuExtension contextMenuExtension(KDevelop::Context* context); KDevelop::SourceFormatterStyle styleForMimeType(const QMimeType& mime) override; KConfigGroup sessionConfig() const; KConfigGroup globalConfig() const; void settingsChanged(); void disableSourceFormatting(bool disable) override; bool sourceFormattingEnabled() override; private Q_SLOTS: void activeDocumentChanged(KDevelop::IDocument *doc); void beautifySource(); void beautifyLine(); void formatFiles(); void documentLoaded( KDevelop::IDocument* ); private: /** \return A modeline string (to add at the end or the beginning of a file) * corresponding to the settings of the active language. */ QString addModelineForCurrentLang(QString input, const QUrl& url, const QMimeType&); /** \return The name of kate indentation mode for the mime type. * examples are cstyle, python, etc. */ QString indentationMode(const QMimeType& mime); void formatDocument(KDevelop::IDocument* doc, ISourceFormatter* formatter, const QMimeType& mime); // Adapts the mode of the editor regarding indentation-style void adaptEditorIndentationMode(KTextEditor::Document* doc, KDevelop::ISourceFormatter* formatter, bool ignoreModeline = false); void formatFiles(QList &list); // GUI actions QAction* m_formatTextAction; QAction* m_formatFilesAction; QAction* m_formatLine; QList m_prjItems; QList m_urls; bool m_enabled; }; } #endif // KDEVPLATFORM_SOURCEFORMATTERMANAGER_H diff --git a/shell/textdocument.h b/shell/textdocument.h index 54f20e3f60..899be6fa72 100644 --- a/shell/textdocument.h +++ b/shell/textdocument.h @@ -1,126 +1,126 @@ /*************************************************************************** * Copyright 2007 Alexander Dymo * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_TEXTDOCUMENT_H #define KDEVPLATFORM_TEXTDOCUMENT_H #include #include #include #include "partdocument.h" #include "shellexport.h" class QMenu; namespace KTextEditor { class View; } namespace KDevelop { /** Text document which represents KTextEditor documents. Usually Kate documents are represented by this class but TextDocument is not limited to Kate. Each conforming text editor will work. */ class KDEVPLATFORMSHELL_EXPORT TextDocument: public PartDocument { Q_OBJECT public: TextDocument(const QUrl &url, ICore*, const QString& encoding ); ~TextDocument() override; - QWidget *createViewWidget(QWidget *parent = 0) override; + QWidget *createViewWidget(QWidget *parent = nullptr) override; KParts::Part *partForView(QWidget *view) const override; bool close(DocumentSaveMode mode = Default) override; bool save(DocumentSaveMode mode = Default) override; DocumentState state() const override; KTextEditor::Cursor cursorPosition() const override; void setCursorPosition(const KTextEditor::Cursor &cursor) override; KTextEditor::Range textSelection() const override; void setTextSelection(const KTextEditor::Range &range) override; QString textLine() const override; QString textWord() const override; bool isTextDocument() const override; KTextEditor::Document* textDocument() const override; QString documentType() const override; QIcon defaultIcon() const override; KTextEditor::View* activeTextView() const override; public Q_SLOTS: void reload() override; protected: Sublime::View *newView(Sublime::Document *doc) override; private: Q_PRIVATE_SLOT(d, void saveSessionConfig()); Q_PRIVATE_SLOT(d, void modifiedOnDisk(KTextEditor::Document *, bool, KTextEditor::ModificationInterface::ModifiedOnDiskReason)); void newDocumentStatus(KTextEditor::Document*); void populateContextMenu(KTextEditor::View*, QMenu*); void textChanged(KTextEditor::Document*); void documentUrlChanged(KTextEditor::Document*); void slotDocumentLoaded(); void documentSaved(KTextEditor::Document*,bool); void repositoryCheckFinished(bool); struct TextDocumentPrivate * const d; friend struct TextDocumentPrivate; }; class KDEVPLATFORMSHELL_EXPORT TextView : public Sublime::View { Q_OBJECT public: explicit TextView(TextDocument* doc); ~TextView() override; - QWidget *createWidget(QWidget *parent = 0) override; + QWidget *createWidget(QWidget *parent = nullptr) override; KTextEditor::View *textView() const; QString viewStatus() const override; QString viewState() const override; void setState(const QString& state) override; void setInitialRange(const KTextEditor::Range& range); KTextEditor::Range initialRange() const; private: void sendStatusChanged(); struct TextViewPrivate* const d; }; } #endif diff --git a/shell/workingsetcontroller.h b/shell/workingsetcontroller.h index 22e4309aa0..e4297984ae 100644 --- a/shell/workingsetcontroller.h +++ b/shell/workingsetcontroller.h @@ -1,127 +1,127 @@ /* Copyright David Nolden 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. */ #ifndef KDEVPLATFORM_WORKINGSETCONTROLLER_H #define KDEVPLATFORM_WORKINGSETCONTROLLER_H #include #include #include #include class QPoint; class QWidget; class QTimer; namespace Sublime { class Area; class AreaIndex; class View; } namespace KDevelop { class ActiveToolTip; class UiController; class MainWindow; class Core; class WorkingSet; class WorkingSetToolTipWidget; class WorkingSetController : public QObject { Q_OBJECT public: WorkingSetController(); void initialize(); void cleanup(); ///Returns a working-set management widget // QWidget* createManagerWidget(QObject* parent); WorkingSet* newWorkingSet(const QString& prefix); /** * Get WorkingSet for given @p id. * * NOTE: Never pass an empty @p id, this means there is no working set * for the given area you got that @p id from. */ WorkingSet* getWorkingSet(const QString& id); QList allWorkingSets() const; //The returned widget is owned by the caller - QWidget* createSetManagerWidget(MainWindow* parent, Sublime::Area* fixedArea = 0); + QWidget* createSetManagerWidget(MainWindow* parent, Sublime::Area* fixedArea = nullptr); void initializeController(UiController* controller); KDevelop::ActiveToolTip* tooltip() const; void showToolTip( KDevelop::WorkingSet* set, const QPoint& pos); Q_SIGNALS: void workingSetAdded(WorkingSet* set); void aboutToRemoveWorkingSet(WorkingSet* set); // Emitted after a working-set in a main-window was switched void workingSetSwitched(); private slots: void areaCreated(Sublime::Area* area); void nextDocument(); void previousDocument(); void showGlobalToolTip(); /** * Disconnect @p oldSet from @p area and save it. Connect @p newSet with @p area. */ void changingWorkingSet( Sublime::Area* area, const QString& oldSet, const QString& newSet); /** * Notify about working set change and setup @p area with contents of @p newSet. */ void changedWorkingSet( Sublime::Area* area, const QString& oldSet, const QString& newSet ); /** * Spawn new WorkingSet when we don't have one already for the view. */ void viewAdded( Sublime::AreaIndex*, Sublime::View* ); /** * Clears the files in the working set */ void clearWorkingSet(Sublime::Area* area); private: WorkingSetToolTipWidget* workingSetToolTip(); void setupActions(); const QString makeSetId(const QString& prefix) const; QSet m_usedIcons; QMap m_workingSets; WorkingSet* m_emptyWorkingSet; QTimer* m_hideToolTipTimer; QPointer m_tooltip; // This is set to true while the working-set controller is forcing a working-set // onto an area. We ignore the low-level feedback then, as we handle the switch on a higher level. bool m_changingWorkingSet; }; } #endif // KDEVPLATFORM_WORKINGSETMANAGER_H diff --git a/shell/workingsets/workingsetwidget.h b/shell/workingsets/workingsetwidget.h index 11615cbed0..a69789cb31 100644 --- a/shell/workingsets/workingsetwidget.h +++ b/shell/workingsets/workingsetwidget.h @@ -1,57 +1,57 @@ /* Copyright David Nolden Copyright 2010 Milian Wolff 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. */ #ifndef KDEVPLATFORM_WORKINGSETWIDGET_H #define KDEVPLATFORM_WORKINGSETWIDGET_H #include #include "workingsettoolbutton.h" namespace Sublime { class Area; } namespace KDevelop { class WorkingSetController; class WorkingSet; /** * One instance of this widget is created per area switcher tab, showing * the currently opened working set for this area. */ class WorkingSetWidget : public WorkingSetToolButton { Q_OBJECT public: - explicit WorkingSetWidget(Sublime::Area* area, QWidget* parent = 0); + explicit WorkingSetWidget(Sublime::Area* area, QWidget* parent = nullptr); void setVisible( bool visible ) override; private slots: void changingWorkingSet(Sublime::Area* area, const QString& from, const QString& to); void setChangedSignificantly(); private: QPointer m_area; }; } #endif // KDEVPLATFORM_WORKINGSETWIDGET_H diff --git a/sublime/aggregatemodel.h b/sublime/aggregatemodel.h index dca2b3aad5..fae9dbdc8c 100644 --- a/sublime/aggregatemodel.h +++ b/sublime/aggregatemodel.h @@ -1,99 +1,99 @@ /*************************************************************************** * Copyright 2007 Alexander Dymo * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_SUBLIMEAGGREGATEMODEL_H #define KDEVPLATFORM_SUBLIMEAGGREGATEMODEL_H #include #include #include #include "sublimeexport.h" class QStandardItemModel; namespace Sublime { /** @short A model to combine several QStandardItemModel's into one. Combine standard models into the aggregate model to display them in the one view. Each new model gets its own parent item to differentiate items between different models, for example: Tea Model: @code - Black - Green - White @endcode Coffee Model: @code - Arabica - Robusta @endcode When aggregated with @code AggregateModel model; model->addModel("Tea", teaModel); model->addModel("Coffee", coffeeModel); @endcode they will look as: @code - Tea - Black - Green - White - Coffee - Arabica - Robusta @endcode @note It is impossible to aggregate any model, aggregation works only for standard models. @note Currently aggregate model displays only 1 column. */ class KDEVPLATFORMSUBLIME_EXPORT AggregateModel: public QAbstractItemModel { Q_OBJECT public: - explicit AggregateModel(QObject *parent = 0); + explicit AggregateModel(QObject *parent = nullptr); ~AggregateModel() override; /**Adds the model and creates a parent item with given @p name in the aggregated model.*/ void addModel(const QString &name, QStandardItemModel *model); /**Removes the model from aggregation.*/ void removeModel(QStandardItemModel *model); //reimplemented methods from QAbstractItemModel Qt::ItemFlags flags(const QModelIndex &index) const override; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QModelIndex parent(const QModelIndex &index) const override; QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; private: struct AggregateModelPrivate *d; }; } #endif diff --git a/sublime/area.h b/sublime/area.h index c8c1f44545..4b5965693e 100644 --- a/sublime/area.h +++ b/sublime/area.h @@ -1,290 +1,290 @@ /*************************************************************************** * Copyright 2006-2007 Alexander Dymo * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_SUBLIMEAREA_H #define KDEVPLATFORM_SUBLIMEAREA_H #include #include "sublimeexport.h" #include "areaindex.h" #include "sublimedefs.h" #include class QAction; namespace Sublime { class AreaIndex; class RootAreaIndex; class Controller; class View; /** @short Area - the universal view container Area contains views and toolviews, knows about their positions and provides functionality to add new (tool)views and remove existing. Area takes care of all placement/configuration details so that in order for @ref MainWindow to show the area it just needs to reconstruct itself according to the area's rules. Usual way of creating an area is: @code Controller *controller = new Controller(); ... //document creation code here Area *area = new Area(controller, "My Area"); area->addView(document->createView()); MainWindow *mw = new MainWindow(controller); controller->show(area, mw); @endcode */ class KDEVPLATFORMSUBLIME_EXPORT Area: public QObject { Q_OBJECT public: /**Creates and area with given @p name and adds it to the @p controller. @param controller is the controller in which this area will be available. @param name should identify this area and be unique for all areas in the controller. @ref QObject::objectName shall be used to get this name after area creation. @param title is the user-visible (translatable) title for the area. Use @ref title and @ref setTitle to operate on the title. This parameter can be omitted and then name will be used as title.*/ Area(Controller *controller, const QString &name, const QString &title = {}); Area(const Area &area); ~Area() override; QString title() const; void setTitle(const QString &title); QString iconName() const; void setIconName(const QString &iconName); /**Adds the @p view to the list of views at the given area index, after the given view @p after. If @p after == 0 && controller()->openAfterCurrent(): @p view is inserted after current view If @p after == 0 && !controller()->openAfterCurrent(): @p view is inserted at the last position. */ - void addView(View *view, AreaIndex *index, View *after = 0); + void addView(View *view, AreaIndex *index, View *after = nullptr); /**Adds the @p view to the list of views at the current area index.*/ - void addView(View *view, View *after = 0); + void addView(View *view, View *after = nullptr); /**Adds the @p view to the area splitting the @p viewToSplit using given @p orientation. @p view Will be in the second child index of the area-index containing the view. */ void addView(View *view, View *viewToSplit, Qt::Orientation orientation); /**Adds the @p view to the area splitting the area index @p indexToSplit using given @p orientation. @p view Will be in the second child index of the area-index containing the view. */ void addView(View *view, AreaIndex *indexToSplit, Qt::Orientation orientation); /**Removes the @p view from the area. Does not delete it. */ View* removeView(View *view); /**@return the list of all views in this area in no particular order. To process the views in ordered manner (tree walk) use @ref walkViews method. This method is added only for convenience.*/ QList views(); /** Removes all views from this area and deletes them. * If an open document has changes, and it is the last view of that document, * the user may push 'Cancel', and the view will stay active. * @param silent If this is true, the user is never asked for feedback. */ void clearViews(bool silent = false); /** * Returns the view that was last stored through setActiveView(view), or zero * if the view was deleted or it was never set. */ View* activeView(); /** * Allows marking a view as active that can later be retrieved through activeView() */ void setActiveView(View* view); /** Closes and deletes the view, asking the user for feedback if needed. * Closes the document if it is the last view. * Does allow breaking the closing process. * If it is the last view of the document that has changes, and the user pushed 'Cancel', * false will be returned, and the view will not be closed. * @param silent If this is false, the user will be asked for feedback. Otherwise he won't. */ bool closeView(View* view, bool silent = false); /**@return the index of view or 0 if it can not be found.*/ AreaIndex *indexOf(View *view); /**@return the root index of the area. Root index always exists so this method will never return 0.*/ RootAreaIndex *rootIndex() const; /**Adds the toolview to the area. Area will use its configuration and restore the proper position for the toolview when necessary. If it has no configuration for this view, it will use @p defaultPosition.*/ void addToolView(View *toolView, Position defaultPosition); /**Removes the toolview from the area.*/ View* removeToolView(View *toolView); /**Moves the toolview to a different position. */ void moveToolView(View *toolView, Position newPosition); /**Raise tool view.*/ void raiseToolView(View *toolView); /**@return the list of toolviews in the area. No particular sort order is guaranteed.*/ QList &toolViews() const; /**@return the current position of @p toolView in the area.*/ Position toolViewPosition(View *toolView) const; /* Returns true if this area actively desires to show a tool view with id of 'id'. The area, of course, will show any tool view added with 'addToolView', however, this method can be used to guess a set of tool views that make most sense to be added. */ bool wantToolView(const QString& id); void setShownToolViews(Sublime::Position pos, const QStringList& ids); QStringList shownToolViews(Sublime::Position pos) const; void setDesiredToolViews( const QMap& desiredToolViews); void setThickness(Sublime::Position pos, int thickness); int thickness(Sublime::Position pos) const; void save(KConfigGroup& group) const; void load(const KConfigGroup& group); /**@return the controller for this area.*/ Controller *controller() const; ///Returns the currently set working-set for this area. The working-set is persistent QString workingSet() const; ///Sets the working-set for this area. The working-set is just a marker, and does nothing ///within Area. ///The actual view management has to be implemented in the entity that knows more ///about possible views, documents, etc. (kdevplatform/shell) ///@warning (KDevelop): Before calling this, make sure that all views are saved! (see IDocumentController::saveAllDocumentsForWindow) void setWorkingSet(QString name); /**Walker mode to determine the behavior of area walkers.*/ enum WalkerMode { StopWalker, /**< Stop after processing this area index or toolview */ ContinueWalker /**< Continue walking */ }; /**Walks the tree of area indices and executes the operator. It will always walk the tree of views from top to bottom from left to right. Operator should be the class with WalkerResult operator()(AreaIndex *index) method. That method should return Area::StopWalker if the walker has to stop at current index or Area::ContinueWalker to continue. Example (operator to print the indices, assumes hypothetical operator <<()): @code struct MyOperator { WalkerMode operator()(AreaIndex *index) { std::cerr << index << std::endl; return Area::ContinueWalker; } }; ... MyOperator op; walkViews(op, rootIndex()) @endcode*/ template void walkViews(Operator &op, AreaIndex *index); /**Walks the list of toolviews. The order in which toolviews are walked is not specified. Operator should be the class with bool operator()(View *view, Sublime::Position position) method. That method should return Area::StopWalker if the walker has to stop at current index or Area::ContinueWalker to continue. Example (operator to print the list of views): @code struct MyOperator { WalkerMode operator()(View *view, Sublime::Position position) { std::cerr << view << " at position " << position << std::endl; return Area::ContinueWalker; } }; ... MyOperator op; walkToolViews(op, Sublime::AllPositions) @endcode */ template void walkToolViews(Operator &op, Positions positions); /** Adds an action to the area. They will be made available from different places, like the Area Display*/ void addAction(QAction* action); /** @returns the actions related to the area */ QList actions() const; /** * Closes all the views and requests the working set to be cleared. * Works even though the area isn't opened yet */ void clearDocuments(); Q_SIGNALS: /**Emitted when a new view is added to the area.*/ void viewAdded(Sublime::AreaIndex*, Sublime::View*); /**Emitted when a view is going to be removed from the area.*/ void aboutToRemoveView(Sublime::AreaIndex*, Sublime::View*); /**Emitted when a view was removed from the area.*/ void viewRemoved(Sublime::AreaIndex*, Sublime::View*); /**Emitted when a new toolview is added to the area.*/ void toolViewAdded(Sublime::View*, Sublime::Position); /**Emitted when a toolview is requesting to be raised.*/ void requestToolViewRaise(Sublime::View*); /**Emitted when a toolview is going to be removed from the area.*/ void aboutToRemoveToolView(Sublime::View*, Sublime::Position); /**Emitted when a toolview is moved to a different position.*/ void toolViewMoved(Sublime::View*, Sublime::Position); /**Emitted before the working-set is changed.*/ void changingWorkingSet(Sublime::Area* area, QString from, QString to); /**Emitted after the working-set was changed.*/ void changedWorkingSet(Sublime::Area* area, QString from, QString to); /** notifies the working set that it should clear */ void clearWorkingSet(Sublime::Area* area); private Q_SLOTS: void positionChanged(Sublime::View*, int); void actionDestroyed(QObject* action); private: template WalkerMode walkViewsInternal(Operator &op, AreaIndex *index); void initialize(); struct AreaPrivate *const d; }; } #include "areawalkers.h" #endif diff --git a/sublime/container.h b/sublime/container.h index 42b37e9f29..580c1d587e 100644 --- a/sublime/container.h +++ b/sublime/container.h @@ -1,119 +1,119 @@ /*************************************************************************** * Copyright 2006-2007 Alexander Dymo * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_SUBLIMECONTAINER_H #define KDEVPLATFORM_SUBLIMECONTAINER_H #include #include "urldocument.h" #include "sublimeexport.h" class QMenu; class QBoxLayout; class QPaintEvent; namespace Sublime { class View; class Document; /** @short Container for the widgets. This container is placed inside mainwindow splitters to show widgets for views in the area. */ class KDEVPLATFORMSUBLIME_EXPORT Container: public QWidget { Q_OBJECT public: - explicit Container(QWidget *parent = 0); + explicit Container(QWidget *parent = nullptr); ~Container() override; /**Adds the widget for given @p view to the container.*/ void addWidget(Sublime::View* view, int position = -1); /**Removes the widget from the container.*/ void removeWidget(QWidget *w); /** @return true if widget is placed inside this container.*/ bool hasWidget(QWidget *w); QList views() const; int count() const; QWidget *currentWidget() const; void setCurrentWidget(QWidget *w); QWidget *widget(int i) const; int indexOf(QWidget *w) const; View *viewForWidget(QWidget *w) const; void setTabBarHidden(bool hide); void setTabColor(const View* view, const QColor& color); void setTabColors(const QHash& colors); void resetTabColors(const QColor& color); /** Adds a corner widget to the left of this containers tab-bar. To remove it again, just delete it. * The ownership otherwise goes to the container. */ void setLeftCornerWidget(QWidget* widget); void showTooltipForTab(int tab); bool isCurrentTab(int tab) const; /// @return Rect in global position of the tab identified by index @p tab QRect tabRect(int tab) const; static bool configTabBarVisible(); Q_SIGNALS: void activateView(Sublime::View* view); void requestClose(QWidget *w); /** * This signal is emitted whenever the users double clicks on the free * space next to the tab bar. Typically, a new document should be * created. */ void newTabRequested(); void tabContextMenuRequested(Sublime::View* view, QMenu* menu); /** * @p view The view represented by the tab that was hovered * @p Container The tab container that triggered the event * @p idx The index of the tab that was hovered */ void tabToolTipRequested(Sublime::View* view, Sublime::Container* container, int idx); void tabDoubleClicked(Sublime::View* view); private Q_SLOTS: void widgetActivated(int idx); void documentTitleChanged(Sublime::Document* doc); void statusIconChanged(Sublime::Document*); void statusChanged(Sublime::View *view); void requestClose(int idx); void tabMoved(int from, int to); void contextMenu(const QPoint&); void doubleClickTriggered(int tab); void documentListActionTriggered(QAction*); private: Sublime::View* currentView() const; struct ContainerPrivate * const d; }; } #endif diff --git a/sublime/controller.h b/sublime/controller.h index 5ec130737f..afb6f372b6 100644 --- a/sublime/controller.h +++ b/sublime/controller.h @@ -1,200 +1,200 @@ /*************************************************************************** * Copyright 2006-2007 Alexander Dymo * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_SUBLIMECONTROLLER_H #define KDEVPLATFORM_SUBLIMECONTROLLER_H #include #include "sublimedefs.h" #include "sublimeexport.h" #include "mainwindowoperator.h" namespace Sublime { class Area; class AreaIndex; class Document; class MainWindow; /** @short Handles association of areas to main windows. Whereas the MainWindow class can be told to show arbitrary Area instance, this class establishes more high-level rules based on the following assumptions: 1. It's desirable to have a list of "area types" -- basically string, and be able to switch each main window between those "area types". For example, to switch main window between "Code" and "Debug" 2. It's also desirable to save the state of area -- like the set of toolviews, position of toolviews, etc. This need to be done per-main window, so that "code" area of one window is allowed to be different from "code" area of another window. 3. Is it desirable to be able to reset an area of given type in a given main window to a default state. The current implementation achieves those goals as follows. 1. Controller keeps a list of default areas. Those areas are not shown by any main window, and never modified as result of user actions. They are directly constructed by kdevelop core. Those areas are returned by the ::defaultAreas method. Each Area instance in the list provides area type id, and human name of the area -- via Area::objectName and Area::title methods respectively. All methods in this class accept area id, and human name of the area is only used to present the area type to the user, for selection. 2. Controller also keeps a list of MainWindow instances that it manages. For each instance, it keeps a list of areas private to the MainWindow instance. There's one area for each area in defaultAreas. That is, for each area type, there's one area in defaultAreas, and one area per each main window 3. It's possible to switch a given main window to display an area of the given type -- which finds the area with the given id in the list of area private to that main window, and switches the main window to the found area. When we create a new main window, we create fresh set of private areas by cloning the default areas. An alternative approach would be to create a clone only when we try to show a specific area type in a main window. However, I think that knowing that each main window has its Area instance for each area type simplifies the code. For example, most of the time, during restoring areas we'd need per-window area instances anyway. Of course, we can introduce a method demand_area_type(MainWindow*, QString) that clones the default area of the necessary type, but I don't see what that will buy us. Controller has to exist before any area, document or mainwindow can be created. There's no point in having two controllers for one application unless they need to show completely different sets of areas. */ class KDEVPLATFORMSUBLIME_EXPORT Controller: public QObject, public MainWindowOperator { Q_OBJECT public: - explicit Controller(QObject *parent = 0); + explicit Controller(QObject *parent = nullptr); ~Controller() override; /** Add the area to the set of default areas in this controller. */ void addDefaultArea(Area *area); /** Return the list of default areas. */ const QList &defaultAreas() const; /** Return the default area with given @p id.*/ Area *defaultArea(const QString &id) const; /** Add a main window to the set of of windows managed by this controller. The ownership of the window is passed to the controller. The window will be associated with a set of areas created by cloning the current defaultAreas. */ void addMainWindow(MainWindow* mainWindow); /** Return the set of MainWindow instances managed by *this. */ const QList &mainWindows() const; /** Return all areas associated with the main window with the specified index. */ const QList &areas(int mainWindow) const; /** Return all areas associated with the main window with the specified index. */ const QList &areas(MainWindow* mainWindow) const; /** Return the area with the given in main window specified by its index, @p mainWindow. */ Area *area(int mainWindow, const QString& id) const; /** Returns the area that contains the given view. * */ Area* areaForView(View* view) const; /**Shows an @p area in @p mainWindow. @todo Remove this method */ void showArea(Area *area, MainWindow *mainWindow); /** Show area with the id of @p areaTypeId in @p mainWindow. */ void showArea(const QString& areaTypeId, MainWindow *mainWindow); /** Make the tool configuration of the area currently shown in @p mainWindow match those of default area with the same area type. */ void resetCurrentArea(MainWindow *mainWindow); /** Return the list of all areas, including default area and area private to each main window. */ const QList &allAreas() const; /**@return the list of documents created in this controller.*/ const QList &documents() const; void setStatusIcon(Document* document, const QIcon& icon); bool openAfterCurrent() const; bool arrangeBuddies() const; void loadSettings(); public Q_SLOTS: //@todo adymo: this should not be a part of public API /**Area can connect to this slot to release itself from its mainwindow.*/ void areaReleased(); /**Releases @p area from its mainwindow.*/ void areaReleased(Sublime::Area *area); protected: bool eventFilter(QObject *obj, QEvent *ev) override; void showAreaInternal(Area* area, MainWindow *mainWindow); private Q_SLOTS: void notifyToolViewRemoved(Sublime::View *view, Sublime::Position); void notifyToolViewAdded(Sublime::View *view, Sublime::Position); void notifyViewRemoved(Sublime::AreaIndex*, Sublime::View *view); void notifyViewAdded(Sublime::AreaIndex*, Sublime::View *view); Q_SIGNALS: void aboutToRemoveToolView(Sublime::View*); void toolViewAdded(Sublime::View*); void aboutToRemoveView(Sublime::View*); void viewAdded(Sublime::View*); void toolViewMoved(Sublime::View*); void mainWindowAdded(Sublime::MainWindow*); void areaCreated(Sublime::Area* area); private: void init(); void removeArea(Sublime::Area*); // called by Sublime::Area void removeDocument(Sublime::Document*); // called by Sublime::Document /**Adds the document to the controller, used by Document class. @todo adymo: refactor*/ void addDocument(Document *document); struct ControllerPrivate *const d; friend class Area; friend class Document; }; } #endif diff --git a/sublime/document.h b/sublime/document.h index c00638f316..2e0001373b 100644 --- a/sublime/document.h +++ b/sublime/document.h @@ -1,146 +1,146 @@ /*************************************************************************** * Copyright 2006-2007 Alexander Dymo * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_SUBLIMEDOCUMENT_H #define KDEVPLATFORM_SUBLIMEDOCUMENT_H #include #include #include "sublimeexport.h" class QIcon; class QWidget; namespace Sublime { class Area; class View; class Controller; /** @short Abstract base class for all Sublime documents Subclass from Document and implement createViewWidget() method to return a new widget for a view. */ class KDEVPLATFORMSUBLIME_EXPORT Document: public QObject { Q_OBJECT public: /**Creates a document and adds it to a @p controller.*/ Document(const QString &title, Controller *controller); ~Document() override; /**@return the new view for this document. @note it will not create a widget, just return a view object.*/ View *createView(); /**@return the list of all views in all areas for this document.*/ const QList &views() const; /**@return the controller for this document.*/ Controller *controller() const; /**@return the document title.*/ enum TitleType { Normal, Extended}; virtual QString title(TitleType type = Normal) const; /**Set the document title.*/ void setTitle(const QString& newTitle); void setToolTip(const QString& newToolTip); QString toolTip() const; /**@return the type of document which can be written to config.*/ virtual QString documentType() const = 0; /**@return the specifics of this document which can be written to config.*/ virtual QString documentSpecifier() const = 0; /** * If the document is in a state where data may be lost while closking, * asks the user whether he really wants to close the document. * * This function may also take actions like saving the document before closing * if the user desires so. * * @return true if the document is allowed to be closed, otherwise false. * * The default implementation always returns true. * * */ virtual bool askForCloseFeedback(); /**Should try closing the document, eventually asking the user for feedback. * *If closing is successful, all views should be deleted, and the document itself *be scheduled for deletion using deleteLater(). * * @param silent If this is true, the user must not be asked. * * Returns whether closing was successful (The user did not push 'Cancel') */ virtual bool closeDocument(bool silent = false); void setStatusIcon(QIcon icon); /** * @return The status icon of the document. */ QIcon statusIcon() const; /** * @return The status icon of the document, or, if none is present, an icon * that resembles the document, i.e. based on its mime type. * @see defaultIcon() */ QIcon icon() const; /** * Optionally override this to return a default icon when no status * icon is set for the document. The default returns an invalid icon. */ virtual QIcon defaultIcon() const; Q_SIGNALS: /**Emitted when the document is about to be deleted but is still in valid state.*/ void aboutToDelete(Sublime::Document *doc); /**Emitted when the document's title is changed.*/ void titleChanged(Sublime::Document *doc); /**Emitted when the document status-icon has changed */ void statusIconChanged(Sublime::Document *doc); protected: /**Creates and returns the new view. Reimplement in subclasses to instantiate views of derived from Sublime::View classes.*/ virtual View *newView(Document *doc); /**Reimplement this to create and return the new widget to display this document in the view. This method is used by View class when it is asked for its widget.*/ - virtual QWidget *createViewWidget(QWidget *parent = 0) = 0; + virtual QWidget *createViewWidget(QWidget *parent = nullptr) = 0; /** Closes all views associated to this document */ virtual void closeViews(); private: struct DocumentPrivate *const d; friend struct DocumentPrivate; friend class View; }; } #endif diff --git a/sublime/ideallayout.h b/sublime/ideallayout.h index 6b469cd888..b40328f93a 100644 --- a/sublime/ideallayout.h +++ b/sublime/ideallayout.h @@ -1,90 +1,90 @@ /* Copyright 2007 Roberto Raggi Copyright 2007 Hamish Rodda Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE KDEVELOP TEAM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef KDEVPLATFORM_SUBLIME_IDEALLAYOUT_H #define KDEVPLATFORM_SUBLIME_IDEALLAYOUT_H #include #include #include #include "sublimedefs.h" #define IDEAL_LAYOUT_MARGIN 0 #define IDEAL_LAYOUT_SPACING 2 class QAction; class KActionCollection; namespace Sublime { class IdealDockWidget; class IdealButtonBarLayout: public QLayout { Q_OBJECT public: - explicit IdealButtonBarLayout(Qt::Orientation orientation, QWidget *parent = 0); + explicit IdealButtonBarLayout(Qt::Orientation orientation, QWidget *parent = nullptr); ~IdealButtonBarLayout() override; void setHeight(int height); inline Qt::Orientation orientation() const; Qt::Orientations expandingDirections() const override; QSize minimumSize() const override; QSize sizeHint() const override; void setGeometry(const QRect &rect) override; void addItem(QLayoutItem *item) override; QLayoutItem* itemAt(int index) const override; QLayoutItem* takeAt(int index) override; int count() const override; void invalidate() override; protected: int doVerticalLayout(const QRect &rect, bool updateGeometry = true) const; int doHorizontalLayout(const QRect &rect, bool updateGeometry = true) const; private: QList _items; Qt::Orientation _orientation; int _height; mutable bool m_minSizeDirty : 1; mutable bool m_sizeHintDirty : 1; mutable bool m_layoutDirty : 1; mutable QSize m_min; mutable QSize m_hint; }; } #endif diff --git a/sublime/idealtoolbutton.h b/sublime/idealtoolbutton.h index cd63af0863..619a7088e4 100644 --- a/sublime/idealtoolbutton.h +++ b/sublime/idealtoolbutton.h @@ -1,46 +1,46 @@ /* Copyright 2007 Roberto Raggi Copyright 2007 Hamish Rodda Copyright 2011 Alexander Dymo Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE KDEVELOP TEAM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef IDEALTOOLBUTTON_H #define IDEALTOOLBUTTON_H #include class IdealToolButton: public QToolButton { Q_OBJECT public: - explicit IdealToolButton(Qt::DockWidgetArea area, QWidget *parent = 0); + explicit IdealToolButton(Qt::DockWidgetArea area, QWidget *parent = nullptr); Qt::Orientation orientation() const; QSize sizeHint() const override; protected: void paintEvent(QPaintEvent *event) override; private: Qt::DockWidgetArea _area; }; #endif // IDEALTOOLBUTTON_H diff --git a/sublime/tooldocument.h b/sublime/tooldocument.h index c73b114385..fcfd14a4e6 100644 --- a/sublime/tooldocument.h +++ b/sublime/tooldocument.h @@ -1,91 +1,91 @@ /*************************************************************************** * Copyright 2006-2007 Alexander Dymo * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_SUBLIMETOOLDOCUMENT_H #define KDEVPLATFORM_SUBLIMETOOLDOCUMENT_H #include "document.h" #include "sublimeexport.h" class QAction; namespace Sublime { class ToolDocument; /** @short Factory to create widgets for toolviews */ class KDEVPLATFORMSUBLIME_EXPORT ToolFactory { public: virtual ~ToolFactory() {} - virtual QWidget* create(ToolDocument *doc, QWidget *parent = 0) = 0; + virtual QWidget* create(ToolDocument *doc, QWidget *parent = nullptr) = 0; virtual QList toolBarActions( QWidget* viewWidget ) const = 0; virtual QList contextMenuActions( QWidget* viewWidget ) const = 0; virtual QString id() const = 0; }; /** @short Simple factory that just creates a new widget of given type */ template class SimpleToolWidgetFactory: public ToolFactory { public: SimpleToolWidgetFactory(const QString &id): ToolFactory(), m_id(id) {} - virtual QWidget* create(ToolDocument * /*doc*/, QWidget *parent = 0) override + QWidget* create(ToolDocument * /*doc*/, QWidget *parent = nullptr) override { return new Widget(parent); } - virtual QList toolBarActions( QWidget* ) const override { return QList(); } - virtual QList< QAction* > contextMenuActions(QWidget* /*viewWidget*/) const override { return QList(); } - virtual QString id() const override { return m_id; } + QList toolBarActions( QWidget* ) const override { return QList(); } + QList< QAction* > contextMenuActions(QWidget* /*viewWidget*/) const override { return QList(); } + QString id() const override { return m_id; } virtual bool viewsWantProgressIndicator() const { return false; } private: QString m_id; }; /** @short Document to represent and manage widgets as toolviews */ class KDEVPLATFORMSUBLIME_EXPORT ToolDocument: public Document { Q_OBJECT public: /**Initializes tool document with given @p factory. Document takes ownership over the factory and deletes it together with itself*/ ToolDocument(const QString &title, Controller *controller, ToolFactory *factory); - ~ToolDocument(); + ~ToolDocument() override; - virtual QString documentType() const override; + QString documentType() const override; - virtual QString documentSpecifier() const override; + QString documentSpecifier() const override; protected: - virtual QWidget *createViewWidget(QWidget *parent = 0) override; + QWidget *createViewWidget(QWidget *parent = nullptr) override; ToolFactory *factory() const; private: struct ToolDocumentPrivate * const d; friend class View; }; } #endif diff --git a/sublime/urldocument.h b/sublime/urldocument.h index b30275c4c4..50cffc0c12 100644 --- a/sublime/urldocument.h +++ b/sublime/urldocument.h @@ -1,65 +1,65 @@ /*************************************************************************** * Copyright 2006-2007 Alexander Dymo * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_URLDOCUMENT_H #define KDEVPLATFORM_URLDOCUMENT_H #include #include "sublimeexport.h" #include "document.h" namespace Sublime { /** @short Basic document that has an URL. */ class KDEVPLATFORMSUBLIME_EXPORT UrlDocument: public Document { Q_OBJECT public: UrlDocument(Controller *controller, const QUrl &url); ~UrlDocument() override; QString documentType() const override; QString documentSpecifier() const override; QUrl url() const; /** * @return the icon for the mimetype of the document url. */ QIcon defaultIcon() const override; QString title(TitleType type) const override; protected: - QWidget *createViewWidget(QWidget *parent = 0) override; + QWidget *createViewWidget(QWidget *parent = nullptr) override; void setUrl(const QUrl& newUrl); private: struct UrlDocumentPrivate * const d; }; } #endif diff --git a/sublime/view.h b/sublime/view.h index 7d59744c4e..7580660f19 100644 --- a/sublime/view.h +++ b/sublime/view.h @@ -1,112 +1,112 @@ /*************************************************************************** * Copyright 2006-2007 Alexander Dymo * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_SUBLIMEVIEW_H #define KDEVPLATFORM_SUBLIMEVIEW_H #include #include #include "sublimeexport.h" class QAction; namespace Sublime { class Document; /** @short View - the wrapper to the widget that knows about its document Views are the convenient way to manage a widget. It is specifically designed to be light and fast. Use @ref Document::createView() to get the new view for the document and call @ref View::widget() to create and get the actual widget. It is not possible to create a view by hand. You need either subclass it or use a Document. If you create a subclass of View you need to override Sublime::View::createWidget to provide a custom widget for your view. */ class KDEVPLATFORMSUBLIME_EXPORT View: public QObject { Q_OBJECT public: enum WidgetOwnership { TakeOwnership, DoNotTakeOwnerShip }; ~View() override; /**@return the toolbar actions for this view, this needs to be called _after_ the first call to widget() */ QList toolBarActions() const; /**@return the toolbar actions for this view, this needs to be called _after_ the first call to widget() */ QList contextMenuActions() const; /**@return the document for this view.*/ Document *document() const; /**@return widget for this view (creates it if it's not yet created).*/ - QWidget *widget(QWidget *parent = 0); + QWidget *widget(QWidget *parent = nullptr); /**@return true if this view has an initialized widget.*/ bool hasWidget() const; /// Retrieve information to be placed in the status bar. virtual QString viewStatus() const; /// Retrieve view state for saving into configuration. virtual QString viewState() const; /// Restore view state from configuration virtual void setState(const QString& state); void notifyPositionChanged(int newPositionInArea); Q_SIGNALS: void raise(Sublime::View*); /// Notify that the status for this document has changed void statusChanged(Sublime::View*); void positionChanged(Sublime::View*, int); public Q_SLOTS: void requestRaise(); protected: View(Document *doc, WidgetOwnership ws = DoNotTakeOwnerShip ); /** * override this function to create a custom widget in your View subclass * @param parent the parent widget * @returns a new widget which is used for this view */ virtual QWidget *createWidget(QWidget *parent); private: Q_PRIVATE_SLOT(d, void unsetWidget()) //copy is not allowed, create a new view from the document instead View(const View &v); struct ViewPrivate *const d; friend class Document; }; } Q_DECLARE_METATYPE(Sublime::View*) #endif diff --git a/template/filters/kdevfilters.h b/template/filters/kdevfilters.h index 6b95eb90c9..c2e0a18b9f 100644 --- a/template/filters/kdevfilters.h +++ b/template/filters/kdevfilters.h @@ -1,94 +1,94 @@ /* This file is part of KDevelop Copyright 2012 Miha Čančula This library 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 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. */ #ifndef KDEVPLATFORM_KDEVFILTERS_H #define KDEVPLATFORM_KDEVFILTERS_H #include #include #include #include namespace KDevelop { class CamelCaseFilter : public Grantlee::Filter { public: QVariant doFilter(const QVariant& input, const QVariant& argument = QVariant(), bool autoescape = false) const override; }; class LowerCamelCaseFilter : public Grantlee::Filter { public: QVariant doFilter(const QVariant& input, const QVariant& argument = QVariant(), bool autoescape = false) const override; }; class UnderscoreFilter : public Grantlee::Filter { public: QVariant doFilter(const QVariant& input, const QVariant& argument = QVariant(), bool autoescape = false) const override; }; class UpperFirstFilter : public Grantlee::Filter { public: QVariant doFilter(const QVariant& input, const QVariant& argument = QVariant(), bool autoescape = false) const override; }; class SplitLinesFilter : public Grantlee::Filter { public: QVariant doFilter(const QVariant& input, const QVariant& argument = QVariant(), bool autoescape = false) const override; }; class ArgumentTypeFilter : public Grantlee::Filter { public: QVariant doFilter(const QVariant& input, const QVariant& argument = QVariant(), bool autoescape = false) const override; }; class KDevFilters : public QObject, public Grantlee::TagLibraryInterface { Q_OBJECT Q_INTERFACES(Grantlee::TagLibraryInterface) Q_PLUGIN_METADATA(IID "org.grantlee.TagLibraryInterface") public: - explicit KDevFilters(QObject* parent = 0, const QVariantList &args = QVariantList()); + explicit KDevFilters(QObject* parent = nullptr, const QVariantList &args = QVariantList()); ~KDevFilters() override; QHash< QString, Grantlee::Filter* > filters(const QString& name = QString()) override; }; } #endif // KDEVPLATFORM_KDEVFILTERS_H diff --git a/tests/modeltest.h b/tests/modeltest.h index 5a215e36b4..5ddf1a048b 100644 --- a/tests/modeltest.h +++ b/tests/modeltest.h @@ -1,78 +1,78 @@ /**************************************************************************** ** ** Copyright (C) 2007 Trolltech ASA. All rights reserved. ** ** This file is part of the Qt Concurrent project on Trolltech Labs. ** ** This file may be used under the terms of the GNU General Public ** License version 2.0 as published by the Free Software Foundation ** and appearing in the file LICENSE.GPL included in the packaging of ** this file. Please review the following information to ensure GNU ** General Public Licensing requirements will be met: ** http://www.trolltech.com/products/qt/opensource.html ** ** If you are unsure which license is appropriate for your use, please ** review the following information: ** http://www.trolltech.com/products/qt/licensing.html or contact the ** sales department at sales@trolltech.com. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ****************************************************************************/ #ifndef KDEVPLATFORM_MODELTEST_H #define KDEVPLATFORM_MODELTEST_H #include #include #include #include "testsexport.h" class KDEVPLATFORMTESTS_EXPORT ModelTest : public QObject { Q_OBJECT public: - ModelTest(QAbstractItemModel *model, QObject *parent = 0); + ModelTest(QAbstractItemModel *model, QObject *parent = nullptr); private Q_SLOTS: void nonDestructiveBasicTest(); void rowCount(); void columnCount(); void hasIndex(); void index(); void parent(); void data(); protected Q_SLOTS: void runAllTests(); void layoutAboutToBeChanged(); void layoutChanged(); void rowsAboutToBeInserted(const QModelIndex &parent, int start, int end); void rowsInserted(const QModelIndex & parent, int start, int end); void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); void rowsRemoved(const QModelIndex & parent, int start, int end); private: void checkChildren(const QModelIndex &parent, int currentDepth = 0); QAbstractItemModel *model; struct Changing { QModelIndex parent; int oldSize; QVariant last; QVariant next; }; QStack insert; QStack remove; bool fetchingMore; QList changing; }; #endif diff --git a/tests/testfile.h b/tests/testfile.h index 90539a0417..ddf49f4598 100644 --- a/tests/testfile.h +++ b/tests/testfile.h @@ -1,167 +1,167 @@ /* This file is part of KDevelop Copyright 2010 Niko Sams Copyright 2011 Milian Wolff 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. */ #ifndef KDEVPLATFORM_TESTFILE_H #define KDEVPLATFORM_TESTFILE_H #include #include #include "testsexport.h" namespace KDevelop { class TestProject; /** * Helper file to parse a file using the full KDevelop architecture. * * The file will be added to the background parser, and eventually * parsed by a fitting language plugin, just like a normal file * would be in an actual KDevelop instance. * * Example usage: * \code * TestFile file("... * @endcode */ - TestFile(const QString& contents, const QString& fileExtension, KDevelop::TestProject *project = 0, + TestFile(const QString& contents, const QString& fileExtension, KDevelop::TestProject *project = nullptr, const QString& dir = QString()); /** * Create a temporary file from @p contents with the same file basename as * @p other but with the given @p fileExtension. * * @param fileExtension the new file extension without the dot. * @param other a different TestFile which is used for this file's basename * * This can be used to create e.g. .cpp/.h file pairs: * * @code * TestFile header("...", "h"); * TestFile impl("...", "cpp", &header); * @endcode */ TestFile(const QString& contents, const QString& fileExtension, const TestFile* base); /** * Removes temporary file and cleans up. */ ~TestFile() override; /** * Returns the URL to this file. */ IndexedString url() const; /** * Trigger (re-)parsing of this file with given @p features and @p priority. * * @see KDevelop::DUChain::updateContextForUrl */ void parse(TopDUContext::Features features = TopDUContext::AllDeclarationsContextsAndUses, int priority = 1); /** * Convenience method: * Trigger parse and wait for the file to be parsed. Internally calls waitForParsed() * * @see waitForParsed() * @see parse() */ bool parseAndWait(TopDUContext::Features features = TopDUContext::AllDeclarationsContextsAndUses, int priority = 1, int timeout = 1000); /** * Blocks current thread and waits until the file has been parsed. * * If it has waited longer than @p timeout ms, we return false * and assume something went wrong. * * Otherwise true is returned, indicating parsing finished * within the timeout interval. */ bool waitForParsed(int timeout = 1000); /** * Check whether the file has been processed after the last call to @c parse(). */ bool isReady() const; /** * Returns the @c TopDUContext for the current file, if it has been successfully parsed. */ KDevelop::ReferencedTopDUContext topContext(); /** * Change the file contents to @p contents. * * Use this to test behavior of your parsing code over * file changes. */ void setFileContents(const QString& contents); /** * Read the files contents and return them. */ QString fileContents() const; /** * Set to true when you want to keep the DUChain data. * * By default the DUChain data is removed on destruction of the TestFile. */ void setKeepDUChainData(bool keep); bool keepDUChainData(); private: struct TestFilePrivate; TestFilePrivate* d; Q_PRIVATE_SLOT(d, void updateReady(const KDevelop::IndexedString& url, KDevelop::ReferencedTopDUContext topContext)) }; } #endif // KDEVPLATFORM_TESTFILE_H diff --git a/tests/testproject.h b/tests/testproject.h index 349e356297..10dd2eecc9 100644 --- a/tests/testproject.h +++ b/tests/testproject.h @@ -1,102 +1,102 @@ /*************************************************************************** * Copyright 2010 Niko Sams * * Copyright 2012 Milian Wolff * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_TEST_PROJECT_H #define KDEVPLATFORM_TEST_PROJECT_H #include #include #include #include #include "testsexport.h" #include namespace KDevelop { /** * Dummy Project than can be used for Unit Tests. * * Currently only FileSet methods are implemented. */ class KDEVPLATFORMTESTS_EXPORT TestProject : public IProject { Q_OBJECT public: /** * @p url Path to project directory. */ - TestProject(const Path& url = Path(), QObject* parent = 0); + TestProject(const Path& url = Path(), QObject* parent = nullptr); ~TestProject() override; - IProjectFileManager* projectFileManager() const override { return 0; } - IBuildSystemManager* buildSystemManager() const override { return 0; } - IPlugin* managerPlugin() const override { return 0; } - IPlugin* versionControlPlugin() const override { return 0; } + IProjectFileManager* projectFileManager() const override { return nullptr; } + IBuildSystemManager* buildSystemManager() const override { return nullptr; } + IPlugin* managerPlugin() const override { return nullptr; } + IPlugin* versionControlPlugin() const override { return nullptr; } ProjectFolderItem* projectItem() const override; void setProjectItem(ProjectFolderItem* item); int fileCount() const { return 0; } - ProjectFileItem* fileAt( int ) const { return 0; } + ProjectFileItem* fileAt( int ) const { return nullptr; } QList files() const; QList< ProjectBaseItem* > itemsForPath(const IndexedString&) const override { return QList< ProjectBaseItem* >(); } QList< ProjectFileItem* > filesForPath(const IndexedString&) const override; QList< ProjectFolderItem* > foldersForPath(const IndexedString&) const override { return QList(); } void reloadModel() override { } void close() override {} Path projectFile() const override; KSharedConfigPtr projectConfiguration() const override { return m_projectConfiguration; } void addToFileSet( ProjectFileItem* file) override; void removeFromFileSet( ProjectFileItem* file) override; QSet fileSet() const override { return m_fileSet; } bool isReady() const override { return true; } void setPath(const Path& path); Path path() const override; QString name() const override { return QStringLiteral("Test Project"); } bool inProject(const IndexedString& path) const override; void setReloadJob(KJob* ) override {} private: QSet m_fileSet; Path m_path; ProjectFolderItem* m_root; KSharedConfigPtr m_projectConfiguration; }; /** * ProjectController that can clear open projects. Useful in Unit Tests. */ class KDEVPLATFORMTESTS_EXPORT TestProjectController : public ProjectController { Q_OBJECT public: TestProjectController(Core* core) : ProjectController(core) {} public: using ProjectController::addProject; using ProjectController::takeProject; void initialize() override; }; } #endif diff --git a/util/autoorientedsplitter.h b/util/autoorientedsplitter.h index 2b12a45ad5..e06a192352 100644 --- a/util/autoorientedsplitter.h +++ b/util/autoorientedsplitter.h @@ -1,52 +1,52 @@ /* This file is part of KDevelop Copyright 2014 Kevin Funk This library 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 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. */ #ifndef KDEVPLATFORM_AUTOORIENTEDSPLITTER_H #define KDEVPLATFORM_AUTOORIENTEDSPLITTER_H #include "utilexport.h" #include namespace KDevelop { /** * Auto-oriented version of QSplitter based on the aspect ratio of the widget size * * In case this widget is resized, we check whether we're currently in * "portrait" (width < height) or "landscape" (width >= height) mode. * Consequently, in "portrait" mode the QSplitter orientation is set to Qt::Vertical * in order to get a vertical layout of the items -- Qt::Horizontal is set for * "landscape" mode */ class KDEVPLATFORMUTIL_EXPORT AutoOrientedSplitter : public QSplitter { Q_OBJECT public: - explicit AutoOrientedSplitter(QWidget* parent = 0); - explicit AutoOrientedSplitter(Qt::Orientation orientation, QWidget* parent = 0); + explicit AutoOrientedSplitter(QWidget* parent = nullptr); + explicit AutoOrientedSplitter(Qt::Orientation orientation, QWidget* parent = nullptr); protected: void resizeEvent(QResizeEvent*) override; }; } #endif diff --git a/util/commandexecutor.h b/util/commandexecutor.h index a1ff1ee8d2..8037e4acdd 100644 --- a/util/commandexecutor.h +++ b/util/commandexecutor.h @@ -1,143 +1,143 @@ /* This file is part of KDevelop Copyright 2007 Andreas Pakulat This library 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 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. */ #ifndef KDEVPLATFORM_COMMANDEXECUTOR_H #define KDEVPLATFORM_COMMANDEXECUTOR_H #include #include #include "utilexport.h" namespace KDevelop { /** * Simplifying the exeuction of a Command through (QK)Process. * * This class emits only very basic signals when the process writes something * to stdout or stderr and for signaling completed and failed status of running * the process. This means that a process that is executed without a crash or so * is considered to be completed, even if it indicates an error during execution * using a non-zero return value. This needs to be handled by the user of the class * using the argument in the completed signal * * If you need more fine-grained control use (QK)Process directly and also * check whether you can use \ref KDevelop::ProcessLineMaker to use properly * terminated lines of output. * * Also this class provides only asynchronous operation, it doesn't allow to * wait for the program to finish. * * @author Andreas Pakulat * TODO: Should this be a KJob?? */ class KDEVPLATFORMUTIL_EXPORT CommandExecutor : public QObject { Q_OBJECT public: /** * Create a command using the given executable, arguments and environment * * The process is not started immediately, instead start() has to be called. */ - explicit CommandExecutor( const QString& command, QObject* parent = 0 ); + explicit CommandExecutor( const QString& command, QObject* parent = nullptr ); ~CommandExecutor() override; /** * set additional arguments to be used when executing the command */ void setArguments( const QStringList& args ); /** * set additional environment variables to be used when executing the command */ void setEnvironment( const QMap& env ); /** * set additional environment variables to be used when executing the command */ void setEnvironment( const QStringList& env ); /** * Sets the working directory of the command */ void setWorkingDirectory( const QString& dir ); /** * start the command, after this has been called signals may be emitted */ void start(); /** * kill the process, failed() will likely be emitted */ void kill(); /** * set the Command that should be started, now a commandexecutor can be reused */ void setCommand( const QString& command ); /** * whether the commands are executed from a shell */ bool useShell() const; /** * if @p shell is true, the command is executed from a shell */ void setUseShell( bool shell ); /** * @returns the arguments */ QStringList arguments() const; /** * @returns the command */ QString command() const; /** * @returns the working directory */ QString workingDirectory() const; Q_SIGNALS: void receivedStandardError( const QStringList& ); void receivedStandardOutput( const QStringList& ); /** * Emitted when there was a severe problem executing the process, for example it * could not be started or crashed during execution. */ void failed( QProcess::ProcessError ); /** * Emitted when the process was successfully started and finished without crashing * The @p code parameter indicates the return value from executing the process */ void completed(int code); private: Q_PRIVATE_SLOT( d, void procError( QProcess::ProcessError ) ) Q_PRIVATE_SLOT( d, void procFinished( int, QProcess::ExitStatus ) ) class CommandExecutorPrivate* const d; friend class CommandExecutorPrivate; }; } #endif diff --git a/util/environmentselectionmodel.h b/util/environmentselectionmodel.h index e32e87a731..0f28260306 100644 --- a/util/environmentselectionmodel.h +++ b/util/environmentselectionmodel.h @@ -1,75 +1,75 @@ /* This file is part of KDevelop Copyright 2013 Ivan Shapovalov This library 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 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. */ #ifndef ENVIRONMENTSELECTIONMODEL_H #define ENVIRONMENTSELECTIONMODEL_H #include "environmentgrouplist.h" #include #include namespace KDevelop { class EnvironmentSelectionModel : public QStringListModel { Q_OBJECT public: enum SpecialRoles { EffectiveNameRole = Qt::UserRole + 1 }; - explicit EnvironmentSelectionModel( QObject* parent = 0 ); + explicit EnvironmentSelectionModel( QObject* parent = nullptr ); QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; QVariant data( const QModelIndex& index, int role ) const override; bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole ) override; /** * @returns The @ref EnvironmentGroupList which has bee used to populate this * model. */ EnvironmentGroupList environment() const; /** * Reloads the model from the global config. */ void reload(); /** * Shall be used by views to update selection (current item) after the model has been reloaded. * * @param currentProfile Previous selected item. * @returns The item which shall become selected. */ QString reloadSelectedItem( const QString& currentProfile ); private: EnvironmentGroupList m_env; QSet m_groupsLookupTable; }; } // namespace KDevelop #endif // ENVIRONMENTSELECTIONMODEL_H diff --git a/util/environmentselectionwidget.h b/util/environmentselectionwidget.h index 82c059719d..9955bf04e5 100644 --- a/util/environmentselectionwidget.h +++ b/util/environmentselectionwidget.h @@ -1,89 +1,89 @@ /* This file is part of KDevelop Copyright 2007 Dukju Ahn This library 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 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. */ #ifndef KDEVPLATFORM_ENVIRONMENTSELECTIONWIDGET_H #define KDEVPLATFORM_ENVIRONMENTSELECTIONWIDGET_H #include #include "utilexport.h" #include "environmentgrouplist.h" namespace KDevelop { /** * Simple combobox which allows each plugin to decide which environment * variable group to use. * * Can be used just like a KComboBox in Configuration dialogs including usage * with KConfigXT. * * @note The widget is populated and defaulted automatically. * */ class KDEVPLATFORMUTIL_EXPORT EnvironmentSelectionWidget : public QWidget { Q_OBJECT Q_PROPERTY( QString currentProfile READ currentProfile WRITE setCurrentProfile NOTIFY currentProfileChanged USER true ) public: - explicit EnvironmentSelectionWidget( QWidget *parent = 0 ); + explicit EnvironmentSelectionWidget( QWidget *parent = nullptr ); ~EnvironmentSelectionWidget() override; /** * @returns The currently selected environment profile name, as written to KConfigXT */ QString currentProfile() const; /** * Sets the environment profile to be written to KConfigXT and updates the combo-box. * * @param text The environment profile name to select */ void setCurrentProfile( const QString& text ); /** * @returns The currently effective environment profile name (like @ref currentProfile(), * but with empty value resolved to the default profile). */ QString effectiveProfileName() const; /** * @returns The @ref EnvironmentGroupList which has been used to populate this * widget. */ EnvironmentGroupList environment() const; public slots: /** * Makes the widget re-read its environment group list. */ void reconfigure(); Q_SIGNALS: void currentProfileChanged(const QString& currentProfile); private: struct EnvironmentSelectionWidgetPrivate* const d; friend struct EnvironmentSelectionWidgetPrivate; }; } #endif diff --git a/util/executecompositejob.h b/util/executecompositejob.h index cb8ebc270c..841cb961bd 100644 --- a/util/executecompositejob.h +++ b/util/executecompositejob.h @@ -1,57 +1,57 @@ /* This file is part of KDevelop Copyright 2007-2008 Hamish Rodda This library 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 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. */ #ifndef KDEVPLATFORM_EXECUTECOMPOSITEJOB_H #define KDEVPLATFORM_EXECUTECOMPOSITEJOB_H #include #include "utilexport.h" template class QList; namespace KDevelop { class KDEVPLATFORMUTIL_EXPORT ExecuteCompositeJob : public KCompositeJob { Q_OBJECT public: - explicit ExecuteCompositeJob(QObject* parent = 0, const QList& jobs = {}); + explicit ExecuteCompositeJob(QObject* parent = nullptr, const QList& jobs = {}); ~ExecuteCompositeJob() override; void start() override; void setAbortOnError(bool abort); public Q_SLOTS: bool addSubjob(KJob* job) override; void slotResult(KJob* job) override; protected Q_SLOTS: virtual void slotPercent(KJob* job, unsigned long percent); protected: bool doKill() override; private: class ExecuteCompositeJobPrivate* const d; }; } #endif diff --git a/util/multilevellistview.h b/util/multilevellistview.h index 3c6fc661b1..355dfa434d 100644 --- a/util/multilevellistview.h +++ b/util/multilevellistview.h @@ -1,152 +1,152 @@ /* This file is part of KDevelop Copyright 2012 Miha Čančula This library 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 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. */ #ifndef KDEVPLATFORM_MULTILEVELLISTVIEW_H #define KDEVPLATFORM_MULTILEVELLISTVIEW_H #include #include #include "utilexport.h" class QTreeView; class QModelIndex; class QAbstractItemModel; namespace KDevelop { /** * A view for displaying a tree structure in a series of list views. * * A MultiLevelListView can have any number of levels, with one list view for each level. * Selecting an item at one level causes that item to become the root of the next level. * * For compatibility and convenience, this class has methods and signals similar to those of * QAbstractItemView, such as setModel(), setRootIndex() and currentIndexChanged(). */ class KDEVPLATFORMUTIL_EXPORT MultiLevelListView : public QWidget { Q_OBJECT public: /** * Creates a new MultiLevelListView with parent @p parent. * * Call setLevels() afterwards to set the number of list views. * * @param parent parent widget * @param f window flags, passed to QWidget */ - explicit MultiLevelListView(QWidget* parent = 0, Qt::WindowFlags f = 0); + explicit MultiLevelListView(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); /** * Default destructor */ ~MultiLevelListView() override; /** * @return the number of list view */ int levels() const; /** * Sets the number of levels, i.e. the number of list views visible, to @p levels * @param levels the new number of levels */ void setLevels(int levels); /** * @return the model displayed by this view, or 0 if none was set * @sa QAbstractItemView::model() */ QAbstractItemModel* model() const; /** * Sets the model to be displayed by this view. * * @param model the model to be displayed * @sa QAbstractItemView::setModel() */ void setModel(QAbstractItemModel* model); /** * Provides access to the QTreeView objects used internally. * Returns the view for level @p level of the tree structure. * * @param level the level of the tree structure shown by the returned view */ QTreeView* viewForLevel(int level) const; /** * The current index of the view. * * The current index is determined as the current index of the last list view. * * @sa QAbstractItemView::currentIndex() */ QModelIndex currentIndex() const; /** * Adds the widget @p widget under the list view for level @p level. * This function can be used to insert custom widgets into the view hierarchy. * * @param level specifies where to place the widget * @param widget the widget to add */ void addWidget(int level, QWidget* widget); void setHeaderLabels(const QStringList& labels); /** * Set the filter behavior of the last model. By default, SubTreesWithoutRoots * is used and only leafs are selectable in the view for that model. */ void setLastModelsFilterBehavior(KSelectionProxyModel::FilterBehavior filter); signals: /** * Notified that the current index has changed from @p previous to @p current * * @param current the new current index * @param previous the previous index * * @sa currentIndex(), QItemSelectionModel::currentChanged() */ void currentIndexChanged(const QModelIndex& current, const QModelIndex& previous); public slots: /** * Sets the root index of the entire view to @p index. * * @sa QAbstractItemView::setRootIndex() */ void setRootIndex(const QModelIndex& index); /** * Sets the current index to @p index. * * @sa currentIndex(), QAbstractItemView::setCurrentIndex() */ void setCurrentIndex(const QModelIndex& index); private: friend class MultiLevelListViewPrivate; class MultiLevelListViewPrivate* const d; Q_PRIVATE_SLOT(d, void viewSelectionChanged(const QModelIndex& current, const QModelIndex& previous)) Q_PRIVATE_SLOT(d, void lastViewsContentsChanged()) Q_PRIVATE_SLOT(d, void ensureViewSelected(QTreeView* view)) }; } #endif // KDEVPLATFORM_MULTILEVELLISTVIEW_H diff --git a/util/objectlist.h b/util/objectlist.h index beec1bf805..a6923f53b7 100644 --- a/util/objectlist.h +++ b/util/objectlist.h @@ -1,137 +1,137 @@ /* * Copyright 2014 Kevin Funk * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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, see . * */ #ifndef KDEVPLATFORM_OBJECTLIST_H #define KDEVPLATFORM_OBJECTLIST_H #include #include #include "utilexport.h" namespace KDevelop { /** * @brief Class for tracking a set of alive objects inheriting from QObject. * * Add individual objects via the append() method to have their lifetime being monitored by this class. * In case one of the tracked objects is destroyed, it is removed from the list. * * This means this class always contains a set of valid pointers to QObject instances. * The up-to-date list can be access via the data() method. * * @note You are *not* being notified if an item is removed from the list. * The purpose of this class is to provide a simple mechanism to keep track of a set of *alive* objects * * @sa append() * @sa data() */ class KDEVPLATFORMUTIL_EXPORT ObjectListTracker : public QObject { Q_OBJECT public: enum CleanupBehavior { NoCleanupWhenDone, ///< Do nothing when this object is destructed CleanupWhenDone ///< Delete list of items when this object is destructed }; - explicit ObjectListTracker(CleanupBehavior behavior = NoCleanupWhenDone, QObject* parent = 0); + explicit ObjectListTracker(CleanupBehavior behavior = NoCleanupWhenDone, QObject* parent = nullptr); ~ObjectListTracker() override; /** * Append and track object @p object * * In case @p object is destroyed, it gets removed from the list * * @note If @p object is already tracked, this operation is a no-op */ void append(QObject* object); /** * Remove and no longer track object @p object * * @return False if object @p object wasn't tracked or null, otherwise true */ bool remove(QObject* object); /** * Delete all objects currently tracked and clears the list */ void deleteAll(); /** * Accessor towards to the internal list of currently tracked objects */ const QList& data() const; private: void objectDestroyed(QObject*); private: struct Private; QScopedPointer const d; }; /** * @brief Template-based wrapper around ObjectListTracker for tracking a set of objects inheriting from QObject * * Provides a type-safe way to access and mutate ObjectListTracker * * @sa KDevelop::ObjectListTracker */ template class ObjectList { public: ObjectList(ObjectListTracker::CleanupBehavior behavior = ObjectListTracker::NoCleanupWhenDone) : m_tracker(behavior) { }; void append(T* object) { m_tracker.append(object); } bool remove(T* object) { return m_tracker.remove(object); } void deleteAll() { m_tracker.deleteAll(); } /** * Accessor to the up-to-date list inside the object tracker */ QList data() const { // This is considered safe, as QList and QList have the same memory layout // also see http://comments.gmane.org/gmane.comp.lib.qt.general/38943 return *reinterpret_cast*>(&m_tracker.data()); } private: ObjectListTracker m_tracker; }; } #endif // KDEVPLATFORM_OBJECTLIST_H diff --git a/util/placeholderitemproxymodel.h b/util/placeholderitemproxymodel.h index 06c9bfc370..baace99673 100644 --- a/util/placeholderitemproxymodel.h +++ b/util/placeholderitemproxymodel.h @@ -1,118 +1,118 @@ /* * Copyright 2013 Kevin Funk * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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, see . * */ #ifndef KDEVPLATFORM_PLACEHOLDERITEMPROXYMODEL_H #define KDEVPLATFORM_PLACEHOLDERITEMPROXYMODEL_H #include "utilexport.h" #include #include namespace KDevelop { /** * Proxy model adding a placeholder item for new entries * * This is mostly a QIdentityProxyModel, with one additional row added at the end * * Example use: * * @code * PlaceholderItemProxyModel* proxyModel = new PlaceholderItemProxyModel; * proxyModel->setSourceModel(new MyItemModel); * proxyModel->setColumnHint(0, "(Add new entry)"); * connect(proxyModel, SIGNAL(dataInserted(...), SLOT(handleDataInserted(...)); * @endcode * * In this case MyItemModel has exactly two entries, "Item1" and "Item2" * * This will end up in PlaceholderItemProxyModel holding the following indices: * - "Item1" (from source model) * - "Item2" (from source model) * - "(Add new entry)" (from PlaceholderItemProxyModel) * * In case the last entry is edited, and a non-empty value is supplied, * dataInserted() is emitted to notify the user about newly created rows. * The user then has to make sure the signal is handled accordingly and * new items are added to the source model. * * @see dataInserted * * @note WARNING: This implementation is only suitable for flat models * It will fall apart when you use a tree model as source */ class KDEVPLATFORMUTIL_EXPORT PlaceholderItemProxyModel : public QIdentityProxyModel { Q_OBJECT public: - explicit PlaceholderItemProxyModel(QObject* parent = 0); + explicit PlaceholderItemProxyModel(QObject* parent = nullptr); ~PlaceholderItemProxyModel() override; QVariant columnHint(int column) const; /** * Set the hint value for @p column to @p hint * * This text is going to be displayed in the place holder item row * * Only columns with non-empty hints are clickable and editable and * eventually cause the dataInserted() signal to be triggered */ void setColumnHint(int column, const QVariant& hint); void setSourceModel(QAbstractItemModel* sourceModel) override; Qt::ItemFlags flags(const QModelIndex& index) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override; QVariant data(const QModelIndex& proxyIndex, int role = Qt::DisplayRole) const override; bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; QModelIndex parent(const QModelIndex& child) const override; QModelIndex sibling(int row, int column, const QModelIndex& idx) const override; QModelIndex buddy(const QModelIndex& index) const override; QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; QModelIndex mapToSource(const QModelIndex& proxyIndex) const override; /** * Implement in subclass. * * @return True in case the input was valid, and the filter should notify * external observers via the dataInserted signal. * * By default, this method returns true only in case @p value is non-empty * * @sa dataInserted() */ virtual bool validateRow(const QModelIndex& index, const QVariant& value) const; Q_SIGNALS: void dataInserted(int column, const QVariant& values); private: struct Private; QScopedPointer const d; }; } #endif // KDEVPLATFORM_PLACEHOLDERITEMPROXYMODEL_H diff --git a/util/processlinemaker.h b/util/processlinemaker.h index b5e5d061ba..12820d7d6c 100644 --- a/util/processlinemaker.h +++ b/util/processlinemaker.h @@ -1,120 +1,120 @@ /* This file is part of the KDE project Copyright 2002 John Firebaugh Copyright 2007 Andreas Pakulat Copyright 2007 Oswald Buddenhagen This library 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 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. */ #ifndef _PROCESSLINEMAKER_H_ #define _PROCESSLINEMAKER_H_ #include #include "utilexport.h" /** @file processlinemaker.h Utility objects for process output views. */ class QProcess; class QStringList; /** Convenience class to catch output of QProcess. */ namespace KDevelop { class KDEVPLATFORMUTIL_EXPORT ProcessLineMaker : public QObject { Q_OBJECT public: - explicit ProcessLineMaker( QObject* parent = 0 ); - explicit ProcessLineMaker( QProcess* process, QObject* parent = 0 ); + explicit ProcessLineMaker( QObject* parent = nullptr ); + explicit ProcessLineMaker( QProcess* process, QObject* parent = nullptr ); ~ProcessLineMaker() override; /** * clears out the internal buffers, this drops any data without * emitting the related signal */ void discardBuffers(); /** * Flush the data from the buffers and then clear them. * This should be called once when the process has * exited to make sure all data that was received from the * process is properly converted and emitted. * * Note: Connecting this class to the process finished signal * is not going to work, as the user of this class will do * that itself too and possibly delete the process, making * it impossible to fetch the last output. */ void flushBuffers(); public Q_SLOTS: /** * This should be used (instead of hand-crafted code) when * you need to do custom things with the process output * before feeding it to the linemaker and have it convert * it to QString lines. * @param buffer the output from the process */ void slotReceivedStdout( const QByteArray& buffer ); /** * This should be used (instead of hand-crafted code) when * you need to do custom things with the process error output * before feeding it to the linemaker and have it convert * it to QString lines. * @param buffer the output from the process */ void slotReceivedStderr( const QByteArray& buffer ); Q_SIGNALS: /** * Emitted whenever the process prints something * to its standard output. The output is converted * to a QString using fromLocal8Bit() and will * be split on '\n'. * @param lines the lines that the process printed */ void receivedStdoutLines( const QStringList& lines ); /** * Emitted whenever the process prints something * to its error output. The output is converted * to a QString using fromLocal8Bit() and will * be split on '\n'. * @param lines the lines that the process printed */ void receivedStderrLines( const QStringList& lines ); private: Q_PRIVATE_SLOT(d, void slotReadyReadStdout( ) ) Q_PRIVATE_SLOT(d, void slotReadyReadStderr( ) ) class ProcessLineMakerPrivate* const d; friend class ProcessLineMakerPrivate; }; } #endif diff --git a/util/projecttestjob.h b/util/projecttestjob.h index 02ea53b1d8..ff8de40c6f 100644 --- a/util/projecttestjob.h +++ b/util/projecttestjob.h @@ -1,123 +1,123 @@ /* * This file is part of KDevelop * * Copyright 2012 Miha Čančula * * 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 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. */ #ifndef KDEVPLATFORM_PROJECTTESTJOB_H #define KDEVPLATFORM_PROJECTTESTJOB_H #include #include "utilexport.h" namespace KDevelop { class IProject; class ITestSuite; struct TestResult; /** * A combined result of a project test job * * @sa ProjectTestJob * **/ struct KDEVPLATFORMUTIL_EXPORT ProjectTestResult { ProjectTestResult() : total(0) , passed(0) , failed(0) , error(0) {} /** * The total number of test suites launched in this job **/ int total; /** * The number of passed test suites in this job. **/ int passed; /** * The number of failed test suites in this job. **/ int failed; /** * The number of errors in this job. **/ int error; }; /** * @brief A job that tests an entire project and reports the total result * * Launches all test suites in the specified project without raising the output window. * Instead of providing individual test results, it combines and simplifies them. * **/ class KDEVPLATFORMUTIL_EXPORT ProjectTestJob : public KJob { Q_OBJECT public: /** * Create a project test job * * @param project The project to be tested * @param parent This job's parent object, or 0 for no parent. * **/ - explicit ProjectTestJob(IProject* project, QObject* parent = 0); + explicit ProjectTestJob(IProject* project, QObject* parent = nullptr); /** * Destructor * **/ ~ProjectTestJob() override; /** * Start this job. **/ void start() override; /** * @brief The result of this job * * This function only returns a correnct result after all the tests are completed. * It is therefore best to call this after the KJob::result() signal is emitted. * * @sa ProjectTestResult **/ ProjectTestResult testResult(); protected: bool doKill() override; private: struct Private; QScopedPointer d; Q_PRIVATE_SLOT(d, void runNext()); Q_PRIVATE_SLOT(d, void gotResult(KDevelop::ITestSuite* suite, const KDevelop::TestResult& result)); }; } Q_DECLARE_TYPEINFO(KDevelop::ProjectTestResult, Q_MOVABLE_TYPE); #endif // KDEVPLATFORM_PROJECTTESTJOB_H diff --git a/util/richtextpushbutton.h b/util/richtextpushbutton.h index 5f3edc5df1..16a9734b41 100644 --- a/util/richtextpushbutton.h +++ b/util/richtextpushbutton.h @@ -1,57 +1,57 @@ /* Copyright 2010 Unknown Author (Qt Centre) Copyright 2010 David Nolden This library 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 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. */ #ifndef KDEVPLATFORM_RICHTEXTPUSHBUTTON_H #define KDEVPLATFORM_RICHTEXTPUSHBUTTON_H #include #include #include #include "utilexport.h" namespace KDevelop { class KDEVPLATFORMUTIL_EXPORT RichTextPushButton : public QPushButton { Q_OBJECT public: - explicit RichTextPushButton(QWidget *parent = 0); + explicit RichTextPushButton(QWidget *parent = nullptr); void setHtml(const QString &text); void setText(const QString &text); QString text() const; QSize sizeHint() const override; signals: public slots: protected: void paintEvent(QPaintEvent *) override; private: QString htmlText; bool isRichText; QStyleOptionButton getStyleOption() const; }; } #endif // KDEVPLATFORM_RICHTEXTPUSHBUTTON_H diff --git a/vcs/dvcs/dvcsjob.h b/vcs/dvcs/dvcsjob.h index 32335136ae..9e55c6e609 100644 --- a/vcs/dvcs/dvcsjob.h +++ b/vcs/dvcs/dvcsjob.h @@ -1,230 +1,230 @@ /*************************************************************************** * This file was partly taken from KDevelop's cvs plugin * * Copyright 2002-2003 Christian Loose * * Copyright 2007 Robert Gruber * * * * Adapted for DVCS * * Copyright 2008 Evgeniy Ivanov * * Copyright 2010 Aleix Pol Gonzalez * * * * 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) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * 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, see . * ***************************************************************************/ #ifndef KDEVPLATFORM_DVCS_JOB_H #define KDEVPLATFORM_DVCS_JOB_H #include #include #include #include #include "../vcsjob.h" class QDir; struct DVcsJobPrivate; /** * This class is capable of running our dvcs commands. * Most of all DVcsJob are created in DVCS executors, but executed in DistributedVersionControlPlugin or * any managers like BranchManager. * @note Connect to KJob::result(KJob*) to be notified when the job finished. * * How to create DVcsJob: * @code * DVcsJob* job = new DVcsJob(vcsplugin); * * job->setDirectory(workDir); * *job << "git-rev-parse"; * foreach(const QString &arg, args) // *job << args can be used instead! * *job << arg; * return job; * * return error_cmd(i18n("could not create the job")); * @endcode * * Usage example 1: * @code * VcsJob* j = add(QList() << a << b << c, IBasicVersionControl::Recursive); * DVcsJob* job = qobject_cast(j); * connect(job, SIGNAL(result(KJob*) ), * this, SIGNAL(jobFinished(KJob*) )); * ICore::self()->runController()->registerJob(job); * @endcode * * Usage example 2, asyunchronous: * @code * DVcsJob* branchJob = d->branch(repo, baseBranch, newBranch); * * if (job->exec() && job->status() == KDevelop::VcsJob::JobSucceeded) * return true; * else * //something, maybe even just * return false * @endcode * * @author Robert Gruber * @author Evgeniy Ivanov */ namespace KDevelop { class KDEVPLATFORMVCS_EXPORT DVcsJob : public KDevelop::VcsJob { Q_OBJECT public: - explicit DVcsJob(const QDir& workingDir, KDevelop::IPlugin* parent=0, KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose); + explicit DVcsJob(const QDir& workingDir, KDevelop::IPlugin* parent=nullptr, KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose); ~DVcsJob() override; /** * Returns current working directory. */ QDir directory() const; /** * Call this method to set command to execute and its arguments. * @note Don't forget <<"one two"; is not the same as <<"one"<<"two"; Use one word(command, arg) per one QString! */ DVcsJob& operator<<(const QString& arg); /** * Overloaded convenience function. * @see operator<<(const QString& arg). */ DVcsJob& operator<<(const char* arg); /** * Overloaded convenience function. * @see operator<<(const QString& arg). */ DVcsJob& operator<<(const QStringList& args); /** * Overloaded operator << for url's, can be used to pass files and * makes arguments absolute to the process working directory * * Override if you need to treat paths beffore adding them as parameters. */ virtual DVcsJob& operator<<(const QUrl& arg); /** * @see operator<<(const QUrl& arg). */ DVcsJob& operator<<(const QList& args); /** * Call this method to start this job. * @note Default communication mode is KProcess::AllOutput. * @see Use setCommunicationMode() to override the default communication mode. */ void start() override; /** * In some cases it's needed to specify the communication mode between the * process and the job object. This is for instance done for the "git status" * command. If stdout and stderr are processed as separate streams, their signals * do not always get emitted in correct order by KProcess, which will lead to a * screwed up output. * @note Default communication mode is KProcess::SeparateChannels. */ void setCommunicationMode(KProcess::OutputChannelMode comm); /** * @return The command that is executed when calling start(). */ QStringList dvcsCommand() const; /** * @return The whole output of the job as a string. (Might fail on binary data) */ QString output() const; /** * @return The whole binary output of the job */ QByteArray rawOutput() const; /** * @return The whole binary stderr output of the job. */ QByteArray errorOutput() const; /** * Ignore a non-zero exit code depending on @p ignore. */ void setIgnoreError(bool ignore); // Begin: KDevelop::VcsJob /** * Sets executions results. * In most cases this method is used by IDVCSexecutor * @see fetchResults() */ virtual void setResults(const QVariant &res); /** * Returns execution results stored in QVariant. * Mostly used in vcscommitdialog. * @see setResults(const QVariant &res) */ QVariant fetchResults() override; /** * Returns JobStatus * @see KDevelop::VcsJob::JobStatus */ KDevelop::VcsJob::JobStatus status() const override; /** * Returns pointer to IPlugin (which was used to create a job). */ KDevelop::IPlugin* vcsPlugin() const override; // End: KDevelop::VcsJob KProcess *process(); void displayOutput(const QString& output); public Q_SLOTS: /** * Cancel slot. */ void cancel(); Q_SIGNALS: void readyForParsing(KDevelop::DVcsJob *job); protected Q_SLOTS: virtual void slotProcessError( QProcess::ProcessError ); private Q_SLOTS: void slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus); void slotReceivedStdout(); protected: bool doKill() override; private: void jobIsReady(); DVcsJobPrivate* const d; }; } #endif diff --git a/vcs/dvcs/ui/branchmanager.h b/vcs/dvcs/ui/branchmanager.h index c5670d8975..5a3c520b5e 100644 --- a/vcs/dvcs/ui/branchmanager.h +++ b/vcs/dvcs/ui/branchmanager.h @@ -1,60 +1,60 @@ /*************************************************************************** * Copyright 2008 Evgeniy Ivanov * * * * 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) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * 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, see . * ***************************************************************************/ #ifndef KDEVPLATFORM_BRANCH_MANAGER_H #define KDEVPLATFORM_BRANCH_MANAGER_H #include class KJob; namespace Ui { class BranchDialogBase; } namespace KDevelop { class BranchesListModel; class DistributedVersionControlPlugin; } class BranchManager : public QDialog { Q_OBJECT public: - BranchManager(const QString& repository, KDevelop::DistributedVersionControlPlugin* executor, QWidget *parent = 0); + BranchManager(const QString& repository, KDevelop::DistributedVersionControlPlugin* executor, QWidget *parent = nullptr); ~BranchManager() override; signals: void checkedOut(KJob*); private slots: void createBranch(); void deleteBranch(); void renameBranch(); void checkoutBranch(); private: QString m_repository; KDevelop::DistributedVersionControlPlugin* m_dvcPlugin; Ui::BranchDialogBase* m_ui; KDevelop::BranchesListModel* m_model; }; #endif diff --git a/vcs/dvcs/ui/dvcsimportmetadatawidget.h b/vcs/dvcs/ui/dvcsimportmetadatawidget.h index 52a32c802f..f48f0943c5 100644 --- a/vcs/dvcs/ui/dvcsimportmetadatawidget.h +++ b/vcs/dvcs/ui/dvcsimportmetadatawidget.h @@ -1,64 +1,64 @@ /*************************************************************************** * Copyright 2007 Robert Gruber * * Copyright 2007 Andreas Pakulat * * * * Adapted for Git * * Copyright 2008 Evgeniy Ivanov * * * * Pimpl-ed and exported * * Copyright 2014 Maciej Poleski * * * * 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) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * 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, see . * ***************************************************************************/ #ifndef KDEVPLATFORM_DVCSIMPORTMETADATAWIDGET_H #define KDEVPLATFORM_DVCSIMPORTMETADATAWIDGET_H #include namespace Ui { class DvcsImportMetadataWidget; } class DvcsImportMetadataWidgetPrivate; /** * Asks the user for all options needed to import an existing directory into * a Git repository * @author Robert Gruber */ class KDEVPLATFORMVCS_EXPORT DvcsImportMetadataWidget : public KDevelop::VcsImportMetadataWidget { Q_OBJECT Q_DECLARE_PRIVATE(DvcsImportMetadataWidget) public: - explicit DvcsImportMetadataWidget(QWidget* parent=0); + explicit DvcsImportMetadataWidget(QWidget* parent=nullptr); ~DvcsImportMetadataWidget() override; QUrl source() const override; KDevelop::VcsLocation destination() const override; QString message() const override; //Is not used, it returns an empty string void setSourceLocation( const KDevelop::VcsLocation& ) override; void setSourceLocationEditable( bool ) override; bool hasValidData() const override; private: DvcsImportMetadataWidgetPrivate *const d_ptr; }; #endif diff --git a/vcs/dvcs/ui/revhistory/commitView.h b/vcs/dvcs/ui/revhistory/commitView.h index c962733ddc..fee9ccc1e8 100644 --- a/vcs/dvcs/ui/revhistory/commitView.h +++ b/vcs/dvcs/ui/revhistory/commitView.h @@ -1,62 +1,62 @@ /*************************************************************************** * Copyright 2008 Evgeniy Ivanov * * * * 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) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * 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, see . * ***************************************************************************/ #ifndef KDEVPLATFORM_COMMIT_VIEW_H #define KDEVPLATFORM_COMMIT_VIEW_H #include #include enum ViewColumns { GRAPH_COLUMN = 0, SLOG_COLUMN = 1, AUTHOR_COLUMN = 2, DATE_COLUMN = 3 }; class CommitView : public QTreeView { Q_OBJECT public: - explicit CommitView(QWidget *parent = 0); + explicit CommitView(QWidget *parent = nullptr); ~CommitView() override {}; // void setLineHeight(int h) { lineHeight = h; } int getLineHeight(const QModelIndex & index) {return rowHeight(index);} private: // int lineHeight; }; class CommitViewDelegate : public QItemDelegate { Q_OBJECT public: CommitViewDelegate(CommitView* _view, QObject* parent); void paint(QPainter* p, const QStyleOptionViewItem& o, const QModelIndex &i) const override; private: void paintGraph(QPainter* p, const QStyleOptionViewItem& o, const QModelIndex &i) const; void paintGraphLane(QPainter* p, int type, int x1, int x2, const int height, const QColor& col, const QBrush& back) const; private: CommitView* view; }; #endif diff --git a/vcs/dvcs/ui/revhistory/commitlogmodel.h b/vcs/dvcs/ui/revhistory/commitlogmodel.h index 5d0ef84b8a..7a2ad97f88 100644 --- a/vcs/dvcs/ui/revhistory/commitlogmodel.h +++ b/vcs/dvcs/ui/revhistory/commitlogmodel.h @@ -1,67 +1,67 @@ /*************************************************************************** * Copyright 2008 Evgeniy Ivanov * * * * 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) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * 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, see . * ***************************************************************************/ #ifndef KDEVPLATFORM_COMMITLOGMODEL_H #define KDEVPLATFORM_COMMITLOGMODEL_H #include #include #include #include namespace KDevelop { class DistributedVersionControlPlugin; } class QStringList; class CommitLogModel : public QAbstractItemModel { Q_OBJECT public: - CommitLogModel(KDevelop::DistributedVersionControlPlugin* plugin, const QString& repo, QObject* parent = 0); + CommitLogModel(KDevelop::DistributedVersionControlPlugin* plugin, const QString& repo, QObject* parent = nullptr); ~CommitLogModel() override {}; QVariant data(const QModelIndex &index, int role) const override; Qt::ItemFlags flags(const QModelIndex& index) const override; QVariant headerData(int s, Qt::Orientation o, int role = Qt::DisplayRole) const override; QModelIndex index(int r, int c, const QModelIndex& par = QModelIndex()) const override; QModelIndex parent(const QModelIndex& index) const override; int rowCount(const QModelIndex& par = QModelIndex()) const override; int columnCount(const QModelIndex&) const override; int branchCount(const int) const {return branchCnt;} QList getProperties(const int i) const {return revs[i].getProperties();} private slots: void initializeModel(); private: QStringList headerInfo; QList revs; int branchCnt; QString m_repo; KDevelop::DistributedVersionControlPlugin* m_plugin; }; #endif diff --git a/vcs/models/brancheslistmodel.h b/vcs/models/brancheslistmodel.h index 20a650fd08..54f5a3b3c3 100644 --- a/vcs/models/brancheslistmodel.h +++ b/vcs/models/brancheslistmodel.h @@ -1,74 +1,74 @@ /*************************************************************************** * Copyright 2008 Evgeniy Ivanov * * Copyright 2012 Aleix Pol Gonzalez * * * * 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) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * 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, see . * ***************************************************************************/ #ifndef KDEVPLATFORM_BRANCHESLISTMODEL_H #define KDEVPLATFORM_BRANCHESLISTMODEL_H #include #include #include namespace KDevelop { class IBranchingVersionControl; class IProject; class BranchesListModelPrivate; class KDEVPLATFORMVCS_EXPORT BranchesListModel : public QStandardItemModel { Q_OBJECT Q_PROPERTY(KDevelop::IProject* project READ project WRITE setProject) Q_PROPERTY(QString currentBranch READ currentBranch WRITE setCurrentBranch NOTIFY currentBranchChanged) public: enum Roles { CurrentRole = Qt::UserRole+1 }; - explicit BranchesListModel(QObject* parent = 0); + explicit BranchesListModel(QObject* parent = nullptr); ~BranchesListModel() override; void initialize(KDevelop::IBranchingVersionControl* dvcsplugin, const QUrl& repo); QHash roleNames() const override; Q_INVOKABLE void createBranch(const QString& baseBranch, const QString& newBranch); Q_INVOKABLE void removeBranch(const QString& branch); QUrl repository() const; KDevelop::IBranchingVersionControl* interface(); void refresh(); QString currentBranch() const; void setCurrentBranch(const QString& branch); KDevelop::IProject* project() const; void setProject(KDevelop::IProject* p); public slots: void resetCurrent(); signals: void currentBranchChanged(); private: const QScopedPointer d; }; } #endif // KDEVPLATFORM_BRANCHESLISTMODEL_H diff --git a/vcs/widgets/standardvcslocationwidget.h b/vcs/widgets/standardvcslocationwidget.h index 6925f12505..71c2d32c4f 100644 --- a/vcs/widgets/standardvcslocationwidget.h +++ b/vcs/widgets/standardvcslocationwidget.h @@ -1,50 +1,50 @@ /* KDevPlatform Vcs Support * * Copyright 2010 Aleix Pol * * 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. */ #ifndef KDEVPLATFORM_STANDARDVCSLOCATIONWIDGET_H #define KDEVPLATFORM_STANDARDVCSLOCATIONWIDGET_H #include #include class QUrl; class KUrlRequester; namespace KDevelop { class KDEVPLATFORMVCS_EXPORT StandardVcsLocationWidget : public VcsLocationWidget { Q_OBJECT public: - explicit StandardVcsLocationWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); + explicit StandardVcsLocationWidget(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); VcsLocation location() const override; bool isCorrect() const override; QUrl url() const; QString projectName() const override; public slots: void textChanged(const QString& str); private: KUrlRequester* m_urlWidget; }; } #endif // KDEVPLATFORM_STANDARDVCSLOCATIONWIDGET_H diff --git a/vcs/widgets/vcscommitdialog.h b/vcs/widgets/vcscommitdialog.h index 68811666c6..90e226f6cb 100644 --- a/vcs/widgets/vcscommitdialog.h +++ b/vcs/widgets/vcscommitdialog.h @@ -1,46 +1,46 @@ /*************************************************************************** * Copyright 2007 Dukju Ahn * * Copyright 2011 Andrey Batyiev * * * * 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. * * * ***************************************************************************/ #ifndef KDEVPLATFORM_VCS_COMMITDIALOG_H #define KDEVPLATFORM_VCS_COMMITDIALOG_H #include #include namespace KDevelop { class VcsStatusInfo; class IPatchSource; class KDEVPLATFORMVCS_EXPORT VcsCommitDialog : public QDialog { Q_OBJECT public: - explicit VcsCommitDialog( IPatchSource *patchSource, QWidget *parent = 0 ); + explicit VcsCommitDialog( IPatchSource *patchSource, QWidget *parent = nullptr ); ~VcsCommitDialog() override; ///Sets the commit candidates void setCommitCandidates( const QList& statuses ); void setRecursive( bool ); bool recursive() const; private slots: void ok(); void cancel(); private: class VcsCommitDialogPrivate* const d; }; } #endif diff --git a/vcs/widgets/vcsdiffwidget.h b/vcs/widgets/vcsdiffwidget.h index 38a32de2e2..34813153b1 100644 --- a/vcs/widgets/vcsdiffwidget.h +++ b/vcs/widgets/vcsdiffwidget.h @@ -1,47 +1,47 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_VCSDIFFWIDGET_H #define KDEVPLATFORM_VCSDIFFWIDGET_H #include #include namespace KDevelop { class VcsJob; class VcsRevision; class KDEVPLATFORMVCS_EXPORT VcsDiffWidget : public QWidget { Q_OBJECT public: - explicit VcsDiffWidget( KDevelop::VcsJob*, QWidget* parent = 0 ); + explicit VcsDiffWidget( KDevelop::VcsJob*, QWidget* parent = nullptr ); ~VcsDiffWidget() override; void setRevisions( const KDevelop::VcsRevision&, const KDevelop::VcsRevision& ); private: Q_PRIVATE_SLOT(d, void diffReady( KDevelop::VcsJob* ) ) class VcsDiffWidgetPrivate* const d; }; } #endif diff --git a/vcs/widgets/vcseventwidget.h b/vcs/widgets/vcseventwidget.h index c2b7d33735..aebf7009dd 100644 --- a/vcs/widgets/vcseventwidget.h +++ b/vcs/widgets/vcseventwidget.h @@ -1,56 +1,56 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Dukju Ahn * * Copyright 2007 Andreas Pakulat * * * * 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., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KDEVPLATFORM_VCSEVENTWIDGET_H #define KDEVPLATFORM_VCSEVENTWIDGET_H #include #include class QPoint; class QModelIndex; class QUrl; namespace KDevelop { class VcsRevision; class IBasicVersionControl; class KDEVPLATFORMVCS_EXPORT VcsEventWidget : public QWidget { Q_OBJECT public: - VcsEventWidget( const QUrl& url, const VcsRevision& rev, KDevelop::IBasicVersionControl* iface, QWidget* parent = 0 ); + VcsEventWidget( const QUrl& url, const VcsRevision& rev, KDevelop::IBasicVersionControl* iface, QWidget* parent = nullptr ); ~VcsEventWidget() override; private: Q_PRIVATE_SLOT(d, void diffToPrevious()) Q_PRIVATE_SLOT(d, void diffRevisions()) Q_PRIVATE_SLOT(d, void eventViewCustomContextMenuRequested( const QPoint &point )) Q_PRIVATE_SLOT(d, void eventViewClicked( const QModelIndex &index )) Q_PRIVATE_SLOT(d, void currentRowChanged(const QModelIndex&, const QModelIndex& )) Q_PRIVATE_SLOT(d, void copyRevision()) class VcsEventWidgetPrivate* const d; }; } #endif diff --git a/vcs/widgets/vcslocationwidget.h b/vcs/widgets/vcslocationwidget.h index 798610db84..62de53c962 100644 --- a/vcs/widgets/vcslocationwidget.h +++ b/vcs/widgets/vcslocationwidget.h @@ -1,61 +1,61 @@ /* This file is part of KDevelop * * Copyright 2010 Aleix Pol Gonzalez * * 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. */ #ifndef KDEVPLATFORM_VCSLOCATIONWIDGET_H #define KDEVPLATFORM_VCSLOCATIONWIDGET_H #include #include namespace KDevelop { class VcsLocation; /** * Provides a widget to be used to ask the user for a VersionControl location. * * Every VCS plugin will provide their own to be able to construct VcsLocations * from the UI in a VCS-dependent fashion. */ class KDEVPLATFORMVCS_EXPORT VcsLocationWidget : public QWidget { Q_OBJECT public: - explicit VcsLocationWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); + explicit VcsLocationWidget(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); /** @returns the VcsLocation specified in the widget. */ virtual VcsLocation location() const=0; /** @returns whether we have a correct location in the widget. */ virtual bool isCorrect() const=0; /** @returns a proposed project name to be used as a hint for an identifier * for the VcsLocation. */ virtual QString projectName() const=0; signals: void changed(); }; } #endif