diff --git a/src/completion/expandingtree/expandingwidgetmodel.h b/src/completion/expandingtree/expandingwidgetmodel.h index 87462e18..e6881fcc 100644 --- a/src/completion/expandingtree/expandingwidgetmodel.h +++ b/src/completion/expandingtree/expandingwidgetmodel.h @@ -1,157 +1,157 @@ /* This file is part of the KDE libraries and the Kate part. * * Copyright (C) 2007 David Nolden * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef EXPANDING_WIDGET_MODEL_H #define EXPANDING_WIDGET_MODEL_H #include #include #include class QTreeView; /** * Cares about expanding/un-expanding items in a tree-view together with ExpandingDelegate */ class ExpandingWidgetModel : public QAbstractItemModel { Q_OBJECT public: explicit ExpandingWidgetModel(QWidget *parent); - virtual ~ExpandingWidgetModel(); + ~ExpandingWidgetModel() override; enum ExpandingType { NotExpandable = 0, Expandable, Expanded }; ///The following three are convenience-functions for the current item that could be replaced by the later ones ///@return whether the current item can be expanded bool canExpandCurrentItem() const; ///@return whether the current item can be collapsed bool canCollapseCurrentItem() const; ///Expand/collapse the current item void setCurrentItemExpanded(bool); void clearMatchQualities(); ///Unexpand all rows and clear all cached information about them(this includes deleting the expanding-widgets) void clearExpanding(); ///@return whether the row given through index is expandable bool isExpandable(const QModelIndex &index) const; enum ExpansionType { NotExpanded = 0, ExpandDownwards, //The additional(expanded) information is shown UNDER the original information ExpandUpwards //The additional(expanded) information is shown ABOVE the original information }; ///Returns whether the given index is currently partially expanded. Does not do any other checks like calling models for data. ExpansionType isPartiallyExpanded(const QModelIndex &index) const; ///@return whether row is currently expanded bool isExpanded(const QModelIndex &row) const; ///Change the expand-state of the row given through index. The display will be updated. void setExpanded(QModelIndex index, bool expanded); ///Returns the total height added through all open expanding-widgets int expandingWidgetsHeight() const; ///@return the expanding-widget for the given row, if available. Expanding-widgets are in best case available for all expanded rows. ///This does not return the partially-expand widget. QWidget *expandingWidget(const QModelIndex &row) const; ///Amount by which the height of a row increases when it is partially expanded int partiallyExpandWidgetHeight() const; /** * Notifies underlying models that the item was selected, collapses any previous partially expanded line, * checks whether this line should be partially expanded, and eventually does it. * Does nothing when nothing needs to be done. * Does NOT show the expanding-widget. That is done immediately when painting by ExpandingDelegate, * to reduce flickering. @see showPartialExpandWidget() * @param row The row * */ /// virtual void rowSelected(const QModelIndex &row); ///Returns the rectangle for the partially expanded part of the given row QRect partialExpandRect(const QModelIndex &row) const; QString partialExpandText(const QModelIndex &row) const; ///Places and shows the expanding-widget for the given row, if it should be visible and is valid. ///Also shows the partial-expanding-widget when it should be visible. void placeExpandingWidget(const QModelIndex &row); virtual QTreeView *treeView() const = 0; ///Should return true if the given row should be painted like a contained item(as opposed to label-rows etc.) virtual bool indexIsItem(const QModelIndex &index) const = 0; ///Does not request data from index, this only returns local data like highlighting for expanded rows and similar QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; ///Returns the first row that is currently partially expanded. QModelIndex partiallyExpandedRow() const; ///Returns the match-color for the given index, or zero if match-quality could not be computed. uint matchColor(const QModelIndex &index) const; public Q_SLOTS: ///Place or hides all expanding-widgets to the correct positions. Should be called after the view was scrolled. void placeExpandingWidgets(); protected: /** * @return the context-match quality from 0 to 10 if it could be determined, else -1 * */ virtual int contextMatchQuality(const QModelIndex &index) const = 0; //Makes sure m_expandedIcon and m_collapsedIcon are loaded void cacheIcons() const; mutable QIcon m_expandedIcon; mutable QIcon m_collapsedIcon; //Does not update the view void partiallyUnExpand(const QModelIndex &index); //Finds out the basic height of the row represented by the given index. Basic means without respecting any expansion. int basicRowHeight(const QModelIndex &index) const; private: QMap m_partiallyExpanded; // Store expanding-widgets and cache whether items can be expanded mutable QMap m_expandState; QMap< QModelIndex, QPointer > m_expandingWidgets; //Map rows to their expanding-widgets QMap< QModelIndex, int > m_contextMatchQualities; //Map rows to their context-match qualities(undefined if unknown, else 0 to 10). Not used yet, eventually remove. }; /** * Helper-function to merge custom-highlighting variant-lists. * * @param strings A list of strings that should be merged * @param highlights One variant-list for highlighting, as described in the kde header ktextedtor/codecompletionmodel.h * @param gapBetweenStrings How many signs are inserted between 2 strings? * */ QList mergeCustomHighlighting(QStringList strings, QList highlights, int gapBetweenStrings = 0); #endif diff --git a/src/completion/katecompletionmodel.h b/src/completion/katecompletionmodel.h index b68fb4da..65b0033b 100644 --- a/src/completion/katecompletionmodel.h +++ b/src/completion/katecompletionmodel.h @@ -1,417 +1,417 @@ /* This file is part of the KDE libraries and the Kate part. * * Copyright (C) 2005-2006 Hamish Rodda * Copyright (C) 2007-2008 David Nolden * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License 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 KATECOMPLETIONMODEL_H #define KATECOMPLETIONMODEL_H #include #include #include #include #include #include "expandingtree/expandingwidgetmodel.h" class KateCompletionWidget; class KateArgumentHintModel; namespace KTextEditor { class ViewPrivate; } class QWidget; class QTextEdit; class QTimer; class HierarchicalModelHandler; /** * This class has the responsibility for filtering, sorting, and manipulating * code completion data provided by a CodeCompletionModel. * * @author Hamish Rodda */ class KTEXTEDITOR_EXPORT KateCompletionModel : public ExpandingWidgetModel { Q_OBJECT public: explicit KateCompletionModel(KateCompletionWidget *parent = nullptr); - ~KateCompletionModel(); + ~KateCompletionModel() override; QList completionModels() const; void clearCompletionModels(); void addCompletionModel(KTextEditor::CodeCompletionModel *model); void setCompletionModel(KTextEditor::CodeCompletionModel *model); void setCompletionModels(const QList &models); void removeCompletionModel(KTextEditor::CodeCompletionModel *model); KTextEditor::ViewPrivate *view() const; KateCompletionWidget *widget() const; QString currentCompletion(KTextEditor::CodeCompletionModel *model) const; void setCurrentCompletion(KTextEditor::CodeCompletionModel *model, const QString &completion); Qt::CaseSensitivity matchCaseSensitivity() const; void setMatchCaseSensitivity(Qt::CaseSensitivity cs); static QString columnName(int column); int translateColumn(int sourceColumn) const; static QString propertyName(KTextEditor::CodeCompletionModel::CompletionProperty property); ///Returns a common prefix for all current visible completion entries ///If there is no common prefix, extracts the next useful prefix for the selected index QString commonPrefix(QModelIndex selectedIndex) const; void rowSelected(const QModelIndex &row) override; bool indexIsItem(const QModelIndex &index) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; Qt::ItemFlags flags(const QModelIndex &index) const override; bool hasChildren(const QModelIndex &parent = QModelIndex()) const override; virtual bool hasIndex(int row, int column, const QModelIndex &parent = QModelIndex()) const; QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; // Disabled in case of bugs, reenable once fully debugged. //virtual QMap itemData ( const QModelIndex & index ) const; QModelIndex parent(const QModelIndex &index) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; // Disabled in case of bugs, reenable once fully debugged. //virtual QModelIndex sibling ( int row, int column, const QModelIndex & index ) const; void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override; ///Maps from this display-model into the appropriate source code-completion model virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const; ///Maps from an index in a source-model to the index of the item in this display-model virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const; // Sorting bool isSortingEnabled() const; bool isSortingAlphabetical() const; bool isSortingByInheritanceDepth() const; void setSortingByInheritanceDepth(bool byIneritance); void setSortingAlphabetical(bool alphabetical); Qt::CaseSensitivity sortingCaseSensitivity() const; void setSortingCaseSensitivity(Qt::CaseSensitivity cs); bool isSortingReverse() const; void setSortingReverse(bool reverse); // Filtering bool isFilteringEnabled() const; bool filterContextMatchesOnly() const; void setFilterContextMatchesOnly(bool filter); bool filterByAttribute() const; void setFilterByAttribute(bool filter); KTextEditor::CodeCompletionModel::CompletionProperties filterAttributes() const; void setFilterAttributes(KTextEditor::CodeCompletionModel::CompletionProperties attributes); // A maximum depth of <= 0 equals don't filter by inheritance depth (i.e. infinity) and is default int maximumInheritanceDepth() const; void setMaximumInheritanceDepth(int maxDepth); // Grouping bool isGroupingEnabled() const; enum gm { ScopeType = 0x1, Scope = 0x2, AccessType = 0x4, ItemType = 0x8 }; enum { //An own property that will be used to mark the best-matches group internally BestMatchesProperty = 2 * KTextEditor::CodeCompletionModel::LastProperty }; Q_DECLARE_FLAGS(GroupingMethods, gm) static const int ScopeTypeMask = 0x380000; static const int AccessTypeMask = 0x7; static const int ItemTypeMask = 0xfe0; GroupingMethods groupingMethod() const; void setGroupingMethod(GroupingMethods m); bool accessIncludeConst() const; void setAccessIncludeConst(bool include); bool accessIncludeStatic() const; void setAccessIncludeStatic(bool include); bool accessIncludeSignalSlot() const; void setAccessIncludeSignalSlot(bool include); // Column merging bool isColumnMergingEnabled() const; const QList< QList > &columnMerges() const; void setColumnMerges(const QList< QList > &columnMerges); void debugStats(); ///Returns whether one of the filtered items exactly matches its completion string bool shouldMatchHideCompletionList() const; uint filteredItemCount() const; protected: int contextMatchQuality(const QModelIndex &index) const override; Q_SIGNALS: void expandIndex(const QModelIndex &index); //Emitted whenever something has changed about the group of argument-hints void argumentHintsChanged(); public Q_SLOTS: void setSortingEnabled(bool enable); void setFilteringEnabled(bool enable); void setGroupingEnabled(bool enable); void setColumnMergingEnabled(bool enable); private Q_SLOTS: void slotRowsInserted(const QModelIndex &parent, int start, int end); void slotRowsRemoved(const QModelIndex &parent, int start, int end); void slotModelReset(); //Updates the best-matches group void updateBestMatches(); //Makes sure that the ungrouped group contains each item only once //Must only be called right after the group was created void makeGroupItemsUnique(bool onlyFiltered = false); private: typedef QPair ModelRow; virtual int contextMatchQuality(const ModelRow &sourceRow) const; QTreeView *treeView() const override; friend class KateArgumentHintModel; ModelRow modelRowPair(const QModelIndex &index) const; // Represents a source row; provides sorting method class Item { public: Item(bool doInitialMatch, KateCompletionModel *model, const HierarchicalModelHandler &handler, ModelRow sourceRow); bool isValid() const; // Returns true if the item is not filtered and matches the current completion string bool isVisible() const; // Returns whether the item is filtered or not bool isFiltered() const; // Returns whether the item matches the current completion string bool isMatching() const; bool filter(); enum MatchType { NoMatch = 0, PerfectMatch, StartsWithMatch, AbbreviationMatch, ContainsMatch }; MatchType match(); const ModelRow &sourceRow() const; // Sorting operator bool operator<(const Item &rhs) const; bool haveExactMatch() const { return m_haveExactMatch; } void clearExactMatch() { m_haveExactMatch = false; } QString name() const { return m_nameColumn; } private: KateCompletionModel *model; ModelRow m_sourceRow; mutable QString m_nameColumn; int inheritanceDepth; // True when currently matching completion string MatchType matchCompletion; // True when passes all active filters bool matchFilters; bool m_haveExactMatch; bool m_unimportant; QString completionSortingName() const; }; public: // Grouping and sorting of rows class Group { public: explicit Group(const QString& title, int attribute, KateCompletionModel *model); void addItem(Item i, bool notifyModel = false); /// Removes the item specified by \a row. Returns true if a change was made to rows. bool removeItem(const ModelRow &row); void resort(); void refilter(); void clear(); //Returns whether this group should be ordered before other bool orderBefore(Group *other) const; //Returns a number that can be used for ordering int orderNumber() const; ///Returns the row in the this group's filtered list of the given model-row in a source-model ///-1 if the item is not in the filtered list ///@todo Implement an efficient way of doing this map, that does _not_ iterate over all items! int rowOf(ModelRow item) { for (int a = 0; a < filtered.size(); ++a) if (filtered[a].sourceRow() == item) { return a; } return -1; } KateCompletionModel *model; int attribute; QString title, scope; QList filtered; QList prefilter; bool isEmpty; //-1 if none was set int customSortingKey; }; bool hasGroups() const; private: QString commonPrefixInternal(const QString &forcePrefix) const; /// @note performs model reset void createGroups(); ///Creates all sub-items of index i, or the item corresponding to index i. Returns the affected groups. ///i must be an index in the source model QSet createItems(const HierarchicalModelHandler &, const QModelIndex &i, bool notifyModel = false); ///Deletes all sub-items of index i, or the item corresponding to index i. Returns the affected groups. ///i must be an index in the source model QSet deleteItems(const QModelIndex &i); Group *createItem(const HierarchicalModelHandler &, const QModelIndex &i, bool notifyModel = false); /// @note Make sure you're in a {begin,end}ResetModel block when calling this! void clearGroups(); void hideOrShowGroup(Group *g, bool notifyModel = false); /// When forceGrouping is enabled, all given attributes will be used for grouping, regardless of the completion settings. Group *fetchGroup(int attribute, const QString &scope = QString(), bool forceGrouping = false); //If this returns nonzero on an index, the index is the header of the returned group Group *groupForIndex(const QModelIndex &index) const; inline Group *groupOfParent(const QModelIndex &child) const { return static_cast(child.internalPointer()); } QModelIndex indexForRow(Group *g, int row) const; QModelIndex indexForGroup(Group *g) const; enum changeTypes { Broaden, Narrow, Change }; //Returns whether the model needs to be reset void changeCompletions(Group *g, changeTypes changeType, bool notifyModel); bool hasCompletionModel() const; /// Removes attributes not used in grouping from the input \a attribute int groupingAttributes(int attribute) const; int countBits(int value) const; void resort(); void refilter(); static bool matchesAbbreviation(const QString &word, const QString &typed); bool m_hasGroups = false; // ### Runtime state // General QList m_completionModels; QMap m_currentMatch; Qt::CaseSensitivity m_matchCaseSensitivity = Qt::CaseInsensitive; // Column merging QList< QList > m_columnMerges; QTimer *m_updateBestMatchesTimer; Group *m_ungrouped; Group *m_argumentHints; //The argument-hints will be passed on to another model, to be shown in another widget Group *m_bestMatches; //A temporary group used for holding the best matches of all visible items // Storing the sorted order QList m_rowTable; QList m_emptyGroups; // Quick access to each specific group (if it exists) QMultiHash m_groupHash; // Maps custom group-names to their specific groups QHash m_customGroupHash; // ### Configurable state // Sorting bool m_sortingEnabled = false; bool m_sortingAlphabetical = false; bool m_isSortingByInheritance = false; Qt::CaseSensitivity m_sortingCaseSensitivity = Qt::CaseInsensitive; QHash< int, QList > m_sortingGroupingOrder; // Filtering bool m_filteringEnabled = false; bool m_filterContextMatchesOnly = false; bool m_filterByAttribute = false; KTextEditor::CodeCompletionModel::CompletionProperties m_filterAttributes; int m_maximumInheritanceDepth = 0; // Grouping bool m_groupingEnabled = false; GroupingMethods m_groupingMethod; bool m_accessConst = false, m_accessStatic = false, m_accesSignalSlot = false; // Column merging bool m_columnMergingEnabled = false/*, m_haveExactMatch*/; friend class CompletionTest; }; Q_DECLARE_OPERATORS_FOR_FLAGS(KateCompletionModel::GroupingMethods) #endif diff --git a/src/dialogs/katedialogs.h b/src/dialogs/katedialogs.h index 5bda8579..13aa6d19 100644 --- a/src/dialogs/katedialogs.h +++ b/src/dialogs/katedialogs.h @@ -1,374 +1,374 @@ /* This file is part of the KDE libraries Copyright (C) 2002, 2003 Anders Lund Copyright (C) 2003 Christoph Cullmann Copyright (C) 2001 Joseph Wenninger Copyright (C) 2006-2016 Dominik Haumann Copyright (C) 2007 Mirko Stocker Copyright (C) 2009 Michel Ludwig Copyright (C) 1999 Jochen Wilhelmy * * 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_DIALOGS_H__ #define __KATE_DIALOGS_H__ #include "katehighlight.h" #include "kateviewhelpers.h" #include "kateconfigpage.h" #include #include #include #include #include #include #include #include #include class ModeConfigPage; namespace KTextEditor { class DocumentPrivate; } namespace KTextEditor { class ViewPrivate; } namespace KTextEditor { class Message; } namespace KIO { class Job; class TransferJob; } class KComboBox; class KShortcutsEditor; class QSpinBox; class KPluginSelector; class KPluginInfo; class KProcess; class QCheckBox; class QLabel; class QCheckBox; class QKeyEvent; class QTemporaryFile; class QTableWidget; namespace Ui { class TextareaAppearanceConfigWidget; class BordersAppearanceConfigWidget; class NavigationConfigWidget; class EditConfigWidget; class IndentationConfigWidget; class OpenSaveConfigWidget; class OpenSaveConfigAdvWidget; class CompletionConfigTab; class SpellCheckConfigWidget; } class KateGotoBar : public KateViewBarWidget { Q_OBJECT public: explicit KateGotoBar(KTextEditor::View *view, QWidget *parent = nullptr); void updateData(); protected Q_SLOTS: void gotoLine(); protected: void keyPressEvent(QKeyEvent *event) override; private: KTextEditor::View *const m_view; QSpinBox *gotoRange; }; class KateDictionaryBar : public KateViewBarWidget { Q_OBJECT public: explicit KateDictionaryBar(KTextEditor::ViewPrivate *view, QWidget *parent = nullptr); virtual ~KateDictionaryBar(); public Q_SLOTS: void updateData(); protected Q_SLOTS: void dictionaryChanged(const QString &dictionary); private: KTextEditor::ViewPrivate *m_view; Sonnet::DictionaryComboBox *m_dictionaryComboBox; }; class KateIndentConfigTab : public KateConfigPage { Q_OBJECT public: explicit KateIndentConfigTab(QWidget *parent); - ~KateIndentConfigTab(); + ~KateIndentConfigTab() override; QString name() const override; protected: Ui::IndentationConfigWidget *ui; public Q_SLOTS: void apply() override; void reload() override; void reset() override {} void defaults() override {} private Q_SLOTS: void slotChanged(); void showWhatsThis(const QString &text); }; class KateCompletionConfigTab : public KateConfigPage { Q_OBJECT public: explicit KateCompletionConfigTab(QWidget *parent); - ~KateCompletionConfigTab(); + ~KateCompletionConfigTab() override; QString name() const override; protected: Ui::CompletionConfigTab *ui; public Q_SLOTS: void apply() override; void reload() override; void reset() override {} void defaults() override {} private Q_SLOTS: void showWhatsThis(const QString &text); }; class KateEditGeneralConfigTab : public KateConfigPage { Q_OBJECT public: explicit KateEditGeneralConfigTab(QWidget *parent); - ~KateEditGeneralConfigTab(); + ~KateEditGeneralConfigTab() override; QString name() const override; private: Ui::EditConfigWidget *ui; public Q_SLOTS: void apply() override; void reload() override; void reset() override {} void defaults() override {} }; class KateNavigationConfigTab : public KateConfigPage { Q_OBJECT public: explicit KateNavigationConfigTab(QWidget *parent); - ~KateNavigationConfigTab(); + ~KateNavigationConfigTab() override; QString name() const override; private: Ui::NavigationConfigWidget *ui; public Q_SLOTS: void apply() override; void reload() override; void reset() override {} void defaults() override {} }; class KateSpellCheckConfigTab : public KateConfigPage { Q_OBJECT public: explicit KateSpellCheckConfigTab(QWidget *parent); - ~KateSpellCheckConfigTab(); + ~KateSpellCheckConfigTab() override; QString name() const override; protected: Ui::SpellCheckConfigWidget *ui; Sonnet::ConfigWidget *m_sonnetConfigWidget; public Q_SLOTS: void apply() override; void reload() override; void reset() override {} void defaults() override {} private Q_SLOTS: void showWhatsThis(const QString &text); }; class KateEditConfigTab : public KateConfigPage { Q_OBJECT public: explicit KateEditConfigTab(QWidget *parent); - ~KateEditConfigTab(); + ~KateEditConfigTab() override; QString name() const override; QString fullName() const override; QIcon icon() const override; public Q_SLOTS: void apply() override; void reload() override; void reset() override; void defaults() override; private: KateEditGeneralConfigTab *editConfigTab; KateNavigationConfigTab *navigationConfigTab; KateIndentConfigTab *indentConfigTab; KateCompletionConfigTab *completionConfigTab; KateSpellCheckConfigTab *spellCheckConfigTab; QList m_inputModeConfigTabs; }; class KateViewDefaultsConfig : public KateConfigPage { Q_OBJECT public: explicit KateViewDefaultsConfig(QWidget *parent); - ~KateViewDefaultsConfig(); + ~KateViewDefaultsConfig() override; QString name() const override; QString fullName() const override; QIcon icon() const override; public Q_SLOTS: void apply() override; void reload() override; void reset() override; void defaults() override; private: Ui::TextareaAppearanceConfigWidget *const textareaUi; Ui::BordersAppearanceConfigWidget *const bordersUi; }; class KateSaveConfigTab : public KateConfigPage { Q_OBJECT public: explicit KateSaveConfigTab(QWidget *parent); - ~KateSaveConfigTab(); + ~KateSaveConfigTab() override; QString name() const override; QString fullName() const override; QIcon icon() const override; public Q_SLOTS: void apply() override; void reload() override; void reset() override; void defaults() override; void swapFileModeChanged(int); protected: //why? //KComboBox *m_encoding, *m_encodingDetection, *m_eol; QCheckBox *cbLocalFiles, *cbRemoteFiles; QCheckBox *replaceTabs, *removeSpaces, *allowEolDetection; class QSpinBox *blockCount; class QLabel *blockCountLabel; private: Ui::OpenSaveConfigWidget *ui; Ui::OpenSaveConfigAdvWidget *uiadv; ModeConfigPage *modeConfigPage; }; class KateHlDownloadDialog: public QDialog { Q_OBJECT public: KateHlDownloadDialog(QWidget *parent, const char *name, bool modal); ~KateHlDownloadDialog(); private: static unsigned parseVersion(const QString &); class QTreeWidget *list; class QString listData; KIO::TransferJob *transferJob; QPushButton *m_installButton; private Q_SLOTS: void listDataReceived(KIO::Job *, const QByteArray &data); void slotInstall(); }; /** * This dialog will prompt the user for what do with a file that is * modified on disk. * If the file wasn't deleted, it has a 'diff' button, which will create * a diff file (uing diff(1)) and launch that using KRun. */ class KateModOnHdPrompt : public QObject { Q_OBJECT public: enum Status { Reload = 1, // 0 is QDialog::Rejected Save, Overwrite, Ignore, Close }; KateModOnHdPrompt(KTextEditor::DocumentPrivate *doc, KTextEditor::ModificationInterface::ModifiedOnDiskReason modtype, const QString &reason); ~KateModOnHdPrompt(); Q_SIGNALS: void saveAsTriggered(); void ignoreTriggered(); void reloadTriggered(); private Q_SLOTS: /** * Show a diff between the document text and the disk file. */ void slotDiff(); private Q_SLOTS: void slotDataAvailable(); ///< read data from the process void slotPDone(); ///< Runs the diff file when done private: KTextEditor::DocumentPrivate *m_doc; QPointer m_message; KTextEditor::ModificationInterface::ModifiedOnDiskReason m_modtype; KProcess *m_proc; QTemporaryFile *m_diffFile; QAction *m_diffAction; }; #endif diff --git a/src/export/htmlexporter.h b/src/export/htmlexporter.h index 7cd82241..5492213d 100644 --- a/src/export/htmlexporter.h +++ b/src/export/htmlexporter.h @@ -1,38 +1,38 @@ /** * This file is part of the KDE libraries * Copyright (C) 2009 Milian Wolff * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef HTMLEXPORTER_H #define HTMLEXPORTER_H #include "abstractexporter.h" /// TODO: add abstract interface for future exporters class HTMLExporter : public AbstractExporter { public: HTMLExporter(KTextEditor::View *view, QTextStream &output, const bool withHeaderFooter = false); - virtual ~HTMLExporter(); + ~HTMLExporter() override; void openLine() override; void closeLine(const bool lastLine) override; void exportText(const QString &text, const KTextEditor::Attribute::Ptr &attrib) override; }; #endif diff --git a/src/schema/kateschemaconfig.h b/src/schema/kateschemaconfig.h index be0dfccd..c3f987e5 100644 --- a/src/schema/kateschemaconfig.h +++ b/src/schema/kateschemaconfig.h @@ -1,216 +1,216 @@ /* This file is part of the KDE libraries Copyright (C) 2001-2003 Christoph Cullmann Copyright (C) 2002, 2003 Anders Lund Copyright (C) 2012 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_SCHEMA_CONFIG_H__ #define __KATE_SCHEMA_CONFIG_H__ #include "katedialogs.h" #include "katecolortreewidget.h" #include "kateextendedattribute.h" #include #include class KateStyleTreeWidget; class KComboBox; class KateSchemaConfigColorTab : public QWidget { Q_OBJECT public: KateSchemaConfigColorTab(); ~KateSchemaConfigColorTab(); QColor backgroundColor() const; QColor selectionColor() const; public Q_SLOTS: void apply(); void reload(); void schemaChanged(const QString &newSchema); void importSchema(KConfigGroup &config); void exportSchema(KConfigGroup &config); Q_SIGNALS: void changed(); private: QVector colorItemList() const; QVector readConfig(KConfigGroup &config); private: // multiple shemas may be edited. Hence, we need one ColorList for each schema QMap > m_schemas; QString m_currentSchema; KateColorTreeWidget *ui; }; class KateSchemaConfigFontTab : public QWidget { Q_OBJECT public: KateSchemaConfigFontTab(); ~KateSchemaConfigFontTab(); public: void readConfig(KConfig *config); void importSchema(KConfigGroup &config); void exportSchema(KConfigGroup &config); public Q_SLOTS: void apply(); void reload(); void schemaChanged(const QString &newSchema); Q_SIGNALS: void changed(); private: class KFontChooser *m_fontchooser; QMap m_fonts; QString m_currentSchema; private Q_SLOTS: void slotFontSelected(const QFont &font); }; class KateSchemaConfigDefaultStylesTab : public QWidget { Q_OBJECT public: KateSchemaConfigDefaultStylesTab(KateSchemaConfigColorTab *colorTab); - ~KateSchemaConfigDefaultStylesTab(); + ~KateSchemaConfigDefaultStylesTab() override; Q_SIGNALS: void changed(); public: void schemaChanged(const QString &schema); void reload(); void apply(); KateAttributeList *attributeList(const QString &schema); void exportSchema(const QString &schema, KConfig *cfg); void importSchema(const QString &schemaName, const QString &schema, KConfig *cfg); protected: void showEvent(QShowEvent *event) override; void updateColorPalette(const QColor &textColor); private: KateStyleTreeWidget *m_defaultStyles; QHash m_defaultStyleLists; KateSchemaConfigColorTab *m_colorTab; QString m_currentSchema; }; class KateSchemaConfigHighlightTab : public QWidget { Q_OBJECT public: explicit KateSchemaConfigHighlightTab(KateSchemaConfigDefaultStylesTab *page, KateSchemaConfigColorTab *colorTab); - ~KateSchemaConfigHighlightTab(); + ~KateSchemaConfigHighlightTab() override; void schemaChanged(const QString &schema); void reload(); void apply(); Q_SIGNALS: void changed(); protected Q_SLOTS: void hlChanged(int z); public Q_SLOTS: void exportHl(QString schema = QString(), int hl = -1, KConfig *cfg = nullptr); void importHl(const QString &fromSchemaName = QString(), QString schema = QString(), int hl = -1, KConfig *cfg = nullptr); protected: void showEvent(QShowEvent *event) override; void updateColorPalette(const QColor &textColor); private: KateSchemaConfigDefaultStylesTab *m_defaults; KateSchemaConfigColorTab *m_colorTab; KComboBox *hlCombo; KateStyleTreeWidget *m_styles; QString m_schema; int m_hl; QHash > > m_hlDict; public: QList hlsForSchema(const QString &schema); bool loadAllHlsForSchema(const QString &schema); }; class KateSchemaConfigPage : public KateConfigPage { Q_OBJECT public: explicit KateSchemaConfigPage(QWidget *parent); - virtual ~KateSchemaConfigPage(); + ~KateSchemaConfigPage() override; QString name() const override; QString fullName() const override; QIcon icon() const override; public Q_SLOTS: void apply() override; void reload() override; void reset() override; void defaults() override; void exportFullSchema(); void importFullSchema(); private Q_SLOTS: void deleteSchema(); bool newSchema(const QString &newName = QString()); void schemaChanged(const QString &schema); void comboBoxIndexChanged(int currentIndex); private: void refillCombos(const QString &schemaName, const QString &defaultSchemaName); QString requestSchemaName(const QString &suggestedName); private: QString m_currentSchema; class QPushButton *btndel; class KComboBox *defaultSchemaCombo; class KComboBox *schemaCombo; KateSchemaConfigColorTab *m_colorTab; KateSchemaConfigFontTab *m_fontTab; KateSchemaConfigDefaultStylesTab *m_defaultStylesTab; KateSchemaConfigHighlightTab *m_highlightTab; }; #endif diff --git a/src/script/katescripthelpers.h b/src/script/katescripthelpers.h index fdc37fc8..330e1e3f 100644 --- a/src/script/katescripthelpers.h +++ b/src/script/katescripthelpers.h @@ -1,59 +1,59 @@ /* This file is part of the KDE libraries * * Copyright (C) 2010 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_SCRIPTHELPERS_H #define KATE_SCRIPTHELPERS_H #include #include #include class QJSEngine; namespace Kate { /** Top-level script functions */ namespace Script { /** read complete file contents, helper */ KTEXTEDITOR_EXPORT bool readFile(const QString &sourceUrl, QString &sourceCode); } // namespace Script class KTEXTEDITOR_EXPORT ScriptHelper : public QObject { Q_OBJECT QJSEngine *m_engine; public: - ScriptHelper(QJSEngine *engine) : m_engine(engine) {} + explicit ScriptHelper(QJSEngine *engine) : m_engine(engine) {} Q_INVOKABLE QString read(const QString &file); Q_INVOKABLE void require(const QString &file); Q_INVOKABLE void debug(const QString &msg); Q_INVOKABLE QString _i18n(const QString &msg); Q_INVOKABLE QString _i18nc(const QString &textContext, const QString &text); Q_INVOKABLE QString _i18np(const QString &trSingular, const QString &trPlural, int number); Q_INVOKABLE QString _i18ncp(const QString &trContext, const QString &trSingular, const QString &trPlural, int number = 0); }; } // namespace Kate #endif diff --git a/src/search/katesearchbar.h b/src/search/katesearchbar.h index 0f38d1e1..4322891b 100644 --- a/src/search/katesearchbar.h +++ b/src/search/katesearchbar.h @@ -1,210 +1,210 @@ /* This file is part of the KDE libraries and the Kate part. * * Copyright (C) 2009-2010 Bernhard Beschow * Copyright (C) 2007 Sebastian Pipping * * 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_SEARCH_BAR_H #define KATE_SEARCH_BAR_H 1 #include "kateviewhelpers.h" #include #include #include namespace KTextEditor { class ViewPrivate; } class KateViewConfig; class QVBoxLayout; class QComboBox; namespace Ui { class IncrementalSearchBar; class PowerSearchBar; } namespace KTextEditor { class MovingRange; class Message; } class KTEXTEDITOR_EXPORT KateSearchBar : public KateViewBarWidget { Q_OBJECT friend class SearchBarTest; public: enum SearchMode { // NOTE: Concrete values are important here // to work with the combobox index! MODE_PLAIN_TEXT = 0, MODE_WHOLE_WORDS = 1, MODE_ESCAPE_SEQUENCES = 2, MODE_REGEX = 3 }; enum MatchResult { MatchFound, MatchWrappedForward, MatchWrappedBackward, MatchMismatch, MatchNothing, MatchNeutral }; enum SearchDirection { SearchForward, SearchBackward }; public: explicit KateSearchBar(bool initAsPower, KTextEditor::ViewPrivate *view, KateViewConfig *config); - ~KateSearchBar(); + ~KateSearchBar() override; void closed() override; bool isPower() const; QString searchPattern() const; QString replacementPattern() const; bool selectionOnly() const; bool matchCase() const; // Only used by KTextEditor::ViewPrivate static void nextMatchForSelection(KTextEditor::ViewPrivate *view, SearchDirection searchDirection); public Q_SLOTS: /** * Set the current search pattern. * @param searchPattern the search pattern */ void setSearchPattern(const QString &searchPattern); /** * Set the current replacement pattern. * @param replacementPattern the replacement pattern */ void setReplacementPattern(const QString &replacementPattern); void setSearchMode(SearchMode mode); void setSelectionOnly(bool selectionOnly); void setMatchCase(bool matchCase); // Called for and + void findNext(); void findPrevious(); void findAll(); void replaceNext(); void replaceAll(); // Also used by KTextEditor::ViewPrivate void enterPowerMode(); void enterIncrementalMode(); bool clearHighlights(); void updateHighlightColors(); // read write status of document changed void slotReadWriteChanged(); protected: // Overridden void showEvent(QShowEvent *event) override; private Q_SLOTS: void onIncPatternChanged(const QString &pattern); void onMatchCaseToggled(bool matchCase); void onReturnPressed(); void updateSelectionOnly(); void updateIncInitCursor(); void onPowerPatternChanged(const QString &pattern); void onPowerModeChanged(int index); void onPowerPatternContextMenuRequest(); void onPowerPatternContextMenuRequest(const QPoint &); void onPowerReplacmentContextMenuRequest(); void onPowerReplacmentContextMenuRequest(const QPoint &); private: // Helpers bool find(SearchDirection searchDirection = SearchForward, const QString *replacement = nullptr); int findAll(KTextEditor::Range inputRange, const QString *replacement); bool isPatternValid() const; KTextEditor::SearchOptions searchOptions(SearchDirection searchDirection = SearchForward) const; void highlightMatch(const KTextEditor::Range &range); void highlightReplacement(const KTextEditor::Range &range); void indicateMatch(MatchResult matchResult); static void selectRange(KTextEditor::ViewPrivate *view, const KTextEditor::Range &range); void selectRange2(const KTextEditor::Range &range); QVector getCapturePatterns(const QString &pattern) const; void showExtendedContextMenu(bool forPattern, const QPoint &pos); void givePatternFeedback(); void addCurrentTextToHistory(QComboBox *combo); void backupConfig(bool ofPower); void sendConfig(); void fixForSingleLine(KTextEditor::Range &range, SearchDirection searchDirection); void showInfoMessage(const QString &text); private: KTextEditor::ViewPrivate *const m_view; KateViewConfig *const m_config; QList m_hlRanges; QPointer m_infoMessage; QPointer m_wrappedTopMessage; QPointer m_wrappedBottomMessage; // Shared by both dialogs QVBoxLayout *const m_layout; QWidget *m_widget; // Incremental search related Ui::IncrementalSearchBar *m_incUi; KTextEditor::Cursor m_incInitCursor; // Power search related Ui::PowerSearchBar *m_powerUi; // attribute to highlight matches with KTextEditor::Attribute::Ptr highlightMatchAttribute; KTextEditor::Attribute::Ptr highlightReplacementAttribute; // Status backup bool m_incHighlightAll : 1; bool m_incFromCursor : 1; bool m_incMatchCase : 1; bool m_powerMatchCase : 1; bool m_powerFromCursor : 1; bool m_powerHighlightAll : 1; unsigned int m_powerMode : 2; }; #endif // KATE_SEARCH_BAR_H diff --git a/src/syntax/katehighlighthelpers.h b/src/syntax/katehighlighthelpers.h index d38388ab..27688bca 100644 --- a/src/syntax/katehighlighthelpers.h +++ b/src/syntax/katehighlighthelpers.h @@ -1,378 +1,378 @@ /* This file is part of the KDE libraries Copyright (C) 2001,2002 Joseph Wenninger Copyright (C) 2001 Christoph Cullmann Copyright (C) 1999 Jochen Wilhelmy * * 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_HIGHLIGHTHELPERS_H__ #define __KATE_HIGHLIGHTHELPERS_H__ #include "katehighlight.h" #include class KateHlItem { public: KateHlItem(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2); virtual ~KateHlItem(); public: // caller must keep in mind: LEN > 0 is a must !!!!!!!!!!!!!!!!!!!!!1 // Now, the function returns the offset detected, or 0 if no match is found. // bool linestart isn't needed, this is equivalent to offset == 0. virtual int checkHgl(const QString &text, int offset, int len) = 0; virtual bool lineContinue() { return false; } virtual void capturedTexts(QStringList &) { } virtual KateHlItem *clone(const QStringList *) { return this; } static void dynamicSubstitute(QString &str, const QStringList *args); QVector subItems; int attr; KateHlContextModification ctx; signed char region; signed char region2; bool lookAhead; bool dynamic; bool dynamicChild; bool firstNonSpace; bool onlyConsume; int column; // start enable flags, nicer than the virtual methodes // saves function calls bool alwaysStartEnable; bool customStartEnable; // set to true when you cached something bool haveCache; // internal for doHighlight, don't set it in the items bool cachingHandled; }; class KateHlContext { public: KateHlContext(const QString &_hlId, int attribute, KateHlContextModification _lineEndContext, bool _fallthrough, KateHlContextModification _fallthroughContext, bool _dynamic, bool _noIndentationBasedFolding, bool _emptyLineContex, KateHlContextModification _emptyLineContextModification ); virtual ~KateHlContext(); KateHlContext *clone(const QStringList *args); QVector items; QString hlId; ///< A unique highlight identifier. Used to look up correct properties. int attr; KateHlContextModification lineEndContext; /** @internal anders: possible escape if no rules matches. false unless 'fallthrough="1|true"' (insensitive) if true, go to ftcxt w/o eating of string. ftctx is "fallthroughContext" in xml files, valid values are int or #pop[..] see in KateHighlighting::doHighlight */ bool fallthrough; KateHlContextModification ftctx; // where to go after no rules matched bool dynamic; bool dynamicChild; bool noIndentationBasedFolding; bool emptyLineContext; KateHlContextModification emptyLineContextModification; }; class KateHlIncludeRule { public: explicit KateHlIncludeRule(int ctx_ = 0, uint pos_ = 0, const QString &incCtxN_ = QString(), bool incAttrib = false) : ctx(ctx_) , pos(pos_) , incCtxN(incCtxN_) , includeAttrib(incAttrib) { incCtx = -1; } //KateHlIncludeRule(int ctx_, uint pos_, bool incAttrib) {ctx=ctx_;pos=pos_;incCtx=-1;incCtxN="";includeAttrib=incAttrib} public: int ctx; uint pos; KateHlContextModification incCtx; QString incCtxN; bool includeAttrib; }; class KateHlCharDetect : public KateHlItem { public: KateHlCharDetect(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, QChar); int checkHgl(const QString &text, int offset, int len) override; KateHlItem *clone(const QStringList *args) override; private: QChar sChar; }; class KateHl2CharDetect : public KateHlItem { public: KateHl2CharDetect(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, QChar ch1, QChar ch2); KateHl2CharDetect(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, const QChar *ch); int checkHgl(const QString &text, int offset, int len) override; KateHlItem *clone(const QStringList *args) override; private: QChar sChar1; QChar sChar2; }; class KateHlStringDetect : public KateHlItem { public: KateHlStringDetect(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, const QString &, bool inSensitive = false); int checkHgl(const QString &text, int offset, int len) override; KateHlItem *clone(const QStringList *args) override; protected: const QString str; const int strLen; const bool _inSensitive; }; class KateHlWordDetect : public KateHlStringDetect { public: KateHlWordDetect(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, const QString &, bool inSensitive = false); int checkHgl(const QString &text, int offset, int len) override; KateHlItem *clone(const QStringList *args) override; }; class KateHlRangeDetect : public KateHlItem { public: KateHlRangeDetect(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, QChar ch1, QChar ch2); int checkHgl(const QString &text, int offset, int len) override; private: QChar sChar1; QChar sChar2; }; class KateHlKeyword : public KateHlItem { public: KateHlKeyword(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, bool insensitive, const QString &delims); - virtual ~KateHlKeyword(); + ~KateHlKeyword() override; QSet allKeywords() const; void addList(const QStringList &); int checkHgl(const QString &text, int offset, int len) override; private: QVector< QSet* > dict; bool _insensitive; QSet deliminators; int minLen; int maxLen; }; class KateHlInt : public KateHlItem { public: KateHlInt(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2); int checkHgl(const QString &text, int offset, int len) override; }; class KateHlFloat : public KateHlItem { public: KateHlFloat(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2); - virtual ~KateHlFloat() {} + ~KateHlFloat() override {} int checkHgl(const QString &text, int offset, int len) override; }; class KateHlCFloat : public KateHlFloat { public: KateHlCFloat(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2); int checkHgl(const QString &text, int offset, int len) override; int checkIntHgl(const QString &text, int offset, int len); }; class KateHlCOct : public KateHlItem { public: KateHlCOct(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2); int checkHgl(const QString &text, int offset, int len) override; }; class KateHlCHex : public KateHlItem { public: KateHlCHex(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2); int checkHgl(const QString &text, int offset, int len) override; }; class KateHlLineContinue : public KateHlItem { public: KateHlLineContinue(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, QChar c); virtual bool endEnable(QChar c) { return c == QLatin1Char('\0'); } int checkHgl(const QString &text, int offset, int len) override; bool lineContinue() override { return true; } private: QChar m_trailer; }; class KateHlCStringChar : public KateHlItem { public: KateHlCStringChar(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2); int checkHgl(const QString &text, int offset, int len) override; }; class KateHlCChar : public KateHlItem { public: KateHlCChar(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2); int checkHgl(const QString &text, int offset, int len) override; }; class KateHlAnyChar : public KateHlItem { public: KateHlAnyChar(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, const QString &charList); int checkHgl(const QString &text, int offset, int len) override; private: const QString _charList; }; class KateHlRegExpr : public KateHlItem { public: KateHlRegExpr(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2, const QString &expr, bool insensitive, bool minimal); int checkHgl(const QString &text, int offset, int len) override; void capturedTexts(QStringList &) override; KateHlItem *clone(const QStringList *args) override; private: /** * regular expression to match */ const QRegularExpression m_regularExpression; /** * does the regular expression start with ^? * allows to skip for any offset > 0 */ const bool m_handlesLineStart; /** * last match, if any */ QRegularExpressionMatch m_lastMatch; }; class KateHlDetectSpaces : public KateHlItem { public: KateHlDetectSpaces(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2) : KateHlItem(attribute, context, regionId, regionId2) {} int checkHgl(const QString &text, int offset, int len) override { int len2 = offset + len; while ((offset < len2) && text[offset].isSpace()) { offset++; } return offset; } }; class KateHlDetectIdentifier : public KateHlItem { public: KateHlDetectIdentifier(int attribute, KateHlContextModification context, signed char regionId, signed char regionId2) : KateHlItem(attribute, context, regionId, regionId2) { alwaysStartEnable = false; } int checkHgl(const QString &text, int offset, int len) override { // first char should be a letter or underscore if (text[offset].isLetter() || text[offset] == QLatin1Char('_')) { // memorize length int len2 = offset + len; // one char seen offset++; // now loop for all other thingies while ( (offset < len2) && (text[offset].isLetterOrNumber() || (text[offset] == QLatin1Char('_'))) ) { offset++; } return offset; } return 0; } }; //END #endif diff --git a/src/variableeditor/variablelineedit.h b/src/variableeditor/variablelineedit.h index 6afb2b21..4ea31649 100644 --- a/src/variableeditor/variablelineedit.h +++ b/src/variableeditor/variablelineedit.h @@ -1,59 +1,59 @@ /* This file is part of the KDE project Copyright (C) 2011 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 VARIABLE_LINE_EDIT_H #define VARIABLE_LINE_EDIT_H #include class QFrame; class QLineEdit; class QToolButton; class VariableListView; class VariableLineEdit : public QWidget { Q_OBJECT public: - VariableLineEdit(QWidget *parent = nullptr); + explicit VariableLineEdit(QWidget *parent = nullptr); virtual ~VariableLineEdit(); void addKateItems(VariableListView *listview); QString text(); public Q_SLOTS: void editVariables(); void setText(const QString &text); void clear(); void updateVariableLine(); Q_SIGNALS: void textChanged(const QString &); private: QFrame *m_popup; QLineEdit *m_lineedit; QToolButton *m_button; VariableListView *m_listview; }; #endif diff --git a/src/view/katefadeeffect.h b/src/view/katefadeeffect.h index 4243220a..e1dc2dba 100644 --- a/src/view/katefadeeffect.h +++ b/src/view/katefadeeffect.h @@ -1,109 +1,109 @@ /* This file is part of the KDE and the Kate project * * Copyright (C) 2013 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_FADE_EFFECT_H #define KATE_FADE_EFFECT_H #include #include class QWidget; class QTimeLine; class QGraphicsOpacityEffect; /** * This class provides a fade in/out effect for arbitrary QWidget%s. * Example: * \code * KateFadeEffect* fadeEffect = new KateFadeEffect(someWidget); * fadeEffect->fadeIn(); * //... * fadeEffect->fadeOut(); * \endcode */ class KateFadeEffect : public QObject { Q_OBJECT public: /** * Constructor. * By default, the widget is fully opaque (opacity = 1.0). */ - KateFadeEffect(QWidget *widget = nullptr); + explicit KateFadeEffect(QWidget *widget = nullptr); /** * Check whether the hide animation started by calling fadeOut() * is still running. If animations are disabled, this function always * returns @e false. */ bool isHideAnimationRunning() const; /** * Check whether the show animation started by calling fadeIn() * is still running. If animations are disabled, this function always * returns @e false. */ bool isShowAnimationRunning() const; public Q_SLOTS: /** * Call to fade out and hide the widget. */ void fadeOut(); /** * Call to show and fade in the widget */ void fadeIn(); Q_SIGNALS: /** * This signal is emitted when the fadeOut animation is finished, started by * calling fadeOut(). If animations are disabled, this signal is * emitted immediately. */ void hideAnimationFinished(); /** * This signal is emitted when the fadeIn animation is finished, started by * calling fadeIn(). If animations are disabled, this signal is * emitted immediately. */ void showAnimationFinished(); protected Q_SLOTS: /** * Helper to update opacity value */ void opacityChanged(qreal value); /** * When the animation is finished, hide the widget if fading out. */ void animationFinished(); private: QPointer m_widget; ///< the fading widget QTimeLine *m_timeLine; ///< update time line QPointer m_effect; ///< graphics opacity effect }; #endif diff --git a/src/vimode/emulatedcommandbar/commandmode.h b/src/vimode/emulatedcommandbar/commandmode.h index b0ef1efd..d29b0e25 100644 --- a/src/vimode/emulatedcommandbar/commandmode.h +++ b/src/vimode/emulatedcommandbar/commandmode.h @@ -1,97 +1,97 @@ /* This file is part of the KDE libraries and the Kate part. * * Copyright (C) 2013-2016 Simon St James * * 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 KATEVI_EMULATED_COMMAND_BAR_COMMANDMODE_H #define KATEVI_EMULATED_COMMAND_BAR_COMMANDMODE_H #include "activemode.h" #include #include namespace KTextEditor { class ViewPrivate; } namespace KateVi { class EmulatedCommandBar; class MatchHighlighter; class InteractiveSedReplaceMode; class Completer; class InputModeManager; class CommandMode : public ActiveMode { public: CommandMode(EmulatedCommandBar* emulatedCommandBar, MatchHighlighter* matchHighlighter, InputModeManager* viInputModeManager, KTextEditor::ViewPrivate* view, QLineEdit* edit, InteractiveSedReplaceMode *interactiveSedReplaceMode, Completer* completer); - virtual ~CommandMode() + ~CommandMode() override { } bool handleKeyPress ( const QKeyEvent* keyEvent ) override; void editTextChanged(const QString &newText) override; CompletionStartParams completionInvoked(Completer::CompletionInvocation invocationType) override; void completionChosen() override; void deactivate(bool wasAborted) override; QString executeCommand(const QString &commandToExecute); private: CompletionStartParams activateCommandCompletion(); CompletionStartParams activateCommandHistoryCompletion(); CompletionStartParams activateSedFindHistoryCompletion(); CompletionStartParams activateSedReplaceHistoryCompletion(); QString withoutRangeExpression(); QString rangeExpression(); QString withSedFindTermReplacedWith(const QString &newFindTerm); QString withSedDelimiterEscaped(const QString &text); bool isCursorInFindTermOfSed(); bool isCursorInReplaceTermOfSed(); QString sedFindTerm(); QString sedReplaceTerm(); /** * Stuff to do with expressions of the form: * * s/find/replace/ */ struct ParsedSedExpression { bool parsedSuccessfully; int findBeginPos; int findEndPos; int replaceBeginPos; int replaceEndPos; QChar delimiter; }; /** * The "range expression" is the (optional) expression before the command that describes * the range over which the command should be run e.g. '<,'>. @see CommandRangeExpressionParser */ CommandMode::ParsedSedExpression parseAsSedExpression(); void replaceCommandBeforeCursorWith(const QString &newCommand); int commandBeforeCursorBegin(); QLineEdit *m_edit; InteractiveSedReplaceMode *m_interactiveSedReplaceMode; Completer *m_completer; KCompletion m_cmdCompletion; QHash m_cmdDict; KTextEditor::Command *queryCommand(const QString &cmd) const; }; } #endif diff --git a/src/vimode/emulatedcommandbar/matchhighlighter.h b/src/vimode/emulatedcommandbar/matchhighlighter.h index d5810b0d..66700aaf 100644 --- a/src/vimode/emulatedcommandbar/matchhighlighter.h +++ b/src/vimode/emulatedcommandbar/matchhighlighter.h @@ -1,52 +1,52 @@ /* This file is part of the KDE libraries and the Kate part. * * Copyright (C) 2013-2016 Simon St James * * 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 KATEVI_EMULATED_COMMAND_BAR_MATCHHIGHLIGHTER_H #define KATEVI_EMULATED_COMMAND_BAR_MATCHHIGHLIGHTER_H #include #include namespace KTextEditor { class ViewPrivate; class Range; class MovingRange; } namespace KateVi { class MatchHighlighter : public QObject { Q_OBJECT public: - MatchHighlighter(KTextEditor::ViewPrivate* view); + explicit MatchHighlighter(KTextEditor::ViewPrivate* view); ~MatchHighlighter(); void updateMatchHighlight(const KTextEditor::Range &matchRange); private Q_SLOTS: void updateMatchHighlightAttrib(); private: KTextEditor::ViewPrivate *m_view = nullptr; KTextEditor::Attribute::Ptr m_highlightMatchAttribute; KTextEditor::MovingRange *m_highlightedMatch; }; } #endif