File indexing completed on 2024-04-28 04:38:54
0001 /* 0002 SPDX-FileCopyrightText: 2010 Silvère Lestang <silvere.lestang@gmail.com> 0003 SPDX-FileCopyrightText: 2010 Julien Desgats <julien.desgats@gmail.com> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef KDEVPLATFORM_PLUGIN_GREPOUTPUTVIEW_H 0009 #define KDEVPLATFORM_PLUGIN_GREPOUTPUTVIEW_H 0010 0011 #include <QList> 0012 0013 #include <interfaces/iuicontroller.h> 0014 #include <interfaces/itoolviewactionlistener.h> 0015 0016 #include "ui_grepoutputview.h" 0017 0018 namespace KDevelop 0019 { 0020 class IStatus; 0021 } 0022 0023 class QModelIndex; 0024 0025 class GrepViewPlugin; 0026 class GrepOutputModel; 0027 struct GrepJobSettings; 0028 0029 class GrepOutputViewFactory: public KDevelop::IToolViewFactory 0030 { 0031 public: 0032 explicit GrepOutputViewFactory(GrepViewPlugin* plugin); 0033 QWidget* create(QWidget* parent = nullptr) override; 0034 Qt::DockWidgetArea defaultPosition() const override; 0035 QString id() const override; 0036 private: 0037 GrepViewPlugin* m_plugin; 0038 }; 0039 0040 class GrepOutputView : public QWidget, Ui::GrepOutputView, public KDevelop::IToolViewActionListener 0041 { 0042 Q_OBJECT 0043 Q_INTERFACES(KDevelop::IToolViewActionListener) 0044 0045 public: 0046 enum MessageType { 0047 Information, 0048 Error 0049 }; 0050 0051 GrepOutputView(QWidget* parent, GrepViewPlugin* plugin); 0052 ~GrepOutputView() override; 0053 GrepOutputModel* model(); 0054 0055 /** 0056 * This causes the creation of a new model, the old one is kept in model history. 0057 * Oldest models are deleted if needed. 0058 * @return pointer to the new model 0059 */ 0060 GrepOutputModel* renewModel(const GrepJobSettings& settings, const QString& description); 0061 0062 void setMessage(const QString& msg, MessageType type = Information); 0063 0064 public Q_SLOTS: 0065 void showErrorMessage( const QString& errorMessage ); 0066 void showMessage( KDevelop::IStatus*, const QString& message ); 0067 void updateApplyState(const QModelIndex &topLeft, const QModelIndex &bottomRight); 0068 void changeModel(int index); 0069 void replacementTextChanged(); 0070 0071 Q_SIGNALS: 0072 void outputViewIsClosed(); 0073 0074 private: 0075 static const int HISTORY_SIZE; 0076 QAction* m_next; 0077 QAction* m_prev; 0078 QAction* m_collapseAll; 0079 QAction* m_expandAll; 0080 QAction* m_refresh; 0081 QAction* m_clearSearchHistory; 0082 QLabel* m_statusLabel; 0083 GrepViewPlugin *m_plugin; 0084 QVector<GrepJobSettings> m_settingsHistory; 0085 0086 private Q_SLOTS: 0087 void selectPreviousItem() override; 0088 void selectNextItem() override; 0089 void collapseAllItems(); 0090 void expandAllItems(); 0091 void onApply(); 0092 void showDialog(); 0093 void refresh(); 0094 void expandElements( const QModelIndex & parent ); 0095 void updateButtonState(bool enable); 0096 void rowsRemoved(); 0097 void clearSearchHistory(); 0098 void modelSelectorContextMenu(const QPoint& pos); 0099 void updateScrollArea(); 0100 void updateCheckable(); 0101 }; 0102 0103 #endif // KDEVPLATFORM_PLUGIN_GREPOUTPUTVIEW_H