diff --git a/addons/backtracebrowser/btfileindexer.h b/addons/backtracebrowser/btfileindexer.h index 082a66019..a8d87961a 100644 --- a/addons/backtracebrowser/btfileindexer.h +++ b/addons/backtracebrowser/btfileindexer.h @@ -1,54 +1,54 @@ /* This file is part of the KDE project Copyright 2008-2014 Dominik Haumann 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 KATE_BACKTRACEINDEXER_H #define KATE_BACKTRACEINDEXER_H #include #include #include class KateBtDatabase; class BtFileIndexer : public QThread { Q_OBJECT public: BtFileIndexer(KateBtDatabase *db); - virtual ~BtFileIndexer(); + ~BtFileIndexer() override; void setSearchPaths(const QStringList &urls); void setFilter(const QStringList &filter); void cancel(); protected: - void run() Q_DECL_OVERRIDE; + void run() override; void indexFiles(const QString &url); private: bool cancelAsap; QStringList searchPaths; QStringList filter; KateBtDatabase *db; }; #endif // kate: space-indent on; indent-width 4; replace-tabs on; diff --git a/addons/backtracebrowser/katebacktracebrowser.h b/addons/backtracebrowser/katebacktracebrowser.h index 1280990f3..2329e1e0c 100644 --- a/addons/backtracebrowser/katebacktracebrowser.h +++ b/addons/backtracebrowser/katebacktracebrowser.h @@ -1,153 +1,153 @@ /* This file is part of the KDE project Copyright 2008-2014 Dominik Haumann 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 KATE_BACKTRACEBROWSER_H #define KATE_BACKTRACEBROWSER_H #include #include #include #include "ui_btbrowserwidget.h" #include "ui_btconfigwidget.h" #include "btdatabase.h" #include "btfileindexer.h" #include #include #include class KateBtConfigWidget; class KateBtBrowserWidget; class KateBtBrowserPlugin : public KTextEditor::Plugin { Q_OBJECT public: explicit KateBtBrowserPlugin(QObject *parent = nullptr, const QList & = QList()); - virtual ~KateBtBrowserPlugin(); + ~KateBtBrowserPlugin() override; static KateBtBrowserPlugin &self(); - QObject *createView(KTextEditor::MainWindow *mainWindow) Q_DECL_OVERRIDE; + QObject *createView(KTextEditor::MainWindow *mainWindow) override; KateBtDatabase &database(); BtFileIndexer &fileIndexer(); void startIndexer(); Q_SIGNALS: void newStatus(const QString &); public: - int configPages() const Q_DECL_OVERRIDE; - KTextEditor::ConfigPage *configPage(int number, QWidget *parent = nullptr) Q_DECL_OVERRIDE; + int configPages() const override; + KTextEditor::ConfigPage *configPage(int number, QWidget *parent = nullptr) override; // // private data // private: KateBtDatabase db; BtFileIndexer indexer; static KateBtBrowserPlugin *s_self; }; class KateBtBrowserPluginView : public QObject { Q_OBJECT public: KateBtBrowserPluginView(KateBtBrowserPlugin *plugin, KTextEditor::MainWindow *mainWindow); /** * Virtual destructor. */ - ~KateBtBrowserPluginView(); + ~KateBtBrowserPluginView() override; private: KateBtBrowserPlugin *m_plugin; KateBtBrowserWidget *m_widget; }; class KateBtBrowserWidget : public QWidget, public Ui::BtBrowserWidget { Q_OBJECT public: KateBtBrowserWidget(KTextEditor::MainWindow *mainwindow, QWidget *parent); - ~KateBtBrowserWidget(); + ~KateBtBrowserWidget() override; void loadBacktrace(const QString &bt); public Q_SLOTS: void loadFile(); void loadClipboard(); void configure(); void clearStatus(); void setStatus(const QString &status); private Q_SLOTS: void itemActivated(QTreeWidgetItem *item, int column); private: KTextEditor::MainWindow *mw; QTimer timer; }; class KateBtConfigWidget : public KTextEditor::ConfigPage, private Ui::BtConfigWidget { Q_OBJECT public: explicit KateBtConfigWidget(QWidget *parent = nullptr); - virtual ~KateBtConfigWidget(); + ~KateBtConfigWidget() override; - QString name() const Q_DECL_OVERRIDE; - QString fullName() const Q_DECL_OVERRIDE; - QIcon icon() const Q_DECL_OVERRIDE; + QString name() const override; + QString fullName() const override; + QIcon icon() const override; public Q_SLOTS: - void apply() Q_DECL_OVERRIDE; - void reset() Q_DECL_OVERRIDE; - void defaults() Q_DECL_OVERRIDE; + void apply() override; + void reset() override; + void defaults() override; private Q_SLOTS: void add(); void remove(); void textChanged(); private: bool m_changed; }; class KateBtConfigDialog : public QDialog { Q_OBJECT public: KateBtConfigDialog(QWidget *parent = nullptr); - ~KateBtConfigDialog(); + ~KateBtConfigDialog() override; private: KateBtConfigWidget *m_configWidget; }; #endif //KATE_BACKTRACEBROWSER_H // kate: space-indent on; indent-width 4; replace-tabs on; diff --git a/addons/close-except-like/close_confirm_dialog.h b/addons/close-except-like/close_confirm_dialog.h index 6eebed73e..f067896df 100644 --- a/addons/close-except-like/close_confirm_dialog.h +++ b/addons/close-except-like/close_confirm_dialog.h @@ -1,65 +1,65 @@ /** * \file * * \brief Class \c kate::CloseConfirmDialog (interface) * * Copyright (C) 2012 Alex Turbov * * \date Sun Jun 24 16:29:13 MSK 2012 -- Initial design */ /* * KateCloseExceptPlugin 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 3 of the License, or * (at your option) any later version. * * KateCloseExceptPlugin is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY 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 __SRC__CLOSE_CONFIRM_DIALOG_H__ # define __SRC__CLOSE_CONFIRM_DIALOG_H__ // Project specific includes // Standard includes # include # include # include # include # include # include # include # include # include "ui_close_confirm_dialog.h" namespace kate { /** * \brief [Type brief class description here] * * [More detailed description here] * */ class CloseConfirmDialog : public QDialog, public Ui::CloseConfirmDialog { Q_OBJECT public: /// Default constructor explicit CloseConfirmDialog(QList&, KToggleAction*, QWidget* const = nullptr); - ~CloseConfirmDialog(); + ~CloseConfirmDialog() override; private Q_SLOTS: void updateDocsList(); private: QList& m_docs; }; } // namespace kate #endif // __SRC__CLOSE_CONFIRM_DIALOG_H__ diff --git a/addons/close-except-like/close_except_plugin.h b/addons/close-except-like/close_except_plugin.h index 9326b5c67..3af3509ba 100644 --- a/addons/close-except-like/close_except_plugin.h +++ b/addons/close-except-like/close_except_plugin.h @@ -1,148 +1,148 @@ /** * \file * * \brief Declate Kate's Close Except/Like plugin classes * * Copyright (C) 2012 Alex Turbov * * \date Thu Mar 8 08:13:43 MSK 2012 -- Initial design */ /* * KateCloseExceptPlugin 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 3 of the License, or * (at your option) any later version. * * KateCloseExceptPlugin is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY 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 __SRC__CLOSE_EXCEPT_PLUGIN_H__ # define __SRC__CLOSE_EXCEPT_PLUGIN_H__ // Project specific includes // Standard includes # include # include # include # include # include # include # include # include # include # include # include # include # include namespace kate { class CloseExceptPlugin; // forward declaration /** * \brief Plugin to close docs grouped by extension or location */ class CloseExceptPluginView : public QObject , public KXMLGUIClient { Q_OBJECT typedef QMap > actions_map_type; public: /// Default constructor CloseExceptPluginView(KTextEditor::MainWindow*, CloseExceptPlugin*); /// Destructor - ~CloseExceptPluginView(); + ~CloseExceptPluginView() override; private Q_SLOTS: void viewCreated(KTextEditor::View*); void documentCreated(KTextEditor::Editor*, KTextEditor::Document*); void updateMenuSlotStub(KTextEditor::Document*); void close(const QString&, const bool); void closeExcept(const QString& item) { close(item, false); } void closeLike(const QString& item) { close(item, true); } private: void displayMessage(const QString&, const QString&, KTextEditor::Message::MessageType); void connectToDocument(KTextEditor::Document*); void updateMenu(); QPointer updateMenu( const std::set& , const std::set& , actions_map_type& , KActionMenu* ); void appendActionsFrom( const std::set& , actions_map_type& , KActionMenu* , QSignalMapper* ); void appendActionsFrom( const std::set& masks , actions_map_type& actions , KActionMenu* menu , QSignalMapper* mapper ); CloseExceptPlugin* m_plugin; QPointer m_show_confirmation_action; QPointer m_except_menu; QPointer m_like_menu; QPointer m_except_mapper; QPointer m_like_mapper; actions_map_type m_except_actions; actions_map_type m_like_actions; KTextEditor::MainWindow *m_mainWindow; QPointer m_infoMessage; }; /** * \brief Plugin view class */ class CloseExceptPlugin : public KTextEditor::Plugin, public KTextEditor::SessionConfigInterface { Q_OBJECT Q_INTERFACES(KTextEditor::SessionConfigInterface) public: /// Default constructor CloseExceptPlugin(QObject* = nullptr, const QList& = QList()); /// Destructor - virtual ~CloseExceptPlugin() {} + ~CloseExceptPlugin() override {} /// Create a new view of this plugin for the given main window - QObject* createView(KTextEditor::MainWindow*) Q_DECL_OVERRIDE; + QObject* createView(KTextEditor::MainWindow*) override; /// \name Plugin interface implementation //@{ - void readSessionConfig(const KConfigGroup&) Q_DECL_OVERRIDE; - void writeSessionConfig(KConfigGroup&) Q_DECL_OVERRIDE; + void readSessionConfig(const KConfigGroup&) override; + void writeSessionConfig(KConfigGroup&) override; //@} bool showConfirmationNeeded() const { return m_show_confirmation_needed; } public Q_SLOTS: void toggleShowConfirmation(bool flag) { m_show_confirmation_needed = flag; } private: bool m_show_confirmation_needed; }; } // namespace kate #endif // __SRC__CLOSE_EXCEPT_PLUGIN_H__ diff --git a/addons/filebrowser/katebookmarkhandler.h b/addons/filebrowser/katebookmarkhandler.h index 0d7a309ce..af868991f 100644 --- a/addons/filebrowser/katebookmarkhandler.h +++ b/addons/filebrowser/katebookmarkhandler.h @@ -1,60 +1,60 @@ /* This file is part of the KDE project Copyright (C) xxxx KFile Authors Copyright (C) 2002 Anders Lund Copyright (C) 2007 Mirko Stocker Copyright (C) 2009 Dominik Haumann 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 KATE_BOOKMARK_HANDLER_H #define KATE_BOOKMARK_HANDLER_H #include #include class KateFileBrowser; class QMenu; class KateBookmarkHandler : public QObject, public KBookmarkOwner { Q_OBJECT public: explicit KateBookmarkHandler( KateFileBrowser *parent, QMenu *kpopupmenu = nullptr ); - ~KateBookmarkHandler(); + ~KateBookmarkHandler() override; // KBookmarkOwner interface: - QUrl currentUrl() const Q_DECL_OVERRIDE; - QString currentTitle() const Q_DECL_OVERRIDE; + QUrl currentUrl() const override; + QString currentTitle() const override; QMenu *menu() const { return m_menu; } - void openBookmark( const KBookmark &, Qt::MouseButtons, Qt::KeyboardModifiers ) Q_DECL_OVERRIDE; + void openBookmark( const KBookmark &, Qt::MouseButtons, Qt::KeyboardModifiers ) override; Q_SIGNALS: void openUrl( const QString& url ); private: KateFileBrowser *mParent; QMenu *m_menu; KBookmarkMenu *m_bookmarkMenu; }; #endif // KATE_BOOKMARK_HANDLER_H // kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/addons/filebrowser/katefilebrowser.h b/addons/filebrowser/katefilebrowser.h index 50c13d2ec..7c2520fc3 100644 --- a/addons/filebrowser/katefilebrowser.h +++ b/addons/filebrowser/katefilebrowser.h @@ -1,109 +1,109 @@ /* This file is part of the KDE project Copyright (C) 2001 Christoph Cullmann Copyright (C) 2001 Joseph Wenninger Copyright (C) 2001 Anders Lund Copyright (C) 2007 Mirko Stocker Copyright (C) 2009 Dominik Haumann 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 KATE_FILEBROWSER_H #define KATE_FILEBROWSER_H #include #include #include #include class KateBookmarkHandler; class KActionCollection; class KDirOperator; class KFileItem; class KHistoryComboBox; class KToolBar; class KConfigGroup; class KUrlNavigator; class QAbstractItemView; class QAction; /* The kate file selector presents a directory view, in which the default action is to open the activated file. Additionally, a toolbar for managing the kdiroperator widget + sync that to the directory of the current file is available, as well as a filter widget allowing to filter the displayed files using a name filter. */ class KateFileBrowser : public QWidget { Q_OBJECT public: explicit KateFileBrowser( KTextEditor::MainWindow *mainWindow = nullptr, QWidget * parent = nullptr); - ~KateFileBrowser(); + ~KateFileBrowser() override; void readSessionConfig (const KConfigGroup& config); void writeSessionConfig (KConfigGroup& config); void setupToolbar(); void setView( KFile::FileView ); KDirOperator *dirOperator() { return m_dirOperator; } KActionCollection* actionCollection() { return m_actionCollection; } public Q_SLOTS: void slotFilterChange(const QString&); void setDir(QUrl); void setDir( const QString &url ) { setDir( QUrl( url ) ); } void selectorViewChanged( QAbstractItemView * ); private Q_SLOTS: void fileSelected(const KFileItem & /*file*/); void updateDirOperator( const QUrl &u ); void updateUrlNavigator( const QUrl &u ); void setActiveDocumentDir(); void autoSyncFolder(); protected: QUrl activeDocumentUrl(); void openSelectedFiles(); void setupActions(); public: KTextEditor::MainWindow* mainWindow() { return m_mainWindow; } private: KToolBar *m_toolbar; KActionCollection *m_actionCollection; KateBookmarkHandler *m_bookmarkHandler; KUrlNavigator *m_urlNavigator; KDirOperator * m_dirOperator; KHistoryComboBox * m_filter; QAction *m_autoSyncFolder; KTextEditor::MainWindow *m_mainWindow; }; #endif //KATE_FILEBROWSER_H // kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/addons/filebrowser/katefilebrowserconfig.h b/addons/filebrowser/katefilebrowserconfig.h index 1d153b9f3..c42174099 100644 --- a/addons/filebrowser/katefilebrowserconfig.h +++ b/addons/filebrowser/katefilebrowserconfig.h @@ -1,63 +1,63 @@ /* This file is part of the KDE project Copyright (C) 2001 Christoph Cullmann Copyright (C) 2001 Joseph Wenninger Copyright (C) 2001 Anders Lund Copyright (C) 2007 Mirko Stocker Copyright (C) 2009 Dominik Haumann 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 KATE_FILEBROWSER_CONFIG_H #define KATE_FILEBROWSER_CONFIG_H #include class KateFileBrowser; class KActionSelector; class KateFileBrowserConfigPage : public KTextEditor::ConfigPage { Q_OBJECT public: explicit KateFileBrowserConfigPage( QWidget* parent = nullptr, KateFileBrowser *kfb = nullptr); - virtual ~KateFileBrowserConfigPage() + ~KateFileBrowserConfigPage() override {} - QString name() const Q_DECL_OVERRIDE; - QString fullName() const Q_DECL_OVERRIDE; - QIcon icon() const Q_DECL_OVERRIDE; + QString name() const override; + QString fullName() const override; + QIcon icon() const override; - void apply() Q_DECL_OVERRIDE; - void reset() Q_DECL_OVERRIDE; - void defaults() Q_DECL_OVERRIDE + void apply() override; + void reset() override; + void defaults() override {} private Q_SLOTS: void slotMyChanged(); private: void init(); KateFileBrowser *fileBrowser; KActionSelector *acSel; bool m_changed; }; #endif //KATE_FILEBROWSER_CONFIG_H // kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/addons/filebrowser/katefilebrowserplugin.h b/addons/filebrowser/katefilebrowserplugin.h index 77e8df234..fa0f30075 100644 --- a/addons/filebrowser/katefilebrowserplugin.h +++ b/addons/filebrowser/katefilebrowserplugin.h @@ -1,86 +1,86 @@ /* This file is part of the KDE project Copyright (C) 2001 Christoph Cullmann Copyright (C) 2001 Joseph Wenninger Copyright (C) 2001 Anders Lund Copyright (C) 2007 Mirko Stocker Copyright (C) 2009 Dominik Haumann 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 KATE_FILEBROWSER_PLUGIN_H #define KATE_FILEBROWSER_PLUGIN_H #include #include #include #include #include class KateFileBrowser; class KateFileBrowserPluginView; class KateFileBrowserPlugin: public KTextEditor::Plugin { Q_OBJECT public: explicit KateFileBrowserPlugin( QObject* parent = nullptr, const QList& = QList() ); - virtual ~KateFileBrowserPlugin() + ~KateFileBrowserPlugin() override {} - QObject *createView (KTextEditor::MainWindow *mainWindow) Q_DECL_OVERRIDE; + QObject *createView (KTextEditor::MainWindow *mainWindow) override; - int configPages() const Q_DECL_OVERRIDE; - KTextEditor::ConfigPage *configPage (int number = 0, QWidget *parent = nullptr) Q_DECL_OVERRIDE; + int configPages() const override; + KTextEditor::ConfigPage *configPage (int number = 0, QWidget *parent = nullptr) override; public Q_SLOTS: void viewDestroyed(QObject* view); private: QList m_views; }; class KateFileBrowserPluginView : public QObject, public KTextEditor::SessionConfigInterface { Q_OBJECT Q_INTERFACES(KTextEditor::SessionConfigInterface) public: /** * Constructor. */ KateFileBrowserPluginView (KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mainWindow); /** * Virtual destructor. */ - ~KateFileBrowserPluginView (); + ~KateFileBrowserPluginView () override; - void readSessionConfig (const KConfigGroup& config) Q_DECL_OVERRIDE; - void writeSessionConfig (KConfigGroup& config) Q_DECL_OVERRIDE; + void readSessionConfig (const KConfigGroup& config) override; + void writeSessionConfig (KConfigGroup& config) override; private: - bool eventFilter(QObject*, QEvent*) Q_DECL_OVERRIDE; + bool eventFilter(QObject*, QEvent*) override; QWidget *m_toolView; KateFileBrowser *m_fileBrowser; KTextEditor::MainWindow *m_mainWindow; friend class KateFileBrowserPlugin; }; #endif //KATE_FILEBROWSER_PLUGIN_H // kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/addons/filetree/autotests/document_dummy.h b/addons/filetree/autotests/document_dummy.h index db9ae114b..bc31e215f 100644 --- a/addons/filetree/autotests/document_dummy.h +++ b/addons/filetree/autotests/document_dummy.h @@ -1,127 +1,127 @@ /* This file is part of the KDE libraries Copyright (C) 2001 Christoph Cullmann Copyright (C) 2005 Dominik Haumann (dhdev@gmx.de) (documentation) 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 TEST_DOCUMENT_H #define TEST_DOCUMENT_H #include #include class DummyDocument : public KTextEditor::Document { Q_OBJECT public: DummyDocument (const QString &url = QString()) : KTextEditor::Document(nullptr, nullptr) , m_name(QLatin1String("foo")) , m_encoding() , m_views() { setUrl(url); m_name = url.section(QLatin1Char('/'), -1); // some nice default to mimic the KateDocument } DummyDocument (const char *url) : DummyDocument(QString::fromLatin1(url)) {} - virtual ~DummyDocument () {} - KTextEditor::View *createView ( QWidget *, KTextEditor::MainWindow * = nullptr ) Q_DECL_OVERRIDE { return nullptr; } + ~DummyDocument () override {} + KTextEditor::View *createView ( QWidget *, KTextEditor::MainWindow * = nullptr ) override { return nullptr; } virtual KTextEditor::View *activeView() const { return nullptr; } - QList views() const Q_DECL_OVERRIDE { return m_views; } - - QString documentName() const Q_DECL_OVERRIDE { return m_name; } - - QString mimeType() Q_DECL_OVERRIDE { return QString(); } - QByteArray checksum() const Q_DECL_OVERRIDE { return QByteArray(); } - bool setEncoding (const QString &) Q_DECL_OVERRIDE { return false; } - QString encoding () const Q_DECL_OVERRIDE { return m_encoding; } - - bool documentReload () Q_DECL_OVERRIDE { return true; } - bool documentSave () Q_DECL_OVERRIDE { return true; } - bool documentSaveAs () Q_DECL_OVERRIDE { return true; } - - bool isEditingTransactionRunning() const Q_DECL_OVERRIDE { return false; } - QString text () const Q_DECL_OVERRIDE { return QString(); } - QString text ( const KTextEditor::Range&, bool = false ) const Q_DECL_OVERRIDE { return QString(); } - QChar characterAt( const KTextEditor::Cursor&) const Q_DECL_OVERRIDE { return QChar(); } - QString wordAt(const KTextEditor::Cursor&) const Q_DECL_OVERRIDE { return QString(); } - KTextEditor::Range wordRangeAt(const KTextEditor::Cursor&) const Q_DECL_OVERRIDE { return KTextEditor::Range(); } - bool isValidTextPosition(const KTextEditor::Cursor&) const Q_DECL_OVERRIDE { return true; } - QStringList textLines ( const KTextEditor::Range&, bool = false ) const Q_DECL_OVERRIDE { return QStringList(); } - QString line ( int ) const Q_DECL_OVERRIDE { return QString(); } - int lines () const Q_DECL_OVERRIDE { return 0; } - KTextEditor::Cursor documentEnd() const Q_DECL_OVERRIDE { return KTextEditor::Cursor(); } - int totalCharacters() const Q_DECL_OVERRIDE { return 0; } - int lineLength ( int ) const Q_DECL_OVERRIDE { return 0; } - - bool setText ( const QString & ) Q_DECL_OVERRIDE { return false; } - bool setText ( const QStringList & ) Q_DECL_OVERRIDE { return false; } - bool clear () Q_DECL_OVERRIDE { return true; } - bool insertText ( const KTextEditor::Cursor &, const QString &, bool = false ) Q_DECL_OVERRIDE { return false; } - bool insertText ( const KTextEditor::Cursor &, const QStringList &, bool = false ) Q_DECL_OVERRIDE { return false; } - bool removeText ( const KTextEditor::Range &, bool = false ) Q_DECL_OVERRIDE { return false; } - bool insertLine ( int, const QString & ) Q_DECL_OVERRIDE { return false; } - bool insertLines ( int, const QStringList & ) Q_DECL_OVERRIDE { return false; } - bool removeLine ( int ) Q_DECL_OVERRIDE { return false; } - KTextEditor::DefaultStyle defaultStyleAt(const KTextEditor::Cursor &) const Q_DECL_OVERRIDE { return KTextEditor::dsNormal; } - QString mode() const Q_DECL_OVERRIDE { return QString(); } - QString highlightingMode() const Q_DECL_OVERRIDE { return QString(); } - QStringList modes() const Q_DECL_OVERRIDE { return QStringList(); } - QStringList highlightingModes() const Q_DECL_OVERRIDE {return QStringList(); } - bool setMode(const QString &) Q_DECL_OVERRIDE { return false; } - bool setHighlightingMode(const QString &) Q_DECL_OVERRIDE { return false; } - QString highlightingModeSection( int ) const Q_DECL_OVERRIDE { return QString(); } - QString modeSection( int ) const Q_DECL_OVERRIDE { return QString(); } - bool print() Q_DECL_OVERRIDE { return false; } - void printPreview() Q_DECL_OVERRIDE {} - QStringList embeddedHighlightingModes() const Q_DECL_OVERRIDE { return QStringList(); } - QString highlightingModeAt(const KTextEditor::Cursor &) Q_DECL_OVERRIDE { return QString(); } - bool isLineModified(int) const Q_DECL_OVERRIDE { return false; } - bool isLineSaved(int) const Q_DECL_OVERRIDE { return false; } - bool isLineTouched(int) const Q_DECL_OVERRIDE { return false; } + QList views() const override { return m_views; } + + QString documentName() const override { return m_name; } + + QString mimeType() override { return QString(); } + QByteArray checksum() const override { return QByteArray(); } + bool setEncoding (const QString &) override { return false; } + QString encoding () const override { return m_encoding; } + + bool documentReload () override { return true; } + bool documentSave () override { return true; } + bool documentSaveAs () override { return true; } + + bool isEditingTransactionRunning() const override { return false; } + QString text () const override { return QString(); } + QString text ( const KTextEditor::Range&, bool = false ) const override { return QString(); } + QChar characterAt( const KTextEditor::Cursor&) const override { return QChar(); } + QString wordAt(const KTextEditor::Cursor&) const override { return QString(); } + KTextEditor::Range wordRangeAt(const KTextEditor::Cursor&) const override { return KTextEditor::Range(); } + bool isValidTextPosition(const KTextEditor::Cursor&) const override { return true; } + QStringList textLines ( const KTextEditor::Range&, bool = false ) const override { return QStringList(); } + QString line ( int ) const override { return QString(); } + int lines () const override { return 0; } + KTextEditor::Cursor documentEnd() const override { return KTextEditor::Cursor(); } + int totalCharacters() const override { return 0; } + int lineLength ( int ) const override { return 0; } + + bool setText ( const QString & ) override { return false; } + bool setText ( const QStringList & ) override { return false; } + bool clear () override { return true; } + bool insertText ( const KTextEditor::Cursor &, const QString &, bool = false ) override { return false; } + bool insertText ( const KTextEditor::Cursor &, const QStringList &, bool = false ) override { return false; } + bool removeText ( const KTextEditor::Range &, bool = false ) override { return false; } + bool insertLine ( int, const QString & ) override { return false; } + bool insertLines ( int, const QStringList & ) override { return false; } + bool removeLine ( int ) override { return false; } + KTextEditor::DefaultStyle defaultStyleAt(const KTextEditor::Cursor &) const override { return KTextEditor::dsNormal; } + QString mode() const override { return QString(); } + QString highlightingMode() const override { return QString(); } + QStringList modes() const override { return QStringList(); } + QStringList highlightingModes() const override {return QStringList(); } + bool setMode(const QString &) override { return false; } + bool setHighlightingMode(const QString &) override { return false; } + QString highlightingModeSection( int ) const override { return QString(); } + QString modeSection( int ) const override { return QString(); } + bool print() override { return false; } + void printPreview() override {} + QStringList embeddedHighlightingModes() const override { return QStringList(); } + QString highlightingModeAt(const KTextEditor::Cursor &) override { return QString(); } + bool isLineModified(int) const override { return false; } + bool isLineSaved(int) const override { return false; } + bool isLineTouched(int) const override { return false; } // KParts::ReadWritePart - bool saveFile() Q_DECL_OVERRIDE { return false; } + bool saveFile() override { return false; } // make QObject happy Q_SIGNALS: void modifiedOnDisk(KTextEditor::Document*, bool, KTextEditor::ModificationInterface::ModifiedOnDiskReason); public: void setUrl(const QString &url) { KParts::ReadOnlyPart::setUrl(QUrl(url)); } void setName(const QString &name) { m_name = name; } - void readSessionConfig(const KConfigGroup &, const QSet & = QSet()) Q_DECL_OVERRIDE {} - void writeSessionConfig(KConfigGroup &, const QSet & = QSet()) Q_DECL_OVERRIDE {} + void readSessionConfig(const KConfigGroup &, const QSet & = QSet()) override {} + void writeSessionConfig(KConfigGroup &, const QSet & = QSet()) override {} - bool postMessage(KTextEditor::Message *) Q_DECL_OVERRIDE { return false; } + bool postMessage(KTextEditor::Message *) override { return false; } - bool isDataRecoveryAvailable() const Q_DECL_OVERRIDE { return false; } - void recoverData() Q_DECL_OVERRIDE {} - void discardDataRecovery() Q_DECL_OVERRIDE {} + bool isDataRecoveryAvailable() const override { return false; } + void recoverData() override {} + void discardDataRecovery() override {} private: QString m_name, m_encoding; QList m_views; }; #endif // kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/addons/filetree/katefiletree.h b/addons/filetree/katefiletree.h index f0634bbb3..f349ba55c 100644 --- a/addons/filetree/katefiletree.h +++ b/addons/filetree/katefiletree.h @@ -1,116 +1,116 @@ /* This file is part of the KDE project Copyright (C) 2010 Thomas Fjellstrom 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 KATE_FILETREE_H #define KATE_FILETREE_H #include #include #include namespace KTextEditor { class Document; } class QActionGroup; class KateFileTree: public QTreeView { Q_OBJECT public: KateFileTree(QWidget *parent); - virtual ~KateFileTree(); + ~KateFileTree() override; - void setModel(QAbstractItemModel *model) Q_DECL_OVERRIDE; + void setModel(QAbstractItemModel *model) override; public Q_SLOTS: void slotDocumentClose(); void slotExpandRecursive(); void slotCollapseRecursive(); void slotDocumentCloseOther(); void slotDocumentReload(); void slotCopyFilename(); void slotCurrentChanged(const QModelIndex ¤t, const QModelIndex &previous); void slotDocumentFirst(); void slotDocumentLast(); void slotDocumentNext(); void slotDocumentPrev(); void slotPrintDocument(); void slotPrintDocumentPreview(); void slotResetHistory(); void slotDocumentDelete(); protected: - void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE; + void contextMenuEvent(QContextMenuEvent *event) override; Q_SIGNALS: void closeDocument(KTextEditor::Document *); void activateDocument(KTextEditor::Document *); void openDocument(QUrl); void viewModeChanged(bool treeMode); void sortRoleChanged(int); private Q_SLOTS: void mouseClicked(const QModelIndex &index); void slotTreeMode(); void slotListMode(); void slotSortName(); void slotSortPath(); void slotSortOpeningOrder(); void slotFixOpenWithMenu(); void slotOpenWithMenuAction(QAction *a); void slotRenameFile(); private: QAction *setupOption(QActionGroup *group, const QIcon &, const QString &, const QString &, const char *slot, bool checked = false); private: QAction *m_filelistCloseDocument; QAction *m_filelistExpandRecursive; QAction *m_filelistCollapseRecursive; QAction *m_filelistCloseOtherDocument; QAction *m_filelistReloadDocument; QAction *m_filelistCopyFilename; QAction *m_filelistRenameFile; QAction *m_filelistPrintDocument; QAction *m_filelistPrintDocumentPreview; QAction *m_filelistDeleteDocument; QAction *m_treeModeAction; QAction *m_listModeAction; QAction *m_sortByFile; QAction *m_sortByPath; QAction *m_sortByOpeningOrder; QAction *m_resetHistory; QPersistentModelIndex m_previouslySelected; QPersistentModelIndex m_indexContextMenu; }; #endif // KATE_FILETREE_H diff --git a/addons/filetree/katefiletreeconfigpage.h b/addons/filetree/katefiletreeconfigpage.h index 35453e6e2..89eb06aaf 100644 --- a/addons/filetree/katefiletreeconfigpage.h +++ b/addons/filetree/katefiletreeconfigpage.h @@ -1,66 +1,66 @@ /* This file is part of the KDE project Copyright (C) 2001 Christoph Cullmann Copyright (C) 2001,2006 Joseph Wenninger Copyright (C) 2001, 2007 Anders Lund Copyright (C) 2010 Thomas Fjellstrom 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 KATE_FILETREE_CONFIGPAGE_H #define KATE_FILETREE_CONFIGPAGE_H #include #include class KateFileTreePlugin; class KateFileTreeConfigPage : public KTextEditor::ConfigPage { Q_OBJECT public: explicit KateFileTreeConfigPage(QWidget *parent = nullptr, KateFileTreePlugin *plug = nullptr); - ~KateFileTreeConfigPage() {} + ~KateFileTreeConfigPage() override {} - QString name() const Q_DECL_OVERRIDE; - QString fullName() const Q_DECL_OVERRIDE; - QIcon icon() const Q_DECL_OVERRIDE; + QString name() const override; + QString fullName() const override; + QIcon icon() const override; public Q_SLOTS: - void apply() Q_DECL_OVERRIDE; - void defaults() Q_DECL_OVERRIDE; - void reset() Q_DECL_OVERRIDE; + void apply() override; + void defaults() override; + void reset() override; //Q_SIGNALS: // void changed(); private Q_SLOTS: void slotMyChanged(); private: class QGroupBox *gbEnableShading; class KColorButton *kcbViewShade, *kcbEditShade; class QLabel *lEditShade, *lViewShade, *lSort, *lMode; class KComboBox *cmbSort, *cmbMode; class QCheckBox *cbShowFullPath; KateFileTreePlugin *m_plug; bool m_changed; }; #endif /* KATE_FILETREE_CONFIGPAGE_H */ diff --git a/addons/filetree/katefiletreemodel.h b/addons/filetree/katefiletreemodel.h index 7a3d93a4a..01200917a 100644 --- a/addons/filetree/katefiletreemodel.h +++ b/addons/filetree/katefiletreemodel.h @@ -1,133 +1,133 @@ /* This file is part of the KDE project Copyright (C) 2010 Thomas Fjellstrom 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 KATEFILETREEMODEL_H #define KATEFILETREEMODEL_H #include #include #include namespace KTextEditor { class Document; } class ProxyItem; class ProxyItemDir; QDebug operator<<(QDebug dbg, ProxyItem *item); QDebug operator<<(QDebug dbg, ProxyItemDir *item); class KateFileTreeModel : public QAbstractItemModel { Q_OBJECT public: enum { DocumentRole = Qt::UserRole + 1, PathRole, OpeningOrderRole, DocumentTreeRole }; KateFileTreeModel(QObject *p); - virtual ~KateFileTreeModel(); + ~KateFileTreeModel() override; /* QAbstractItemModel implementations */ - Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; - int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - - QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE; - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - bool hasChildren(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; + Qt::ItemFlags flags(const QModelIndex &index) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + + QModelIndex parent(const QModelIndex &index) const override; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; + bool hasChildren(const QModelIndex &parent = QModelIndex()) const override; QMimeData *mimeData(const QModelIndexList &indexes) const override; /* extra api for view */ QModelIndex docIndex(const KTextEditor::Document *) const; bool isDir(const QModelIndex &index) const; bool listMode() const; void setListMode(bool); bool shadingEnabled() const; void setShadingEnabled(bool); const QColor &editShade() const; void setEditShade(const QColor &); const QColor &viewShade() const; void setViewShade(const QColor &); bool showFullPathOnRoots(void) const; void setShowFullPathOnRoots(bool); void documentsOpened(const QList &); /* used strictly for the item coloring */ void documentActivated(const KTextEditor::Document *); void documentEdited(const KTextEditor::Document *); void resetHistory(); public Q_SLOTS: void documentOpened(KTextEditor::Document *); void documentClosed(KTextEditor::Document *); void documentNameChanged(KTextEditor::Document *); void documentModifiedChanged(KTextEditor::Document *); void documentModifiedOnDisc(KTextEditor::Document *, bool, KTextEditor::ModificationInterface::ModifiedOnDiskReason); void slotAboutToDeleteDocuments(const QList &); void slotDocumentsDeleted(const QList &); Q_SIGNALS: void triggerViewChangeAfterNameChange(); private: ProxyItemDir *findRootNode(const QString &name, const int r = 1) const; ProxyItemDir *findChildNode(const ProxyItemDir *parent, const QString &name) const; void insertItemInto(ProxyItemDir *root, ProxyItem *item); void handleInsert(ProxyItem *item); void handleNameChange(ProxyItem *item); void handleEmptyParents(ProxyItemDir *item); void setupIcon(ProxyItem *item) const; void updateItemPathAndHost(ProxyItem *item) const; void handleDuplicitRootDisplay(ProxyItemDir *item); void updateBackgrounds(bool force = false); void initModel(); void clearModel(); void connectDocument(const KTextEditor::Document *); private: ProxyItemDir *m_root; QHash m_docmap; bool m_shadingEnabled; QList m_viewHistory; QList m_editHistory; QMap m_brushes; QColor m_editShade; QColor m_viewShade; bool m_listMode; }; #endif /* KATEFILETREEMODEL_H */ diff --git a/addons/filetree/katefiletreeplugin.h b/addons/filetree/katefiletreeplugin.h index 4bce7c56c..e8d8d45bd 100644 --- a/addons/filetree/katefiletreeplugin.h +++ b/addons/filetree/katefiletreeplugin.h @@ -1,142 +1,142 @@ /* This file is part of the KDE project Copyright (C) 2010 Thomas Fjellstrom 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 KATE_FILETREE_PLUGIN_H #define KATE_FILETREE_PLUGIN_H #include #include #include #include #include #include #include #include "katefiletreepluginsettings.h" #include class KToolBar; class KateFileTree; class KateFileTreeModel; class KateFileTreeProxyModel; class KateFileTreeConfigPage; class KateFileTreePluginView; class KateFileTreePlugin: public KTextEditor::Plugin { Q_OBJECT public: explicit KateFileTreePlugin(QObject *parent = nullptr, const QList & = QList()); - virtual ~KateFileTreePlugin(); + ~KateFileTreePlugin() override; - QObject *createView(KTextEditor::MainWindow *mainWindow) Q_DECL_OVERRIDE; + QObject *createView(KTextEditor::MainWindow *mainWindow) override; - int configPages() const Q_DECL_OVERRIDE; - KTextEditor::ConfigPage *configPage(int number = 0, QWidget *parent = nullptr) Q_DECL_OVERRIDE; + int configPages() const override; + KTextEditor::ConfigPage *configPage(int number = 0, QWidget *parent = nullptr) override; const KateFileTreePluginSettings &settings(); void applyConfig(bool shadingEnabled, QColor viewShade, QColor editShade, bool listMode, int sortRole, bool showFulPath); public Q_SLOTS: void viewDestroyed(QObject *view); private: QList m_views; KateFileTreeConfigPage *m_confPage; KateFileTreePluginSettings m_settings; }; class KateFileTreePluginView : public QObject, public KXMLGUIClient, public KTextEditor::SessionConfigInterface { Q_OBJECT Q_INTERFACES(KTextEditor::SessionConfigInterface) public: /** * Constructor. */ KateFileTreePluginView(KTextEditor::MainWindow *mainWindow, KateFileTreePlugin *plug); /** * Virtual destructor. */ - ~KateFileTreePluginView(); + ~KateFileTreePluginView() override; - void readSessionConfig(const KConfigGroup &config) Q_DECL_OVERRIDE; - void writeSessionConfig(KConfigGroup &config) Q_DECL_OVERRIDE; + void readSessionConfig(const KConfigGroup &config) override; + void writeSessionConfig(KConfigGroup &config) override; /** * The file tree model. * @return the file tree model */ KateFileTreeModel *model(); /** * The file tree proxy model. * @return the file tree proxy model */ KateFileTreeProxyModel *proxy(); /** * The file tree. * @return the file tree */ KateFileTree *tree(); void setListMode(bool listMode); bool hasLocalPrefs(); void setHasLocalPrefs(bool); protected: void setupActions(); private: QWidget *m_toolView; KToolBar *m_toolbar; KateFileTree *m_fileTree; KateFileTreeProxyModel *m_proxyModel; KateFileTreeModel *m_documentModel; bool m_hasLocalPrefs; bool m_loadingDocuments; KateFileTreePlugin *m_plug; KTextEditor::MainWindow *m_mainWindow; private Q_SLOTS: void showToolView(); void hideToolView(); void showActiveDocument(); void activateDocument(KTextEditor::Document *); void viewChanged(KTextEditor::View * = nullptr); void documentOpened(KTextEditor::Document *); void documentClosed(KTextEditor::Document *); void viewModeChanged(bool); void sortRoleChanged(int); void slotAboutToCreateDocuments(); void slotDocumentsCreated(const QList &); void slotDocumentSave(); void slotDocumentSaveAs(); }; #endif //KATE_FILETREE_PLUGIN_H diff --git a/addons/filetree/katefiletreeproxymodel.h b/addons/filetree/katefiletreeproxymodel.h index fb092fea5..facdf47de 100644 --- a/addons/filetree/katefiletreeproxymodel.h +++ b/addons/filetree/katefiletreeproxymodel.h @@ -1,46 +1,46 @@ /* This file is part of the KDE project Copyright (C) 2010 Thomas Fjellstrom 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 KATE_FILETREEPROXYMODEL_H #define KATE_FILETREEPROXYMODEL_H #include namespace KTextEditor { class Document; } class KateFileTreeProxyModel : public QSortFilterProxyModel { Q_OBJECT public: KateFileTreeProxyModel(QObject *p = nullptr); QModelIndex docIndex(const KTextEditor::Document *) const; bool isDir(const QModelIndex &i) const; - void setSourceModel(QAbstractItemModel *model) Q_DECL_OVERRIDE; + void setSourceModel(QAbstractItemModel *model) override; protected: - bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE; + bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; }; #endif /* KATE_FILETREEPROXYMODEL_H */ diff --git a/addons/gdbplugin/advanced_settings.h b/addons/gdbplugin/advanced_settings.h index f2658ca2d..e3572e85f 100644 --- a/addons/gdbplugin/advanced_settings.h +++ b/addons/gdbplugin/advanced_settings.h @@ -1,65 +1,65 @@ // Description: Advanced settings dialog for gdb // // // Copyright (c) 2012 Kåre Särs // // 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 ADVANCED_SETTINGS_H #define ADVANCED_SETTINGS_H #include "ui_advanced_settings.h" #include #include class AdvancedGDBSettings : public QDialog, public Ui::AdvancedGDBSettings { Q_OBJECT public: enum CustomStringOrder { GDBIndex = 0, LocalRemoteIndex, RemoteBaudIndex, SoAbsoluteIndex, SoRelativeIndex, SrcPathsIndex, CustomStartIndex }; AdvancedGDBSettings(QWidget *parent = nullptr); - ~AdvancedGDBSettings(); + ~AdvancedGDBSettings() override; const QStringList configs() const; void setConfigs(const QStringList &cfgs); private: void setComboText(QComboBox *combo, const QString &str); private Q_SLOTS: void slotBrowseGDB(); void slotSetSoPrefix(); void slotAddSoPath(); void slotDelSoPath(); void slotAddSrcPath(); void slotDelSrcPath(); void slotLocalRemoteChanged(); }; #endif diff --git a/addons/gdbplugin/configview.h b/addons/gdbplugin/configview.h index 922b17053..5c98be34a 100644 --- a/addons/gdbplugin/configview.h +++ b/addons/gdbplugin/configview.h @@ -1,132 +1,132 @@ // // configview.h // // Description: View for configuring the set of targets to be used with the debugger // // // Copyright (c) 2010 Ian Wakeling // Copyright (c) 2012 Kåre Särs // // 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 CONFIGVIEW_H #define CONFIGVIEW_H #include "advanced_settings.h" #include #include #include #include #include #include #include #include #include #include #include #include #include struct GDBTargetConf { QString executable; QString workDir; QString arguments; QString gdbCmd; QStringList customInit; QStringList srcPaths; }; class ConfigView : public QWidget { Q_OBJECT public: enum TargetStringOrder { NameIndex = 0, ExecIndex, WorkDirIndex, ArgsIndex, GDBIndex, CustomStartIndex }; ConfigView(QWidget* parent, KTextEditor::MainWindow* mainWin); - ~ConfigView(); + ~ConfigView() override; public: void registerActions(KActionCollection* actionCollection); void readConfig (const KConfigGroup& config); void writeConfig (KConfigGroup& config); const GDBTargetConf currentTarget() const; bool takeFocusAlways() const; bool showIOTab() const; Q_SIGNALS: void showIO(bool show); private Q_SLOTS: void slotTargetEdited(const QString &newText); void slotTargetSelected(int index); void slotAddTarget(); void slotCopyTarget(); void slotDeleteTarget(); void slotAdvancedClicked(); void slotBrowseExec(); void slotBrowseDir(); protected: - void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *event) override; private: void saveCurrentToIndex(int index); void loadFromIndex(int index); void setAdvancedOptions(); private: KTextEditor::MainWindow* m_mainWindow; QComboBox* m_targetCombo; int m_currentTarget; QToolButton* m_addTarget; QToolButton* m_copyTarget; QToolButton* m_deleteTarget; QFrame* m_line; QLineEdit* m_executable; QToolButton* m_browseExe; QLineEdit* m_workingDirectory; QToolButton* m_browseDir; QLineEdit* m_arguments; QCheckBox* m_takeFocus; QCheckBox* m_redirectTerminal; QPushButton* m_advancedSettings; QBoxLayout* m_checBoxLayout; bool m_useBottomLayout; QLabel* m_execLabel; QLabel* m_workDirLabel; QLabel* m_argumentsLabel; KSelectAction* m_targetSelectAction; AdvancedGDBSettings* m_advanced; }; #endif diff --git a/addons/gdbplugin/debugview.h b/addons/gdbplugin/debugview.h index d3bbb5234..c10c24e58 100644 --- a/addons/gdbplugin/debugview.h +++ b/addons/gdbplugin/debugview.h @@ -1,143 +1,143 @@ // // debugview.h // // Description: Manages the interaction with GDB // // // Copyright (c) 2008-2010 Ian Wakeling // Copyright (c) 2010 Kåre Särs // // 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 DEBUGVIEW_H #define DEBUGVIEW_H #include #include #include #include "configview.h" class DebugView : public QObject { Q_OBJECT public: DebugView(QObject* parent); - ~DebugView(); + ~DebugView() override; void runDebugger(const GDBTargetConf &conf, const QStringList &ioFifos); bool debuggerRunning() const; bool debuggerBusy() const; bool hasBreakpoint(QUrl const& url, int line); void toggleBreakpoint(QUrl const& url, int line); void movePC(QUrl const& url, int line); void runToCursor(QUrl const& url, int line); void issueCommand(QString const& cmd); public Q_SLOTS: void slotInterrupt(); void slotStepInto(); void slotStepOver(); void slotStepOut(); void slotContinue(); void slotKill(); void slotReRun(); void slotQueryLocals(bool display); private Q_SLOTS: void slotError(); void slotReadDebugStdOut(); void slotReadDebugStdErr(); void slotDebugFinished(int exitCode, QProcess::ExitStatus status); void issueNextCommand(); Q_SIGNALS: void debugLocationChanged(const QUrl &file, int lineNum); void breakPointSet(const QUrl &file, int lineNum); void breakPointCleared(const QUrl &file, int lineNum); void clearBreakpointMarks(); void stackFrameInfo(QString const& level, QString const& info); void stackFrameChanged(int level); void threadInfo(int number, bool avtive); void infoLocal(QString const& line); void outputText(const QString &text); void outputError(const QString &text); void readyForInput(bool ready); void programEnded(); void gdbEnded(); private: enum State { none, ready, executingCmd, listingBreakpoints, infoStack, infoArgs, printThis, infoLocals, infoThreads }; enum SubState { normal, stackFrameSeen, stackTraceSeen }; struct BreakPoint { int number; QUrl file; int line; }; private: void processLine(QString output); void processErrors(); void outputTextMaybe(const QString &text); QUrl resolveFileName(const QString &fileName); private: QProcess m_debugProcess; GDBTargetConf m_targetConf; QString m_ioPipeString; State m_state; SubState m_subState; QString m_currentFile; QString m_newFrameFile; int m_newFrameLevel; QStringList m_nextCommands; QString m_lastCommand; bool m_debugLocationChanged; QList m_breakPointList; QString m_outBuffer; QString m_errBuffer; QStringList m_errorList; bool m_queryLocals; }; #endif diff --git a/addons/gdbplugin/ioview.h b/addons/gdbplugin/ioview.h index 685d434dd..ae2b796a3 100644 --- a/addons/gdbplugin/ioview.h +++ b/addons/gdbplugin/ioview.h @@ -1,86 +1,86 @@ // // ioview.h // // Description: Widget that interacts with the debugged application // // // Copyright (c) 2010 Kåre Särs // // 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 IOVIEW_H #define IOVIEW_H #include #include class QTextEdit; class QLineEdit; class QSocketNotifier; class IOView : public QWidget { Q_OBJECT public: IOView(QWidget *parent = nullptr); - ~IOView(); + ~IOView() override; const QString stdinFifo(); const QString stdoutFifo(); const QString stderrFifo(); void enableInput(bool enable); void clearOutput(); public Q_SLOTS: void addStdOutText(const QString &text); void addStdErrText(const QString &text); private Q_SLOTS: void returnPressed(); void readOutput(); void readErrors(); Q_SIGNALS: void stdOutText(const QString &text); void stdErrText(const QString &text); private: void createFifos(); QString createFifo(const QString &prefix); QTextEdit *m_output; QLineEdit *m_input; QString m_stdinFifo; QString m_stdoutFifo; QString m_stderrFifo; QFile m_stdin; QFile m_stdout; QFile m_stderr; QFile m_stdoutD; QFile m_stderrD; int m_stdoutFD; int m_stderrFD; QSocketNotifier *m_stdoutNotifier; QSocketNotifier *m_stderrNotifier; }; #endif diff --git a/addons/gdbplugin/localsview.h b/addons/gdbplugin/localsview.h index 557385c1f..4c38eb886 100644 --- a/addons/gdbplugin/localsview.h +++ b/addons/gdbplugin/localsview.h @@ -1,54 +1,54 @@ // // Description: Widget that local variables of the gdb inferior // // Copyright (c) 2010 Kåre Särs // // 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 LOCALSVIEW_H #define LOCALSVIEW_H #include #include class LocalsView : public QTreeWidget { Q_OBJECT public: LocalsView(QWidget *parent = nullptr); - ~LocalsView(); + ~LocalsView() override; public Q_SLOTS: // An empty value string ends the locals void addLocal(const QString &vString); void addStruct(QTreeWidgetItem *parent, const QString &vString); void addArray(QTreeWidgetItem *parent, const QString &vString); Q_SIGNALS: void localsVisible(bool visible); protected: - void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; - void hideEvent(QHideEvent *event) Q_DECL_OVERRIDE; + void showEvent(QShowEvent *event) override; + void hideEvent(QHideEvent *event) override; private: void createWrappedItem(QTreeWidgetItem *parent, const QString &name, const QString &value); void createWrappedItem(QTreeWidget *parent, const QString &name, const QString &value); bool m_allAdded; QString m_local; }; #endif diff --git a/addons/gdbplugin/plugin_kategdb.h b/addons/gdbplugin/plugin_kategdb.h index b175f7a78..ebd6f0915 100644 --- a/addons/gdbplugin/plugin_kategdb.h +++ b/addons/gdbplugin/plugin_kategdb.h @@ -1,130 +1,130 @@ // // Description: Kate Plugin for GDB integration // // // Copyright (c) 2010 Ian Wakeling // Copyright (c) 2010-2014 Kåre Särs // // 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 PLUGIN_KATEGDB_H #define PLUGIN_KATEGDB_H #include #include #include #include #include #include #include #include "debugview.h" #include "configview.h" #include "ioview.h" #include "localsview.h" class KHistoryComboBox; class QTextEdit; class QTreeWidget; typedef QList VariantList; class KatePluginGDB : public KTextEditor::Plugin { Q_OBJECT public: explicit KatePluginGDB(QObject* parent = nullptr, const VariantList& = VariantList()); - virtual ~KatePluginGDB(); + ~KatePluginGDB() override; - QObject* createView(KTextEditor::MainWindow* mainWindow) Q_DECL_OVERRIDE; + QObject* createView(KTextEditor::MainWindow* mainWindow) override; }; class KatePluginGDBView : public QObject, public KXMLGUIClient, public KTextEditor::SessionConfigInterface { Q_OBJECT Q_INTERFACES(KTextEditor::SessionConfigInterface) public: KatePluginGDBView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mainWin); - ~KatePluginGDBView(); + ~KatePluginGDBView() override; // reimplemented: read and write session config - void readSessionConfig (const KConfigGroup& config) Q_DECL_OVERRIDE; - void writeSessionConfig (KConfigGroup& config) Q_DECL_OVERRIDE; + void readSessionConfig (const KConfigGroup& config) override; + void writeSessionConfig (KConfigGroup& config) override; private Q_SLOTS: void slotDebug(); void slotRestart(); void slotToggleBreakpoint(); void slotMovePC(); void slotRunToCursor(); void slotGoTo(const QUrl &fileName, int lineNum); void slotValue(); void aboutToShowMenu(); void slotBreakpointSet(const QUrl &file, int line); void slotBreakpointCleared(const QUrl &file, int line); void slotSendCommand(); void enableDebugActions(bool enable); void programEnded(); void gdbEnded(); void insertStackFrame(QString const& level, QString const& info); void stackFrameChanged(int level); void stackFrameSelected(); void insertThread(int number, bool active); void threadSelected(int thread); void showIO(bool show); void addOutputText(QString const& text); void addErrorText(QString const& text); void clearMarks(); void handleEsc(QEvent *e); protected: - bool eventFilter(QObject *obj, QEvent *ev) Q_DECL_OVERRIDE; + bool eventFilter(QObject *obj, QEvent *ev) override; private: QString currentWord(); KTextEditor::Application *m_kateApplication; KTextEditor::MainWindow *m_mainWin; QWidget* m_toolView; QWidget* m_localsStackToolView; QTabWidget* m_tabWidget; QTextEdit* m_outputArea; KHistoryComboBox* m_inputArea; QWidget* m_gdbPage; QComboBox* m_threadCombo; int m_activeThread; QTreeWidget* m_stackTree; QString m_lastCommand; DebugView* m_debugView; ConfigView* m_configView; IOView* m_ioView; LocalsView* m_localsView; QPointer m_menu; QAction* m_breakpoint; QUrl m_lastExecUrl; int m_lastExecLine; int m_lastExecFrame; bool m_focusOnInput; }; #endif diff --git a/addons/kate-ctags/kate_ctags_plugin.h b/addons/kate-ctags/kate_ctags_plugin.h index 16bd3e5cb..3a7f867de 100644 --- a/addons/kate-ctags/kate_ctags_plugin.h +++ b/addons/kate-ctags/kate_ctags_plugin.h @@ -1,85 +1,85 @@ #ifndef KATE_CTAGS_PLUGIN_H #define KATE_CTAGS_PLUGIN_H /* Description : Kate CTags plugin * * Copyright (C) 2008-2011 by Kare Sars * * 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.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 program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY 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 . */ #include #include #include #include #include #include #include "kate_ctags_view.h" #include "ui_CTagsGlobalConfig.h" //******************************************************************/ class KateCTagsPlugin : public KTextEditor::Plugin { Q_OBJECT public: explicit KateCTagsPlugin(QObject* parent = nullptr, const QList & = QList()); - virtual ~KateCTagsPlugin() {} + ~KateCTagsPlugin() override {} - QObject *createView(KTextEditor::MainWindow *mainWindow) Q_DECL_OVERRIDE; + QObject *createView(KTextEditor::MainWindow *mainWindow) override; - int configPages() const Q_DECL_OVERRIDE { return 1; }; - KTextEditor::ConfigPage *configPage (int number = 0, QWidget *parent = nullptr) Q_DECL_OVERRIDE; + int configPages() const override { return 1; }; + KTextEditor::ConfigPage *configPage (int number = 0, QWidget *parent = nullptr) override; void readConfig(); KateCTagsView *m_view; }; //******************************************************************/ class KateCTagsConfigPage : public KTextEditor::ConfigPage { Q_OBJECT public: explicit KateCTagsConfigPage( QWidget* parent = nullptr, KateCTagsPlugin *plugin = nullptr ); - ~KateCTagsConfigPage() {} + ~KateCTagsConfigPage() override {} - QString name() const Q_DECL_OVERRIDE; - QString fullName() const Q_DECL_OVERRIDE; - QIcon icon() const Q_DECL_OVERRIDE; + QString name() const override; + QString fullName() const override; + QIcon icon() const override; - void apply() Q_DECL_OVERRIDE; - void reset() Q_DECL_OVERRIDE; - void defaults() Q_DECL_OVERRIDE {} + void apply() override; + void reset() override; + void defaults() override {} private Q_SLOTS: void addGlobalTagTarget(); void delGlobalTagTarget(); void updateGlobalDB(); void updateDone(int exitCode, QProcess::ExitStatus status); private: bool listContains(const QString &target); QProcess m_proc; KateCTagsPlugin *m_plugin; Ui_CTagsGlobalConfig m_confUi; }; #endif diff --git a/addons/kate-ctags/kate_ctags_view.h b/addons/kate-ctags/kate_ctags_view.h index 17465fce7..75e563f4d 100644 --- a/addons/kate-ctags/kate_ctags_view.h +++ b/addons/kate-ctags/kate_ctags_view.h @@ -1,119 +1,119 @@ #ifndef KATE_CTAGS_VIEW_H #define KATE_CTAGS_VIEW_H /* Description : Kate CTags plugin * * Copyright (C) 2008-2011 by Kare Sars * * 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.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 program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY 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 . */ #include #include #include #include #include #include #include #include #include #include #include #include "tags.h" #include "ui_kate_ctags.h" const static QString DEFAULT_CTAGS_CMD = QLatin1String("ctags -R --c++-types=+px --extra=+q --excmd=pattern --exclude=Makefile --exclude=."); typedef struct { QUrl url; KTextEditor::Cursor cursor; } TagJump; /******************************************************************/ class KateCTagsView : public QObject, public KXMLGUIClient, public KTextEditor::SessionConfigInterface { Q_OBJECT Q_INTERFACES(KTextEditor::SessionConfigInterface) public: KateCTagsView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mainWin); - ~KateCTagsView(); + ~KateCTagsView() override; // reimplemented: read and write session config - void readSessionConfig (const KConfigGroup& config) Q_DECL_OVERRIDE; - void writeSessionConfig (KConfigGroup& config) Q_DECL_OVERRIDE; + void readSessionConfig (const KConfigGroup& config) override; + void writeSessionConfig (KConfigGroup& config) override; public Q_SLOTS: void gotoDefinition(); void gotoDeclaration(); void lookupTag(); void stepBack(); void editLookUp(); void aboutToShow(); void tagHitClicked(QTreeWidgetItem *); void startEditTmr(); void addTagTarget(); void delTagTarget(); void updateSessionDB(); void updateDone(int exitCode, QProcess::ExitStatus status); protected: - bool eventFilter(QObject *obj, QEvent *ev) Q_DECL_OVERRIDE; + bool eventFilter(QObject *obj, QEvent *ev) override; private Q_SLOTS: void resetCMD(); void handleEsc(QEvent *e); private: bool listContains(const QString &target); QString currentWord(); void setNewLookupText(const QString &newText); void displayHits(const Tags::TagList &list); void gotoTagForTypes(const QString &tag, QStringList const &types); void jumpToTag(const QString &file, const QString &pattern, const QString &word); KTextEditor::MainWindow *m_mWin; QWidget *m_toolView; Ui::kateCtags m_ctagsUi; QPointer m_menu; QAction *m_gotoDef; QAction *m_gotoDec; QAction *m_lookup; QProcess m_proc; QString m_commonDB; QTimer m_editTimer; QStack m_jumpStack; }; #endif diff --git a/addons/katebuild-plugin/SelectTargetView.cpp b/addons/katebuild-plugin/SelectTargetView.cpp index 3422c369d..30c4d4ce2 100644 --- a/addons/katebuild-plugin/SelectTargetView.cpp +++ b/addons/katebuild-plugin/SelectTargetView.cpp @@ -1,127 +1,127 @@ /*************************************************************************** * This file is part of Kate build plugin * * Copyright 2014 Kåre Särs * * * * 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 "SelectTargetView.h" #include "TargetHtmlDelegate.h" #include #include #include #include class TargetFilterProxyModel: public QSortFilterProxyModel { public: TargetFilterProxyModel(QObject *parent): QSortFilterProxyModel(parent) {} - bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const Q_DECL_OVERRIDE + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override { if (m_filter.isEmpty()) { return true; } QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent); QString name = index0.data().toString(); if (index0.internalId() == 0xffffffff) { int i=0; while (index0.child(i,0).data().isValid()) { name = index0.child(i,0).data().toString(); if (name.contains(m_filter, Qt::CaseInsensitive)) { return true; } i++; } return false; } return name.contains(m_filter, Qt::CaseInsensitive); } void setFilter(const QString &filter) { m_filter = filter; invalidateFilter(); } - Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE + Qt::ItemFlags flags(const QModelIndex &index) const override { if (!index.isValid()) { return nullptr; } return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } QString m_filter; }; SelectTargetView::SelectTargetView(QAbstractItemModel *model, QWidget* parent) :QDialog(parent) { setupUi(this); m_proxyModel = new TargetFilterProxyModel(this); m_proxyModel->setSourceModel(model); u_treeView->setModel(m_proxyModel); u_treeView->expandAll(); u_treeView->resizeColumnToContents(0); u_treeView->setEditTriggers(QAbstractItemView::EditKeyPressed); setFocusProxy(u_filterEdit); connect(u_filterEdit, SIGNAL(textChanged(QString)), this, SLOT(setFilter(QString))); connect(u_treeView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(accept())); u_filterEdit->installEventFilter(this); } void SelectTargetView::setFilter(const QString &filter) { m_proxyModel->setFilter(filter); u_treeView->expandAll(); } const QModelIndex SelectTargetView::currentIndex() const { return m_proxyModel->mapToSource(u_treeView->currentIndex()); } void SelectTargetView::setCurrentIndex(const QModelIndex &index) { u_treeView->setCurrentIndex(m_proxyModel->mapFromSource(index)); } bool SelectTargetView::eventFilter(QObject *obj, QEvent *event) { if (event->type()==QEvent::KeyPress) { QKeyEvent *keyEvent=static_cast(event); if (obj==u_filterEdit) { if ((keyEvent->key()==Qt::Key_Up) || (keyEvent->key()==Qt::Key_Down) || (keyEvent->key()==Qt::Key_PageUp) || (keyEvent->key()==Qt::Key_PageDown)) { QCoreApplication::sendEvent(u_treeView ,event); return true; } } } return QDialog::eventFilter(obj, event); } diff --git a/addons/katebuild-plugin/SelectTargetView.h b/addons/katebuild-plugin/SelectTargetView.h index 0ca1f5b82..c8ecd0849 100644 --- a/addons/katebuild-plugin/SelectTargetView.h +++ b/addons/katebuild-plugin/SelectTargetView.h @@ -1,47 +1,47 @@ /*************************************************************************** * This file is part of Kate build plugin * * Copyright 2014 Kåre Särs * * * * 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 SelectTargetView_H #define SelectTargetView_H #include "ui_SelectTargetUi.h" #include class TargetFilterProxyModel; class SelectTargetView : public QDialog, public Ui::SelectTargetUi { Q_OBJECT public: SelectTargetView(QAbstractItemModel *model, QWidget *parent = nullptr); const QModelIndex currentIndex() const; void setCurrentIndex(const QModelIndex &index); public Q_SLOTS: void setFilter(const QString &filter); protected: - bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *obj, QEvent *event) override; private: TargetFilterProxyModel *m_proxyModel; }; #endif diff --git a/addons/katebuild-plugin/TargetHtmlDelegate.h b/addons/katebuild-plugin/TargetHtmlDelegate.h index 44cccb9eb..170915cc2 100644 --- a/addons/katebuild-plugin/TargetHtmlDelegate.h +++ b/addons/katebuild-plugin/TargetHtmlDelegate.h @@ -1,56 +1,56 @@ /*************************************************************************** * This file is part of Kate build plugin * * Copyright 2014 Kåre Särs * * * * 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 TargetHtmlDelegate_H #define TargetHtmlDelegate_H #include class TargetHtmlDelegate : public QStyledItemDelegate { Q_OBJECT public: TargetHtmlDelegate(QObject* parent); - ~TargetHtmlDelegate(); + ~TargetHtmlDelegate() override; - QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE; - void setEditorData(QWidget *editor, const QModelIndex &index) const Q_DECL_OVERRIDE; - void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const Q_DECL_OVERRIDE; + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + void setEditorData(QWidget *editor, const QModelIndex &index) const override; + void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override; - void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE; + void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override; - void paint(QPainter*, const QStyleOptionViewItem&, const QModelIndex&) const Q_DECL_OVERRIDE; - QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const Q_DECL_OVERRIDE; + void paint(QPainter*, const QStyleOptionViewItem&, const QModelIndex&) const override; + QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; bool isEditing() const; public Q_SLOTS: void editStarted(); void editEnded(); Q_SIGNALS: void sendEditStart() const; private: bool m_isEditing; }; #endif diff --git a/addons/katebuild-plugin/TargetModel.h b/addons/katebuild-plugin/TargetModel.h index b0eebfa58..1b518cf5f 100644 --- a/addons/katebuild-plugin/TargetModel.h +++ b/addons/katebuild-plugin/TargetModel.h @@ -1,97 +1,97 @@ /*************************************************************************** * This file is part of Kate build plugin * * Copyright 2014 Kåre Särs * * * * 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 TargetModel_h #define TargetModel_h #include #include class TargetModel : public QAbstractItemModel { Q_OBJECT public: struct TargetSet { TargetSet(const QString &_name, const QString &_workDir); QString name; QString workDir; QString defaultCmd; QList > commands; }; TargetModel(QObject *parent = nullptr); - ~TargetModel(); + ~TargetModel() override; /** This function sets the default command for a target set */ void setDefaultCmd(int rootRow, const QString &defCmd); public Q_SLOTS: /** This function clears all the target-sets */ void clear(); /** This function adds a target set and returns the row number of the newly * inserted row */ int addTargetSet(const QString &setName, const QString &workDir); /** This function adds a new command to a target-set and returns the model index */ QModelIndex addCommand(int rootRow, const QString &cmdName, const QString &command); /** This function copies the target(-set) the model index points to and returns * the model index of the copy. */ QModelIndex copyTargetOrSet(const QModelIndex &index); /** This function returns the model index of the default command of the target-set */ QModelIndex defaultTarget(const QModelIndex &index); /** This function deletes the index */ void deleteItem(const QModelIndex &index); /** This function deletes the target-set with the same name */ void deleteTargetSet(const QString &targetSet); const QList targetSets() const { return m_targets; } const QString command(const QModelIndex &itemIndex) const; const QString cmdName(const QModelIndex &itemIndex) const; const QString workDir(const QModelIndex &itemIndex) const; const QString targetName(const QModelIndex &itemIndex) const; Q_SIGNALS: public: static const quint32 InvalidIndex = 0xFFFFFFFF; // Model-View model functions - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; - bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole) Q_DECL_OVERRIDE; - Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE; - QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - QModelIndex parent(const QModelIndex &child) const Q_DECL_OVERRIDE; - int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole) override; + Qt::ItemFlags flags(const QModelIndex &index) const override; + QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex &child) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; private: QList m_targets; }; #endif diff --git a/addons/katebuild-plugin/plugin_katebuild.h b/addons/katebuild-plugin/plugin_katebuild.h index 5d73bd53b..f005fd666 100644 --- a/addons/katebuild-plugin/plugin_katebuild.h +++ b/addons/katebuild-plugin/plugin_katebuild.h @@ -1,182 +1,182 @@ #ifndef PLUGIN_KATEBUILD_H #define PLUGIN_KATEBUILD_H /* plugin_katebuild.h Kate Plugin ** ** Copyright (C) 2008-2015 by Kåre Särs ** ** This code is almost a total rewrite of the GPL'ed Make plugin ** by Adriaan de Groot. */ /* ** 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 in a file called COPYING; 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 #include #include #include #include "ui_build.h" #include "targets.h" /******************************************************************/ class KateBuildView : public QObject, public KXMLGUIClient, public KTextEditor::SessionConfigInterface { Q_OBJECT Q_INTERFACES(KTextEditor::SessionConfigInterface) Q_PROPERTY(QUrl docUrl READ docUrl) public: enum ResultDetails { FullOutput, ParsedOutput, ErrorsAndWarnings, OnlyErrors }; enum TreeWidgetRoles { ErrorRole = Qt::UserRole+1 }; enum ErrorCategory { CategoryInfo, CategoryWarning, CategoryError }; KateBuildView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mw); - ~KateBuildView(); + ~KateBuildView() override; // reimplemented: read and write session config - void readSessionConfig(const KConfigGroup& config) Q_DECL_OVERRIDE; - void writeSessionConfig(KConfigGroup& config) Q_DECL_OVERRIDE; + void readSessionConfig(const KConfigGroup& config) override; + void writeSessionConfig(KConfigGroup& config) override; bool buildCurrentTarget(); QUrl docUrl(); private Q_SLOTS: // Building void slotSelectTarget(); void slotBuildActiveTarget(); void slotBuildPreviousTarget(); void slotBuildDefaultTarget(); bool slotStop(); // Parse output void slotProcExited(int exitCode, QProcess::ExitStatus exitStatus); void slotReadReadyStdErr(); void slotReadReadyStdOut(); // Selecting warnings/errors void slotNext(); void slotPrev(); void slotErrorSelected(QTreeWidgetItem *item); // Settings void targetSetNew(); void targetOrSetCopy(); void targetDelete(); void slotAddTargetClicked(); void slotDisplayMode(int mode); void handleEsc(QEvent *e); /** * keep track if the project plugin is alive and if the project map did change */ void slotPluginViewCreated(const QString &name, QObject *pluginView); void slotPluginViewDeleted(const QString &name, QObject *pluginView); void slotProjectMapChanged(); void slotAddProjectTarget(); protected: - bool eventFilter(QObject *obj, QEvent *ev) Q_DECL_OVERRIDE; + bool eventFilter(QObject *obj, QEvent *ev) override; private: void processLine(const QString &); void addError(const QString &filename, const QString &line, const QString &column, const QString &message); bool startProcess(const QString &dir, const QString &command); bool checkLocal(const QUrl &dir); void clearBuildResults(); void displayBuildResult(const QString &message, KTextEditor::Message::MessageType level); KTextEditor::MainWindow *m_win; QWidget *m_toolView; Ui::build m_buildUi; QWidget *m_buildWidget; int m_outputWidgetWidth; TargetsUi *m_targetsUi; KProcess m_proc; QString m_stdOut; QString m_stdErr; QString m_currentlyBuildingTarget; bool m_buildCancelled; int m_displayModeBeforeBuild; QString m_make_dir; QStack m_make_dir_stack; QRegularExpression m_filenameDetector; QRegularExpression m_filenameDetectorIcpc; bool m_filenameDetectorGccWorked; QRegularExpression m_newDirDetector; unsigned int m_numErrors; unsigned int m_numWarnings; QString m_prevItemContent; QModelIndex m_previousIndex; QPointer m_infoMessage; /** * current project plugin view, if any */ QObject *m_projectPluginView; }; typedef QList VariantList; /******************************************************************/ class KateBuildPlugin : public KTextEditor::Plugin { Q_OBJECT public: explicit KateBuildPlugin(QObject* parent = nullptr, const VariantList& = VariantList()); - virtual ~KateBuildPlugin() {} + ~KateBuildPlugin() override {} - QObject *createView(KTextEditor::MainWindow *mainWindow) Q_DECL_OVERRIDE; + QObject *createView(KTextEditor::MainWindow *mainWindow) override; }; #endif diff --git a/addons/katebuild-plugin/targets.h b/addons/katebuild-plugin/targets.h index 3c6b4d976..fa1f2a66a 100644 --- a/addons/katebuild-plugin/targets.h +++ b/addons/katebuild-plugin/targets.h @@ -1,66 +1,66 @@ // // Description: Widget for configuring build targets // // Copyright (c) 2011-2014 Kåre Särs // // 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 TARGETS_H #define TARGETS_H #include #include #include #include #include #include #include "TargetHtmlDelegate.h" #include "TargetModel.h" class TargetsUi: public QWidget { Q_OBJECT public: TargetsUi(QObject *view, QWidget *parent = nullptr); QLabel *targetLabel; QComboBox *targetCombo; QToolButton *newTarget; QToolButton *copyTarget; QToolButton *deleteTarget; QTreeView *targetsView; TargetModel targetsModel; QToolButton *addButton; QToolButton *buildButton; public Q_SLOTS: void targetSetSelected(int index); void targetActivated(const QModelIndex &index); Q_SIGNALS: void enterPressed(); protected: - bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *obj, QEvent *event) override; private: TargetHtmlDelegate *m_delegate; }; #endif diff --git a/addons/katesql/cachedsqlquerymodel.h b/addons/katesql/cachedsqlquerymodel.h index 95fec5040..99bfa130a 100644 --- a/addons/katesql/cachedsqlquerymodel.h +++ b/addons/katesql/cachedsqlquerymodel.h @@ -1,51 +1,51 @@ /* Copyright (C) 2010 Marco Mentasti 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 CACHEDSQLQUERYMODEL_H #define CACHEDSQLQUERYMODEL_H #include #include #include class CachedSqlQueryModel : public QSqlQueryModel { Q_OBJECT public: explicit CachedSqlQueryModel(QObject *parent = nullptr, int cacheCapacity = 1000); - QVariant data(const QModelIndex &item, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; + QVariant data(const QModelIndex &item, int role = Qt::DisplayRole) const override; QSqlRecord record(int row) const; - void clear() Q_DECL_OVERRIDE; + void clear() override; int cacheCapacity() const; public Q_SLOTS: void clearCache(); void setCacheCapacity(int); protected: - void queryChange() Q_DECL_OVERRIDE; + void queryChange() override; private: void cacheRecords(int from, int to) const; mutable QContiguousCache cache; }; #endif // CACHEDSQLQUERYMODEL_H diff --git a/addons/katesql/connectionmodel.h b/addons/katesql/connectionmodel.h index 8fa629830..da0010595 100644 --- a/addons/katesql/connectionmodel.h +++ b/addons/katesql/connectionmodel.h @@ -1,58 +1,58 @@ /* Copyright (C) 2010 Marco Mentasti 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 CONNECTIONMODEL_H #define CONNECTIONMODEL_H #include "connection.h" #include #include #include #include class ConnectionModel : public QAbstractListModel { Q_OBJECT public: ConnectionModel(QObject *parent = nullptr); - virtual ~ConnectionModel(); + ~ConnectionModel() override; - int rowCount ( const QModelIndex & parent = QModelIndex() ) const Q_DECL_OVERRIDE; - QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const Q_DECL_OVERRIDE; + int rowCount ( const QModelIndex & parent = QModelIndex() ) const override; + QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const override; virtual int addConnection(Connection conn); virtual void removeConnection(const QString &name); Connection::Status status(const QString &name) const; void setStatus(const QString &name, const Connection::Status status); void setPassword(const QString &name, const QString &password); int indexOf(const QString &name); // virtual bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()); // virtual bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()); private: QHash m_connections; QHash m_icons; }; #endif // CONNECTIONMODEL_H diff --git a/addons/katesql/connectionwizard.h b/addons/katesql/connectionwizard.h index 3bf9217c6..d414664ed 100644 --- a/addons/katesql/connectionwizard.h +++ b/addons/katesql/connectionwizard.h @@ -1,113 +1,113 @@ /* Copyright (C) 2010 Marco Mentasti 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 CONNECTIONWIZARD_H #define CONNECTIONWIZARD_H class SQLManager; class KComboBox; class KLineEdit; class QSpinBox; class KUrlRequester; #include "connection.h" #include #include class ConnectionWizard : public QWizard { public: enum { Page_Driver, Page_Standard_Server, Page_SQLite_Server, Page_Save }; ConnectionWizard(SQLManager *manager, Connection *conn, QWidget *parent=nullptr, Qt::WindowFlags flags = nullptr); - ~ConnectionWizard(); + ~ConnectionWizard() override; SQLManager *manager() { return m_manager; } Connection *connection() { return m_connection; } private: SQLManager *m_manager; Connection *m_connection; }; class ConnectionDriverPage : public QWizardPage { public: ConnectionDriverPage(QWidget *parent=nullptr); - void initializePage() Q_DECL_OVERRIDE; - int nextId() const Q_DECL_OVERRIDE; + void initializePage() override; + int nextId() const override; private: KComboBox *driverComboBox; }; class ConnectionStandardServerPage : public QWizardPage { public: ConnectionStandardServerPage(QWidget *parent=nullptr); - ~ConnectionStandardServerPage(); - void initializePage() Q_DECL_OVERRIDE; - bool validatePage() Q_DECL_OVERRIDE; - int nextId() const Q_DECL_OVERRIDE; + ~ConnectionStandardServerPage() override; + void initializePage() override; + bool validatePage() override; + int nextId() const override; private: KLineEdit *hostnameLineEdit; KLineEdit *usernameLineEdit; KLineEdit *passwordLineEdit; KLineEdit *databaseLineEdit; KLineEdit *optionsLineEdit; QSpinBox *portSpinBox; }; class ConnectionSQLiteServerPage : public QWizardPage { public: ConnectionSQLiteServerPage(QWidget *parent=nullptr); - void initializePage() Q_DECL_OVERRIDE; - bool validatePage() Q_DECL_OVERRIDE; - int nextId() const Q_DECL_OVERRIDE; + void initializePage() override; + bool validatePage() override; + int nextId() const override; private: // KLineEdit *pathLineEdit; KUrlRequester *pathUrlRequester; KLineEdit *optionsLineEdit; }; class ConnectionSavePage : public QWizardPage { public: ConnectionSavePage(QWidget *parent=nullptr); - void initializePage() Q_DECL_OVERRIDE; - bool validatePage() Q_DECL_OVERRIDE; - int nextId() const Q_DECL_OVERRIDE; + void initializePage() override; + bool validatePage() override; + int nextId() const override; private: KLineEdit *connectionNameLineEdit; }; #endif // CONNECTIONWIZARD_H diff --git a/addons/katesql/dataoutputmodel.h b/addons/katesql/dataoutputmodel.h index cbcb7f6d1..9ee6499e2 100644 --- a/addons/katesql/dataoutputmodel.h +++ b/addons/katesql/dataoutputmodel.h @@ -1,52 +1,52 @@ /* Copyright (C) 2010 Marco Mentasti 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 DATAOUTPUTMODEL_H #define DATAOUTPUTMODEL_H struct OutputStyle; #include "cachedsqlquerymodel.h" #include #include /// provide colors and styles class DataOutputModel : public CachedSqlQueryModel { Q_OBJECT public: DataOutputModel(QObject *parent = nullptr); - ~DataOutputModel(); + ~DataOutputModel() override; bool useSystemLocale() const; void setUseSystemLocale(bool useSystemLocale); - QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const Q_DECL_OVERRIDE; + QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const override; - void clear() Q_DECL_OVERRIDE; + void clear() override; void readConfig(); private: QHash m_styles; bool m_useSystemLocale; }; #endif // DATAOUTPUTMODEL_H diff --git a/addons/katesql/dataoutputwidget.h b/addons/katesql/dataoutputwidget.h index eb5726533..40a303b25 100644 --- a/addons/katesql/dataoutputwidget.h +++ b/addons/katesql/dataoutputwidget.h @@ -1,77 +1,77 @@ /* Copyright (C) 2010 Marco Mentasti 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 DATAOUTPUTWIDGET_H #define DATAOUTPUTWIDGET_H class QTextStream; class QVBoxLayout; class QSqlQuery; class DataOutputModel; class DataOutputView; #include class DataOutputWidget : public QWidget { Q_OBJECT public: enum Option { NoOptions = 0x0, ExportColumnNames = 0x1, ExportLineNumbers = 0x2 }; Q_DECLARE_FLAGS(Options, Option) DataOutputWidget(QWidget *parent); - ~DataOutputWidget(); + ~DataOutputWidget() override; void exportData(QTextStream &stream, const QChar stringsQuoteChar = QLatin1Char ('\0'), const QChar numbersQuoteChar = QLatin1Char ('\0'), const QString fieldDelimiter = QLatin1String ("\t"), const Options opt = NoOptions); DataOutputModel *model() const { return m_model; } DataOutputView *view() const { return m_view; } public Q_SLOTS: void showQueryResultSets(QSqlQuery &query); void resizeColumnsToContents(); void resizeRowsToContents(); void clearResults(); void slotToggleLocale(); void slotCopySelected(); void slotExport(); private: QVBoxLayout *m_dataLayout; /// TODO: manage multiple views for query with multiple resultsets DataOutputModel *m_model; DataOutputView *m_view; bool m_isEmpty; }; Q_DECLARE_OPERATORS_FOR_FLAGS(DataOutputWidget::Options) #endif // DATAOUTPUTWIDGET_H diff --git a/addons/katesql/exportwizard.h b/addons/katesql/exportwizard.h index 8ece665ff..207d616b8 100644 --- a/addons/katesql/exportwizard.h +++ b/addons/katesql/exportwizard.h @@ -1,72 +1,72 @@ /* Copyright (C) 2010 Marco Mentasti 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 EXPORTWIZARD_H #define EXPORTWIZARD_H class KUrlRequester; class KLineEdit; class QRadioButton; class QCheckBox; #include class ExportWizard : public QWizard { public: ExportWizard(QWidget *parent); - ~ExportWizard(); + ~ExportWizard() override; }; class ExportOutputPage : public QWizardPage { public: ExportOutputPage(QWidget *parent=nullptr); - void initializePage() Q_DECL_OVERRIDE; - bool validatePage() Q_DECL_OVERRIDE; + void initializePage() override; + bool validatePage() override; private: QRadioButton *documentRadioButton; QRadioButton *clipboardRadioButton; QRadioButton *fileRadioButton; KUrlRequester *fileUrl; }; class ExportFormatPage : public QWizardPage { public: ExportFormatPage(QWidget *parent=nullptr); - void initializePage() Q_DECL_OVERRIDE; - bool validatePage() Q_DECL_OVERRIDE; + void initializePage() override; + bool validatePage() override; private: QCheckBox *exportColumnNamesCheckBox; QCheckBox *exportLineNumbersCheckBox; QCheckBox *quoteStringsCheckBox; QCheckBox *quoteNumbersCheckBox; KLineEdit *quoteStringsLine; KLineEdit *quoteNumbersLine; KLineEdit *fieldDelimiterLine; }; #endif // EXPORTWIZARD_H diff --git a/addons/katesql/katesqlconfigpage.h b/addons/katesql/katesqlconfigpage.h index 194e84c5a..6a957caa7 100644 --- a/addons/katesql/katesqlconfigpage.h +++ b/addons/katesql/katesqlconfigpage.h @@ -1,58 +1,58 @@ /* Copyright (C) 2010 Marco Mentasti 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 KATESQLCONFIGPAGE_H #define KATESQLCONFIGPAGE_H class OutputStyleWidget; class QCheckBox; #include "katesqlplugin.h" #include /// TODO: add options to change datetime and numbers format class KateSQLConfigPage : public KTextEditor::ConfigPage { Q_OBJECT public: explicit KateSQLConfigPage( QWidget* parent = nullptr ); - virtual ~KateSQLConfigPage(); + ~KateSQLConfigPage() override; - QString name() const Q_DECL_OVERRIDE; - QString fullName() const Q_DECL_OVERRIDE; - QIcon icon() const Q_DECL_OVERRIDE; + QString name() const override; + QString fullName() const override; + QIcon icon() const override; public Q_SLOTS: - void apply() Q_DECL_OVERRIDE; - void reset() Q_DECL_OVERRIDE; - void defaults() Q_DECL_OVERRIDE; + void apply() override; + void reset() override; + void defaults() override; private: KateSQLPlugin *m_plugin; QCheckBox *m_box; OutputStyleWidget *m_outputStyleWidget; Q_SIGNALS: void settingsChanged(); }; #endif // KATESQLCONFIGPAGE_H diff --git a/addons/katesql/katesqlplugin.h b/addons/katesql/katesqlplugin.h index 24f8b3e34..358357b11 100644 --- a/addons/katesql/katesqlplugin.h +++ b/addons/katesql/katesqlplugin.h @@ -1,51 +1,51 @@ /* Copyright (C) 2010 Marco Mentasti 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 KATESQLPLUGIN_H #define KATESQLPLUGIN_H #include #include #include #include #include class KateSQLPlugin : public KTextEditor::Plugin { Q_OBJECT public: explicit KateSQLPlugin(QObject* parent = nullptr, const QList& = QList()); - virtual ~KateSQLPlugin(); + ~KateSQLPlugin() override; - QObject *createView(KTextEditor::MainWindow *mainWindow) Q_DECL_OVERRIDE; + QObject *createView(KTextEditor::MainWindow *mainWindow) override; - int configPages() const Q_DECL_OVERRIDE { return 1; }; - KTextEditor::ConfigPage *configPage (int number = 0, QWidget *parent = nullptr) Q_DECL_OVERRIDE; + int configPages() const override { return 1; }; + KTextEditor::ConfigPage *configPage (int number = 0, QWidget *parent = nullptr) override; QString configPageName (int number = 0) const; QString configPageFullName (int number = 0) const; QIcon configPageIcon (int number = 0) const; Q_SIGNALS: void globalSettingsChanged(); }; #endif // KATESQLPLUGIN_H diff --git a/addons/katesql/katesqlview.h b/addons/katesql/katesqlview.h index d4745d4f8..f765ed129 100644 --- a/addons/katesql/katesqlview.h +++ b/addons/katesql/katesqlview.h @@ -1,88 +1,88 @@ /* Copyright (C) 2010 Marco Mentasti 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 KATESQLVIEW_H #define KATESQLVIEW_H class KateSQLOutputWidget; class SchemaBrowserWidget; class SQLManager; class KConfigBase; class KComboBox; class QSqlQuery; class QActionGroup; #include #include class KateSQLView : public QObject, public KXMLGUIClient { Q_OBJECT public: KateSQLView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mw); - ~KateSQLView(); + ~KateSQLView() override; void readSessionConfig (KConfigBase* config, const QString& groupPrefix); void writeSessionConfig (KConfigBase* config, const QString& groupPrefix); SchemaBrowserWidget *schemaBrowserWidget() const { return m_schemaBrowserWidget; } public Q_SLOTS: void slotConnectionCreate(); void slotConnectionEdit(); void slotConnectionRemove(); void slotConnectionReconnect(); void slotConnectionChanged(const QString &connection); void slotRunQuery(); void slotError(const QString &message); void slotSuccess(const QString &message); void slotQueryActivated(QSqlQuery &query, const QString &connection); void slotConnectionCreated(const QString &name); void slotGlobalSettingsChanged(); void slotSQLMenuAboutToShow(); void slotConnectionSelectedFromMenu(QAction *action); void slotConnectionAboutToBeClosed(const QString &name); protected: void setupActions(); private: QWidget *m_outputToolView; QWidget *m_schemaBrowserToolView; QActionGroup *m_connectionsGroup; KateSQLOutputWidget *m_outputWidget; SchemaBrowserWidget *m_schemaBrowserWidget; KComboBox *m_connectionsComboBox; SQLManager *m_manager; QString m_currentResultsetConnection; KTextEditor::MainWindow *m_mainWindow; }; #endif // KATESQLVIEW_H diff --git a/addons/katesql/outputstylewidget.h b/addons/katesql/outputstylewidget.h index 14f1bd7ab..9f648b688 100644 --- a/addons/katesql/outputstylewidget.h +++ b/addons/katesql/outputstylewidget.h @@ -1,50 +1,50 @@ /* Copyright (C) 2010 Marco Mentasti 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 OUTPUTSTYLEWIDGET_H #define OUTPUTSTYLEWIDGET_H #include class OutputStyleWidget : public QTreeWidget { Q_OBJECT public: OutputStyleWidget(QWidget *parent = nullptr); - ~OutputStyleWidget(); + ~OutputStyleWidget() override; QTreeWidgetItem* addContext(const QString &key, const QString &name); public Q_SLOTS: void readConfig(); void writeConfig(); protected Q_SLOTS: void slotChanged(); void updatePreviews(); void readConfig(QTreeWidgetItem *item); void writeConfig(QTreeWidgetItem *item); Q_SIGNALS: void changed(); }; #endif // OUTPUTSTYLEWIDGET_H diff --git a/addons/katesql/outputwidget.h b/addons/katesql/outputwidget.h index 586800d92..05df1e133 100644 --- a/addons/katesql/outputwidget.h +++ b/addons/katesql/outputwidget.h @@ -1,50 +1,50 @@ /* This file is part of the Kate project. * * Copyright (C) 2012 Joseph Wenninger * * 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 _KATE_SQL_OUTPUT_VIEW_ #define _KATE_SQL_OUTPUT_VIEW_ #include class TextOutputWidget; class DataOutputWidget; class KateSQLOutputWidget : public QTabWidget { Q_OBJECT public: KateSQLOutputWidget (QWidget *parent); - ~KateSQLOutputWidget (); + ~KateSQLOutputWidget () override; TextOutputWidget *textOutputWidget() const { return m_textOutputWidget; } DataOutputWidget *dataOutputWidget() const { return m_dataOutputWidget; } private: TextOutputWidget *m_textOutputWidget; DataOutputWidget *m_dataOutputWidget; }; #endif // kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/addons/katesql/schemabrowserwidget.h b/addons/katesql/schemabrowserwidget.h index 58c937f14..664a3a58d 100644 --- a/addons/katesql/schemabrowserwidget.h +++ b/addons/katesql/schemabrowserwidget.h @@ -1,41 +1,41 @@ /* Copyright (C) 2010 Marco Mentasti 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 SCHEMABROWSERWIDGET_H #define SCHEMABROWSERWIDGET_H class SQLManager; class SchemaWidget; #include class SchemaBrowserWidget : public QWidget { Q_OBJECT public: SchemaBrowserWidget(QWidget *parent, SQLManager *manager); - ~SchemaBrowserWidget(); + ~SchemaBrowserWidget() override; SchemaWidget *schemaWidget() const; private: SchemaWidget *m_schemaWidget; }; #endif // SCHEMABROWSERWIDGET_H diff --git a/addons/katesql/schemawidget.h b/addons/katesql/schemawidget.h index a550feaaf..8bf5b36a4 100644 --- a/addons/katesql/schemawidget.h +++ b/addons/katesql/schemawidget.h @@ -1,80 +1,80 @@ /* Copyright (C) 2010 Marco Mentasti 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 SCHEMAWIDGET_H #define SCHEMAWIDGET_H class SQLManager; class QMouseEvent; #include #include #include #include class SchemaWidget : public QTreeWidget { Q_OBJECT public: static const int TableType = QTreeWidgetItem::UserType + 1; static const int SystemTableType = QTreeWidgetItem::UserType + 2; static const int ViewType = QTreeWidgetItem::UserType + 3; static const int FieldType = QTreeWidgetItem::UserType + 4; static const int TablesFolderType = QTreeWidgetItem::UserType + 101; static const int SystemTablesFolderType = QTreeWidgetItem::UserType + 102; static const int ViewsFolderType = QTreeWidgetItem::UserType + 103; SchemaWidget(QWidget *parent, SQLManager *manager); - virtual ~SchemaWidget(); + ~SchemaWidget() override; void buildDatabase(QTreeWidgetItem * databaseItem); void buildTables(QTreeWidgetItem * tablesItem); void buildViews(QTreeWidgetItem * viewsItem); void buildFields(QTreeWidgetItem * tableItem); public Q_SLOTS: void buildTree(const QString &connection); void refresh(); void generateSelect(); void generateUpdate(); void generateInsert(); void generateDelete(); void generateStatement(QSqlDriver::StatementType type); private Q_SLOTS: void slotCustomContextMenuRequested(const QPoint &pos); void slotItemExpanded(QTreeWidgetItem *item); private: void deleteChildren(QTreeWidgetItem *item); - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; bool isConnectionValidAndOpen(); QString m_connectionName; QPoint m_dragStartPosition; bool m_tablesLoaded; bool m_viewsLoaded; SQLManager *m_manager; }; #endif // SCHEMAWIDGET_H diff --git a/addons/katesql/sqlmanager.h b/addons/katesql/sqlmanager.h index da46c31f3..a633c5259 100644 --- a/addons/katesql/sqlmanager.h +++ b/addons/katesql/sqlmanager.h @@ -1,71 +1,71 @@ /* Copyright (C) 2010 Marco Mentasti 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 SQLMANAGER_H #define SQLMANAGER_H class ConnectionModel; class KConfigGroup; #include "connection.h" #include #include class SQLManager : public QObject { Q_OBJECT public: SQLManager(QObject *parent = nullptr); - ~SQLManager(); + ~SQLManager() override; ConnectionModel *connectionModel(); void createConnection(const Connection &conn); bool testConnection(const Connection &conn, QSqlError &error); bool isValidAndOpen(const QString &connection); KWallet::Wallet * openWallet(); int storeCredentials(const Connection &conn); int readCredentials(const QString &name, QString &password); public Q_SLOTS: void removeConnection(const QString &name); void reopenConnection(const QString &name); void loadConnections(KConfigGroup *connectionsGroup); void saveConnections(KConfigGroup *connectionsGroup); void runQuery(const QString &text, const QString &connection ); protected: void saveConnection(KConfigGroup *connectionsGroup, const Connection &conn); Q_SIGNALS: void connectionCreated(const QString &name); void connectionRemoved(const QString &name); void connectionAboutToBeClosed(const QString &name); void queryActivated(QSqlQuery &query, const QString &connection); void error(const QString &message); void success(const QString &message); private: ConnectionModel *m_model; KWallet::Wallet *m_wallet; }; #endif // SQLMANAGER_H diff --git a/addons/katesql/textoutputwidget.h b/addons/katesql/textoutputwidget.h index 7d0a0886f..8001178d9 100644 --- a/addons/katesql/textoutputwidget.h +++ b/addons/katesql/textoutputwidget.h @@ -1,53 +1,53 @@ /* Copyright (C) 2010 Marco Mentasti 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 TEXTOUTPUTWIDGET_H #define TEXTOUTPUTWIDGET_H class QHBoxLayout; class QTextEdit; #include "connection.h" #include class TextOutputWidget : public QWidget { Q_OBJECT public: TextOutputWidget(QWidget *parent = nullptr); - ~TextOutputWidget(); + ~TextOutputWidget() override; public Q_SLOTS: void showErrorMessage(const QString &message); void showSuccessMessage(const QString &message); private: void writeMessage(const QString &msg); private: QHBoxLayout *m_layout; QTextEdit *m_output; QColor m_succesTextColor; QColor m_succesBackgroundColor; QColor m_errorTextColor; QColor m_errorBackgroundColor; }; #endif // TEXTOUTPUTWIDGET_H diff --git a/addons/konsole/kateconsole.h b/addons/konsole/kateconsole.h index 4c25d80a3..5253316c0 100644 --- a/addons/konsole/kateconsole.h +++ b/addons/konsole/kateconsole.h @@ -1,216 +1,216 @@ /* This file is part of the KDE project Copyright (C) 2001 Christoph Cullmann Copyright (C) 2002 Joseph Wenninger Copyright (C) 2002 Anders Lund 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 __KATE_CONSOLE_H__ #define __KATE_CONSOLE_H__ #include #include #include #include #include #include class QShowEvent; namespace KParts { class ReadOnlyPart; } class KateConsole; class KateKonsolePluginView; class KateKonsolePlugin: public KTextEditor::Plugin { Q_OBJECT friend class KateKonsolePluginView; public: explicit KateKonsolePlugin( QObject* parent = nullptr, const QList& = QList() ); - virtual ~KateKonsolePlugin(); + ~KateKonsolePlugin() override; - QObject *createView (KTextEditor::MainWindow *mainWindow) Q_DECL_OVERRIDE; + QObject *createView (KTextEditor::MainWindow *mainWindow) override; - int configPages() const Q_DECL_OVERRIDE { return 1; } - KTextEditor::ConfigPage *configPage (int number = 0, QWidget *parent = nullptr) Q_DECL_OVERRIDE; + int configPages() const override { return 1; } + KTextEditor::ConfigPage *configPage (int number = 0, QWidget *parent = nullptr) override; void readConfig(); QByteArray previousEditorEnv() {return m_previousEditorEnv;} private: QList mViews; QByteArray m_previousEditorEnv; }; class KateKonsolePluginView : public QObject { Q_OBJECT public: /** * Constructor. */ KateKonsolePluginView (KateKonsolePlugin* plugin, KTextEditor::MainWindow *mainWindow); /** * Virtual destructor. */ - ~KateKonsolePluginView (); + ~KateKonsolePluginView () override; void readConfig(); private: KateKonsolePlugin *m_plugin; KateConsole *m_console; }; /** * KateConsole * This class is used for the internal terminal emulator * It uses internally the konsole part, thx to konsole devs :) */ class KateConsole : public QWidget, public KXMLGUIClient { Q_OBJECT public: /** * construct us * @param mw main window * @param parent toolview */ KateConsole (KateKonsolePlugin* plugin, KTextEditor::MainWindow *mw, QWidget* parent); /** * destruct us */ - ~KateConsole (); + ~KateConsole () override; void readConfig(); /** * cd to dir * @param path given local directory */ void cd (const QString & path); /** * send given text to console * @param text commands for console */ void sendInput( const QString& text ); KTextEditor::MainWindow *mainWindow() { return m_mw; } public Q_SLOTS: /** * pipe current document to console */ void slotPipeToConsole (); /** * synchronize the konsole with the current document (cd to the directory) */ void slotSync(KTextEditor::View *view = nullptr); /** * When syncing is done by the user, also show the terminal if it is hidden */ void slotManualSync(); private Q_SLOTS: /** * the konsole exited ;) * handle that, hide the dock */ void slotDestroyed (); /** * construct console if needed */ void loadConsoleIfNeeded(); /** * set or clear focus as appropriate. */ void slotToggleFocus(); /** * Handle that shortcuts are not eaten by console */ void overrideShortcut (QKeyEvent *event, bool &override); protected: /** * the konsole get shown * @param ev show event */ - void showEvent(QShowEvent *ev) Q_DECL_OVERRIDE; + void showEvent(QShowEvent *ev) override; private: /** * console part */ KParts::ReadOnlyPart *m_part; /** * main window of this console */ KTextEditor::MainWindow *m_mw; /** * toolview for this console */ QWidget *m_toolView; KateKonsolePlugin *m_plugin; QString m_currentPath; }; class KateKonsoleConfigPage : public KTextEditor::ConfigPage { Q_OBJECT public: explicit KateKonsoleConfigPage( QWidget* parent = nullptr, KateKonsolePlugin *plugin = nullptr ); - virtual ~KateKonsoleConfigPage() + ~KateKonsoleConfigPage() override {} - QString name() const Q_DECL_OVERRIDE; - QString fullName() const Q_DECL_OVERRIDE; - QIcon icon() const Q_DECL_OVERRIDE; + QString name() const override; + QString fullName() const override; + QIcon icon() const override; - void apply() Q_DECL_OVERRIDE; - void reset() Q_DECL_OVERRIDE; - void defaults() Q_DECL_OVERRIDE + void apply() override; + void reset() override; + void defaults() override {} private: class QCheckBox *cbAutoSyncronize; class QCheckBox *cbSetEditor; KateKonsolePlugin *mPlugin; }; #endif // kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/addons/lumen/completion.h b/addons/lumen/completion.h index 694e626cd..68d7dde4a 100644 --- a/addons/lumen/completion.h +++ b/addons/lumen/completion.h @@ -1,50 +1,50 @@ /* * Copyright 2014-2015 David Herberth kde@dav1d.de * * 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 LUMEN_COMPLETION_H #define LUMEN_COMPLETION_H #include #include #include "dcd.h" using namespace KTextEditor; class LumenCompletionModel : public CodeCompletionModel , public KTextEditor::CodeCompletionModelControllerInterface { Q_OBJECT Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface) public: LumenCompletionModel(QObject* parent, DCD* dcd); - virtual ~LumenCompletionModel(); + ~LumenCompletionModel() override; - bool shouldStartCompletion(View* view, const QString& insertedText, bool userInsertion, const Cursor& position) Q_DECL_OVERRIDE; - void completionInvoked(View* view, const Range& range, InvocationType invocationType) Q_DECL_OVERRIDE; - void executeCompletionItem(View *view, const Range &word, const QModelIndex &index) const Q_DECL_OVERRIDE; - QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; + bool shouldStartCompletion(View* view, const QString& insertedText, bool userInsertion, const Cursor& position) override; + void completionInvoked(View* view, const Range& range, InvocationType invocationType) override; + void executeCompletionItem(View *view, const Range &word, const QModelIndex &index) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; private: DCD* m_dcd; DCDCompletion m_data; }; #endif diff --git a/addons/lumen/lumen.h b/addons/lumen/lumen.h index 6cce7e2ee..10b441127 100644 --- a/addons/lumen/lumen.h +++ b/addons/lumen/lumen.h @@ -1,86 +1,86 @@ /* * Copyright 2014-2015 David Herberth kde@dav1d.de * * 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 LUMEN_H #define LUMEN_H #include #include #include #include #include #include #include "dcd.h" #include "completion.h" using namespace KTextEditor; class LumenPlugin; class LumenHintProvider; class LumenPluginView: public QObject { Q_OBJECT public: LumenPluginView(LumenPlugin *plugin, KTextEditor::MainWindow *view); - virtual ~LumenPluginView(); + ~LumenPluginView() override; void registerCompletion(KTextEditor::View *view); void registerTextHints(KTextEditor::View *view); private Q_SLOTS: void urlChanged(KTextEditor::Document*); void viewCreated(KTextEditor::View *view); void viewDestroyed(QObject *view); void documentChanged(KTextEditor::Document *document); private: LumenPlugin* m_plugin; MainWindow* m_mainWin; LumenCompletionModel* m_model; QSet m_completionViews; bool m_registered; LumenHintProvider* m_hinter; }; class LumenHintProvider : public KTextEditor::TextHintProvider { public: explicit LumenHintProvider(LumenPlugin* plugin); - QString textHint(KTextEditor::View* view, const KTextEditor::Cursor& position) Q_DECL_OVERRIDE; + QString textHint(KTextEditor::View* view, const KTextEditor::Cursor& position) override; private: LumenPlugin *m_plugin; }; class LumenPlugin: public Plugin { Q_OBJECT public: explicit LumenPlugin(QObject *parent = nullptr, const QList & = QList()); - virtual ~LumenPlugin(); + ~LumenPlugin() override; DCD* dcd(); - QObject *createView(MainWindow *mainWindow) Q_DECL_OVERRIDE; + QObject *createView(MainWindow *mainWindow) override; private: DCD* m_dcd; }; #endif diff --git a/addons/openheader/plugin_kateopenheader.h b/addons/openheader/plugin_kateopenheader.h index 991fc53a0..29a030477 100644 --- a/addons/openheader/plugin_kateopenheader.h +++ b/addons/openheader/plugin_kateopenheader.h @@ -1,68 +1,68 @@ /* This file is part of the KDE project Copyright (C) 2001 Joseph Wenninger Copyright (C) 2009 Erlend Hamberg 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 PLUGIN_KATEOPENHEADER_H #define PLUGIN_KATEOPENHEADER_H #include #include #include #include #include #include #include class PluginKateOpenHeader : public KTextEditor::Plugin { Q_OBJECT public: explicit PluginKateOpenHeader( QObject* parent = nullptr, const QList& = QList() ); - virtual ~PluginKateOpenHeader(); + ~PluginKateOpenHeader() override; - QObject *createView (KTextEditor::MainWindow *mainWindow) Q_DECL_OVERRIDE; + QObject *createView (KTextEditor::MainWindow *mainWindow) override; public Q_SLOTS: void slotOpenHeader (); void tryOpen( const QUrl& url, const QStringList& extensions ); bool tryOpenInternal( const QUrl& url, const QStringList& extensions ); private: bool fileExists(const QUrl &url); void setFileName(QUrl *url,const QString &_txt); }; class PluginViewKateOpenHeader : public KTextEditor::Command , public KXMLGUIClient { Q_OBJECT public: PluginViewKateOpenHeader(PluginKateOpenHeader* plugin, KTextEditor::MainWindow *mainwindow); - virtual ~PluginViewKateOpenHeader(); + ~PluginViewKateOpenHeader() override; - bool exec (KTextEditor::View *view, const QString &cmd, QString &msg, const KTextEditor::Range &range = KTextEditor::Range::invalid()) Q_DECL_OVERRIDE; - bool help (KTextEditor::View *view, const QString &cmd, QString &msg) Q_DECL_OVERRIDE; + bool exec (KTextEditor::View *view, const QString &cmd, QString &msg, const KTextEditor::Range &range = KTextEditor::Range::invalid()) override; + bool help (KTextEditor::View *view, const QString &cmd, QString &msg) override; private: PluginKateOpenHeader* m_plugin; KTextEditor::MainWindow *m_mainWindow; }; #endif // PLUGIN_KATEOPENHEADER_H diff --git a/addons/project/kateproject.h b/addons/project/kateproject.h index 224e0c802..ed383bc94 100644 --- a/addons/project/kateproject.h +++ b/addons/project/kateproject.h @@ -1,302 +1,302 @@ /* This file is part of the Kate project. * * Copyright (C) 2010 Christoph Cullmann * * 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 KATE_PROJECT_H #define KATE_PROJECT_H #include #include #include #include #include #include "kateprojectindex.h" #include "kateprojectitem.h" /** * Shared pointer data types. * Used to pass pointers over queued connected slots */ typedef QSharedPointer KateProjectSharedQStandardItem; Q_DECLARE_METATYPE(KateProjectSharedQStandardItem) typedef QSharedPointer > KateProjectSharedQMapStringItem; Q_DECLARE_METATYPE(KateProjectSharedQMapStringItem) typedef QSharedPointer KateProjectSharedProjectIndex; Q_DECLARE_METATYPE(KateProjectSharedProjectIndex) namespace ThreadWeaver { class Queue; } /** * Class representing a project. * Holds project properties like name, groups, contained files, ... */ class KateProject : public QObject { Q_OBJECT public: /** * construct empty project */ KateProject(ThreadWeaver::Queue *weaver); /** * deconstruct project */ - ~KateProject(); + ~KateProject() override; /** * Load a project from project file * Only works once, afterwards use reload(). * @param fileName name of project file * @return success */ bool loadFromFile(const QString &fileName); bool loadFromData(const QVariantMap &globalProject, const QString &directory); /** * Try to reload a project. * If the reload fails, e.g. because the file is not readable or corrupt, nothing will happen! * @param force will enforce the worker to update files list and co even if the content of the file was not changed! * @return success */ bool reload(bool force = false); /** * Accessor to file name. * @return file name */ const QString &fileName() const { return m_fileName; } /** * Return the base directory of this project. * @return base directory of project, might not be the directory of the fileName! */ const QString &baseDir() const { return m_baseDir; } /** * Return the time when the project file has been modified last. * @return QFileInfo::lastModified() */ QDateTime fileLastModified() const { return m_fileLastModified; } /** * Accessor to project map containing the whole project info. * @return project info */ const QVariantMap &projectMap() const { return m_projectMap; } /** * Accessor to project name. * @return project name */ QString name() const { //MSVC doesn't support QStringLiteral here return m_projectMap[QLatin1String("name")].toString(); } /** * Accessor for the model. * @return model of this project */ QStandardItemModel *model() { return &m_model; } /** * Flat list of all files in the project * @return list of files in project */ QStringList files() { return m_file2Item ? m_file2Item->keys() : QStringList(); } /** * get item for file * @param file file to get item for * @return item for given file or 0 */ KateProjectItem *itemForFile(const QString &file) { return m_file2Item ? m_file2Item->value(file) : 0; } /** * Access to project index. * May be null. * Don't store this pointer, might change. * @return project index */ KateProjectIndex *projectIndex() { return m_projectIndex.data(); } /** * Computes a suitable file name for the given suffix. * If you e.g. want to store a "notes" file, you could pass "notes" and get * the full path to projectbasedir/.kateproject.notes * @param suffix suffix for the file * @return full path for project local file, on error => empty string */ QString projectLocalFileName(const QString &suffix) const; /** * Document with project local notes. * Will be stored in a projectLocalFile "notes.txt". * @return notes document */ QTextDocument *notesDocument(); /** * Save the notes document to "notes.txt" if any document around. */ void saveNotesDocument(); /** * Register a document for this project. * @param document document to register */ void registerDocument(KTextEditor::Document *document); /** * Unregister a document for this project. * @param document document to unregister */ void unregisterDocument(KTextEditor::Document *document); private Q_SLOTS: bool load(const QVariantMap &globalProject, bool force = false); /** * Used for worker to send back the results of project loading * @param topLevel new toplevel element for model * @param file2Item new file => item mapping */ void loadProjectDone(KateProjectSharedQStandardItem topLevel, KateProjectSharedQMapStringItem file2Item); /** * Used for worker to send back the results of index loading * @param projectIndex new project index */ void loadIndexDone(KateProjectSharedProjectIndex projectIndex); void slotModifiedChanged(KTextEditor::Document *); void slotModifiedOnDisk(KTextEditor::Document *document, bool isModified, KTextEditor::ModificationInterface::ModifiedOnDiskReason reason); Q_SIGNALS: /** * Emitted on project map changes. * This includes the name! */ void projectMapChanged(); /** * Emitted on model changes. * This includes the files list, itemForFile mapping! */ void modelChanged(); /** * Emitted when the index creation is finished. * This includes the ctags index. */ void indexChanged(); private: void registerUntrackedDocument(KTextEditor::Document *document); void unregisterUntrackedItem(const KateProjectItem *item); QVariantMap readProjectFile() const; private: /** * Last modification time of the project file */ QDateTime m_fileLastModified; /** * project file name */ QString m_fileName; /** * base directory of the project */ QString m_baseDir; /** * project name */ QString m_name; /** * variant map representing the project */ QVariantMap m_projectMap; /** * standard item model with content of this project */ QStandardItemModel m_model; /** * mapping files => items */ KateProjectSharedQMapStringItem m_file2Item; /** * project index, if any */ KateProjectSharedProjectIndex m_projectIndex; /** * notes buffer for project local notes */ QTextDocument *m_notesDocument; /** * Set of existing documents for this project. */ QMap m_documents; /** * Parent item for existing documents that are not in the project tree */ QStandardItem *m_untrackedDocumentsRoot; ThreadWeaver::Queue *m_weaver; /** * project configuration (read from file or injected) */ QVariantMap m_globalProject; }; #endif diff --git a/addons/project/kateprojectcompletion.h b/addons/project/kateprojectcompletion.h index 8e27d0ff5..a650aa351 100644 --- a/addons/project/kateprojectcompletion.h +++ b/addons/project/kateprojectcompletion.h @@ -1,99 +1,99 @@ /* This file is part of the Kate project. * * Copyright (C) 2010 Christoph Cullmann * Copyright (C) 2003 Anders Lund * * 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 KATE_PROJECT_COMPLETION_H #define KATE_PROJECT_COMPLETION_H #include #include #include #include /** * Project wide completion support. */ class KateProjectCompletion : public KTextEditor::CodeCompletionModel, public KTextEditor::CodeCompletionModelControllerInterface { Q_OBJECT Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface) public: /** * Construct project completion. * @param plugin our plugin */ KateProjectCompletion(class KateProjectPlugin *plugin); /** * Deconstruct project completion. */ - ~KateProjectCompletion(); + ~KateProjectCompletion() override; /** * This function is responsible to generating / updating the list of current * completions. The default implementation does nothing. * * When implementing this function, remember to call setRowCount() (or implement * rowCount()), and to generate the appropriate change notifications (for instance * by calling QAbstractItemModel::reset()). * @param view The view to generate completions for * @param range The range of text to generate completions for * */ - void completionInvoked(KTextEditor::View *view, const KTextEditor::Range &range, InvocationType invocationType) Q_DECL_OVERRIDE; + void completionInvoked(KTextEditor::View *view, const KTextEditor::Range &range, InvocationType invocationType) override; - bool shouldStartCompletion(KTextEditor::View *view, const QString &insertedText, bool userInsertion, const KTextEditor::Cursor &position) Q_DECL_OVERRIDE; - bool shouldAbortCompletion(KTextEditor::View *view, const KTextEditor::Range &range, const QString ¤tCompletion) Q_DECL_OVERRIDE; + bool shouldStartCompletion(KTextEditor::View *view, const QString &insertedText, bool userInsertion, const KTextEditor::Cursor &position) override; + bool shouldAbortCompletion(KTextEditor::View *view, const KTextEditor::Range &range, const QString ¤tCompletion) override; void saveMatches(KTextEditor::View *view, const KTextEditor::Range &range); - int rowCount(const QModelIndex &parent) const Q_DECL_OVERRIDE; + int rowCount(const QModelIndex &parent) const override; - QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE; - MatchReaction matchingItem(const QModelIndex &matched) Q_DECL_OVERRIDE; + QVariant data(const QModelIndex &index, int role) const override; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex &index) const override; + MatchReaction matchingItem(const QModelIndex &matched) override; - KTextEditor::Range completionRange(KTextEditor::View *view, const KTextEditor::Cursor &position) Q_DECL_OVERRIDE; + KTextEditor::Range completionRange(KTextEditor::View *view, const KTextEditor::Cursor &position) override; void allMatches(QStandardItemModel &model, KTextEditor::View *view, const KTextEditor::Range &range) const; private: /** * our plugin view */ KateProjectPlugin *m_plugin; /** * model with matching data */ QStandardItemModel m_matches; /** * automatic invocation? */ bool m_automatic; }; #endif diff --git a/addons/project/kateprojectconfigpage.h b/addons/project/kateprojectconfigpage.h index 34e3854b2..4d8521f4e 100644 --- a/addons/project/kateprojectconfigpage.h +++ b/addons/project/kateprojectconfigpage.h @@ -1,55 +1,55 @@ /* This file is part of the KDE project 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 KATE_PROJECT_CONFIGPAGE_H #define KATE_PROJECT_CONFIGPAGE_H #include class KateProjectPlugin; class QWidget; class QCheckBox; class KateProjectConfigPage : public KTextEditor::ConfigPage { Q_OBJECT public: explicit KateProjectConfigPage(QWidget *parent = nullptr, KateProjectPlugin *plugin = nullptr); - ~KateProjectConfigPage() {} + ~KateProjectConfigPage() override {} - QString name() const Q_DECL_OVERRIDE; - QString fullName() const Q_DECL_OVERRIDE; - QIcon icon() const Q_DECL_OVERRIDE; + QString name() const override; + QString fullName() const override; + QIcon icon() const override; public Q_SLOTS: - void apply() Q_DECL_OVERRIDE; - void defaults() Q_DECL_OVERRIDE; - void reset() Q_DECL_OVERRIDE; + void apply() override; + void defaults() override; + void reset() override; private Q_SLOTS: void slotMyChanged(); private: QCheckBox *m_cbAutoGit; QCheckBox *m_cbAutoSubversion; QCheckBox *m_cbAutoMercurial; KateProjectPlugin *m_plugin; bool m_changed; }; #endif /* KATE_PROJECT_CONFIGPAGE_H */ diff --git a/addons/project/kateprojectinfoview.h b/addons/project/kateprojectinfoview.h index e89a7e517..41af7c034 100644 --- a/addons/project/kateprojectinfoview.h +++ b/addons/project/kateprojectinfoview.h @@ -1,74 +1,74 @@ /* This file is part of the Kate project. * * Copyright (C) 2010 Christoph Cullmann * * 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 KATE_PROJECT_INFO_VIEW_H #define KATE_PROJECT_INFO_VIEW_H #include "kateproject.h" #include class KateProjectPluginView; /** * Class representing a view of a project. * A tree like view of project content. */ class KateProjectInfoView : public QTabWidget { Q_OBJECT public: /** * construct project info view for given project * @param pluginView our plugin view * @param project project this view is for */ KateProjectInfoView(KateProjectPluginView *pluginView, KateProject *project); /** * deconstruct info view */ - ~KateProjectInfoView(); + ~KateProjectInfoView() override; /** * our project. * @return project */ KateProject *project() const { return m_project; } - void showEvent(QShowEvent *) Q_DECL_OVERRIDE; + void showEvent(QShowEvent *) override; private: /** * our plugin view */ KateProjectPluginView *m_pluginView; /** * our project */ KateProject *m_project; }; #endif diff --git a/addons/project/kateprojectinfoviewcodeanalysis.h b/addons/project/kateprojectinfoviewcodeanalysis.h index 5d00fd6d1..e8356caa1 100644 --- a/addons/project/kateprojectinfoviewcodeanalysis.h +++ b/addons/project/kateprojectinfoviewcodeanalysis.h @@ -1,124 +1,124 @@ /* This file is part of the Kate project. * * Copyright (C) 2010 Christoph Cullmann * * 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 KATE_PROJECT_INFO_VIEW_CODE_ANALYSIS_H #define KATE_PROJECT_INFO_VIEW_CODE_ANALYSIS_H #include "kateproject.h" #include #include #include class KateProjectPluginView; class KMessageWidget; /** * View for Code Analysis. * cppcheck and perhaps later more... */ class KateProjectInfoViewCodeAnalysis : public QWidget { Q_OBJECT public: /** * construct project info view for given project * @param pluginView our plugin view * @param project project this view is for */ KateProjectInfoViewCodeAnalysis(KateProjectPluginView *pluginView, KateProject *project); /** * deconstruct info view */ - ~KateProjectInfoViewCodeAnalysis(); + ~KateProjectInfoViewCodeAnalysis() override; /** * our project. * @return project */ KateProject *project() const { return m_project; } private Q_SLOTS: /** * Called if start/stop button is clicked. */ void slotStartStopClicked(); /** * More checker output is available */ void slotReadyRead(); /** * item got clicked, do stuff, like open document * @param index model index of clicked item */ void slotClicked(const QModelIndex &index); /** * Analysis finished * @param exitCode analyser process exit code * @param exitStatus analyser process exit status */ void finished(int exitCode, QProcess::ExitStatus exitStatus); private: /** * our plugin view */ KateProjectPluginView *m_pluginView; /** * our project */ KateProject *m_project; /** * information widget showing a warning about missing ctags. */ KMessageWidget *m_messageWidget; /** * start/stop analysis button */ QPushButton *m_startStopAnalysis; /** * tree view for results */ QTreeView *m_treeView; /** * standard item model for results */ QStandardItemModel *m_model; /** * running analyzer process */ QProcess *m_analyzer; }; #endif diff --git a/addons/project/kateprojectinfoviewindex.h b/addons/project/kateprojectinfoviewindex.h index 985be9197..241ca789e 100644 --- a/addons/project/kateprojectinfoviewindex.h +++ b/addons/project/kateprojectinfoviewindex.h @@ -1,113 +1,113 @@ /* This file is part of the Kate project. * * Copyright (C) 2010 Christoph Cullmann * * 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 KATE_PROJECT_INFO_VIEW_INDEX_H #define KATE_PROJECT_INFO_VIEW_INDEX_H #include "kateproject.h" #include #include class KateProjectPluginView; class KMessageWidget; /** * Class representing a view of a project. * A tree like view of project content. */ class KateProjectInfoViewIndex : public QWidget { Q_OBJECT public: /** * construct project info view for given project * @param pluginView our plugin view * @param project project this view is for */ KateProjectInfoViewIndex(KateProjectPluginView *pluginView, KateProject *project); /** * deconstruct info view */ - ~KateProjectInfoViewIndex(); + ~KateProjectInfoViewIndex() override; /** * our project. * @return project */ KateProject *project() const { return m_project; } private Q_SLOTS: /** * Called if text in lineedit changes, then we need to search * @param text new text */ void slotTextChanged(const QString &text); /** * item got clicked, do stuff, like open document * @param index model index of clicked item */ void slotClicked(const QModelIndex &index); /** * called whenever the index of the project was updated. Here, * it's used to show a warning, if ctags is not installed. */ void indexAvailable(); private: /** * our plugin view */ KateProjectPluginView *m_pluginView; /** * our project */ KateProject *m_project; /** * information widget showing a warning about missing ctags. */ KMessageWidget *m_messageWidget; /** * line edit which allows to search index */ QLineEdit *m_lineEdit; /** * tree view for results */ QTreeView *m_treeView; /** * standard item model for results */ QStandardItemModel *m_model; }; #endif diff --git a/addons/project/kateprojectinfoviewnotes.h b/addons/project/kateprojectinfoviewnotes.h index 6c9a066bd..e532b82ea 100644 --- a/addons/project/kateprojectinfoviewnotes.h +++ b/addons/project/kateprojectinfoviewnotes.h @@ -1,77 +1,77 @@ /* This file is part of the Kate project. * * Copyright (C) 2012 Joseph Wenninger * * 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 KATE_PROJECT_INFO_VIEW_NOTES_H #define KATE_PROJECT_INFO_VIEW_NOTES_H #include "kateproject.h" #include class KateProjectPluginView; /** * Class representing a view of a project. * A tree like view of project content. */ class KateProjectInfoViewNotes : public QWidget { Q_OBJECT public: /** * construct project info view for given project * @param pluginView our plugin view * @param project project this view is for */ KateProjectInfoViewNotes(KateProjectPluginView *pluginView, KateProject *project); /** * deconstruct info view */ - ~KateProjectInfoViewNotes(); + ~KateProjectInfoViewNotes() override; /** * our project. * @return project */ KateProject *project() const { return m_project; } private: /** * our plugin view */ KateProjectPluginView *m_pluginView; /** * our project */ KateProject *m_project; /** * edit widget bound to notes document of project */ QPlainTextEdit *m_edit; }; #endif diff --git a/addons/project/kateprojectinfoviewterminal.h b/addons/project/kateprojectinfoviewterminal.h index 256964cbf..b7d065333 100644 --- a/addons/project/kateprojectinfoviewterminal.h +++ b/addons/project/kateprojectinfoviewterminal.h @@ -1,96 +1,96 @@ /* This file is part of the Kate project. * * Copyright (C) 2010 Christoph Cullmann * * 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 KATE_PROJECT_INFO_VIEW_TERMINAL_H #define KATE_PROJECT_INFO_VIEW_TERMINAL_H #include "kateproject.h" #include #include #include class KateProjectPluginView; /** * Class representing a view of a project. * A tree like view of project content. */ class KateProjectInfoViewTerminal : public QWidget { Q_OBJECT public: /** * construct project info view for given project * @param pluginView our plugin view * @param project project this view is for */ KateProjectInfoViewTerminal(KateProjectPluginView *pluginView, KateProject *project); /** * deconstruct info view */ - ~KateProjectInfoViewTerminal(); + ~KateProjectInfoViewTerminal() override; /** * our project. * @return project */ KateProject *project() const { return m_project; } private Q_SLOTS: /** * Construct a new terminal for this view */ void loadTerminal(); /** * Handle that shortcuts are not eaten by console */ void overrideShortcut(QKeyEvent *event, bool &override); private: /** * our plugin view */ KateProjectPluginView *m_pluginView; /** * our project */ KateProject *m_project; /** * our layout */ QVBoxLayout *m_layout; /** * konsole part */ KParts::ReadOnlyPart *m_konsolePart; }; #endif diff --git a/addons/project/kateprojectitem.h b/addons/project/kateprojectitem.h index 42b221d32..097989750 100644 --- a/addons/project/kateprojectitem.h +++ b/addons/project/kateprojectitem.h @@ -1,96 +1,96 @@ /* This file is part of the Kate project. * * Copyright (C) 2010 Christoph Cullmann * * 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 KATE_PROJECT_ITEM_H #define KATE_PROJECT_ITEM_H #include #include namespace KTextEditor { class Document; } /** * Class representing a item inside a project. * Items can be: projects, directories, files */ class KateProjectItem : public QStandardItem { public: /** * Possible Types */ enum Type { Project , Directory , File }; /** * construct new item with given text * @param type type for this item * @param text text for this item */ KateProjectItem(Type type, const QString &text); /** * deconstruct project */ - ~KateProjectItem(); + ~KateProjectItem() override; /** * Overwritten data methode for on-demand icon creation and co. * @param role role to get data for * @return data for role */ - QVariant data(int role = Qt::UserRole + 1) const Q_DECL_OVERRIDE; + QVariant data(int role = Qt::UserRole + 1) const override; public: void slotModifiedChanged(KTextEditor::Document *); void slotModifiedOnDisk(KTextEditor::Document *document, bool isModified, KTextEditor::ModificationInterface::ModifiedOnDiskReason reason); private: QIcon *icon() const; private: /** * type */ const Type m_type; /** * cached icon */ mutable QIcon *m_icon; /** * for document icons */ QString m_emblem; }; #endif diff --git a/addons/project/kateprojectplugin.h b/addons/project/kateprojectplugin.h index aa7c704b4..662e0ee50 100644 --- a/addons/project/kateprojectplugin.h +++ b/addons/project/kateprojectplugin.h @@ -1,179 +1,179 @@ /* This file is part of the Kate project. * * Copyright (C) 2010 Christoph Cullmann * * 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 _PLUGIN_KATE_PROJECT_H_ #define _PLUGIN_KATE_PROJECT_H_ #include #include #include #include #include #include #include "kateproject.h" #include "kateprojectcompletion.h" namespace ThreadWeaver { class Queue; } class KateProjectPlugin : public KTextEditor::Plugin { Q_OBJECT public: explicit KateProjectPlugin(QObject *parent = nullptr, const QList & = QList()); - virtual ~KateProjectPlugin(); + ~KateProjectPlugin() override; - QObject *createView(KTextEditor::MainWindow *mainWindow) Q_DECL_OVERRIDE; + QObject *createView(KTextEditor::MainWindow *mainWindow) override; - int configPages() const Q_DECL_OVERRIDE; - KTextEditor::ConfigPage *configPage (int number = 0, QWidget *parent = nullptr) Q_DECL_OVERRIDE; + int configPages() const override; + KTextEditor::ConfigPage *configPage (int number = 0, QWidget *parent = nullptr) override; /** * Create new project for given project filename. * Null pointer if no project can be opened. * File name will be canonicalized! * @param fileName canonicalized file name for the project * @return project or null if not openable */ KateProject *createProjectForFileName(const QString &fileName); /** * Search and open project for given dir, if possible. * Will search upwards for .kateproject file. * Will use internally projectForFileName if project file is found. * @param dir dir to search matching project for * @return project or null if not openable */ KateProject *projectForDir(QDir dir); /** * Search and open project that contains given url, if possible. * Will search upwards for .kateproject file, if the url is a local file. * Will use internally projectForDir. * @param url url to search matching project for * @return project or null if not openable */ KateProject *projectForUrl(const QUrl &url); /** * get list of all current open projects * @return list of all open projects */ QList projects() const { return m_projects; } /** * Get global code completion. * @return global completion object for KTextEditor::View */ KateProjectCompletion *completion() { return &m_completion; } /** * Map current open documents to projects. * @param document document we want to know which project it belongs to * @return project or 0 if none found for this document */ KateProject *projectForDocument(KTextEditor::Document *document) { return m_document2Project.value(document); } void setAutoRepository(bool onGit, bool onSubversion, bool onMercurial); bool autoGit() const; bool autoSubversion() const; bool autoMercurial() const; Q_SIGNALS: /** * Signal that a new project got created. * @param project new created project */ void projectCreated(KateProject *project); public Q_SLOTS: /** * New document got created, we need to update our connections * @param document new created document */ void slotDocumentCreated(KTextEditor::Document *document); /** * Document got destroyed. * @param document deleted document */ void slotDocumentDestroyed(QObject *document); /** * Url changed, to auto-load projects */ void slotDocumentUrlChanged(KTextEditor::Document *document); /** * did some project file change? * @param path name of directory that did change */ void slotDirectoryChanged(const QString &path); private: KateProject *createProjectForRepository(const QString &type, const QDir &dir); KateProject *detectGit(const QDir &dir); KateProject *detectSubversion(const QDir &dir); KateProject *detectMercurial(const QDir &dir); void readConfig(); void writeConfig(); private: /** * open plugins, maps project base directory => project */ QList m_projects; /** * filesystem watcher to keep track of all project files * and auto-reload */ QFileSystemWatcher m_fileWatcher; /** * Mapping document => project */ QHash m_document2Project; /** * Project completion */ KateProjectCompletion m_completion; bool m_autoGit : 1; bool m_autoSubversion : 1; bool m_autoMercurial : 1; ThreadWeaver::Queue *m_weaver; }; #endif diff --git a/addons/project/kateprojectpluginview.h b/addons/project/kateprojectpluginview.h index 244fd3a1f..696282493 100644 --- a/addons/project/kateprojectpluginview.h +++ b/addons/project/kateprojectpluginview.h @@ -1,256 +1,256 @@ /* This file is part of the Kate project. * * Copyright (C) 2010 Christoph Cullmann * * 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 _PLUGIN_KATE_PROJECTVIEW_H_ #define _PLUGIN_KATE_PROJECTVIEW_H_ #include "kateprojectplugin.h" #include "kateproject.h" #include "kateprojectview.h" #include "kateprojectinfoview.h" #include #include #include #include #include class QAction; class KateProjectPluginView : public QObject, public KXMLGUIClient { Q_OBJECT Q_PROPERTY(QString projectFileName READ projectFileName NOTIFY projectFileNameChanged) Q_PROPERTY(QString projectName READ projectName) Q_PROPERTY(QString projectBaseDir READ projectBaseDir) Q_PROPERTY(QVariantMap projectMap READ projectMap NOTIFY projectMapChanged) Q_PROPERTY(QStringList projectFiles READ projectFiles) Q_PROPERTY(QString allProjectsCommonBaseDir READ allProjectsCommonBaseDir) Q_PROPERTY(QStringList allProjectsFiles READ allProjectsFiles) public: KateProjectPluginView(KateProjectPlugin *plugin, KTextEditor::MainWindow *mainWindow); - ~KateProjectPluginView(); + ~KateProjectPluginView() override; /** * content of current active project, as variant map * @return empty map if no project active, else content of project JSON */ QVariantMap projectMap() const; /** * which project file is currently active? * @return empty string if none, else project file name */ QString projectFileName() const; /** * Returns the name of the project */ QString projectName() const; /** * Returns the base directory of the project */ QString projectBaseDir() const; /** * files for the current active project? * @return empty list if none, else project files as stringlist */ QStringList projectFiles() const; /** * Example: Two projects are loaded with baseDir1="/home/dev/project1" and * baseDir2="/home/dev/project2". Then "/home/dev/" is returned. * @see projectBaseDir(). * Used for the Search&Replace plugin for option "Search in all open projects". */ QString allProjectsCommonBaseDir() const; /** * @returns a flat list of files for all open projects (@see also projectFiles()) */ QStringList allProjectsFiles() const; /** * the main window we belong to * @return our main window */ KTextEditor::MainWindow *mainWindow() const { return m_mainWindow; } public Q_SLOTS: /** * Create views for given project. * Either gives existing ones or creates new one * @param project project we want view for * @return views (normal + info view) */ QPair viewForProject(KateProject *project); private Q_SLOTS: /** * New view got created, we need to update our connections * @param view new created view */ void slotViewCreated(KTextEditor::View *view); /** * View got destroyed. * @param view deleted view */ void slotViewDestroyed(QObject *view); /** * Activate the previous project. */ void slotProjectPrev(); /** * Activate the next project. */ void slotProjectNext(); /** * Reload current project, if any. * This will trigger a reload with force. */ void slotProjectReload(); /** * Lookup current word */ void slotProjectIndex(); Q_SIGNALS: /** * Emitted if projectFileName changed. */ void projectFileNameChanged(); /** * Emitted if projectMap changed. */ void projectMapChanged(); /** * Emitted when a ctags lookup in requested * @param word lookup word */ void projectLookupWord(const QString &word); private Q_SLOTS: /** * This slot is called whenever the active view changes in our main window. */ void slotViewChanged(); /** * Current project changed. * @param index index in toolbox */ void slotCurrentChanged(int index); /** * Url changed, to auto-load projects */ void slotDocumentUrlChanged(KTextEditor::Document *document); /** * Show context menu */ void slotContextMenuAboutToShow(); private: /** * find current selected or under cursor word */ QString currentWord() const; private: /** * our plugin */ KateProjectPlugin *m_plugin; /** * the main window we belong to */ KTextEditor::MainWindow *m_mainWindow; /** * our projects toolview */ QWidget *m_toolView; /** * our projects info toolview */ QWidget *m_toolInfoView; /** * combo box with all loaded projects inside */ QComboBox *m_projectsCombo; /** * Reload button */ QToolButton *m_reloadButton; /** * stacked widget will all currently created project views */ QStackedWidget *m_stackedProjectViews; /** * stacked widget will all currently created project info views */ QStackedWidget *m_stackedProjectInfoViews; /** * project => view */ QMap > m_project2View; /** * remember current active view text editor view * might be 0 */ QPointer m_activeTextEditorView; /** * remember for which text views we might need to cleanup stuff */ QSet m_textViews; /** * lookup action */ QAction *m_lookupAction; }; #endif diff --git a/addons/project/kateprojectview.h b/addons/project/kateprojectview.h index 1b32e019f..44dc3ed4d 100644 --- a/addons/project/kateprojectview.h +++ b/addons/project/kateprojectview.h @@ -1,100 +1,100 @@ /* This file is part of the Kate project. * * Copyright (C) 2010 Christoph Cullmann * * 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 KATE_PROJECT_VIEW_H #define KATE_PROJECT_VIEW_H #include "kateproject.h" #include "kateprojectviewtree.h" class KLineEdit; class KateProjectPluginView; /** * Class representing a view of a project. * A tree like view of project content. */ class KateProjectView : public QWidget { Q_OBJECT public: /** * construct project view for given project * @param pluginView our plugin view * @param project project this view is for */ KateProjectView(KateProjectPluginView *pluginView, KateProject *project); /** * deconstruct project */ - ~KateProjectView(); + ~KateProjectView() override; /** * our project. * @return project */ KateProject *project() const { return m_project; } /** * Select given file in the view. * @param file select this file in the view, will be shown if invisible */ void selectFile(const QString &file); /** * Open the selected document, if any. */ void openSelectedDocument(); private Q_SLOTS: /** * React on filter change * @param filterText new filter text */ void filterTextChanged(QString filterText); private: /** * our plugin view */ KateProjectPluginView *m_pluginView; /** * our project */ KateProject *m_project; /** * our tree view */ KateProjectViewTree *m_treeView; /** * filter */ KLineEdit *m_filter; }; #endif diff --git a/addons/project/kateprojectviewtree.h b/addons/project/kateprojectviewtree.h index aafdeef66..460d1a0a2 100644 --- a/addons/project/kateprojectviewtree.h +++ b/addons/project/kateprojectviewtree.h @@ -1,102 +1,102 @@ /* This file is part of the Kate project. * * Copyright (C) 2010 Christoph Cullmann * * 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 KATE_PROJECT_VIEW_TREE_H #define KATE_PROJECT_VIEW_TREE_H #include "kateproject.h" #include class KateProjectPluginView; /** * A tree like view of project content. */ class KateProjectViewTree : public QTreeView { Q_OBJECT public: /** * construct project view for given project * @param pluginView our plugin view * @param project project this view is for */ KateProjectViewTree(KateProjectPluginView *pluginView, KateProject *project); /** * deconstruct project */ - ~KateProjectViewTree(); + ~KateProjectViewTree() override; /** * our project. * @return project */ KateProject *project() const { return m_project; } /** * Select given file in the view. * @param file select this file in the view, will be shown if invisible */ void selectFile(const QString &file); /** * Open the selected document, if any. */ void openSelectedDocument(); private Q_SLOTS: /** * item got clicked, do stuff, like open document * @param index model index of clicked item */ void slotClicked(const QModelIndex &index); /** * Triggered on model changes. * This includes the files list, itemForFile mapping! */ void slotModelChanged(); protected: /** * Create matching context menu. * @param event context menu event */ - void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE; + void contextMenuEvent(QContextMenuEvent *event) override; private: /** * our plugin view */ KateProjectPluginView *m_pluginView; /** * our project */ KateProject *m_project; }; #endif diff --git a/addons/project/kateprojectworker.h b/addons/project/kateprojectworker.h index 242b285b6..13ecf95e6 100644 --- a/addons/project/kateprojectworker.h +++ b/addons/project/kateprojectworker.h @@ -1,102 +1,102 @@ /* This file is part of the Kate project. * * Copyright (C) 2010 Christoph Cullmann * * 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 KATE_PROJECT_WORKER_H #define KATE_PROJECT_WORKER_H #include "kateprojectitem.h" #include "kateproject.h" #include #include #include class QDir; /** * Class representing a project background worker. * This worker will build up the model for the project on load and do other stuff in the background. */ class KateProjectWorker : public QObject, public ThreadWeaver::Job { Q_OBJECT public: /** * Type for QueuedConnection */ typedef QMap MapString2Item; explicit KateProjectWorker(const QString &baseDir, const QVariantMap &projectMap); - void run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread *thread) Q_DECL_OVERRIDE; + void run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread *thread) override; Q_SIGNALS: void loadDone(KateProjectSharedQStandardItem topLevel, KateProjectSharedQMapStringItem file2Item); void loadIndexDone(KateProjectSharedProjectIndex index); private: /** * Load one project inside the project tree. * Fill data from JSON storage to model and recurse to sub-projects. * @param parent parent standard item in the model * @param project variant map for this group * @param file2Item mapping file => item, will be filled */ void loadProject(QStandardItem *parent, const QVariantMap &project, QMap *file2Item); /** * Load one files entry in the current parent item. * @param parent parent standard item in the model * @param filesEntry one files entry specification to load * @param file2Item mapping file => item, will be filled */ void loadFilesEntry(QStandardItem *parent, const QVariantMap &filesEntry, QMap *file2Item); /** * Load index for whole project. * @param files list of all project files to index */ void loadIndex(const QStringList &files); QStringList findFiles(const QDir &dir, const QVariantMap &filesEntry); QStringList filesFromGit(const QDir &dir, bool recursive); QStringList filesFromMercurial(const QDir &dir, bool recursive); QStringList filesFromSubversion(const QDir &dir, bool recursive); QStringList filesFromDarcs(const QDir &dir, bool recursive); QStringList filesFromDirectory(const QDir &dir, bool recursive, const QStringList &filters); private: /** * our project, only as QObject, we only send messages back and forth! */ QObject *m_project; /** * project base directory name */ QString m_baseDir; QVariantMap m_projectMap; }; #endif diff --git a/addons/replicode/replicodeconfig.h b/addons/replicode/replicodeconfig.h index 999e55a14..1ea3194f9 100644 --- a/addons/replicode/replicodeconfig.h +++ b/addons/replicode/replicodeconfig.h @@ -1,47 +1,47 @@ /* This file is part of the KDE project Copyright (C) 2014 Martin Sandsmark 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 REPLICODECONFIG_H #define REPLICODECONFIG_H #include #include class Ui_tabWidget; class ReplicodeSettings; class ReplicodeConfig : public QTabWidget { Q_OBJECT public: explicit ReplicodeConfig(QWidget *parent = nullptr); - virtual ~ReplicodeConfig(); + ~ReplicodeConfig() override; public Q_SLOTS: void reset(); void save(); void load(); ReplicodeSettings *settingsObject() { save(); return m_settings; } private: Ui_tabWidget *m_ui; ReplicodeSettings *m_settings; }; #endif//REPLICODECONFIG_H diff --git a/addons/replicode/replicodeconfigpage.h b/addons/replicode/replicodeconfigpage.h index 2d9d5706b..5954b9245 100644 --- a/addons/replicode/replicodeconfigpage.h +++ b/addons/replicode/replicodeconfigpage.h @@ -1,46 +1,46 @@ /* This file is part of the KDE project Copyright (C) 2014 Martin Sandsmark 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 REPLICODEPLUGINCONFIGPAGE_H #define REPLICODEPLUGINCONFIGPAGE_H #include class KUrlRequester; class ReplicodeConfig; class ReplicodeConfigPage : public KTextEditor::ConfigPage { Q_OBJECT public: ReplicodeConfigPage(QWidget *parent = nullptr); - QString name() const Q_DECL_OVERRIDE; - QString fullName() const Q_DECL_OVERRIDE; + QString name() const override; + QString fullName() const override; public Q_SLOTS: - void apply() Q_DECL_OVERRIDE; - void reset() Q_DECL_OVERRIDE; - void defaults() Q_DECL_OVERRIDE; + void apply() override; + void reset() override; + void defaults() override; private: KUrlRequester *m_requester; ReplicodeConfig *m_config; }; #endif//REPLICODEPLUGINCONFIGPAGE_H diff --git a/addons/replicode/replicodeplugin.h b/addons/replicode/replicodeplugin.h index 986818ad8..9f330cb1f 100644 --- a/addons/replicode/replicodeplugin.h +++ b/addons/replicode/replicodeplugin.h @@ -1,45 +1,45 @@ /* This file is part of the KDE project Copyright (C) 2014 Martin Sandsmark 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 REPLICODEPLUGIN_H #define REPLICODEPLUGIN_H #include #include #include "replicodeview.h" class ReplicodePlugin : public KTextEditor::Plugin { Q_OBJECT public: // Constructor explicit ReplicodePlugin(QObject *parent = nullptr, const QList &args = QList()); // Destructor - virtual ~ReplicodePlugin(); + ~ReplicodePlugin() override; - QObject *createView(KTextEditor::MainWindow *mainWindow) Q_DECL_OVERRIDE { + QObject *createView(KTextEditor::MainWindow *mainWindow) override { return new ReplicodeView(this, mainWindow); } // Config interface - int configPages () const Q_DECL_OVERRIDE { return 1; } - KTextEditor::ConfigPage *configPage (int number = 0, QWidget *parent = nullptr) Q_DECL_OVERRIDE; + int configPages () const override { return 1; } + KTextEditor::ConfigPage *configPage (int number = 0, QWidget *parent = nullptr) override; }; #endif diff --git a/addons/replicode/replicodeview.h b/addons/replicode/replicodeview.h index 279ab81ab..75930e1b4 100644 --- a/addons/replicode/replicodeview.h +++ b/addons/replicode/replicodeview.h @@ -1,72 +1,72 @@ /* This file is part of the KDE project Copyright (C) 2014 Martin Sandsmark 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 REPLICODEVIEW_H #define REPLICODEVIEW_H #include #include #include #include class QListWidgetItem; class QListWidget; class QTemporaryFile; class QProcess; class QListWidget; class QPushButton; class QAction; class ReplicodeConfig; class ReplicodeView : public QObject, public KXMLGUIClient, public KTextEditor::SessionConfigInterface { Q_OBJECT Q_INTERFACES(KTextEditor::SessionConfigInterface) public: explicit ReplicodeView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mainWindow); - ~ReplicodeView(); - void readSessionConfig(const KConfigGroup&) Q_DECL_OVERRIDE {} - void writeSessionConfig(KConfigGroup&) Q_DECL_OVERRIDE {} + ~ReplicodeView() override; + void readSessionConfig(const KConfigGroup&) override {} + void writeSessionConfig(KConfigGroup&) override {} private Q_SLOTS: void runReplicode(); void stopReplicode(); void replicodeFinished(); void gotStderr(); void gotStdout(); void runErrored(QProcess::ProcessError); void outputClicked(QListWidgetItem *item); void viewChanged(); private: KTextEditor::MainWindow *m_mainWindow; QProcess *m_executor; QListWidget *m_replicodeOutput; QWidget *m_toolview; QWidget *m_configSidebar; QPushButton *m_runButton; QPushButton *m_stopButton; QAction *m_runAction; QAction *m_stopAction; ReplicodeConfig *m_configView; bool m_completed; }; #endif diff --git a/addons/rustcompletion/kterustcompletion.h b/addons/rustcompletion/kterustcompletion.h index dd1edb89f..d75a5ba11 100644 --- a/addons/rustcompletion/kterustcompletion.h +++ b/addons/rustcompletion/kterustcompletion.h @@ -1,81 +1,81 @@ /*************************************************************************** * Copyright (C) 2015 by Eike Hein * * * * 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 KTERUSTCOMPLETION_H #define KTERUSTCOMPLETION_H #include #include #include #include class KTERustCompletionPlugin; namespace KTextEditor { class Document; class View; } struct CompletionMatch { CompletionMatch() : type(KTextEditor::CodeCompletionModel::NoProperty), depth(0), line(-1), col(-1) {} QString text; QIcon icon; KTextEditor::CodeCompletionModel::CompletionProperty type; int depth; QUrl url; int line; int col; }; class KTERustCompletion : public KTextEditor::CodeCompletionModel, public KTextEditor::CodeCompletionModelControllerInterface { Q_OBJECT Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface) public: KTERustCompletion(KTERustCompletionPlugin *plugin); - ~KTERustCompletion(); + ~KTERustCompletion() override; enum MatchAction { Complete = 0, FindDefinition }; - bool shouldStartCompletion(KTextEditor::View *view, const QString &insertedText, bool userInsertion, const KTextEditor::Cursor &position) Q_DECL_OVERRIDE; + bool shouldStartCompletion(KTextEditor::View *view, const QString &insertedText, bool userInsertion, const KTextEditor::Cursor &position) override; - void completionInvoked(KTextEditor::View *view, const KTextEditor::Range &range, InvocationType invocationType) Q_DECL_OVERRIDE; + void completionInvoked(KTextEditor::View *view, const KTextEditor::Range &range, InvocationType invocationType) override; - void aborted(KTextEditor::View *view) Q_DECL_OVERRIDE; + void aborted(KTextEditor::View *view) override; - QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; + QVariant data(const QModelIndex &index, int role) const override; QList getMatches(const KTextEditor::Document *document, MatchAction action, const KTextEditor::Cursor &position); private: static void addType(CompletionMatch &match, const QString &type); QList m_matches; KTERustCompletionPlugin *m_plugin; }; #endif diff --git a/addons/rustcompletion/kterustcompletionconfigpage.h b/addons/rustcompletion/kterustcompletionconfigpage.h index c246b9d6f..afc79a0c4 100644 --- a/addons/rustcompletion/kterustcompletionconfigpage.h +++ b/addons/rustcompletion/kterustcompletionconfigpage.h @@ -1,60 +1,60 @@ /*************************************************************************** * Copyright (C) 2015 by Eike Hein * * * * 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 KTERUSTCOMPLETIONCONFIGPAGE_H #define KTERUSTCOMPLETIONCONFIGPAGE_H #include class KTERustCompletionPlugin; class QLineEdit; class KUrlRequester; class KTERustCompletionConfigPage : public KTextEditor::ConfigPage { Q_OBJECT public: explicit KTERustCompletionConfigPage(QWidget *parent = nullptr, KTERustCompletionPlugin *plugin = nullptr); - ~KTERustCompletionConfigPage() {}; + ~KTERustCompletionConfigPage() override {}; - QString name() const Q_DECL_OVERRIDE; - QString fullName() const Q_DECL_OVERRIDE; - QIcon icon() const Q_DECL_OVERRIDE; + QString name() const override; + QString fullName() const override; + QIcon icon() const override; public Q_SLOTS: - void apply() Q_DECL_OVERRIDE; - void defaults() Q_DECL_OVERRIDE; - void reset() Q_DECL_OVERRIDE; + void apply() override; + void defaults() override; + void reset() override; private Q_SLOTS: void changedInternal(); private: QLineEdit *m_racerCmd; KUrlRequester *m_rustSrcPath; bool m_changed; KTERustCompletionPlugin *m_plugin; }; #endif diff --git a/addons/rustcompletion/kterustcompletionplugin.h b/addons/rustcompletion/kterustcompletionplugin.h index ffc7c63a2..7ca09a0f0 100644 --- a/addons/rustcompletion/kterustcompletionplugin.h +++ b/addons/rustcompletion/kterustcompletionplugin.h @@ -1,71 +1,71 @@ /*************************************************************************** * Copyright (C) 2015 by Eike Hein * * * * 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 KTERUSTCOMPLETIONPLUGIN_H #define KTERUSTCOMPLETIONPLUGIN_H #include "kterustcompletion.h" #include #include #include class KDirWatch; class KTERustCompletionPlugin : public KTextEditor::Plugin { Q_OBJECT public: explicit KTERustCompletionPlugin(QObject *parent = nullptr, const QList & = QList()); - virtual ~KTERustCompletionPlugin(); + ~KTERustCompletionPlugin() override; - QObject *createView(KTextEditor::MainWindow *mainWindow) Q_DECL_OVERRIDE; + QObject *createView(KTextEditor::MainWindow *mainWindow) override; - int configPages() const Q_DECL_OVERRIDE; - KTextEditor::ConfigPage *configPage(int number = 0, QWidget *parent = nullptr) Q_DECL_OVERRIDE; + int configPages() const override; + KTextEditor::ConfigPage *configPage(int number = 0, QWidget *parent = nullptr) override; KTERustCompletion *completion(); QString racerCmd() const; void setRacerCmd(const QString &cmd); QUrl rustSrcPath() const; void setRustSrcPath(const QUrl &path); bool configOk() const; private Q_SLOTS: void updateConfigOk(); private: void readConfig(); void writeConfig(); KTERustCompletion m_completion; QString m_racerCmd; QUrl m_rustSrcPath; KDirWatch *m_rustSrcWatch; bool m_configOk; }; #endif diff --git a/addons/rustcompletion/kterustcompletionpluginview.h b/addons/rustcompletion/kterustcompletionpluginview.h index c7d5257a9..3ac5572c5 100644 --- a/addons/rustcompletion/kterustcompletionpluginview.h +++ b/addons/rustcompletion/kterustcompletionpluginview.h @@ -1,62 +1,62 @@ /*************************************************************************** * Copyright (C) 2015 by Eike Hein * * * * 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 KTERUSTCOMPLETIONPLUGINVIEW_H #define KTERUSTCOMPLETIONPLUGINVIEW_H #include #include #include class KTERustCompletionPlugin; namespace KTextEditor { class Document; class MainWindow; class View; } class KTERustCompletionPluginView : public QObject, public KXMLGUIClient { Q_OBJECT public: KTERustCompletionPluginView(KTERustCompletionPlugin *plugin, KTextEditor::MainWindow *mainWindow); - ~KTERustCompletionPluginView(); + ~KTERustCompletionPluginView() override; private Q_SLOTS: void goToDefinition(); void viewChanged(); void viewCreated(KTextEditor::View *view); void viewDestroyed(QObject *view); void documentChanged(KTextEditor::Document *document); private: void registerCompletion(KTextEditor::View *view); static bool isRustView(const KTextEditor::View *view); KTERustCompletionPlugin *m_plugin; KTextEditor::MainWindow *m_mainWindow; QSet m_completionViews; }; #endif diff --git a/addons/search/FolderFilesList.h b/addons/search/FolderFilesList.h index 2e5f339db..7734cf255 100644 --- a/addons/search/FolderFilesList.h +++ b/addons/search/FolderFilesList.h @@ -1,75 +1,75 @@ /* Kate search plugin * * Copyright (C) 2013 by Kåre Särs * * 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 in a file called COPYING; if not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ #ifndef FolderFilesList_h #define FolderFilesList_h #include #include #include #include #include #include class FolderFilesList: public QThread { Q_OBJECT public: FolderFilesList(QObject *parent = nullptr); - ~FolderFilesList(); + ~FolderFilesList() override; - void run() Q_DECL_OVERRIDE; + void run() override; void generateList(const QString &folder, bool recursive, bool hidden, bool symlinks, bool binary, const QString &types, const QString &excludes); QStringList fileList(); public Q_SLOTS: void cancelSearch(); Q_SIGNALS: void searching(const QString &path); private: void checkNextItem(const QFileInfo &item); private: QString m_folder; QStringList m_files; bool m_cancelSearch; bool m_recursive; bool m_hidden; bool m_symlinks; bool m_binary; QStringList m_types; QVector m_excludeList; QTime m_time; }; #endif diff --git a/addons/search/SearchDiskFiles.h b/addons/search/SearchDiskFiles.h index 04a09862f..529804eb5 100644 --- a/addons/search/SearchDiskFiles.h +++ b/addons/search/SearchDiskFiles.h @@ -1,68 +1,68 @@ /* Kate search plugin * * Copyright (C) 2011-2013 by Kåre Särs * * 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 in a file called COPYING; if not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ #ifndef SearchDiskFiles_h #define SearchDiskFiles_h #include #include #include #include #include #include #include class SearchDiskFiles: public QThread { Q_OBJECT public: SearchDiskFiles(QObject *parent = nullptr); - ~SearchDiskFiles(); + ~SearchDiskFiles() override; void startSearch(const QStringList &iles, const QRegularExpression ®exp); - void run() Q_DECL_OVERRIDE; + void run() override; bool searching(); private: void searchSingleLineRegExp(const QString &fileName); void searchMultiLineRegExp(const QString &fileName); public Q_SLOTS: void cancelSearch(); Q_SIGNALS: void matchFound(const QString &url, const QString &docName, int line, int column, const QString &lineContent, int matchLen); void searchDone(); void searching(const QString &file); private: QRegularExpression m_regExp; QStringList m_files; bool m_cancelSearch; int m_matchCount; QTime m_statusTime; }; #endif diff --git a/addons/search/htmldelegate.h b/addons/search/htmldelegate.h index 60b1e47d2..5eefcdaee 100644 --- a/addons/search/htmldelegate.h +++ b/addons/search/htmldelegate.h @@ -1,37 +1,37 @@ /*************************************************************************** * This file is part of Kate search plugin * * Copyright 2011 Kåre Särs * * * * 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 HTML_DELEGATE_H #define HTML_DELEGATE_H #include class SPHtmlDelegate : public QStyledItemDelegate { public: explicit SPHtmlDelegate(QObject* parent); - virtual ~SPHtmlDelegate(); + ~SPHtmlDelegate() override; - void paint(QPainter*, const QStyleOptionViewItem&, const QModelIndex&) const Q_DECL_OVERRIDE; - QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const Q_DECL_OVERRIDE; + void paint(QPainter*, const QStyleOptionViewItem&, const QModelIndex&) const override; + QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; }; #endif diff --git a/addons/search/plugin_search.cpp b/addons/search/plugin_search.cpp index 6f6cfdf72..2fba6d673 100644 --- a/addons/search/plugin_search.cpp +++ b/addons/search/plugin_search.cpp @@ -1,2173 +1,2173 @@ /* Kate search plugin * * Copyright (C) 2011-2013 by Kåre Särs * * 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 in a file called COPYING; if not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ #include "plugin_search.h" #include "htmldelegate.h" #include #include #include #include #include #include #include #include #include "kacceleratormanager.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static QUrl localFileDirUp (const QUrl &url) { if (!url.isLocalFile()) return url; // else go up return QUrl::fromLocalFile (QFileInfo (url.toLocalFile()).dir().absolutePath()); } static QAction *menuEntry(QMenu *menu, const QString &before, const QString &after, const QString &desc, QString menuBefore = QString(), QString menuAfter = QString()); static QAction *menuEntry(QMenu *menu, const QString &before, const QString &after, const QString &desc, QString menuBefore, QString menuAfter) { if (menuBefore.isEmpty()) menuBefore = before; if (menuAfter.isEmpty()) menuAfter = after; QAction *const action = menu->addAction(menuBefore + menuAfter + QLatin1Char('\t') + desc); if (!action) return nullptr; action->setData(QString(before + QLatin1Char(' ') + after)); return action; } class TreeWidgetItem : public QTreeWidgetItem { public: TreeWidgetItem(QTreeWidget* parent):QTreeWidgetItem(parent){} TreeWidgetItem(QTreeWidget* parent, const QStringList &list):QTreeWidgetItem(parent, list){} TreeWidgetItem(QTreeWidgetItem* parent, const QStringList &list):QTreeWidgetItem(parent, list){} private: - bool operator<(const QTreeWidgetItem &other) const Q_DECL_OVERRIDE { + bool operator<(const QTreeWidgetItem &other) const override { if (childCount() == 0) { int line = data(0, ReplaceMatches::LineRole).toInt(); int column = data(0, ReplaceMatches::ColumnRole).toInt(); int oLine = other.data(0, ReplaceMatches::LineRole).toInt(); int oColumn = other.data(0, ReplaceMatches::ColumnRole).toInt(); if (line < oLine) { return true; } if ((line == oLine) && (column < oColumn)) { return true; } return false; } int sepCount = data(0, ReplaceMatches::FileUrlRole).toString().count(QDir::separator()); int oSepCount = other.data(0, ReplaceMatches::FileUrlRole).toString().count(QDir::separator()); if (sepCount < oSepCount) return true; if (sepCount > oSepCount) return false; return data(0, ReplaceMatches::FileUrlRole).toString().toLower() < other.data(0, ReplaceMatches::FileUrlRole).toString().toLower(); } }; Results::Results(QWidget *parent): QWidget(parent), matches(0), useRegExp(false), searchPlaceIndex(0) { setupUi(this); tree->setItemDelegate(new SPHtmlDelegate(tree)); } K_PLUGIN_FACTORY_WITH_JSON (KatePluginSearchFactory, "katesearch.json", registerPlugin();) KatePluginSearch::KatePluginSearch(QObject* parent, const QList&) : KTextEditor::Plugin (parent), m_searchCommand(nullptr) { m_searchCommand = new KateSearchCommand(this); } KatePluginSearch::~KatePluginSearch() { delete m_searchCommand; } QObject *KatePluginSearch::createView(KTextEditor::MainWindow *mainWindow) { KatePluginSearchView *view = new KatePluginSearchView(this, mainWindow, KTextEditor::Editor::instance()->application()); connect(m_searchCommand, SIGNAL(setSearchPlace(int)), view, SLOT(setSearchPlace(int))); connect(m_searchCommand, SIGNAL(setCurrentFolder()), view, SLOT(setCurrentFolder())); connect(m_searchCommand, SIGNAL(setSearchString(QString)), view, SLOT(setSearchString(QString))); connect(m_searchCommand, SIGNAL(startSearch()), view, SLOT(startSearch())); connect(m_searchCommand, SIGNAL(newTab()), view, SLOT(addTab())); return view; } bool ContainerWidget::focusNextPrevChild (bool next) { QWidget* fw = focusWidget(); bool found = false; emit nextFocus(fw, &found, next); if (found) { return true; } return QWidget::focusNextPrevChild(next); } void KatePluginSearchView::nextFocus(QWidget *currentWidget, bool *found, bool next) { *found = false; if (!currentWidget) { return; } // we use the object names here because there can be multiple replaceButtons (on multiple result tabs) if (next) { if (currentWidget->objectName() == QStringLiteral("tree") || currentWidget == m_ui.binaryCheckBox) { m_ui.newTabButton->setFocus(); *found = true; return; } if (currentWidget == m_ui.displayOptions) { if (m_ui.displayOptions->isChecked()) { m_ui.folderRequester->setFocus(); *found = true; return; } else { Results *res = qobject_cast(m_ui.resultTabWidget->currentWidget()); if (!res) { return; } res->tree->setFocus(); *found = true; return; } } } else { if (currentWidget == m_ui.newTabButton) { if (m_ui.displayOptions->isChecked()) { m_ui.binaryCheckBox->setFocus(); } else { Results *res = qobject_cast(m_ui.resultTabWidget->currentWidget()); if (!res) { return; } res->tree->setFocus(); } *found = true; return; } else { if (currentWidget->objectName() == QStringLiteral("tree")) { m_ui.displayOptions->setFocus(); *found = true; return; } } } } KatePluginSearchView::KatePluginSearchView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mainWin, KTextEditor::Application* application) : QObject (mainWin), m_kateApp(application), m_curResults(nullptr), m_searchJustOpened(false), m_switchToProjectModeWhenAvailable(false), m_searchDiskFilesDone(true), m_searchOpenFilesDone(true), m_projectPluginView(nullptr), m_mainWindow (mainWin) { KXMLGUIClient::setComponentName (QStringLiteral("katesearch"), i18n ("Kate Search & Replace")); setXMLFile( QStringLiteral("ui.rc") ); m_toolView = mainWin->createToolView (plugin, QStringLiteral("kate_plugin_katesearch"), KTextEditor::MainWindow::Bottom, QIcon::fromTheme(QStringLiteral("edit-find")), i18n("Search and Replace")); ContainerWidget *container = new ContainerWidget(m_toolView); m_ui.setupUi(container); container->setFocusProxy(m_ui.searchCombo); connect(container, SIGNAL(nextFocus(QWidget*,bool*,bool)), this, SLOT(nextFocus(QWidget*,bool*,bool))); QAction *a = actionCollection()->addAction(QStringLiteral("search_in_files")); actionCollection()->setDefaultShortcut(a, QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_F)); a->setText(i18n("Search in Files")); connect(a, SIGNAL(triggered(bool)), this, SLOT(openSearchView())); a = actionCollection()->addAction(QStringLiteral("search_in_files_new_tab")); a->setText(i18n("Search in Files (in new tab)")); // first add tab, then open search view, since open search view switches to show the search options connect(a, SIGNAL(triggered(bool)), this, SLOT(addTab())); connect(a, SIGNAL(triggered(bool)), this, SLOT(openSearchView())); a = actionCollection()->addAction(QStringLiteral("go_to_next_match")); a->setText(i18n("Go to Next Match")); connect(a, SIGNAL(triggered(bool)), this, SLOT(goToNextMatch())); a = actionCollection()->addAction(QStringLiteral("go_to_prev_match")); a->setText(i18n("Go to Previous Match")); connect(a, SIGNAL(triggered(bool)), this, SLOT(goToPreviousMatch())); m_ui.resultTabWidget->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectLeftTab); KAcceleratorManager::setNoAccel(m_ui.resultTabWidget); m_ui.displayOptions->setIcon(QIcon::fromTheme(QStringLiteral("games-config-options"))); m_ui.searchButton->setIcon(QIcon::fromTheme(QStringLiteral("edit-find"))); m_ui.nextButton->setIcon(QIcon::fromTheme(QStringLiteral("go-down-search"))); m_ui.stopButton->setIcon(QIcon::fromTheme(QStringLiteral("process-stop"))); m_ui.matchCase->setIcon(QIcon::fromTheme(QStringLiteral("format-text-superscript"))); m_ui.useRegExp->setIcon(QIcon::fromTheme(QStringLiteral("code-context"))); m_ui.expandResults->setIcon(QIcon::fromTheme(QStringLiteral("view-list-tree"))); m_ui.searchPlaceCombo->setItemIcon(CurrentFile, QIcon::fromTheme(QStringLiteral("text-plain"))); m_ui.searchPlaceCombo->setItemIcon(OpenFiles, QIcon::fromTheme(QStringLiteral("text-plain"))); m_ui.searchPlaceCombo->setItemIcon(Folder, QIcon::fromTheme(QStringLiteral("folder"))); m_ui.folderUpButton->setIcon(QIcon::fromTheme(QStringLiteral("go-up"))); m_ui.currentFolderButton->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh"))); m_ui.newTabButton->setIcon(QIcon::fromTheme(QStringLiteral("tab-new"))); m_ui.filterCombo->setToolTip(i18n("Comma separated list of file types to search in. Example: \"*.cpp,*.h\"\n")); m_ui.excludeCombo->setToolTip(i18n("Comma separated list of files and directories to exclude from the search. Example: \"build*\"")); // the order here is important to get the tabBar hidden for only one tab addTab(); m_ui.resultTabWidget->tabBar()->hide(); // get url-requester's combo box and sanely initialize KComboBox* cmbUrl = m_ui.folderRequester->comboBox(); cmbUrl->setDuplicatesEnabled(false); cmbUrl->setEditable(true); m_ui.folderRequester->setMode(KFile::Directory | KFile::LocalOnly); KUrlCompletion* cmpl = new KUrlCompletion(KUrlCompletion::DirCompletion); cmbUrl->setCompletionObject(cmpl); cmbUrl->setAutoDeleteCompletionObject(true); connect(m_ui.newTabButton, SIGNAL(clicked()), this, SLOT(addTab())); connect(m_ui.resultTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(tabCloseRequested(int))); connect(m_ui.resultTabWidget, SIGNAL(currentChanged(int)), this, SLOT(resultTabChanged(int))); connect(m_ui.folderUpButton, SIGNAL(clicked()), this, SLOT(navigateFolderUp())); connect(m_ui.currentFolderButton, SIGNAL(clicked()), this, SLOT(setCurrentFolder())); connect(m_ui.searchCombo, SIGNAL(editTextChanged(QString)), &m_changeTimer, SLOT(start())); connect(m_ui.matchCase, SIGNAL(toggled(bool)), &m_changeTimer, SLOT(start())); connect(m_ui.matchCase, &QToolButton::toggled, this, [this](bool) { Results *res = qobject_cast(m_ui.resultTabWidget->currentWidget()); if (res) { res->matchCase = m_ui.matchCase->isChecked(); } }); connect(m_ui.useRegExp, SIGNAL(toggled(bool)), &m_changeTimer, SLOT(start())); connect(m_ui.useRegExp, &QToolButton::toggled, this, [this](bool) { Results *res = qobject_cast(m_ui.resultTabWidget->currentWidget()); if (res) { res->useRegExp = m_ui.useRegExp->isChecked(); } }); m_changeTimer.setInterval(300); m_changeTimer.setSingleShot(true); connect(&m_changeTimer, SIGNAL(timeout()), this, SLOT(startSearchWhileTyping())); connect(m_ui.searchCombo->lineEdit(), SIGNAL(returnPressed()), this, SLOT(startSearch())); // connecting to returnPressed() of the folderRequester doesn't work, I haven't found out why yet. But connecting to the linedit works: connect(m_ui.folderRequester->comboBox()->lineEdit(), SIGNAL(returnPressed()), this, SLOT(startSearch())); connect(m_ui.filterCombo, SIGNAL(returnPressed()), this, SLOT(startSearch())); connect(m_ui.excludeCombo, SIGNAL(returnPressed()), this, SLOT(startSearch())); connect(m_ui.searchButton, SIGNAL(clicked()), this, SLOT(startSearch())); connect(m_ui.displayOptions, SIGNAL(toggled(bool)), this, SLOT(toggleOptions(bool))); connect(m_ui.searchPlaceCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(searchPlaceChanged())); connect(m_ui.searchPlaceCombo, static_cast(&QComboBox::currentIndexChanged), this, [this](int) { if (m_ui.searchPlaceCombo->currentIndex() == Folder) { m_ui.displayOptions->setChecked(true); } }); connect(m_ui.stopButton, SIGNAL(clicked()), &m_searchOpenFiles, SLOT(cancelSearch())); connect(m_ui.stopButton, SIGNAL(clicked()), &m_searchDiskFiles, SLOT(cancelSearch())); connect(m_ui.stopButton, SIGNAL(clicked()), &m_folderFilesList, SLOT(cancelSearch())); connect(m_ui.stopButton, SIGNAL(clicked()), &m_replacer, SLOT(cancelReplace())); connect(m_ui.nextButton, SIGNAL(clicked()), this, SLOT(goToNextMatch())); connect(m_ui.replaceButton, SIGNAL(clicked(bool)), this, SLOT(replaceSingleMatch())); connect(m_ui.replaceCheckedBtn, SIGNAL(clicked(bool)), this, SLOT(replaceChecked())); connect(m_ui.replaceCombo->lineEdit(), SIGNAL(returnPressed()), this, SLOT(replaceChecked())); m_ui.displayOptions->setChecked(true); connect(&m_searchOpenFiles, SIGNAL(matchFound(QString,QString,int,int,QString,int)), this, SLOT(matchFound(QString,QString,int,int,QString,int))); connect(&m_searchOpenFiles, SIGNAL(searchDone()), this, SLOT(searchDone())); connect(&m_searchOpenFiles, SIGNAL(searching(QString)), this, SLOT(searching(QString))); connect(&m_folderFilesList, SIGNAL(finished()), this, SLOT(folderFileListChanged())); connect(&m_folderFilesList, SIGNAL(searching(QString)), this, SLOT(searching(QString))); connect(&m_searchDiskFiles, SIGNAL(matchFound(QString,QString,int,int,QString,int)), this, SLOT(matchFound(QString,QString,int,int,QString,int))); connect(&m_searchDiskFiles, SIGNAL(searchDone()), this, SLOT(searchDone())); connect(&m_searchDiskFiles, SIGNAL(searching(QString)), this, SLOT(searching(QString))); connect(m_kateApp, SIGNAL(documentWillBeDeleted(KTextEditor::Document*)), &m_searchOpenFiles, SLOT(cancelSearch())); connect(m_kateApp, SIGNAL(documentWillBeDeleted(KTextEditor::Document*)), &m_replacer, SLOT(cancelReplace())); connect(m_kateApp, SIGNAL(documentWillBeDeleted(KTextEditor::Document*)), this, SLOT(clearDocMarks(KTextEditor::Document*))); connect(&m_replacer, SIGNAL(matchReplaced(KTextEditor::Document*,int,int,int)), this, SLOT(addMatchMark(KTextEditor::Document*,int,int,int))); connect(&m_replacer, &ReplaceMatches::replaceStatus, this, &KatePluginSearchView::replaceStatus); // Hook into line edit context menus m_ui.searchCombo->setContextMenuPolicy(Qt::CustomContextMenu); connect(m_ui.searchCombo, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(searchContextMenu(QPoint))); m_ui.searchCombo->completer()->setCompletionMode(QCompleter::PopupCompletion); m_ui.searchCombo->completer()->setCaseSensitivity(Qt::CaseSensitive); m_ui.searchCombo->setInsertPolicy(QComboBox::NoInsert); m_ui.searchCombo->lineEdit()->setClearButtonEnabled(true); m_ui.searchCombo->setMaxCount(25); m_ui.replaceCombo->completer()->setCompletionMode(QCompleter::PopupCompletion); m_ui.replaceCombo->completer()->setCaseSensitivity(Qt::CaseSensitive); m_ui.replaceCombo->setInsertPolicy(QComboBox::NoInsert); m_ui.replaceCombo->lineEdit()->setClearButtonEnabled(true); m_ui.replaceCombo->setMaxCount(25); m_toolView->setMinimumHeight(container->sizeHint().height()); connect(m_mainWindow, SIGNAL(unhandledShortcutOverride(QEvent*)), this, SLOT(handleEsc(QEvent*))); // watch for project plugin view creation/deletion connect(m_mainWindow, SIGNAL(pluginViewCreated (const QString &, QObject *)) , this, SLOT(slotPluginViewCreated (const QString &, QObject *))); connect(m_mainWindow, SIGNAL(pluginViewDeleted (const QString &, QObject *)) , this, SLOT(slotPluginViewDeleted (const QString &, QObject *))); connect(m_mainWindow, SIGNAL(viewChanged(KTextEditor::View *)), this, SLOT(docViewChanged())); // update once project plugin state manually m_projectPluginView = m_mainWindow->pluginView (QStringLiteral("kateprojectplugin")); slotProjectFileNameChanged (); m_replacer.setDocumentManager(m_kateApp); connect(&m_replacer, SIGNAL(replaceDone()), this, SLOT(replaceDone())); searchPlaceChanged(); m_toolView->installEventFilter(this); m_mainWindow->guiFactory()->addClient(this); } KatePluginSearchView::~KatePluginSearchView() { clearMarks(); m_mainWindow->guiFactory()->removeClient(this); delete m_toolView; } void KatePluginSearchView::navigateFolderUp() { // navigate one folder up m_ui.folderRequester->setUrl(localFileDirUp(m_ui.folderRequester->url())); } void KatePluginSearchView::setCurrentFolder() { if (!m_mainWindow) { return; } KTextEditor::View* editView = m_mainWindow->activeView(); if (editView && editView->document()) { // upUrl as we want the folder not the file m_ui.folderRequester->setUrl(localFileDirUp(editView->document()->url())); } m_ui.displayOptions->setChecked(true); } void KatePluginSearchView::openSearchView() { if (!m_mainWindow) { return; } if (!m_toolView->isVisible()) { m_mainWindow->showToolView(m_toolView); } m_ui.searchCombo->setFocus(Qt::OtherFocusReason); if (m_ui.searchPlaceCombo->currentIndex() == Folder) { m_ui.displayOptions->setChecked(true); } KTextEditor::View* editView = m_mainWindow->activeView(); if (editView && editView->document()) { if (m_ui.folderRequester->text().isEmpty()) { // upUrl as we want the folder not the file m_ui.folderRequester->setUrl(localFileDirUp (editView->document()->url())); } QString selection; if (editView->selection()) { selection = editView->selectionText(); // remove possible trailing '\n' if (selection.endsWith(QLatin1Char('\n'))) { selection = selection.left(selection.size() -1); } } if (selection.isEmpty()) { selection = editView->document()->wordAt(editView->cursorPosition()); } if (!selection.isEmpty() && !selection.contains(QLatin1Char('\n'))) { m_ui.searchCombo->blockSignals(true); m_ui.searchCombo->lineEdit()->setText(selection); m_ui.searchCombo->blockSignals(false); } m_ui.searchCombo->lineEdit()->selectAll(); m_searchJustOpened = true; startSearchWhileTyping(); } } void KatePluginSearchView::handleEsc(QEvent *e) { if (!m_mainWindow) return; QKeyEvent *k = static_cast(e); if (k->key() == Qt::Key_Escape && k->modifiers() == Qt::NoModifier) { static ulong lastTimeStamp; if (lastTimeStamp == k->timestamp()) { // Same as previous... This looks like a bug somewhere... return; } lastTimeStamp = k->timestamp(); if (!m_matchRanges.isEmpty()) { clearMarks(); } else if (m_toolView->isVisible()) { m_mainWindow->hideToolView(m_toolView); } } } void KatePluginSearchView::setSearchString(const QString &pattern) { m_ui.searchCombo->lineEdit()->setText(pattern); } void KatePluginSearchView::toggleOptions(bool show) { m_ui.stackedWidget->setCurrentIndex((show) ? 1:0); } void KatePluginSearchView::setSearchPlace(int place) { m_ui.searchPlaceCombo->setCurrentIndex(place); } QStringList KatePluginSearchView::filterFiles(const QStringList& files) const { QString types = m_ui.filterCombo->currentText(); QString excludes = m_ui.excludeCombo->currentText(); if (((types.isEmpty() || types == QStringLiteral("*"))) && (excludes.isEmpty())) { // shortcut for use all files return files; } QStringList tmpTypes = types.split(QLatin1Char(',')); QVector typeList; for (int i=0; i excludeList; for (int i=0; i openList; for (int i=0; idocuments().size(); i++) { int index = fileList.indexOf(m_kateApp->documents()[i]->url().toLocalFile()); if (index != -1) { openList << m_kateApp->documents()[i]; fileList.removeAt(index); } } // search order is important: Open files starts immediately and should finish // earliest after first event loop. // The DiskFile might finish immediately if (openList.size() > 0) { m_searchOpenFiles.startSearch(openList, m_curResults->regExp); } else { m_searchOpenFilesDone = true; } m_searchDiskFiles.startSearch(fileList, m_curResults->regExp); } void KatePluginSearchView::searchPlaceChanged() { int searchPlace = m_ui.searchPlaceCombo->currentIndex(); const bool inFolder = (searchPlace == Folder); m_ui.filterCombo->setEnabled(searchPlace >= Folder); m_ui.excludeCombo->setEnabled(searchPlace >= Folder); m_ui.folderRequester->setEnabled(inFolder); m_ui.folderUpButton->setEnabled(inFolder); m_ui.currentFolderButton->setEnabled(inFolder); m_ui.recursiveCheckBox->setEnabled(inFolder); m_ui.hiddenCheckBox->setEnabled(inFolder); m_ui.symLinkCheckBox->setEnabled(inFolder); m_ui.binaryCheckBox->setEnabled(inFolder); if (inFolder && sender() == m_ui.searchPlaceCombo) { setCurrentFolder(); } // ... and the labels: m_ui.folderLabel->setEnabled(m_ui.folderRequester->isEnabled()); m_ui.filterLabel->setEnabled(m_ui.filterCombo->isEnabled()); m_ui.excludeLabel->setEnabled(m_ui.excludeCombo->isEnabled()); Results *res = qobject_cast(m_ui.resultTabWidget->currentWidget()); if (res) { res->searchPlaceIndex = searchPlace; } } void KatePluginSearchView::addHeaderItem() { QTreeWidgetItem *item = new QTreeWidgetItem(m_curResults->tree, QStringList()); item->setCheckState(0, Qt::Checked); item->setFlags(item->flags() | Qt::ItemIsTristate); m_curResults->tree->expandItem(item); } QTreeWidgetItem * KatePluginSearchView::rootFileItem(const QString &url, const QString &fName) { if (!m_curResults) { return nullptr; } QUrl fullUrl = QUrl::fromUserInput(url); QString path = fullUrl.isLocalFile() ? localFileDirUp(fullUrl).path() : fullUrl.url(); if (!path.isEmpty() && !path.endsWith(QLatin1Char('/'))) { path += QLatin1Char('/'); } path.replace(m_resultBaseDir, QString()); QString name = fullUrl.fileName(); if (url.isEmpty()) { name = fName; } // make sure we have a root item if (m_curResults->tree->topLevelItemCount() == 0) { addHeaderItem(); } QTreeWidgetItem *root = m_curResults->tree->topLevelItem(0); if (root->data(0, ReplaceMatches::FileNameRole).toString() == fName) { // The root item contains the document name -> // this is search as you type, return the root item return root; } for (int i=0; ichildCount(); i++) { //qDebug() << root->child(i)->data(0, ReplaceMatches::FileNameRole).toString() << fName; if ((root->child(i)->data(0, ReplaceMatches::FileUrlRole).toString() == url)&& (root->child(i)->data(0, ReplaceMatches::FileNameRole).toString() == fName)) { int matches = root->child(i)->data(0, ReplaceMatches::LineRole).toInt() + 1; QString tmpUrl = QString::fromLatin1("%1%2: %3").arg(path).arg(name).arg(matches); root->child(i)->setData(0, Qt::DisplayRole, tmpUrl); root->child(i)->setData(0, ReplaceMatches::LineRole, matches); return root->child(i); } } // file item not found create a new one QString tmpUrl = QString::fromLatin1("%1%2: %3").arg(path).arg(name).arg(1); TreeWidgetItem *item = new TreeWidgetItem(root, QStringList(tmpUrl)); item->setData(0, ReplaceMatches::FileUrlRole, url); item->setData(0, ReplaceMatches::FileNameRole, fName); item->setData(0, ReplaceMatches::LineRole, 1); item->setCheckState(0, Qt::Checked); item->setFlags(item->flags() | Qt::ItemIsTristate); return item; } void KatePluginSearchView::addMatchMark(KTextEditor::Document* doc, int line, int column, int matchLen) { if (!doc) return; KTextEditor::View* activeView = m_mainWindow->activeView(); KTextEditor::MovingInterface* miface = qobject_cast(doc); KTextEditor::ConfigInterface* ciface = qobject_cast(activeView); KTextEditor::Attribute::Ptr attr(new KTextEditor::Attribute()); bool replace = ((sender() == &m_replacer) || (sender() == nullptr) || (sender() == m_ui.replaceButton)); if (replace) { QColor replaceColor(Qt::green); if (ciface) replaceColor = ciface->configValue(QStringLiteral("replace-highlight-color")).value(); attr->setBackground(replaceColor); if (activeView) { attr->setForeground(activeView->defaultStyleAttribute(KTextEditor::dsNormal)->foreground().color()); } } else { QColor searchColor(Qt::yellow); if (ciface) searchColor = ciface->configValue(QStringLiteral("search-highlight-color")).value(); attr->setBackground(searchColor); if (activeView) { attr->setForeground(activeView->defaultStyleAttribute(KTextEditor::dsNormal)->foreground().color()); } } // calculate end line in case of multi-line match int endLine = line; int endColumn = column + matchLen; while ((endLine < doc->lines()) && (endColumn > doc->line(endLine).size())) { endColumn -= doc->line(endLine).size(); endColumn--; // remove one for '\n' endLine++; } KTextEditor::Range range(line, column, endLine, endColumn); if (m_curResults && !replace) { // special handling for "(?=\\n)" in multi-line search QRegularExpression tmpReg = m_curResults->regExp; if (m_curResults->regExp.pattern().endsWith(QStringLiteral("(?=\\n)"))) { QString newPatern = tmpReg.pattern(); newPatern.replace(QStringLiteral("(?=\\n)"), QStringLiteral("$")); tmpReg.setPattern(newPatern); } if (tmpReg.match(doc->text(range)).capturedStart() != 0) { qDebug() << doc->text(range) << "Does not match" << m_curResults->regExp.pattern(); return; } } KTextEditor::MovingRange* mr = miface->newMovingRange(range); mr->setAttribute(attr); mr->setZDepth(-90000.0); // Set the z-depth to slightly worse than the selection mr->setAttributeOnlyForViews(true); m_matchRanges.append(mr); KTextEditor::MarkInterface* iface = qobject_cast(doc); if (!iface) return; iface->setMarkDescription(KTextEditor::MarkInterface::markType32, i18n("SearchHighLight")); iface->setMarkPixmap(KTextEditor::MarkInterface::markType32, QIcon().pixmap(0,0)); iface->addMark(line, KTextEditor::MarkInterface::markType32); connect(doc, SIGNAL(aboutToInvalidateMovingInterfaceContent(KTextEditor::Document*)), this, SLOT(clearMarks()), Qt::UniqueConnection); } void KatePluginSearchView::matchFound(const QString &url, const QString &fName, int line, int column, const QString &lineContent, int matchLen) { if (!m_curResults) { return; } QString pre = lineContent.left(column).toHtmlEscaped(); QString match = lineContent.mid(column, matchLen).toHtmlEscaped(); match.replace(QLatin1Char('\n'), QStringLiteral("\\n")); QString post = lineContent.mid(column + matchLen).toHtmlEscaped(); QStringList row; row << i18n("Line: %1: %2", line+1, pre+QStringLiteral("")+match+QStringLiteral("")+post); TreeWidgetItem *item = new TreeWidgetItem(rootFileItem(url, fName), row); item->setData(0, ReplaceMatches::FileUrlRole, url); item->setData(0, Qt::ToolTipRole, url); item->setData(0, ReplaceMatches::FileNameRole, fName); item->setData(0, ReplaceMatches::LineRole, line); item->setData(0, ReplaceMatches::ColumnRole, column); item->setData(0, ReplaceMatches::MatchLenRole, matchLen); item->setData(0, ReplaceMatches::PreMatchRole, pre); item->setData(0, ReplaceMatches::MatchRole, match); item->setData(0, ReplaceMatches::PostMatchRole, post); item->setCheckState (0, Qt::Checked); m_curResults->matches++; // Add mark if the document is open KTextEditor::Document* doc; if (url.isEmpty()) { doc = m_replacer.findNamed(fName); } else { doc = m_kateApp->findUrl(QUrl::fromUserInput(url)); } addMatchMark(doc, line, column, matchLen); } void KatePluginSearchView::clearMarks() { // FIXME: check for ongoing search... KTextEditor::MarkInterface* iface; foreach (KTextEditor::Document* doc, m_kateApp->documents()) { iface = qobject_cast(doc); if (iface) { const QHash marks = iface->marks(); QHashIterator i(marks); while (i.hasNext()) { i.next(); if (i.value()->type & KTextEditor::MarkInterface::markType32) { iface->removeMark(i.value()->line, KTextEditor::MarkInterface::markType32); } } } } qDeleteAll(m_matchRanges); m_matchRanges.clear(); } void KatePluginSearchView::clearDocMarks(KTextEditor::Document* doc) { //qDebug() << sender(); // FIXME: check for ongoing search... KTextEditor::MarkInterface* iface; iface = qobject_cast(doc); if (iface) { const QHash marks = iface->marks(); QHashIterator i(marks); while (i.hasNext()) { i.next(); if (i.value()->type & KTextEditor::MarkInterface::markType32) { iface->removeMark(i.value()->line, KTextEditor::MarkInterface::markType32); } } } int i = 0; while (idocument() == doc) { //qDebug() << "removing mark in" << doc->url(); delete m_matchRanges.at(i); m_matchRanges.removeAt(i); } else { i++; } } } void KatePluginSearchView::startSearch() { m_changeTimer.stop(); // make sure not to start a "while you type" search now m_mainWindow->showToolView(m_toolView); // in case we are invoked from the command interface m_switchToProjectModeWhenAvailable = false; // now that we started, don't switch back automatically if (m_ui.searchCombo->currentText().isEmpty()) { // return pressed in the folder combo or filter combo return; } QString currentSearchText = m_ui.searchCombo->currentText(); m_ui.searchCombo->setItemText(0, QString()); // remove the text from index 0 on enter/search int index = m_ui.searchCombo->findText(currentSearchText); if (index > 0) { m_ui.searchCombo->removeItem(index); } m_ui.searchCombo->insertItem(1, currentSearchText); m_ui.searchCombo->setCurrentIndex(1); if (m_ui.filterCombo->findText(m_ui.filterCombo->currentText()) == -1) { m_ui.filterCombo->insertItem(0, m_ui.filterCombo->currentText()); m_ui.filterCombo->setCurrentIndex(0); } if (m_ui.excludeCombo->findText(m_ui.excludeCombo->currentText()) == -1) { m_ui.excludeCombo->insertItem(0, m_ui.excludeCombo->currentText()); m_ui.excludeCombo->setCurrentIndex(0); } if (m_ui.folderRequester->comboBox()->findText(m_ui.folderRequester->comboBox()->currentText()) == -1) { m_ui.folderRequester->comboBox()->insertItem(0, m_ui.folderRequester->comboBox()->currentText()); m_ui.folderRequester->comboBox()->setCurrentIndex(0); } m_curResults = qobject_cast(m_ui.resultTabWidget->currentWidget()); if (!m_curResults) { qWarning() << "This is a bug"; return; } QRegularExpression::PatternOptions patternOptions = (m_ui.matchCase->isChecked() ? QRegularExpression::NoPatternOption : QRegularExpression::CaseInsensitiveOption); QString pattern = (m_ui.useRegExp->isChecked() ? currentSearchText : QRegularExpression::escape(currentSearchText)); QRegularExpression reg(pattern, patternOptions); if (!reg.isValid()) { //qDebug() << "invalid regexp"; indicateMatch(false); return; } m_curResults->regExp = reg; m_curResults->useRegExp = m_ui.useRegExp->isChecked(); m_curResults->matchCase = m_ui.matchCase->isChecked(); m_curResults->searchPlaceIndex = m_ui.searchPlaceCombo->currentIndex(); m_ui.newTabButton->setDisabled(true); m_ui.searchCombo->setDisabled(true); m_ui.searchButton->setDisabled(true); m_ui.displayOptions->setChecked (false); m_ui.displayOptions->setDisabled(true); m_ui.replaceCheckedBtn->setDisabled(true); m_ui.replaceButton->setDisabled(true); m_ui.stopAndNext->setCurrentIndex(1); m_ui.replaceCombo->setDisabled(true); m_ui.searchPlaceCombo->setDisabled(true); m_ui.useRegExp->setDisabled(true); m_ui.matchCase->setDisabled(true); m_ui.expandResults->setDisabled(true); m_ui.currentFolderButton->setDisabled(true); clearMarks(); m_curResults->tree->clear(); m_curResults->tree->setCurrentItem(nullptr); m_curResults->matches = 0; m_ui.resultTabWidget->setTabText(m_ui.resultTabWidget->currentIndex(), m_ui.searchCombo->currentText()); m_toolView->setCursor(Qt::WaitCursor); m_searchDiskFilesDone = false; m_searchOpenFilesDone = false; const bool inCurrentProject = m_ui.searchPlaceCombo->currentIndex() == Project; const bool inAllOpenProjects = m_ui.searchPlaceCombo->currentIndex() == AllProjects; if (m_ui.searchPlaceCombo->currentIndex() == CurrentFile) { m_searchDiskFilesDone = true; m_resultBaseDir.clear(); QList documents; documents << m_mainWindow->activeView()->document(); addHeaderItem(); m_searchOpenFiles.startSearch(documents, reg); } else if (m_ui.searchPlaceCombo->currentIndex() == OpenFiles) { m_searchDiskFilesDone = true; m_resultBaseDir.clear(); const QList documents = m_kateApp->documents(); addHeaderItem(); m_searchOpenFiles.startSearch(documents, reg); } else if (m_ui.searchPlaceCombo->currentIndex() == Folder) { m_resultBaseDir = m_ui.folderRequester->url().path(); if (!m_resultBaseDir.isEmpty() && !m_resultBaseDir.endsWith(QLatin1Char('/'))) m_resultBaseDir += QLatin1Char('/'); addHeaderItem(); m_folderFilesList.generateList(m_ui.folderRequester->text(), m_ui.recursiveCheckBox->isChecked(), m_ui.hiddenCheckBox->isChecked(), m_ui.symLinkCheckBox->isChecked(), m_ui.binaryCheckBox->isChecked(), m_ui.filterCombo->currentText(), m_ui.excludeCombo->currentText()); // the file list will be ready when the thread returns (connected to folderFileListChanged) } else if (inCurrentProject || inAllOpenProjects) { /** * init search with file list from current project, if any */ m_resultBaseDir.clear(); QStringList files; if (m_projectPluginView) { if (inCurrentProject) { m_resultBaseDir = m_projectPluginView->property ("projectBaseDir").toString(); } else { m_resultBaseDir = m_projectPluginView->property ("allProjectsCommonBaseDir").toString(); } if (!m_resultBaseDir.endsWith(QLatin1Char('/'))) m_resultBaseDir += QLatin1Char('/'); QStringList projectFiles; if (inCurrentProject) { projectFiles = m_projectPluginView->property ("projectFiles").toStringList(); } else { projectFiles = m_projectPluginView->property ("allProjectsFiles").toStringList(); } files = filterFiles(projectFiles); } addHeaderItem(); QList openList; for (int i=0; idocuments().size(); i++) { int index = files.indexOf(m_kateApp->documents()[i]->url().toString()); if (index != -1) { openList << m_kateApp->documents()[i]; files.removeAt(index); } } // search order is important: Open files starts immediately and should finish // earliest after first event loop. // The DiskFile might finish immediately if (openList.size() > 0) { m_searchOpenFiles.startSearch(openList, m_curResults->regExp); } else { m_searchOpenFilesDone = true; } m_searchDiskFiles.startSearch(files, reg); } else { Q_ASSERT_X(false, "KatePluginSearchView::startSearch", "case not handled"); } } void KatePluginSearchView::startSearchWhileTyping() { if (!m_searchDiskFilesDone || !m_searchOpenFilesDone) { return; } QString currentSearchText = m_ui.searchCombo->currentText(); m_ui.searchButton->setDisabled(currentSearchText.isEmpty()); // Do not clear the search results if you press up by mistake if (currentSearchText.isEmpty()) return; if (!m_mainWindow->activeView()) return; KTextEditor::Document *doc = m_mainWindow->activeView()->document(); if (!doc) return; m_curResults =qobject_cast(m_ui.resultTabWidget->currentWidget()); if (!m_curResults) { qWarning() << "This is a bug"; return; } // check if we typed something or just changed combobox index // changing index should not trigger a search-as-you-type if (m_ui.searchCombo->currentIndex() > 0 && currentSearchText == m_ui.searchCombo->itemText(m_ui.searchCombo->currentIndex())) { return; } // Now we should have a true typed text change QRegularExpression::PatternOptions patternOptions = (m_ui.matchCase->isChecked() ? QRegularExpression::NoPatternOption : QRegularExpression::CaseInsensitiveOption); QString pattern = (m_ui.useRegExp->isChecked() ? currentSearchText : QRegularExpression::escape(currentSearchText)); QRegularExpression reg(pattern, patternOptions); if (!reg.isValid()) { //qDebug() << "invalid regexp"; indicateMatch(false); return; } m_curResults->regExp = reg; m_curResults->useRegExp = m_ui.useRegExp->isChecked(); m_ui.replaceCheckedBtn->setDisabled(true); m_ui.replaceButton->setDisabled(true); m_ui.nextButton->setDisabled(true); int cursorPosition = m_ui.searchCombo->lineEdit()->cursorPosition(); bool hasSelected = m_ui.searchCombo->lineEdit()->hasSelectedText(); m_ui.searchCombo->blockSignals(true); m_ui.searchCombo->setItemText(0, currentSearchText); m_ui.searchCombo->setCurrentIndex(0); m_ui.searchCombo->lineEdit()->setCursorPosition(cursorPosition); if (hasSelected) { // This restores the select all from invoking openSearchView // This selects too much if we have a partial selection and toggle match-case/regexp m_ui.searchCombo->lineEdit()->selectAll(); } m_ui.searchCombo->blockSignals(false); // Prepare for the new search content clearMarks(); m_resultBaseDir.clear(); m_curResults->tree->clear(); m_curResults->tree->setCurrentItem(nullptr); m_curResults->matches = 0; // Add the search-as-you-type header item TreeWidgetItem *item = new TreeWidgetItem(m_curResults->tree, QStringList()); item->setData(0, ReplaceMatches::FileUrlRole, doc->url().toString()); item->setData(0, ReplaceMatches::FileNameRole, doc->documentName()); item->setData(0, ReplaceMatches::LineRole, 0); item->setCheckState(0, Qt::Checked); item->setFlags(item->flags() | Qt::ItemIsTristate); // Do the search int searchStoppedAt = m_searchOpenFiles.searchOpenFile(doc, reg, 0); searchWhileTypingDone(); if (searchStoppedAt != 0) { delete m_infoMessage; const QString msg = i18n("Searching while you type was interrupted. It would have taken too long."); m_infoMessage = new KTextEditor::Message(msg, KTextEditor::Message::Warning); m_infoMessage->setPosition(KTextEditor::Message::TopInView); m_infoMessage->setAutoHide(3000); m_infoMessage->setAutoHideMode(KTextEditor::Message::Immediate); m_infoMessage->setView(m_mainWindow->activeView()); m_mainWindow->activeView()->document()->postMessage(m_infoMessage); } } void KatePluginSearchView::searchDone() { m_changeTimer.stop(); // avoid "while you type" search directly after if (sender() == &m_searchDiskFiles) { m_searchDiskFilesDone = true; } if (sender() == &m_searchOpenFiles) { m_searchOpenFilesDone = true; } if (!m_searchDiskFilesDone || !m_searchOpenFilesDone) { return; } QWidget* fw = QApplication::focusWidget(); // NOTE: we take the focus widget here before the enabling/disabling // moves the focus around. m_ui.newTabButton->setDisabled(false); m_ui.searchCombo->setDisabled(false); m_ui.searchButton->setDisabled(false); m_ui.stopAndNext->setCurrentIndex(0); m_ui.displayOptions->setDisabled(false); m_ui.replaceCombo->setDisabled(false); m_ui.searchPlaceCombo->setDisabled(false); m_ui.useRegExp->setDisabled(false); m_ui.matchCase->setDisabled(false); m_ui.expandResults->setDisabled(false); m_ui.currentFolderButton->setDisabled(false); if (!m_curResults) { return; } m_ui.replaceCheckedBtn->setDisabled(m_curResults->matches < 1); m_ui.replaceButton->setDisabled(m_curResults->matches < 1); m_ui.nextButton->setDisabled(m_curResults->matches < 1); m_curResults->tree->sortItems(0, Qt::AscendingOrder); m_curResults->tree->expandAll(); m_curResults->tree->resizeColumnToContents(0); if (m_curResults->tree->columnWidth(0) < m_curResults->tree->width()-30) { m_curResults->tree->setColumnWidth(0, m_curResults->tree->width()-30); } // expand the "header item " to display all files and all results if configured QTreeWidgetItem *root = m_curResults->tree->topLevelItem(0); m_curResults->tree->expandItem(root); if (root && (root->childCount() > 1) && (!m_ui.expandResults->isChecked())) { for (int i=0; ichildCount(); i++) { m_curResults->tree->collapseItem(root->child(i)); } } if (root) { switch (m_ui.searchPlaceCombo->currentIndex()) { case CurrentFile: root->setData(0, Qt::DisplayRole, i18np("One match found in current file", "%1 matches found in current file", m_curResults->matches)); break; case OpenFiles: root->setData(0, Qt::DisplayRole, i18np("One match found in open files", "%1 matches found in open files", m_curResults->matches)); break; case Folder: root->setData(0, Qt::DisplayRole, i18np("One match found in folder %2", "%1 matches found in folder %2", m_curResults->matches, m_resultBaseDir)); break; case Project: { QString projectName; if (m_projectPluginView) { projectName = m_projectPluginView->property("projectName").toString(); } root->setData(0, Qt::DisplayRole, i18np("One match found in project %2 (%3)", "%1 matches found in project %2 (%3)", m_curResults->matches, projectName, m_resultBaseDir)); break; } case AllProjects: // "in Open Projects" root->setData(0, Qt::DisplayRole, i18np("One match found in all open projects (common parent: %2)", "%1 matches found in all open projects (common parent: %2)", m_curResults->matches, m_resultBaseDir)); break; } } indicateMatch(m_curResults->matches > 0); m_curResults = nullptr; m_toolView->unsetCursor(); if (fw == m_ui.stopButton) { m_ui.searchCombo->setFocus(); } m_searchJustOpened = false; } void KatePluginSearchView::searchWhileTypingDone() { if (!m_curResults) { return; } bool popupVisible = m_ui.searchCombo->lineEdit()->completer()->popup()->isVisible(); m_ui.replaceCheckedBtn->setDisabled(m_curResults->matches < 1); m_ui.replaceButton->setDisabled(m_curResults->matches < 1); m_ui.nextButton->setDisabled(m_curResults->matches < 1); m_curResults->tree->expandAll(); m_curResults->tree->resizeColumnToContents(0); if (m_curResults->tree->columnWidth(0) < m_curResults->tree->width()-30) { m_curResults->tree->setColumnWidth(0, m_curResults->tree->width()-30); } QWidget *focusObject = nullptr; QTreeWidgetItem *root = m_curResults->tree->topLevelItem(0); if (root) { QTreeWidgetItem *child = root->child(0); if (!m_searchJustOpened) { focusObject = qobject_cast(QGuiApplication::focusObject()); } indicateMatch(child); root->setData(0, Qt::DisplayRole, i18np("One match found", "%1 matches found", m_curResults->matches)); } m_curResults = nullptr; if (focusObject) { focusObject->setFocus(); } if (popupVisible) { m_ui.searchCombo->lineEdit()->completer()->complete(); } m_searchJustOpened = false; } void KatePluginSearchView::searching(const QString &file) { if (!m_curResults) { return; } QTreeWidgetItem *root = m_curResults->tree->topLevelItem(0); if (root) { if (file.size() > 70) { root->setData(0, Qt::DisplayRole, i18n("Searching: ...%1", file.right(70))); } else { root->setData(0, Qt::DisplayRole, i18n("Searching: %1", file)); } } } void KatePluginSearchView::indicateMatch(bool hasMatch) { QLineEdit * const lineEdit = m_ui.searchCombo->lineEdit(); QPalette background(lineEdit->palette()); if (hasMatch) { // Green background for line edit KColorScheme::adjustBackground(background, KColorScheme::PositiveBackground); } else { // Reset background of line edit background = QPalette(); } // Red background for line edit //KColorScheme::adjustBackground(background, KColorScheme::NegativeBackground); // Neutral background //KColorScheme::adjustBackground(background, KColorScheme::NeutralBackground); lineEdit->setPalette(background); } void KatePluginSearchView::replaceSingleMatch() { if (m_ui.searchCombo->findText(m_ui.searchCombo->currentText()) == -1) { m_ui.searchCombo->insertItem(1, m_ui.searchCombo->currentText()); m_ui.searchCombo->setCurrentIndex(1); } if (m_ui.replaceCombo->findText(m_ui.replaceCombo->currentText()) == -1) { m_ui.replaceCombo->insertItem(1, m_ui.replaceCombo->currentText()); m_ui.replaceCombo->setCurrentIndex(1); } // check if the cursor is at the current item if not jump there Results *res = qobject_cast(m_ui.resultTabWidget->currentWidget()); if (!res) { return; } QTreeWidgetItem *item = res->tree->currentItem(); if (!item || !item->parent()) { // nothing was selected goToNextMatch(); return; } if (!m_mainWindow->activeView() || !m_mainWindow->activeView()->cursorPosition().isValid()) { itemSelected(item); return; } int dLine = m_mainWindow->activeView()->cursorPosition().line(); int dColumn = m_mainWindow->activeView()->cursorPosition().column(); int iLine = item->data(0, ReplaceMatches::LineRole).toInt(); int iColumn = item->data(0, ReplaceMatches::ColumnRole).toInt(); if ((dLine != iLine) || (dColumn != iColumn)) { itemSelected(item); return; } KTextEditor::Document *doc = m_mainWindow->activeView()->document(); // Find the corresponding range int i; for (i=0; idocument() != doc) continue; if (m_matchRanges[i]->start().line() != iLine) continue; if (m_matchRanges[i]->start().column() != iColumn) continue; break; } if (i >=m_matchRanges.size()) { goToNextMatch(); return; } QRegularExpressionMatch match = res->regExp.match(doc->text(m_matchRanges[i]->toRange())); if (match.capturedStart() != 0) { qDebug() << doc->text(m_matchRanges[i]->toRange()) << "Does not match" << res->regExp.pattern(); goToNextMatch(); return; } QString replaceText = m_ui.replaceCombo->currentText(); replaceText.replace(QStringLiteral("\\\\"), QStringLiteral("¤Search&Replace¤")); for (int j=1; j<=match.lastCapturedIndex() ; j++) { replaceText.replace(QString(QStringLiteral("\\%1")).arg(j), match.captured(j)); } replaceText.replace(QStringLiteral("\\n"), QStringLiteral("\n")); replaceText.replace(QStringLiteral("\\t"), QStringLiteral("\t")); replaceText.replace(QStringLiteral("¤Search&Replace¤"), QStringLiteral("\\\\")); doc->replaceText(m_matchRanges[i]->toRange(), replaceText); addMatchMark(doc, dLine, dColumn, replaceText.size()); replaceText.replace(QLatin1Char('\n'), QStringLiteral("\\n")); replaceText.replace(QLatin1Char('\t'), QStringLiteral("\\t")); QString html = item->data(0, ReplaceMatches::PreMatchRole).toString(); html += QStringLiteral("") + item->data(0, ReplaceMatches::MatchRole).toString() + QStringLiteral(" "); html += QStringLiteral("") + replaceText + QStringLiteral(""); html += item->data(0, ReplaceMatches::PostMatchRole).toString(); item->setData(0, Qt::DisplayRole, i18n("Line: %1: %2",m_matchRanges[i]->start().line()+1, html)); // now update the rest of the tree items for this file (they are sorted in ascending order i++; for (; idocument() != doc) continue; item = res->tree->itemBelow(item); if (!item) break; if (item->data(0, ReplaceMatches::FileUrlRole).toString() != doc->url().toString()) break; iLine = item->data(0, ReplaceMatches::LineRole).toInt(); iColumn = item->data(0, ReplaceMatches::ColumnRole).toInt(); if ((m_matchRanges[i]->start().line() == iLine) && (m_matchRanges[i]->start().column() == iColumn)) { break; } item->setData(0, ReplaceMatches::LineRole, m_matchRanges[i]->start().line()); item->setData(0, ReplaceMatches::ColumnRole, m_matchRanges[i]->start().column()); } goToNextMatch(); } void KatePluginSearchView::replaceChecked() { if (m_ui.searchCombo->findText(m_ui.searchCombo->currentText()) == -1) { m_ui.searchCombo->insertItem(1, m_ui.searchCombo->currentText()); m_ui.searchCombo->setCurrentIndex(1); } if (m_ui.replaceCombo->findText(m_ui.replaceCombo->currentText()) == -1) { m_ui.replaceCombo->insertItem(1, m_ui.replaceCombo->currentText()); m_ui.replaceCombo->setCurrentIndex(1); } m_curResults =qobject_cast(m_ui.resultTabWidget->currentWidget()); if (!m_curResults) { qWarning() << "Results not found"; return; } m_ui.stopAndNext->setCurrentIndex(1); m_ui.displayOptions->setChecked(false); m_ui.displayOptions->setDisabled(true); m_ui.newTabButton->setDisabled(true); m_ui.searchCombo->setDisabled(true); m_ui.searchButton->setDisabled(true); m_ui.replaceCheckedBtn->setDisabled(true); m_ui.replaceButton->setDisabled(true); m_ui.replaceCombo->setDisabled(true); m_ui.searchPlaceCombo->setDisabled(true); m_ui.useRegExp->setDisabled(true); m_ui.matchCase->setDisabled(true); m_ui.expandResults->setDisabled(true); m_ui.currentFolderButton->setDisabled(true); m_curResults->replaceStr = m_ui.replaceCombo->currentText(); QTreeWidgetItem *root = m_curResults->tree->topLevelItem(0); if (root) { m_curResults->treeRootText = root->data(0, Qt::DisplayRole).toString(); } m_replacer.replaceChecked(m_curResults->tree, m_curResults->regExp, m_curResults->replaceStr); } void KatePluginSearchView::replaceStatus(const QUrl &url) { if (!m_curResults) { qDebug() << "m_curResults == nullptr"; return; } QTreeWidgetItem *root = m_curResults->tree->topLevelItem(0); if (root) { QString file = url.toString(QUrl::PreferLocalFile); if (file.size() > 70) { root->setData(0, Qt::DisplayRole, i18n("Replacing in: ...%1", file.right(70))); } else { root->setData(0, Qt::DisplayRole, i18n("Replacing in: %1", file)); } } } void KatePluginSearchView::replaceDone() { m_ui.stopAndNext->setCurrentIndex(0); m_ui.replaceCombo->setDisabled(false); m_ui.newTabButton->setDisabled(false); m_ui.searchCombo->setDisabled(false); m_ui.searchButton->setDisabled(false); m_ui.replaceCheckedBtn->setDisabled(false); m_ui.replaceButton->setDisabled(false); m_ui.displayOptions->setDisabled(false); m_ui.searchPlaceCombo->setDisabled(false); m_ui.useRegExp->setDisabled(false); m_ui.matchCase->setDisabled(false); m_ui.expandResults->setDisabled(false); m_ui.currentFolderButton->setDisabled(false); if (!m_curResults) { qDebug() << "m_curResults == nullptr"; return; } QTreeWidgetItem *root = m_curResults->tree->topLevelItem(0); if (root) { root->setData(0, Qt::DisplayRole, m_curResults->treeRootText); } } void KatePluginSearchView::docViewChanged() { Results *res = qobject_cast(m_ui.resultTabWidget->currentWidget()); if (!res) { return; } m_curResults = res; if (!m_mainWindow->activeView()) { return; } // add the marks if it is not already open KTextEditor::Document *doc = m_mainWindow->activeView()->document(); if (doc) { QTreeWidgetItem *rootItem = nullptr; for (int i=0; itree->topLevelItemCount(); i++) { QString url = res->tree->topLevelItem(i)->data(0, ReplaceMatches::FileUrlRole).toString(); QString fName = res->tree->topLevelItem(i)->data(0, ReplaceMatches::FileNameRole).toString(); if (url == doc->url().toString() && fName == doc->documentName()) { rootItem = res->tree->topLevelItem(i); break; } } if (rootItem) { int line; int column; int len; QTreeWidgetItem *item; for (int i=0; ichildCount(); i++) { item = rootItem->child(i); line = item->data(0, ReplaceMatches::LineRole).toInt(); column = item->data(0, ReplaceMatches::ColumnRole).toInt(); len = item->data(0, ReplaceMatches::MatchLenRole).toInt(); addMatchMark(doc, line, column, len); } } } } void KatePluginSearchView::itemSelected(QTreeWidgetItem *item) { if (!item) return; m_curResults = qobject_cast(m_ui.resultTabWidget->currentWidget()); if (!m_curResults) { return; } while (item->data(0, ReplaceMatches::ColumnRole).toString().isEmpty()) { item->treeWidget()->expandItem(item); item = item->child(0); if (!item) return; } item->treeWidget()->setCurrentItem(item); // get stuff int toLine = item->data(0, ReplaceMatches::LineRole).toInt(); int toColumn = item->data(0, ReplaceMatches::ColumnRole).toInt(); KTextEditor::Document* doc; QString url = item->data(0, ReplaceMatches::FileUrlRole).toString(); if (!url.isEmpty()) { doc = m_kateApp->findUrl(QUrl::fromUserInput(url)); } else { doc = m_replacer.findNamed(item->data(0, ReplaceMatches::FileNameRole).toString()); } // add the marks to the document if it is not already open if (!doc) { doc = m_kateApp->openUrl(QUrl::fromUserInput(url)); if (doc) { int line; int column; int len; QTreeWidgetItem *rootItem = (item->parent()==nullptr) ? item : item->parent(); for (int i=0; ichildCount(); i++) { item = rootItem->child(i); line = item->data(0, ReplaceMatches::LineRole).toInt(); column = item->data(0, ReplaceMatches::ColumnRole).toInt(); len = item->data(0, ReplaceMatches::MatchLenRole).toInt(); addMatchMark(doc, line, column, len); } } } if (!doc) return; // open the right view... m_mainWindow->activateView(doc); // any view active? if (!m_mainWindow->activeView()) { return; } // set the cursor to the correct position m_mainWindow->activeView()->setCursorPosition(KTextEditor::Cursor(toLine, toColumn)); m_mainWindow->activeView()->setFocus(); } void KatePluginSearchView::goToNextMatch() { bool wrapFromFirst = false; bool startFromFirst = false; bool startFromCursor = false; Results *res = qobject_cast(m_ui.resultTabWidget->currentWidget()); if (!res) { return; } QTreeWidgetItem *curr = res->tree->currentItem(); bool focusInView = m_mainWindow->activeView() && m_mainWindow->activeView()->hasFocus(); if (!curr && focusInView) { // no item has been visited && focus is not in searchCombo (probably in the view) -> // jump to the closest match after current cursor position // check if current file is in the file list curr = res->tree->topLevelItem(0); while (curr && curr->data(0, ReplaceMatches::FileUrlRole).toString() != m_mainWindow->activeView()->document()->url().toString()) { curr = res->tree->itemBelow(curr); } // now we are either in this file or !curr if (curr) { QTreeWidgetItem *fileBefore = curr; res->tree->expandItem(curr); int lineNr = 0; int columnNr = 0; if (m_mainWindow->activeView()->cursorPosition().isValid()) { lineNr = m_mainWindow->activeView()->cursorPosition().line(); columnNr = m_mainWindow->activeView()->cursorPosition().column(); } if (!curr->data(0, ReplaceMatches::ColumnRole).isValid()) { curr = res->tree->itemBelow(curr); }; while (curr && curr->data(0, ReplaceMatches::LineRole).toInt() <= lineNr && curr->data(0, ReplaceMatches::FileUrlRole).toString() == m_mainWindow->activeView()->document()->url().toString()) { if (curr->data(0, ReplaceMatches::LineRole).toInt() == lineNr && curr->data(0, ReplaceMatches::ColumnRole).toInt() >= columnNr - curr->data(0, ReplaceMatches::MatchLenRole).toInt()) { break; } fileBefore = curr; curr = res->tree->itemBelow(curr); } curr = fileBefore; startFromCursor = true; } } if (!curr) { curr = res->tree->topLevelItem(0); startFromFirst = true; } if (!curr) return; if (!curr->data(0, ReplaceMatches::ColumnRole).toString().isEmpty()) { curr = res->tree->itemBelow(curr); if (!curr) { wrapFromFirst = true; curr = res->tree->topLevelItem(0); } } itemSelected(curr); if (startFromFirst) { delete m_infoMessage; const QString msg = i18n("Starting from first match"); m_infoMessage = new KTextEditor::Message(msg, KTextEditor::Message::Information); m_infoMessage->setPosition(KTextEditor::Message::TopInView); m_infoMessage->setAutoHide(2000); m_infoMessage->setAutoHideMode(KTextEditor::Message::Immediate); m_infoMessage->setView(m_mainWindow->activeView()); m_mainWindow->activeView()->document()->postMessage(m_infoMessage); } else if (startFromCursor) { delete m_infoMessage; const QString msg = i18n("Next from cursor"); m_infoMessage = new KTextEditor::Message(msg, KTextEditor::Message::Information); m_infoMessage->setPosition(KTextEditor::Message::BottomInView); m_infoMessage->setAutoHide(2000); m_infoMessage->setAutoHideMode(KTextEditor::Message::Immediate); m_infoMessage->setView(m_mainWindow->activeView()); m_mainWindow->activeView()->document()->postMessage(m_infoMessage); } else if (wrapFromFirst) { delete m_infoMessage; const QString msg = i18n("Continuing from first match"); m_infoMessage = new KTextEditor::Message(msg, KTextEditor::Message::Information); m_infoMessage->setPosition(KTextEditor::Message::TopInView); m_infoMessage->setAutoHide(2000); m_infoMessage->setAutoHideMode(KTextEditor::Message::Immediate); m_infoMessage->setView(m_mainWindow->activeView()); m_mainWindow->activeView()->document()->postMessage(m_infoMessage); } } void KatePluginSearchView::goToPreviousMatch() { bool fromLast = false; Results *res = qobject_cast(m_ui.resultTabWidget->currentWidget()); if (!res) { return; } if (res->tree->topLevelItemCount() == 0) { return; } QTreeWidgetItem *curr = res->tree->currentItem(); if (!curr) { // no item has been visited -> jump to the closest match before current cursor position // check if current file is in the file curr = res->tree->topLevelItem(0); while (curr && curr->data(0, ReplaceMatches::FileUrlRole).toString() != m_mainWindow->activeView()->document()->url().toString()) { curr = res->tree->itemBelow(curr); } // now we are either in this file or !curr if (curr) { res->tree->expandItem(curr); int lineNr = 0; int columnNr = 0; if (m_mainWindow->activeView()->cursorPosition().isValid()) { lineNr = m_mainWindow->activeView()->cursorPosition().line(); columnNr = m_mainWindow->activeView()->cursorPosition().column()-1; } if (!curr->data(0, ReplaceMatches::ColumnRole).isValid()) { curr = res->tree->itemBelow(curr); }; while (curr && curr->data(0, ReplaceMatches::LineRole).toInt() <= lineNr && curr->data(0, ReplaceMatches::FileUrlRole).toString() == m_mainWindow->activeView()->document()->url().toString()) { if (curr->data(0, ReplaceMatches::LineRole).toInt() == lineNr && curr->data(0, ReplaceMatches::ColumnRole).toInt() > columnNr) { break; } curr = res->tree->itemBelow(curr); } } } QTreeWidgetItem *startChild = curr; // go to the item above. (curr == null is not a problem) curr = res->tree->itemAbove(curr); // expand the items above if needed if (curr && curr->data(0, ReplaceMatches::ColumnRole).toString().isEmpty()) { res->tree->expandItem(curr); // probably this file item curr = res->tree->itemAbove(curr); if (curr && curr->data(0, ReplaceMatches::ColumnRole).toString().isEmpty()) { res->tree->expandItem(curr); // probably file above if this is reached } curr = res->tree->itemAbove(startChild); } // skip file name items and the root item while (curr && curr->data(0, ReplaceMatches::ColumnRole).toString().isEmpty()) { curr = res->tree->itemAbove(curr); } if (!curr) { // select the last child of the last next-to-top-level item QTreeWidgetItem *root = res->tree->topLevelItem(0); // select the last "root item" if (!root || (root->childCount() < 1)) return; root = root->child(root->childCount()-1); // select the last match of the "root item" if (!root || (root->childCount() < 1)) return; curr = root->child(root->childCount()-1); fromLast = true; } itemSelected(curr); if (fromLast) { delete m_infoMessage; const QString msg = i18n("Continuing from last match"); m_infoMessage = new KTextEditor::Message(msg, KTextEditor::Message::Information); m_infoMessage->setPosition(KTextEditor::Message::BottomInView); m_infoMessage->setAutoHide(2000); m_infoMessage->setAutoHideMode(KTextEditor::Message::Immediate); m_infoMessage->setView(m_mainWindow->activeView()); m_mainWindow->activeView()->document()->postMessage(m_infoMessage); } } void KatePluginSearchView::readSessionConfig(const KConfigGroup &cg) { m_ui.searchCombo->clear(); m_ui.searchCombo->addItem(QString()); // Add empty Item m_ui.searchCombo->addItems(cg.readEntry("Search", QStringList())); m_ui.replaceCombo->clear(); m_ui.replaceCombo->addItem(QString()); // Add empty Item m_ui.replaceCombo->addItems(cg.readEntry("Replaces", QStringList())); m_ui.matchCase->setChecked(cg.readEntry("MatchCase", false)); m_ui.useRegExp->setChecked(cg.readEntry("UseRegExp", false)); m_ui.expandResults->setChecked(cg.readEntry("ExpandSearchResults", false)); int searchPlaceIndex = cg.readEntry("Place", 1); if (searchPlaceIndex < 0) { searchPlaceIndex = Folder; // for the case we happen to read -1 as Place } if ((searchPlaceIndex == Project) && (searchPlaceIndex >= m_ui.searchPlaceCombo->count())) { // handle the case that project mode was selected, but not yet available m_switchToProjectModeWhenAvailable = true; searchPlaceIndex = Folder; } m_ui.searchPlaceCombo->setCurrentIndex(searchPlaceIndex); m_ui.recursiveCheckBox->setChecked(cg.readEntry("Recursive", true)); m_ui.hiddenCheckBox->setChecked(cg.readEntry("HiddenFiles", false)); m_ui.symLinkCheckBox->setChecked(cg.readEntry("FollowSymLink", false)); m_ui.binaryCheckBox->setChecked(cg.readEntry("BinaryFiles", false)); m_ui.folderRequester->comboBox()->clear(); m_ui.folderRequester->comboBox()->addItems(cg.readEntry("SearchDiskFiless", QStringList())); m_ui.folderRequester->setText(cg.readEntry("SearchDiskFiles", QString())); m_ui.filterCombo->clear(); m_ui.filterCombo->addItems(cg.readEntry("Filters", QStringList())); m_ui.filterCombo->setCurrentIndex(cg.readEntry("CurrentFilter", -1)); m_ui.excludeCombo->clear(); m_ui.excludeCombo->addItems(cg.readEntry("ExcludeFilters", QStringList())); m_ui.excludeCombo->setCurrentIndex(cg.readEntry("CurrentExcludeFilter", -1)); m_ui.displayOptions->setChecked(searchPlaceIndex == Folder); } void KatePluginSearchView::writeSessionConfig(KConfigGroup &cg) { QStringList searchHistoy; for (int i=1; icount(); i++) { searchHistoy << m_ui.searchCombo->itemText(i); } cg.writeEntry("Search", searchHistoy); QStringList replaceHistoy; for (int i=1; icount(); i++) { replaceHistoy << m_ui.replaceCombo->itemText(i); } cg.writeEntry("Replaces", replaceHistoy); cg.writeEntry("MatchCase", m_ui.matchCase->isChecked()); cg.writeEntry("UseRegExp", m_ui.useRegExp->isChecked()); cg.writeEntry("ExpandSearchResults", m_ui.expandResults->isChecked()); cg.writeEntry("Place", m_ui.searchPlaceCombo->currentIndex()); cg.writeEntry("Recursive", m_ui.recursiveCheckBox->isChecked()); cg.writeEntry("HiddenFiles", m_ui.hiddenCheckBox->isChecked()); cg.writeEntry("FollowSymLink", m_ui.symLinkCheckBox->isChecked()); cg.writeEntry("BinaryFiles", m_ui.binaryCheckBox->isChecked()); QStringList folders; for (int i=0; icomboBox()->count(), 10); i++) { folders << m_ui.folderRequester->comboBox()->itemText(i); } cg.writeEntry("SearchDiskFiless", folders); cg.writeEntry("SearchDiskFiles", m_ui.folderRequester->text()); QStringList filterItems; for (int i=0; icount(), 10); i++) { filterItems << m_ui.filterCombo->itemText(i); } cg.writeEntry("Filters", filterItems); cg.writeEntry("CurrentFilter", m_ui.filterCombo->findText(m_ui.filterCombo->currentText())); QStringList excludeFilterItems; for (int i=0; icount(), 10); i++) { excludeFilterItems << m_ui.excludeCombo->itemText(i); } cg.writeEntry("ExcludeFilters", excludeFilterItems); cg.writeEntry("CurrentExcludeFilter", m_ui.excludeCombo->findText(m_ui.excludeCombo->currentText())); } void KatePluginSearchView::addTab() { if ((sender() != m_ui.newTabButton) && (m_ui.resultTabWidget->count() > 0) && m_ui.resultTabWidget->tabText(m_ui.resultTabWidget->currentIndex()).isEmpty()) { return; } Results *res = new Results(); res->tree->setRootIsDecorated(false); connect(res->tree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT (itemSelected(QTreeWidgetItem*)), Qt::QueuedConnection); res->searchPlaceIndex = m_ui.searchPlaceCombo->currentIndex(); res->useRegExp = m_ui.useRegExp->isChecked(); res->matchCase = m_ui.matchCase->isChecked(); m_ui.resultTabWidget->addTab(res, QString()); m_ui.resultTabWidget->setCurrentIndex(m_ui.resultTabWidget->count()-1); m_ui.stackedWidget->setCurrentIndex(0); m_ui.resultTabWidget->tabBar()->show(); m_ui.displayOptions->setChecked(false); res->tree->installEventFilter(this); } void KatePluginSearchView::tabCloseRequested(int index) { Results *tmp = qobject_cast(m_ui.resultTabWidget->widget(index)); if (m_curResults == tmp) { m_searchOpenFiles.cancelSearch(); m_searchDiskFiles.cancelSearch(); } if (m_ui.resultTabWidget->count() > 1) { delete tmp; // remove the tab m_curResults = nullptr; } if (m_ui.resultTabWidget->count() == 1) { m_ui.resultTabWidget->tabBar()->hide(); } } void KatePluginSearchView::resultTabChanged(int index) { if (index < 0) { return; } Results *res = qobject_cast(m_ui.resultTabWidget->widget(index)); if (!res) { qDebug() << "No res found"; return; } m_ui.searchCombo->blockSignals(true); m_ui.matchCase->blockSignals(true); m_ui.useRegExp->blockSignals(true); m_ui.searchPlaceCombo->blockSignals(true); m_ui.searchCombo->lineEdit()->setText(m_ui.resultTabWidget->tabText(index)); m_ui.useRegExp->setChecked(res->useRegExp); m_ui.matchCase->setChecked(res->matchCase); m_ui.searchPlaceCombo->setCurrentIndex(res->searchPlaceIndex); m_ui.searchCombo->blockSignals(false); m_ui.matchCase->blockSignals(false); m_ui.useRegExp->blockSignals(false); m_ui.searchPlaceCombo->blockSignals(false); searchPlaceChanged(); } bool KatePluginSearchView::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::KeyPress) { QKeyEvent *ke = static_cast(event); QTreeWidget *tree = qobject_cast(obj); if (tree) { if (ke->matches(QKeySequence::Copy)) { // user pressed ctrl+c -> copy full URL to the clipboard QVariant variant = tree->currentItem()->data(0, ReplaceMatches::FileUrlRole); QApplication::clipboard()->setText(variant.toString()); event->accept(); return true; } if (ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return) { if (tree->currentItem()) { itemSelected(tree->currentItem()); event->accept(); return true; } } } // NOTE: Qt::Key_Escape is handeled by handleEsc } return QObject::eventFilter(obj, event); } void KatePluginSearchView::searchContextMenu(const QPoint& pos) { QSet actionPointers; QMenu* const contextMenu = m_ui.searchCombo->lineEdit()->createStandardContextMenu(); if (!contextMenu) return; if (m_ui.useRegExp->isChecked()) { QMenu* menu = contextMenu->addMenu(i18n("Add...")); if (!menu) return; menu->setIcon(QIcon::fromTheme(QStringLiteral("list-add"))); actionPointers << menuEntry(menu, QStringLiteral("^"), QStringLiteral(""), i18n("Beginning of line")); actionPointers << menuEntry(menu, QStringLiteral("$"), QStringLiteral(""), i18n("End of line")); menu->addSeparator(); actionPointers << menuEntry(menu, QStringLiteral("."), QStringLiteral(""), i18n("Any single character (excluding line breaks)")); menu->addSeparator(); actionPointers << menuEntry(menu, QStringLiteral("+"), QStringLiteral(""), i18n("One or more occurrences")); actionPointers << menuEntry(menu, QStringLiteral("*"), QStringLiteral(""), i18n("Zero or more occurrences")); actionPointers << menuEntry(menu, QStringLiteral("?"), QStringLiteral(""), i18n("Zero or one occurrences")); actionPointers << menuEntry(menu, QStringLiteral("{"), QStringLiteral(",}"), i18n(" through occurrences"), QStringLiteral("{a"), QStringLiteral(",b}")); menu->addSeparator(); actionPointers << menuEntry(menu, QStringLiteral("("), QStringLiteral(")"), i18n("Group, capturing")); actionPointers << menuEntry(menu, QStringLiteral("|"), QStringLiteral(""), i18n("Or")); actionPointers << menuEntry(menu, QStringLiteral("["), QStringLiteral("]"), i18n("Set of characters")); actionPointers << menuEntry(menu, QStringLiteral("[^"), QStringLiteral("]"), i18n("Negative set of characters")); actionPointers << menuEntry(menu, QStringLiteral("(?:"), QStringLiteral(")"), i18n("Group, non-capturing"), QStringLiteral("(?:E")); actionPointers << menuEntry(menu, QStringLiteral("(?="), QStringLiteral(")"), i18n("Lookahead"), QStringLiteral("(?=E")); actionPointers << menuEntry(menu, QStringLiteral("(?!"), QStringLiteral(")"), i18n("Negative lookahead"), QStringLiteral("(?!E")); menu->addSeparator(); actionPointers << menuEntry(menu, QStringLiteral("\\n"), QStringLiteral(""), i18n("Line break")); actionPointers << menuEntry(menu, QStringLiteral("\\t"), QStringLiteral(""), i18n("Tab")); actionPointers << menuEntry(menu, QStringLiteral("\\b"), QStringLiteral(""), i18n("Word boundary")); actionPointers << menuEntry(menu, QStringLiteral("\\B"), QStringLiteral(""), i18n("Not word boundary")); actionPointers << menuEntry(menu, QStringLiteral("\\d"), QStringLiteral(""), i18n("Digit")); actionPointers << menuEntry(menu, QStringLiteral("\\D"), QStringLiteral(""), i18n("Non-digit")); actionPointers << menuEntry(menu, QStringLiteral("\\s"), QStringLiteral(""), i18n("Whitespace (excluding line breaks)")); actionPointers << menuEntry(menu, QStringLiteral("\\S"), QStringLiteral(""), i18n("Non-whitespace (excluding line breaks)")); actionPointers << menuEntry(menu, QStringLiteral("\\w"), QStringLiteral(""), i18n("Word character (alphanumerics plus '_')")); actionPointers << menuEntry(menu, QStringLiteral("\\W"), QStringLiteral(""), i18n("Non-word character")); } // Show menu QAction * const result = contextMenu->exec(m_ui.searchCombo->mapToGlobal(pos)); // Act on action if (result && actionPointers.contains(result)) { QLineEdit * lineEdit = m_ui.searchCombo->lineEdit(); const int cursorPos = lineEdit->cursorPosition(); QStringList beforeAfter = result->data().toString().split(QLatin1Char(' ')); if (beforeAfter.size() != 2) return; lineEdit->insert(beforeAfter[0] + beforeAfter[1]); lineEdit->setCursorPosition(cursorPos + beforeAfter[0].count()); lineEdit->setFocus(); } } void KatePluginSearchView::slotPluginViewCreated (const QString &name, QObject *pluginView) { // add view if (name == QStringLiteral("kateprojectplugin")) { m_projectPluginView = pluginView; slotProjectFileNameChanged (); connect (pluginView, SIGNAL(projectFileNameChanged()), this, SLOT(slotProjectFileNameChanged())); } } void KatePluginSearchView::slotPluginViewDeleted (const QString &name, QObject *) { // remove view if (name == QStringLiteral("kateprojectplugin")) { m_projectPluginView = nullptr; slotProjectFileNameChanged (); } } void KatePluginSearchView::slotProjectFileNameChanged () { // query new project file name QString projectFileName; if (m_projectPluginView) { projectFileName = m_projectPluginView->property("projectFileName").toString(); } // have project, enable gui for it if (!projectFileName.isEmpty()) { if (m_ui.searchPlaceCombo->count() <= Project) { // add "in Project" m_ui.searchPlaceCombo->addItem (QIcon::fromTheme(QStringLiteral("project-open")), i18n("In Current Project")); if (m_switchToProjectModeWhenAvailable) { // switch to search "in Project" m_switchToProjectModeWhenAvailable = false; setSearchPlace(Project); } // add "in Open Projects" m_ui.searchPlaceCombo->addItem(QIcon::fromTheme(QStringLiteral("project-open")), i18n("In All Open Projects")); } } // else: disable gui for it else { if (m_ui.searchPlaceCombo->count() >= Project) { // switch to search "in Open files", if "in Project" is active if (m_ui.searchPlaceCombo->currentIndex() >= Project) { setSearchPlace(OpenFiles); } // remove "in Project" and "in all projects" while (m_ui.searchPlaceCombo->count() > Project) { m_ui.searchPlaceCombo->removeItem(m_ui.searchPlaceCombo->count()-1); } } } } KateSearchCommand::KateSearchCommand(QObject *parent) : KTextEditor::Command(QStringList() << QStringLiteral("grep") << QStringLiteral("newGrep") << QStringLiteral("search") << QStringLiteral("newSearch") << QStringLiteral("pgrep") << QStringLiteral("newPGrep"), parent) { } bool KateSearchCommand::exec(KTextEditor::View* /*view*/, const QString& cmd, QString& /*msg*/, const KTextEditor::Range &) { //create a list of args QStringList args(cmd.split(QLatin1Char(' '), QString::KeepEmptyParts)); QString command = args.takeFirst(); QString searchText = args.join(QLatin1Char(' ')); if (command == QStringLiteral("grep") || command == QStringLiteral("newGrep")) { emit setSearchPlace(KatePluginSearchView::Folder); emit setCurrentFolder(); if (command == QStringLiteral("newGrep")) emit newTab(); } else if (command == QStringLiteral("search") || command == QStringLiteral("newSearch")) { emit setSearchPlace(KatePluginSearchView::OpenFiles); if (command == QStringLiteral("newSearch")) emit newTab(); } else if (command == QStringLiteral("pgrep") || command == QStringLiteral("newPGrep")) { emit setSearchPlace(KatePluginSearchView::Project); if (command == QStringLiteral("newPGrep")) emit newTab(); } emit setSearchString(searchText); emit startSearch(); return true; } bool KateSearchCommand::help(KTextEditor::View */*view*/, const QString &cmd, QString & msg) { if (cmd.startsWith(QStringLiteral("grep"))) { msg = i18n("Usage: grep [pattern to search for in folder]"); } else if (cmd.startsWith(QStringLiteral("newGrep"))) { msg = i18n("Usage: newGrep [pattern to search for in folder]"); } else if (cmd.startsWith(QStringLiteral("search"))) { msg = i18n("Usage: search [pattern to search for in open files]"); } else if (cmd.startsWith(QStringLiteral("newSearch"))) { msg = i18n("Usage: search [pattern to search for in open files]"); } else if (cmd.startsWith(QStringLiteral("pgrep"))) { msg = i18n("Usage: pgrep [pattern to search for in current project]"); } else if (cmd.startsWith(QStringLiteral("newPGrep"))) { msg = i18n("Usage: newPGrep [pattern to search for in current project]"); } return true; } #include "plugin_search.moc" // kate: space-indent on; indent-width 4; replace-tabs on; diff --git a/addons/search/plugin_search.h b/addons/search/plugin_search.h index 700115587..d3e13839e 100644 --- a/addons/search/plugin_search.h +++ b/addons/search/plugin_search.h @@ -1,237 +1,237 @@ /* Kate search plugin * * Copyright (C) 2011-2013 by Kåre Särs * * 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 in a file called COPYING; if not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ #ifndef _PLUGIN_SEARCH_H_ #define _PLUGIN_SEARCH_H_ #include #include #include #include #include #include #include #include #include #include #include "ui_search.h" #include "ui_results.h" #include "search_open_files.h" #include "SearchDiskFiles.h" #include "FolderFilesList.h" #include "replace_matches.h" class KateSearchCommand; namespace KTextEditor{ class MovingRange; } class Results: public QWidget, public Ui::Results { Q_OBJECT public: Results(QWidget *parent = nullptr); int matches; QRegularExpression regExp; bool useRegExp; bool matchCase; QString replaceStr; int searchPlaceIndex; QString treeRootText; }; // This class keeps the focus inside the S&R plugin when pressing tab/shift+tab by overriding focusNextPrevChild() class ContainerWidget:public QWidget { Q_OBJECT public: ContainerWidget(QWidget *parent): QWidget(parent) {} Q_SIGNALS: void nextFocus(QWidget *currentWidget, bool *found, bool next); protected: - bool focusNextPrevChild (bool next) Q_DECL_OVERRIDE; + bool focusNextPrevChild (bool next) override; }; class KatePluginSearch : public KTextEditor::Plugin { Q_OBJECT public: explicit KatePluginSearch(QObject* parent = nullptr, const QList& = QList()); - virtual ~KatePluginSearch(); + ~KatePluginSearch() override; - QObject *createView(KTextEditor::MainWindow *mainWindow) Q_DECL_OVERRIDE; + QObject *createView(KTextEditor::MainWindow *mainWindow) override; private: KateSearchCommand* m_searchCommand; }; class KatePluginSearchView : public QObject, public KXMLGUIClient, public KTextEditor::SessionConfigInterface { Q_OBJECT Q_INTERFACES(KTextEditor::SessionConfigInterface) public: enum SearchPlaces { CurrentFile, OpenFiles, Folder, Project, AllProjects }; KatePluginSearchView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mainWindow, KTextEditor::Application* application); - ~KatePluginSearchView(); + ~KatePluginSearchView() override; - void readSessionConfig (const KConfigGroup& config) Q_DECL_OVERRIDE; - void writeSessionConfig (KConfigGroup& config) Q_DECL_OVERRIDE; + void readSessionConfig (const KConfigGroup& config) override; + void writeSessionConfig (KConfigGroup& config) override; public Q_SLOTS: void startSearch(); void setSearchString(const QString &pattern); void navigateFolderUp(); void setCurrentFolder(); void setSearchPlace(int place); void goToNextMatch(); void goToPreviousMatch(); private Q_SLOTS: void openSearchView(); void handleEsc(QEvent *e); void nextFocus(QWidget *currentWidget, bool *found, bool next); void addTab(); void tabCloseRequested(int index); void toggleOptions(bool show); void searchContextMenu(const QPoint& pos); void searchPlaceChanged(); void startSearchWhileTyping(); void folderFileListChanged(); void matchFound(const QString &url, const QString &fileName, int line, int column, const QString &lineContent, int matchLen); void addMatchMark(KTextEditor::Document* doc, int line, int column, int len); void searchDone(); void searchWhileTypingDone(); void indicateMatch(bool hasMatch); void searching(const QString &file); void itemSelected(QTreeWidgetItem *item); void clearMarks(); void clearDocMarks(KTextEditor::Document* doc); void replaceSingleMatch(); void replaceChecked(); void replaceStatus(const QUrl &url); void replaceDone(); void docViewChanged(); void resultTabChanged(int index); /** * keep track if the project plugin is alive and if the project file did change */ void slotPluginViewCreated (const QString &name, QObject *pluginView); void slotPluginViewDeleted (const QString &name, QObject *pluginView); void slotProjectFileNameChanged (); protected: - bool eventFilter(QObject *obj, QEvent *ev) Q_DECL_OVERRIDE; + bool eventFilter(QObject *obj, QEvent *ev) override; void addHeaderItem(); private: QTreeWidgetItem *rootFileItem(const QString &url, const QString &fName); QStringList filterFiles(const QStringList& files) const; Ui::SearchDialog m_ui; QWidget *m_toolView; KTextEditor::Application *m_kateApp; SearchOpenFiles m_searchOpenFiles; FolderFilesList m_folderFilesList; SearchDiskFiles m_searchDiskFiles; ReplaceMatches m_replacer; QAction *m_matchCase; QAction *m_useRegExp; Results *m_curResults; bool m_searchJustOpened; bool m_switchToProjectModeWhenAvailable; bool m_searchDiskFilesDone; bool m_searchOpenFilesDone; QString m_resultBaseDir; QList m_matchRanges; QTimer m_changeTimer; QPointer m_infoMessage; /** * current project plugin view, if any */ QObject *m_projectPluginView; /** * our main window */ KTextEditor::MainWindow *m_mainWindow; }; class KateSearchCommand : public KTextEditor::Command { Q_OBJECT public: KateSearchCommand(QObject *parent); Q_SIGNALS: void setSearchPlace(int place); void setCurrentFolder(); void setSearchString(const QString &pattern); void startSearch(); void newTab(); // // KTextEditor::Command // public: bool exec (KTextEditor::View *view, const QString &cmd, QString &msg, - const KTextEditor::Range &range = KTextEditor::Range::invalid()) Q_DECL_OVERRIDE; - bool help (KTextEditor::View *view, const QString &cmd, QString &msg) Q_DECL_OVERRIDE; + const KTextEditor::Range &range = KTextEditor::Range::invalid()) override; + bool help (KTextEditor::View *view, const QString &cmd, QString &msg) override; }; #endif // kate: space-indent on; indent-width 4; replace-tabs on; diff --git a/addons/sessionapplet/engine/katesessionsengine.h b/addons/sessionapplet/engine/katesessionsengine.h index ef5438be8..1849e98ee 100644 --- a/addons/sessionapplet/engine/katesessionsengine.h +++ b/addons/sessionapplet/engine/katesessionsengine.h @@ -1,38 +1,38 @@ /******************************************************************** This file is part of the KDE project. Copyright (C) 2014 Joseph Wenninger based on clipboard engine: Copyright (C) 2014 Martin Gräßlin 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 KATESESSIONS_ENGINE_H #define KATESESSIONS_ENGINE_H #include class KateSessionsEngine : public Plasma::DataEngine { Q_OBJECT public: KateSessionsEngine(QObject *parent, const QVariantList &args); - ~KateSessionsEngine(); + ~KateSessionsEngine() override; Plasma::Service *serviceForSource (const QString &source) override; }; #endif diff --git a/addons/sessionapplet/engine/katesessionsjob.h b/addons/sessionapplet/engine/katesessionsjob.h index a2c3df291..4bf302c37 100644 --- a/addons/sessionapplet/engine/katesessionsjob.h +++ b/addons/sessionapplet/engine/katesessionsjob.h @@ -1,41 +1,41 @@ /******************************************************************** This file is part of the KDE project. Copyright (C) 2014 Joseph Wenninger based on clipboard engine: Copyright (C) 2014 Martin Gräßlin 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 KLIPPER_CLIPBOARDJOB_H #define KLIPPER_CLIPBOARDJOB_H #include class KateSessionsEngine; class KateSessionsJob : public Plasma::ServiceJob { Q_OBJECT public: KateSessionsJob(KateSessionsEngine* engine,const QString &destination, const QString &operation, const QVariantMap ¶meters, QObject *parent=nullptr); - ~KateSessionsJob() = default; + ~KateSessionsJob() override = default; void start() override; private: KateSessionsEngine *m_engine; }; #endif diff --git a/addons/sessionapplet/engine/katesessionsmodel.h b/addons/sessionapplet/engine/katesessionsmodel.h index 9401b0c93..da4a35fa2 100644 --- a/addons/sessionapplet/engine/katesessionsmodel.h +++ b/addons/sessionapplet/engine/katesessionsmodel.h @@ -1,66 +1,66 @@ /*************************************************************************** * Copyright (C) 2014 Joseph Wenninger * * Copyright (C) 2008 by Montel Laurent * * * * 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 _KATESESSIONSMODEL_H_ #define _KATESESSIONSMODEL_H_ /* #include #include "ui_katesessionConfig.h" */ #include class QModelIndex; class KConfigDialog; class QStringList; class KateSessionsModel : public QStandardItemModel { Q_OBJECT public: KateSessionsModel(QObject *parent); - ~KateSessionsModel(); + ~KateSessionsModel() override; QHash< int, QByteArray > roleNames() const override; enum SpecificRoles { Uuid = Qt::UserRole+3, TypeRole = Qt::UserRole+4 }; protected Q_SLOTS: // void slotOnItemClicked(const QModelIndex &index); void slotUpdateSessionMenu(); // void slotSaveConfig(); protected: void initSessionFiles(); /* void createConfigurationInterface(KConfigDialog *parent); void configChanged();*/ private: QStringList m_sessions; QStringList m_fullList; QString m_sessionsDir; // KateSessionConfigInterface *m_config; }; #endif diff --git a/addons/sessionapplet/engine/katesessionsservice.h b/addons/sessionapplet/engine/katesessionsservice.h index 6e1ba7bf1..931652d3a 100644 --- a/addons/sessionapplet/engine/katesessionsservice.h +++ b/addons/sessionapplet/engine/katesessionsservice.h @@ -1,43 +1,43 @@ /******************************************************************** This file is part of the KDE project. Copyright (C) 2014 Joseph Wenninger based on clipboard engine: Copyright (C) 2014 Martin Gräßlin 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 KLIPPER_CLIPBOARDSERVICE_H #define KLIPPER_CLIPBOARDSERVICE_H #include class KateSessionsEngine; class KateSessionsService : public Plasma::Service { Q_OBJECT public: KateSessionsService(KateSessionsEngine *engine, const QString &uuid); - ~KateSessionsService() = default; + ~KateSessionsService() override = default; protected: Plasma::ServiceJob *createJob(const QString &operation, QVariantMap ¶meters) override; private: KateSessionsEngine *m_engine; QString m_uuid; }; #endif diff --git a/addons/snippets/editsnippet.h b/addons/snippets/editsnippet.h index ac3bd0126..851e203c6 100644 --- a/addons/snippets/editsnippet.h +++ b/addons/snippets/editsnippet.h @@ -1,74 +1,74 @@ /* This file is part of the Kate project. * Based on the snippet plugin from KDevelop 4. * * Copyright (C) 2007 Robert Gruber * Copyright (C) 2010 Milian Wolff * Copyright (C) 2012 Christoph Cullmann * * 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 EDITSNIPPET_H #define EDITSNIPPET_H #include namespace KTextEditor { class View; } class SnippetRepository; class Snippet; namespace Ui { class EditSnippetBase; } /** * This dialog is used to create/edit snippets in a given repository. * * @author Milian Wolff */ class EditSnippet : public QDialog { Q_OBJECT public: /// @p snippet set to 0 when you want to create a new snippet. explicit EditSnippet(SnippetRepository* repo, Snippet* snippet, QWidget* parent = nullptr); - virtual ~EditSnippet(); + ~EditSnippet() override; void setSnippetText(const QString& text); - void reject() Q_DECL_OVERRIDE; + void reject() override; private: Ui::EditSnippetBase* m_ui; SnippetRepository* m_repo; Snippet* m_snippet; KTextEditor::View* m_snippetView; KTextEditor::View* m_scriptsView; KTextEditor::View* m_testView; bool m_topBoxModified; QPushButton* m_okButton; private Q_SLOTS: void test(); void save(); void validate(); void topBoxModified(); }; #endif diff --git a/addons/snippets/katesnippetglobal.h b/addons/snippets/katesnippetglobal.h index ed74a6238..5e253b4b4 100644 --- a/addons/snippets/katesnippetglobal.h +++ b/addons/snippets/katesnippetglobal.h @@ -1,77 +1,77 @@ /* This file is part of the Kate project. * Based on the snippet plugin from KDevelop 4. * * Copyright (C) 2007 Robert Gruber * Copyright (C) 2012 Christoph Cullmann * * 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 __SNIPPETPLUGIN_H__ #define __SNIPPETPLUGIN_H__ #include #include #include class SnippetCompletionModel; class Snippet; /** * This is the main class of KDevelop's snippet plugin. * @author Robert Gruber */ class KateSnippetGlobal : public QObject { Q_OBJECT public: KateSnippetGlobal(QObject *parent, const QVariantList &args = QVariantList() ); - ~KateSnippetGlobal (); + ~KateSnippetGlobal () override; /** * Inserts the given @p snippet into the currently active view. * If the current active view is not inherited from KTextEditor::View * nothing will happen. */ void insertSnippet(Snippet* snippet); static KateSnippetGlobal* self() { return s_self; } /** * Code completion model. * @return code completion model for snippets */ SnippetCompletionModel *completionModel () { return m_model.data(); } public Q_SLOTS: /** * Create snippet for given view, e.g. by using the selection * @param view view to create snippet for */ void createSnippet (KTextEditor::View *view); void insertSnippetFromActionData(); private: static KateSnippetGlobal *s_self; QScopedPointer m_model; QPointer m_activeViewForDialog; }; #endif diff --git a/addons/snippets/katesnippets.h b/addons/snippets/katesnippets.h index caf44e646..c353f81e3 100644 --- a/addons/snippets/katesnippets.h +++ b/addons/snippets/katesnippets.h @@ -1,89 +1,89 @@ /* This file is part of the Kate project. * * Copyright (C) 2010 Christoph Cullmann * * 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 __KATE_SNIPPETS_H__ #define __KATE_SNIPPETS_H__ #include #include #include #include #include "katesnippetglobal.h" class SnippetView; class KateSnippetsPluginView; class KateSnippetsPlugin: public KTextEditor::Plugin { Q_OBJECT friend class KateSnippetsPluginView; public: explicit KateSnippetsPlugin(QObject *parent = nullptr, const QList & = QList()); - virtual ~KateSnippetsPlugin(); + ~KateSnippetsPlugin() override; - QObject *createView(KTextEditor::MainWindow *mainWindow) Q_DECL_OVERRIDE; + QObject *createView(KTextEditor::MainWindow *mainWindow) override; private: KateSnippetGlobal *m_snippetGlobal; }; class KateSnippetsPluginView : public QObject, public KXMLGUIClient { Q_OBJECT public: /** * Constructor. */ KateSnippetsPluginView(KateSnippetsPlugin *plugin, KTextEditor::MainWindow *mainWindow); /** * Virtual destructor. */ - ~KateSnippetsPluginView(); + ~KateSnippetsPluginView() override; void readConfig(); private Q_SLOTS: /** * New view got created, we need to update our connections * @param view new created view */ void slotViewCreated(KTextEditor::View *view); void createSnippet(); private: KateSnippetsPlugin *m_plugin; KTextEditor::MainWindow *m_mainWindow; QPointer m_toolView; SnippetView *m_snippets; /** * remember for which text views we might need to cleanup stuff */ QVector< QPointer > m_textViews; }; #endif diff --git a/addons/snippets/snippet.h b/addons/snippets/snippet.h index f17f85d4e..874200737 100644 --- a/addons/snippets/snippet.h +++ b/addons/snippets/snippet.h @@ -1,77 +1,77 @@ /* This file is part of the Kate project. * Based on the snippet plugin from KDevelop 4. * * Copyright (C) 2007 Robert Gruber * Copyright (C) 2010 Milian Wolff * Copyright (C) 2012 Christoph Cullmann * * 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 __SNIPPET_H__ #define __SNIPPET_H__ #include class QAction; /** * One object of this class represents a single snippet. * Multiple snippets are stored in one repository (XML-file). * * To access the snippet's name (which should also be used for matching * during code completion) use @p QStandardItem::text(). * * @author Robert Gruber * @author Milian Wolff */ class Snippet : public QStandardItem { public: /** * Construct an empty snippet. */ Snippet(); - ~Snippet(); + ~Snippet() override; /** * Returns the actual contents of this snippet. */ QString snippet() const; /** * Sets the actual contents of this snippet. */ void setSnippet(const QString& snippet); /** * Action to trigger insertion of this snippet. */ QAction* action(); void registerActionForView(QWidget* view); - QVariant data(int role = Qt::UserRole + 1) const Q_DECL_OVERRIDE; + QVariant data(int role = Qt::UserRole + 1) const override; private: /// the actual snippet contents aka \code\endcode QString m_snippet; /// the insertion action for this snippet. QAction* m_action; }; Q_DECLARE_METATYPE ( Snippet* ) #endif diff --git a/addons/snippets/snippetcompletionmodel.h b/addons/snippets/snippetcompletionmodel.h index 673dfc3f8..6cb944feb 100644 --- a/addons/snippets/snippetcompletionmodel.h +++ b/addons/snippets/snippetcompletionmodel.h @@ -1,63 +1,63 @@ /* This file is part of the Kate project. * Based on the snippet plugin from KDevelop 4. * * Copyright (C) 2008 Andreas Pakulat * Copyright (C) 2012 Christoph Cullmann * * 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 SNIPPETCOMPLETIONMODEL_H #define SNIPPETCOMPLETIONMODEL_H #include #include #include namespace KTextEditor { class View; } class SnippetCompletionItem; class SnippetCompletionModel : public KTextEditor::CodeCompletionModel, public KTextEditor::CodeCompletionModelControllerInterface { Q_OBJECT Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface) public: SnippetCompletionModel(); - ~SnippetCompletionModel(); + ~SnippetCompletionModel() override; - QVariant data( const QModelIndex& idx, int role = Qt::DisplayRole ) const Q_DECL_OVERRIDE; + QVariant data( const QModelIndex& idx, int role = Qt::DisplayRole ) const override; void completionInvoked(KTextEditor::View *view, const KTextEditor::Range &range, - KTextEditor::CodeCompletionModel::InvocationType invocationType) Q_DECL_OVERRIDE; - void executeCompletionItem (KTextEditor::View *view, const KTextEditor::Range &word, const QModelIndex &index) const Q_DECL_OVERRIDE; - int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE; - QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE; - QModelIndex parent(const QModelIndex& index) const Q_DECL_OVERRIDE; - - KTextEditor::Range completionRange(KTextEditor::View* view, const KTextEditor::Cursor& position) Q_DECL_OVERRIDE; - bool shouldAbortCompletion(KTextEditor::View* view, const KTextEditor::Range& range, const QString& currentCompletion) Q_DECL_OVERRIDE; + KTextEditor::CodeCompletionModel::InvocationType invocationType) override; + void executeCompletionItem (KTextEditor::View *view, const KTextEditor::Range &word, const QModelIndex &index) const override; + int rowCount(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; + + KTextEditor::Range completionRange(KTextEditor::View* view, const KTextEditor::Cursor& position) override; + bool shouldAbortCompletion(KTextEditor::View* view, const KTextEditor::Range& range, const QString& currentCompletion) override; private: void initData(KTextEditor::View* view); QList m_snippets; }; #endif diff --git a/addons/snippets/snippetrepository.h b/addons/snippets/snippetrepository.h index d00d655da..58bcf32e8 100644 --- a/addons/snippets/snippetrepository.h +++ b/addons/snippets/snippetrepository.h @@ -1,166 +1,166 @@ /* This file is part of the Kate project. * Based on the snippet plugin from KDevelop 4. * * Copyright (C) 2007 Robert Gruber * Copyright (C) 2010 Milian Wolff * Copyright (C) 2012 Christoph Cullmann * * 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 __SNIPPETREPOSITORY_H__ #define __SNIPPETREPOSITORY_H__ #include #include #include #include namespace KTextEditor { } /** * Each object of this type represents a repository of snippets. Each repository * has a name and will be saved to an XML file that includes all items of this repository. * * To access the snippets in this repo, iterate over it's children and dynamic_cast as required. * To add a snippet, @p appendRow() it. * To access the name of the repository, use @p text() and @p setText(). * * NOTE: Unchecked repositores are considered "disabled" in the sense that their snippets * won't show up during code completion. * * @author Robert Gruber * @author Milian Wolff */ class SnippetRepository : public QObject, public QStandardItem { Q_OBJECT public: /** * Creates a new SnippetRepository. When @p file exists it will be parsed (XML). * * @param file Location of the snippet's repository file. */ SnippetRepository(const QString& file); - ~SnippetRepository(); + ~SnippetRepository() override; /** * Creates a snippet repository for the given name and adds it to the SnippetStore. */ static SnippetRepository* createRepoFromName(const QString& name); /** * The license for the snippets contained in this repository. */ QString license() const; /** * Sets the license for the snippets contained in this repository. */ void setLicense(const QString& license); /** * The author(s) of the snippets contained in this repository. */ QString authors() const; /** * Sets the author(s) of the snippets contained in this repository. */ void setAuthors(const QString& authors); /** * The valid filetypes for the snippets contained in this repository. * Empty list means no restriction on the modes. * @see KTextEditor::Document::mode() */ QStringList fileTypes() const; /** * Sets the valid filetypes for the snippets contained in this repository. * An empty list, or any list which contains an element "*" is treated as * a no-restriction filter. */ void setFileTypes(const QStringList& filetypes); /** * The path to this repository's file. */ const QString& file() const; /** * The namespace associated with this repository. * Used in CodeCompletion for filtering. */ QString completionNamespace() const; /** * Sets the code completion namespace for this repository. */ void setCompletionNamespace(const QString& completionNamespace); /** * The QtScript(s) associated with this repository. * * @since KDE 4.5 */ QString script() const; /** * Sets the QtScript(s) associated with this repository. * * @since KDE 4.5 */ void setScript(const QString& script); /** * Remove this repository from the disk. Also deletes the item and all its children. */ void remove(); /** * Save this repository to disk. */ void save(); /** * Get directory for data storage from QStandardPaths */ static QDir dataPath(); - QVariant data(int role = Qt::UserRole + 1) const Q_DECL_OVERRIDE; - void setData(const QVariant& value, int role = Qt::UserRole + 1) Q_DECL_OVERRIDE; + QVariant data(int role = Qt::UserRole + 1) const override; + void setData(const QVariant& value, int role = Qt::UserRole + 1) override; private Q_SLOTS: /// parses the XML file and load the containing snippets. void slotParseFile(); private: /// path to the repository file QString m_file; /// license of the snippets in this repo QString m_license; /// author(s) of the snippets in this repo QString m_authors; /// valid filetypes for the snippets in this repo QStringList m_filetypes; /// filtering namespace for code completion QString m_namespace; /// QtScript with functions to be used in the snippets; common to all snippets QString m_script; }; #endif diff --git a/addons/snippets/snippetstore.h b/addons/snippets/snippetstore.h index 8c931e35b..81089f4a9 100644 --- a/addons/snippets/snippetstore.h +++ b/addons/snippets/snippetstore.h @@ -1,73 +1,73 @@ /* This file is part of the Kate project. * Based on the snippet plugin from KDevelop 4. * * Copyright (C) 2007 Robert Gruber * Copyright (C) 2010 Milian Wolff * Copyright (C) 2012 Christoph Cullmann * * 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 __SNIPPETSTORE_H__ #define __SNIPPETSTORE_H__ #include #include class SnippetRepository; class KateSnippetGlobal; namespace KTextEditor { } /** * This class is implemented as singelton. * It represents the model containing all snippet repositories with their snippets. * @author Robert Gruber * @author Milian Wolff */ class SnippetStore : public QStandardItemModel { Q_OBJECT public: /** * Initialize the SnippetStore. */ static void init(KateSnippetGlobal* plugin); /** * Retuns the SnippetStore. Call init() to set it up first. */ static SnippetStore* self(); - virtual ~SnippetStore(); + ~SnippetStore() override; KConfigGroup getConfig(); - bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) Q_DECL_OVERRIDE; + bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; /** * Returns the repository for the given @p file if there is any. */ SnippetRepository* repositoryForFile(const QString &file); private: SnippetStore(KateSnippetGlobal* plugin); - Qt::ItemFlags flags (const QModelIndex & index) const Q_DECL_OVERRIDE; + Qt::ItemFlags flags (const QModelIndex & index) const override; static SnippetStore* m_self; KateSnippetGlobal* m_plugin; }; #endif diff --git a/addons/snippets/snippetview.cpp b/addons/snippets/snippetview.cpp index 6d26ecfb3..3180aab76 100644 --- a/addons/snippets/snippetview.cpp +++ b/addons/snippets/snippetview.cpp @@ -1,378 +1,378 @@ /* This file is part of the Kate project. * Based on the snippet plugin from KDevelop 4. * * Copyright (C) 2007 Robert Gruber * Copyright (C) 2010 Milian Wolff * Copyright (C) 2012 Christoph Cullmann * * 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 "snippetview.h" #include "snippet.h" #include "katesnippetglobal.h" #include "snippetrepository.h" #include "snippetstore.h" #include "editrepository.h" #include "editsnippet.h" #include #include #include #include #include #include #include #include #include class SnippetFilterModel : public QSortFilterProxyModel { public: SnippetFilterModel(QObject* parent = nullptr) : QSortFilterProxyModel(parent) { }; - bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const Q_DECL_OVERRIDE { + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override { auto index = sourceModel()->index(sourceRow, 0, sourceParent); auto item = SnippetStore::self()->itemFromIndex(index); if ( ! item ) { return false; } auto snippet = dynamic_cast(item); if ( ! snippet ) { return true; } return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); } }; void SnippetView::setupActionsForWindow(QWidget* widget) { const auto& model = SnippetStore::self(); for ( int i = 0; i < model->rowCount(); i++ ) { auto index = model->index(i, 0, QModelIndex()); auto item = model->itemFromIndex(index); auto repo = dynamic_cast(item); if ( ! repo ) { continue; } for ( int j = 0; j < model->rowCount(index); j++ ) { auto item = model->itemFromIndex(model->index(j, 0, index)); auto snippet = dynamic_cast(item); if ( ! snippet ) { continue; } snippet->registerActionForView(widget); } } } SnippetView::SnippetView(KateSnippetGlobal* plugin, QWidget* parent) : QWidget(parent), Ui::SnippetViewBase(), m_plugin(plugin) { Ui::SnippetViewBase::setupUi(this); setWindowTitle(i18n("Snippets")); setWindowIcon(QIcon::fromTheme(QLatin1String("document-new"), windowIcon())); snippetTree->setContextMenuPolicy( Qt::CustomContextMenu ); snippetTree->viewport()->installEventFilter( this ); connect(snippetTree, &QTreeView::customContextMenuRequested, this, &SnippetView::contextMenu); m_proxy = new SnippetFilterModel(this); m_proxy->setFilterKeyColumn(0); m_proxy->setSourceModel(SnippetStore::self()); connect(filterText, &KLineEdit::textChanged, m_proxy, &QSortFilterProxyModel::setFilterFixedString); snippetTree->setModel(m_proxy); snippetTree->header()->hide(); m_addRepoAction = new QAction(QIcon::fromTheme(QLatin1String("folder-new")), i18n("Add Repository"), this); connect(m_addRepoAction, &QAction::triggered, this, &SnippetView::slotAddRepo); addAction(m_addRepoAction); m_editRepoAction = new QAction(QIcon::fromTheme(QLatin1String("folder-txt")), i18n("Edit Repository"), this); connect(m_editRepoAction, &QAction::triggered, this, &SnippetView::slotEditRepo); addAction(m_editRepoAction); m_removeRepoAction = new QAction(QIcon::fromTheme(QLatin1String("edit-delete")), i18n("Remove Repository"), this); connect(m_removeRepoAction, &QAction::triggered, this, &SnippetView::slotRemoveRepo); addAction(m_removeRepoAction); const bool newStuffAllowed = KAuthorized::authorize(QStringLiteral("ghns")); m_putNewStuffAction = new QAction(QIcon::fromTheme(QLatin1String("get-hot-new-stuff")), i18n("Publish Repository"), this); m_putNewStuffAction->setVisible(newStuffAllowed); connect(m_putNewStuffAction, &QAction::triggered, this, &SnippetView::slotSnippetToGHNS); addAction(m_putNewStuffAction); QAction* separator = new QAction(this); separator->setSeparator(true); addAction(separator); m_addSnippetAction = new QAction(QIcon::fromTheme(QLatin1String("document-new")), i18n("Add Snippet"), this); connect(m_addSnippetAction, &QAction::triggered, this, &SnippetView::slotAddSnippet); addAction(m_addSnippetAction); m_editSnippetAction = new QAction(QIcon::fromTheme(QLatin1String("document-edit")), i18n("Edit Snippet"), this); connect(m_editSnippetAction, &QAction::triggered, this, &SnippetView::slotEditSnippet); addAction(m_editSnippetAction); m_removeSnippetAction = new QAction(QIcon::fromTheme(QLatin1String("document-close")), i18n("Remove Snippet"), this); connect(m_removeSnippetAction, &QAction::triggered, this, &SnippetView::slotRemoveSnippet); addAction(m_removeSnippetAction); addAction(separator); m_getNewStuffAction = new QAction(QIcon::fromTheme(QLatin1String("get-hot-new-stuff")), i18n("Get New Snippets"), this); m_getNewStuffAction->setVisible(newStuffAllowed); connect(m_getNewStuffAction, &QAction::triggered, this, &SnippetView::slotGHNS); addAction(m_getNewStuffAction); connect(snippetTree->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(validateActions())); validateActions(); connect(snippetTree->model(), &QAbstractItemModel::rowsInserted, this, [this]() { setupActionsForWindow(this); }); m_proxy->setDynamicSortFilter(true); m_proxy->sort(0, Qt::AscendingOrder); } void SnippetView::validateActions() { QStandardItem* item = currentItem(); Snippet* selectedSnippet = dynamic_cast( item ); SnippetRepository* selectedRepo = dynamic_cast( item ); m_addRepoAction->setEnabled(true); m_editRepoAction->setEnabled(selectedRepo); m_removeRepoAction->setEnabled(selectedRepo); m_putNewStuffAction->setEnabled(selectedRepo); m_addSnippetAction->setEnabled(selectedRepo || selectedSnippet); m_editSnippetAction->setEnabled(selectedSnippet); m_removeSnippetAction->setEnabled(selectedSnippet); } QStandardItem* SnippetView::currentItem() { ///TODO: support multiple selected items QModelIndex index = snippetTree->currentIndex(); index = m_proxy->mapToSource(index); return SnippetStore::self()->itemFromIndex( index ); } void SnippetView::slotSnippetClicked (const QModelIndex & index) { QStandardItem* item = SnippetStore::self()->itemFromIndex( m_proxy->mapToSource(index) ); if (!item) return; Snippet* snippet = dynamic_cast( item ); if (!snippet) return; m_plugin->insertSnippet( snippet ); } void SnippetView::contextMenu (const QPoint& pos) { QModelIndex index = snippetTree->indexAt( pos ); index = m_proxy->mapToSource(index); QStandardItem* item = SnippetStore::self()->itemFromIndex( index ); if (!item) { // User clicked into an empty place of the tree QMenu menu(this); menu.addSection(i18n("Snippets")); menu.addAction(m_addRepoAction); menu.addAction(m_getNewStuffAction); menu.exec(snippetTree->mapToGlobal(pos)); } else if (Snippet* snippet = dynamic_cast( item )) { QMenu menu(this); menu.addSection(i18n("Snippet: %1", snippet->text())); menu.addAction(m_editSnippetAction); menu.addAction(m_removeSnippetAction); menu.exec(snippetTree->mapToGlobal(pos)); } else if (SnippetRepository* repo = dynamic_cast( item )) { QMenu menu(this); menu.addSection(i18n("Repository: %1", repo->text())); menu.addAction(m_addSnippetAction); menu.addSeparator(); menu.addAction(m_editRepoAction); menu.addAction(m_removeRepoAction); menu.addAction(m_putNewStuffAction); menu.exec(snippetTree->mapToGlobal(pos)); } } void SnippetView::slotEditSnippet() { QStandardItem* item = currentItem(); if (!item) return; Snippet* snippet = dynamic_cast( item ); if (!snippet) return; SnippetRepository* repo = dynamic_cast( item->parent() ); if (!repo) return; EditSnippet dlg(repo, snippet, this); dlg.exec(); } void SnippetView::slotAddSnippet() { QStandardItem* item = currentItem(); if (!item) return; SnippetRepository* repo = dynamic_cast( item ); if (!repo) { repo = dynamic_cast( item->parent() ); if ( !repo ) return; } EditSnippet dlg(repo, nullptr, this); dlg.exec(); } void SnippetView::slotRemoveSnippet() { QStandardItem* item = currentItem(); if (!item) return; SnippetRepository* repo = dynamic_cast( item->parent() ); if (!repo) return; int ans = KMessageBox::warningContinueCancel( QApplication::activeWindow(), i18n("Do you really want to delete the snippet \"%1\"?", item->text()) ); if ( ans == KMessageBox::Continue ) { item->parent()->removeRow(item->row()); repo->save(); } } void SnippetView::slotAddRepo() { EditRepository dlg(nullptr, this); dlg.exec(); } void SnippetView::slotEditRepo() { QStandardItem* item = currentItem(); if (!item) return; SnippetRepository* repo = dynamic_cast( item ); if (!repo) return; EditRepository dlg(repo, this); dlg.exec(); } void SnippetView::slotRemoveRepo() { QStandardItem* item = currentItem(); if (!item) return; SnippetRepository* repo = dynamic_cast( item ); if (!repo) return; int ans = KMessageBox::warningContinueCancel( QApplication::activeWindow(), i18n("Do you really want to delete the repository \"%1\" with all its snippets?", repo->text()) ); if ( ans == KMessageBox::Continue ) { repo->remove(); } } void SnippetView::slotGHNS() { KNS3::DownloadDialog dialog(QLatin1String(":/katesnippets/ktexteditor_codesnippets_core.knsrc"), this); dialog.exec(); foreach ( const KNS3::Entry& entry, dialog.changedEntries() ) { foreach ( const QString& path, entry.uninstalledFiles() ) { if ( path.endsWith(QLatin1String(".xml")) ) { if ( SnippetRepository* repo = SnippetStore::self()->repositoryForFile(path) ) { repo->remove(); } } } foreach ( const QString& path, entry.installedFiles() ) { if ( path.endsWith(QLatin1String(".xml")) ) { SnippetStore::self()->appendRow(new SnippetRepository(path)); } } } } void SnippetView::slotSnippetToGHNS() { QStandardItem* item = currentItem(); if ( !item) return; SnippetRepository* repo = dynamic_cast( item ); if ( !repo ) return; KNS3::UploadDialog dialog(QLatin1String(":/katesnippets/ktexteditor_codesnippets_core.knsrc"), this); dialog.setUploadFile(QUrl::fromLocalFile(repo->file())); dialog.setUploadName(repo->text()); dialog.exec(); } bool SnippetView::eventFilter(QObject* obj, QEvent* e) { // no, listening to activated() is not enough since that would also trigger the edit mode which we _dont_ want here // users may still rename stuff via select + F2 though if (obj == snippetTree->viewport()) { const bool singleClick = style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, nullptr, this); if ( (!singleClick && e->type() == QEvent::MouseButtonDblClick) || (singleClick && e->type() == QEvent::MouseButtonRelease) ) { QMouseEvent* mouseEvent = dynamic_cast(e); Q_ASSERT(mouseEvent); QModelIndex clickedIndex = snippetTree->indexAt(mouseEvent->pos()); if (clickedIndex.isValid() && clickedIndex.parent().isValid()) { slotSnippetClicked(clickedIndex); e->accept(); return true; } } } return QObject::eventFilter(obj, e); } diff --git a/addons/snippets/snippetview.h b/addons/snippets/snippetview.h index 8e00b2c4a..682c8a7bc 100644 --- a/addons/snippets/snippetview.h +++ b/addons/snippets/snippetview.h @@ -1,122 +1,122 @@ /* This file is part of the Kate project. * Based on the snippet plugin from KDevelop 4. * * Copyright (C) 2007 Robert Gruber * Copyright (C) 2010 Milian Wolff * Copyright (C) 2012 Christoph Cullmann * Copyright (C) 2014 Sven Brauch * * 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 SNIPPETVIEW_H #define SNIPPETVIEW_H #include "ui_snippetview.h" class QStandardItem; class KateSnippetGlobal; class QAction; class QSortFilterProxyModel; namespace KTextEditor { } /** * This class gets embedded into the right tool view by the KateSnippetGlobal. * @author Robert Gruber * @author Milian Wolff */ class SnippetView : public QWidget, public Ui::SnippetViewBase { Q_OBJECT public: explicit SnippetView(KateSnippetGlobal* plugin, QWidget* parent = nullptr); public: void setupActionsForWindow(QWidget* widget); private Q_SLOTS: /** * Opens the "Add Repository" dialog. */ void slotAddRepo(); /** * Opens the "Edit repository" dialog. */ void slotEditRepo(); /** * Removes the selected repository from the disk. */ void slotRemoveRepo(); /** * Insert the selected snippet into the current file */ void slotSnippetClicked(const QModelIndex & index); /** * Open the edit dialog for the selected snippet */ void slotEditSnippet(); /** * Removes the selected snippet from the tree and the filesystem */ void slotRemoveSnippet(); /** * Creates a new snippet and open the edit dialog for it */ void slotAddSnippet(); /** * Slot to get hot new stuff. */ void slotGHNS(); /** * Slot to put the selected snippet to GHNS */ void slotSnippetToGHNS(); void contextMenu (const QPoint & pos); /// disables or enables available actions based on the currently selected item void validateActions(); /// insert snippet on double click - bool eventFilter(QObject* , QEvent* ) Q_DECL_OVERRIDE; + bool eventFilter(QObject* , QEvent* ) override; private: QStandardItem* currentItem(); KateSnippetGlobal* m_plugin; QSortFilterProxyModel* m_proxy; QAction *m_addRepoAction; QAction *m_removeRepoAction; QAction *m_editRepoAction; QAction *m_addSnippetAction; QAction *m_removeSnippetAction; QAction *m_editSnippetAction; QAction *m_getNewStuffAction; QAction *m_putNewStuffAction; }; #endif diff --git a/addons/symbolviewer/plugin_katesymbolviewer.h b/addons/symbolviewer/plugin_katesymbolviewer.h index d10551c20..f748fe613 100644 --- a/addons/symbolviewer/plugin_katesymbolviewer.h +++ b/addons/symbolviewer/plugin_katesymbolviewer.h @@ -1,312 +1,312 @@ /*************************************************************************** plugin_katesymbolviewer.h - description ------------------- begin : Apr 2 2003 author : 2003 Massimo Callegari email : massimocallegari@yahoo.it ***************************************************************************/ /*************************************************************************** * * * 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 _PLUGIN_KATE_SYMBOLVIEWER_H_ #define _PLUGIN_KATE_SYMBOLVIEWER_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /** * Plugin's config page */ class KatePluginSymbolViewerConfigPage : public KTextEditor::ConfigPage { Q_OBJECT friend class KatePluginSymbolViewer; public: explicit KatePluginSymbolViewerConfigPage (QObject* parent = nullptr, QWidget *parentWidget = nullptr); - ~KatePluginSymbolViewerConfigPage (); + ~KatePluginSymbolViewerConfigPage () override; /** * Reimplemented from KTextEditor::ConfigPage * just emits configPageApplyRequest( this ). */ - QString name() const Q_DECL_OVERRIDE; - QString fullName() const Q_DECL_OVERRIDE; - QIcon icon() const Q_DECL_OVERRIDE; + QString name() const override; + QString fullName() const override; + QIcon icon() const override; - void apply() Q_DECL_OVERRIDE; - void reset () Q_DECL_OVERRIDE { ; } - void defaults () Q_DECL_OVERRIDE { ; } + void apply() override; + void reset () override { ; } + void defaults () override { ; } Q_SIGNALS: /** * Ask the plugin to set initial values */ void configPageApplyRequest( KatePluginSymbolViewerConfigPage* ); /** * Ask the plugin to apply changes */ void configPageInitRequest( KatePluginSymbolViewerConfigPage* ); private: QCheckBox* viewReturns; QCheckBox* expandTree; QCheckBox* treeView; QCheckBox* sortSymbols; }; class KatePluginSymbolViewer; class KatePluginSymbolViewerView : public QObject, public KXMLGUIClient { Q_OBJECT public: KatePluginSymbolViewerView (KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mw); - virtual ~KatePluginSymbolViewerView (); + ~KatePluginSymbolViewerView () override; void parseSymbols(void); public Q_SLOTS: void slotRefreshSymbol(); void slotChangeMode(); void slotEnableSorting(); void slotDocChanged(); void goToSymbol(QTreeWidgetItem *); void slotShowContextMenu(const QPoint&); void toggleShowMacros(void); void toggleShowStructures(void); void toggleShowFunctions(void); void cursorPositionChanged(); QTreeWidgetItem *newActveItem(int &currMinLine, int currLine, QTreeWidgetItem *item); void updateCurrTreeItem(); void slotDocEdited(); protected: - bool eventFilter(QObject *obj, QEvent *ev) Q_DECL_OVERRIDE; + bool eventFilter(QObject *obj, QEvent *ev) override; private: KTextEditor::MainWindow *m_mainWindow; KatePluginSymbolViewer *m_plugin; QMenu *m_popup; QWidget *m_toolview; QTreeWidget *m_symbols; QAction *m_macro, *m_struct, *m_func, *m_sort; bool macro_on, struct_on, func_on; QTimer m_updateTimer; QTimer m_currItemTimer; void updatePixmapScroll(); void parseCppSymbols(void); void parseTclSymbols(void); void parseFortranSymbols(void); void parsePerlSymbols(void); void parsePythonSymbols(void); void parseRubySymbols(void); void parseXsltSymbols(void); void parsePhpSymbols(void); void parseBashSymbols(void); void parseEcmaSymbols(void); }; class KatePluginSymbolViewer : public KTextEditor::Plugin { Q_OBJECT public: explicit KatePluginSymbolViewer(QObject* parent = nullptr, const QList& = QList()); - virtual ~KatePluginSymbolViewer(); + ~KatePluginSymbolViewer() override; - QObject *createView (KTextEditor::MainWindow *mainWindow) Q_DECL_OVERRIDE; + QObject *createView (KTextEditor::MainWindow *mainWindow) override; - int configPages () const Q_DECL_OVERRIDE { return 1; } - KTextEditor::ConfigPage *configPage (int number = 0, QWidget *parent = nullptr) Q_DECL_OVERRIDE; + int configPages () const override { return 1; } + KTextEditor::ConfigPage *configPage (int number = 0, QWidget *parent = nullptr) override; public Q_SLOTS: void applyConfig( KatePluginSymbolViewerConfigPage* p ); public: bool typesOn; bool expandedOn; bool treeOn; bool sortOn; }; /* XPM */ static const char* const class_xpm[] = { "16 16 10 1", " c None", ". c #000000", "+ c #A4E8FC", "@ c #24D0FC", "# c #001CD0", "$ c #0080E8", "% c #C0FFFF", "& c #00FFFF", "* c #008080", "= c #00C0C0", " .. ", " .++.. ", " .+++@@. ", " .@@@@@#... ", " .$$@@##.%%.. ", " .$$$##.%%%&&. ", " .$$$#.&&&&&*. ", " ...#.==&&**. ", " .++..===***. ", " .+++@@.==**. ", " .@@@@@#..=*. ", " .$$@@##. .. ", " .$$$###. ", " .$$$##. ", " ..$#. ", " .. "}; static const char * const class_int_xpm[] = { "16 16 10 1", " c None", ". c #000000", "+ c #B8B8B8", "@ c #8A8A8A", "# c #212121", "$ c #575757", "% c #CCCCCC", "& c #9A9A9A", "* c #4D4D4D", "= c #747474", " .. ", " .++.. ", " .+++@@. ", " .@@@@@#... ", " .$$@@##.%%.. ", " .$$$##.%%%&&. ", " .$$$#.&&&&&*. ", " ...#.==&&**. ", " .++..===***. ", " .+++@@.==**. ", " .@@@@@#..=*. ", " .$$@@##. .. ", " .$$$###. ", " .$$$##. ", " ..$#. ", " .. "}; static const char* const struct_xpm[] = { "16 16 14 1", " c None", ". c #000000", "+ c #C0FFC0", "@ c #00FF00", "# c #008000", "$ c #00C000", "% c #C0FFFF", "& c #00FFFF", "* c #008080", "= c #00C0C0", "- c #FFFFC0", "; c #FFFF00", "> c #808000", ", c #C0C000", " .. ", " .++.. ", " .+++@@. ", " .@@@@@#... ", " .$$@@##.%%.. ", " .$$$##.%%%&&. ", " .$$$#.&&&&&*. ", " ...#.==&&**. ", " .--..===***. ", " .---;;.==**. ", " .;;;;;>..=*. ", " .,,;;>>. .. ", " .,,,>>>. ", " .,,,>>. ", " ..,>. ", " .. "}; static const char* const macro_xpm[] = { "16 16 14 1", " c None", ". c #000000", "+ c #FF7FE5", "@ c #FF00C7", "# c #7F0066", "$ c #BC0096", "% c #C0FFFF", "& c #00FFFF", "* c #008080", "= c #00C0C0", "- c #D493FF", "; c #A100FF", "> c #470082", ", c #6B00B7", " .. ", " .++.. ", " .+++@@. ", " .@@@@@#... ", " .$$@@##.%%.. ", " .$$$##.%%%&&. ", " .$$$#.&&&&&*. ", " ...#.==&&**. ", " .--..===***. ", " .---;;.==**. ", " .;;;;;>..=*. ", " .,,;;>>. .. ", " .,,,>>>. ", " .,,,>>. ", " ..,>. ", " .. "}; static const char* const method_xpm[] = { "16 16 5 1", " c None", ". c #000000", "+ c #FCFC80", "@ c #E0BC38", "# c #F0DC5C", " ", " ", " ", " .. ", " .++.. ", " .+++++. ", " .+++++@. ", " .. .##++@@. ", " .++..###@@@. ", " .+++++.##@@. ", " .+++++@..#@. ", " .##++@@. .. ", " .###@@@. ", " .###@@. ", " ..#@. ", " .. " }; #endif diff --git a/addons/tabswitcher/tabswitcher.h b/addons/tabswitcher/tabswitcher.h index 81c385a10..976fd8ade 100644 --- a/addons/tabswitcher/tabswitcher.h +++ b/addons/tabswitcher/tabswitcher.h @@ -1,144 +1,144 @@ /* This file is part of the KDE project Copyright (C) 2014 Dominik Haumann 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 KTEXTEDITOR_TAB_SWITCHER_PLUGIN_H #define KTEXTEDITOR_TAB_SWITCHER_PLUGIN_H #include #include #include #include #include #include class TabSwitcherPluginView; class TabSwitcherTreeView; class QStandardItemModel; class QModelIndex; class TabSwitcherPlugin : public KTextEditor::Plugin { Q_OBJECT friend TabSwitcherPluginView; public: /** * Plugin constructor. */ explicit TabSwitcherPlugin(QObject *parent = nullptr, const QList & = QList()); /** * Create a new tab switcher for @p mainWindow. */ - QObject *createView(KTextEditor::MainWindow *mainWindow) Q_DECL_OVERRIDE; + QObject *createView(KTextEditor::MainWindow *mainWindow) override; private: QList m_views; }; class TabSwitcherPluginView : public QObject, public KXMLGUIClient { Q_OBJECT public: /** * View constructor. */ TabSwitcherPluginView(TabSwitcherPlugin *plugin, KTextEditor::MainWindow *mainWindow); /** * View destructor. */ - virtual ~TabSwitcherPluginView(); + ~TabSwitcherPluginView() override; /** * Setup the shortcut actions. */ void setupActions(); /** * Initial fill of model with documents from the application. */ void setupModel(); public Q_SLOTS: /** * Adds @p document to the model. */ void registerDocument(KTextEditor::Document * document); /** * Removes @p document from the model. */ void unregisterDocument(KTextEditor::Document * document); /** * Update the name in the model for @p document. */ void updateDocumentName(KTextEditor::Document * document); /** * Raise @p view in a lru fasion. */ void raiseView(KTextEditor::View * view); /** * Focus next item in the treeview. */ void walkForward(); /** * Focus previous item in the treeview. */ void walkBackward(); /** * Activate the document for @p index. */ void switchToClicked(const QModelIndex& index); /** * Show the document for @p index. */ void activateView(const QModelIndex& index); protected: /** * Move through the list. */ void walk(const int from, const int to); /** * Make sure the popup view has a sane size. */ void updateViewGeometry(); private: TabSwitcherPlugin *m_plugin; KTextEditor::MainWindow *m_mainWindow; QStandardItemModel * m_model; QSet m_documents; TabSwitcherTreeView * m_treeView; }; #endif // KTEXTEDITOR_TAB_SWITCHER_PLUGIN_H diff --git a/addons/tabswitcher/tabswitchertreeview.h b/addons/tabswitcher/tabswitchertreeview.h index 24687a65d..fb594a006 100644 --- a/addons/tabswitcher/tabswitchertreeview.h +++ b/addons/tabswitcher/tabswitchertreeview.h @@ -1,52 +1,52 @@ /* This file is part of the KDE project Copyright (C) 2014 Dominik Haumann 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 KTEXTEDITOR_TABSWITCHER_TREEVIEW_H #define KTEXTEDITOR_TABSWITCHER_TREEVIEW_H #include class TabSwitcherTreeView : public QListView { Q_OBJECT public: /** * Default constructor. */ TabSwitcherTreeView(); Q_SIGNALS: /** * This signal is emitted whenever use activates an item through * the list view. * @note @p selectionIndex is a model index of the selectionModel() * and not of the QListView's model itself. */ void itemActivated(const QModelIndex & selectionIndex); protected: /** * Reimplemented for tracking the CTRL key modifier. */ - void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE; + void keyReleaseEvent(QKeyEvent * event) override; }; #endif // KTEXTEDITOR_TABSWITCHER_TREEVIEW_H diff --git a/addons/textfilter/plugin_katetextfilter.h b/addons/textfilter/plugin_katetextfilter.h index 0c845ab15..430682473 100644 --- a/addons/textfilter/plugin_katetextfilter.h +++ b/addons/textfilter/plugin_katetextfilter.h @@ -1,104 +1,104 @@ /*************************************************************************** plugin_katetextfilter.h - description ------------------- begin : FRE Feb 23 2001 copyright : (C) 2001 by Joseph Wenninger email : jowenn@bigfoot.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. * * * ***************************************************************************/ #ifndef PLUGIN_KATETEXTFILTER_H #define PLUGIN_KATETEXTFILTER_H #include #include #include #include #include #include #include #include class PluginKateTextFilter : public KTextEditor::Plugin { Q_OBJECT public: /** * Plugin constructor. */ explicit PluginKateTextFilter(QObject *parent = nullptr, const QList & = QList()); - virtual ~PluginKateTextFilter(); + ~PluginKateTextFilter() override; - QObject *createView(KTextEditor::MainWindow *mainWindow) Q_DECL_OVERRIDE; + QObject *createView(KTextEditor::MainWindow *mainWindow) override; void runFilter(KTextEditor::View *kv, const QString & filter); private: QString m_strFilterOutput; QString m_stderrOutput; QString m_last_command; KProcess * m_pFilterProcess; QStringList completionList; bool copyResult; bool mergeOutput; public Q_SLOTS: void slotEditFilter (); void slotFilterReceivedStdout(); void slotFilterReceivedStderr(); void slotFilterProcessExited(int exitCode, QProcess::ExitStatus exitStatus); }; class PluginKateTextFilterCommand : public KTextEditor::Command { Q_OBJECT public: PluginKateTextFilterCommand (PluginKateTextFilter *plugin); // Kate::Command bool exec (KTextEditor::View *view, const QString &cmd, QString &msg, - const KTextEditor::Range &range = KTextEditor::Range::invalid()) Q_DECL_OVERRIDE; - bool help (KTextEditor::View *view, const QString &cmd, QString &msg) Q_DECL_OVERRIDE; + const KTextEditor::Range &range = KTextEditor::Range::invalid()) override; + bool help (KTextEditor::View *view, const QString &cmd, QString &msg) override; private: PluginKateTextFilter *m_plugin; }; /** * Plugin view to merge the actions into the UI */ class PluginViewKateTextFilter: public QObject, public KXMLGUIClient { Q_OBJECT public: /** * Construct plugin view * @param plugin our plugin * @param mainwindows the mainwindow for this view */ explicit PluginViewKateTextFilter(PluginKateTextFilter *plugin, KTextEditor::MainWindow *mainwindow); /** * Our Destructor */ - virtual ~PluginViewKateTextFilter(); + ~PluginViewKateTextFilter() override; private: /** * the main window we belong to */ KTextEditor::MainWindow *m_mainWindow; }; #endif diff --git a/addons/xmlcheck/plugin_katexmlcheck.h b/addons/xmlcheck/plugin_katexmlcheck.h index 39e5550de..9f3b0dc1e 100644 --- a/addons/xmlcheck/plugin_katexmlcheck.h +++ b/addons/xmlcheck/plugin_katexmlcheck.h @@ -1,84 +1,84 @@ /*************************************************************************** plugin_katexmlcheck.h ------------------- begin : 2002-07-06 copyright : (C) 2002 by Daniel Naber email : daniel.naber@t-online.de ***************************************************************************/ /*************************************************************************** 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 PLUGIN_KATEXMLCHECK_H #define PLUGIN_KATEXMLCHECK_H #include #include #include #include #include #include #include #include class QTreeWidget; class QTreeWidgetItem; class QTemporaryFile; class QProcess; class PluginKateXMLCheckView : public QObject, public KXMLGUIClient { Q_OBJECT public: PluginKateXMLCheckView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mainwin); - virtual ~PluginKateXMLCheckView(); + ~PluginKateXMLCheckView() override; KTextEditor::MainWindow *m_mainWindow; QWidget *dock; public Q_SLOTS: bool slotValidate(); void slotClicked(QTreeWidgetItem *item, int column); void slotProcExited(int exitCode, QProcess::ExitStatus exitStatus); void slotUpdate(); private: QTemporaryFile *m_tmp_file; KParts::ReadOnlyPart *part; bool m_validating; QProcess m_proc; QString m_proc_stderr; QString m_dtdname; QTreeWidget *listview; }; class PluginKateXMLCheck : public KTextEditor::Plugin { Q_OBJECT public: explicit PluginKateXMLCheck( QObject* parent = nullptr, const QVariantList& = QVariantList() ); - virtual ~PluginKateXMLCheck(); - QObject *createView(KTextEditor::MainWindow *mainWindow) Q_DECL_OVERRIDE; + ~PluginKateXMLCheck() override; + QObject *createView(KTextEditor::MainWindow *mainWindow) override; }; #endif // PLUGIN_KATEXMLCHECK_H diff --git a/addons/xmltools/plugin_katexmltools.h b/addons/xmltools/plugin_katexmltools.h index c3d2931f7..2d0b4f82d 100644 --- a/addons/xmltools/plugin_katexmltools.h +++ b/addons/xmltools/plugin_katexmltools.h @@ -1,182 +1,182 @@ /*************************************************************************** pluginKatexmltools.cpp copyright : (C) 2001-2002 by Daniel Naber email : daniel.naber@t-online.de ***************************************************************************/ /*************************************************************************** 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 PLUGIN_KATEXMLTOOLS_H #define PLUGIN_KATEXMLTOOLS_H #include "pseudo_dtd.h" #include #include #include #include #include #include #include #include #include #include class QComboBox; class QPushButton; class PluginKateXMLTools : public KTextEditor::Plugin { Q_OBJECT public: explicit PluginKateXMLTools(QObject *parent = nullptr, const QVariantList& = QVariantList()); - ~PluginKateXMLTools(); - QObject *createView(KTextEditor::MainWindow *mainWindow) Q_DECL_OVERRIDE; + ~PluginKateXMLTools() override; + QObject *createView(KTextEditor::MainWindow *mainWindow) override; }; class PluginKateXMLToolsCompletionModel : public KTextEditor::CodeCompletionModel , public KTextEditor::CodeCompletionModelControllerInterface { Q_OBJECT Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface) public: PluginKateXMLToolsCompletionModel(QObject *parent); - virtual ~PluginKateXMLToolsCompletionModel(); + ~PluginKateXMLToolsCompletionModel() override; // // KTextEditor::CodeCompletionModel // public: - int columnCount(const QModelIndex &) const Q_DECL_OVERRIDE; - int rowCount(const QModelIndex &parent) const Q_DECL_OVERRIDE; - QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE; - QModelIndex index(int row, int column, const QModelIndex &parent) const Q_DECL_OVERRIDE; - QVariant data(const QModelIndex &idx, int role) const Q_DECL_OVERRIDE; + int columnCount(const QModelIndex &) const override; + int rowCount(const QModelIndex &parent) const override; + QModelIndex parent(const QModelIndex &index) const override; + QModelIndex index(int row, int column, const QModelIndex &parent) const override; + QVariant data(const QModelIndex &idx, int role) const override; void executeCompletionItem(KTextEditor::View *view, const KTextEditor::Range &word, - const QModelIndex &index) const Q_DECL_OVERRIDE; + const QModelIndex &index) const override; // // KTextEditor::CodeCompletionModelControllerInterface // public: bool shouldStartCompletion(KTextEditor::View *view, const QString &insertedText, bool userInsertion, - const KTextEditor::Cursor &position) Q_DECL_OVERRIDE; + const KTextEditor::Cursor &position) override; public Q_SLOTS: void getDTD(); void slotInsertElement(); void slotCloseElement(); void slotFinished(KJob *job); void slotData(KIO::Job *, const QByteArray &data); - void completionInvoked(KTextEditor::View *kv, const KTextEditor::Range &range, InvocationType invocationType) Q_DECL_OVERRIDE; + void completionInvoked(KTextEditor::View *kv, const KTextEditor::Range &range, InvocationType invocationType) override; /// Connected to the document manager, to manage the dtd collection. void slotDocumentDeleted(KTextEditor::Document *doc); protected: QString currentModeToString() const; static QStringList sortQStringList(QStringList list); //bool eventFilter( QObject *object, QEvent *event ); QString insideTag(KTextEditor::View &kv); QString insideAttribute(KTextEditor::View &kv); static bool isOpeningTag(const QString &tag); static bool isClosingTag(const QString &tag); static bool isEmptyTag(const QString &tag); static bool isQuote(const QString &ch); QString getParentElement(KTextEditor::View &view, int skipCharacters); enum Mode {none, entities, attributevalues, attributes, elements, closingtag}; enum PopupMode {noPopup, tagname, attributename, attributevalue, entityname}; enum Level {groupNode = 1}; /// Assign the PseudoDTD @p dtd to the Kate::View @p view void assignDTD(PseudoDTD *dtd, KTextEditor::View *view); /// temporary placeholder for the metaDTD file QString m_dtdString; /// temporary placeholder for the view to assign a DTD to while the file is loaded KTextEditor::View *m_viewToAssignTo; /// URL of the last loaded meta DTD QString m_urlString; QStringList m_allowed; Mode m_mode; int m_correctPos; // code completion stuff: KTextEditor::CodeCompletionInterface *m_codeInterface; /// maps KTE::Document -> DTD QHash m_docDtds; /// maps DTD filename -> DTD QHash m_dtds; }; class PluginKateXMLToolsView : public QObject, public KXMLGUIClient { Q_OBJECT public: explicit PluginKateXMLToolsView(KTextEditor::MainWindow *mainWin); - virtual ~PluginKateXMLToolsView(); + ~PluginKateXMLToolsView() override; protected: KTextEditor::MainWindow *m_mainWindow; PluginKateXMLToolsCompletionModel m_model; }; class InsertElement : public QDialog { Q_OBJECT public: InsertElement(const QStringList &completions, QWidget *parent); - virtual ~InsertElement(); + ~InsertElement() override; QString text() const; private Q_SLOTS: void slotHistoryTextChanged(const QString &); private: QComboBox * m_cmbElements; QPushButton * m_okButton; }; #endif // PLUGIN_KATEXMLTOOLS_H // kate: space-indent on; indent-width 4; replace-tabs on; mixed-indent off; diff --git a/kate/kateapp.h b/kate/kateapp.h index ae43a1087..6b3a4df6d 100644 --- a/kate/kateapp.h +++ b/kate/kateapp.h @@ -1,366 +1,366 @@ /* This file is part of the KDE project Copyright (C) 2001 Christoph Cullmann Copyright (C) 2002 Joseph Wenninger 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 __KATE_APP_H__ #define __KATE_APP_H__ #include #include "kateprivate_export.h" #include "katemainwindow.h" #include "katedocmanager.h" #include "katepluginmanager.h" #include "katesessionmanager.h" #include "kateappadaptor.h" #include #include class KateSessionManager; class KateMainWindow; class KatePluginManager; class KateDocManager; class KateAppCommands; class KateAppAdaptor; class QCommandLineParser; /** * Kate Application * This class represents the core kate application object */ class KATE_TESTS_EXPORT KateApp : public QObject { Q_OBJECT /** * constructors & accessor to app object + plugin interface for it */ public: /** * application constructor */ KateApp(const QCommandLineParser &args); /** * get kate inited * @return false, if application should exit */ bool init(); /** * application destructor */ - ~KateApp(); + ~KateApp() override; /** * static accessor to avoid casting ;) * @return app instance */ static KateApp *self(); /** * KTextEditor::Application wrapper * @return KTextEditor::Application wrapper. */ KTextEditor::Application *wrapper() { return &m_wrapper; } /** * kate init */ private: /** * restore a old kate session */ void restoreKate(); /** * try to start kate * @return success, if false, kate should exit */ bool startupKate(); /** * kate shutdown */ public: /** * shutdown kate application * @param win mainwindow which is used for dialogs */ void shutdownKate(KateMainWindow *win); /** * other accessors for global unique instances */ public: /** * accessor to plugin manager * @return plugin manager instance */ KatePluginManager *pluginManager(); /** * accessor to document manager * @return document manager instance */ KateDocManager *documentManager(); /** * accessor to session manager * @return session manager instance */ KateSessionManager *sessionManager(); /** * window management */ public: /** * create a new main window, use given config if any for restore * @param sconfig session config object * @param sgroup session group for this window * @return new constructed main window */ KateMainWindow *newMainWindow(KConfig *sconfig = nullptr, const QString &sgroup = QString()); /** * add the mainwindow given * should be called in mainwindow constructor * @param mainWindow window to remove */ void addMainWindow(KateMainWindow *mainWindow); /** * removes the mainwindow given, DOES NOT DELETE IT * should be called in mainwindow destructor * @param mainWindow window to remove */ void removeMainWindow(KateMainWindow *mainWindow); /** * give back current active main window * can only be 0 at app start or exit * @return current active main window */ KateMainWindow *activeKateMainWindow(); /** * give back number of existing main windows * @return number of main windows */ int mainWindowsCount() const; /** * give back the window you want * @param n window index * @return requested main window */ KateMainWindow *mainWindow(int n); int mainWindowID(KateMainWindow *window); /** * some stuff for the dcop API */ public: /** * open url with given encoding * used by kate if --use given * @param url filename * @param encoding encoding name * @return success */ bool openUrl(const QUrl &url, const QString &encoding, bool isTempFile); KTextEditor::Document *openDocUrl(const QUrl &url, const QString &encoding, bool isTempFile); void emitDocumentClosed(const QString &token); /** * position cursor in current active view * will clear selection * @param line line to set * @param column column to set * @return success */ bool setCursor(int line, int column); /** * helper to handle stdin input * open a new document/view, fill it with the text given * @param text text to fill in the new doc/view * @param encoding encoding to set for the document, if any * @return success */ bool openInput(const QString &text, const QString &encoding); // // KTextEditor::Application interface, called by wrappers via invokeMethod // public Q_SLOTS: /** * Get a list of all main windows. * @return all main windows */ QList mainWindows() { // assemble right list QList windows; for (int i = 0; i < m_mainWindows.size(); ++i) { windows.push_back(m_mainWindows[i]->wrapper()); } return windows; } /** * Accessor to the active main window. * \return a pointer to the active mainwindow */ KTextEditor::MainWindow *activeMainWindow() { // either return wrapper or nullptr if (KateMainWindow *a = activeKateMainWindow()) { return a->wrapper(); } return nullptr; } /** * Get a list of all documents that are managed by the application. * This might contain less documents than the editor has in his documents () list. * @return all documents the application manages */ QList documents() { return m_docManager.documentList(); } /** * Get the document with the URL \p url. * if multiple documents match the searched url, return the first found one... * \param url the document's URL * \return the document with the given \p url or NULL, if none found */ KTextEditor::Document *findUrl(const QUrl &url) { return m_docManager.findDocument(url); } /** * Open the document \p url with the given \p encoding. * if the url is empty, a new empty document will be created * \param url the document's url * \param encoding the preferred encoding. If encoding is QString() the * encoding will be guessed or the default encoding will be used. * \return a pointer to the created document */ KTextEditor::Document *openUrl(const QUrl &url, const QString &encoding = QString()) { return m_docManager.openUrl(url, encoding); } /** * Close the given \p document. If the document is modified, user will be asked if he wants that. * \param document the document to be closed * \return \e true on success, otherwise \e false */ bool closeDocument(KTextEditor::Document *document) { return m_docManager.closeDocument(document); } /** * Close a list of documents. If any of them are modified, user will be asked if he wants that. * Use this, if you want to close multiple documents at once, as the application might * be able to group the "do you really want that" dialogs into one. * \param documents list of documents to be closed * \return \e true on success, otherwise \e false */ bool closeDocuments(const QList &documents) { return m_docManager.closeDocumentList(documents); } /** * Get a plugin for the plugin with with identifier \p name. * \param name the plugin's name * \return pointer to the plugin if a plugin with \p name is loaded, otherwise nullptr */ KTextEditor::Plugin *plugin(const QString &name); /** * Ask app to quit. The app might interact with the user and decide that * quitting is not possible and return false. * * \return true if the app could quit */ bool quit() { shutdownKate(activeKateMainWindow()); return true; } /** * A message is received from an external instance, if we use QtSingleApplication * * \p message is a serialized message (at the moment just the file list separated by ';') * \p socket is the QLocalSocket used for the communication */ void remoteMessageReceived(const QString &message, QObject *socket); protected: /** * Event filter for QApplication to handle mac os like file open */ - bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *obj, QEvent *event) override; private: /** * kate's command line args */ const QCommandLineParser &m_args; /** * known main windows */ QList m_mainWindows; /** * Wrapper of application for KTextEditor */ KTextEditor::Application m_wrapper; /** * document manager */ KateDocManager m_docManager; /** * dbus interface */ KateAppAdaptor m_adaptor; /** * plugin manager */ KatePluginManager m_pluginManager; /** * session manager */ KateSessionManager m_sessionManager; }; #endif diff --git a/kate/kateconfigdialog.h b/kate/kateconfigdialog.h index 88637c5e0..0f4ed92a2 100644 --- a/kate/kateconfigdialog.h +++ b/kate/kateconfigdialog.h @@ -1,98 +1,98 @@ /* This file is part of the KDE project Copyright (C) 2001 Christoph Cullmann Copyright (C) 2002 Joseph Wenninger Copyright (C) 2007 Mirko Stocker 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 __kate_configdialog_h__ #define __kate_configdialog_h__ #include #include #include #include #include #include class QCheckBox; class QSpinBox; class KateMainWindow; class KPluralHandlingSpinBox; namespace Ui { class SessionConfigWidget; } struct PluginPageListItem { KTextEditor::Plugin *plugin; uint idInPlugin; KTextEditor::ConfigPage *pluginPage; QWidget *pageParent; KPageWidgetItem *pageWidgetItem; }; class KateConfigDialog : public KPageDialog { Q_OBJECT public: KateConfigDialog(KateMainWindow *parent, KTextEditor::View *view); - ~KateConfigDialog(); + ~KateConfigDialog() override; public: // static /** * Reads the value from the given open config. If not present in config yet then * the default value 10 is used. */ static int recentFilesMaxCount(); public: void addPluginPage(KTextEditor::Plugin *plugin); void removePluginPage(KTextEditor::Plugin *plugin); void showAppPluginPage(KTextEditor::Plugin *plugin, uint id); protected Q_SLOTS: void slotApply(); void slotChanged(); void slotHelp(); void slotCurrentPageChanged(KPageWidgetItem *current, KPageWidgetItem *before); private: KateMainWindow *m_mainWindow; KTextEditor::View *m_view; bool m_dataChanged; QCheckBox *m_modNotifications; QCheckBox *m_saveMetaInfos; KPluralHandlingSpinBox *m_daysMetaInfos; // Sessions Page Ui::SessionConfigWidget *sessionConfigUi; QHash m_pluginPages; QList m_editorPages; KPageWidgetItem *m_applicationPage; KPageWidgetItem *m_editorPage; void addEditorPages(); }; #endif diff --git a/kate/katedocmanager.h b/kate/katedocmanager.h index eb3c700ae..0dcd4eeaf 100644 --- a/kate/katedocmanager.h +++ b/kate/katedocmanager.h @@ -1,222 +1,222 @@ /* This file is part of the KDE project Copyright (C) 2001 Christoph Cullmann Copyright (C) 2002 Joseph Wenninger 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 __KATE_DOCMANAGER_H__ #define __KATE_DOCMANAGER_H__ #include #include #include #include #include #include #include #include #include #include #include class KateMainWindow; class KateDocumentInfo { public: enum CustomRoles {RestoreOpeningFailedRole }; public: KateDocumentInfo() : modifiedOnDisc(false) , modifiedOnDiscReason(KTextEditor::ModificationInterface::OnDiskUnmodified) , openedByUser(false) , openSuccess(true) {} bool modifiedOnDisc; KTextEditor::ModificationInterface::ModifiedOnDiskReason modifiedOnDiscReason; bool openedByUser; bool openSuccess; }; class KateDocManager : public QObject { Q_OBJECT public: KateDocManager(QObject *parent); - ~KateDocManager(); + ~KateDocManager() override; KTextEditor::Document *createDoc(const KateDocumentInfo &docInfo = KateDocumentInfo()); KateDocumentInfo *documentInfo(KTextEditor::Document *doc); /** Returns the documentNumber of the doc with url URL or -1 if no such doc is found */ KTextEditor::Document *findDocument(const QUrl &url) const; const QList &documentList() const { return m_docList; } KTextEditor::Document *openUrl(const QUrl &, const QString &encoding = QString(), bool isTempFile = false, const KateDocumentInfo &docInfo = KateDocumentInfo()); QList openUrls(const QList &, const QString &encoding = QString(), bool isTempFile = false, const KateDocumentInfo &docInfo = KateDocumentInfo()); bool closeDocument(KTextEditor::Document *, bool closeUrl = true); bool closeDocuments(const QList documents, bool closeUrl = true); bool closeDocumentList(QList documents); bool closeAllDocuments(bool closeUrl = true); bool closeOtherDocuments(KTextEditor::Document *); QList modifiedDocumentList(); bool queryCloseDocuments(KateMainWindow *w); void saveDocumentList(KConfig *config); void restoreDocumentList(KConfig *config); inline bool getSaveMetaInfos() { return m_saveMetaInfos; } inline void setSaveMetaInfos(bool b) { m_saveMetaInfos = b; } inline int getDaysMetaInfos() { return m_daysMetaInfos; } inline void setDaysMetaInfos(int i) { m_daysMetaInfos = i; } public Q_SLOTS: /** * saves all documents that has at least one view. * documents with no views are ignored :P */ void saveAll(); /** * reloads all documents that has at least one view. * documents with no views are ignored :P */ void reloadAll(); /** * close all documents, which could not be reopened */ void closeOrphaned(); /** * save selected documents from the File List */ void saveSelected(const QList &); Q_SIGNALS: /** * This signal is emitted when the \p document was created. */ void documentCreated(KTextEditor::Document *document); /** * This signal is emitted when the \p document was created. * This is emitted after the initial documentCreated for internal use in view manager */ void documentCreatedViewManager(KTextEditor::Document *document); /** * This signal is emitted before a \p document which should be closed is deleted * The document is still accessible and usable, but it will be deleted * after this signal was send. * * @param document document that will be deleted */ void documentWillBeDeleted(KTextEditor::Document *document); /** * This signal is emitted when the \p document has been deleted. * * Warning !!! DO NOT ACCESS THE DATA REFERENCED BY THE POINTER, IT IS ALREADY INVALID * Use the pointer only to remove mappings in hash or maps */ void documentDeleted(KTextEditor::Document *document); /** * This signal is emitted before the batch of documents is being created. * * You can use it to pause some updates. */ void aboutToCreateDocuments(); /** * This signal is emitted after the batch of ducuments is created. * * @param documents list of documents that have been created */ void documentsCreated(const QList &documents); /** * This signal is emitted before the documents batch is going to be deleted * * note that the batch can be interrupted in the middle and only some * of the documents may be actually deleted. See documentsDeleted() signal. */ void aboutToDeleteDocuments(const QList &); /** * This singnal is emitted after the documents batch was deleted * * This is the batch closing signal for aboutToDeleteDocuments * @param documents the documents that weren't deleted after all */ void documentsDeleted(const QList &documents); private Q_SLOTS: void slotModifiedOnDisc(KTextEditor::Document *doc, bool b, KTextEditor::ModificationInterface::ModifiedOnDiskReason reason); void slotModChanged(KTextEditor::Document *doc); void slotModChanged1(KTextEditor::Document *doc); void showRestoreErrors(); private: bool loadMetaInfos(KTextEditor::Document *doc, const QUrl &url); void saveMetaInfos(const QList &docs); QList m_docList; QHash m_docInfos; KConfig m_metaInfos; bool m_saveMetaInfos; int m_daysMetaInfos; typedef QPair TPair; QMap m_tempFiles; QString m_openingErrors; int m_documentStillToRestore; private Q_SLOTS: void documentOpened(); }; #endif diff --git a/kate/katemainwindow.h b/kate/katemainwindow.h index ba514a497..931a239da 100644 --- a/kate/katemainwindow.h +++ b/kate/katemainwindow.h @@ -1,575 +1,575 @@ /* This file is part of the KDE project Copyright (C) 2001 Christoph Cullmann Copyright (C) 2001 Joseph Wenninger Copyright (C) 2001 Anders Lund 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 __KATE_MAINWINDOW_H__ #define __KATE_MAINWINDOW_H__ #include "katemdi.h" #include "kateviewmanager.h" #include #include #include #include #include #include #include #include #include #include #include #include #include class QMenu; namespace KIO { class UDSEntry; typedef class QList UDSEntryList; } class KFileItem; class KRecentFilesAction; class KateViewManager; class KateMwModOnHdDialog; class KateQuickOpen; // Helper layout class to always provide minimum size class KateContainerStackedLayout : public QStackedLayout { Q_OBJECT public: KateContainerStackedLayout(QWidget *parent); - QSize sizeHint() const Q_DECL_OVERRIDE; - QSize minimumSize() const Q_DECL_OVERRIDE; + QSize sizeHint() const override; + QSize minimumSize() const override; }; class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBase { Q_OBJECT public: /** * Construct the window and restore its state from given config if any * @param sconfig session config for this window, 0 if none * @param sgroup session config group to use */ KateMainWindow(KConfig *sconfig, const QString &sgroup); /** * Destruct the nice window */ - ~KateMainWindow(); + ~KateMainWindow() override; /** * Accessor methodes for interface and child objects */ public: KateViewManager *viewManager() { return m_viewManager; } /** * KTextEditor::MainWindow wrapper * @return KTextEditor::MainWindow wrapper. */ KTextEditor::MainWindow *wrapper() { return m_wrapper; } public: /** Returns the URL of the current document. * anders: I add this for use from the file selector. */ QUrl activeDocumentUrl(); /** * Prompts the user for what to do with files that are modified on disk if any. * This is optionally run when the window receives focus, and when the last * window is closed. * @return true if no documents are modified on disk, or all documents were * handled by the dialog; otherwise (the dialog was canceled) false. */ bool showModOnDiskPrompt(); public: - /*reimp*/ void readProperties(const KConfigGroup &config) Q_DECL_OVERRIDE; - /*reimp*/ void saveProperties(KConfigGroup &config) Q_DECL_OVERRIDE; - /*reimp*/ void saveGlobalProperties(KConfig *sessionConfig) Q_DECL_OVERRIDE; + /*reimp*/ void readProperties(const KConfigGroup &config) override; + /*reimp*/ void saveProperties(KConfigGroup &config) override; + /*reimp*/ void saveGlobalProperties(KConfig *sessionConfig) override; public: bool queryClose_internal(KTextEditor::Document *doc = nullptr); /** * save the settings, size and state of this window in * the provided config group */ void saveWindowConfig(const KConfigGroup &); /** * restore the settings, size and state of this window from * the provided config group. */ void restoreWindowConfig(const KConfigGroup &); /** * save some global options to katerc */ void saveOptions(); private: /** * Setup actions which pointers are needed already in setupMainWindow */ void setupImportantActions(); void setupMainWindow(); void setupActions(); - bool queryClose() Q_DECL_OVERRIDE; + bool queryClose() override; void addMenuBarActionToContextMenu(); void removeMenuBarActionFromContextMenu(); /** * read some global options from katerc */ void readOptions(); - void dragEnterEvent(QDragEnterEvent *) Q_DECL_OVERRIDE; - void dropEvent(QDropEvent *) Q_DECL_OVERRIDE; + void dragEnterEvent(QDragEnterEvent *) override; + void dropEvent(QDropEvent *) override; public Q_SLOTS: void slotFileClose(); void slotFileQuit(); void queueModifiedOnDisc(KTextEditor::Document *doc); void slotFocusPrevTab(); void slotFocusNextTab(); /** * Show quick open */ void slotQuickOpen(); /** * Overwrite size hint for better default window sizes * @return size hint */ - QSize sizeHint() const Q_DECL_OVERRIDE; + QSize sizeHint() const override; /** * slots used for actions in the menus/toolbars * or internal signal connections */ private Q_SLOTS: void newWindow(); void slotConfigure(); void slotOpenWithMenuAction(QAction *a); void slotEditToolbars(); void slotNewToolbarConfig(); void slotUpdateOpenWith(); void slotOpenDocument(QUrl); void slotDropEvent(QDropEvent *); void editKeys(); void mSlotFixOpenWithMenu(); void reloadXmlGui(); /* to update the caption */ void slotDocumentCreated(KTextEditor::Document *doc); void updateCaption(KTextEditor::Document *doc); // calls updateCaption(doc) with the current document void updateCaption(); void pluginHelp(); void aboutEditor(); void slotFullScreen(bool); void slotListRecursiveEntries(KIO::Job *job, const KIO::UDSEntryList &list); private Q_SLOTS: void toggleShowMenuBar(bool showMessage = true); void toggleShowStatusBar(); void toggleShowTabBar(); public: bool showStatusBar(); bool showTabBar(); Q_SIGNALS: void statusBarToggled(); void tabBarToggled(); void unhandledShortcutOverride(QEvent *e); public: void openUrl(const QString &name = QString()); QHash &pluginViews() { return m_pluginViews; } QWidget *bottomViewBarContainer() { return m_bottomViewBarContainer; } void addToBottomViewBarContainer(KTextEditor::View *view, QWidget *bar) { m_bottomContainerStack->addWidget(bar); m_bottomViewBarMapping[view] = BarState(bar); } void hideBottomViewBarForView(KTextEditor::View *view) { BarState &state = m_bottomViewBarMapping[view]; if (state.bar()) { m_bottomContainerStack->setCurrentWidget(state.bar()); state.bar()->hide(); state.setState(false); } m_bottomViewBarContainer->hide(); } void showBottomViewBarForView(KTextEditor::View *view) { BarState &state = m_bottomViewBarMapping[view]; if (state.bar()) { m_bottomContainerStack->setCurrentWidget(state.bar()); state.bar()->show(); state.setState(true); m_bottomViewBarContainer->show(); } } void deleteBottomViewBarForView(KTextEditor::View *view) { BarState state = m_bottomViewBarMapping.take(view); if (state.bar()) { if (m_bottomContainerStack->currentWidget() == state.bar()) { m_bottomViewBarContainer->hide(); } delete state.bar(); } } bool modNotificationEnabled() const { return m_modNotification; } void setModNotificationEnabled(bool e) { m_modNotification = e; } KRecentFilesAction *fileOpenRecent() const { return m_fileOpenRecent; } // // KTextEditor::MainWindow interface, get called by invokeMethod from our wrapper object! // public Q_SLOTS: /** * get the toplevel widget. * \return the real main window widget. */ QWidget *window() { return this; } /** * Accessor to the XMLGUIFactory. * \return the mainwindow's KXMLGUIFactory. */ - KXMLGUIFactory *guiFactory() Q_DECL_OVERRIDE { + KXMLGUIFactory *guiFactory() override { return KateMDI::MainWindow::guiFactory(); } /** * Get a list of all views for this main window. * @return all views */ QList views() { return viewManager()->views(); } /** * Access the active view. * \return active view */ KTextEditor::View *activeView() { return viewManager()->activeView(); } /** * Activate the view with the corresponding \p document. * If none exist for this document, create one * \param document the document * \return activated view of this document */ KTextEditor::View *activateView(KTextEditor::Document *document) { return viewManager()->activateView(document); } /** * Open the document \p url with the given \p encoding. * \param url the document's url * \param encoding the preferred encoding. If encoding is QString() the * encoding will be guessed or the default encoding will be used. * \return a pointer to the created view for the new document, if a document * with this url is already existing, its view will be activated */ KTextEditor::View *openUrl(const QUrl &url, const QString &encoding = QString()) { return viewManager()->openUrlWithView(url, encoding); } /** * Close selected view * \param view the view * \return true if view was closed */ bool closeView(KTextEditor::View *view) { m_viewManager->closeView(view); return true; } /** * Close the split view where the given view is contained. * \param view the view. * \return true if the split view was closed. */ bool closeSplitView(KTextEditor::View *view) { m_viewManager->closeViewSpace(view); return true; } /** * @returns true if the two given views share the same split view, * false otherwise. */ bool viewsInSameSplitView(KTextEditor::View *view1, KTextEditor::View *view2) { return m_viewManager->viewsInSameViewSpace(view1, view2); } /** * Split current view space according to @orientation * \param orientation in which line split the view */ void splitView(Qt::Orientation orientation) { m_viewManager->splitViewSpace(nullptr, orientation); } /** * Try to create a view bar for the given view. * @param view view for which we want an view bar * @return suitable widget that can host view bars widgets or nullptr */ QWidget *createViewBar(KTextEditor::View *) { return bottomViewBarContainer(); } /** * Delete the view bar for the given view. * @param view view for which we want an view bar */ void deleteViewBar(KTextEditor::View *view) { deleteBottomViewBarForView(view); } /** * Add a widget to the view bar. * @param view view for which the view bar is used * @param bar bar widget, shall have the viewBarParent() as parent widget */ void addWidgetToViewBar(KTextEditor::View *view, QWidget *bar) { addToBottomViewBarContainer(view, bar); } /** * Show the view bar for the given view * @param view view for which the view bar is used */ void showViewBar(KTextEditor::View *view) { showBottomViewBarForView(view); } /** * Hide the view bar for the given view * @param view view for which the view bar is used */ void hideViewBar(KTextEditor::View *view) { hideBottomViewBarForView(view); } /** * Create a new toolview with unique \p identifier at side \p pos * with \p icon and caption \p text. Use the returned widget to embedd * your widgets. * \param plugin which owns this tool view * \param identifier unique identifier for this toolview * \param pos position for the toolview, if we are in session restore, * this is only a preference * \param icon icon to use in the sidebar for the toolview * \param text translated text (i18n()) to use in addition to icon * \return created toolview on success, otherwise NULL */ QWidget *createToolView(KTextEditor::Plugin *plugin, const QString &identifier, KTextEditor::MainWindow::ToolViewPosition pos, const QIcon &icon, const QString &text); /** * Move the toolview \p widget to position \p pos. * \param widget the toolview to move, where the widget was constructed * by createToolView(). * \param pos new position to move widget to * \return \e true on success, otherwise \e false */ bool moveToolView(QWidget *widget, KTextEditor::MainWindow::ToolViewPosition pos); /** * Show the toolview \p widget. * \param widget the toolview to show, where the widget was constructed * by createToolView(). * \return \e true on success, otherwise \e false * \todo add focus parameter: bool showToolView (QWidget *widget, bool giveFocus ); */ bool showToolView(QWidget *widget); /** * Hide the toolview \p widget. * \param widget the toolview to hide, where the widget was constructed * by createToolView(). * \return \e true on success, otherwise \e false */ bool hideToolView(QWidget *widget); /** * Get a plugin view for the plugin with with identifier \p name. * \param name the plugin's name * \return pointer to the plugin view if a plugin with \p name is loaded and has a view for this mainwindow, * otherwise NULL */ QObject *pluginView(const QString &name); private Q_SLOTS: void slotUpdateBottomViewBar(); private Q_SLOTS: void slotDocumentCloseAll(); void slotDocumentCloseOther(); void slotDocumentCloseOther(KTextEditor::Document *document); void slotDocumentCloseSelected(const QList &); private: /** * Notify about file modifications from other processes? */ bool m_modNotification; /** * stacked widget containing the central area, aka view manager, quickopen, ... */ QStackedWidget *m_mainStackedWidget; /** * quick open to fast switch documents */ KateQuickOpen *m_quickOpen; /** * keeps track of views */ KateViewManager *m_viewManager; KRecentFilesAction *m_fileOpenRecent; KActionMenu *documentOpenWith; KToggleAction *settingsShowFileselector; KToggleAction *m_showFullScreenAction; bool m_modignore; // all plugin views for this mainwindow, used by the pluginmanager QHash m_pluginViews; // options: show statusbar + show path KToggleAction *m_paShowPath; KToggleAction *m_paShowMenuBar; KToggleAction *m_paShowStatusBar; KToggleAction *m_paShowTabBar; QWidget *m_bottomViewBarContainer; KateContainerStackedLayout *m_bottomContainerStack; class BarState { public: BarState(): m_bar(nullptr), m_state(false) {} BarState(QWidget *bar): m_bar(bar), m_state(false) {} ~BarState() {} QWidget *bar() { return m_bar; } bool state() { return m_state; } void setState(bool state) { m_state = state; } private: QWidget *m_bar; bool m_state; }; QHash m_bottomViewBarMapping; public: static void unsetModifiedOnDiscDialogIfIf(KateMwModOnHdDialog *diag) { if (s_modOnHdDialog == diag) { s_modOnHdDialog = nullptr; } } private: static KateMwModOnHdDialog *s_modOnHdDialog; /** * Wrapper of main window for KTextEditor */ KTextEditor::MainWindow *m_wrapper; public Q_SLOTS: void showPluginConfigPage(KTextEditor::Plugin *configpageinterface, uint id); void slotWindowActivated(); protected: - bool event(QEvent *e) Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + bool event(QEvent *e) override; + void mousePressEvent(QMouseEvent *e) override; }; #endif diff --git a/kate/katemdi.h b/kate/katemdi.h index 680ebb338..81874d4b7 100644 --- a/kate/katemdi.h +++ b/kate/katemdi.h @@ -1,461 +1,461 @@ /* This file is part of the KDE libraries Copyright (C) 2005 Christoph Cullmann Copyright (C) 2002, 2003 Joseph Wenninger 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 __KATE_MDI_H__ #define __KATE_MDI_H__ #include #include #include #include #include #include #include #include #include #include #include #include class KActionMenu; class QAction; class QPixmap; class KConfigBase; namespace KTextEditor { class ConfigPageInterface; }; namespace KateMDI { class ToolView; class ToggleToolViewAction : public KToggleAction { Q_OBJECT public: ToggleToolViewAction(const QString &text, ToolView *tv, QObject *parent); - virtual ~ToggleToolViewAction(); + ~ToggleToolViewAction() override; protected Q_SLOTS: - void slotToggled(bool) Q_DECL_OVERRIDE; + void slotToggled(bool) override; void toolVisibleChanged(bool); private: ToolView *m_tv; }; class GUIClient : public QObject, public KXMLGUIClient { Q_OBJECT public: GUIClient(class MainWindow *mw); - virtual ~GUIClient(); + ~GUIClient() override; void registerToolView(ToolView *tv); void unregisterToolView(ToolView *tv); void updateSidebarsVisibleAction(); private Q_SLOTS: void clientAdded(KXMLGUIClient *client); void updateActions(); private: MainWindow *m_mw; KToggleAction *m_showSidebarsAction; QList m_toolViewActions; QMap m_toolToAction; KActionMenu *m_toolMenu; }; class ToolView : public QFrame { Q_OBJECT friend class Sidebar; friend class MainWindow; friend class GUIClient; friend class ToggleToolViewAction; protected: /** * ToolView * Objects of this clas represent a toolview in the mainwindow * you should only add one widget as child to this toolview, it will * be automatically set to be the focus proxy of the toolview * @param mainwin main window for this toolview * @param sidebar sidebar of this toolview * @param parent parent widget, e.g. the splitter of one of the sidebars */ ToolView(class MainWindow *mainwin, class Sidebar *sidebar, QWidget *parent); public: /** * destuct me, this is allowed for all, will care itself that the toolview is removed * from the mainwindow and sidebar */ - virtual ~ToolView(); + ~ToolView() override; Q_SIGNALS: /** * toolview hidden or shown * @param visible is this toolview made visible? */ void toolVisibleChanged(bool visible); /** * some internal methodes needed by the main window and the sidebars */ protected: MainWindow *mainWindow() { return m_mainWin; } Sidebar *sidebar() { return m_sidebar; } void setToolVisible(bool vis); public: bool toolVisible() const; - QSize sizeHint() const Q_DECL_OVERRIDE; - QSize minimumSizeHint() const Q_DECL_OVERRIDE; + QSize sizeHint() const override; + QSize minimumSizeHint() const override; protected: - void childEvent(QChildEvent *ev) Q_DECL_OVERRIDE; - void actionEvent(QActionEvent *event) Q_DECL_OVERRIDE; + void childEvent(QChildEvent *ev) override; + void actionEvent(QActionEvent *event) override; private: MainWindow *m_mainWin; Sidebar *m_sidebar; KToolBar *m_toolbar; ///plugin this view belongs to, may be 0 QPointer plugin; /** * unique id */ QString id; /** * is visible in sidebar */ bool m_toolVisible; /** * is this view persistent? */ bool persistent; QIcon icon; QString text; }; class Sidebar : public KMultiTabBar { Q_OBJECT public: Sidebar(KMultiTabBar::KMultiTabBarPosition pos, class MainWindow *mainwin, QWidget *parent); - virtual ~Sidebar(); + ~Sidebar() override; void setSplitter(QSplitter *sp); public: ToolView *addWidget(const QIcon &icon, const QString &text, ToolView *widget); bool removeWidget(ToolView *widget); bool showWidget(ToolView *widget); bool hideWidget(ToolView *widget); void setLastSize(int s) { m_lastSize = s; } int lastSize() const { return m_lastSize; } void updateLastSize(); bool splitterVisible() const { return m_ownSplit->isVisible(); } void restoreSession(); /** * restore the current session config from given object, use current group * @param config config object to use */ void restoreSession(KConfigGroup &config); /** * save the current session config to given object, use current group * @param config config object to use */ void saveSession(KConfigGroup &config); public Q_SLOTS: // reimplemented, to block a show() call if all sidebars are forced hidden - void setVisible(bool visible) Q_DECL_OVERRIDE; + void setVisible(bool visible) override; private Q_SLOTS: void tabClicked(int); protected: - bool eventFilter(QObject *obj, QEvent *ev) Q_DECL_OVERRIDE; + bool eventFilter(QObject *obj, QEvent *ev) override; private Q_SLOTS: void buttonPopupActivate(QAction *); private: MainWindow *m_mainWin; KMultiTabBar::KMultiTabBarPosition m_pos; QSplitter *m_splitter; KMultiTabBar *m_tabBar; QSplitter *m_ownSplit; QMap m_idToWidget; QMap m_widgetToId; QMap m_widgetToSize; /** * list of all toolviews around in this sidebar */ QList m_toolviews; int m_lastSize; QSize m_preHideSize; int m_popupButton; Q_SIGNALS: void sigShowPluginConfigPage(KTextEditor::Plugin*configpageinterface, uint id); }; class MainWindow : public KParts::MainWindow { Q_OBJECT friend class ToolView; // // Constructor area // public: /** * Constructor */ MainWindow(QWidget *parentWidget = nullptr); /** * Destructor */ - virtual ~MainWindow(); + ~MainWindow() override; // // public interfaces // /** * add a given widget to the given sidebar if possible, name is very important * @param identifier unique identifier for this toolview * @param pos position for the toolview, if we are in session restore, this is only a preference * @param icon icon to use for the toolview * @param text text to use in addition to icon * @return created toolview on success or 0 */ ToolView *createToolView(KTextEditor::Plugin *plugin, const QString &identifier, KMultiTabBar::KMultiTabBarPosition pos, const QIcon &icon, const QString &text); /** * give you handle to toolview for the given name, 0 if no toolview around * @param identifier toolview name * @return toolview if existing, else 0 */ ToolView *toolView(const QString &identifier) const; /** * set the toolview's tabbar style. * @param style the tabbar style. */ void setToolViewStyle(KMultiTabBar::KMultiTabBarStyle style); /** * get the toolview's tabbar style. Call this before @p startRestore(), * otherwise you overwrite the usersettings. * @return toolview's tabbar style */ KMultiTabBar::KMultiTabBarStyle toolViewStyle() const; /** * get the sidebars' visibility. * @return false, if the sidebars' visibility is forced hidden, otherwise true */ bool sidebarsVisible() const; public Q_SLOTS: /** * set the sidebars' visibility to @p visible. If false, the sidebars * are @e always hidden. Usually you do not have to call this because * the user can set this in the menu. * @param visible sidebars visibility */ void setSidebarsVisible(bool visible); protected: /** * called by toolview destructor * @param widget toolview which is destroyed */ void toolViewDeleted(ToolView *widget); /** * central widget ;) * use this as parent for your content * this widget will get focus if a toolview is hidden * @return central widget */ QWidget *centralWidget() const; /** * modifiers for existing toolviews */ public: /** * move a toolview around * @param widget toolview to move * @param pos position to move too, during session restore, only preference * @return success */ bool moveToolView(ToolView *widget, KMultiTabBar::KMultiTabBarPosition pos); /** * show given toolview, discarded while session restore * @param widget toolview to show * @return success */ bool showToolView(ToolView *widget); /** * hide given toolview, discarded while session restore * @param widget toolview to hide * @return success */ bool hideToolView(ToolView *widget); /** * session saving and restore stuff */ public: /** * start the restore * @param config config object to use * @param group config group to use */ void startRestore(KConfigBase *config, const QString &group); /** * finish the restore */ void finishRestore(); /** * save the current session config to given object and group * @param config config object to use * @param group config group to use */ void saveSession(KConfigGroup &group); /** * internal data ;) */ private: /** * map identifiers to widgets */ QMap m_idToWidget; /** * list of all toolviews around */ QList m_toolviews; /** * widget, which is the central part of the * main window ;) */ QWidget *m_centralWidget; /** * horizontal splitter */ QSplitter *m_hSplitter; /** * vertical splitter */ QSplitter *m_vSplitter; /** * sidebars for the four sides */ Sidebar *m_sidebars[4]; /** * sidebars state. */ bool m_sidebarsVisible; /** * config object for session restore, only valid between * start and finish restore calls */ KConfigBase *m_restoreConfig; /** * restore group */ QString m_restoreGroup; /** * out guiclient */ GUIClient *m_guiClient; Q_SIGNALS: void sigShowPluginConfigPage(KTextEditor::Plugin*configpageinterface, uint id); }; } #endif diff --git a/kate/katemwmodonhddialog.cpp b/kate/katemwmodonhddialog.cpp index b8ac4ffb0..795d7c353 100644 --- a/kate/katemwmodonhddialog.cpp +++ b/kate/katemwmodonhddialog.cpp @@ -1,375 +1,375 @@ /* 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. --- Copyright (C) 2004, Anders Lund */ #include "katemwmodonhddialog.h" #include "kateapp.h" #include "katedocmanager.h" #include "katemainwindow.h" #include #include #include #include #include #include #include #include #include #include #include #include class KateDocItem : public QTreeWidgetItem { public: KateDocItem(KTextEditor::Document *doc, const QString &status, QTreeWidget *tw) : QTreeWidgetItem(tw), document(doc) { setText(0, doc->url().toString()); setText(1, status); if (! doc->isModified()) { setCheckState(0, Qt::Checked); } else { setCheckState(0, Qt::Unchecked); } } - ~KateDocItem() + ~KateDocItem() override {} KTextEditor::Document *document; }; KateMwModOnHdDialog::KateMwModOnHdDialog(DocVector docs, QWidget *parent, const char *name) : QDialog(parent), m_proc(nullptr), m_diffFile(nullptr), m_blockAddDocument(false) { setWindowTitle(i18n("Documents Modified on Disk")); setObjectName(QString::fromLatin1(name)); setModal(true); QVBoxLayout *mainLayout = new QVBoxLayout; setLayout(mainLayout); // Message QHBoxLayout *hb = new QHBoxLayout; mainLayout->addLayout(hb); // dialog text QLabel *icon = new QLabel(this); hb->addWidget(icon); icon->setPixmap(DesktopIcon(QStringLiteral("dialog-warning"))); QLabel *t = new QLabel(i18n( "The documents listed below have changed on disk.

Select one " "or more at once, and press an action button until the list is empty.

"), this); hb->addWidget(t); hb->setStretchFactor(t, 1000); // Document list twDocuments = new QTreeWidget(this); mainLayout->addWidget(twDocuments); QStringList header; header << i18n("Filename") << i18n("Status on Disk"); twDocuments->setHeaderLabels(header); twDocuments->setSelectionMode(QAbstractItemView::SingleSelection); twDocuments->setRootIsDecorated(false); m_stateTexts << QString() << i18n("Modified") << i18n("Created") << i18n("Deleted"); for (int i = 0; i < docs.size(); i++) { new KateDocItem(docs[i], m_stateTexts[(uint)KateApp::self()->documentManager()->documentInfo(docs[i])->modifiedOnDiscReason ], twDocuments); } twDocuments->header()->setStretchLastSection(false); twDocuments->header()->setSectionResizeMode(0, QHeaderView::Stretch); twDocuments->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents); connect(twDocuments, &QTreeWidget::currentItemChanged, this, &KateMwModOnHdDialog::slotSelectionChanged); // Diff line hb = new QHBoxLayout; mainLayout->addLayout(hb); btnDiff = new QPushButton(QIcon::fromTheme(QStringLiteral("document-preview")), i18n("&View Difference"), this); btnDiff->setWhatsThis(i18n( "Calculates the difference between the editor contents and the disk " "file for the selected document, and shows the difference with the " "default application. Requires diff(1).")); hb->addWidget(btnDiff); connect(btnDiff, &QPushButton::clicked, this, &KateMwModOnHdDialog::slotDiff); // Dialog buttons QDialogButtonBox *buttons = new QDialogButtonBox(this); mainLayout->addWidget(buttons); QPushButton *ignoreButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-warning")), i18n("&Ignore Changes")); ignoreButton->setToolTip(i18n("Remove modified flag from selected documents")); buttons->addButton(ignoreButton, QDialogButtonBox::RejectRole); connect(ignoreButton, &QPushButton::clicked, this, &KateMwModOnHdDialog::slotIgnore); QPushButton *overwriteButton = new QPushButton; KGuiItem::assign(overwriteButton, KStandardGuiItem::overwrite()); overwriteButton->setToolTip(i18n("Overwrite selected documents, discarding disk changes")); buttons->addButton(overwriteButton, QDialogButtonBox::DestructiveRole); connect(overwriteButton, &QPushButton::clicked, this, &KateMwModOnHdDialog::slotOverwrite); QPushButton *reloadButton = new QPushButton(QIcon::fromTheme(QStringLiteral("view-refresh")), i18n("&Reload")); reloadButton->setDefault(true); reloadButton->setToolTip(i18n("Reload selected documents from disk")); buttons->addButton(reloadButton, QDialogButtonBox::DestructiveRole); connect(reloadButton, &QPushButton::clicked, this, &KateMwModOnHdDialog::slotReload); slotSelectionChanged(nullptr, nullptr); } KateMwModOnHdDialog::~KateMwModOnHdDialog() { KateMainWindow::unsetModifiedOnDiscDialogIfIf(this); if (m_proc) { m_proc->kill(); m_proc->waitForFinished(); delete m_proc; m_proc = Q_NULLPTR; } if (m_diffFile) { m_diffFile->setAutoRemove(true); delete m_diffFile; m_diffFile = Q_NULLPTR; } } void KateMwModOnHdDialog::slotIgnore() { handleSelected(Ignore); } void KateMwModOnHdDialog::slotOverwrite() { handleSelected(Overwrite); } void KateMwModOnHdDialog::slotReload() { handleSelected(Reload); } void KateMwModOnHdDialog::handleSelected(int action) { // don't alter the treewidget via addDocument, we modify it here! m_blockAddDocument = true; // collect all items we can remove QList itemsToDelete; for (QTreeWidgetItemIterator it(twDocuments); *it; ++it) { KateDocItem *item = (KateDocItem *) * it; if (item->checkState(0) == Qt::Checked) { KTextEditor::ModificationInterface::ModifiedOnDiskReason reason = KateApp::self()->documentManager()->documentInfo(item->document)->modifiedOnDiscReason; bool success = true; if (KTextEditor::ModificationInterface *iface = qobject_cast(item->document)) { iface->setModifiedOnDisk(KTextEditor::ModificationInterface::OnDiskUnmodified); } switch (action) { case Overwrite: success = item->document->save(); if (! success) { KMessageBox::sorry(this, i18n("Could not save the document \n'%1'", item->document->url().toString())); } break; case Reload: item->document->documentReload(); break; default: break; } if (success) { itemsToDelete.append(item); } else { if (KTextEditor::ModificationInterface *iface = qobject_cast(item->document)) { iface->setModifiedOnDisk(reason); } } } } // remove the marked items, addDocument is blocked, this is save! for (int i = 0; i < itemsToDelete.count(); ++i) { delete itemsToDelete[i]; } // any documents left unhandled? if (! twDocuments->topLevelItemCount()) { accept(); } // allow addDocument again m_blockAddDocument = false; } void KateMwModOnHdDialog::slotSelectionChanged(QTreeWidgetItem *current, QTreeWidgetItem *) { KateDocItem *currentDocItem = static_cast(current); // set the diff button enabled btnDiff->setEnabled(currentDocItem && KateApp::self()->documentManager()->documentInfo(currentDocItem->document)->modifiedOnDiscReason != KTextEditor::ModificationInterface::OnDiskDeleted); } // ### the code below is slightly modified from kdelibs/kate/part/katedialogs, // class KateModOnHdPrompt. void KateMwModOnHdDialog::slotDiff() { if (!btnDiff->isEnabled()) { // diff button already pressed, proc not finished yet return; } if (! twDocuments->currentItem()) { return; } KTextEditor::Document *doc = (static_cast(twDocuments->currentItem()))->document; // don't try to diff a deleted file if (KateApp::self()->documentManager()->documentInfo(doc)->modifiedOnDiscReason == KTextEditor::ModificationInterface::OnDiskDeleted) { return; } if (m_diffFile) { return; } m_diffFile = new QTemporaryFile(); m_diffFile->open(); // Start a KProcess that creates a diff m_proc = new KProcess(this); m_proc->setOutputChannelMode(KProcess::MergedChannels); *m_proc << QStringLiteral("diff") << QStringLiteral("-ub") << QStringLiteral("-") << doc->url().toLocalFile(); connect(m_proc, &KProcess::readyRead, this, &KateMwModOnHdDialog::slotDataAvailable); connect(m_proc, static_cast(&KProcess::finished), this, &KateMwModOnHdDialog::slotPDone); setCursor(Qt::WaitCursor); btnDiff->setEnabled(false); m_proc->start(); QTextStream ts(m_proc); int lastln = doc->lines() - 1; for (int l = 0; l < lastln; ++l) { ts << doc->line(l) << QLatin1Char('\n'); } ts << doc->line(lastln); ts.flush(); m_proc->closeWriteChannel(); } void KateMwModOnHdDialog::slotDataAvailable() { m_diffFile->write(m_proc->readAll()); } void KateMwModOnHdDialog::slotPDone() { setCursor(Qt::ArrowCursor); slotSelectionChanged(twDocuments->currentItem(), nullptr); const QProcess::ExitStatus es = m_proc->exitStatus(); delete m_proc; m_proc = nullptr; if (es != QProcess::NormalExit) { KMessageBox::sorry(this, i18n("The diff command failed. Please make sure that " "diff(1) is installed and in your PATH."), i18n("Error Creating Diff")); delete m_diffFile; m_diffFile = nullptr; return; } if (m_diffFile->size() == 0) { KMessageBox::information(this, i18n("Ignoring amount of white space changed, the files are identical."), i18n("Diff Output")); delete m_diffFile; m_diffFile = nullptr; return; } m_diffFile->setAutoRemove(false); QUrl url = QUrl::fromLocalFile(m_diffFile->fileName()); delete m_diffFile; m_diffFile = nullptr; // KRun::runUrl should delete the file, once the client exits KRun::runUrl(url, QStringLiteral("text/x-patch"), this, true); } void KateMwModOnHdDialog::addDocument(KTextEditor::Document *doc) { // guard this e.g. during handleSelected if (m_blockAddDocument) return; for (QTreeWidgetItemIterator it(twDocuments); *it; ++it) { KateDocItem *item = (KateDocItem *) * it; if (item->document == doc) { delete item; break; } } uint reason = (uint)KateApp::self()->documentManager()->documentInfo(doc)->modifiedOnDiscReason; if (reason) { new KateDocItem(doc, m_stateTexts[reason], twDocuments); } if (! twDocuments->topLevelItemCount()) { accept(); } } void KateMwModOnHdDialog::keyPressEvent(QKeyEvent *event) { if (event->modifiers() == 0) { if (event->key() == Qt::Key_Escape) { event->accept(); return; } } QDialog::keyPressEvent(event); } void KateMwModOnHdDialog::closeEvent(QCloseEvent *e) { if (! twDocuments->topLevelItemCount()) { QDialog::closeEvent(e); } else { e->ignore(); } } diff --git a/kate/katemwmodonhddialog.h b/kate/katemwmodonhddialog.h index 266522bd2..9819b1e73 100644 --- a/kate/katemwmodonhddialog.h +++ b/kate/katemwmodonhddialog.h @@ -1,72 +1,72 @@ /* Copyright (C) 2004, Anders Lund 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 _KATE_MW_MODONHD_DIALOG_H_ #define _KATE_MW_MODONHD_DIALOG_H_ #include #include #include class KProcess; class QTemporaryFile; class QTreeWidget; class QTreeWidgetItem; typedef QVector DocVector; /** * A dialog for handling multiple documents modified on disk * from within KateMainWindow */ class KateMwModOnHdDialog : public QDialog { Q_OBJECT public: explicit KateMwModOnHdDialog(DocVector docs, QWidget *parent = nullptr, const char *name = nullptr); - ~KateMwModOnHdDialog(); + ~KateMwModOnHdDialog() override; void addDocument(KTextEditor::Document *doc); private Q_SLOTS: void slotIgnore(); void slotOverwrite(); void slotReload(); void slotDiff(); void slotSelectionChanged(QTreeWidgetItem *current, QTreeWidgetItem *); void slotDataAvailable(); void slotPDone(); private: enum Action { Ignore, Overwrite, Reload }; void handleSelected(int action); class QTreeWidget *twDocuments; class QPushButton *btnDiff; KProcess *m_proc; QTemporaryFile *m_diffFile; QStringList m_stateTexts; bool m_blockAddDocument; protected: - void closeEvent(QCloseEvent *e) Q_DECL_OVERRIDE; - void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void closeEvent(QCloseEvent *e) override; + void keyPressEvent(QKeyEvent *) override; }; #endif // _KATE_MW_MODONHD_DIALOG_H_ diff --git a/kate/katepluginmanager.h b/kate/katepluginmanager.h index aac474b75..27c895e40 100644 --- a/kate/katepluginmanager.h +++ b/kate/katepluginmanager.h @@ -1,104 +1,104 @@ /* This file is part of the KDE project Copyright (C) 2001 Christoph Cullmann Copyright (C) 2001 Joseph Wenninger Copyright (C) 2001 Anders Lund 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 __KATE_PLUGINMANAGER_H__ #define __KATE_PLUGINMANAGER_H__ #include #include #include #include #include #include class KConfig; class KateMainWindow; class KatePluginInfo { public: KatePluginInfo() : load(false) , defaultLoad(false) , plugin(nullptr) {} bool load; bool defaultLoad; KPluginMetaData metaData; KTextEditor::Plugin *plugin; QString saveName() const; }; typedef QList KatePluginList; class KatePluginManager : public QObject { Q_OBJECT public: KatePluginManager(QObject *parent); - ~KatePluginManager(); + ~KatePluginManager() override; void unloadAllPlugins(); void enableAllPluginsGUI(KateMainWindow *win, KConfigBase *config = nullptr); void disableAllPluginsGUI(KateMainWindow *win); void loadConfig(KConfig *); void writeConfig(KConfig *); bool loadPlugin(KatePluginInfo *item); void unloadPlugin(KatePluginInfo *item); void enablePluginGUI(KatePluginInfo *item, KateMainWindow *win, KConfigBase *config = nullptr); void enablePluginGUI(KatePluginInfo *item); void disablePluginGUI(KatePluginInfo *item, KateMainWindow *win); void disablePluginGUI(KatePluginInfo *item); inline KatePluginList &pluginList() { return m_pluginList; } KTextEditor::Plugin *plugin(const QString &name); bool pluginAvailable(const QString &name); KTextEditor::Plugin *loadPlugin(const QString &name, bool permanent = true); void unloadPlugin(const QString &name, bool permanent = true); private: void setupPluginList(); /** * all known plugins */ KatePluginList m_pluginList; /** * fast access map from name => plugin info * uses the info stored in the plugin list */ QMap m_name2Plugin; }; #endif diff --git a/kate/katequickopen.h b/kate/katequickopen.h index 8f102eb5f..8cc59dce2 100644 --- a/kate/katequickopen.h +++ b/kate/katequickopen.h @@ -1,72 +1,72 @@ /* Copyright (C) 2007,2009 Joseph Wenninger 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 KATE_QUICK_OPEN_H #define KATE_QUICK_OPEN_H #include class KateMainWindow; class KLineEdit; class QModelIndex; class QStandardItemModel; class QSortFilterProxyModel; class QTreeView; class KateQuickOpen : public QWidget { Q_OBJECT public: KateQuickOpen(QWidget *parent, KateMainWindow *mainWindow); /** * update state * will fill model with current open documents, project documents, ... */ void update(); protected: - bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *obj, QEvent *event) override; private Q_SLOTS: void reselectFirst(); /** * Return pressed, activate the selected document * and go back to background */ void slotReturnPressed(); private: KateMainWindow *m_mainWindow; QTreeView *m_listView; KLineEdit *m_inputLine; /** * our model we search in */ QStandardItemModel *m_base_model; /** * filtered model we search in */ QSortFilterProxyModel *m_model; }; #endif diff --git a/kate/katerunninginstanceinfo.h b/kate/katerunninginstanceinfo.h index 18d9f6bb8..70912780b 100644 --- a/kate/katerunninginstanceinfo.h +++ b/kate/katerunninginstanceinfo.h @@ -1,78 +1,78 @@ /* This file is part of the KDE project Copyright (C) 2009 Joseph Wenninger 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 _KATE_RUNNING_INSTANCE_INFO_ #define _KATE_RUNNING_INSTANCE_INFO_ #include #include #include #include #include class KateRunningInstanceInfo: public QObject { Q_OBJECT public: KateRunningInstanceInfo(const QString &serviceName_): QObject(), valid(false), serviceName(serviceName_), dbus_if(new QDBusInterface(serviceName_, QStringLiteral("/MainApplication"), QString(), //I don't know why it does not work if I specify org.kde.Kate.Application here QDBusConnection::sessionBus(), this)) { if (!dbus_if->isValid()) { std::cerr << qPrintable(QDBusConnection::sessionBus().lastError().message()) << std::endl; } QVariant a_s = dbus_if->property("activeSession"); /* std::cerr< KateRunningInstanceMap; Q_DECL_EXPORT bool fillinRunningKateAppInstances(KateRunningInstanceMap *map); Q_DECL_EXPORT void cleanupRunningKateAppInstanceMap(KateRunningInstanceMap *map); #endif diff --git a/kate/katesavemodifieddialog.cpp b/kate/katesavemodifieddialog.cpp index 1e02034ce..e1e177758 100644 --- a/kate/katesavemodifieddialog.cpp +++ b/kate/katesavemodifieddialog.cpp @@ -1,261 +1,261 @@ /* This file is part of the KDE project Copyright (C) 2004 Joseph Wenninger 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 "katesavemodifieddialog.h" #include "katedebug.h" #include #include #include #include #include #include #include #include #include class AbstractKateSaveModifiedDialogCheckListItem: public QTreeWidgetItem { public: AbstractKateSaveModifiedDialogCheckListItem(const QString &title, const QString &url): QTreeWidgetItem() { setFlags(flags() | Qt::ItemIsUserCheckable); setText(0, title); setText(1, url); setCheckState(0, Qt::Checked); setState(InitialState); } - virtual ~AbstractKateSaveModifiedDialogCheckListItem() + ~AbstractKateSaveModifiedDialogCheckListItem() override {} virtual bool synchronousSave(QWidget *dialogParent) = 0; enum STATE {InitialState, SaveOKState, SaveFailedState}; STATE state() const { return m_state; } void setState(enum STATE state) { m_state = state; switch (state) { case InitialState: setIcon(0, QIcon()); break; case SaveOKState: setIcon(0, QIcon::fromTheme(QStringLiteral("dialog-ok"))); // QStringLiteral("ok") icon should probably be QStringLiteral("dialog-success"), but we don't have that icon in KDE 4.0 break; case SaveFailedState: setIcon(0, QIcon::fromTheme(QStringLiteral("dialog-error"))); break; } } private: STATE m_state; }; class KateSaveModifiedDocumentCheckListItem: public AbstractKateSaveModifiedDialogCheckListItem { public: KateSaveModifiedDocumentCheckListItem(KTextEditor::Document *document) : AbstractKateSaveModifiedDialogCheckListItem(document->documentName(), document->url().toString()) { m_document = document; } - virtual ~KateSaveModifiedDocumentCheckListItem() + ~KateSaveModifiedDocumentCheckListItem() override {} - virtual bool synchronousSave(QWidget *dialogParent) Q_DECL_OVERRIDE { + bool synchronousSave(QWidget *dialogParent) override { if (m_document->url().isEmpty()) { const QUrl url = QFileDialog::getSaveFileUrl(dialogParent, i18n("Save As (%1)", m_document->documentName())); if (!url.isEmpty()) { // check for overwriting a file if (url.isLocalFile()) { QFileInfo info(url.path()); if (info.exists()) { if (KMessageBox::Cancel == KMessageBox::warningContinueCancel(dialogParent, i18n("A file named \"%1\" already exists. " "Are you sure you want to overwrite it?" , info.fileName()), i18n("Overwrite File?"), KStandardGuiItem::overwrite(), KStandardGuiItem::cancel(), QString(), KMessageBox::Notify | KMessageBox::Dangerous)) { setState(SaveFailedState); return false; } } } if (!m_document->saveAs(url)) { setState(SaveFailedState); setText(1, m_document->url().toString()); return false; } else { bool sc = m_document->waitSaveComplete(); setText(1, m_document->url().toString()); if (!sc) { setState(SaveFailedState); return false; } else { setState(SaveOKState); return true; } } } else { //setState(SaveFailedState); return false; } } else { //document has an exising location if (!m_document->save()) { setState(SaveFailedState); setText(1, m_document->url().toString()); return false; } else { bool sc = m_document->waitSaveComplete(); setText(1, m_document->url().toString()); if (!sc) { setState(SaveFailedState); return false; } else { setState(SaveOKState); return true; } } } return false; } private: KTextEditor::Document *m_document; }; KateSaveModifiedDialog::KateSaveModifiedDialog(QWidget *parent, QList documents): QDialog(parent) { setWindowTitle(i18n("Save Documents")); setObjectName(QStringLiteral("KateSaveModifiedDialog")); setModal(true); QVBoxLayout *mainLayout = new QVBoxLayout; setLayout(mainLayout); // label QLabel *lbl = new QLabel(i18n("The following documents have been modified. Do you want to save them before closing?"), this); mainLayout->addWidget(lbl); // main view m_list = new QTreeWidget(this); mainLayout->addWidget(m_list); m_list->setColumnCount(2); m_list->setHeaderLabels(QStringList() << i18n("Documents") << i18n("Location")); m_list->setRootIsDecorated(true); foreach(KTextEditor::Document * doc, documents) { m_list->addTopLevelItem(new KateSaveModifiedDocumentCheckListItem(doc)); } m_list->resizeColumnToContents(0); connect(m_list, &QTreeWidget::itemChanged, this, &KateSaveModifiedDialog::slotItemActivated); QPushButton *selectAllButton = new QPushButton(i18n("Se&lect All"), this); mainLayout->addWidget(selectAllButton); connect(selectAllButton, &QPushButton::clicked, this, &KateSaveModifiedDialog::slotSelectAll); // dialog buttons QDialogButtonBox *buttons = new QDialogButtonBox(this); mainLayout->addWidget(buttons); m_saveButton = new QPushButton; KGuiItem::assign(m_saveButton, KStandardGuiItem::save()); buttons->addButton(m_saveButton, QDialogButtonBox::YesRole); connect(m_saveButton, &QPushButton::clicked, this, &KateSaveModifiedDialog::slotSaveSelected); QPushButton *discardButton = new QPushButton; KGuiItem::assign(discardButton, KStandardGuiItem::discard()); buttons->addButton(discardButton, QDialogButtonBox::NoRole); connect(discardButton, &QPushButton::clicked, this, &KateSaveModifiedDialog::slotDoNotSave); QPushButton *cancelButton = new QPushButton; KGuiItem::assign(cancelButton, KStandardGuiItem::cancel()); cancelButton->setDefault(true); cancelButton->setFocus(); buttons->addButton(cancelButton, QDialogButtonBox::RejectRole); connect(cancelButton, &QPushButton::clicked, this, &KateSaveModifiedDialog::reject); } KateSaveModifiedDialog::~KateSaveModifiedDialog() {} void KateSaveModifiedDialog::slotItemActivated(QTreeWidgetItem *, int) { bool enableSaveButton = false; for (int i = 0; i < m_list->topLevelItemCount(); ++i) { if (m_list->topLevelItem(i)->checkState(0) == Qt::Checked) { enableSaveButton = true; break; } } m_saveButton->setEnabled(enableSaveButton); } void KateSaveModifiedDialog::slotSelectAll() { for (int i = 0; i < m_list->topLevelItemCount(); ++i) { m_list->topLevelItem(i)->setCheckState(0, Qt::Checked); } m_saveButton->setEnabled(true); } void KateSaveModifiedDialog::slotSaveSelected() { if (doSave()) { done(QDialog::Accepted); } } void KateSaveModifiedDialog::slotDoNotSave() { done(QDialog::Accepted); } bool KateSaveModifiedDialog::doSave() { for (int i = 0; i < m_list->topLevelItemCount(); ++i) { AbstractKateSaveModifiedDialogCheckListItem *cit = static_cast(m_list->topLevelItem(i)); if (cit->checkState(0) == Qt::Checked && (cit->state() != AbstractKateSaveModifiedDialogCheckListItem::SaveOKState)) { if (!cit->synchronousSave(this /*perhaps that should be the kate mainwindow*/)) { if (cit->state() == AbstractKateSaveModifiedDialogCheckListItem::SaveFailedState) { KMessageBox::sorry(this, i18n("Data you requested to be saved could not be written. Please choose how you want to proceed.")); } return false; } } else if ((cit->checkState(0) != Qt::Checked) && (cit->state() == AbstractKateSaveModifiedDialogCheckListItem::SaveFailedState)) { cit->setState(AbstractKateSaveModifiedDialogCheckListItem::InitialState); } } return true; } bool KateSaveModifiedDialog::queryClose(QWidget *parent, QList documents) { KateSaveModifiedDialog d(parent, documents); return (d.exec() != QDialog::Rejected); } diff --git a/kate/katesavemodifieddialog.h b/kate/katesavemodifieddialog.h index 5bccdb29c..38a7ec816 100644 --- a/kate/katesavemodifieddialog.h +++ b/kate/katesavemodifieddialog.h @@ -1,54 +1,54 @@ /* This file is part of the KDE project Copyright (C) 2004 Joseph Wenninger 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 _KATE_SAVE_MODIFIED_DIALOG_ #define _KATE_SAVE_MODIFIED_DIALOG_ #include #include #include class QTreeWidget; class QTreeWidgetItem; class QPushButton; class KateSaveModifiedDialog: public QDialog { Q_OBJECT public: KateSaveModifiedDialog(QWidget *parent, QList documents); - virtual ~KateSaveModifiedDialog(); + ~KateSaveModifiedDialog() override; static bool queryClose(QWidget *parent, QList documents); protected: bool doSave(); protected Q_SLOTS: void slotSelectAll(); void slotItemActivated(QTreeWidgetItem *, int); void slotSaveSelected(); void slotDoNotSave(); private: QTreeWidgetItem *m_documentRoot; QTreeWidget *m_list; QPushButton *m_saveButton; }; #endif diff --git a/kate/katetabbar.h b/kate/katetabbar.h index 66926c8a6..3d79e883c 100644 --- a/kate/katetabbar.h +++ b/kate/katetabbar.h @@ -1,262 +1,262 @@ /* This file is part of the KDE project * * Copyright (C) 2014 Dominik Haumann * * 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 KATE_TAB_BAR_H #define KATE_TAB_BAR_H #include #include #include #include class KateTabButton; class KateTabBarPrivate; /** * The \p KateTabBar class provides a tab bar, e.g. for tabbed documents. * * The API closely follows the API of QTabBar. * * @author Dominik Haumann */ class KateTabBar : public QWidget { Q_OBJECT Q_PROPERTY(bool isActive READ isActive WRITE setActive) public: explicit KateTabBar(QWidget *parent = nullptr); - virtual ~KateTabBar(); + ~KateTabBar() override; /** * Adds a new tab with \a text. Returns the new tab's id. */ int addTab(const QString &text); /** * Insert a tab at \p position with \a text. Returns the new tab's id. * @param position index of the tab, i.e. 0, ..., count() */ int insertTab(int position, const QString & text); /** * Removes the tab with ID \a id. * @return the position where the tab was */ int removeTab(int index); /** * Get the ID of the tab bar's activated tab. Returns -1 if no tab is activated. */ int currentTab() const; /** * Get the ID of the tab that is located left of the current tab. * The return value is -1, if there is no previous tab. */ int prevTab() const; /** * Get the ID of the tab that is located right of the current tab. * The return value is -1, if there is no next tab. */ int nextTab() const; public Q_SLOTS: /** * Activate the tab with \p id. No signal is emitted. */ void setCurrentTab(int index); // does not emit signal public: /** * Returns whether a tab with ID \a id exists. */ bool containsTab(int index) const; /** * Set the button @p id's tool tip to @p tip. */ void setTabToolTip(int index, const QString &tip); /** * Get the button @p id's url. Result is QStrint() if not available. */ QString tabToolTip(int index) const; /** * Sets the text of the tab with ID \a id to \a text. * \see tabText() */ void setTabText(int index, const QString &text); /** * Returns the text of the tab with ID \a id. If the button id does not * exist \a QString() is returned. * \see setTabText() */ QString tabText(int index) const; /** * Sets the URL of the tab with ID \a id to \a url. * \see tabUrl() * \since 17.08 */ void setTabUrl(int index, const QUrl &url); /** * Returns the text of the tab with ID \a id. If the button id does not * exist \a QString() is returned. * \see setTabUrl() * \since 17.08 */ QUrl tabUrl(int index) const; /** * Sets the icon of the tab with ID \a id to \a icon. * \see tabIcon() */ void setTabIcon(int index, const QIcon &pixmap); /** * Returns the icon of the tab with ID \a id. If the button id does not * exist \a QIcon() is returned. * \see setTabIcon() */ QIcon tabIcon(int index) const; /** * Returns the number of tabs in the tab bar. */ int count() const; /** * Return the maximum amount of tabs that fit into the tab bar given * the minimumTabWidth(). */ int maxTabCount() const; /** * Marks this tabbar as active. That is, current-tab indicators are * properly highlighted, indicating that child widgets of this tabbar * will get input. * * This concept is mostly useful, if your application has multiple tabbars. * Inactive tabbars are grayed out. */ void setActive(bool active); /** * Returns whether this tabbar is active. */ bool isActive() const; Q_SIGNALS: /** * This signal is emitted whenever the current activated tab changes. */ void currentChanged(int id); /** * This signal is emitted whenever tab @p id should be closed. */ void closeTabRequested(int id); /** * This signal is emitted whenever the context menu is requested for * button @p id at position @p globalPos. * @param id the button, or -1 if the context menu was requested on * at a place where no tab exists * @param globalPos the position of the context menu in global coordinates */ void contextMenuRequest(int id, const QPoint & globalPos); /** * This signal is emitted whenever the tab bar's width allows to * show more tabs than currently available. In other words, * you can safely add @p count tabs which are guaranteed to be visible. */ void moreTabsRequested(int count); /** * This signal is emitted whenever the tab bar's width is too small, * such that not all tabs can be shown. * Therefore, @p count tabs should be removed. */ void lessTabsRequested(int count); /** * This signal is emitted whenever the users double clicks on the free * space next to the tab bar. Typically, a new document should be * created. */ void newTabRequested(); /** * This signal is emitted whenever the tab bar was clicked while the * tab bar is not the active view space tab bar. */ void activateViewSpaceRequested(); protected Q_SLOTS: /** * Active button changed. Emit signal \p currentChanged() with the button's ID. */ void tabButtonActivated(KateTabButton *tabButton); /** * If the user wants to close a tab with the context menu, it sends a close * request. */ void tabButtonCloseRequest(KateTabButton *tabButton); protected: //! Recalculate geometry for all tabs. void resizeEvent(QResizeEvent *event) override; //! Override to avoid requesting a new tab. void mouseDoubleClickEvent(QMouseEvent *event) override; //! Override to request making the tab bar active. void mousePressEvent(QMouseEvent *event) override; //! trigger repaint on hover leave event void leaveEvent(QEvent *event) override; //! Paint tab separators void paintEvent(QPaintEvent *event) override; //! Request context menu void contextMenuEvent(QContextMenuEvent *ev) override; //! Cycle through tabs void wheelEvent(QWheelEvent * event) override; //! Support for drag & drop of tabs void dragEnterEvent(QDragEnterEvent *event) override; void dragMoveEvent(QDragMoveEvent *event) override; void dropEvent(QDropEvent *event) override; private: // pimpl data holder KateTabBarPrivate * const d; }; #endif // KATE_TAB_BAR_H diff --git a/kate/katetabbutton.h b/kate/katetabbutton.h index 1029049b9..c3d02fa39 100644 --- a/kate/katetabbutton.h +++ b/kate/katetabbutton.h @@ -1,135 +1,135 @@ /* This file is part of the KDE project * * Copyright (C) 2014 Dominik Haumann * * 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 KATE_TAB_BUTTON #define KATE_TAB_BUTTON #include #include class QPropertyAnimation; class TabCloseButton : public QAbstractButton { Q_OBJECT public: // constructor TabCloseButton(QWidget * parent = nullptr); // paint close button depending on its state - void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *event) override; // returns the size hint depending on the style - QSize sizeHint() const Q_DECL_OVERRIDE; + QSize sizeHint() const override; protected: - void enterEvent(QEvent *event) Q_DECL_OVERRIDE; - void leaveEvent(QEvent *event) Q_DECL_OVERRIDE; + void enterEvent(QEvent *event) override; + void leaveEvent(QEvent *event) override; }; /** * A \p KateTabButton represents a button on the tab bar. It can either be * \e activated or \e deactivated. If the state is \e deactivated it will * be @e activated when the mouse is pressed. It then emits the signal * @p activated(). The \p KateTabButton's text can be set with \p setText() * and an additional icon can be shown with \p setIcon(). * * @author Dominik Haumann */ class KateTabButton : public QAbstractButton { Q_OBJECT public: /** * Constructs a new tab bar button with \a text and \a parent. */ KateTabButton(const QString &text, QWidget *parent = nullptr); /** * Returns @e true, if the tabbar is the currently active tab bar. */ bool isActiveTabBar() const; /** * Check whether a geometry animation is running. */ bool geometryAnimationRunning() const; /** * The URL of the document this tab represents. * \since 17.08 */ QUrl url() const; /** * Sets the URL of the document this tab represents. * \since 17.08 */ void setUrl(const QUrl &url); public Q_SLOTS: /** * Animate the button's geometry from @p startGeom to @p endGeom * with linear interpolation. */ void setAnimatedGeometry(const QRect & startGeom, const QRect & endGeom); Q_SIGNALS: /** * Emitted whenever the button changes state from deactivated to activated, * or when the button was clicked although it was already active. * @param tabbutton the pressed button (this) */ void activated(KateTabButton *tabbutton); /** * Emitted whenever the user wants to close the tab button. * @param tabbutton the button that emitted this signal */ void closeRequest(KateTabButton *tabbutton); protected Q_SLOTS: void closeButtonClicked(); protected: /** paint eyecandy rectangles around the button */ void paintEvent(QPaintEvent *ev) override; /** activate, and for drag & drop */ void mousePressEvent(QMouseEvent *ev) override; /** possibly start drag event */ void mouseMoveEvent(QMouseEvent *event) override; /** eat double click events */ void mouseDoubleClickEvent(QMouseEvent *event) override; /** trigger repaint on hover enter event */ void enterEvent(QEvent *event) override; /** trigger repaint on hover leave event */ void leaveEvent(QEvent *event) override; /** track geometry changes to trigger proper repaint*/ void moveEvent(QMoveEvent *event) override; private: TabCloseButton * m_closeButton; QPropertyAnimation * m_geometryAnimation; QPoint m_mouseDownPosition; QUrl m_url; }; #endif diff --git a/kate/kateviewmanager.h b/kate/kateviewmanager.h index 305376de3..cae9edec7 100644 --- a/kate/kateviewmanager.h +++ b/kate/kateviewmanager.h @@ -1,351 +1,351 @@ /* This file is part of the KDE project Copyright (C) 2001 Christoph Cullmann Copyright (C) 2001 Joseph Wenninger Copyright (C) 2001 Anders Lund 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 __KATE_VIEWMANAGER_H__ #define __KATE_VIEWMANAGER_H__ #include "katedocmanager.h" #include #include #include #include #include namespace KActivities { class ResourceInstance; } namespace KTextEditor { class View; class Document; } class KateDocumentInfo; class KConfigGroup; class KConfigBase; class KateMainWindow; class KateViewSpace; class KateViewManager : public QSplitter { Q_OBJECT public: KateViewManager(QWidget *parentW, KateMainWindow *parent); - ~KateViewManager(); + ~KateViewManager() override; private: /** * create all actions needed for the view manager */ void setupActions(); void updateViewSpaceActions(); public: /* This will save the splitter configuration */ void saveViewConfiguration(KConfigGroup &group); /* restore it */ void restoreViewConfiguration(const KConfigGroup &group); KTextEditor::Document *openUrl(const QUrl &url, const QString &encoding, bool activate = true, bool isTempFile = false, const KateDocumentInfo &docInfo = KateDocumentInfo()); KTextEditor::Document *openUrls(const QList &url, const QString &encoding, bool isTempFile = false, const KateDocumentInfo &docInfo = KateDocumentInfo()); KTextEditor::View *openUrlWithView(const QUrl &url, const QString &encoding); public Q_SLOTS: void openUrl(const QUrl &url); public: void closeView(KTextEditor::View *view); KateMainWindow *mainWindow(); private Q_SLOTS: void activateView(KTextEditor::View *view); void activateSpace(KTextEditor::View *v); public Q_SLOTS: void slotDocumentNew(); void slotDocumentOpen(); void slotDocumentClose(); void slotDocumentClose(KTextEditor::Document *document); void setActiveSpace(KateViewSpace *vs); void setActiveView(KTextEditor::View *view); void activateNextView(); void activatePrevView(); Q_SIGNALS: void viewChanged(KTextEditor::View *); void viewCreated(KTextEditor::View *); public: /** * create and activate a new view for doc, if doc == 0, then * create a new document. * Can return NULL. */ KTextEditor::View *createView(KTextEditor::Document *doc = nullptr, KateViewSpace *vs = nullptr); private: bool deleteView(KTextEditor::View *view); void moveViewtoSplit(KTextEditor::View *view); void moveViewtoStack(KTextEditor::View *view); /* Save the configuration of a single splitter. * If child splitters are found, it calls it self with those as the argument. * If a viewspace child is found, it is asked to save its filelist. */ QString saveSplitterConfig(QSplitter *s, KConfigBase *config, const QString &viewConfGrp); /** Restore a single splitter. * This is all the work is done for @see saveSplitterConfig() */ void restoreSplitter(const KConfigBase *config, const QString &group, QSplitter *parent, const QString &viewConfGrp); void removeViewSpace(KateViewSpace *viewspace); public: KTextEditor::View *activeView(); KateViewSpace *activeViewSpace(); private Q_SLOTS: void slotViewChanged(); void documentCreated(KTextEditor::Document *doc); void documentWillBeDeleted(KTextEditor::Document *doc); void documentSavedOrUploaded(KTextEditor::Document *document, bool saveAs); /** * This signal is emitted before the documents batch is going to be deleted * * note that the batch can be interrupted in the middle and only some * of the documents may be actually deleted. See documentsDeleted() signal. * * @param documents documents we want to delete, may not be deleted */ void aboutToDeleteDocuments(const QList &documents); /** * This singnal is emitted after the documents batch was deleted * * This is the batch closing signal for aboutToDeleteDocuments * @param documents the documents that weren't deleted after all */ void documentsDeleted(const QList &documents); public Q_SLOTS: /** * Splits a KateViewSpace into two in the following steps: * 1. create a QSplitter in the parent of the KateViewSpace to be split * 2. move the to-be-split KateViewSpace to the new splitter * 3. create new KateViewSpace and added to the new splitter * 4. create KateView to populate the new viewspace. * 5. The new KateView is made the active one, because createView() does that. * If no viewspace is provided, the result of activeViewSpace() is used. * The orientation of the new splitter is determined by the value of o. * Note: horizontal splitter means vertically aligned views. */ void splitViewSpace(KateViewSpace *vs = nullptr, Qt::Orientation o = Qt::Horizontal); /** * Close the view space that contains the given view. If no view was * given, then the active view space will be closed instead. */ void closeViewSpace(KTextEditor::View *view = nullptr); /** * @returns true of the two given views share the same view space. */ bool viewsInSameViewSpace(KTextEditor::View *view1, KTextEditor::View *view2); /** * activate view for given document * @param doc document to activate view for */ KTextEditor::View *activateView(KTextEditor::Document *doc); /** Splits the active viewspace horizontally */ void slotSplitViewSpaceHoriz() { splitViewSpace(nullptr, Qt::Vertical); } /** Splits the active viewspace vertically */ void slotSplitViewSpaceVert() { splitViewSpace(); } /** moves the splitter according to the key that has been pressed */ void moveSplitter(Qt::Key key, int repeats = 1); /** moves the splitter to the right */ void moveSplitterRight() { moveSplitter(Qt::Key_Right); } /** moves the splitter to the left */ void moveSplitterLeft() { moveSplitter(Qt::Key_Left); } /** moves the splitter up */ void moveSplitterUp() { moveSplitter(Qt::Key_Up); } /** moves the splitter down */ void moveSplitterDown() { moveSplitter(Qt::Key_Down); } /** closes the current view space. */ void slotCloseCurrentViewSpace() { closeViewSpace(); } /** closes every view but the active one */ void slotCloseOtherViews(); /** hide every view but the active one */ void slotHideOtherViews(bool hideOthers); void reactivateActiveView(); /** * Toogle the orientation of current split view */ void toggleSplitterOrientation(); /** * Get a list of all views. * @return all views */ QList views() const { return m_views.keys(); } /** * get views in lru order * @return views in lru order */ QList sortedViews() const { QMap sortedViews; QHashIterator i(m_views); while (i.hasNext()) { i.next(); sortedViews[i.value().lruAge] = i.key(); } return sortedViews.values(); } private: KateMainWindow *m_mainWindow; bool m_init; QAction *m_splitViewVert; QAction *m_splitViewHoriz; QAction *m_closeView; QAction *m_closeOtherViews; QAction *m_toggleSplitterOrientation; QAction *m_hideOtherViews; QAction *goNext; QAction *goPrev; QList m_viewSpaceList; bool m_blockViewCreationAndActivation; bool m_activeViewRunning; int m_splitterIndex; // used during saving splitter config. /** * View meta data */ class ViewData { public: /** * Default constructor */ ViewData() : active(false) , lruAge(0) , activityResource(Q_NULLPTR) { } /** * view active? */ bool active; /** * lru age of the view * important: smallest age ==> latest used view */ qint64 lruAge; /** * activity resource for the view */ KActivities::ResourceInstance *activityResource; }; /** * central storage of all views known in the view manager * maps the view to meta data */ QHash m_views; /** * current minimal age */ qint64 m_minAge; /** * the view that is ATM merged to the xml gui factory */ QPointer m_guiMergedView; /** * last url of open file dialog, used if current document has no valid url */ QUrl m_lastOpenDialogUrl; }; #endif diff --git a/kate/kateviewspace.h b/kate/kateviewspace.h index ed844cdf2..0571713e6 100644 --- a/kate/kateviewspace.h +++ b/kate/kateviewspace.h @@ -1,214 +1,214 @@ /* This file is part of the KDE project Copyright (C) 2001 Christoph Cullmann Copyright (C) 2001 Joseph Wenninger Copyright (C) 2001 Anders Lund 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 KATE_VIEWSPACE_H #define KATE_VIEWSPACE_H #include #include #include #include #include class KConfigBase; class KateViewManager; class QStackedWidget; class QToolButton; class KateTabBar; class KateViewSpace : public QWidget { Q_OBJECT public: explicit KateViewSpace(KateViewManager *, QWidget *parent = nullptr, const char *name = nullptr); /** * Returns \e true, if this view space is currently the active view space. */ bool isActiveSpace(); /** * Depending on @p active, mark this view space as active or inactive. * Called from the view manager. */ void setActive(bool active); /** * Create new view for given document * @param doc document to create view for * @return new created view */ KTextEditor::View *createView(KTextEditor::Document *doc); void removeView(KTextEditor::View *v); bool showView(KTextEditor::View *view) { return showView(view->document()); } bool showView(KTextEditor::Document *document); // might be nullptr, if there is no view KTextEditor::View *currentView(); void saveConfig(KConfigBase *config, int myIndex, const QString &viewConfGrp); void restoreConfig(KateViewManager *viewMan, const KConfigBase *config, const QString &group); /** * Returns the document LRU list of this view space. */ QVector lruDocumentList() const; /** * Called by the view manager if a viewspace was closed. * The documents of the closed are merged into this viewspace */ void mergeLruList(const QVector & lruList); /** * Called by the view manager to notify that new documents were created * while this view space was active. If @p append is @e true, the @p doc * is appended to the lru document list, otherwise, it is prepended. */ void registerDocument(KTextEditor::Document *doc, bool append = true); /** * Event filter to catch events from view space tool buttons. */ - bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *obj, QEvent *event) override; /** * Focus the previous tab in the tabbar. */ void focusPrevTab(); /** * Focus the next tab in the tabbar. */ void focusNextTab(); public Q_SLOTS: void documentDestroyed(QObject *doc); void updateDocumentName(KTextEditor::Document *doc); void updateDocumentUrl(KTextEditor::Document *doc); void updateDocumentState(KTextEditor::Document *doc); private Q_SLOTS: void statusBarToggled(); void tabBarToggled(); void changeView(int buttonId); /** * Calls this slot to make this view space the currently active view space. * Making it active goes through the KateViewManager. * @param focusCurrentView if @e true, the current view will get focus */ void makeActive(bool focusCurrentView = true); /** * Add a tab for @p doc at position @p index. */ void insertTab(int index, KTextEditor::Document * doc); /** * Remove tab for @p doc, and return the index (position) * of the removed tab. */ int removeTab(KTextEditor::Document * doc, bool documentDestroyed); /** * Remove @p count tabs, since the tab bar shrinked. */ void removeTabs(int count); /** * Add @p count tabs, since the tab bar grew. */ void addTabs(int count); /** * This slot is called by the tabbar, if tab @p id was closed through the * context menu. */ void closeTabRequest(int id); /** * This slot is called when the context menu is requested for button * @p id at position @p globalPos. * @param id the button, or -1 if the context menu was requested on * at a place where no tab exists * @param globalPos the position of the context menu in global coordinates */ void showContextMenu(int id, const QPoint & globalPos); /** * Called to create a new empty document. */ void createNewDocument(); /** * Update the quick open button to reflect the currently hidden tabs. */ void updateQuickOpen(); private: /** * Returns the amount of documents in KateDocManager that currently * have no tab in this tab bar. */ int hiddenDocuments() const; private: // Kate's view manager KateViewManager *m_viewManager; // config group string, used for restoring View session configuration QString m_group; // flag that indicates whether this view space is the active one. // correct setter: m_viewManager->setActiveSpace(this); bool m_isActiveSpace; // widget stack that contains all KTE::Views QStackedWidget *stack; // document's in the view space, sorted in LRU mode: // the most recently used Document is at the end of the list QVector m_lruDocList; // the list of views that are contained in this view space, // mapped through a hash from Document to View. // note: the number of entries match stack->count(); QHash m_docToView; // tab bar that contains viewspace tabs KateTabBar *m_tabBar; // split action QToolButton *m_split; // quick open action QToolButton *m_quickOpen; // map from Document to button id QHash m_docToTabId; }; #endif diff --git a/kate/session/katesessionchooser.h b/kate/session/katesessionchooser.h index c2d1ee227..71018b99b 100644 --- a/kate/session/katesessionchooser.h +++ b/kate/session/katesessionchooser.h @@ -1,71 +1,71 @@ /* This file is part of the KDE project * * Copyright (C) 2005 Christoph Cullmann * * 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 __KATE_SESSION_CHOOSER_H__ #define __KATE_SESSION_CHOOSER_H__ #include class QPushButton; class QCheckBox; class QTreeWidget; class QTreeWidgetItem; #include "katesession.h" class KateSessionChooser : public QDialog { Q_OBJECT public: KateSessionChooser(QWidget *parent, const QString &lastSession); - ~KateSessionChooser(); + ~KateSessionChooser() override; KateSession::Ptr selectedSession(); bool reopenLastSession(); enum { resultQuit = QDialog::Rejected, resultOpen, resultNew, resultNone, resultCopy }; protected Q_SLOTS: void slotCancel(); void slotOpen(); void slotNew(); void slotCopySession(); void slotDeleteSession(); /** * selection has changed */ void selectionChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous); private: QTreeWidget *m_sessions; QCheckBox *m_useLast; QPushButton *m_openButton; }; #endif diff --git a/kate/session/katesessionmanagedialog.h b/kate/session/katesessionmanagedialog.h index 9bdda06a9..f9caf35b5 100644 --- a/kate/session/katesessionmanagedialog.h +++ b/kate/session/katesessionmanagedialog.h @@ -1,78 +1,78 @@ /* This file is part of the KDE project * * Copyright (C) 2005 Christoph Cullmann * * 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 __KATE_SESSION_MANAGE_DIALOG_H__ #define __KATE_SESSION_MANAGE_DIALOG_H__ #include class QPushButton; class QTreeWidget; class QTreeWidgetItem; class KateSessionManageDialog : public QDialog { Q_OBJECT public: KateSessionManageDialog(QWidget *parent); - ~KateSessionManageDialog(); + ~KateSessionManageDialog() override; protected Q_SLOTS: /** * close pressed */ void slotClose(); /** * selection has changed */ void selectionChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous); /** * try to rename session */ void rename(); /** * try to delete session */ void del(); /** * close dialog and open the selected session */ - void open() Q_DECL_OVERRIDE; + void open() override; private: /** * update our list */ void updateSessionList(); private: QTreeWidget *m_sessions; QPushButton *m_rename; QPushButton *m_del; QPushButton *m_openButton; }; #endif diff --git a/kate/session/katesessionmanager.h b/kate/session/katesessionmanager.h index ee05d6fd3..833b9f55a 100644 --- a/kate/session/katesessionmanager.h +++ b/kate/session/katesessionmanager.h @@ -1,209 +1,209 @@ /* This file is part of the KDE project * * Copyright (C) 2005 Christoph Cullmann * * 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 __KATE_SESSION_MANAGER_H__ #define __KATE_SESSION_MANAGER_H__ #include "katesession.h" #include #include typedef QList KateSessionList; class KATE_TESTS_EXPORT KateSessionManager : public QObject { Q_OBJECT public: KateSessionManager(QObject *parent = nullptr, const QString &sessionsDir = QString()); - ~KateSessionManager(); + ~KateSessionManager() override; /** * allow access to the session list * kept up to date by watching the dir */ KateSessionList sessionList(); /** * activate session by @name * first, it will look if a session with this name exists in list * if yes, it will use this session, else it will create a new session file * @param name name of the session to activate * @param closeAndSaveLast try to close and save last session or not? * @param loadNew load new session stuff? * @return false==session has been delegated, true==session has been activated in this distance */ bool activateSession(const QString &name, const bool closeAndSaveLast = true, const bool loadNew = true); /** * activates new/anonymous session */ bool activateAnonymousSession(); /** * save current session * @param rememberAsLast remember this session as last used? * @return success */ bool saveActiveSession(bool rememberAsLast = false); /** * return the current active session * sessionFile == empty means we have no session around for this instance of kate * @return session active atm */ inline KateSession::Ptr activeSession() { return m_activeSession; } /** * session dir * @return global session dir */ inline const QString &sessionsDir() const { return m_sessionsDir; } /** * initial session chooser, on app start * @return success, if false, app should exit */ bool chooseSession(); public Q_SLOTS: /** * try to start a new session * asks user first for name */ void sessionNew(); /** * try to open a existing session */ void sessionOpen(); /** * try to save current session */ void sessionSave(); /** * try to save as current session */ void sessionSaveAs(); /** * show dialog to manage our sessions */ void sessionManage(); Q_SIGNALS: /** * Emitted, whenever the session changes, e.g. when it was renamed. */ void sessionChanged(); /** * module internal APIs */ public: /** * return session with given name * if no existing session matches, create new one with this name * @param name session name */ KateSession::Ptr giveSession(const QString &name); /** * deletes session file and removes the session from sessions list */ void deleteSession(KateSession::Ptr session); /** * renames the session to @newName * @return true if succesfull */ bool renameSession(KateSession::Ptr session, const QString &newName); /** * activate a session * first, it will look if a session with this name exists in list * if yes, it will use this session, else it will create a new session file * @param session session to activate * @param closeAndSaveLast try to close and save last session or not? * @param loadNew load new session stuff? * @return false==session has been delegated, true==session has been activated in this distance */ bool activateSession(KateSession::Ptr session, const bool closeAndSaveLast = true, const bool loadNew = true); private Q_SLOTS: /** * trigger update of session list */ void updateSessionList(); private: /** * Asks the user for a new session name. Used by save as for example. */ bool newSessionName(); /** * returns session config file according to policy */ QString sessionFileForName(const QString &name) const; /** * returns session file for anonymous session */ QString anonymousSessionFile() const; /** * helper function to save the session to a given config object */ void saveSessionTo(KConfig *sc) const; /** * restore sessions documents, windows, etc... */ void loadSession(const KateSession::Ptr &session) const; private: /** * absolute path to dir in home dir where to store the sessions */ QString m_sessionsDir; /** * list of current available sessions */ QHash m_sessions; /** * current active session */ KateSession::Ptr m_activeSession; class KDirWatch *m_dirWatch; }; #endif diff --git a/kate/session/katesessionopendialog.h b/kate/session/katesessionopendialog.h index 237717532..34ca173e8 100644 --- a/kate/session/katesessionopendialog.h +++ b/kate/session/katesessionopendialog.h @@ -1,62 +1,62 @@ /* This file is part of the KDE project * * Copyright (C) 2005 Christoph Cullmann * * 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 __KATE_SESSION_OPEN_DIALOG_H__ #define __KATE_SESSION_OPEN_DIALOG_H__ #include class QPushButton; class QTreeWidget; class QTreeWidgetItem; #include "katesession.h" class KateSessionOpenDialog : public QDialog { Q_OBJECT public: KateSessionOpenDialog(QWidget *parent); - ~KateSessionOpenDialog(); + ~KateSessionOpenDialog() override; KateSession::Ptr selectedSession(); enum { resultOk, resultCancel }; protected Q_SLOTS: void slotCanceled(); void slotOpen(); /** * selection has changed */ void selectionChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous); private: QTreeWidget *m_sessions; QPushButton *m_openButton; }; #endif diff --git a/kate/session/katesessionsaction.h b/kate/session/katesessionsaction.h index 3b48a0ae3..aaa449ec9 100644 --- a/kate/session/katesessionsaction.h +++ b/kate/session/katesessionsaction.h @@ -1,50 +1,50 @@ /* This file is part of the KDE project * * Copyright (C) 2005 Christoph Cullmann * * 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 __KATE_SESSIONS_ACTION_H__ #define __KATE_SESSIONS_ACTION_H__ #include "kateprivate_export.h" #include class KateSessionManager; class KATE_TESTS_EXPORT KateSessionsAction : public KActionMenu { Q_OBJECT public: KateSessionsAction(const QString &text, QObject *parent, KateSessionManager *manager = nullptr); - ~KateSessionsAction() { + ~KateSessionsAction() override { } public Q_SLOTS: void slotAboutToShow(); void openSession(QAction *action); void slotSessionChanged(); private: friend class KateSessionsActionTest; // tfuj QActionGroup *sessionsGroup; KateSessionManager *m_manager; }; #endif diff --git a/kwrite/kwrite.h b/kwrite/kwrite.h index a3e0bf07f..85649f6d0 100644 --- a/kwrite/kwrite.h +++ b/kwrite/kwrite.h @@ -1,147 +1,147 @@ /* This file is part of the KDE project Copyright (C) 2001 Christoph Cullmann Copyright (C) 2001 Joseph Wenninger Copyright (C) 2001 Anders Lund 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 KWRITE_MAIN_H #define KWRITE_MAIN_H #include #include #include #include #include #include class QLabel; namespace KActivities { class ResourceInstance; } class KToggleAction; class KRecentFilesAction; class KSqueezedTextLabel; class KWrite : public KParts::MainWindow { Q_OBJECT public: KWrite(KTextEditor::Document * = nullptr); - ~KWrite(); + ~KWrite() override; void loadURL(const QUrl &url); KTextEditor::View *view() const { return m_view; } static bool noWindows() { return winList.isEmpty(); } private: void setupActions(); void addMenuBarActionToContextMenu(); void removeMenuBarActionFromContextMenu(); - bool queryClose() Q_DECL_OVERRIDE; + bool queryClose() override; - void dragEnterEvent(QDragEnterEvent *) Q_DECL_OVERRIDE; - void dropEvent(QDropEvent *) Q_DECL_OVERRIDE; + void dragEnterEvent(QDragEnterEvent *) override; + void dropEvent(QDropEvent *) override; public Q_SLOTS: void slotNew(); void slotFlush(); void slotOpen(); void slotOpen(const QUrl &url); void newView(); void toggleStatusBar(); void toggleMenuBar(bool showMessage = true); void editKeys(); void editToolbars(); void aboutEditor(); void modifiedChanged(); private Q_SLOTS: void slotNewToolbarConfig(); public Q_SLOTS: void slotDropEvent(QDropEvent *); void slotEnableActions(bool enable); /** * adds a changed URL to the recent files */ void urlChanged(); /** * Overwrite size hint for better default window sizes * @return size hint */ - QSize sizeHint () const Q_DECL_OVERRIDE; + QSize sizeHint () const override; //config file functions public: void readConfig(KSharedConfigPtr); void writeConfig(KSharedConfigPtr); void readConfig(); void writeConfig(); //session management public: void restore(KConfig *, int); static void restore(); private: - void readProperties(const KConfigGroup &) Q_DECL_OVERRIDE; - void saveProperties(KConfigGroup &) Q_DECL_OVERRIDE; - void saveGlobalProperties(KConfig *) Q_DECL_OVERRIDE; + void readProperties(const KConfigGroup &) override; + void saveProperties(KConfigGroup &) override; + void saveGlobalProperties(KConfig *) override; private: KTextEditor::View *m_view; KRecentFilesAction *m_recentFiles; KToggleAction *m_paShowPath; KToggleAction *m_paShowMenuBar; KToggleAction *m_paShowStatusBar; QAction *m_closeAction; KActivities::ResourceInstance *m_activityResource; static QList docList; static QList winList; public Q_SLOTS: void documentNameChanged(); protected: /** * Event filter for QApplication to handle mac os like file open */ - bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *obj, QEvent *event) override; }; #endif