diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ec87ba537..3fb06b4019 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,176 +1,177 @@ cmake_minimum_required(VERSION 2.8.12) # kdevplatform version set(KDEVPLATFORM_VERSION_MAJOR 5) set(KDEVPLATFORM_VERSION_MINOR 1) set(KDEVPLATFORM_VERSION_PATCH 40) # plugin versions listed in the .desktop files set(KDEV_PLUGIN_VERSION 27) # Increase this to reset incompatible item-repositories set(KDEV_ITEMREPOSITORY_VERSION 86) # library version / SO version set(KDEVPLATFORM_LIB_VERSION 10.0.0) set(KDEVPLATFORM_LIB_SOVERSION 10) project(KDevPlatform) # we need some parts of the ECM CMake helpers find_package (ECM 0.0.9 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${KDevPlatform_SOURCE_DIR}/cmake/modules ${ECM_MODULE_PATH}) include(KDECompilerSettings NO_POLICY_SCOPE) include(ECMAddTests) include(ECMOptionalAddSubdirectory) include(ECMInstallIcons) include(ECMSetupVersion) include(ECMMarkAsTest) include(ECMMarkNonGuiExecutable) include(ECMGenerateHeaders) include(ECMPackageConfigHelpers) include(GenerateExportHeader) include(FeatureSummary) include(WriteBasicConfigVersionFile) include(CheckFunctionExists) include(KDEInstallDirs) include(KDECMakeSettings) include(KDevPlatformMacros) set(QT_MIN_VERSION "5.4.0") find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core DBus Widgets Concurrent Test) find_package(Qt5QuickWidgets ${QT_MIN_VERSION}) set_package_properties(Qt5QuickWidgets PROPERTIES PURPOSE "Qt5 QuickWidgets library (part of Qt >=5.3). Required for the Welcome Page plugin." ) set(KF5_DEP_VERSION "5.18.0") # need KAboutData::fromPluginMetaData in kcoreaddons find_package(KF5 ${KF5_DEP_VERSION} REQUIRED COMPONENTS Archive Config GuiAddons WidgetsAddons IconThemes I18n ItemModels ItemViews JobWidgets KCMUtils KIO NewStuff Notifications NotifyConfig Parts Service Sonnet TextEditor ThreadWeaver WindowSystem Declarative XmlGui ) find_package(Grantlee5) set_package_properties(Grantlee5 PROPERTIES PURPOSE "Grantlee templating library, needed for file templates" URL "http://www.grantlee.org/" TYPE RECOMMENDED) set(Boost_ADDITIONAL_VERSIONS 1.39.0 1.39) find_package(Boost 1.35.0) set_package_properties(Boost PROPERTIES PURPOSE "Boost libraries for enabling the classbrowser" URL "http://www.boost.org" TYPE REQUIRED) add_definitions( -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050400 + -DQT_NO_SIGNALS_SLOTS_KEYWORDS -DQT_NO_URL_CAST_FROM_STRING -DQT_STRICT_ITERATORS -DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS ) # Turn off missing-field-initializers warning for GCC to avoid noise from false positives with empty {} # See discussion: http://mail.kde.org/pipermail/kdevelop-devel/2014-February/046910.html check_cxx_compiler_flag(-Wno-missing-field-initializers HAVE_MFI_FLAG) check_cxx_compiler_flag(-Werror=undefined-bool-conversion HAVE_UBC_FLAG) check_cxx_compiler_flag(-Werror=tautological-undefined-compare HAVE_TUC_FLAG) if (HAVE_MFI_FLAG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers") endif() if (HAVE_UBC_FLAG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=undefined-bool-conversion") endif() if (HAVE_TUC_FLAG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=tautological-undefined-compare") endif() if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdocumentation") endif() configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config-kdevplatform.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kdevplatform.h ) include_directories(${KDevPlatform_SOURCE_DIR} ${KDevPlatform_BINARY_DIR}) string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_TOLOWER) if(CMAKE_BUILD_TYPE_TOLOWER MATCHES "debug" OR CMAKE_BUILD_TYPE_TOLOWER STREQUAL "") set(COMPILER_OPTIMIZATIONS_DISABLED TRUE) else() set(COMPILER_OPTIMIZATIONS_DISABLED FALSE) endif() add_subdirectory(sublime) add_subdirectory(interfaces) add_subdirectory(project) add_subdirectory(language) add_subdirectory(shell) add_subdirectory(util) add_subdirectory(outputview) add_subdirectory(vcs) add_subdirectory(pics) add_subdirectory(debugger) add_subdirectory(documentation) add_subdirectory(serialization) add_subdirectory(template) add_subdirectory(tests) add_subdirectory(plugins) set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KDevPlatform") ecm_configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/KDevPlatformConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KDevPlatformConfig.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} ) ecm_setup_version(${KDEVPLATFORM_VERSION_MAJOR}.${KDEVPLATFORM_VERSION_MINOR}.${KDEVPLATFORM_VERSION_PATCH} VARIABLE_PREFIX KDEVPLATFORM VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kdevplatform_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KDevPlatformConfigVersion.cmake" SOVERSION ${KDEVPLATFORM_LIB_SOVERSION}) install( FILES "${KDevPlatform_BINARY_DIR}/kdevplatform_version.h" "${KDevPlatform_BINARY_DIR}/config-kdevplatform.h" DESTINATION "${KDE_INSTALL_INCLUDEDIR}/kdevplatform" ) install( FILES "${KDevPlatform_BINARY_DIR}/KDevPlatformConfig.cmake" "${KDevPlatform_BINARY_DIR}/KDevPlatformConfigVersion.cmake" cmake/modules/KDevPlatformMacros.cmake DESTINATION "${CMAKECONFIG_INSTALL_DIR}" ) install( EXPORT KDevPlatformTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" NAMESPACE KDev:: FILE KDevPlatformTargets.cmake ) include(CTest) # CTestCustom.cmake has to be in the CTEST_BINARY_DIR. # in the KDE build system, this is the same as CMAKE_BINARY_DIR. configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR}/CTestCustom.cmake) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/debugger/variable/variablecollection.h b/debugger/variable/variablecollection.h index 81bcce3c44..8fb4424c45 100644 --- a/debugger/variable/variablecollection.h +++ b/debugger/variable/variablecollection.h @@ -1,253 +1,253 @@ /* * 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 "../util/treemodel.h" #include "../util/treeitem.h" #include "../../interfaces/idocument.h" #include "../../interfaces/idebugcontroller.h" namespace KDevMI { namespace GDB { class GdbTest; } } namespace KDevelop { class VariableToolTip; class IDebugSession; class KDEVPLATFORMDEBUGGER_EXPORT Variable : public TreeItem { Q_OBJECT friend class KDevMI::GDB::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 = 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 m_changed; } void setChanged(bool c); void resetChanged(); -public slots: +public Q_SLOTS: void die(); protected: bool topLevel() const { return m_topLevel; } private: // TreeItem overrides QVariant data(int column, int role) const override; private: bool isPotentialProblematicValue() const; QString m_expression; bool m_inScope; bool m_topLevel; bool m_changed; bool m_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 KDevMI::GDB::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 m_watches; } Locals *locals(const QString &name = QStringLiteral("Locals")); QHash allLocals() const; void fetchMoreChildren() override {} void resetChanged(); private: Watches *m_watches; QHash m_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 m_universe; } Watches* watches() const { return m_universe->watches(); } Locals* locals(const QString &name = i18n("Locals")) const { return m_universe->locals(name); } QHash allLocals() const { return m_universe->allLocals(); } public Q_SLOTS: void variableWidgetShown(); void variableWidgetHidden(); private Q_SLOTS: void updateAutoUpdate(KDevelop::IDebugSession* session = nullptr); void textDocumentCreated( KDevelop::IDocument*); void viewCreated(KTextEditor::Document*, KTextEditor::View*); private: VariablesRoot* m_universe; QPointer m_activeTooltip; bool m_widgetVisible; friend class VariableProvider; VariableProvider m_textHintProvider; }; } #endif diff --git a/debugger/variable/variabletooltip.h b/debugger/variable/variabletooltip.h index cc415ffacd..42e6f2d1a1 100644 --- a/debugger/variable/variabletooltip.h +++ b/debugger/variable/variabletooltip.h @@ -1,61 +1,61 @@ /* * KDevelop Debugger Support * * 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_VARIABLETOOLTIP_H #define KDEVPLATFORM_VARIABLETOOLTIP_H #include "../../util/activetooltip.h" class QItemSelectionModel; class QString; class QSortFilterProxyModel; namespace KDevelop { class Variable; class TreeModel; class TreeItem; class AsyncTreeView; class VariableToolTip : public ActiveToolTip { Q_OBJECT public: VariableToolTip(QWidget* parent, const QPoint& position, const QString& identifier); Variable* variable() const { return m_var; }; - private slots: + private Q_SLOTS: void variableCreated(bool hasValue); void slotLinkActivated(const QString& link); void slotRangeChanged(int min, int max); private: TreeModel* m_model; Variable* m_var; QItemSelectionModel* m_selection; int m_itemHeight; AsyncTreeView* m_view; QSortFilterProxyModel* m_proxy; }; } #endif diff --git a/debugger/variable/variablewidget.h b/debugger/variable/variablewidget.h index 1d7cbeb350..080439d6f5 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 "../util/treeview.h" #include "variablecollection.h" class KHistoryComboBox; class QSortFilterProxyModel; class QAction; 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=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 *m_varTree; KHistoryComboBox *m_watchVarEditor; VariablesRoot *m_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: +private Q_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 6d2609126d..6c49a14bef 100644 --- a/documentation/documentationview.h +++ b/documentation/documentationview.h @@ -1,101 +1,101 @@ /* 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 "documentationexport.h" namespace KDevelop { class IPlugin; class DocumentationFindWidget; } class QModelIndex; class QLineEdit; class ProvidersModel; class QComboBox; class KToolBar; class KDEVPLATFORMDOCUMENTATION_EXPORT DocumentationView : public QWidget { Q_OBJECT public: DocumentationView(QWidget* parent, ProvidersModel* m); void showDocumentation(const KDevelop::IDocumentation::Ptr& doc); -public slots: +public Q_SLOTS: void initialize(); void addHistory(const KDevelop::IDocumentation::Ptr& doc); void emptyHistory(); void browseForward(); void browseBack(); void changedSelection(const QModelIndex& idx); void changedProvider(int); void showHome(); private: void updateView(); void returnPressed(); 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 = 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: +public Q_SLOTS: void unloaded(KDevelop::IPlugin* p); void loaded(KDevelop::IPlugin* p); void reloadProviders(); private: void addProvider(KDevelop::IDocumentationProvider* provider); void removeProvider(KDevelop::IDocumentationProvider* provider); QList mProviders; -signals: +Q_SIGNALS: void providersChanged(); }; #endif // KDEVPLATFORM_DOCUMENTATIONVIEW_H diff --git a/documentation/standarddocumentationview.h b/documentation/standarddocumentationview.h index 989890fbb1..2c7b4e0cbe 100644 --- a/documentation/standarddocumentationview.h +++ b/documentation/standarddocumentationview.h @@ -1,82 +1,82 @@ /* * 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 class QNetworkAccessManager; namespace KDevelop { struct StandardDocumentationViewPrivate; /** * A standard documentation view, based on QtWebKit or QtWebEngine, depending on your distribution preferences. */ class KDEVPLATFORMDOCUMENTATION_EXPORT StandardDocumentationView : public QWidget { Q_OBJECT Q_DISABLE_COPY(StandardDocumentationView) public: explicit StandardDocumentationView(DocumentationFindWidget* findWidget, QWidget* parent = nullptr ); ~StandardDocumentationView() override; void setDocumentation(const IDocumentation::Ptr& doc); void setOverrideCss(const QUrl &url); void load(const QUrl &url); void setHtml(const QString &html); void setNetworkAccessManager(QNetworkAccessManager* manager); /** * */ void setDelegateLinks(bool delegate); QAction* copyAction() const; Q_SIGNALS: void linkClicked(const QUrl &link); -public slots: +public Q_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: const QScopedPointer d; }; } #endif // KDEVPLATFORM_STANDARDDOCUMENTATIONVIEW_H diff --git a/interfaces/iprojectprovider.h b/interfaces/iprojectprovider.h index d943c478b6..9941cbe7c2 100644 --- a/interfaces/iprojectprovider.h +++ b/interfaces/iprojectprovider.h @@ -1,67 +1,67 @@ /* 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 "interfacesexport.h" class QUrl; namespace KDevelop { class VcsJob; class KDEVPLATFORMINTERFACES_EXPORT IProjectProviderWidget : public QWidget { Q_OBJECT public: 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: + Q_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/launchconfigurationtype.h b/interfaces/launchconfigurationtype.h index f321620471..49e303dd4c 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 class QMenu; class QIcon; class QUrl; class QStringList; 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 args argument list */ 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 nullptr; } -signals: +Q_SIGNALS: void signalAddLaunchConfiguration(KDevelop::ILaunchConfiguration* launch); private: class LaunchConfigurationTypePrivate* const d; }; } #endif diff --git a/language/assistant/staticassistantsmanager.h b/language/assistant/staticassistantsmanager.h index 86033e4abd..43d8c3a26c 100644 --- a/language/assistant/staticassistantsmanager.h +++ b/language/assistant/staticassistantsmanager.h @@ -1,77 +1,77 @@ /* 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 #include #include #include 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 = nullptr); ~StaticAssistantsManager() override; void registerAssistant(const StaticAssistant::Ptr assistant); void unregisterAssistant(const StaticAssistant::Ptr assistant); QVector registeredAssistants() const; void notifyAssistants(const IndexedString& url, const KDevelop::ReferencedTopDUContext& context); QVector problemsForContext(const ReferencedTopDUContext& top); -signals: +Q_SIGNALS: void problemsChanged(const IndexedString& url); private: struct Private; QScopedPointer const d; }; } #endif // KDEVPLATFORM_STATICASSISTANTSMANAGER_H diff --git a/language/backgroundparser/documentchangetracker.h b/language/backgroundparser/documentchangetracker.h index 9a16b0023e..11d6a0987e 100644 --- a/language/backgroundparser/documentchangetracker.h +++ b/language/backgroundparser/documentchangetracker.h @@ -1,260 +1,260 @@ /* * This file is part of KDevelop * * Copyright 2010 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_DOCUMENTCHANGETRACKER_H #define KDEVPLATFORM_DOCUMENTCHANGETRACKER_H #include #include #include #include #include #include #include namespace KTextEditor { class Document; class MovingRange; class MovingInterface; } namespace KDevelop { class DocumentChangeTracker; /** * These objects belongs to the foreground, and thus can only be accessed from background threads if the foreground lock is held. * */ class RevisionLockerAndClearerPrivate; /** * Helper class that locks a revision, and clears it on its destruction within the foreground thread. * Just delete it using deleteLater(). * */ class KDEVPLATFORMLANGUAGE_EXPORT RevisionLockerAndClearer : public QSharedData { public: typedef QExplicitlySharedDataPointer Ptr; ~RevisionLockerAndClearer(); /** * Returns the revision number * */ qint64 revision() const; /** * Whether the revision is still being held. It may have been lost due to document-reloads, * in which case the revision must not be used. * */ bool valid() const; /** * Transform a range from this document revision to the given @p to. * */ RangeInRevision transformToRevision(const RangeInRevision& range, const Ptr& to) const; /** * Transform a cursor from this document revision to the given @p to. * If a zero target revision is given, the transformation is done to the current document revision. * */ CursorInRevision transformToRevision(const CursorInRevision& cursor, const Ptr& to, KTextEditor::MovingCursor::InsertBehavior behavior = KTextEditor::MovingCursor::StayOnInsert) const; /** * Transforms the given range from this revision into the current revision. */ KTextEditor::Range transformToCurrentRevision(const RangeInRevision& range) const; /** * Transforms the given cursor from this revision into the current revision. */ KTextEditor::Cursor transformToCurrentRevision(const CursorInRevision& cursor, KTextEditor::MovingCursor::InsertBehavior behavior = KTextEditor::MovingCursor::StayOnInsert) const; /** * Transform ranges from the given document revision @p from to the this one. * If a zero @p from revision is given, the transformation is done from the current document revision. * */ RangeInRevision transformFromRevision(const RangeInRevision& range, const Ptr& from = Ptr()) const; /** * Transform ranges from the given document revision @p from to the this one. * If a zero @p from revision is given, the transformation is done from the current document revision. * */ CursorInRevision transformFromRevision(const CursorInRevision& cursor, const Ptr& from = Ptr(), KTextEditor::MovingCursor::InsertBehavior behavior = KTextEditor::MovingCursor::StayOnInsert) const; /** * Transforms the given range from the current revision into this revision. */ RangeInRevision transformFromCurrentRevision(const KTextEditor::Range& range) const; /** * Transforms the given cursor from the current revision into this revision. */ CursorInRevision transformFromCurrentRevision(const KTextEditor::Cursor& cursor, KTextEditor::MovingCursor::InsertBehavior behavior = KTextEditor::MovingCursor::StayOnInsert) const; private: friend class DocumentChangeTracker; RevisionLockerAndClearerPrivate* m_p; }; typedef RevisionLockerAndClearer::Ptr RevisionReference; /** * Internal helper class for RevisionLockerAndClearer * */ class KDEVPLATFORMLANGUAGE_EXPORT RevisionLockerAndClearerPrivate : public QObject { Q_OBJECT public: RevisionLockerAndClearerPrivate(DocumentChangeTracker* tracker, qint64 revision); ~RevisionLockerAndClearerPrivate() override; inline qint64 revision() const { return m_revision; } private: friend class RevisionLockerAndClearer; QPointer m_tracker; qint64 m_revision; }; class KDEVPLATFORMLANGUAGE_EXPORT DocumentChangeTracker : public QObject { Q_OBJECT public: explicit DocumentChangeTracker( KTextEditor::Document* document ); ~DocumentChangeTracker() override; /** * Completions of the users current edits that are supposed to complete * not-yet-finished statements, like for example for-loops for parsing. * */ virtual QList > completions() const; /** * Resets the tracking to the current revision. * */ virtual void reset(); /** * Returns the document revision at which reset() was called last. * * The revision is being locked by the tracker in MovingInterface, * it will be unlocked as soon as reset() is called, so if you want to use * the revision afterwards, you have to lock it before calling reset. * * zero is returned if the revisions were invalidated after the last call. * */ RevisionReference revisionAtLastReset() const; /** * Returns the current revision (which is not locked by the tracker) * */ RevisionReference currentRevision(); /** * Whether the changes that happened since the last reset are significant enough to require an update * */ virtual bool needUpdate() const; /** * Returns the tracked document **/ KTextEditor::Document* document() const; KTextEditor::MovingInterface* documentMovingInterface() const; /** * Returns the revision object which locks the revision representing the on-disk state. * Returns a zero object if the file is not on disk. * */ RevisionReference diskRevision() const; /** * Returns whether the given revision is being current held, so that it can be used * for transformations in MovingInterface * */ bool holdingRevision(qint64 revision) const; /** * Use this function to acquire a revision. As long as the returned object is stored somewhere, * the revision can be used for transformations in MovingInterface, and especially for * DocumentChangeTracker::transformBetweenRevisions. * * Returns a zero revision object if the revision could not be acquired (it wasn't held). * */ RevisionReference acquireRevision(qint64 revision); /** * Safely maps the given range between the two given revisions. * The mapping is only done if both the from- and to- revision are held, * else the original range is returned. * * @warning: Make sure that you actually hold the referenced revisions, else no transformation will be done. * @note It is much less error-prone to use RevisionReference->transformToRevision() and RevisionReference->transformFromRevision() directly. * */ RangeInRevision transformBetweenRevisions(RangeInRevision range, qint64 fromRevision, qint64 toRevision) const; CursorInRevision transformBetweenRevisions(CursorInRevision cursor, qint64 fromRevision, qint64 toRevision, KTextEditor::MovingCursor::InsertBehavior behavior = KTextEditor::MovingCursor::StayOnInsert) const; KTextEditor::Range transformToCurrentRevision(RangeInRevision range, qint64 fromRevision) const; KTextEditor::Cursor transformToCurrentRevision(CursorInRevision cursor, qint64 fromRevision, KTextEditor::MovingCursor::InsertBehavior behavior = KTextEditor::MovingCursor::StayOnInsert) const; /// Transform the range from the current revision into the given one RangeInRevision transformToRevision(KTextEditor::Range range, qint64 toRevision) const; /// Transform the cursor from the current revision into the given one CursorInRevision transformToRevision(KTextEditor::Cursor cursor, qint64 toRevision, KTextEditor::MovingCursor::InsertBehavior behavior = KTextEditor::MovingCursor::StayOnInsert) const; protected: RevisionReference m_revisionAtLastReset; bool m_needUpdate; QString m_currentCleanedInsertion; KTextEditor::Cursor m_lastInsertionPosition; KTextEditor::MovingRange* m_changedRange; KTextEditor::Document* m_document; KTextEditor::MovingInterface* m_moving; KDevelop::IndexedString m_url; void updateChangedRange(int delay); int recommendedDelay(KTextEditor::Document* doc, const KTextEditor::Range& range, const QString& text, bool removal); -public slots: +public Q_SLOTS: void textInserted(KTextEditor::Document* document, const KTextEditor::Cursor& position, const QString& inserted); void textRemoved(KTextEditor::Document* document, const KTextEditor::Range& range, const QString& oldText); void lineWrapped(KTextEditor::Document* document, const KTextEditor::Cursor& position); void lineUnwrapped(KTextEditor::Document* document, int line); void documentDestroyed( QObject* ); void aboutToInvalidateMovingInterfaceContent ( KTextEditor::Document* document ); void documentSavedOrUploaded(KTextEditor::Document*,bool); private: bool checkMergeTokens(const KTextEditor::Range& range); friend class RevisionLockerAndClearerPrivate; void lockRevision(qint64 revision); void unlockRevision(qint64 revision); QMap m_revisionLocks; }; } #endif diff --git a/language/backgroundparser/tests/test_backgroundparser.h b/language/backgroundparser/tests/test_backgroundparser.h index c27f570060..4f6c01940b 100644 --- a/language/backgroundparser/tests/test_backgroundparser.h +++ b/language/backgroundparser/tests/test_backgroundparser.h @@ -1,116 +1,116 @@ /* * 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: +private Q_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: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void init(); void testShutdownWithRunningJobs(); void testParseOrdering_simple(); void testParseOrdering_lockup(); void testParseOrdering_foregroundThread(); void testParseOrdering_noSequentialProcessing(); void testNoDeadlockInJobCreation(); void benchmark(); void benchmarkDocumentChanges(); private: JobPlan m_jobPlan; TestLanguageSupport *m_langSupport = nullptr; }; #endif // KDEVPLATFORM_TEST_BACKGROUNDPARSER_H diff --git a/language/backgroundparser/tests/testlanguagesupport.h b/language/backgroundparser/tests/testlanguagesupport.h index 1b5fad57b7..e657afa60e 100644 --- a/language/backgroundparser/tests/testlanguagesupport.h +++ b/language/backgroundparser/tests/testlanguagesupport.h @@ -1,46 +1,46 @@ /* * 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: +Q_SIGNALS: void aboutToCreateParseJob(const IndexedString& url, KDevelop::ParseJob** job); void parseJobCreated(KDevelop::ParseJob* job); }; #endif diff --git a/language/codecompletion/codecompletion.h b/language/codecompletion/codecompletion.h index 14548b68d9..ea7232b8de 100644 --- a/language/codecompletion/codecompletion.h +++ b/language/codecompletion/codecompletion.h @@ -1,78 +1,78 @@ /* * KDevelop Generic Code Completion Support * * Copyright 2006 Hamish Rodda * * 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_CODECOMPLETION_H #define KDEVPLATFORM_CODECOMPLETION_H #include #include namespace KTextEditor { class Document; class View; class CodeCompletionModel; } namespace KDevelop { class IDocument; class ILanguage; // TODO: cleanup this class for 5.1 class KDEVPLATFORMLANGUAGE_EXPORT CodeCompletion : public QObject { Q_OBJECT public: /** CodeCompletion will be the @p aModel parent. * If @p language is empty, the completion model will work for all files, * otherwise only for ones that contain the selected language. */ CodeCompletion(QObject* parent, KTextEditor::CodeCompletionModel* aModel, const QString& language); ~CodeCompletion() override; private Q_SLOTS: void textDocumentCreated(KDevelop::IDocument*); void viewCreated(KTextEditor::Document *document, KTextEditor::View *view); void documentUrlChanged(KDevelop::IDocument*); /** * check already opened documents, * needs to be done via delayed call to prevent infinite loop in * checkDocument() -> load lang plugin -> register CodeCompletion -> checkDocument() -> ... */ void checkDocuments(); - signals: + Q_SIGNALS: void registeredToView(KTextEditor::View* view); void unregisteredFromView(KTextEditor::View* view); private: void unregisterDocument(KTextEditor::Document*); void checkDocument(KTextEditor::Document*); KTextEditor::CodeCompletionModel* m_model; QString m_language; }; } #endif diff --git a/language/codegen/basicrefactoring.h b/language/codegen/basicrefactoring.h index f2d4fffb0e..282ebf35a3 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 = 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: +public Q_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/progressdialogs/refactoringdialog.h b/language/codegen/progressdialogs/refactoringdialog.h index 52c3380007..4b3215e906 100644 --- a/language/codegen/progressdialogs/refactoringdialog.h +++ b/language/codegen/progressdialogs/refactoringdialog.h @@ -1,50 +1,50 @@ /*************************************************************************** * 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 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 PROGRESSDIALOGS_H #define PROGRESSDIALOGS_H #include #include #include "ui_refactoringdialog.h" namespace KDevelop { class UsesCollector; class RefactoringProgressDialog : public QDialog { Q_OBJECT public: RefactoringProgressDialog(const QString& action, UsesCollector* collector); -private slots: +private Q_SLOTS: void progress(uint done, uint max); void maximumProgress(uint max); void processUses(const KDevelop::ReferencedTopDUContext& context); private: UsesCollector* m_collector; Ui::RefactoringDialog m_rd; }; } #endif diff --git a/language/codegen/tests/test_documentchangeset.h b/language/codegen/tests/test_documentchangeset.h index 713591ebda..46afc25547 100644 --- a/language/codegen/tests/test_documentchangeset.h +++ b/language/codegen/tests/test_documentchangeset.h @@ -1,37 +1,37 @@ /* * 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 TESTDOCUMENTCHANGESET_H #define TESTDOCUMENTCHANGESET_H #include class TestDocumentchangeset : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void testReplaceSameLine(); }; #endif // TESTDOCUMENTCHANGESET_H diff --git a/language/codegen/tests/test_templateclassgenerator.h b/language/codegen/tests/test_templateclassgenerator.h index 32db01476c..31c07db155 100644 --- a/language/codegen/tests/test_templateclassgenerator.h +++ b/language/codegen/tests/test_templateclassgenerator.h @@ -1,68 +1,68 @@ /* * 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_TESTTEMPLATECLASSGENERATOR_H #define KDEVPLATFORM_TESTTEMPLATECLASSGENERATOR_H #include #include #include #include "language/codegen/codedescription.h" namespace KDevelop { class TemplateClassGenerator; } class TestTemplateClassGenerator : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void fileLabelsCpp(); void fileLabelsYaml(); void defaultFileUrlsCpp(); void defaultFileUrlsYaml(); void customOptions(); void templateVariablesCpp(); void templateVariablesYaml(); void codeDescription(); void generate(); void cppOutput(); void yamlOutput(); private: KDevelop::TemplateClassGenerator* loadTemplate(const QString& name); private: QUrl baseUrl; QTemporaryDir tempDir; KDevelop::ClassDescription description; void setLowercaseFileNames(KDevelop::TemplateClassGenerator* generator); }; #endif // KDEVPLATFORM_TESTTEMPLATECLASSGENERATOR_H diff --git a/language/codegen/tests/test_templaterenderer.h b/language/codegen/tests/test_templaterenderer.h index 58ab65dd63..87ce7d5474 100644 --- a/language/codegen/tests/test_templaterenderer.h +++ b/language/codegen/tests/test_templaterenderer.h @@ -1,52 +1,52 @@ /* * 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_TEST_TEMPLATERENDERER_H #define KDEVPLATFORM_TEST_TEMPLATERENDERER_H #include #include namespace KDevelop { class TemplateRenderer; } class TestTemplateRenderer : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void simpleVariables_data(); void simpleVariables(); void includeTemplates(); void kdevFilters(); void kdevFiltersWithLookup(); private: KDevelop::TemplateRenderer* renderer; }; #endif // KDEVPLATFORM_TEST_TEMPLATERENDERER_H diff --git a/language/codegen/tests/test_templatesmodel.h b/language/codegen/tests/test_templatesmodel.h index dcdcdb1e63..610623a048 100644 --- a/language/codegen/tests/test_templatesmodel.h +++ b/language/codegen/tests/test_templatesmodel.h @@ -1,46 +1,46 @@ /* * 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_TESTTEMPLATESMODEL_H #define KDEVPLATFORM_TESTTEMPLATESMODEL_H #include namespace KDevelop { class TemplatesModel; } class TestTemplatesModel : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void descriptionExtraction(); void descriptionParsing(); void templateIndexes(); private: KDevelop::TemplatesModel* model; }; #endif // KDEVPLATFORM_TESTTEMPLATESMODEL_H diff --git a/language/duchain/navigation/abstractnavigationwidget.h b/language/duchain/navigation/abstractnavigationwidget.h index c200d19c91..47eae2b609 100644 --- a/language/duchain/navigation/abstractnavigationwidget.h +++ b/language/duchain/navigation/abstractnavigationwidget.h @@ -1,102 +1,102 @@ /* 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_ABSTRACTNAVIGATIONWIDGET_H #define KDEVPLATFORM_ABSTRACTNAVIGATIONWIDGET_H #include #include #include #include "../../interfaces/quickopendataprovider.h" #include "abstractnavigationcontext.h" class QTextBrowser; namespace KDevelop { class AbstractNavigationWidgetPrivate; /** * This class deleted itself when its part is deleted, so always use a QPointer when referencing it. * The duchain must be read-locked for most operations * */ class KDEVPLATFORMLANGUAGE_EXPORT AbstractNavigationWidget : public QWidget, public QuickOpenEmbeddedWidgetInterface { Q_OBJECT public: enum DisplayHint { NoHints = 0x0, // < Normal display EmbeddableWidget = 0x1, // < Omit parts which are only useful for the navigation popup }; Q_DECLARE_FLAGS(DisplayHints, DisplayHint) AbstractNavigationWidget(); ~AbstractNavigationWidget() override; void setContext(NavigationContextPointer context, int initBrowser = 400); void setDisplayHints(DisplayHints hints); QSize sizeHint() const override; - public slots: + public Q_SLOTS: ///Keyboard-action "next" void next() override; ///Keyboard-action "previous" void previous() override; ///Keyboard-action "accept" void accept() override; void up() override; void down() override; virtual void back(); ///These are temporarily for gettings these events directly from kate ///@todo Do this through a public interface post 4.2 void embeddedWidgetRight(); ///Keyboard-action "previous" void embeddedWidgetLeft(); ///Keyboard-action "accept" void embeddedWidgetAccept(); void embeddedWidgetUp(); void embeddedWidgetDown(); NavigationContextPointer context(); void navigateDeclaration(const KDevelop::IndexedDeclaration& decl); Q_SIGNALS: void sizeHintChanged(); /// Emitted whenever the current navigation-context has changed /// @param wasInitial whether the previous context was the initial context /// @param isInitial whether the current context is the initial context void contextChanged(bool wasInitial, bool isInitial); protected: void wheelEvent(QWheelEvent* ) override; void updateIdealSize() const; void initBrowser(int height); void update(); private: QScopedPointer d; Q_PRIVATE_SLOT(d, void anchorClicked(const QUrl&)) }; } #endif diff --git a/language/duchain/navigation/problemnavigationcontext.h b/language/duchain/navigation/problemnavigationcontext.h index 9eeccc02ba..0e9d1b18bf 100644 --- a/language/duchain/navigation/problemnavigationcontext.h +++ b/language/duchain/navigation/problemnavigationcontext.h @@ -1,73 +1,73 @@ /* 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 #include namespace KDevelop { class KDEVPLATFORMLANGUAGE_EXPORT ProblemNavigationContext : public AbstractNavigationContext { Q_OBJECT public: enum Flag { NoFlag = 0, ShowLocation = 1 << 0, }; Q_DECLARE_FLAGS(Flags, Flag) explicit ProblemNavigationContext(const QVector& problems, const Flags flags = {}); ~ProblemNavigationContext() override; QString name() const override; QString html(bool shorten = false) override; QWidget* widget() const override; bool isWidgetMaximized() const override; NavigationContextPointer executeKeyAction(QString key) override; -public slots: +public Q_SLOTS: void executeAction(int index); // TODO: Add API in base class? private: void html(IProblem::Ptr problem); /** * Return HTML-ized text. Used for processing problem's description and explanation. * Some plugins (kdev-cppcheck for example) return already HTML-ized strings, * therefore we should make check for this case. */ QString escapedHtml(const QString& text) const; QVector m_problems; Flags m_flags; QPointer m_widget; QVector m_assistantsActions; }; } #endif // KDEVPLATFORM_PROBLEMNAVIGATIONCONTEXT_H diff --git a/language/duchain/navigation/usescollector.h b/language/duchain/navigation/usescollector.h index 0c7e167494..23e24e2107 100644 --- a/language/duchain/navigation/usescollector.h +++ b/language/duchain/navigation/usescollector.h @@ -1,130 +1,130 @@ /* 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_USESCOLLECTOR_H #define KDEVPLATFORM_USESCOLLECTOR_H #include #include #include #include namespace KDevelop { class IndexedDeclaration; ///A helper base-class for collecting the top-contexts that contain all uses of a declaration ///The most important part is that this also updates the duchain if it's not up-to-date or doesn't contain ///the required features. The virtual function processUses(..) is called with each up-to-date top-context found ///that contains uses of the declaration. class KDEVPLATFORMLANGUAGE_EXPORT UsesCollector : public QObject { Q_OBJECT public: explicit UsesCollector(IndexedDeclaration declaration); ~UsesCollector() override; ///@warning For most tasks, you should use declarations() instead, and respect all of them! IndexedDeclaration declaration() const; ///This must be called to start the actual collecting! void startCollecting(); ///Override this to decide whether a file should be respect while computation. ///If true is returned, the uses will be computed for this file, and for all files ///in the import-chain between that file, and the file where the declaration occurs. ///The default-implementation returns true if the file is part of an open project, or ///if no project is opened and the file is open in an editor. virtual bool shouldRespectFile(IndexedString url); bool isReady() const; ///If this is true, the complete overload-chain is computed, and the uses of all overloaded functions together ///are computed. ///They are also returned in declarations(): ///The default is "true" void setCollectOverloads(bool collect); ///If this is true, all definitions are loaded too, and part of the processed declarations. ///This also means that the collector will first jump from any definition to its declaration, and start ///collecting from there. ///They are also returned in declarations(): ///The default is "true" void setCollectDefinitions(bool collectDefinition); ///Use this to set whether processUses should also be called on contexts that only contain ///a declaration that was used for searching the uses ///The default is "true". void setProcessDeclarations(bool process); ///If the searched declaration is a class, this can be used to decide whether constructors ///searched as well. The constructors and destructors will also be part of the declarations() list. ///The default is "true". This only works with constructors that have the same name as the class. ///If this is set to true, also destructors are searched and eventually renamed. void setCollectConstructors(bool process); ///The declarations that were used as base for the search ///For classes this contains forward-declarations etc. ///@warning When doing refactoring, you have to respect all of these as possible used declarations, /// even within the same context. Multiple different of them may have been used in the same top-context, /// with different local use-indices. QList declarations(); Q_SIGNALS: ///@see maximumProgress() void maximumProgressSignal(uint); ///@see progress() void progressSignal(uint, uint); ///@see processUses() void processUsesSignal(KDevelop::ReferencedTopDUContext); - private slots: + private Q_SLOTS: void updateReady(KDevelop::IndexedString url, KDevelop::ReferencedTopDUContext topContext); private: ///Called with every top-context that can contain uses of the declaration, or if setProcessDeclarations(false) ///has not been called also with all contexts that contain declarations used as base for the search. ///Override this to do your custom processing. You do not need to recurse into imports, that's done for you. ///The duchain is not locked when this is called. virtual void processUses(KDevelop::ReferencedTopDUContext topContext) = 0; ///Indicates the maximum progress this collector can make. If zero is given, this collector is not going to ///do any progress, and progress(..) is never called. virtual void maximumProgress(uint max); ///Called whenever progress has been made. max equals the value given initially by maximumProgress virtual void progress(uint processed, uint max); IndexedDeclaration m_declaration; QSet m_waitForUpdate; QSet m_updateReady; //All files that already have been feed to processUses QSet m_processed; //To prevent endless recursion in updateReady() QSet m_checked; ///Set of all files where the features were manipulated statically through ParseJob QSet m_staticFeaturesManipulated; QList m_declarations; QSet m_declarationTopContexts; bool m_collectOverloads; bool m_collectDefinitions; bool m_collectConstructors; bool m_processDeclarations; }; } #endif diff --git a/language/duchain/navigation/useswidget.h b/language/duchain/navigation/useswidget.h index 71fe8cc403..ca533314be 100644 --- a/language/duchain/navigation/useswidget.h +++ b/language/duchain/navigation/useswidget.h @@ -1,163 +1,163 @@ /* 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 QVBoxLayout; class QHBoxLayout; class QBoxLayout; 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; void setHighlighted(bool highlight); bool isHighlighted() const; void activateLink(); private: void mousePressEvent(QMouseEvent * event) override; 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; bool m_isHighlighted = false; }; 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 = {}); ///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: + private Q_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 ); explicit 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: + public Q_SLOTS: void headerLinkActivated(QString linkName); void redrawHeaderLine(); }; } #endif diff --git a/language/duchain/tests/bench_hashes.h b/language/duchain/tests/bench_hashes.h index 1aa2447f5c..d76de91ba9 100644 --- a/language/duchain/tests/bench_hashes.h +++ b/language/duchain/tests/bench_hashes.h @@ -1,49 +1,49 @@ /* * 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 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_BENCH_HASHES_H #define KDEVPLATFORM_BENCH_HASHES_H #include class BenchHashes : public QObject { Q_OBJECT private: void feedData(); -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void insert(); void insert_data(); void find(); void find_data(); void constFind(); void constFind_data(); void remove(); void remove_data(); void typeRepo(); void typeRepo_data(); }; #endif // KDEVPLATFORM_BENCH_HASHES_H diff --git a/language/duchain/tests/test_duchain.cpp b/language/duchain/tests/test_duchain.cpp index 3e29d2c22e..6943437ccd 100644 --- a/language/duchain/tests/test_duchain.cpp +++ b/language/duchain/tests/test_duchain.cpp @@ -1,1034 +1,1034 @@ /* * This file is part of KDevelop * * Copyright 2011-2013 Milian Wolff * Copyright 2006 Hamish Rodda * Copyright 2007-2009 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 "test_duchain.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // #include #include #include #include // needed for std::insert_iterator on windows #include //Extremely slow // #define TEST_NORMAL_IMPORTS QTEST_MAIN(TestDUChain) using namespace KDevelop; using namespace Utils; typedef BasicSetRepository::Index Index; struct Timer { Timer() { m_timer.start(); } qint64 elapsed() { return m_timer.nsecsElapsed(); } QElapsedTimer m_timer; }; void TestDUChain::initTestCase() { AutoTestShell::init(); TestCore::initialize(Core::NoUi); DUChain::self()->disablePersistentStorage(); CodeRepresentation::setDiskChangesForbidden(true); } void TestDUChain::cleanupTestCase() { TestCore::shutdown(); } #ifndef Q_OS_WIN void TestDUChain::testStringSets() { const unsigned int setCount = 8; const unsigned int choiceCount = 40; const unsigned int itemCount = 120; BasicSetRepository rep(QStringLiteral("test repository")); // qDebug() << "Start repository-layout: \n" << rep.dumpDotGraph(); qint64 repositoryTime = 0; //Time spent on repository-operations qint64 genericTime = 0; //Time spend on equivalent operations with generic sets qint64 repositoryIntersectionTime = 0; //Time spent on repository-operations qint64 genericIntersectionTime = 0; //Time spend on equivalent operations with generic sets qint64 qsetIntersectionTime = 0; //Time spend on equivalent operations with generic sets qint64 repositoryUnionTime = 0; //Time spent on repository-operations qint64 genericUnionTime = 0; //Time spend on equivalent operations with generic sets qint64 repositoryDifferenceTime = 0; //Time spent on repository-operations qint64 genericDifferenceTime = 0; //Time spend on equivalent operations with generic sets Set sets[setCount]; std::set realSets[setCount]; for(unsigned int a = 0; a < setCount; a++) { std::set chosenIndices; unsigned int thisCount = rand() % choiceCount; if(thisCount == 0) thisCount = 1; for(unsigned int b = 0; b < thisCount; b++) { Index choose = (rand() % itemCount) + 1; while(chosenIndices.find(choose) != chosenIndices.end()) { choose = (rand() % itemCount) + 1; } Timer t; chosenIndices.insert(chosenIndices.end(), choose); genericTime += t.elapsed(); } { Timer t; sets[a] = rep.createSet(chosenIndices); repositoryTime += t.elapsed(); } realSets[a] = chosenIndices; std::set tempSet = sets[a].stdSet(); if(tempSet != realSets[a]) { QString dbg = QStringLiteral("created set: "); for(std::set::const_iterator it = realSets[a].begin(); it != realSets[a].end(); ++it) dbg += QStringLiteral("%1 ").arg(*it); qDebug() << dbg; dbg = QStringLiteral("repo. set: "); for(std::set::const_iterator it = tempSet.begin(); it != tempSet.end(); ++it) dbg += QStringLiteral("%1 ").arg(*it); qDebug() << dbg; qDebug() << "DOT-Graph:\n\n" << sets[a].dumpDotGraph() << "\n\n"; QFAIL("sets are not the same!"); } } for(int cycle = 0; cycle < 100; ++cycle) { if(cycle % 10 == 0) qDebug() << "cycle" << cycle; for(unsigned int a = 0; a < setCount; a++) { for(unsigned int b = 0; b < setCount; b++) { /// ----- SUBTRACTION/DIFFERENCE std::set _realDifference; { Timer t; std::set_difference(realSets[a].begin(), realSets[a].end(), realSets[b].begin(), realSets[b].end(), std::insert_iterator >(_realDifference, _realDifference.begin())); genericDifferenceTime += t.elapsed(); } Set _difference; { Timer t; _difference = sets[a] - sets[b]; repositoryDifferenceTime += t.elapsed(); } if(_difference.stdSet() != _realDifference) { { qDebug() << "SET a:"; QString dbg = QLatin1String(""); for(std::set::const_iterator it = realSets[a].begin(); it != realSets[a].end(); ++it) dbg += QStringLiteral("%1 ").arg(*it); qDebug() << dbg; qDebug() << "DOT-Graph:\n\n" << sets[a].dumpDotGraph() << "\n\n"; } { qDebug() << "SET b:"; QString dbg = QLatin1String(""); for(std::set::const_iterator it = realSets[b].begin(); it != realSets[b].end(); ++it) dbg += QStringLiteral("%1 ").arg(*it); qDebug() << dbg; qDebug() << "DOT-Graph:\n\n" << sets[b].dumpDotGraph() << "\n\n"; } { std::set tempSet = _difference.stdSet(); qDebug() << "SET difference:"; QString dbg = QStringLiteral("real set: "); for(std::set::const_iterator it = _realDifference.begin(); it != _realDifference.end(); ++it) dbg += QStringLiteral("%1 ").arg(*it); qDebug() << dbg; dbg = QStringLiteral("repo. set: "); for(std::set::const_iterator it = tempSet.begin(); it != tempSet.end(); ++it) dbg += QStringLiteral("%1 ").arg(*it); qDebug() << dbg; qDebug() << "DOT-Graph:\n\n" << _difference.dumpDotGraph() << "\n\n"; } QFAIL("difference sets are not the same!"); } /// ------ UNION std::set _realUnion; { Timer t; std::set_union(realSets[a].begin(), realSets[a].end(), realSets[b].begin(), realSets[b].end(), std::insert_iterator >(_realUnion, _realUnion.begin())); genericUnionTime += t.elapsed(); } Set _union; { Timer t; _union = sets[a] + sets[b]; repositoryUnionTime += t.elapsed(); } if(_union.stdSet() != _realUnion) { { qDebug() << "SET a:"; QString dbg; for(std::set::const_iterator it = realSets[a].begin(); it != realSets[a].end(); ++it) dbg += QStringLiteral("%1 ").arg(*it); qDebug() << dbg; qDebug() << "DOT-Graph:\n\n" << sets[a].dumpDotGraph() << "\n\n"; } { qDebug() << "SET b:"; QString dbg; for(std::set::const_iterator it = realSets[b].begin(); it != realSets[b].end(); ++it) dbg += QStringLiteral("%1 ").arg(*it); qDebug() << dbg; qDebug() << "DOT-Graph:\n\n" << sets[b].dumpDotGraph() << "\n\n"; } { std::set tempSet = _union.stdSet(); qDebug() << "SET union:"; QString dbg = QStringLiteral("real set: "); for(std::set::const_iterator it = _realUnion.begin(); it != _realUnion.end(); ++it) dbg += QStringLiteral("%1 ").arg(*it); qDebug() << dbg; dbg = QStringLiteral("repo. set: "); for(std::set::const_iterator it = tempSet.begin(); it != tempSet.end(); ++it) dbg += QStringLiteral("%1 ").arg(*it); qDebug() << dbg; qDebug() << "DOT-Graph:\n\n" << _union.dumpDotGraph() << "\n\n"; } QFAIL("union sets are not the same"); } std::set _realIntersection; /// -------- INTERSECTION { Timer t; std::set_intersection(realSets[a].begin(), realSets[a].end(), realSets[b].begin(), realSets[b].end(), std::insert_iterator >(_realIntersection, _realIntersection.begin())); genericIntersectionTime += t.elapsed(); } //Just for fun: Test how fast QSet intersections are QSet first, second; for(std::set::const_iterator it = realSets[a].begin(); it != realSets[a].end(); ++it) { first.insert(*it); } for(std::set::const_iterator it = realSets[b].begin(); it != realSets[b].end(); ++it) { second.insert(*it); } { Timer t; QSet i = first.intersect(second); qsetIntersectionTime += t.elapsed(); } Set _intersection; { Timer t; _intersection = sets[a] & sets[b]; repositoryIntersectionTime += t.elapsed(); } if(_intersection.stdSet() != _realIntersection) { { qDebug() << "SET a:"; QString dbg; for(std::set::const_iterator it = realSets[a].begin(); it != realSets[a].end(); ++it) dbg += QStringLiteral("%1 ").arg(*it); qDebug() << dbg; qDebug() << "DOT-Graph:\n\n" << sets[a].dumpDotGraph() << "\n\n"; } { qDebug() << "SET b:"; QString dbg; for(std::set::const_iterator it = realSets[b].begin(); it != realSets[b].end(); ++it) dbg += QStringLiteral("%1 ").arg(*it); qDebug() << dbg; qDebug() << "DOT-Graph:\n\n" << sets[b].dumpDotGraph() << "\n\n"; } { std::set tempSet = _intersection.stdSet(); qDebug() << "SET intersection:"; QString dbg = QStringLiteral("real set: "); for(std::set::const_iterator it = _realIntersection.begin(); it != _realIntersection.end(); ++it) dbg += QStringLiteral("%1 ").arg(*it); qDebug() << dbg; dbg = QStringLiteral("repo. set: "); for(std::set::const_iterator it = tempSet.begin(); it != tempSet.end(); ++it) dbg += QStringLiteral("%1 ").arg(*it); qDebug() << dbg; qDebug() << "DOT-Graph:\n\n" << _intersection.dumpDotGraph() << "\n\n"; } QFAIL("intersection sets are not the same"); } } } qDebug() << "cycle " << cycle; qDebug() << "ns needed for set-building: repository-set: " << float(repositoryTime) << " generic-set: " << float(genericTime); qDebug() << "ns needed for intersection: repository-sets: " << float(repositoryIntersectionTime) << " generic-set: " << float(genericIntersectionTime) << " QSet: " << float(qsetIntersectionTime); qDebug() << "ns needed for union: repository-sets: " << float(repositoryUnionTime) << " generic-set: " << float(genericUnionTime); qDebug() << "ns needed for difference: repository-sets: " << float(repositoryDifferenceTime) << " generic-set: " << float(genericDifferenceTime); } } #endif void TestDUChain::testSymbolTableValid() { DUChainReadLocker lock(DUChain::lock()); PersistentSymbolTable::self().dump(QTextStream(stdout)); } void TestDUChain::testIndexedStrings() { int testCount = 600000; QHash knownIndices; int a = 0; for(a = 0; a < testCount; ++a) { QString testString; int length = rand() % 10; for(int b = 0; b < length; ++b) testString.append((char)(rand() % 6) + 'a'); QByteArray array = testString.toUtf8(); //qDebug() << "checking with" << testString; //qDebug() << "checking" << a; IndexedString indexed(array.constData(), array.size(), IndexedString::hashString(array.constData(), array.size())); QCOMPARE(indexed.str(), testString); if(knownIndices.contains(testString)) { QCOMPARE(indexed.index(), knownIndices[testString].index()); } else { knownIndices[testString] = indexed; } if(a % (testCount/10) == 0) qDebug() << a << "of" << testCount; } qDebug() << a << "successful tests"; } struct TestContext { TestContext() { static int number = 0; ++number; DUChainWriteLocker lock(DUChain::lock()); m_context = new TopDUContext(IndexedString(QStringLiteral("/test1/%1").arg(number)), RangeInRevision()); m_normalContext = new DUContext(RangeInRevision(), m_context); DUChain::self()->addDocumentChain(m_context); Q_ASSERT(IndexedDUContext(m_context).context() == m_context); } ~TestContext() { foreach(TestContext* importer, importers) importer->unImport(QList() << this); unImport(imports); DUChainWriteLocker lock(DUChain::lock()); TopDUContextPointer tp(m_context); DUChain::self()->removeDocumentChain(static_cast(m_context)); Q_ASSERT(!tp); } void verify(QList allContexts) { { DUChainReadLocker lock(DUChain::lock()); QCOMPARE(m_context->importedParentContexts().count(), imports.count()); } //Compute a closure of all children, and verify that they are imported. QSet collected; collectImports(collected); collected.remove(this); DUChainReadLocker lock(DUChain::lock()); foreach(TestContext* context, collected) { QVERIFY(m_context->imports(context->m_context, CursorInRevision::invalid())); #ifdef TEST_NORMAL_IMPORTS QVERIFY(m_normalContext->imports(context->m_normalContext)); #endif } //Verify that no other contexts are imported foreach(TestContext* context, allContexts) if(context != this) { QVERIFY(collected.contains(context) || !m_context->imports(context->m_context, CursorInRevision::invalid())); #ifdef TEST_NORMAL_IMPORTS QVERIFY(collected.contains(context) || !m_normalContext->imports(context->m_normalContext, CursorInRevision::invalid())); #endif } } void collectImports(QSet& collected) { if(collected.contains(this)) return; collected.insert(this); foreach(TestContext* context, imports) context->collectImports(collected); } void import(TestContext* ctx) { if(imports.contains(ctx) || ctx == this) return; imports << ctx; ctx->importers << this; DUChainWriteLocker lock(DUChain::lock()); m_context->addImportedParentContext(ctx->m_context); #ifdef TEST_NORMAL_IMPORTS m_normalContext->addImportedParentContext(ctx->m_normalContext); #endif } void unImport(QList ctxList) { QList list; QList normalList; foreach(TestContext* ctx, ctxList) { if(!imports.contains(ctx)) continue; list << ctx->m_context; normalList << ctx->m_normalContext; imports.removeAll(ctx); ctx->importers.removeAll(this); } DUChainWriteLocker lock(DUChain::lock()); m_context->removeImportedParentContexts(list); #ifdef TEST_NORMAL_IMPORTS foreach(DUContext* ctx, normalList) m_normalContext->removeImportedParentContext(ctx); #endif } void clearImports() { { DUChainWriteLocker lock(DUChain::lock()); m_context->clearImportedParentContexts(); m_normalContext->clearImportedParentContexts(); } foreach(TestContext* ctx, imports) { imports.removeAll(ctx); ctx->importers.removeAll(this); } } QList imports; private: TopDUContext* m_context; DUContext* m_normalContext; QList importers; }; void collectReachableNodes(QSet& reachableNodes, uint currentNode) { if(!currentNode) return; reachableNodes.insert(currentNode); const Utils::SetNodeData* node = KDevelop::RecursiveImportRepository::repository()->nodeFromIndex(currentNode); Q_ASSERT(node); collectReachableNodes(reachableNodes, node->leftNode()); collectReachableNodes(reachableNodes, node->rightNode()); } uint collectNaiveNodeCount(uint currentNode) { if(!currentNode) return 0; uint ret = 1; const Utils::SetNodeData* node = KDevelop::RecursiveImportRepository::repository()->nodeFromIndex(currentNode); Q_ASSERT(node); ret += collectNaiveNodeCount(node->leftNode()); ret += collectNaiveNodeCount(node->rightNode()); return ret; } void TestDUChain::testImportStructure() { Timer total; qDebug() << "before: " << KDevelop::RecursiveImportRepository::repository()->getDataRepository().statistics().print(); ///Maintains a naive import-structure along with a real top-context import structure, and allows comparing both. int cycles = 5; //int cycles = 100; //srand(time(NULL)); for(int t = 0; t < cycles; ++t) { QList allContexts; //Create a random structure int contextCount = 50; int verifyOnceIn = contextCount/*((contextCount*contextCount)/20)+1*/; //Verify once in every chances(not in all cases, because else the import-structure isn't built on-demand!) int clearOnceIn = contextCount; for(int a = 0; a < contextCount; a++) allContexts << new TestContext(); for(int c = 0; c < cycles; ++c) { //qDebug() << "main-cycle" << t << "sub-cycle" << c; //Add random imports and compare for(int a = 0; a < contextCount; a++) { //Import up to 5 random other contexts into each context int importCount = rand() % 5; //qDebug() << "cnt> " << importCount; for(int i = 0; i < importCount; ++i) { //int importNr = rand() % contextCount; //qDebug() << "nmr > " << importNr; //allContexts[a]->import(allContexts[importNr]); allContexts[a]->import(allContexts[rand() % contextCount]); } for(int b = 0; b < contextCount; b++) if(rand() % verifyOnceIn == 0) allContexts[b]->verify(allContexts); } //Remove random imports and compare for(int a = 0; a < contextCount; a++) { //Import up to 5 random other contexts into each context int removeCount = rand() % 3; QSet removeImports; for(int i = 0; i < removeCount; ++i) if(!allContexts[a]->imports.isEmpty()) removeImports.insert(allContexts[a]->imports[rand() % allContexts[a]->imports.count()]); allContexts[a]->unImport(removeImports.toList()); for(int b = 0; b < contextCount; b++) if(rand() % verifyOnceIn == 0) allContexts[b]->verify(allContexts); } for(int a = 0; a < contextCount; a++) { if(rand() % clearOnceIn == 0) { allContexts[a]->clearImports(); allContexts[a]->verify(allContexts); } } } qDebug() << "after: " << KDevelop::RecursiveImportRepository::repository()->getDataRepository().statistics().print(); for(int a = 0; a < contextCount; ++a) delete allContexts[a]; allContexts.clear(); qDebug() << "after cleanup: " << KDevelop::RecursiveImportRepository::repository()->getDataRepository().statistics().print(); } qDebug() << "total ns needed for import-structure test:" << float(total.elapsed()); } class TestWorker : public QObject { Q_OBJECT -public slots: +public Q_SLOTS: void lockForWrite() { for(int i = 0; i < 10000; ++i) { DUChainWriteLocker lock; } } void lockForRead() { for(int i = 0; i < 10000; ++i) { DUChainReadLocker lock; } } void lockForReadWrite() { for(int i = 0; i < 10000; ++i) { { DUChainReadLocker lock; } { DUChainWriteLocker lock; } } } static QSharedPointer createWorkerThread(const char* workerSlot) { QThread* thread = new QThread; TestWorker* worker = new TestWorker; connect(thread, SIGNAL(started()), worker, workerSlot); connect(thread, &QThread::finished, worker, &TestWorker::deleteLater); worker->moveToThread(thread); return QSharedPointer(thread); } }; class ThreadList : public QVector< QSharedPointer > { public: bool join(int timeout) { foreach(const QSharedPointer& thread, *this) { // quit event loop Q_ASSERT(thread->isRunning()); thread->quit(); // wait for finish if (!thread->wait(timeout)) { return false; } Q_ASSERT(thread->isFinished()); } return true; } void start() { foreach(const QSharedPointer& thread, *this) { thread->start(); } } }; void TestDUChain::testLockForWrite() { ThreadList threads; for(int i = 0; i < 10; ++i) { threads << TestWorker::createWorkerThread(SLOT(lockForWrite())); } threads.start(); QBENCHMARK { { DUChainWriteLocker lock; } { DUChainReadLocker lock; } } QVERIFY(threads.join(1000)); } void TestDUChain::testLockForRead() { ThreadList threads; for(int i = 0; i < 10; ++i) { threads << TestWorker::createWorkerThread(SLOT(lockForRead())); } threads.start(); QBENCHMARK { DUChainReadLocker lock; } QVERIFY(threads.join(1000)); } void TestDUChain::testLockForReadWrite() { ThreadList threads; for(int i = 0; i < 10; ++i) { threads << TestWorker::createWorkerThread(SLOT(lockForReadWrite())); } threads.start(); QBENCHMARK { DUChainWriteLocker lock; } QVERIFY(threads.join(1000)); } void TestDUChain::testProblemSerialization() { DUChain::self()->disablePersistentStorage(false); auto parent = ProblemPointer{new Problem}; parent->setDescription(QStringLiteral("parent")); auto child = ProblemPointer{new Problem}; child->setDescription(QStringLiteral("child")); parent->addDiagnostic(child); const IndexedString url("/my/test/file"); TopDUContextPointer smartTop; { // serialize DUChainWriteLocker lock; auto file = new ParsingEnvironmentFile(url); auto top = new TopDUContext(url, {}, file); top->addProblem(parent); QCOMPARE(top->problems().size(), 1); auto p = top->problems().at(0); QCOMPARE(p->description(), QStringLiteral("parent")); QCOMPARE(p->diagnostics().size(), 1); auto c = p->diagnostics().first(); QCOMPARE(c->description(), QStringLiteral("child")); DUChain::self()->addDocumentChain(top); QVERIFY(DUChain::self()->chainForDocument(url)); smartTop = top; } DUChain::self()->storeToDisk(); ProblemPointer parent_deserialized; IProblem::Ptr child_deserialized; { // deserialize DUChainWriteLocker lock; QVERIFY(!smartTop); auto top = DUChain::self()->chainForDocument(url); QVERIFY(top); smartTop = top; QCOMPARE(top->problems().size(), 1); parent_deserialized = top->problems().at(0); QCOMPARE(parent_deserialized->diagnostics().size(), 1); child_deserialized = parent_deserialized->diagnostics().first(); QCOMPARE(parent_deserialized->description(), QStringLiteral("parent")); QCOMPARE(child_deserialized->description(), QStringLiteral("child")); top->clearProblems(); QVERIFY(top->problems().isEmpty()); QCOMPARE(parent_deserialized->description(), QStringLiteral("parent")); QCOMPARE(child_deserialized->description(), QStringLiteral("child")); DUChain::self()->removeDocumentChain(top); QCOMPARE(parent_deserialized->description(), QStringLiteral("parent")); QCOMPARE(child_deserialized->description(), QStringLiteral("child")); QVERIFY(!smartTop); } DUChain::self()->disablePersistentStorage(true); QCOMPARE(parent->description(), QStringLiteral("parent")); QCOMPARE(child->description(), QStringLiteral("child")); QCOMPARE(parent_deserialized->description(), QStringLiteral("parent")); QCOMPARE(child_deserialized->description(), QStringLiteral("child")); parent->clearDiagnostics(); QVERIFY(parent->diagnostics().isEmpty()); } void TestDUChain::testIdentifiers() { QualifiedIdentifier aj(QStringLiteral("::Area::jump")); QCOMPARE(aj.count(), 2); QCOMPARE(aj.explicitlyGlobal(), true); QCOMPARE(aj.at(0), Identifier(QStringLiteral("Area"))); QCOMPARE(aj.at(1), Identifier(QStringLiteral("jump"))); QualifiedIdentifier aj2 = QualifiedIdentifier(QStringLiteral("Area::jump")); QCOMPARE(aj2.count(), 2); QCOMPARE(aj2.explicitlyGlobal(), false); QCOMPARE(aj2.at(0), Identifier(QStringLiteral("Area"))); QCOMPARE(aj2.at(1), Identifier(QStringLiteral("jump"))); QVERIFY(aj != aj2); QVERIFY(QualifiedIdentifier(QLatin1String("")) == QualifiedIdentifier()); QVERIFY(QualifiedIdentifier(QLatin1String("")).index() == QualifiedIdentifier().index()); QualifiedIdentifier ajt(QStringLiteral("Area::jump::test")); QualifiedIdentifier jt(QStringLiteral("jump::test")); QualifiedIdentifier ajt2(QStringLiteral("Area::jump::tes")); QualifiedIdentifier t(QStringLiteral(" Area::jump ::tes")); QCOMPARE(t.count(), 3); QCOMPARE(t.at(0).templateIdentifiersCount(), 2u); QCOMPARE(t.at(1).templateIdentifiersCount(), 1u); QCOMPARE(t.at(2).templateIdentifiersCount(), 1u); QCOMPARE(t.at(0).identifier().str(), QStringLiteral("Area")); QCOMPARE(t.at(1).identifier().str(), QStringLiteral("jump")); QCOMPARE(t.at(2).identifier().str(), QStringLiteral("tes")); QualifiedIdentifier op1(QStringLiteral("operator<")); QualifiedIdentifier op2(QStringLiteral("operator<=")); QualifiedIdentifier op3(QStringLiteral("operator>")); QualifiedIdentifier op4(QStringLiteral("operator>=")); QualifiedIdentifier op5(QStringLiteral("operator()")); QualifiedIdentifier op6(QStringLiteral("operator( )")); QCOMPARE(op1.count(), 1); QCOMPARE(op2.count(), 1); QCOMPARE(op3.count(), 1); QCOMPARE(op4.count(), 1); QCOMPARE(op5.count(), 1); QCOMPARE(op6.count(), 1); QCOMPARE(op4.toString(), QStringLiteral("operator>=")); QCOMPARE(op3.toString(), QStringLiteral("operator>")); QCOMPARE(op1.toString(), QStringLiteral("operator<")); QCOMPARE(op2.toString(), QStringLiteral("operator<=")); QCOMPARE(op5.toString(), QStringLiteral("operator()")); QCOMPARE(op6.toString(), QStringLiteral("operator( )")); QCOMPARE(QualifiedIdentifier(QStringLiteral("Area::jump ::tes")).index(), t.index()); QCOMPARE(op4.index(), QualifiedIdentifier(QStringLiteral("operator>=")).index()); QualifiedIdentifier pushTest(QStringLiteral("foo")); QCOMPARE(pushTest.count(), 1); QCOMPARE(pushTest.toString(), QStringLiteral("foo")); pushTest.push(Identifier(QStringLiteral("bar"))); QCOMPARE(pushTest.count(), 2); QCOMPARE(pushTest.toString(), QStringLiteral("foo::bar")); pushTest.push(QualifiedIdentifier(QStringLiteral("baz::asdf"))); QCOMPARE(pushTest.count(), 4); QCOMPARE(pushTest.toString(), QStringLiteral("foo::bar::baz::asdf")); QualifiedIdentifier mergeTest = pushTest.merge(QualifiedIdentifier(QStringLiteral("meh::muh"))); QCOMPARE(mergeTest.count(), 6); QCOMPARE(mergeTest.toString(), QStringLiteral("meh::muh::foo::bar::baz::asdf")); QualifiedIdentifier plusTest = QualifiedIdentifier(QStringLiteral("la::lu")) + QualifiedIdentifier(QStringLiteral("ba::bu")); QCOMPARE(plusTest.count(), 4); QCOMPARE(plusTest.toString(), QStringLiteral("la::lu::ba::bu")); ///@todo create a big randomized test for the identifier repository(check that indices are the same) } #if 0 ///NOTE: the "unit tests" below are not automated, they - so far - require /// human interpretation which is not useful for a unit test! /// someone should investigate what the expected output should be /// and add proper QCOMPARE/QVERIFY checks accordingly ///FIXME: this needs to be rewritten in order to remove dependencies on formerly run unit tests void TestDUChain::testImportCache() { KDevelop::globalItemRepositoryRegistry().printAllStatistics(); KDevelop::RecursiveImportRepository::repository()->printStatistics(); //Analyze the whole existing import-cache //This is very expensive, since it involves loading all existing top-contexts uint topContextCount = DUChain::self()->newTopContextIndex(); uint analyzedCount = 0; uint totalImportCount = 0; uint naiveNodeCount = 0; QSet reachableNodes; DUChainReadLocker lock(DUChain::lock()); for(uint a = 0; a < topContextCount; ++a) { if(a % qMax(1u, topContextCount / 100) == 0) { qDebug() << "progress:" << (a * 100) / topContextCount; } TopDUContext* context = DUChain::self()->chainForIndex(a); if(context) { TopDUContext::IndexedRecursiveImports imports = context->recursiveImportIndices(); ++analyzedCount; totalImportCount += imports.set().count(); collectReachableNodes(reachableNodes, imports.setIndex()); naiveNodeCount += collectNaiveNodeCount(imports.setIndex()); } } QVERIFY(analyzedCount); qDebug() << "average total count of imports:" << totalImportCount / analyzedCount; qDebug() << "count of reachable nodes:" << reachableNodes.size(); qDebug() << "naive node-count:" << naiveNodeCount << "sharing compression factor:" << ((float)reachableNodes.size()) / ((float)naiveNodeCount); } #endif void TestDUChain::benchCodeModel() { const IndexedString file("testFile"); QVERIFY(!QTypeInfo< KDevelop::CodeModelItem >::isStatic); int i = 0; QBENCHMARK { CodeModel::self().addItem(file, QualifiedIdentifier("testQID" + QString::number(i++)), KDevelop::CodeModelItem::Class); } } void TestDUChain::benchTypeRegistry() { IntegralTypeData data; data.m_dataType = IntegralType::TypeInt; data.typeClassId = IntegralType::Identity; data.inRepository = false; data.m_modifiers = 42; data.m_dynamic = false; data.refCount = 1; IntegralTypeData to; QFETCH(int, func); QBENCHMARK { switch(func) { case 0: TypeSystem::self().dataClassSize(data); break; case 1: TypeSystem::self().dynamicSize(data); break; case 2: TypeSystem::self().create(&data); break; case 3: TypeSystem::self().isFactoryLoaded(data); break; case 4: TypeSystem::self().copy(data, to, !data.m_dynamic); break; case 5: TypeSystem::self().copy(data, to, data.m_dynamic); break; case 6: TypeSystem::self().callDestructor(&data); break; } } } void TestDUChain::benchTypeRegistry_data() { QTest::addColumn("func"); QTest::newRow("dataClassSize") << 0; QTest::newRow("dynamicSize") << 1; QTest::newRow("create") << 2; QTest::newRow("isFactoryLoaded") << 3; QTest::newRow("copy") << 4; QTest::newRow("copyNonDynamic") << 5; QTest::newRow("callDestructor") << 6; } void TestDUChain::benchDuchainReadLocker() { QBENCHMARK { DUChainReadLocker lock; } } void TestDUChain::benchDuchainWriteLocker() { QBENCHMARK { DUChainWriteLocker lock; } } void TestDUChain::benchDUChainItemFactory_copy() { DUChainItemFactory factory; DeclarationData from, to; from.classId = Declaration::Identity; QFETCH(int, constant); bool c = constant; QBENCHMARK { factory.copy(from, to, c); if (constant == 2) { c = !c; } } } void TestDUChain::benchDUChainItemFactory_copy_data() { QTest::addColumn("constant"); QTest::newRow("non-const") << 0; QTest::newRow("const") << 1; QTest::newRow("flip") << 2; } void TestDUChain::benchDeclarationQualifiedIdentifier() { QVector contexts; contexts.reserve(10); DUChainWriteLocker lock; contexts << new TopDUContext(IndexedString("/tmp/something"), {0, 0, INT_MAX, INT_MAX}); for (int i = 1; i < contexts.capacity(); ++i) { contexts << new DUContext({0, 0, INT_MAX, INT_MAX}, contexts.at(i-1)); contexts.last()->setLocalScopeIdentifier(QualifiedIdentifier(QString::number(i))); } auto dec = new Declaration({0, 0, 0, 1}, contexts.last()); dec->setIdentifier(Identifier(QStringLiteral("myDecl"))); qDebug() << "start benchmark!"; qint64 count = 0; QBENCHMARK { count += dec->qualifiedIdentifier().count(); } QVERIFY(count > 0); } #include "test_duchain.moc" #include "moc_test_duchain.cpp" diff --git a/language/duchain/tests/test_duchain.h b/language/duchain/tests/test_duchain.h index fee4990294..b0ff7b8b6f 100644 --- a/language/duchain/tests/test_duchain.h +++ b/language/duchain/tests/test_duchain.h @@ -1,62 +1,62 @@ /* * This file is part of KDevelop * * Copyright 2011-2013 Milian Wolff * Copyright 2006 Hamish Rodda * Copyright 2007-2009 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_TEST_DUCHAIN_H #define KDEVPLATFORM_TEST_DUCHAIN_H #include class TestDUChain : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); #ifndef Q_OS_WIN // Causes stack overflow on Windows (MSVC2015) void testStringSets(); #endif void testSymbolTableValid(); void testIndexedStrings(); void testImportStructure(); void testLockForWrite(); void testLockForRead(); void testLockForReadWrite(); void testProblemSerialization(); void testIdentifiers(); ///NOTE: these are not "automated"! // void testImportCache(); void benchCodeModel(); void benchTypeRegistry(); void benchTypeRegistry_data(); void benchDuchainWriteLocker(); void benchDuchainReadLocker(); void benchDUChainItemFactory_copy(); void benchDUChainItemFactory_copy_data(); void benchDeclarationQualifiedIdentifier(); }; #endif // KDEVPLATFORM_TEST_DUCHAIN_H diff --git a/language/duchain/tests/test_duchainshutdown.h b/language/duchain/tests/test_duchainshutdown.h index 98451e0ab2..63e536ac91 100644 --- a/language/duchain/tests/test_duchainshutdown.h +++ b/language/duchain/tests/test_duchainshutdown.h @@ -1,44 +1,44 @@ /* * This file is part of KDevelop * Copyright 2014 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_DUCHAINSHUTDOWN_H #define KDEVPLATFORM_TEST_DUCHAINSHUTDOWN_H #include namespace KDevelop { class TestCore; } class TestDUChainShutdown : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void runTest(); private: KDevelop::TestCore* m_core; }; #endif // TST_DUCHAINSHUTDOWN_H diff --git a/language/duchain/tests/test_identifier.h b/language/duchain/tests/test_identifier.h index 045e42431e..f7dd48d101 100644 --- a/language/duchain/tests/test_identifier.h +++ b/language/duchain/tests/test_identifier.h @@ -1,46 +1,46 @@ /* * This file is part of KDevelop * Copyright 2012-2013 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_TESTIDENTIFIER_H #define KDEVPLATFORM_TESTIDENTIFIER_H #include class TestIdentifier : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void testIdentifier(); void testIdentifier_data(); void testQualifiedIdentifier(); void testQualifiedIdentifier_data(); void benchIdentifierCopyConstant(); void benchIdentifierCopyDynamic(); void benchQidCopyPush(); }; #endif // KDEVPLATFORM_TESTIDENTIFIER_H diff --git a/language/duchain/tests/test_stringhelpers.h b/language/duchain/tests/test_stringhelpers.h index 5a2bba3690..d78cb5794d 100644 --- a/language/duchain/tests/test_stringhelpers.h +++ b/language/duchain/tests/test_stringhelpers.h @@ -1,37 +1,37 @@ /* * This file is part of KDevelop * * Copyright 2016 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_STRINGHELPERS_H #define KDEVPLATFORM_TEST_STRINGHELPERS_H #include class TestDUChain : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void testFormatComment_data(); void testFormatComment(); void benchFormatComment(); }; #endif // KDEVPLATFORM_TEST_STRINGHELPERS_H diff --git a/language/duchain/waitforupdate.h b/language/duchain/waitforupdate.h index 2db83802be..a1ad8cf65b 100644 --- a/language/duchain/waitforupdate.h +++ b/language/duchain/waitforupdate.h @@ -1,48 +1,48 @@ /* 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_WAITFORUPDATE_H #define KDEVPLATFORM_WAITFORUPDATE_H #include "duchain/topducontext.h" #include #include namespace KDevelop { struct WaitForUpdate : public QObject { Q_OBJECT public: WaitForUpdate(); - public slots: + public Q_SLOTS: void updateReady(const KDevelop::IndexedString& url, const KDevelop::ReferencedTopDUContext& topContext); public: bool m_ready; ReferencedTopDUContext m_topContext; }; } #endif // KDEVPLATFORM_WAITFORUPDATE_H diff --git a/language/highlighting/colorcache.h b/language/highlighting/colorcache.h index e08f26dfcb..0d9c91f789 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: + Q_SIGNALS: /// will be emitted whenever the colors got changed /// @see update() void colorsGotChanged(); - private slots: + private Q_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: explicit 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; remove-trailing-spaces all; show-tabs on; tab-indents on; tab-width 2; diff --git a/language/highlighting/tests/test_highlighting.h b/language/highlighting/tests/test_highlighting.h index f60a8cc611..47b8dd58a7 100644 --- a/language/highlighting/tests/test_highlighting.h +++ b/language/highlighting/tests/test_highlighting.h @@ -1,39 +1,39 @@ /* * This file is part of KDevelop * * Copyright 2010 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_HIGHLIGHTING_H #define KDEVPLATFORM_TEST_HIGHLIGHTING_H #include class TestHighlighting : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); // for valgrind void testInitialization(); }; #endif // KDEVPLATFORM_TEST_HIGHLIGHTING_H diff --git a/language/util/tests/test_kdevhash.cpp b/language/util/tests/test_kdevhash.cpp index e976ca5fd6..f8d422d7fb 100644 --- a/language/util/tests/test_kdevhash.cpp +++ b/language/util/tests/test_kdevhash.cpp @@ -1,82 +1,82 @@ /* This file is part of KDevelop Copyright 2015 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. */ #include #include #include #include #include "../kdevhash.h" namespace { template std::vector generateData(std::size_t size) { auto ret = std::vector(size); std::iota(ret.begin(), ret.end(), T(0)); return ret; } template void runBench() { const auto data = generateData(10000); KDevHash hash; QBENCHMARK { for (T i : data) { hash << i; } } QVERIFY(static_cast(hash)); } } class TestKDevHash : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void benchHash_int() { runBench(); } void benchHash_uint() { runBench(); } void benchHash_quint64() { runBench(); } void benchHash_bool() { runBench(); } }; QTEST_MAIN(TestKDevHash) #include "test_kdevhash.moc" diff --git a/outputview/outputexecutejob.h b/outputview/outputexecutejob.h index 92aa3f34f4..dc11c76ec0 100644 --- a/outputview/outputexecutejob.h +++ b/outputview/outputexecutejob.h @@ -1,250 +1,250 @@ /* 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 namespace KDevelop { 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) explicit 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: +protected Q_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; }; } // namespace KDevelop Q_DECLARE_OPERATORS_FOR_FLAGS(KDevelop::OutputExecuteJob::JobProperties); #endif // KDEVPLATFORM_OUTPUTEXECUTEJOB_H diff --git a/outputview/outputmodel.cpp b/outputview/outputmodel.cpp index bb45cb1324..c5c8fb48c1 100644 --- a/outputview/outputmodel.cpp +++ b/outputview/outputmodel.cpp @@ -1,475 +1,475 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * Copyright 2010 Aleix Pol Gonzalez * * 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. * ***************************************************************************/ #include "outputmodel.h" #include "filtereditem.h" #include "outputfilteringstrategies.h" #include "debug.h" #include #include #include #include #include #include #include #include #include #include Q_DECLARE_METATYPE(QVector) namespace KDevelop { /** * Number of lines that are processed in one go before we notify the GUI thread * about the result. It is generally faster to add multiple items to a model * in one go compared to adding each item independently. */ static const int BATCH_SIZE = 50; /** * Time in ms that we wait in the parse worker for new incoming lines before * actually processing them. If we already have enough for one batch though * we process immediately. */ static const int BATCH_AGGREGATE_TIME_DELAY = 50; class ParseWorker : public QObject { Q_OBJECT public: ParseWorker() : QObject(nullptr) , m_filter(new NoFilterStrategy) , m_timer(new QTimer(this)) { m_timer->setInterval(BATCH_AGGREGATE_TIME_DELAY); m_timer->setSingleShot(true); connect(m_timer, &QTimer::timeout, this, &ParseWorker::process); } -public slots: +public Q_SLOTS: void changeFilterStrategy( KDevelop::IFilterStrategy* newFilterStrategy ) { m_filter = QSharedPointer( newFilterStrategy ); } void addLines( const QStringList& lines ) { m_cachedLines << lines; if (m_cachedLines.size() >= BATCH_SIZE) { // if enough lines were added, process immediately m_timer->stop(); process(); } else if (!m_timer->isActive()) { m_timer->start(); } } void flushBuffers() { m_timer->stop(); process(); emit allDone(); } -signals: +Q_SIGNALS: void parsedBatch(const QVector& filteredItems); void progress(const KDevelop::IFilterStrategy::Progress& progress); void allDone(); -private slots: +private Q_SLOTS: /** * Process *all* cached lines, emit parsedBatch for each batch */ void process() { QVector filteredItems; filteredItems.reserve(qMin(BATCH_SIZE, m_cachedLines.size())); // apply pre-filtering functions std::transform(m_cachedLines.constBegin(), m_cachedLines.constEnd(), m_cachedLines.begin(), &KDevelop::stripAnsiSequences); // apply filtering strategy foreach(const QString& line, m_cachedLines) { FilteredItem item = m_filter->errorInLine(line); if( item.type == FilteredItem::InvalidItem ) { item = m_filter->actionInLine(line); } filteredItems << item; auto progress = m_filter->progressInLine(line); if (progress.percent >= 0 && m_progress.percent != progress.percent) { m_progress = progress; emit this->progress(m_progress); } if( filteredItems.size() == BATCH_SIZE ) { emit parsedBatch(filteredItems); filteredItems.clear(); filteredItems.reserve(qMin(BATCH_SIZE, m_cachedLines.size())); } } // Make sure to emit the rest as well if( !filteredItems.isEmpty() ) { emit parsedBatch(filteredItems); } m_cachedLines.clear(); } private: QSharedPointer m_filter; QStringList m_cachedLines; QTimer* m_timer; IFilterStrategy::Progress m_progress; }; class ParsingThread { public: ParsingThread() { m_thread.setObjectName(QStringLiteral("OutputFilterThread")); } virtual ~ParsingThread() { if (m_thread.isRunning()) { m_thread.quit(); m_thread.wait(); } } void addWorker(ParseWorker* worker) { if (!m_thread.isRunning()) { m_thread.start(); } worker->moveToThread(&m_thread); } private: QThread m_thread; }; Q_GLOBAL_STATIC(ParsingThread, s_parsingThread); struct OutputModelPrivate { explicit OutputModelPrivate( OutputModel* model, const QUrl& builddir = QUrl() ); ~OutputModelPrivate(); bool isValidIndex( const QModelIndex&, int currentRowCount ) const; OutputModel* model; ParseWorker* worker; QVector m_filteredItems; // We use std::set because that is ordered std::set m_errorItems; // Indices of all items that we want to move to using previous and next QUrl m_buildDir; void linesParsed(const QVector& items) { model->beginInsertRows( QModelIndex(), model->rowCount(), model->rowCount() + items.size() - 1); foreach( const FilteredItem& item, items ) { if( item.type == FilteredItem::ErrorItem ) { m_errorItems.insert(m_filteredItems.size()); } m_filteredItems << item; } model->endInsertRows(); } }; OutputModelPrivate::OutputModelPrivate( OutputModel* model_, const QUrl& builddir) : model(model_) , worker(new ParseWorker ) , m_buildDir( builddir ) { qRegisterMetaType >(); qRegisterMetaType(); qRegisterMetaType(); s_parsingThread->addWorker(worker); model->connect(worker, &ParseWorker::parsedBatch, model, [=] (const QVector& items) { linesParsed(items); }); model->connect(worker, &ParseWorker::allDone, model, &OutputModel::allDone); model->connect(worker, &ParseWorker::progress, model, &OutputModel::progress); } bool OutputModelPrivate::isValidIndex( const QModelIndex& idx, int currentRowCount ) const { return ( idx.isValid() && idx.row() >= 0 && idx.row() < currentRowCount && idx.column() == 0 ); } OutputModelPrivate::~OutputModelPrivate() { worker->deleteLater(); } OutputModel::OutputModel( const QUrl& builddir, QObject* parent ) : QAbstractListModel(parent) , d( new OutputModelPrivate( this, builddir ) ) { } OutputModel::OutputModel( QObject* parent ) : QAbstractListModel(parent) , d( new OutputModelPrivate( this ) ) { } OutputModel::~OutputModel() { delete d; } QVariant OutputModel::data(const QModelIndex& idx , int role ) const { if( d->isValidIndex(idx, rowCount()) ) { switch( role ) { case Qt::DisplayRole: return d->m_filteredItems.at( idx.row() ).originalLine; break; case OutputModel::OutputItemTypeRole: return static_cast(d->m_filteredItems.at( idx.row() ).type); break; case Qt::FontRole: return QFontDatabase::systemFont(QFontDatabase::FixedFont); break; default: break; } } return QVariant(); } int OutputModel::rowCount( const QModelIndex& parent ) const { if( !parent.isValid() ) return d->m_filteredItems.count(); return 0; } QVariant OutputModel::headerData( int, Qt::Orientation, int ) const { return QVariant(); } void OutputModel::activate( const QModelIndex& index ) { if( index.model() != this || !d->isValidIndex(index, rowCount()) ) { return; } qCDebug(OUTPUTVIEW) << "Model activated" << index.row(); FilteredItem item = d->m_filteredItems.at( index.row() ); if( item.isActivatable ) { qCDebug(OUTPUTVIEW) << "activating:" << item.lineNo << item.url; KTextEditor::Cursor range( item.lineNo, item.columnNo ); KDevelop::IDocumentController *docCtrl = KDevelop::ICore::self()->documentController(); QUrl url = item.url; if (item.url.isEmpty()) { qCWarning(OUTPUTVIEW) << "trying to open empty url"; return; } if(url.isRelative()) { url = d->m_buildDir.resolved(url); } Q_ASSERT(!url.isRelative()); docCtrl->openDocument( url, range ); } else { qCDebug(OUTPUTVIEW) << "not an activateable item"; } } QModelIndex OutputModel::firstHighlightIndex() { if( !d->m_errorItems.empty() ) { return index( *d->m_errorItems.begin(), 0, QModelIndex() ); } for( int row = 0; row < rowCount(); ++row ) { if( d->m_filteredItems.at( row ).isActivatable ) { return index( row, 0, QModelIndex() ); } } return QModelIndex(); } QModelIndex OutputModel::nextHighlightIndex( const QModelIndex ¤tIdx ) { int startrow = d->isValidIndex(currentIdx, rowCount()) ? currentIdx.row() + 1 : 0; if( !d->m_errorItems.empty() ) { qCDebug(OUTPUTVIEW) << "searching next error"; // Jump to the next error item std::set< int >::const_iterator next = d->m_errorItems.lower_bound( startrow ); if( next == d->m_errorItems.end() ) next = d->m_errorItems.begin(); return index( *next, 0, QModelIndex() ); } for( int row = 0; row < rowCount(); ++row ) { int currow = (startrow + row) % rowCount(); if( d->m_filteredItems.at( currow ).isActivatable ) { return index( currow, 0, QModelIndex() ); } } return QModelIndex(); } QModelIndex OutputModel::previousHighlightIndex( const QModelIndex ¤tIdx ) { //We have to ensure that startrow is >= rowCount - 1 to get a positive value from the % operation. int startrow = rowCount() + (d->isValidIndex(currentIdx, rowCount()) ? currentIdx.row() : rowCount()) - 1; if(!d->m_errorItems.empty()) { qCDebug(OUTPUTVIEW) << "searching previous error"; // Jump to the previous error item std::set< int >::const_iterator previous = d->m_errorItems.lower_bound( currentIdx.row() ); if( previous == d->m_errorItems.begin() ) previous = d->m_errorItems.end(); --previous; return index( *previous, 0, QModelIndex() ); } for ( int row = 0; row < rowCount(); ++row ) { int currow = (startrow - row) % rowCount(); if( d->m_filteredItems.at( currow ).isActivatable ) { return index( currow, 0, QModelIndex() ); } } return QModelIndex(); } QModelIndex OutputModel::lastHighlightIndex() { if( !d->m_errorItems.empty() ) { return index( *d->m_errorItems.rbegin(), 0, QModelIndex() ); } for( int row = rowCount()-1; row >=0; --row ) { if( d->m_filteredItems.at( row ).isActivatable ) { return index( row, 0, QModelIndex() ); } } return QModelIndex(); } void OutputModel::setFilteringStrategy(const OutputFilterStrategy& currentStrategy) { // TODO: Turn into factory, decouple from OutputModel IFilterStrategy* filter = nullptr; switch( currentStrategy ) { case NoFilter: filter = new NoFilterStrategy; break; case CompilerFilter: filter = new CompilerFilterStrategy( d->m_buildDir ); break; case ScriptErrorFilter: filter = new ScriptErrorFilterStrategy; break; case NativeAppErrorFilter: filter = new NativeAppErrorFilterStrategy; break; case StaticAnalysisFilter: filter = new StaticAnalysisFilterStrategy; break; default: // assert(false); filter = new NoFilterStrategy; break; } Q_ASSERT(filter); QMetaObject::invokeMethod(d->worker, "changeFilterStrategy", Q_ARG(KDevelop::IFilterStrategy*, filter)); } void OutputModel::setFilteringStrategy(IFilterStrategy* filterStrategy) { QMetaObject::invokeMethod(d->worker, "changeFilterStrategy", Q_ARG(KDevelop::IFilterStrategy*, filterStrategy)); } void OutputModel::appendLines( const QStringList& lines ) { if( lines.isEmpty() ) return; QMetaObject::invokeMethod(d->worker, "addLines", Q_ARG(QStringList, lines)); } void OutputModel::appendLine( const QString& line ) { appendLines( QStringList() << line ); } void OutputModel::ensureAllDone() { QMetaObject::invokeMethod(d->worker, "flushBuffers"); } void OutputModel::clear() { ensureAllDone(); beginResetModel(); d->m_filteredItems.clear(); endResetModel(); } } #include "outputmodel.moc" #include "moc_outputmodel.cpp" diff --git a/outputview/outputmodel.h b/outputview/outputmodel.h index 24a5eaf9f1..edb98b3ffd 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 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 = 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(); void clear(); -signals: +Q_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_filteringstrategy.h b/outputview/tests/test_filteringstrategy.h index e928bd23e0..8ba35d85a8 100644 --- a/outputview/tests/test_filteringstrategy.h +++ b/outputview/tests/test_filteringstrategy.h @@ -1,52 +1,52 @@ /* This file is part of KDevelop 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_FILTERINGSTRATEGY_H #define KDEVPLATFORM_TEST_FILTERINGSTRATEGY_H #include namespace KDevelop { class TestFilteringStrategy : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void testNoFilterStrategy_data(); void testNoFilterStrategy(); void testCompilerFilterStrategy_data(); void testCompilerFilterStrategy(); void testCompilerFilterstrategyMultipleKeywords_data(); void testCompilerFilterstrategyMultipleKeywords(); void testCompilerFilterstrategyUrlFromAction_data(); void testCompilerFilterstrategyUrlFromAction(); void testScriptErrorFilterStrategy_data(); void testScriptErrorFilterStrategy(); void testNativeAppErrorFilterStrategy_data(); void testNativeAppErrorFilterStrategy(); void testStaticAnalysisFilterStrategy_data(); void testStaticAnalysisFilterStrategy(); void testExtractionOfLineAndColumn_data(); void testExtractionOfLineAndColumn(); void benchMarkCompilerFilterAction(); }; } #endif // KDEVPLATFORM_TEST_FILTERINGSTRATEGY_H diff --git a/outputview/tests/test_outputmodel.h b/outputview/tests/test_outputmodel.h index 90f96a0dbd..f1040eb47b 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 = nullptr); -private slots: +private Q_SLOTS: void bench(); void bench_data(); }; } #endif // KDEVPLATFORM_TEST_OUTPUTMODEL_H diff --git a/plugins/appwizard/appwizarddialog.h b/plugins/appwizard/appwizarddialog.h index 22ace6d6da..f1de1c51e8 100644 --- a/plugins/appwizard/appwizarddialog.h +++ b/plugins/appwizard/appwizarddialog.h @@ -1,64 +1,64 @@ /*************************************************************************** * Copyright 2007 Alexander Dymo * * * * 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 _APPWIZARDDIALOG_H_ #define _APPWIZARDDIALOG_H_ #include #include #include #include class KPageWidgetItem; class QSignalMapper; class ProjectSelectionPage; class ProjectVcsPage; class ProjectTemplatesModel; namespace KDevelop { class IPluginController; } class ApplicationInfo { public: QString name; QUrl location; QString vcsPluginName; QUrl sourceLocation; KDevelop::VcsLocation repository; QString importCommitMessage; QString appTemplate; }; class AppWizardDialog: public KAssistantDialog { Q_OBJECT public: AppWizardDialog( KDevelop::IPluginController*, ProjectTemplatesModel*, QWidget *parent = nullptr); ApplicationInfo appInfo() const; -private slots: +private Q_SLOTS: void pageInValid( QWidget* w ); void pageValid( QWidget* w ); void next() override; private: QMap m_pageItems; QSignalMapper* m_invalidMapper; QSignalMapper* m_validMapper; ProjectSelectionPage* m_selectionPage; ProjectVcsPage* m_vcsPage; }; #endif diff --git a/plugins/appwizard/appwizardplugin.h b/plugins/appwizard/appwizardplugin.h index 8549f85f3e..ed0a7f7f8e 100644 --- a/plugins/appwizard/appwizardplugin.h +++ b/plugins/appwizard/appwizardplugin.h @@ -1,59 +1,59 @@ /*************************************************************************** * Copyright 2001 Bernd Gehrmann * * Copyright 2004-2005 Sascha Cunz * * Copyright 2007 Alexander Dymo * * * * 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 _APPWIZARDPLUGIN_H_ #define _APPWIZARDPLUGIN_H_ #include #include #include #include class ProjectTemplatesModel; class ApplicationInfo; class KArchiveDirectory; class AppWizardPlugin: public KDevelop::IPlugin, public KDevelop::ITemplateProvider { Q_OBJECT Q_INTERFACES(KDevelop::ITemplateProvider) public: explicit AppWizardPlugin(QObject *parent, const QVariantList & = QVariantList()); ~AppWizardPlugin() override; KDevelop::ContextMenuExtension contextMenuExtension(KDevelop::Context* context) override; QAbstractItemModel* templatesModel() override; QString knsConfigurationFile() const override; QStringList supportedMimeTypes() const override; QString name() const override; QIcon icon() const override; void loadTemplate(const QString& fileName) override; void reload() override; -private slots: +private Q_SLOTS: void slotNewProject(); private: ProjectTemplatesModel* model(); QString createProject(const ApplicationInfo& ); bool unpackArchive(const KArchiveDirectory *dir, const QString &dest); bool copyFileAndExpandMacros(const QString &source, const QString &dest); ProjectTemplatesModel* m_templatesModel; QAction* m_newFromTemplate; QHash m_variables; }; #endif diff --git a/plugins/appwizard/projectselectionpage.h b/plugins/appwizard/projectselectionpage.h index fd91b49401..16f9050d60 100644 --- a/plugins/appwizard/projectselectionpage.h +++ b/plugins/appwizard/projectselectionpage.h @@ -1,68 +1,68 @@ /*************************************************************************** * Copyright 2007 Alexander Dymo * * * * 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 _PROJECTSELECTIONPAGE_H_ #define _PROJECTSELECTIONPAGE_H_ #include "appwizardpagewidget.h" #include "appwizarddialog.h" namespace KDevelop { class MultiLevelListView; } namespace Ui { class ProjectSelectionPage; } class ProjectTemplatesModel; class QModelIndex; class QStandardItem; class QUrl; class ProjectSelectionPage : public AppWizardPageWidget { Q_OBJECT public: explicit ProjectSelectionPage(ProjectTemplatesModel *templatesModel, AppWizardDialog *wizardDialog); ~ProjectSelectionPage() override; bool shouldContinue() override; QString selectedTemplate(); QString projectName(); QUrl location(); -signals: +Q_SIGNALS: void locationChanged( const QUrl& ); void valid(); void invalid(); -private slots: +private Q_SLOTS: void itemChanged( const QModelIndex& current ); void urlEdited(); void validateData(); void nameChanged(); void typeChanged(const QModelIndex& idx); void templateChanged(int); void loadFileClicked(); void moreTemplatesClicked(); private: inline QByteArray encodedProjectName(); inline QStandardItem* getCurrentItem() const; void setCurrentTemplate(const QString& fileName); Ui::ProjectSelectionPage *ui; KDevelop::MultiLevelListView* m_listView; ProjectTemplatesModel *m_templatesModel; AppWizardDialog *m_wizardDialog; }; #endif diff --git a/plugins/appwizard/projectvcspage.h b/plugins/appwizard/projectvcspage.h index cd2c2932ea..99b1b86677 100644 --- a/plugins/appwizard/projectvcspage.h +++ b/plugins/appwizard/projectvcspage.h @@ -1,67 +1,67 @@ /*************************************************************************** * 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 "appwizardpagewidget.h" namespace Ui { class ProjectVcsPage; } namespace KDevelop { class IPluginController; class VcsImportMetadataWidget; class VcsLocation; } class QUrl; class ProjectVcsPage : public AppWizardPageWidget { Q_OBJECT public: explicit ProjectVcsPage( KDevelop::IPluginController*, QWidget* parent = nullptr ); ~ProjectVcsPage() override; bool shouldContinue() override; -signals: +Q_SIGNALS: void valid(); void invalid(); -public slots: +public Q_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/bazaarplugin.h b/plugins/bazaar/bazaarplugin.h index 81956c0dec..66b067e5ae 100644 --- a/plugins/bazaar/bazaarplugin.h +++ b/plugins/bazaar/bazaarplugin.h @@ -1,79 +1,79 @@ /*************************************************************************** * 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_BAZAARPLUGIN_H #define BAZAAR_BAZAARPLUGIN_H #include #include #include #include namespace KDevelop { class DVcsJob; } class BazaarPlugin : public KDevelop::IPlugin, public KDevelop::IDistributedVersionControl { Q_OBJECT Q_INTERFACES(KDevelop::IBasicVersionControl KDevelop::IDistributedVersionControl) public: explicit BazaarPlugin(QObject* parent, const QVariantList& args = QVariantList()); ~BazaarPlugin() override; QString name() const override; bool isValidRemoteRepositoryUrl(const QUrl& remoteLocation) override; KDevelop::VcsJob* add(const QList& localLocations, RecursionMode recursion=Recursive) override; KDevelop::VcsJob* annotate(const QUrl& localLocation, const KDevelop::VcsRevision& rev) override; KDevelop::VcsJob* commit(const QString& message, const QList& localLocations, RecursionMode recursion=Recursive) override; KDevelop::VcsJob* copy(const QUrl& localLocationSrc, const QUrl& localLocationDstn) override; KDevelop::VcsImportMetadataWidget* createImportMetadataWidget(QWidget* parent) override; KDevelop::VcsJob* createWorkingCopy(const KDevelop::VcsLocation& sourceRepository, const QUrl& destinationDirectory, RecursionMode recursion=Recursive) override; KDevelop::VcsJob* diff(const QUrl& fileOrDirectory, const KDevelop::VcsRevision& srcRevision, const KDevelop::VcsRevision& dstRevision, KDevelop::VcsDiff::Type, RecursionMode recursion=Recursive) override; KDevelop::VcsJob* init(const QUrl& localRepositoryRoot) override; bool isVersionControlled(const QUrl& localLocation) override; KDevelop::VcsJob* log(const QUrl& localLocation, const KDevelop::VcsRevision& rev, long unsigned int limit) override; KDevelop::VcsJob* log(const QUrl& localLocation, const KDevelop::VcsRevision& rev, const KDevelop::VcsRevision& limit) override; KDevelop::VcsJob* move(const QUrl& localLocationSrc, const QUrl& localLocationDst) override; KDevelop::VcsJob* pull(const KDevelop::VcsLocation& localOrRepoLocationSrc, const QUrl& localRepositoryLocation) override; KDevelop::VcsJob* push(const QUrl& localRepositoryLocation, const KDevelop::VcsLocation& localOrRepoLocationDst) override; KDevelop::VcsJob* remove(const QList& localLocations) override; KDevelop::VcsJob* repositoryLocation(const QUrl& localLocation) override; KDevelop::VcsJob* resolve(const QList& localLocations, RecursionMode recursio=Recursive) override; KDevelop::VcsJob* revert(const QList& localLocations, RecursionMode recursion=Recursive) override; KDevelop::VcsJob* status(const QList& localLocations, RecursionMode recursion=Recursive) override; KDevelop::VcsJob* update(const QList& localLocations, const KDevelop::VcsRevision& rev, RecursionMode recursion=Recursive) override; KDevelop::VcsLocationWidget* vcsLocation(QWidget* parent) const override; KDevelop::ContextMenuExtension contextMenuExtension(KDevelop::Context* context) override; -private slots: +private Q_SLOTS: void parseBzrStatus(KDevelop::DVcsJob* job); void parseBzrLog(KDevelop::DVcsJob* job); void parseBzrRoot(KDevelop::DVcsJob* job); private: KDevelop::VcsPluginHelper* m_vcsPluginHelper; }; #endif // BAZAAR_BAZAARPLUGIN_H diff --git a/plugins/bazaar/bzrannotatejob.h b/plugins/bazaar/bzrannotatejob.h index 1b1b9a98a1..82f3ec4533 100644 --- a/plugins/bazaar/bzrannotatejob.h +++ b/plugins/bazaar/bzrannotatejob.h @@ -1,74 +1,74 @@ /*************************************************************************** * 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 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 = 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: +private Q_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 34685dd112..bf9afa9a77 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 = 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: +private Q_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 87becaaed5..ef043880e4 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 = 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: +private Q_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/bazaar/tests/test_bazaar.h b/plugins/bazaar/tests/test_bazaar.h index a116249cb5..77e7527dd0 100644 --- a/plugins/bazaar/tests/test_bazaar.h +++ b/plugins/bazaar/tests/test_bazaar.h @@ -1,70 +1,70 @@ /*************************************************************************** * This file was partly taken from KDevelop's cvs plugin * * Copyright 2007 Robert Gruber * * * * Adapted for Git * * Copyright 2008 Evgeniy Ivanov * * * * Adapted for Bazaar * * 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_PLUGIN_TEST_BAZAAR_H #define KDEVPLATFORM_PLUGIN_TEST_BAZAAR_H #include class BazaarPlugin; namespace KDevelop { class TestCore; } class TestBazaar: public QObject { Q_OBJECT private: void repoInit(); void addFiles(); void prepareWhoamiInformations(); void commitFiles(); -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void init(); void cleanup(); void testInit(); void testAdd(); void testCommit(); void testAnnotation(); void testRemoveEmptyFolder(); void testRemoveEmptyFolderInFolder(); void testRemoveUnindexedFile(); void testRemoveFolderContainingUnversionedFiles(); private: BazaarPlugin* m_plugin; void removeTempDirs(); }; #endif // KDEVPLATFORM_PLUGIN_TEST_BAZAAR_H diff --git a/plugins/codeutils/codeutilsplugin.h b/plugins/codeutils/codeutilsplugin.h index 6049de6049..99576596df 100644 --- a/plugins/codeutils/codeutilsplugin.h +++ b/plugins/codeutils/codeutilsplugin.h @@ -1,43 +1,43 @@ /* * This file is part of KDevelop * Copyright 2010 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_PLUGIN_CODEUTILSPLUGIN_H #define KDEVPLATFORM_PLUGIN_CODEUTILSPLUGIN_H #include #include #include #include Q_DECLARE_LOGGING_CATEGORY(PLUGIN_CODEUTILS) class CodeUtilsPlugin : public KDevelop::IPlugin { Q_OBJECT public: explicit CodeUtilsPlugin( QObject *parent, const QVariantList & = QVariantList() ); ~CodeUtilsPlugin() override; -private slots: +private Q_SLOTS: void documentDeclaration(); }; #endif // KDEVPLATFORM_PLUGIN_CODEUTILSPLUGIN_H diff --git a/plugins/contextbrowser/browsemanager.h b/plugins/contextbrowser/browsemanager.h index 8ed48f7e43..654bfd747c 100644 --- a/plugins/contextbrowser/browsemanager.h +++ b/plugins/contextbrowser/browsemanager.h @@ -1,122 +1,122 @@ /* * 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 class QWidget; namespace KTextEditor { class View; class Document; } namespace KDevelop { class IDocument; } class EditorViewWatcher : public QObject { Q_OBJECT public: 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: +private Q_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(); void invokeAction(int index); - public slots: + public Q_SLOTS: ///Enabled/disables the browsing mode void setBrowsing(bool); - private slots: + private Q_SLOTS: void eventuallyStartDelayedBrowsing(); private: struct JumpLocation { QUrl url; KTextEditor::Cursor cursor; 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; bool m_browsing; 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_browsingStartedInView; KTextEditor::Cursor m_buttonPressPosition; }; #endif diff --git a/plugins/contextbrowser/contextbrowser.h b/plugins/contextbrowser/contextbrowser.h index 25ab2d4ad9..62c6164743 100644 --- a/plugins/contextbrowser/contextbrowser.h +++ b/plugins/contextbrowser/contextbrowser.h @@ -1,282 +1,282 @@ /* * This file is part of KDevelop * * Copyright 2007 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_CONTEXTBROWSERPLUGIN_H #define KDEVPLATFORM_PLUGIN_CONTEXTBROWSERPLUGIN_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include class QHBoxLayout; class QMenu; class QToolButton; namespace Sublime { class MainWindow; } namespace KDevelop { class IDocument; class DUContext; class TopDUContext; class ReferencedTopDUContext; class DUChainBase; class AbstractNavigationWidget; } namespace KTextEditor { class Document; class View; } class ContextBrowserViewFactory; class ContextBrowserView; class ContextBrowserPlugin; class BrowseManager; class ContextBrowserHintProvider : public KTextEditor::TextHintProvider { public: explicit ContextBrowserHintProvider(ContextBrowserPlugin* plugin); QString textHint(KTextEditor::View* view, const KTextEditor::Cursor& position) override; private: ContextBrowserPlugin* m_plugin; }; QWidget* masterWidget(QWidget* w); struct ViewHighlights { ViewHighlights() : keep(false) { } // Whether the same highlighting should be kept highlighted (usually during typing) bool keep; // The declaration that is highlighted for this view KDevelop::IndexedDeclaration declaration; // Highlighted ranges. Those may also be contained by different views. QList highlights; }; class ContextBrowserPlugin : public KDevelop::IPlugin, public KDevelop::IContextBrowser { Q_OBJECT Q_INTERFACES( KDevelop::IContextBrowser ) public: explicit ContextBrowserPlugin(QObject *parent, const QVariantList & = QVariantList() ); ~ContextBrowserPlugin() override; void unload() override; void registerToolView(ContextBrowserView* view); void unRegisterToolView(ContextBrowserView* view); KDevelop::ContextMenuExtension contextMenuExtension(KDevelop::Context*) override; KXMLGUIClient* createGUIForMainWindow( Sublime::MainWindow* window ) override; ///duchain must be locked ///@param force When this is true, the history-entry is added, no matter whether the context is "interesting" or not void updateHistory(KDevelop::DUContext* context, const KTextEditor::Cursor& cursorPosition, bool force = false); void updateDeclarationListBox(KDevelop::DUContext* context); void showUses(const KDevelop::DeclarationPointer& declaration) override; KTextEditor::Attribute::Ptr highlightedUseAttribute(KTextEditor::View* view) const; KTextEditor::Attribute::Ptr highlightedSpecialObjectAttribute(KTextEditor::View* view) const; public Q_SLOTS: void showUsesDelayed(const KDevelop::DeclarationPointer& declaration); void previousContextShortcut(); void nextContextShortcut(); void startDelayedBrowsing(KTextEditor::View* view); void stopDelayedBrowsing(); void invokeAction(int index); void previousUseShortcut(); void nextUseShortcut(); void declarationSelectedInUI(const KDevelop::DeclarationPointer& decl); void updateReady(const KDevelop::IndexedString& url, const KDevelop::ReferencedTopDUContext& topContext); void textDocumentCreated( KDevelop::IDocument* document ); void documentActivated( KDevelop::IDocument* ); void viewDestroyed( QObject* obj ); void cursorPositionChanged( KTextEditor::View* view, const KTextEditor::Cursor& newPosition ); void viewCreated( KTextEditor::Document* , KTextEditor::View* ); void updateViews(); void hideToolTip(); void findUses(); void textInserted(KTextEditor::Document* doc, const KTextEditor::Cursor& cursor, const QString& text); void selectionChanged(KTextEditor::View*); void historyNext(); void historyPrevious(); void colorSetupChanged(); - private slots: + private Q_SLOTS: // history browsing void documentJumpPerformed( KDevelop::IDocument* newDocument, const KTextEditor::Cursor& newCursor, KDevelop::IDocument* previousDocument, const KTextEditor::Cursor& previousCursor); void nextMenuAboutToShow(); void previousMenuAboutToShow(); void actionTriggered(); void navigateLeft(); void navigateRight(); void navigateUp(); void navigateDown(); void navigateAccept(); void navigateBack(); private: QWidget* toolbarWidgetForMainWindow(Sublime::MainWindow* window); void createActionsForMainWindow(Sublime::MainWindow* window, QString& xmlFile, KActionCollection& actions) override; QWidget* navigationWidgetForPosition(KTextEditor::View* view, KTextEditor::Cursor position); void switchUse(bool forward); void clearMouseHover(); void addHighlight( KTextEditor::View* view, KDevelop::Declaration* decl ); /** helper for updateBrowserView(). * Tries to find a 'specialLanguageObject' (eg macro) in @p view under cursor @c. * If found returns true and sets @p pickedLanguage to the language this object belongs to */ KDevelop::Declaration* findDeclaration(KTextEditor::View* view, const KTextEditor::Cursor&, bool mouseHighlight); void updateForView(KTextEditor::View* view); // history browsing bool isPreviousEntry(KDevelop::DUContext*, const KTextEditor::Cursor& cursor) const; QString actionTextFor(int historyIndex) const; void updateButtonState(); void openDocument(int historyIndex); void fillHistoryPopup(QMenu* menu, const QList& historyIndices); enum NavigationActionType { Accept, Back, Down, Up, Left, Right }; void doNavigate(NavigationActionType action); private: // Returns the currently active and visible context browser view that belongs // to the same context (mainwindow and area) as the given widget ContextBrowserView* browserViewForWidget(QWidget* widget); void showToolTip(KTextEditor::View* view, KTextEditor::Cursor position); QTimer* m_updateTimer; //Contains the range, the old attribute, and the attribute it was replaced with QSet m_updateViews; QMap m_highlightedRanges; //Holds a list of all active context browser tool views QList m_views; //Used to override the next declaration that will be highlighted KDevelop::IndexedDeclaration m_useDeclaration; KDevelop::IndexedDeclaration m_lastHighlightedDeclaration; QUrl m_mouseHoverDocument; KTextEditor::Cursor m_mouseHoverCursor; ContextBrowserViewFactory* m_viewFactory; QPointer m_currentToolTip; QPointer m_currentNavigationWidget; KDevelop::IndexedDeclaration m_currentToolTipDeclaration; QVector m_currentToolTipProblems; QAction* m_findUses; QPointer m_lastInsertionDocument; KTextEditor::Cursor m_lastInsertionPos; // outline toolbar QPointer m_outlineLine; QPointer m_toolbarWidgetLayout; QPointer m_toolbarWidget; // history browsing struct HistoryEntry { //Duchain must be locked explicit HistoryEntry(KDevelop::IndexedDUContext ctx = KDevelop::IndexedDUContext(), const KTextEditor::Cursor& cursorPosition = KTextEditor::Cursor()); explicit HistoryEntry(KDevelop::DocumentCursor pos); //Duchain must be locked void setCursorPosition(const KTextEditor::Cursor& cursorPosition); //Duchain does not need to be locked KDevelop::DocumentCursor computePosition() const; KDevelop::IndexedDUContext context; KDevelop::DocumentCursor absoluteCursorPosition; KTextEditor::Cursor relativeCursorPosition; //Cursor position relative to the start line of the context QString alternativeString; }; QVector m_history; QPointer m_previousButton; QPointer m_nextButton; QPointer m_previousMenu, m_nextMenu; QList m_listDeclarations; KDevelop::IndexedString m_listUrl; BrowseManager* m_browseManager; //Used to not record jumps triggered by the context-browser as history entries QPointer m_focusBackWidget; int m_nextHistoryIndex; mutable KTextEditor::Attribute::Ptr m_highlightAttribute; friend class ContextBrowserHintProvider; ContextBrowserHintProvider m_textHintProvider; }; #endif // KDEVPLATFORM_PLUGIN_CONTEXTBROWSERPLUGIN_H // kate: space-indent on; indent-width 2; tab-width 4; replace-tabs on; auto-insert-doxygen on diff --git a/plugins/cvs/checkoutdialog.h b/plugins/cvs/checkoutdialog.h index b02bcbd596..9f736f99ef 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=nullptr); ~CheckoutDialog() override; -public slots: +public Q_SLOTS: void accept() override; void jobFinished(KJob* job); private: CvsPlugin* m_plugin; }; #endif diff --git a/plugins/cvs/cvsgenericoutputview.h b/plugins/cvs/cvsgenericoutputview.h index 5c40b08584..1e6cea9ffa 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 = nullptr, QWidget* parent = nullptr); ~CvsGenericOutputView() override; -public slots: +public Q_SLOTS: void appendText(const QString& text); void slotJobFinished(KJob* job); }; #endif diff --git a/plugins/cvs/cvsmainview.h b/plugins/cvs/cvsmainview.h index d4ac748d3c..afacf353d0 100644 --- a/plugins/cvs/cvsmainview.h +++ b/plugins/cvs/cvsmainview.h @@ -1,67 +1,67 @@ /*************************************************************************** * 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_CVSMAINVIEW_H #define KDEVPLATFORM_PLUGIN_CVSMAINVIEW_H #include #include #include #include "ui_cvsmainview.h" class CvsPlugin; class CvsGenericOutputView; /** * This class is the main output view of KDevelop's CVS plugin. * It only constists out of a QTabWidget. * * When created, a CvsGenericOutputView will be inserted. * * Inserting text into that default output view is possible via the * slotJobFinished() slot. * * Additional tabs can be added via slotAddTab(). * * @author Robert Gruber */ class CvsMainView : public QWidget, private Ui::CvsMainViewBase { Q_OBJECT public: CvsMainView(CvsPlugin *plugin, QWidget* parent); ~CvsMainView() override; -public slots: +public Q_SLOTS: /** * Inserts @p tag into the QTabWidget and calls it @p label . * This slot gets connected to CvsPlugin::addNewTabToMainView(). */ void slotAddTab(QWidget* tab, const QString& label); /** * When this slot gets called, the output of the job will be written to * the default outputview of the QTabWidget. * This slot gets connected to CvsPlugin::jobFinished(). */ void slotJobFinished(KJob* job); /** * Closes the current active tab (if it's not the first tab) */ void slotTabClose(); private: CvsPlugin* m_plugin; CvsGenericOutputView* m_mainview; QToolButton* m_closeButton; }; #endif diff --git a/plugins/cvs/cvsplugin.h b/plugins/cvs/cvsplugin.h index fa5efe6f9f..fdceb0ad9a 100644 --- a/plugins/cvs/cvsplugin.h +++ b/plugins/cvs/cvsplugin.h @@ -1,140 +1,140 @@ /*************************************************************************** * 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_CVSPLUGIN_H #define KDEVPLATFORM_PLUGIN_CVSPLUGIN_H #include #include #include #include #include #include class CvsProxy; namespace KDevelop { class ContextMenuExtension; } class CvsPluginPrivate; /** * This is the main class of KDevelop's CVS plugin. * * It implements the IVersionControl interface. * * @author Robert Gruber */ class CvsPlugin : public KDevelop::IPlugin, public KDevelop::ICentralizedVersionControl { Q_OBJECT Q_INTERFACES(KDevelop::IBasicVersionControl KDevelop::ICentralizedVersionControl) friend class CvsProxy; public: explicit CvsPlugin(QObject *parent, const QVariantList & args = QVariantList()); ~CvsPlugin() override; void unload() override; QString name() const override; KDevelop::VcsImportMetadataWidget* createImportMetadataWidget(QWidget* parent) override; // From KDevelop::IPlugin KDevelop::ContextMenuExtension contextMenuExtension(KDevelop::Context*) override; // Begin: KDevelop::IBasicVersionControl bool isValidRemoteRepositoryUrl(const QUrl& remoteLocation) override; bool isVersionControlled(const QUrl& localLocation) override; KDevelop::VcsJob* repositoryLocation(const QUrl& localLocation) override; KDevelop::VcsJob* add(const QList& localLocations, KDevelop::IBasicVersionControl::RecursionMode recursion) override; KDevelop::VcsJob* remove(const QList& localLocations) override; KDevelop::VcsJob* copy(const QUrl& localLocationSrc, const QUrl& localLocationDstn) override; KDevelop::VcsJob* move(const QUrl& localLocationSrc, const QUrl& localLocationDst) override; KDevelop::VcsJob* status(const QList& localLocations, KDevelop::IBasicVersionControl::RecursionMode recursion) override; KDevelop::VcsJob* revert(const QList& localLocations, KDevelop::IBasicVersionControl::RecursionMode recursion) override; KDevelop::VcsJob* update(const QList& localLocations, const KDevelop::VcsRevision& rev, KDevelop::IBasicVersionControl::RecursionMode recursion) override; KDevelop::VcsJob* commit(const QString& message, const QList& localLocations, KDevelop::IBasicVersionControl::RecursionMode recursion) override; KDevelop::VcsJob* diff(const QUrl& fileOrDirectory, const KDevelop::VcsRevision& srcRevision, const KDevelop::VcsRevision& dstRevision, KDevelop::VcsDiff::Type, KDevelop::IBasicVersionControl::RecursionMode = KDevelop::IBasicVersionControl::Recursive) override; KDevelop::VcsJob* log(const QUrl& localLocation, const KDevelop::VcsRevision& rev, unsigned long limit) override; KDevelop::VcsJob* log(const QUrl& localLocation, const KDevelop::VcsRevision& rev, const KDevelop::VcsRevision& limit) override; KDevelop::VcsJob* annotate(const QUrl& localLocation, const KDevelop::VcsRevision& rev) override; KDevelop::VcsJob* resolve(const QList& localLocations, KDevelop::IBasicVersionControl::RecursionMode recursion) override; KDevelop::VcsJob* createWorkingCopy(const KDevelop::VcsLocation & sourceRepository, const QUrl & destinationDirectory, KDevelop::IBasicVersionControl::RecursionMode recursion = KDevelop::IBasicVersionControl::Recursive) override; // End: KDevelop::IBasicVersionControl // Begin: KDevelop::ICentralizedVersionControl KDevelop::VcsJob* edit(const QUrl& localLocation) override; KDevelop::VcsJob* unedit(const QUrl& localLocation) override; KDevelop::VcsJob* localRevision(const QUrl& localLocation, KDevelop::VcsRevision::RevisionType) override; KDevelop::VcsJob* import(const QString& commitMessage, const QUrl& sourceDirectory, const KDevelop::VcsLocation& destinationRepository) override; // End: KDevelop::ICentralizedVersionControl CvsProxy* proxy(); const QUrl urlFocusedDocument() const; KDevelop::VcsLocationWidget* vcsLocation(QWidget* parent) const override; -public slots: +public Q_SLOTS: // slots for context menu void ctxEdit(); void ctxUnEdit(); void ctxEditors(); // slots for menu void slotImport(); void slotCheckout(); void slotStatus(); -signals: +Q_SIGNALS: /** * Some actions like commit, add, remove... will connect the job's * result() signal to this signal. Anybody, like for instance the * CvsMainView class, that is interested in getting notified about * jobs that finished can connect to this signal. * @see class CvsMainView */ void jobFinished(KJob* job); /** * Gets emmited when a job like log, editors... was created. * CvsPlugin will connect the newly created view to the result() signal * of a job. So the new view will show the output of that job as * soon as it has finished. */ void addNewTabToMainView(QWidget* tab, QString label); private: void setupActions(); QScopedPointer d; QString findWorkingDir(const QUrl& location); }; #endif diff --git a/plugins/cvs/editorsview.h b/plugins/cvs/editorsview.h index 5d3a1059f5..636208dceb 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=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: +private Q_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 ce1c044e2c..c2f9bb5244 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=nullptr); ~ImportDialog() override; -public slots: +public Q_SLOTS: void accept() override; void jobFinished(KJob* job); private: QUrl m_url; CvsPlugin* m_plugin; ImportMetadataWidget* m_widget; }; #endif diff --git a/plugins/cvs/tests/test_cvs.h b/plugins/cvs/tests/test_cvs.h index ab32080c9f..bcf64236cc 100644 --- a/plugins/cvs/tests/test_cvs.h +++ b/plugins/cvs/tests/test_cvs.h @@ -1,41 +1,41 @@ /*************************************************************************** * 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_TEST_CVS_H #define KDEVPLATFORM_PLUGIN_TEST_CVS_H #include class CvsProxy; class TestCvs: public QObject { Q_OBJECT private: void repoInit(); void importTestData(); void checkoutTestData(); -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void init(); void cleanup(); void testInitAndImport(); void testLogFolder(); private: CvsProxy* m_proxy; }; #endif diff --git a/plugins/documentswitcher/documentswitcherplugin.h b/plugins/documentswitcher/documentswitcherplugin.h index 8f5eb1a2c8..a5bbceb820 100644 --- a/plugins/documentswitcher/documentswitcherplugin.h +++ b/plugins/documentswitcher/documentswitcherplugin.h @@ -1,78 +1,78 @@ /*************************************************************************** * 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_DOCUMENTSWITCHERPLUGIN_H #define KDEVPLATFORM_PLUGIN_DOCUMENTSWITCHERPLUGIN_H #include #include #include Q_DECLARE_LOGGING_CATEGORY(PLUGIN_DOCUMENTSWITCHER) class QStandardItemModel; namespace Sublime { class View; class MainWindow; class Area; class MainWindow; } class DocumentSwitcherTreeView; class QModelIndex; class QAction; class DocumentSwitcherPlugin: public KDevelop::IPlugin { Q_OBJECT public: explicit DocumentSwitcherPlugin( QObject *parent, const QVariantList &args = QVariantList() ); ~DocumentSwitcherPlugin() override; void unload() override; -public slots: +public Q_SLOTS: void itemActivated( const QModelIndex& ); void switchToClicked(const QModelIndex& ); -private slots: +private Q_SLOTS: void addView( Sublime::View* ); void changeView( Sublime::View* ); void addMainWindow( Sublime::MainWindow* ); void changeArea( Sublime::Area* ); void removeView( Sublime::View* ); void removeMainWindow(QObject*); void walkForward(); void walkBackward(); protected: bool eventFilter( QObject*, QEvent* ) override; private: void setViewGeometry(Sublime::MainWindow* window); void storeAreaViewList( Sublime::MainWindow* mainwindow, Sublime::Area* area ); void enableActions(); void fillModel( Sublime::MainWindow* window ); void walk(const int from, const int to); // Need to use QObject here as we only have a QObject* in // the removeMainWindow method and cannot cast it to the mainwindow anymore QMap > > documentLists; DocumentSwitcherTreeView* view; QStandardItemModel* model; QAction* forwardAction; QAction* backwardAction; }; #endif diff --git a/plugins/documentview/kdevdocumentselection.h b/plugins/documentview/kdevdocumentselection.h index c734e776be..587cfb003c 100644 --- a/plugins/documentview/kdevdocumentselection.h +++ b/plugins/documentview/kdevdocumentselection.h @@ -1,40 +1,40 @@ /* 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_KDEVDOCUMENTSELECTION_H #define KDEVPLATFORM_PLUGIN_KDEVDOCUMENTSELECTION_H #include class KDevDocumentSelection: public QItemSelectionModel { Q_OBJECT public: explicit KDevDocumentSelection( QAbstractItemModel* model ); ~KDevDocumentSelection() override; -public slots: +public Q_SLOTS: void select( const QModelIndex & index, QItemSelectionModel::SelectionFlags command ) override; void select( const QItemSelection & selection, QItemSelectionModel::SelectionFlags command ) override; }; #endif // KDEVPLATFORM_PLUGIN_KDEVDOCUMENTSELECTION_H diff --git a/plugins/documentview/kdevdocumentview.h b/plugins/documentview/kdevdocumentview.h index 79e353d2e3..2de2754b50 100644 --- a/plugins/documentview/kdevdocumentview.h +++ b/plugins/documentview/kdevdocumentview.h @@ -1,100 +1,100 @@ /* 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_KDEVDOCUMENTVIEW_H #define KDEVPLATFORM_PLUGIN_KDEVDOCUMENTVIEW_H #include #include class QSortFilterProxyModel; class QAction; class KDevDocumentViewPlugin; class KDevDocumentModel; class KDevDocumentViewDelegate; class KDevDocumentSelection; class KDevFileItem; namespace KDevelop { class IDocument; class IProject; } class KDevCategoryItem; class KDevDocumentModel; class KDevDocumentItem; class KDevDocumentView: public QTreeView { Q_OBJECT public: explicit KDevDocumentView( KDevDocumentViewPlugin *plugin, QWidget *parent ); ~KDevDocumentView() override; KDevDocumentViewPlugin *plugin() const; -signals: +Q_SIGNALS: void activateURL( const QUrl &url ); -public slots: +public Q_SLOTS: void opened( KDevelop::IDocument* document ); -private slots: +private Q_SLOTS: void activated( KDevelop::IDocument* document ); void saved( KDevelop::IDocument* document ); void closed( KDevelop::IDocument* document ); void contentChanged( KDevelop::IDocument* document ); void stateChanged( KDevelop::IDocument* document ); void documentUrlChanged( KDevelop::IDocument* document ); void updateCategoryItem( KDevCategoryItem *item ); void updateProjectPaths(); void saveSelected(); void reloadSelected(); void closeSelected(); void closeUnselected(); protected: void mousePressEvent( QMouseEvent * event ) override; void contextMenuEvent( QContextMenuEvent * event ) override; void drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const override; private: template void visitItems(F, bool selectedItems); bool selectedDocHasChanges(); void updateSelectedDocs(); void appendActions(QMenu* menu, const QList< QAction* >& actions); private: KDevDocumentViewPlugin *m_plugin; KDevDocumentModel *m_documentModel; KDevDocumentSelection* m_selectionModel; QSortFilterProxyModel* m_proxy; KDevDocumentViewDelegate* m_delegate; QHash< KDevelop::IDocument*, KDevFileItem* > m_doc2index; QList m_selectedDocs; // used for ctx menu QList m_unselectedDocs; // used for ctx menu friend class KDevDocumentViewPluginFactory; // to connect to the private slots stateChanged and documentUrlChanged }; #endif // KDEVPLATFORM_PLUGIN_KDEVDOCUMENTVIEW_H diff --git a/plugins/documentview/settings/preferences.h b/plugins/documentview/settings/preferences.h index 1a64dc2682..304126cb43 100644 --- a/plugins/documentview/settings/preferences.h +++ b/plugins/documentview/settings/preferences.h @@ -1,50 +1,50 @@ /* Document View Settings * * Copyright 2006 Matt Rogers * * 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_PREFERENCES_H #define KDEVPLATFORM_PLUGIN_PREFERENCES_H #include namespace Ui { class SettingsWidget; } class Preferences : public KDevelop::ConfigModule { Q_OBJECT public: Preferences( QWidget *parent, const QStringList &args ); virtual ~Preferences(); virtual void save(); virtual void load(); virtual void defaults(); -private slots: +private Q_SLOTS: void slotSettingsChanged(); private: Ui::SettingsWidget *preferencesDialog; }; #endif diff --git a/plugins/execute/nativeappconfig.h b/plugins/execute/nativeappconfig.h index 7b4a9527e7..7542f5fa85 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 = nullptr ) override; void saveToConfiguration( KConfigGroup cfg, KDevelop::IProject* project = nullptr ) const override; QString title() const override; QIcon icon() const override; -private slots: +private Q_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 information, 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: +public Q_SLOTS: void suggestionTriggered(); }; #endif diff --git a/plugins/executescript/scriptappjob.h b/plugins/executescript/scriptappjob.h index 08d7d38722..b470eb4fb0 100644 --- a/plugins/executescript/scriptappjob.h +++ b/plugins/executescript/scriptappjob.h @@ -1,55 +1,55 @@ /* 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_SCRIPTAPPJOB_H #define KDEVPLATFORM_PLUGIN_SCRIPTAPPJOB_H #include #include class ExecuteScriptPlugin; namespace KDevelop { class ILaunchConfiguration; class ProcessLineMaker; class OutputModel; } class KProcess; class ScriptAppJob : public KDevelop::OutputJob { Q_OBJECT public: ScriptAppJob( ExecuteScriptPlugin* parent, KDevelop::ILaunchConfiguration* cfg ); void start() override; bool doKill() override; KDevelop::OutputModel* model(); -private slots: +private Q_SLOTS: void processError(QProcess::ProcessError); void processFinished(int,QProcess::ExitStatus); private: void appendLine(const QString &l); KProcess* proc; KDevelop::ProcessLineMaker* lineMaker; }; #endif diff --git a/plugins/externalscript/editexternalscript.h b/plugins/externalscript/editexternalscript.h index 4c6e5c1cf7..072a15712e 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 = nullptr); ~EditExternalScript() override; -private slots: +private Q_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/externalscriptjob.h b/plugins/externalscript/externalscriptjob.h index 6a1fee65b5..6ac47fcc40 100644 --- a/plugins/externalscript/externalscriptjob.h +++ b/plugins/externalscript/externalscriptjob.h @@ -1,87 +1,87 @@ /* This file is part of KDevelop Copyright 2009 Andreas Pakulat 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_PLUGIN_EXTERNALSCRIPTJOB_H #define KDEVPLATFORM_PLUGIN_EXTERNALSCRIPTJOB_H #include #include #include "externalscriptitem.h" #include #include namespace KDevelop { class ProcessLineMaker; class OutputModel; class Document; } namespace KTextEditor { class Document; } class KProcess; class ExternalScriptPlugin; class ExternalScriptJob : public KDevelop::OutputJob { Q_OBJECT public: ExternalScriptJob( ExternalScriptItem* item, const QUrl &url, ExternalScriptPlugin* parent ); void start() override; KDevelop::OutputModel* model(); protected: bool doKill() override; -private slots: +private Q_SLOTS: void processError( QProcess::ProcessError ); void processFinished( int, QProcess::ExitStatus ); void receivedStdoutLines(const QStringList& lines); void receivedStderrLines(const QStringList& lines); private: void appendLine( const QString &l ); KProcess* m_proc; KDevelop::ProcessLineMaker* m_lineMaker; ExternalScriptItem::OutputMode m_outputMode; ExternalScriptItem::InputMode m_inputMode; ExternalScriptItem::ErrorMode m_errorMode; int m_filterMode; KTextEditor::Document* m_document; QUrl m_url; /// invalid when whole doc should be replaced KTextEditor::Range m_selectionRange; KTextEditor::Cursor m_cursorPosition; bool m_showOutput; QStringList m_stdout; QStringList m_stderr; }; #endif // KDEVPLATFORM_PLUGIN_EXTERNALSCRIPTJOB_H // kate: indent-mode cstyle; space-indent on; indent-width 2; replace-tabs on; diff --git a/plugins/externalscript/externalscriptplugin.h b/plugins/externalscript/externalscriptplugin.h index de8b00678d..7b64eb5534 100644 --- a/plugins/externalscript/externalscriptplugin.h +++ b/plugins/externalscript/externalscriptplugin.h @@ -1,104 +1,104 @@ /* 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_EXTERNALSCRIPTPLUGIN_H #define KDEVPLATFORM_PLUGIN_EXTERNALSCRIPTPLUGIN_H #include #include #include #include class ExternalScriptItem; class QStandardItem; class QStandardItemModel; class QModelIndex; class ExternalScriptPlugin : public KDevelop::IPlugin { Q_OBJECT Q_CLASSINFO( "D-Bus Interface", "org.kdevelop.ExternalScriptPlugin" ) public: explicit ExternalScriptPlugin( QObject *parent, const QVariantList &args = QVariantList() ); ~ExternalScriptPlugin() override; void unload() override; KDevelop::ContextMenuExtension contextMenuExtension(KDevelop::Context* context) override; static ExternalScriptPlugin* self(); /** * @return The model storing all external scripts managed by this plugin. * @NOTE: always append() items, never insert in the middle! */ QStandardItemModel* model() const; /** * Executes @p script. */ void execute(ExternalScriptItem* item, const QUrl &url) const; /** * Executes @p script. */ void execute(ExternalScriptItem* item) const; /** * Returns config group to store all settings for this plugin in. */ KConfigGroup getConfig() const; void saveItem(const ExternalScriptItem* item); -public slots: +public Q_SLOTS: void executeScriptFromActionData() const; /** * Executes the command (Used by the shell-integration) * */ Q_SCRIPTABLE bool executeCommand(QString command, QString workingDirectory) const; /** * Executes the command synchronously and returns the output text (Used by the shell-integration) * */ Q_SCRIPTABLE QString executeCommandSync(QString command, QString workingDirectory) const; -private slots: +private Q_SLOTS: void rowsRemoved( const QModelIndex& parent, int start, int end ); void rowsInserted( const QModelIndex& parent, int start, int end ); void executeScriptFromContextMenu() const; private: /// @param row row in the model for the item to save void saveItemForRow( int row ); QStandardItemModel* m_model; QList m_urls; static ExternalScriptPlugin* m_self; class ExternalScriptViewFactory *m_factory; }; #endif // KDEVPLATFORM_PLUGIN_EXTERNALSCRIPTPLUGIN_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 db23d771d9..8318f5c5cc 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 = nullptr ); ~ExternalScriptView() override; /// @return Currently selected script item. ExternalScriptItem* currentItem() const; /// @return Item for @p index. ExternalScriptItem* itemForIndex(const QModelIndex& index) const; -private slots: +private Q_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/filemanager.h b/plugins/filemanager/filemanager.h index dd2d68a97b..434e2e0ba4 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() override; QList toolBarActions() const; KActionCollection* actionCollection() const; KDirOperator* dirOperator() const; KDevFileManagerPlugin* plugin() const; -private slots: +private Q_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/filemanager/kdevfilemanagerplugin.h b/plugins/filemanager/kdevfilemanagerplugin.h index f88384e2a7..2eb7badfd4 100644 --- a/plugins/filemanager/kdevfilemanagerplugin.h +++ b/plugins/filemanager/kdevfilemanagerplugin.h @@ -1,43 +1,43 @@ /*************************************************************************** * Copyright 2006 Alexander Dymo * * * * 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_KDEVFILEMANAGERPLUGIN_H #define KDEVPLATFORM_PLUGIN_KDEVFILEMANAGERPLUGIN_H #include #include class FileManager; class KDevFileManagerPlugin: public KDevelop::IPlugin { Q_OBJECT public: explicit KDevFileManagerPlugin(QObject *parent, const QVariantList &args = QVariantList() ); ~KDevFileManagerPlugin() override; void unload() override; -private slots: +private Q_SLOTS: void init(); private: class KDevFileManagerViewFactory *m_factory; }; #endif diff --git a/plugins/filetemplates/filetemplatesplugin.h b/plugins/filetemplates/filetemplatesplugin.h index 702cb33355..a9c011d830 100644 --- a/plugins/filetemplates/filetemplatesplugin.h +++ b/plugins/filetemplates/filetemplatesplugin.h @@ -1,55 +1,55 @@ #ifndef KDEVPLATFORM_PLUGIN_FILETEMPLATESPLUGIN_H #define KDEVPLATFORM_PLUGIN_FILETEMPLATESPLUGIN_H #include #include #include class QUrl; namespace KDevelop { class TemplatesModel; class IToolViewFactory; } class FileTemplatesPlugin : public KDevelop::IPlugin, public KDevelop::ITemplateProvider { Q_OBJECT Q_INTERFACES(KDevelop::ITemplateProvider) public: enum TemplateType { NoTemplate, FileTemplate, ProjectTemplate }; FileTemplatesPlugin(QObject* parent, const QVariantList& args); ~FileTemplatesPlugin() override; void unload() override; KDevelop::ContextMenuExtension contextMenuExtension (KDevelop::Context* context) override; QString name() const override; QIcon icon() const override; QAbstractItemModel* templatesModel() override; QString knsConfigurationFile() const override; QStringList supportedMimeTypes() const override; void reload() override; void loadTemplate(const QString& fileName) override; TemplateType determineTemplateType(const QUrl& url); private: KDevelop::TemplatesModel* m_model; KDevelop::IToolViewFactory* m_toolView; -public slots: +public Q_SLOTS: void createFromTemplate(); void previewTemplate(); }; #endif // KDEVPLATFORM_PLUGIN_FILETEMPLATESPLUGIN_H diff --git a/plugins/filetemplates/templatepreviewtoolview.h b/plugins/filetemplates/templatepreviewtoolview.h index 6eaf3b5013..ec1d3ddf2b 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); ~TemplatePreviewToolView() override; private: Ui::TemplatePreviewToolView* ui; KTextEditor::Document* m_original; FileTemplatesPlugin* m_plugin; KDevelop::TemplateRenderer::EmptyLinesPolicy m_policy; -private slots: +private Q_SLOTS: void sourceTextChanged(const QString& text); protected: void showEvent(QShowEvent*) override; -public slots: +public Q_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/tests/data/testgenerationtest/templates/test_qtestlib/class.h b/plugins/filetemplates/tests/data/testgenerationtest/templates/test_qtestlib/class.h index 92e0dc3527..a2904ff556 100644 --- a/plugins/filetemplates/tests/data/testgenerationtest/templates/test_qtestlib/class.h +++ b/plugins/filetemplates/tests/data/testgenerationtest/templates/test_qtestlib/class.h @@ -1,33 +1,33 @@ {% load kdev_filters %} /* {{ license|lines_prepend:" * " }} */ #ifndef {{ name|upper }}_H #define {{ name|upper }}_H #include class {{ name }} : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void init(); void cleanup(); {% for case in testCases %} void {{ case }}(); {% endfor %} }; #endif // {{ name|upper }}_H \ No newline at end of file diff --git a/plugins/filetemplates/tests/expected/testname.h b/plugins/filetemplates/tests/expected/testname.h index 066b4a6bb6..eb702ced42 100644 --- a/plugins/filetemplates/tests/expected/testname.h +++ b/plugins/filetemplates/tests/expected/testname.h @@ -1,26 +1,26 @@ /* * Test license header * In two lines */ #ifndef TESTNAME_H #define TESTNAME_H #include class TestName : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void init(); void cleanup(); void firstTestCase(); void secondTestCase(); void thirdTestCase(); }; #endif // TESTNAME_H diff --git a/plugins/filetemplates/tests/test_generationtest.h b/plugins/filetemplates/tests/test_generationtest.h index 849dd02d8b..c34db56a17 100644 --- a/plugins/filetemplates/tests/test_generationtest.h +++ b/plugins/filetemplates/tests/test_generationtest.h @@ -1,38 +1,38 @@ /* * */ #ifndef KDEVPLATFORM_PLUGIN_TEST_GENERATIONTEST_H #define KDEVPLATFORM_PLUGIN_TEST_GENERATIONTEST_H #include #include #include namespace KDevelop { class TemplateRenderer; class SourceFileTemplate; } class TestGenerationTest : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void init(); void yamlTemplate(); void cppTemplate(); private: KDevelop::TemplateRenderer* renderer; QScopedPointer dir; QUrl baseUrl; QHash urls(const KDevelop::SourceFileTemplate& file); }; #endif // KDEVPLATFORM_PLUGIN_TEST_GENERATIONTEST_H diff --git a/plugins/genericprojectmanager/test/test_projectload.h b/plugins/genericprojectmanager/test/test_projectload.h index 73c1e91bfb..056952f955 100644 --- a/plugins/genericprojectmanager/test/test_projectload.h +++ b/plugins/genericprojectmanager/test/test_projectload.h @@ -1,49 +1,49 @@ /* This file is part of KDevelop Copyright 2010 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_PROJECTLOADTEST_H #define KDEVPLATFORM_PLUGIN_PROJECTLOADTEST_H #include namespace KDevelop { class TestCore; } class TestProjectLoad : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void init(); void addRemoveFiles(); void removeDirRecursive(); void addLotsOfFiles(); void addMultipleJobs(); void raceJob(); void addDuringImport(); }; #endif diff --git a/plugins/git/gitclonejob.h b/plugins/git/gitclonejob.h index 51886e8b65..70e66ad1e4 100644 --- a/plugins/git/gitclonejob.h +++ b/plugins/git/gitclonejob.h @@ -1,39 +1,39 @@ /*************************************************************************** * 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_PLUGIN_GITCLONEJOB_H #define KDEVPLATFORM_PLUGIN_GITCLONEJOB_H #include class GitCloneJob : public KDevelop::DVcsJob { Q_OBJECT public: GitCloneJob(const QDir& d, KDevelop::IPlugin* parent, KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose); - public slots: + public Q_SLOTS: void processResult(); private: uint m_steps; }; #endif // KDEVPLATFORM_PLUGIN_GITCLONEJOB_H diff --git a/plugins/git/gitnameemaildialog.h b/plugins/git/gitnameemaildialog.h index 1e9e332c60..56e3b3f487 100644 --- a/plugins/git/gitnameemaildialog.h +++ b/plugins/git/gitnameemaildialog.h @@ -1,50 +1,50 @@ /************************************************************************** * Copyright 2016 Artur Puzio * * Copyright 2016 Kevin Funk * * * * 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_GIT_NAMEEMAILDIALOG_H #define KDEVPLATFORM_PLUGIN_GIT_NAMEEMAILDIALOG_H #include namespace Ui { class GitNameEmailDialog; } class GitNameEmailDialog : public QDialog { Q_OBJECT public: explicit GitNameEmailDialog(QWidget *parent = nullptr); ~GitNameEmailDialog() override; QString name() const; void setName(const QString& name); QString email() const; void setEmail(const QString& email); bool isGlobal() const; -private slots: +private Q_SLOTS: void updateUi(); private: QScopedPointer ui; }; #endif //KDEVPLATFORM_PLUGIN_GIT_NAMEEMAILDIALOG_H diff --git a/plugins/git/gitplugin.h b/plugins/git/gitplugin.h index f5b73466cf..741c5c07f7 100644 --- a/plugins/git/gitplugin.h +++ b/plugins/git/gitplugin.h @@ -1,223 +1,223 @@ /*************************************************************************** * Copyright 2008 Evgeniy Ivanov * * Copyright 2009 Hugo Parente Lima * * * * 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_GIT_PLUGIN_H #define KDEVPLATFORM_PLUGIN_GIT_PLUGIN_H #include #include #include #include #include #include class KDirWatch; class QDir; namespace KDevelop { class VcsJob; class VcsRevision; } class StandardJob : public KDevelop::VcsJob { Q_OBJECT public: StandardJob(KDevelop::IPlugin* parent, KJob* job, OutputJobVerbosity verbosity); QVariant fetchResults() override { return QVariant(); } void start() override; JobStatus status() const override { return m_status; } KDevelop::IPlugin* vcsPlugin() const override { return m_plugin; } - public slots: + public Q_SLOTS: void result(KJob*); private: KJob* m_job; KDevelop::IPlugin* m_plugin; JobStatus m_status; }; /** * This is the main class of KDevelop's Git plugin. * * It implements the DVCS dependent things not implemented in KDevelop::DistributedVersionControlPlugin * @author Evgeniy Ivanov */ class GitPlugin: public KDevelop::DistributedVersionControlPlugin, public KDevelop::IContentAwareVersionControl { Q_OBJECT Q_INTERFACES(KDevelop::IBasicVersionControl KDevelop::IDistributedVersionControl KDevelop::IContentAwareVersionControl) friend class GitInitTest; public: explicit GitPlugin(QObject *parent, const QVariantList & args = QVariantList() ); ~GitPlugin() override; QString name() const override; bool isValidRemoteRepositoryUrl(const QUrl& remoteLocation) override; bool isVersionControlled(const QUrl &path) override; KDevelop::VcsJob* copy(const QUrl& localLocationSrc, const QUrl& localLocationDstn) override; KDevelop::VcsJob* move(const QUrl& localLocationSrc, const QUrl& localLocationDst) override; //TODO KDevelop::VcsJob* pull(const KDevelop::VcsLocation& localOrRepoLocationSrc, const QUrl& localRepositoryLocation) override; KDevelop::VcsJob* push(const QUrl& localRepositoryLocation, const KDevelop::VcsLocation& localOrRepoLocationDst) override; KDevelop::VcsJob* repositoryLocation(const QUrl& localLocation) override; KDevelop::VcsJob* resolve(const QList& localLocations, RecursionMode recursion) override; KDevelop::VcsJob* update(const QList& localLocations, const KDevelop::VcsRevision& rev, RecursionMode recursion) override; KDevelop::VcsLocationWidget* vcsLocation(QWidget* parent) const override; void setupCommitMessageEditor(const QUrl& localLocation, KTextEdit* editor) const override; //End of KDevelop::VcsJob* add(const QList& localLocations, KDevelop::IBasicVersionControl::RecursionMode recursion = KDevelop::IBasicVersionControl::Recursive) override; KDevelop::VcsJob* createWorkingCopy(const KDevelop::VcsLocation & localOrRepoLocationSrc, const QUrl& localRepositoryRoot, KDevelop::IBasicVersionControl::RecursionMode) override; KDevelop::VcsJob* remove(const QList& files) override; KDevelop::VcsJob* status(const QList& localLocations, KDevelop::IBasicVersionControl::RecursionMode recursion = KDevelop::IBasicVersionControl::Recursive) override; KDevelop::VcsJob* commit(const QString& message, const QList& localLocations, KDevelop::IBasicVersionControl::RecursionMode recursion = KDevelop::IBasicVersionControl::Recursive) override; KDevelop::VcsJob* diff(const QUrl& fileOrDirectory, const KDevelop::VcsRevision& srcRevision, const KDevelop::VcsRevision& dstRevision, KDevelop::VcsDiff::Type, RecursionMode recursion) override; KDevelop::VcsJob* log( const QUrl& localLocation, const KDevelop::VcsRevision& rev, unsigned long limit) override; KDevelop::VcsJob* log(const QUrl& localLocation, const KDevelop::VcsRevision& rev, const KDevelop::VcsRevision& limit) override; KDevelop::VcsJob* annotate(const QUrl &localLocation, const KDevelop::VcsRevision &rev) override; KDevelop::VcsJob* revert(const QList& localLocations, RecursionMode recursion) override; // Begin: KDevelop::IDistributedVersionControl KDevelop::VcsJob* init(const QUrl & directory) override; // Branch management KDevelop::VcsJob* tag(const QUrl& repository, const QString& commitMessage, const KDevelop::VcsRevision& rev, const QString& tagName) override; KDevelop::VcsJob* branch(const QUrl& repository, const KDevelop::VcsRevision& rev, const QString& branchName) override; KDevelop::VcsJob* branches(const QUrl& repository) override; KDevelop::VcsJob* currentBranch(const QUrl& repository) override; KDevelop::VcsJob* deleteBranch(const QUrl& repository, const QString& branchName) override; KDevelop::VcsJob* switchBranch(const QUrl& repository, const QString& branchName) override; KDevelop::VcsJob* renameBranch(const QUrl& repository, const QString& oldBranchName, const QString& newBranchName) override; KDevelop::VcsJob* mergeBranch(const QUrl& repository, const QString& branchName) override; //graph helpers QList getAllCommits(const QString &repo) override; //used in log void parseLogOutput(const KDevelop::DVcsJob * job, QList& commits) const override; void additionalMenuEntries(QMenu* menu, const QList& urls) override; KDevelop::DVcsJob* gitStash(const QDir& repository, const QStringList& args, KDevelop::OutputJob::OutputJobVerbosity verbosity); bool hasStashes(const QDir& repository); bool hasModifications(const QDir& repository); bool hasModifications(const QDir& repo, const QUrl& file); void registerRepositoryForCurrentBranchChanges(const QUrl& repository) override; KDevelop::CheckInRepositoryJob* isInRepository(KTextEditor::Document* document) override; KDevelop::DVcsJob* setConfigOption(const QUrl& repository, const QString& key, const QString& value, bool global = false); QString readConfigOption(const QUrl& repository, const QString& key); // this indicates whether the diff() function will generate a diff (patch) which // includes the working copy directory name or not (in which case git diff is called // with --no-prefix). bool usePrefix() const { return m_usePrefix; } void setUsePrefix(bool p) { m_usePrefix = p; } protected: QUrl repositoryRoot(const QUrl& path); bool isValidDirectory(const QUrl &dirPath) override; KDevelop::DVcsJob* lsFiles(const QDir &repository, const QStringList &args, KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose); KDevelop::DVcsJob* gitRevList(const QString &directory, const QStringList &args); KDevelop::DVcsJob* gitRevParse(const QString &repository, const QStringList &args, KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Silent); -private slots: +private Q_SLOTS: void parseGitBlameOutput(KDevelop::DVcsJob *job); void parseGitLogOutput(KDevelop::DVcsJob *job); void parseGitDiffOutput(KDevelop::DVcsJob* job); void parseGitRepoLocationOutput(KDevelop::DVcsJob* job); void parseGitStatusOutput(KDevelop::DVcsJob* job); void parseGitStatusOutput_old(KDevelop::DVcsJob* job); void parseGitVersionOutput(KDevelop::DVcsJob* job); void parseGitBranchOutput(KDevelop::DVcsJob* job); void parseGitCurrentBranch(KDevelop::DVcsJob* job); void ctxPushStash(); void ctxPopStash(); void ctxStashManager(); void fileChanged(const QString& file); void delayedBranchChanged(); -signals: +Q_SIGNALS: void repositoryBranchChanged(const QUrl& repository); private: bool ensureValidGitIdentity(const QDir& dir); void addNotVersionedFiles(const QDir& dir, const QList& files); //commit dialog "main" helper QStringList getLsFiles(const QDir &directory, const QStringList &args, KDevelop::OutputJob::OutputJobVerbosity verbosity); KDevelop::DVcsJob* errorsFound(const QString& error, KDevelop::OutputJob::OutputJobVerbosity verbosity); void initBranchHash(const QString &repo); static KDevelop::VcsStatusInfo::State messageToState(const QStringRef& ch); QList branchesShas; QList m_urls; /** Tells if it's older than 1.7.0 or not */ bool m_oldVersion; KDirWatch* m_watcher; QList m_branchesChange; bool m_usePrefix; }; QVariant runSynchronously(KDevelop::VcsJob* job); #endif diff --git a/plugins/git/gitplugincheckinrepositoryjob.h b/plugins/git/gitplugincheckinrepositoryjob.h index b5f8f11d60..8af462a737 100644 --- a/plugins/git/gitplugincheckinrepositoryjob.h +++ b/plugins/git/gitplugincheckinrepositoryjob.h @@ -1,45 +1,45 @@ /*************************************************************************** * Copyright 2014 Sven Brauch * * * * 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 GITPLUGINCHECKINREPOSITORYJOB_H #define GITPLUGINCHECKINREPOSITORYJOB_H #include #include class GitPluginCheckInRepositoryJob : public KDevelop::CheckInRepositoryJob { Q_OBJECT public: GitPluginCheckInRepositoryJob(KTextEditor::Document* document, const QString& rootDirectory); ~GitPluginCheckInRepositoryJob() override; void start() override; -private slots: +private Q_SLOTS: void repositoryQueryFinished(int); void processFailed(QProcess::ProcessError); private: QProcess* m_hashjob; QProcess* m_findjob; QString m_rootDirectory; }; #endif // GITPLUGINCHECKINREPOSITORYJOB_H diff --git a/plugins/git/stashmanagerdialog.h b/plugins/git/stashmanagerdialog.h index 3997af9530..7f94457c46 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: + public Q_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 = nullptr); - private slots: + private Q_SLOTS: void stashListReady(KJob*); }; #endif // KDEVPLATFORM_PLUGIN_STASHMANAGERDIALOG_H diff --git a/plugins/git/stashpatchsource.h b/plugins/git/stashpatchsource.h index 5e8ac87650..797023aeb9 100644 --- a/plugins/git/stashpatchsource.h +++ b/plugins/git/stashpatchsource.h @@ -1,60 +1,60 @@ /* * * Copyright (C) 2013 David E. Narvaez * * 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 STASHPATCHSOURCE_H #define STASHPATCHSOURCE_H #include #include namespace KDevelop { class VcsJob; } class GitPlugin; class StashPatchSource : public KDevelop::IPatchSource { Q_OBJECT public: StashPatchSource(const QString & stashName, GitPlugin * patch, const QDir & baseDir); ~StashPatchSource() override; QUrl baseDir() const override; QUrl file() const override; void update() override; bool isAlreadyApplied() const override; QString name() const override; bool canSelectFiles() const override { return true; }; uint depth() const override { return 1; } -private slots: +private Q_SLOTS: void updatePatchFile(KDevelop::VcsJob* job); private: QString m_stashName; GitPlugin * m_plugin; QDir m_baseDir; QUrl m_patchFile; }; #endif // STASHPATCHSOURCE_H diff --git a/plugins/git/tests/test_git.h b/plugins/git/tests/test_git.h index d154e54ca8..a4a9fc50d9 100644 --- a/plugins/git/tests/test_git.h +++ b/plugins/git/tests/test_git.h @@ -1,72 +1,72 @@ /*************************************************************************** * This file was partly taken from KDevelop's cvs plugin * * Copyright 2007 Robert Gruber * * * * Adapted for Git * * 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_PLUGIN_GIT_INIT_H #define KDEVPLATFORM_PLUGIN_GIT_INIT_H #include class GitPlugin; namespace KDevelop { class TestCore; } class GitInitTest: public QObject { Q_OBJECT private: void repoInit(); void addFiles(); void commitFiles(); -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void init(); void cleanup(); void testInit(); void testReadAndSetConfigOption(); void testAdd(); void testCommit(); void testBranching(); void testBranch(const QString &branchName); void testMerge(); void revHistory(); void testAnnotation(); void testRemoveEmptyFolder(); void testRemoveEmptyFolderInFolder(); void testRemoveUnindexedFile(); void testRemoveFolderContainingUnversionedFiles(); void testDiff(); private: GitPlugin* m_plugin; void removeTempDirs(); }; #endif diff --git a/plugins/grepview/grepoutputmodel.h b/plugins/grepview/grepoutputmodel.h index 2862966f4a..1e7b851365 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 = 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: +private Q_SLOTS: void updateCheckState(QStandardItem*); }; #endif diff --git a/plugins/grepview/grepoutputview.h b/plugins/grepview/grepoutputview.h index 08309d3aa3..a73aae94fe 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 GrepOutputViewFactory: public KDevelop::IToolViewFactory { public: explicit GrepOutputViewFactory(GrepViewPlugin* plugin); 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: +private Q_SLOTS: void selectPreviousItem() override; void selectNextItem() override; void collapseAllItems(); void expandAllItems(); void onApply(); void showDialog(); void refresh(); 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/grepview/tests/test_findreplace.h b/plugins/grepview/tests/test_findreplace.h index a78c221358..b07fe047c7 100644 --- a/plugins/grepview/tests/test_findreplace.h +++ b/plugins/grepview/tests/test_findreplace.h @@ -1,61 +1,61 @@ /*************************************************************************** * Copyright 1999-2001 Bernd Gehrmann and the KDevelop Team * * bernd@kdevelop.org * * 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_REPLACETEST_H #define KDEVPLATFORM_PLUGIN_REPLACETEST_H #include #include #include #include namespace KDevelop { class TestCore; } class GrepViewPlugin; class FindReplaceTest : public QObject { Q_OBJECT public: struct Match { Match() {} Match(int l,int s,int e) : line(l), start(s), end(e) {} int line; int start; int end; }; typedef QList MatchList; typedef QPair File; /// Represent a file with name => content typedef QList FileList; private: GrepViewPlugin* m_plugin; -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void testFind(); void testFind_data(); void testReplace(); void testReplace_data(); }; Q_DECLARE_METATYPE(FindReplaceTest::MatchList) Q_DECLARE_METATYPE(FindReplaceTest::FileList) #endif // KDEVPLATFORM_PLUGIN_REPLACETEST_H diff --git a/plugins/konsole/kdevkonsoleview.h b/plugins/konsole/kdevkonsoleview.h index 075fd89181..aa9ba2a0b0 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 = nullptr ); ~KDevKonsoleView() override; -public slots: +public Q_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/openwith/openwithplugin.h b/plugins/openwith/openwithplugin.h index c0242adf84..e6e6456687 100644 --- a/plugins/openwith/openwithplugin.h +++ b/plugins/openwith/openwithplugin.h @@ -1,64 +1,64 @@ /* * This file is part of KDevelop * Copyright 2009 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 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_OPENWITHPLUGIN_H #define KDEVPLATFORM_PLUGIN_OPENWITHPLUGIN_H #include #include #include #include "iopenwith.h" class QSignalMapper; namespace KDevelop { class ContextMenuExtension; class Context; } class OpenWithPlugin : public KDevelop::IPlugin, public KDevelop::IOpenWith { Q_OBJECT Q_INTERFACES( KDevelop::IOpenWith ) public: OpenWithPlugin( QObject* parent, const QVariantList& args ); ~OpenWithPlugin() override; KDevelop::ContextMenuExtension contextMenuExtension ( KDevelop::Context* context ) override; protected: void openFilesInternal( const QList& files ) override; -private slots: +private Q_SLOTS: void open( const QString& storageId ); void openService( const KService::Ptr& service ); void openDefault(); private: QList actionsForServiceType( const QString& serviceType ); QScopedPointer m_actionMap; QList m_urls; QString m_mimeType; KService::List m_services; }; #endif // KDEVPLATFORM_PLUGIN_OPENWITHPLUGIN_H diff --git a/plugins/outlineview/outlinemodel.h b/plugins/outlineview/outlinemodel.h index b935048638..5e76f6cb2c 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 = 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: +public Q_SLOTS: void activate(const QModelIndex& realIndex); -private slots: +private Q_SLOTS: void rebuildOutline(KDevelop::IDocument* doc); private: std::unique_ptr m_rootNode; KDevelop::IDocument* m_lastDoc; KDevelop::IndexedString m_lastUrl; }; diff --git a/plugins/outlineview/outlinewidget.h b/plugins/outlineview/outlinewidget.h index 07da95e141..35a2ac5e06 100644 --- a/plugins/outlineview/outlinewidget.h +++ b/plugins/outlineview/outlinewidget.h @@ -1,52 +1,52 @@ /* * 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 class KRecursiveFilterProxyModel; class QModelIndex; class QAction; class QTreeView; class QLineEdit; class OutlineModel; class OutlineViewPlugin; class OutlineWidget : public QWidget { Q_OBJECT public: OutlineWidget(QWidget* parent, OutlineViewPlugin* plugin); ~OutlineWidget() override; private: OutlineViewPlugin* m_plugin; OutlineModel* m_model; QTreeView* m_tree; KRecursiveFilterProxyModel* m_proxy; QLineEdit* m_filter; QAction* m_sortAlphabeticallyAction; Q_DISABLE_COPY(OutlineWidget) -public slots: +public Q_SLOTS: void activated(const QModelIndex& index); void expandFirstLevel(); }; diff --git a/plugins/patchreview/CMakeLists.txt b/plugins/patchreview/CMakeLists.txt index a35d0a536a..7d00e5cee3 100644 --- a/plugins/patchreview/CMakeLists.txt +++ b/plugins/patchreview/CMakeLists.txt @@ -1,29 +1,35 @@ find_package(LibKompareDiff2 5.0 REQUIRED) find_package(KDEExperimentalPurpose QUIET) set_package_properties(KDEExperimentalPurpose PROPERTIES DESCRIPTION "EXPERIMENTAL. Support for patch sharing" URL "https://projects.kde.org/projects/playground/libs/purpose" TYPE OPTIONAL ) add_definitions(-DTRANSLATION_DOMAIN=\"kdevpatchreview\") kde_enable_exceptions() include_directories(${LIBKOMPAREDIFF2_INCLUDE_DIR}) +if(LibKompareDiff2_VERSION VERSION_LESS 5.1) + remove_definitions( + -DQT_NO_SIGNALS_SLOTS_KEYWORDS + ) +endif() + set(patchreview_PART_SRCS patchreview.cpp patchhighlighter.cpp patchreviewtoolview.cpp localpatchsource.cpp ) ki18n_wrap_ui(patchreview_PART_SRCS patchreview.ui localpatchwidget.ui) qt5_add_resources(patchreview_PART_SRCS kdevpatchreview.qrc) kdevplatform_add_plugin(kdevpatchreview JSON kdevpatchreview.json SOURCES ${patchreview_PART_SRCS}) target_link_libraries(kdevpatchreview KDev::Project KF5::IconThemes KF5::TextEditor KF5::Parts KDev::Interfaces KDev::Util KDev::Language KDev::Vcs KDev::Sublime ${LIBKOMPAREDIFF2_LIBRARIES}) if (KDEExperimentalPurpose_FOUND) target_compile_definitions(kdevpatchreview PRIVATE WITH_PURPOSE) target_link_libraries(kdevpatchreview KDEExperimental::PurposeWidgets) endif() diff --git a/plugins/patchreview/localpatchsource.h b/plugins/patchreview/localpatchsource.h index e0f7958cb7..74b07a6491 100644 --- a/plugins/patchreview/localpatchsource.h +++ b/plugins/patchreview/localpatchsource.h @@ -1,86 +1,86 @@ /*************************************************************************** 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_LOCALPATCHSOURCE_H #define KDEVPLATFORM_PLUGIN_LOCALPATCHSOURCE_H #include #include #include #include namespace Ui { class LocalPatchWidget; } class LocalPatchSource : public KDevelop::IPatchSource { Q_OBJECT friend class LocalPatchWidget; public: LocalPatchSource(); ~LocalPatchSource() override; QString name() const override; QUrl baseDir() const override { return m_baseDir; } QUrl file() const override { return m_filename; } void update() override; QIcon icon() const override; void setFilename(const QUrl& filename) { m_filename = filename; } void setBaseDir(const QUrl& dir) { m_baseDir = dir; } void setCommand(const QString& cmd) { m_command = cmd; } QString command() const { return m_command; } bool isAlreadyApplied() const override { return m_applied; } void setAlreadyApplied( bool applied ) { m_applied = applied; } // the widget should be created _after_ the basic // values have been filled void createWidget(); QWidget* customWidget() const override; private: QUrl m_filename; QUrl m_baseDir; QString m_command; bool m_applied; uint m_depth; class LocalPatchWidget* m_widget; }; class LocalPatchWidget : public QWidget { Q_OBJECT public: LocalPatchWidget(LocalPatchSource* lpatch, QWidget* parent); -public slots: +public Q_SLOTS: void updatePatchFromEdit(); void syncPatch(); private: LocalPatchSource* m_lpatch; Ui::LocalPatchWidget* m_ui; }; #endif // KDEVPLATFORM_PLUGIN_LOCALPATCHSOURCE_H diff --git a/plugins/patchreview/patchhighlighter.h b/plugins/patchreview/patchhighlighter.h index 95adf3dc94..2b4b78f4cf 100644 --- a/plugins/patchreview/patchhighlighter.h +++ b/plugins/patchreview/patchhighlighter.h @@ -1,84 +1,84 @@ /*************************************************************************** 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_PATCHHIGHLIGHTER_H #define KDEVPLATFORM_PLUGIN_PATCHHIGHLIGHTER_H #include #include #include #include #include namespace Diff2 { class Difference; class DiffModel; } class PatchReviewPlugin; namespace KDevelop { class IDocument; } namespace KTextEditor { class Document; class Range; class Cursor; class Mark; class MovingRange; } ///Delete itself when the document(or textDocument), or Diff-Model is deleted. class PatchHighlighter : public QObject { Q_OBJECT public: PatchHighlighter( Diff2::DiffModel* model, KDevelop::IDocument* doc, PatchReviewPlugin* plugin, bool updatePatchFromEdits ) throw( QString ); ~PatchHighlighter() override; KDevelop::IDocument* doc(); QList< KTextEditor::MovingRange* > ranges() const; -private slots: +private Q_SLOTS: void documentDestroyed(); void aboutToDeleteMovingInterfaceContent( KTextEditor::Document* ); private: void highlightFromScratch(KTextEditor::Document* doc); void addLineMarker( KTextEditor::MovingRange* arg1, Diff2::Difference* arg2 ); void removeLineMarker( KTextEditor::MovingRange* range ); QStringList splitAndAddNewlines( const QString& text ) const; void performContentChange( KTextEditor::Document* doc, const QStringList& oldLines, const QStringList& newLines, int editLineNumber ); KTextEditor::MovingRange* rangeForMark(const KTextEditor::Mark& mark); void clear(); QSet< KTextEditor::MovingRange* > m_ranges; QMap< KTextEditor::MovingRange*, Diff2::Difference* > m_differencesForRanges; KDevelop::IDocument* m_doc; PatchReviewPlugin* m_plugin; Diff2::DiffModel* m_model; bool m_applying; -public slots: +public Q_SLOTS: void markToolTipRequested( KTextEditor::Document*, const KTextEditor::Mark&, QPoint, bool & ); void showToolTipForMark( QPoint arg1, KTextEditor::MovingRange* arg2); bool isRemoval( Diff2::Difference* ); bool isInsertion( Diff2::Difference* ); void markClicked( KTextEditor::Document*, const KTextEditor::Mark&, bool& ); void textInserted(KTextEditor::Document* doc, const KTextEditor::Cursor& cursor, const QString& text); void textRemoved( KTextEditor::Document*, const KTextEditor::Range&, const QString& oldText ); }; #endif diff --git a/plugins/patchreview/patchreviewtoolview.cpp b/plugins/patchreview/patchreviewtoolview.cpp index 3a1e78713f..e47f4bba02 100644 --- a/plugins/patchreview/patchreviewtoolview.cpp +++ b/plugins/patchreview/patchreviewtoolview.cpp @@ -1,603 +1,603 @@ /*************************************************************************** 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. * * * ***************************************************************************/ #include "patchreviewtoolview.h" #include "localpatchsource.h" #include "patchreview.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 #include #include #include #include #include #include #ifdef WITH_PURPOSE #include #include #endif using namespace KDevelop; class PatchFilesModel : public VcsFileChangesModel { Q_OBJECT public: PatchFilesModel( QObject *parent, bool allowSelection ) : VcsFileChangesModel( parent, allowSelection ) { }; enum ItemRoles { HunksNumberRole = LastItemRole+1 }; -public slots: +public Q_SLOTS: void updateState( const KDevelop::VcsStatusInfo &status, unsigned hunksNum ) { int row = VcsFileChangesModel::updateState( invisibleRootItem(), status ); if ( row == -1 ) return; QStandardItem *item = invisibleRootItem()->child( row, 0 ); setFileInfo( item, hunksNum ); item->setData( QVariant( hunksNum ), HunksNumberRole ); } void updateState( const KDevelop::VcsStatusInfo &status ) { int row = VcsFileChangesModel::updateState( invisibleRootItem(), status ); if ( row == -1 ) return; QStandardItem *item = invisibleRootItem()->child( row, 0 ); setFileInfo( invisibleRootItem()->child( row, 0 ), item->data( HunksNumberRole ).toUInt() ); } private: void setFileInfo( QStandardItem *item, unsigned int hunksNum ) { const auto url = item->index().data(VcsFileChangesModel::UrlRole).toUrl(); const QString path = ICore::self()->projectController()->prettyFileName(url, KDevelop::IProjectController::FormatPlain); const QString newText = i18ncp( "%1: number of changed hunks, %2: file name", "%2 (1 hunk)", "%2 (%1 hunks)", hunksNum, path); item->setText( newText ); } }; PatchReviewToolView::PatchReviewToolView( QWidget* parent, PatchReviewPlugin* plugin ) : QWidget( parent ), m_resetCheckedUrls( true ), m_plugin( plugin ) { connect( m_plugin->finishReviewAction(), &QAction::triggered, this, &PatchReviewToolView::finishReview ); connect( plugin, &PatchReviewPlugin::patchChanged, this, &PatchReviewToolView::patchChanged ); connect( plugin, &PatchReviewPlugin::startingNewReview, this, &PatchReviewToolView::startingNewReview ); connect( ICore::self()->documentController(), &IDocumentController::documentActivated, this, &PatchReviewToolView::documentActivated ); Sublime::MainWindow* w = dynamic_cast( ICore::self()->uiController()->activeMainWindow() ); connect(w, &Sublime::MainWindow::areaChanged, m_plugin, &PatchReviewPlugin::areaChanged); showEditDialog(); patchChanged(); } void PatchReviewToolView::resizeEvent(QResizeEvent* ev) { bool vertical = (width() < height()); m_editPatch.buttonsLayout->setDirection(vertical ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight); m_editPatch.contentLayout->setDirection(vertical ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight); m_editPatch.buttonsSpacer->changeSize(vertical ? 0 : 40, 0, QSizePolicy::Fixed, QSizePolicy::Fixed); QWidget::resizeEvent(ev); if(m_customWidget) { m_editPatch.contentLayout->removeWidget( m_customWidget ); m_editPatch.contentLayout->insertWidget(0, m_customWidget ); } } void PatchReviewToolView::startingNewReview() { m_resetCheckedUrls = true; } void PatchReviewToolView::patchChanged() { fillEditFromPatch(); kompareModelChanged(); #ifdef WITH_PURPOSE IPatchSource::Ptr p = m_plugin->patch(); if (p) { m_exportMenu->model()->setInputData(QJsonObject { { QStringLiteral("urls"), QJsonArray { p->file().toString() } }, { QStringLiteral("mimeType"), { QStringLiteral("text/x-patch") } }, { QStringLiteral("localBaseDir"), { p->baseDir().toString() } } }); } #endif } PatchReviewToolView::~PatchReviewToolView() { } LocalPatchSource* PatchReviewToolView::GetLocalPatchSource() { IPatchSource::Ptr ips = m_plugin->patch(); if ( !ips ) return nullptr; return dynamic_cast( ips.data() ); } void PatchReviewToolView::fillEditFromPatch() { IPatchSource::Ptr ipatch = m_plugin->patch(); if ( !ipatch ) return; m_editPatch.cancelReview->setVisible( ipatch->canCancel() ); m_fileModel->setIsCheckbable( m_plugin->patch()->canSelectFiles() ); if( m_customWidget ) { qCDebug(PLUGIN_PATCHREVIEW) << "removing custom widget"; m_customWidget->hide(); m_editPatch.contentLayout->removeWidget( m_customWidget ); } m_customWidget = ipatch->customWidget(); if( m_customWidget ) { m_editPatch.contentLayout->insertWidget( 0, m_customWidget ); m_customWidget->show(); qCDebug(PLUGIN_PATCHREVIEW) << "got custom widget"; } bool showTests = false; IProject* project = nullptr; QMap files = ipatch->additionalSelectableFiles(); QMap::const_iterator it = files.constBegin(); for (; it != files.constEnd(); ++it) { project = ICore::self()->projectController()->findProjectForUrl(it.key()); if (project && !ICore::self()->testController()->testSuitesForProject(project).isEmpty()) { showTests = true; break; } } m_editPatch.testsButton->setVisible(showTests); m_editPatch.testProgressBar->hide(); } void PatchReviewToolView::slotAppliedChanged( int newState ) { if ( LocalPatchSource* lpatch = GetLocalPatchSource() ) { lpatch->setAlreadyApplied( newState == Qt::Checked ); m_plugin->notifyPatchChanged(); } } void PatchReviewToolView::showEditDialog() { m_editPatch.setupUi( this ); bool allowSelection = m_plugin->patch() && m_plugin->patch()->canSelectFiles(); m_fileModel = new PatchFilesModel( this, allowSelection ); m_fileSortProxyModel = new VcsFileChangesSortProxyModel(this); m_fileSortProxyModel->setSourceModel(m_fileModel); m_fileSortProxyModel->sort(1); m_fileSortProxyModel->setDynamicSortFilter(true); m_editPatch.filesList->setModel( m_fileSortProxyModel ); m_editPatch.filesList->header()->hide(); m_editPatch.filesList->setRootIsDecorated( false ); m_editPatch.filesList->setContextMenuPolicy(Qt::CustomContextMenu); connect(m_editPatch.filesList, &QTreeView::customContextMenuRequested, this, &PatchReviewToolView::customContextMenuRequested); connect(m_fileModel, &PatchFilesModel::itemChanged, this, &PatchReviewToolView::fileItemChanged); m_editPatch.previousFile->setIcon( QIcon::fromTheme( QStringLiteral("arrow-left") ) ); m_editPatch.previousHunk->setIcon( QIcon::fromTheme( QStringLiteral("arrow-up") ) ); m_editPatch.nextHunk->setIcon( QIcon::fromTheme( QStringLiteral("arrow-down") ) ); m_editPatch.nextFile->setIcon( QIcon::fromTheme( QStringLiteral("arrow-right") ) ); m_editPatch.cancelReview->setIcon( QIcon::fromTheme( QStringLiteral("dialog-cancel") ) ); m_editPatch.updateButton->setIcon( QIcon::fromTheme( QStringLiteral("view-refresh") ) ); m_editPatch.testsButton->setIcon( QIcon::fromTheme( QStringLiteral("preflight-verifier") ) ); m_editPatch.finishReview->setDefaultAction(m_plugin->finishReviewAction()); #ifdef WITH_PURPOSE m_exportMenu = new Purpose::Menu(this); connect(m_exportMenu, &Purpose::Menu::finished, this, [](const QJsonObject &output, int error, const QString &message) { if (error==0) { KMessageBox::information(nullptr, i18n("You can find the new request at:
%1
", output["url"].toString()), QString(), QString(), KMessageBox::AllowLink); } else { QMessageBox::warning(nullptr, i18n("Error exporting"), i18n("Couldn't export the patch.\n%1", message)); } }); m_exportMenu->model()->setPluginType("Export"); m_editPatch.exportReview->setMenu( m_exportMenu ); #else m_editPatch.exportReview->setEnabled(false); #endif connect( m_editPatch.previousHunk, &QToolButton::clicked, this, &PatchReviewToolView::prevHunk ); connect( m_editPatch.nextHunk, &QToolButton::clicked, this, &PatchReviewToolView::nextHunk ); connect( m_editPatch.previousFile, &QToolButton::clicked, this, &PatchReviewToolView::prevFile ); connect( m_editPatch.nextFile, &QToolButton::clicked, this, &PatchReviewToolView::nextFile ); connect( m_editPatch.filesList, &QTreeView::activated , this, &PatchReviewToolView::fileDoubleClicked ); connect( m_editPatch.cancelReview, &QPushButton::clicked, m_plugin, &PatchReviewPlugin::cancelReview ); //connect( m_editPatch.cancelButton, SIGNAL(pressed()), this, SLOT(slotEditCancel()) ); //connect( this, SIGNAL(finished(int)), this, SLOT(slotEditDialogFinished(int)) ); connect( m_editPatch.updateButton, &QPushButton::clicked, m_plugin, &PatchReviewPlugin::forceUpdate ); connect( m_editPatch.testsButton, &QPushButton::clicked, this, &PatchReviewToolView::runTests ); m_selectAllAction = new QAction(QIcon::fromTheme(QStringLiteral("edit-select-all")), i18n("Select All"), this ); connect( m_selectAllAction, &QAction::triggered, this, &PatchReviewToolView::selectAll ); m_deselectAllAction = new QAction( i18n("Deselect All"), this ); connect( m_deselectAllAction, &QAction::triggered, this, &PatchReviewToolView::deselectAll ); } void PatchReviewToolView::customContextMenuRequested(const QPoint& ) { QList urls; QModelIndexList selectionIdxs = m_editPatch.filesList->selectionModel()->selectedIndexes(); foreach(const QModelIndex& idx, selectionIdxs) { urls += idx.data(KDevelop::VcsFileChangesModel::UrlRole).toUrl(); } QPointer menu = new QMenu(m_editPatch.filesList); QList extensions; if(!urls.isEmpty()) { KDevelop::FileContext context(urls); extensions = ICore::self()->pluginController()->queryPluginsForContextMenuExtensions( &context ); } QList vcsActions; foreach( const ContextMenuExtension& ext, extensions ) { vcsActions += ext.actions(ContextMenuExtension::VcsGroup); } menu->addAction(m_selectAllAction); menu->addAction(m_deselectAllAction); menu->addActions(vcsActions); if ( !menu->isEmpty() ) { menu->exec(QCursor::pos()); } delete menu; } void PatchReviewToolView::nextHunk() { IDocument* current = ICore::self()->documentController()->activeDocument(); if(current && current->textDocument()) m_plugin->seekHunk( true, current->textDocument()->url() ); } void PatchReviewToolView::prevHunk() { IDocument* current = ICore::self()->documentController()->activeDocument(); if(current && current->textDocument()) m_plugin->seekHunk( false, current->textDocument()->url() ); } void PatchReviewToolView::seekFile(bool forwards) { if(!m_plugin->patch()) return; QList checkedUrls = m_fileModel->checkedUrls(); QList allUrls = m_fileModel->urls(); IDocument* current = ICore::self()->documentController()->activeDocument(); if(!current || checkedUrls.empty()) return; qCDebug(PLUGIN_PATCHREVIEW) << "seeking direction" << forwards; int currentIndex = allUrls.indexOf(current->url()); QUrl newUrl; if((forwards && current->url() == checkedUrls.back()) || (!forwards && current->url() == checkedUrls[0])) { newUrl = m_plugin->patch()->file(); qCDebug(PLUGIN_PATCHREVIEW) << "jumping to patch"; } else if(current->url() == m_plugin->patch()->file() || currentIndex == -1) { if(forwards) newUrl = checkedUrls[0]; else newUrl = checkedUrls.back(); qCDebug(PLUGIN_PATCHREVIEW) << "jumping from patch"; } else { QSet checkedUrlsSet( checkedUrls.toSet() ); for(int offset = 1; offset < allUrls.size(); ++offset) { int pos; if(forwards) { pos = (currentIndex + offset) % allUrls.size(); }else{ pos = currentIndex - offset; if(pos < 0) pos += allUrls.size(); } if(checkedUrlsSet.contains(allUrls[pos])) { newUrl = allUrls[pos]; break; } } } if(newUrl.isValid()) { open( newUrl, true ); }else{ qCDebug(PLUGIN_PATCHREVIEW) << "found no valid target url"; } } void PatchReviewToolView::open( const QUrl& url, bool activate ) const { qCDebug(PLUGIN_PATCHREVIEW) << "activating url" << url; // If the document is already open in this area, just re-activate it if(KDevelop::IDocument* doc = ICore::self()->documentController()->documentForUrl(url)) { foreach(Sublime::View* view, ICore::self()->uiController()->activeArea()->views()) { if(view->document() == dynamic_cast(doc)) { if (activate) { // use openDocument() for the activation so that the document is added to File/Open Recent. ICore::self()->documentController()->openDocument(doc->url(), KTextEditor::Range::invalid()); } return; } } } QStandardItem* item = m_fileModel->itemForUrl( url ); IDocument* buddyDoc = nullptr; if (m_plugin->patch() && item) { for (int preRow = item->row() - 1; preRow >= 0; --preRow) { QStandardItem* preItem = m_fileModel->item(preRow); if (!m_fileModel->isCheckable() || preItem->checkState() == Qt::Checked) { // found valid predecessor, take it as buddy buddyDoc = ICore::self()->documentController()->documentForUrl(preItem->index().data(VcsFileChangesModel::UrlRole).toUrl()); if (buddyDoc) { break; } } } if (!buddyDoc) { buddyDoc = ICore::self()->documentController()->documentForUrl(m_plugin->patch()->file()); } } // we simplify and assume that documents to be opened without activating them also need not be // added to the Files/Open Recent menu. IDocument* newDoc = ICore::self()->documentController()->openDocument(url, KTextEditor::Range::invalid(), activate ? IDocumentController::DefaultMode : IDocumentController::DoNotActivate|IDocumentController::DoNotAddToRecentOpen, QString(), buddyDoc); KTextEditor::View* view = nullptr; if(newDoc) view = newDoc->activeTextView(); if(view && view->cursorPosition().line() == 0) m_plugin->seekHunk( true, url ); } void PatchReviewToolView::fileItemChanged( QStandardItem* item ) { if (item->column() != 0 || !m_plugin->patch()) return; QUrl url = item->index().data(VcsFileChangesModel::UrlRole).toUrl(); if (url.isEmpty()) return; KDevelop::IDocument* doc = ICore::self()->documentController()->documentForUrl(url); if(m_fileModel->isCheckable() && item->checkState() != Qt::Checked) { // The file was deselected, so eventually close it if(doc && doc->state() == IDocument::Clean) { foreach(Sublime::View* view, ICore::self()->uiController()->activeArea()->views()) { if(view->document() == dynamic_cast(doc)) { ICore::self()->uiController()->activeArea()->closeView(view); return; } } } } else if (!doc) { // Maybe the file was unchecked before, or it was just loaded. open( url, false ); } } void PatchReviewToolView::nextFile() { seekFile(true); } void PatchReviewToolView::prevFile() { seekFile(false); } void PatchReviewToolView::deselectAll() { m_fileModel->setAllChecked(false); } void PatchReviewToolView::selectAll() { m_fileModel->setAllChecked(true); } void PatchReviewToolView::finishReview() { QList selectedUrls = m_fileModel->checkedUrls(); qCDebug(PLUGIN_PATCHREVIEW) << "finishing review with" << selectedUrls; m_plugin->finishReview( selectedUrls ); } void PatchReviewToolView::fileDoubleClicked( const QModelIndex& idx ) { const QUrl file = idx.data(VcsFileChangesModel::UrlRole).toUrl(); open( file, true ); } void PatchReviewToolView::kompareModelChanged() { QList oldCheckedUrls = m_fileModel->checkedUrls(); m_fileModel->clear(); if ( !m_plugin->modelList() ) return; QMap additionalUrls = m_plugin->patch()->additionalSelectableFiles(); const Diff2::DiffModelList* models = m_plugin->modelList()->models(); if( models ) { Diff2::DiffModelList::const_iterator it = models->constBegin(); for(; it != models->constEnd(); ++it ) { Diff2::DifferenceList * diffs = ( *it )->differences(); int cnt = 0; if ( diffs ) cnt = diffs->count(); const QUrl file = m_plugin->urlForFileModel( *it ); if( file.isLocalFile() && !QFileInfo( file.toLocalFile() ).isReadable() ) continue; VcsStatusInfo status; status.setUrl( file ); status.setState( cnt>0 ? VcsStatusInfo::ItemModified : VcsStatusInfo::ItemUpToDate ); m_fileModel->updateState( status, cnt ); } } for( QMap::const_iterator it = additionalUrls.constBegin(); it != additionalUrls.constEnd(); ++it ) { VcsStatusInfo status; status.setUrl( it.key() ); status.setState( it.value() ); m_fileModel->updateState( status ); } if(!m_resetCheckedUrls) m_fileModel->setCheckedUrls(oldCheckedUrls); else m_resetCheckedUrls = false; m_editPatch.filesList->resizeColumnToContents( 0 ); // Eventually select the active document documentActivated( ICore::self()->documentController()->activeDocument() ); } void PatchReviewToolView::documentActivated( IDocument* doc ) { if( !doc ) return; if ( !m_plugin->modelList() ) return; const auto matches = m_fileSortProxyModel->match( m_fileSortProxyModel->index(0, 0), VcsFileChangesModel::UrlRole, doc->url(), 1, Qt::MatchExactly); m_editPatch.filesList->setCurrentIndex(matches.value(0)); } void PatchReviewToolView::runTests() { IPatchSource::Ptr ipatch = m_plugin->patch(); if ( !ipatch ) { return; } IProject* project = nullptr; QMap files = ipatch->additionalSelectableFiles(); QMap::const_iterator it = files.constBegin(); for (; it != files.constEnd(); ++it) { project = ICore::self()->projectController()->findProjectForUrl(it.key()); if (project) { break; } } if (!project) { return; } m_editPatch.testProgressBar->setFormat(i18n("Running tests: %p%")); m_editPatch.testProgressBar->setValue(0); m_editPatch.testProgressBar->show(); ProjectTestJob* job = new ProjectTestJob(project, this); connect(job, &ProjectTestJob::finished, this, &PatchReviewToolView::testJobResult); connect(job, SIGNAL(percent(KJob*,ulong)), this, SLOT(testJobPercent(KJob*,ulong))); ICore::self()->runController()->registerJob(job); } void PatchReviewToolView::testJobPercent(KJob* job, ulong percent) { Q_UNUSED(job); m_editPatch.testProgressBar->setValue(percent); } void PatchReviewToolView::testJobResult(KJob* job) { ProjectTestJob* testJob = qobject_cast(job); if (!testJob) { return; } ProjectTestResult result = testJob->testResult(); QString format; if (result.passed > 0 && result.failed == 0 && result.error == 0) { format = i18np("Test passed", "All %1 tests passed", result.passed); } else { format = i18n("Test results: %1 passed, %2 failed, %3 errors", result.passed, result.failed, result.error); } m_editPatch.testProgressBar->setFormat(format); // Needed because some test jobs may raise their own output views ICore::self()->uiController()->raiseToolView(this); } #include "patchreviewtoolview.moc" diff --git a/plugins/patchreview/patchreviewtoolview.h b/plugins/patchreview/patchreviewtoolview.h index 26d93ebbe0..58b23a7ab2 100644 --- a/plugins/patchreview/patchreviewtoolview.h +++ b/plugins/patchreview/patchreviewtoolview.h @@ -1,112 +1,112 @@ /*************************************************************************** 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 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; // opens the document which should be part of the patch, // ensuring that the tabs are sorted correctly void open( const QUrl& url, bool activate ) const; -signals: +Q_SIGNALS: void dialogClosed( PatchReviewToolView* ); void stateChanged( PatchReviewToolView* ); -private slots: +private Q_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 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: +public Q_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/perforce/perforceplugin.h b/plugins/perforce/perforceplugin.h index b32da1c723..6aab47ec25 100644 --- a/plugins/perforce/perforceplugin.h +++ b/plugins/perforce/perforceplugin.h @@ -1,175 +1,175 @@ /*************************************************************************** * Copyright 2010 Morten Danielsen Volden * * * * 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 KDEVPERFORCEPLUGIN_H #define KDEVPERFORCEPLUGIN_H #include #include #include #include #include #include class QMenu; class QFileInfo; namespace KDevelop { class ContextMenuExtension; class VcsPluginHelper; class DVcsJob; } class PerforcePlugin : public KDevelop::IPlugin, public KDevelop::ICentralizedVersionControl { Q_OBJECT Q_INTERFACES(KDevelop::IBasicVersionControl KDevelop::ICentralizedVersionControl) friend class PerforcePluginTest; public: explicit PerforcePlugin(QObject* parent, const QVariantList & = QVariantList()); ~PerforcePlugin() override; //@{ /** Methods inherited from KDevelop::IBasicVersionControl */ QString name() const override; KDevelop::VcsImportMetadataWidget* createImportMetadataWidget(QWidget* parent) override; bool isValidRemoteRepositoryUrl(const QUrl& remoteLocation) override; bool isVersionControlled(const QUrl& localLocation) override; KDevelop::VcsJob* repositoryLocation(const QUrl& localLocation) override; KDevelop::VcsJob* add(const QList& localLocations, RecursionMode recursion = IBasicVersionControl::Recursive) override; KDevelop::VcsJob* remove(const QList& localLocations) override; KDevelop::VcsJob* copy(const QUrl& localLocationSrc, const QUrl& localLocationDstn) override; KDevelop::VcsJob* move(const QUrl& localLocationSrc, const QUrl& localLocationDst) override; KDevelop::VcsJob* status(const QList& localLocations, RecursionMode recursion = IBasicVersionControl::Recursive) override; KDevelop::VcsJob* revert(const QList& localLocations, RecursionMode recursion = IBasicVersionControl::Recursive) override; KDevelop::VcsJob* update(const QList& localLocations, const KDevelop::VcsRevision& rev = KDevelop::VcsRevision::createSpecialRevision(KDevelop::VcsRevision::Head), KDevelop::IBasicVersionControl::RecursionMode recursion = KDevelop::IBasicVersionControl::Recursive) override; KDevelop::VcsJob* commit(const QString& message, const QList& localLocations, KDevelop::IBasicVersionControl::RecursionMode recursion = KDevelop::IBasicVersionControl::Recursive) override; KDevelop::VcsJob* diff(const QUrl& fileOrDirectory, const KDevelop::VcsRevision& srcRevision, const KDevelop::VcsRevision& dstRevision, KDevelop::VcsDiff::Type = KDevelop::VcsDiff::DiffUnified, KDevelop::IBasicVersionControl::RecursionMode recursion = KDevelop::IBasicVersionControl::Recursive) override; KDevelop::VcsJob* log(const QUrl& localLocation, const KDevelop::VcsRevision& rev, unsigned long limit = 0) override; KDevelop::VcsJob* log(const QUrl& localLocation, const KDevelop::VcsRevision& rev = KDevelop::VcsRevision::createSpecialRevision(KDevelop::VcsRevision::Base), const KDevelop::VcsRevision& limit = KDevelop::VcsRevision::createSpecialRevision(KDevelop::VcsRevision::Start)) override; KDevelop::VcsJob* annotate(const QUrl& localLocation, const KDevelop::VcsRevision& rev = KDevelop::VcsRevision::createSpecialRevision(KDevelop::VcsRevision::Head)) override; KDevelop::VcsJob* resolve(const QList& localLocations, KDevelop::IBasicVersionControl::RecursionMode recursion) override; KDevelop::VcsJob* createWorkingCopy(const KDevelop::VcsLocation & sourceRepository, const QUrl & destinationDirectory, KDevelop::IBasicVersionControl::RecursionMode recursion = IBasicVersionControl::Recursive) override; KDevelop::VcsLocationWidget* vcsLocation(QWidget* parent) const override; //@} //@{ /** Methods inherited from KDevelop::ICentralizedVersionControl */ KDevelop::VcsJob* edit(const QUrl& localLocation) override; KDevelop::VcsJob* unedit(const QUrl& localLocation) override; KDevelop::VcsJob* localRevision(const QUrl& localLocation, KDevelop::VcsRevision::RevisionType) override; KDevelop::VcsJob* import(const QString & commitMessage, const QUrl & sourceDirectory, const KDevelop::VcsLocation & destinationRepository) override; //@} /// This plugin implements its own edit method KDevelop::VcsJob* edit(const QList& localLocations); KDevelop::ContextMenuExtension contextMenuExtension(KDevelop::Context* context) override; public Q_SLOTS: /// invoked by context-menu void ctxEdit(); // void ctxUnedit(); // void ctxLocalRevision(); // void ctxImport(); -private slots: +private Q_SLOTS: void parseP4StatusOutput(KDevelop::DVcsJob* job); void parseP4DiffOutput(KDevelop::DVcsJob* job); void parseP4LogOutput(KDevelop::DVcsJob* job); void parseP4AnnotateOutput(KDevelop::DVcsJob* job); private: bool isValidDirectory(const QUrl & dirPath); KDevelop::DVcsJob* p4fstatJob(const QFileInfo& curFile, KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose); bool parseP4fstat(const QFileInfo& curFile, KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose); KDevelop::VcsJob* errorsFound(const QString& error, KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose); QString getRepositoryName(const QFileInfo& curFile); void setEnvironmentForJob(KDevelop::DVcsJob* job, QFileInfo const& fsObject); QList getQvariantFromLogOutput(QStringList const& outputLines); std::unique_ptr m_common; QMenu* m_perforcemenu; QString m_perforceConfigName; QString m_perforceExecutable; QAction* m_edit_action; }; #endif // PERFORCEPLUGIN_H diff --git a/plugins/perforce/test/test_perforce.h b/plugins/perforce/test/test_perforce.h index 70438d9dc8..a2a0b7062c 100644 --- a/plugins/perforce/test/test_perforce.h +++ b/plugins/perforce/test/test_perforce.h @@ -1,58 +1,58 @@ /*************************************************************************** * This file was inspired by KDevelop's git plugin * * Copyright 2008 Evgeniy Ivanov * * * * Adapted for Perforce * * Copyright 2011 Morten Danielsen Volden * * * * 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 PERFORCEPLUGIN_TEST_H #define PERFORCEPLUGIN_TEST_H #include class PerforcePlugin; namespace KDevelop { class TestCore; } class PerforcePluginTest : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void init(); void cleanup(); void testAdd(); void testEdit(); void testEditMultipleFiles(); void testStatus(); void testAnnotate(); void testHistory(); void testRevert(); void testUpdateFile(); void testUpdateDir(); void testCommit(); void testDiff(); private: PerforcePlugin* m_plugin; KDevelop::TestCore* m_core; void removeTempDirsIfAny(); void createNewTempDirs(); }; #endif diff --git a/plugins/problemreporter/problemhighlighter.h b/plugins/problemreporter/problemhighlighter.h index 97dde7a2ef..ce80d364c9 100644 --- a/plugins/problemreporter/problemhighlighter.h +++ b/plugins/problemreporter/problemhighlighter.h @@ -1,53 +1,53 @@ /* * KDevelop Problem Reporter * * Copyright 2008 Hamish Rodda * Copyright 2008-2009 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_PROBLEM_HIGHLIGHT_H #define KDEVPLATFORM_PLUGIN_PROBLEM_HIGHLIGHT_H #include #include #include #include class ProblemHighlighter : public QObject { Q_OBJECT public: explicit ProblemHighlighter(KTextEditor::Document* document); ~ProblemHighlighter() override; void setProblems(const QVector& problems); -private slots: +private Q_SLOTS: void aboutToRemoveText(const KTextEditor::Range& range); void clearProblems(); private: QPointer m_document; QList m_topHLRanges; QVector m_problems; -public slots: +public Q_SLOTS: void settingsChanged(); }; #endif // KDEVPLATFORM_PLUGIN_PROBLEM_HIGHLIGHT_H diff --git a/plugins/problemreporter/problemreporterplugin.h b/plugins/problemreporter/problemreporterplugin.h index 272d3b26ca..4b9c005528 100644 --- a/plugins/problemreporter/problemreporterplugin.h +++ b/plugins/problemreporter/problemreporterplugin.h @@ -1,83 +1,83 @@ /* * KDevelop Problem Reporter * * Copyright 2006 Adam Treat * Copyright 2006-2007 Hamish Rodda * 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_PLUGIN_PROBLEMREPORTERPLUGIN_H #define KDEVPLATFORM_PLUGIN_PROBLEMREPORTERPLUGIN_H #include #include #include #include #include Q_DECLARE_LOGGING_CATEGORY(PLUGIN_PROBLEMREPORTER) namespace KTextEditor { class Document; } namespace KDevelop { class IDocument; } class ProblemHighlighter; class ProblemReporterModel; class ProblemReporterPlugin : public KDevelop::IPlugin { Q_OBJECT public: explicit ProblemReporterPlugin(QObject* parent, const QVariantList& = QVariantList()); ~ProblemReporterPlugin() override; KDevelop::ContextMenuExtension contextMenuExtension(KDevelop::Context* context) override; // KDevelop::Plugin methods void unload() override; ProblemReporterModel* model() const; private Q_SLOTS: void updateReady(const KDevelop::IndexedString& url, const KDevelop::ReferencedTopDUContext&); void updateHighlight(const KDevelop::IndexedString& url); void textDocumentCreated(KDevelop::IDocument* document); void documentActivated(KDevelop::IDocument* document); void showModel(const QString& id); private: void updateOpenedDocumentsHighlight(); class ProblemReporterFactory* m_factory; ProblemReporterModel* m_model; QHash m_highlighters; QSet m_reHighlightNeeded; -public slots: +public Q_SLOTS: void documentClosed(KDevelop::IDocument*); }; #endif // KDEVPLATFORM_PLUGIN_PROBLEMREPORTERPLUGIN_H // kate: space-indent on; indent-width 2; tab-width 4; replace-tabs on; auto-insert-doxygen on diff --git a/plugins/problemreporter/problemtreeview.h b/plugins/problemreporter/problemtreeview.h index 331c16b424..b1d33b7381 100644 --- a/plugins/problemreporter/problemtreeview.h +++ b/plugins/problemreporter/problemtreeview.h @@ -1,76 +1,76 @@ /* * KDevelop Problem Reporter * * Copyright (c) 2007 Hamish Rodda * * 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_PROBLEMWIDGET_H #define KDEVPLATFORM_PLUGIN_PROBLEMWIDGET_H #include namespace KDevelop { class TopDUContext; class IDocument; class ProblemModel; } class ProblemReporterPlugin; class QSortFilterProxyModel; class ProblemTreeView : public QTreeView { Q_OBJECT public: ProblemTreeView(QWidget* parent, QAbstractItemModel* itemModel); ~ProblemTreeView() override; KDevelop::ProblemModel* model() const; void setModel(QAbstractItemModel* model) override; void contextMenuEvent(QContextMenuEvent*) override; void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector& roles = QVector()) override; void reset() override; int setFilter(const QString& filterText); -public slots: +public Q_SLOTS: void openDocumentForCurrentProblem(); -signals: +Q_SIGNALS: // Emitted when the model's rows change (added/removed/reset) void changed(); protected: void showEvent(QShowEvent* event) override; -private slots: +private Q_SLOTS: void itemActivated(const QModelIndex& index); private: void resizeColumns(); ProblemReporterPlugin* m_plugin; QSortFilterProxyModel* m_proxy; }; #endif // kate: space-indent on; indent-width 2; tab-width: 4; replace-tabs on; auto-insert-doxygen on diff --git a/plugins/problemreporter/tests/test_problemsview.cpp b/plugins/problemreporter/tests/test_problemsview.cpp index db47768727..58c2c398bb 100644 --- a/plugins/problemreporter/tests/test_problemsview.cpp +++ b/plugins/problemreporter/tests/test_problemsview.cpp @@ -1,211 +1,211 @@ /* * 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. */ #include #include #include #include "../problemsview.h" #include #include #include #include #include #include using namespace KDevelop; class TestProblemsView : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void testLoad(); void testAddModel(); void testSwitchTab(); void testRemoveModel(); void testAddRemoveProblems(); void testSetProblems(); private: QTabWidget* tabWidget(); QScopedPointer m_view; }; void TestProblemsView::initTestCase() { AutoTestShell::init(); TestCore::initialize(Core::NoUi); ProblemModelSet* pms = ICore::self()->languageController()->problemModelSet(); ProblemModel* model = new ProblemModel(pms); IProblem::Ptr p(new DetectedProblem()); model->addProblem(p); pms->addModel(QStringLiteral("MODEL1_ID"), QStringLiteral("MODEL1"), model); m_view.reset(new ProblemsView()); } void TestProblemsView::cleanupTestCase() { TestCore::shutdown(); } void TestProblemsView::testLoad() { m_view->load(); // Check that the initial model's tab shows up QTabWidget* tab = tabWidget(); QVERIFY(tab); QCOMPARE(tab->count(), 1); QCOMPARE(tab->tabText(0), QStringLiteral("MODEL1 (1)")); } void TestProblemsView::testAddModel() { ProblemModelSet* pms = ICore::self()->languageController()->problemModelSet(); pms->addModel(QStringLiteral("MODEL2_ID"), QStringLiteral("MODEL2"), new ProblemModel(pms)); QTabWidget* tab = tabWidget(); QVERIFY(tab); QCOMPARE(tab->count(), 2); QCOMPARE(tab->tabText(0), QStringLiteral("MODEL1 (1)")); QCOMPARE(tab->tabText(1), QStringLiteral("MODEL2 (0)")); } QVector visibilites(const QList actions) { QVector visibilites; foreach (auto action, actions) { visibilites << action->isVisible(); } return visibilites; } void TestProblemsView::testSwitchTab() { QTabWidget* tab = tabWidget(); QVERIFY(tab); // Check that the current widget's actions are in the toolbar QWidget* oldWidget = tab->currentWidget(); QVERIFY(oldWidget); const auto oldVisibilites = visibilites(m_view->actions()); tab->setCurrentIndex(1); // Check that the new widget's actions are in the toolbar QWidget* newWidget = tab->currentWidget(); QVERIFY(newWidget); QVERIFY(newWidget != oldWidget); const auto newVisibilites = visibilites(m_view->actions()); QCOMPARE(oldVisibilites, newVisibilites); } void TestProblemsView::testRemoveModel() { // Remove the model ProblemModelSet* pms = ICore::self()->languageController()->problemModelSet(); ProblemModel* model = pms->findModel(QStringLiteral("MODEL1_ID")); QVERIFY(model); pms->removeModel(QStringLiteral("MODEL1_ID")); delete model; model = nullptr; // Now let's see if the view has been updated! QTabWidget* tab = tabWidget(); QVERIFY(tab); QCOMPARE(tab->count(), 1); QCOMPARE(tab->tabText(0), QStringLiteral("MODEL2 (0)")); } void TestProblemsView::testAddRemoveProblems() { ProblemModelSet* pms = ICore::self()->languageController()->problemModelSet(); ProblemModel* model = pms->findModel(QStringLiteral("MODEL2_ID")); QVERIFY(model); QTabWidget* tab = tabWidget(); QVERIFY(tab); // Make sure there are no problems right now model->clearProblems(); QCOMPARE(tab->tabText(0), QStringLiteral("MODEL2 (0)")); // Let's add some problems int c = 0; for (int i = 0; i < 3; i++) { IProblem::Ptr p(new DetectedProblem()); model->addProblem(p); c++; // Check if the view has noticed the addition QString label = QStringLiteral("MODEL2 (%1)").arg(c); QCOMPARE(tab->tabText(0), label); } // Clear the problems model->clearProblems(); // Check if the view has noticed the clear QCOMPARE(tab->tabText(0), QStringLiteral("MODEL2 (0)")); } void TestProblemsView::testSetProblems() { ProblemModelSet* pms = ICore::self()->languageController()->problemModelSet(); ProblemModel* model = pms->findModel(QStringLiteral("MODEL2_ID")); QVERIFY(model); QTabWidget* tab = tabWidget(); QVERIFY(tab); // Make sure there are no problems right now model->clearProblems(); QCOMPARE(tab->tabText(0), QStringLiteral("MODEL2 (0)")); // Build a problem vector and set the problems QVector problems; for (int i = 0; i < 3; i++) { IProblem::Ptr p(new DetectedProblem()); problems.push_back(p); } model->setProblems(problems); // Check if the view has noticed QCOMPARE(tab->tabText(0), QStringLiteral("MODEL2 (3)")); } ////////////////////////////////////////////////////////////////////////////////////////////////////////// QTabWidget* TestProblemsView::tabWidget() { QTabWidget* tab = m_view->findChild(); return tab; } QTEST_MAIN(TestProblemsView) #include "test_problemsview.moc" diff --git a/plugins/projectfilter/projectfilterconfigpage.h b/plugins/projectfilter/projectfilterconfigpage.h index f2419302c0..1bd6a48beb 100644 --- a/plugins/projectfilter/projectfilterconfigpage.h +++ b/plugins/projectfilter/projectfilterconfigpage.h @@ -1,74 +1,74 @@ /* This file is part of KDevelop Copyright 2013 Milian Wolff Copyright 2008 Alexander Dymo 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_PROJECTFILTERCONFIGPAGE_H #define KDEVPLATFORM_PLUGIN_PROJECTFILTERCONFIGPAGE_H #include #include "projectfiltersettings.h" namespace Ui { class ProjectFilterSettings; } namespace KDevelop { class FilterModel; class ProjectFilterProvider; class ProjectFilterConfigPage : public ProjectConfigPage { Q_OBJECT public: ProjectFilterConfigPage(ProjectFilterProvider* provider, const KDevelop::ProjectConfigOptions& options, QWidget* parent); ~ProjectFilterConfigPage() override; QString name() const override; QIcon icon() const override; QString fullName() const override; protected: bool eventFilter(QObject* object, QEvent* event) override; -private slots: +private Q_SLOTS: void add(); void remove(); void moveUp(); void moveDown(); void selectionChanged(); void emitChanged(); public Q_SLOTS: void apply() override; void reset() override; void defaults() override; private: void checkFilters(); FilterModel *m_model; ProjectFilterProvider* m_projectFilterProvider; QScopedPointer m_ui; }; } #endif diff --git a/plugins/projectfilter/projectfilterprovider.h b/plugins/projectfilter/projectfilterprovider.h index f2eac9fd69..81d9bdba3d 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 = 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: +Q_SIGNALS: void filterChanged(KDevelop::IProjectFilterProvider*, KDevelop::IProject*); -public slots: +public Q_SLOTS: void updateProjectFilters(KDevelop::IProject* project); -private slots: +private Q_SLOTS: void projectClosing(KDevelop::IProject*); void projectAboutToBeOpened(KDevelop::IProject*); void addFilterFromContextMenu(); private: QHash > m_filters; }; } #endif // KDEVPLATFORM_PLUGIN_PROJECTFILTERPROVIDER_H diff --git a/plugins/projectfilter/tests/test_projectfilter.h b/plugins/projectfilter/tests/test_projectfilter.h index 53fe1b9bc3..8bf8fd55e6 100644 --- a/plugins/projectfilter/tests/test_projectfilter.h +++ b/plugins/projectfilter/tests/test_projectfilter.h @@ -1,41 +1,41 @@ /* * 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 TESTPROJECTFILTER_H #define TESTPROJECTFILTER_H #include class TestProjectFilter : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void match(); void match_data(); void bench(); void bench_data(); }; #endif // TESTPROJECTFILTER_H diff --git a/plugins/projectmanagerview/projectbuildsetwidget.h b/plugins/projectmanagerview/projectbuildsetwidget.h index 3c31e03686..67673cb56a 100644 --- a/plugins/projectmanagerview/projectbuildsetwidget.h +++ b/plugins/projectmanagerview/projectbuildsetwidget.h @@ -1,64 +1,64 @@ /*************************************************************************** * 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 class ProjectManagerViewPlugin; class ProjectManagerView; namespace KDevelop { class ProjectBaseItem; } namespace Ui { class ProjectBuildSetWidget; } class ProjectBuildSetWidget : public QWidget { Q_OBJECT public: explicit ProjectBuildSetWidget( QWidget* parent = nullptr ); ~ProjectBuildSetWidget() override; void setProjectView( ProjectManagerView* view ); -public slots: +public Q_SLOTS: void selectionChanged(); -private slots: +private Q_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/projectmanagerview.h b/plugins/projectmanagerview/projectmanagerview.h index 1ca23a504c..d83e81f79f 100644 --- a/plugins/projectmanagerview/projectmanagerview.h +++ b/plugins/projectmanagerview/projectmanagerview.h @@ -1,95 +1,95 @@ /* 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_PROJECTMANAGERVIEW_H #define KDEVPLATFORM_PLUGIN_PROJECTMANAGERVIEW_H #include #include #include class QModelIndex; class QAction; namespace Ui { class ProjectManagerView; } class ProjectProxyModel; class VcsOverlayProxyModel; namespace KDevelop { class ProjectBaseItem; class Path; } class ProjectManagerView; class ProjectManagerViewPlugin; //own subclass to the current view can be passed from ProjectManagetView to ProjectManagerViewPlugin class ProjectManagerViewItemContext : public KDevelop::ProjectItemContextImpl { public: ProjectManagerViewItemContext(const QList< KDevelop::ProjectBaseItem* >& items, ProjectManagerView *view); ProjectManagerView *view() const; private: ProjectManagerView *m_view; }; class ProjectManagerView: public QWidget { Q_OBJECT public: ProjectManagerView( ProjectManagerViewPlugin*, QWidget *parent ); ~ProjectManagerView() override; ProjectManagerViewPlugin* plugin() const { return m_plugin; } QList selectedItems() const; void selectItems(const QList &items); void expandItem(KDevelop::ProjectBaseItem *item); protected: bool eventFilter(QObject* obj, QEvent* event) override; -private slots: +private Q_SLOTS: void selectionChanged(); void locateCurrentDocument(); void updateSyncAction(); void open( const KDevelop::Path& ); void toggleHideTargets(bool hidden); private: QModelIndex indexFromView(const QModelIndex& index) const; QModelIndex indexToView(const QModelIndex& index) const; QAction* m_syncAction; QAction* m_toggleTargetsAction; Ui::ProjectManagerView* m_ui; QStringList m_cachedFileList; ProjectProxyModel* m_modelFilter; VcsOverlayProxyModel* m_overlayProxy; ProjectManagerViewPlugin* m_plugin; }; #endif // KDEVPLATFORM_PLUGIN_PROJECTMANAGERVIEW_H diff --git a/plugins/projectmanagerview/vcsoverlayproxymodel.h b/plugins/projectmanagerview/vcsoverlayproxymodel.h index 39b91d76a6..025ad53660 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 = nullptr); QVariant data(const QModelIndex& proxyIndex, int role = Qt::DisplayRole) const override; - private slots: + private Q_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/expandingtree/expandingwidgetmodel.h b/plugins/quickopen/expandingtree/expandingwidgetmodel.h index 6d00016d67..da14db51fc 100644 --- a/plugins/quickopen/expandingtree/expandingwidgetmodel.h +++ b/plugins/quickopen/expandingtree/expandingwidgetmodel.h @@ -1,167 +1,167 @@ /* This file is part of the KDE libraries and the Kate part. * * 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_EXPANDING_WIDGET_MODEL_H #define KDEVPLATFORM_PLUGIN_EXPANDING_WIDGET_MODEL_H #include #include #include class ExpandingDelegate; class ExpandingTree; class KWidget; class QTreeView; /** * Cares about expanding/un-expanding items in a tree-view together with ExpandingDelegate */ class ExpandingWidgetModel : public QAbstractTableModel { Q_OBJECT public: explicit ExpandingWidgetModel(QWidget* parent); virtual ~ExpandingWidgetModel(); enum ExpandingType { NotExpandable = 0, Expandable, Expanded }; ///The following three are convenience-functions for the current item that could be replaced by the later ones ///@return whether the current item can be expanded bool canExpandCurrentItem() const; ///@return whether the current item can be collapsed bool canCollapseCurrentItem() const; ///Expand/collapse the current item void setCurrentItemExpanded(bool); void clearMatchQualities(); ///Unexpand all rows and clear all cached information about them(this includes deleting the expanding-widgets) void clearExpanding(); ///@return whether the row given through index is expandable bool isExpandable(const QModelIndex& index) const; enum ExpansionType { NotExpanded = 0, ExpandDownwards, //The additional(expanded) information is shown UNDER the original information ExpandUpwards //The additional(expanded) information is shown ABOVE the original information }; ///Returns whether the given index is currently partially expanded. Does not do any other checks like calling models for data. ExpansionType isPartiallyExpanded(const QModelIndex& index) const; ///@return whether row is currently expanded bool isExpanded(const QModelIndex& row) const; ///Change the expand-state of the row given through index. The display will be updated. void setExpanded(const QModelIndex& index, bool expanded); ///Returns the total height added through all open expanding-widgets int expandingWidgetsHeight() const; ///@return the expanding-widget for the given row, if available. Expanding-widgets are in best case available for all expanded rows. ///This does not return the partially-expand widget. QWidget* expandingWidget(const QModelIndex& row) const; ///Amount by which the height of a row increases when it is partially expanded int partiallyExpandWidgetHeight() const; /** * Notifies underlying models that the item was selected, collapses any previous partially expanded line, * checks whether this line should be partially expanded, and eventually does it. * Does nothing when nothing needs to be done. * Does NOT show the expanding-widget. That is done immediately when painting by ExpandingDelegate, * to reduce flickering. @see showPartialExpandWidget() * @param row The row * */ /// virtual void rowSelected(const QModelIndex& row); /// Returns the rectangle for the partially expanded part of the given row /// TODO: Do this via QAIM roles? QRect partialExpandRect(const QModelIndex& row) const; /// TODO: Do this via QAIM roles? QString partialExpandText(const QModelIndex& row) const; ///Places and shows the expanding-widget for the given row, if it should be visible and is valid. ///Also shows the partial-expanding-widget when it should be visible. void placeExpandingWidget(const QModelIndex& row); virtual QTreeView* treeView() const = 0; ///Should return true if the given row should be painted like a contained item(as opposed to label-rows etc.) virtual bool indexIsItem(const QModelIndex& index) const = 0; ///Does not request data from index, this only returns local data like highlighting for expanded rows and similar QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const override; ///Returns the first row that is currently partially expanded. QModelIndex partiallyExpandedRow() const; ///Returns the match-color for the given index, or zero if match-quality could not be computed. uint matchColor(const QModelIndex& index) const; -public slots: +public Q_SLOTS: ///Place or hides all expanding-widgets to the correct positions. Should be called after the view was scrolled. void placeExpandingWidgets(); protected: /** * @return the context-match quality from 0 to 10 if it could be determined, else -1 * */ virtual int contextMatchQuality(const QModelIndex& index) const = 0; QModelIndex mapFromSource(const QModelIndex& index) const; QModelIndex mapToSource(const QModelIndex& index) const; //Makes sure m_expandedIcon and m_collapsedIcon are loaded void cacheIcons() const; static QIcon m_expandedIcon; static QIcon m_collapsedIcon; //Does not update the view void partiallyUnExpand(const QModelIndex& index); //Finds out the basic height of the row represented by the given index. Basic means without respecting any expansion. int basicRowHeight(const QModelIndex& index) const; private: friend ExpandingDelegate; friend ExpandingTree; QMap m_partiallyExpanded; // Store expanding-widgets and cache whether items can be expanded mutable QMap m_expandState; QMap > m_expandingWidgets; //Map rows to their expanding-widgets QMap m_contextMatchQualities; //Map rows to their context-match qualities(undefined if unknown, else 0 to 10). Not used yet, eventually remove. }; /** * Helper-function to merge custom-highlighting variant-lists. * * @param strings A list of strings that should be merged * @param highlights One variant-list for highlighting, as described in the kde header ktextedtor/codecompletionmodel.h * @param gapBetweenStrings How many signs are inserted between 2 strings? * */ QList mergeCustomHighlighting(QStringList strings, QList highlights, int gapBetweenStrings = 0); #endif diff --git a/plugins/quickopen/projectfilequickopen.h b/plugins/quickopen/projectfilequickopen.h index 5b46bab2bc..4c8fd2b877 100644 --- a/plugins/quickopen/projectfilequickopen.h +++ b/plugins/quickopen/projectfilequickopen.h @@ -1,147 +1,147 @@ /* 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_FILE_QUICKOPEN #define PROJECT_FILE_QUICKOPEN #include #include #include #include namespace KDevelop { class IProject; class ProjectFileItem; } /** * Internal data class for the BaseFileDataProvider and ProjectFileData. */ struct ProjectFile { ProjectFile() : outsideOfProject(false) {} KDevelop::Path path; // project root folder url KDevelop::Path projectPath; // indexed url - only set for project files // currently open documents don't use this! KDevelop::IndexedString indexedPath; // true for files which reside outside of the project root // this happens e.g. for generated files in out-of-source build folders bool outsideOfProject; }; inline bool operator<(const ProjectFile& left, const ProjectFile& right) { if (left.outsideOfProject != right.outsideOfProject) { return !left.outsideOfProject; } return left.path < right.path; } Q_DECLARE_TYPEINFO(ProjectFile, Q_MOVABLE_TYPE); /** * The shared data class that is used by the quick open model. */ class ProjectFileData : public KDevelop::QuickOpenDataBase { public: explicit ProjectFileData(const ProjectFile& file); QString text() const override; QString htmlDescription() const override; bool execute(QString& filterText) override; bool isExpandable() const override; QWidget* expandingWidget() const override; QIcon icon() const override; QList highlighting() const override; QString project() const; KDevelop::Path projectPath() const; private: ProjectFile m_file; }; class BaseFileDataProvider : public KDevelop::QuickOpenDataProviderBase , public KDevelop::PathFilter , public KDevelop::QuickOpenFileSetInterface { Q_OBJECT public: BaseFileDataProvider(); void setFilterText(const QString& text) override; uint itemCount() const override; uint unfilteredItemCount() const override; KDevelop::QuickOpenDataPointer data(uint row) const override; inline KDevelop::Path itemPath(const ProjectFile& data) const { return data.path; } }; /** * QuickOpen data provider for file-completion using project-files. * * It provides all files from all open projects except currently opened ones. */ class ProjectFileDataProvider : public BaseFileDataProvider { Q_OBJECT public: ProjectFileDataProvider(); void reset() override; QSet files() const override; -private slots: +private Q_SLOTS: void projectClosing(KDevelop::IProject*); void projectOpened(KDevelop::IProject*); void fileAddedToSet(KDevelop::ProjectFileItem*); void fileRemovedFromSet(KDevelop::ProjectFileItem*); private: // project files sorted by their url // this is done so we can limit ourselves to a relatively fast // filtering without any expensive sorting in reset(). QList m_projectFiles; }; /** * Quick open data provider for currently opened documents. */ class OpenFilesDataProvider : public BaseFileDataProvider { Q_OBJECT public: void reset() override; QSet files() const override; }; #endif diff --git a/plugins/quickopen/quickopenmodel.h b/plugins/quickopen/quickopenmodel.h index 5d5f529639..396c4c9fcb 100644 --- a/plugins/quickopen/quickopenmodel.h +++ b/plugins/quickopen/quickopenmodel.h @@ -1,133 +1,133 @@ /* 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 KDEVPLATFORM_PLUGIN_QUICKOPENMODEL_H #define KDEVPLATFORM_PLUGIN_QUICKOPENMODEL_H #include #include #include #include #include #include "expandingtree/expandingwidgetmodel.h" class QuickOpenModel : public ExpandingWidgetModel { Q_OBJECT public: explicit QuickOpenModel(QWidget* parent); void registerProvider(const QStringList& scopes, const QStringList& type, KDevelop::QuickOpenDataProviderBase* provider); /** * Remove provider. * @param provider The provider to remove * @return Whether a provider was removed. If false, the provider was not attached. * */ bool removeProvider(KDevelop::QuickOpenDataProviderBase* provider); ///Returns a list of all scopes that a registered through some providers QStringList allScopes() const; ///Returns a list of all types that a registered through some providers QStringList allTypes() const; /** * @param items The list of items that should be used. * @param scopes The list of scopes that should be used. * When this is called, the state is restart()ed. * */ void enableProviders(const QStringList& items, const QStringList& scopes); ///Reset all providers, unexpand everything, empty caches. void restart(bool keepFilterText = false); QModelIndex index(int, int, const QModelIndex& parent) const override; QModelIndex parent(const QModelIndex&) const override; int rowCount(const QModelIndex&) const override; int unfilteredRowCount() const; int columnCount() const; int columnCount(const QModelIndex&) const override; QVariant data(const QModelIndex&, int) const override; /** * Tries to execute the item currently selected. * Returns true if the quickopen-dialog should be closed. * @param filterText Should be the current content of the filter line-edit. * * If this returns false, and filterText was changed, the change must be put * into the line-edit. That way items may execute by changing the content * of the line-edit. * */ bool execute(const QModelIndex& index, QString& filterText); //The expandingwidgetmodel needs access to the tree-view void setTreeView(QTreeView* view); QTreeView* treeView() const override; virtual QSet fileSet() const; ///This value will be added to the height of all created expanding-widgets void setExpandingWidgetHeightIncrease(int pixels); -public slots: +public Q_SLOTS: void textChanged(const QString& str); -private slots: +private Q_SLOTS: void destroyed(QObject* obj); void resetTimer(); void restart_internal(bool keepFilterText); private: bool indexIsItem(const QModelIndex& index) const override; int contextMatchQuality(const QModelIndex& index) const override; KDevelop::QuickOpenDataPointer getItem(int row, bool noReset = false) const; typedef QHash DataList; mutable DataList m_cachedData; QTreeView* m_treeView; QTimer* m_resetTimer; struct ProviderEntry { ProviderEntry() : enabled(false) { } bool enabled; QSet scopes; QSet types; KDevelop::QuickOpenDataProviderBase* provider; }; //typedef QMultiMap< QString, ProviderEntry > ProviderMap; typedef QList ProviderList; QList m_providers; QString m_filterText; int m_expandingWidgetHeightIncrease; mutable int m_resetBehindRow; QSet m_enabledItems; QSet m_enabledScopes; }; #endif diff --git a/plugins/quickopen/quickopenplugin.h b/plugins/quickopen/quickopenplugin.h index 5572139b4e..e088f4fd01 100644 --- a/plugins/quickopen/quickopenplugin.h +++ b/plugins/quickopen/quickopenplugin.h @@ -1,168 +1,168 @@ /* * This file is part of KDevelop * * Copyright 2007 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_QUICKOPENPLUGIN_H #define KDEVPLATFORM_PLUGIN_QUICKOPENPLUGIN_H #include #include #include #include #include class QAction; namespace KTextEditor { class Cursor; } class QuickOpenModel; class QuickOpenWidget; class QuickOpenLineEdit; class QuickOpenPlugin : public KDevelop::IPlugin , public KDevelop::IQuickOpen { Q_OBJECT Q_INTERFACES(KDevelop::IQuickOpen) public: explicit QuickOpenPlugin(QObject* parent, const QVariantList& = QVariantList()); ~QuickOpenPlugin() override; static QuickOpenPlugin* self(); // KDevelop::Plugin methods void unload() override; KDevelop::ContextMenuExtension contextMenuExtension(KDevelop::Context* context) override; enum ModelTypes { Files = 1, Functions = 2, Classes = 4, OpenFiles = 8, All = Files + Functions + Classes + OpenFiles }; /** * Shows the quickopen dialog with the specified Model-types * @param modes A combination of ModelTypes * */ void showQuickOpen(ModelTypes modes = All); void showQuickOpen(const QStringList& items) override; void registerProvider(const QStringList& scope, const QStringList& type, KDevelop::QuickOpenDataProviderBase* provider) override; bool removeProvider(KDevelop::QuickOpenDataProviderBase* provider) override; QSet fileSet() const override; //Frees the model by closing active quickopen dialoags, and retuns whether successful. bool freeModel(); void createActionsForMainWindow(Sublime::MainWindow* window, QString& xmlFile, KActionCollection& actions) override; QuickOpenLineEdit* createQuickOpenLineWidget(); KDevelop::IQuickOpenLine* createQuickOpenLine(const QStringList& scopes, const QStringList& type, QuickOpenType kind) override; -public slots: +public Q_SLOTS: void quickOpen(); void quickOpenFile(); void quickOpenFunction(); void quickOpenClass(); void quickOpenDeclaration(); void quickOpenOpenFile(); void quickOpenDefinition(); void quickOpenNavigateFunctions(); void quickOpenDocumentation(); void quickOpenActions(); void previousFunction(); void nextFunction(); -private slots: +private Q_SLOTS: void storeScopes(const QStringList&); void storeItems(const QStringList&); private: friend class QuickOpenLineEdit; friend class StandardQuickOpenWidgetCreator; QuickOpenLineEdit* quickOpenLine(QString name = QStringLiteral( "Quickopen" )); enum FunctionJumpDirection { NextFunction, PreviousFunction }; void jumpToNearestFunction(FunctionJumpDirection direction); QPair specialObjectJumpPosition() const; QWidget* specialObjectNavigationWidget() const; bool jumpToSpecialObject(); void showQuickOpenWidget(const QStringList& items, const QStringList& scopes, bool preselectText); QuickOpenModel* m_model; class ProjectFileDataProvider* m_projectFileData; class ProjectItemDataProvider* m_projectItemData; class OpenFilesDataProvider* m_openFilesData; class DocumentationQuickOpenProvider* m_documentationItemData; class ActionsQuickOpenProvider* m_actionsItemData; QStringList lastUsedScopes; QStringList lastUsedItems; //We can only have one widget at a time, because we manipulate the model. QPointer m_currentWidgetHandler; QAction* m_quickOpenDeclaration; QAction* m_quickOpenDefinition; }; class QuickOpenWidgetCreator; class QuickOpenLineEdit : public KDevelop::IQuickOpenLine { Q_OBJECT public: explicit QuickOpenLineEdit(QuickOpenWidgetCreator* creator); ~QuickOpenLineEdit() override; bool insideThis(QObject* object); void showWithWidget(QuickOpenWidget* widget); void setDefaultText(const QString& text) override { m_defaultText = text; setPlaceholderText(m_defaultText); } -private slots: +private Q_SLOTS: void activate(); void deactivate(); void checkFocus(); void widgetDestroyed(QObject*); private: void focusInEvent(QFocusEvent* ev) override; bool eventFilter(QObject* obj, QEvent* e) override; void hideEvent(QHideEvent*) override; QPointer m_widget; bool m_forceUpdate; QString m_defaultText; QuickOpenWidgetCreator* m_widgetCreator; }; #endif // KDEVPLATFORM_PLUGIN_QUICKOPENPLUGIN_H diff --git a/plugins/quickopen/quickopenwidget.h b/plugins/quickopen/quickopenwidget.h index 78d44f0cbd..730819d529 100644 --- a/plugins/quickopen/quickopenwidget.h +++ b/plugins/quickopen/quickopenwidget.h @@ -1,120 +1,120 @@ /* * This file is part of KDevelop * * Copyright 2007 David Nolden * Copyright 2016 Kevin Funk * * 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_QUICKOPENWIDGET_H #define KDEVPLATFORM_PLUGIN_QUICKOPENWIDGET_H #include "ui_quickopenwidget.h" #include #include #include class QuickOpenModel; class QAbstractProxyModel; class QLineEdit; /// Will delete itself once the dialog is closed, so use QPointer when referencing it permanently class QuickOpenWidget : public QMenu { Q_OBJECT public: /** * @param initialItems List of items that should initially be enabled in the quickopen-list. If empty, all are enabled. * @param initialScopes List of scopes that should initially be enabled in the quickopen-list. If empty, all are enabled. * @param listOnly when this is true, the given items will be listed, but all filtering using checkboxes is disabled. * @param noSearchField when this is true, no search-line is shown. * */ QuickOpenWidget(QString title, QuickOpenModel* model, const QStringList& initialItems, const QStringList& initialScopes, bool listOnly = false, bool noSearchField = false); ~QuickOpenWidget() override; void setPreselectedText(const QString& text); void prepareShow(); void setAlternativeSearchField(QLineEdit* alterantiveSearchField); bool sortingEnabled() const; void setSortingEnabled(bool enabled); //Shows OK + Cancel. By default they are hidden void showStandardButtons(bool show); void showSearchField(bool show); -signals: +Q_SIGNALS: void scopesChanged(const QStringList& scopes); void itemsChanged(const QStringList& scopes); void ready(); -private slots: +private Q_SLOTS: void callRowSelected(); void updateTimerInterval(bool cheapFilterChange); void accept(); void textChanged(const QString& str); void updateProviders(); void doubleClicked (const QModelIndex& index); void applyFilter(); private: void showEvent(QShowEvent*) override; bool eventFilter (QObject* watched, QEvent* event) override; void avoidMenuAltFocus(); QuickOpenModel* m_model; QAbstractProxyModel* m_proxy = nullptr; bool m_sortingEnabled = false; bool m_expandedTemporary, m_hadNoCommandSinceAlt; QTime m_altDownTime; QString m_preselectedText; QTimer m_filterTimer; QString m_filter; public: Ui::QuickOpenWidget ui; friend class QuickOpenWidgetDialog; friend class QuickOpenPlugin; friend class QuickOpenLineEdit; }; class QuickOpenWidgetDialog : public QObject { Q_OBJECT public: QuickOpenWidgetDialog(QString title, QuickOpenModel* model, const QStringList& initialItems, const QStringList& initialScopes, bool listOnly = false, bool noSearchField = false); ~QuickOpenWidgetDialog() override; /// Shows the dialog void run(); QuickOpenWidget* widget() const { return m_widget; } private: QDialog* m_dialog; /// @warning m_dialog is also the parent QuickOpenWidget* m_widget; }; #endif diff --git a/plugins/quickopen/tests/bench_quickopen.h b/plugins/quickopen/tests/bench_quickopen.h index 94a9291327..9e3255ff3c 100644 --- a/plugins/quickopen/tests/bench_quickopen.h +++ b/plugins/quickopen/tests/bench_quickopen.h @@ -1,47 +1,47 @@ /* * 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 = nullptr); private: void getData(); -private slots: +private Q_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 a7fc1752ed..3c6bba1247 100644 --- a/plugins/quickopen/tests/quickopentestbase.h +++ b/plugins/quickopen/tests/quickopentestbase.h @@ -1,85 +1,85 @@ /* * 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 = nullptr); -private slots: +private Q_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 ec66b125d1..da8bcb9b7a 100644 --- a/plugins/quickopen/tests/test_quickopen.h +++ b/plugins/quickopen/tests/test_quickopen.h @@ -1,43 +1,43 @@ /* * 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 = nullptr); -private slots: +private Q_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/outputwidget.h b/plugins/standardoutputview/outputwidget.h index a23cf87e0d..2bd324dd74 100644 --- a/plugins/standardoutputview/outputwidget.h +++ b/plugins/standardoutputview/outputwidget.h @@ -1,120 +1,120 @@ /* 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 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_OUTPUTWIDGET_H #define KDEVPLATFORM_PLUGIN_OUTPUTWIDGET_H #include #include #include #include #include class KToggleAction; class StandardOutputViewTest; class QAction; class QAbstractItemView; class QLineEdit; class QModelIndex; class QSortFilterProxyModel; class QStackedWidget; class QString; class QTabWidget; class QToolButton; class QTreeView; class QWidgetAction; class ToolViewData; class OutputWidget : public QWidget, public KDevelop::IToolViewActionListener { Q_OBJECT Q_INTERFACES(KDevelop::IToolViewActionListener) friend class StandardOutputViewTest; public: OutputWidget(QWidget* parent, const ToolViewData* data); void removeOutput( int id ); void raiseOutput( int id ); public Q_SLOTS: void addOutput( int id ); void changeModel( int id ); void changeDelegate( int id ); void closeActiveView(); void closeOtherViews(); void selectFirstItem(); void selectNextItem() override; void selectPreviousItem() override; void selectLastItem(); void activate(const QModelIndex&); void scrollToIndex( const QModelIndex& ); void setTitle(int outputId, const QString& title); Q_SIGNALS: void outputRemoved( int, int ); -private slots: +private Q_SLOTS: void nextOutput(); void previousOutput(); void copySelection(); void selectAll(); void outputFilter(const QString& filter); void updateFilter(int index); void clearModel(); private: enum SelectionMode { Last, Next, Previous, First }; void selectItem(SelectionMode selectionMode); QTreeView* createListView(int id); void setCurrentWidget( QTreeView* view ); QWidget* currentWidget() const; void enableActions(); KDevelop::IOutputViewModel* outputViewModel() const; QAbstractItemView* outputView() const; void activateIndex(const QModelIndex& index, QAbstractItemView* view, KDevelop::IOutputViewModel* iface); void eventuallyDoFocus(); int currentOutputIndex(); QMap m_views; QMap m_proxyModels; QMap m_filters; QTabWidget* m_tabwidget; QStackedWidget* m_stackwidget; const ToolViewData* data; QToolButton* m_closeButton; QAction* m_closeOthersAction; QAction* m_nextAction; QAction* m_previousAction; KToggleAction* m_activateOnSelect; KToggleAction* m_focusOnSelect; QLineEdit * m_filterInput; QWidgetAction* m_filterAction; }; #endif diff --git a/plugins/standardoutputview/tests/test_standardoutputview.h b/plugins/standardoutputview/tests/test_standardoutputview.h index 34948febad..7804f9618e 100644 --- a/plugins/standardoutputview/tests/test_standardoutputview.h +++ b/plugins/standardoutputview/tests/test_standardoutputview.h @@ -1,64 +1,64 @@ /* Copyright (C) 2011 Silvère Lestang 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_TEST_STANDARDOUTPUTVIEW_H #define KDEVPLATFORM_PLUGIN_TEST_STANDARDOUTPUTVIEW_H #include #include namespace KDevelop { class TestCore; class IOutputView; } namespace Sublime { class View; class Controller; } class OutputWidget; class StandardOutputViewTest: public QObject { Q_OBJECT private: OutputWidget* toolviewPointer(QString toolviewTitle); KDevelop::TestCore* m_testCore; KDevelop::IOutputView* m_stdOutputView; KDevelop::UiController* m_controller; int toolviewId; int outputId[5]; static const QString toolviewTitle; -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void testRegisterAndRemoveToolView(); void testActions(); void testRegisterAndRemoveOutput(); void testSetModelAndDelegate(); void testStandardToolViews(); void testStandardToolViews_data(); }; #endif // KDEVPLATFORM_PLUGIN_TEST_STANDARDOUTPUTVIEW_H diff --git a/plugins/standardoutputview/toolviewdata.h b/plugins/standardoutputview/toolviewdata.h index 29e70f57b5..6153537da7 100644 --- a/plugins/standardoutputview/toolviewdata.h +++ b/plugins/standardoutputview/toolviewdata.h @@ -1,78 +1,78 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2008 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_TOOLVIEWDATA_H #define KDEVPLATFORM_PLUGIN_TOOLVIEWDATA_H #include #include #include namespace Sublime { class View; } class QAbstractItemModel; class StandardOutputView; class ToolViewData; class OutputData : public QObject { Q_OBJECT public: explicit OutputData( ToolViewData* tv ); QAbstractItemDelegate* delegate; QAbstractItemModel* model; ToolViewData* toolView; KDevelop::IOutputView::Behaviours behaviour; QString title; int id; void setModel( QAbstractItemModel* model ); void setDelegate( QAbstractItemDelegate* delegate ); -signals: +Q_SIGNALS: void modelChanged( int ); void delegateChanged( int ); }; class ToolViewData : public QObject { Q_OBJECT public: explicit ToolViewData( QObject* parent ); ~ToolViewData() override; OutputData* addOutput( int id, const QString& title, KDevelop::IOutputView::Behaviours behave ); // If we would adhere to model-view-separation strictly, then this member would move into standardoutputview, but it is more convenient this way. // TODO: move into standardoutputview mutable QList views; StandardOutputView* plugin; QMap outputdata; KDevelop::IOutputView::ViewType type; QString title; QIcon icon; int toolViewId; KDevelop::IOutputView::Options option; QList actionList; -signals: +Q_SIGNALS: void outputAdded( int ); }; #endif diff --git a/plugins/subversion/svnblamejob.h b/plugins/subversion/svnblamejob.h index 5408ee1c7b..335e1a2a7a 100644 --- a/plugins/subversion/svnblamejob.h +++ b/plugins/subversion/svnblamejob.h @@ -1,55 +1,55 @@ /*************************************************************************** * 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_H #define KDEVPLATFORM_PLUGIN_SVNBLAMEJOB_H #include "svnjobbase.h" #include #include #include #include class SvnInternalBlameJob; class SvnBlameJob : public SvnJobBaseImpl { Q_OBJECT public: explicit SvnBlameJob( KDevSvnPlugin* parent ); QVariant fetchResults() override; void start() override; void setLocation( const QUrl &location ); void setEndRevision( const KDevelop::VcsRevision& rev ); void setStartRevision( const KDevelop::VcsRevision& rev ); -private slots: +private Q_SLOTS: void blameLineReceived( const KDevelop::VcsAnnotationLine& ); private: QList m_annotations; }; #endif diff --git a/plugins/subversion/svnblamejob_p.h b/plugins/subversion/svnblamejob_p.h index 734a696aad..1bbafe697e 100644 --- a/plugins/subversion/svnblamejob_p.h +++ b/plugins/subversion/svnblamejob_p.h @@ -1,58 +1,58 @@ /*************************************************************************** * 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 namespace KDevelop { class VcsAnnotationLine; } class QUrl; class SvnInternalBlameJob : public SvnInternalJobBase { Q_OBJECT public: 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: +Q_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.h b/plugins/subversion/svncatjob.h index 0bc7805f43..9f08c06e1d 100644 --- a/plugins/subversion/svncatjob.h +++ b/plugins/subversion/svncatjob.h @@ -1,52 +1,52 @@ /*************************************************************************** * 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_H #define KDEVPLATFORM_PLUGIN_SVNCATJOB_H #include "svnjobbase.h" namespace KDevelop { class VcsRevision; } class SvnInternalCatJob; class SvnCatJob : public SvnJobBaseImpl { Q_OBJECT public: explicit SvnCatJob( KDevSvnPlugin* parent ); QVariant fetchResults() override; void start() override; void setSource( const KDevelop::VcsLocation& ); void setPegRevision( const KDevelop::VcsRevision& ); void setSrcRevision( const KDevelop::VcsRevision& ); -public slots: +public Q_SLOTS: void setContent( const QString& ); private: QString m_content; }; #endif diff --git a/plugins/subversion/svncatjob_p.h b/plugins/subversion/svncatjob_p.h index dff4fd67b5..39433a9364 100644 --- a/plugins/subversion/svncatjob_p.h +++ b/plugins/subversion/svncatjob_p.h @@ -1,52 +1,52 @@ /*************************************************************************** * 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 class SvnInternalCatJob : public SvnInternalJobBase { Q_OBJECT public: 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: +Q_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/svnclient.h b/plugins/subversion/svnclient.h index e50bd19892..327bee905b 100644 --- a/plugins/subversion/svnclient.h +++ b/plugins/subversion/svnclient.h @@ -1,67 +1,67 @@ /*************************************************************************** * 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 "kdevsvncpp/path.hpp" #include "kdevsvncpp/revision.hpp" #include "kdevsvncpp/client.hpp" #include class SvnClient : public QObject, public svn::Client { Q_OBJECT public: 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: +Q_SIGNALS: void logEventReceived( const KDevelop::VcsEvent& ); private: svn::Context* m_ctxt; }; #endif diff --git a/plugins/subversion/svndiffjob.h b/plugins/subversion/svndiffjob.h index 1a4e5ae78c..f98cd61c22 100644 --- a/plugins/subversion/svndiffjob.h +++ b/plugins/subversion/svndiffjob.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_H #define KDEVPLATFORM_PLUGIN_SVNDIFFJOB_H #include "svnjobbase.h" #include #include class SvnCatJob; namespace KDevelop { class VcsRevision; } class SvnInternalDiffJob; class SvnDiffJob : public SvnJobBaseImpl { Q_OBJECT public: explicit SvnDiffJob( KDevSvnPlugin* parent ); QVariant fetchResults() override; void start() override; void setSource( const KDevelop::VcsLocation& ); void setDestination( const KDevelop::VcsLocation& ); void setPegRevision( const KDevelop::VcsRevision& ); void setSrcRevision( const KDevelop::VcsRevision& ); void setDstRevision( const KDevelop::VcsRevision& ); void setRecursive( bool ); void setIgnoreAncestry( bool ); void setIgnoreContentType( bool ); void setNoDiffOnDelete( bool ); void setDiffType( KDevelop::VcsDiff::Type type ); -public slots: +public Q_SLOTS: void setDiff( const QString& ); void addLeftText( KDevelop::VcsJob* job ); void removeJob( KJob* job ); private: KDevelop::VcsDiff m_diff; KDevelop::VcsDiff::Type m_diffType; QMap m_catJobMap; }; #endif diff --git a/plugins/subversion/svndiffjob_p.h b/plugins/subversion/svndiffjob_p.h index 80f7a9b93b..d91aca3023 100644 --- a/plugins/subversion/svndiffjob_p.h +++ b/plugins/subversion/svndiffjob_p.h @@ -1,70 +1,70 @@ /*************************************************************************** * 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 class SvnInternalDiffJob : public SvnInternalJobBase { Q_OBJECT public: 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: +Q_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/svninfojob.h b/plugins/subversion/svninfojob.h index bb18edf2d8..eb69b85093 100644 --- a/plugins/subversion/svninfojob.h +++ b/plugins/subversion/svninfojob.h @@ -1,91 +1,91 @@ /*************************************************************************** * 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_H #define KDEVPLATFORM_PLUGIN_SVNINFOJOB_H #include "svnjobbase.h" #include #include #include class SvnInternalInfoJob; /// A structure which describes various system-generated metadata about /// a working-copy path or URL. class SvnInfoHolder { public: QString name; QUrl url; qlonglong rev; int kind; QUrl repoUrl; QString repouuid; qlonglong lastChangedRev; QDateTime lastChangedDate; QString lastChangedAuthor; int scheduled; QUrl copyFromUrl; qlonglong copyFromRevision; QDateTime textTime; QDateTime propertyTime; QString oldFileConflict; QString newFileConflict; QString workingCopyFileConflict; QString propertyRejectFile; }; /// This is an svn internal class, it shouldn't be used outside of the svn /// plugin class SvnInfoJob : public SvnJobBaseImpl { Q_OBJECT public: enum ProvideInformationType { AllInfo, RevisionOnly, RepoUrlOnly }; explicit SvnInfoJob( KDevSvnPlugin* parent ); QVariant fetchResults() override; void start() override; void setLocation( const QUrl &location ); void setProvideInformation( ProvideInformationType ); void setProvideRevisionType( KDevelop::VcsRevision::RevisionType ); -public slots: +public Q_SLOTS: void setInfo( const SvnInfoHolder& ); private: SvnInfoHolder m_info; ProvideInformationType m_provideInfo; KDevelop::VcsRevision::RevisionType m_provideRevisionType; }; Q_DECLARE_METATYPE( SvnInfoHolder ) #endif diff --git a/plugins/subversion/svninfojob_p.h b/plugins/subversion/svninfojob_p.h index 6a2df8896e..473e4d1c2b 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 = nullptr ); void setLocation( const QUrl& ); QUrl location() const; -signals: +Q_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 8d40856626..005e644686 100644 --- a/plugins/subversion/svninternaljobbase.h +++ b/plugins/subversion/svninternaljobbase.h @@ -1,127 +1,127 @@ /*************************************************************************** * 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 extern "C" { #include } #include "kdevsvncpp/context_listener.hpp" namespace KDevelop { class VcsRevision; } namespace svn { class Context; class Revision; } class SvnJobBase; class SvnInternalJobBase : public QObject, public ThreadWeaver::Job, public svn::ContextListener { Q_OBJECT public: 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: +Q_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/svnjobbase.h b/plugins/subversion/svnjobbase.h index 05ae31c282..6b79acf727 100644 --- a/plugins/subversion/svnjobbase.h +++ b/plugins/subversion/svnjobbase.h @@ -1,90 +1,90 @@ /*************************************************************************** * 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_SVNJOBBASE_H #define KDEVPLATFORM_PLUGIN_SVNJOBBASE_H #include #include "kdevsvncpp/context_listener.hpp" #include "kdevsvnplugin.h" #include "debug.h" #include extern "C" { #include } class SvnInternalJobBase; namespace ThreadWeaver { class Job; } class KDevSvnPlugin; class SvnJobBase : public KDevelop::VcsJob { Q_OBJECT public: explicit SvnJobBase( KDevSvnPlugin*, KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose ); ~SvnJobBase() override; virtual SvnInternalJobBase* internalJob() const = 0; KDevelop::VcsJob::JobStatus status() const override; KDevelop::IPlugin* vcsPlugin() const override; -public slots: +public Q_SLOTS: void askForLogin( const QString& ); void showNotification( const QString&, const QString& ); void askForCommitMessage(); void askForSslServerTrust( const QStringList&, const QString&, const QString&, const QString&, const QString&, const QString&, const QString& ); void askForSslClientCert( const QString& ); void askForSslClientCertPassword( const QString& ); -protected slots: +protected Q_SLOTS: void internalJobStarted(); void internalJobDone(); void internalJobFailed(); protected: void startInternalJob(); bool doKill() override; KDevSvnPlugin* m_part; private: void outputMessage(const QString &message); KDevelop::VcsJob::JobStatus m_status; }; template class SvnJobBaseImpl : public SvnJobBase { public: explicit SvnJobBaseImpl(KDevSvnPlugin* plugin, KDevelop::OutputJob::OutputJobVerbosity verbosity = KDevelop::OutputJob::Verbose) : SvnJobBase(plugin, verbosity) { m_job = new InternalJobClass(this); } SvnInternalJobBase* internalJob() const override { return m_job; } protected: InternalJobClass* m_job = nullptr; }; #endif diff --git a/plugins/subversion/svnlogjob.h b/plugins/subversion/svnlogjob.h index 64070333de..4abf590571 100644 --- a/plugins/subversion/svnlogjob.h +++ b/plugins/subversion/svnlogjob.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_SVNLOGJOB_H #define KDEVPLATFORM_PLUGIN_SVNLOGJOB_H #include "svnjobbase.h" #include #include #include #include class SvnInternalLogJob; class SvnLogJob : public SvnJobBaseImpl { Q_OBJECT public: explicit SvnLogJob( KDevSvnPlugin* parent ); QVariant fetchResults() override; void start() override; void setLocation( const QUrl &location ); void setLimit( int limit ); void setEndRevision( const KDevelop::VcsRevision& rev ); void setStartRevision( const KDevelop::VcsRevision& rev ); -private slots: +private Q_SLOTS: void logEventReceived( const KDevelop::VcsEvent& ); private: QList m_eventList; }; #endif diff --git a/plugins/subversion/svnlogjob_p.h b/plugins/subversion/svnlogjob_p.h index 4f9d3f4e2d..cfe95d235f 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 = 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: +Q_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/svnssldialog.h b/plugins/subversion/svnssldialog.h index 50d51f645c..a8dd3bb67b 100644 --- a/plugins/subversion/svnssldialog.h +++ b/plugins/subversion/svnssldialog.h @@ -1,38 +1,38 @@ /*************************************************************************** * 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 class QDialogButtonBox; class QAbstractButton; class SvnSSLTrustDialog: public QDialog { Q_OBJECT public: 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: +private Q_SLOTS: void buttonClicked(QAbstractButton *button); private: class SvnSSLTrustDialogPrivate *d; QDialogButtonBox *buttonBox; }; #endif diff --git a/plugins/subversion/svnstatusjob.h b/plugins/subversion/svnstatusjob.h index db584c3cca..a01b9a4030 100644 --- a/plugins/subversion/svnstatusjob.h +++ b/plugins/subversion/svnstatusjob.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_SVNSTATUSJOB_H #define KDEVPLATFORM_PLUGIN_SVNSTATUSJOB_H #include "svnjobbase.h" #include #include class SvnInternalStatusJob; class SvnStatusJob : public SvnJobBaseImpl { Q_OBJECT public: explicit SvnStatusJob( KDevSvnPlugin* parent ); QVariant fetchResults() override; void start() override; void setLocations( const QList& locations ); void setRecursive( bool ); -public slots: +public Q_SLOTS: void addToStats( const KDevelop::VcsStatusInfo& ); private: QList m_stats; }; #endif diff --git a/plugins/subversion/svnstatusjob_p.h b/plugins/subversion/svnstatusjob_p.h index 7df29b0165..dde2582077 100644 --- a/plugins/subversion/svnstatusjob_p.h +++ b/plugins/subversion/svnstatusjob_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_SVNSTATUSJOB_P_H #define KDEVPLATFORM_PLUGIN_SVNSTATUSJOB_P_H #include "svninternaljobbase.h" #include #include class SvnInternalStatusJob : public SvnInternalJobBase { Q_OBJECT public: explicit SvnInternalStatusJob( SvnJobBase* parent = nullptr ); void setLocations( const QList& ); void setRecursive( bool ); bool recursive() const; QList locations() const; -signals: +Q_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/tests/test_svnimport.h b/plugins/subversion/tests/test_svnimport.h index 2e1ac780f1..5ff51e2a97 100644 --- a/plugins/subversion/tests/test_svnimport.h +++ b/plugins/subversion/tests/test_svnimport.h @@ -1,47 +1,47 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2009 Fabian Wiesel * * * * 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_SVNIMPORT_H #define KDEVPLATFORM_PLUGIN_SVNIMPORT_H #include class QTemporaryDir; namespace KDevelop { class TestCore; class ICentralizedVersionControl; } class TestSvnImport : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void testBasic(); void testImportIntoDir(); void testImportWithMissingDirs(); private: void validateImport( const QString& repo, QTemporaryDir& checkout, const QString& origcontent ); KDevelop::ICentralizedVersionControl* vcs = nullptr; }; #endif // KDEVPLATFORM_PLUGIN_SVNRECURSIVEADD_H diff --git a/plugins/subversion/tests/test_svnrecursiveadd.h b/plugins/subversion/tests/test_svnrecursiveadd.h index 4873c20240..1b26441f63 100644 --- a/plugins/subversion/tests/test_svnrecursiveadd.h +++ b/plugins/subversion/tests/test_svnrecursiveadd.h @@ -1,36 +1,36 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2009 Fabian Wiesel * * * * 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_SVNRECURSIVEADD_H #define KDEVPLATFORM_PLUGIN_SVNRECURSIVEADD_H #include class TestSvnRecursiveAdd : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void test(); }; #endif // KDEVPLATFORM_PLUGIN_SVNRECURSIVEADD_H diff --git a/plugins/switchtobuddy/switchtobuddyplugin.h b/plugins/switchtobuddy/switchtobuddyplugin.h index ae631c92c4..0b81ffe1fa 100644 --- a/plugins/switchtobuddy/switchtobuddyplugin.h +++ b/plugins/switchtobuddy/switchtobuddyplugin.h @@ -1,86 +1,86 @@ /* * This file is part of KDevelop * Copyright 2012 André Stein * Copyright 2014 Kevin Funk * * 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_SWITCHTOBUDDY_H #define KDEVPLATFORM_PLUGIN_SWITCHTOBUDDY_H #include #include #include #include Q_DECLARE_LOGGING_CATEGORY(PLUGIN_SWITCHTOBUDDY) /** * @short Implements a context menu extension in an editor context which provides * an action that allows switching to associated buddy documents. * * Using the @c IBuddyDocumentFinder interface, the current document's * language plugin provides potential buddy candidates. Depending on their * existence on the file system the @c SwitchToBuddyPlugin * enables a 'Switch To XXX' action which opens that buddy document * using the @c IDocumentController. * * If a language plugin either doesn't provide the @c IBuddyDocumentFinder * interface or no buddy exists on the file system, no context menu * extension is performed. * * @see IBuddyDocumentFinder * @see IDocumentController */ class SwitchToBuddyPlugin : public KDevelop::IPlugin { Q_OBJECT public: explicit SwitchToBuddyPlugin( QObject *parent, const QVariantList & = QVariantList()); ~SwitchToBuddyPlugin() override; KDevelop::ContextMenuExtension contextMenuExtension(KDevelop::Context* context) override; void createActionsForMainWindow(Sublime::MainWindow* window, QString& xmlFile, KActionCollection& actions) override; -private slots: +private Q_SLOTS: /** * Context menu slot which switches to the QUrl provided * in the data part of the sending QAction. */ void switchToBuddy(const QString& url); /** * Switch between header and source files */ void switchHeaderSource(); /** * @brief Switch between definitions and declarations * * E.g. if the cursor in the currently active view points to an implementation file * this shortcut will open the header document (or any buddy file). * * Furthermore, if the cursor points to a definition, and the buddy document contains its declaration, * the cursor will be also set to the declaration's position when the buddy document is opened */ void switchDefinitionDeclaration(); private: class QSignalMapper* m_signalMapper; }; #endif // KDEVPLATFORM_PLUGIN_SWITCHTOBUDDY_H diff --git a/plugins/testview/testview.h b/plugins/testview/testview.h index b745dedc0a..82164d75d5 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 = nullptr); ~TestView() override; -public slots: +public Q_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/testview/testviewplugin.h b/plugins/testview/testviewplugin.h index 66fbde7062..901fd0ca57 100644 --- a/plugins/testview/testviewplugin.h +++ b/plugins/testview/testviewplugin.h @@ -1,46 +1,46 @@ /* 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_TESTVIEWPLUGIN_H #define KDEVPLATFORM_PLUGIN_TESTVIEWPLUGIN_H #include "interfaces/iplugin.h" #include class TestToolViewFactory; class TestViewPlugin : public KDevelop::IPlugin { Q_OBJECT public: explicit TestViewPlugin(QObject* parent, const QVariantList& args = QVariantList()); ~TestViewPlugin() override; void unload() override; private: TestToolViewFactory* m_viewFactory; -private slots: +private Q_SLOTS: void runAllTests(); void stopRunningTests(); void jobStateChanged(); }; #endif // KDEVPLATFORM_PLUGIN_TESTVIEWPLUGIN_H diff --git a/plugins/vcschangesview/vcschangesview.h b/plugins/vcschangesview/vcschangesview.h index 58492410d8..0dc1a2abb5 100644 --- a/plugins/vcschangesview/vcschangesview.h +++ b/plugins/vcschangesview/vcschangesview.h @@ -1,49 +1,49 @@ /* * 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 #include #include class VcsProjectIntegrationPlugin; namespace KDevelop { class IProject; } class VcsChangesView : public QTreeView { Q_OBJECT public: explicit VcsChangesView(VcsProjectIntegrationPlugin* plugin, QWidget* parent = nullptr); void setModel(QAbstractItemModel* model) override; - public slots: + public Q_SLOTS: void popupContextMenu( const QPoint &pos ); void selectCurrentDocument(); void openSelected(const QModelIndex& idx); - signals: + Q_SIGNALS: void reload(const QList& p); void reload(const QList& p); }; #endif // KDEVPLATFORM_PLUGIN_VCSCHANGESVIEW_H diff --git a/plugins/vcschangesview/vcschangesviewplugin.h b/plugins/vcschangesview/vcschangesviewplugin.h index ff9ad37167..61046ccc78 100644 --- a/plugins/vcschangesview/vcschangesviewplugin.h +++ b/plugins/vcschangesview/vcschangesviewplugin.h @@ -1,51 +1,51 @@ /* This file is part of KDevelop Copyright 2010 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_VCSPROJECTINTEGRATIONPLUGIN_H #define KDEVPLATFORM_PLUGIN_VCSPROJECTINTEGRATIONPLUGIN_H #include #include class QModelIndex; namespace KDevelop { class IProject; class IDocument; class ProjectChangesModel; } class VcsProjectIntegrationPlugin : public KDevelop::IPlugin { Q_OBJECT public: VcsProjectIntegrationPlugin(QObject *parent, const QVariantList & args); KDevelop::ProjectChangesModel* model(); - private slots: + private Q_SLOTS: void activated(const QModelIndex& idx); private: KDevelop::ProjectChangesModel* m_model; friend class VCSProjectToolViewFactory; // to access activated() slot }; #endif diff --git a/plugins/welcomepage/sessionsmodel.h b/plugins/welcomepage/sessionsmodel.h index 22b50d0f3d..74f2fc64ad 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 = 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: + private Q_SLOTS: void sessionDeleted(const QString& id); }; #endif // SESSIONSMODEL_H diff --git a/plugins/welcomepage/uihelper.h b/plugins/welcomepage/uihelper.h index 4fddaf7eb4..5868183196 100644 --- a/plugins/welcomepage/uihelper.h +++ b/plugins/welcomepage/uihelper.h @@ -1,40 +1,40 @@ /* 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 UIHELPER_H #define UIHELPER_H #include class QString; class QAction; class UiHelper : public QObject { Q_OBJECT public: explicit UiHelper(QObject* parent); - public slots: + public Q_SLOTS: QAction* retrieveMenuAction(const QString& name); void showMenu(const QString& name); void setArea(const QString& name); void raiseToolView(const QString& id); }; #endif // UIHELPER_H diff --git a/plugins/welcomepage/welcomepageview.h b/plugins/welcomepage/welcomepageview.h index 79f54189bc..0d5581eac2 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 = nullptr); -public slots: +public Q_SLOTS: void areaChanged(Sublime::Area* a); }; #endif // WELCOMEPAGEVIEW_H diff --git a/project/filemanagerlistjob.h b/project/filemanagerlistjob.h index fcd6547b1e..0d32c992c4 100644 --- a/project/filemanagerlistjob.h +++ b/project/filemanagerlistjob.h @@ -1,80 +1,80 @@ /* This file is part of KDevelop Copyright 2009 Radu Benea 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_FILEMANAGERLISTJOB_H #define KDEVPLATFORM_FILEMANAGERLISTJOB_H #include #include // uncomment to time imort jobs // #define TIME_IMPORT_JOB #ifdef TIME_IMPORT_JOB #include #endif namespace KDevelop { class ProjectFolderItem; class FileManagerListJob : public KIO::Job { Q_OBJECT public: explicit FileManagerListJob(ProjectFolderItem* item); ProjectFolderItem* item() const; void addSubDir(ProjectFolderItem* item); void removeSubDir(ProjectFolderItem* item); void abort(); void start() override; -signals: +Q_SIGNALS: void entries(FileManagerListJob* job, ProjectFolderItem* baseItem, const KIO::UDSEntryList& entries); void nextJob(); -private slots: +private Q_SLOTS: void slotEntries(KIO::Job* job, const KIO::UDSEntryList& entriesIn ); void slotResult(KJob* job) override; void handleResults(const KIO::UDSEntryList& entries); void startNextJob(); private: QQueue m_listQueue; /// current base dir ProjectFolderItem* m_item; KIO::UDSEntryList entryList; // kill does not delete the job instantaniously QAtomicInt m_aborted; #ifdef TIME_IMPORT_JOB QElapsedTimer m_timer; QElapsedTimer m_subTimer; qint64 m_subWaited = 0; #endif }; } #endif // KDEVPLATFORM_FILEMANAGERLISTJOB_H diff --git a/project/projectbuildsetmodel.h b/project/projectbuildsetmodel.h index c00fca12aa..3de788d7a1 100644 --- a/project/projectbuildsetmodel.h +++ b/project/projectbuildsetmodel.h @@ -1,93 +1,93 @@ /*************************************************************************** * 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_PROJECTBUILDSETMODEL_H #define KDEVPLATFORM_PROJECTBUILDSETMODEL_H #include "projectexport.h" #include #include namespace KDevelop { class ProjectBaseItem; class ICore; class IProject; class ISession; class KDEVPLATFORMPROJECT_EXPORT BuildItem { public: BuildItem(); explicit BuildItem( const QStringList& itemPath ); BuildItem( const BuildItem& rhs ); explicit BuildItem( KDevelop::ProjectBaseItem* ); void initializeFromItem( KDevelop::ProjectBaseItem* item ); KDevelop::ProjectBaseItem* findItem() const; BuildItem& operator=( const BuildItem& ); QString itemName() const; QStringList itemPath() const { return m_itemPath; } QString itemProject() const; private: QStringList m_itemPath; }; bool operator==( const BuildItem& rhs, const BuildItem& lhs ); class KDEVPLATFORMPROJECT_EXPORT ProjectBuildSetModel : public QAbstractTableModel { Q_OBJECT public: explicit ProjectBuildSetModel( QObject* parent ); QVariant data( const QModelIndex&, int role = Qt::DisplayRole ) const override; QVariant headerData( int, Qt::Orientation, int role = Qt::DisplayRole ) const override; int rowCount( const QModelIndex& = QModelIndex() ) const override; int columnCount( const QModelIndex& = QModelIndex() ) const override; void loadFromSession( ISession* session ); void storeToSession( ISession* session ); void addProjectItem( KDevelop::ProjectBaseItem* ); bool removeRows( int row, int count, const QModelIndex& parent = QModelIndex() ) override; void moveRowsUp( int row, int count ); void moveRowsDown( int row, int count ); void moveRowsToTop( int row, int count ); void moveRowsToBottom( int row, int count ); QList items(); -public slots: +public Q_SLOTS: void saveToProject( KDevelop::IProject* ) const; void loadFromProject( KDevelop::IProject* ); void projectClosed( KDevelop::IProject* ); private: QList m_items; QList< QStringList > m_orderingCache; int findInsertionPlace( const QStringList& itemPath ); void removeItemsWithCache( const QList& itemIndices ); void insertItemWithCache( const KDevelop::BuildItem& item ); void insertItemsOverrideCache( int index, const QList& items ); }; } #endif //kate: space-indent on; indent-width 4; replace-tabs on; auto-insert-doxygen on; indent-mode cstyle; diff --git a/project/projectchangesmodel.h b/project/projectchangesmodel.h index a43ae41299..1963448a0f 100644 --- a/project/projectchangesmodel.h +++ b/project/projectchangesmodel.h @@ -1,66 +1,66 @@ /* 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_PROJECTCHANGESMODEL_H #define KDEVPLATFORM_PROJECTCHANGESMODEL_H #include #include #include "projectexport.h" class KJob; namespace KDevelop { class IProject; class IDocument; class KDEVPLATFORMPROJECT_EXPORT ProjectChangesModel : public VcsFileChangesModel { Q_OBJECT public: enum Role { ProjectNameRole = LastItemRole+1 }; explicit ProjectChangesModel(QObject* parent); ~ProjectChangesModel() override; void updateState(KDevelop::IProject* p, const KDevelop::VcsStatusInfo& status); void changes(KDevelop::IProject* project, const QList& urls, KDevelop::IBasicVersionControl::RecursionMode mode); - public slots: + public Q_SLOTS: void reloadAll(); void reload(const QList& p); void reload(const QList& p); void addProject(KDevelop::IProject* p); void removeProject(KDevelop::IProject* p); void statusReady(KJob* job); void documentSaved(KDevelop::IDocument*); void itemsAdded(const QModelIndex& idx, int start, int end); void jobUnregistered(KJob*); void repositoryBranchChanged(const QUrl& url); void branchNameReady(KDevelop::VcsJob* job); private: QStandardItem* projectItem(KDevelop::IProject* p) const; }; } #endif // KDEVPLATFORM_PROJECTCHANGESMODEL_H diff --git a/project/projectitemlineedit.h b/project/projectitemlineedit.h index 6183815694..c08f484bfe 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=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: +public Q_SLOTS: bool selectItemDialog(); -private slots: +private Q_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/tests/projectmodelperformancetest.h b/project/tests/projectmodelperformancetest.h index a7230395e6..33c70faec7 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: explicit ProjectModelPerformanceTest(QWidget* parent = nullptr); ~ProjectModelPerformanceTest() override; -private slots: +private Q_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/project/tests/test_projectmodel.h b/project/tests/test_projectmodel.h index a98fd76a3d..6e1dc9946f 100644 --- a/project/tests/test_projectmodel.h +++ b/project/tests/test_projectmodel.h @@ -1,64 +1,64 @@ /*************************************************************************** * 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_TEST_PROJECTMODEL #define KDEVELOP_PROJECT_TEST_PROJECTMODEL #include #include class ProjectProxyModel; namespace KDevelop { class ProjectModel; } class ModelTest; class TestProjectModel : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void init(); void cleanupTestCase(); void testCreateFileSystemItems(); void testCreateFileSystemItems_data(); void testCreateTargetItems(); void testCreateTargetItems_data(); void testCreateSimpleHierarchy(); void testItemSanity(); void testRename(); void testRename_data(); void testChangeWithProxyModel(); void testWithProject(); void testTakeRow(); void testItemsForPath(); void testItemsForPath_data(); void testProjectProxyModel(); void testProjectFileSet(); void testProjectFileIcon(); private: KDevelop::ProjectModel* model; ProjectProxyModel* proxy; }; Q_DECLARE_METATYPE( QModelIndex ) #endif diff --git a/serialization/tests/bench_itemrepository.h b/serialization/tests/bench_itemrepository.h index ba9e44175b..3dc943148f 100644 --- a/serialization/tests/bench_itemrepository.h +++ b/serialization/tests/bench_itemrepository.h @@ -1,41 +1,41 @@ /* * This file is part of KDevelop * Copyright 2012-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 TESTITEMREPOSITORY_H #define TESTITEMREPOSITORY_H #include class TestItemRepository : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void insert(); void remove(); void removeDisk(); void lookupKey(); void lookupValue(); }; #endif // TESTITEMREPOSITORY_H diff --git a/serialization/tests/test_indexedstring.h b/serialization/tests/test_indexedstring.h index 951d6fb8c6..51a926daac 100644 --- a/serialization/tests/test_indexedstring.h +++ b/serialization/tests/test_indexedstring.h @@ -1,53 +1,53 @@ /* * This file is part of KDevelop * Copyright 2012-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 TESTINDEXEDSTRING_H #define TESTINDEXEDSTRING_H #include class TestIndexedString : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void testUrl_data(); void testUrl(); void bench_index(); void bench_length(); void bench_qstring(); void bench_kurl(); void bench_qhashQString(); void bench_qhashIndexedString(); void bench_hashString(); void bench_kdevhash(); void bench_qSet(); void test(); void test_data(); void testCString(); }; #endif // TESTINDEXEDSTRING_H diff --git a/serialization/tests/test_itemrepository.cpp b/serialization/tests/test_itemrepository.cpp index 963ad1581f..2d85671b63 100644 --- a/serialization/tests/test_itemrepository.cpp +++ b/serialization/tests/test_itemrepository.cpp @@ -1,358 +1,358 @@ #include #include #include #include #include #include #include #include struct TestItem { TestItem(uint hash, uint dataSize) : m_hash(hash), m_dataSize(dataSize) { } //Every item has to implement this function, and return a valid hash. //Must be exactly the same hash value as ExampleItemRequest::hash() has returned while creating the item. unsigned int hash() const { return m_hash; } //Every item has to implement this function, and return the complete size this item takes in memory. //Must be exactly the same value as ExampleItemRequest::itemSize() has returned while creating the item. unsigned int itemSize() const { return sizeof(TestItem) + m_dataSize; } bool equals(const TestItem* rhs) const { return rhs->m_hash == m_hash && itemSize() == rhs->itemSize() && memcmp((char*)this, rhs, itemSize()) == 0; } uint m_hash; uint m_dataSize; }; struct TestItemRequest { TestItem& m_item; bool m_compareData; TestItemRequest(TestItem& item, bool compareData = false) : m_item(item) , m_compareData(compareData) { } enum { AverageSize = 700 //This should be the approximate average size of an Item }; uint hash() const { return m_item.hash(); } //Should return the size of an item created with createItem size_t itemSize() const { return m_item.itemSize(); } void createItem(TestItem* item) const { memcpy(item, &m_item, m_item.itemSize()); } static void destroy(TestItem* /*item*/, KDevelop::AbstractItemRepository&) { //Nothing to do } static bool persistent(const TestItem* /*item*/) { return true; } //Should return whether the here requested item equals the given item bool equals(const TestItem* item) const { return hash() == item->hash() && (!m_compareData || m_item.equals(item)); } }; uint smallItemsFraction = 20; //Fraction of items betwen 0 and 1 kb uint largeItemsFraction = 1; //Fraction of items between 0 and 200 kb uint cycles = 100000; uint deletionProbability = 1; //Percentual probability that a checked item is deleted. Per-cycle probability must be multiplied with checksPerCycle. uint checksPerCycle = 10; TestItem* createItem(uint id, uint size) { TestItem* ret; char* data = new char[size]; uint dataSize = size - sizeof(TestItem); ret = new (data) TestItem(id, dataSize); //Fill in same random pattern for(uint a = 0; a < dataSize; ++a) data[sizeof(TestItem) + a] = (char)(a + id); return ret; } ///@todo Add a test where the complete content is deleted again, and make sure the result has a nice structure ///@todo More consistency and lost-space tests, especially about monster-buckets. Make sure their space is re-claimed class TestItemRepository : public QObject { Q_OBJECT - private slots: + private Q_SLOTS: void initTestCase() { KDevelop::AutoTestShell::init(); KDevelop::TestCore* core = new KDevelop::TestCore(); core->initialize(KDevelop::Core::NoUi); } void cleanupTestCase() { KDevelop::TestCore::shutdown(); } void testItemRepository() { KDevelop::ItemRepository repository(QStringLiteral("TestItemRepository")); uint itemId = 0; QHash realItemsByIndex; QHash realItemsById; uint totalInsertions = 0, totalDeletions = 0; uint maxSize = 0; uint totalSize = 0; srand(time(nullptr)); uint highestSeenIndex = 0; for(uint a = 0; a < cycles; ++a) { { //Insert an item uint itemDecision = rand() % (smallItemsFraction + largeItemsFraction); uint itemSize; if(itemDecision < largeItemsFraction) { //Create a large item: Up to 200kb itemSize = (rand() % 200000) + sizeof(TestItem); } else itemSize = (rand() % 1000) + sizeof(TestItem); TestItem* item = createItem(++itemId, itemSize); Q_ASSERT(item->hash() == itemId); QVERIFY(item->equals(item)); uint index = repository.index(TestItemRequest(*item)); if(index > highestSeenIndex) highestSeenIndex = index; Q_ASSERT(index); realItemsByIndex.insert(index, item); realItemsById.insert(itemId, item); ++totalInsertions; totalSize += itemSize; if(itemSize > maxSize) maxSize = itemSize; } for(uint a = 0; a < checksPerCycle; ++a) { //Check an item uint pick = rand() % itemId; if(realItemsById.contains(pick)) { uint index = repository.findIndex(*realItemsById[pick]); QVERIFY(index); QVERIFY(realItemsByIndex.contains(index)); QVERIFY(realItemsByIndex[index]->equals(repository.itemFromIndex(index))); if((uint) (rand() % 100) < deletionProbability) { ++totalDeletions; //Delete the item repository.deleteItem(index); QVERIFY(!repository.findIndex(*realItemsById[pick])); uint newIndex = repository.index(*realItemsById[pick]); QVERIFY(newIndex); QVERIFY(realItemsByIndex[index]->equals(repository.itemFromIndex(newIndex))); #ifdef POSITION_TEST //Since we have previously deleted the item, there must be enough space if(!((newIndex >> 16) <= (highestSeenIndex >> 16))) { qDebug() << "size:" << realItemsById[pick]->itemSize(); qDebug() << "previous highest seen bucket:" << (highestSeenIndex >> 16); qDebug() << "new bucket:" << (newIndex >> 16); } QVERIFY((newIndex >> 16) <= (highestSeenIndex >> 16)); #endif repository.deleteItem(newIndex); QVERIFY(!repository.findIndex(*realItemsById[pick])); delete[] realItemsById[pick]; realItemsById.remove(pick); realItemsByIndex.remove(index); } } } } qDebug() << "total insertions:" << totalInsertions << "total deletions:" << totalDeletions << "average item size:" << (totalSize / totalInsertions) << "biggest item size:" << maxSize; KDevelop::ItemRepository::Statistics stats = repository.statistics(); qDebug() << stats; QVERIFY(stats.freeUnreachableSpace < stats.freeSpaceInBuckets/100); // < 1% of the free space is unreachable QVERIFY(stats.freeSpaceInBuckets < stats.usedSpaceForBuckets); // < 20% free space } void testLeaks() { KDevelop::ItemRepository repository(QStringLiteral("TestItemRepository")); QList items; for(int i = 0; i < 10000; ++i) { TestItem* item = createItem(i, (rand() % 1000) + sizeof(TestItem)); items << item; repository.index(TestItemRequest(*item)); } foreach(auto item, items) { delete[] item; } } void testStringSharing() { QString qString; qString.fill('.', 1000); KDevelop::IndexedString indexedString(qString); const int repeat = 10000; QVector strings; strings.resize(repeat); for(int i = 0; i < repeat; ++i) { strings[i] = indexedString.str(); QCOMPARE(qString, strings[i]); } } void deleteClashingMonsterBucket() { KDevelop::ItemRepository repository(QStringLiteral("TestItemRepository")); const uint hash = 1235; QScopedArrayPointer monsterItem(createItem(hash, KDevelop::ItemRepositoryBucketSize + 10)); QScopedArrayPointer smallItem(createItem(hash, 20)); QVERIFY(!monsterItem->equals(smallItem.data())); uint smallIndex = repository.index(TestItemRequest(*smallItem, true)); uint monsterIndex = repository.index(TestItemRequest(*monsterItem, true)); QVERIFY(monsterIndex != smallIndex); repository.deleteItem(smallIndex); QVERIFY(!repository.findIndex(TestItemRequest(*smallItem, true))); QCOMPARE(monsterIndex, repository.findIndex(TestItemRequest(*monsterItem, true))); repository.deleteItem(monsterIndex); // now in reverse order, with different data see: https://bugs.kde.org/show_bug.cgi?id=272408 monsterItem.reset(createItem(hash + 1, KDevelop::ItemRepositoryBucketSize + 10)); smallItem.reset(createItem(hash + 1, 20)); QVERIFY(!monsterItem->equals(smallItem.data())); monsterIndex = repository.index(TestItemRequest(*monsterItem, true)); smallIndex = repository.index(TestItemRequest(*smallItem, true)); repository.deleteItem(monsterIndex); QCOMPARE(smallIndex, repository.findIndex(TestItemRequest(*smallItem, true))); QVERIFY(!repository.findIndex(TestItemRequest(*monsterItem, true))); repository.deleteItem(smallIndex); } void usePermissiveModuloWhenRemovingClashLinks() { KDevelop::ItemRepository repository(QStringLiteral("PermissiveModulo")); const uint bucketHashSize = decltype(repository)::bucketHashSize; const uint nextBucketHashSize = decltype(repository)::MyBucket::NextBucketHashSize; auto bucketNumberForIndex = [](const uint index) { return index >> 16; }; const uint clashValue = 2; // Choose sizes that ensure that the items fit in the desired buckets const uint bigItemSize = KDevelop::ItemRepositoryBucketSize * 0.55 - 1; const uint smallItemSize = KDevelop::ItemRepositoryBucketSize * 0.25 - 1; // Will get placed in bucket 1 (bucket zero is invalid), so the root bucket table at position 'clashValue' will be '1' const QScopedArrayPointer firstChainFirstLink(createItem(clashValue, bigItemSize)); const uint firstChainFirstLinkIndex = repository.index(*firstChainFirstLink); QCOMPARE(bucketNumberForIndex(firstChainFirstLinkIndex), 1u); // Will also get placed in bucket 1, so root bucket table at position 'nextBucketHashSize + clashValue' will be '1' const QScopedArrayPointer secondChainFirstLink(createItem(nextBucketHashSize + clashValue, smallItemSize)); const uint secondChainFirstLinkIndex = repository.index(*secondChainFirstLink); QCOMPARE(bucketNumberForIndex(secondChainFirstLinkIndex), 1u); // Will get placed in bucket 2, so bucket 1's next hash table at position 'clashValue' will be '2' const QScopedArrayPointer firstChainSecondLink(createItem(bucketHashSize + clashValue, bigItemSize)); const uint firstChainSecondLinkIndex = repository.index(*firstChainSecondLink); QCOMPARE(bucketNumberForIndex(firstChainSecondLinkIndex), 2u); // Will also get placed in bucket 2, reachable since bucket 1's next hash table at position 'clashValue' is '2' const QScopedArrayPointer secondChainSecondLink(createItem(bucketHashSize + nextBucketHashSize + clashValue, smallItemSize)); const uint secondChainSecondLinkIndex = repository.index(*secondChainSecondLink); QCOMPARE(bucketNumberForIndex(secondChainSecondLinkIndex), 2u); /* * At this point we have two chains in the repository, rooted at 'clashValue' and 'nextBucketHashSize + clashValue' * Both of the chains start in bucket 1 and end in bucket 2, but both chains share the same link to bucket 2 * This is because two of the hashes clash the other two when % bucketHashSize, but all of them clash % nextBucketHashSize */ repository.deleteItem(firstChainSecondLinkIndex); /* * Now we've deleted the second item in the first chain, this means the first chain no longer requires a link to the * second bucket where that item was... but the link must remain, since it's shared (clashed) by the second chain. * * When cutting a link out of the middle of the chain, we need to check if its items clash using the "permissive" * modulus (the size of the /next/ buckets map), which is always a factor of the "stricter" modulus (the size of the * /root/ buckets map). * * This behavior implies that there will sometimes be useless buckets in the bucket chain for a given hash, so when * cutting out the root link, it's safe to skip over them to the first clash with the 'stricter' modulus. */ // The second item of the second chain must still be reachable QCOMPARE(repository.findIndex(*secondChainSecondLink), secondChainSecondLinkIndex); /* * As a memo to anyone who's still reading this, this also means the following situation can exist: * * bucketHashSize == 8 * nextBucketHashSize == 4 * U is a link table * B is a bucket * [...] are the hashes of the contained items * * U * U * U -> B1 * U * U * U * U -> B2 * U * * B0 (Invalid) * B1 -> [2, 6] * U * U * U -> B3 * U * B2 -> [14] * U * U * U -> B1 * U * B3 -> [10] * U * U * U * U * * The chain for hash 6 is: * Root[6] -> B2[2] -> B1[2] -> B3 * * If you remove the item with hash 6, 6 and 2 will clash with mod 4 (permissive) * * So the useless link `B2[2] -> B1` will be preserved, even though its useless * as the item with hash 2 is reachable directly from the root. * * So TODO: Don't preserve links to items accessible from root buckets. This cannot * be done correctly using only Bucket::hasClashingItem as of now. */ } }; #include "test_itemrepository.moc" QTEST_MAIN(TestItemRepository) diff --git a/serialization/tests/test_itemrepositoryregistry_automatic.cpp b/serialization/tests/test_itemrepositoryregistry_automatic.cpp index 28016bf6ea..91859f67db 100644 --- a/serialization/tests/test_itemrepositoryregistry_automatic.cpp +++ b/serialization/tests/test_itemrepositoryregistry_automatic.cpp @@ -1,51 +1,51 @@ #include #include #include #include #include class TestItemRepositoryRegistryAutomaticDeletion : public QObject { Q_OBJECT void initCore(const QString& sessionName = QString()) { KDevelop::TestCore* core = new KDevelop::TestCore(); core->initialize(KDevelop::Core::NoUi, sessionName); } void destroyCore() { KDevelop::TestCore::shutdown(); } - private slots: + private Q_SLOTS: void initTestCase() { KDevelop::AutoTestShell::init(); } void testTemporarySessionDeletion() { // Create and shutdown a TestCore. The session created by it is temporary // and thus shall be deleted upon core shutdown together with its // item-repository directory. { initCore(); // The session created by TestCore shall be temporary QVERIFY(KDevelop::Core::self()->activeSession()->isTemporary()); // The repository shall exist QString repositoryPath = KDevelop::globalItemRepositoryRegistry().path(); QVERIFY(QFile::exists(repositoryPath)); // The repository shall die with the core shutdown destroyCore(); QVERIFY(!QFile::exists(repositoryPath)); } } void cleanupTestCase() { } }; #include "test_itemrepositoryregistry_automatic.moc" QTEST_MAIN(TestItemRepositoryRegistryAutomaticDeletion) diff --git a/serialization/tests/test_itemrepositoryregistry_deferred.cpp b/serialization/tests/test_itemrepositoryregistry_deferred.cpp index ab21ab52e9..088ac59f4e 100644 --- a/serialization/tests/test_itemrepositoryregistry_deferred.cpp +++ b/serialization/tests/test_itemrepositoryregistry_deferred.cpp @@ -1,58 +1,58 @@ #include #include #include #include #include class TestItemRepositoryRegistryDeferredDeletion : public QObject { Q_OBJECT void initCore(const QString& sessionName = QString()) { KDevelop::TestCore* core = new KDevelop::TestCore(); core->initialize(KDevelop::Core::NoUi, sessionName); } void destroyCore() { KDevelop::TestCore::shutdown(); } - private slots: + private Q_SLOTS: void initTestCase() { KDevelop::AutoTestShell::init(); } void testDeferredDeletion() { // Create and shutdown a TestCore, giving the session a custom name // so it will stay (won't be temporary) and request the session deletion // from the same core instance. static const char sessionName[] = "test-itemrepositoryregistry-deferreddeletion"; QString repositoryPath; { initCore(sessionName); // The session with a custom name shall not be temporary QVERIFY(!KDevelop::Core::self()->activeSession()->isTemporary()); // The repository shall exist repositoryPath = KDevelop::globalItemRepositoryRegistry().path(); QVERIFY(QFile::exists(repositoryPath)); // The repository shall survive session deletion request KDevelop::Core::self()->sessionController()->deleteSession(KDevelop::Core::self()->sessionController()->activeSessionLock()); QVERIFY(QFile::exists(repositoryPath)); // The repository shall die together with the core shutdown destroyCore(); QVERIFY(!QFile::exists(repositoryPath)); } } void cleanupTestCase() { } }; #include "test_itemrepositoryregistry_deferred.moc" QTEST_MAIN(TestItemRepositoryRegistryDeferredDeletion) diff --git a/shell/areadisplay.h b/shell/areadisplay.h index 8112a31203..908383774e 100644 --- a/shell/areadisplay.h +++ b/shell/areadisplay.h @@ -1,64 +1,64 @@ /*************************************************************************** * 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 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 AREADISPLAY_H #define AREADISPLAY_H #include class QLabel; class QToolButton; class QMenu; namespace KDevelop { class MainWindow; } namespace Sublime { class MainWindow; class Area; } /** * This widget displays the current area by the menu */ class AreaDisplay : public QWidget { Q_OBJECT public: explicit AreaDisplay(KDevelop::MainWindow* parent); QSize sizeHint() const override; QSize minimumSizeHint() const override; protected: bool eventFilter(QObject* obj, QEvent* event) override; -private slots: +private Q_SLOTS: void newArea(Sublime::Area* area); void backToCode(); private: QLabel* m_separator; QMenu* m_menu; QToolButton* m_button; KDevelop::MainWindow* m_mainWindow; }; #endif // AREADISPLAY_H diff --git a/shell/checkerstatus.h b/shell/checkerstatus.h index 6407a98349..22f8ebdade 100644 --- a/shell/checkerstatus.h +++ b/shell/checkerstatus.h @@ -1,97 +1,97 @@ /* * 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 CHECKER_STATUS_H #define CHECKER_STATUS_H #include #include struct CheckerStatusPrivate; namespace KDevelop { /** * Status / Progress reporter for checker tools. It shows a progress bar as more and more items are checked. * As part of initialization the max. number of items have to be set, and then when an item is checked that has to be indicated to the class. When stopped the progressbar first filled up to max, then it disappears. * * Initialization: * @code * m_status = new CheckerStatus(); * m_status->setCheckerName(QStringLiteral("SomeChecker")); * ICore::self()->uiController()->registerStatus(m_status); * @endcode * * Starting: * @code * m_status->setMaxItems(9001); * m_status->start(); * @endcode * * Stopping: * @code * m_status->stop(); * @endcode * * Showing progress: * @code * m_status->itemChecked(); * @endcode */ class KDEVPLATFORMSHELL_EXPORT CheckerStatus : public QObject, public KDevelop::IStatus { Q_OBJECT Q_INTERFACES(KDevelop::IStatus) public: CheckerStatus(); ~CheckerStatus() override; QString statusName() const override; /// Sets the name of the checker tool void setCheckerName(const QString &name); /// Sets the maximum number of items that will be checked void setMaxItems(int maxItems); /// Increases the number of checked items void itemChecked(); /// Starts status / progress reporting void start(); /// Stops status / progress reporting void stop(); -signals: +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; private: QScopedPointer d; }; } #endif diff --git a/shell/core.h b/shell/core.h index 2aa67df441..b577f584c2 100644 --- a/shell/core.h +++ b/shell/core.h @@ -1,134 +1,134 @@ /*************************************************************************** * 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. * ***************************************************************************/ #ifndef KDEVPLATFORM_CORE_H #define KDEVPLATFORM_CORE_H #include "shellexport.h" #include class KAboutData; namespace KDevelop { class UiController; class PluginController; class ProjectController; class LanguageController; class PartController; class DocumentController; class RunController; class SessionController; class CorePrivate; class SourceFormatterController; class ProgressManager; class SelectionController; class DocumentationController; class DebugController; class WorkingSetController; class TestController; class KDEVPLATFORMSHELL_EXPORT Core: public ICore { Q_OBJECT public: enum Setup { Default=0, NoUi=1 }; static QString version(); /** Initialize the core of the kdevplatform application * returns false if the initialization fails, which may happen * if the same session is already active in another instance * * @param mode the mode in which to run * @param session the name or uuid of the session to be loaded * */ static bool initialize(Setup mode=Default, const QString& session = {}); // TODO: remove before 5.2 release static QT_DEPRECATED bool initialize(QObject* splash = nullptr, Setup mode=Default, const QString& session = {}); /** * \brief Provide access an instance of Core */ static Core *self(); virtual ~Core(); IUiController *uiController() override; IPluginController *pluginController() override; IProjectController *projectController() override; ILanguageController *languageController() override; IPartController *partController() override; IDocumentController *documentController() override; IRunController *runController() override; ISourceFormatterController* sourceFormatterController() override; ISelectionController* selectionController() override; IDocumentationController* documentationController() override; IDebugController* debugController() override; ITestController* testController() override; ISession *activeSession() override; ISessionLock::Ptr activeSessionLock() override; KAboutData aboutData() const override; /// The following methods may only be used within the shell. UiController *uiControllerInternal(); PluginController *pluginControllerInternal(); ProjectController *projectControllerInternal(); LanguageController *languageControllerInternal(); PartController *partControllerInternal(); DocumentController *documentControllerInternal(); RunController *runControllerInternal(); DocumentationController *documentationControllerInternal(); DebugController *debugControllerInternal(); WorkingSetController* workingSetControllerInternal(); SourceFormatterController* sourceFormatterControllerInternal(); TestController* testControllerInternal(); /// @internal SessionController *sessionController(); /// @internal ProgressManager *progressController(); void cleanup(); bool shuttingDown() const override; Core::Setup setupFlags() const; -public slots: +public Q_SLOTS: void shutdown(); protected: friend class CorePrivate; explicit Core( KDevelop::CorePrivate* dd, QObject* parent = nullptr ); KDevelop::CorePrivate *d; static Core *m_self; private: explicit Core(QObject *parent = nullptr); }; } #endif diff --git a/shell/documentationcontroller.h b/shell/documentationcontroller.h index 0721570474..671f1a4ca4 100644 --- a/shell/documentationcontroller.h +++ b/shell/documentationcontroller.h @@ -1,63 +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: +public Q_SLOTS: void changedDocumentationProviders() override; -private slots: +private Q_SLOTS: void doShowDocumentation(); private: DocumentationViewFactory* m_factory; QAction* m_showDocumentation; }; } #endif // KDEVPLATFORM_DOCUMENTATIONCONTROLLER_H diff --git a/shell/environmentconfigurebutton.h b/shell/environmentconfigurebutton.h index bef97018cd..597511b793 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 = nullptr); ~EnvironmentConfigureButton() override; void setSelectionWidget(EnvironmentSelectionWidget* widget); -signals: +Q_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/ktexteditorpluginintegration.h b/shell/ktexteditorpluginintegration.h index b3279fd68d..e26e449419 100644 --- a/shell/ktexteditorpluginintegration.h +++ b/shell/ktexteditorpluginintegration.h @@ -1,127 +1,127 @@ /* Copyright 2015 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) 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_KTEXTEDITOR_PLUGIN_INTEGRATION_H #define KDEVPLATFORM_KTEXTEDITOR_PLUGIN_INTEGRATION_H #include #include #include #include #include class QStackedLayout; namespace KDevelop { class ObjectListTracker; class MainWindow; } namespace KTextEditorIntegration { /** * Class mimicking the KTextEditor::Application interface */ class Application : public QObject { Q_OBJECT public: explicit Application(QObject *parent = nullptr); ~Application() override; -public slots: +public Q_SLOTS: KTextEditor::MainWindow *activeMainWindow() const; QList mainWindows() const; KTextEditor::Plugin *plugin(const QString &id) const; bool closeDocument(KTextEditor::Document *document) const; }; class MainWindow : public QObject { Q_OBJECT public: explicit MainWindow(KDevelop::MainWindow *mainWindow); ~MainWindow() override; -public slots: +public Q_SLOTS: QWidget *createToolView(KTextEditor::Plugin *plugin, const QString &identifier, KTextEditor::MainWindow::ToolViewPosition pos, const QIcon &icon, const QString &text); KXMLGUIFactory *guiFactory() const; QWidget *window() const; QList views() const; KTextEditor::View *activeView() const; QObject *pluginView(const QString &id) const; void splitView(Qt::Orientation orientation); QWidget *createViewBar(KTextEditor::View *view); void deleteViewBar(KTextEditor::View *view); void showViewBar(KTextEditor::View *view); void hideViewBar(KTextEditor::View *view); void addWidgetToViewBar(KTextEditor::View *view, QWidget *widget); public: KTextEditor::MainWindow *interface() const; void addPluginView(const QString &id, QObject *pluginView); void removePluginView(const QString &id); private: KDevelop::MainWindow *m_mainWindow; KTextEditor::MainWindow *m_interface; QHash> m_pluginViews; QStackedLayout *m_viewBarContainerLayout; QHash m_viewBars; }; class Plugin : public KDevelop::IPlugin { Q_OBJECT public: explicit Plugin(KTextEditor::Plugin *plugin, QObject *parent = nullptr); ~Plugin() override; KXMLGUIClient* createGUIForMainWindow(Sublime::MainWindow *window) override; void unload() override; KTextEditor::Plugin *interface() const; QString pluginId() const; private: QPointer m_plugin; // view objects and toolviews that should get deleted when the plugin gets unloaded KDevelop::ObjectListTracker *m_tracker; }; void initialize(); } #endif diff --git a/shell/launchconfiguration.h b/shell/launchconfiguration.h index 891a736a8d..47a575093b 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* = 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 typeId 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: +Q_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 f44e69301d..790e78faed 100644 --- a/shell/launchconfigurationdialog.h +++ b/shell/launchconfigurationdialog.h @@ -1,167 +1,167 @@ /* 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 = 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(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 = nullptr ); void setLaunchConfiguration( LaunchConfiguration* ); void save(); -signals: +Q_SIGNALS: void changed(); private: LaunchConfiguration* config; QList pages; }; class LaunchConfigurationDialog : public QDialog, public Ui::LaunchConfigurationDialog { Q_OBJECT public: explicit LaunchConfigurationDialog(QWidget* parent = nullptr ); QSize sizeHint() const override; -private slots: +private Q_SLOTS: void deleteConfiguration(); void createConfiguration(); void addConfiguration(KDevelop::ILaunchConfiguration*); void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected); void modelChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight); void pageChanged(); void saveConfig(); void updateNameLabel( LaunchConfiguration* l ); void createEmptyLauncher(); void launchModeChanged(int index); void doTreeContextMenu(const QPoint& point); void renameSelected(); private: void saveConfig( const QModelIndex& ); LaunchConfigurationsModel* model; QMap typeWidgets; QMap launcherWidgets; bool currentPageChanged; }; } #endif diff --git a/shell/openprojectdialog.h b/shell/openprojectdialog.h index ffca733e9b..6f0da9f5ea 100644 --- a/shell/openprojectdialog.h +++ b/shell/openprojectdialog.h @@ -1,90 +1,90 @@ /*************************************************************************** * Copyright (C) 2008 by Andreas Pakulat #include #include #include class KPageWidgetItem; class QFileDialog; namespace KIO { class Job; } namespace KDevelop { class ProjectSourcePage; class OpenProjectPage; class IPlugin; class OpenProjectDialog : public KAssistantDialog { Q_OBJECT public: OpenProjectDialog(bool fetch, const QUrl& startUrl, const QUrl& repoUrl = QUrl(), IPlugin* vcsOrProviderPlugin = nullptr, 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; int exec() override; QStringList projectManagerForFile(const QString& file) const; -private slots: +private Q_SLOTS: void validateSourcePage( bool ); void validateOpenUrl( const QUrl& ); void validateProjectName( const QString& ); void validateProjectManager( const QString&, const QString & ); void storeFileList(KIO::Job*, const KIO::UDSEntryList&); void openPageAccepted(); private: bool execNativeDialog(); void validateProjectInfo(); QUrl m_url; QUrl m_selected; QString m_projectName; QString m_projectManager; bool m_urlIsDirectory; /// Used to select files when we aren't in KDE QFileDialog* nativeDialog = nullptr; KPageWidgetItem* sourcePage; KPageWidgetItem* openPage; KPageWidgetItem* projectInfoPage; QStringList m_fileList; QMap m_projectFilters; QMap m_projectPlugins; KDevelop::OpenProjectPage* openPageWidget = nullptr; KDevelop::ProjectSourcePage* sourcePageWidget = nullptr; }; } #endif diff --git a/shell/openprojectpage.h b/shell/openprojectpage.h index 865650e6b1..97ee5b6271 100644 --- a/shell/openprojectpage.h +++ b/shell/openprojectpage.h @@ -1,51 +1,51 @@ /*************************************************************************** * Copyright (C) 2008 by Andreas Pakulat class QUrl; class KFileWidget; namespace KDevelop { class OpenProjectPage : public QWidget { Q_OBJECT public: explicit OpenProjectPage( const QUrl& startUrl, const QStringList& filters, QWidget* parent = nullptr ); void setUrl(const QUrl& url); -signals: +Q_SIGNALS: void urlSelected(const QUrl&); void accepted(); protected: void showEvent(QShowEvent*) override; -private slots: +private Q_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; }; } #endif diff --git a/shell/problemmodel.h b/shell/problemmodel.h index 273c5a71ad..4fce5dfe03 100644 --- a/shell/problemmodel.h +++ b/shell/problemmodel.h @@ -1,210 +1,210 @@ /* * 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 struct ProblemModelPrivate; namespace KDevelop { class IDocument; class IndexedString; 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 ShowSource = 64 /// Show problem's source. Set if problems can have different sources. }; Q_DECLARE_FLAGS(Features, FeatureCode) 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 problems for selected document QVector problems(const KDevelop::IndexedString& document); /// Retrieve the supported features Features features() const; /// Retrieve 'show imports' filter setting bool showImports(); /// Set the supported features void setFeatures(Features features); /// Tooltip for "Force Full Update" action in the Problems View when the model /// is active (correspondent tab is selected) QString fullUpdateTooltip() const; /// Set the "Force Full Update" action tooltip void setFullUpdateTooltip(const QString& tooltip); -signals: +Q_SIGNALS: /// Emitted when the stored problems are changed with addProblem(), setProblems() and /// clearProblems() methods. This signal emitted only when internal problems storage is /// really changed: for example, it is not emitted when we call clearProblems() method /// for empty model. void problemsChanged(); /// Emitted when the "Force Full Update" action tooltip is changed with setFullUpdateTooltip(). /// This signal emitted only when tooltip is really changed. void fullUpdateTooltipChanged(); -public slots: +public Q_SLOTS: /// Show imports void setShowImports(bool showImports); /// Sets the scope filter. Uses int to be able to use QSignalMapper void setScope(int scope); /// Sets the severity filter. Uses int to be able to use QSignalMapper void setSeverity(int severity);///old-style severity filtering 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: +protected Q_SLOTS: /// Triggered when problems change virtual void onProblemsChanged(){} -private slots: +private Q_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/problemmodelset.h b/shell/problemmodelset.h index 54cbfad649..5003e87df9 100644 --- a/shell/problemmodelset.h +++ b/shell/problemmodelset.h @@ -1,103 +1,103 @@ /* * 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 PROBLEMMODELSET_H #define PROBLEMMODELSET_H #include #include namespace KDevelop { class ProblemModel; /// Struct that handles the model and it's name as one unit, stored in ProblemModelSet struct ModelData { QString id; QString name; ProblemModel *model; }; struct ProblemModelSetPrivate; /** * @brief Stores name/model pairs and emits signals when they are added/removed. * * Typically it's used from plugins, which maintains a reference to the model added. * Therefore It assumes that models get removed, so it doesn't delete! * * Usage example: * @code * ProblemModelSet *set = new ProblemModelSet(); * ProblemModel *model = new ProblemModel(nullptr); * set->addModel(QStringLiteral("MODEL_ID"), QStringLiteral("MODEL"), model); // added() signal is emitted * set->models().count(); // returns 1 * set->findModel(QStringLiteral("MODEL_ID")); // returns the model just added * set->removeModel(QStringLiteral("MODEL_ID")); // removed() signal is emitted * @endcode * */ class KDEVPLATFORMSHELL_EXPORT ProblemModelSet : public QObject { Q_OBJECT public: explicit ProblemModelSet(QObject *parent = nullptr); ~ProblemModelSet() override; /// Adds a model void addModel(const QString &id, const QString &name, ProblemModel *model); /// Finds a model ProblemModel* findModel(const QString &id) const; /// Removes a model void removeModel(const QString &id); /// Show model in ProblemsView void showModel(const QString &id); /// Retrieves a list of models stored QVector models() const; -signals: +Q_SIGNALS: /// Emitted when a new model is added void added(const ModelData &model); /// Emitted when a model is removed void removed(const QString &id); /// Emitted when showModel() is called void showRequested(const QString &id); /// Emitted when any model emits problemsChanged() void problemsChanged(); private: QScopedPointer d; }; } Q_DECLARE_TYPEINFO(KDevelop::ModelData, Q_MOVABLE_TYPE); #endif diff --git a/shell/problemstore.h b/shell/problemstore.h index ad0bda8d29..eb46d097ac 100644 --- a/shell/problemstore.h +++ b/shell/problemstore.h @@ -1,162 +1,162 @@ /* * 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 PROBLEMSTORE_H #define PROBLEMSTORE_H #include #include #include #include struct ProblemStorePrivate; namespace KDevelop { class WatchedDocumentSet; class ProblemStoreNode; /** * @brief Stores and handles problems. Does no ordering or filtering, those should be done in subclasses. * * Used to store problems that are ordered, filtered somewhere else. For example: DUChain problems gathered by ProblemReporter. * Stores the problems in ProblemStoreNodes. * When implementing a subclass, first and foremost the rebuild method needs to be implemented, which is called every time there's a change in scope and severity filter. * If grouping is desired then also the setGrouping method must be implemented. * ProblemStore depending on settings uses CurrentDocumentSet, OpenDocumentSet, CurrentProjectSet, or AllProjectSet for scope support (NOTE: Filtering still has to be implemented in either a subclass, or somewhere else). * When the scope changes it emits the changed() signal. * * Scope set / query methods: * \li setScope() * \li scope() * * Valid scope settings: * \li CurrentDocument * \li OpenDocuments * \li CurrentProject * \li AllProjects * \li BypassScopeFilter * * Usage example: * @code * QVector problems; * // Add 4 problems * ... * ProblemStore *store = new ProblemStore(); * store->setProblems(problems); * store->count(); // Returns 4 * * ProblemStoreNode *node = store->findNode(0); // Returns the node with the first problem * @endcode * */ class KDEVPLATFORMSHELL_EXPORT ProblemStore : public QObject { Q_OBJECT public: explicit ProblemStore(QObject *parent = nullptr); ~ProblemStore() override; /// Adds a problem virtual void addProblem(const IProblem::Ptr &problem); /// Clears the current problems, and adds new ones from a list virtual void setProblems(const QVector &problems); /// Retrieve problems for selected document QVector problems(const KDevelop::IndexedString& document) const; /// Finds the specified node virtual const ProblemStoreNode* findNode(int row, ProblemStoreNode *parent = nullptr) const; /// Returns the number of problems virtual int count(ProblemStoreNode *parent = nullptr) const; /// Clears the problems virtual void clear(); /// Rebuild the problems list, if applicable. It does nothing in the base class. virtual void rebuild(); /// Specifies the severity filter virtual void setSeverity(int severity);///old-style severity access virtual void setSeverities(KDevelop::IProblem::Severities severities);///new-style severity access /// Retrives the severity filter settings int severity() const;///old-style severity access KDevelop::IProblem::Severities severities() const;//new-style severity access /// Retrieves the currently watched document set WatchedDocumentSet* documents() const; /// Sets the scope filter void setScope(int scope); /// Returns the current scope int scope() const; /// Sets the grouping method virtual void setGrouping(int grouping); /// Set 'show imports' filter value void setShowImports(bool showImports); /// Retrieve 'show imports' filter setting int showImports() const; /// Sets the currently shown document (in the editor, it's triggered by the IDE) void setCurrentDocument(const IndexedString &doc); /// Retrives the path of the current document const KDevelop::IndexedString& currentDocument() const; -signals: +Q_SIGNALS: /// Emitted when any store setting (grouping, scope, severity, document) is changed void changed(); /// Emitted when the stored problems are changed with clear(), addProblem() and setProblems() /// methods. This signal emitted only when internal problems storage is really changed: /// for example, it is not emitted when we call clear() method for empty storage. void problemsChanged(); /// Emitted before the problemlist is rebuilt void beginRebuild(); /// Emitted once the problemlist has been rebuilt void endRebuild(); -private slots: +private Q_SLOTS: /// Triggered when the watched document set changes. E.g.:document closed, new one added, etc virtual void onDocumentSetChanged(); protected: ProblemStoreNode* rootNode(); private: QScopedPointer d; }; } #endif diff --git a/shell/project.h b/shell/project.h index fb35759276..1f5c495e4b 100644 --- a/shell/project.h +++ b/shell/project.h @@ -1,139 +1,139 @@ /* 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 = 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: +Q_SIGNALS: /** * Internal signal to make IProjectController::projectAboutToOpen useful. */ void aboutToOpen(KDevelop::IProject*); private: class ProjectPrivate* const d; }; } // namespace KDevelop #endif diff --git a/shell/projectinfopage.h b/shell/projectinfopage.h index 960aa0d388..ad7ba31883 100644 --- a/shell/projectinfopage.h +++ b/shell/projectinfopage.h @@ -1,50 +1,50 @@ /*************************************************************************** * Copyright (C) 2008 by Andreas Pakulat struct ProjectFileChoice { QString text; QString pluginId; QString iconName; QString fileName; }; namespace Ui { class ProjectInfoPage; } namespace KDevelop { class ProjectInfoPage : public QWidget { Q_OBJECT public: explicit ProjectInfoPage( QWidget* parent = nullptr ); ~ProjectInfoPage() override; void setProjectName( const QString& ); void populateProjectFileCombo( const QVector& choices ); -signals: +Q_SIGNALS: void projectNameChanged( const QString& ); void projectManagerChanged( const QString& pluginId, const QString & fileName); -private slots: +private Q_SLOTS: void changeProjectManager( int ); private: Ui::ProjectInfoPage* page_ui; }; } #endif diff --git a/shell/projectsourcepage.h b/shell/projectsourcepage.h index 37da36bedd..3627fbbfa9 100644 --- a/shell/projectsourcepage.h +++ b/shell/projectsourcepage.h @@ -1,67 +1,67 @@ /*************************************************************************** * 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, const QUrl& repoUrl, IPlugin* preSelectPlugin, QWidget* parent = nullptr); ~ProjectSourcePage() override; QUrl workingDir() const; - private slots: + private Q_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: + Q_SIGNALS: void isCorrect(bool); private: void setSourceWidget(int index, const QUrl& repoUrl); 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/sessioncontroller.cpp b/shell/sessioncontroller.cpp index 35e05beaee..db1050244d 100644 --- a/shell/sessioncontroller.cpp +++ b/shell/sessioncontroller.cpp @@ -1,659 +1,659 @@ /* This file is part of KDevelop Copyright 2008 Andreas Pakulat 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. */ #include "sessioncontroller.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "session.h" #include "core.h" #include "uicontroller.h" #include "shellextension.h" #include "sessionlock.h" #include "sessionchooserdialog.h" #include "debug.h" #include #include #include namespace KDevelop { namespace { int argc = 0; char** argv = nullptr; }; void SessionController::setArguments(int _argc, char** _argv) { argc = _argc; argv = _argv; } static QStringList standardArguments() { QStringList ret; for(int a = 0; a < argc; ++a) { QString arg = QString::fromLocal8Bit(argv[a]); if(arg.startsWith(QLatin1String("-graphicssystem")) || arg.startsWith(QLatin1String("-style"))) { ret << '-' + arg; if(a+1 < argc) ret << QString::fromLocal8Bit(argv[a+1]); } } return ret; } class SessionControllerPrivate : public QObject { Q_OBJECT public: explicit SessionControllerPrivate( SessionController* s ) : q(s) , activeSession(nullptr) , grp(nullptr) { } ~SessionControllerPrivate() override { } Session* findSessionForName( const QString& name ) const { foreach( Session* s, sessionActions.keys() ) { if( s->name() == name ) return s; } return nullptr; } Session* findSessionForId(QString idString) { QUuid id(idString); foreach( Session* s, sessionActions.keys() ) { if( s->id() == id) return s; } return nullptr; } void newSession() { qsrand(QDateTime::currentDateTimeUtc().toTime_t()); Session* session = new Session( QUuid::createUuid().toString() ); KProcess::startDetached(ShellExtension::getInstance()->executableFilePath(), QStringList() << QStringLiteral("-s") << session->id().toString() << standardArguments()); delete session; #if 0 //Terminate this instance of kdevelop if the user agrees foreach(Sublime::MainWindow* window, Core::self()->uiController()->controller()->mainWindows()) window->close(); #endif } void deleteCurrentSession() { int choice = KMessageBox::warningContinueCancel(Core::self()->uiController()->activeMainWindow(), i18n("The current session and all contained settings will be deleted. The projects will stay unaffected. Do you really want to continue?")); if(choice == KMessageBox::Continue) { q->deleteSessionFromDisk(sessionLock); q->emitQuitSession(); } } void renameSession() { bool ok; auto newSessionName = QInputDialog::getText(Core::self()->uiController()->activeMainWindow(), i18n("Rename Session"), i18n("New Session Name:"), QLineEdit::Normal, q->activeSession()->name(), &ok); if (ok) { static_cast(q->activeSession())->setName(newSessionName); } q->updateXmlGuiActionList(); // resort } bool loadSessionExternally( Session* s ) { Q_ASSERT( s ); KProcess::startDetached(ShellExtension::getInstance()->executableFilePath(), QStringList() << QStringLiteral("-s") << s->id().toString() << standardArguments()); return true; } TryLockSessionResult activateSession( Session* s ) { Q_ASSERT( s ); activeSession = s; TryLockSessionResult result = SessionController::tryLockSession( s->id().toString()); if( !result.lock ) { activeSession = nullptr; return result; } Q_ASSERT(s->id().toString() == result.lock->id()); sessionLock = result.lock; KConfigGroup grp = KSharedConfig::openConfig()->group( SessionController::cfgSessionGroup() ); grp.writeEntry( SessionController::cfgActiveSessionEntry(), s->id().toString() ); grp.sync(); if (Core::self()->setupFlags() & Core::NoUi) return result; QHash::iterator it = sessionActions.find(s); Q_ASSERT( it != sessionActions.end() ); (*it)->setCheckable(true); (*it)->setChecked(true); for(it = sessionActions.begin(); it != sessionActions.end(); ++it) { if(it.key() != s) (*it)->setCheckable(false); } return result; } void loadSessionFromAction(QAction* action) { auto session = action->data().value(); loadSessionExternally(session); } void addSession( Session* s ) { if (Core::self()->setupFlags() & Core::NoUi) { sessionActions[s] = nullptr; return; } QAction* a = new QAction( grp ); a->setText( s->description() ); a->setCheckable( false ); a->setData(QVariant::fromValue(s)); sessionActions[s] = a; q->actionCollection()->addAction( "session_"+s->id().toString(), a ); connect( s, &Session::sessionUpdated, this, &SessionControllerPrivate::sessionUpdated ); sessionUpdated( s ); } SessionController* q; QHash sessionActions; ISession* activeSession; QActionGroup* grp; ISessionLock::Ptr sessionLock; static QString sessionBaseDirectory() { return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) +'/'+ qApp->applicationName() + "/sessions/"; } QString ownSessionDirectory() const { Q_ASSERT(activeSession); return q->sessionDirectory( activeSession->id().toString() ); } -private slots: +private Q_SLOTS: void sessionUpdated( KDevelop::ISession* s ) { sessionActions[static_cast( s )]->setText( KStringHandler::rsqueeze(s->description()) ); } }; SessionController::SessionController( QObject *parent ) : QObject( parent ), d(new SessionControllerPrivate(this)) { setObjectName(QStringLiteral("SessionController")); setComponentName(QStringLiteral("kdevsession"), i18n("Session Manager")); setXMLFile(QStringLiteral("kdevsessionui.rc")); QDBusConnection::sessionBus().registerObject( QStringLiteral("/org/kdevelop/SessionController"), this, QDBusConnection::ExportScriptableSlots ); if (Core::self()->setupFlags() & Core::NoUi) return; QAction* action = actionCollection()->addAction( QStringLiteral("new_session"), this, SLOT(newSession()) ); action->setText( i18nc("@action:inmenu", "Start New Session") ); action->setToolTip( i18nc("@info:tooltip", "Start a new KDevelop instance with an empty session") ); action->setIcon(QIcon::fromTheme(QStringLiteral("window-new"))); action = actionCollection()->addAction( QStringLiteral("rename_session"), this, SLOT(renameSession()) ); action->setText( i18n("Rename Current Session...") ); action->setIcon(QIcon::fromTheme(QStringLiteral("edit-rename"))); action = actionCollection()->addAction( QStringLiteral("delete_session"), this, SLOT(deleteCurrentSession()) ); action->setText( i18n("Delete Current Session...") ); action->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete"))); action = actionCollection()->addAction( QStringLiteral("quit"), this, SIGNAL(quitSession()) ); action->setText( i18n("Quit") ); action->setMenuRole( QAction::NoRole ); // OSX: prevent QT from hiding this due to conflict with 'Quit KDevelop...' actionCollection()->setDefaultShortcut( action, Qt::CTRL | Qt::Key_Q ); action->setIcon(QIcon::fromTheme(QStringLiteral("application-exit"))); d->grp = new QActionGroup( this ); connect( d->grp, &QActionGroup::triggered, this, [&] (QAction* a) { d->loadSessionFromAction(a); } ); } SessionController::~SessionController() { delete d; } void SessionController::startNewSession() { d->newSession(); } void SessionController::cleanup() { if (d->activeSession) { Q_ASSERT(d->activeSession->id().toString() == d->sessionLock->id()); if (d->activeSession->isTemporary()) { deleteSessionFromDisk(d->sessionLock); } d->activeSession = nullptr; } d->sessionLock.clear(); qDeleteAll(d->sessionActions); d->sessionActions.clear(); } void SessionController::initialize( const QString& session ) { QDir sessiondir( SessionControllerPrivate::sessionBaseDirectory() ); foreach( const QString& s, sessiondir.entryList( QDir::AllDirs | QDir::NoDotAndDotDot ) ) { QUuid id( s ); if( id.isNull() ) continue; // Only create sessions for directories that represent proper uuid's Session* ses = new Session( id.toString(), this ); //Delete sessions that have no name and are empty if( ses->containedProjects().isEmpty() && ses->name().isEmpty() && (session.isEmpty() || (ses->id().toString() != session && ses->name() != session)) ) { TryLockSessionResult result = tryLockSession(s); if (result.lock) { deleteSessionFromDisk(result.lock); } delete ses; } else { d->addSession( ses ); } } loadDefaultSession( session ); updateXmlGuiActionList(); } ISession* SessionController::activeSession() const { return d->activeSession; } ISessionLock::Ptr SessionController::activeSessionLock() const { return d->sessionLock; } void SessionController::loadSession( const QString& nameOrId ) { d->loadSessionExternally( session( nameOrId ) ); } QList SessionController::sessionNames() const { QStringList l; foreach( const Session* s, d->sessionActions.keys() ) { l << s->name(); } return l; } QList< const KDevelop::Session* > SessionController::sessions() const { QList< const KDevelop::Session* > ret; foreach( const Session* s, d->sessionActions.keys() ) { ret << s; } return ret; } Session* SessionController::createSession( const QString& name ) { Session* s; if(name.startsWith('{')) { s = new Session( QUuid(name).toString(), this ); }else{ qsrand(QDateTime::currentDateTimeUtc().toTime_t()); s = new Session( QUuid::createUuid().toString(), this ); s->setName( name ); } d->addSession( s ); updateXmlGuiActionList(); return s; } void SessionController::deleteSession( const ISessionLock::Ptr& lock ) { Session* s = session(lock->id()); QHash::iterator it = d->sessionActions.find(s); Q_ASSERT( it != d->sessionActions.end() ); unplugActionList( QStringLiteral("available_sessions") ); actionCollection()->removeAction(*it); if (d->grp) { // happens in unit tests d->grp->removeAction(*it); plugActionList( QStringLiteral("available_sessions"), d->grp->actions() ); } if (s == d->activeSession) { d->activeSession = nullptr; } deleteSessionFromDisk(lock); emit sessionDeleted( s->id().toString() ); d->sessionActions.remove(s); delete s; } void SessionController::deleteSessionFromDisk( const ISessionLock::Ptr& lock ) { qCDebug(SHELL) << "Deleting session:" << lock->id(); static_cast(lock.data())->removeFromDisk(); ItemRepositoryRegistry::deleteRepositoryFromDisk( lock ); } void SessionController::loadDefaultSession( const QString& session ) { QString load = session; if (load.isEmpty()) { KConfigGroup grp = KSharedConfig::openConfig()->group( cfgSessionGroup() ); load = grp.readEntry( cfgActiveSessionEntry(), "default" ); } // Iteratively try to load the session, asking user what to do in case of failure // If showForceOpenDialog() returns empty string, stop trying Session* s = nullptr; do { s = this->session( load ); if( !s ) { s = createSession( load ); } TryLockSessionResult result = d->activateSession( s ); if( result.lock ) { Q_ASSERT(d->activeSession == s); Q_ASSERT(d->sessionLock = result.lock); break; } load = handleLockedSession( s->name(), s->id().toString(), result.runInfo ); } while( !load.isEmpty() ); } Session* SessionController::session( const QString& nameOrId ) const { Session* ret = d->findSessionForName( nameOrId ); if(ret) return ret; return d->findSessionForId( nameOrId ); } QString SessionController::cloneSession( const QString& nameOrid ) { Session* origSession = session( nameOrid ); qsrand(QDateTime::currentDateTimeUtc().toTime_t()); QUuid id = QUuid::createUuid(); auto copyJob = KIO::copy(QUrl::fromLocalFile(sessionDirectory(origSession->id().toString())), QUrl::fromLocalFile(sessionDirectory( id.toString()))); KJobWidgets::setWindow(copyJob, Core::self()->uiController()->activeMainWindow()); copyJob->exec(); Session* newSession = new Session( id.toString() ); newSession->setName( i18n( "Copy of %1", origSession->name() ) ); d->addSession(newSession); updateXmlGuiActionList(); return newSession->name(); } void SessionController::updateXmlGuiActionList() { unplugActionList( QStringLiteral("available_sessions") ); if (d->grp) { auto actions = d->grp->actions(); std::sort(actions.begin(), actions.end(), [](const QAction* lhs, const QAction* rhs) { auto s1 = lhs->data().value(); auto s2 = rhs->data().value(); return QString::localeAwareCompare(s1->description(), s2->description()) < 0; }); plugActionList(QStringLiteral("available_sessions"), actions); } } QString SessionController::cfgSessionGroup() { return QStringLiteral("Sessions"); } QString SessionController::cfgActiveSessionEntry() { return QStringLiteral("Active Session ID"); } QList SessionController::availableSessionInfo() { return availableSessionInfos().toList(); } SessionInfos SessionController::availableSessionInfos() { SessionInfos sessionInfos; foreach( const QString& sessionId, QDir( SessionControllerPrivate::sessionBaseDirectory() ).entryList( QDir::AllDirs ) ) { if( !QUuid( sessionId ).isNull() ) { sessionInfos << Session::parse( sessionId ); } } return sessionInfos; } QString SessionController::sessionDirectory(const QString& sessionId) { return SessionControllerPrivate::sessionBaseDirectory() + sessionId; } TryLockSessionResult SessionController::tryLockSession(const QString& id, bool doLocking) { return SessionLock::tryLockSession(id, doLocking); } bool SessionController::isSessionRunning(const QString& id) { return sessionRunInfo(id).isRunning; } SessionRunInfo SessionController::sessionRunInfo(const QString& id) { return SessionLock::tryLockSession(id, false).runInfo; } QString SessionController::showSessionChooserDialog(QString headerText, bool onlyRunning) { ///FIXME: move this code into sessiondialog.cpp QListView* view = new QListView; QLineEdit* filter = new QLineEdit; filter->setClearButtonEnabled( true ); filter->setPlaceholderText(i18n("Search")); QStandardItemModel* model = new QStandardItemModel(view); QSortFilterProxyModel *proxy = new QSortFilterProxyModel(model); proxy->setSourceModel(model); proxy->setFilterKeyColumn( 1 ); proxy->setFilterCaseSensitivity( Qt::CaseInsensitive ); connect(filter, &QLineEdit::textChanged, proxy, &QSortFilterProxyModel::setFilterFixedString); SessionChooserDialog dialog(view, proxy, filter); view->setEditTriggers(QAbstractItemView::NoEditTriggers); QVBoxLayout layout(dialog.mainWidget()); if(!headerText.isEmpty()) { QLabel* heading = new QLabel(headerText); QFont font = heading->font(); font.setBold(true); heading->setFont(font); layout.addWidget(heading); } model->setColumnCount(3); model->setHeaderData(0, Qt::Horizontal,i18n("Identity")); model->setHeaderData(1, Qt::Horizontal, i18n("Contents")); model->setHeaderData(2, Qt::Horizontal,i18n("State")); view->setModel(proxy); view->setModelColumn(1); QHBoxLayout* filterLayout = new QHBoxLayout(); filterLayout->addWidget(new QLabel(i18n("Filter:"))); filterLayout->addWidget(filter); layout.addLayout(filterLayout); layout.addWidget(view); filter->setFocus(); int row = 0; QString defaultSession = KSharedConfig::openConfig()->group( cfgSessionGroup() ).readEntry( cfgActiveSessionEntry(), "default" ); foreach(const KDevelop::SessionInfo& si, KDevelop::SessionController::availableSessionInfos()) { if ( si.name.isEmpty() && si.projects.isEmpty() ) { continue; } bool running = KDevelop::SessionController::isSessionRunning(si.uuid.toString()); if(onlyRunning && !running) continue; model->setItem(row, 0, new QStandardItem(si.uuid.toString())); model->setItem(row, 1, new QStandardItem(si.description)); model->setItem(row, 2, new QStandardItem); ++row; } model->sort(1); if(!onlyRunning) { model->setItem(row, 0, new QStandardItem); model->setItem(row, 1, new QStandardItem(QIcon::fromTheme(QStringLiteral("window-new")), i18n("Create New Session"))); } dialog.updateState(); dialog.mainWidget()->layout()->setContentsMargins(0,0,0,0); const QModelIndex defaultSessionIndex = model->match(model->index(0, 0), Qt::DisplayRole, defaultSession, 1, Qt::MatchExactly).value(0); view->selectionModel()->setCurrentIndex(proxy->mapFromSource(defaultSessionIndex), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); view->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); ///@todo We need a way to get a proper size-hint from the view, but unfortunately, that only seems possible after the view was shown. dialog.resize(QSize(900, 600)); if(dialog.exec() != QDialog::Accepted) { return QString(); } QModelIndex selected = view->selectionModel()->currentIndex(); if (!selected.isValid()) return QString(); const QString selectedSessionId = selected.sibling(selected.row(), 0).data().toString(); if (selectedSessionId.isEmpty()) { // "Create New Session" item selected, return a fresh UUID qsrand(QDateTime::currentDateTimeUtc().toTime_t()); return QUuid::createUuid().toString(); } return selectedSessionId; } QString SessionController::handleLockedSession( const QString& sessionName, const QString& sessionId, const SessionRunInfo& runInfo ) { return SessionLock::handleLockedSession(sessionName, sessionId, runInfo); } QString SessionController::sessionDir() { if( !activeSession() ) return QString(); return d->ownSessionDirectory(); } QString SessionController::sessionName() { if(!activeSession()) return QString(); return activeSession()->description(); } } #include "sessioncontroller.moc" #include "moc_sessioncontroller.cpp" diff --git a/shell/settings/editstyledialog.h b/shell/settings/editstyledialog.h index 926280ffe2..a5a16a7e7a 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 = nullptr); ~EditStyleDialog() override; /** \return The string representing the style given by the \ref SettingsWidget. */ QString content(); protected: void init(); -public slots: +public Q_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/projectpreferences.h b/shell/settings/projectpreferences.h index 74ed1b1228..2fe307566a 100644 --- a/shell/settings/projectpreferences.h +++ b/shell/settings/projectpreferences.h @@ -1,56 +1,56 @@ /* KDevelop Project Settings * * Copyright 2006 Matt Rogers * * 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_PROJECTPREFERENCES_H #define KDEVPLATFORM_PROJECTPREFERENCES_H #include namespace Ui { class ProjectPreferences; } namespace KDevelop { class ProjectPreferences : public ConfigPage { Q_OBJECT public: explicit ProjectPreferences(QWidget *parent); ~ProjectPreferences() override; QString name() const override; QString fullName() const override; QIcon icon() const override; void apply() override; -private slots: +private Q_SLOTS: void slotSettingsChanged(); private: Ui::ProjectPreferences *preferencesDialog; }; } #endif diff --git a/shell/settings/sourceformattersettings.h b/shell/settings/sourceformattersettings.h index 68cfb42c61..505f64e07b 100644 --- a/shell/settings/sourceformattersettings.h +++ b/shell/settings/sourceformattersettings.h @@ -1,97 +1,97 @@ /* 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 "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 = nullptr); ~SourceFormatterSettings() override; QString name() const override; QString fullName() const override; QIcon icon() const override; -public slots: +public Q_SLOTS: void reset() override; void apply() override; void defaults() override; -private slots: +private Q_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/templatepage.h b/shell/settings/templatepage.h index f988e098a8..16d9d43306 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 = nullptr); ~TemplatePage() override; -private slots: +private Q_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/tests/test_checkerstatus.cpp b/shell/tests/test_checkerstatus.cpp index 707da7f90c..8d7510884a 100644 --- a/shell/tests/test_checkerstatus.cpp +++ b/shell/tests/test_checkerstatus.cpp @@ -1,108 +1,108 @@ /* * 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. */ #include #include #include #include using namespace KDevelop; #define MYCOMPARE(actual, expected) \ if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__)) \ return false class TestCheckerStatus : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void testName(); void testStart(); void testItemChecked(); void testStop(); private: QScopedPointer m_status; }; void TestCheckerStatus::initTestCase() { m_status.reset(new CheckerStatus()); } void TestCheckerStatus::cleanupTestCase() { } void TestCheckerStatus::testName() { QString name = QStringLiteral("TESTNAME"); QString s = QStringLiteral("Running ") + name; m_status->setCheckerName(name); QCOMPARE(m_status->statusName(), i18nc("@info:progress", s.toUtf8().data())); } bool checkValues(const QList &signal, int min, int max, int value) { MYCOMPARE(qvariant_cast(signal[1]), min); MYCOMPARE(qvariant_cast(signal[2]), max); MYCOMPARE(qvariant_cast(signal[3]), value); return true; } void TestCheckerStatus::testStart() { QSignalSpy spy(m_status.data(), &CheckerStatus::showProgress); m_status->setMaxItems(100); m_status->start(); QCOMPARE(spy.count(), 1); QVERIFY(checkValues(spy.takeFirst(), 0, 100, 0)); } void TestCheckerStatus::testItemChecked() { QSignalSpy spy(m_status.data(), &CheckerStatus::showProgress); m_status->itemChecked(); QCOMPARE(spy.count(), 1); QVERIFY(checkValues(spy.takeFirst(), 0, 100, 1)); } void TestCheckerStatus::testStop() { QSignalSpy spy(m_status.data(), &CheckerStatus::showProgress); m_status->stop(); QCOMPARE(spy.count(), 1); QVERIFY(checkValues(spy.takeFirst(), 0, 100, 100)); } QTEST_MAIN(TestCheckerStatus) #include "test_checkerstatus.moc" diff --git a/shell/tests/test_detectedproblem.cpp b/shell/tests/test_detectedproblem.cpp index 436728f23d..2633104a39 100644 --- a/shell/tests/test_detectedproblem.cpp +++ b/shell/tests/test_detectedproblem.cpp @@ -1,222 +1,222 @@ /* * 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. */ #include #include #include #include #include #include #include #include using namespace KDevelop; class TestDetectedProblem : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void testSource(); void testSeverity(); void testDescription(); void testExplanation(); void testFinalLocation(); void testDiagnostics(); void testPluginName(); private: IProblem::Ptr m_problem; }; void TestDetectedProblem::initTestCase() { AutoTestShell::init(); TestCore::initialize(Core::NoUi); m_problem = new DetectedProblem(); } void TestDetectedProblem::cleanupTestCase() { TestCore::shutdown(); } struct Source { IProblem::Source source; QString sourceString; }; void TestDetectedProblem::testSource() { static Source sources[] = { { IProblem::Unknown, i18n("Unknown") }, { IProblem::Disk, i18n("Disk") }, { IProblem::Preprocessor, i18n("Preprocessor") }, { IProblem::Lexer, i18n("Lexer") }, { IProblem::Parser, i18n("Parser") }, { IProblem::DUChainBuilder, i18n("DuchainBuilder") }, { IProblem::SemanticAnalysis, i18n("Semantic analysis") }, { IProblem::ToDo, i18n("Todo") }, { IProblem::Plugin, i18n("Plugin") } }; int c = sizeof(sources) / sizeof(Source); for (int i = 0; i < c; i++) { m_problem->setSource(sources[i].source); QCOMPARE(sources[i].source, m_problem->source()); QCOMPARE(sources[i].sourceString, m_problem->sourceString()); } } struct Severity { IProblem::Severity severity; QString severityString; }; void TestDetectedProblem::testSeverity() { static Severity severities[] = { { IProblem::Error, i18n("Error") }, { IProblem::Warning, i18n("Warning") }, { IProblem::Hint, i18n("Hint") }, }; int c = sizeof(severities) / sizeof(Severity); for (int i = 0; i < c; i++) { m_problem->setSeverity(severities[i].severity); QCOMPARE(severities[i].severity, m_problem->severity()); QCOMPARE(severities[i].severityString, m_problem->severityString()); } } void TestDetectedProblem::testDescription() { QString TESTDESCRIPTION = QStringLiteral("Just a test description"); m_problem->setDescription(TESTDESCRIPTION); QCOMPARE(TESTDESCRIPTION, m_problem->description()); } void TestDetectedProblem::testExplanation() { QString TESTEXPLANATION = QStringLiteral("Just a test explanation"); m_problem->setExplanation(TESTEXPLANATION); QCOMPARE(TESTEXPLANATION, m_problem->explanation()); } void TestDetectedProblem::testFinalLocation() { QString TESTPATH = QStringLiteral("/just/a/bogus/path/to/a/fake/document"); int TESTLINE = 9001; int TESTCOLUMN = 1337; DocumentRange range; range.document = IndexedString(TESTPATH); range.setBothLines(TESTLINE); range.setBothColumns(TESTCOLUMN); m_problem->setFinalLocation(range); QCOMPARE(TESTPATH, m_problem->finalLocation().document.str()); QCOMPARE(TESTLINE, m_problem->finalLocation().start().line()); QCOMPARE(TESTLINE, m_problem->finalLocation().end().line()); QCOMPARE(TESTCOLUMN, m_problem->finalLocation().start().column()); QCOMPARE(TESTCOLUMN, m_problem->finalLocation().end().column()); } void TestDetectedProblem::testDiagnostics() { QString one = QStringLiteral("One"); QString two = QStringLiteral("Two"); QString three = QStringLiteral("Three"); IProblem::Ptr p1(new DetectedProblem()); IProblem::Ptr p2(new DetectedProblem()); IProblem::Ptr p3(new DetectedProblem()); p1->setDescription(one); p2->setDescription(two); p3->setDescription(three); QCOMPARE(m_problem->diagnostics().size(), 0); m_problem->addDiagnostic(p1); m_problem->addDiagnostic(p2); m_problem->addDiagnostic(p3); QCOMPARE(m_problem->diagnostics().size(), 3); QCOMPARE(m_problem->diagnostics().at(0)->description(), one); QCOMPARE(m_problem->diagnostics().at(1)->description(), two); QCOMPARE(m_problem->diagnostics().at(2)->description(), three); m_problem->clearDiagnostics(); QCOMPARE(0, m_problem->diagnostics().size()); QVector diags; diags.push_back(p3); diags.push_back(p2); diags.push_back(p1); m_problem->setDiagnostics(diags); QCOMPARE(m_problem->diagnostics().size(), 3); QCOMPARE(m_problem->diagnostics().at(2)->description(), one); QCOMPARE(m_problem->diagnostics().at(1)->description(), two); QCOMPARE(m_problem->diagnostics().at(0)->description(), three); m_problem->clearDiagnostics(); QCOMPARE(m_problem->diagnostics().size(), 0); } void TestDetectedProblem::testPluginName() { DetectedProblem p1(QStringLiteral("Plugin1")); DetectedProblem p2(QStringLiteral("Plugin2")); DetectedProblem p3(QStringLiteral("")); DetectedProblem p4; QCOMPARE(p1.source(), IProblem::Plugin); QCOMPARE(p2.source(), IProblem::Plugin); QCOMPARE(p3.source(), IProblem::Plugin); QCOMPARE(p4.source(), IProblem::Unknown); QCOMPARE(p1.sourceString(), QStringLiteral("Plugin1")); QCOMPARE(p2.sourceString(), QStringLiteral("Plugin2")); QCOMPARE(p3.sourceString(), QStringLiteral("")); QCOMPARE(p4.sourceString(), i18n("Unknown")); p4.setSource(IProblem::Plugin); QCOMPARE(p4.source(), IProblem::Plugin); QCOMPARE(p4.sourceString(), i18n("Plugin")); } QTEST_MAIN(TestDetectedProblem) #include "test_detectedproblem.moc" diff --git a/shell/tests/test_documentcontroller.h b/shell/tests/test_documentcontroller.h index 58d9856718..2c99bfd3ba 100644 --- a/shell/tests/test_documentcontroller.h +++ b/shell/tests/test_documentcontroller.h @@ -1,62 +1,62 @@ /* Unit tests for DocumentController. Copyright 2011 Damien Flament 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_TEST_DOCUMENTCONTROLLER_H #define KDEVPLATFORM_TEST_DOCUMENTCONTROLLER_H #include #include #include #include namespace KDevelop { class IDocument; class IDocumentController; } using namespace KDevelop; class TestDocumentController : public QObject { Q_OBJECT -private slots : +private Q_SLOTS: void initTestCase(); void init(); void cleanup(); void cleanupTestCase(); void testOpeningNewDocumentFromText(); void testOpeningDocumentFromUrl(); void testSaveSomeDocuments(); void testSaveAllDocuments(); void testCloseAllDocuments(); void testEmptyUrl(); private : QUrl createFile(const QTemporaryDir& dir, const QString& filename); IDocumentController* m_subject; QTemporaryDir m_tempDir; QTemporaryFile m_file1; QTemporaryFile m_file2; }; #endif // KDEVPLATFORM_TEST_DOCUMENTCONTROLLER_H diff --git a/shell/tests/test_filteredproblemstore.cpp b/shell/tests/test_filteredproblemstore.cpp index 05c5cbdae0..c601f6a103 100644 --- a/shell/tests/test_filteredproblemstore.cpp +++ b/shell/tests/test_filteredproblemstore.cpp @@ -1,682 +1,682 @@ /* * 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. */ #include #include #include #include #include #include #include #include #include #include namespace { const int ErrorCount = 1; const int WarningCount = 2; const int HintCount = 3; const int ProblemsCount = ErrorCount + WarningCount + HintCount; const int ErrorFilterProblemCount = ErrorCount; const int WarningFilterProblemCount = ErrorCount + WarningCount; const int HintFilterProblemCount = ErrorCount + WarningCount + HintCount; } using namespace KDevelop; class TestFilteredProblemStore : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void testSeverity(); void testSeverities(); void testGrouping(); void testNoGrouping(); void testPathGrouping(); void testSeverityGrouping(); private: // Severity grouping testing bool checkCounts(int error, int warning, int hint); bool checkNodeLabels(); // --------------------------- void generateProblems(); QScopedPointer m_store; QVector m_problems; IProblem::Ptr m_diagnosticTestProblem; }; #define MYCOMPARE(actual, expected) \ if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__)) \ return false #define MYVERIFY(statement) \ if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\ return false void TestFilteredProblemStore::initTestCase() { AutoTestShell::init(); TestCore::initialize(Core::NoUi); m_store.reset(new FilteredProblemStore()); generateProblems(); } void TestFilteredProblemStore::cleanupTestCase() { TestCore::shutdown(); } void TestFilteredProblemStore::testSeverity() { QVERIFY(m_store->severity() == IProblem::Hint); QSignalSpy changedSpy(m_store.data(), &FilteredProblemStore::changed); QSignalSpy beginRebuildSpy(m_store.data(), &FilteredProblemStore::beginRebuild); QSignalSpy endRebuildSpy(m_store.data(), &FilteredProblemStore::endRebuild); m_store->setSeverity(IProblem::Error); QVERIFY(m_store->severity() == IProblem::Error); QCOMPARE(changedSpy.count(), 1); QCOMPARE(beginRebuildSpy.count(), 1); QCOMPARE(endRebuildSpy.count(), 1); m_store->setSeverity(IProblem::Hint); } void TestFilteredProblemStore::testSeverities() { QVERIFY(m_store->severities() == (IProblem::Error | IProblem::Warning | IProblem::Hint)); QSignalSpy changedSpy(m_store.data(), &FilteredProblemStore::changed); QSignalSpy beginRebuildSpy(m_store.data(), &FilteredProblemStore::beginRebuild); QSignalSpy endRebuildSpy(m_store.data(), &FilteredProblemStore::endRebuild); m_store->setSeverities(IProblem::Error | IProblem::Hint); QVERIFY(m_store->severities() == (IProblem::Error | IProblem::Hint)); QCOMPARE(changedSpy.count(), 1); QCOMPARE(beginRebuildSpy.count(), 1); QCOMPARE(endRebuildSpy.count(), 1); m_store->setSeverities(IProblem::Error | IProblem::Warning | IProblem::Hint); } void TestFilteredProblemStore::testGrouping() { QVERIFY(m_store->grouping() == NoGrouping); QSignalSpy changedSpy(m_store.data(), &FilteredProblemStore::changed); QSignalSpy beginRebuildSpy(m_store.data(), &FilteredProblemStore::beginRebuild); QSignalSpy endRebuildSpy(m_store.data(), &FilteredProblemStore::endRebuild); m_store->setGrouping(PathGrouping); QVERIFY(m_store->grouping() == PathGrouping); QCOMPARE(changedSpy.count(), 1); QCOMPARE(beginRebuildSpy.count(), 1); QCOMPARE(endRebuildSpy.count(), 1); m_store->setGrouping(NoGrouping); } // Compares the node and it's children to a reference problem and it's diagnostics bool checkDiagnodes(const ProblemStoreNode *node, const IProblem::Ptr &reference) { const ProblemNode *problemNode = dynamic_cast(node); MYVERIFY(problemNode); MYCOMPARE(problemNode->problem()->description(), reference->description()); MYCOMPARE(problemNode->problem()->finalLocation().document.str(), reference->finalLocation().document.str()); MYCOMPARE(problemNode->count(), 1); const IProblem::Ptr diag = reference->diagnostics().at(0); const ProblemNode *diagNode = dynamic_cast(problemNode->child(0)); MYVERIFY(diagNode); MYCOMPARE(diagNode->problem()->description(), diag->description()); MYCOMPARE(diagNode->count(), 1); const IProblem::Ptr diagdiag = diag->diagnostics().at(0); const ProblemNode *diagdiagNode = dynamic_cast(diagNode->child(0)); MYVERIFY(diagdiagNode); MYCOMPARE(diagdiagNode->problem()->description(), diagdiag->description()); MYCOMPARE(diagdiagNode->count(), 0); return true; } void TestFilteredProblemStore::testNoGrouping() { // Add problems int c = 0; foreach (const IProblem::Ptr &p, m_problems) { m_store->addProblem(p); c++; QCOMPARE(m_store->count(), c); } for (int i = 0; i < c; i++) { const ProblemNode *node = dynamic_cast(m_store->findNode(i)); QVERIFY(node); QCOMPARE(node->problem()->description(), m_problems[i]->description()); } // Check if clear works m_store->clear(); QCOMPARE(m_store->count(), 0); // Set problems m_store->setProblems(m_problems); QCOMPARE(m_problems.count(), m_store->count()); for (int i = 0; i < c; i++) { const ProblemNode *node = dynamic_cast(m_store->findNode(i)); QVERIFY(node); QCOMPARE(node->problem()->description(), m_problems[i]->description()); } // Check old style severity filtering // old-style setSeverity // Error filter m_store->setSeverity(IProblem::Error); QCOMPARE(m_store->count(), ErrorFilterProblemCount); for (int i = 0; i < ErrorFilterProblemCount; i++) { const ProblemNode *node = dynamic_cast(m_store->findNode(0)); QVERIFY(node); QCOMPARE(node->problem()->description(), m_problems[i]->description()); } // Warning filter m_store->setSeverity(IProblem::Warning); QCOMPARE(m_store->count(), WarningFilterProblemCount); for (int i = 0; i < WarningFilterProblemCount; i++) { const ProblemNode *node = dynamic_cast(m_store->findNode(i)); QVERIFY(node); QCOMPARE(node->problem()->description(), m_problems[i]->description()); } // Hint filter m_store->setSeverity(IProblem::Hint); QCOMPARE(m_store->count(), HintFilterProblemCount); for (int i = 0; i < HintFilterProblemCount; i++) { const ProblemNode *node = dynamic_cast(m_store->findNode(i)); QVERIFY(node); QCOMPARE(node->problem()->description(), m_problems[i]->description()); } // Check new severity filtering // Error filter m_store->setSeverities(IProblem::Error); QCOMPARE(m_store->count(), ErrorCount); for (int i = 0; i < ErrorCount; i++) { const ProblemNode *node = dynamic_cast(m_store->findNode(i)); QVERIFY(node); QCOMPARE(node->problem()->description(), m_problems[i]->description()); } // Warning filter m_store->setSeverities(IProblem::Warning); QCOMPARE(m_store->count(), WarningCount); for (int i = 0; i < WarningCount; i++) { const ProblemNode *node = dynamic_cast(m_store->findNode(i)); QVERIFY(node); QCOMPARE(node->problem()->description(), m_problems[i+ErrorCount]->description()); } // Hint filter m_store->setSeverities(IProblem::Hint); QCOMPARE(m_store->count(), HintCount); for (int i = 0; i < HintCount; i++) { const ProblemNode *node = dynamic_cast(m_store->findNode(i)); QVERIFY(node); QCOMPARE(node->problem()->description(), m_problems[i+ErrorCount+WarningCount]->description()); } //Error + Hint filter m_store->setSeverities(IProblem::Error | IProblem::Hint); QCOMPARE(m_store->count(), HintCount + ErrorCount); for (int i = 0; i < ErrorCount; i++) { const ProblemNode *node = dynamic_cast(m_store->findNode(i)); QVERIFY(node); QCOMPARE(node->problem()->description(), m_problems[i]->description()); } for (int i = ErrorCount; i < ErrorCount+HintCount; i++) { const ProblemNode *node = dynamic_cast(m_store->findNode(i)); QVERIFY(node); QCOMPARE(node->problem()->description(), m_problems[i+WarningCount]->description()); } m_store->setSeverities(IProblem::Error | IProblem::Warning | IProblem::Hint); m_store->clear(); // Check if diagnostics are added properly m_store->addProblem(m_diagnosticTestProblem); QCOMPARE(m_store->count(), 1); QVERIFY(checkDiagnodes(m_store->findNode(0), m_diagnosticTestProblem)); } bool checkNodeLabel(const ProblemStoreNode *node, const QString &label) { const LabelNode *parent = dynamic_cast(node); MYVERIFY(parent); MYCOMPARE(parent->label(), label); return true; } bool checkNodeDescription(const ProblemStoreNode *node, const QString &descr) { const ProblemNode *n = dynamic_cast(node); MYVERIFY(n); MYCOMPARE(n->problem()->description(), descr); return true; } void TestFilteredProblemStore::testPathGrouping() { m_store->clear(); // Rebuild the problem list with grouping m_store->setGrouping(PathGrouping); // Add problems foreach (const IProblem::Ptr &p, m_problems) { m_store->addProblem(p); } QCOMPARE(m_store->count(), ProblemsCount); for (int i = 0; i < 3; i++) { const ProblemStoreNode *node = m_store->findNode(i); checkNodeLabel(node, m_problems[i]->finalLocation().document.str()); QCOMPARE(node->count(), 1); checkNodeDescription(node->child(0), m_problems[i]->description()); } // Now add a new problem IProblem::Ptr p(new DetectedProblem()); p->setDescription(QStringLiteral("PROBLEM4")); p->setFinalLocation(m_problems[2]->finalLocation()); m_store->addProblem(p); QCOMPARE(m_store->count(), ProblemsCount); // Check the first 2 top-nodes for (int i = 0; i < 2; i++) { const ProblemStoreNode *node = m_store->findNode(i); checkNodeLabel(node, m_problems[i]->finalLocation().document.str()); QCOMPARE(node->count(), 1); checkNodeDescription(node->child(0), m_problems[i]->description()); } // check the last one, and check the added problem is at the right place { const ProblemStoreNode *node = m_store->findNode(2); checkNodeLabel(node, m_problems[2]->finalLocation().document.str()); QCOMPARE(node->count(), 2); checkNodeDescription(node->child(1), p->description()); } m_store->clear(); m_store->setProblems(m_problems); // Check filters // old-style setSeverity // Error filter m_store->setSeverity(IProblem::Error); QCOMPARE(m_store->count(), ErrorFilterProblemCount); { const ProblemStoreNode *node = m_store->findNode(0); checkNodeLabel(node, m_problems[0]->finalLocation().document.str()); QCOMPARE(node->count(), 1); checkNodeDescription(node->child(0), m_problems[0]->description()); } // Warning filter m_store->setSeverity(IProblem::Warning); QCOMPARE(m_store->count(), WarningFilterProblemCount); for (int i = 0; i < WarningFilterProblemCount; i++) { const ProblemStoreNode *node = m_store->findNode(i); checkNodeLabel(node, m_problems[i]->finalLocation().document.str()); QCOMPARE(node->count(), 1); checkNodeDescription(node->child(0), m_problems[i]->description()); } // Hint filter m_store->setSeverity(IProblem::Hint); QCOMPARE(m_store->count(), HintFilterProblemCount); for (int i = 0; i < HintFilterProblemCount; i++) { const ProblemStoreNode *node = m_store->findNode(i); checkNodeLabel(node, m_problems[i]->finalLocation().document.str()); QCOMPARE(node->count(), 1); checkNodeDescription(node->child(0), m_problems[i]->description()); } // Check new severity filtering // Error filter m_store->setSeverities(IProblem::Error); for (int i = 0; i < ErrorCount; i++) { const ProblemStoreNode *node = m_store->findNode(i); checkNodeLabel(node, m_problems[i]->finalLocation().document.str()); QCOMPARE(node->count(), 1); checkNodeDescription(node->child(0), m_problems[i]->description()); } // Warning filter m_store->setSeverities(IProblem::Warning); for (int i = 0; i < WarningCount; i++) { const ProblemStoreNode *node = m_store->findNode(i); checkNodeLabel(node, m_problems[i+ErrorCount]->finalLocation().document.str()); QCOMPARE(node->count(), 1); checkNodeDescription(node->child(0), m_problems[i+ErrorCount]->description()); } // Hint filter m_store->setSeverities(IProblem::Hint); for (int i = 0; i < HintCount; i++) { const ProblemStoreNode *node = m_store->findNode(i); checkNodeLabel(node, m_problems[i+ErrorCount+WarningCount]->finalLocation().document.str()); QCOMPARE(node->count(), 1); checkNodeDescription(node->child(0), m_problems[i+ErrorCount+WarningCount]->description()); } //Error + Hint filter m_store->setSeverities(IProblem::Error | IProblem::Hint); QCOMPARE(m_store->count(), HintCount + ErrorCount); for (int i = 0; i < ErrorCount; i++) { const ProblemStoreNode *node = m_store->findNode(i); checkNodeLabel(node, m_problems[i]->finalLocation().document.str()); QCOMPARE(node->count(), 1); checkNodeDescription(node->child(0), m_problems[i]->description()); } for (int i = ErrorCount; i < ErrorCount+HintCount; i++) { const ProblemStoreNode *node = m_store->findNode(i); checkNodeLabel(node, m_problems[i+WarningCount]->finalLocation().document.str()); QCOMPARE(node->count(), 1); checkNodeDescription(node->child(0), m_problems[i+WarningCount]->description()); } m_store->setSeverities(IProblem::Error | IProblem::Warning | IProblem::Hint); m_store->clear(); // Check if the diagnostics are added properly m_store->addProblem(m_diagnosticTestProblem); QCOMPARE(m_store->count(), 1); const LabelNode *node = dynamic_cast(m_store->findNode(0)); QVERIFY(node); QCOMPARE(node->label(), m_diagnosticTestProblem->finalLocation().document.str()); QVERIFY(checkDiagnodes(node->child(0), m_diagnosticTestProblem)); } void TestFilteredProblemStore::testSeverityGrouping() { m_store->clear(); m_store->setGrouping(SeverityGrouping); QCOMPARE(m_store->count(), 3); const ProblemStoreNode *errorNode = m_store->findNode(0); const ProblemStoreNode *warningNode = m_store->findNode(1); const ProblemStoreNode *hintNode = m_store->findNode(2); // Add problems for (int i=0;iaddProblem(m_problems[i]); int severityType = 0; //error int addedCountOfCurrentSeverityType = i + 1; if (i>=ErrorCount) { severityType = 1; //warning addedCountOfCurrentSeverityType = i - ErrorCount + 1; } if (i>=ErrorCount+WarningCount) { severityType = 2; //hint addedCountOfCurrentSeverityType = i - (ErrorCount + WarningCount) + 1; } QCOMPARE(m_store->findNode(severityType)->count(), addedCountOfCurrentSeverityType); } QVERIFY(checkNodeLabels()); QVERIFY(checkCounts(ErrorCount, WarningCount, HintCount)); checkNodeDescription(errorNode->child(0), m_problems[0]->description()); checkNodeDescription(warningNode->child(0), m_problems[1]->description()); checkNodeDescription(hintNode->child(0), m_problems[3]->description()); // Clear m_store->clear(); QCOMPARE(m_store->count(), 3); QVERIFY(checkCounts(0,0,0)); // Set problems m_store->setProblems(m_problems); QCOMPARE(m_store->count(), 3); QVERIFY(checkNodeLabels()); QVERIFY(checkCounts(ErrorCount, WarningCount, HintCount)); checkNodeDescription(errorNode->child(0), m_problems[0]->description()); checkNodeDescription(warningNode->child(0), m_problems[1]->description()); checkNodeDescription(hintNode->child(0), m_problems[3]->description()); // Check severity filter // old-style setSeverity // Error filter m_store->setSeverity(IProblem::Error); QCOMPARE(m_store->count(), 3); QVERIFY(checkNodeLabels()); QVERIFY(checkCounts(ErrorCount, 0, 0)); checkNodeDescription(errorNode->child(0), m_problems[0]->description()); // Warning filter m_store->setSeverity(IProblem::Warning); QCOMPARE(m_store->count(), 3); checkNodeLabels(); QVERIFY(checkCounts(ErrorCount, WarningCount, 0)); checkNodeDescription(errorNode->child(0), m_problems[0]->description()); checkNodeDescription(warningNode->child(0), m_problems[1]->description()); // Hint filter m_store->setSeverity(IProblem::Hint); QCOMPARE(m_store->count(), 3); QVERIFY(checkNodeLabels()); QVERIFY(checkCounts(ErrorCount, WarningCount, HintCount)); checkNodeDescription(errorNode->child(0), m_problems[0]->description()); checkNodeDescription(warningNode->child(0), m_problems[1]->description()); checkNodeDescription(hintNode->child(0), m_problems[3]->description()); // Check severity filter // Error filter m_store->setSeverities(IProblem::Error); QCOMPARE(m_store->count(), 3); QVERIFY(checkNodeLabels()); QVERIFY(checkCounts(ErrorCount, 0, 0)); checkNodeDescription(errorNode->child(0), m_problems[0]->description()); // Warning filter m_store->setSeverities(IProblem::Warning); QCOMPARE(m_store->count(), 3); QVERIFY(checkNodeLabels()); QVERIFY(checkCounts(0, WarningCount, 0)); checkNodeDescription(warningNode->child(0), m_problems[1]->description()); // Hint filter m_store->setSeverities(IProblem::Hint); QCOMPARE(m_store->count(), 3); QVERIFY(checkNodeLabels()); QVERIFY(checkCounts(0, 0, HintCount)); checkNodeDescription(hintNode->child(0), m_problems[3]->description()); // Error + Hint filter m_store->setSeverities(IProblem::Error | IProblem::Hint); QCOMPARE(m_store->count(), 3); QVERIFY(checkNodeLabels()); QVERIFY(checkCounts(ErrorCount, 0, HintCount)); checkNodeDescription(errorNode->child(0), m_problems[0]->description()); checkNodeDescription(hintNode->child(0), m_problems[3]->description()); m_store->setSeverities(IProblem::Error | IProblem::Warning | IProblem::Hint); m_store->clear(); // Check if diagnostics are added properly m_store->addProblem(m_diagnosticTestProblem); QVERIFY(checkNodeLabels()); QVERIFY(checkCounts(1, 0, 0)); QVERIFY(checkDiagnodes(m_store->findNode(0)->child(0), m_diagnosticTestProblem)); } bool TestFilteredProblemStore::checkCounts(int error, int warning, int hint) { const ProblemStoreNode *errorNode = m_store->findNode(0); const ProblemStoreNode *warningNode = m_store->findNode(1); const ProblemStoreNode *hintNode = m_store->findNode(2); MYVERIFY(errorNode); MYVERIFY(warningNode); MYVERIFY(hintNode); MYCOMPARE(errorNode->count(), error); MYCOMPARE(warningNode->count(), warning); MYCOMPARE(hintNode->count(), hint); return true; } bool TestFilteredProblemStore::checkNodeLabels() { const ProblemStoreNode *errorNode = m_store->findNode(0); const ProblemStoreNode *warningNode = m_store->findNode(1); const ProblemStoreNode *hintNode = m_store->findNode(2); MYCOMPARE(checkNodeLabel(errorNode, i18n("Error")), true); MYCOMPARE(checkNodeLabel(warningNode, i18n("Warning")), true); MYCOMPARE(checkNodeLabel(hintNode, i18n("Hint")), true); return true; } // Generate 3 problems, all with different paths, different severity // Also generates a problem with diagnostics void TestFilteredProblemStore::generateProblems() { IProblem::Ptr p1(new DetectedProblem()); IProblem::Ptr p2(new DetectedProblem()); IProblem::Ptr p3(new DetectedProblem()); IProblem::Ptr p4(new DetectedProblem()); IProblem::Ptr p5(new DetectedProblem()); IProblem::Ptr p6(new DetectedProblem()); DocumentRange r1; r1.document = IndexedString("/just/a/random/path"); p1->setDescription(QStringLiteral("PROBLEM1")); p1->setSeverity(IProblem::Error); p1->setFinalLocation(r1); DocumentRange r2; r2.document = IndexedString("/just/another/path"); p2->setDescription(QStringLiteral("PROBLEM2")); p2->setSeverity(IProblem::Warning); p2->setFinalLocation(r2); DocumentRange r3; r3.document = IndexedString("/just/another/pathy/patha"); p3->setDescription(QStringLiteral("PROBLEM3")); p3->setSeverity(IProblem::Warning); p3->setFinalLocation(r3); DocumentRange r4; r4.document = IndexedString("/yet/another/test/path"); p4->setDescription(QStringLiteral("PROBLEM4")); p4->setSeverity(IProblem::Hint); p4->setFinalLocation(r4); DocumentRange r5; r5.document = IndexedString("/yet/another/pathy/test/path"); p5->setDescription(QStringLiteral("PROBLEM5")); p5->setSeverity(IProblem::Hint); p5->setFinalLocation(r5); DocumentRange r6; r6.document = IndexedString("/yet/another/test/pathy/path"); p6->setDescription(QStringLiteral("PROBLEM6")); p6->setSeverity(IProblem::Hint); p6->setFinalLocation(r6); m_problems.push_back(p1); m_problems.push_back(p2); m_problems.push_back(p3); m_problems.push_back(p4); m_problems.push_back(p5); m_problems.push_back(p6); // Problem for diagnostic testing IProblem::Ptr p(new DetectedProblem()); DocumentRange r; r.document = IndexedString("DIAGTEST"); p->setFinalLocation(r); p->setDescription(QStringLiteral("PROBLEM")); p->setSeverity(IProblem::Error); IProblem::Ptr d(new DetectedProblem()); d->setDescription(QStringLiteral("DIAG")); IProblem::Ptr dd(new DetectedProblem()); dd->setDescription(QStringLiteral("DIAGDIAG")); d->addDiagnostic(dd); p->addDiagnostic(d); m_diagnosticTestProblem = p; } QTEST_MAIN(TestFilteredProblemStore) #include "test_filteredproblemstore.moc" diff --git a/shell/tests/test_ktexteditorpluginintegration.h b/shell/tests/test_ktexteditorpluginintegration.h index ba5592b4a1..eadee8839a 100644 --- a/shell/tests/test_ktexteditorpluginintegration.h +++ b/shell/tests/test_ktexteditorpluginintegration.h @@ -1,40 +1,40 @@ /* Copyright 2015 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_TEST_KTEXTEDITORPLUGININTEGRATION_H #define KDEVPLATFORM_TEST_KTEXTEDITORPLUGININTEGRATION_H #include class TestKTextEditorPluginIntegration : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void testApplication(); void testMainWindow(); void testPlugin(); void testPluginUnload(); }; #endif // KDEVPLATFORM_TEST_KTEXTEDITORPLUGININTEGRATION_H \ No newline at end of file diff --git a/shell/tests/test_plugincontroller.h b/shell/tests/test_plugincontroller.h index 6941fc0462..0675ae5d2c 100644 --- a/shell/tests/test_plugincontroller.h +++ b/shell/tests/test_plugincontroller.h @@ -1,49 +1,49 @@ /*************************************************************************** * Copyright 2008 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_TEST_PLUGINCONTROLLER_H #define KDEVPLATFORM_TEST_PLUGINCONTROLLER_H #include namespace KDevelop { class Core; class PluginController; } class TestPluginController : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void init(); void cleanup(); void loadUnloadPlugin(); void loadFromExtension(); void pluginInfo(); void benchPluginForExtension(); private: KDevelop::PluginController* m_pluginCtrl; }; #endif // KDEVPLATFORM_TEST_PLUGINCONTROLLER_H diff --git a/shell/tests/test_problemmodel.cpp b/shell/tests/test_problemmodel.cpp index 828f00a02f..0a62d636b0 100644 --- a/shell/tests/test_problemmodel.cpp +++ b/shell/tests/test_problemmodel.cpp @@ -1,515 +1,515 @@ /* * 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. */ #include #include #include #include #include #include #include #include #define MYCOMPARE(actual, expected) \ if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__)) \ return false #define MYVERIFY(statement) \ if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\ return false using namespace KDevelop; class TestProblemModel : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void testNoGrouping(); void testPathGrouping(); void testSeverityGrouping(); private: void generateProblems(); bool checkIsSame(int row, const QModelIndex &parent, const IProblem::Ptr &problem); bool checkDiagnostics(int row, const QModelIndex &parent); bool checkDisplay(int row, const QModelIndex &parent, const IProblem::Ptr &problem); bool checkLabel(int row, const QModelIndex &parent, const QString &label); bool checkPathGroup(int row, const IProblem::Ptr &problem); bool checkSeverityGroup(int row, const IProblem::Ptr &problem); QScopedPointer m_model; QVector m_problems; IProblem::Ptr m_diagnosticTestProblem; }; void TestProblemModel::initTestCase() { AutoTestShell::init(); TestCore::initialize(Core::NoUi); m_model.reset(new ProblemModel(nullptr)); m_model->setScope(BypassScopeFilter); generateProblems(); } void TestProblemModel::cleanupTestCase() { TestCore::shutdown(); } void TestProblemModel::testNoGrouping() { m_model->setGrouping(NoGrouping); m_model->setSeverity(IProblem::Hint); QCOMPARE(m_model->rowCount(), 0); // Check if setting the problems works m_model->setProblems(m_problems); QCOMPARE(m_model->rowCount(), 3); for (int i = 0; i < m_model->rowCount(); i++) { QVERIFY(checkIsSame(i, QModelIndex(), m_problems[i])); } // Check if displaying various data parts works QVERIFY(checkDisplay(0, QModelIndex(), m_problems[0])); // Check if clearing the problems works m_model->clearProblems(); QCOMPARE(m_model->rowCount(), 0); // Check if adding the problems works int c = 0; foreach (const IProblem::Ptr &p, m_problems) { m_model->addProblem(p); c++; QCOMPARE(m_model->rowCount(), c); } for (int i = 0; i < m_model->rowCount(); i++) { QVERIFY(checkIsSame(i, QModelIndex(), m_problems[i])); } // Check if filtering works // old-style setSeverity // Error filter m_model->setSeverity(IProblem::Error); QCOMPARE(m_model->rowCount(), 1); QVERIFY(checkIsSame(0, QModelIndex(), m_problems[0])); // Warning filter m_model->setSeverity(IProblem::Warning); QCOMPARE(m_model->rowCount(), 2); QVERIFY(checkIsSame(0, QModelIndex(), m_problems[0])); QVERIFY(checkIsSame(1, QModelIndex(), m_problems[1])); // Hint filter m_model->setSeverity(IProblem::Hint); QCOMPARE(m_model->rowCount(), 3); QVERIFY(checkIsSame(0, QModelIndex(), m_problems[0])); QVERIFY(checkIsSame(1, QModelIndex(), m_problems[1])); QVERIFY(checkIsSame(2, QModelIndex(), m_problems[2])); // Check if filtering works // new style // Error filter m_model->setSeverities(IProblem::Error); QCOMPARE(m_model->rowCount(), 1); QVERIFY(checkIsSame(0, QModelIndex(), m_problems[0])); // Warning filter m_model->setSeverities(IProblem::Warning); QCOMPARE(m_model->rowCount(), 1); QVERIFY(checkIsSame(0, QModelIndex(), m_problems[1])); // Hint filter m_model->setSeverities(IProblem::Hint); QCOMPARE(m_model->rowCount(), 1); QVERIFY(checkIsSame(0, QModelIndex(), m_problems[2])); // Error + Hint filter m_model->setSeverities(IProblem::Error | IProblem::Hint); QCOMPARE(m_model->rowCount(), 2); QVERIFY(checkIsSame(0, QModelIndex(), m_problems[0])); QVERIFY(checkIsSame(1, QModelIndex(), m_problems[2])); m_model->setSeverities(IProblem::Error | IProblem::Warning | IProblem::Hint); // Check if diagnostics are added properly m_model->clearProblems(); m_model->addProblem(m_diagnosticTestProblem); QVERIFY(checkDiagnostics(0, QModelIndex())); m_model->clearProblems(); } void TestProblemModel::testPathGrouping() { m_model->setGrouping(PathGrouping); m_model->setSeverity(IProblem::Hint); QCOMPARE(m_model->rowCount(), 0); // Check if setting problems works m_model->setProblems(m_problems); QCOMPARE(m_model->rowCount(), 3); for (int i = 0; i < m_model->rowCount(); i++) { QVERIFY(checkLabel(i, QModelIndex(), m_problems[i]->finalLocation().document.str())); QModelIndex idx = m_model->index(i, 0); QVERIFY(idx.isValid()); QVERIFY(checkIsSame(0, idx, m_problems[i])); } // Check if displaying various data parts works { QModelIndex idx = m_model->index(0, 0); QVERIFY(idx.isValid()); QVERIFY(checkDisplay(0, idx, m_problems[0])); } // Check if clearing works m_model->clearProblems(); QCOMPARE(m_model->rowCount(), 0); // Check if add problems works int c = 0; foreach (const IProblem::Ptr &p, m_problems) { m_model->addProblem(p); c++; QCOMPARE(m_model->rowCount(), c); } for (int i = 0; i < m_model->rowCount(); i++) { QVERIFY(checkLabel(i, QModelIndex(), m_problems[i]->finalLocation().document.str())); QModelIndex idx = m_model->index(i, 0); QVERIFY(idx.isValid()); QVERIFY(checkIsSame(0, idx, m_problems[i])); } // Check if filtering works // old-style setSeverity // Error filtering m_model->setSeverity(IProblem::Error); QCOMPARE(m_model->rowCount(), 1); QVERIFY(checkPathGroup(0, m_problems[0])); // Warning filtering m_model->setSeverity(IProblem::Warning); QCOMPARE(m_model->rowCount(), 2); QVERIFY(checkPathGroup(0, m_problems[0])); QVERIFY(checkPathGroup(1, m_problems[1])); // Hint filtering m_model->setSeverity(IProblem::Hint); QCOMPARE(m_model->rowCount(), 3); QVERIFY(checkPathGroup(0, m_problems[0])); QVERIFY(checkPathGroup(1, m_problems[1])); QVERIFY(checkPathGroup(2, m_problems[2])); // Check if filtering works // new style // Error filtering m_model->setSeverities(IProblem::Error); QCOMPARE(m_model->rowCount(), 1); QVERIFY(checkPathGroup(0, m_problems[0])); // Warning filtering m_model->setSeverities(IProblem::Warning); QCOMPARE(m_model->rowCount(), 1); QVERIFY(checkPathGroup(0, m_problems[1])); // Hint filtering m_model->setSeverities(IProblem::Hint); QCOMPARE(m_model->rowCount(), 1);; QVERIFY(checkPathGroup(0, m_problems[2])); // Error + Hint filtering m_model->setSeverities(IProblem::Error | IProblem::Hint); QCOMPARE(m_model->rowCount(), 2); QVERIFY(checkPathGroup(0, m_problems[0])); QVERIFY(checkPathGroup(1, m_problems[2])); m_model->setSeverities(IProblem::Error | IProblem::Warning | IProblem::Hint); // Check if diagnostics get to the right place m_model->clearProblems(); m_model->addProblem(m_diagnosticTestProblem); { QModelIndex parent = m_model->index(0, 0); QVERIFY(parent.isValid()); checkDiagnostics(0, parent); } m_model->clearProblems(); } void TestProblemModel::testSeverityGrouping() { m_model->setGrouping(SeverityGrouping); m_model->setSeverity(IProblem::Hint); QCOMPARE(m_model->rowCount(), 3); // Check if setting problems works m_model->setProblems(m_problems); QCOMPARE(m_model->rowCount(), 3); for (int i = 0; i < m_model->rowCount(); i++) { QVERIFY(checkSeverityGroup(i, m_problems[i])); } // Check if displaying works for (int i = 0; i < m_model->rowCount(); i++) { QModelIndex parent = m_model->index(i, 0); QVERIFY(parent.isValid()); QVERIFY(checkDisplay(0, parent, m_problems[i])); } // Check if clearing works m_model->clearProblems(); QCOMPARE(m_model->rowCount(), 3); // Check if adding problems works int c = 0; foreach (const IProblem::Ptr &p, m_problems) { m_model->addProblem(p); QVERIFY(checkSeverityGroup(c, m_problems[c])); c++; } // Check if filtering works // old-style setSeverity // Error filtering m_model->setSeverity(IProblem::Error); QCOMPARE(m_model->rowCount(), 3); checkSeverityGroup(0, m_problems[0]); // Warning filtering m_model->setSeverity(IProblem::Warning); QCOMPARE(m_model->rowCount(), 3); checkSeverityGroup(0, m_problems[0]); checkSeverityGroup(1, m_problems[1]); // Hint filtering m_model->setSeverity(IProblem::Hint); QCOMPARE(m_model->rowCount(), 3); checkSeverityGroup(0, m_problems[0]); checkSeverityGroup(1, m_problems[1]); checkSeverityGroup(2, m_problems[2]); // Check if filtering works // Error filtering m_model->setSeverities(IProblem::Error); QCOMPARE(m_model->rowCount(), 3); checkSeverityGroup(0, m_problems[0]); // Warning filtering m_model->setSeverities(IProblem::Warning); QCOMPARE(m_model->rowCount(), 3); checkSeverityGroup(1, m_problems[1]); // Hint filtering m_model->setSeverities(IProblem::Hint); QCOMPARE(m_model->rowCount(), 3); checkSeverityGroup(2, m_problems[2]); // Error + Hint filtering m_model->setSeverities(IProblem::Error | IProblem::Hint); QCOMPARE(m_model->rowCount(), 3); checkSeverityGroup(0, m_problems[0]); checkSeverityGroup(2, m_problems[2]); m_model->setSeverities(IProblem::Error | IProblem::Warning | IProblem::Hint); // Check if diagnostics get to the right place m_model->clearProblems(); m_model->addProblem(m_diagnosticTestProblem); { QModelIndex parent = m_model->index(0, 0); QVERIFY(parent.isValid()); checkDiagnostics(0, parent); } m_model->clearProblems(); } // Generate 3 problems, all with different paths, different severity // Also generates a problem with diagnostics void TestProblemModel::generateProblems() { IProblem::Ptr p1(new DetectedProblem()); IProblem::Ptr p2(new DetectedProblem()); IProblem::Ptr p3(new DetectedProblem()); DocumentRange r1; r1.document = IndexedString("/just/a/random/path"); p1->setDescription(QStringLiteral("PROBLEM1")); p1->setSeverity(IProblem::Error); p1->setFinalLocation(r1); DocumentRange r2; r2.document = IndexedString("/just/another/path"); p2->setDescription(QStringLiteral("PROBLEM2")); p2->setSeverity(IProblem::Warning); p2->setFinalLocation(r2); DocumentRange r3; r3.document = IndexedString("/yet/another/test/path"); p2->setDescription(QStringLiteral("PROBLEM3")); p3->setSeverity(IProblem::Hint); p3->setFinalLocation(r3); m_problems.push_back(p1); m_problems.push_back(p2); m_problems.push_back(p3); // Problem for diagnostic testing IProblem::Ptr p(new DetectedProblem()); DocumentRange r; r.document = IndexedString("DIAGTEST"); p->setFinalLocation(r); p->setDescription(QStringLiteral("PROBLEM")); p->setSeverity(IProblem::Error); IProblem::Ptr d(new DetectedProblem()); d->setDescription(QStringLiteral("DIAG")); IProblem::Ptr dd(new DetectedProblem()); dd->setDescription(QStringLiteral("DIAGDIAG")); d->addDiagnostic(dd); p->addDiagnostic(d); m_diagnosticTestProblem = p; } bool TestProblemModel::checkIsSame(int row, const QModelIndex &parent, const IProblem::Ptr &problem) { QModelIndex idx; idx = m_model->index(row, 0, parent); MYVERIFY(idx.isValid()); MYCOMPARE(m_model->data(idx).toString(), problem->description()); return true; } bool TestProblemModel::checkDiagnostics(int row, const QModelIndex &parent) { MYCOMPARE(m_model->rowCount(parent), 1); QModelIndex idx; idx = m_model->index(row, 0, parent); MYVERIFY(idx.isValid()); MYCOMPARE(m_model->data(idx).toString(), m_diagnosticTestProblem->description()); QModelIndex diagidx; IProblem::Ptr diag = m_diagnosticTestProblem->diagnostics().at(0); diagidx = m_model->index(0, 0, idx); MYVERIFY(diagidx.isValid()); MYCOMPARE(m_model->data(diagidx).toString(), diag->description()); QModelIndex diagdiagidx; IProblem::Ptr diagdiag = diag->diagnostics().at(0); diagdiagidx = m_model->index(0, 0, diagidx); MYVERIFY(diagdiagidx.isValid()); MYCOMPARE(m_model->data(diagdiagidx).toString(), diagdiag->description()); return true; } bool TestProblemModel::checkDisplay(int row, const QModelIndex &parent, const IProblem::Ptr &problem) { QModelIndex idx; idx = m_model->index(row, 0, parent); MYVERIFY(idx.isValid()); MYCOMPARE(m_model->data(idx).toString(), problem->description()); idx = m_model->index(row, 1, parent); MYVERIFY(idx.isValid()); MYCOMPARE(m_model->data(idx).toString(), problem->sourceString()); idx = m_model->index(row, 2, parent); MYVERIFY(idx.isValid()); MYCOMPARE(m_model->data(idx).toString(), problem->finalLocation().document.str()); idx = m_model->index(row, 3, parent); MYVERIFY(idx.isValid()); MYCOMPARE(m_model->data(idx).toString(), QString::number(problem->finalLocation().start().line() + 1)); idx = m_model->index(row, 4, parent); MYVERIFY(idx.isValid()); MYCOMPARE(m_model->data(idx).toString(), QString::number(problem->finalLocation().start().column() + 1)); return true; } bool TestProblemModel::checkLabel(int row, const QModelIndex &parent, const QString &label) { QModelIndex idx = m_model->index(row, 0, parent); MYVERIFY(idx.isValid()); MYCOMPARE(m_model->data(idx).toString(), label); return true; } bool TestProblemModel::checkPathGroup(int row, const IProblem::Ptr &problem) { QModelIndex parent = m_model->index(row, 0); MYVERIFY(parent.isValid()); MYCOMPARE(m_model->data(parent).toString(), problem->finalLocation().document.str()); QModelIndex idx = m_model->index(0, 0, parent); MYVERIFY(idx.isValid()); MYCOMPARE(m_model->data(idx).toString(), problem->description()); return true; } bool TestProblemModel::checkSeverityGroup(int row, const IProblem::Ptr &problem) { QModelIndex parent = m_model->index(row, 0); MYVERIFY(parent.isValid()); MYCOMPARE(m_model->data(parent).toString(), problem->severityString()); QModelIndex idx = m_model->index(0, 0, parent); MYVERIFY(idx.isValid()); MYCOMPARE(m_model->data(idx).toString(), problem->description()); return true; } QTEST_MAIN(TestProblemModel) #include "test_problemmodel.moc" diff --git a/shell/tests/test_problemmodelset.cpp b/shell/tests/test_problemmodelset.cpp index 33ea45fa8c..06aafbe404 100644 --- a/shell/tests/test_problemmodelset.cpp +++ b/shell/tests/test_problemmodelset.cpp @@ -1,159 +1,159 @@ /* * 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. */ #include #include #include #include "shell/problemmodelset.h" #include "shell/problemmodel.h" #include "tests/testcore.h" #include "tests/autotestshell.h" using namespace KDevelop; namespace { const int testModelCount = 3; const QString testModelIds[] = { QStringLiteral("MODEL1_ID"), QStringLiteral("MODEL2_ID"), QStringLiteral("MODEL3_ID") }; const QString testModelNames[] = { QStringLiteral("MODEL1"), QStringLiteral("MODEL2"), QStringLiteral("MODEL3") }; struct TestModelData { QString id; QString name; ProblemModel* model; }; } class TestProblemModelSet : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void testAddModel(); void testFindModel(); void testModelListing(); void testRemoveModel(); private: QScopedPointer m_set; QVector m_testData; }; void TestProblemModelSet::initTestCase() { AutoTestShell::init(); TestCore::initialize(Core::NoUi); m_set.reset(new ProblemModelSet()); for (int i = 0; i < testModelCount; i++) { m_testData.push_back(TestModelData({testModelIds[i], testModelNames[i], new ProblemModel(nullptr)})); } } void TestProblemModelSet::cleanupTestCase() { for (int i = 0; i < m_testData.size(); i++) { delete m_testData[i].model; } m_testData.clear(); TestCore::shutdown(); } void TestProblemModelSet::testAddModel() { QSignalSpy spy(m_set.data(), &ProblemModelSet::added); int c = 0; for (int i = 0; i < testModelCount; i++) { m_set->addModel(m_testData[i].id, m_testData[i].name, m_testData[i].model); c++; QCOMPARE(spy.count(), c); QCOMPARE(m_set->models().count(), c); } } void TestProblemModelSet::testFindModel() { ProblemModel *model = nullptr; for (int i = 0; i < testModelCount; i++) { model = m_set->findModel(m_testData[i].id); QVERIFY(model); QVERIFY(model == m_testData[i].model); } model = m_set->findModel(QStringLiteral("")); QVERIFY(model == nullptr); model = m_set->findModel(QStringLiteral("RandomName")); QVERIFY(model == nullptr); } void TestProblemModelSet::testModelListing() { QVector models = m_set->models(); QCOMPARE(models.size(), testModelCount); for (int i = 0; i < testModelCount; i++) { QCOMPARE(models[i].name, m_testData[i].name); QCOMPARE(models[i].model, m_testData[i].model); } } void TestProblemModelSet::testRemoveModel() { QSignalSpy spy(m_set.data(), &ProblemModelSet::removed); int c = 0; foreach (const TestModelData &data, m_testData) { m_set->removeModel(data.id); c++; QCOMPARE(spy.count(), c); QVERIFY(testModelCount >= c); QCOMPARE(m_set->models().count(), testModelCount - c); } } QTEST_MAIN(TestProblemModelSet) #include "test_problemmodelset.moc" diff --git a/shell/tests/test_problemstore.cpp b/shell/tests/test_problemstore.cpp index 266b8cd27f..2fe1478222 100644 --- a/shell/tests/test_problemstore.cpp +++ b/shell/tests/test_problemstore.cpp @@ -1,158 +1,158 @@ /* * 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. */ #include #include #include #include #include #include #include #include using namespace KDevelop; class TestProblemStore : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void testAddProblems(); void testClearProblems(); void testSetProblems(); void testFindNode(); void testSeverity(); void testSeverities(); void testScope(); private: void generateProblems(); QScopedPointer m_store; QVector m_problems; }; void TestProblemStore::initTestCase() { AutoTestShell::init(); TestCore::initialize(Core::NoUi); m_store.reset(new ProblemStore()); m_store->setScope(CurrentDocument); QVERIFY(m_store->scope() == CurrentDocument); generateProblems(); } void TestProblemStore::cleanupTestCase() { TestCore::shutdown(); } void TestProblemStore::testAddProblems() { QCOMPARE(m_store->count(), 0); int c = 0; foreach (const IProblem::Ptr &problem, m_problems) { m_store->addProblem(problem); c++; QCOMPARE(m_store->count(), c); } } void TestProblemStore::testClearProblems() { m_store->clear(); QCOMPARE(m_store->count(), 0); } void TestProblemStore::testSetProblems() { m_store->setProblems(m_problems); QCOMPARE(m_store->count(), m_problems.count()); } void TestProblemStore::testFindNode() { for (int i = 0; i < m_problems.count(); i++) { const ProblemNode *node = dynamic_cast(m_store->findNode(i)); QVERIFY(node); QVERIFY(node->problem().data()); QCOMPARE(node->problem().data()->description(), m_problems[i]->description()); } } void TestProblemStore::testSeverity() { IProblem::Severity severity = IProblem::Error; QVERIFY(severity != m_store->severity()); QSignalSpy spy(m_store.data(), &ProblemStore::changed); m_store->setSeverity(severity); QVERIFY(m_store->severity() == severity); QCOMPARE(spy.count(), 1); } void TestProblemStore::testSeverities() { IProblem::Severities severities = IProblem::Error | IProblem::Hint; QVERIFY(severities != m_store->severities()); QSignalSpy spy(m_store.data(), &ProblemStore::changed); m_store->setSeverities(severities); QVERIFY(m_store->severities() == severities); QCOMPARE(spy.count(), 1); } void TestProblemStore::testScope() { QSignalSpy spy(m_store.data(), &ProblemStore::changed); ProblemScope scope = AllProjects; m_store->setScope(scope); QVERIFY(m_store->scope() == scope); QCOMPARE(spy.count(), 1); } void TestProblemStore::generateProblems() { for (int i = 0; i < 5; i++) { IProblem::Ptr problem(new DetectedProblem()); problem->setDescription(QStringLiteral("PROBLEM") + QString::number(i + 1)); m_problems.push_back(problem); } } QTEST_MAIN(TestProblemStore) #include "test_problemstore.moc" diff --git a/shell/tests/test_problemstorenode.cpp b/shell/tests/test_problemstorenode.cpp index ce96ae60a6..d97613fe4c 100644 --- a/shell/tests/test_problemstorenode.cpp +++ b/shell/tests/test_problemstorenode.cpp @@ -1,129 +1,129 @@ /* * 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. */ #include #include #include using namespace KDevelop; class TestProblemStoreNode : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void testRootNode(); void testChildren(); void testLabelNode(); void testProblemNode(); private: QScopedPointer m_root; }; void TestProblemStoreNode::initTestCase() { m_root.reset(new ProblemStoreNode()); } void TestProblemStoreNode::cleanupTestCase() { } void TestProblemStoreNode::testRootNode() { QVERIFY(m_root->isRoot()); QVERIFY(m_root->parent() == nullptr); QCOMPARE(m_root->index(), -1); QCOMPARE(m_root->count(), 0); QCOMPARE(m_root->children().count(), 0); QVERIFY(m_root->label().isEmpty()); QVERIFY(m_root->problem().constData() == nullptr); } void TestProblemStoreNode::testChildren() { QVector nodes; nodes.push_back(new ProblemStoreNode()); nodes.push_back(new ProblemStoreNode()); nodes.push_back(new ProblemStoreNode()); int c = 0; foreach (ProblemStoreNode *node, nodes) { m_root->addChild(node); c++; QCOMPARE(m_root->count(), c); QCOMPARE(m_root->children().count(), c); QVERIFY(node->parent() == m_root.data()); QVERIFY(!node->isRoot()); } for (int i = 0; i < c; i++) { ProblemStoreNode *node = m_root->child(i); QVERIFY(node); QVERIFY(node == nodes[i]); QCOMPARE(node->index(), i); } nodes.clear(); m_root->clear(); QCOMPARE(m_root->count(), 0); } void TestProblemStoreNode::testLabelNode() { QString s1 = QStringLiteral("TEST1"); QString s2 = QStringLiteral("TEST2"); LabelNode *node = new LabelNode(nullptr, s1); QCOMPARE(node->label(), s1); node->setLabel(s2); QCOMPARE(node->label(), s2); } void TestProblemStoreNode::testProblemNode() { IProblem::Ptr p1(new DetectedProblem()); IProblem::Ptr p2(new DetectedProblem()); QString s1 = QStringLiteral("PROBLEM1"); QString s2 = QStringLiteral("PROBLEM2"); p1->setDescription(s1); p2->setDescription(s2); QScopedPointer node; node.reset(new ProblemNode(nullptr, p1)); QCOMPARE(node->problem()->description(), p1->description()); node->setProblem(p2); QCOMPARE(node->problem()->description(), p2->description()); } QTEST_MAIN(TestProblemStoreNode) #include "test_problemstorenode.moc" diff --git a/shell/tests/test_projectcontroller.cpp b/shell/tests/test_projectcontroller.cpp index 0dd166efb9..5098987729 100644 --- a/shell/tests/test_projectcontroller.cpp +++ b/shell/tests/test_projectcontroller.cpp @@ -1,577 +1,577 @@ /*************************************************************************** * Copyright 2008 Manuel Breugelmans * * * * 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 "test_projectcontroller.h" #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace KDevelop; Q_DECLARE_METATYPE(KDevelop::IProject*) namespace { class DialogProviderFake : public IProjectDialogProvider { Q_OBJECT public: DialogProviderFake() : m_reopen(true) {} ~DialogProviderFake() override {} bool m_reopen; -public slots: +public Q_SLOTS: QUrl askProjectConfigLocation(bool /*fetch*/, const QUrl& /*startUrl*/, const QUrl& /*repoUrl*/, IPlugin* /*plugin*/) override { return QUrl(); } bool userWantsReopen() override { return m_reopen; } }; } /*! A Filemanager plugin that allows you to setup a file & directory structure */ class FakeFileManager : public IPlugin, public IProjectFileManager { Q_OBJECT Q_INTERFACES(KDevelop::IProjectFileManager) public: FakeFileManager(QObject*, const QVariantList&) : IPlugin(ICore::self()->aboutData().componentName(), Core::self()) { } FakeFileManager() : IPlugin(ICore::self()->aboutData().componentName(), Core::self()) { } ~FakeFileManager() override {} Features features() const override { return IProjectFileManager::Files | IProjectFileManager::Folders; } QMap m_filesInFolder; // initialize QMap m_subFoldersInFolder; /*! Setup this manager such that @p folder contains @p file */ void addFileToFolder(const Path& folder, const Path& file) { if (!m_filesInFolder.contains(folder)) { m_filesInFolder[folder] = Path::List(); } m_filesInFolder[folder] << file; } /*! Setup this manager such that @p folder has @p subFolder */ void addSubFolderTo(const Path& folder, Path subFolder) { if (!m_subFoldersInFolder.contains(folder)) { m_subFoldersInFolder[folder] = Path::List(); } m_subFoldersInFolder[folder] << subFolder; } QList parse(ProjectFolderItem *dom) override { Path::List files = m_filesInFolder[dom->path()]; foreach (const Path& file, files) { new ProjectFileItem(dom->project(), file, dom); } Path::List folderPaths = m_subFoldersInFolder[dom->path()]; QList folders; foreach (const Path& folderPath, folderPaths) { folders << new ProjectFolderItem(dom->project(), folderPath, dom); } return folders; } ProjectFolderItem *import(IProject *project) override { ProjectFolderItem* it = new ProjectFolderItem(project, project->path()); return it; } ProjectFolderItem* addFolder(const Path& /*folder*/, ProjectFolderItem */*parent*/) override { return nullptr; } ProjectFileItem* addFile(const Path& /*file*/, ProjectFolderItem */*parent*/) override { return nullptr; } bool removeFilesAndFolders(const QList &/*items*/) override { return false; } bool moveFilesAndFolders(const QList< KDevelop::ProjectBaseItem* > &/*items*/, KDevelop::ProjectFolderItem* /*newParent*/) override { return false; } bool copyFilesAndFolders(const Path::List &/*items*/, KDevelop::ProjectFolderItem* /*newParent*/) override { return false; } bool renameFile(ProjectFileItem* /*file*/, const Path& /*newPath*/) override { return false; } bool renameFolder(ProjectFolderItem* /*oldFolder*/, const Path& /*newPath*/ ) override { return false; } bool reload(ProjectFolderItem* /*item*/) override { return false; } }; class FakePluginController : public PluginController { Q_OBJECT public: using PluginController::PluginController; IPlugin* pluginForExtension(const QString& extension, const QString& pluginName = {}, const QVariantMap& constraints = QVariantMap()) override { if (extension == qobject_interface_iid()) { if (!m_fakeFileManager) { // Can't initialize in the constructor, because the pluginController must be setup // before constructing a plugin, and this _is_ the pluginController. m_fakeFileManager = new FakeFileManager; } return m_fakeFileManager; } return PluginController::pluginForExtension(extension, pluginName, constraints); } private: FakeFileManager* m_fakeFileManager = nullptr; }; ////////////////////// Fixture /////////////////////////////////////////////// void TestProjectController::initTestCase() { AutoTestShell::init({{}}); TestCore* testCore = new TestCore; testCore->setPluginController( new FakePluginController(testCore) ); testCore->initialize(); qRegisterMetaType(); m_core = Core::self(); m_scratchDir = QDir(QDir::tempPath()); m_scratchDir.mkdir(QStringLiteral("prjctrltest")); m_scratchDir.cd(QStringLiteral("prjctrltest")); } void TestProjectController::cleanupTestCase() { TestCore::shutdown(); } void TestProjectController::init() { m_projName = QStringLiteral("foo"); m_projFilePath = writeProjectConfig(m_projName); m_projCtrl = m_core->projectControllerInternal(); m_tmpConfigs << m_projFilePath; m_projFolder = Path(m_scratchDir.absolutePath() + '/'); } void TestProjectController::cleanup() { // also close any opened projects as we do not get a clean fixture, // following tests should start off clean. foreach(IProject* p, m_projCtrl->projects()) { m_projCtrl->closeProject(p); } foreach(const Path &cfg, m_tmpConfigs) { QFile::remove(cfg.pathOrUrl()); } qDeleteAll(m_fileManagerGarbage); m_fileManagerGarbage.clear(); } ////////////////////// Commands ////////////////////////////////////////////// #define WAIT_FOR_OPEN_SIGNAL \ {\ QSignalSpy signal(m_projCtrl, SIGNAL(projectOpened(KDevelop::IProject*)));\ QVERIFY2(signal.wait(30000), "Timeout while waiting for opened signal");\ } void(0) void TestProjectController::openProject() { QSignalSpy* spy = createOpenedSpy(); QVERIFY(!m_projCtrl->isProjectNameUsed(m_projName)); m_projCtrl->openProject(m_projFilePath.toUrl()); WAIT_FOR_OPEN_SIGNAL; QCOMPARE(m_projCtrl->projectCount(), 1); IProject* proj; assertProjectOpened(m_projName, proj);QVERIFY(proj); assertSpyCaughtProject(spy, proj); QCOMPARE(proj->projectFile(), m_projFilePath); QCOMPARE(proj->path(), Path(m_scratchDir.absolutePath()+'/')); QVERIFY(m_projCtrl->isProjectNameUsed(m_projName)); } void TestProjectController::closeProject() { m_projCtrl->openProject(m_projFilePath.toUrl()); WAIT_FOR_OPEN_SIGNAL; IProject* proj = m_projCtrl->findProjectByName(m_projName); Q_ASSERT(proj); QSignalSpy* spy1 = createClosedSpy(); QSignalSpy* spy2 = createClosingSpy(); m_projCtrl->closeProject(proj); QVERIFY(!m_projCtrl->isProjectNameUsed(m_projName)); QCOMPARE(m_projCtrl->projectCount(), 0); assertProjectClosed(proj); assertSpyCaughtProject(spy1, proj); assertSpyCaughtProject(spy2, proj); } void TestProjectController::openCloseOpen() { m_projCtrl->openProject(m_projFilePath.toUrl()); WAIT_FOR_OPEN_SIGNAL; IProject* proj; assertProjectOpened(m_projName, proj); m_projCtrl->closeProject(proj); QSignalSpy* spy = createOpenedSpy(); m_projCtrl->openProject(m_projFilePath.toUrl()); WAIT_FOR_OPEN_SIGNAL; QVERIFY(m_projCtrl->isProjectNameUsed(m_projName)); QCOMPARE(m_projCtrl->projectCount(), 1); assertProjectOpened(m_projName, proj); assertSpyCaughtProject(spy, proj); } void TestProjectController::reopen() { m_projCtrl->setDialogProvider(new DialogProviderFake); m_projCtrl->openProject(m_projFilePath.toUrl()); WAIT_FOR_OPEN_SIGNAL; QSignalSpy* spy = createOpenedSpy(); m_projCtrl->openProject(m_projFilePath.toUrl()); WAIT_FOR_OPEN_SIGNAL; QCOMPARE(m_projCtrl->projectCount(), 1); QVERIFY(m_projCtrl->isProjectNameUsed(m_projName)); IProject* proj; assertProjectOpened(m_projName, proj); assertSpyCaughtProject(spy, proj); } void TestProjectController::reopenWhileLoading() { // Open the same project again while the first is still // loading. The second open request should be blocked. m_projCtrl->setDialogProvider(new DialogProviderFake); QSignalSpy* spy = createOpenedSpy(); m_projCtrl->openProject(m_projFilePath.toUrl()); //m_projCtrl->openProject(m_projFilePath.toUrl()); WAIT_FOR_OPEN_SIGNAL; // wait a bit for a second signal, this should timeout QSignalSpy signal(m_projCtrl, SIGNAL(projectOpened(KDevelop::IProject*))); QVERIFY2(!signal.wait(100), "Received 2 projectOpened signals."); QCOMPARE(m_projCtrl->projectCount(), 1); IProject* proj; assertProjectOpened(m_projName, proj); assertSpyCaughtProject(spy, proj); } void TestProjectController::openMultiple() { QString secondProj(QStringLiteral("bar")); Path secondCfgUrl = writeProjectConfig(secondProj); QSignalSpy* spy = createOpenedSpy(); m_projCtrl->openProject(m_projFilePath.toUrl()); WAIT_FOR_OPEN_SIGNAL; m_projCtrl->openProject(secondCfgUrl.toUrl()); WAIT_FOR_OPEN_SIGNAL; QCOMPARE(m_projCtrl->projectCount(), 2); IProject *proj1, *proj2; assertProjectOpened(m_projName, proj1); assertProjectOpened(secondProj, proj2); QVERIFY(m_projCtrl->isProjectNameUsed(m_projName)); QVERIFY(m_projCtrl->isProjectNameUsed(QStringLiteral("bar"))); QCOMPARE(spy->size(), 2); IProject* emittedProj1 = (*spy)[0][0].value(); IProject* emittedProj2 = (*spy)[1][0].value(); QCOMPARE(emittedProj1, proj1); QCOMPARE(emittedProj2, proj2); m_tmpConfigs << secondCfgUrl; } /*! Verify that the projectmodel contains a single project. Put this project's * ProjectFolderItem in the output parameter @p RootItem */ #define ASSERT_SINGLE_PROJECT_IN_MODEL(rootItem) \ {\ QCOMPARE(m_projCtrl->projectModel()->rowCount(), 1); \ QModelIndex projIndex = m_projCtrl->projectModel()->index(0,0); \ QVERIFY(projIndex.isValid()); \ ProjectBaseItem* i = m_projCtrl->projectModel()->itemFromIndex( projIndex ); \ QVERIFY(i); \ QVERIFY(i->folder()); \ rootItem = i->folder();\ } void(0) /*! Verify that the projectitem @p item has a single child item * named @p name with url @p url. @p subFolder is an output parameter * that contains the sub-folder projectitem. */ #define ASSERT_SINGLE_SUBFOLDER_IN(item, name, path__, subFolder) \ {\ QCOMPARE(item->rowCount(), 1);\ QCOMPARE(item->folderList().size(), 1);\ ProjectFolderItem* fo = item->folderList().at(0);\ QVERIFY(fo);\ QCOMPARE(fo->path(), path__);\ QCOMPARE(fo->folderName(), QStringLiteral(name));\ subFolder = fo;\ } void(0) #define ASSERT_SINGLE_FILE_IN(rootFolder, name, path__, fileItem)\ {\ QCOMPARE(rootFolder->rowCount(), 1);\ QCOMPARE(rootFolder->fileList().size(), 1);\ fileItem = rootFolder->fileList().at(0);\ QVERIFY(fileItem);\ QCOMPARE(fileItem->path(), path__);\ QCOMPARE(fileItem->fileName(), QStringLiteral(name));\ } void(0) // command void TestProjectController::emptyProject() { // verify that the project model contains a single top-level folder after loading // an empty project assertEmptyProjectModel(); m_projCtrl->openProject(m_projFilePath.toUrl()); WAIT_FOR_OPEN_SIGNAL; Project* proj; assertProjectOpened(m_projName, (KDevelop::IProject*&)proj); FakeFileManager* fileMng = createFileManager(); Q_ASSERT(fileMng); proj->setManagerPlugin(fileMng); proj->reloadModel(); QTest::qWait(100); ProjectFolderItem* rootFolder; ASSERT_SINGLE_PROJECT_IN_MODEL(rootFolder); // check that the project is empty QCOMPARE(rootFolder->rowCount(), 0); QCOMPARE(rootFolder->project()->name(), m_projName); QCOMPARE(rootFolder->path(), m_projFolder); } // command void TestProjectController::singleFile() { // verify that the project model contains a single file in the // top folder. First setup a FakeFileManager with this file m_projCtrl->openProject(m_projFilePath.toUrl()); WAIT_FOR_OPEN_SIGNAL; Project* proj; assertProjectOpened(m_projName, (KDevelop::IProject*&)proj); FakeFileManager* fileMng = createFileManager(); proj->setManagerPlugin(fileMng); Path filePath = Path(m_projFolder, QStringLiteral("foobar")); fileMng->addFileToFolder(m_projFolder, filePath); proj->reloadModel(); QTest::qWait(100); // NO signals for reload ... ProjectFolderItem* rootFolder; ASSERT_SINGLE_PROJECT_IN_MODEL(rootFolder); ProjectFileItem* fi; ASSERT_SINGLE_FILE_IN(rootFolder, "foobar", filePath, fi); QCOMPARE(fi->rowCount(), 0); ASSERT_SINGLE_PROJECT_IN_MODEL(rootFolder); ASSERT_SINGLE_FILE_IN(rootFolder, "foobar", filePath, fi); } // command void TestProjectController::singleDirectory() { // verify that the project model contains a single folder in the // top folder. First setup a FakeFileManager with this folder m_projCtrl->openProject(m_projFilePath.toUrl()); WAIT_FOR_OPEN_SIGNAL; Project* proj; assertProjectOpened(m_projName, (KDevelop::IProject*&)proj); Path folderPath = Path(m_projFolder, QStringLiteral("foobar/")); FakeFileManager* fileMng = createFileManager(); fileMng->addSubFolderTo(m_projFolder, folderPath); proj->setManagerPlugin(fileMng); proj->reloadModel(); QTest::qWait(100); ProjectFolderItem* rootFolder; ASSERT_SINGLE_PROJECT_IN_MODEL(rootFolder); // check that the project contains a single subfolder ProjectFolderItem* sub; ASSERT_SINGLE_SUBFOLDER_IN(rootFolder, "foobar", folderPath, sub); QCOMPARE(sub->rowCount(), 0); } // command void TestProjectController::fileInSubdirectory() { // verify that the project model contains a single file in a subfolder // First setup a FakeFileManager with this folder + file m_projCtrl->openProject(m_projFilePath.toUrl()); WAIT_FOR_OPEN_SIGNAL; Project* proj; assertProjectOpened(m_projName, (KDevelop::IProject*&)proj); Path folderPath = Path(m_projFolder, QStringLiteral("foobar/")); FakeFileManager* fileMng = createFileManager(); fileMng->addSubFolderTo(m_projFolder, folderPath); Path filePath = Path(folderPath, QStringLiteral("zoo")); fileMng->addFileToFolder(folderPath, filePath); proj->setManagerPlugin(fileMng); ProjectFolderItem* rootFolder = nullptr; ProjectFolderItem* sub = nullptr; ProjectFileItem* file = nullptr; proj->reloadModel(); QTest::qWait(100); ASSERT_SINGLE_PROJECT_IN_MODEL(rootFolder); ASSERT_SINGLE_SUBFOLDER_IN(rootFolder, "foobar", folderPath, sub); ASSERT_SINGLE_FILE_IN(sub,"zoo",filePath,file); ASSERT_SINGLE_PROJECT_IN_MODEL(rootFolder); ASSERT_SINGLE_SUBFOLDER_IN(rootFolder, "foobar", folderPath, sub); ASSERT_SINGLE_FILE_IN(sub,"zoo",filePath,file); } void TestProjectController::prettyFileName_data() { QTest::addColumn("relativeFilePath"); QTest::newRow("basic") << "foobar.txt"; QTest::newRow("subfolder") << "sub/foobar.txt"; } void TestProjectController::prettyFileName() { QFETCH(QString, relativeFilePath); m_projCtrl->openProject(m_projFilePath.toUrl()); WAIT_FOR_OPEN_SIGNAL; Project* proj; assertProjectOpened(m_projName, (KDevelop::IProject*&)proj); FakeFileManager* fileMng = createFileManager(); proj->setManagerPlugin(fileMng); Path filePath = Path(m_projFolder, relativeFilePath); fileMng->addFileToFolder(m_projFolder, filePath); QCOMPARE(m_projCtrl->prettyFileName(filePath.toUrl(), ProjectController::FormattingOptions::FormatPlain), QString(m_projName + ':' + relativeFilePath)); } ////////////////////// Helpers /////////////////////////////////////////////// Path TestProjectController::writeProjectConfig(const QString& name) { Path configPath = Path(m_scratchDir.absolutePath() + '/' + name + ".kdev4"); QFile f(configPath.pathOrUrl()); f.open(QIODevice::WriteOnly); QTextStream str(&f); str << "[Project]\n" << "Name=" << name << "\n"; f.close(); return configPath; } ////////////////// Custom assertions ///////////////////////////////////////// void TestProjectController::assertProjectOpened(const QString& name, IProject*& proj) { QVERIFY(proj = m_projCtrl->findProjectByName(name)); QVERIFY(m_projCtrl->projects().contains(proj)); } void TestProjectController::assertSpyCaughtProject(QSignalSpy* spy, IProject* proj) { QCOMPARE(spy->size(), 1); IProject* emittedProj = (*spy)[0][0].value(); QCOMPARE(proj, emittedProj); } void TestProjectController::assertProjectClosed(IProject* proj) { IProject* p = m_projCtrl->findProjectByName(proj->name()); QVERIFY(p == nullptr); QVERIFY(!m_projCtrl->projects().contains(proj)); } void TestProjectController::assertEmptyProjectModel() { ProjectModel* m = m_projCtrl->projectModel(); Q_ASSERT(m); QCOMPARE(m->rowCount(), 0); } ///////////////////// Creation stuff ///////////////////////////////////////// QSignalSpy* TestProjectController::createOpenedSpy() { return new QSignalSpy(m_projCtrl, SIGNAL(projectOpened(KDevelop::IProject*))); } QSignalSpy* TestProjectController::createClosedSpy() { return new QSignalSpy(m_projCtrl, SIGNAL(projectClosed(KDevelop::IProject*))); } QSignalSpy* TestProjectController::createClosingSpy() { return new QSignalSpy(m_projCtrl, SIGNAL(projectClosing(KDevelop::IProject*))); } FakeFileManager* TestProjectController::createFileManager() { FakeFileManager* fileMng = new FakeFileManager; m_fileManagerGarbage << fileMng; return fileMng; } QTEST_MAIN(TestProjectController) #include "moc_test_projectcontroller.cpp" #include "test_projectcontroller.moc" diff --git a/shell/tests/test_projectcontroller.h b/shell/tests/test_projectcontroller.h index 36c34fa84d..e0cc373eba 100644 --- a/shell/tests/test_projectcontroller.h +++ b/shell/tests/test_projectcontroller.h @@ -1,87 +1,87 @@ /*************************************************************************** * Copyright 2008 Manuel Breugelmans * * * * 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_SHELL_TEST_PROJECTCONTROLLER_H #define KDEVELOP_SHELL_TEST_PROJECTCONTROLLER_H #include #include #include "util/path.h" class QSignalSpy; namespace KDevelop { class Core; class IProject; class ProjectController; } class FakeFileManager; class TestProjectController : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void init(); void cleanup(); void openProject(); void closeProject(); void openCloseOpen(); void openMultiple(); void reopen(); void reopenWhileLoading(); void emptyProject(); void singleFile(); void singleDirectory(); void fileInSubdirectory(); void prettyFileName_data(); void prettyFileName(); private: KDevelop::Path writeProjectConfig(const QString& name); QSignalSpy* createOpenedSpy(); QSignalSpy* createClosedSpy(); QSignalSpy* createClosingSpy(); void assertProjectOpened(const QString& name, KDevelop::IProject*& proj); void assertSpyCaughtProject(QSignalSpy* spy, KDevelop::IProject* proj); void assertProjectClosed(KDevelop::IProject* proj); void assertEmptyProjectModel(); FakeFileManager* createFileManager(); private: KDevelop::Path m_projFilePath; KDevelop::Core* m_core; KDevelop::ProjectController* m_projCtrl; QString m_projName; QList m_tmpConfigs; QDir m_scratchDir; KDevelop::Path m_projFolder; QList m_fileManagerGarbage; }; #endif // KDEVELOP_SHELL_TEST_PROJECTCONTROLLER_H diff --git a/shell/tests/test_sessioncontroller.h b/shell/tests/test_sessioncontroller.h index 2b1388ea5e..c5e934a0d8 100644 --- a/shell/tests/test_sessioncontroller.h +++ b/shell/tests/test_sessioncontroller.h @@ -1,54 +1,54 @@ /*************************************************************************** * Copyright 2008 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_TEST_SESSIONCONTROLLER_H #define KDEVPLATFORM_TEST_SESSIONCONTROLLER_H #include namespace KDevelop { class Core; class Session; class SessionController; } class TestSessionController : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void init(); void cleanupTestCase(); void createSession_data(); void createSession(); void deleteSession(); void cloneSession(); void renameSession(); void canRenameActiveSession(); void readFromConfig(); void temporary(); void tryLockSession(); private: KDevelop::Core* m_core; KDevelop::SessionController* m_sessionCtrl; }; #endif // KDEVPLATFORM_TEST_SESSIONCONTROLLER_H diff --git a/shell/tests/test_shellbuddy.h b/shell/tests/test_shellbuddy.h index 6fd0f2898b..880fdaa8f9 100644 --- a/shell/tests/test_shellbuddy.h +++ b/shell/tests/test_shellbuddy.h @@ -1,57 +1,57 @@ /*************************************************************************** * Copyright 2011 Martin Heide * * * * 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_SHELLBUDDY_H #define KDEVPLATFORM_TEST_SHELLBUDDY_H #include #include #include #include "../documentcontroller.h" #include "../uicontroller.h" class TestBuddyFinder; using namespace KDevelop; class TestShellBuddy: public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void testDeclarationDefinitionOrder(); void testActivation(); void testDisableBuddies(); void testDisableOpenAfterCurrent(); void testDisableAll(); void testsplitViewBuddies(); private: void createFile(const QTemporaryDir& dir, const QString& filename); void enableBuddies(bool enable = true); void enableOpenAfterCurrent(bool enable = true); IDocumentController *m_documentController; UiController *m_uiController; TestBuddyFinder* m_finder; }; #endif diff --git a/shell/tests/test_shelldocumentoperation.h b/shell/tests/test_shelldocumentoperation.h index c05b425d21..e1d975a377 100644 --- a/shell/tests/test_shelldocumentoperation.h +++ b/shell/tests/test_shelldocumentoperation.h @@ -1,36 +1,36 @@ /*************************************************************************** * Copyright 2008 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_TEST_SHELLDOCUMENTOPERATION_H #define KDEVPLATFORM_TEST_SHELLDOCUMENTOPERATION_H #include class TestShellDocumentOperation: public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void testOpenDocumentFromText(); void testClosing(); void testKateDocumentAndViewCreation(); }; #endif diff --git a/shell/tests/test_testcontroller.h b/shell/tests/test_testcontroller.h index ac03f23bf7..23e35c31d1 100644 --- a/shell/tests/test_testcontroller.h +++ b/shell/tests/test_testcontroller.h @@ -1,58 +1,58 @@ /* Unit tests for TestController. 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_TEST_TESTCONTROLLER_H #define KDEVPLATFORM_TEST_TESTCONTROLLER_H #include #include namespace KDevelop { class ITestSuite; class IProject; class TestController; class TestTestController : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void addSuite(); void removeSuite(); void replaceSuite(); void findByProject(); void testResults(); void cleanupTestCase(); private: void emitTestResult(ITestSuite* suite, TestResult::TestCaseResult caseResult); TestController* m_testController; IProject* m_project; }; } #endif // KDEVPLATFORM_TEST_TESTCONTROLLER_H diff --git a/shell/tests/test_uicontroller.h b/shell/tests/test_uicontroller.h index 945ed984fe..300d65094c 100644 --- a/shell/tests/test_uicontroller.h +++ b/shell/tests/test_uicontroller.h @@ -1,38 +1,38 @@ /* * This file is part of KDevelop * * Copyright 2011 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_UICONTROLLER_H #define KDEVPLATFORM_TEST_UICONTROLLER_H #include class TestUiController : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void showErrorMessage(); }; #endif // KDEVPLATFORM_TEST_UICONTROLLER_H diff --git a/shell/watcheddocumentset.h b/shell/watcheddocumentset.h index 28a1ef1f9c..8b193a3238 100644 --- a/shell/watcheddocumentset.h +++ b/shell/watcheddocumentset.h @@ -1,150 +1,150 @@ /* * KDevelop Problem Reporter * * Copyright 2010 Dmitry Risenberg * * 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_WATCHEDDOCUMENTSET_H #define KDEVPLATFORM_PLUGIN_WATCHEDDOCUMENTSET_H #include #include #include #include #include "problemconstants.h" namespace KDevelop { class IDocument; class IProject; class ProjectFileItem; class Path; class WatchedDocumentSetPrivate; /** * Helper class that tracks set of documents and notifies its owner whenever this set changes. Derived classes implement different tracking strategies. */ class KDEVPLATFORMSHELL_EXPORT WatchedDocumentSet : public QObject { Q_OBJECT public: using DocumentSet = QSet; explicit WatchedDocumentSet(QObject* parent); ~WatchedDocumentSet() override; bool showImports() const; void setShowImports(bool showImports); virtual DocumentSet get() const; virtual DocumentSet getImports() const; virtual void setCurrentDocument(const IndexedString& url); virtual ProblemScope getScope() const = 0; -signals: +Q_SIGNALS: void changed(); protected: QScopedPointer d; }; /** * Tracks a document that is current at any given moment. * When a new file is activated, it becomes tracked instead of the old one. */ class CurrentDocumentSet : public WatchedDocumentSet { Q_OBJECT public: explicit CurrentDocumentSet(const IndexedString& document, QObject* parent); void setCurrentDocument(const IndexedString& url) override; ProblemScope getScope() const override; }; /** * Tracks all open documents. */ class OpenDocumentSet : public WatchedDocumentSet { Q_OBJECT public: explicit OpenDocumentSet(QObject* parent); ProblemScope getScope() const override; -private slots: +private Q_SLOTS: void documentClosed(IDocument* doc); void documentCreated(IDocument* doc); }; /** * Tracks documents that are in the same project as the current file. * If current file is not in any project, none are tracked. */ class ProjectSet : public WatchedDocumentSet { Q_OBJECT public: explicit ProjectSet(QObject* parent); protected: void trackProjectFiles(const IProject* project); -protected slots: +protected Q_SLOTS: void fileAdded(ProjectFileItem*); void fileRemoved(ProjectFileItem* file); void fileRenamed(const Path& oldFile, ProjectFileItem* newFile); }; /** * Tracks files in all open projects. */ class CurrentProjectSet : public ProjectSet { Q_OBJECT public: explicit CurrentProjectSet(const IndexedString& document, QObject* parent); void setCurrentDocument(const IndexedString& url) override; ProblemScope getScope() const override; private: void setCurrentDocumentInternal(const IndexedString& url); // to avoid virtual in constructor IProject* m_currentProject; }; class AllProjectSet : public ProjectSet { Q_OBJECT public: explicit AllProjectSet(QObject* parent); ProblemScope getScope() const override; }; class BypassSet : public WatchedDocumentSet { Q_OBJECT public: explicit BypassSet(QObject* parent); ProblemScope getScope() const override; }; } #endif // KDEVPLATFORM_PLUGIN_WATCHEDDOCUMENTSET_H diff --git a/shell/workingsetcontroller.h b/shell/workingsetcontroller.h index e4297984ae..0cbf33a642 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 = 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: +private Q_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/closedworkingsetswidget.h b/shell/workingsets/closedworkingsetswidget.h index a341e8253b..e5ee9e5859 100644 --- a/shell/workingsets/closedworkingsetswidget.h +++ b/shell/workingsets/closedworkingsetswidget.h @@ -1,69 +1,69 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2010 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_CLOSEDWORKINGSETSWIDGET_H #define KDEVPLATFORM_CLOSEDWORKINGSETSWIDGET_H #include #include #include #include namespace Sublime { class Area; } namespace KDevelop { class MainWindow; class WorkingSet; class WorkingSetController; class WorkingSetToolButton; /** * This widget shows all working sets that are not open in any area. * * It's put next to the area switcher tabs. */ class ClosedWorkingSetsWidget : public QWidget { Q_OBJECT public: explicit ClosedWorkingSetsWidget(MainWindow* window); -private slots: +private Q_SLOTS: void areaChanged(Sublime::Area* area); void changedWorkingSet(Sublime::Area* area, const QString& from, const QString& to); void addWorkingSet(WorkingSet* set); void removeWorkingSet( WorkingSet* ); private: MainWindow* m_mainWindow; QHBoxLayout* m_layout; QPointer m_connectedArea; QMap m_buttons; }; } #endif // KDEVPLATFORM_CLOSEDWORKINGSETSWIDGET_H diff --git a/shell/workingsets/workingset.h b/shell/workingsets/workingset.h index ac2aa04206..b50f436b15 100644 --- a/shell/workingsets/workingset.h +++ b/shell/workingsets/workingset.h @@ -1,128 +1,128 @@ /* 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_WORKINGSET_H #define KDEVPLATFORM_WORKINGSET_H #include #include #include #include namespace Sublime { class Area; class AreaIndex; class View; } namespace KDevelop { /// Contains all significant parameters which control the appearance of a working set icon struct WorkingSetIconParameters { explicit WorkingSetIconParameters(const QString& id) : setId(qHash(id) % 268435459) , coloredCount((setId % 15 < 4) ? 1 : (setId % 15 < 10) ? 2 : (setId % 15 == 14) ? 4 : 3) , hue((setId % 273 * 83) % 360) , swapDiagonal(setId % 31 < 16) { }; // calculate layout and colors depending on the working set ID // modulo it so it's around 2^28, leaving some space before uint overflows const uint setId; // amount of colored squares in this icon (the rest is grey or whatever you set as default color) // use 4-6-4-1 weighting for 1, 2, 3, 4 squares, because that's the number of arrangements for each const uint coloredCount; const uint hue; bool swapDiagonal; // between 0 and 100, 100 = very similar, 0 = very different // 20 points should make a significantly different icon. uint similarity(const WorkingSetIconParameters& other) const { int sim = 100; uint hueDiff = qAbs(hue - other.hue); hueDiff = hueDiff > 180 ? 360 - hueDiff : hueDiff; sim -= hueDiff > 35 ? 50 : (hueDiff * 50) / 180; if ( coloredCount != other.coloredCount ) { sim -= 50; } else if ( coloredCount == 2 && swapDiagonal != other.swapDiagonal ) { sim -= 35; } return sim; }; }; class WorkingSet : public QObject { Q_OBJECT public: explicit WorkingSet(const QString& id); bool isConnected(Sublime::Area* area); QIcon icon() const; bool isPersistent() const; void setPersistent(bool persistent); QString id() const; QStringList fileList() const; bool isEmpty() const; ///Updates this working-set from the given area and area-index void saveFromArea(Sublime::Area* area, Sublime::AreaIndex * areaIndex); ///Loads this working-set directly from the configuration file, and stores it in the given area ///Does not ask the user, this should be done beforehand. void loadToArea(Sublime::Area* area, Sublime::AreaIndex* areaIndex); bool hasConnectedAreas() const; bool hasConnectedAreas(QList areas) const; void connectArea(Sublime::Area* area); void disconnectArea(Sublime::Area* area); void deleteSet(bool force, bool silent = false); -private slots: +private Q_SLOTS: void areaViewAdded(Sublime::AreaIndex* /*index*/, Sublime::View* /*view*/); void areaViewRemoved(Sublime::AreaIndex* /*index*/, Sublime::View* /*view*/); -signals: +Q_SIGNALS: void setChangedSignificantly(); void aboutToRemove(WorkingSet*); private: void changed(Sublime::Area* area); void saveFromArea(Sublime::Area* area, Sublime::AreaIndex *areaIndex, KConfigGroup setGroup, KConfigGroup areaGroup); void loadToArea(Sublime::Area* area, Sublime::AreaIndex *areaIndex, KConfigGroup setGroup, KConfigGroup areaGroup, QMultiMap& recycle); QString m_id; QIcon m_icon; QList > m_areas; static bool m_loading; }; } #endif // KDEVPLATFORM_WORKINGSET_H diff --git a/shell/workingsets/workingsettoolbutton.h b/shell/workingsets/workingsettoolbutton.h index a2e1dadbdd..8831868f1b 100644 --- a/shell/workingsets/workingsettoolbutton.h +++ b/shell/workingsets/workingsettoolbutton.h @@ -1,64 +1,64 @@ /* 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_WORKINGSETTOOLBUTTON_H #define KDEVPLATFORM_WORKINGSETTOOLBUTTON_H #include namespace KDevelop { class MainWindow; class WorkingSet; /** * @NOTE: This button should be hidden when it is not associated to any set! */ class WorkingSetToolButton : public QToolButton { Q_OBJECT public: WorkingSetToolButton(QWidget* parent, WorkingSet* set); void disableTooltip() { m_toolTipEnabled = false; } WorkingSet* workingSet() const; void setWorkingSet(WorkingSet* set); -public slots: +public Q_SLOTS: void closeSet(bool ask = false); void loadSet(); void duplicateSet(); void mergeSet(); void subtractSet(); void intersectSet(); void buttonTriggered(); void showTooltip(); private: void contextMenuEvent(QContextMenuEvent* ev) override; bool event(QEvent* e) override; WorkingSet* m_set; bool m_toolTipEnabled; }; } #endif // KDEVPLATFORM_WORKINGSETTOOLBUTTON_H diff --git a/shell/workingsets/workingsettooltipwidget.h b/shell/workingsets/workingsettooltipwidget.h index 7150ebbaae..d91b9b5c79 100644 --- a/shell/workingsets/workingsettooltipwidget.h +++ b/shell/workingsets/workingsettooltipwidget.h @@ -1,76 +1,76 @@ /* 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_WORKINGSETTOOLTIPWIDGET_H #define KDEVPLATFORM_WORKINGSETTOOLTIPWIDGET_H #include #include class QLabel; class QToolButton; class QPushButton; namespace KDevelop { class WorkingSet; class WorkingSetToolButton; class MainWindow; class WorkingSetToolTipWidget : public QWidget { Q_OBJECT public: WorkingSetToolTipWidget(QWidget* parent, WorkingSet* set, MainWindow* mainwindow); Q_SIGNALS: void shouldClose(); -public slots: +public Q_SLOTS: void buttonClicked(bool); void updateFileButtons(); void labelClicked(); void nextDocument(); void previousDocument(); private: bool isActiveSet() const; class FileWidget : public QWidget { public: QToolButton* m_button; class WorkingSetFileLabel* m_label; }; QVector m_orderedFileWidgets; QMap m_fileWidgets; WorkingSet* m_set; QPushButton* m_mergeButton; QPushButton* m_subtractButton; QPushButton* m_openButton; QLabel* m_documentsLabel; WorkingSetToolButton* m_setButton; QPushButton* m_deleteButton; }; } #endif // KDEVPLATFORM_WORKINGSETTOOLTIPWIDGET_H diff --git a/shell/workingsets/workingsetwidget.h b/shell/workingsets/workingsetwidget.h index a69789cb31..53781e62f8 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 = nullptr); void setVisible( bool visible ) override; -private slots: +private Q_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/examples/example1main.h b/sublime/examples/example1main.h index 9b96012d79..07a237efeb 100644 --- a/sublime/examples/example1main.h +++ b/sublime/examples/example1main.h @@ -1,50 +1,50 @@ /*************************************************************************** * 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_EXAMPLE1MAIN_H #define KDEVPLATFORM_EXAMPLE1MAIN_H #include namespace Sublime { class Area; class Controller; } class Example1Main: public KXmlGuiWindow { Q_OBJECT public: Example1Main(); -public slots: +public Q_SLOTS: void selectArea1(); void selectArea2(); -private slots: +private Q_SLOTS: void updateTitle(Sublime::Area *area); private: Sublime::Controller *m_controller; Sublime::Area *m_area1; Sublime::Area *m_area2; }; #endif diff --git a/sublime/examples/example2main.h b/sublime/examples/example2main.h index ff07d76f21..78f9bbf811 100644 --- a/sublime/examples/example2main.h +++ b/sublime/examples/example2main.h @@ -1,38 +1,38 @@ /*************************************************************************** * 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_EXAMPLE2MAIN_H #define KDEVPLATFORM_EXAMPLE2MAIN_H #include class Example2Main: public Sublime::MainWindow { Q_OBJECT public: explicit Example2Main(Sublime::Controller *controller, Qt::WindowFlags flags = KDE_DEFAULT_WINDOWFLAGS); -public slots: +public Q_SLOTS: void splitVertical(); void splitHorizontal(); void close(); }; #endif diff --git a/sublime/idealbuttonbarwidget.h b/sublime/idealbuttonbarwidget.h index e167d4f18c..407e12cedb 100644 --- a/sublime/idealbuttonbarwidget.h +++ b/sublime/idealbuttonbarwidget.h @@ -1,100 +1,100 @@ /* 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 IDEALBUTTONBARWIDGET_H #define IDEALBUTTONBARWIDGET_H #include class IdealToolButton; class ToolViewAction; class QAction; class KConfigGroup; namespace Sublime { class MainWindow; class IdealController; class IdealDockWidget; class View; class Area; class IdealButtonBarWidget: public QWidget { Q_OBJECT public: IdealButtonBarWidget(Qt::DockWidgetArea area, IdealController *controller, Sublime::MainWindow *parent); QAction* addWidget(IdealDockWidget *widget, Area* area, View *view); void addAction(QAction *action); void removeAction(QAction* action); Qt::Orientation orientation() const; Qt::DockWidgetArea area() const; IdealDockWidget* widgetForAction(QAction* action) const; QWidget* corner(); void showWidget(QAction *widgetAction, bool checked); bool isEmpty(); bool isShown(); void saveShowState(); bool lastShowState(); void loadOrderSettings(const KConfigGroup& configGroup); void saveOrderSettings(KConfigGroup& configGroup); bool isLocked(); -signals: +Q_SIGNALS: void emptyChanged(); private: void showWidget(bool checked); void applyOrderToLayout(); void takeOrderFromLayout(); IdealToolButton* button(const QString& id) const; QString id(const IdealToolButton* button) const; void addButtonToOrder(const IdealToolButton* button); Qt::DockWidgetArea _area; IdealController *_controller; QWidget *_corner; bool _showState; QStringList _buttonsOrder; }; } #endif // IDEALBUTTONBARWIDGET_H diff --git a/sublime/idealdockwidget.h b/sublime/idealdockwidget.h index c966481b23..5842080b04 100644 --- a/sublime/idealdockwidget.h +++ b/sublime/idealdockwidget.h @@ -1,67 +1,67 @@ /* 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 IDEALDOCKWIDGET_H #define IDEALDOCKWIDGET_H #include #include "idealcontroller.h" namespace Sublime { class IdealDockWidget : public QDockWidget { Q_OBJECT public: IdealDockWidget(IdealController *controller, Sublime::MainWindow *parent); ~IdealDockWidget() override; Area *area() const; void setArea(Area *area); View *view() const; void setView(View *view); Qt::DockWidgetArea dockWidgetArea() const; void setDockWidgetArea(Qt::DockWidgetArea dockingArea); -public slots: +public Q_SLOTS: /// The IdealToolButton also connects to this slot to show the same context menu. void contextMenuRequested(const QPoint &point); Q_SIGNALS: void closeRequested(); private Q_SLOTS: void slotRemove(); private: Qt::Orientation m_orientation; Area *m_area; View *m_view; Qt::DockWidgetArea m_docking_area; IdealController *m_controller; }; } #endif // IDEALDOCKWIDGET_H diff --git a/sublime/mainwindow_p.cpp b/sublime/mainwindow_p.cpp index e3388eb8b7..26ffddebc6 100644 --- a/sublime/mainwindow_p.cpp +++ b/sublime/mainwindow_p.cpp @@ -1,815 +1,815 @@ /*************************************************************************** * Copyright 2006-2009 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. * ***************************************************************************/ #include "mainwindow_p.h" #include #include #include #include #include #include #include #include #include #include "area.h" #include "view.h" #include "areaindex.h" #include "document.h" #include "container.h" #include "controller.h" #include "mainwindow.h" #include "idealcontroller.h" #include "holdupdates.h" #include "idealbuttonbarwidget.h" #include "sublimedebug.h" class IdealToolBar : public QToolBar { Q_OBJECT public: explicit IdealToolBar(const QString& title, bool hideWhenEmpty, Sublime::IdealButtonBarWidget* buttons, QMainWindow* parent) : QToolBar(title, parent) , m_buttons(buttons) , m_hideWhenEmpty(hideWhenEmpty) { setMovable(false); setFloatable(false); setObjectName(title); layout()->setMargin(0); addWidget(m_buttons); if (m_hideWhenEmpty) { connect(m_buttons, &Sublime::IdealButtonBarWidget::emptyChanged, this, &IdealToolBar::updateVisibilty); } } - private slots: + private Q_SLOTS: void updateVisibilty() { setVisible(!m_buttons->isEmpty()); } private: Sublime::IdealButtonBarWidget* m_buttons; const bool m_hideWhenEmpty; }; namespace Sublime { MainWindowPrivate::MainWindowPrivate(MainWindow *w, Controller* controller) :controller(controller), area(nullptr), activeView(nullptr), activeToolView(nullptr), bgCentralWidget(nullptr), ignoreDockShown(false), autoAreaSettingsSave(false), m_mainWindow(w) { KActionCollection *ac = m_mainWindow->actionCollection(); m_concentrationModeAction = new QAction(i18n("Concentration Mode"), this); m_concentrationModeAction->setIcon(QIcon::fromTheme(QStringLiteral("page-zoom"))); m_concentrationModeAction->setToolTip(i18n("Removes most of the controls so you can focus on what matters.")); m_concentrationModeAction->setCheckable(true); m_concentrationModeAction->setChecked(false); ac->setDefaultShortcut(m_concentrationModeAction, Qt::META | Qt::Key_C); connect(m_concentrationModeAction, &QAction::toggled, this, &MainWindowPrivate::restoreConcentrationMode); ac->addAction(QStringLiteral("toggle_concentration_mode"), m_concentrationModeAction); QAction* action = new QAction(i18n("Show Left Dock"), this); action->setCheckable(true); ac->setDefaultShortcut(action, Qt::META | Qt::CTRL | Qt::Key_Left); connect(action, &QAction::toggled, this, &MainWindowPrivate::showLeftDock); ac->addAction(QStringLiteral("show_left_dock"), action); action = new QAction(i18n("Show Right Dock"), this); action->setCheckable(true); ac->setDefaultShortcut(action, Qt::META | Qt::CTRL | Qt::Key_Right); connect(action, &QAction::toggled, this, &MainWindowPrivate::showRightDock); ac->addAction(QStringLiteral("show_right_dock"), action); action = new QAction(i18n("Show Bottom Dock"), this); action->setCheckable(true); ac->setDefaultShortcut(action, Qt::META | Qt::CTRL | Qt::Key_Down); connect(action, &QAction::toggled, this, &MainWindowPrivate::showBottomDock); ac->addAction(QStringLiteral("show_bottom_dock"), action); action = new QAction(i18nc("@action", "Focus Editor"), this); ac->setDefaultShortcut(action, Qt::META | Qt::CTRL | Qt::Key_E); connect(action, &QAction::triggered, this, &MainWindowPrivate::focusEditor); ac->addAction(QStringLiteral("focus_editor"), action); action = new QAction(i18n("Hide/Restore Docks"), this); ac->setDefaultShortcut(action, Qt::META | Qt::CTRL | Qt::Key_Up); connect(action, &QAction::triggered, this, &MainWindowPrivate::toggleDocksShown); ac->addAction(QStringLiteral("hide_all_docks"), action); action = new QAction(i18n("Next Tool View"), this); ac->setDefaultShortcut(action, Qt::META | Qt::CTRL | Qt::Key_N); action->setIcon(QIcon::fromTheme(QStringLiteral("go-next"))); connect(action, &QAction::triggered, this, &MainWindowPrivate::selectNextDock); ac->addAction(QStringLiteral("select_next_dock"), action); action = new QAction(i18n("Previous Tool View"), this); ac->setDefaultShortcut(action, Qt::META | Qt::CTRL | Qt::Key_P); action->setIcon(QIcon::fromTheme(QStringLiteral("go-previous"))); connect(action, &QAction::triggered, this, &MainWindowPrivate::selectPreviousDock); ac->addAction(QStringLiteral("select_previous_dock"), action); action = new KActionMenu(i18n("Tool Views"), this); ac->addAction(QStringLiteral("docks_submenu"), action); idealController = new IdealController(m_mainWindow); m_leftToolBar = new IdealToolBar(i18n("Left Button Bar"), true, idealController->leftBarWidget, m_mainWindow); m_mainWindow->addToolBar(Qt::LeftToolBarArea, m_leftToolBar); m_rightToolBar = new IdealToolBar(i18n("Right Button Bar"), true, idealController->rightBarWidget, m_mainWindow); m_mainWindow->addToolBar(Qt::RightToolBarArea, m_rightToolBar); m_bottomToolBar = new IdealToolBar(i18n("Bottom Button Bar"), false, idealController->bottomBarWidget, m_mainWindow); m_mainWindow->addToolBar(Qt::BottomToolBarArea, m_bottomToolBar); // adymo: intentionally do not add a toolbar for top buttonbar // this doesn't work well with toolbars added via xmlgui centralWidget = new QWidget; centralWidget->setObjectName(QStringLiteral("centralWidget")); QVBoxLayout* layout = new QVBoxLayout(centralWidget); layout->setMargin(0); centralWidget->setLayout(layout); splitterCentralWidget = new QSplitter(centralWidget); // take as much space as possible splitterCentralWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); layout->addWidget(splitterCentralWidget, 2); // this view bar container is used for the ktexteditor integration to show // all view bars at a central place, esp. for split view configurations viewBarContainer = new QWidget; viewBarContainer->setObjectName(QStringLiteral("viewBarContainer")); // hide by default viewBarContainer->setVisible(false); // only take as much as needed viewBarContainer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); layout->addWidget(viewBarContainer); m_mainWindow->setCentralWidget(centralWidget); connect(idealController, &IdealController::dockShown, this, &MainWindowPrivate::slotDockShown); connect(idealController, &IdealController::widgetResized, this, &MainWindowPrivate::widgetResized); connect(idealController, &IdealController::dockBarContextMenuRequested, m_mainWindow, &MainWindow::dockBarContextMenuRequested); } MainWindowPrivate::~MainWindowPrivate() { delete m_leftTabbarCornerWidget.data(); m_leftTabbarCornerWidget.clear(); } void MainWindowPrivate::disableConcentrationMode() { m_concentrationModeAction->setChecked(false); restoreConcentrationMode(); } void MainWindowPrivate::restoreConcentrationMode() { const bool concentrationModeOn = m_concentrationModeAction->isChecked(); QWidget* cornerWidget = nullptr; if (m_concentrateToolBar) { QLayout* l = m_concentrateToolBar->layout(); QLayoutItem* li = l->takeAt(1); //ensure the cornerWidget isn't destroyed with the toolbar if (li) { cornerWidget = li->widget(); delete li; } m_concentrateToolBar->deleteLater(); } m_mainWindow->menuBar()->setVisible(!concentrationModeOn); m_bottomToolBar->setVisible(!concentrationModeOn); m_leftToolBar->setVisible(!concentrationModeOn); m_rightToolBar->setVisible(!concentrationModeOn); if (concentrationModeOn) { m_concentrateToolBar = new QToolBar(m_mainWindow); m_concentrateToolBar->setObjectName(QStringLiteral("concentrateToolBar")); m_concentrateToolBar->addAction(m_concentrationModeAction); QWidgetAction *action = new QWidgetAction(this); action->setDefaultWidget(m_mainWindow->menuBar()->cornerWidget(Qt::TopRightCorner)); m_concentrateToolBar->addAction(action); m_concentrateToolBar->setMovable(false); m_mainWindow->addToolBar(Qt::TopToolBarArea, m_concentrateToolBar); m_mainWindow->menuBar()->setCornerWidget(nullptr, Qt::TopRightCorner); } else if (cornerWidget) { m_mainWindow->menuBar()->setCornerWidget(cornerWidget, Qt::TopRightCorner); cornerWidget->show(); } if (concentrationModeOn) { m_mainWindow->installEventFilter(this); } else { m_mainWindow->removeEventFilter(this); } } bool MainWindowPrivate::eventFilter(QObject* obj, QEvent* event) { Q_ASSERT(m_mainWindow == obj); if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) { const auto ev = static_cast(event); Qt::KeyboardModifiers modifiers = ev->modifiers(); //QLineEdit banned mostly so that alt navigation can be used from QuickOpen const bool visible = modifiers == Qt::AltModifier && ev->type() == QEvent::KeyPress && !qApp->focusWidget()->inherits("QLineEdit"); m_mainWindow->menuBar()->setVisible(visible); } return false; } void MainWindowPrivate::showLeftDock(bool b) { idealController->showLeftDock(b); } void MainWindowPrivate::showBottomDock(bool b) { idealController->showBottomDock(b); } void MainWindowPrivate::showRightDock(bool b) { idealController->showRightDock(b); } void MainWindowPrivate::setBackgroundCentralWidget(QWidget* w) { delete bgCentralWidget; QLayout* l=m_mainWindow->centralWidget()->layout(); l->addWidget(w); bgCentralWidget=w; setBackgroundVisible(area->views().isEmpty()); } void MainWindowPrivate::setBackgroundVisible(bool v) { if(!bgCentralWidget) return; bgCentralWidget->setVisible(v); splitterCentralWidget->setVisible(!v); } void MainWindowPrivate::focusEditor() { if (View* view = m_mainWindow->activeView()) if (view->hasWidget()) view->widget()->setFocus(Qt::ShortcutFocusReason); } void MainWindowPrivate::toggleDocksShown() { idealController->toggleDocksShown(); } void MainWindowPrivate::selectNextDock() { idealController->goPrevNextDock(IdealController::NextDock); } void MainWindowPrivate::selectPreviousDock() { idealController->goPrevNextDock(IdealController::PrevDock); } Area::WalkerMode MainWindowPrivate::IdealToolViewCreator::operator() (View *view, Sublime::Position position) { if (!d->docks.contains(view)) { d->docks << view; //add view d->idealController->addView(d->positionToDockArea(position), view); } return Area::ContinueWalker; } Area::WalkerMode MainWindowPrivate::ViewCreator::operator() (AreaIndex *index) { QSplitter *splitter = d->m_indexSplitters.value(index); if (!splitter) { //no splitter - we shall create it and populate with views if (!index->parent()) { qCDebug(SUBLIME) << "reconstructing root area"; //this is root area splitter = d->splitterCentralWidget; d->m_indexSplitters[index] = splitter; } else { if (!d->m_indexSplitters.value(index->parent())) { // can happen in working set code, as that adds a view to a child index first // hence, recursively reconstruct the parent indizes first operator()(index->parent()); } QSplitter *parent = d->m_indexSplitters.value(index->parent()); splitter = new QSplitter(parent); d->m_indexSplitters[index] = splitter; if(index == index->parent()->first()) parent->insertWidget(0, splitter); else parent->addWidget(splitter); } Q_ASSERT(splitter); } if (index->isSplit()) //this is a visible splitter splitter->setOrientation(index->orientation()); else { Container *container = nullptr; while(splitter->count() && qobject_cast(splitter->widget(0))) { // After unsplitting, we might have to remove old splitters QWidget* widget = splitter->widget(0); qCDebug(SUBLIME) << "deleting" << widget; widget->setParent(nullptr); delete widget; } if (!splitter->widget(0)) { //we need to create view container container = new Container(splitter); connect(container, &Container::activateView, d->m_mainWindow, &MainWindow::activateViewAndFocus); connect(container, &Container::tabDoubleClicked, d->m_mainWindow, &MainWindow::tabDoubleClicked); connect(container, &Container::tabContextMenuRequested, d->m_mainWindow, &MainWindow::tabContextMenuRequested); connect(container, &Container::tabToolTipRequested, d->m_mainWindow, &MainWindow::tabToolTipRequested); connect(container, static_cast(&Container::requestClose), d, &MainWindowPrivate::widgetCloseRequest, Qt::QueuedConnection); connect(container, &Container::newTabRequested, d->m_mainWindow, &MainWindow::newTabRequested); splitter->addWidget(container); } else container = qobject_cast(splitter->widget(0)); container->show(); int position = 0; bool hadActiveView = false; Sublime::View* activeView = d->activeView; foreach (View *view, index->views()) { QWidget *widget = view->widget(container); if (widget) { if(!container->hasWidget(widget)) { container->addWidget(view, position); d->viewContainers[view] = container; d->widgetToView[widget] = view; } if(activeView == view) { hadActiveView = true; container->setCurrentWidget(widget); }else if(topViews.contains(view) && !hadActiveView) container->setCurrentWidget(widget); } position++; } } return Area::ContinueWalker; } void MainWindowPrivate::reconstructViews(QList topViews) { ViewCreator viewCreator(this, topViews); area->walkViews(viewCreator, area->rootIndex()); setBackgroundVisible(area->views().isEmpty()); } void MainWindowPrivate::reconstruct() { if(m_leftTabbarCornerWidget) { m_leftTabbarCornerWidget->hide(); m_leftTabbarCornerWidget->setParent(nullptr); } IdealToolViewCreator toolViewCreator(this); area->walkToolViews(toolViewCreator, Sublime::AllPositions); reconstructViews(); { QSignalBlocker blocker(m_mainWindow); qCDebug(SUBLIME) << "RECONSTRUCT" << area << area->shownToolViews(Sublime::Left); foreach (View *view, area->toolViews()) { QString id = view->document()->documentSpecifier(); if (!id.isEmpty()) { Sublime::Position pos = area->toolViewPosition(view); if (area->shownToolViews(pos).contains(id)) idealController->raiseView(view, IdealController::GroupWithOtherViews); } } } setTabBarLeftCornerWidget(m_leftTabbarCornerWidget.data()); } void MainWindowPrivate::clearArea() { if(m_leftTabbarCornerWidget) m_leftTabbarCornerWidget->setParent(nullptr); //reparent toolview widgets to 0 to prevent their deletion together with dockwidgets foreach (View *view, area->toolViews()) { // FIXME should we really delete here?? bool nonDestructive = true; idealController->removeView(view, nonDestructive); if (view->hasWidget()) view->widget()->setParent(nullptr); } docks.clear(); //reparent all view widgets to 0 to prevent their deletion together with central //widget. this reparenting is necessary when switching areas inside the same mainwindow foreach (View *view, area->views()) { if (view->hasWidget()) view->widget()->setParent(nullptr); } cleanCentralWidget(); m_mainWindow->setActiveView(nullptr); m_indexSplitters.clear(); area = nullptr; viewContainers.clear(); setTabBarLeftCornerWidget(m_leftTabbarCornerWidget.data()); } void MainWindowPrivate::cleanCentralWidget() { while(splitterCentralWidget->count()) delete splitterCentralWidget->widget(0); setBackgroundVisible(true); } struct ShownToolViewFinder { ShownToolViewFinder() {} Area::WalkerMode operator()(View *v, Sublime::Position /*position*/) { if (v->hasWidget() && v->widget()->isVisible()) views << v; return Area::ContinueWalker; } QList views; }; void MainWindowPrivate::slotDockShown(Sublime::View* /*view*/, Sublime::Position pos, bool /*shown*/) { if (ignoreDockShown) return; ShownToolViewFinder finder; m_mainWindow->area()->walkToolViews(finder, pos); QStringList ids; foreach (View *v, finder.views) { ids << v->document()->documentSpecifier(); } area->setShownToolViews(pos, ids); } void MainWindowPrivate::viewRemovedInternal(AreaIndex* index, View* view) { Q_UNUSED(index); Q_UNUSED(view); setBackgroundVisible(area->views().isEmpty()); } void MainWindowPrivate::viewAdded(Sublime::AreaIndex *index, Sublime::View *view) { if(m_leftTabbarCornerWidget) { m_leftTabbarCornerWidget->hide(); m_leftTabbarCornerWidget->setParent(nullptr); } // Remove container objects in the hierarchy from the parents, // because they are not needed anymore, and might lead to broken splitter hierarchy and crashes. for(Sublime::AreaIndex* current = index; current; current = current->parent()) { QSplitter *splitter = m_indexSplitters[current]; if (current->isSplit() && splitter) { // Also update the orientation splitter->setOrientation(current->orientation()); for(int w = 0; w < splitter->count(); ++w) { Container *container = qobject_cast(splitter->widget(w)); //we need to remove extra container before reconstruction //first reparent widgets in container so that they are not deleted if(container) { while (container->count()) { container->widget(0)->setParent(nullptr); } //and then delete the container delete container; } } } } ViewCreator viewCreator(this); area->walkViews(viewCreator, index); emit m_mainWindow->viewAdded( view ); setTabBarLeftCornerWidget(m_leftTabbarCornerWidget.data()); setBackgroundVisible(false); } void Sublime::MainWindowPrivate::raiseToolView(Sublime::View * view) { idealController->raiseView(view); } void MainWindowPrivate::aboutToRemoveView(Sublime::AreaIndex *index, Sublime::View *view) { QSplitter *splitter = m_indexSplitters[index]; if (!splitter) return; qCDebug(SUBLIME) << "index " << index << " root " << area->rootIndex(); qCDebug(SUBLIME) << "splitter " << splitter << " container " << splitter->widget(0); qCDebug(SUBLIME) << "structure: " << index->print() << " whole structure: " << area->rootIndex()->print(); //find the container for the view and remove the widget Container *container = qobject_cast(splitter->widget(0)); if (!container) { qCWarning(SUBLIME) << "Splitter does not have a left widget!"; return; } emit m_mainWindow->aboutToRemoveView( view ); if (view->widget()) widgetToView.remove(view->widget()); viewContainers.remove(view); const bool wasActive = m_mainWindow->activeView() == view; if (container->count() > 1) { //container is not empty or this is a root index //just remove a widget if( view->widget() ) { container->removeWidget(view->widget()); view->widget()->setParent(nullptr); //activate what is visible currently in the container if the removed view was active if (wasActive) return m_mainWindow->setActiveView(container->viewForWidget(container->currentWidget())); } } else { if(m_leftTabbarCornerWidget) { m_leftTabbarCornerWidget->hide(); m_leftTabbarCornerWidget->setParent(nullptr); } // We've about to remove the last view of this container. It will // be empty, so have to delete it, as well. // If we have a container, then it should be the only child of // the splitter. Q_ASSERT(splitter->count() == 1); container->removeWidget(view->widget()); if (view->widget()) view->widget()->setParent(nullptr); else qCWarning(SUBLIME) << "View does not have a widget!"; Q_ASSERT(container->count() == 0); // We can be called from signal handler of container // (which is tab widget), so defer deleting it. container->deleteLater(); container->setParent(nullptr); /* If we're not at the top level, we get to collapse split views. */ if (index->parent()) { /* The splitter used to have container as the only child, now it's time to get rid of it. Make sure deleting splitter does not delete container -- per above comment, we'll delete it later. */ container->setParent(nullptr); m_indexSplitters.remove(index); delete splitter; AreaIndex *parent = index->parent(); QSplitter *parentSplitter = m_indexSplitters[parent]; AreaIndex *sibling = parent->first() == index ? parent->second() : parent->first(); QSplitter *siblingSplitter = m_indexSplitters[sibling]; if(siblingSplitter) { HoldUpdates du(parentSplitter); //save sizes and orientation of the sibling splitter parentSplitter->setOrientation(siblingSplitter->orientation()); QList sizes = siblingSplitter->sizes(); /* Parent has two children -- 'index' that we've deleted and 'sibling'. We move all children of 'sibling' into parent, and delete 'sibling'. sibling either contains a single Container instance, or a bunch of further QSplitters. */ while (siblingSplitter->count() > 0) { //reparent contents into parent splitter QWidget *siblingWidget = siblingSplitter->widget(0); siblingWidget->setParent(parentSplitter); parentSplitter->addWidget(siblingWidget); } m_indexSplitters.remove(sibling); delete siblingSplitter; parentSplitter->setSizes(sizes); } qCDebug(SUBLIME) << "after deleation " << parent << " has " << parentSplitter->count() << " elements"; //find the container somewhere to activate Container *containerToActivate = parentSplitter->findChild(); //activate the current view there if (containerToActivate) { m_mainWindow->setActiveView(containerToActivate->viewForWidget(containerToActivate->currentWidget())); setTabBarLeftCornerWidget(m_leftTabbarCornerWidget.data()); return; } } } setTabBarLeftCornerWidget(m_leftTabbarCornerWidget.data()); if ( wasActive ) { m_mainWindow->setActiveView(nullptr); } } void MainWindowPrivate::toolViewAdded(Sublime::View* /*toolView*/, Sublime::Position position) { IdealToolViewCreator toolViewCreator(this); area->walkToolViews(toolViewCreator, position); } void MainWindowPrivate::aboutToRemoveToolView(Sublime::View *toolView, Sublime::Position /*position*/) { if (!docks.contains(toolView)) return; idealController->removeView(toolView); // TODO are Views unique? docks.removeAll(toolView); } void MainWindowPrivate::toolViewMoved( Sublime::View *toolView, Sublime::Position position) { if (!docks.contains(toolView)) return; idealController->moveView(toolView, positionToDockArea(position)); } Qt::DockWidgetArea MainWindowPrivate::positionToDockArea(Position position) { switch (position) { case Sublime::Left: return Qt::LeftDockWidgetArea; case Sublime::Right: return Qt::RightDockWidgetArea; case Sublime::Bottom: return Qt::BottomDockWidgetArea; case Sublime::Top: return Qt::TopDockWidgetArea; default: return Qt::LeftDockWidgetArea; } } void MainWindowPrivate::switchToArea(QAction *action) { qCDebug(SUBLIME) << "for" << action; controller->showArea(m_actionAreas.value(action), m_mainWindow); } void MainWindowPrivate::updateAreaSwitcher(Sublime::Area *area) { QAction* action = m_areaActions.value(area); if (action) action->setChecked(true); } void MainWindowPrivate::activateFirstVisibleView() { QList views = area->views(); if (views.count() > 0) m_mainWindow->activateView(views.first()); } void MainWindowPrivate::widgetResized(Qt::DockWidgetArea /*dockArea*/, int /*thickness*/) { //TODO: adymo: remove all thickness business } void MainWindowPrivate::widgetCloseRequest(QWidget* widget) { if (View *view = widgetToView.value(widget)) { area->closeView(view); } } void MainWindowPrivate::setTabBarLeftCornerWidget(QWidget* widget) { if(widget != m_leftTabbarCornerWidget.data()) { delete m_leftTabbarCornerWidget.data(); m_leftTabbarCornerWidget.clear(); } m_leftTabbarCornerWidget = widget; if(!widget || !area || viewContainers.isEmpty()) return; AreaIndex* putToIndex = area->rootIndex(); QSplitter* splitter = m_indexSplitters[putToIndex]; while(putToIndex->isSplit()) { putToIndex = putToIndex->first(); splitter = m_indexSplitters[putToIndex]; } // Q_ASSERT(splitter || putToIndex == area->rootIndex()); Container* c = nullptr; if(splitter) { c = qobject_cast(splitter->widget(0)); }else{ c = *viewContainers.constBegin(); } Q_ASSERT(c); c->setLeftCornerWidget(widget); } } #include "mainwindow_p.moc" #include "moc_mainwindow_p.cpp" diff --git a/sublime/mainwindow_p.h b/sublime/mainwindow_p.h index 542cf3ae23..698b2e91ab 100644 --- a/sublime/mainwindow_p.h +++ b/sublime/mainwindow_p.h @@ -1,156 +1,156 @@ /*************************************************************************** * 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_SUBLIMEMAINWINDOW_P_H #define KDEVPLATFORM_SUBLIMEMAINWINDOW_P_H #include #include #include #include #include "area.h" #include "sublimedefs.h" #include "mainwindow.h" #include class QAction; class QSplitter; class IdealToolBar; namespace Sublime { class View; class Container; class Controller; class AreaIndex; class IdealMainWidget; class IdealController; class MainWindowPrivate: public QObject { Q_OBJECT public: MainWindowPrivate(MainWindow *w, Controller* controller); ~MainWindowPrivate() override; /**Use this to create tool views for an area.*/ class IdealToolViewCreator { public: explicit IdealToolViewCreator(MainWindowPrivate *_d): d(_d) {} Area::WalkerMode operator() (View *view, Sublime::Position position); private: MainWindowPrivate *d; }; /**Use this to create views for an area.*/ class ViewCreator { public: explicit ViewCreator(MainWindowPrivate *_d, QList _topViews = QList()): d(_d), topViews(_topViews.toSet()) {} Area::WalkerMode operator() (AreaIndex *index); private: MainWindowPrivate *d; QSet topViews; }; /**Reconstructs the mainwindow according to the current area.*/ void reconstruct(); /**Reconstructs the views according to the current area index.*/ void reconstructViews(QList topViews = QList()); /**Clears the area leaving mainwindow empty.*/ void clearArea(); /** Sets a @p w widget that will be shown when there are no documents on the area */ void setBackgroundCentralWidget(QWidget* w); void activateFirstVisibleView(); Controller *controller; Area *area; QList docks; QMap viewContainers; QMap widgetToView; View *activeView; View *activeToolView; QWidget *centralWidget; QWidget* bgCentralWidget; QWidget* viewBarContainer; QSplitter* splitterCentralWidget; IdealController *idealController; int ignoreDockShown; bool autoAreaSettingsSave; bool eventFilter(QObject* obj, QEvent* event) override; void disableConcentrationMode(); -public slots: +public Q_SLOTS: void toggleDocksShown(); void viewAdded(Sublime::AreaIndex *index, Sublime::View *view); void viewRemovedInternal(Sublime::AreaIndex *index, Sublime::View *view); void raiseToolView(Sublime::View* view); void aboutToRemoveView(Sublime::AreaIndex *index, Sublime::View *view); void toolViewAdded(Sublime::View *toolView, Sublime::Position position); void aboutToRemoveToolView(Sublime::View *toolView, Sublime::Position position); void toolViewMoved(Sublime::View *toolView, Sublime::Position position); void setTabBarLeftCornerWidget(QWidget* widget); -private slots: +private Q_SLOTS: void switchToArea(QAction *action); void updateAreaSwitcher(Sublime::Area *area); void slotDockShown(Sublime::View*, Sublime::Position, bool); void widgetResized(Qt::DockWidgetArea dockArea, int thickness); void widgetCloseRequest(QWidget* widget); void showLeftDock(bool b); void showRightDock(bool b); void showBottomDock(bool b); void focusEditor(); void selectNextDock(); void selectPreviousDock(); private: void restoreConcentrationMode(); void setBackgroundVisible(bool v); Qt::DockWidgetArea positionToDockArea(Position position); void cleanCentralWidget(); MainWindow *m_mainWindow; // uses QPointer to make already-deleted splitters detectable QMap > m_indexSplitters; QMap m_areaActions; QMap m_actionAreas; QPointer m_leftTabbarCornerWidget; QPointer m_concentrateToolBar; IdealToolBar* m_bottomToolBar; IdealToolBar* m_rightToolBar; IdealToolBar* m_leftToolBar; QAction* m_concentrationModeAction; }; } #endif diff --git a/sublime/tests/test_aggregatemodel.h b/sublime/tests/test_aggregatemodel.h index be02501678..30a4353107 100644 --- a/sublime/tests/test_aggregatemodel.h +++ b/sublime/tests/test_aggregatemodel.h @@ -1,36 +1,36 @@ /*************************************************************************** * 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_TEST_AGGREGATEMODEL_H #define KDEVPLATFORM_TEST_AGGREGATEMODEL_H #include class QStandardItemModel; class TestAggregateModel: public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void modelAggregationInASingleView(); private: QStandardItemModel *newModel(); }; #endif diff --git a/sublime/tests/test_areaoperation.h b/sublime/tests/test_areaoperation.h index 5fe42f25c0..7f3f22b572 100644 --- a/sublime/tests/test_areaoperation.h +++ b/sublime/tests/test_areaoperation.h @@ -1,68 +1,68 @@ /*************************************************************************** * 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_TEST_AREAOPERATION_H #define KDEVPLATFORM_TEST_AREAOPERATION_H #include namespace Sublime { class Area; class View; class Controller; class MainWindow; } class TestAreaOperation: public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void init(); void cleanup(); void areaConstruction(); void mainWindowConstruction(); void areaCloning(); void areaSwitchingInSameMainwindow(); void simpleViewAdditionAndDeletion(); void complexViewAdditionAndDeletion(); void toolViewAdditionAndDeletion(); void testAddingViewAfter(); void splitViewActiveTabsTest(); private: void checkArea1(Sublime::MainWindow *mw); void checkArea2(Sublime::MainWindow *mw); /*! @param location short descriptive message printed on failure. */ void checkAreaViewsDisplay(Sublime::MainWindow *mw, Sublime::Area *area, const QString &areas, int containers, int splitters, QString location=QString()); Sublime::View *findNamedView(Sublime::Area *area, const QString &name); Sublime::Controller *m_controller; Sublime::Area *m_area1; Sublime::Area *m_area2; Sublime::Area *m_area3; Sublime::View *m_pView111; Sublime::View *m_pView121; Sublime::View *m_pView122; Sublime::View *m_pView131; }; #endif diff --git a/sublime/tests/test_areawalker.h b/sublime/tests/test_areawalker.h index 7edd489477..253b1c281f 100644 --- a/sublime/tests/test_areawalker.h +++ b/sublime/tests/test_areawalker.h @@ -1,30 +1,30 @@ /*************************************************************************** * 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_TEST_AREAWALKER_H #define KDEVPLATFORM_TEST_AREAWALKER_H #include class TestAreaWalker: public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void viewWalkerModes(); void toolViewWalkerModes(); }; #endif diff --git a/sublime/tests/test_controller.h b/sublime/tests/test_controller.h index 6c5e1ae0cc..1b93d764d9 100644 --- a/sublime/tests/test_controller.h +++ b/sublime/tests/test_controller.h @@ -1,32 +1,32 @@ /*************************************************************************** * 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_TEST_CONTROLLER_H #define KDEVPLATFORM_TEST_CONTROLLER_H #include class TestController: public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void documentDeletion(); void areaDeletion(); void namedAreas(); }; #endif diff --git a/sublime/tests/test_document.h b/sublime/tests/test_document.h index 5c751d7990..38b78a535f 100644 --- a/sublime/tests/test_document.h +++ b/sublime/tests/test_document.h @@ -1,30 +1,30 @@ /*************************************************************************** * 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_TEST_DOCUMENT_H #define KDEVPLATFORM_TEST_DOCUMENT_H #include class TestDocument: public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void viewDeletion(); }; #endif diff --git a/sublime/tests/test_toolviewtoolbar.h b/sublime/tests/test_toolviewtoolbar.h index 50d5c1431f..0f71f75bd6 100644 --- a/sublime/tests/test_toolviewtoolbar.h +++ b/sublime/tests/test_toolviewtoolbar.h @@ -1,60 +1,60 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2008 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_TEST_TOOLVIEWTOOLBAR_H #define KDEVPLATFORM_TEST_TOOLVIEWTOOLBAR_H #include namespace Sublime { class View; class Controller; class ToolDocument; class Area; } class QToolBar; class TestToolViewToolBar : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void init(); void cleanup(); void horizontalTool(); void verticalTool(); void toolViewMove(); private: QToolBar* fetchToolBarFor(Sublime::View*); void assertGoodBar(QToolBar*, QString actionText); private: Sublime::Controller *controller; Sublime::Area *area; Sublime::ToolDocument *tool1; Sublime::ToolDocument *tool2; Sublime::View *viewT11; Sublime::View *viewT21; QString actionTextT1; QString actionTextT2; }; #endif diff --git a/sublime/tests/test_view.h b/sublime/tests/test_view.h index 1d7fc7b402..d93ca0c555 100644 --- a/sublime/tests/test_view.h +++ b/sublime/tests/test_view.h @@ -1,31 +1,31 @@ /*************************************************************************** * 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_TEST_VIEW_H #define KDEVPLATFORM_TEST_VIEW_H #include class TestView: public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void widgetDeletion(); void viewReimplementation(); }; #endif diff --git a/sublime/tests/test_viewactivation.h b/sublime/tests/test_viewactivation.h index 0a51035022..f2e744d725 100644 --- a/sublime/tests/test_viewactivation.h +++ b/sublime/tests/test_viewactivation.h @@ -1,68 +1,68 @@ /*************************************************************************** * 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_TEST_VIEWACTIVATION_H #define KDEVPLATFORM_TEST_VIEWACTIVATION_H #include namespace Sublime { class View; class Controller; class Document; class Area; } class TestViewActivation: public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void init(); void cleanup(); void viewActivation(); void activationInMultipleMainWindows(); void activationAfterViewRemoval(); void activationAfterRemovalSimplestCase(); void signalsOnViewCreationAndDeletion(); private: Sublime::Controller *controller; Sublime::Area *area; Sublime::Document *doc1; Sublime::Document *doc2; Sublime::Document *doc3; Sublime::Document *doc4; Sublime::Document *tool1; Sublime::Document *tool2; Sublime::Document *tool3; Sublime::View *view211; Sublime::View *view212; Sublime::View *view221; Sublime::View *view231; Sublime::View *view241; Sublime::View *viewT11; Sublime::View *viewT21; Sublime::View *viewT31; Sublime::View *viewT32; }; #endif diff --git a/util/duchainify/main.h b/util/duchainify/main.h index b52e74ecd6..7175cafa54 100644 --- a/util/duchainify/main.h +++ b/util/duchainify/main.h @@ -1,52 +1,52 @@ /*************************************************************************** * Copyright 2009 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_MAIN_H #define KDEVPLATFORM_MAIN_H #include #include #include #include #include class QCommandLineParser; class Manager : public QObject { Q_OBJECT public: explicit Manager(QCommandLineParser* args); void addToBackgroundParser(QString path, KDevelop::TopDUContext::Features features); QSet waiting(); private: QSet m_waiting; uint m_total; QCommandLineParser* m_args; QAtomicInt m_allFilesAdded; - public slots: + public Q_SLOTS: // delay init into event loop so the DUChain can always shutdown gracefully void init(); void updateReady(KDevelop::IndexedString url, KDevelop::ReferencedTopDUContext topContext); void finish(); void dump(const KDevelop::ReferencedTopDUContext& topContext); }; #endif diff --git a/util/environmentselectionwidget.h b/util/environmentselectionwidget.h index cb180aa88e..0f89025070 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" namespace KDevelop { class EnvironmentProfileList; /** * 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 = 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 EnvironmentProfileList which has been used to populate this * widget. */ EnvironmentProfileList environmentProfiles() const; -public slots: +public Q_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/multilevellistview.h b/util/multilevellistview.h index c8c4c9fa4e..2a2c1a3760 100644 --- a/util/multilevellistview.h +++ b/util/multilevellistview.h @@ -1,149 +1,149 @@ /* 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 = nullptr, Qt::WindowFlags f = {}); /** * 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: +Q_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: +public Q_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 ensureViewSelected(QTreeView* view)) }; } #endif // KDEVPLATFORM_MULTILEVELLISTVIEW_H diff --git a/util/tests/test_embeddedfreetree.cpp b/util/tests/test_embeddedfreetree.cpp index 409164ed94..f2eb264296 100644 --- a/util/tests/test_embeddedfreetree.cpp +++ b/util/tests/test_embeddedfreetree.cpp @@ -1,609 +1,609 @@ /* This file is part of KDevelop 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. */ unsigned int extractor_div_with = 0; #include #include #include #include #include #include #include #include #include #include #include #include struct TestItem { explicit TestItem(uint _value = 0) : value(_value), leftChild(-1), rightChild(-1) { } uint value; int leftChild; int rightChild; bool operator==(const TestItem& rhs) const { return value == rhs.value; } bool operator<(const TestItem& item) const { return value < item.value; } }; struct TestItemConversion { static uint toIndex(const TestItem& item) { return item.value; } static TestItem toItem(uint index) { return TestItem(index); } }; struct Extractor{ static TestItem extract(const TestItem& item) { return TestItem(item.value/extractor_div_with); } }; clock_t std_insertion = 0, std_removal = 0, std_contains = 0, std_iteration = 0, emb_insertion = 0, emb_removal = 0, emb_contains = 0, emb_iteration = 0; QString toString(std::set set) { QString ret; for(std::set::const_iterator it = set.begin(); it != set.end(); ++it) ret += QStringLiteral("%1 ").arg(*it); return ret; } bool operator==(const std::set a, const std::set b) { if(a.size() != b.size()) { qDebug() << "size mismatch" << toString(a) << ": " << toString(b); return false; } std::set::const_iterator aIt = a.begin(); std::set::const_iterator bIt = b.begin(); for(; aIt != a.end(); ++aIt, ++bIt) if(*aIt != *bIt) { qDebug() << "mismatch" << toString(a) << ": " << toString(b); return false; } return true; } struct TestItemHandler { public: static int rightChild(const TestItem& m_data) { return m_data.rightChild; } static int leftChild(const TestItem& m_data) { return m_data.leftChild; } static void setLeftChild(TestItem& m_data, int child) { m_data.leftChild = child; } static void setRightChild(TestItem& m_data, int child) { m_data.rightChild = child; } //Copies this item into the given one static void copyTo(const TestItem& m_data, TestItem& data) { data = m_data; } static void createFreeItem(TestItem& data) { data = TestItem(); } static inline bool isFree(const TestItem& m_data) { return !m_data.value; } static const TestItem& data(const TestItem& m_data) { return m_data; } inline static bool equals(const TestItem& m_data, const TestItem& rhs) { return m_data.value == rhs.value; } }; class TestItemBasedSet { public: TestItemBasedSet() : m_centralFree(-1) { } void insert(uint i) { TestItem item(i); KDevelop::EmbeddedTreeAddItem add(data.data(), data.size(), m_centralFree, item); if((int)add.newItemCount() != (int)data.size()) { QVector newData; newData.resize(add.newItemCount()); add.transferData(newData.data(), newData.size()); data = newData; } } bool contains(uint item) { KDevelop::EmbeddedTreeAlgorithms alg(data.data(), data.size(), m_centralFree); return alg.indexOf(TestItem(item)) != -1; } void remove(uint i) { TestItem item(i); KDevelop::EmbeddedTreeRemoveItem remove(data.data(), data.size(), m_centralFree, item); if((int)remove.newItemCount() != (int)data.size()) { QVector newData; newData.resize(remove.newItemCount()); remove.transferData(newData.data(), newData.size()); data = newData; } } std::set toSet() const { std::set ret; for(int a = 0; a < data.size(); ++a) if(data[a].value) ret.insert(data[a].value); return ret; } void verify() { //1. verify order uint last = 0; uint freeCount = 0; for(int a = 0; a < data.size(); ++a) { if(data[a].value) { QVERIFY(last < data[a].value); last = data[a].value; }else{ ++freeCount; } } KDevelop::EmbeddedTreeAlgorithms algorithms(data.data(), data.size(), m_centralFree); uint countFree = algorithms.countFreeItems(); QCOMPARE(freeCount, countFree); algorithms.verifyTreeConsistent(); } uint getItem(uint number) const { Q_ASSERT(number < (uint)data.size()); uint ret = 0; uint size = (uint)data.size(); uint current = 0; for(uint a = 0; a < size; ++a) { if(data[a].value) { //Only count the non-free items if(current == number) ret = data[a].value; ++current; }else{ //This is a free item } } return ret; } private: int m_centralFree; QVector data; }; class TestSet { public: void add(uint i) { if(realSet.find(i) != realSet.end()) { QVERIFY(set.contains(i)); return; }else{ QVERIFY(!set.contains(i)); } clock_t start = clock(); realSet.insert(i); std_insertion += clock() - start; start = clock(); set.insert(i); emb_insertion += clock() - start; start = clock(); bool contained = realSet.find(i) != realSet.end(); std_contains += clock() - start; start = clock(); set.contains(i); emb_contains += clock() - start; QVERIFY(set.contains(i)); QVERIFY(contained); set.verify(); } void remove(uint i) { if(realSet.find(i) != realSet.end()) { QVERIFY(set.contains(i)); }else{ QVERIFY(!set.contains(i)); return; } clock_t start = clock(); set.remove(i); emb_removal += clock() - start; start = clock(); realSet.erase(i); std_removal += clock() - start; QVERIFY(!set.contains(i)); } uint size() const { return realSet.size(); } uint getItem(uint number) const { Q_ASSERT(number < size()); uint current = 0; uint ret = 0; clock_t start = clock(); for(std::set::const_iterator it = realSet.begin(); it != realSet.end(); ++it) { if(current == number) { ret = *it; } ++current; } std_iteration += clock() - start; start = clock(); set.getItem(number); emb_iteration += clock() - start; Q_ASSERT(ret); return ret; } void verify() { QVERIFY(realSet == set.toSet()); set.verify(); } private: std::set realSet; TestItemBasedSet set; }; float toSeconds(clock_t time) { return ((float)time) / CLOCKS_PER_SEC; } struct StaticRepository { static Utils::BasicSetRepository* repository() { static Utils::BasicSetRepository repository(QStringLiteral("test repository")); return &repository; } }; struct UintSetVisitor { std::set& s; explicit UintSetVisitor(std::set& _s) : s(_s) { } inline bool operator() (const TestItem& item) { s.insert(item.value); return true; } }; struct NothingDoVisitor { inline bool operator() (const TestItem& item) { Q_UNUSED(item); return true; } }; class TestEmbeddedFreeTree : public QObject { Q_OBJECT - private slots: + private Q_SLOTS: void initTestCase() { KDevelop::AutoTestShell::init(); KDevelop::TestCore::initialize(KDevelop::Core::NoUi); } void cleanupTestCase() { KDevelop::TestCore::shutdown(); } void randomizedTest() { const int cycles = 10000; const int valueRange = 1000; const int removeProbability = 40; //Percent TestSet set; srand(time(nullptr)); for(int a = 0; a < cycles; ++a) { if(a % (cycles / 10) == 0) { qDebug() << "cycle" << a; } bool remove = (rand() % 100) < removeProbability; if(remove && set.size()) { set.remove(set.getItem(rand() % set.size())); }else{ int value = (rand() % valueRange) + 1; set.add(value); } set.verify(); } qDebug() << "Performance embedded list: insertion:" << toSeconds(emb_insertion) << "removal:" << toSeconds(emb_removal) << "contains:" << toSeconds(emb_contains) << "iteration:" << toSeconds(emb_iteration); qDebug() << "Performance std::set: insertion:" << toSeconds(std_insertion) << "removal:" << toSeconds(std_removal) << "contains:" << toSeconds(std_contains) << "iteration:" << toSeconds(std_iteration); } void sequentialTest() { TestSet set; set.add(5); set.verify(); set.remove(5); set.verify(); set.add(3); set.verify(); set.add(4); set.verify(); set.add(7); set.verify(); set.remove(3); set.verify(); set.remove(7); set.verify(); set.add(6); set.verify(); set.add(1); set.verify(); set.add(9); set.verify(); set.remove(4); set.verify(); set.remove(9); set.verify(); set.add(1); set.verify(); set.add(2); set.verify(); set.add(3); set.verify(); set.add(4); set.verify(); set.add(5); set.verify(); set.remove(1); set.verify(); set.remove(3); set.verify(); set.add(15); set.verify(); set.add(16); set.verify(); set.add(17); set.verify(); set.add(18); set.verify(); set.remove(18); set.verify(); set.remove(17); set.verify(); set.add(9); set.verify(); } void testFiltering() { clock_t stdTime = 0; clock_t algoTime = 0; clock_t treeAlgoTime = 0; clock_t treeAlgoVisitorTime = 0; clock_t insertionStdTime = 0; clock_t insertionAlgoTime = 0; clock_t insertionTreeAlgoTime = 0; typedef Utils::StorableSet RepositorySet; const uint cycles = 3000; const uint setSize = 1500; uint totalItems = 0, totalFilteredItems = 0; srand(time(nullptr)); for(uint a = 0; a < cycles; ++a) { KDevelop::ConvenientFreeListSet set1; std::set testSet1; KDevelop::ConvenientFreeListSet set2; std::set testSet2; RepositorySet repSet2; if(a % (cycles / 10) == 0) { qDebug() << "cycle" << a; } //Build the sets extractor_div_with = (rand() % 10) + 1; for(uint a = 0; a < setSize; ++a) { uint value = rand() % 3000; uint divValue = value/extractor_div_with; if(!divValue) continue; // qDebug() << "inserting" << value; std::set::const_iterator it = testSet1.lower_bound(value); int pos = set1.iterator().lowerBound(TestItem(value)); //This tests the upperBound functionality if (pos != -1) { QVERIFY(it != testSet1.end()); QVERIFY(set1.data()[pos].value == *it); } else { QVERIFY(it == testSet1.end()); } if((rand() % 10) == 0) { set1.insert(TestItem(value)); testSet1.insert(value); } //This is tuned so in the end, about 99% of all declarations are filtered out, like in the symbol table. if((rand() % (extractor_div_with*100)) == 0) { clock_t start = clock(); set2.insert(TestItem(divValue)); insertionStdTime += clock() - start; start = clock(); testSet2.insert(divValue); insertionAlgoTime += clock() - start; start = clock(); repSet2.insert(TestItem(divValue)); insertionTreeAlgoTime += clock() - start; start = clock(); } } std::set verifySet1; for(KDevelop::ConvenientFreeListSet::Iterator it = set1.iterator(); it; ++it) verifySet1.insert(it->value); std::set verifySet2; for(KDevelop::ConvenientFreeListSet::Iterator it = set2.iterator(); it; ++it) verifySet2.insert(it->value); std::set verifyRepSet2; for(RepositorySet::Iterator it = repSet2.iterator(); it; ++it) verifyRepSet2.insert((*it).value); QCOMPARE(verifySet1, testSet1); QCOMPARE(verifySet2, testSet2); QCOMPARE(verifyRepSet2, testSet2); std::set algoFiltered; std::set treeAlgoFiltered; std::set treeAlgoVisitorFiltered; { //Do the filtering once without actions on the filtered items, just for calculating the time clock_t start = clock(); { KDevelop::ConvenientEmbeddedSetFilterIterator filterIterator(set1.iterator(), set2.iterator()); while(filterIterator) ++filterIterator; algoTime += clock() - start; } start = clock(); { KDevelop::ConvenientEmbeddedSetTreeFilterIterator filterIterator(set1.iterator(), repSet2); while(filterIterator) ++filterIterator; treeAlgoTime += clock() - start; } { start = clock(); NothingDoVisitor v; KDevelop::ConvenientEmbeddedSetTreeFilterVisitor visit(v, set1.iterator(), repSet2); treeAlgoVisitorTime += clock() - start; } start = clock(); for(std::set::const_iterator it = testSet1.begin(); it != testSet1.end(); ++it) { if(testSet2.count((*it) / extractor_div_with) == 1) { } } stdTime += clock() - start; } { KDevelop::ConvenientEmbeddedSetFilterIterator filterIterator(set1.iterator(), set2.iterator()); while(filterIterator) { algoFiltered.insert(filterIterator->value); ++filterIterator; } } { KDevelop::ConvenientEmbeddedSetTreeFilterIterator filterIterator(set1.iterator(), repSet2); while(filterIterator) { treeAlgoFiltered.insert((*filterIterator).value); ++filterIterator; } } { UintSetVisitor v(treeAlgoVisitorFiltered); KDevelop::ConvenientEmbeddedSetTreeFilterVisitor visit(v, set1.iterator(), repSet2); } totalItems += testSet1.size(); totalFilteredItems += algoFiltered.size(); std::set stdFiltered; for(std::set::const_iterator it = testSet1.begin(); it != testSet1.end(); ++it) { if(testSet2.count((*it) / extractor_div_with) == 1) { stdFiltered.insert(*it); } } QCOMPARE(algoFiltered, stdFiltered); QCOMPARE(treeAlgoFiltered, stdFiltered); QCOMPARE(treeAlgoVisitorFiltered, stdFiltered); } qDebug() << "Filtering performance: embedded-list filtering:" << toSeconds(algoTime) << "set-repository filtering:" << toSeconds(treeAlgoTime) << "set-repository visitor filtering:" << toSeconds(treeAlgoVisitorTime) << "std::set filtering:" << toSeconds(stdTime) << "Normal -> Embedded speedup ratio:" << (toSeconds(stdTime) / toSeconds(algoTime)) << "Normal -> Repository speedup ratio:" << (toSeconds(stdTime) / toSeconds(treeAlgoVisitorTime)) << "total processed items:" << totalItems << "total items after filtering:" << totalFilteredItems; qDebug() << "Insertion: embedded-list:" << toSeconds(insertionAlgoTime) << "set-repository:" << toSeconds(insertionTreeAlgoTime) << "std::set:" << toSeconds(insertionStdTime); } }; #include "test_embeddedfreetree.moc" QTEST_MAIN(TestEmbeddedFreeTree) diff --git a/util/tests/test_executecompositejob.h b/util/tests/test_executecompositejob.h index 90d3719396..aaa936ef2d 100644 --- a/util/tests/test_executecompositejob.h +++ b/util/tests/test_executecompositejob.h @@ -1,55 +1,55 @@ /* * This file is part of KDevelop * Copyright 2014 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_TEST_EXECUTECOMPOSITEJOB_H #define KDEVPLATFORM_TEST_EXECUTECOMPOSITEJOB_H #include #include class TestJob : public KJob { Q_OBJECT public: void start() override { emit started(this); } void callEmitResult() { emitResult(); } -signals: +Q_SIGNALS: void started(KJob* job); }; class TestExecuteCompositeJob : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void runOneJob(); void runTwoJobs(); }; #endif // KDEVPLATFORM_TEST_EXECUTECOMPOSITEJOB_H diff --git a/util/tests/test_foregroundlock.h b/util/tests/test_foregroundlock.h index 0b262de3dd..bedf45cab3 100644 --- a/util/tests/test_foregroundlock.h +++ b/util/tests/test_foregroundlock.h @@ -1,35 +1,35 @@ /* 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_TEST_FOREGROUNDLOCK_H #define KDEVPLATFORM_TEST_FOREGROUNDLOCK_H #include namespace KDevelop { class TestForegroundLock : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void testTryLock_data(); void testTryLock(); }; } #endif // KDEVPLATFORM_TEST_FOREGROUNDLOCK_H diff --git a/util/tests/test_kdevformatsource.h b/util/tests/test_kdevformatsource.h index 4a4a1c280d..8cfd020967 100644 --- a/util/tests/test_kdevformatsource.h +++ b/util/tests/test_kdevformatsource.h @@ -1,63 +1,63 @@ /* Copyright 2016 Anton Anikin 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. */ #pragma once #include #include namespace KDevelop { struct Source { QString path; QStringList lines; }; class TestKdevFormatSource: public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void testNotFound(); void testNotFound_data(); void testNoCommands(); void testNoCommands_data(); void testNotMatch(); void testNotMatch_data(); void testMatch1(); void testMatch1_data(); void testMatch2(); void testMatch2_data(); private: bool initTest(const QStringList& formatFileData); void runTest() const; bool mkPath(const QString& path) const; bool writeLines(const QString& path, const QStringList& lines) const; bool readLines(const QString& path, QStringList& lines) const; QVector m_sources; }; } diff --git a/util/tests/test_kdevvarlengtharray.cpp b/util/tests/test_kdevvarlengtharray.cpp index c2d18cca30..61b62fec17 100644 --- a/util/tests/test_kdevvarlengtharray.cpp +++ b/util/tests/test_kdevvarlengtharray.cpp @@ -1,99 +1,99 @@ /* 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 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 #include #include "../kdevvarlengtharray.h" struct TestValue { TestValue() : m_index(0) {} TestValue(const TestValue& other) { if (other.m_index) { int mustDo = 1; ++mustDo; } m_index = other.m_index; } uint m_index; }; class TestKDevVarLengthArray : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: /** * Make sure that valgrind does not report any warnings here * about uninitialized member variables. */ void appendReallocIntegrity() { KDevVarLengthArray array; QCOMPARE(array.size(), 0); QCOMPARE(array.capacity(), 2); qDebug() << "append item 1"; array << TestValue(); qDebug() << "appended index is:" << array[0].m_index; QCOMPARE(array.size(), 1); QCOMPARE(array.capacity(), 2); qDebug() << "append item 2"; array << TestValue(); // should trigger the realloc qDebug() << "appended index is:" << array[1].m_index; QCOMPARE(array.size(), 2); QCOMPARE(array.capacity(), 2); qDebug() << "append item 3"; array << TestValue(); qDebug() << "appended index is:" << array[2].m_index; QCOMPARE(array.size(), 3); QCOMPARE(array.capacity(), 4); array.clear(); } void mixed() { KDevVarLengthArray array; array.append(1); array << 2; array.insert(0, 0); QCOMPARE(array.back(), 2); array.pop_back(); QCOMPARE(array.back(), 1); array.append(1); QVERIFY(array.removeOne(1)); QCOMPARE(array.toList(), QList() << 0 << 1); QCOMPARE(array.toVector(), QVector() << 0 << 1); array.insert(0, 42); QCOMPARE(array.toVector(), QVector() << 42 << 0 << 1); array.remove(0); QCOMPARE(array.toVector(), QVector() << 0 << 1); QVERIFY(array.contains(1)); QVERIFY(!array.contains(42)); QCOMPARE(array.back(), 1); QCOMPARE(array.indexOf(1), 1); QCOMPARE(array.indexOf(42), -1); } }; QTEST_MAIN(TestKDevVarLengthArray) #include "test_kdevvarlengtharray.moc" diff --git a/util/tests/test_path.h b/util/tests/test_path.h index 5c8281ce14..4f474b3aec 100644 --- a/util/tests/test_path.h +++ b/util/tests/test_path.h @@ -1,59 +1,59 @@ /* * 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 TESTPATH_H #define TESTPATH_H #include class TestPath : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void bench_qurl(); void bench_qstringlist(); void bench_path(); void bench_fromLocalPath(); void bench_fromLocalPath_data(); void bench_hash(); void testPath(); void testPath_data(); void testPathInvalid(); void testPathInvalid_data(); void testPathOperators(); void testPathOperators_data(); void testPathAddData(); void testPathAddData_data(); void testPathBaseCtor(); void testPathBaseCtor_data(); void testPathCd(); void testPathCd_data(); void testHasParent_data(); void testHasParent(); void QUrl_acceptance(); }; #endif // TESTPATH_H diff --git a/vcs/dvcs/tests/test_dvcsjob.h b/vcs/dvcs/tests/test_dvcsjob.h index 7ae3e40861..3cd52c857f 100644 --- a/vcs/dvcs/tests/test_dvcsjob.h +++ b/vcs/dvcs/tests/test_dvcsjob.h @@ -1,36 +1,36 @@ /*************************************************************************** * 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_TEST_DVCSJOB_H #define KDEVPLATFORM_TEST_DVCSJOB_H #include class TestDVcsJob: public QObject { Q_OBJECT - private slots: + private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void testJob(); }; #endif diff --git a/vcs/dvcs/ui/branchmanager.h b/vcs/dvcs/ui/branchmanager.h index 37c9f86edf..2a08f0fb88 100644 --- a/vcs/dvcs/ui/branchmanager.h +++ b/vcs/dvcs/ui/branchmanager.h @@ -1,63 +1,63 @@ /*************************************************************************** * 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 = nullptr); ~BranchManager() override; -signals: +Q_SIGNALS: void checkedOut(KJob*); -private slots: +private Q_SLOTS: void createBranch(); void deleteBranch(); void renameBranch(); void checkoutBranch(); void mergeBranch(); void diffFromBranch(); void diffJobFinished(KJob* job); private: QString m_repository; KDevelop::DistributedVersionControlPlugin* m_dvcPlugin; Ui::BranchDialogBase* m_ui; KDevelop::BranchesListModel* m_model; }; #endif diff --git a/vcs/interfaces/icontentawareversioncontrol.h b/vcs/interfaces/icontentawareversioncontrol.h index 53700a8ab6..93671b5edb 100644 --- a/vcs/interfaces/icontentawareversioncontrol.h +++ b/vcs/interfaces/icontentawareversioncontrol.h @@ -1,79 +1,79 @@ /* This file is part of KDevelop * * Copyright 2013 Sven Brauch * * 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_ICONTENTAWAREVERSIONCONTROL_H #define KDEVPLATFORM_ICONTENTAWAREVERSIONCONTROL_H #include #include namespace KTextEditor { class Document; } namespace KDevelop { class KDEVPLATFORMVCS_EXPORT CheckInRepositoryJob : public KJob { Q_OBJECT public: explicit CheckInRepositoryJob(KTextEditor::Document* document); ~CheckInRepositoryJob() override; KTextEditor::Document* document() const; -public slots: +public Q_SLOTS: /// Abort this request. void abort(); -signals: +Q_SIGNALS: void finished(bool canRecreate); protected: struct CheckInRepositoryJobPrivate* d; }; /** * This interface is used by version control systems which can tell whether a given * blob of data is stored in the repository or not, such as git. * This information is used to reload files automatically if that involves no data loss. */ class IContentAwareVersionControl { public: virtual ~IContentAwareVersionControl() {}; /** * @brief Determines whether the given data is stored in the VCS' repository. * * @param document Document to search for in the repository * @returns CheckInRepositoryJob request object to track get notified when this finishes. * The request object deletes itself after finished() was emitted. */ virtual CheckInRepositoryJob* isInRepository(KTextEditor::Document* document) = 0; }; } Q_DECLARE_INTERFACE( KDevelop::IContentAwareVersionControl, "org.kdevelop.IContentAwareVersionControl" ) #endif diff --git a/vcs/models/brancheslistmodel.h b/vcs/models/brancheslistmodel.h index 54f5a3b3c3..59244370f0 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 = 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: + public Q_SLOTS: void resetCurrent(); - signals: + Q_SIGNALS: void currentBranchChanged(); private: const QScopedPointer d; }; } #endif // KDEVPLATFORM_BRANCHESLISTMODEL_H diff --git a/vcs/models/tests/test_models.h b/vcs/models/tests/test_models.h index 9ec818ae4b..a7ce95581a 100644 --- a/vcs/models/tests/test_models.h +++ b/vcs/models/tests/test_models.h @@ -1,37 +1,37 @@ /*************************************************************************** * 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) 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_TEST_MODELS_H #define KDEVPLATFORM_TEST_MODELS_H #include class TestModels : public QObject { Q_OBJECT -private slots: +private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void testVcsFileChangesModel(); }; #endif // KDEVPLATFORM_TEST_MODELS_H diff --git a/vcs/models/vcseventmodel.h b/vcs/models/vcseventmodel.h index a6c8431e7d..40f5dcc9ac 100644 --- a/vcs/models/vcseventmodel.h +++ b/vcs/models/vcseventmodel.h @@ -1,96 +1,96 @@ /*************************************************************************** * 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_VCSEVENTMODEL_H #define KDEVPLATFORM_VCSEVENTMODEL_H #include #include #include class QUrl; class KJob; namespace KDevelop { class VcsRevision; class IBasicVersionControl; class VcsEvent; /** * This is a generic model to store a list of VcsEvents. * * To add events use @c addEvents */ class KDEVPLATFORMVCS_EXPORT VcsBasicEventModel : public QAbstractTableModel { Q_OBJECT public: enum Column { RevisionColumn, SummaryColumn, AuthorColumn, DateColumn, ColumnCount, }; explicit VcsBasicEventModel(QObject* parent); ~VcsBasicEventModel() override; int rowCount(const QModelIndex& = QModelIndex()) const override; int columnCount(const QModelIndex& parent = QModelIndex()) const override; QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const override; KDevelop::VcsEvent eventForIndex(const QModelIndex&) const; protected: void addEvents(const QList&); private: QScopedPointer d; }; /** * This model stores a list of VcsEvents corresponding to the log obtained * via IBasicVersionControl::log for a given revision. The model is populated * lazily via @c fetchMore. */ class KDEVPLATFORMVCS_EXPORT VcsEventLogModel : public VcsBasicEventModel { Q_OBJECT public: VcsEventLogModel(KDevelop::IBasicVersionControl* iface, const KDevelop::VcsRevision& rev, const QUrl& url, QObject* parent); ~VcsEventLogModel() override; /// Adds events to the model via @sa IBasicVersionControl::log void fetchMore(const QModelIndex& parent) override; bool canFetchMore(const QModelIndex& parent) const override; -private slots: +private Q_SLOTS: void jobReceivedResults( KJob* job ); private: QScopedPointer d; }; } #endif diff --git a/vcs/models/vcsfilechangesmodel.h b/vcs/models/vcsfilechangesmodel.h index 4d08001aaa..5d58eecc1a 100644 --- a/vcs/models/vcsfilechangesmodel.h +++ b/vcs/models/vcsfilechangesmodel.h @@ -1,155 +1,155 @@ /* This file is part of KDevelop Copyright 2010 Aleix Pol Split into separate class Copyright 2011 Andrey Batyiev 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_VCSFILECHANGESMODEL_H #define KDEVPLATFORM_VCSFILECHANGESMODEL_H #include #include #include #include class QUrl; namespace KDevelop { class VcsStatusInfo; class KDEVPLATFORMVCS_EXPORT VcsFileChangesSortProxyModel : public QSortFilterProxyModel { Q_OBJECT public: explicit VcsFileChangesSortProxyModel(QObject* parent = nullptr); bool lessThan(const QModelIndex& rLeft, const QModelIndex& rRight) const override; }; /** * This class holds and represents information about changes in files. * Also it is possible to provide tree like models by inheriting this class, see protected members. * All stuff should be pulled in by @p updateState. */ class VcsFileChangesModelPrivate; class KDEVPLATFORMVCS_EXPORT VcsFileChangesModel : public QStandardItemModel { Q_OBJECT public: enum ItemRoles { VcsStatusInfoRole = Qt::UserRole+1, UrlRole, StateRole, LastItemRole }; enum Column { PathColumn = 0, StatusColumn = 1 }; /** * Constructor for class. * @param isCheckable if true, model will show checkboxes on items. */ explicit VcsFileChangesModel(QObject *parent = nullptr, bool isCheckable = false); ~VcsFileChangesModel() override; QVariant data(const QModelIndex &index, int role) const override; /** * Returns list of currently checked urls. */ QList checkedUrls() const { return checkedUrls(invisibleRootItem()); } /** * Returns urls of all files * */ QList urls() const { return urls(invisibleRootItem()); } /** * Set the checked urls * */ void setCheckedUrls(const QList& urls) const { return checkUrls(invisibleRootItem(), urls); } /** * Returns the item for the specified url * */ QStandardItem* itemForUrl(const QUrl &url) const { return fileItemForUrl(invisibleRootItem(), url); } /** * Changes the check-state of all files to the given state * */ void setAllChecked(bool checked); void setIsCheckbable(bool checkable); bool isCheckable() const; bool removeUrl(const QUrl& url); -public slots: +public Q_SLOTS: /** * Used to post update of status of some file. Any status except UpToDate * and Unknown will update (or add) item representation. */ void updateState(const KDevelop::VcsStatusInfo &status) { updateState(invisibleRootItem(), status); } protected: /** * Post update of status of some file. * @return changed row or -1 if row is deleted */ int updateState(QStandardItem *parent, const KDevelop::VcsStatusInfo &status); /** * Returns list of currently checked urls. */ QList checkedUrls(QStandardItem *parent) const; /** * Checks the given urls, unchecks all others. * */ void checkUrls(QStandardItem *parent, const QList& urls) const; /** * Returns all urls * */ QList urls(QStandardItem *parent) const; /** * Returns item for particular url. */ QStandardItem* fileItemForUrl(QStandardItem *parent, const QUrl &url) const; private: QScopedPointer const d; }; } Q_DECLARE_METATYPE(KDevelop::VcsStatusInfo::State) #endif // KDEVPLATFORM_VCSFILECHANGESMODEL_H diff --git a/vcs/widgets/standardvcslocationwidget.h b/vcs/widgets/standardvcslocationwidget.h index 9d5bdcb3a4..fe76f9909e 100644 --- a/vcs/widgets/standardvcslocationwidget.h +++ b/vcs/widgets/standardvcslocationwidget.h @@ -1,52 +1,52 @@ /* 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 = nullptr, Qt::WindowFlags f = {}); VcsLocation location() const override; bool isCorrect() const override; QUrl url() const; QString projectName() const override; void setLocation(const QUrl& remoteLocation) override; void setUrl(const QUrl& url); - public slots: + public Q_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 90e226f6cb..81c98a5093 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 = nullptr ); ~VcsCommitDialog() override; ///Sets the commit candidates void setCommitCandidates( const QList& statuses ); void setRecursive( bool ); bool recursive() const; -private slots: +private Q_SLOTS: void ok(); void cancel(); private: class VcsCommitDialogPrivate* const d; }; } #endif diff --git a/vcs/widgets/vcsdiffpatchsources.h b/vcs/widgets/vcsdiffpatchsources.h index da1aef411c..78717a64e4 100644 --- a/vcs/widgets/vcsdiffpatchsources.h +++ b/vcs/widgets/vcsdiffpatchsources.h @@ -1,137 +1,137 @@ /* 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. */ /** * This is an internal header */ #ifndef KDEVPLATFORM_VCSDIFFPATCHSOURCES_H #define KDEVPLATFORM_VCSDIFFPATCHSOURCES_H #include #include "vcs/vcsstatusinfo.h" #include #include #include class KTextEdit; class KComboBox; class KJob; namespace KDevelop { class VcsCommitDialog; class IBasicVersionControl; class VcsDiff; } class QWidget; class VCSDiffUpdater { public: virtual ~VCSDiffUpdater(); virtual KDevelop::VcsDiff update() const = 0; virtual KDevelop::IBasicVersionControl* vcs() const = 0; virtual QUrl url() const = 0; }; class KDEVPLATFORMVCS_EXPORT VCSStandardDiffUpdater : public VCSDiffUpdater { public: VCSStandardDiffUpdater(KDevelop::IBasicVersionControl* vcs, QUrl url); ~VCSStandardDiffUpdater() override; KDevelop::VcsDiff update() const override; KDevelop::IBasicVersionControl* vcs() const override { return m_vcs; } QUrl url() const override { return m_url; } private: KDevelop::IBasicVersionControl* m_vcs; QUrl m_url; }; class KDEVPLATFORMVCS_EXPORT VCSDiffPatchSource : public KDevelop::IPatchSource { Q_OBJECT public: /// The ownership of the updater is taken explicit VCSDiffPatchSource(VCSDiffUpdater* updater); explicit VCSDiffPatchSource(const KDevelop::VcsDiff& diff); ~VCSDiffPatchSource() override; QUrl baseDir() const override ; QUrl file() const override ; QString name() const override ; uint depth() const override ; void update() override ; bool isAlreadyApplied() const override { return true; } QMap additionalSelectableFiles() const override ; QUrl m_base, m_file; QString m_name; VCSDiffUpdater* m_updater; QList m_infos; QMap m_selectable; private: void updateFromDiff(KDevelop::VcsDiff diff); uint m_depth = 0; }; class KDEVPLATFORMVCS_EXPORT VCSCommitDiffPatchSource : public VCSDiffPatchSource { Q_OBJECT public: /// The ownership of the updater is taken explicit VCSCommitDiffPatchSource(VCSDiffUpdater* updater); ~VCSCommitDiffPatchSource() override ; QStringList oldMessages() const; bool canSelectFiles() const override ; QWidget* customWidget() const override ; QString finishReviewCustomText() const override ; bool canCancel() const override; void cancelReview() override; bool finishReview(QList< QUrl > selection) override ; QList infos() const { return m_infos; } Q_SIGNALS: void reviewFinished(QString message, QList selection); void reviewCancelled(QString message); public: QPointer m_commitMessageWidget; QPointer m_commitMessageEdit; KDevelop::IBasicVersionControl* m_vcs; KComboBox* m_oldMessages; -public slots: +public Q_SLOTS: void addMessageToHistory(const QString& message); void oldMessageChanged(QString); void jobFinished(KJob*); }; ///Sends the diff to the patch-review plugin. ///Returns whether the diff was shown successfully. bool KDEVPLATFORMVCS_EXPORT showVcsDiff(KDevelop::IPatchSource* vcsDiff); #endif // KDEVPLATFORM_VCSDIFFPATCHSOURCES_H diff --git a/vcs/widgets/vcslocationwidget.h b/vcs/widgets/vcslocationwidget.h index dea66f2379..98e6b85f83 100644 --- a/vcs/widgets/vcslocationwidget.h +++ b/vcs/widgets/vcslocationwidget.h @@ -1,67 +1,67 @@ /* 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 = nullptr, Qt::WindowFlags f = {}); /** @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; /** Sets the location by a respective URL * @param remoteLocation the URL used to access a remote repository * @see IBasicVersionControl::isValidRemoteRepositoryUrl */ virtual void setLocation(const QUrl& remoteLocation) = 0; - signals: + Q_SIGNALS: void changed(); }; } #endif