Commit 82d1b8da authored by Christoph Cullmann's avatar Christoph Cullmann

filebrowser is back

parent 078c08d1
......@@ -19,13 +19,15 @@ ecm_optional_add_subdirectory (backtracebrowser)
# kate sql
ecm_optional_add_subdirectory (katesql)
# file browser
ecm_optional_add_subdirectory (filebrowser)
#if(NOT WIN32)
# add_subdirectory( gdbplugin ) # reading /proc/...
#endif(NOT WIN32)
#add_subdirectory( textfilter )
#ecm_optional_add_subdirectory ( filebrowser )
#add_subdirectory( mailfiles )
#add_subdirectory( tabbarextension )
......
project(katefilebrowserplugin)
# Load the frameworks we need
#find_package(KF5 CONFIG REQUIRED COMPONENTS ItemModels)
include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
set(katefilebrowserplugin_PART_SRCS
......@@ -14,7 +11,7 @@ set(katefilebrowserplugin_PART_SRCS
add_library(katefilebrowserplugin MODULE ${katefilebrowserplugin_PART_SRCS})
target_link_libraries(katefilebrowserplugin kateinterfaces KF5::KIOCore KF5::KIOWidgets)
target_link_libraries(katefilebrowserplugin KF5::TextEditor KF5::KIOCore KF5::KIOFileWidgets KF5::KIOWidgets KF5::I18n)
install(TARGETS katefilebrowserplugin DESTINATION ${PLUGIN_INSTALL_DIR} )
......
......@@ -26,6 +26,7 @@
#include <kdiroperator.h>
#include <QStandardPaths>
#include <QMenu>
KateBookmarkHandler::KateBookmarkHandler( KateFileBrowser *parent, QMenu* kpopupmenu )
: QObject( parent ),
......@@ -33,15 +34,15 @@ KateBookmarkHandler::KateBookmarkHandler( KateFileBrowser *parent, QMenu* kpopup
mParent( parent ),
m_menu( kpopupmenu )
{
setObjectName( "KateBookmarkHandler" );
setObjectName( QLatin1String ("KateBookmarkHandler") );
if (!m_menu)
m_menu = new QMenu( parent);
QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kate/fsbookmarks.xml");
QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("kate/fsbookmarks.xml"));
if ( file.isEmpty() )
file = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/kate/fsbookmarks.xml";
file = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/kate/fsbookmarks.xml");
KBookmarkManager *manager = KBookmarkManager::managerForFile( file, "kate" );
KBookmarkManager *manager = KBookmarkManager::managerForFile( file, QLatin1String("kate") );
manager->setUpdate( true );
m_bookmarkMenu = new KBookmarkMenu( manager, this, m_menu, parent->actionCollection() );
......
......@@ -51,12 +51,12 @@
//END Includes
KateFileBrowser::KateFileBrowser(Kate::MainWindow *mainWindow,
QWidget * parent, const char * name)
KateFileBrowser::KateFileBrowser(KTextEditor::MainWindow *mainWindow,
QWidget * parent, const char *name)
: QWidget (parent)
, m_mainWindow(mainWindow)
{
setObjectName(name);
setObjectName( QLatin1String (name) );
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->setMargin(0);
......@@ -85,7 +85,7 @@ KateFileBrowser::KateFileBrowser(Kate::MainWindow *mainWindow,
// Mime filter for the KDirOperator
QStringList filter;
filter << "text/plain" << "text/html" << "inode/directory";
filter << QLatin1String("text/plain") << QLatin1String("text/html") << QLatin1String("inode/directory");
m_dirOperator->setNewFileMenuSupportedMimeTypes(filter);
setFocusProxy(m_dirOperator);
......@@ -140,7 +140,7 @@ void KateFileBrowser::setupToolbar()
KConfigGroup config(KSharedConfig::openConfig(), "filebrowser");
QStringList actions = config.readEntry( "toolbar actions", QStringList() );
if ( actions.isEmpty() ) // default toolbar
actions << "back" << "forward" << "bookmarks" << "sync_dir" << "configure";
actions << QLatin1String("back") << QLatin1String("forward") << QLatin1String("bookmarks") << QLatin1String("sync_dir") << QLatin1String("configure");
// remove all actions from the toolbar (there should be none)
m_toolbar->clear();
......@@ -150,7 +150,7 @@ void KateFileBrowser::setupToolbar()
{
QAction *ac = 0;
if (it.isEmpty()) continue;
if (it == "bookmarks" || it == "sync_dir" || it == "configure")
if (it == QLatin1String("bookmarks") || it == QLatin1String("sync_dir") || it == QLatin1String("configure"))
ac = actionCollection()->action(it);
else
ac = m_dirOperator->actionCollection()->action(it);
......@@ -160,26 +160,22 @@ void KateFileBrowser::setupToolbar()
}
}
void KateFileBrowser::readSessionConfig(KConfigBase *config, const QString & name)
void KateFileBrowser::readSessionConfig (const KConfigGroup& cg)
{
KConfigGroup cgDir(config, name + ":dir");
m_dirOperator->readConfig(cgDir);
m_dirOperator->readConfig(cg);
m_dirOperator->setView(KFile::Default);
KConfigGroup cg(config, name);
m_urlNavigator->setLocationUrl(cg.readPathEntry("location", QDir::homePath()));
setDir(cg.readPathEntry("location", QDir::homePath()));
m_urlNavigator->setLocationUrl(cg.readEntry("location", QUrl::fromLocalFile (QDir::homePath())));
setDir(cg.readEntry("location", QUrl::fromLocalFile (QDir::homePath())));
m_autoSyncFolder->setChecked(cg.readEntry("auto sync folder", false));
m_filter->setHistoryItems(cg.readEntry("filter history", QStringList()), true);
}
void KateFileBrowser::writeSessionConfig(KConfigBase *config, const QString & name)
void KateFileBrowser::writeSessionConfig (KConfigGroup& cg)
{
KConfigGroup cgDir(config, name + ":dir");
m_dirOperator->writeConfig(cgDir);
m_dirOperator->writeConfig(cg);
KConfigGroup cg = KConfigGroup(config, name);
cg.writePathEntry("location", m_urlNavigator->locationUrl().url());
cg.writeEntry("location", m_urlNavigator->locationUrl().url());
cg.writeEntry("auto sync folder", m_autoSyncFolder->isChecked());
cg.writeEntry("filter history", m_filter->historyItems());
}
......@@ -191,7 +187,7 @@ void KateFileBrowser::writeSessionConfig(KConfigBase *config, const QString & na
void KateFileBrowser::slotFilterChange(const QString & nf)
{
QString f = nf.trimmed();
const bool empty = f.isEmpty() || f == "*";
const bool empty = f.isEmpty() || f == QLatin1String("*");
if (empty) {
m_dirOperator->clearFilter();
......@@ -220,7 +216,7 @@ void KateFileBrowser::setDir(QUrl u)
else
newurl = u;
newurl.setPath(newurl.path() + '/');
newurl.setPath(newurl.path() + QLatin1Char('/'));
if (!kateFileSelectorIsReadable(newurl)) {
newurl.setPath(newurl.path() + QLatin1String("../"));
......@@ -308,7 +304,7 @@ QUrl KateFileBrowser::activeDocumentUrl()
void KateFileBrowser::setupActions()
{
// bookmarks action!
KActionMenu *acmBookmarks = new KActionMenu(QIcon::fromTheme("bookmarks"), i18n("Bookmarks"), this);
KActionMenu *acmBookmarks = new KActionMenu(QIcon::fromTheme(QLatin1String("bookmarks")), i18n("Bookmarks"), this);
acmBookmarks->setDelayed(false);
m_bookmarkHandler = new KateBookmarkHandler(this, acmBookmarks->menu());
acmBookmarks->setShortcutContext(Qt::WidgetWithChildrenShortcut);
......@@ -317,31 +313,31 @@ void KateFileBrowser::setupActions()
QAction* syncFolder = new QAction(this);
syncFolder->setShortcutContext(Qt::WidgetWithChildrenShortcut);
syncFolder->setText(i18n("Current Document Folder"));
syncFolder->setIcon(QIcon::fromTheme("system-switch-user"));
syncFolder->setIcon(QIcon::fromTheme(QLatin1String("system-switch-user")));
connect(syncFolder, SIGNAL(triggered()), this, SLOT(setActiveDocumentDir()));
m_actionCollection->addAction("sync_dir", syncFolder);
m_actionCollection->addAction("bookmarks", acmBookmarks);
m_actionCollection->addAction(QLatin1String("sync_dir"), syncFolder);
m_actionCollection->addAction(QLatin1String("bookmarks"), acmBookmarks);
// section for settings menu
KActionMenu *optionsMenu = new KActionMenu(QIcon::fromTheme("configure"), i18n("Options"), this);
KActionMenu *optionsMenu = new KActionMenu(QIcon::fromTheme(QLatin1String("configure")), i18n("Options"), this);
optionsMenu->setDelayed(false);
optionsMenu->addAction(m_dirOperator->actionCollection()->action("short view"));
optionsMenu->addAction(m_dirOperator->actionCollection()->action("detailed view"));
optionsMenu->addAction(m_dirOperator->actionCollection()->action("tree view"));
optionsMenu->addAction(m_dirOperator->actionCollection()->action("detailed tree view"));
optionsMenu->addAction(m_dirOperator->actionCollection()->action(QLatin1String("short view")));
optionsMenu->addAction(m_dirOperator->actionCollection()->action(QLatin1String("detailed view")));
optionsMenu->addAction(m_dirOperator->actionCollection()->action(QLatin1String("tree view")));
optionsMenu->addAction(m_dirOperator->actionCollection()->action(QLatin1String("detailed tree view")));
optionsMenu->addSeparator();
optionsMenu->addAction(m_dirOperator->actionCollection()->action("show hidden"));
optionsMenu->addAction(m_dirOperator->actionCollection()->action(QLatin1String("show hidden")));
// action for synchronising the dir operator with the current document path
m_autoSyncFolder = new QAction(this);
m_autoSyncFolder->setCheckable(true);
m_autoSyncFolder->setText(i18n("Automatically synchronize with current document"));
m_autoSyncFolder->setIcon(QIcon::fromTheme("system-switch-user"));
m_autoSyncFolder->setIcon(QIcon::fromTheme(QLatin1String("system-switch-user")));
connect(m_autoSyncFolder, SIGNAL(triggered()), this, SLOT(autoSyncFolder()));
optionsMenu->addAction(m_autoSyncFolder);
m_actionCollection->addAction("configure", optionsMenu);
m_actionCollection->addAction(QLatin1String("configure"), optionsMenu);
//
// Remove all shortcuts due to shortcut clashes (e.g. F5: reload, Ctrl+B: bookmark)
......
......@@ -23,7 +23,7 @@
#ifndef KATE_FILEBROWSER_H
#define KATE_FILEBROWSER_H
#include <kate/mainwindow.h>
#include <ktexteditor/mainwindow.h>
#include <KFile>
......@@ -36,7 +36,7 @@ class KDirOperator;
class KFileItem;
class KHistoryComboBox;
class KToolBar;
class KConfigGroup;
class KUrlNavigator;
class KConfigBase;
......@@ -56,12 +56,12 @@ class KateFileBrowser : public QWidget
Q_OBJECT
public:
explicit KateFileBrowser( Kate::MainWindow *mainWindow = 0,
explicit KateFileBrowser( KTextEditor::MainWindow *mainWindow = 0,
QWidget * parent = 0, const char * name = 0 );
~KateFileBrowser();
virtual void readSessionConfig( KConfigBase *, const QString & );
virtual void writeSessionConfig( KConfigBase *, const QString & );
void readSessionConfig (const KConfigGroup& config);
void writeSessionConfig (KConfigGroup& config);
void setupToolbar();
void setView( KFile::FileView );
......@@ -89,7 +89,7 @@ class KateFileBrowser : public QWidget
void setupActions();
public:
Kate::MainWindow* mainWindow()
KTextEditor::MainWindow* mainWindow()
{
return m_mainWindow;
}
......@@ -102,7 +102,7 @@ class KateFileBrowser : public QWidget
KHistoryComboBox * m_filter;
QAction *m_autoSyncFolder;
Kate::MainWindow *m_mainWindow;
KTextEditor::MainWindow *m_mainWindow;
};
#endif //KATE_FILEBROWSER_H
......
......@@ -104,7 +104,7 @@ void KateFileBrowserConfigPage::apply()
KConfigGroup config(KSharedConfig::openConfig(), "filebrowser");
QStringList l;
ActionLBItem *aItem;
QList<QListWidgetItem *> list = acSel->selectedListWidget()->findItems(QString("*"), Qt::MatchWildcard);
QList<QListWidgetItem *> list = acSel->selectedListWidget()->findItems(QLatin1String("*"), Qt::MatchWildcard);
foreach(QListWidgetItem *item, list)
{
aItem = static_cast<ActionLBItem*>(item);
......@@ -128,27 +128,27 @@ void KateFileBrowserConfigPage::init()
// toolbar
QStringList l = config.readEntry( "toolbar actions", QStringList() );
if ( l.isEmpty() ) // default toolbar
l << "back" << "forward" << "bookmarks" << "sync_dir" << "configure";
l << QLatin1String("back") << QLatin1String("forward") << QLatin1String("bookmarks") << QLatin1String("sync_dir") << QLatin1String("configure");
// actions from diroperator + two of our own
QStringList allActions;
allActions << "up" << "back" << "forward" << "home"
<< "reload" << "mkdir" << "delete"
<< "short view" << "detailed view"
<< "tree view" << "detailed tree view"
<< "show hidden" /*<< "view menu" << "properties"*/
<< "bookmarks" << "sync_dir" << "configure";
QRegExp re("&(?=[^&])");
allActions << QLatin1String("up") << QLatin1String("back") << QLatin1String("forward") << QLatin1String("home")
<< QLatin1String("reload") << QLatin1String("mkdir") << QLatin1String("delete")
<< QLatin1String("short view") << QLatin1String("detailed view")
<< QLatin1String("tree view") << QLatin1String("detailed tree view")
<< QLatin1String("show hidden") /*<< QLatin1String("view menu") << QLatin1String("properties")*/
<< QLatin1String("bookmarks") << QLatin1String("sync_dir") << QLatin1String("configure");
QRegExp re(QLatin1String ("&(?=[^&])"));
QAction *ac = 0;
QListWidget *lb;
for ( QStringList::Iterator it = allActions.begin(); it != allActions.end(); ++it )
{
lb = l.contains( *it ) ? acSel->selectedListWidget() : acSel->availableListWidget();
if ( *it == "bookmarks" || *it == "sync_dir" || *it == "configure" )
ac = fileBrowser->actionCollection()->action( (*it).toLatin1().constData() );
if ( *it == QLatin1String ("bookmarks") || *it == QLatin1String ("sync_dir") || *it == QLatin1String ("configure") )
ac = fileBrowser->actionCollection()->action( *it );
else
ac = fileBrowser->dirOperator()->actionCollection()->action( (*it).toLatin1().constData() );
ac = fileBrowser->dirOperator()->actionCollection()->action( *it );
if ( ac )
{
......
......@@ -25,31 +25,29 @@
#include "katefilebrowserconfig.h"
#include "katefilebrowser.h"
#include <kate/mainwindow.h>
#include <ktexteditor/mainwindow.h>
#include <ktexteditor/view.h>
#include <kaboutdata.h>
#include <KLocalizedString>
#include <KPluginFactory>
#include <KIconLoader>
#include <QtGui/QKeyEvent>
#include <QKeyEvent>
//END Includes
K_PLUGIN_FACTORY_WITH_JSON (KateFileBrowserPluginFactory, "katefilebrowserplugin.json", registerPlugin<KateFileBrowserPlugin>();)
//BEGIN KateFileBrowserPlugin
KateFileBrowserPlugin::KateFileBrowserPlugin(QObject* parent, const QList<QVariant>&)
: Kate::Plugin ((Kate::Application*)parent)
: KTextEditor::Plugin (parent)
{
}
Kate::PluginView *KateFileBrowserPlugin::createView (Kate::MainWindow *mainWindow)
QObject *KateFileBrowserPlugin::createView (KTextEditor::MainWindow *mainWindow)
{
KateFileBrowserPluginView* view = new KateFileBrowserPluginView (mainWindow);
KateFileBrowserPluginView* view = new KateFileBrowserPluginView (this, mainWindow);
connect(view, SIGNAL(destroyed(QObject*)), this, SLOT(viewDestroyed(QObject*)));
m_views.append(view);
return view;
}
......@@ -86,24 +84,25 @@ QString KateFileBrowserPlugin::configPageFullName (int number) const
QIcon KateFileBrowserPlugin::configPageIcon (int number) const
{
if (number != 0) return QIcon();
return QIcon::fromTheme("document-open");
return QIcon::fromTheme(QLatin1String("document-open"));
}
//END KateFileBrowserPlugin
//BEGIN KateFileBrowserPluginView
KateFileBrowserPluginView::KateFileBrowserPluginView (Kate::MainWindow *mainWindow)
: Kate::PluginView (mainWindow)
KateFileBrowserPluginView::KateFileBrowserPluginView (KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mainWindow)
: QObject (mainWindow)
, m_toolView(
mainWindow->createToolView(
"kate_private_plugin_katefileselectorplugin"
, Kate::MainWindow::Left
, KIconLoader::global()->loadIcon("document-open", KIconLoader::Small)
mainWindow->createToolView(plugin,
QLatin1String ("kate_private_plugin_katefileselectorplugin")
, KTextEditor::MainWindow::Left
, QIcon::fromTheme(QLatin1String("document-open"))
, i18n("Filesystem Browser")
)
)
, m_fileBrowser(new KateFileBrowser(mainWindow, m_toolView))
, m_mainWindow (mainWindow)
{
m_toolView->installEventFilter(this);
}
......@@ -114,14 +113,14 @@ KateFileBrowserPluginView::~KateFileBrowserPluginView ()
delete m_fileBrowser->parentWidget();
}
void KateFileBrowserPluginView::readSessionConfig(KConfigBase* config, const QString& group)
void KateFileBrowserPluginView::readSessionConfig (const KConfigGroup& config)
{
m_fileBrowser->readSessionConfig(config, group);
m_fileBrowser->readSessionConfig(config);
}
void KateFileBrowserPluginView::writeSessionConfig(KConfigBase* config, const QString& group)
void KateFileBrowserPluginView::writeSessionConfig (KConfigGroup& config)
{
m_fileBrowser->writeSessionConfig(config, group);
m_fileBrowser->writeSessionConfig(config);
}
bool KateFileBrowserPluginView::eventFilter(QObject* obj, QEvent* event)
......@@ -131,7 +130,7 @@ bool KateFileBrowserPluginView::eventFilter(QObject* obj, QEvent* event)
QKeyEvent* ke = static_cast<QKeyEvent*>(event);
if ((obj == m_toolView) && (ke->key() == Qt::Key_Escape))
{
mainWindow()->hideToolView(m_toolView);
m_mainWindow->hideToolView(m_toolView);
event->accept();
return true;
}
......
[Desktop Entry]
Type=Service
ServiceTypes=Kate/Plugin
ServiceTypes=KTextEditor/Plugin
X-KDE-Library=katefilebrowserplugin
X-Kate-Version=2.8
Name=File system browser
Name[ar]=متصفح نظام الملفات
Name[ast]=Restolador del sistema de ficheros
......
......@@ -23,14 +23,14 @@
#ifndef KATE_FILEBROWSER_PLUGIN_H
#define KATE_FILEBROWSER_PLUGIN_H
#include <ktexteditor/document.h>
#include <kate/plugin.h>
#include <kate/mainwindow.h>
#include <ktexteditor/configpage.h>
#include <ktexteditor/plugin.h>
#include <ktexteditor/mainwindow.h>
#include <ktexteditor/configpageinterface.h>
#include <kurlcombobox.h>
#include <ktexteditor/configpage.h>
#include <KTextEditor/SessionConfigInterface>
#include <kurlcombobox.h>
#include <KFile>
class KActionCollection;
......@@ -47,7 +47,7 @@ class QSpinBox;
class KateFileBrowser;
class KateFileBrowserPluginView;
class KateFileBrowserPlugin: public Kate::Plugin, public KTextEditor::ConfigPageInterface
class KateFileBrowserPlugin: public KTextEditor::Plugin, public KTextEditor::ConfigPageInterface
{
Q_OBJECT
Q_INTERFACES(KTextEditor::ConfigPageInterface)
......@@ -57,7 +57,7 @@ class KateFileBrowserPlugin: public Kate::Plugin, public KTextEditor::ConfigPage
virtual ~KateFileBrowserPlugin()
{}
Kate::PluginView *createView (Kate::MainWindow *mainWindow);
QObject *createView (KTextEditor::MainWindow *mainWindow);
virtual int configPages() const;
virtual KTextEditor::ConfigPage *configPage (int number = 0, QWidget *parent = 0);
......@@ -72,29 +72,31 @@ class KateFileBrowserPlugin: public Kate::Plugin, public KTextEditor::ConfigPage
QList<KateFileBrowserPluginView *> m_views;
};
class KateFileBrowserPluginView : public Kate::PluginView
class KateFileBrowserPluginView : public QObject, public KTextEditor::SessionConfigInterface
{
Q_OBJECT
Q_INTERFACES(KTextEditor::SessionConfigInterface)
public:
/**
* Constructor.
*/
KateFileBrowserPluginView (Kate::MainWindow *mainWindow);
KateFileBrowserPluginView (KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mainWindow);
/**
* Virtual destructor.
*/
~KateFileBrowserPluginView ();
virtual void readSessionConfig (KConfigBase* config, const QString& groupPrefix);
virtual void writeSessionConfig (KConfigBase* config, const QString& groupPrefix);
void readSessionConfig (const KConfigGroup& config);
void writeSessionConfig (KConfigGroup& config);
private:
bool eventFilter(QObject*, QEvent*);
QWidget *m_toolView;
KateFileBrowser *m_fileBrowser;
KTextEditor::MainWindow *m_mainWindow;
friend class KateFileBrowserPlugin;
};
......
......@@ -46,8 +46,6 @@ K_PLUGIN_FACTORY_WITH_JSON (KateFileTreeFactory, "katefiletreeplugin.json", regi
Q_LOGGING_CATEGORY(FILETREE, "kate-filetree")
//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>&)
: KTextEditor::Plugin (parent),
......@@ -514,5 +512,3 @@ bool KateFileTreeCommand::help(KTextEditor::View * /*view*/, const QString &cmd,
//END KateFileTreeCommand
#include "katefiletreeplugin.moc"
// kate: space-indent on; indent-width 2; replace-tabs on;
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