File indexing completed on 2024-05-05 05:51:20

0001 /* This file is part of the KDE project
0002    SPDX-FileCopyrightText: 2008-2014 Dominik Haumann <dhaumann kde org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-only
0005 */
0006 
0007 #pragma once
0008 
0009 #include <KTextEditor/Plugin>
0010 #include <ktexteditor/configpage.h>
0011 #include <ktexteditor/mainwindow.h>
0012 
0013 #include "btdatabase.h"
0014 #include "btfileindexer.h"
0015 #include "ui_btbrowserwidget.h"
0016 #include "ui_btconfigwidget.h"
0017 
0018 #include <QDialog>
0019 #include <QString>
0020 #include <QTimer>
0021 
0022 class KateBtConfigWidget;
0023 class KateBtBrowserWidget;
0024 
0025 class KateBtBrowserPlugin : public KTextEditor::Plugin
0026 {
0027     Q_OBJECT
0028 
0029 public:
0030     explicit KateBtBrowserPlugin(QObject *parent = nullptr, const QVariantList & = QVariantList());
0031     ~KateBtBrowserPlugin() override;
0032 
0033     static KateBtBrowserPlugin &self();
0034 
0035     QObject *createView(KTextEditor::MainWindow *mainWindow) override;
0036 
0037     KateBtDatabase &database();
0038     BtFileIndexer &fileIndexer();
0039 
0040     void startIndexer();
0041 
0042 Q_SIGNALS:
0043     void newStatus(const QString &);
0044 
0045 public:
0046     int configPages() const override;
0047     KTextEditor::ConfigPage *configPage(int number, QWidget *parent = nullptr) override;
0048 
0049     //
0050     // private data
0051     //
0052 private:
0053     KateBtDatabase db;
0054     BtFileIndexer indexer;
0055     static KateBtBrowserPlugin *s_self;
0056 };
0057 
0058 class KateBtBrowserPluginView : public QObject
0059 {
0060     Q_OBJECT
0061 
0062 public:
0063     KateBtBrowserPluginView(KateBtBrowserPlugin *plugin, KTextEditor::MainWindow *mainWindow);
0064 
0065     /**
0066      * Virtual destructor.
0067      */
0068     ~KateBtBrowserPluginView() override;
0069 
0070 private:
0071     KateBtBrowserWidget *m_widget;
0072 };
0073 
0074 class KateBtBrowserWidget : public QWidget, public Ui::BtBrowserWidget
0075 {
0076     Q_OBJECT
0077 
0078 public:
0079     KateBtBrowserWidget(KTextEditor::MainWindow *mainwindow, QWidget *parent);
0080 
0081     ~KateBtBrowserWidget() override;
0082 
0083     void loadBacktrace(const QString &bt);
0084 
0085 public Q_SLOTS:
0086     void loadFile();
0087     void loadClipboard();
0088     void configure();
0089     void clearStatus();
0090     void setStatus(const QString &status);
0091 
0092 private Q_SLOTS:
0093     void itemActivated(QTreeWidgetItem *item, int column);
0094 
0095 private:
0096     KTextEditor::MainWindow *mw;
0097     QTimer timer;
0098 };
0099 
0100 class KateBtConfigWidget : public KTextEditor::ConfigPage, private Ui::BtConfigWidget
0101 {
0102     Q_OBJECT
0103 public:
0104     explicit KateBtConfigWidget(QWidget *parent = nullptr);
0105     ~KateBtConfigWidget() override;
0106 
0107     QString name() const override;
0108     QString fullName() const override;
0109     QIcon icon() const override;
0110 
0111 public Q_SLOTS:
0112     void apply() override;
0113     void reset() override;
0114     void defaults() override;
0115 
0116 private Q_SLOTS:
0117     void add();
0118     void remove();
0119     void textChanged();
0120 
0121 private:
0122     bool m_changed;
0123 };
0124 
0125 class KateBtConfigDialog : public QDialog
0126 {
0127     Q_OBJECT
0128 public:
0129     KateBtConfigDialog(QWidget *parent = nullptr);
0130     ~KateBtConfigDialog() override;
0131 
0132 private:
0133     KateBtConfigWidget *m_configWidget;
0134 };
0135 
0136 // kate: space-indent on; indent-width 4; replace-tabs on;