Commit 9791b8e8 authored by Christoph Cullmann's avatar Christoph Cullmann

try to get filetree plugin up and running ;) not working ATM

parent f051e7fe
......@@ -6,7 +6,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/interfaces)
add_subdirectory( interfaces/kate )
add_subdirectory( app )
#add_subdirectory( filetree )
add_subdirectory( filetree )
add_subdirectory( data )
......
......@@ -3,21 +3,19 @@ project(katefiletreeplugin)
set(katefiletreeplugin_PART_SRCS katefiletreeplugin.cpp katefiletree.cpp katefiletreemodel.cpp katefiletreeproxymodel.cpp katefiletreeconfigpage.cpp katefiletreepluginsettings.cpp )
if(NOT KDE4_FOUND)
find_package(KDE4 REQUIRED)
include_directories( ${KDE4_INCLUDES} ${QT_INCLUDES} )
endif(NOT KDE4_FOUND)
include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
kde4_add_plugin(katefiletreeplugin ${katefiletreeplugin_PART_SRCS})
target_link_libraries(katefiletreeplugin ${KDE4_KFILE_LIBS} ${KDE4_KPARTS_LIBS} kateinterfaces ${KDE4_KTEXTEDITOR_LIBS} )
add_library (katefiletreeplugin MODULE ${katefiletreeplugin_PART_SRCS})
target_link_libraries(katefiletreeplugin kateinterfaces ktexteditor
KF5::KParts
KF5::KDE4Support
KF5::KNewStuff Qt5::Script KF5::SonnetCore KF5::KArchive KF5::KCMUtils KF5::KPrintUtils KF5::ItemViews)
install(TARGETS katefiletreeplugin DESTINATION ${PLUGIN_INSTALL_DIR} )
kservice_desktop_to_json (katefiletreeplugin.desktop)
########### install files ###############
install( FILES ui.rc DESTINATION ${DATA_INSTALL_DIR}/kate/plugins/filetree )
install( FILES katefiletreeplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
install( FILES ui.rc DESTINATION ${DATA_INSTALL_DIR}/kate/plugins/filetree )
\ No newline at end of file
......@@ -33,9 +33,10 @@
#include <KOpenWithDialog>
#include <KRun>
#include <KMessageBox>
#include <klocalizedstring.h>
#include <QtGui/QMenu>
#include <QtGui/QContextMenuEvent>
#include <QMenu>
#include <QContextMenuEvent>
#include <kicon.h>
#include <kdebug.h>
#include <qapplication.h>
......
......@@ -46,6 +46,7 @@ view needs to pull default settings from the main plugin config
#include <QVBoxLayout>
#include <KLocale>
#include <QCheckBox>
#include <klocalizedstring.h>
KateFileTreeConfigPage::KateFileTreeConfigPage( QWidget* parent, KateFileTreePlugin *fl )
: Kate::PluginConfigPage( parent ),
......
......@@ -25,6 +25,7 @@
#include <KColorScheme>
#include <KColorUtils>
#include <klocale.h>
#include <klocalizedstring.h>
#include <ktexteditor/document.h>
......@@ -59,8 +60,8 @@ class ProxyItem {
QString documentName();
void setPath(const QString &str);
void setIcon(KIcon i);
KIcon icon();
void setIcon(QIcon i);
QIcon icon();
QList<ProxyItem*> &children();
......@@ -84,7 +85,7 @@ class ProxyItem {
Flags m_flags;
QString m_display;
KIcon m_icon;
QIcon m_icon;
KTextEditor::Document *m_doc;
QString m_host;
protected:
......@@ -214,7 +215,7 @@ int ProxyItem::row()
return m_row;
}
KIcon ProxyItem::icon()
QIcon ProxyItem::icon()
{
if(m_children.count())
return KIcon("folder");
......@@ -222,7 +223,7 @@ KIcon ProxyItem::icon()
return m_icon;
}
void ProxyItem::setIcon(KIcon i)
void ProxyItem::setIcon(QIcon i)
{
m_icon = i;
}
......@@ -473,7 +474,7 @@ QVariant KateFileTreeModel::data( const QModelIndex &index, int role ) const
switch(role) {
case KateFileTreeModel::PathRole:
// allow to sort with hostname + path, bug 271488
return (item->doc() && !item->doc()->url().isEmpty()) ? item->doc()->url().pathOrUrl() : item->path();
return (item->doc() && !item->doc()->url().isEmpty()) ? item->doc()->url().toString() : item->path();
case KateFileTreeModel::DocumentRole:
return QVariant::fromValue(item->doc());
......
......@@ -19,7 +19,6 @@
//BEGIN Includes
#include "katefiletreeplugin.h"
#include "katefiletreeplugin.moc"
#include "katefiletree.h"
#include "katefiletreemodel.h"
#include "katefiletreeproxymodel.h"
......@@ -35,6 +34,7 @@
#include <KAction>
#include <KActionCollection>
#include <klocalizedstring.h>
#include <KConfigGroup>
......@@ -44,8 +44,9 @@
//END Includes
K_PLUGIN_FACTORY(KateFileTreeFactory, registerPlugin<KateFileTreePlugin>();)
K_EXPORT_PLUGIN(KateFileTreeFactory(KAboutData("filetree","katefiletreeplugin",ki18n("Document Tree"), "0.1", ki18n("Show open documents in a tree"), KAboutData::License_LGPL_V2)) )
K_PLUGIN_FACTORY_WITH_JSON (KateFileTreeFactory, "katefiletreeplugin.json", registerPlugin<KateFileTreePlugin>();)
//K_EXPORT_PLUGIN(KateFileTreeFactory(KAboutData("filetree","katefiletreeplugin",ki18n("Document Tree"), "0.1", ki18n("Show open documents in a tree"), KAboutData::License_LGPL_V2)) )
//BEGIN KateFileTreePlugin
KateFileTreePlugin::KateFileTreePlugin(QObject* parent, const QList<QVariant>&)
......@@ -168,7 +169,7 @@ void KateFileTreePlugin::applyConfig(bool shadingEnabled, QColor viewShade, QCol
//BEGIN KateFileTreePluginView
KateFileTreePluginView::KateFileTreePluginView (Kate::MainWindow *mainWindow, KateFileTreePlugin *plug)
: Kate::PluginView (mainWindow), Kate::XMLGUIClient(KateFileTreeFactory::componentData()), m_plug(plug)
: Kate::PluginView (mainWindow), Kate::XMLGUIClient("filetree"), m_plug(plug)
{
// init console
kDebug(debugArea()) << "BEGIN: mw:" << mainWindow;
......@@ -218,7 +219,7 @@ KateFileTreePluginView::KateFileTreePluginView (Kate::MainWindow *mainWindow, Ka
connect(mainWindow, SIGNAL(viewChanged()), this, SLOT(viewChanged()));
KAction *show_active = actionCollection()->addAction("filetree_show_active_document", mainWindow);
QAction *show_active = actionCollection()->addAction("filetree_show_active_document", mainWindow);
show_active->setText(i18n("&Show Active"));
show_active->setIcon(KIcon("folder-sync"));
connect( show_active, SIGNAL(triggered(bool)), this, SLOT(showActiveDocument()) );
......@@ -515,4 +516,6 @@ bool KateFileTreeCommand::help(KTextEditor::View * /*view*/, const QString &cmd,
}
//END KateFileTreeCommand
#include "katefiletreeplugin.moc"
// kate: space-indent on; indent-width 2; replace-tabs on;
......@@ -20,6 +20,7 @@
#define KATE_FILETREE_PLUGIN_SETTINGS_H
#include <KConfigGroup>
#include <QColor>
// Geh, should make this into a proper class, setters and getters.
class KateFileTreePluginSettings
......
......@@ -20,6 +20,7 @@
#include "katefiletreemodel.h"
#include "katefiletreedebug.h"
#include <QCollator>
#include <kstringhandler.h>
#include <ktexteditor/document.h>
......@@ -42,17 +43,20 @@ bool KateFileTreeProxyModel::lessThan(const QModelIndex &left, const QModelIndex
return ((left_isdir - right_isdir)) > 0;
}
QCollator collate;
collate.setCaseSensitivity (Qt::CaseInsensitive);
switch(sortRole()) {
case Qt::DisplayRole: {
QString left_name = model->data(left).toString();
QString right_name = model->data(right).toString();
return KStringHandler::naturalCompare(left_name, right_name, Qt::CaseInsensitive) < 0;
return collate.compare(left_name, right_name) < 0;
}
case KateFileTreeModel::PathRole: {
QString left_name = model->data(left, KateFileTreeModel::PathRole).toString();
QString right_name = model->data(right, KateFileTreeModel::PathRole).toString();
return KStringHandler::naturalCompare(left_name, right_name, Qt::CaseInsensitive) < 0;
return collate.compare(left_name, right_name) < 0;
}
case KateFileTreeModel::OpeningOrderRole:
......
......@@ -120,17 +120,17 @@ namespace Kate
XMLGUIClient::XMLGUIClient(const KComponentData &componentData)
XMLGUIClient::XMLGUIClient(const QString &componentName)
: KXMLGUIClient()
{
// FIXME KF5 setComponentData (componentData);
setXMLFile( xmlDataFile( componentData, "ui.rc" ));
setLocalXMLFile( localXmlDataFile( componentData, "ui.rc" ));
setXMLFile( xmlDataFile( componentName, "ui.rc" ));
setLocalXMLFile( localXmlDataFile( componentName, "ui.rc" ));
}
QString XMLGUIClient::xmlDataFile(const KComponentData &componentData, const QString &filename)
QString XMLGUIClient::xmlDataFile(const QString &componentName, const QString &filename)
{
const QString filter = "kate/plugins/" + componentData.componentName() + '/' + filename;
const QString filter = "kate/plugins/" + componentName + '/' + filename;
const QStringList allFiles = KGlobal::dirs()->findAllResources("data", filter);
QString file;
QString doc;
......@@ -139,9 +139,9 @@ namespace Kate
return file;
}
QString XMLGUIClient::localXmlDataFile(const KComponentData &componentData, const QString &filename)
QString XMLGUIClient::localXmlDataFile(const QString &componentName, const QString &filename)
{
QString result = KStandardDirs::locateLocal( "data", "kate/plugins/" + componentData.componentName() + QDir::separator() + filename);
QString result = KStandardDirs::locateLocal( "data", "kate/plugins/" + componentName + QDir::separator() + filename);
kDebug(13000) << "File for shortcut storage" << result;
return result;
}
......
......@@ -311,11 +311,11 @@ namespace Kate
class KATEINTERFACES_EXPORT XMLGUIClient : public KXMLGUIClient
{
public:
explicit XMLGUIClient(const KComponentData& componentData);
explicit XMLGUIClient(const QString &componentName);
private:
QString xmlDataFile(const KComponentData &componentData, const QString &filename);
QString localXmlDataFile(const KComponentData &componentData, const QString &filename);
QString xmlDataFile(const QString &componentName, const QString &filename);
QString localXmlDataFile(const QString &componentName, const QString &filename);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment