summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Haumann <dhaumann@kde.org>2014-01-19 17:17:58 (GMT)
committerDominik Haumann <dhaumann@kde.org>2014-01-19 17:18:14 (GMT)
commite6f7b7c8aea55a98852b41dd4f94eca20c5381f7 (patch)
tree241f99c90c852bd36cfe10b9515c2101b38a5281
parent789d2d8fb07b7803ef58fea65c640da4f40ff39f (diff)
initial port to new interfaces
-rw-r--r--addons/kate/backtracebrowser/CMakeLists.txt20
-rw-r--r--addons/kate/backtracebrowser/btconfigwidget.ui9
-rw-r--r--addons/kate/backtracebrowser/btdatabase.cpp1
-rw-r--r--addons/kate/backtracebrowser/btfileindexer.cpp1
-rw-r--r--addons/kate/backtracebrowser/btparser.cpp1
-rw-r--r--addons/kate/backtracebrowser/katebacktracebrowser.cpp118
-rw-r--r--addons/kate/backtracebrowser/katebacktracebrowser.h56
-rw-r--r--addons/kate/backtracebrowser/katebacktracebrowserplugin.desktop5
8 files changed, 125 insertions, 86 deletions
diff --git a/addons/kate/backtracebrowser/CMakeLists.txt b/addons/kate/backtracebrowser/CMakeLists.txt
index f3e9488..6ebd26f 100644
--- a/addons/kate/backtracebrowser/CMakeLists.txt
+++ b/addons/kate/backtracebrowser/CMakeLists.txt
@@ -1,20 +1,32 @@
########### next target ###############
+find_package(KF5 CONFIG REQUIRED COMPONENTS ItemModels KDE4Support)
+
+include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
+
set(katebacktracebrowserplugin_PART_SRCS
katebacktracebrowser.cpp
btparser.cpp
btfileindexer.cpp
btdatabase.cpp
)
+
set(katebacktracebrowserplugin_PART_UI
btbrowserwidget.ui
btconfigwidget.ui
)
-kde4_add_ui_files(katebacktracebrowserplugin_PART_SRCS ${katebacktracebrowserplugin_PART_UI} )
-kde4_add_plugin(katebacktracebrowserplugin ${katebacktracebrowserplugin_PART_SRCS})
-target_link_libraries(katebacktracebrowserplugin ${KDE4_KFILE_LIBS} kateinterfaces ktexteditor)
+qt5_wrap_ui(katebacktracebrowserplugin_PART_SRCS ${katebacktracebrowserplugin_PART_UI} )
+add_library(katebacktracebrowserplugin MODULE ${katebacktracebrowserplugin_PART_SRCS})
+target_link_libraries(katebacktracebrowserplugin
+ KF5::TextEditor
+ KF5::Parts
+ KF5::IconThemes
+ KF5::I18n
+ KF5::Service
+ KF5::KDE4Support
+)
########### install files ###############
-
install( TARGETS katebacktracebrowserplugin DESTINATION ${PLUGIN_INSTALL_DIR} )
+kservice_desktop_to_json (katebacktracebrowserplugin.desktop)
install( FILES katebacktracebrowserplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
diff --git a/addons/kate/backtracebrowser/btconfigwidget.ui b/addons/kate/backtracebrowser/btconfigwidget.ui
index ae92730..b27d807 100644
--- a/addons/kate/backtracebrowser/btconfigwidget.ui
+++ b/addons/kate/backtracebrowser/btconfigwidget.ui
@@ -56,14 +56,14 @@ p, li { white-space: pre-wrap; }
</spacer>
</item>
<item>
- <widget class="KPushButton" name="btnRemove" >
+ <widget class="QPushButton" name="btnRemove" >
<property name="text" >
<string>&amp;Remove</string>
</property>
</widget>
</item>
<item>
- <widget class="KPushButton" name="btnAdd" >
+ <widget class="QPushButton" name="btnAdd" >
<property name="text" >
<string>&amp;Add</string>
</property>
@@ -112,11 +112,6 @@ p, li { white-space: pre-wrap; }
</widget>
<customwidgets>
<customwidget>
- <class>KPushButton</class>
- <extends>QPushButton</extends>
- <header>kpushbutton.h</header>
- </customwidget>
- <customwidget>
<class>KUrlRequester</class>
<extends>QFrame</extends>
<header>kurlrequester.h</header>
diff --git a/addons/kate/backtracebrowser/btdatabase.cpp b/addons/kate/backtracebrowser/btdatabase.cpp
index b48d255..b936fb6 100644
--- a/addons/kate/backtracebrowser/btdatabase.cpp
+++ b/addons/kate/backtracebrowser/btdatabase.cpp
@@ -21,6 +21,7 @@
#include <QFile>
#include <QDataStream>
#include <QDir>
+#include <QDebug>
void KateBtDatabase::loadFromFile(const QString& url)
diff --git a/addons/kate/backtracebrowser/btfileindexer.cpp b/addons/kate/backtracebrowser/btfileindexer.cpp
index 7f08687..e57b065 100644
--- a/addons/kate/backtracebrowser/btfileindexer.cpp
+++ b/addons/kate/backtracebrowser/btfileindexer.cpp
@@ -20,6 +20,7 @@
#include "btdatabase.h"
#include <QDir>
+#include <QDebug>
BtFileIndexer::BtFileIndexer(KateBtDatabase* database)
: QThread()
diff --git a/addons/kate/backtracebrowser/btparser.cpp b/addons/kate/backtracebrowser/btparser.cpp
index eff825e..04ec05b 100644
--- a/addons/kate/backtracebrowser/btparser.cpp
+++ b/addons/kate/backtracebrowser/btparser.cpp
@@ -19,6 +19,7 @@
#include "btparser.h"
#include <QStringList>
+#include <QDebug>
static QString eolDelimiter(const QString& str)
diff --git a/addons/kate/backtracebrowser/katebacktracebrowser.cpp b/addons/kate/backtracebrowser/katebacktracebrowser.cpp
index bd7d684..213c48d 100644
--- a/addons/kate/backtracebrowser/katebacktracebrowser.cpp
+++ b/addons/kate/backtracebrowser/katebacktracebrowser.cpp
@@ -18,7 +18,6 @@
//BEGIN Includes
#include "katebacktracebrowser.h"
-#include "katebacktracebrowser.moc"
#include "btparser.h"
#include "btfileindexer.h"
@@ -27,11 +26,12 @@
#include <kpluginfactory.h>
#include <kpluginloader.h>
#include <kaboutdata.h>
-#include <KStandardDirs>
+#include <QStandardPaths>
#include <ktexteditor/view.h>
#include <ksharedconfig.h>
#include <klineedit.h>
#include <kfiledialog.h>
+#include <kurl.h>
#include <QDir>
#include <QFile>
@@ -42,9 +42,7 @@
//END Includes
-K_PLUGIN_FACTORY(KateBtBrowserFactory, registerPlugin<KateBtBrowserPlugin>();)
-K_EXPORT_PLUGIN(KateBtBrowserFactory(KAboutData("katebacktracebrowserplugin","katebacktracebrowserplugin",ki18n("Backtrace Browser"), "0.1", ki18n("Browsing backtraces"), KAboutData::License_LGPL_V2)) )
-
+K_PLUGIN_FACTORY_WITH_JSON (KateBtBrowserFactory, "katebacktracebrowserplugin.json", registerPlugin<KateBtBrowserPlugin>();)
KateBtBrowserPlugin* KateBtBrowserPlugin::s_self = 0L;
static QStringList fileExtensions =
@@ -52,14 +50,13 @@ static QStringList fileExtensions =
<< "*.h" << "*.hpp" << "*.hxx"
<< "*.moc";
-
-KateBtBrowserPlugin::KateBtBrowserPlugin( QObject* parent, const QList<QVariant>&)
- : Kate::Plugin ( (Kate::Application*)parent )
+KateBtBrowserPlugin::KateBtBrowserPlugin(QObject* parent, const QList<QVariant>&)
+ : KTextEditor::Plugin(parent)
, KTextEditor::ConfigPageInterface()
, indexer(&db)
{
s_self = this;
- db.loadFromFile(KStandardDirs::locateLocal( "data", "kate/backtracedatabase"));
+ db.loadFromFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kate/backtracedatabase"));
}
KateBtBrowserPlugin::~KateBtBrowserPlugin()
@@ -69,7 +66,7 @@ KateBtBrowserPlugin::~KateBtBrowserPlugin()
indexer.wait();
}
- db.saveToFile(KStandardDirs::locateLocal( "data", "kate/backtracedatabase"));
+ db.saveToFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kate/backtracedatabase"));
s_self = 0L;
}
@@ -79,13 +76,10 @@ KateBtBrowserPlugin& KateBtBrowserPlugin::self()
return *s_self;
}
-Kate::PluginView *KateBtBrowserPlugin::createView (Kate::MainWindow *mainWindow)
+QObject *KateBtBrowserPlugin::createView (KTextEditor::MainWindow *mainWindow)
{
- KateBtBrowserPluginView* pv = new KateBtBrowserPluginView (mainWindow);
- connect(this, SIGNAL(newStatus(QString)),
- pv, SLOT(setStatus(QString)));
- pv->setStatus(i18n("Indexed files: %1", db.size()));
- return pv;
+ KateBtBrowserPluginView * view = new KateBtBrowserPluginView(this, mainWindow);
+ return view;
}
KateBtDatabase& KateBtBrowserPlugin::database()
@@ -104,28 +98,28 @@ void KateBtBrowserPlugin::startIndexer()
indexer.cancel();
indexer.wait();
}
- KConfigGroup cg(KSharedConfig::config(), "backtracebrowser");
+ KConfigGroup cg(KSharedConfig::openConfig(), "backtracebrowser");
indexer.setSearchPaths(cg.readEntry("search-folders", QStringList()));
indexer.setFilter(cg.readEntry("file-extensions", fileExtensions));
indexer.start();
emit newStatus(i18n("Indexing files..."));
}
-uint KateBtBrowserPlugin::configPages () const
+int KateBtBrowserPlugin::configPages () const
{
return 1;
}
-KTextEditor::ConfigPage* KateBtBrowserPlugin::configPage(uint number, QWidget *parent, const char *name)
+KTextEditor::ConfigPage* KateBtBrowserPlugin::configPage(int number, QWidget *parent)
{
if (number == 0) {
- return new KateBtConfigWidget(parent, name);
+ return new KateBtConfigWidget(parent);
}
return 0L;
}
-QString KateBtBrowserPlugin::configPageName (uint number) const
+QString KateBtBrowserPlugin::configPageName (int number) const
{
if (number == 0) {
return i18n("Backtrace Browser");
@@ -133,7 +127,7 @@ QString KateBtBrowserPlugin::configPageName (uint number) const
return QString();
}
-QString KateBtBrowserPlugin::configPageFullName (uint number) const
+QString KateBtBrowserPlugin::configPageFullName (int number) const
{
if (number == 0) {
return i18n("Backtrace Browser Settings");
@@ -141,47 +135,63 @@ QString KateBtBrowserPlugin::configPageFullName (uint number) const
return QString();
}
-KIcon KateBtBrowserPlugin::configPageIcon (uint) const
+QIcon KateBtBrowserPlugin::configPageIcon (int) const
{
- return KIcon("kbugbuster");
+ return QIcon::fromTheme(QLatin1String("kbugbuster"));
}
-KateBtBrowserPluginView::KateBtBrowserPluginView(Kate::MainWindow *mainWindow)
- : Kate::PluginView(mainWindow)
- , mw(mainWindow)
+KateBtBrowserPluginView::KateBtBrowserPluginView(KateBtBrowserPlugin* plugin, KTextEditor::MainWindow *mainWindow)
+ : QObject(mainWindow), m_plugin(plugin)
{
- toolView = mainWindow->createToolView("KateBtBrowserPlugin", Kate::MainWindow::Bottom, SmallIcon("kbugbuster"), i18n("Backtrace Browser"));
- QWidget* w = new QWidget(toolView);
- setupUi(w);
- w->show();
+ // init console
+ QWidget *toolview = mainWindow->createToolView (plugin,
+ QLatin1String("kate_private_plugin_katebacktracebrowserplugin"),
+ KTextEditor::MainWindow::Bottom,
+ QIcon::fromTheme(QLatin1String("kbugbuster")),
+ i18n("Backtrace Browser"));
+ m_widget = new KateBtBrowserWidget(m_plugin, mainWindow, toolview);
- timer.setSingleShot(true);
- connect(&timer, SIGNAL(timeout()), this, SLOT(clearStatus()));
-
- connect(btnBacktrace, SIGNAL(clicked()), this, SLOT(loadFile()));
- connect(btnClipboard, SIGNAL(clicked()), this, SLOT(loadClipboard()));
- connect(btnConfigure, SIGNAL(clicked()), this, SLOT(configure()));
- connect(lstBacktrace, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(itemActivated(QTreeWidgetItem*,int)));
+ connect(plugin, SIGNAL(newStatus(QString)),
+ this, SLOT(setStatus(QString)));
}
KateBtBrowserPluginView::~KateBtBrowserPluginView ()
{
- delete toolView;
+ // cleanup, kill toolview + widget
+ QWidget *toolview = m_widget->parentWidget();
+ delete m_widget;
+ delete toolview;
}
-void KateBtBrowserPluginView::readSessionConfig(KConfigBase*, const QString&)
+
+
+
+
+
+KateBtBrowserWidget::KateBtBrowserWidget(KateBtBrowserPlugin* plugin, KTextEditor::MainWindow *mainwindow, QWidget* parent)
+ : QWidget(parent)
+ , mw(mainwindow)
{
+ setupUi(this);
+
+ timer.setSingleShot(true);
+ connect(&timer, SIGNAL(timeout()), this, SLOT(clearStatus()));
+
+ connect(btnBacktrace, SIGNAL(clicked()), this, SLOT(loadFile()));
+ connect(btnClipboard, SIGNAL(clicked()), this, SLOT(loadClipboard()));
+ connect(btnConfigure, SIGNAL(clicked()), this, SLOT(configure()));
+ connect(lstBacktrace, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(itemActivated(QTreeWidgetItem*,int)));
}
-void KateBtBrowserPluginView::writeSessionConfig(KConfigBase*, const QString&)
+KateBtBrowserWidget::~KateBtBrowserWidget ()
{
}
-void KateBtBrowserPluginView::loadFile()
+void KateBtBrowserWidget::loadFile()
{
QString url = KFileDialog::getOpenFileName(KUrl(), QString(), mw->window(), i18n("Load Backtrace"));
QFile f(url);
@@ -191,13 +201,13 @@ void KateBtBrowserPluginView::loadFile()
}
}
-void KateBtBrowserPluginView::loadClipboard()
+void KateBtBrowserWidget::loadClipboard()
{
QString bt = QApplication::clipboard()->text();
loadBacktrace(bt);
}
-void KateBtBrowserPluginView::loadBacktrace(const QString& bt)
+void KateBtBrowserWidget::loadBacktrace(const QString& bt)
{
QList<BtInfo> infos = KateBtParser::parseBacktrace(bt);
@@ -232,13 +242,13 @@ void KateBtBrowserPluginView::loadBacktrace(const QString& bt)
}
-void KateBtBrowserPluginView::configure()
+void KateBtBrowserWidget::configure()
{
KateBtConfigDialog dlg(mw->window());
dlg.exec();
}
-void KateBtBrowserPluginView::itemActivated(QTreeWidgetItem* item, int column)
+void KateBtBrowserWidget::itemActivated(QTreeWidgetItem* item, int column)
{
Q_UNUSED(column);
@@ -282,13 +292,13 @@ void KateBtBrowserPluginView::itemActivated(QTreeWidgetItem* item, int column)
}
}
-void KateBtBrowserPluginView::setStatus(const QString& status)
+void KateBtBrowserWidget::setStatus(const QString& status)
{
lblStatus->setText(status);
timer.start(10*1000);
}
-void KateBtBrowserPluginView::clearStatus()
+void KateBtBrowserWidget::clearStatus()
{
lblStatus->setText(QString());
}
@@ -296,8 +306,8 @@ void KateBtBrowserPluginView::clearStatus()
-KateBtConfigWidget::KateBtConfigWidget(QWidget* parent, const char* name)
- : KTextEditor::ConfigPage(parent, name)
+KateBtConfigWidget::KateBtConfigWidget(QWidget* parent)
+ : KTextEditor::ConfigPage(parent)
{
setupUi(this);
edtUrl->setMode(KFile::Directory);
@@ -323,7 +333,7 @@ void KateBtConfigWidget::apply()
for (int i = 0; i < lstFolders->count(); ++i) {
sl << lstFolders->item(i)->data(Qt::DisplayRole).toString();
}
- KConfigGroup cg(KGlobal::config(), "backtracebrowser");
+ KConfigGroup cg(KSharedConfig::openConfig(), "backtracebrowser");
cg.writeEntry("search-folders", sl);
QString filter = edtExtensions->text();
@@ -337,7 +347,7 @@ void KateBtConfigWidget::apply()
void KateBtConfigWidget::reset()
{
- KConfigGroup cg(KGlobal::config(), "backtracebrowser");
+ KConfigGroup cg(KSharedConfig::openConfig(), "backtracebrowser");
lstFolders->clear();
lstFolders->addItems(cg.readEntry("search-folders", QStringList()));
edtExtensions->setText(cg.readEntry("file-extensions", fileExtensions).join(" "));
@@ -388,7 +398,7 @@ KateBtConfigDialog::KateBtConfigDialog(QWidget* parent)
setCaption(i18n("Backtrace Browser Settings"));
setButtons(KDialog::Ok | KDialog::Cancel);
- m_configWidget = new KateBtConfigWidget(this, "kate_bt_config_widget");
+ m_configWidget = new KateBtConfigWidget(this);
setMainWidget(m_configWidget);
connect(this, SIGNAL(applyClicked()), m_configWidget, SLOT(apply()));
@@ -405,4 +415,6 @@ void KateBtConfigDialog::changed()
enableButtonApply(true);
}
+#include "katebacktracebrowser.moc"
+
// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/addons/kate/backtracebrowser/katebacktracebrowser.h b/addons/kate/backtracebrowser/katebacktracebrowser.h
index 7de4cda..3979d6f 100644
--- a/addons/kate/backtracebrowser/katebacktracebrowser.h
+++ b/addons/kate/backtracebrowser/katebacktracebrowser.h
@@ -19,11 +19,10 @@
#ifndef KATE_BACKTRACEBROWSER_H
#define KATE_BACKTRACEBROWSER_H
-#include <ktexteditor/document.h>
-#include <ktexteditor/configpage.h>
-#include <kate/plugin.h>
+#include <KTextEditor/Plugin>
+#include <ktexteditor/mainwindow.h>
#include <ktexteditor/configpageinterface.h>
-#include <kate/mainwindow.h>
+#include <ktexteditor/configpage.h>
#include "ui_btbrowserwidget.h"
#include "ui_btconfigwidget.h"
@@ -33,17 +32,23 @@
#include <QString>
#include <QTimer>
-class KateBtBrowserPlugin: public Kate::Plugin, public KTextEditor::ConfigPageInterface
+#include "kdialog.h"
+
+class KateBtConfigWidget;
+class KateBtBrowserWidget;
+
+class KateBtBrowserPlugin : public KTextEditor::Plugin, public KTextEditor::ConfigPageInterface
{
Q_OBJECT
Q_INTERFACES(KTextEditor::ConfigPageInterface)
+
public:
explicit KateBtBrowserPlugin( QObject* parent = 0, const QList<QVariant>& = QList<QVariant>() );
virtual ~KateBtBrowserPlugin();
static KateBtBrowserPlugin& self();
- Kate::PluginView *createView (Kate::MainWindow *mainWindow);
+ QObject *createView (KTextEditor::MainWindow *mainWindow);
KateBtDatabase& database();
BtFileIndexer& fileIndexer();
@@ -57,11 +62,11 @@ class KateBtBrowserPlugin: public Kate::Plugin, public KTextEditor::ConfigPageIn
// PluginConfigPageInterface
//
public:
- virtual uint configPages() const;
- virtual KTextEditor::ConfigPage* configPage (uint number = 0, QWidget *parent = 0, const char *name = 0);
- virtual QString configPageName(uint number = 0) const;
- virtual QString configPageFullName(uint number = 0) const;
- virtual KIcon configPageIcon(uint number = 0) const;
+ virtual int configPages() const;
+ virtual KTextEditor::ConfigPage* configPage (int number, QWidget *parent = 0);
+ virtual QString configPageName(int number) const;
+ virtual QString configPageFullName(int number) const;
+ virtual QIcon configPageIcon(int number) const;
//
// private data
@@ -72,17 +77,31 @@ class KateBtBrowserPlugin: public Kate::Plugin, public KTextEditor::ConfigPageIn
static KateBtBrowserPlugin* s_self;
};
-class KateBtBrowserPluginView : public Kate::PluginView, public Ui::BtBrowserWidget
+class KateBtBrowserPluginView : public QObject
{
Q_OBJECT
public:
- KateBtBrowserPluginView(Kate::MainWindow* mainWindow);
+ KateBtBrowserPluginView (KateBtBrowserPlugin* plugin, KTextEditor::MainWindow *mainWindow);
+
+ /**
+ * Virtual destructor.
+ */
+ ~KateBtBrowserPluginView ();
- ~KateBtBrowserPluginView();
+ private:
+ KateBtBrowserPlugin *m_plugin;
+ KateBtBrowserWidget *m_widget;
+};
+
+class KateBtBrowserWidget : public QWidget, public Ui::BtBrowserWidget
+{
+ Q_OBJECT
+
+ public:
+ KateBtBrowserWidget(KateBtBrowserPlugin* plugin, KTextEditor::MainWindow *mainwindow, QWidget* parent);
- virtual void readSessionConfig (KConfigBase* config, const QString& groupPrefix);
- virtual void writeSessionConfig (KConfigBase* config, const QString& groupPrefix);
+ ~KateBtBrowserWidget();
void loadBacktrace(const QString& bt);
@@ -97,8 +116,7 @@ class KateBtBrowserPluginView : public Kate::PluginView, public Ui::BtBrowserWid
void itemActivated(QTreeWidgetItem* item, int column);
private:
- QWidget* toolView;
- Kate::MainWindow* mw;
+ KTextEditor::MainWindow* mw;
QTimer timer;
};
@@ -106,7 +124,7 @@ class KateBtConfigWidget : public KTextEditor::ConfigPage, private Ui::BtConfigW
{
Q_OBJECT
public:
- explicit KateBtConfigWidget(QWidget* parent = 0, const char* name = 0);
+ explicit KateBtConfigWidget(QWidget* parent = 0);
virtual ~KateBtConfigWidget();
public Q_SLOTS:
diff --git a/addons/kate/backtracebrowser/katebacktracebrowserplugin.desktop b/addons/kate/backtracebrowser/katebacktracebrowserplugin.desktop
index 97ab7a4..68e9576 100644
--- a/addons/kate/backtracebrowser/katebacktracebrowserplugin.desktop
+++ b/addons/kate/backtracebrowser/katebacktracebrowserplugin.desktop
@@ -1,8 +1,7 @@
[Desktop Entry]
Type=Service
-ServiceTypes=Kate/Plugin
+ServiceTypes=KTextEditor/Plugin
X-KDE-Library=katebacktracebrowserplugin
-X-Kate-Version=3.0
Name=Backtrace Browser
Name[ast]=Desaminador de trazaos inversos
Name[bg]=Преглед на backtrace
@@ -110,4 +109,4 @@ Comment[wa]=Vuwe di l' usteye di naiviaedje emey les backtraces
Comment[x-test]=xxBacktrace navigation tool viewxx
Comment[zh_CN]=回溯导航工具视图
Comment[zh_TW]=回溯追蹤導覽工具檢視
-author=Dominik Haumann, dhdev@gmx.de
+author=Dominik Haumann, dhaumann@kde.org