┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views
diff options
context:
space:
mode:
Diffstat (limited to 'src/views')
-rw-r--r--src/views/dolphinfileitemlistwidget.cpp36
-rw-r--r--src/views/dolphinfileitemlistwidget.h10
-rw-r--r--src/views/dolphinitemlistview.cpp10
-rw-r--r--src/views/dolphinitemlistview.h16
-rw-r--r--src/views/dolphinnewfilemenuobserver.cpp28
-rw-r--r--src/views/dolphinnewfilemenuobserver.h7
-rw-r--r--src/views/dolphinremoteencoding.cpp41
-rw-r--r--src/views/dolphinremoteencoding.h8
-rw-r--r--src/views/dolphinview.cpp373
-rw-r--r--src/views/dolphinview.h89
-rw-r--r--src/views/dolphinviewactionhandler.cpp162
-rw-r--r--src/views/dolphinviewactionhandler.h8
-rw-r--r--src/views/draganddrophelper.cpp40
-rw-r--r--src/views/draganddrophelper.h27
-rw-r--r--src/views/renamedialog.cpp119
-rw-r--r--src/views/renamedialog.h24
-rw-r--r--src/views/tooltips/filemetadatatooltip.cpp22
-rw-r--r--src/views/tooltips/filemetadatatooltip.h4
-rw-r--r--src/views/tooltips/tooltipmanager.cpp26
-rw-r--r--src/views/tooltips/tooltipmanager.h4
-rw-r--r--src/views/versioncontrol/kversioncontrolplugin.cpp29
-rw-r--r--src/views/versioncontrol/kversioncontrolplugin.h223
-rw-r--r--src/views/versioncontrol/updateitemstatesthread.cpp19
-rw-r--r--src/views/versioncontrol/updateitemstatesthread.h8
-rw-r--r--src/views/versioncontrol/versioncontrolobserver.cpp112
-rw-r--r--src/views/versioncontrol/versioncontrolobserver.h18
-rw-r--r--src/views/viewmodecontroller.cpp7
-rw-r--r--src/views/viewmodecontroller.h16
-rw-r--r--src/views/viewproperties.cpp53
-rw-r--r--src/views/viewproperties.h21
30 files changed, 889 insertions, 671 deletions
diff --git a/src/views/dolphinfileitemlistwidget.cpp b/src/views/dolphinfileitemlistwidget.cpp
index 33ee6a277..f15230841 100644
--- a/src/views/dolphinfileitemlistwidget.cpp
+++ b/src/views/dolphinfileitemlistwidget.cpp
@@ -19,12 +19,11 @@
#include "dolphinfileitemlistwidget.h"
-#include <KIcon>
+#include <QIcon>
#include <KIconLoader>
-#include <kversioncontrolplugin2.h>
#include <QColor>
-#include <KDebug>
+#include "dolphindebug.h"
DolphinFileItemListWidget::DolphinFileItemListWidget(KItemListWidgetInformant* informant,
QGraphicsItem* parent) :
@@ -43,7 +42,7 @@ void DolphinFileItemListWidget::refreshCache()
if (values.contains("version")) {
// The item is under version control. Apply the text color corresponding
// to its version state.
- const KVersionControlPlugin2::ItemVersion version = static_cast<KVersionControlPlugin2::ItemVersion>(values.value("version").toInt());
+ const KVersionControlPlugin::ItemVersion version = static_cast<KVersionControlPlugin::ItemVersion>(values.value("version").toInt());
const QColor textColor = styleOption().palette.text().color();
QColor tintColor = textColor;
@@ -51,16 +50,16 @@ void DolphinFileItemListWidget::refreshCache()
// as tint colors and are mixed with the current set text color. The tint colors
// have been optimized for the base colors of the corresponding Oxygen emblems.
switch (version) {
- case KVersionControlPlugin2::UpdateRequiredVersion: tintColor = Qt::yellow; break;
- case KVersionControlPlugin2::LocallyModifiedUnstagedVersion: tintColor = Qt::green; break;
- case KVersionControlPlugin2::LocallyModifiedVersion: tintColor = Qt::green; break;
- case KVersionControlPlugin2::AddedVersion: tintColor = Qt::green; break;
- case KVersionControlPlugin2::RemovedVersion: tintColor = Qt::darkRed; break;
- case KVersionControlPlugin2::ConflictingVersion: tintColor = Qt::red; break;
- case KVersionControlPlugin2::IgnoredVersion: tintColor = Qt::white; break;
- case KVersionControlPlugin2::MissingVersion: tintColor = Qt::red; break;
- case KVersionControlPlugin2::NormalVersion:
- case KVersionControlPlugin2::UnversionedVersion:
+ case KVersionControlPlugin::UpdateRequiredVersion: tintColor = Qt::yellow; break;
+ case KVersionControlPlugin::LocallyModifiedUnstagedVersion: tintColor = Qt::green; break;
+ case KVersionControlPlugin::LocallyModifiedVersion: tintColor = Qt::green; break;
+ case KVersionControlPlugin::AddedVersion: tintColor = Qt::green; break;
+ case KVersionControlPlugin::RemovedVersion: tintColor = Qt::darkRed; break;
+ case KVersionControlPlugin::ConflictingVersion: tintColor = Qt::red; break;
+ case KVersionControlPlugin::IgnoredVersion: tintColor = Qt::white; break;
+ case KVersionControlPlugin::MissingVersion: tintColor = Qt::red; break;
+ case KVersionControlPlugin::NormalVersion:
+ case KVersionControlPlugin::UnversionedVersion:
default:
break;
}
@@ -78,7 +77,7 @@ void DolphinFileItemListWidget::refreshCache()
setTextColor(color);
}
-QPixmap DolphinFileItemListWidget::overlayForState(KVersionControlPlugin2::ItemVersion version, int size)
+QPixmap DolphinFileItemListWidget::overlayForState(KVersionControlPlugin::ItemVersion version, int size)
{
int overlayHeight = KIconLoader::SizeSmall;
if (size >= KIconLoader::SizeEnormous) {
@@ -115,15 +114,14 @@ QPixmap DolphinFileItemListWidget::overlayForState(KVersionControlPlugin2::ItemV
iconName = "vcs-conflicting";
break;
case KVersionControlPlugin::UnversionedVersion:
- case KVersionControlPlugin2::IgnoredVersion:
- case KVersionControlPlugin2::MissingVersion:
+ case KVersionControlPlugin::IgnoredVersion:
+ case KVersionControlPlugin::MissingVersion:
break;
default:
Q_ASSERT(false);
break;
}
- return KIcon(iconName).pixmap(QSize(overlayHeight, overlayHeight));
+ return QIcon::fromTheme(iconName).pixmap(QSize(overlayHeight, overlayHeight));
}
-#include "dolphinfileitemlistwidget.moc"
diff --git a/src/views/dolphinfileitemlistwidget.h b/src/views/dolphinfileitemlistwidget.h
index b9de6fb19..af73ac937 100644
--- a/src/views/dolphinfileitemlistwidget.h
+++ b/src/views/dolphinfileitemlistwidget.h
@@ -20,10 +20,10 @@
#ifndef DOLPHINFILEITEMLISTWIDGET_H
#define DOLPHINFILEITEMLISTWIDGET_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <kitemviews/kfileitemlistwidget.h>
-#include <kversioncontrolplugin2.h>
+#include "versioncontrol/kversioncontrolplugin.h"
/**
* @brief Extends KFileItemListWidget to handle the "version" role.
@@ -31,7 +31,7 @@
* The "version" role is set if version-control-plugins have been enabled.
* @see KVersionControlPlugin
*/
-class LIBDOLPHINPRIVATE_EXPORT DolphinFileItemListWidget : public KFileItemListWidget
+class DOLPHIN_EXPORT DolphinFileItemListWidget : public KFileItemListWidget
{
Q_OBJECT
@@ -40,10 +40,10 @@ public:
virtual ~DolphinFileItemListWidget();
protected:
- virtual void refreshCache();
+ virtual void refreshCache() Q_DECL_OVERRIDE;
private:
- static QPixmap overlayForState(KVersionControlPlugin2::ItemVersion version, int size);
+ static QPixmap overlayForState(KVersionControlPlugin::ItemVersion version, int size);
};
diff --git a/src/views/dolphinitemlistview.cpp b/src/views/dolphinitemlistview.cpp
index db4dadf2f..60c8bb97c 100644
--- a/src/views/dolphinitemlistview.cpp
+++ b/src/views/dolphinitemlistview.cpp
@@ -30,7 +30,6 @@
#include <kitemviews/kitemlistcontroller.h>
#include <kitemviews/kitemliststyleoption.h>
-#include <KGlobalSettings>
#include <views/viewmodecontroller.h>
@@ -94,7 +93,7 @@ void DolphinItemListView::readSettings()
updateFont();
updateGridSize();
- const KConfigGroup globalConfig(KGlobal::config(), "PreviewSettings");
+ const KConfigGroup globalConfig(KSharedConfig::openConfig(), "PreviewSettings");
const QStringList plugins = globalConfig.readEntry("Plugins", QStringList()
<< "directorythumbnail"
<< "imagethumbnail"
@@ -106,9 +105,9 @@ void DolphinItemListView::readSettings()
void DolphinItemListView::writeSettings()
{
- IconsModeSettings::self()->writeConfig();
- CompactModeSettings::self()->writeConfig();
- DetailsModeSettings::self()->writeConfig();
+ IconsModeSettings::self()->save();
+ CompactModeSettings::self()->save();
+ DetailsModeSettings::self()->save();
}
KItemListWidgetCreatorBase* DolphinItemListView::defaultWidgetCreator() const
@@ -262,4 +261,3 @@ ViewModeSettings::ViewMode DolphinItemListView::viewMode() const
return mode;
}
-#include "dolphinitemlistview.moc"
diff --git a/src/views/dolphinitemlistview.h b/src/views/dolphinitemlistview.h
index 67302e44d..7eec6f17a 100644
--- a/src/views/dolphinitemlistview.h
+++ b/src/views/dolphinitemlistview.h
@@ -23,7 +23,7 @@
#include <kitemviews/kfileitemlistview.h>
#include <settings/viewmodes/viewmodesettings.h>
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
class KFileItemListView;
@@ -34,7 +34,7 @@ class KFileItemListView;
* the view-properties into the corresponding KItemListView
* properties.
*/
-class LIBDOLPHINPRIVATE_EXPORT DolphinItemListView : public KFileItemListView
+class DOLPHIN_EXPORT DolphinItemListView : public KFileItemListView
{
Q_OBJECT
@@ -49,14 +49,14 @@ public:
void writeSettings();
protected:
- virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const;
- virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const;
- virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous);
- virtual void onPreviewsShownChanged(bool shown);
+ virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const Q_DECL_OVERRIDE;
+ virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const Q_DECL_OVERRIDE;
+ virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous) Q_DECL_OVERRIDE;
+ virtual void onPreviewsShownChanged(bool shown) Q_DECL_OVERRIDE;
virtual void onVisibleRolesChanged(const QList<QByteArray>& current,
- const QList<QByteArray>& previous);
+ const QList<QByteArray>& previous) Q_DECL_OVERRIDE;
- virtual void updateFont();
+ virtual void updateFont() Q_DECL_OVERRIDE;
private:
void updateGridSize();
diff --git a/src/views/dolphinnewfilemenuobserver.cpp b/src/views/dolphinnewfilemenuobserver.cpp
index 7669f1561..275e1c4fb 100644
--- a/src/views/dolphinnewfilemenuobserver.cpp
+++ b/src/views/dolphinnewfilemenuobserver.cpp
@@ -19,7 +19,6 @@
#include "dolphinnewfilemenuobserver.h"
-#include <KGlobal>
#include "dolphinnewfilemenu.h"
class DolphinNewFileMenuObserverSingleton
@@ -27,7 +26,7 @@ class DolphinNewFileMenuObserverSingleton
public:
DolphinNewFileMenuObserver instance;
};
-K_GLOBAL_STATIC(DolphinNewFileMenuObserverSingleton, s_DolphinNewFileMenuObserver)
+Q_GLOBAL_STATIC(DolphinNewFileMenuObserverSingleton, s_DolphinNewFileMenuObserver)
DolphinNewFileMenuObserver& DolphinNewFileMenuObserver::instance()
{
@@ -36,22 +35,22 @@ DolphinNewFileMenuObserver& DolphinNewFileMenuObserver::instance()
void DolphinNewFileMenuObserver::attach(const DolphinNewFileMenu* menu)
{
- connect(menu, SIGNAL(fileCreated(KUrl)),
- this, SIGNAL(itemCreated(KUrl)));
- connect(menu, SIGNAL(directoryCreated(KUrl)),
- this, SIGNAL(itemCreated(KUrl)));
- connect(menu, SIGNAL(errorMessage(QString)),
- this, SIGNAL(errorMessage(QString)));
+ connect(menu, &DolphinNewFileMenu::fileCreated,
+ this, &DolphinNewFileMenuObserver::itemCreated);
+ connect(menu, &DolphinNewFileMenu::directoryCreated,
+ this, &DolphinNewFileMenuObserver::itemCreated);
+ connect(menu, &DolphinNewFileMenu::errorMessage,
+ this, &DolphinNewFileMenuObserver::errorMessage);
}
void DolphinNewFileMenuObserver::detach(const DolphinNewFileMenu* menu)
{
- disconnect(menu, SIGNAL(fileCreated(KUrl)),
- this, SIGNAL(itemCreated(KUrl)));
- disconnect(menu, SIGNAL(directoryCreated(KUrl)),
- this, SIGNAL(itemCreated(KUrl)));
- disconnect(menu, SIGNAL(errorMessage(QString)),
- this, SIGNAL(errorMessage(QString)));
+ disconnect(menu, &DolphinNewFileMenu::fileCreated,
+ this, &DolphinNewFileMenuObserver::itemCreated);
+ disconnect(menu, &DolphinNewFileMenu::directoryCreated,
+ this, &DolphinNewFileMenuObserver::itemCreated);
+ disconnect(menu, &DolphinNewFileMenu::errorMessage,
+ this, &DolphinNewFileMenuObserver::errorMessage);
}
DolphinNewFileMenuObserver::DolphinNewFileMenuObserver() :
@@ -63,4 +62,3 @@ DolphinNewFileMenuObserver::~DolphinNewFileMenuObserver()
{
}
-#include "dolphinnewfilemenuobserver.moc"
diff --git a/src/views/dolphinnewfilemenuobserver.h b/src/views/dolphinnewfilemenuobserver.h
index 239476eb9..df4621f17 100644
--- a/src/views/dolphinnewfilemenuobserver.h
+++ b/src/views/dolphinnewfilemenuobserver.h
@@ -22,10 +22,9 @@
#include <QObject>
-#include "libdolphin_export.h"
+#include "dolphin_export.h"
class DolphinNewFileMenu;
-class KUrl;
/**
* @brief Allows to observe new file items that have been created
@@ -34,7 +33,7 @@ class KUrl;
* As soon as a DolphinNewFileMenu instance created a new item,
* the observer will emit the signal itemCreated().
*/
-class LIBDOLPHINPRIVATE_EXPORT DolphinNewFileMenuObserver : public QObject
+class DOLPHIN_EXPORT DolphinNewFileMenuObserver : public QObject
{
Q_OBJECT
@@ -44,7 +43,7 @@ public:
void detach(const DolphinNewFileMenu* menu);
signals:
- void itemCreated(const KUrl& url);
+ void itemCreated(const QUrl& url);
void errorMessage(const QString& error);
private:
diff --git a/src/views/dolphinremoteencoding.cpp b/src/views/dolphinremoteencoding.cpp
index 04b350eda..961a7c800 100644
--- a/src/views/dolphinremoteencoding.cpp
+++ b/src/views/dolphinremoteencoding.cpp
@@ -26,16 +26,14 @@
#include "dolphinremoteencoding.h"
#include "dolphinviewactionhandler.h"
-#include <KDebug>
+#include "dolphindebug.h"
#include <KActionMenu>
#include <KActionCollection>
-#include <KIcon>
-#include <KLocale>
-#include <KGlobal>
-#include <KMimeType>
+#include <QIcon>
+#include <KLocalizedString>
#include <KConfig>
#include <KCharsets>
-#include <KMenu>
+#include <QMenu>
#include <KProtocolInfo>
#include <KProtocolManager>
#include <KIO/Scheduler>
@@ -49,10 +47,10 @@ DolphinRemoteEncoding::DolphinRemoteEncoding(QObject* parent, DolphinViewActionH
m_loaded(false),
m_idDefault(0)
{
- m_menu = new KActionMenu(KIcon("character-set"), i18n("Select Remote Charset"), this);
+ m_menu = new KActionMenu(QIcon::fromTheme("character-set"), i18n("Select Remote Charset"), this);
m_actionHandler->actionCollection()->addAction("change_remote_encoding", m_menu);
- connect(m_menu->menu(), SIGNAL(aboutToShow()),
- this, SLOT(slotAboutToShow()));
+ connect(m_menu->menu(), &QMenu::aboutToShow,
+ this, &DolphinRemoteEncoding::slotAboutToShow);
m_menu->setEnabled(false);
m_menu->setDelayed(false);
@@ -70,17 +68,17 @@ void DolphinRemoteEncoding::slotReload()
void DolphinRemoteEncoding::loadSettings()
{
m_loaded = true;
- m_encodingDescriptions = KGlobal::charsets()->descriptiveEncodingNames();
+ m_encodingDescriptions = KCharsets::charsets()->descriptiveEncodingNames();
fillMenu();
}
void DolphinRemoteEncoding::slotAboutToOpenUrl()
{
- KUrl oldURL = m_currentURL;
+ QUrl oldURL = m_currentURL;
m_currentURL = m_actionHandler->currentView()->url();
- if (m_currentURL.protocol() != oldURL.protocol()) {
+ if (m_currentURL.scheme() != oldURL.scheme()) {
// This plugin works on ftp, fish, etc.
// everything whose type is T_FILESYSTEM except for local files
if (!m_currentURL.isLocalFile() &&
@@ -101,7 +99,7 @@ void DolphinRemoteEncoding::slotAboutToOpenUrl()
void DolphinRemoteEncoding::fillMenu()
{
- KMenu* menu = m_menu->menu();
+ QMenu* menu = m_menu->menu();
menu->clear();
@@ -117,7 +115,7 @@ void DolphinRemoteEncoding::fillMenu()
menu->addAction(i18n("Default"), this, SLOT(slotDefault()), 0)->setCheckable(true);
m_idDefault = m_encodingDescriptions.size() + 2;
- connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(slotItemSelected(QAction*)));
+ connect(menu, &QMenu::triggered, this, &DolphinRemoteEncoding::slotItemSelected);
}
void DolphinRemoteEncoding::updateMenu()
@@ -131,7 +129,7 @@ void DolphinRemoteEncoding::updateMenu()
m_menu->menu()->actions().at(i)->setChecked(false);
}
- const QString charset = KGlobal::charsets()->descriptionForEncoding(KProtocolManager::charsetFor(m_currentURL));
+ const QString charset = KCharsets::charsets()->descriptionForEncoding(KProtocolManager::charsetFor(m_currentURL));
if (!charset.isEmpty()) {
int id = 0;
bool isFound = false;
@@ -143,10 +141,10 @@ void DolphinRemoteEncoding::updateMenu()
}
}
- kDebug() << "URL=" << m_currentURL << " charset=" << charset;
+ qCDebug(DolphinDebug) << "URL=" << m_currentURL << " charset=" << charset;
if (!isFound) {
- kWarning() << "could not find entry for charset=" << charset ;
+ qCWarning(DolphinDebug) << "could not find entry for charset=" << charset ;
} else {
m_menu->menu()->actions().at(id)->setChecked(true);
}
@@ -169,10 +167,10 @@ void DolphinRemoteEncoding::slotItemSelected(QAction* action)
if (action) {
int id = action->data().toInt();
- KConfig config(("kio_" + m_currentURL.protocol() + "rc").toLatin1());
+ KConfig config(("kio_" + m_currentURL.scheme() + "rc").toLatin1());
QString host = m_currentURL.host();
if (m_menu->menu()->actions().at(id)->isChecked()) {
- QString charset = KGlobal::charsets()->encodingForName(m_encodingDescriptions.at(id));
+ QString charset = KCharsets::charsets()->encodingForName(m_encodingDescriptions.at(id));
KConfigGroup cg(&config, host);
cg.writeEntry(DATA_KEY, charset);
config.sync();
@@ -187,7 +185,7 @@ void DolphinRemoteEncoding::slotDefault()
{
// We have no choice but delete all higher domain level
// settings here since it affects what will be matched.
- KConfig config(("kio_" + m_currentURL.protocol() + "rc").toLatin1());
+ KConfig config(("kio_" + m_currentURL.scheme() + "rc").toLatin1());
QStringList partList = m_currentURL.host().split('.', QString::SkipEmptyParts);
if (!partList.isEmpty()) {
@@ -213,7 +211,7 @@ void DolphinRemoteEncoding::slotDefault()
}
for (QStringList::const_iterator it = domains.constBegin(); it != domains.constEnd();++it) {
- kDebug() << "Domain to remove: " << *it;
+ qCDebug(DolphinDebug) << "Domain to remove: " << *it;
if (config.hasGroup(*it)) {
config.deleteGroup(*it);
} else if (config.group("").hasKey(*it)) {
@@ -235,4 +233,3 @@ void DolphinRemoteEncoding::updateView()
m_actionHandler->currentView()->reload();
}
-#include "dolphinremoteencoding.moc"
diff --git a/src/views/dolphinremoteencoding.h b/src/views/dolphinremoteencoding.h
index 8dec518d0..28ff52cb3 100644
--- a/src/views/dolphinremoteencoding.h
+++ b/src/views/dolphinremoteencoding.h
@@ -22,8 +22,8 @@
#include <QStringList>
#include <QAction>
-#include <KUrl>
-#include "libdolphin_export.h"
+#include <QUrl>
+#include "dolphin_export.h"
class KActionMenu;
@@ -35,7 +35,7 @@ class DolphinViewActionHandler;
* When browsing remote url, its possible to change encoding from Tools Menu.
*/
-class LIBDOLPHINPRIVATE_EXPORT DolphinRemoteEncoding: public QObject
+class DOLPHIN_EXPORT DolphinRemoteEncoding: public QObject
{
Q_OBJECT
public:
@@ -59,7 +59,7 @@ private:
KActionMenu* m_menu;
QStringList m_encodingDescriptions;
- KUrl m_currentURL;
+ QUrl m_currentURL;
DolphinViewActionHandler* m_actionHandler;
bool m_loaded;
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index 1de973bd5..191cd6511 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -24,24 +24,21 @@
#include <QAbstractItemView>
#include <QApplication>
-#include <QBoxLayout>
#include <QClipboard>
#include <QDropEvent>
#include <QGraphicsSceneDragDropEvent>
-#include <QKeyEvent>
-#include <QItemSelection>
#include <QTimer>
#include <QScrollBar>
-
+#include <QPointer>
+#include <QMenu>
+#include <QVBoxLayout>
#include <KDesktopFile>
#include <KProtocolManager>
-#include <KActionCollection>
#include <KColorScheme>
#include <KDirModel>
-#include <KIconEffect>
#include <KFileItem>
#include <KFileItemListProperties>
-#include <KLocale>
+#include <KLocalizedString>
#include <kitemviews/kfileitemmodel.h>
#include <kitemviews/kfileitemlistview.h>
#include <kitemviews/kitemlistcontainer.h>
@@ -49,18 +46,18 @@
#include <kitemviews/kitemlistselectionmanager.h>
#include <kitemviews/kitemlistview.h>
#include <kitemviews/kitemlistcontroller.h>
+#include <KIO/CopyJob>
#include <KIO/DeleteJob>
#include <KIO/JobUiDelegate>
-#include <KIO/NetAccess>
#include <KIO/PreviewJob>
+#include <KIO/DropJob>
+#include <KIO/PasteJob>
+#include <KIO/Paste>
#include <KJob>
-#include <KMenu>
+#include <QMenu>
#include <KMessageBox>
-#include <konq_fileitemcapabilities.h>
-#include <konq_operations.h>
-#include <konqmimedata.h>
-#include <KToggleAction>
-#include <KUrl>
+#include <KJobWidgets>
+#include <QUrl>
#include "dolphinnewfilemenuobserver.h"
#include "dolphin_detailsmodesettings.h"
@@ -75,14 +72,15 @@
#include "zoomlevelinfo.h"
#ifdef HAVE_BALOO
- #include <baloo/indexerconfig.h>
+ #include <Baloo/IndexerConfig>
#endif
+#include <KFormat>
namespace {
const int MaxModeEnum = DolphinView::CompactView;
};
-DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
+DolphinView::DolphinView(const QUrl& url, QWidget* parent) :
QWidget(parent),
m_active(true),
m_tabsForFiles(false),
@@ -114,19 +112,19 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
// When a new item has been created by the "Create New..." menu, the item should
// get selected and it must be assured that the item will get visible. As the
// creation is done asynchronously, several signals must be checked:
- connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(itemCreated(KUrl)),
- this, SLOT(observeCreatedItem(KUrl)));
+ connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::itemCreated,
+ this, &DolphinView::observeCreatedItem);
m_selectionChangedTimer = new QTimer(this);
m_selectionChangedTimer->setSingleShot(true);
m_selectionChangedTimer->setInterval(300);
- connect(m_selectionChangedTimer, SIGNAL(timeout()),
- this, SLOT(emitSelectionChangedSignal()));
+ connect(m_selectionChangedTimer, &QTimer::timeout,
+ this, &DolphinView::emitSelectionChangedSignal);
m_model = new KFileItemModel(this);
m_view = new DolphinItemListView();
m_view->setEnabledSelectionToggles(GeneralSettings::showSelectionToggle());
- m_view->setVisibleRoles(QList<QByteArray>() << "text");
+ m_view->setVisibleRoles({"text"});
applyModeToView();
KItemListController* controller = new KItemListController(m_model, m_view, this);
@@ -140,60 +138,60 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
m_container = new KItemListContainer(controller, this);
m_container->installEventFilter(this);
setFocusProxy(m_container);
- connect(m_container->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(hideToolTip()));
- connect(m_container->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(hideToolTip()));
+ connect(m_container->horizontalScrollBar(), &QScrollBar::valueChanged, this, &DolphinView::hideToolTip);
+ connect(m_container->verticalScrollBar(), &QScrollBar::valueChanged, this, &DolphinView::hideToolTip);
controller->setSelectionBehavior(KItemListController::MultiSelection);
- connect(controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int)));
- connect(controller, SIGNAL(itemsActivated(KItemSet)), this, SLOT(slotItemsActivated(KItemSet)));
- connect(controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));
- connect(controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF)));
- connect(controller, SIGNAL(viewContextMenuRequested(QPointF)), this, SLOT(slotViewContextMenuRequested(QPointF)));
- connect(controller, SIGNAL(headerContextMenuRequested(QPointF)), this, SLOT(slotHeaderContextMenuRequested(QPointF)));
- connect(controller, SIGNAL(mouseButtonPressed(int,Qt::MouseButtons)), this, SLOT(slotMouseButtonPressed(int,Qt::MouseButtons)));
- connect(controller, SIGNAL(itemHovered(int)), this, SLOT(slotItemHovered(int)));
- connect(controller, SIGNAL(itemUnhovered(int)), this, SLOT(slotItemUnhovered(int)));
- connect(controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*)));
- connect(controller, SIGNAL(escapePressed()), this, SLOT(stopLoading()));
- connect(controller, SIGNAL(modelChanged(KItemModelBase*,KItemModelBase*)), this, SLOT(slotModelChanged(KItemModelBase*,KItemModelBase*)));
+ connect(controller, &KItemListController::itemActivated, this, &DolphinView::slotItemActivated);
+ connect(controller, &KItemListController::itemsActivated, this, &DolphinView::slotItemsActivated);
+ connect(controller, &KItemListController::itemMiddleClicked, this, &DolphinView::slotItemMiddleClicked);
+ connect(controller, &KItemListController::itemContextMenuRequested, this, &DolphinView::slotItemContextMenuRequested);
+ connect(controller, &KItemListController::viewContextMenuRequested, this, &DolphinView::slotViewContextMenuRequested);
+ connect(controller, &KItemListController::headerContextMenuRequested, this, &DolphinView::slotHeaderContextMenuRequested);
+ connect(controller, &KItemListController::mouseButtonPressed, this, &DolphinView::slotMouseButtonPressed);
+ connect(controller, &KItemListController::itemHovered, this, &DolphinView::slotItemHovered);
+ connect(controller, &KItemListController::itemUnhovered, this, &DolphinView::slotItemUnhovered);
+ connect(controller, &KItemListController::itemDropEvent, this, &DolphinView::slotItemDropEvent);
+ connect(controller, &KItemListController::escapePressed, this, &DolphinView::stopLoading);
+ connect(controller, &KItemListController::modelChanged, this, &DolphinView::slotModelChanged);
- connect(m_model, SIGNAL(directoryLoadingStarted()), this, SLOT(slotDirectoryLoadingStarted()));
- connect(m_model, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
- connect(m_model, SIGNAL(directoryLoadingCanceled()), this, SIGNAL(directoryLoadingCanceled()));
- connect(m_model, SIGNAL(directoryLoadingProgress(int)), this, SIGNAL(directoryLoadingProgress(int)));
- connect(m_model, SIGNAL(directorySortingProgress(int)), this, SIGNAL(directorySortingProgress(int)));
- connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(slotItemsChanged()));
- connect(m_model, SIGNAL(itemsRemoved(KItemRangeList)), this, SIGNAL(itemCountChanged()));
- connect(m_model, SIGNAL(itemsInserted(KItemRangeList)), this, SIGNAL(itemCountChanged()));
- connect(m_model, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString)));
- connect(m_model, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString)));
- connect(m_model, SIGNAL(directoryRedirection(KUrl,KUrl)), this, SLOT(slotDirectoryRedirection(KUrl,KUrl)));
- connect(m_model, SIGNAL(urlIsFileError(KUrl)), this, SIGNAL(urlIsFileError(KUrl)));
+ connect(m_model, &KFileItemModel::directoryLoadingStarted, this, &DolphinView::slotDirectoryLoadingStarted);
+ connect(m_model, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::slotDirectoryLoadingCompleted);
+ connect(m_model, &KFileItemModel::directoryLoadingCanceled, this, &DolphinView::directoryLoadingCanceled);
+ connect(m_model, &KFileItemModel::directoryLoadingProgress, this, &DolphinView::directoryLoadingProgress);
+ connect(m_model, &KFileItemModel::directorySortingProgress, this, &DolphinView::directorySortingProgress);
+ connect(m_model, &KFileItemModel::itemsChanged,
+ this, &DolphinView::slotItemsChanged);
+ connect(m_model, &KFileItemModel::itemsRemoved, this, &DolphinView::itemCountChanged);
+ connect(m_model, &KFileItemModel::itemsInserted, this, &DolphinView::itemCountChanged);
+ connect(m_model, &KFileItemModel::infoMessage, this, &DolphinView::infoMessage);
+ connect(m_model, &KFileItemModel::errorMessage, this, &DolphinView::errorMessage);
+ connect(m_model, &KFileItemModel::directoryRedirection, this, &DolphinView::slotDirectoryRedirection);
+ connect(m_model, &KFileItemModel::urlIsFileError, this, &DolphinView::urlIsFileError);
m_view->installEventFilter(this);
- connect(m_view, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
- this, SLOT(slotSortOrderChangedByHeader(Qt::SortOrder,Qt::SortOrder)));
- connect(m_view, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
- this, SLOT(slotSortRoleChangedByHeader(QByteArray,QByteArray)));
- connect(m_view, SIGNAL(visibleRolesChanged(QList<QByteArray>,QList<QByteArray>)),
- this, SLOT(slotVisibleRolesChangedByHeader(QList<QByteArray>,QList<QByteArray>)));
- connect(m_view, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingCanceled()));
- connect(m_view->header(), SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)),
- this, SLOT(slotHeaderColumnWidthChanged(QByteArray,qreal,qreal)));
+ connect(m_view, &DolphinItemListView::sortOrderChanged,
+ this, &DolphinView::slotSortOrderChangedByHeader);
+ connect(m_view, &DolphinItemListView::sortRoleChanged,
+ this, &DolphinView::slotSortRoleChangedByHeader);
+ connect(m_view, &DolphinItemListView::visibleRolesChanged,
+ this, &DolphinView::slotVisibleRolesChangedByHeader);
+ connect(m_view, &DolphinItemListView::roleEditingCanceled,
+ this, &DolphinView::slotRoleEditingCanceled);
+ connect(m_view->header(), &KItemListHeader::columnWidthChanged,
+ this, &DolphinView::slotHeaderColumnWidthChanged);
KItemListSelectionManager* selectionManager = controller->selectionManager();
- connect(selectionManager, SIGNAL(selectionChanged(KItemSet,KItemSet)),
- this, SLOT(slotSelectionChanged(KItemSet,KItemSet)));
+ connect(selectionManager, &KItemListSelectionManager::selectionChanged,
+ this, &DolphinView::slotSelectionChanged);
m_toolTipManager = new ToolTipManager(this);
m_versionControlObserver = new VersionControlObserver(this);
m_versionControlObserver->setModel(m_model);
- connect(m_versionControlObserver, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString)));
- connect(m_versionControlObserver, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString)));
- connect(m_versionControlObserver, SIGNAL(operationCompletedMessage(QString)), this, SIGNAL(operationCompletedMessage(QString)));
+ connect(m_versionControlObserver, &VersionControlObserver::infoMessage, this, &DolphinView::infoMessage);
+ connect(m_versionControlObserver, &VersionControlObserver::errorMessage, this, &DolphinView::errorMessage);
+ connect(m_versionControlObserver, &VersionControlObserver::operationCompletedMessage, this, &DolphinView::operationCompletedMessage);
applyViewProperties();
m_topLayout->addWidget(m_container);
@@ -205,7 +203,7 @@ DolphinView::~DolphinView()
{
}
-KUrl DolphinView::url() const
+QUrl DolphinView::url() const
{
return m_url;
}
@@ -364,12 +362,12 @@ int DolphinView::selectedItemsCount() const
return selectionManager->selectedItems().count();
}
-void DolphinView::markUrlsAsSelected(const QList<KUrl>& urls)
+void DolphinView::markUrlsAsSelected(const QList<QUrl>& urls)
{
m_selectedUrls = urls;
}
-void DolphinView::markUrlAsCurrent(const KUrl& url)
+void DolphinView::markUrlAsCurrent(const QUrl &url)
{
m_currentItemUrl = url;
m_scrollToCurrentItem = true;
@@ -485,7 +483,7 @@ void DolphinView::readSettings()
{
const int oldZoomLevel = m_view->zoomLevel();
- GeneralSettings::self()->readConfig();
+ GeneralSettings::self()->load();
m_view->readSettings();
applyViewProperties();
@@ -500,7 +498,7 @@ void DolphinView::readSettings()
void DolphinView::writeSettings()
{
- GeneralSettings::self()->writeConfig();
+ GeneralSettings::self()->save();
m_view->writeSettings();
}
@@ -563,11 +561,11 @@ QString DolphinView::statusBarText() const
if (fileCount > 0 && folderCount > 0) {
summary = i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
foldersText, filesText,
- KGlobal::locale()->formatByteSize(totalFileSize));
+ KFormat().formatByteSize(totalFileSize));
} else if (fileCount > 0) {
summary = i18nc("@info:status files (size)", "%1 (%2)",
filesText,
- KGlobal::locale()->formatByteSize(totalFileSize));
+ KFormat().formatByteSize(totalFileSize));
} else if (folderCount > 0) {
summary = foldersText;
} else {
@@ -593,7 +591,7 @@ QList<QAction*> DolphinView::versionControlActions(const KFileItemList& items) c
return actions;
}
-void DolphinView::setUrl(const KUrl& url)
+void DolphinView::setUrl(const QUrl& url)
{
if (url == m_url) {
return;
@@ -606,8 +604,8 @@ void DolphinView::setUrl(const KUrl& url)
hideToolTip();
- disconnect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
+ disconnect(m_view, &DolphinItemListView::roleEditingFinished,
+ this, &DolphinView::slotRoleEditingFinished);
// It is important to clear the items from the model before
// applying the view properties, otherwise expensive operations
@@ -651,8 +649,8 @@ void DolphinView::renameSelectedItems()
hideToolTip();
- connect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
+ connect(m_view, &DolphinItemListView::roleEditingFinished,
+ this, &DolphinView::slotRoleEditingFinished);
} else {
RenameDialog* dialog = new RenameDialog(this, items);
dialog->setAttribute(Qt::WA_DeleteOnClose);
@@ -669,32 +667,36 @@ void DolphinView::renameSelectedItems()
void DolphinView::trashSelectedItems()
{
- const KUrl::List list = simplifiedSelectedUrls();
- KonqOperations::del(this, KonqOperations::TRASH, list);
+ const QList<QUrl> list = simplifiedSelectedUrls();
+ KIO::JobUiDelegate uiDelegate;
+ uiDelegate.setWindow(window());
+ if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Trash, KIO::JobUiDelegate::DefaultConfirmation)) {
+ KIO::Job* job = KIO::trash(list);
+ KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Trash, list, QUrl("trash:/"), job);
+ KJobWidgets::setWindow(job, this);
+ connect(job, &KIO::Job::result,
+ this, &DolphinView::slotTrashFileFinished);
+ }
}
void DolphinView::deleteSelectedItems()
{
- const KUrl::List list = simplifiedSelectedUrls();
- const bool del = KonqOperations::askDeleteConfirmation(list,
- KonqOperations::DEL,
- KonqOperations::DEFAULT_CONFIRMATION,
- this);
+ const QList<QUrl> list = simplifiedSelectedUrls();
- if (del) {
+ KIO::JobUiDelegate uiDelegate;
+ uiDelegate.setWindow(window());
+ if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Delete, KIO::JobUiDelegate::DefaultConfirmation)) {
KIO::Job* job = KIO::del(list);
- if (job->ui()) {
- job->ui()->setWindow(this);
- }
- connect(job, SIGNAL(result(KJob*)),
- this, SLOT(slotDeleteFileFinished(KJob*)));
+ KJobWidgets::setWindow(job, this);
+ connect(job, &KIO::Job::result,
+ this, &DolphinView::slotDeleteFileFinished);
}
}
void DolphinView::cutSelectedItems()
{
QMimeData* mimeData = selectionMimeData();
- KonqMimeData::addIsCutSelection(mimeData, true);
+ KIO::setClipboardDataCut(mimeData, true);
QApplication::clipboard()->setMimeData(mimeData);
}
@@ -817,7 +819,7 @@ void DolphinView::slotItemsActivated(const KItemSet& indexes)
foreach (int index, indexes) {
KFileItem item = m_model->fileItem(index);
- const KUrl& url = openItemAsFolderUrl(item);
+ const QUrl& url = openItemAsFolderUrl(item);
if (!url.isEmpty()) { // Open folders in new tabs
emit tabRequested(url);
@@ -836,7 +838,7 @@ void DolphinView::slotItemsActivated(const KItemSet& indexes)
void DolphinView::slotItemMiddleClicked(int index)
{
const KFileItem& item = m_model->fileItem(index);
- const KUrl& url = openItemAsFolderUrl(item);
+ const QUrl& url = openItemAsFolderUrl(item);
if (!url.isEmpty()) {
emit tabRequested(url);
} else if (isTabsForFilesEnabled()) {
@@ -865,7 +867,7 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
{
ViewProperties props(viewPropertiesUrl());
- QPointer<KMenu> menu = new KMenu(QApplication::activeWindow());
+ QPointer<QMenu> menu = new QMenu(QApplication::activeWindow());
KItemListView* view = m_container->controller()->view();
const QSet<QByteArray> visibleRolesSet = view->visibleRoles().toSet();
@@ -1019,7 +1021,7 @@ void DolphinView::slotItemUnhovered(int index)
void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event)
{
- KUrl destUrl;
+ QUrl destUrl;
KFileItem destItem = m_model->fileItem(index);
if (destItem.isNull() || (!destItem.isDir() && !destItem.isDesktopFile())) {
// Use the URL of the view as drop target if the item is no directory
@@ -1036,35 +1038,40 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
event->mimeData(),
event->buttons(),
event->modifiers());
+ dropUrls(destUrl, &dropEvent);
- QString error;
- KonqOperations* op = DragAndDropHelper::dropUrls(destItem, destUrl, &dropEvent, error);
- if (!error.isEmpty()) {
- emit infoMessage(error);
- }
+ setActive(true);
+}
- if (op && destUrl == url()) {
- // Mark the dropped urls as selected.
- m_clearSelectionBeforeSelectingNewItems = true;
- m_markFirstNewlySelectedItemAsCurrent = true;
- connect(op, SIGNAL(aboutToCreate(KUrl::List)), this, SLOT(slotAboutToCreate(KUrl::List)));
- }
+void DolphinView::dropUrls(const QUrl &destUrl, QDropEvent *dropEvent)
+{
+ KIO::DropJob* job = DragAndDropHelper::dropUrls(destUrl, dropEvent, this);
- setActive(true);
+ if (job) {
+ connect(job, &KIO::DropJob::result, this, &DolphinView::slotPasteJobResult);
+
+ if (destUrl == url()) {
+ // Mark the dropped urls as selected.
+ m_clearSelectionBeforeSelectingNewItems = true;
+ m_markFirstNewlySelectedItemAsCurrent = true;
+ connect(job, &KIO::DropJob::itemCreated, this, &DolphinView::slotItemCreated);
+ }
+ }
}
void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* previous)
{
if (previous != 0) {
- disconnect(previous, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
+ Q_ASSERT(qobject_cast<KFileItemModel*>(previous));
+ KFileItemModel* fileItemModel = static_cast<KFileItemModel*>(previous);
+ disconnect(fileItemModel, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::slotDirectoryLoadingCompleted);
m_versionControlObserver->setModel(0);
}
if (current) {
Q_ASSERT(qobject_cast<KFileItemModel*>(current));
- connect(current, SIGNAL(loadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
-
KFileItemModel* fileItemModel = static_cast<KFileItemModel*>(current);
+ connect(fileItemModel, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::slotDirectoryLoadingCompleted);
m_versionControlObserver->setModel(fileItemModel);
}
}
@@ -1075,22 +1082,29 @@ void DolphinView::slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons
hideToolTip();
- // TODO: Qt5: Replace Qt::XButton1 by Qt::BackButton and Qt::XButton2 by Qt::ForwardButton
- if (buttons & Qt::XButton1) {
+ if (buttons & Qt::BackButton) {
emit goBackRequested();
- } else if (buttons & Qt::XButton2) {
+ } else if (buttons & Qt::ForwardButton) {
emit goForwardRequested();
}
}
-void DolphinView::slotAboutToCreate(const KUrl::List& urls)
+void DolphinView::slotItemCreated(const QUrl& url)
{
- if (!urls.isEmpty()) {
- if (m_markFirstNewlySelectedItemAsCurrent) {
- markUrlAsCurrent(urls.first());
- m_markFirstNewlySelectedItemAsCurrent = false;
- }
- m_selectedUrls << KDirModel::simplifiedUrlList(urls);
+ if (m_markFirstNewlySelectedItemAsCurrent) {
+ markUrlAsCurrent(url);
+ m_markFirstNewlySelectedItemAsCurrent = false;
+ }
+ m_selectedUrls << url;
+}
+
+void DolphinView::slotPasteJobResult(KJob *job)
+{
+ if (job->error()) {
+ emit errorMessage(job->errorString());
+ }
+ if (!m_selectedUrls.isEmpty()) {
+ m_selectedUrls << KDirModel::simplifiedUrlList(m_selectedUrls);
}
}
@@ -1147,7 +1161,10 @@ void DolphinView::updateSortFoldersFirst(bool foldersFirst)
QPair<bool, QString> DolphinView::pasteInfo() const
{
- return KonqOperations::pasteInfo(url());
+ const QMimeData *mimeData = QApplication::clipboard()->mimeData();
+ QPair<bool, QString> info;
+ info.second = KIO::pasteActionText(mimeData, &info.first, rootItem());
+ return info;
}
void DolphinView::setTabsForFilesEnabled(bool tabsForFiles)
@@ -1182,7 +1199,7 @@ void DolphinView::restoreState(QDataStream& stream)
stream >> m_restoredContentsPosition;
// Restore expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
- QSet<KUrl> urls;
+ QSet<QUrl> urls;
stream >> urls;
m_model->restoreExpandedDirectories(urls);
}
@@ -1196,10 +1213,10 @@ void DolphinView::saveState(QDataStream& stream)
if (currentIndex != -1) {
KFileItem item = m_model->fileItem(currentIndex);
Q_ASSERT(!item.isNull()); // If the current index is valid a item must exist
- KUrl currentItemUrl = item.url();
+ QUrl currentItemUrl = item.url();
stream << currentItemUrl;
} else {
- stream << KUrl();
+ stream << QUrl();
}
// Save view position
@@ -1226,13 +1243,13 @@ QString DolphinView::viewPropertiesContext() const
return m_viewPropertiesContext;
}
-KUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseThroughArchives)
+QUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseThroughArchives)
{
if (item.isNull()) {
- return KUrl();
+ return QUrl();
}
- KUrl url = item.targetUrl();
+ QUrl url = item.targetUrl();
if (item.isDir()) {
return url;
@@ -1249,7 +1266,7 @@ KUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseTh
// open OpenDocument files as zip folders...
const QString& protocol = KProtocolManager::protocolForArchiveMimetype(mimetype);
if (!protocol.isEmpty()) {
- url.setProtocol(protocol);
+ url.setScheme(protocol);
return url;
}
}
@@ -1266,21 +1283,21 @@ KUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseTh
}
}
- return KUrl();
+ return QUrl();
}
-void DolphinView::observeCreatedItem(const KUrl& url)
+void DolphinView::observeCreatedItem(const QUrl& url)
{
if (m_active) {
clearSelection();
markUrlAsCurrent(url);
- markUrlsAsSelected(QList<KUrl>() << url);
+ markUrlsAsSelected({url});
}
}
-void DolphinView::slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl)
+void DolphinView::slotDirectoryRedirection(const QUrl& oldUrl, const QUrl& newUrl)
{
- if (oldUrl.equals(url(), KUrl::CompareWithoutTrailingSlash)) {
+ if (oldUrl.matches(url(), QUrl::StripTrailingSlash)) {
emit redirection(oldUrl, newUrl);
m_url = newUrl; // #186947
}
@@ -1288,7 +1305,7 @@ void DolphinView::slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUr
void DolphinView::updateViewState()
{
- if (m_currentItemUrl != KUrl()) {
+ if (m_currentItemUrl != QUrl()) {
KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
const int currentIndex = m_model->index(m_currentItemUrl);
if (currentIndex != -1) {
@@ -1303,7 +1320,7 @@ void DolphinView::updateViewState()
selectionManager->setCurrentItem(0);
}
- m_currentItemUrl = KUrl();
+ m_currentItemUrl = QUrl();
}
if (!m_restoredContentsPosition.isNull()) {
@@ -1325,7 +1342,7 @@ void DolphinView::updateViewState()
KItemSet selectedItems = selectionManager->selectedItems();
- QList<KUrl>::iterator it = m_selectedUrls.begin();
+ QList<QUrl>::iterator it = m_selectedUrls.begin();
while (it != m_selectedUrls.end()) {
const int index = m_model->index(*it);
if (index >= 0) {
@@ -1363,6 +1380,15 @@ void DolphinView::calculateItemCount(int& fileCount,
}
}
+void DolphinView::slotTrashFileFinished(KJob* job)
+{
+ if (job->error() == 0) {
+ emit operationCompletedMessage(i18nc("@info:status", "Trash operation completed."));
+ } else if (job->error() != KIO::ERR_USER_CANCELED) {
+ emit errorMessage(job->errorString());
+ }
+}
+
void DolphinView::slotDeleteFileFinished(KJob* job)
{
if (job->error() == 0) {
@@ -1372,13 +1398,19 @@ void DolphinView::slotDeleteFileFinished(KJob* job)
}
}
-void DolphinView::slotRenamingFailed(const KUrl& oldUrl, const KUrl& newUrl)
+void DolphinView::slotRenamingResult(KJob* job)
{
- const int index = m_model->index(newUrl);
- if (index >= 0) {
- QHash<QByteArray, QVariant> data;
- data.insert("text", oldUrl.fileName());
- m_model->setData(index, data);
+ if (job->error()) {
+ KIO::CopyJob *copyJob = qobject_cast<KIO::CopyJob *>(job);
+ Q_ASSERT(copyJob);
+ const QUrl newUrl = copyJob->destUrl();
+ const int index = m_model->index(newUrl);
+ if (index >= 0) {
+ QHash<QByteArray, QVariant> data;
+ const QUrl oldUrl = copyJob->srcUrls().first();
+ data.insert("text", oldUrl.fileName());
+ m_model->setData(index, data);
+ }
}
}
@@ -1450,14 +1482,14 @@ void DolphinView::slotVisibleRolesChangedByHeader(const QList<QByteArray>& curre
void DolphinView::slotRoleEditingCanceled()
{
- disconnect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
+ disconnect(m_view, &DolphinItemListView::roleEditingFinished,
+ this, &DolphinView::slotRoleEditingFinished);
}
void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value)
{
- disconnect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
+ disconnect(m_view, &DolphinItemListView::roleEditingFinished,
+ this, &DolphinView::slotRoleEditingFinished);
if (index < 0 || index >= m_model->count()) {
return;
@@ -1467,14 +1499,16 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con
const KFileItem oldItem = m_model->fileItem(index);
const QString newName = value.toString();
if (!newName.isEmpty() && newName != oldItem.text() && newName != QLatin1String(".") && newName != QLatin1String("..")) {
- const KUrl oldUrl = oldItem.url();
+ const QUrl oldUrl = oldItem.url();
+
+ QUrl newUrl = oldUrl.adjusted(QUrl::RemoveFilename);
+ newUrl.setPath(newUrl.path() + KIO::encodeFileName(newName));
- const KUrl newUrl(url().path(KUrl::AddTrailingSlash) + newName);
const bool newNameExistsAlready = (m_model->index(newUrl) >= 0);
if (!newNameExistsAlready) {
// Only change the data in the model if no item with the new name
// is in the model yet. If there is an item with the new name
- // already, calling KonqOperations::rename() will open a dialog
+ // already, calling KIO::CopyJob will open a dialog
// asking for a new name, and KFileItemModel will update the
// data when the dir lister signals that the file name has changed.
QHash<QByteArray, QVariant> data;
@@ -1482,20 +1516,24 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con
m_model->setData(index, data);
}
- KonqOperations* op = KonqOperations::renameV2(this, oldUrl, newName);
- if (op && !newNameExistsAlready) {
- // Only connect the renamingFailed signal if there is no item with the new name
+ KIO::Job * job = KIO::moveAs(oldUrl, newUrl);
+ KJobWidgets::setWindow(job, this);
+ KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, {oldUrl}, newUrl, job);
+ job->ui()->setAutoErrorHandlingEnabled(true);
+
+ if (!newNameExistsAlready) {
+ // Only connect the result signal if there is no item with the new name
// in the model yet, see bug 328262.
- connect(op, SIGNAL(renamingFailed(KUrl,KUrl)), SLOT(slotRenamingFailed(KUrl,KUrl)));
+ connect(job, &KJob::result, this, &DolphinView::slotRenamingResult);
}
}
}
}
-void DolphinView::loadDirectory(const KUrl& url, bool reload)
+void DolphinView::loadDirectory(const QUrl& url, bool reload)
{
if (!url.isValid()) {
- const QString location(url.pathOrUrl());
+ const QString location(url.toDisplayString(QUrl::PreferLocalFile));
if (location.isEmpty()) {
emit errorMessage(i18nc("@info:status", "The location is empty."));
} else {
@@ -1621,19 +1659,19 @@ void DolphinView::applyModeToView()
}
}
-void DolphinView::pasteToUrl(const KUrl& url)
+void DolphinView::pasteToUrl(const QUrl& url)
{
- KonqOperations* op = KonqOperations::doPasteV2(this, url);
- if (op) {
- m_clearSelectionBeforeSelectingNewItems = true;
- m_markFirstNewlySelectedItemAsCurrent = true;
- connect(op, SIGNAL(aboutToCreate(KUrl::List)), this, SLOT(slotAboutToCreate(KUrl::List)));
- }
+ KIO::PasteJob *job = KIO::paste(QApplication::clipboard()->mimeData(), url);
+ KJobWidgets::setWindow(job, this);
+ m_clearSelectionBeforeSelectingNewItems = true;
+ m_markFirstNewlySelectedItemAsCurrent = true;
+ connect(job, &KIO::PasteJob::itemCreated, this, &DolphinView::slotItemCreated);
+ connect(job, &KIO::PasteJob::result, this, &DolphinView::slotPasteJobResult);
}
-KUrl::List DolphinView::simplifiedSelectedUrls() const
+QList<QUrl> DolphinView::simplifiedSelectedUrls() const
{
- KUrl::List urls;
+ QList<QUrl> urls;
const KFileItemList items = selectedItems();
foreach (const KFileItem& item, items) {
@@ -1665,7 +1703,8 @@ void DolphinView::updateWritableState()
if (item.isNull()) {
// Try to find out if the URL is writable even if the "root item" is
// null, see https://bugs.kde.org/show_bug.cgi?id=330001
- item = KFileItem(KFileItem::Unknown, KFileItem::Unknown, url(), true);
+ item = KFileItem(url());
+ item.setDelayedMimeTypes(true);
}
KFileItemListProperties capabilities(KFileItemList() << item);
@@ -1676,16 +1715,14 @@ void DolphinView::updateWritableState()
}
}
-KUrl DolphinView::viewPropertiesUrl() const
+QUrl DolphinView::viewPropertiesUrl() const
{
if (m_viewPropertiesContext.isEmpty()) {
return m_url;
}
- KUrl url;
- url.setProtocol(m_url.protocol());
+ QUrl url;
+ url.setScheme(m_url.scheme());
url.setPath(m_viewPropertiesContext);
return url;
}
-
-#include "dolphinview.moc"
diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h
index 06c09edc3..24b560f10 100644
--- a/src/views/dolphinview.h
+++ b/src/views/dolphinview.h
@@ -23,29 +23,23 @@
#include <config-baloo.h>
-#include "libdolphin_export.h"
+#include "dolphin_export.h"
#include <kparts/part.h>
#include <KFileItem>
-#include <KFileItemDelegate>
#include <kio/fileundomanager.h>
#include <KIO/Job>
-
-#include <QBoxLayout>
-#include <QKeyEvent>
-#include <QLinkedList>
+#include <QUrl>
+#include <QMimeData>
#include <QWidget>
typedef KIO::FileUndoManager::CommandType CommandType;
-
+class QVBoxLayout;
class DolphinItemListView;
-class KAction;
-class KActionCollection;
class KFileItemModel;
class KItemListContainer;
class KItemModelBase;
class KItemSet;
-class KUrl;
class ToolTipManager;
class VersionControlObserver;
class ViewProperties;
@@ -63,7 +57,7 @@ class QRegExp;
* - show previews
* - enable grouping
*/
-class LIBDOLPHINPRIVATE_EXPORT DolphinView : public QWidget
+class DOLPHIN_EXPORT DolphinView : public QWidget
{
Q_OBJECT
@@ -97,7 +91,7 @@ public:
* @param url Specifies the content which should be shown.
* @param parent Parent widget of the view.
*/
- DolphinView(const KUrl& url, QWidget* parent);
+ DolphinView(const QUrl& url, QWidget* parent);
virtual ~DolphinView();
@@ -105,7 +99,7 @@ public:
* Returns the current active URL, where all actions are applied.
* The URL navigator is synchronized with this URL.
*/
- KUrl url() const;
+ QUrl url() const;
/**
* If \a active is true, the view will marked as active. The active
@@ -178,13 +172,13 @@ public:
* gets selected if no loading of a directory has been triggered
* by DolphinView::setUrl() or DolphinView::reload().
*/
- void markUrlsAsSelected(const QList<KUrl>& urls);
+ void markUrlsAsSelected(const QList<QUrl> &urls);
/**
* Marks the item indicated by \p url to be scrolled to and as the
* current item after directory DolphinView::url() has been loaded.
*/
- void markUrlAsCurrent(const KUrl& url);
+ void markUrlAsCurrent(const QUrl& url);
/**
* All items that match to the pattern \a pattern will get selected
@@ -309,14 +303,14 @@ public:
* @return a valid and adjusted url if the item can be opened as folder,
* otherwise return an empty url.
*/
- static KUrl openItemAsFolderUrl(const KFileItem& item, const bool browseThroughArchives = true);
+ static QUrl openItemAsFolderUrl(const KFileItem& item, const bool browseThroughArchives = true);
public slots:
/**
* Changes the directory to \a url. If the current directory is equal to
* \a url, nothing will be done (use DolphinView::reload() instead).
*/
- void setUrl(const KUrl& url);
+ void setUrl(const QUrl& url);
/**
* Selects all items.
@@ -368,10 +362,15 @@ public slots:
*/
void pasteIntoFolder();
+ /**
+ * Handles a drop of @p dropEvent onto @p destUrl
+ */
+ void dropUrls(const QUrl &destUrl, QDropEvent *dropEvent);
+
void stopLoading();
/** Activates the view if the item list container gets focus. */
- virtual bool eventFilter(QObject* watched, QEvent* event);
+ virtual bool eventFilter(QObject* watched, QEvent* event) Q_DECL_OVERRIDE;
signals:
/**
@@ -384,10 +383,10 @@ signals:
* After the URL has been changed the signal urlChanged() will
* be emitted.
*/
- void urlAboutToBeChanged(const KUrl& url);
+ void urlAboutToBeChanged(const QUrl& url);
/** Is emitted if the URL of the view has been changed to \a url. */
- void urlChanged(const KUrl& url);
+ void urlChanged(const QUrl& url);
/**
* Is emitted when clicking on an item with the left mouse button.
@@ -408,7 +407,7 @@ signals:
/**
* Is emitted if a new tab should be opened for the URL \a url.
*/
- void tabRequested(const KUrl& url);
+ void tabRequested(const QUrl& url);
/**
* Is emitted if the view mode (IconsView, DetailsView,
@@ -463,7 +462,7 @@ signals:
*/
void requestContextMenu(const QPoint& pos,
const KFileItem& item,
- const KUrl& url,
+ const QUrl& url,
const QList<QAction*>& customActions);
/**
@@ -520,13 +519,13 @@ signals:
* Emitted when the file-item-model emits redirection.
* Testcase: fish://localhost
*/
- void redirection(const KUrl& oldUrl, const KUrl& newUrl);
+ void redirection(const QUrl& oldUrl, const QUrl& newUrl);
/**
* Is emitted when the URL set by DolphinView::setUrl() represents a file.
* In this case no signal errorMessage() will be emitted.
*/
- void urlIsFileError(const KUrl& url);
+ void urlIsFileError(const QUrl& url);
/**
* Is emitted when the write state of the folder has been changed. The application
@@ -549,11 +548,10 @@ signals:
protected:
/** Changes the zoom level if Control is pressed during a wheel event. */
- virtual void wheelEvent(QWheelEvent* event);
+ virtual void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE;
- /** @reimp */
- virtual void hideEvent(QHideEvent* event);
- virtual bool event(QEvent* event);
+ virtual void hideEvent(QHideEvent* event) Q_DECL_OVERRIDE;
+ virtual bool event(QEvent* event) Q_DECL_OVERRIDE;
private slots:
/**
@@ -578,7 +576,11 @@ private slots:
/*
* Is called when new items get pasted or dropped.
*/
- void slotAboutToCreate(const KUrl::List& urls);
+ void slotItemCreated(const QUrl &url);
+ /*
+ * Is called after all pasted or dropped items have been copied to destination.
+ */
+ void slotPasteJobResult(KJob *job);
/**
* Emits the signal \a selectionChanged() with a small delay. This is
@@ -619,7 +621,16 @@ private slots:
*/
void slotDeleteFileFinished(KJob* job);
- void slotRenamingFailed(const KUrl& oldUrl, const KUrl& newUrl);
+ /**
+ * Indicates in the status bar that the trash operation
+ * of the job \a job has been finished.
+ */
+ void slotTrashFileFinished(KJob* job);
+
+ /**
+ * Invoked when the rename job is done, for error handling.
+ */
+ void slotRenamingResult(KJob* job);
/**
* Invoked when the file item model has started the loading
@@ -665,13 +676,13 @@ private slots:
* model indicates that the item is available, the item will
* get selected and it is assured that the item stays visible.
*/
- void observeCreatedItem(const KUrl& url);
+ void observeCreatedItem(const QUrl &url);
/**
* Called when a redirection happens.
* Testcase: fish://localhost
*/
- void slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl);
+ void slotDirectoryRedirection(const QUrl& oldUrl, const QUrl& newUrl);
/**
* Applies the state that has been restored by restoreViewState()
@@ -692,7 +703,7 @@ private slots:
void calculateItemCount(int& fileCount, int& folderCount, KIO::filesize_t& totalFileSize) const;
private:
- void loadDirectory(const KUrl& url, bool reload = false);
+ void loadDirectory(const QUrl& url, bool reload = false);
/**
* Applies the view properties which are defined by the current URL
@@ -717,14 +728,14 @@ private:
* Helper method for DolphinView::paste() and DolphinView::pasteIntoFolder().
* Pastes the clipboard data into the URL \a url.
*/
- void pasteToUrl(const KUrl& url);
+ void pasteToUrl(const QUrl& url);
/**
* Returns a list of URLs for all selected items. The list is
* simplified, so that when the URLs are part of different tree
* levels, only the parent is returned.
*/
- KUrl::List simplifiedSelectedUrls() const;
+ QList<QUrl> simplifiedSelectedUrls() const;
/**
* Returns the MIME data for all selected items.
@@ -743,7 +754,7 @@ private:
* DolphinView::viewPropertiesContext(), otherwise the context
* is returned.
*/
- KUrl viewPropertiesUrl() const;
+ QUrl viewPropertiesUrl() const;
private:
bool m_active;
@@ -753,7 +764,7 @@ private:
bool m_dragging; // True if a dragging is done. Required to be able to decide whether a
// tooltip may be shown when hovering an item.
- KUrl m_url;
+ QUrl m_url;
QString m_viewPropertiesContext;
Mode m_mode;
QList<QByteArray> m_visibleRoles;
@@ -768,11 +779,11 @@ private:
QTimer* m_selectionChangedTimer;
- KUrl m_currentItemUrl; // Used for making the view to remember the current URL after F5
+ QUrl m_currentItemUrl; // Used for making the view to remember the current URL after F5
bool m_scrollToCurrentItem; // Used for marking we need to scroll to current item or not
QPoint m_restoredContentsPosition;
- QList<KUrl> m_selectedUrls; // Used for making the view to remember selections after F5
+ QList<QUrl> m_selectedUrls; // Used for making the view to remember selections after F5
bool m_clearSelectionBeforeSelectingNewItems;
bool m_markFirstNewlySelectedItemAsCurrent;
diff --git a/src/views/dolphinviewactionhandler.cpp b/src/views/dolphinviewactionhandler.cpp
index 48ec95c70..ac538a648 100644
--- a/src/views/dolphinviewactionhandler.cpp
+++ b/src/views/dolphinviewactionhandler.cpp
@@ -25,24 +25,24 @@
#include "settings/viewpropertiesdialog.h"
#include "views/dolphinview.h"
#include "views/zoomlevelinfo.h"
-#include <konq_operations.h>
-#include <KAction>
+#include <QPointer>
+#include <QMenu>
+
#include <KActionCollection>
#include <KActionMenu>
#include <kitemviews/kfileitemmodel.h>
-#include <KLocale>
-#include <KMenu>
+#include <KLocalizedString>
#include <KNewFileMenu>
#include <KSelectAction>
#include <KToggleAction>
#include <KPropertiesDialog>
-#include <KIcon>
+#include <QIcon>
-#include <KDebug>
+#include "dolphindebug.h"
#ifdef HAVE_BALOO
- #include <baloo/indexerconfig.h>
+ #include <Baloo/IndexerConfig>
#endif
DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection* collection, QObject* parent) :
@@ -66,26 +66,26 @@ void DolphinViewActionHandler::setCurrentView(DolphinView* view)
m_currentView = view;
- connect(view, SIGNAL(modeChanged(DolphinView::Mode,DolphinView::Mode)),
- this, SLOT(updateViewActions()));
- connect(view, SIGNAL(previewsShownChanged(bool)),
- this, SLOT(slotPreviewsShownChanged(bool)));
- connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder)),
- this, SLOT(slotSortOrderChanged(Qt::SortOrder)));
- connect(view, SIGNAL(sortFoldersFirstChanged(bool)),
- this, SLOT(slotSortFoldersFirstChanged(bool)));
- connect(view, SIGNAL(visibleRolesChanged(QList<QByteArray>,QList<QByteArray>)),
- this, SLOT(slotVisibleRolesChanged(QList<QByteArray>,QList<QByteArray>)));
- connect(view, SIGNAL(groupedSortingChanged(bool)),
- this, SLOT(slotGroupedSortingChanged(bool)));
- connect(view, SIGNAL(hiddenFilesShownChanged(bool)),
- this, SLOT(slotHiddenFilesShownChanged(bool)));
- connect(view, SIGNAL(sortRoleChanged(QByteArray)),
- this, SLOT(slotSortRoleChanged(QByteArray)));
- connect(view, SIGNAL(zoomLevelChanged(int,int)),
- this, SLOT(slotZoomLevelChanged(int,int)));
- connect(view, SIGNAL(writeStateChanged(bool)),
- this, SLOT(slotWriteStateChanged(bool)));
+ connect(view, &DolphinView::modeChanged,
+ this, &DolphinViewActionHandler::updateViewActions);
+ connect(view, &DolphinView::previewsShownChanged,
+ this, &DolphinViewActionHandler::slotPreviewsShownChanged);
+ connect(view, &DolphinView::sortOrderChanged,
+ this, &DolphinViewActionHandler::slotSortOrderChanged);
+ connect(view, &DolphinView::sortFoldersFirstChanged,
+ this, &DolphinViewActionHandler::slotSortFoldersFirstChanged);
+ connect(view, &DolphinView::visibleRolesChanged,
+ this, &DolphinViewActionHandler::slotVisibleRolesChanged);
+ connect(view, &DolphinView::groupedSortingChanged,
+ this, &DolphinViewActionHandler::slotGroupedSortingChanged);
+ connect(view, &DolphinView::hiddenFilesShownChanged,
+ this, &DolphinViewActionHandler::slotHiddenFilesShownChanged);
+ connect(view, &DolphinView::sortRoleChanged,
+ this, &DolphinViewActionHandler::slotSortRoleChanged);
+ connect(view, &DolphinView::zoomLevelChanged,
+ this, &DolphinViewActionHandler::slotZoomLevelChanged);
+ connect(view, &DolphinView::writeStateChanged,
+ this, &DolphinViewActionHandler::slotWriteStateChanged);
}
DolphinView* DolphinViewActionHandler::currentView()
@@ -97,51 +97,51 @@ void DolphinViewActionHandler::createActions()
{
// This action doesn't appear in the GUI, it's for the shortcut only.
// KNewFileMenu takes care of the GUI stuff.
- KAction* newDirAction = m_actionCollection->addAction("create_dir");
+ QAction* newDirAction = m_actionCollection->addAction("create_dir");
newDirAction->setText(i18nc("@action", "Create Folder..."));
- newDirAction->setShortcut(Qt::Key_F10);
- newDirAction->setIcon(KIcon("folder-new"));
+ m_actionCollection->setDefaultShortcut(newDirAction, Qt::Key_F10);
+ newDirAction->setIcon(QIcon::fromTheme("folder-new"));
newDirAction->setEnabled(false); // Will be enabled in slotWriteStateChanged(bool) if the current URL is writable
- connect(newDirAction, SIGNAL(triggered()), this, SIGNAL(createDirectory()));
+ connect(newDirAction, &QAction::triggered, this, &DolphinViewActionHandler::createDirectory);
// File menu
- KAction* rename = m_actionCollection->addAction("rename");
+ QAction* rename = m_actionCollection->addAction("rename");
rename->setText(i18nc("@action:inmenu File", "Rename..."));
- rename->setShortcut(Qt::Key_F2);
- rename->setIcon(KIcon("edit-rename"));
- connect(rename, SIGNAL(triggered()), this, SLOT(slotRename()));
+ m_actionCollection->setDefaultShortcut(rename, Qt::Key_F2);
+ rename->setIcon(QIcon::fromTheme("edit-rename"));
+ connect(rename, &QAction::triggered, this, &DolphinViewActionHandler::slotRename);
- KAction* moveToTrash = m_actionCollection->addAction("move_to_trash");
+ QAction* moveToTrash = m_actionCollection->addAction("move_to_trash");
moveToTrash->setText(i18nc("@action:inmenu File", "Move to Trash"));
- moveToTrash->setIcon(KIcon("user-trash"));
- moveToTrash->setShortcut(QKeySequence::Delete);
- connect(moveToTrash, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)),
- this, SLOT(slotTrashActivated(Qt::MouseButtons,Qt::KeyboardModifiers)));
+ moveToTrash->setIcon(QIcon::fromTheme("user-trash"));
+ m_actionCollection->setDefaultShortcut(moveToTrash, QKeySequence::Delete);
+ connect(moveToTrash, &QAction::triggered,
+ this, &DolphinViewActionHandler::slotTrashActivated);
- KAction* deleteAction = m_actionCollection->addAction("delete");
- deleteAction->setIcon(KIcon("edit-delete"));
+ QAction* deleteAction = m_actionCollection->addAction("delete");
+ deleteAction->setIcon(QIcon::fromTheme("edit-delete"));
deleteAction->setText(i18nc("@action:inmenu File", "Delete"));
- deleteAction->setShortcut(Qt::SHIFT | Qt::Key_Delete);
- connect(deleteAction, SIGNAL(triggered()), this, SLOT(slotDeleteItems()));
+ m_actionCollection->setDefaultShortcut(deleteAction, Qt::SHIFT | Qt::Key_Delete);
+ connect(deleteAction, &QAction::triggered, this, &DolphinViewActionHandler::slotDeleteItems);
// This action is useful for being enabled when "move_to_trash" should be
// disabled and "delete" is enabled (e.g. non-local files), so that Key_Del
// can be used for deleting the file (#76016). It needs to be a separate action
// so that the Edit menu isn't affected.
- KAction* deleteWithTrashShortcut = m_actionCollection->addAction("delete_shortcut");
+ QAction* deleteWithTrashShortcut = m_actionCollection->addAction("delete_shortcut");
// The descriptive text is just for the shortcuts editor.
deleteWithTrashShortcut->setText(i18nc("@action \"Move to Trash\" for non-local files, etc.", "Delete (using shortcut for Trash)"));
- deleteWithTrashShortcut->setShortcut(QKeySequence::Delete);
+ m_actionCollection->setDefaultShortcut(deleteWithTrashShortcut, QKeySequence::Delete);
deleteWithTrashShortcut->setEnabled(false);
- connect(deleteWithTrashShortcut, SIGNAL(triggered()), this, SLOT(slotDeleteItems()));
+ connect(deleteWithTrashShortcut, &QAction::triggered, this, &DolphinViewActionHandler::slotDeleteItems);
- KAction *propertiesAction = m_actionCollection->addAction( "properties" );
+ QAction *propertiesAction = m_actionCollection->addAction( "properties" );
// Well, it's the File menu in dolphinmainwindow and the Edit menu in dolphinpart... :)
propertiesAction->setText( i18nc("@action:inmenu File", "Properties") );
- propertiesAction->setIcon(KIcon("document-properties"));
- propertiesAction->setShortcuts(QList<QKeySequence>() << Qt::ALT + Qt::Key_Return << Qt::ALT + Qt::Key_Enter);
- connect(propertiesAction, SIGNAL(triggered()), SLOT(slotProperties()));
+ propertiesAction->setIcon(QIcon::fromTheme("document-properties"));
+ m_actionCollection->setDefaultShortcuts(propertiesAction, {Qt::ALT + Qt::Key_Return, Qt::ALT + Qt::Key_Enter});
+ connect(propertiesAction, &QAction::triggered, this, &DolphinViewActionHandler::slotProperties);
// View menu
KToggleAction* iconsAction = iconsModeAction();
@@ -154,7 +154,7 @@ void DolphinViewActionHandler::createActions()
viewModeActions->addAction(compactAction);
viewModeActions->addAction(detailsAction);
viewModeActions->setToolBarMode(KSelectAction::MenuMode);
- connect(viewModeActions, SIGNAL(triggered(QAction*)), this, SLOT(slotViewModeActionTriggered(QAction*)));
+ connect(viewModeActions, static_cast<void(KSelectAction::*)(QAction*)>(&KSelectAction::triggered), this, &DolphinViewActionHandler::slotViewModeActionTriggered);
KStandardAction::zoomIn(this,
SLOT(zoomIn()),
@@ -167,16 +167,16 @@ void DolphinViewActionHandler::createActions()
KToggleAction* showPreview = m_actionCollection->add<KToggleAction>("show_preview");
showPreview->setText(i18nc("@action:intoolbar", "Preview"));
showPreview->setToolTip(i18nc("@info", "Show preview of files and folders"));
- showPreview->setIcon(KIcon("view-preview"));
- connect(showPreview, SIGNAL(triggered(bool)), this, SLOT(togglePreview(bool)));
+ showPreview->setIcon(QIcon::fromTheme("view-preview"));
+ connect(showPreview, &KToggleAction::triggered, this, &DolphinViewActionHandler::togglePreview);
KToggleAction* sortDescending = m_actionCollection->add<KToggleAction>("descending");
sortDescending->setText(i18nc("@action:inmenu Sort", "Descending"));
- connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder()));
+ connect(sortDescending, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleSortOrder);
KToggleAction* sortFoldersFirst = m_actionCollection->add<KToggleAction>("folders_first");
sortFoldersFirst->setText(i18nc("@action:inmenu Sort", "Folders First"));
- connect(sortFoldersFirst, SIGNAL(triggered()), this, SLOT(toggleSortFoldersFirst()));
+ connect(sortFoldersFirst, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleSortFoldersFirst);
// View -> Sort By
QActionGroup* sortByActionGroup = createFileItemRolesActionGroup("sort_by_");
@@ -204,18 +204,18 @@ void DolphinViewActionHandler::createActions()
}
KToggleAction* showInGroups = m_actionCollection->add<KToggleAction>("show_in_groups");
- showInGroups->setIcon(KIcon("view-group"));
+ showInGroups->setIcon(QIcon::fromTheme("view-group"));
showInGroups->setText(i18nc("@action:inmenu View", "Show in Groups"));
- connect(showInGroups, SIGNAL(triggered(bool)), this, SLOT(toggleGroupedSorting(bool)));
+ connect(showInGroups, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleGroupedSorting);
KToggleAction* showHiddenFiles = m_actionCollection->add<KToggleAction>("show_hidden_files");
showHiddenFiles->setText(i18nc("@action:inmenu View", "Show Hidden Files"));
- showHiddenFiles->setShortcuts(QList<QKeySequence>() << Qt::ALT + Qt::Key_Period << Qt::Key_F8);
- connect(showHiddenFiles, SIGNAL(triggered(bool)), this, SLOT(toggleShowHiddenFiles(bool)));
+ m_actionCollection->setDefaultShortcuts(showHiddenFiles, {Qt::ALT + Qt::Key_Period, Qt::Key_F8});
+ connect(showHiddenFiles, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleShowHiddenFiles);
- KAction* adjustViewProps = m_actionCollection->addAction("view_properties");
+ QAction* adjustViewProps = m_actionCollection->addAction("view_properties");
adjustViewProps->setText(i18nc("@action:inmenu View", "Adjust View Properties..."));
- connect(adjustViewProps, SIGNAL(triggered()), this, SLOT(slotAdjustViewProperties()));
+ connect(adjustViewProps, &QAction::triggered, this, &DolphinViewActionHandler::slotAdjustViewProperties);
}
QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QString& groupPrefix)
@@ -226,11 +226,11 @@ QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QSt
QActionGroup* rolesActionGroup = new QActionGroup(m_actionCollection);
rolesActionGroup->setExclusive(isSortGroup);
if (isSortGroup) {
- connect(rolesActionGroup, SIGNAL(triggered(QAction*)),
- this, SLOT(slotSortTriggered(QAction*)));
+ connect(rolesActionGroup, &QActionGroup::triggered,
+ this, &DolphinViewActionHandler::slotSortTriggered);
} else {
- connect(rolesActionGroup, SIGNAL(triggered(QAction*)),
- this, SLOT(toggleVisibleRole(QAction*)));
+ connect(rolesActionGroup, &QActionGroup::triggered,
+ this, &DolphinViewActionHandler::toggleVisibleRole);
}
QString groupName;
@@ -265,11 +265,11 @@ QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QSt
groupMenuGroup = new QActionGroup(groupMenu);
groupMenuGroup->setExclusive(isSortGroup);
if (isSortGroup) {
- connect(groupMenuGroup, SIGNAL(triggered(QAction*)),
- this, SLOT(slotSortTriggered(QAction*)));
+ connect(groupMenuGroup, &QActionGroup::triggered,
+ this, &DolphinViewActionHandler::slotSortTriggered);
} else {
- connect(groupMenuGroup, SIGNAL(triggered(QAction*)),
- this, SLOT(toggleVisibleRole(QAction*)));
+ connect(groupMenuGroup, &QActionGroup::triggered,
+ this, &DolphinViewActionHandler::toggleVisibleRole);
}
}
@@ -301,7 +301,7 @@ void DolphinViewActionHandler::slotViewModeActionTriggered(QAction* action)
m_currentView->setMode(mode);
QAction* viewModeMenu = m_actionCollection->action("view_mode");
- viewModeMenu->setIcon(KIcon(action->icon()));
+ viewModeMenu->setIcon(action->icon());
}
void DolphinViewActionHandler::slotRename()
@@ -310,7 +310,7 @@ void DolphinViewActionHandler::slotRename()
m_currentView->renameSelectedItems();
}
-void DolphinViewActionHandler::slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers modifiers)
+void DolphinViewActionHandler::slotTrashActivated()
{
emit actionBeingHandled();
m_currentView->trashSelectedItems();
@@ -364,7 +364,7 @@ void DolphinViewActionHandler::updateViewActions()
viewModeAction->setChecked(true);
QAction* viewModeMenu = m_actionCollection->action("view_mode");
- viewModeMenu->setIcon(KIcon(viewModeAction->icon()));
+ viewModeMenu->setIcon(viewModeAction->icon());
}
QAction* showPreviewAction = m_actionCollection->action("show_preview");
@@ -491,8 +491,8 @@ KToggleAction* DolphinViewActionHandler::iconsModeAction()
KToggleAction* iconsView = m_actionCollection->add<KToggleAction>("icons");
iconsView->setText(i18nc("@action:inmenu View Mode", "Icons"));
iconsView->setToolTip(i18nc("@info", "Icons view mode"));
- iconsView->setShortcut(Qt::CTRL | Qt::Key_1);
- iconsView->setIcon(KIcon("view-list-icons"));
+ m_actionCollection->setDefaultShortcut(iconsView, Qt::CTRL | Qt::Key_1);
+ iconsView->setIcon(QIcon::fromTheme("view-list-icons"));
iconsView->setData(QVariant::fromValue(DolphinView::IconsView));
return iconsView;
}
@@ -502,8 +502,8 @@ KToggleAction* DolphinViewActionHandler::compactModeAction()
KToggleAction* iconsView = m_actionCollection->add<KToggleAction>("compact");
iconsView->setText(i18nc("@action:inmenu View Mode", "Compact"));
iconsView->setToolTip(i18nc("@info", "Compact view mode"));
- iconsView->setShortcut(Qt::CTRL | Qt::Key_2);
- iconsView->setIcon(KIcon("view-list-details")); // TODO: discuss with Oxygen-team the wrong (?) name
+ m_actionCollection->setDefaultShortcut(iconsView, Qt::CTRL | Qt::Key_2);
+ iconsView->setIcon(QIcon::fromTheme("view-list-details")); // TODO: discuss with Oxygen-team the wrong (?) name
iconsView->setData(QVariant::fromValue(DolphinView::CompactView));
return iconsView;
}
@@ -513,8 +513,8 @@ KToggleAction* DolphinViewActionHandler::detailsModeAction()
KToggleAction* detailsView = m_actionCollection->add<KToggleAction>("details");
detailsView->setText(i18nc("@action:inmenu View Mode", "Details"));
detailsView->setToolTip(i18nc("@info", "Details view mode"));
- detailsView->setShortcut(Qt::CTRL | Qt::Key_3);
- detailsView->setIcon(KIcon("view-list-tree"));
+ m_actionCollection->setDefaultShortcut(detailsView, Qt::CTRL | Qt::Key_3);
+ detailsView->setIcon(QIcon::fromTheme("view-list-tree"));
detailsView->setData(QVariant::fromValue(DolphinView::DetailsView));
return detailsView;
}
@@ -527,7 +527,7 @@ void DolphinViewActionHandler::slotSortRoleChanged(const QByteArray& role)
if (!action->icon().isNull()) {
QAction* sortByMenu = m_actionCollection->action("sort");
- sortByMenu->setIcon(KIcon(action->icon()));
+ sortByMenu->setIcon(action->icon());
}
}
}
@@ -585,7 +585,7 @@ void DolphinViewActionHandler::slotProperties()
KPropertiesDialog* dialog = 0;
const KFileItemList list = m_currentView->selectedItems();
if (list.isEmpty()) {
- const KUrl url = m_currentView->url();
+ const QUrl url = m_currentView->url();
dialog = new KPropertiesDialog(url, m_currentView);
} else {
dialog = new KPropertiesDialog(list, m_currentView);
diff --git a/src/views/dolphinviewactionhandler.h b/src/views/dolphinviewactionhandler.h
index e80ffc0df..eb375b5c9 100644
--- a/src/views/dolphinviewactionhandler.h
+++ b/src/views/dolphinviewactionhandler.h
@@ -22,9 +22,7 @@
#ifndef DOLPHINVIEWACTIONHANDLER_H
#define DOLPHINVIEWACTIONHANDLER_H
-#include "libdolphin_export.h"
-#include <KActionMenu>
-#include <KSelectAction>
+#include "dolphin_export.h"
#include "views/dolphinview.h"
#include <QObject>
@@ -48,7 +46,7 @@ class KActionCollection;
* @see DolphinMainWindow
* @see DolphinPart
*/
-class LIBDOLPHINPRIVATE_EXPORT DolphinViewActionHandler : public QObject
+class DOLPHIN_EXPORT DolphinViewActionHandler : public QObject
{
Q_OBJECT
@@ -112,7 +110,7 @@ private Q_SLOTS:
* Moves the selected items of the active view to the trash.
* This methods adds "shift means del" handling.
*/
- void slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers);
+ void slotTrashActivated();
/**
* Deletes the selected items of the active view.
diff --git a/src/views/draganddrophelper.cpp b/src/views/draganddrophelper.cpp
index f8ae0ad03..c0044c96e 100644
--- a/src/views/draganddrophelper.cpp
+++ b/src/views/draganddrophelper.cpp
@@ -20,23 +20,17 @@
#include "draganddrophelper.h"
-#include <KFileItem>
-#include <KLocale>
-#include <konq_operations.h>
-#include <KUrl>
-#include <QApplication>
-#include <QtDBus>
+#include <QUrl>
+#include <QDBusMessage>
+#include <QDBusConnection>
#include <QDropEvent>
+#include <QMimeData>
-KonqOperations* DragAndDropHelper::dropUrls(const KFileItem& destItem, const KUrl& destUrl, QDropEvent* event, QString& error)
-{
- error.clear();
-
- if (!destItem.isNull() && !destItem.isWritable()) {
- error = i18nc("@info:status", "Access denied. Could not write to <filename>%1</filename>", destUrl.pathOrUrl());
- return 0;
- }
+#include <KIO/DropJob>
+#include <KJobWidgets>
+KIO::DropJob* DragAndDropHelper::dropUrls(const QUrl& destUrl, QDropEvent* event, QWidget* window)
+{
const QMimeData* mimeData = event->mimeData();
if (mimeData->hasFormat("application/x-kde-ark-dndextract-service") &&
mimeData->hasFormat("application/x-kde-ark-dndextract-path")) {
@@ -45,21 +39,13 @@ KonqOperations* DragAndDropHelper::dropUrls(const KFileItem& destItem, const KUr
QDBusMessage message = QDBusMessage::createMethodCall(remoteDBusClient, remoteDBusPath,
"org.kde.ark.DndExtract", "extractSelectedFilesTo");
- message.setArguments(QVariantList() << destUrl.pathOrUrl());
+ message.setArguments({destUrl.toDisplayString(QUrl::PreferLocalFile)});
QDBusConnection::sessionBus().call(message);
- } else if (!destItem.isNull() && (destItem.isDir() || destItem.isDesktopFile())) {
- // Drop into a directory or a desktop-file
- const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
- foreach (const KUrl& url, urls) {
- if (url == destUrl) {
- error = i18nc("@info:status", "A folder cannot be dropped into itself");
- return 0;
- }
- }
-
- return KonqOperations::doDrop(destItem, destUrl, event, QApplication::activeWindow(), QList<QAction*>());
} else {
- return KonqOperations::doDrop(KFileItem(), destUrl, event, QApplication::activeWindow(), QList<QAction*>());
+ // Drop into a directory or a desktop-file
+ KIO::DropJob *job = KIO::drop(event, destUrl);
+ KJobWidgets::setWindow(job, window);
+ return job;
}
return 0;
diff --git a/src/views/draganddrophelper.h b/src/views/draganddrophelper.h
index eda5fc5c2..fe77b1e6e 100644
--- a/src/views/draganddrophelper.h
+++ b/src/views/draganddrophelper.h
@@ -21,17 +21,15 @@
#ifndef DRAGANDDROPHELPER_H
#define DRAGANDDROPHELPER_H
-#include "libdolphin_export.h"
+#include "dolphin_export.h"
-#include <QString>
-class KFileItem;
-class KUrl;
+class QUrl;
class QDropEvent;
class QWidget;
-class KonqOperations;
+namespace KIO { class DropJob; }
-class LIBDOLPHINPRIVATE_EXPORT DragAndDropHelper
+class DOLPHIN_EXPORT DragAndDropHelper
{
public:
/**
@@ -40,22 +38,15 @@ public:
* offered to the user. The drag destination must represent a directory or
* a desktop-file, otherwise the dropping gets ignored.
*
- * @param destItem Item of the destination. Can be 0 (KFileItem::isNull()) if
- * no file-item is available for the destination. In this case
- * destUrl is used as fallback. For performance reasons it is
- * recommended to pass a file-item if available.
* @param destUrl URL of the item destination. Is used only if destItem::isNull()
* is true.
* @param event Drop event.
- * @param error Error message intended to be shown for users if dropping is not
- * possible. If an empty string is returned, the dropping has been
- * successful.
- * @return KonqOperations pointer
+ * @param window Associated widget.
+ * @return KIO::DropJob pointer
*/
- static KonqOperations* dropUrls(const KFileItem& destItem,
- const KUrl& destUrl,
- QDropEvent* event,
- QString& error);
+ static KIO::DropJob* dropUrls(const QUrl& destUrl,
+ QDropEvent* event,
+ QWidget *window);
};
#endif
diff --git a/src/views/renamedialog.cpp b/src/views/renamedialog.cpp
index 5c0ae6126..be9e34c4a 100644
--- a/src/views/renamedialog.cpp
+++ b/src/views/renamedialog.cpp
@@ -19,19 +19,24 @@
#include "renamedialog.h"
-#include <KLineEdit>
-#include <KLocale>
-#include <konq_operations.h>
-#include <KStringHandler>
-#include <knuminput.h>
-#include <kmimetype.h>
+#include <KLocalizedString>
+#include <KJobWidgets>
+#include <KIO/CopyJob>
+#include <KIO/FileUndoManager>
+#include <KJobUiDelegate>
#include <QHBoxLayout>
#include <QLabel>
#include <QVBoxLayout>
+#include <QMimeDatabase>
+#include <QDialogButtonBox>
+#include <QPushButton>
+#include <QLineEdit>
+#include <QSpinBox>
+#include <KGuiItem>
RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
- KDialog(parent),
+ QDialog(parent),
m_renameOneItem(false),
m_newName(),
m_lineEdit(0),
@@ -46,23 +51,31 @@ RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
Q_ASSERT(itemCount >= 1);
m_renameOneItem = (itemCount == 1);
- setCaption(m_renameOneItem ?
+ setWindowTitle(m_renameOneItem ?
i18nc("@title:window", "Rename Item") :
i18nc("@title:window", "Rename Items"));
- setButtons(Ok | Cancel);
- setDefaultButton(Ok);
+ QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ setLayout(mainLayout);
+ m_okButton = buttonBox->button(QDialogButtonBox::Ok);
+ m_okButton->setDefault(true);
+ m_okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
+ connect(buttonBox, SIGNAL(accepted()), this, SLOT(slotAccepted()));
+ connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+ m_okButton->setDefault(true);
- setButtonGuiItem(Ok, KGuiItem(i18nc("@action:button", "&Rename"), "dialog-ok-apply"));
+ KGuiItem::assign(m_okButton, KGuiItem(i18nc("@action:button", "&Rename"), "dialog-ok-apply"));
QWidget* page = new QWidget(this);
- setMainWidget(page);
+ mainLayout->addWidget(page);
+ mainLayout->addWidget(buttonBox);
QVBoxLayout* topLayout = new QVBoxLayout(page);
QLabel* editLabel = 0;
if (m_renameOneItem) {
m_newName = items.first().name();
- editLabel = new QLabel(i18nc("@label:textbox", "Rename the item <filename>%1</filename> to:", m_newName),
+ editLabel = new QLabel(xi18nc("@label:textbox", "Rename the item <filename>%1</filename> to:", m_newName),
page);
editLabel->setTextFormat(Qt::PlainText);
} else {
@@ -73,13 +86,15 @@ RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
page);
}
- m_lineEdit = new KLineEdit(page);
- connect(m_lineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotTextChanged(QString)));
+ m_lineEdit = new QLineEdit(page);
+ mainLayout->addWidget(m_lineEdit);
+ connect(m_lineEdit, &QLineEdit::textChanged, this, &RenameDialog::slotTextChanged);
int selectionLength = m_newName.length();
if (m_renameOneItem) {
- const QString fileName = items.first().url().prettyUrl();
- const QString extension = KMimeType::extractKnownExtension(fileName.toLower());
+ const QString fileName = items.first().url().toDisplayString();
+ QMimeDatabase db;
+ const QString extension = db.suffixForFileName(fileName.toLower());
// If the current item is a directory, select the whole file name.
if ((extension.length() > 0) && !items.first().isDir()) {
@@ -101,7 +116,8 @@ RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
if (!m_renameOneItem) {
QSet<QString> extensions;
foreach (const KFileItem& item, m_items) {
- const QString extension = KMimeType::extractKnownExtension(item.url().prettyUrl().toLower());
+ QMimeDatabase db;
+ const QString extension = db.suffixForFileName(item.url().toDisplayString().toLower());
if (extensions.contains(extension)) {
m_allExtensionsDifferent = false;
@@ -112,7 +128,13 @@ RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
}
QLabel* infoLabel = new QLabel(i18nc("@info", "# will be replaced by ascending numbers starting with:"), page);
- m_spinBox = new KIntSpinBox(0, 10000, 1, 1, page, 10);
+ mainLayout->addWidget(infoLabel);
+ m_spinBox = new QSpinBox(page);
+ m_spinBox->setMaximum(10000);
+ m_spinBox->setMinimum(0);
+ m_spinBox->setSingleStep(1);
+ m_spinBox->setValue(1);
+ m_spinBox->setDisplayIntegerBase(10);
QHBoxLayout* horizontalLayout = new QHBoxLayout(page);
horizontalLayout->setMargin(0);
@@ -127,29 +149,34 @@ RenameDialog::~RenameDialog()
{
}
-void RenameDialog::slotButtonClicked(int button)
+void RenameDialog::renameItem(const KFileItem &item, const QString& newName)
{
- if (button == KDialog::Ok) {
- m_newName = m_lineEdit->text();
+ const QUrl oldUrl = item.url();
+ QUrl newUrl = oldUrl.adjusted(QUrl::RemoveFilename);
+ newUrl.setPath(newUrl.path() + KIO::encodeFileName(newName));
- if (m_renameOneItem) {
- Q_ASSERT(m_items.count() == 1);
- const KUrl oldUrl = m_items.first().url();
- KUrl newUrl = oldUrl;
- newUrl.setFileName(KIO::encodeFileName(m_newName));
+ QWidget* widget = parentWidget();
+ if (!widget) {
+ widget = this;
+ }
- QWidget* widget = parentWidget();
- if (!widget) {
- widget = this;
- }
+ KIO::Job * job = KIO::moveAs(oldUrl, newUrl);
+ KJobWidgets::setWindow(job, widget);
+ KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, {oldUrl}, newUrl, job);
+ job->ui()->setAutoErrorHandlingEnabled(true);
+}
- KonqOperations::rename(widget, oldUrl, newUrl);
- } else {
- renameItems();
- }
- }
+void RenameDialog::slotAccepted()
+{
+ m_newName = m_lineEdit->text();
- KDialog::slotButtonClicked(button);
+ if (m_renameOneItem) {
+ Q_ASSERT(m_items.count() == 1);
+ renameItem(m_items.first(), m_newName);
+ } else {
+ renameItems();
+ }
+ accept();
}
void RenameDialog::slotTextChanged(const QString& newName)
@@ -167,7 +194,7 @@ void RenameDialog::slotTextChanged(const QString& newName)
enable = (last - first + 1 == count);
}
}
- enableButtonOk(enable);
+ m_okButton->setEnabled(enable);
}
void RenameDialog::renameItems()
@@ -178,23 +205,16 @@ void RenameDialog::renameItems()
QString newName = indexedName(m_newName, index, QLatin1Char('#'));
++index;
- const KUrl oldUrl = item.url();
- const QString extension = KMimeType::extractKnownExtension(oldUrl.prettyUrl().toLower());
+ const QUrl oldUrl = item.url();
+ QMimeDatabase db;
+ const QString extension = db.suffixForFileName(oldUrl.path().toLower());
if (!extension.isEmpty()) {
newName.append(QLatin1Char('.'));
newName.append(extension);
}
if (oldUrl.fileName() != newName) {
- KUrl newUrl = oldUrl;
- newUrl.setFileName(KIO::encodeFileName(newName));
-
- QWidget* widget = parentWidget();
- if (!widget) {
- widget = this;
- }
-
- KonqOperations::rename(widget, oldUrl, newUrl);
+ renameItem(item, newName);
}
}
}
@@ -218,4 +238,3 @@ QString RenameDialog::indexedName(const QString& name, int index, const QChar& i
return newName;
}
-#include "renamedialog.moc"
diff --git a/src/views/renamedialog.h b/src/views/renamedialog.h
index 29ef8bdf1..a1953e8b3 100644
--- a/src/views/renamedialog.h
+++ b/src/views/renamedialog.h
@@ -20,20 +20,20 @@
#ifndef RENAMEDIALOG_H
#define RENAMEDIALOG_H
-#include "libdolphin_export.h"
+#include "dolphin_export.h"
-#include <KDialog>
+#include <QDialog>
#include <KFileItem>
-
-class KLineEdit;
-class KIntSpinBox;
-
#include <QString>
+class QLineEdit;
+class QSpinBox;
+class QPushButton;
+
/**
* @brief Dialog for renaming a variable number of files.
*/
-class LIBDOLPHINPRIVATE_EXPORT RenameDialog : public KDialog
+class DOLPHIN_EXPORT RenameDialog : public QDialog
{
Q_OBJECT
@@ -41,14 +41,13 @@ public:
explicit RenameDialog(QWidget* parent, const KFileItemList& items);
virtual ~RenameDialog();
-protected slots:
- virtual void slotButtonClicked(int button);
-
private slots:
+ void slotAccepted();
void slotTextChanged(const QString& newName);
private:
void renameItems();
+ void renameItem(const KFileItem &item, const QString& newName);
/**
* @return Returns the string \p name, where the characters represented by
@@ -62,10 +61,11 @@ private:
private:
bool m_renameOneItem;
QString m_newName;
- KLineEdit* m_lineEdit;
+ QLineEdit* m_lineEdit;
KFileItemList m_items;
bool m_allExtensionsDifferent;
- KIntSpinBox* m_spinBox;
+ QSpinBox* m_spinBox;
+ QPushButton* m_okButton;
};
#endif
diff --git a/src/views/tooltips/filemetadatatooltip.cpp b/src/views/tooltips/filemetadatatooltip.cpp
index b72699664..11b9ecd1d 100644
--- a/src/views/tooltips/filemetadatatooltip.cpp
+++ b/src/views/tooltips/filemetadatatooltip.cpp
@@ -23,26 +23,24 @@
#include <KColorScheme>
#include <KSeparator>
-#include <KWindowSystem>
+// For the blurred tooltip background
+#include <KWindowEffects>
#include <KStringHandler>
+#include <QTextDocument>
#include <QLabel>
#include <QStyleOptionFrame>
#include <QStylePainter>
#include <QVBoxLayout>
-#include <QTextDocument>
#include <QTextLayout>
#include <QTextLine>
#ifndef HAVE_BALOO
#include <KFileMetaDataWidget>
#else
-#include <baloo/filemetadatawidget.h>
+#include <Baloo/FileMetaDataWidget>
#endif
-// For the blurred tooltip background
-#include <plasma/windoweffects.h>
-
FileMetaDataToolTip::FileMetaDataToolTip(QWidget* parent) :
QWidget(parent),
m_preview(0),
@@ -72,13 +70,15 @@ FileMetaDataToolTip::FileMetaDataToolTip(QWidget* parent) :
// Create widget for the meta data
#ifndef HAVE_BALOO
m_fileMetaDataWidget = new KFileMetaDataWidget(this);
+ connect(m_fileMetaDataWidget, &KFileMetaDataWidget::metaDataRequestFinished,
+ this, &FileMetaDataToolTip::metaDataRequestFinished);
#else
m_fileMetaDataWidget = new Baloo::FileMetaDataWidget(this);
+ connect(m_fileMetaDataWidget, &Baloo::FileMetaDataWidget::metaDataRequestFinished,
+ this, &FileMetaDataToolTip::metaDataRequestFinished);
#endif
m_fileMetaDataWidget->setForegroundRole(QPalette::ToolTipText);
m_fileMetaDataWidget->setReadOnly(true);
- connect(m_fileMetaDataWidget, SIGNAL(metaDataRequestFinished(KFileItemList)),
- this, SIGNAL(metaDataRequestFinished(KFileItemList)));
QVBoxLayout* textLayout = new QVBoxLayout();
textLayout->addWidget(m_name);
@@ -174,8 +174,8 @@ void FileMetaDataToolTip::paintEvent(QPaintEvent* event)
void FileMetaDataToolTip::showEvent(QShowEvent *)
{
- Plasma::WindowEffects::overrideShadow(winId(), true);
- Plasma::WindowEffects::enableBlurBehind(winId(), true, mask());
+#pragma message("TODO: port Plasma::WindowEffects::overrideShadow")
+ //Plasma::WindowEffects::overrideShadow(winId(), true);
+ KWindowEffects::enableBlurBehind(winId(), true, mask());
}
-#include "filemetadatatooltip.moc"
diff --git a/src/views/tooltips/filemetadatatooltip.h b/src/views/tooltips/filemetadatatooltip.h
index 7197871fc..379b025c8 100644
--- a/src/views/tooltips/filemetadatatooltip.h
+++ b/src/views/tooltips/filemetadatatooltip.h
@@ -70,8 +70,8 @@ signals:
void metaDataRequestFinished(const KFileItemList& items);
protected:
- virtual void paintEvent(QPaintEvent* event);
- virtual void showEvent(QShowEvent *);
+ virtual void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE;
+ virtual void showEvent(QShowEvent *) Q_DECL_OVERRIDE;
private:
QLabel* m_preview;
diff --git a/src/views/tooltips/tooltipmanager.cpp b/src/views/tooltips/tooltipmanager.cpp
index bd6948363..0636df795 100644
--- a/src/views/tooltips/tooltipmanager.cpp
+++ b/src/views/tooltips/tooltipmanager.cpp
@@ -20,15 +20,14 @@
#include "tooltipmanager.h"
#include "filemetadatatooltip.h"
-#include <KIcon>
+#include <QIcon>
#include <KIO/JobUiDelegate>
#include <KIO/PreviewJob>
+#include <KJobWidgets>
#include <QApplication>
#include <QDesktopWidget>
#include <QLayout>
-#include <QScrollArea>
-#include <QScrollBar>
#include <QStyle>
#include <QTimer>
@@ -51,12 +50,12 @@ ToolTipManager::ToolTipManager(QWidget* parent) :
m_showToolTipTimer = new QTimer(this);
m_showToolTipTimer->setSingleShot(true);
m_showToolTipTimer->setInterval(500);
- connect(m_showToolTipTimer, SIGNAL(timeout()), this, SLOT(showToolTip()));
+ connect(m_showToolTipTimer, &QTimer::timeout, this, static_cast<void(ToolTipManager::*)()>(&ToolTipManager::showToolTip));
m_contentRetrievalTimer = new QTimer(this);
m_contentRetrievalTimer->setSingleShot(true);
m_contentRetrievalTimer->setInterval(200);
- connect(m_contentRetrievalTimer, SIGNAL(timeout()), this, SLOT(startContentRetrieval()));
+ connect(m_contentRetrievalTimer, &QTimer::timeout, this, &ToolTipManager::startContentRetrieval);
Q_ASSERT(m_contentRetrievalTimer->interval() < m_showToolTipTimer->interval());
}
@@ -81,8 +80,8 @@ void ToolTipManager::showToolTip(const KFileItem& item, const QRectF& itemRect)
// meta data retrieval, when passing rapidly over a lot of items.
Q_ASSERT(!m_fileMetaDataToolTip);
m_fileMetaDataToolTip = new FileMetaDataToolTip();
- connect(m_fileMetaDataToolTip, SIGNAL(metaDataRequestFinished(KFileItemList)),
- this, SLOT(slotMetaDataRequestFinished()));
+ connect(m_fileMetaDataToolTip, &FileMetaDataToolTip::metaDataRequestFinished,
+ this, &ToolTipManager::slotMetaDataRequestFinished);
m_contentRetrievalTimer->start();
m_showToolTipTimer->start();
@@ -132,13 +131,13 @@ void ToolTipManager::startContentRetrieval()
KIO::PreviewJob* job = new KIO::PreviewJob(KFileItemList() << m_item, QSize(256, 256));
job->setIgnoreMaximumSize(m_item.isLocalFile());
if (job->ui()) {
- job->ui()->setWindow(qApp->activeWindow());
+ KJobWidgets::setWindow(job, qApp->activeWindow());
}
- connect(job, SIGNAL(gotPreview(KFileItem,QPixmap)),
- this, SLOT(setPreviewPix(KFileItem,QPixmap)));
- connect(job, SIGNAL(failed(KFileItem)),
- this, SLOT(previewFailed()));
+ connect(job, &KIO::PreviewJob::gotPreview,
+ this, &ToolTipManager::setPreviewPix);
+ connect(job, &KIO::PreviewJob::failed,
+ this, &ToolTipManager::previewFailed);
}
@@ -166,7 +165,7 @@ void ToolTipManager::previewFailed()
return;
}
- const QPixmap pixmap = KIcon(m_item.iconName()).pixmap(128, 128);
+ const QPixmap pixmap = QIcon::fromTheme(m_item.iconName()).pixmap(128, 128);
m_fileMetaDataToolTip->setPreview(pixmap);
if (!m_showToolTipTimer->isActive()) {
showToolTip();
@@ -266,4 +265,3 @@ void ToolTipManager::showToolTip()
m_toolTipRequested = false;
}
-#include "tooltipmanager.moc"
diff --git a/src/views/tooltips/tooltipmanager.h b/src/views/tooltips/tooltipmanager.h
index 4fd8f843e..f6d8b8f26 100644
--- a/src/views/tooltips/tooltipmanager.h
+++ b/src/views/tooltips/tooltipmanager.h
@@ -25,11 +25,7 @@
#include <KFileItem>
-class DolphinModel;
-class DolphinSortFilterProxyModel;
class FileMetaDataToolTip;
-class QAbstractItemView;
-class QModelIndex;
class QTimer;
/**
diff --git a/src/views/versioncontrol/kversioncontrolplugin.cpp b/src/views/versioncontrol/kversioncontrolplugin.cpp
new file mode 100644
index 000000000..2c0632878
--- /dev/null
+++ b/src/views/versioncontrol/kversioncontrolplugin.cpp
@@ -0,0 +1,29 @@
+/*****************************************************************************
+ * Copyright (C) 2011 by Vishesh Yadav <[email protected]> *
+ * Copyright (C) 2011 by Peter Penz <[email protected]> *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License version 2 as published by the Free Software Foundation. *
+ * *
+ * This library is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public License *
+ * along with this library; see the file COPYING.LIB. If not, write to *
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301, USA. *
+ *****************************************************************************/
+
+#include "kversioncontrolplugin.h"
+
+KVersionControlPlugin::KVersionControlPlugin(QObject* parent) :
+ QObject(parent)
+{
+}
+
+KVersionControlPlugin::~KVersionControlPlugin()
+{
+}
diff --git a/src/views/versioncontrol/kversioncontrolplugin.h b/src/views/versioncontrol/kversioncontrolplugin.h
new file mode 100644
index 000000000..e5a267848
--- /dev/null
+++ b/src/views/versioncontrol/kversioncontrolplugin.h
@@ -0,0 +1,223 @@
+/*****************************************************************************
+ * Copyright (C) 2011 by Vishesh Yadav <[email protected]> *
+ * Copyright (C) 2011 by Peter Penz <[email protected]> *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License version 2 as published by the Free Software Foundation. *
+ * *
+ * This library is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public License *
+ * along with this library; see the file COPYING.LIB. If not, write to *
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301, USA. *
+ *****************************************************************************/
+
+#ifndef KVERSIONCONTROLPLUGIN_H
+#define KVERSIONCONTROLPLUGIN_H
+
+#include <dolphin_export.h>
+
+#include <QObject>
+#include <KFileItem>
+#include <QAction>
+
+/**
+ * @brief Base class for version control plugins.
+ *
+ * Enables the file manager to show the version state
+ * of a versioned file. To write a custom plugin, the following
+ * steps are required (in the example below it is assumed that a plugin for
+ * Subversion will be written):
+ *
+ * - Create a fileviewsvnplugin.desktop file with the following content:
+ * <code>
+ * [Desktop Entry]
+ * Type=Service
+ * Name=Subversion
+ * X-KDE-ServiceTypes=FileViewVersionControlPlugin
+ * MimeType=text/plain;
+ * X-KDE-Library=fileviewsvnplugin
+ * </code>
+ *
+ * - Create a class FileViewSvnPlugin derived from KVersionControlPlugin and
+ * implement all abstract interfaces (fileviewsvnplugin.h, fileviewsvnplugin.cpp).
+ *
+ * - Take care that the constructor has the following signature:
+ * <code>
+ * FileViewSvnPlugin(QObject* parent, const QList<QVariant>& args);
+ * </code>
+ *
+ * - Add the following lines at the top of fileviewsvnplugin.cpp:
+ * <code>
+ * #include <KPluginFactory>
+ * #include <KPluginLoader>
+ * K_PLUGIN_FACTORY(FileViewSvnPluginFactory, registerPlugin<FileViewSvnPlugin>();)
+ * K_EXPORT_PLUGIN(FileViewSvnPluginFactory("fileviewsvnplugin"))
+ * </code>
+ *
+ * - Add the following lines to your CMakeLists.txt file:
+ * <code>
+ * kde4_add_plugin(fileviewsvnplugin fileviewsvnplugin.cpp)
+ * target_link_libraries(fileviewsvnplugin konq)
+ * install(FILES fileviewsvnplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR})
+ * </code>
+ *
+ * General implementation notes:
+ *
+ * - The implementations of beginRetrieval(), endRetrieval() and versionState()
+ * can contain blocking operations, as Dolphin will execute
+ * those methods in a separate thread. It is assured that
+ * all other methods are invoked in a serialized way, so that it is not necessary for
+ * the plugin to use any mutex.
+ *
+ * - Dolphin keeps only one instance of the plugin, which is instantiated shortly after
+ * starting Dolphin. Take care that the constructor does no expensive and time
+ * consuming operations.
+ *
+ * @since 4.8
+ */
+class DOLPHIN_EXPORT KVersionControlPlugin : public QObject
+{
+ Q_OBJECT
+
+public:
+ enum ItemVersion
+ {
+ /** The file is not under version control. */
+ UnversionedVersion,
+ /**
+ * The file is under version control and represents
+ * the latest version.
+ */
+ NormalVersion,
+ /**
+ * The file is under version control and a newer
+ * version exists on the main branch.
+ */
+ UpdateRequiredVersion,
+ /**
+ * The file is under version control and has been
+ * modified locally. All modifications will be part
+ * of the next commit.
+ */
+ LocallyModifiedVersion,
+ /**
+ * The file has not been under version control but
+ * has been marked to get added with the next commit.
+ */
+ AddedVersion,
+ /**
+ * The file is under version control but has been marked
+ * for getting removed with the next commit.
+ */
+ RemovedVersion,
+ /**
+ * The file is under version control and has been locally
+ * modified. A modification has also been done on the main
+ * branch.
+ */
+ ConflictingVersion,
+ /**
+ * The file is under version control and has local
+ * modifications, which will not be part of the next
+ * commit (or are "unstaged" in git jargon).
+ * @since 4.6
+ */
+ LocallyModifiedUnstagedVersion,
+ /**
+ * The file is not under version control and is listed
+ * in the ignore list of the version control system.
+ * @since 4.8
+ */
+ IgnoredVersion,
+ /**
+ * The file is is tracked by the version control system, but
+ * is missing in the directory (e.g. by deleted without using
+ * a version control command).
+ * @since 4.8
+ */
+ MissingVersion
+ };
+
+ KVersionControlPlugin(QObject* parent = 0);
+ virtual ~KVersionControlPlugin();
+
+ /**
+ * Returns the name of the file which stores
+ * the version controls information.
+ * (e. g. .svn, .cvs, .git).
+ */
+ virtual QString fileName() const = 0;
+
+ /**
+ * Is invoked whenever the version control
+ * information will get retrieved for the directory
+ * \p directory. It is assured that the directory
+ * contains a trailing slash.
+ */
+ virtual bool beginRetrieval(const QString& directory) = 0;
+
+ /**
+ * Is invoked after the version control information has been
+ * received. It is assured that
+ * KVersionControlPluginV2::beginInfoRetrieval() has been
+ * invoked before.
+ */
+ virtual void endRetrieval() = 0;
+
+ /**
+ * @return The version for the item \p item.
+ * It is assured that KVersionControlPlugin::beginInfoRetrieval() has been
+ * invoked before and that the file is part of the directory specified
+ * in beginInfoRetrieval().
+ */
+ virtual ItemVersion itemVersion(const KFileItem& item) const = 0;
+
+ /**
+ * @return List of actions that are available for the items \p items.
+ * It is recommended to keep the number of returned actions small
+ * in case if an item is an unversioned directory that is not
+ * inside the hierarchy tree of the version control system. This
+ * prevents having a cluttered context menu for directories
+ * outside the version control system.
+ */
+ virtual QList<QAction*> actions(const KFileItemList& items) const = 0;
+
+Q_SIGNALS:
+ /**
+ * Should be emitted when the version state of items might have been changed
+ * after the last retrieval (e. g. by executing a context menu action
+ * of the version control plugin). The file manager will be triggered to
+ * update the version states of the directory \p directory by invoking
+ * KVersionControlPlugin::beginRetrieval(),
+ * KVersionControlPlugin::itemVersion() and
+ * KVersionControlPlugin::endRetrieval().
+ */
+ void itemVersionsChanged();
+
+ /**
+ * Is emitted if an information message with the content \a msg
+ * should be shown.
+ */
+ void infoMessage(const QString& msg);
+
+ /**
+ * Is emitted if an error message with the content \a msg
+ * should be shown.
+ */
+ void errorMessage(const QString& msg);
+
+ /**
+ * Is emitted if an "operation completed" message with the content \a msg
+ * should be shown.
+ */
+ void operationCompletedMessage(const QString& msg);
+};
+
+#endif // KVERSIONCONTROLPLUGIN_H
+
diff --git a/src/views/versioncontrol/updateitemstatesthread.cpp b/src/views/versioncontrol/updateitemstatesthread.cpp
index 62fcd09aa..e4413fabf 100644
--- a/src/views/versioncontrol/updateitemstatesthread.cpp
+++ b/src/views/versioncontrol/updateitemstatesthread.cpp
@@ -19,8 +19,7 @@
#include "updateitemstatesthread.h"
-#include <kversioncontrolplugin2.h>
-
+#include <QVector>
#include <QMutexLocker>
UpdateItemStatesThread::UpdateItemStatesThread(KVersionControlPlugin* plugin,
@@ -52,17 +51,10 @@ void UpdateItemStatesThread::run()
if (m_plugin->beginRetrieval(it.key())) {
QVector<VersionControlObserver::ItemState>& items = it.value();
const int count = items.count();
-
- KVersionControlPlugin2* pluginV2 = qobject_cast<KVersionControlPlugin2*>(m_plugin);
- if (pluginV2) {
- for (int i = 0; i < count; ++i) {
- items[i].version = pluginV2->itemVersion(items[i].item);
- }
- } else {
- for (int i = 0; i < count; ++i) {
- const KVersionControlPlugin::VersionState state = m_plugin->versionState(items[i].item);
- items[i].version = static_cast<KVersionControlPlugin2::ItemVersion>(state);
- }
+ for (int i = 0; i < count; ++i) {
+ const KFileItem& item = items.at(i).first;
+ const KVersionControlPlugin::ItemVersion version = m_plugin->itemVersion(item);
+ items[i].second = version;
}
}
@@ -75,4 +67,3 @@ QMap<QString, QVector<VersionControlObserver::ItemState> > UpdateItemStatesThrea
return m_itemStates;
}
-#include "updateitemstatesthread.moc"
diff --git a/src/views/versioncontrol/updateitemstatesthread.h b/src/views/versioncontrol/updateitemstatesthread.h
index 5c6c6a208..3dc03fc75 100644
--- a/src/views/versioncontrol/updateitemstatesthread.h
+++ b/src/views/versioncontrol/updateitemstatesthread.h
@@ -20,20 +20,18 @@
#ifndef UPDATEITEMSTATESTHREAD_H
#define UPDATEITEMSTATESTHREAD_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <views/versioncontrol/versioncontrolobserver.h>
#include <QMutex>
#include <QThread>
-class KVersionControlPlugin;
-
/**
* The performance of updating the version state of items depends
* on the used plugin. To prevent that Dolphin gets blocked by a
* slow plugin, the updating is delegated to a thread.
*/
-class LIBDOLPHINPRIVATE_EXPORT UpdateItemStatesThread : public QThread
+class DOLPHIN_EXPORT UpdateItemStatesThread : public QThread
{
Q_OBJECT
@@ -53,7 +51,7 @@ public:
QMap<QString, QVector<VersionControlObserver::ItemState> > itemStates() const;
protected:
- virtual void run();
+ virtual void run() Q_DECL_OVERRIDE;
private:
QMutex* m_globalPluginMutex; // Protects the m_plugin globally
diff --git a/src/views/versioncontrol/versioncontrolobserver.cpp b/src/views/versioncontrol/versioncontrolobserver.cpp
index 6affe80d3..4b0d65029 100644
--- a/src/views/versioncontrol/versioncontrolobserver.cpp
+++ b/src/views/versioncontrol/versioncontrolobserver.cpp
@@ -21,16 +21,15 @@
#include "dolphin_versioncontrolsettings.h"
-#include <KLocale>
+#include <KLocalizedString>
#include <KService>
+#include "dolphindebug.h"
#include <KServiceTypeTrader>
#include <kitemviews/kfileitemmodel.h>
-#include <kversioncontrolplugin2.h>
#include "updateitemstatesthread.h"
#include <QFile>
-#include <QMutexLocker>
#include <QTimer>
VersionControlObserver::VersionControlObserver(QObject* parent) :
@@ -51,8 +50,8 @@ VersionControlObserver::VersionControlObserver(QObject* parent) :
m_dirVerificationTimer = new QTimer(this);
m_dirVerificationTimer->setSingleShot(true);
m_dirVerificationTimer->setInterval(500);
- connect(m_dirVerificationTimer, SIGNAL(timeout()),
- this, SLOT(verifyDirectory()));
+ connect(m_dirVerificationTimer, &QTimer::timeout,
+ this, &VersionControlObserver::verifyDirectory);
}
VersionControlObserver::~VersionControlObserver()
@@ -66,19 +65,19 @@ VersionControlObserver::~VersionControlObserver()
void VersionControlObserver::setModel(KFileItemModel* model)
{
if (m_model) {
- disconnect(m_model, SIGNAL(itemsInserted(KItemRangeList)),
- this, SLOT(delayedDirectoryVerification()));
- disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(delayedDirectoryVerification()));
+ disconnect(m_model, &KFileItemModel::itemsInserted,
+ this, &VersionControlObserver::delayedDirectoryVerification);
+ disconnect(m_model, &KFileItemModel::itemsChanged,
+ this, &VersionControlObserver::delayedDirectoryVerification);
}
m_model = model;
if (model) {
- connect(m_model, SIGNAL(itemsInserted(KItemRangeList)),
- this, SLOT(delayedDirectoryVerification()));
- connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(delayedDirectoryVerification()));
+ connect(m_model, &KFileItemModel::itemsInserted,
+ this, &VersionControlObserver::delayedDirectoryVerification);
+ connect(m_model, &KFileItemModel::itemsChanged,
+ this, &VersionControlObserver::delayedDirectoryVerification);
}
}
@@ -89,42 +88,20 @@ KFileItemModel* VersionControlObserver::model() const
QList<QAction*> VersionControlObserver::actions(const KFileItemList& items) const
{
- QList<QAction*> actions;
-
bool hasNullItems = false;
foreach (const KFileItem& item, items) {
if (item.isNull()) {
- kWarning() << "Requesting version-control-actions for empty items";
+ qCWarning(DolphinDebug) << "Requesting version-control-actions for empty items";
hasNullItems = true;
break;
}
}
- if (!m_model || hasNullItems) {
- return actions;
- }
-
- KVersionControlPlugin2* pluginV2 = qobject_cast<KVersionControlPlugin2*>(m_plugin);
- if (pluginV2) {
- // Use version 2 of the KVersionControlPlugin which allows providing actions
- // also for non-versioned directories.
- actions = pluginV2->actions(items);
- } else if (isVersioned()) {
- // Support deprecated interfaces from KVersionControlPlugin version 1.
- // Context menu actions where only available for versioned directories.
- QString directory;
- if (items.count() == 1) {
- const KFileItem rootItem = m_model->rootItem();
- if (!rootItem.isNull() && items.first().url() == rootItem.url()) {
- directory = rootItem.url().path(KUrl::AddTrailingSlash);
- }
- }
-
- actions = directory.isEmpty() ? m_plugin->contextMenuActions(items)
- : m_plugin->contextMenuActions(directory);
+ if (!m_model || hasNullItems || !isVersioned()) {
+ return {};
}
- return actions;
+ return m_plugin->actions(items);
}
void VersionControlObserver::delayedDirectoryVerification()
@@ -156,20 +133,14 @@ void VersionControlObserver::verifyDirectory()
m_plugin = searchPlugin(rootItem.url());
if (m_plugin) {
- KVersionControlPlugin2* pluginV2 = qobject_cast<KVersionControlPlugin2*>(m_plugin);
- if (pluginV2) {
- connect(pluginV2, SIGNAL(itemVersionsChanged()),
- this, SLOT(silentDirectoryVerification()));
- } else {
- connect(m_plugin, SIGNAL(versionStatesChanged()),
- this, SLOT(silentDirectoryVerification()));
- }
- connect(m_plugin, SIGNAL(infoMessage(QString)),
- this, SIGNAL(infoMessage(QString)));
- connect(m_plugin, SIGNAL(errorMessage(QString)),
- this, SIGNAL(errorMessage(QString)));
- connect(m_plugin, SIGNAL(operationCompletedMessage(QString)),
- this, SIGNAL(operationCompletedMessage(QString)));
+ connect(m_plugin, &KVersionControlPlugin::itemVersionsChanged,
+ this, &VersionControlObserver::silentDirectoryVerification);
+ connect(m_plugin, &KVersionControlPlugin::infoMessage,
+ this, &VersionControlObserver::infoMessage);
+ connect(m_plugin, &KVersionControlPlugin::errorMessage,
+ this, &VersionControlObserver::errorMessage);
+ connect(m_plugin, &KVersionControlPlugin::operationCompletedMessage,
+ this, &VersionControlObserver::operationCompletedMessage);
if (!m_versionedDirectory) {
m_versionedDirectory = true;
@@ -204,9 +175,11 @@ void VersionControlObserver::slotThreadFinished()
const QVector<ItemState>& items = it.value();
foreach (const ItemState& item, items) {
+ const KFileItem& fileItem = item.first;
+ const KVersionControlPlugin::ItemVersion version = item.second;
QHash<QByteArray, QVariant> values;
- values.insert("version", QVariant(item.version));
- m_model->setData(m_model->index(item.item), values);
+ values.insert("version", QVariant(version));
+ m_model->setData(m_model->index(fileItem), values);
}
}
@@ -241,10 +214,10 @@ void VersionControlObserver::updateItemStates()
emit infoMessage(i18nc("@info:status", "Updating version information..."));
}
m_updateItemStatesThread = new UpdateItemStatesThread(m_plugin, itemStates);
- connect(m_updateItemStatesThread, SIGNAL(finished()),
- this, SLOT(slotThreadFinished()));
- connect(m_updateItemStatesThread, SIGNAL(finished()),
- m_updateItemStatesThread, SLOT(deleteLater()));
+ connect(m_updateItemStatesThread, &UpdateItemStatesThread::finished,
+ this, &VersionControlObserver::slotThreadFinished);
+ connect(m_updateItemStatesThread, &UpdateItemStatesThread::finished,
+ m_updateItemStatesThread, &UpdateItemStatesThread::deleteLater);
m_updateItemStatesThread->start(); // slotThreadFinished() is called when finished
}
@@ -265,8 +238,8 @@ int VersionControlObserver::createItemStatesList(QMap<QString, QVector<ItemState
if (expansionLevel == currentExpansionLevel) {
ItemState itemState;
- itemState.item = m_model->fileItem(index);
- itemState.version = KVersionControlPlugin2::UnversionedVersion;
+ itemState.first = m_model->fileItem(index);
+ itemState.second = KVersionControlPlugin::UnversionedVersion;
items.append(itemState);
} else if (expansionLevel > currentExpansionLevel) {
@@ -278,14 +251,14 @@ int VersionControlObserver::createItemStatesList(QMap<QString, QVector<ItemState
}
if (items.count() > 0) {
- const KUrl& url = items.first().item.url();
- itemStates.insert(url.directory(KUrl::AppendTrailingSlash), items);
+ const QUrl& url = items.first().first.url();
+ itemStates.insert(url.adjusted(QUrl::RemoveFilename).path(), items);
}
return index - firstIndex; // number of processed items
}
-KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& directory) const
+KVersionControlPlugin* VersionControlObserver::searchPlugin(const QUrl& directory) const
{
static bool pluginsAvailable = true;
static QList<KVersionControlPlugin*> plugins;
@@ -324,7 +297,7 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director
// Verify whether the current directory contains revision information
// like .svn, .git, ...
foreach (KVersionControlPlugin* plugin, plugins) {
- const QString fileName = directory.path(KUrl::AddTrailingSlash) + plugin->fileName();
+ const QString fileName = directory.path() + '/' + plugin->fileName();
if (QFile::exists(fileName)) {
// The score of this plugin is 0 (best), so we can just return this plugin,
// instead of going through the plugin scoring procedure, we can't find a better one ;)
@@ -338,11 +311,11 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director
// m_versionedDirectory. Drawback: Until e. g. Git is recognized, the root directory
// must be shown at least once.
if (m_versionedDirectory) {
- KUrl dirUrl(directory);
- KUrl upUrl = dirUrl.upUrl();
+ QUrl dirUrl(directory);
+ QUrl upUrl = KIO::upUrl(dirUrl);
int upUrlCounter = 1;
while ((upUrlCounter < bestScore) && (upUrl != dirUrl)) {
- const QString fileName = dirUrl.path(KUrl::AddTrailingSlash) + plugin->fileName();
+ const QString fileName = dirUrl.path() + '/' + plugin->fileName();
if (QFile::exists(fileName)) {
if (upUrlCounter < bestScore) {
bestPlugin = plugin;
@@ -351,7 +324,7 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director
break;
}
dirUrl = upUrl;
- upUrl = dirUrl.upUrl();
+ upUrl = KIO::upUrl(dirUrl);
++upUrlCounter;
}
}
@@ -365,4 +338,3 @@ bool VersionControlObserver::isVersioned() const
return m_versionedDirectory && m_plugin;
}
-#include "versioncontrolobserver.moc"
diff --git a/src/views/versioncontrol/versioncontrolobserver.h b/src/views/versioncontrol/versioncontrolobserver.h
index d12d2cfe0..c817c2187 100644
--- a/src/views/versioncontrol/versioncontrolobserver.h
+++ b/src/views/versioncontrol/versioncontrolobserver.h
@@ -20,12 +20,14 @@
#ifndef VERSIONCONTROLOBSERVER_H
#define VERSIONCONTROLOBSERVER_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
+
+#include "kversioncontrolplugin.h"
#include <KFileItem>
-#include <kversioncontrolplugin2.h>
+
+#include <QUrl>
#include <QList>
-#include <QMutex>
#include <QObject>
#include <QString>
@@ -43,7 +45,7 @@ class UpdateItemStatesThread;
*
* @see VersionControlPlugin
*/
-class LIBDOLPHINPRIVATE_EXPORT VersionControlObserver : public QObject
+class DOLPHIN_EXPORT VersionControlObserver : public QObject
{
Q_OBJECT
@@ -100,11 +102,7 @@ private slots:
void slotThreadFinished();
private:
- struct ItemState
- {
- KFileItem item;
- KVersionControlPlugin2::ItemVersion version;
- };
+ typedef QPair<KFileItem, KVersionControlPlugin::ItemVersion> ItemState;
void updateItemStates();
@@ -128,7 +126,7 @@ private:
* Returns a matching plugin for the given directory.
* 0 is returned, if no matching plugin has been found.
*/
- KVersionControlPlugin* searchPlugin(const KUrl& directory) const;
+ KVersionControlPlugin* searchPlugin(const QUrl& directory) const;
/**
* Returns true, if the directory contains a version control information.
diff --git a/src/views/viewmodecontroller.cpp b/src/views/viewmodecontroller.cpp
index 26e181888..28f9ea472 100644
--- a/src/views/viewmodecontroller.cpp
+++ b/src/views/viewmodecontroller.cpp
@@ -33,12 +33,12 @@ ViewModeController::~ViewModeController()
{
}
-KUrl ViewModeController::url() const
+QUrl ViewModeController::url() const
{
return m_url;
}
-void ViewModeController::redirectToUrl(const KUrl& url)
+void ViewModeController::redirectToUrl(const QUrl& url)
{
m_url = url;
}
@@ -76,7 +76,7 @@ int ViewModeController::zoomLevel() const
return m_zoomLevel;
}
-void ViewModeController::setUrl(const KUrl& url)
+void ViewModeController::setUrl(const QUrl& url)
{
if (m_url != url) {
m_url = url;
@@ -85,4 +85,3 @@ void ViewModeController::setUrl(const KUrl& url)
}
}
-#include "viewmodecontroller.moc"
diff --git a/src/views/viewmodecontroller.h b/src/views/viewmodecontroller.h
index f4765955b..4b1ff2083 100644
--- a/src/views/viewmodecontroller.h
+++ b/src/views/viewmodecontroller.h
@@ -20,9 +20,9 @@
#ifndef VIEWMODECONTROLLER_H
#define VIEWMODECONTROLLER_H
-#include <KUrl>
+#include <QUrl>
#include <QObject>
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <views/dolphinview.h>
/**
@@ -33,7 +33,7 @@
* connect to signals of the ViewModeController to react on changes. The view
* implementations get only read-access to the ViewModeController.
*/
-class LIBDOLPHINPRIVATE_EXPORT ViewModeController : public QObject
+class DOLPHIN_EXPORT ViewModeController : public QObject
{
Q_OBJECT
@@ -44,13 +44,13 @@ public:
/**
* @return URL that is shown by the view mode implementation.
*/
- KUrl url() const;
+ QUrl url() const;
/**
* Sets the URL to \a url and does nothing else. Called when
* a redirection happens. See ViewModeController::setUrl()
*/
- void redirectToUrl(const KUrl& url);
+ void redirectToUrl(const QUrl& url);
/**
* Informs the view mode implementation about a change of the activation
@@ -83,13 +83,13 @@ public slots:
* Sets the URL to \a url and emits the signals cancelPreviews() and
* urlChanged() if \a url is different for the current URL.
*/
- void setUrl(const KUrl& url);
+ void setUrl(const QUrl& url);
signals:
/**
* Is emitted if the URL has been changed by ViewModeController::setUrl().
*/
- void urlChanged(const KUrl& url);
+ void urlChanged(const QUrl& url);
/**
* Is emitted, if ViewModeController::indicateActivationChange() has been
@@ -118,7 +118,7 @@ signals:
private:
int m_zoomLevel;
QString m_nameFilter;
- KUrl m_url;
+ QUrl m_url;
};
#endif
diff --git a/src/views/viewproperties.cpp b/src/views/viewproperties.cpp
index d4ecfafa0..05c993585 100644
--- a/src/views/viewproperties.cpp
+++ b/src/views/viewproperties.cpp
@@ -23,15 +23,14 @@
#include "dolphin_directoryviewpropertysettings.h"
#include "dolphin_generalsettings.h"
-#include <KComponentData>
-#include <KLocale>
-#include <KStandardDirs>
-#include <KUrl>
+#include <QUrl>
+#include "dolphindebug.h"
#include <QCryptographicHash>
#include <QDate>
#include <QFile>
#include <QFileInfo>
+#include <QStandardPaths>
namespace {
const int AdditionalInfoViewPropertiesVersion = 1;
@@ -41,13 +40,13 @@ namespace {
// String representation to mark the additional properties of
// the details view as customized by the user. See
// ViewProperties::visibleRoles() for more information.
- const char* CustomizedDetailsString = "CustomizedDetails";
+ const char CustomizedDetailsString[] = "CustomizedDetails";
// Filename that is used for storing the properties
- const char* ViewPropertiesFileName = ".directory";
+ const char ViewPropertiesFileName[] = ".directory";
}
-ViewProperties::ViewProperties(const KUrl& url) :
+ViewProperties::ViewProperties(const QUrl& url) :
m_changedProps(false),
m_autoSave(true),
m_node(0)
@@ -61,10 +60,10 @@ ViewProperties::ViewProperties(const KUrl& url) :
// we store the properties information in a local file.
if (useGlobalViewProps) {
m_filePath = destinationDir("global");
- } else if (url.protocol().contains("search")) {
+ } else if (url.scheme().contains("search")) {
m_filePath = destinationDir("search/") + directoryHashForUrl(url);
useDetailsViewWithPath = true;
- } else if (url.protocol() == QLatin1String("trash")) {
+ } else if (url.scheme() == QLatin1String("trash")) {
m_filePath = destinationDir("trash");
useDetailsViewWithPath = true;
} else if (url.isLocalFile()) {
@@ -97,13 +96,13 @@ ViewProperties::ViewProperties(const KUrl& url) :
if (useDefaultProps) {
if (useDetailsViewWithPath) {
setViewMode(DolphinView::DetailsView);
- setVisibleRoles(QList<QByteArray>() << "path");
+ setVisibleRoles({"path"});
} else {
// The global view-properties act as default for directories without
// any view-property configuration. Constructing a ViewProperties
- // instance for an empty KUrl ensures that the global view-properties
+ // instance for an empty QUrl ensures that the global view-properties
// are loaded.
- KUrl emptyUrl;
+ QUrl emptyUrl;
ViewProperties defaultProps(emptyUrl);
setDirProperties(defaultProps);
@@ -285,8 +284,7 @@ QList<QByteArray> ViewProperties::visibleRoles() const
// by "CustomizedDetails"), also a details-view with no additional information
// is accepted.
- QList<QByteArray> roles;
- roles.append("text");
+ QList<QByteArray> roles{"text"};
// Iterate through all stored keys and append all roles that match to
// the current view mode.
@@ -361,10 +359,11 @@ void ViewProperties::update()
void ViewProperties::save()
{
- kDebug() << "Saving view-properties to" << m_filePath;
- KStandardDirs::makeDir(m_filePath);
+ qCDebug(DolphinDebug) << "Saving view-properties to" << m_filePath;
+ QDir dir;
+ dir.mkpath(m_filePath);
m_node->setVersion(CurrentViewPropertiesVersion);
- m_node->writeConfig();
+ m_node->save();
m_changedProps = false;
}
@@ -376,9 +375,9 @@ bool ViewProperties::exist() const
QString ViewProperties::destinationDir(const QString& subDir) const
{
- QString basePath = KGlobal::mainComponent().componentName();
- basePath.append("/view_properties/").append(subDir);
- return KStandardDirs::locateLocal("data", basePath);
+ QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
+ path.append("/view_properties/").append(subDir);
+ return path;
}
QString ViewProperties::viewModePrefix() const
@@ -389,7 +388,7 @@ QString ViewProperties::viewModePrefix() const
case DolphinView::IconsView: prefix = "Icons_"; break;
case DolphinView::CompactView: prefix = "Compact_"; break;
case DolphinView::DetailsView: prefix = "Details_"; break;
- default: kWarning() << "Unknown view-mode of the view properties";
+ default: qCWarning(DolphinDebug) << "Unknown view-mode of the view properties";
}
return prefix;
@@ -461,18 +460,10 @@ bool ViewProperties::isPartOfHome(const QString& filePath)
return filePath.startsWith(homePath);
}
-QString ViewProperties::directoryHashForUrl(const KUrl& url)
+QString ViewProperties::directoryHashForUrl(const QUrl& url)
{
- const QByteArray hashValue = QCryptographicHash::hash(url.prettyUrl().toLatin1(),
- QCryptographicHash::Sha1);
+ const QByteArray hashValue = QCryptographicHash::hash(url.toEncoded(), QCryptographicHash::Sha1);
QString hashString = hashValue.toBase64();
hashString.replace('/', '-');
return hashString;
}
-
-KUrl ViewProperties::mirroredDirectory()
-{
- QString basePath = KGlobal::mainComponent().componentName();
- basePath.append("/view_properties/");
- return KUrl(KStandardDirs::locateLocal("data", basePath));
-}
diff --git a/src/views/viewproperties.h b/src/views/viewproperties.h
index 69b507f1b..dc118e2d7 100644
--- a/src/views/viewproperties.h
+++ b/src/views/viewproperties.h
@@ -22,8 +22,8 @@
#define VIEWPROPERTIES_H
#include <views/dolphinview.h>
-#include <KUrl>
-#include <libdolphin_export.h>
+#include <QUrl>
+#include "dolphin_export.h"
class ViewPropertySettings;
/**
@@ -35,7 +35,7 @@ class ViewPropertySettings;
* just construct an instance by passing the path of the directory:
*
* \code
- * ViewProperties props(KUrl("/home/peter/Documents"));
+ * ViewProperties props(QUrl::fromLocalFile("/home/peter/Documents"));
* const DolphinView::Mode mode = props.viewMode();
* const bool hiddenFilesShown = props.hiddenFilesShown();
* \endcode
@@ -47,10 +47,10 @@ class ViewPropertySettings;
* (see GeneralSettings::globalViewMode()), the values from the global .directory file
* are used for initialization.
*/
-class LIBDOLPHINPRIVATE_EXPORT ViewProperties
+class DOLPHIN_EXPORT ViewProperties
{
public:
- explicit ViewProperties(const KUrl& url);
+ explicit ViewProperties(const QUrl& url);
virtual ~ViewProperties();
void setViewMode(DolphinView::Mode mode);
@@ -162,16 +162,7 @@ private:
* @return A hash-value for an URL that can be used as directory name.
* Is used to be able to remember view-properties for long baloo-URLs.
*/
- static QString directoryHashForUrl(const KUrl& url);
-
- /**
- * Returns the URL of the directory, where the mirrored view properties
- * are stored into. Mirrored view properties are used if:
- * - there is no write access for storing the view properties into
- * the original directory
- * - for non local directories
- */
- static KUrl mirroredDirectory();
+ static QString directoryHashForUrl(const QUrl &url);
Q_DISABLE_COPY(ViewProperties)