1/* This file is part of the KDE project
2 Copyright 2008 Dominik Haumann <dhaumann kde org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17*/
18
19#ifndef KATE_BACKTRACEBROWSER_H
20#define KATE_BACKTRACEBROWSER_H
21
22#include <ktexteditor/document.h>
23#include <ktexteditor/configpage.h>
24#include <kate/plugin.h>
25#include <kate/pluginconfigpageinterface.h>
26#include <kate/mainwindow.h>
27
28#include "ui_btbrowserwidget.h"
29#include "ui_btconfigwidget.h"
30#include "btdatabase.h"
31#include "btfileindexer.h"
32
33#include <QString>
34#include <QTimer>
35
36class KateBtBrowserPlugin: public Kate::Plugin, public Kate::PluginConfigPageInterface
37{
38 Q_OBJECT
39 Q_INTERFACES(Kate::PluginConfigPageInterface)
40 public:
41 explicit KateBtBrowserPlugin( QObject* parent = 0, const QList<QVariant>& = QList<QVariant>() );
42 virtual ~KateBtBrowserPlugin();
43
44 static KateBtBrowserPlugin& self();
45
46 Kate::PluginView *createView (Kate::MainWindow *mainWindow);
47
48 KateBtDatabase& database();
49 BtFileIndexer& fileIndexer();
50
51 void startIndexer();
52
53 signals:
54 void newStatus(const QString&);
55
56 //
57 // PluginConfigPageInterface
58 //
59 public:
60 virtual uint configPages() const;
61 virtual Kate::PluginConfigPage* configPage (uint number = 0, QWidget *parent = 0, const char *name = 0);
62 virtual QString configPageName(uint number = 0) const;
63 virtual QString configPageFullName(uint number = 0) const;
64 virtual KIcon configPageIcon(uint number = 0) const;
65
66 //
67 // private data
68 //
69 private:
70 KateBtDatabase db;
71 BtFileIndexer indexer;
72 static KateBtBrowserPlugin* s_self;
73};
74
75class KateBtBrowserPluginView : public Kate::PluginView, public Ui::BtBrowserWidget
76{
77 Q_OBJECT
78
79 public:
80 KateBtBrowserPluginView(Kate::MainWindow* mainWindow);
81
82 ~KateBtBrowserPluginView();
83
84 virtual void readSessionConfig (KConfigBase* config, const QString& groupPrefix);
85 virtual void writeSessionConfig (KConfigBase* config, const QString& groupPrefix);
86
87 void loadBacktrace(const QString& bt);
88
89 public slots:
90 void loadFile();
91 void loadClipboard();
92 void configure();
93 void clearStatus();
94 void setStatus(const QString& status);
95
96 private slots:
97 void itemActivated(QTreeWidgetItem* item, int column);
98
99 private:
100 QWidget* toolView;
101 Kate::MainWindow* mw;
102 QTimer timer;
103};
104
105class KateBtConfigWidget : public Kate::PluginConfigPage, private Ui::BtConfigWidget
106{
107 Q_OBJECT
108 public:
109 explicit KateBtConfigWidget(QWidget* parent = 0, const char* name = 0);
110 virtual ~KateBtConfigWidget();
111
112 public slots:
113 virtual void apply();
114 virtual void reset();
115 virtual void defaults();
116
117 private slots:
118 void add();
119 void remove();
120 void textChanged();
121
122 private:
123 bool m_changed;
124};
125
126class KateBtConfigDialog : public KDialog
127{
128 Q_OBJECT
129 public:
130 KateBtConfigDialog(QWidget* parent = 0);
131 ~KateBtConfigDialog();
132
133 public slots:
134 void changed();
135
136private:
137 KateBtConfigWidget* m_configWidget;
138};
139
140#endif //KATE_BACKTRACEBROWSER_H
141
142// kate: space-indent on; indent-width 2; replace-tabs on;
143