aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKåre Särs <kare.sars@iki.fi>2014-01-20 02:04:13 (GMT)
committerKåre Särs <kare.sars@iki.fi>2014-01-20 02:05:04 (GMT)
commit01ee01427750604a80a41510e470f790847cc3e8 (patch)
tree113c1526f0e9432381d3737f37dab8c4e551bc5e
parent77f1c74ce4671f778c1d4c68404f423e29aeeb61 (diff)
Port the CTags plugin to frameworks and re-enable building
-rw-r--r--addons/kate/CMakeLists.txt2
-rw-r--r--addons/kate/kate-ctags/CMakeLists.txt19
-rw-r--r--addons/kate/kate-ctags/CTagsGlobalConfig.ui23
-rw-r--r--addons/kate/kate-ctags/ctagskinds.cpp2
-rw-r--r--addons/kate/kate-ctags/kate_ctags.ui31
-rw-r--r--addons/kate/kate-ctags/kate_ctags_plugin.cpp77
-rw-r--r--addons/kate/kate-ctags/kate_ctags_plugin.h24
-rw-r--r--addons/kate/kate-ctags/kate_ctags_view.cpp226
-rw-r--r--addons/kate/kate-ctags/kate_ctags_view.h39
-rw-r--r--addons/kate/kate-ctags/katectagsplugin.desktop3
-rw-r--r--addons/kate/kate-ctags/tags.cpp24
11 files changed, 195 insertions, 275 deletions
diff --git a/addons/kate/CMakeLists.txt b/addons/kate/CMakeLists.txt
index 1010605..1272410 100644
--- a/addons/kate/CMakeLists.txt
+++ b/addons/kate/CMakeLists.txt
@@ -31,7 +31,7 @@ ecm_optional_add_subdirectory ( backtracebrowser )
#add_subdirectory( filetemplates )
-#add_subdirectory( kate-ctags )
+add_subdirectory( kate-ctags )
#add_subdirectory( katebuild-plugin )
#add_subdirectory( kttsd )
diff --git a/addons/kate/kate-ctags/CMakeLists.txt b/addons/kate/kate-ctags/CMakeLists.txt
index a4d53b6..d358a74 100644
--- a/addons/kate/kate-ctags/CMakeLists.txt
+++ b/addons/kate/kate-ctags/CMakeLists.txt
@@ -1,10 +1,3 @@
-# building separately or as part of kdesdk?
-if(NOT KDE4_FOUND)
- find_package(KDE4 REQUIRED)
-endif(NOT KDE4_FOUND)
-
-include_directories (${KDE4_INCLUDES})
-include_directories( ${KDE4_KIO_INCLUDES} )
include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
set(ctagsplugin_SRC
@@ -15,15 +8,15 @@ set(ctagsplugin_SRC
kate_ctags_plugin.cpp
)
-kde4_add_ui_files(ctagsplugin_SRC kate_ctags.ui CTagsGlobalConfig.ui)
-
-kde4_add_plugin(katectagsplugin ${ctagsplugin_SRC})
+qt5_wrap_ui(ctagsplugin_SRC kate_ctags.ui CTagsGlobalConfig.ui)
-target_link_libraries(katectagsplugin ${KDE4_KDECORE_LIBS} kateinterfaces ktexteditor )
+add_library(katectagsplugin MODULE ${ctagsplugin_SRC})
-install(TARGETS katectagsplugin DESTINATION ${PLUGIN_INSTALL_DIR} )
+target_link_libraries(katectagsplugin KF5::TextEditor KF5::I18n KF5::IconThemes)
########### install files ###############
+install(TARGETS katectagsplugin DESTINATION ${PLUGIN_INSTALL_DIR} )
+install(FILES ui.rc DESTINATION ${DATA_INSTALL_DIR}/katectags)
-install(FILES ui.rc DESTINATION ${DATA_INSTALL_DIR}/kate/plugins/katectags)
+kservice_desktop_to_json (katectagsplugin.desktop)
install(FILES katectagsplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
diff --git a/addons/kate/kate-ctags/CTagsGlobalConfig.ui b/addons/kate/kate-ctags/CTagsGlobalConfig.ui
index e52fd0c..02f5df3 100644
--- a/addons/kate/kate-ctags/CTagsGlobalConfig.ui
+++ b/addons/kate/kate-ctags/CTagsGlobalConfig.ui
@@ -10,7 +10,7 @@
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
- <widget class="KListWidget" name="targetList"/>
+ <widget class="QListWidget" name="targetList"/>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
@@ -49,7 +49,7 @@
</widget>
</item>
<item row="3" column="0">
- <widget class="KPushButton" name="updateDB">
+ <widget class="QPushButton" name="updateDB">
<property name="text">
<string>Update</string>
</property>
@@ -67,7 +67,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
- <widget class="KLineEdit" name="cmdEdit">
+ <widget class="QLineEdit" name="cmdEdit">
<property name="frame">
<bool>true</bool>
</property>
@@ -78,23 +78,6 @@
</item>
</layout>
</widget>
- <customwidgets>
- <customwidget>
- <class>KListWidget</class>
- <extends>QListWidget</extends>
- <header>klistwidget.h</header>
- </customwidget>
- <customwidget>
- <class>KPushButton</class>
- <extends>QPushButton</extends>
- <header>kpushbutton.h</header>
- </customwidget>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- </customwidgets>
<resources/>
<connections/>
</ui>
diff --git a/addons/kate/kate-ctags/ctagskinds.cpp b/addons/kate/kate-ctags/ctagskinds.cpp
index ac0f2d2..8d76592 100644
--- a/addons/kate/kate-ctags/ctagskinds.cpp
+++ b/addons/kate/kate-ctags/ctagskinds.cpp
@@ -274,7 +274,7 @@ static CTagsExtensionMapping extensionMapping[] = {
static CTagsKindMapping *findKindMapping(const QString &extension)
{
- const char *pextension = extension.toLocal8Bit();
+ const char *pextension = extension.toLocal8Bit().constData();
CTagsExtensionMapping *pem = extensionMapping;
while (pem->extension != 0) {
diff --git a/addons/kate/kate-ctags/kate_ctags.ui b/addons/kate/kate-ctags/kate_ctags.ui
index 5717880..32cb4a3 100644
--- a/addons/kate/kate-ctags/kate_ctags.ui
+++ b/addons/kate/kate-ctags/kate_ctags.ui
@@ -4,7 +4,7 @@
<widget class="QWidget" name="kateCtags">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
- <widget class="KTabWidget" name="tabWidget">
+ <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
@@ -14,14 +14,14 @@
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
- <widget class="KLineEdit" name="inputEdit">
+ <widget class="QLineEdit" name="inputEdit">
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
- <widget class="KPushButton" name="updateButton">
+ <widget class="QPushButton" name="updateButton">
<property name="text">
<string>Update Index</string>
</property>
@@ -57,7 +57,7 @@
</attribute>
<layout class="QGridLayout" name="gridLayout_2" columnstretch="1,0,0">
<item row="0" column="0" rowspan="4" colspan="2">
- <widget class="KListWidget" name="targetList"/>
+ <widget class="QListWidget" name="targetList"/>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="addButton">
@@ -121,7 +121,7 @@
</widget>
</item>
<item row="3" column="1">
- <widget class="KLineEdit" name="cmdEdit">
+ <widget class="QLineEdit" name="cmdEdit">
<property name="frame">
<bool>true</bool>
</property>
@@ -168,27 +168,6 @@
<extends>QFrame</extends>
<header>kurlrequester.h</header>
</customwidget>
- <customwidget>
- <class>KListWidget</class>
- <extends>QListWidget</extends>
- <header>klistwidget.h</header>
- </customwidget>
- <customwidget>
- <class>KPushButton</class>
- <extends>QPushButton</extends>
- <header>kpushbutton.h</header>
- </customwidget>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- <customwidget>
- <class>KTabWidget</class>
- <extends>QTabWidget</extends>
- <header>ktabwidget.h</header>
- <container>1</container>
- </customwidget>
</customwidgets>
<resources/>
<connections/>
diff --git a/addons/kate/kate-ctags/kate_ctags_plugin.cpp b/addons/kate/kate-ctags/kate_ctags_plugin.cpp
index 598828a..3c3a1af 100644
--- a/addons/kate/kate-ctags/kate_ctags_plugin.cpp
+++ b/addons/kate/kate-ctags/kate_ctags_plugin.cpp
@@ -22,65 +22,65 @@
#include "kate_ctags_plugin.h"
#include <QFileInfo>
-#include <KFileDialog>
+#include <QFileDialog>
#include <QCheckBox>
-#include <kmenu.h>
+#include <KConfigGroup>
+
#include <kactioncollection.h>
#include <kstringhandler.h>
#include <kmessagebox.h>
-#include <kstandarddirs.h>
+#include <ktexteditor/editor.h>
+#include <klocalizedstring.h>
#include <kpluginfactory.h>
#include <kpluginloader.h>
#include <kaboutdata.h>
-K_PLUGIN_FACTORY(KateCTagsPluginFactory, registerPlugin<KateCTagsPlugin>();)
-K_EXPORT_PLUGIN(KateCTagsPluginFactory(KAboutData("katectags", "kate-ctags-plugin",
- ki18n("CTags Plugin"), "0.2",
- ki18n( "CTags Plugin"))))
+K_PLUGIN_FACTORY_WITH_JSON (KateCTagsPluginFactory, "katectagsplugin.json", registerPlugin<KateCTagsPlugin>();)
/******************************************************************/
KateCTagsPlugin::KateCTagsPlugin(QObject* parent, const QList<QVariant>&):
-Kate::Plugin ((Kate::Application*)parent), m_view(0)
+KTextEditor::Plugin (parent), m_view(0)
{
- KGlobal::locale()->insertCatalog("kate-ctags-plugin");
+ // FIXME KF5
+ //KGlobal::locale()->insertCatalog("kate-ctags-plugin");
}
/******************************************************************/
-Kate::PluginView *KateCTagsPlugin::createView(Kate::MainWindow *mainWindow)
+QObject *KateCTagsPlugin::createView(KTextEditor::MainWindow *mainWindow)
{
- m_view = new KateCTagsView(mainWindow, KateCTagsPluginFactory::componentData());
+ m_view = new KateCTagsView(this, mainWindow);
return m_view;
}
/******************************************************************/
-KTextEditor::ConfigPage *KateCTagsPlugin::configPage (uint number, QWidget *parent, const char *)
+KTextEditor::ConfigPage *KateCTagsPlugin::configPage (int number, QWidget *parent)
{
if (number != 0) return 0;
return new KateCTagsConfigPage(parent, this);
}
/******************************************************************/
-QString KateCTagsPlugin::configPageName (uint number) const
+QString KateCTagsPlugin::configPageName (int number) const
{
if (number != 0) return QString();
return i18n("CTags");
}
/******************************************************************/
-QString KateCTagsPlugin::configPageFullName (uint number) const
+QString KateCTagsPlugin::configPageFullName (int number) const
{
if (number != 0) return QString();
return i18n("CTags Settings");
}
/******************************************************************/
-KIcon KateCTagsPlugin::configPageIcon (uint number) const
+QIcon KateCTagsPlugin::configPageIcon (int number) const
{
- if (number != 0) return KIcon();
- return KIcon("text-x-csrc");
+ if (number != 0) return QIcon();
+ return QIcon::fromTheme(QStringLiteral("text-x-csrc"));
}
/******************************************************************/
@@ -100,13 +100,13 @@ KateCTagsConfigPage::KateCTagsConfigPage( QWidget* parent, KateCTagsPlugin *plug
m_confUi.cmdEdit->setText(DEFAULT_CTAGS_CMD);
m_confUi.addButton->setToolTip(i18n("Add a directory to index."));
- m_confUi.addButton->setIcon(KIcon("list-add"));
+ m_confUi.addButton->setIcon(QIcon::fromTheme(QStringLiteral("list-add")));
m_confUi.delButton->setToolTip(i18n("Remove a directory."));
- m_confUi.delButton->setIcon(KIcon("list-remove"));
+ m_confUi.delButton->setIcon(QIcon::fromTheme(QStringLiteral("list-remove")));
m_confUi.updateDB->setToolTip(i18n("(Re-)generate the common CTags database."));
- m_confUi.updateDB->setIcon(KIcon("view-refresh"));
+ m_confUi.updateDB->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh")));
connect(m_confUi.updateDB, SIGNAL(clicked()), this, SLOT(updateGlobalDB()));
connect(m_confUi.addButton, SIGNAL(clicked()), this, SLOT(addGlobalTagTarget()));
@@ -121,15 +121,15 @@ KateCTagsConfigPage::KateCTagsConfigPage( QWidget* parent, KateCTagsPlugin *plug
/******************************************************************/
void KateCTagsConfigPage::apply()
{
- KConfigGroup config(KGlobal::config(), "CTags");
+ KConfigGroup config(KSharedConfig::openConfig(), QStringLiteral("CTags"));
config.writeEntry("GlobalCommand", m_confUi.cmdEdit->text());
config.writeEntry("GlobalNumTargets", m_confUi.targetList->count());
QString nr;
for (int i=0; i<m_confUi.targetList->count(); i++) {
- nr = QString("%1").arg(i,3);
- config.writeEntry("GlobalTarget_"+nr, m_confUi.targetList->item(i)->text());
+ nr = QStringLiteral("%1").arg(i,3);
+ config.writeEntry(QStringLiteral("GlobalTarget_")+nr, m_confUi.targetList->item(i)->text());
}
config.sync();
}
@@ -137,15 +137,15 @@ void KateCTagsConfigPage::apply()
/******************************************************************/
void KateCTagsConfigPage::reset()
{
- KConfigGroup config(KGlobal::config(), "CTags");
- m_confUi.cmdEdit->setText(config.readEntry("GlobalCommand", DEFAULT_CTAGS_CMD));
+ KConfigGroup config(KSharedConfig::openConfig(), "CTags");
+ m_confUi.cmdEdit->setText(config.readEntry(QStringLiteral("GlobalCommand"), DEFAULT_CTAGS_CMD));
- int numEntries = config.readEntry("GlobalNumTargets", 0);
+ int numEntries = config.readEntry(QStringLiteral("GlobalNumTargets"), 0);
QString nr;
QString target;
for (int i=0; i<numEntries; i++) {
- nr = QString("%1").arg(i,3);
- target = config.readEntry("GlobalTarget_"+nr, QString());
+ nr = QStringLiteral("%1").arg(i,3);
+ target = config.readEntry(QStringLiteral("GlobalTarget_")+nr, QString());
if (!listContains(target)) {
new QListWidgetItem(target, m_confUi.targetList);
}
@@ -157,8 +157,9 @@ void KateCTagsConfigPage::reset()
/******************************************************************/
void KateCTagsConfigPage::addGlobalTagTarget()
{
- KFileDialog dialog(KUrl(), QString(), 0, 0);
- dialog.setMode(KFile::Directory | KFile::Files | KFile::ExistingOnly | KFile::LocalOnly);
+ QFileDialog dialog;
+ dialog.setFileMode(QFileDialog::Directory);
+ //dialog.setMode(KFile::Directory | KFile::Files | KFile::ExistingOnly | KFile::LocalOnly);
// i18n("CTags Database Location"));
if (dialog.exec() != QDialog::Accepted) {
@@ -205,24 +206,23 @@ void KateCTagsConfigPage::updateGlobalDB()
QString target;
for (int i=0; i<m_confUi.targetList->count(); i++) {
target = m_confUi.targetList->item(i)->text();
- if (target.endsWith('/') || target.endsWith('\\')) {
+ if (target.endsWith(QLatin1Char('/')) || target.endsWith(QLatin1Char('\\'))) {
target = target.left(target.size() - 1);
}
- targets += target + ' ';
+ targets += target + QLatin1Char(' ');
}
- QString file = KStandardDirs::locateLocal("appdata", "plugins/katectags/common_db", true);
+ QString file = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1String("/katectags");
+ QDir().mkpath(file);
+ file += QLatin1String("/common_db");
if (targets.isEmpty()) {
QFile::remove(file);
return;
}
- QString command = QString("%1 -f %2 %3").arg(m_confUi.cmdEdit->text()).arg(file).arg(targets) ;
-
- m_proc.setShellCommand(command);
- m_proc.setOutputChannelMode(KProcess::SeparateChannels);
- m_proc.start();
+ QString command = QStringLiteral("%1 -f %2 %3").arg(m_confUi.cmdEdit->text()).arg(file).arg(targets) ;
+ m_proc.start(command);
if(!m_proc.waitForStarted(500)) {
KMessageBox::error(0, i18n("Failed to run \"%1\". exitStatus = %2", command, m_proc.exitStatus()));
@@ -246,4 +246,5 @@ void KateCTagsConfigPage::updateDone(int exitCode, QProcess::ExitStatus status)
QApplication::restoreOverrideCursor();
}
+#include "kate_ctags_plugin.moc"
diff --git a/addons/kate/kate-ctags/kate_ctags_plugin.h b/addons/kate/kate-ctags/kate_ctags_plugin.h
index 7c50a60..81ee52a 100644
--- a/addons/kate/kate-ctags/kate_ctags_plugin.h
+++ b/addons/kate/kate-ctags/kate_ctags_plugin.h
@@ -25,17 +25,17 @@
#include <ktexteditor/view.h>
#include <ktexteditor/document.h>
-#include <kate/plugin.h>
-#include <kate/application.h>
-#include <kate/documentmanager.h>
-#include <kate/mainwindow.h>
+#include <ktexteditor/application.h>
+#include <ktexteditor/mainwindow.h>
#include <ktexteditor/configpageinterface.h>
+#include <KTextEditor/ConfigPage>
+#include <KTextEditor/Plugin>
#include "kate_ctags_view.h"
#include "ui_CTagsGlobalConfig.h"
//******************************************************************/
-class KateCTagsPlugin : public Kate::Plugin, public KTextEditor::ConfigPageInterface
+class KateCTagsPlugin : public KTextEditor::Plugin, public KTextEditor::ConfigPageInterface
{
Q_OBJECT
Q_INTERFACES(KTextEditor::ConfigPageInterface)
@@ -44,14 +44,14 @@ class KateCTagsPlugin : public Kate::Plugin, public KTextEditor::ConfigPageInter
explicit KateCTagsPlugin(QObject* parent = 0, const QList<QVariant> & = QList<QVariant>());
virtual ~KateCTagsPlugin() {}
- Kate::PluginView *createView(Kate::MainWindow *mainWindow);
+ QObject *createView(KTextEditor::MainWindow *mainWindow);
// PluginConfigPageInterface
- uint configPages() const { return 1; };
- KTextEditor::ConfigPage *configPage (uint number = 0, QWidget *parent = 0, const char *name = 0);
- QString configPageName (uint number = 0) const;
- QString configPageFullName (uint number = 0) const;
- KIcon configPageIcon (uint number = 0) const;
+ int configPages() const { return 1; };
+ KTextEditor::ConfigPage *configPage (int number = 0, QWidget *parent = 0);
+ QString configPageName (int number = 0) const;
+ QString configPageFullName (int number = 0) const;
+ QIcon configPageIcon (int number = 0) const;
void readConfig();
KateCTagsView *m_view;
@@ -78,7 +78,7 @@ private:
bool listContains(const QString &target);
- KProcess m_proc;
+ QProcess m_proc;
KateCTagsPlugin *m_plugin;
Ui_CTagsGlobalConfig m_confUi;
};
diff --git a/addons/kate/kate-ctags/kate_ctags_view.cpp b/addons/kate/kate-ctags/kate_ctags_view.cpp
index 60a87a3..2b8a8e7 100644
--- a/addons/kate/kate-ctags/kate_ctags_view.cpp
+++ b/addons/kate/kate-ctags/kate_ctags_view.cpp
@@ -22,76 +22,76 @@
#include "kate_ctags_view.h"
#include <QFileInfo>
-#include <KFileDialog>
+#include <QFileDialog>
#include <QKeyEvent>
-#include <kmenu.h>
-#include <kactioncollection.h>
-#include <kstandarddirs.h>
+#include <KXMLGUIFactory>
+#include <KActionCollection>
+#include <KConfigGroup>
+#include <QMenu>
+
+#include <klocalizedstring.h>
#include <kstringhandler.h>
#include <kmessagebox.h>
-
+#include <QStandardPaths>
/******************************************************************/
-KateCTagsView::KateCTagsView(Kate::MainWindow *mw, const KComponentData& componentData)
- : Kate::PluginView (mw)
- , Kate::XMLGUIClient(componentData)
- , m_toolView (mw->createToolView ("kate_private_plugin_katectagsplugin",
- Kate::MainWindow::Bottom,
- SmallIcon("application-x-ms-dos-executable"),
- i18n("CTags"))
- )
- , m_proc(0)
+KateCTagsView::KateCTagsView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mainWin)
+: QObject(mainWin)
+, m_proc(0)
{
- m_mWin = mw;
+ KXMLGUIClient::setComponentName (QLatin1String("katectags"), i18n ("Kate CTag"));
+ setXMLFile( QLatin1String("ui.rc") );
+
+ m_toolView = mainWin->createToolView(plugin, QLatin1String("kate_plugin_katectagsplugin"),
+ KTextEditor::MainWindow::Bottom,
+ QIcon::fromTheme(QStringLiteral("application-x-ms-dos-executable")),
+ i18n("CTags"));
+ m_mWin = mainWin;
- KAction *back = actionCollection()->addAction("ctags_return_step");
+ QAction *back = actionCollection()->addAction(QLatin1String("ctags_return_step"));
back->setText(i18n("Jump back one step"));
- back->setShortcut(QKeySequence(Qt::ALT+Qt::Key_1) );
connect(back, SIGNAL(triggered(bool)), this, SLOT(stepBack()));
- KAction *decl = actionCollection()->addAction("ctags_lookup_current_as_declaration");
+ QAction *decl = actionCollection()->addAction(QLatin1String("ctags_lookup_current_as_declaration"));
decl->setText(i18n("Go to Declaration"));
- decl->setShortcut(QKeySequence(Qt::ALT+Qt::Key_2) );
connect(decl, SIGNAL(triggered(bool)), this, SLOT(gotoDeclaration()));
- KAction *defin = actionCollection()->addAction("ctags_lookup_current_as_definition");
+ QAction *defin = actionCollection()->addAction(QLatin1String("ctags_lookup_current_as_definition"));
defin->setText(i18n("Go to Definition"));
- defin->setShortcut(QKeySequence(Qt::ALT+Qt::Key_3) );
connect(defin, SIGNAL(triggered(bool)), this, SLOT(gotoDefinition()));
- KAction *lookup = actionCollection()->addAction("ctags_lookup_current");
+ QAction *lookup = actionCollection()->addAction(QLatin1String("ctags_lookup_current"));
lookup->setText(i18n("Lookup Current Text"));
- lookup->setShortcut(QKeySequence(Qt::ALT+Qt::Key_4) );
connect(lookup, SIGNAL(triggered(bool)), this, SLOT(lookupTag()));
// popup menu
m_menu = new KActionMenu(i18n("CTags"), this);
- actionCollection()->addAction("popup_ctags", m_menu);
+ actionCollection()->addAction(QLatin1String("popup_ctags"), m_menu);
m_gotoDec=m_menu->menu()->addAction(i18n("Go to Declaration: %1",QString()), this, SLOT(gotoDeclaration()));
m_gotoDef=m_menu->menu()->addAction(i18n("Go to Definition: %1",QString()), this, SLOT(gotoDefinition()));
m_lookup=m_menu->menu()->addAction(i18n("Lookup: %1",QString()), this, SLOT(lookupTag()));
- connect(m_menu->menu(), SIGNAL(aboutToShow()), this, SLOT(aboutToShow()));
+ connect(m_menu, SIGNAL(aboutToShow()), this, SLOT(aboutToShow()));
QWidget *ctagsWidget = new QWidget(m_toolView);
m_ctagsUi.setupUi(ctagsWidget);
m_ctagsUi.cmdEdit->setText(DEFAULT_CTAGS_CMD);
m_ctagsUi.addButton->setToolTip(i18n("Add a directory to index."));
- m_ctagsUi.addButton->setIcon(KIcon("list-add"));
+ m_ctagsUi.addButton->setIcon(QIcon::fromTheme(QStringLiteral("list-add")));
m_ctagsUi.delButton->setToolTip(i18n("Remove a directory."));
- m_ctagsUi.delButton->setIcon(KIcon("list-remove"));
+ m_ctagsUi.delButton->setIcon(QIcon::fromTheme(QStringLiteral("list-remove")));
m_ctagsUi.updateButton->setToolTip(i18n("(Re-)generate the session specific CTags database."));
- m_ctagsUi.updateButton->setIcon(KIcon("view-refresh"));
+ m_ctagsUi.updateButton->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh")));
m_ctagsUi.updateButton2->setToolTip(i18n("(Re-)generate the session specific CTags database."));
- m_ctagsUi.updateButton2->setIcon(KIcon("view-refresh"));
+ m_ctagsUi.updateButton2->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh")));
- m_ctagsUi.resetCMD->setIcon(KIcon("view-refresh"));
+ m_ctagsUi.resetCMD->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh")));
m_ctagsUi.tagsFile->setToolTip(i18n("Select new or existing database file."));
@@ -111,21 +111,21 @@ KateCTagsView::KateCTagsView(Kate::MainWindow *mw, const KComponentData& compone
connect(m_ctagsUi.tagTreeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)),
SLOT(tagHitClicked(QTreeWidgetItem*)));
- connect(mainWindow(), SIGNAL(unhandledShortcutOverride(QEvent*)),
+ connect(m_mWin, SIGNAL(unhandledShortcutOverride(QEvent*)),
this, SLOT(handleEsc(QEvent*)));
m_toolView->installEventFilter(this);
- mainWindow()->guiFactory()->addClient(this);
+ m_mWin->guiFactory()->addClient(this);
- m_commonDB = KStandardDirs::locateLocal("appdata", "plugins/katectags/common_db", true);
+ m_commonDB = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1String("/katectags/common_db");
}
/******************************************************************/
KateCTagsView::~KateCTagsView()
{
- mainWindow()->guiFactory()->removeClient( this );
+ m_mWin->guiFactory()->removeClient( this );
delete m_toolView;
}
@@ -149,44 +149,36 @@ void KateCTagsView::aboutToShow()
/******************************************************************/
-void KateCTagsView::readSessionConfig (KConfigBase* config, const QString& groupPrefix)
+void KateCTagsView::readSessionConfig (const KConfigGroup& cg)
{
- KConfigGroup cg(config, groupPrefix + ":ctags-plugin");
-
m_ctagsUi.cmdEdit->setText(cg.readEntry("TagsGenCMD", DEFAULT_CTAGS_CMD));
int numEntries = cg.readEntry("SessionNumTargets", 0);
QString nr;
QString target;
for (int i=0; i<numEntries; i++) {
- nr = QString("%1").arg(i,3);
- target = cg.readEntry("SessionTarget_"+nr, QString());
+ nr = QStringLiteral("%1").arg(i,3);
+ target = cg.readEntry(QStringLiteral("SessionTarget_%1").arg(nr), QString());
if (!listContains(target)) {
new QListWidgetItem(target, m_ctagsUi.targetList);
}
}
QString sessionDB = cg.readEntry("SessionDatabase", QString());
- if (sessionDB.isEmpty()) {
- sessionDB = KStandardDirs::locateLocal("appdata", "plugins/katectags/session_db_", true);
- sessionDB += QDateTime::currentDateTime().toString("yyyyMMdd_hhmmss");
- }
m_ctagsUi.tagsFile->setText(sessionDB);
}
/******************************************************************/
-void KateCTagsView::writeSessionConfig (KConfigBase* config, const QString& groupPrefix)
+void KateCTagsView::writeSessionConfig (KConfigGroup& cg)
{
- KConfigGroup cg(config, groupPrefix + ":ctags-plugin");
-
cg.writeEntry("TagsGenCMD", m_ctagsUi.cmdEdit->text());
cg.writeEntry("SessionNumTargets", m_ctagsUi.targetList->count());
QString nr;
for (int i=0; i<m_ctagsUi.targetList->count(); i++) {
- nr = QString("%1").arg(i,3);
- cg.writeEntry("SessionTarget_"+nr, m_ctagsUi.targetList->item(i)->text());
+ nr = QStringLiteral("%1").arg(i,3);
+ cg.writeEntry(QStringLiteral("SessionTarget_%1").arg(nr), m_ctagsUi.targetList->item(i)->text());
}
cg.writeEntry("SessionDatabase", m_ctagsUi.tagsFile->text());
@@ -247,7 +239,7 @@ void KateCTagsView::gotoDefinition( )
}
QStringList types;
- types << "S" << "d" << "f" << "t" << "v";
+ types << QStringLiteral("S") << QStringLiteral("d") << QStringLiteral("f") << QStringLiteral("t") << QStringLiteral("v");
gotoTagForTypes(currWord, types);
}
@@ -260,7 +252,16 @@ void KateCTagsView::gotoDeclaration( )
}
QStringList types;
- types << "L" << "c" << "e" << "g" << "m" << "n" << "p" << "s" << "u" << "x";
+ types << QStringLiteral("L")
+ << QStringLiteral("c")
+ << QStringLiteral("e")
+ << QStringLiteral("g")
+ << QStringLiteral("m")
+ << QStringLiteral("n")
+ << QStringLiteral("p")
+ << QStringLiteral("s")
+ << QStringLiteral("u")
+ << QStringLiteral("x");
gotoTagForTypes(currWord, types);
}
@@ -306,8 +307,6 @@ void KateCTagsView::setNewLookupText(const QString &newString)
/******************************************************************/
void KateCTagsView::displayHits(const Tags::TagList &list)
{
- KUrl url;
-
m_ctagsUi.tagTreeWidget->clear();
if (list.isEmpty()) {
new QTreeWidgetItem(m_ctagsUi.tagTreeWidget, QStringList(i18n("No hits found")));
@@ -315,40 +314,21 @@ void KateCTagsView::displayHits(const Tags::TagList &list)
}
m_ctagsUi.tagTreeWidget->setSortingEnabled(false);
- Tags::TagList::ConstIterator it = list.begin();
- while(it != list.end()) {
- // search for the file
- QFileInfo file((*it).file);
- if(file.isAbsolute()) {
- // we have absolute path
- url.setPath((*it).file);
- }
- else {
- // not absolute
- QString name = (*it).file;
- name = name.remove(".\\");
- name = name.replace("\\", "/");
- QFileInfo abs(QFileInfo(Tags::getTagsFile()).path()+ '/' + name);
- url.setPath(abs.absoluteFilePath());
- }
-
+ for (int i=0; i<list.size(); i++) {
QTreeWidgetItem* item = new QTreeWidgetItem(m_ctagsUi.tagTreeWidget);
- item->setText(0, (*it).tag);
- item->setText(1, (*it).type);
- item->setText(2, url.toLocalFile());
-
- item->setData(0, Qt::UserRole, (*it).pattern);
+ item->setText(0, list[i].tag);
+ item->setText(1, list[i].type);
+ item->setText(2, list[i].file);
+ item->setData(0, Qt::UserRole, list[i].pattern);
- QString pattern = (*it).pattern;
- pattern.replace( "\\/", "/" );
+ QString pattern = list[i].pattern;
+ pattern.replace( QStringLiteral("\\/"), QStringLiteral("/"));
pattern = pattern.mid(2, pattern.length() - 4);
pattern = pattern.trimmed();
item->setData(0, Qt::ToolTipRole, pattern);
item->setData(1, Qt::ToolTipRole, pattern);
item->setData(2, Qt::ToolTipRole, pattern);
-
- ++it;
}
m_ctagsUi.tagTreeWidget->setSortingEnabled(true);
}
@@ -367,7 +347,7 @@ void KateCTagsView::tagHitClicked(QTreeWidgetItem *item)
/******************************************************************/
QString KateCTagsView::currentWord( )
{
- KTextEditor::View *kv = mainWindow()->activeView();
+ KTextEditor::View *kv = m_mWin->activeView();
if (!kv) {
qDebug() << "no KTextEditor::View" << endl;
return QString();
@@ -384,22 +364,22 @@ QString KateCTagsView::currentWord( )
int line = kv->cursorPosition().line();
int col = kv->cursorPosition().column();
- bool includeColon = m_ctagsUi.cmdEdit->text().contains("--extra=+q");
+ bool includeColon = m_ctagsUi.cmdEdit->text().contains(QLatin1String("--extra=+q"));
QString linestr = kv->document()->line(line);
int startPos = qMax(qMin(col, linestr.length()-1), 0);
int endPos = startPos;
while (startPos >= 0 && (linestr[startPos].isLetterOrNumber() ||
- (linestr[startPos] == ':' && includeColon) ||
- linestr[startPos] == '_' ||
- linestr[startPos] == '~'))
+ (linestr[startPos] == QLatin1Char(':') && includeColon) ||
+ linestr[startPos] == QLatin1Char('_') ||
+ linestr[startPos] == QLatin1Char('~')))
{
startPos--;
}
while (endPos < (int)linestr.length() && (linestr[endPos].isLetterOrNumber() ||
- (linestr[endPos] == ':' && includeColon) ||
- linestr[endPos] == '_')) {
+ (linestr[endPos] == QLatin1Char(':') && includeColon) ||
+ linestr[endPos] == QLatin1Char('_'))) {
endPos++;
}
if (startPos == endPos) {
@@ -409,12 +389,12 @@ QString KateCTagsView::currentWord( )
linestr = linestr.mid(startPos+1, endPos-startPos-1);
- while (linestr.endsWith(':')) {
- linestr.remove(linestr.size()-1, 1);
+ while (linestr.endsWith(QLatin1Char(':'))) {
+ linestr.remove(linestr.size()-1, 1);
}
- while (linestr.startsWith(':')) {
- linestr.remove(0, 1);
+ while (linestr.startsWith(QLatin1Char(':'))) {
+ linestr.remove(0, 1);
}
//qDebug() << linestr;
@@ -424,14 +404,12 @@ QString KateCTagsView::currentWord( )
/******************************************************************/
void KateCTagsView::jumpToTag(const QString &file, const QString &pattern, const QString &word)
{
- KUrl url;
-
if (pattern.isEmpty()) return;
// generate a regexp from the pattern
// ctags interestingly escapes "/", but apparently nothing else. lets revert that
QString unescaped = pattern;
- unescaped.replace( "\\/", "/" );
+ unescaped.replace( QStringLiteral("\\/"), QStringLiteral("/") );
// most of the time, the ctags pattern has the form /^foo$/
// but this isn't true for some macro definitions
@@ -442,44 +420,29 @@ void KateCTagsView::jumpToTag(const QString &file, const QString &pattern, const
QString escaped;
QString re_string;
- if (unescaped.endsWith("$/")) {
+ if (unescaped.endsWith(QStringLiteral("$/"))) {
reduced = unescaped.mid(2, unescaped.length() - 4);
escaped = QRegExp::escape(reduced);
- re_string = QString('^' + escaped + '$');
+ re_string = QStringLiteral("^%1$").arg(escaped);
}
else {
reduced = unescaped.mid( 2, unescaped.length() -3 );
escaped = QRegExp::escape(reduced);
- re_string = QString('^' + escaped);
+ re_string = QStringLiteral("^%1").arg(escaped);
}
QRegExp re(re_string);
- // search for the file
- QFileInfo find(file);
- if(find.isAbsolute()) {
- // we have absolute path
- url.setPath(file);
- }
- else {
- // not absolute
- QString name = file;
- name = name.remove(".\\");
- name = name.replace("\\", "/");
- QFileInfo abs(QFileInfo(Tags::getTagsFile()).path()+ '/' + name);
- url.setPath(abs.absoluteFilePath());
- }
-
- //qDebug() << url << pattern;
-
// save current location
TagJump from;
from.url = m_mWin->activeView()->document()->url();
from.cursor = m_mWin->activeView()->cursorPosition();
m_jumpStack.push(from);
- // open/activate the file
- m_mWin->openUrl(url);
+ // open/activate the new file
+ QFileInfo fInfo(file);
+ //qDebug() << pattern << file << fInfo.absoluteFilePath();
+ m_mWin->openUrl(QUrl::fromLocalFile(fInfo.absoluteFilePath()));
// any view active?
if (!m_mWin->activeView()) {
@@ -525,17 +488,20 @@ void KateCTagsView::updateSessionDB()
QString target;
for (int i=0; i<m_ctagsUi.targetList->count(); i++) {
target = m_ctagsUi.targetList->item(i)->text();
- if (target.endsWith('/') || target.endsWith('\\')) {
+ if (target.endsWith(QLatin1Char('/')) || target.endsWith(QLatin1Char('\\'))) {
target = target.left(target.size() - 1);
}
- targets += target + ' ';
+ targets += target + QLatin1Char(' ');
}
+ QString pluginFolder = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1String("/katectags");
+ QDir().mkpath(pluginFolder);
+
if (m_ctagsUi.tagsFile->text().isEmpty()) {
// FIXME we need a way to get the session name
- QString sessionDB = KStandardDirs::locateLocal("appdata", "plugins/katectags/session_db_", true);
- sessionDB += QDateTime::currentDateTime().toString("yyyyMMdd_hhmmss");
- m_ctagsUi.tagsFile->setText(sessionDB);
+ pluginFolder + QLatin1String("/session_db_");
+ pluginFolder += QDateTime::currentDateTime().toString(QStringLiteral("yyyyMMdd_hhmmss"));
+ m_ctagsUi.tagsFile->setText(pluginFolder);
}
if (targets.isEmpty()) {
@@ -543,11 +509,10 @@ void KateCTagsView::updateSessionDB()
return;
}
- QString command = QString("%1 -f %2 %3").arg(m_ctagsUi.cmdEdit->text()).arg(m_ctagsUi.tagsFile->text()).arg(targets);
- m_proc.setShellCommand(command);
- m_proc.setOutputChannelMode(KProcess::SeparateChannels);
- m_proc.start();
+ QString command = QStringLiteral("%1 -f %2 %3").arg(m_ctagsUi.cmdEdit->text()).arg(m_ctagsUi.tagsFile->text()).arg(targets);
+
+ m_proc.start(command);
if(!m_proc.waitForStarted(500)) {
KMessageBox::error(0, i18n("Failed to run \"%1\". exitStatus = %2", command, m_proc.exitStatus()));
@@ -576,11 +541,10 @@ void KateCTagsView::updateDone(int exitCode, QProcess::ExitStatus status)
/******************************************************************/
void KateCTagsView::addTagTarget()
{
- KUrl defDir = m_mWin->activeView()->document()->url().directory();
-
- KFileDialog dialog(defDir, QString(), 0, 0);
- dialog.setMode(KFile::Directory | KFile::Files | KFile::ExistingOnly | KFile::LocalOnly);
-
+ QFileDialog dialog;
+ dialog.setDirectory(m_mWin->activeView()->document()->url().path());
+ dialog.setFileMode(QFileDialog::Directory);
+
// i18n("CTags Database Location"));
if (dialog.exec() != QDialog::Accepted) {
return;
@@ -618,7 +582,7 @@ bool KateCTagsView::eventFilter(QObject *obj, QEvent *event)
if (event->type() == QEvent::KeyPress) {
QKeyEvent *ke = static_cast<QKeyEvent*>(event);
if ((obj == m_toolView) && (ke->key() == Qt::Key_Escape)) {
- mainWindow()->hideToolView(m_toolView);
+ m_mWin->hideToolView(m_toolView);
event->accept();
return true;
}
@@ -635,12 +599,12 @@ void KateCTagsView::resetCMD()
/******************************************************************/
void KateCTagsView::handleEsc(QEvent *e)
{
- if (!mainWindow()) return;
+ if (!m_mWin) return;
QKeyEvent *k = static_cast<QKeyEvent *>(e);
if (k->key() == Qt::Key_Escape && k->modifiers() == Qt::NoModifier) {
if (m_toolView->isVisible()) {
- mainWindow()->hideToolView(m_toolView);
+ m_mWin->hideToolView(m_toolView);
}
}
}
diff --git a/addons/kate/kate-ctags/kate_ctags_view.h b/addons/kate/kate-ctags/kate_ctags_view.h
index bcc0ff9..07ce0b6 100644
--- a/addons/kate/kate-ctags/kate_ctags_view.h
+++ b/addons/kate/kate-ctags/kate_ctags_view.h
@@ -22,45 +22,46 @@
*/
-#include <ktexteditor/view.h>
-#include <ktexteditor/document.h>
+#include <KTextEditor/View>
+#include <KTextEditor/Document>
-#include <kate/plugin.h>
-#include <kate/application.h>
-#include <kate/documentmanager.h>
-#include <kate/mainwindow.h>
-#include <ktexteditor/configpageinterface.h>
+#include <KTextEditor/Application>
+#include <KTextEditor/MainWindow>
+#include <ktexteditor/sessionconfiginterface.h>
-#include <kprocess.h>
-#include <kactionmenu.h>
+#include <QProcess>
+#include <KXMLGUIClient>
#include <QStack>
#include <QTimer>
+#include <KActionMenu>
+#include <QPointer>
#include "tags.h"
#include "ui_kate_ctags.h"
-#define DEFAULT_CTAGS_CMD "ctags -R --c++-types=+px --extra=+q --excmd=pattern --exclude=Makefile --exclude=."
+const static QString DEFAULT_CTAGS_CMD = QLatin1String("ctags -R --c++-types=+px --extra=+q --excmd=pattern --exclude=Makefile --exclude=.");
typedef struct
{
- KUrl url;
+ QUrl url;
KTextEditor::Cursor cursor;
} TagJump;
/******************************************************************/
-class KateCTagsView : public Kate::PluginView, public Kate::XMLGUIClient
+class KateCTagsView : public QObject, public KXMLGUIClient, public KTextEditor::SessionConfigInterface
{
Q_OBJECT
-
+ Q_INTERFACES(KTextEditor::SessionConfigInterface)
+
public:
- KateCTagsView(Kate::MainWindow *mw, const KComponentData& componentData);
+ KateCTagsView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mainWin);
~KateCTagsView();
- // overwritten: read and write session config
- void readSessionConfig (KConfigBase* config, const QString& groupPrefix);
- void writeSessionConfig (KConfigBase* config, const QString& groupPrefix);
+ // reimplemented: read and write session config
+ void readSessionConfig (const KConfigGroup& config);
+ void writeSessionConfig (KConfigGroup& config);
public Q_SLOTS:
void gotoDefinition();
@@ -97,7 +98,7 @@ private:
void jumpToTag(const QString &file, const QString &pattern, const QString &word);
- Kate::MainWindow *m_mWin;
+ KTextEditor::MainWindow *m_mWin;
QWidget *m_toolView;
Ui::kateCtags m_ctagsUi;
@@ -106,7 +107,7 @@ private:
QAction *m_gotoDec;
QAction *m_lookup;
- KProcess m_proc;
+ QProcess m_proc;
QString m_commonDB;
QTimer m_editTimer;
diff --git a/addons/kate/kate-ctags/katectagsplugin.desktop b/addons/kate/kate-ctags/katectagsplugin.desktop
index 43ee99a..9271dbe 100644
--- a/addons/kate/kate-ctags/katectagsplugin.desktop
+++ b/addons/kate/kate-ctags/katectagsplugin.desktop
@@ -1,8 +1,7 @@
[Desktop Entry]
Type=Service
-ServiceTypes=Kate/Plugin
+ServiceTypes=KTextEditor/Plugin
X-KDE-Library=katectagsplugin
-X-Kate-Version=2.9
Name=CTags
Name[bg]=CTags
Name[bs]=C‑tags
diff --git a/addons/kate/kate-ctags/tags.cpp b/addons/kate/kate-ctags/tags.cpp
index c0b03d3..65178e0 100644
--- a/addons/kate/kate-ctags/tags.cpp
+++ b/addons/kate/kate-ctags/tags.cpp
@@ -30,10 +30,10 @@ Tags::TagEntry::TagEntry( const QString & tag, const QString & type, const QStri
bool Tags::hasTag( const QString & tag )
{
ctags::tagFileInfo info;
- ctags::tagFile * file = ctags::tagsOpen( _tagsfile.toLocal8Bit(), &info );
+ ctags::tagFile * file = ctags::tagsOpen( _tagsfile.toLocal8Bit().constData(), &info );
ctags::tagEntry entry;
- bool found = ( ctags::tagsFind( file, &entry, tag.toLocal8Bit(), TAG_FULLMATCH | TAG_OBSERVECASE ) == ctags::TagSuccess );
+ bool found = ( ctags::tagsFind( file, &entry, tag.toLocal8Bit().constData(), TAG_FULLMATCH | TAG_OBSERVECASE ) == ctags::TagSuccess );
ctags::tagsClose( file );
@@ -47,7 +47,7 @@ unsigned int Tags::numberOfMatches( const QString & tagpart, bool partial )
if ( tagpart.isEmpty() ) return 0;
ctags::tagFileInfo info;
- ctags::tagFile * file = ctags::tagsOpen( _tagsfile.toLocal8Bit(), &info );
+ ctags::tagFile * file = ctags::tagsOpen( _tagsfile.toLocal8Bit().constData(), &info );
ctags::tagEntry entry;
QByteArray tagpartBArray = tagpart.toLocal8Bit(); // for holding the char *
@@ -72,7 +72,7 @@ Tags::TagList Tags::getMatches( const QString & tagpart, bool partial, const QSt
if ( tagpart.isEmpty() ) return list;
ctags::tagFileInfo info;
- ctags::tagFile * file = ctags::tagsOpen( _tagsfile.toLocal8Bit(), &info );
+ ctags::tagFile * file = ctags::tagsOpen( _tagsfile.toLocal8Bit().constData(), &info );
ctags::tagEntry entry;
QByteArray tagpartBArray = tagpart.toLocal8Bit(); // for holding the char *
@@ -80,16 +80,16 @@ Tags::TagList Tags::getMatches( const QString & tagpart, bool partial, const QSt
{
do
{
- QString type( CTagsKinds::findKind( entry.kind, QString( entry.file ).section( '.', -1 ) ) );
- QString file( entry.file );
+ QString type( CTagsKinds::findKind( entry.kind, QString::fromLocal8Bit(entry.file).section( QLatin1Char('.') , -1 ) ) );
+ QString file = QString::fromLocal8Bit( entry.file );
- if ( type.isEmpty() && file.endsWith( "Makefile" ) )
+ if ( type.isEmpty() && file.endsWith( QLatin1String("Makefile") ) )
{
- type = "macro";
+ type = QLatin1String("macro");
}
- if ( types.isEmpty() || types.contains( entry.kind ) )
+ if ( types.isEmpty() || types.contains( QString::fromLocal8Bit(entry.kind) ) )
{
- list << TagEntry( QString( entry.name ), type, file, QString( entry.address.pattern ) );
+ list << TagEntry( QString::fromLocal8Bit( entry.name ), type, file, QString::fromLocal8Bit( entry.address.pattern ) );
}
}
while ( ctags::tagsFindNext( file, &entry ) == ctags::TagSuccess );
@@ -102,7 +102,7 @@ Tags::TagList Tags::getMatches( const QString & tagpart, bool partial, const QSt
void Tags::setTagsFile( const QString & file )
{
- _tagsfile = file.toLocal8Bit();
+ _tagsfile = file;
}
QString Tags::getTagsFile( )
@@ -148,6 +148,6 @@ Tags::TagList Tags::getMatches( const QString & file, const QString & tagpart,
return getMatches( tagpart, partial, types);
}
- // kate: space-indent off; indent-width 4; tab-width 4; show-tabs off;
+ // kate: space-indent off; indent-width 4; tab-width 4; show-tabs on;