aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Wenninger <jowenn@kde.org>2014-01-21 17:10:30 (GMT)
committerJoseph Wenninger <jowenn@kde.org>2014-01-21 17:13:52 (GMT)
commit2899f2ab5c2838c6d55737fe51194eb71a0e6977 (patch)
tree62166d68bff5f61b3a7be3fcff77673bdc65a744
parent6ca4ac75590a437f75ebc255f2ba10976f931bf5 (diff)
seems to work with KF5, except for the save/restoreWindowSize of the dialog
-rw-r--r--addons/kate/CMakeLists.txt3
-rw-r--r--addons/kate/close-except-like/CMakeLists.txt26
-rw-r--r--addons/kate/close-except-like/close_confirm_dialog.cpp61
-rw-r--r--addons/kate/close-except-like/close_confirm_dialog.h14
-rw-r--r--addons/kate/close-except-like/close_confirm_dialog.ui107
-rw-r--r--addons/kate/close-except-like/close_except_plugin.cpp123
-rw-r--r--addons/kate/close-except-like/close_except_plugin.h37
-rw-r--r--addons/kate/close-except-like/katecloseexceptplugin.desktop2
8 files changed, 263 insertions, 110 deletions
diff --git a/addons/kate/CMakeLists.txt b/addons/kate/CMakeLists.txt
index e6d6943..f2784f1 100644
--- a/addons/kate/CMakeLists.txt
+++ b/addons/kate/CMakeLists.txt
@@ -30,6 +30,8 @@ ecm_optional_add_subdirectory (xmltools)
ecm_optional_add_subdirectory( openheader )
+ecm_optional_add_subdirectory( close-except-like )
+
if(NOT WIN32)
add_subdirectory( gdbplugin ) # should be tested on windows...
@@ -55,7 +57,6 @@ endif(NOT WIN32)
#add_subdirectory( tabify )
-#add_subdirectory( close-except-like )
#macro_optional_add_subdirectory(pate)
diff --git a/addons/kate/close-except-like/CMakeLists.txt b/addons/kate/close-except-like/CMakeLists.txt
index 87b5b98..e348e96 100644
--- a/addons/kate/close-except-like/CMakeLists.txt
+++ b/addons/kate/close-except-like/CMakeLists.txt
@@ -1,24 +1,38 @@
+project(katecloseexceptplugin)
+
set(VERSION_MAJOR 0)
set(VERSION_MINOR 3)
set(VERSION_PATCH 5)
set(VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
+include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
+
+find_package(KF5 CONFIG REQUIRED COMPONENTS Parts TextEditor XmlGui Notifications)
+
set(KATE_CLOSE_EXCEPT_PLUGIN_SOURCES
close_confirm_dialog.cpp
close_except_plugin.cpp
)
+
+set(KATE_CLOSE_EXCEPT_PLUGIN_UI
+ close_confirm_dialog.ui
+)
+qt5_wrap_ui(KATE_CLOSE_EXCEPT_PLUGIN_SOURCES ${KATE_CLOSE_EXCEPT_PLUGIN_UI})
-kde4_add_plugin(katecloseexceptplugin ${KATE_CLOSE_EXCEPT_PLUGIN_SOURCES})
+add_library(katecloseexceptplugin MODULE ${KATE_CLOSE_EXCEPT_PLUGIN_SOURCES})
target_link_libraries(katecloseexceptplugin
- ${KDE4_KDEUI_LIBS}
- ${KDE4_KFILE_LIBS}
- ktexteditor
- kateinterfaces
+ KF5::TextEditor
+ KF5::Parts
+ KF5::I18n
+ KF5::IconThemes
+ KF5::Notifications
)
configure_file(config.h.in config.h)
install(TARGETS katecloseexceptplugin DESTINATION ${PLUGIN_INSTALL_DIR})
-install(FILES ui.rc DESTINATION ${DATA_INSTALL_DIR}/kate/plugins/katecloseexceptplugin)
+
+kservice_desktop_to_json(katecloseexceptplugin.desktop)
+install(FILES ui.rc DESTINATION ${DATA_INSTALL_DIR}//katecloseexceptplugin)
install(FILES katecloseexceptplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR})
diff --git a/addons/kate/close-except-like/close_confirm_dialog.cpp b/addons/kate/close-except-like/close_confirm_dialog.cpp
index 3dff1be..551b932 100644
--- a/addons/kate/close-except-like/close_confirm_dialog.cpp
+++ b/addons/kate/close-except-like/close_confirm_dialog.cpp
@@ -28,9 +28,14 @@
// Standard includes
#include <KConfig>
#include <KLocalizedString> /// \todo Where is \c i18n() defiend?
-#include <KVBox>
-#include <QtGui/QLabel>
-#include <QtGui/QHeaderView>
+#include <KIconLoader>
+#include <KSharedConfig>
+#include <KConfigGroup>
+#include <QBoxLayout>
+#include <QLabel>
+#include <QHeaderView>
+#include <QPushButton>
+
#include <cassert>
namespace kate { namespace {
@@ -43,7 +48,7 @@ class KateDocItem : public QTreeWidgetItem
, document(doc)
{
setText(0, doc->documentName());
- setText(1, doc->url().prettyUrl());
+ setText(1, doc->url().toString());
setCheckState(0, Qt::Checked);
}
KTextEditor::Document* document;
@@ -55,34 +60,22 @@ CloseConfirmDialog::CloseConfirmDialog(
, KToggleAction* show_confirmation_action
, QWidget* const parent
)
- : KDialog(parent)
+ : QDialog(parent)
, m_docs(docs)
{
assert("Documents container expected to be non empty" && !docs.isEmpty());
-
- setCaption(i18nc("@title:window", "Close files confirmation"));
- setButtons(Ok | Cancel);
+ setupUi(this);
+
+ setWindowTitle(i18nc("@title:window", "Close files confirmation"));
setModal(true);
- setDefaultButton(KDialog::Ok);
-
- KVBox* w = new KVBox(this);
- setMainWidget(w);
- w->setSpacing(KDialog::spacingHint());
+ buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
+
+ icon->setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("dialog-warning"),KIconLoader::Desktop,KIconLoader::SizeLarge));
- KHBox* lo1 = new KHBox(w);
-
- // dialog text
- QLabel* icon = new QLabel(lo1);
- icon->setPixmap(DesktopIcon("dialog-warning"));
-
- QLabel* t = new QLabel(
+ text->setText(
i18nc("@label:listbox", "You are about to close the following documents:")
- , lo1
- );
- lo1->setStretchFactor(t, 1000);
-
- // document list
- m_docs_tree = new QTreeWidget(w);
+ );
+
QStringList headers;
headers << i18nc("@title:column", "Document") << i18nc("@title:column", "Location");
m_docs_tree->setHeaderLabels(headers);
@@ -94,10 +87,10 @@ CloseConfirmDialog::CloseConfirmDialog(
new KateDocItem(m_docs[i], m_docs_tree);
}
m_docs_tree->header()->setStretchLastSection(false);
- m_docs_tree->header()->setResizeMode(0, QHeaderView::ResizeToContents);
- m_docs_tree->header()->setResizeMode(1, QHeaderView::ResizeToContents);
+ m_docs_tree->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
+ m_docs_tree->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
- m_dont_ask_again = new QCheckBox(i18nc("option:check", "Do not ask again"), w);
+ m_dont_ask_again->setText(i18nc("option:check", "Do not ask again"));
// NOTE If we are here, it means that 'Show Confirmation' action is enabled,
// so not needed to read config...
assert("Sanity check" && show_confirmation_action->isChecked());
@@ -107,14 +100,14 @@ CloseConfirmDialog::CloseConfirmDialog(
// Update documents list according checkboxes
connect(this, SIGNAL(accepted()), this, SLOT(updateDocsList()));
- KConfigGroup gcg(KGlobal::config(), "CloseConfirmationDialog");
- restoreDialogSize(gcg); // restore dialog geometry from config
+ KConfigGroup gcg(KSharedConfig::openConfig(), "kate-close-except-like-CloseConfirmationDialog");
+ KWindowConfig::restoreWindowSize(windowHandle(),gcg); // restore dialog geometry from config
}
CloseConfirmDialog::~CloseConfirmDialog()
{
- KConfigGroup gcg(KGlobal::config(), "CloseConfirmationDialog");
- saveDialogSize(gcg); // write dialog geometry to config
+ KConfigGroup gcg(KSharedConfig::openConfig(), "kate-close-except-like-CloseConfirmationDialog");
+ KWindowConfig::saveWindowSize(windowHandle(),gcg); // write dialog geometry to config
gcg.sync();
}
@@ -131,7 +124,7 @@ void CloseConfirmDialog::updateDocsList()
{
KateDocItem* item = static_cast<KateDocItem*>(*it);
m_docs.removeAll(item->document);
- qDebug() << "do not close the file " << item->document->url().prettyUrl();
+ qDebug() << "do not close the file " << item->document->url().toString();
}
}
diff --git a/addons/kate/close-except-like/close_confirm_dialog.h b/addons/kate/close-except-like/close_confirm_dialog.h
index f967c8a..b38092f 100644
--- a/addons/kate/close-except-like/close_confirm_dialog.h
+++ b/addons/kate/close-except-like/close_confirm_dialog.h
@@ -28,13 +28,15 @@
// Project specific includes
// Standard includes
-# include <KDialog>
+# include <QDialog>
# include <KTextEditor/Document>
# include <KToggleAction>
+# include <kwindowconfig.h>
# include <QtCore/QList>
-# include <QtGui/QTreeWidget>
-# include <QtGui/QTreeWidgetItem>
-# include <QtGui/QCheckBox>
+# include <QTreeWidget>
+# include <QTreeWidgetItem>
+# include <QCheckBox>
+# include "ui_close_confirm_dialog.h"
namespace kate {
@@ -44,7 +46,7 @@ namespace kate {
* [More detailed description here]
*
*/
-class CloseConfirmDialog : public KDialog
+class CloseConfirmDialog : public QDialog, public Ui::CloseConfirmDialog
{
Q_OBJECT
public:
@@ -57,8 +59,6 @@ private Q_SLOTS:
private:
QList<KTextEditor::Document*>& m_docs;
- QTreeWidget* m_docs_tree;
- QCheckBox* m_dont_ask_again;
};
} // namespace kate
diff --git a/addons/kate/close-except-like/close_confirm_dialog.ui b/addons/kate/close-except-like/close_confirm_dialog.ui
new file mode 100644
index 0000000..4cac73b
--- /dev/null
+++ b/addons/kate/close-except-like/close_confirm_dialog.ui
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CloseConfirmDialog</class>
+ <widget class="QDialog" name="CloseConfirmDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>668</width>
+ <height>487</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <property name="modal">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="icon">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="text">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QTreeWidget" name="m_docs_tree">
+ <column>
+ <property name="text">
+ <string notr="true">1</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="m_dont_ask_again">
+ <property name="text">
+ <string>CheckBox</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>CloseConfirmDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>CloseConfirmDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/addons/kate/close-except-like/close_except_plugin.cpp b/addons/kate/close-except-like/close_except_plugin.cpp
index ae54f7b..90c82e1 100644
--- a/addons/kate/close-except-like/close_except_plugin.cpp
+++ b/addons/kate/close-except-like/close_except_plugin.cpp
@@ -28,20 +28,23 @@
#include "close_confirm_dialog.h"
// Standard includes
-#include <kate/application.h>
-#include <kate/documentmanager.h>
-#include <kate/mainwindow.h>
+#include <KLocalizedString>
+#include <KTextEditor/Application>
+#include <KTextEditor/MainWindow>
+#include <KTextEditor/Editor>
#include <KAboutData>
#include <KActionCollection>
-#include <KDebug>
#include <KPassivePopup>
#include <KPluginFactory>
#include <KPluginLoader>
#include <KTextEditor/Editor>
#include <QtCore/QFileInfo>
+#include <QUrl>
+#include <kio/global.h>
+#include <KXMLGUIFactory>
-K_PLUGIN_FACTORY(CloseExceptPluginFactory, registerPlugin<kate::CloseExceptPlugin>();)
-K_EXPORT_PLUGIN(
+K_PLUGIN_FACTORY_WITH_JSON(CloseExceptPluginFactory, "katecloseexceptplugin.json",registerPlugin<kate::CloseExceptPlugin>();)
+/*K_EXPORT_PLUGIN(
CloseExceptPluginFactory(
KAboutData(
"katecloseexceptplugin"
@@ -52,7 +55,7 @@ K_EXPORT_PLUGIN(
, KAboutData::License_LGPL_V3
)
)
- )
+ )*/
namespace kate {
//BEGIN CloseExceptPlugin
@@ -60,37 +63,36 @@ CloseExceptPlugin::CloseExceptPlugin(
QObject* application
, const QList<QVariant>&
)
- : Kate::Plugin(static_cast<Kate::Application*>(application), "katecloseexceptplugin")
+ : KTextEditor::Plugin(application)
{
}
-Kate::PluginView* CloseExceptPlugin::createView(Kate::MainWindow* parent)
+QObject* CloseExceptPlugin::createView(KTextEditor::MainWindow* parent)
{
- return new CloseExceptPluginView(parent, CloseExceptPluginFactory::componentData(), this);
+ return new CloseExceptPluginView(parent, this);
}
-void CloseExceptPlugin::readSessionConfig(KConfigBase* config, const QString& groupPrefix)
+void CloseExceptPlugin::readSessionConfig(const KConfigGroup& config)
{
- KConfigGroup scg(config, groupPrefix + "menu");
- m_show_confirmation_needed = scg.readEntry("ShowConfirmation", true);
+ const KConfigGroup scg(&config, QStringLiteral("menu"));
+ m_show_confirmation_needed = scg.readEntry(QStringLiteral("ShowConfirmation"), true);
}
-void CloseExceptPlugin::writeSessionConfig(KConfigBase* config, const QString& groupPrefix)
+void CloseExceptPlugin::writeSessionConfig(KConfigGroup& config)
{
- KConfigGroup scg(config, groupPrefix + "menu");
- scg.writeEntry("ShowConfirmation", m_show_confirmation_needed);
+ KConfigGroup scg(&config, QStringLiteral("menu"));
+ scg.writeEntry(QStringLiteral("ShowConfirmation"), m_show_confirmation_needed);
scg.sync();
}
//END CloseExceptPlugin
//BEGIN CloseExceptPluginView
CloseExceptPluginView::CloseExceptPluginView(
- Kate::MainWindow* mw
- , const KComponentData& data
+ KTextEditor::MainWindow* mw
, CloseExceptPlugin* plugin
)
- : Kate::PluginView(mw)
- , Kate::XMLGUIClient(data)
+ : QObject(mw)
+ , KXMLGUIClient()
, m_plugin(plugin)
, m_show_confirmation_action(new KToggleAction(i18nc("@action:inmenu", "Show Confirmation"), this))
, m_except_menu(new KActionMenu(
@@ -101,13 +103,17 @@ CloseExceptPluginView::CloseExceptPluginView(
i18nc("@action:inmenu close docs like the following...", "Close Like")
, this
))
-{
- actionCollection()->addAction("file_close_except", m_except_menu);
- actionCollection()->addAction("file_close_like", m_like_menu);
+ , m_mainWindow(mw)
+{
+ KXMLGUIClient::setComponentName (QStringLiteral("katecloseexceptplugin"), i18n("Close Except/Like Plugin"));
+ setXMLFile( QStringLiteral("ui.rc") );
+
+ actionCollection()->addAction(QStringLiteral("file_close_except"), m_except_menu);
+ actionCollection()->addAction(QStringLiteral("file_close_like"), m_like_menu);
// Subscribe self to document creation
connect(
- m_plugin->application()->editor()
+ KTextEditor::Editor::instance()
, SIGNAL(documentCreated(KTextEditor::Editor*, KTextEditor::Document*))
, this
, SLOT(documentCreated(KTextEditor::Editor*, KTextEditor::Document*))
@@ -122,7 +128,7 @@ CloseExceptPluginView::CloseExceptPluginView(
);
//
connect(
- mainWindow()
+ m_mainWindow
, SIGNAL(viewCreated(KTextEditor::View*))
, this
, SLOT(viewCreated(KTextEditor::View*))
@@ -130,12 +136,12 @@ CloseExceptPluginView::CloseExceptPluginView(
// Fill menu w/ currently opened document masks/groups
updateMenu();
- mainWindow()->guiFactory()->addClient(this);
+ m_mainWindow->guiFactory()->addClient(this);
}
CloseExceptPluginView::~CloseExceptPluginView()
{
- mainWindow()->guiFactory()->removeClient(this);
+ m_mainWindow->guiFactory()->removeClient(this);
}
void CloseExceptPluginView::viewCreated(KTextEditor::View* view)
@@ -179,16 +185,33 @@ void CloseExceptPluginView::updateMenuSlotStub(KTextEditor::Document*)
}
void CloseExceptPluginView::appendActionsFrom(
- const std::set<QString>& paths
+ const std::set<QUrl>& paths
, actions_map_type& actions
, KActionMenu* menu
, QSignalMapper* mapper
)
{
- Q_FOREACH(const QString& path, paths)
+ Q_FOREACH(const QUrl& path, paths)
{
- QString action = path.startsWith('*') ? path : path + '*';
- actions[action] = QPointer<KAction>(new KAction(action, menu));
+ QString action = path.path() + QLatin1Char('*');
+ actions[action] = QPointer<QAction>(new QAction(action, menu));
+ menu->addAction(actions[action]);
+ connect(actions[action], SIGNAL(triggered()), mapper, SLOT(map()));
+ mapper->setMapping(actions[action], action);
+ }
+}
+
+void CloseExceptPluginView::appendActionsFrom(
+ const std::set<QString>& masks
+ , actions_map_type& actions
+ , KActionMenu* menu
+ , QSignalMapper* mapper
+ )
+{
+ Q_FOREACH(const QString& mask, masks)
+ {
+ QString action = mask.startsWith(QLatin1Char('*')) ? mask : mask + QLatin1Char('*');
+ actions[action] = QPointer<QAction>(new QAction(action, menu));
menu->addAction(actions[action]);
connect(actions[action], SIGNAL(triggered()), mapper, SLOT(map()));
mapper->setMapping(actions[action], action);
@@ -196,7 +219,7 @@ void CloseExceptPluginView::appendActionsFrom(
}
QPointer<QSignalMapper> CloseExceptPluginView::updateMenu(
- const std::set<QString>& paths
+ const std::set<QUrl>& paths
, const std::set<QString>& masks
, actions_map_type& actions
, KActionMenu* menu
@@ -228,7 +251,7 @@ QPointer<QSignalMapper> CloseExceptPluginView::updateMenu(
void CloseExceptPluginView::updateMenu()
{
- const QList<KTextEditor::Document*>& docs = m_plugin->application()->documentManager()->documents();
+ const QList<KTextEditor::Document*>& docs = KTextEditor::Editor::instance()->application()->documents();
if (docs.size() < 2)
{
qDebug() << "No docs r (or the only) opened right now --> disable menu";
@@ -241,15 +264,16 @@ void CloseExceptPluginView::updateMenu()
else
{
// Iterate over documents and form a set of candidates
- typedef std::set<QString> paths_set_type;
+ typedef std::set<QUrl> paths_set_type;
+ typedef std::set<QString> paths_set_type_masks;
paths_set_type doc_paths;
- paths_set_type masks;
+ paths_set_type_masks masks;
Q_FOREACH(KTextEditor::Document* document, docs)
{
const QString& ext = QFileInfo(document->url().path()).completeSuffix();
if (!ext.isEmpty())
- masks.insert("*." + ext);
- doc_paths.insert(document->url().upUrl().path());
+ masks.insert(QStringLiteral("*.") + ext);
+ doc_paths.insert(KIO::upUrl(document->url()));
}
paths_set_type paths = doc_paths;
qDebug() << "stage #1: Collected" << paths.size() << "paths and" << masks.size() << "masks";
@@ -257,18 +281,18 @@ void CloseExceptPluginView::updateMenu()
for (paths_set_type::iterator it = doc_paths.begin(), last = doc_paths.end(); it != last; ++it)
{
for (
- KUrl url = *it
- ; url.hasPath() && url.path() != "/"
- ; url = url.upUrl()
+ QUrl url = *it
+ ; (!url.path().isEmpty()) && url.path() != QStringLiteral("/")
+ ; url = KIO::upUrl(url)
)
{
paths_set_type::iterator not_it = it;
for (++not_it; not_it != last; ++not_it)
- if (!not_it->startsWith(url.path()))
+ if (!not_it->path().startsWith(url.path()))
break;
if (not_it == last)
{
- paths.insert(url.path());
+ paths.insert(url);
break;
}
}
@@ -284,22 +308,23 @@ void CloseExceptPluginView::updateMenu()
void CloseExceptPluginView::close(const QString& item, const bool close_if_match)
{
+ QChar asterisk=QLatin1Char('*');
assert(
"Parameter seems invalid! Is smth has changed in the code?"
- && !item.isEmpty() && (item[0] == '*' || item[item.size() - 1] == '*')
+ && !item.isEmpty() && (item[0] == asterisk || item[item.size() - 1] == asterisk)
);
- const bool is_path = item[0] != '*';
+ const bool is_path = item[0] != asterisk;
const QString mask = is_path ? item.left(item.size() - 1) : item;
qDebug() << "Going to close items [" << close_if_match << "/" << is_path << "]: " << mask;
QList<KTextEditor::Document*> docs2close;
- const QList<KTextEditor::Document*>& docs = m_plugin->application()->documentManager()->documents();
+ const QList<KTextEditor::Document*>& docs = KTextEditor::Editor::instance()->application()->documents();
Q_FOREACH(KTextEditor::Document* document, docs)
{
- const QString& path = document->url().upUrl().path();
+ const QString& path = KIO::upUrl(document->url()).path();
/// \note Take a dot in account, so \c *.c would not match for \c blah.kcfgc
- const QString& ext = '.' + QFileInfo(document->url().fileName()).completeSuffix();
+ const QString& ext = QLatin1Char('.') + QFileInfo(document->url().fileName()).completeSuffix();
const bool match = (!is_path && mask.endsWith(ext))
|| (is_path && path.startsWith(mask))
;
@@ -334,7 +359,7 @@ void CloseExceptPluginView::close(const QString& item, const bool close_if_match
else
{
// Close 'em all!
- m_plugin->application()->documentManager()->closeDocumentList(docs2close);
+ KTextEditor::Editor::instance()->application()->closeDocuments(docs2close);
updateMenu();
KPassivePopup::message(
i18nc("@title:window", "Done")
@@ -347,4 +372,6 @@ void CloseExceptPluginView::close(const QString& item, const bool close_if_match
//END CloseExceptPluginView
} // namespace kate
+#include "close_except_plugin.moc"
+
// kate: hl C++11/Qt4;
diff --git a/addons/kate/close-except-like/close_except_plugin.h b/addons/kate/close-except-like/close_except_plugin.h
index fa42d60..93f4be8 100644
--- a/addons/kate/close-except-like/close_except_plugin.h
+++ b/addons/kate/close-except-like/close_except_plugin.h
@@ -28,16 +28,20 @@
// Project specific includes
// Standard includes
-# include <kate/plugin.h>
+# include <KTextEditor/Editor>
+# include <KTextEditor/Plugin>
+# include <ktexteditor/sessionconfiginterface.h>
# include <ktexteditor/configpageinterface.h>
# include <KActionMenu>
# include <KTextEditor/Document>
# include <KTextEditor/View>
# include <KToggleAction>
+# include <KConfigGroup>
# include <QtCore/QSignalMapper>
+# include <QPointer>
# include <cassert>
# include <set>
-
+
namespace kate {
class CloseExceptPlugin; // forward declaration
@@ -45,15 +49,15 @@ class CloseExceptPlugin; // forward declarati
* \brief Plugin to close docs grouped by extension or location
*/
class CloseExceptPluginView
- : public Kate::PluginView
- , public Kate::XMLGUIClient
+ : public QObject
+ , public KXMLGUIClient
{
Q_OBJECT
- typedef QMap<QString, QPointer<KAction> > actions_map_type;
+ typedef QMap<QString, QPointer<QAction> > actions_map_type;
public:
/// Default constructor
- CloseExceptPluginView(Kate::MainWindow*, const KComponentData&, CloseExceptPlugin*);
+ CloseExceptPluginView(KTextEditor::MainWindow*, CloseExceptPlugin*);
/// Destructor
~CloseExceptPluginView();
@@ -75,17 +79,23 @@ private:
void connectToDocument(KTextEditor::Document*);
void updateMenu();
QPointer<QSignalMapper> updateMenu(
- const std::set<QString>&
+ const std::set<QUrl>&
, const std::set<QString>&
, actions_map_type&
, KActionMenu*
);
void appendActionsFrom(
- const std::set<QString>&
+ const std::set<QUrl>&
, actions_map_type&
, KActionMenu*
, QSignalMapper*
);
+ void appendActionsFrom(
+ const std::set<QString>& masks
+ , actions_map_type& actions
+ , KActionMenu* menu
+ , QSignalMapper* mapper
+ );
CloseExceptPlugin* m_plugin;
QPointer<KToggleAction> m_show_confirmation_action;
@@ -95,26 +105,27 @@ private:
QPointer<QSignalMapper> m_like_mapper;
actions_map_type m_except_actions;
actions_map_type m_like_actions;
+ KTextEditor::MainWindow *m_mainWindow;
};
/**
* \brief Plugin view class
*/
-class CloseExceptPlugin : public Kate::Plugin
+class CloseExceptPlugin : public KTextEditor::Plugin, public KTextEditor::SessionConfigInterface
{
Q_OBJECT
-
+ Q_INTERFACES(KTextEditor::SessionConfigInterface)
public:
/// Default constructor
CloseExceptPlugin(QObject* = 0, const QList<QVariant>& = QList<QVariant>());
/// Destructor
virtual ~CloseExceptPlugin() {}
/// Create a new view of this plugin for the given main window
- Kate::PluginView* createView(Kate::MainWindow*);
+ QObject* createView(KTextEditor::MainWindow*);
/// \name Plugin interface implementation
//@{
- void readSessionConfig(KConfigBase*, const QString&);
- void writeSessionConfig(KConfigBase*, const QString&);
+ void readSessionConfig(const KConfigGroup&);
+ void writeSessionConfig(KConfigGroup&);
//@}
bool showConfirmationNeeded() const
{
diff --git a/addons/kate/close-except-like/katecloseexceptplugin.desktop b/addons/kate/close-except-like/katecloseexceptplugin.desktop
index 490eedf..562b3ef 100644
--- a/addons/kate/close-except-like/katecloseexceptplugin.desktop
+++ b/addons/kate/close-except-like/katecloseexceptplugin.desktop
@@ -1,7 +1,7 @@
[Desktop Entry]
Encoding=UTF-8
Type=Service
-ServiceTypes=Kate/Plugin
+ServiceTypes=KTextEditor/Plugin
X-KDE-Library=katecloseexceptplugin
X-KDE-Version=4.0
X-Kate-Version=2.9