┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/panels
diff options
context:
space:
mode:
authorEmmanuel Pescosta <[email protected]>2015-02-27 11:30:27 +0100
committerEmmanuel Pescosta <[email protected]>2015-02-27 11:30:27 +0100
commit9aee5d22513f0367febab54b38b3a7dc58d120bb (patch)
tree99cf391070ac5d4650a3f1b309c3ec2e814f1ac6 /src/panels
parentf025aeb63aa2a38e91c43d99ba9955793d3adf1e (diff)
parentb701b7e4edefb628d6f8b14146b2e299bd0ce5fc (diff)
Merge branch 'frameworks'
Diffstat (limited to 'src/panels')
-rw-r--r--src/panels/folders/foldersitemlistwidget.cpp1
-rw-r--r--src/panels/folders/foldersitemlistwidget.h2
-rw-r--r--src/panels/folders/folderspanel.cpp55
-rw-r--r--src/panels/folders/folderspanel.h16
-rw-r--r--src/panels/folders/treeviewcontextmenu.cpp93
-rw-r--r--src/panels/folders/treeviewcontextmenu.h1
-rw-r--r--src/panels/information/filemetadataconfigurationdialog.cpp44
-rw-r--r--src/panels/information/filemetadataconfigurationdialog.h7
-rw-r--r--src/panels/information/informationpanel.cpp63
-rw-r--r--src/panels/information/informationpanel.h20
-rw-r--r--src/panels/information/informationpanelcontent.cpp74
-rw-r--r--src/panels/information/informationpanelcontent.h11
-rw-r--r--src/panels/information/phononwidget.cpp32
-rw-r--r--src/panels/information/phononwidget.h13
-rw-r--r--src/panels/information/pixmapviewer.cpp7
-rw-r--r--src/panels/information/pixmapviewer.h4
-rw-r--r--src/panels/panel.cpp11
-rw-r--r--src/panels/panel.h12
-rw-r--r--src/panels/places/placesitem.cpp43
-rw-r--r--src/panels/places/placesitem.h12
-rw-r--r--src/panels/places/placesitemeditdialog.cpp61
-rw-r--r--src/panels/places/placesitemeditdialog.h20
-rw-r--r--src/panels/places/placesitemlistgroupheader.cpp1
-rw-r--r--src/panels/places/placesitemlistgroupheader.h2
-rw-r--r--src/panels/places/placesitemlistwidget.cpp3
-rw-r--r--src/panels/places/placesitemlistwidget.h4
-rw-r--r--src/panels/places/placesitemmodel.cpp193
-rw-r--r--src/panels/places/placesitemmodel.h34
-rw-r--r--src/panels/places/placesitemsignalhandler.cpp1
-rw-r--r--src/panels/places/placesitemsignalhandler.h2
-rw-r--r--src/panels/places/placespanel.cpp139
-rw-r--r--src/panels/places/placespanel.h18
-rw-r--r--src/panels/places/placesview.cpp3
-rw-r--r--src/panels/terminal/terminalpanel.cpp26
-rw-r--r--src/panels/terminal/terminalpanel.h16
35 files changed, 531 insertions, 513 deletions
diff --git a/src/panels/folders/foldersitemlistwidget.cpp b/src/panels/folders/foldersitemlistwidget.cpp
index b4f9a5be8..5b2b20698 100644
--- a/src/panels/folders/foldersitemlistwidget.cpp
+++ b/src/panels/folders/foldersitemlistwidget.cpp
@@ -33,4 +33,3 @@ QPalette::ColorRole FoldersItemListWidget::normalTextColorRole() const
return QPalette::WindowText;
}
-#include "foldersitemlistwidget.moc"
diff --git a/src/panels/folders/foldersitemlistwidget.h b/src/panels/folders/foldersitemlistwidget.h
index 08d41b829..2278762e3 100644
--- a/src/panels/folders/foldersitemlistwidget.h
+++ b/src/panels/folders/foldersitemlistwidget.h
@@ -34,7 +34,7 @@ public:
virtual ~FoldersItemListWidget();
protected:
- virtual QPalette::ColorRole normalTextColorRole() const;
+ virtual QPalette::ColorRole normalTextColorRole() const Q_DECL_OVERRIDE;
};
#endif
diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp
index 46c1b3450..13df9019b 100644
--- a/src/panels/folders/folderspanel.cpp
+++ b/src/panels/folders/folderspanel.cpp
@@ -33,7 +33,11 @@
#include <kitemviews/kfileitemmodel.h>
#include <KFileItem>
-#include <konq_operations.h>
+#include <KJobWidgets>
+#include <KJobUiDelegate>
+#include <KIO/CopyJob>
+#include <KIO/DropJob>
+#include <KIO/FileUndoManager>
#include <QApplication>
#include <QBoxLayout>
@@ -45,7 +49,7 @@
#include <views/draganddrophelper.h>
-#include <KDebug>
+#include "dolphindebug.h"
FoldersPanel::FoldersPanel(QWidget* parent) :
Panel(parent),
@@ -58,7 +62,7 @@ FoldersPanel::FoldersPanel(QWidget* parent) :
FoldersPanel::~FoldersPanel()
{
- FoldersPanelSettings::self()->writeConfig();
+ FoldersPanelSettings::self()->save();
if (m_controller) {
KItemListView* view = m_controller->view();
@@ -105,7 +109,7 @@ void FoldersPanel::rename(const KFileItem& item)
bool FoldersPanel::urlChanged()
{
- if (!url().isValid() || url().protocol().contains("search")) {
+ if (!url().isValid() || url().scheme().contains("search")) {
// Skip results shown by a search, as possible identical
// directory names are useless without parent-path information.
return false;
@@ -137,15 +141,15 @@ void FoldersPanel::showEvent(QShowEvent* event)
// opening the folders panel.
view->setOpacity(0);
- connect(view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
+ connect(view, &KFileItemListView::roleEditingFinished,
+ this, &FoldersPanel::slotRoleEditingFinished);
m_model = new KFileItemModel(this);
m_model->setShowDirectoriesOnly(true);
m_model->setShowHiddenFiles(FoldersPanelSettings::hiddenFilesShown());
// Use a QueuedConnection to give the view the possibility to react first on the
// finished loading.
- connect(m_model, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotLoadingCompleted()), Qt::QueuedConnection);
+ connect(m_model, &KFileItemModel::directoryLoadingCompleted, this, &FoldersPanel::slotLoadingCompleted, Qt::QueuedConnection);
m_controller = new KItemListController(m_model, view, this);
m_controller->setSelectionBehavior(KItemListController::SingleSelection);
@@ -154,11 +158,11 @@ void FoldersPanel::showEvent(QShowEvent* event)
m_controller->setAutoActivationDelay(750);
m_controller->setSingleClickActivationEnforced(true);
- connect(m_controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int)));
- connect(m_controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));
- connect(m_controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF)));
- connect(m_controller, SIGNAL(viewContextMenuRequested(QPointF)), this, SLOT(slotViewContextMenuRequested(QPointF)));
- connect(m_controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*)));
+ connect(m_controller, &KItemListController::itemActivated, this, &FoldersPanel::slotItemActivated);
+ connect(m_controller, &KItemListController::itemMiddleClicked, this, &FoldersPanel::slotItemMiddleClicked);
+ connect(m_controller, &KItemListController::itemContextMenuRequested, this, &FoldersPanel::slotItemContextMenuRequested);
+ connect(m_controller, &KItemListController::viewContextMenuRequested, this, &FoldersPanel::slotViewContextMenuRequested);
+ connect(m_controller, &KItemListController::itemDropEvent, this, &FoldersPanel::slotItemDropEvent);
KItemListContainer* container = new KItemListContainer(m_controller, this);
container->setEnabledFrame(false);
@@ -204,7 +208,7 @@ void FoldersPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
const KFileItem fileItem = m_model->fileItem(index);
- QWeakPointer<TreeViewContextMenu> contextMenu = new TreeViewContextMenu(this, fileItem);
+ QPointer<TreeViewContextMenu> contextMenu = new TreeViewContextMenu(this, fileItem);
contextMenu.data()->open();
if (contextMenu.data()) {
delete contextMenu.data();
@@ -215,7 +219,7 @@ void FoldersPanel::slotViewContextMenuRequested(const QPointF& pos)
{
Q_UNUSED(pos);
- QWeakPointer<TreeViewContextMenu> contextMenu = new TreeViewContextMenu(this, KFileItem());
+ QPointer<TreeViewContextMenu> contextMenu = new TreeViewContextMenu(this, KFileItem());
contextMenu.data()->open();
if (contextMenu.data()) {
delete contextMenu.data();
@@ -236,10 +240,9 @@ void FoldersPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* eve
event->buttons(),
event->modifiers());
- QString error;
- DragAndDropHelper::dropUrls(destItem, destItem.url(), &dropEvent, error);
- if (!error.isEmpty()) {
- emit errorMessage(error);
+ KIO::DropJob *job = DragAndDropHelper::dropUrls(destItem.url(), &dropEvent, this);
+ if (job) {
+ connect(job, &KIO::DropJob::result, this, [this](KJob *job) { if (job->error()) emit errorMessage(job->errorString()); });
}
}
}
@@ -250,7 +253,14 @@ void FoldersPanel::slotRoleEditingFinished(int index, const QByteArray& role, co
const KFileItem item = m_model->fileItem(index);
const QString newName = value.toString();
if (!newName.isEmpty() && newName != item.text() && newName != QLatin1String(".") && newName != QLatin1String("..")) {
- KonqOperations::rename(this, item.url(), newName);
+ const QUrl oldUrl = item.url();
+ QUrl newUrl = oldUrl.adjusted(QUrl::RemoveFilename);
+ newUrl.setPath(newUrl.path() + KIO::encodeFileName(newName));
+
+ 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);
}
}
}
@@ -286,16 +296,16 @@ void FoldersPanel::startFadeInAnimation()
anim->setDuration(200);
}
-void FoldersPanel::loadTree(const KUrl& url)
+void FoldersPanel::loadTree(const QUrl& url)
{
Q_ASSERT(m_controller);
m_updateCurrentItem = false;
- KUrl baseUrl;
+ QUrl baseUrl;
if (url.isLocalFile()) {
// Use the root directory as base for local URLs (#150941)
- baseUrl = QDir::rootPath();
+ baseUrl = QUrl::fromLocalFile(QDir::rootPath());
} else {
// Clear the path for non-local URLs and use it as base
baseUrl = url;
@@ -328,4 +338,3 @@ void FoldersPanel::updateCurrentItem(int index)
m_controller->view()->scrollToItem(index);
}
-#include "folderspanel.moc"
diff --git a/src/panels/folders/folderspanel.h b/src/panels/folders/folderspanel.h
index 14d8e8782..7c591cc20 100644
--- a/src/panels/folders/folderspanel.h
+++ b/src/panels/folders/folderspanel.h
@@ -20,13 +20,13 @@
#ifndef FOLDERSPANEL_H
#define FOLDERSPANEL_H
-#include <KUrl>
+#include <QUrl>
#include <panels/panel.h>
class KFileItemModel;
class KItemListController;
class QGraphicsSceneDragDropEvent;
-
+class KFileItem;
/**
* @brief Shows a tree view of the directories starting from
* the currently selected place.
@@ -51,19 +51,19 @@ public:
void rename(const KFileItem& item);
signals:
- void folderActivated(const KUrl& url);
- void folderMiddleClicked(const KUrl& url);
+ void folderActivated(const QUrl& url);
+ void folderMiddleClicked(const QUrl& url);
void errorMessage(const QString& error);
protected:
/** @see Panel::urlChanged() */
- virtual bool urlChanged();
+ virtual bool urlChanged() Q_DECL_OVERRIDE;
/** @see QWidget::showEvent() */
- virtual void showEvent(QShowEvent* event);
+ virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
/** @see QWidget::keyPressEvent() */
- virtual void keyPressEvent(QKeyEvent* event);
+ virtual void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
private slots:
void slotItemActivated(int index);
@@ -87,7 +87,7 @@ private:
* directories until \a url.
* @param url URL of the leaf directory that should get expanded.
*/
- void loadTree(const KUrl& url);
+ void loadTree(const QUrl& url);
/**
* Sets the item with the index \a index as current item, selects
diff --git a/src/panels/folders/treeviewcontextmenu.cpp b/src/panels/folders/treeviewcontextmenu.cpp
index 83ffa87a7..e45fcd67e 100644
--- a/src/panels/folders/treeviewcontextmenu.cpp
+++ b/src/panels/folders/treeviewcontextmenu.cpp
@@ -21,19 +21,28 @@
#include "treeviewcontextmenu.h"
#include <KFileItem>
-#include <KIconLoader>
+#include <KIO/CopyJob>
#include <KIO/DeleteJob>
-#include <KMenu>
-#include <konqmimedata.h>
+#include <KIO/JobUiDelegate>
+#include <QMenu>
+#include <QIcon>
+#include <KJobWidgets>
+#include <KSharedConfig>
+#include <KConfigGroup>
+#include <KUrlMimeData>
#include <KFileItemListProperties>
-#include <konq_operations.h>
-#include <KLocale>
+#include <KLocalizedString>
+#include <KIO/PasteJob>
+#include <KIO/Paste>
+#include <KIO/FileUndoManager>
#include <KPropertiesDialog>
#include "folderspanel.h"
#include <QApplication>
#include <QClipboard>
+#include <QMimeData>
+#include <QPointer>
TreeViewContextMenu::TreeViewContextMenu(FoldersPanel* parent,
const KFileItem& fileInfo) :
@@ -49,23 +58,25 @@ TreeViewContextMenu::~TreeViewContextMenu()
void TreeViewContextMenu::open()
{
- KMenu* popup = new KMenu(m_parent);
+ QMenu* popup = new QMenu(m_parent);
if (!m_fileItem.isNull()) {
KFileItemListProperties capabilities(KFileItemList() << m_fileItem);
// insert 'Cut', 'Copy' and 'Paste'
- QAction* cutAction = new QAction(KIcon("edit-cut"), i18nc("@action:inmenu", "Cut"), this);
+ QAction* cutAction = new QAction(QIcon::fromTheme("edit-cut"), i18nc("@action:inmenu", "Cut"), this);
cutAction->setEnabled(capabilities.supportsMoving());
- connect(cutAction, SIGNAL(triggered()), this, SLOT(cut()));
+ connect(cutAction, &QAction::triggered, this, &TreeViewContextMenu::cut);
- QAction* copyAction = new QAction(KIcon("edit-copy"), i18nc("@action:inmenu", "Copy"), this);
- connect(copyAction, SIGNAL(triggered()), this, SLOT(copy()));
+ QAction* copyAction = new QAction(QIcon::fromTheme("edit-copy"), i18nc("@action:inmenu", "Copy"), this);
+ connect(copyAction, &QAction::triggered, this, &TreeViewContextMenu::copy);
- const QPair<bool, QString> pasteInfo = KonqOperations::pasteInfo(m_fileItem.url());
- QAction* pasteAction = new QAction(KIcon("edit-paste"), pasteInfo.second, this);
- connect(pasteAction, SIGNAL(triggered()), this, SLOT(paste()));
- pasteAction->setEnabled(pasteInfo.first);
+ const QMimeData *mimeData = QApplication::clipboard()->mimeData();
+ bool canPaste;
+ const QString text = KIO::pasteActionText(mimeData, &canPaste, m_fileItem);
+ QAction* pasteAction = new QAction(QIcon::fromTheme("edit-paste"), text, this);
+ connect(pasteAction, &QAction::triggered, this, &TreeViewContextMenu::paste);
+ pasteAction->setEnabled(canPaste);
popup->addAction(cutAction);
popup->addAction(copyAction);
@@ -75,8 +86,8 @@ void TreeViewContextMenu::open()
// insert 'Rename'
QAction* renameAction = new QAction(i18nc("@action:inmenu", "Rename..."), this);
renameAction->setEnabled(capabilities.supportsMoving());
- renameAction->setIcon(KIcon("edit-rename"));
- connect(renameAction, SIGNAL(triggered()), this, SLOT(rename()));
+ renameAction->setIcon(QIcon::fromTheme("edit-rename"));
+ connect(renameAction, &QAction::triggered, this, &TreeViewContextMenu::rename);
popup->addAction(renameAction);
// insert 'Move to Trash' and (optionally) 'Delete'
@@ -84,22 +95,22 @@ void TreeViewContextMenu::open()
KConfigGroup configGroup(globalConfig, "KDE");
bool showDeleteCommand = configGroup.readEntry("ShowDeleteCommand", false);
- const KUrl url = m_fileItem.url();
+ const QUrl url = m_fileItem.url();
if (url.isLocalFile()) {
- QAction* moveToTrashAction = new QAction(KIcon("user-trash"),
+ QAction* moveToTrashAction = new QAction(QIcon::fromTheme("user-trash"),
i18nc("@action:inmenu", "Move to Trash"), this);
const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
moveToTrashAction->setEnabled(enableMoveToTrash);
- connect(moveToTrashAction, SIGNAL(triggered()), this, SLOT(moveToTrash()));
+ connect(moveToTrashAction, &QAction::triggered, this, &TreeViewContextMenu::moveToTrash);
popup->addAction(moveToTrashAction);
} else {
showDeleteCommand = true;
}
if (showDeleteCommand) {
- QAction* deleteAction = new QAction(KIcon("edit-delete"), i18nc("@action:inmenu", "Delete"), this);
+ QAction* deleteAction = new QAction(QIcon::fromTheme("edit-delete"), i18nc("@action:inmenu", "Delete"), this);
deleteAction->setEnabled(capabilities.supportsDeleting());
- connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteItem()));
+ connect(deleteAction, &QAction::triggered, this, &TreeViewContextMenu::deleteItem);
popup->addAction(deleteAction);
}
@@ -111,7 +122,7 @@ void TreeViewContextMenu::open()
showHiddenFilesAction->setCheckable(true);
showHiddenFilesAction->setChecked(m_parent->showHiddenFiles());
popup->addAction(showHiddenFilesAction);
- connect(showHiddenFilesAction, SIGNAL(toggled(bool)), this, SLOT(setShowHiddenFiles(bool)));
+ connect(showHiddenFilesAction, &QAction::toggled, this, &TreeViewContextMenu::setShowHiddenFiles);
// insert 'Automatic Scrolling'
QAction* autoScrollingAction = new QAction(i18nc("@action:inmenu", "Automatic Scrolling"), this);
@@ -120,13 +131,13 @@ void TreeViewContextMenu::open()
// TODO: Temporary disabled. Horizontal autoscrolling will be implemented later either
// in KItemViews or manually as part of the FoldersPanel
//popup->addAction(autoScrollingAction);
- connect(autoScrollingAction, SIGNAL(toggled(bool)), this, SLOT(setAutoScrolling(bool)));
+ connect(autoScrollingAction, &QAction::toggled, this, &TreeViewContextMenu::setAutoScrolling);
if (!m_fileItem.isNull()) {
// insert 'Properties' entry
QAction* propertiesAction = new QAction(i18nc("@action:inmenu", "Properties"), this);
- propertiesAction->setIcon(KIcon("document-properties"));
- connect(propertiesAction, SIGNAL(triggered()), this, SLOT(showProperties()));
+ propertiesAction->setIcon(QIcon::fromTheme("document-properties"));
+ connect(propertiesAction, &QAction::triggered, this, &TreeViewContextMenu::showProperties);
popup->addAction(propertiesAction);
}
@@ -138,7 +149,7 @@ void TreeViewContextMenu::open()
}
}
- QWeakPointer<KMenu> popupPtr = popup;
+ QPointer<QMenu> popupPtr = popup;
popup->exec(QCursor::pos());
if (popupPtr.data()) {
popupPtr.data()->deleteLater();
@@ -147,12 +158,13 @@ void TreeViewContextMenu::open()
void TreeViewContextMenu::populateMimeData(QMimeData* mimeData, bool cut)
{
- KUrl::List kdeUrls;
+ QList<QUrl> kdeUrls;
kdeUrls.append(m_fileItem.url());
- KUrl::List mostLocalUrls;
+ QList<QUrl> mostLocalUrls;
bool dummy;
mostLocalUrls.append(m_fileItem.mostLocalUrl(dummy));
- KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, cut);
+ KIO::setClipboardDataCut(mimeData, cut);
+ KUrlMimeData::setUrls(kdeUrls, mostLocalUrls, mimeData);
}
void TreeViewContextMenu::cut()
@@ -171,7 +183,8 @@ void TreeViewContextMenu::copy()
void TreeViewContextMenu::paste()
{
- KonqOperations::doPaste(m_parent, m_fileItem.url());
+ KIO::PasteJob *job = KIO::paste(QApplication::clipboard()->mimeData(), m_fileItem.url());
+ KJobWidgets::setWindow(job, m_parent);
}
void TreeViewContextMenu::rename()
@@ -181,12 +194,27 @@ void TreeViewContextMenu::rename()
void TreeViewContextMenu::moveToTrash()
{
- KonqOperations::del(m_parent, KonqOperations::TRASH, m_fileItem.url());
+ const QList<QUrl> list{m_fileItem.url()};
+ KIO::JobUiDelegate uiDelegate;
+ uiDelegate.setWindow(m_parent);
+ 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, m_parent);
+ job->ui()->setAutoErrorHandlingEnabled(true);
+ }
}
void TreeViewContextMenu::deleteItem()
{
- KonqOperations::del(m_parent, KonqOperations::DEL, m_fileItem.url());
+ const QList<QUrl> list{m_fileItem.url()};
+ KIO::JobUiDelegate uiDelegate;
+ uiDelegate.setWindow(m_parent);
+ if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Delete, KIO::JobUiDelegate::DefaultConfirmation)) {
+ KIO::Job* job = KIO::del(list);
+ KJobWidgets::setWindow(job, m_parent);
+ job->ui()->setAutoErrorHandlingEnabled(true);
+ }
}
void TreeViewContextMenu::showProperties()
@@ -206,4 +234,3 @@ void TreeViewContextMenu::setAutoScrolling(bool enable)
m_parent->setAutoScrolling(enable);
}
-#include "treeviewcontextmenu.moc"
diff --git a/src/panels/folders/treeviewcontextmenu.h b/src/panels/folders/treeviewcontextmenu.h
index 0b3fd79bd..598ffaed6 100644
--- a/src/panels/folders/treeviewcontextmenu.h
+++ b/src/panels/folders/treeviewcontextmenu.h
@@ -23,6 +23,7 @@
#include <QObject>
#include <KFileItem>
+class QMimeData;
class FoldersPanel;
/**
diff --git a/src/panels/information/filemetadataconfigurationdialog.cpp b/src/panels/information/filemetadataconfigurationdialog.cpp
index 4ad9066c4..2f8c16037 100644
--- a/src/panels/information/filemetadataconfigurationdialog.cpp
+++ b/src/panels/information/filemetadataconfigurationdialog.cpp
@@ -22,22 +22,33 @@
#ifndef HAVE_BALOO
#include <kfilemetadataconfigurationwidget.h>
#else
-#include <baloo/filemetadataconfigwidget.h>
+#include <Baloo/FileMetaDataConfigWidget>
#endif
-
-#include <KLocale>
+#include <KSharedConfig>
+#include <KLocalizedString>
#include <QLabel>
#include <QVBoxLayout>
+#include <KConfigGroup>
+#include <KWindowConfig>
+#include <QDialogButtonBox>
+#include <QPushButton>
FileMetaDataConfigurationDialog::FileMetaDataConfigurationDialog(QWidget* parent) :
- KDialog(parent),
+ QDialog(parent),
m_descriptionLabel(0),
m_configWidget(0)
{
- setCaption(i18nc("@title:window", "Configure Shown Data"));
- setButtons(KDialog::Ok | KDialog::Cancel);
- setDefaultButton(KDialog::Ok);
+ setWindowTitle(i18nc("@title:window", "Configure Shown Data"));
+ QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ setLayout(mainLayout);
+ QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
+ okButton->setDefault(true);
+ okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
+ connect(buttonBox, SIGNAL(accepted()), this, SLOT(slotAccepted()));
+ connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+ buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
m_descriptionLabel = new QLabel(i18nc("@label::textbox",
"Select which data should "
@@ -55,18 +66,20 @@ FileMetaDataConfigurationDialog::FileMetaDataConfigurationDialog(QWidget* parent
QVBoxLayout* topLayout = new QVBoxLayout(mainWidget);
topLayout->addWidget(m_descriptionLabel);
topLayout->addWidget(m_configWidget);
- setMainWidget(mainWidget);
+ mainLayout->addWidget(mainWidget);
+ mainLayout->addWidget(buttonBox);
+
const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
"FileMetaDataConfigurationDialog");
- restoreDialogSize(dialogConfig);
+ KWindowConfig::restoreWindowSize(windowHandle(), dialogConfig);
}
FileMetaDataConfigurationDialog::~FileMetaDataConfigurationDialog()
{
KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
"FileMetaDataConfigurationDialog");
- saveDialogSize(dialogConfig, KConfigBase::Persistent);
+ KWindowConfig::saveWindowSize(windowHandle(), dialogConfig);
}
void FileMetaDataConfigurationDialog::setItems(const KFileItemList& items)
@@ -79,14 +92,10 @@ KFileItemList FileMetaDataConfigurationDialog::items() const
return m_configWidget->items();
}
-void FileMetaDataConfigurationDialog::slotButtonClicked(int button)
+void FileMetaDataConfigurationDialog::slotAccepted()
{
- if (button == KDialog::Ok) {
- m_configWidget->save();
- accept();
- } else {
- KDialog::slotButtonClicked(button);
- }
+ m_configWidget->save();
+ accept();
}
void FileMetaDataConfigurationDialog::setDescription(const QString& description)
@@ -99,4 +108,3 @@ QString FileMetaDataConfigurationDialog::description() const
return m_descriptionLabel->text();
}
-#include "filemetadataconfigurationdialog.moc"
diff --git a/src/panels/information/filemetadataconfigurationdialog.h b/src/panels/information/filemetadataconfigurationdialog.h
index a3ce9548b..13562ef5c 100644
--- a/src/panels/information/filemetadataconfigurationdialog.h
+++ b/src/panels/information/filemetadataconfigurationdialog.h
@@ -20,7 +20,7 @@
#ifndef FILEMETADATACONFIGURATIONDIALOG_H
#define FILEMETADATACONFIGURATIONDIALOG_H
-#include <KDialog>
+#include <QDialog>
#include <KFileItem>
#include "config-baloo.h"
@@ -38,7 +38,7 @@ class QLabel;
* @brief Dialog which allows to configure which meta data should be shown
* in the KFileMetaDataWidget.
*/
-class FileMetaDataConfigurationDialog : public KDialog
+class FileMetaDataConfigurationDialog : public QDialog
{
Q_OBJECT
@@ -67,8 +67,7 @@ public:
QString description() const;
protected slots:
- virtual void slotButtonClicked(int button);
-
+ void slotAccepted();
private:
QLabel* m_descriptionLabel;
#ifndef HAVE_BALOO
diff --git a/src/panels/information/informationpanel.cpp b/src/panels/information/informationpanel.cpp
index eda74f3b5..3f778b07a 100644
--- a/src/panels/information/informationpanel.cpp
+++ b/src/panels/information/informationpanel.cpp
@@ -22,10 +22,12 @@
#include "informationpanelcontent.h"
#include <KIO/Job>
#include <KIO/JobUiDelegate>
+#include <KJobWidgets>
#include <KDirNotify>
#include <QApplication>
#include <QShowEvent>
#include <QVBoxLayout>
+#include <QTimer>
InformationPanel::InformationPanel(QWidget* parent) :
Panel(parent),
@@ -184,10 +186,10 @@ void InformationPanel::showItemInfo()
// an item for the currently shown directory.
m_folderStatJob = KIO::stat(url(), KIO::HideProgressInfo);
if (m_folderStatJob->ui()) {
- m_folderStatJob->ui()->setWindow(this);
+ KJobWidgets::setWindow(m_folderStatJob, this);
}
- connect(m_folderStatJob, SIGNAL(result(KJob*)),
- this, SLOT(slotFolderStatFinished(KJob*)));
+ connect(m_folderStatJob, &KIO::Job::result,
+ this, &InformationPanel::slotFolderStatFinished);
} else {
m_content->showItem(item);
}
@@ -211,7 +213,7 @@ void InformationPanel::slotInfoTimeout()
void InformationPanel::reset()
{
if (m_invalidUrlCandidate == m_shownUrl) {
- m_invalidUrlCandidate = KUrl();
+ m_invalidUrlCandidate = QUrl();
// The current URL is still invalid. Reset
// the content to show the directory URL.
@@ -224,11 +226,11 @@ void InformationPanel::reset()
void InformationPanel::slotFileRenamed(const QString& source, const QString& dest)
{
- if (m_shownUrl == KUrl(source)) {
- m_shownUrl = KUrl(dest);
- m_fileItem = KFileItem(KFileItem::Unknown, KFileItem::Unknown, m_shownUrl);
+ if (m_shownUrl == QUrl::fromLocalFile(source)) {
+ m_shownUrl = QUrl::fromLocalFile(dest);
+ m_fileItem = KFileItem(m_shownUrl);
- if ((m_selection.count() == 1) && (m_selection[0].url() == KUrl(source))) {
+ if ((m_selection.count() == 1) && (m_selection[0].url() == QUrl::fromLocalFile(source))) {
m_selection[0] = m_fileItem;
// Implementation note: Updating the selection is only required if exactly one
// item is selected, as the name of the item is shown. If this should change
@@ -242,10 +244,10 @@ void InformationPanel::slotFileRenamed(const QString& source, const QString& des
void InformationPanel::slotFilesAdded(const QString& directory)
{
- if (m_shownUrl == KUrl(directory)) {
+ if (m_shownUrl == QUrl::fromLocalFile(directory)) {
// If the 'trash' icon changes because the trash has been emptied or got filled,
// the signal filesAdded("trash:/") will be emitted.
- KFileItem item(KFileItem::Unknown, KFileItem::Unknown, KUrl(directory));
+ KFileItem item(QUrl::fromLocalFile(directory));
requestDelayedItemInfo(item);
}
}
@@ -253,7 +255,7 @@ void InformationPanel::slotFilesAdded(const QString& directory)
void InformationPanel::slotFilesChanged(const QStringList& files)
{
foreach (const QString& fileName, files) {
- if (m_shownUrl == KUrl(fileName)) {
+ if (m_shownUrl == QUrl::fromLocalFile(fileName)) {
showItemInfo();
break;
}
@@ -263,7 +265,7 @@ void InformationPanel::slotFilesChanged(const QStringList& files)
void InformationPanel::slotFilesRemoved(const QStringList& files)
{
foreach (const QString& fileName, files) {
- if (m_shownUrl == KUrl(fileName)) {
+ if (m_shownUrl == QUrl::fromLocalFile(fileName)) {
// the currently shown item has been removed, show
// the parent directory as fallback
markUrlAsInvalid();
@@ -274,15 +276,15 @@ void InformationPanel::slotFilesRemoved(const QStringList& files)
void InformationPanel::slotEnteredDirectory(const QString& directory)
{
- if (m_shownUrl == KUrl(directory)) {
- KFileItem item(KFileItem::Unknown, KFileItem::Unknown, KUrl(directory));
+ if (m_shownUrl == QUrl::fromLocalFile(directory)) {
+ KFileItem item(QUrl::fromLocalFile(directory));
requestDelayedItemInfo(item);
}
}
void InformationPanel::slotLeftDirectory(const QString& directory)
{
- if (m_shownUrl == KUrl(directory)) {
+ if (m_shownUrl == QUrl::fromLocalFile(directory)) {
// The signal 'leftDirectory' is also emitted when a media
// has been unmounted. In this case no directory change will be
// done in Dolphin, but the Information Panel must be updated to
@@ -306,9 +308,9 @@ void InformationPanel::cancelRequest()
m_urlCandidate.clear();
}
-bool InformationPanel::isEqualToShownUrl(const KUrl& url) const
+bool InformationPanel::isEqualToShownUrl(const QUrl& url) const
{
- return m_shownUrl.equals(url, KUrl::CompareWithoutTrailingSlash);
+ return m_shownUrl.matches(url, QUrl::StripTrailingSlash);
}
void InformationPanel::markUrlAsInvalid()
@@ -322,35 +324,35 @@ void InformationPanel::init()
m_infoTimer = new QTimer(this);
m_infoTimer->setInterval(300);
m_infoTimer->setSingleShot(true);
- connect(m_infoTimer, SIGNAL(timeout()),
- this, SLOT(slotInfoTimeout()));
+ connect(m_infoTimer, &QTimer::timeout,
+ this, &InformationPanel::slotInfoTimeout);
m_urlChangedTimer = new QTimer(this);
m_urlChangedTimer->setInterval(200);
m_urlChangedTimer->setSingleShot(true);
- connect(m_urlChangedTimer, SIGNAL(timeout()),
- this, SLOT(showItemInfo()));
+ connect(m_urlChangedTimer, &QTimer::timeout,
+ this, &InformationPanel::showItemInfo);
m_resetUrlTimer = new QTimer(this);
m_resetUrlTimer->setInterval(1000);
m_resetUrlTimer->setSingleShot(true);
- connect(m_resetUrlTimer, SIGNAL(timeout()),
- this, SLOT(reset()));
+ connect(m_resetUrlTimer, &QTimer::timeout,
+ this, &InformationPanel::reset);
Q_ASSERT(m_urlChangedTimer->interval() < m_infoTimer->interval());
Q_ASSERT(m_urlChangedTimer->interval() < m_resetUrlTimer->interval());
org::kde::KDirNotify* dirNotify = new org::kde::KDirNotify(QString(), QString(),
QDBusConnection::sessionBus(), this);
- connect(dirNotify, SIGNAL(FileRenamed(QString,QString)), SLOT(slotFileRenamed(QString,QString)));
- connect(dirNotify, SIGNAL(FilesAdded(QString)), SLOT(slotFilesAdded(QString)));
- connect(dirNotify, SIGNAL(FilesChanged(QStringList)), SLOT(slotFilesChanged(QStringList)));
- connect(dirNotify, SIGNAL(FilesRemoved(QStringList)), SLOT(slotFilesRemoved(QStringList)));
- connect(dirNotify, SIGNAL(enteredDirectory(QString)), SLOT(slotEnteredDirectory(QString)));
- connect(dirNotify, SIGNAL(leftDirectory(QString)), SLOT(slotLeftDirectory(QString)));
+ connect(dirNotify, &OrgKdeKDirNotifyInterface::FileRenamed, this, &InformationPanel::slotFileRenamed);
+ connect(dirNotify, &OrgKdeKDirNotifyInterface::FilesAdded, this, &InformationPanel::slotFilesAdded);
+ connect(dirNotify, &OrgKdeKDirNotifyInterface::FilesChanged, this, &InformationPanel::slotFilesChanged);
+ connect(dirNotify, &OrgKdeKDirNotifyInterface::FilesRemoved, this, &InformationPanel::slotFilesRemoved);
+ connect(dirNotify, &OrgKdeKDirNotifyInterface::enteredDirectory, this, &InformationPanel::slotEnteredDirectory);
+ connect(dirNotify, &OrgKdeKDirNotifyInterface::leftDirectory, this, &InformationPanel::slotLeftDirectory);
m_content = new InformationPanelContent(this);
- connect(m_content, SIGNAL(urlActivated(KUrl)), this, SIGNAL(urlActivated(KUrl)));
+ connect(m_content, &InformationPanelContent::urlActivated, this, &InformationPanel::urlActivated);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
@@ -359,4 +361,3 @@ void InformationPanel::init()
m_initialized = true;
}
-#include "informationpanel.moc"
diff --git a/src/panels/information/informationpanel.h b/src/panels/information/informationpanel.h
index c68b66ee1..78e2d71ff 100644
--- a/src/panels/information/informationpanel.h
+++ b/src/panels/information/informationpanel.h
@@ -21,7 +21,7 @@
#define INFORMATIONPANEL_H
#include <panels/panel.h>
-
+#include <KFileItem>
class InformationPanelContent;
namespace KIO
{
@@ -40,7 +40,7 @@ public:
virtual ~InformationPanel();
signals:
- void urlActivated(const KUrl& url);
+ void urlActivated(const QUrl& url);
public slots:
/**
@@ -59,16 +59,16 @@ public slots:
protected:
/** @see Panel::urlChanged() */
- virtual bool urlChanged();
+ virtual bool urlChanged() Q_DECL_OVERRIDE;
/** @see QWidget::showEvent() */
- virtual void showEvent(QShowEvent* event);
+ virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
/** @see QWidget::resizeEvent() */
- virtual void resizeEvent(QResizeEvent* event);
+ virtual void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
/** @see QWidget::contextMenuEvent() */
- virtual void contextMenuEvent(QContextMenuEvent* event);
+ virtual void contextMenuEvent(QContextMenuEvent* event) Q_DECL_OVERRIDE;
private slots:
/**
@@ -116,7 +116,7 @@ private:
/**
* Returns true, if \a url is equal to the shown URL m_shownUrl.
*/
- bool isEqualToShownUrl(const KUrl& url) const;
+ bool isEqualToShownUrl(const QUrl& url) const;
/**
* Marks the URL as invalid and will reset the Information Panel
@@ -136,17 +136,17 @@ private:
QTimer* m_resetUrlTimer;
// URL that is currently shown in the Information Panel.
- KUrl m_shownUrl;
+ QUrl m_shownUrl;
// URL candidate that will replace m_shownURL after a delay.
// Used to remember URLs when hovering items.
- KUrl m_urlCandidate;
+ QUrl m_urlCandidate;
// URL candidate that is marked as invalid (e. g. because the directory
// has been deleted or the shown item has been renamed). The Information
// Panel will be reset asynchronously to prevent unnecessary resets when
// a directory has been changed.
- KUrl m_invalidUrlCandidate;
+ QUrl m_invalidUrlCandidate;
KFileItem m_fileItem; // file item for m_shownUrl if available (otherwise null)
KFileItemList m_selection;
diff --git a/src/panels/information/informationpanelcontent.cpp b/src/panels/information/informationpanelcontent.cpp
index 4fb0d9442..c18d4738e 100644
--- a/src/panels/information/informationpanelcontent.cpp
+++ b/src/panels/information/informationpanelcontent.cpp
@@ -19,22 +19,23 @@
#include "informationpanelcontent.h"
-#include <KDialog>
#include <KFileItem>
-#include <KGlobalSettings>
#include <KIO/JobUiDelegate>
#include <KIO/PreviewJob>
+#include <KJobWidgets>
#include <KIconEffect>
#include <KIconLoader>
-#include <KLocale>
-#include <KMenu>
-#include <kseparator.h>
+#include <QIcon>
+#include <KLocalizedString>
+#include <QMenu>
+#include <KSeparator>
#include <KStringHandler>
+#include <QTextDocument>
#ifndef HAVE_BALOO
#include <KFileMetaDataWidget>
#else
-#include <baloo/filemetadatawidget.h>
+#include <Baloo/FileMetaDataWidget>
#endif
#include <panels/places/placesitem.h>
@@ -47,14 +48,14 @@
#include <QEvent>
#include <QLabel>
#include <QPixmap>
-#include <QPointer>
#include <QResizeEvent>
#include <QScrollArea>
-#include <QTextDocument>
#include <QTextLayout>
#include <QTextLine>
#include <QTimer>
#include <QVBoxLayout>
+#include <QFontDatabase>
+#include <QStyle>
#include "dolphin_informationpanelsettings.h"
#include "filemetadataconfigurationdialog.h"
@@ -81,11 +82,10 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) :
m_outdatedPreviewTimer = new QTimer(this);
m_outdatedPreviewTimer->setInterval(300);
m_outdatedPreviewTimer->setSingleShot(true);
- connect(m_outdatedPreviewTimer, SIGNAL(timeout()),
- this, SLOT(markOutdatedPreview()));
+ connect(m_outdatedPreviewTimer, &QTimer::timeout,
+ this, &InformationPanelContent::markOutdatedPreview);
QVBoxLayout* layout = new QVBoxLayout(this);
- layout->setSpacing(KDialog::spacingHint());
// preview
const int minPreviewWidth = KIconLoader::SizeEnormous + KIconLoader::SizeMedium;
@@ -97,8 +97,8 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) :
m_phononWidget = new PhononWidget(parent);
m_phononWidget->hide();
m_phononWidget->setMinimumWidth(minPreviewWidth);
- connect(m_phononWidget, SIGNAL(hasVideoChanged(bool)),
- this, SLOT(slotHasVideoChanged(bool)));
+ connect(m_phononWidget, &PhononWidget::hasVideoChanged,
+ this, &InformationPanelContent::slotHasVideoChanged);
// name
m_nameLabel = new QLabel(parent);
@@ -114,12 +114,15 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) :
#ifndef HAVE_BALOO
m_metaDataWidget = new KFileMetaDataWidget(parent);
+ connect(m_metaDataWidget, &KFileMetaDataWidget::urlActivated,
+ this, &InformationPanelContent::urlActivated);
#else
m_metaDataWidget = new Baloo::FileMetaDataWidget(parent);
+ connect(m_metaDataWidget, &Baloo::FileMetaDataWidget::urlActivated,
+ this, &InformationPanelContent::urlActivated);
#endif
- m_metaDataWidget->setFont(KGlobalSettings::smallestReadableFont());
+ m_metaDataWidget->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
- connect(m_metaDataWidget, SIGNAL(urlActivated(KUrl)), this, SIGNAL(urlActivated(KUrl)));
// Encapsulate the MetaDataWidget inside a container that has a dummy widget
// at the bottom. This prevents that the meta data widget gets vertically stretched
@@ -154,7 +157,7 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) :
InformationPanelContent::~InformationPanelContent()
{
- InformationPanelSettings::self()->writeConfig();
+ InformationPanelSettings::self()->save();
}
void InformationPanelContent::showItem(const KFileItem& item)
@@ -165,8 +168,8 @@ void InformationPanelContent::showItem(const KFileItem& item)
m_previewJob->kill();
}
- const KUrl itemUrl = item.url();
- const bool isSearchUrl = itemUrl.protocol().contains("search") && item.localPath().isEmpty();
+ const QUrl itemUrl = item.url();
+ const bool isSearchUrl = itemUrl.scheme().contains("search") && item.localPath().isEmpty();
if (!applyPlace(itemUrl)) {
setNameLabelText(item.text());
if (isSearchUrl) {
@@ -193,13 +196,13 @@ void InformationPanelContent::showItem(const KFileItem& item)
m_previewJob->setScaleType(KIO::PreviewJob::Unscaled);
m_previewJob->setIgnoreMaximumSize(item.isLocalFile());
if (m_previewJob->ui()) {
- m_previewJob->ui()->setWindow(this);
+ KJobWidgets::setWindow(m_previewJob, this);
}
- connect(m_previewJob, SIGNAL(gotPreview(KFileItem,QPixmap)),
- this, SLOT(showPreview(KFileItem,QPixmap)));
- connect(m_previewJob, SIGNAL(failed(KFileItem)),
- this, SLOT(showIcon(KFileItem)));
+ connect(m_previewJob.data(), &KIO::PreviewJob::gotPreview,
+ this, &InformationPanelContent::showPreview);
+ connect(m_previewJob.data(), &KIO::PreviewJob::failed,
+ this, &InformationPanelContent::showIcon);
}
}
@@ -272,7 +275,7 @@ bool InformationPanelContent::eventFilter(QObject* obj, QEvent* event)
break;
case QEvent::FontChange:
- m_metaDataWidget->setFont(KGlobalSettings::smallestReadableFont());
+ m_metaDataWidget->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
break;
default:
@@ -284,15 +287,15 @@ bool InformationPanelContent::eventFilter(QObject* obj, QEvent* event)
void InformationPanelContent::configureSettings(const QList<QAction*>& customContextMenuActions)
{
- KMenu popup(this);
+ QMenu popup(this);
QAction* previewAction = popup.addAction(i18nc("@action:inmenu", "Preview"));
- previewAction->setIcon(KIcon("view-preview"));
+ previewAction->setIcon(QIcon::fromTheme("view-preview"));
previewAction->setCheckable(true);
previewAction->setChecked(InformationPanelSettings::previewsShown());
QAction* configureAction = popup.addAction(i18nc("@action:inmenu", "Configure..."));
- configureAction->setIcon(KIcon("configure"));
+ configureAction->setIcon(QIcon::fromTheme("configure"));
popup.addSeparator();
foreach (QAction* action, customContextMenuActions) {
@@ -319,7 +322,7 @@ void InformationPanelContent::configureSettings(const QList<QAction*>& customCon
dialog->show();
dialog->raise();
dialog->activateWindow();
- connect(dialog, SIGNAL(destroyed()), this, SLOT(refreshMetaData()));
+ connect(dialog, &FileMetaDataConfigurationDialog::destroyed, this, &InformationPanelContent::refreshMetaData);
}
}
@@ -327,8 +330,10 @@ void InformationPanelContent::showIcon(const KFileItem& item)
{
m_outdatedPreviewTimer->stop();
if (!applyPlace(item.targetUrl())) {
- KIcon icon(item.iconName(), KIconLoader::global(), item.overlays());
- m_preview->setPixmap(icon.pixmap(KIconLoader::SizeEnormous));
+ const QPixmap icon = KIconLoader::global()->loadIcon(item.iconName(), KIconLoader::Desktop,
+ KIconLoader::SizeEnormous, KIconLoader::DefaultState,
+ item.overlays());
+ m_preview->setPixmap(icon);
}
}
@@ -364,14 +369,14 @@ void InformationPanelContent::refreshMetaData()
}
}
-bool InformationPanelContent::applyPlace(const KUrl& url)
+bool InformationPanelContent::applyPlace(const QUrl& url)
{
const int count = m_placesItemModel->count();
for (int i = 0; i < count; ++i) {
const PlacesItem* item = m_placesItemModel->placesItem(i);
- if (item->url().equals(url, KUrl::CompareWithoutTrailingSlash)) {
+ if (item->url().matches(url, QUrl::StripTrailingSlash)) {
setNameLabelText(item->text());
- m_preview->setPixmap(KIcon(item->icon()).pixmap(128, 128));
+ m_preview->setPixmap(QIcon::fromTheme(item->icon()).pixmap(128, 128));
return true;
}
}
@@ -417,7 +422,7 @@ void InformationPanelContent::adjustWidgetSizes(int width)
// so that the width of the information panel gets increased.
// To prevent this, the maximum width is adjusted to
// the current width of the panel.
- const int maxWidth = width - KDialog::spacingHint() * 4;
+ const int maxWidth = width - style()->layoutSpacing(QSizePolicy::DefaultType, QSizePolicy::DefaultType, Qt::Horizontal) * 4;
m_nameLabel->setMaximumWidth(maxWidth);
// The metadata widget also contains a text widget which may return
@@ -435,4 +440,3 @@ void InformationPanelContent::adjustWidgetSizes(int width)
}
}
-#include "informationpanelcontent.moc"
diff --git a/src/panels/information/informationpanelcontent.h b/src/panels/information/informationpanelcontent.h
index 67fdf6c5a..533e9de3b 100644
--- a/src/panels/information/informationpanelcontent.h
+++ b/src/panels/information/informationpanelcontent.h
@@ -21,12 +21,11 @@
#define INFORMATIONPANELCONTENT_H
#include "config-baloo.h"
-#include <KConfig>
#include <KFileItem>
-#include <KUrl>
-#include <KVBox>
+#include <QUrl>
#include <QPointer>
+#include <QWidget>
class KFileItemList;
class PhononWidget;
@@ -82,11 +81,11 @@ public:
void configureSettings(const QList<QAction*>& customContextMenuActions);
signals:
- void urlActivated( const KUrl& url );
+ void urlActivated( const QUrl& url );
protected:
/** @see QObject::eventFilter() */
- virtual bool eventFilter(QObject* obj, QEvent* event);
+ virtual bool eventFilter(QObject* obj, QEvent* event) Q_DECL_OVERRIDE;
private slots:
/**
@@ -122,7 +121,7 @@ private:
* @return True, if the URL represents exactly a place.
* @param url The url to check.
*/
- bool applyPlace(const KUrl& url);
+ bool applyPlace(const QUrl& url);
/**
* Sets the text for the label \a m_nameLabel and assures that the
diff --git a/src/panels/information/phononwidget.cpp b/src/panels/information/phononwidget.cpp
index 63f5aa3a5..1d6361f19 100644
--- a/src/panels/information/phononwidget.cpp
+++ b/src/panels/information/phononwidget.cpp
@@ -30,11 +30,11 @@
#include <QHBoxLayout>
#include <QShowEvent>
#include <QToolButton>
-
-#include <KDialog>
-#include <KIcon>
-#include <KUrl>
-#include <KLocale>
+#include <QDialog>
+#include <QIcon>
+#include <KIconLoader>
+#include <QUrl>
+#include <KLocalizedString>
class EmbeddedVideoPlayer : public Phonon::VideoWidget
{
@@ -72,7 +72,7 @@ PhononWidget::PhononWidget(QWidget *parent)
{
}
-void PhononWidget::setUrl(const KUrl &url)
+void PhononWidget::setUrl(const QUrl &url)
{
if (m_url != url) {
stop(); // emits playingStopped() signal
@@ -80,7 +80,7 @@ void PhononWidget::setUrl(const KUrl &url)
}
}
-KUrl PhononWidget::url() const
+QUrl PhononWidget::url() const
{
return m_url;
}
@@ -108,7 +108,7 @@ void PhononWidget::showEvent(QShowEvent *event)
if (!m_topLayout) {
m_topLayout = new QVBoxLayout(this);
m_topLayout->setMargin(0);
- m_topLayout->setSpacing(KDialog::spacingHint());
+
QHBoxLayout *controlsLayout = new QHBoxLayout(this);
controlsLayout->setMargin(0);
controlsLayout->setSpacing(0);
@@ -128,16 +128,16 @@ void PhononWidget::showEvent(QShowEvent *event)
m_playButton->setToolTip(i18n("play"));
m_playButton->setIconSize(buttonSize);
- m_playButton->setIcon(KIcon("media-playback-start"));
+ m_playButton->setIcon(QIcon::fromTheme("media-playback-start"));
m_playButton->setAutoRaise(true);
- connect(m_playButton, SIGNAL(clicked()), this, SLOT(play()));
+ connect(m_playButton, &QToolButton::clicked, this, &PhononWidget::play);
m_stopButton->setToolTip(i18n("stop"));
m_stopButton->setIconSize(buttonSize);
- m_stopButton->setIcon(KIcon("media-playback-stop"));
+ m_stopButton->setIcon(QIcon::fromTheme("media-playback-stop"));
m_stopButton->setAutoRaise(true);
m_stopButton->hide();
- connect(m_stopButton, SIGNAL(clicked()), this, SLOT(stop()));
+ connect(m_stopButton, &QToolButton::clicked, this, &PhononWidget::stop);
m_seekSlider->setIconVisible(false);
@@ -183,10 +183,10 @@ void PhononWidget::play()
{
if (!m_media) {
m_media = new Phonon::MediaObject(this);
- connect(m_media, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
- this, SLOT(stateChanged(Phonon::State)));
- connect(m_media, SIGNAL(hasVideoChanged(bool)),
- this, SLOT(slotHasVideoChanged(bool)));
+ connect(m_media, &Phonon::MediaObject::stateChanged,
+ this, &PhononWidget::stateChanged);
+ connect(m_media, &Phonon::MediaObject::hasVideoChanged,
+ this, &PhononWidget::slotHasVideoChanged);
m_seekSlider->setMediaObject(m_media);
}
diff --git a/src/panels/information/phononwidget.h b/src/panels/information/phononwidget.h
index b5aedfe4f..837a66888 100644
--- a/src/panels/information/phononwidget.h
+++ b/src/panels/information/phononwidget.h
@@ -21,8 +21,7 @@
#ifndef PHONONWIDGET_H
#define PHONONWIDGET_H
-#include <KUrl>
-
+#include <QUrl>
#include <QSize>
#include <QWidget>
@@ -46,8 +45,8 @@ class PhononWidget : public QWidget
public:
PhononWidget(QWidget *parent = 0);
- void setUrl(const KUrl &url);
- KUrl url() const;
+ void setUrl(const QUrl &url);
+ QUrl url() const;
void setVideoSize(const QSize& size);
QSize videoSize() const;
@@ -64,8 +63,8 @@ class PhononWidget : public QWidget
void hasVideoChanged(bool hasVideo);
protected:
- virtual void showEvent(QShowEvent *event);
- virtual void hideEvent(QHideEvent *event);
+ virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
+ virtual void hideEvent(QHideEvent *event) Q_DECL_OVERRIDE;
private slots:
void stateChanged(Phonon::State);
@@ -77,7 +76,7 @@ class PhononWidget : public QWidget
void applyVideoSize();
private:
- KUrl m_url;
+ QUrl m_url;
QSize m_videoSize;
QToolButton *m_playButton;
diff --git a/src/panels/information/pixmapviewer.cpp b/src/panels/information/pixmapviewer.cpp
index 45a8c17e2..0053e43f9 100644
--- a/src/panels/information/pixmapviewer.cpp
+++ b/src/panels/information/pixmapviewer.cpp
@@ -21,10 +21,8 @@
#include <KIconLoader>
-#include <QLayout>
#include <QPainter>
#include <QPixmap>
-#include <QKeyEvent>
PixmapViewer::PixmapViewer(QWidget* parent, Transition transition) :
QWidget(parent),
@@ -39,8 +37,8 @@ PixmapViewer::PixmapViewer(QWidget* parent, Transition transition) :
m_animation.setCurveShape(QTimeLine::LinearCurve);
if (m_transition != NoTransition) {
- connect(&m_animation, SIGNAL(valueChanged(qreal)), this, SLOT(update()));
- connect(&m_animation, SIGNAL(finished()), this, SLOT(checkPendingPixmaps()));
+ connect(&m_animation, &QTimeLine::valueChanged, this, static_cast<void(PixmapViewer::*)()>(&PixmapViewer::update));
+ connect(&m_animation, &QTimeLine::finished, this, &PixmapViewer::checkPendingPixmaps);
}
}
@@ -129,4 +127,3 @@ void PixmapViewer::checkPendingPixmaps()
}
}
-#include "pixmapviewer.moc"
diff --git a/src/panels/information/pixmapviewer.h b/src/panels/information/pixmapviewer.h
index 8197df979..ddc183351 100644
--- a/src/panels/information/pixmapviewer.h
+++ b/src/panels/information/pixmapviewer.h
@@ -71,10 +71,10 @@ public:
* of the parent widget. Per default no size hint is given.
*/
void setSizeHint(const QSize& size);
- virtual QSize sizeHint() const;
+ virtual QSize sizeHint() const Q_DECL_OVERRIDE;
protected:
- virtual void paintEvent(QPaintEvent* event);
+ virtual void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE;
private Q_SLOTS:
void checkPendingPixmaps();
diff --git a/src/panels/panel.cpp b/src/panels/panel.cpp
index 14b7c0230..348191c98 100644
--- a/src/panels/panel.cpp
+++ b/src/panels/panel.cpp
@@ -19,7 +19,7 @@
***************************************************************************/
#include "panel.h"
-#include <KUrl>
+#include <QUrl>
Panel::Panel(QWidget* parent) :
QWidget(parent),
@@ -32,7 +32,7 @@ Panel::~Panel()
{
}
-KUrl Panel::url() const
+QUrl Panel::url() const
{
return m_url;
}
@@ -57,13 +57,13 @@ QSize Panel::sizeHint() const
return QSize(180, 180);
}
-void Panel::setUrl(const KUrl& url)
+void Panel::setUrl(const QUrl& url)
{
- if (url.equals(m_url, KUrl::CompareWithoutTrailingSlash)) {
+ if (url.matches(m_url, QUrl::StripTrailingSlash)) {
return;
}
- const KUrl oldUrl = m_url;
+ const QUrl oldUrl = m_url;
m_url = url;
const bool accepted = urlChanged();
if (!accepted) {
@@ -76,4 +76,3 @@ void Panel::readSettings()
}
-#include "panel.moc"
diff --git a/src/panels/panel.h b/src/panels/panel.h
index a0b25d6cc..d3460bf13 100644
--- a/src/panels/panel.h
+++ b/src/panels/panel.h
@@ -22,8 +22,7 @@
#define PANEL_H
#include <QWidget>
-#include <KUrl>
-#include <KFileItem>
+#include <QUrl>
/**
* @brief Base widget for all panels that can be docked on the window borders.
@@ -40,7 +39,7 @@ public:
virtual ~Panel();
/** Returns the current set URL of the active Dolphin view. */
- KUrl url() const;
+ QUrl url() const;
/**
* Sets custom context menu actions that are added to the panel specific
@@ -50,15 +49,14 @@ public:
void setCustomContextMenuActions(const QList<QAction*>& actions);
QList<QAction*> customContextMenuActions() const;
- /** @see QWidget::sizeHint() */
- virtual QSize sizeHint() const;
+ virtual QSize sizeHint() const Q_DECL_OVERRIDE;
public slots:
/**
* This is invoked every time the folder being displayed in the
* active Dolphin view changes.
*/
- void setUrl(const KUrl& url);
+ void setUrl(const QUrl &url);
/**
* Refreshes the view to get synchronized with the settings.
@@ -76,7 +74,7 @@ protected:
virtual bool urlChanged() = 0;
private:
- KUrl m_url;
+ QUrl m_url;
QList<QAction*> m_customContextMenuActions;
};
diff --git a/src/panels/places/placesitem.cpp b/src/panels/places/placesitem.cpp
index 173da29c5..638d59ec0 100644
--- a/src/panels/places/placesitem.cpp
+++ b/src/panels/places/placesitem.cpp
@@ -23,10 +23,9 @@
#include "placesitem.h"
#include <KBookmarkManager>
-#include <KDebug>
+#include "dolphindebug.h"
#include <KDirLister>
-#include <KIcon>
-#include <KLocale>
+#include <KLocalizedString>
#include "placesitemsignalhandler.h"
#include <QDateTime>
#include <Solid/Block>
@@ -52,16 +51,16 @@ PlacesItem::~PlacesItem()
delete m_trashDirLister;
}
-void PlacesItem::setUrl(const KUrl& url)
+void PlacesItem::setUrl(const QUrl &url)
{
// The default check in KStandardItem::setDataValue()
// for equal values does not work with a custom value
- // like KUrl. Hence do a manual check to prevent that
+ // like QUrl. Hence do a manual check to prevent that
// setting an equal URL results in an itemsChanged()
// signal.
- if (dataValue("url").value<KUrl>() != url) {
+ if (dataValue("url").value<QUrl>() != url) {
delete m_trashDirLister;
- if (url.protocol() == QLatin1String("trash")) {
+ if (url.scheme() == QLatin1String("trash")) {
// The trash icon must always be updated dependent on whether
// the trash is empty or not. We use a KDirLister that automatically
// watches for changes if the number of items has been changed.
@@ -69,8 +68,8 @@ void PlacesItem::setUrl(const KUrl& url)
m_trashDirLister = new KDirLister();
m_trashDirLister->setAutoErrorHandlingEnabled(false, 0);
m_trashDirLister->setDelayedMimeTypes(true);
- QObject::connect(m_trashDirLister, SIGNAL(completed()),
- m_signalHandler, SLOT(onTrashDirListerCompleted()));
+ QObject::connect(m_trashDirLister.data(), static_cast<void(KDirLister::*)()>(&KDirLister::completed),
+ m_signalHandler.data(), &PlacesItemSignalHandler::onTrashDirListerCompleted);
m_trashDirLister->openUrl(url);
}
@@ -78,9 +77,9 @@ void PlacesItem::setUrl(const KUrl& url)
}
}
-KUrl PlacesItem::url() const
+QUrl PlacesItem::url() const
{
- return dataValue("url").value<KUrl>();
+ return dataValue("url").value<QUrl>();
}
void PlacesItem::setUdi(const QString& udi)
@@ -135,7 +134,7 @@ void PlacesItem::setBookmark(const KBookmark& bookmark)
const QString udi = bookmark.metaDataItem("UDI");
if (udi.isEmpty()) {
setIcon(bookmark.icon());
- setText(i18nc("KFile System Bookmarks", bookmark.text().toUtf8().data()));
+ setText(i18nc("KFile System Bookmarks", bookmark.text().toUtf8().constData()));
setUrl(bookmark.url());
} else {
initializeDevice(udi);
@@ -171,7 +170,7 @@ KBookmark PlacesItem::bookmark() const
PlacesItem::GroupType PlacesItem::groupType() const
{
if (udi().isEmpty()) {
- const QString protocol = url().protocol();
+ const QString protocol = url().scheme();
if (protocol == QLatin1String("timeline")) {
return RecentlySavedType;
}
@@ -197,7 +196,7 @@ bool PlacesItem::storageSetupNeeded() const
KBookmark PlacesItem::createBookmark(KBookmarkManager* manager,
const QString& text,
- const KUrl& url,
+ const QUrl& url,
const QString& iconName)
{
KBookmarkGroup root = manager->root();
@@ -270,31 +269,31 @@ void PlacesItem::initializeDevice(const QString& udi)
setUdi(udi);
if (m_access) {
- setUrl(m_access->filePath());
- QObject::connect(m_access, SIGNAL(accessibilityChanged(bool,QString)),
- m_signalHandler, SLOT(onAccessibilityChanged()));
+ setUrl(QUrl::fromLocalFile(m_access->filePath()));
+ QObject::connect(m_access.data(), SIGNAL(accessibilityChanged(bool,QString)),
+ m_signalHandler.data(), SLOT(onAccessibilityChanged()));
} else if (m_disc && (m_disc->availableContent() & Solid::OpticalDisc::Audio) != 0) {
Solid::Block *block = m_device.as<Solid::Block>();
if (block) {
const QString device = block->device();
- setUrl(QString("audiocd:/?device=%1").arg(device));
+ setUrl(QStringLiteral("audiocd:/?device=%1").arg(device));
} else {
- setUrl(QString("audiocd:/"));
+ setUrl(QStringLiteral("audiocd:/"));
}
} else if (m_mtp) {
- setUrl(QString("mtp:udi=%1").arg(m_device.udi()));
+ setUrl(QStringLiteral("mtp:udi=%1").arg(m_device.udi()));
}
}
void PlacesItem::onAccessibilityChanged()
{
setIconOverlays(m_device.emblems());
- setUrl(m_access->filePath());
+ setUrl(QUrl::fromLocalFile(m_access->filePath()));
}
void PlacesItem::onTrashDirListerCompleted()
{
- Q_ASSERT(url().protocol() == QLatin1String("trash"));
+ Q_ASSERT(url().scheme() == QLatin1String("trash"));
const bool isTrashEmpty = m_trashDirLister->items().isEmpty();
setIcon(isTrashEmpty ? "user-trash" : "user-trash-full");
diff --git a/src/panels/places/placesitem.h b/src/panels/places/placesitem.h
index 4c636ec63..4ae4fd677 100644
--- a/src/panels/places/placesitem.h
+++ b/src/panels/places/placesitem.h
@@ -22,7 +22,7 @@
#include <KBookmark>
#include <kitemviews/kstandarditem.h>
-#include <KUrl>
+#include <QUrl>
#include <QPointer>
#include <Solid/Device>
#include <Solid/OpticalDisc>
@@ -51,8 +51,8 @@ public:
explicit PlacesItem(const KBookmark& bookmark, PlacesItem* parent = 0);
virtual ~PlacesItem();
- void setUrl(const KUrl& url);
- KUrl url() const;
+ void setUrl(const QUrl& url);
+ QUrl url() const;
void setUdi(const QString& udi);
QString udi() const;
@@ -74,7 +74,7 @@ public:
static KBookmark createBookmark(KBookmarkManager* manager,
const QString& text,
- const KUrl& url,
+ const QUrl& url,
const QString& iconName);
static KBookmark createDeviceBookmark(KBookmarkManager* manager,
const QString& udi);
@@ -82,10 +82,10 @@ public:
protected:
virtual void onDataValueChanged(const QByteArray& role,
const QVariant& current,
- const QVariant& previous);
+ const QVariant& previous) Q_DECL_OVERRIDE;
virtual void onDataChanged(const QHash<QByteArray, QVariant>& current,
- const QHash<QByteArray, QVariant>& previous);
+ const QHash<QByteArray, QVariant>& previous) Q_DECL_OVERRIDE;
private:
PlacesItem(const PlacesItem& item);
diff --git a/src/panels/places/placesitemeditdialog.cpp b/src/panels/places/placesitemeditdialog.cpp
index 08c910d17..d035b0403 100644
--- a/src/panels/places/placesitemeditdialog.cpp
+++ b/src/panels/places/placesitemeditdialog.cpp
@@ -24,21 +24,22 @@
#include "placesitemeditdialog.h"
#include <KAboutData>
-#include <KComponentData>
-#include <KDebug>
+#include "dolphindebug.h"
#include <KFile>
#include <KIconButton>
-#include <KLineEdit>
-#include <KLocale>
-#include <KMimeType>
+#include <KLocalizedString>
+#include <QMimeDatabase>
#include <KUrlRequester>
#include <QCheckBox>
#include <QEvent>
#include <QFormLayout>
#include <QVBoxLayout>
+#include <QDialogButtonBox>
+#include <QPushButton>
+#include <QLineEdit>
PlacesItemEditDialog::PlacesItemEditDialog(QWidget* parent) :
- KDialog(parent),
+ QDialog(parent),
m_icon(),
m_text(),
m_url(),
@@ -48,9 +49,6 @@ PlacesItemEditDialog::PlacesItemEditDialog(QWidget* parent) :
m_iconButton(0),
m_appLocal(0)
{
- setButtons( Ok | Cancel );
- setModal(true);
- setDefaultButton(Ok);
}
void PlacesItemEditDialog::setIcon(const QString& icon)
@@ -72,18 +70,18 @@ QString PlacesItemEditDialog::text() const
{
QString text = m_textEdit->text();
if (text.isEmpty()) {
- const KUrl url = m_urlEdit->url();
- text = url.fileName().isEmpty() ? url.prettyUrl() : url.fileName();
+ const QUrl url = m_urlEdit->url();
+ text = url.fileName().isEmpty() ? url.toDisplayString(QUrl::PreferLocalFile) : url.fileName();
}
return text;
}
-void PlacesItemEditDialog::setUrl(const KUrl& url)
+void PlacesItemEditDialog::setUrl(const QUrl& url)
{
m_url = url;
}
-KUrl PlacesItemEditDialog::url() const
+QUrl PlacesItemEditDialog::url() const
{
return m_urlEdit->url();
}
@@ -108,7 +106,7 @@ bool PlacesItemEditDialog::event(QEvent* event)
void PlacesItemEditDialog::slotUrlChanged(const QString& text)
{
- enableButtonOk(!text.isEmpty());
+ m_okButton->setEnabled(!text.isEmpty());
}
PlacesItemEditDialog::~PlacesItemEditDialog()
@@ -117,42 +115,51 @@ PlacesItemEditDialog::~PlacesItemEditDialog()
void PlacesItemEditDialog::initialize()
{
+ QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
+ m_okButton = buttonBox->button(QDialogButtonBox::Ok);
+ m_okButton->setDefault(true);
+ m_okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
+ connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+ setModal(true);
+ m_okButton->setDefault(true);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ setLayout(mainLayout);
QWidget* mainWidget = new QWidget(this);
+ mainLayout->addWidget(mainWidget);
+ mainLayout->addWidget(buttonBox);
+
QVBoxLayout* vBox = new QVBoxLayout(mainWidget);
QFormLayout* formLayout = new QFormLayout();
vBox->addLayout( formLayout );
- m_textEdit = new KLineEdit(mainWidget);
+ m_textEdit = new QLineEdit(mainWidget);
formLayout->addRow(i18nc("@label", "Label:"), m_textEdit);
m_textEdit->setText(m_text);
- m_textEdit->setClickMessage(i18n("Enter descriptive label here"));
+ m_textEdit->setPlaceholderText(i18n("Enter descriptive label here"));
- m_urlEdit = new KUrlRequester(m_url.prettyUrl(), mainWidget);
+ m_urlEdit = new KUrlRequester(m_url, mainWidget);
m_urlEdit->setMode(KFile::Directory);
formLayout->addRow(i18nc("@label", "Location:"), m_urlEdit);
// Provide room for at least 40 chars (average char width is half of height)
m_urlEdit->setMinimumWidth(m_urlEdit->fontMetrics().height() * (40 / 2));
- connect(m_urlEdit->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(slotUrlChanged(QString)));
+ connect(m_urlEdit, &KUrlRequester::textChanged, this, &PlacesItemEditDialog::slotUrlChanged);
m_iconButton = new KIconButton(mainWidget);
formLayout->addRow(i18nc("@label", "Choose an icon:"), m_iconButton);
m_iconButton->setIconSize(IconSize(KIconLoader::Desktop));
m_iconButton->setIconType(KIconLoader::NoGroup, KIconLoader::Place);
if (m_icon.isEmpty()) {
- m_iconButton->setIcon(KMimeType::iconNameForUrl(m_url));
+ QMimeDatabase db;
+ m_iconButton->setIcon(db.mimeTypeForUrl(m_url).iconName());
} else {
m_iconButton->setIcon(m_icon);
}
if (m_allowGlobal) {
- QString appName;
- if (KGlobal::mainComponent().aboutData()) {
- appName = KGlobal::mainComponent().aboutData()->programName();
- }
- if (appName.isEmpty()) {
- appName = KGlobal::mainComponent().componentName();
- }
+ const QString appName = KAboutData::applicationData().displayName();
m_appLocal = new QCheckBox( i18n("&Only show when using this application (%1)", appName ), mainWidget );
m_appLocal->setChecked(false);
vBox->addWidget(m_appLocal);
@@ -164,7 +171,5 @@ void PlacesItemEditDialog::initialize()
m_textEdit->setFocus();
}
- setMainWidget(mainWidget);
}
-#include "placesitemeditdialog.moc"
diff --git a/src/panels/places/placesitemeditdialog.h b/src/panels/places/placesitemeditdialog.h
index bf348479c..8a0dc0471 100644
--- a/src/panels/places/placesitemeditdialog.h
+++ b/src/panels/places/placesitemeditdialog.h
@@ -24,15 +24,16 @@
#ifndef PLACESITEMEDITDIALOG_H
#define PLACESITEMEDITDIALOG_H
-#include <KDialog>
-#include <KUrl>
+#include <QDialog>
+#include <QUrl>
class KIconButton;
-class KLineEdit;
class KUrlRequester;
+class QLineEdit;
class QCheckBox;
+class QPushButton;
-class PlacesItemEditDialog: public KDialog
+class PlacesItemEditDialog: public QDialog
{
Q_OBJECT
@@ -46,14 +47,14 @@ public:
void setText(const QString& text);
QString text() const;
- void setUrl(const KUrl& url);
- KUrl url() const;
+ void setUrl(const QUrl& url);
+ QUrl url() const;
void setAllowGlobal(bool allow);
bool allowGlobal() const;
protected:
- virtual bool event(QEvent* event);
+ virtual bool event(QEvent* event) Q_DECL_OVERRIDE;
private slots:
void slotUrlChanged(const QString& text);
@@ -64,13 +65,14 @@ private:
private:
QString m_icon;
QString m_text;
- KUrl m_url;
+ QUrl m_url;
bool m_allowGlobal;
KUrlRequester* m_urlEdit;
- KLineEdit* m_textEdit;
+ QLineEdit* m_textEdit;
KIconButton* m_iconButton;
QCheckBox* m_appLocal;
+ QPushButton *m_okButton;
};
#endif
diff --git a/src/panels/places/placesitemlistgroupheader.cpp b/src/panels/places/placesitemlistgroupheader.cpp
index ec7c4b18c..e17fd4d66 100644
--- a/src/panels/places/placesitemlistgroupheader.cpp
+++ b/src/panels/places/placesitemlistgroupheader.cpp
@@ -42,4 +42,3 @@ QPalette::ColorRole PlacesItemListGroupHeader::normalTextColorRole() const
return QPalette::WindowText;
}
-#include "placesitemlistgroupheader.moc"
diff --git a/src/panels/places/placesitemlistgroupheader.h b/src/panels/places/placesitemlistgroupheader.h
index 1c2d5cc25..7daaba602 100644
--- a/src/panels/places/placesitemlistgroupheader.h
+++ b/src/panels/places/placesitemlistgroupheader.h
@@ -31,7 +31,7 @@ public:
virtual ~PlacesItemListGroupHeader();
protected:
- virtual void paintSeparator(QPainter* painter, const QColor& color);
+ virtual void paintSeparator(QPainter* painter, const QColor& color) Q_DECL_OVERRIDE;
virtual QPalette::ColorRole normalTextColorRole() const;
};
diff --git a/src/panels/places/placesitemlistwidget.cpp b/src/panels/places/placesitemlistwidget.cpp
index e33d1daf9..18e561864 100644
--- a/src/panels/places/placesitemlistwidget.cpp
+++ b/src/panels/places/placesitemlistwidget.cpp
@@ -19,8 +19,6 @@
#include "placesitemlistwidget.h"
-#include "kdebug.h"
-
PlacesItemListWidget::PlacesItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent) :
KStandardItemListWidget(informant, parent)
{
@@ -40,4 +38,3 @@ QPalette::ColorRole PlacesItemListWidget::normalTextColorRole() const
return QPalette::WindowText;
}
-#include "placesitemlistwidget.moc"
diff --git a/src/panels/places/placesitemlistwidget.h b/src/panels/places/placesitemlistwidget.h
index a2a88c1f0..e9e6a0767 100644
--- a/src/panels/places/placesitemlistwidget.h
+++ b/src/panels/places/placesitemlistwidget.h
@@ -35,8 +35,8 @@ public:
virtual ~PlacesItemListWidget();
protected:
- virtual bool isHidden() const;
- virtual QPalette::ColorRole normalTextColorRole() const;
+ virtual bool isHidden() const Q_DECL_OVERRIDE;
+ virtual QPalette::ColorRole normalTextColorRole() const Q_DECL_OVERRIDE;
};
#endif
diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp
index 637bfc107..bc7c2b7d3 100644
--- a/src/panels/places/placesitemmodel.cpp
+++ b/src/panels/places/placesitemmodel.cpp
@@ -26,20 +26,20 @@
#include "dolphin_generalsettings.h"
#include <KBookmark>
-#include <KBookmarkGroup>
#include <KBookmarkManager>
-#include <KComponentData>
-#include <KDebug>
-#include <KIcon>
-#include <kprotocolinfo.h>
-#include <KLocale>
-#include <KStandardDirs>
+#include "dolphindebug.h"
+#include <QIcon>
+#include <KProtocolInfo>
+#include <KLocalizedString>
+#include <QStandardPaths>
#include <KUser>
+#include <KAboutData>
#include "placesitem.h"
#include <QAction>
#include <QDate>
#include <QMimeData>
#include <QTimer>
+#include <KUrlMimeData>
#include <Solid/Device>
#include <Solid/DeviceNotifier>
@@ -52,8 +52,8 @@
#include <views/viewproperties.h>
#ifdef HAVE_BALOO
- #include <baloo/query.h>
- #include <baloo/indexerconfig.h>
+ #include <Baloo/Query>
+ #include <Baloo/IndexerConfig>
#endif
namespace {
@@ -64,7 +64,7 @@ namespace {
// be independent from changes in the Baloo-search-URL-syntax.
// Hence a prefix to the application-name of the stored bookmarks is
// added, which is only read by PlacesItemModel.
- const char* AppNamePrefix = "-places-panel";
+ const char AppNamePrefix[] = "-places-panel";
}
PlacesItemModel::PlacesItemModel(QObject* parent) :
@@ -85,7 +85,7 @@ PlacesItemModel::PlacesItemModel(QObject* parent) :
Baloo::IndexerConfig config;
m_fileIndexingEnabled = config.fileIndexingEnabled();
#endif
- const QString file = KStandardDirs::locateLocal("data", "kfileplaces/bookmarks.xml");
+ const QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kfileplaces/bookmarks.xml");
m_bookmarkManager = KBookmarkManager::managerForFile(file, "kfilePlaces");
createSystemBookmarks();
@@ -97,12 +97,12 @@ PlacesItemModel::PlacesItemModel(QObject* parent) :
m_updateBookmarksTimer = new QTimer(this);
m_updateBookmarksTimer->setInterval(syncBookmarksTimeout);
m_updateBookmarksTimer->setSingleShot(true);
- connect(m_updateBookmarksTimer, SIGNAL(timeout()), this, SLOT(updateBookmarks()));
+ connect(m_updateBookmarksTimer, &QTimer::timeout, this, &PlacesItemModel::updateBookmarks);
- connect(m_bookmarkManager, SIGNAL(changed(QString,QString)),
- m_updateBookmarksTimer, SLOT(start()));
- connect(m_bookmarkManager, SIGNAL(bookmarksChanged(QString)),
- m_updateBookmarksTimer, SLOT(start()));
+ connect(m_bookmarkManager, &KBookmarkManager::changed,
+ m_updateBookmarksTimer, static_cast<void(QTimer::*)()>(&QTimer::start));
+ connect(m_bookmarkManager, &KBookmarkManager::bookmarksChanged,
+ m_updateBookmarksTimer, static_cast<void(QTimer::*)()>(&QTimer::start));
}
PlacesItemModel::~PlacesItemModel()
@@ -112,7 +112,7 @@ PlacesItemModel::~PlacesItemModel()
}
PlacesItem* PlacesItemModel::createPlacesItem(const QString& text,
- const KUrl& url,
+ const QUrl& url,
const QString& iconName)
{
const KBookmark bookmark = PlacesItem::createBookmark(m_bookmarkManager, text, url, iconName);
@@ -188,7 +188,7 @@ void PlacesItemModel::setHiddenItemsShown(bool show)
}
#ifdef PLACESITEMMODEL_DEBUG
- kDebug() << "Changed visibility of hidden items";
+ qCDebug(DolphinDebug) << "Changed visibility of hidden items";
showModelState();
#endif
}
@@ -198,15 +198,19 @@ bool PlacesItemModel::hiddenItemsShown() const
return m_hiddenItemsShown;
}
-int PlacesItemModel::closestItem(const KUrl& url) const
+int PlacesItemModel::closestItem(const QUrl& url) const
{
int foundIndex = -1;
int maxLength = 0;
for (int i = 0; i < count(); ++i) {
- const KUrl itemUrl = placesItem(i)->url();
- if (itemUrl.isParentOf(url)) {
- const int length = itemUrl.prettyUrl().length();
+ const QUrl itemUrl = placesItem(i)->url();
+ if (url == itemUrl) {
+ // We can't find a closer one, so stop here.
+ foundIndex = i;
+ break;
+ } else if (itemUrl.isParentOf(url)) {
+ const int length = itemUrl.path().length();
if (length > maxLength) {
foundIndex = i;
maxLength = length;
@@ -247,7 +251,7 @@ QAction* PlacesItemModel::ejectAction(int index) const
{
const PlacesItem* item = placesItem(index);
if (item && item->device().is<Solid::OpticalDisc>()) {
- return new QAction(KIcon("media-eject"), i18nc("@item", "Eject '%1'", item->text()), 0);
+ return new QAction(QIcon::fromTheme("media-eject"), i18nc("@item", "Eject '%1'", item->text()), 0);
}
return 0;
@@ -296,7 +300,7 @@ QAction* PlacesItemModel::teardownAction(int index) const
return new QAction(text, 0);
}
- return new QAction(KIcon(iconName), text, 0);
+ return new QAction(QIcon::fromTheme(iconName), text, 0);
}
void PlacesItemModel::requestEject(int index)
@@ -305,9 +309,8 @@ void PlacesItemModel::requestEject(int index)
if (item) {
Solid::OpticalDrive* drive = item->device().parent().as<Solid::OpticalDrive>();
if (drive) {
- connect(drive, SIGNAL(ejectDone(Solid::ErrorType,QVariant,QString)),
- this, SLOT(slotStorageTeardownDone(Solid::ErrorType,QVariant)),
- Qt::UniqueConnection);
+ connect(drive, &Solid::OpticalDrive::ejectDone,
+ this, &PlacesItemModel::slotStorageTeardownDone);
drive->eject();
} else {
const QString label = item->text();
@@ -323,9 +326,8 @@ void PlacesItemModel::requestTeardown(int index)
if (item) {
Solid::StorageAccess* access = item->device().as<Solid::StorageAccess>();
if (access) {
- connect(access, SIGNAL(teardownDone(Solid::ErrorType,QVariant,QString)),
- this, SLOT(slotStorageTeardownDone(Solid::ErrorType,QVariant)),
- Qt::UniqueConnection);
+ connect(access, &Solid::StorageAccess::teardownDone,
+ this, &PlacesItemModel::slotStorageTeardownDone);
access->teardown();
}
}
@@ -353,9 +355,8 @@ void PlacesItemModel::requestStorageSetup(int index)
m_storageSetupInProgress[access] = index;
- connect(access, SIGNAL(setupDone(Solid::ErrorType,QVariant,QString)),
- this, SLOT(slotStorageSetupDone(Solid::ErrorType,QVariant,QString)),
- Qt::UniqueConnection);
+ connect(access, &Solid::StorageAccess::setupDone,
+ this, &PlacesItemModel::slotStorageSetupDone);
access->setup();
}
@@ -363,13 +364,13 @@ void PlacesItemModel::requestStorageSetup(int index)
QMimeData* PlacesItemModel::createMimeData(const KItemSet& indexes) const
{
- KUrl::List urls;
+ QList<QUrl> urls;
QByteArray itemData;
QDataStream stream(&itemData, QIODevice::WriteOnly);
foreach (int index, indexes) {
- const KUrl itemUrl = placesItem(index)->url();
+ const QUrl itemUrl = placesItem(index)->url();
if (itemUrl.isValid()) {
urls << itemUrl;
}
@@ -378,7 +379,7 @@ QMimeData* PlacesItemModel::createMimeData(const KItemSet& indexes) const
QMimeData* mimeData = new QMimeData();
if (!urls.isEmpty()) {
- urls.populateMimeData(mimeData);
+ mimeData->setUrls(urls);
}
mimeData->setData(internalMimeType(), itemData);
@@ -419,9 +420,9 @@ void PlacesItemModel::dropMimeDataBefore(int index, const QMimeData* mimeData)
insertItem(dropIndex, newItem);
} else if (mimeData->hasFormat("text/uri-list")) {
// One or more items must be added to the model
- const KUrl::List urls = KUrl::List::fromMimeData(mimeData);
+ const QList<QUrl> urls = KUrlMimeData::urlsFromMimeData(mimeData);
for (int i = urls.count() - 1; i >= 0; --i) {
- const KUrl& url = urls[i];
+ const QUrl& url = urls[i];
QString text = url.fileName();
if (text.isEmpty()) {
@@ -429,7 +430,7 @@ void PlacesItemModel::dropMimeDataBefore(int index, const QMimeData* mimeData)
}
if ((url.isLocalFile() && !QFileInfo(url.toLocalFile()).isDir())
- || url.protocol() == "trash") {
+ || url.scheme() == "trash") {
// Only directories outside the trash are allowed
continue;
}
@@ -441,12 +442,12 @@ void PlacesItemModel::dropMimeDataBefore(int index, const QMimeData* mimeData)
}
}
-KUrl PlacesItemModel::convertedUrl(const KUrl& url)
+QUrl PlacesItemModel::convertedUrl(const QUrl& url)
{
- KUrl newUrl = url;
- if (url.protocol() == QLatin1String("timeline")) {
+ QUrl newUrl = url;
+ if (url.scheme() == QLatin1String("timeline")) {
newUrl = createTimelineUrl(url);
- } else if (url.protocol() == QLatin1String("search")) {
+ } else if (url.scheme() == QLatin1String("search")) {
newUrl = createSearchUrl(url);
}
@@ -492,7 +493,7 @@ void PlacesItemModel::onItemInserted(int index)
}
#ifdef PLACESITEMMODEL_DEBUG
- kDebug() << "Inserted item" << index;
+ qCDebug(DolphinDebug) << "Inserted item" << index;
showModelState();
#endif
}
@@ -510,7 +511,7 @@ void PlacesItemModel::onItemRemoved(int index, KStandardItem* removedItem)
m_bookmarkedItems.removeAt(boomarkIndex);
#ifdef PLACESITEMMODEL_DEBUG
- kDebug() << "Removed item" << index;
+ qCDebug(DolphinDebug) << "Removed item" << index;
showModelState();
#endif
}
@@ -589,14 +590,13 @@ void PlacesItemModel::slotStorageSetupDone(Solid::ErrorType error,
{
Q_UNUSED(udi);
- Q_ASSERT(!m_storageSetupInProgress.isEmpty());
const int index = m_storageSetupInProgress.take(sender());
const PlacesItem* item = placesItem(index);
if (!item) {
return;
}
- if (error) {
+ if (error != Solid::NoError) {
if (errorData.isValid()) {
emit errorMessage(i18nc("@info", "An error occurred while accessing '%1', the system responded: %2",
item->text(),
@@ -642,7 +642,7 @@ void PlacesItemModel::updateBookmarks()
found = true;
if (newBookmark.metaDataItem("UDI").isEmpty()) {
item->setBookmark(newBookmark);
- item->setText(i18nc("KFile System Bookmarks", newBookmark.text().toUtf8().data()));
+ item->setText(i18nc("KFile System Bookmarks", newBookmark.text().toUtf8().constData()));
}
break;
}
@@ -719,7 +719,7 @@ void PlacesItemModel::loadBookmarks()
KBookmark bookmark = root.first();
QSet<QString> devices = m_availableDevices;
- QSet<KUrl> missingSystemBookmarks;
+ QSet<QUrl> missingSystemBookmarks;
foreach (const SystemBookmarkData& data, m_systemBookmarks) {
missingSystemBookmarks.insert(data.url);
}
@@ -740,7 +740,7 @@ void PlacesItemModel::loadBookmarks()
devices.remove(item->udi());
devicesItems.append(item);
} else {
- const KUrl url = bookmark.url();
+ const QUrl url = bookmark.url();
if (missingSystemBookmarks.contains(url)) {
missingSystemBookmarks.remove(url);
@@ -749,7 +749,7 @@ void PlacesItemModel::loadBookmarks()
// text, the retranslation will fail and the users custom text is still used.
// It is important to use "KFile System Bookmarks" as context (see
// createSystemBookmarks()).
- item->setText(i18nc("KFile System Bookmarks", bookmark.text().toUtf8().data()));
+ item->setText(i18nc("KFile System Bookmarks", bookmark.text().toUtf8().constData()));
item->setSystemItem(true);
}
@@ -804,7 +804,7 @@ void PlacesItemModel::loadBookmarks()
}
#ifdef PLACESITEMMODEL_DEBUG
- kDebug() << "Loaded bookmarks";
+ qCDebug(DolphinDebug) << "Loaded bookmarks";
showModelState();
#endif
}
@@ -813,15 +813,15 @@ bool PlacesItemModel::acceptBookmark(const KBookmark& bookmark,
const QSet<QString>& availableDevices) const
{
const QString udi = bookmark.metaDataItem("UDI");
- const KUrl url = bookmark.url();
+ const QUrl url = bookmark.url();
const QString appName = bookmark.metaDataItem("OnlyInApp");
const bool deviceAvailable = availableDevices.contains(udi);
const bool allowedHere = (appName.isEmpty()
- || appName == KGlobal::mainComponent().componentName()
- || appName == KGlobal::mainComponent().componentName() + AppNamePrefix)
- && (m_fileIndexingEnabled || (url.protocol() != QLatin1String("timeline") &&
- url.protocol() != QLatin1String("search")));
+ || appName == KAboutData::applicationData().componentName()
+ || appName == KAboutData::applicationData().componentName() + AppNamePrefix)
+ && (m_fileIndexingEnabled || (url.scheme() != QLatin1String("timeline") &&
+ url.scheme() != QLatin1String("search")));
return (udi.isEmpty() && allowedHere) || deviceAvailable;
}
@@ -833,12 +833,12 @@ PlacesItem* PlacesItemModel::createSystemPlacesItem(const SystemBookmarkData& da
data.url,
data.icon);
- const QString protocol = data.url.protocol();
+ const QString protocol = data.url.scheme();
if (protocol == QLatin1String("timeline") || protocol == QLatin1String("search")) {
// As long as the KFilePlacesView from kdelibs is available, the system-bookmarks
// for "Recently Saved" and "Search For" should be a setting available only
// in the Places Panel (see description of AppNamePrefix for more details).
- const QString appName = KGlobal::mainComponent().componentName() + AppNamePrefix;
+ const QString appName = KAboutData::applicationData().componentName() + AppNamePrefix;
bookmark.setMetaDataItem("OnlyInApp", appName);
}
@@ -858,22 +858,22 @@ PlacesItem* PlacesItemModel::createSystemPlacesItem(const SystemBookmarkData& da
if (path == QLatin1String("/documents")) {
props.setViewMode(DolphinView::DetailsView);
props.setPreviewsShown(false);
- props.setVisibleRoles(QList<QByteArray>() << "text" << "path");
+ props.setVisibleRoles({"text", "path"});
} else if (path == QLatin1String("/images")) {
props.setViewMode(DolphinView::IconsView);
props.setPreviewsShown(true);
- props.setVisibleRoles(QList<QByteArray>() << "text" << "imageSize");
+ props.setVisibleRoles({"text", "imageSize"});
} else if (path == QLatin1String("/audio")) {
props.setViewMode(DolphinView::DetailsView);
props.setPreviewsShown(false);
- props.setVisibleRoles(QList<QByteArray>() << "text" << "artist" << "album");
+ props.setVisibleRoles({"text", "artist", "album"});
} else if (path == QLatin1String("/videos")) {
props.setViewMode(DolphinView::IconsView);
props.setPreviewsShown(true);
- props.setVisibleRoles(QList<QByteArray>() << "text");
- } else if (data.url.protocol() == "timeline") {
+ props.setVisibleRoles({"text"});
+ } else if (data.url.scheme() == "timeline") {
props.setViewMode(DolphinView::DetailsView);
- props.setVisibleRoles(QList<QByteArray>() << "text" << "date");
+ props.setVisibleRoles({"text", "date"});
}
}
}
@@ -890,42 +890,42 @@ void PlacesItemModel::createSystemBookmarks()
// i18nc call is done after reading the bookmark. The reason why the i18nc call is not
// done here is because otherwise switching the language would not result in retranslating the
// bookmarks.
- m_systemBookmarks.append(SystemBookmarkData(KUrl(KUser().homeDir()),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl::fromLocalFile(KUser().homeDir()),
"user-home",
I18N_NOOP2("KFile System Bookmarks", "Home")));
- m_systemBookmarks.append(SystemBookmarkData(KUrl("remote:/"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl("remote:/"),
"network-workgroup",
I18N_NOOP2("KFile System Bookmarks", "Network")));
- m_systemBookmarks.append(SystemBookmarkData(KUrl("/"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl::fromLocalFile("/"),
"folder-red",
I18N_NOOP2("KFile System Bookmarks", "Root")));
- m_systemBookmarks.append(SystemBookmarkData(KUrl("trash:/"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl("trash:/"),
"user-trash",
I18N_NOOP2("KFile System Bookmarks", "Trash")));
if (m_fileIndexingEnabled) {
- m_systemBookmarks.append(SystemBookmarkData(KUrl("timeline:/today"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl("timeline:/today"),
"go-jump-today",
I18N_NOOP2("KFile System Bookmarks", "Today")));
- m_systemBookmarks.append(SystemBookmarkData(KUrl("timeline:/yesterday"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl("timeline:/yesterday"),
"view-calendar-day",
I18N_NOOP2("KFile System Bookmarks", "Yesterday")));
- m_systemBookmarks.append(SystemBookmarkData(KUrl("timeline:/thismonth"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl("timeline:/thismonth"),
"view-calendar-month",
I18N_NOOP2("KFile System Bookmarks", "This Month")));
- m_systemBookmarks.append(SystemBookmarkData(KUrl("timeline:/lastmonth"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl("timeline:/lastmonth"),
"view-calendar-month",
I18N_NOOP2("KFile System Bookmarks", "Last Month")));
- m_systemBookmarks.append(SystemBookmarkData(KUrl("search:/documents"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl("search:/documents"),
"folder-txt",
I18N_NOOP2("KFile System Bookmarks", "Documents")));
- m_systemBookmarks.append(SystemBookmarkData(KUrl("search:/images"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl("search:/images"),
"folder-image",
I18N_NOOP2("KFile System Bookmarks", "Images")));
- m_systemBookmarks.append(SystemBookmarkData(KUrl("search:/audio"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl("search:/audio"),
"folder-sound",
I18N_NOOP2("KFile System Bookmarks", "Audio Files")));
- m_systemBookmarks.append(SystemBookmarkData(KUrl("search:/videos"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl("search:/videos"),
"folder-video",
I18N_NOOP2("KFile System Bookmarks", "Videos")));
}
@@ -960,8 +960,8 @@ void PlacesItemModel::initializeAvailableDevices()
Q_ASSERT(m_predicate.isValid());
Solid::DeviceNotifier* notifier = Solid::DeviceNotifier::instance();
- connect(notifier, SIGNAL(deviceAdded(QString)), this, SLOT(slotDeviceAdded(QString)));
- connect(notifier, SIGNAL(deviceRemoved(QString)), this, SLOT(slotDeviceRemoved(QString)));
+ connect(notifier, &Solid::DeviceNotifier::deviceAdded, this, &PlacesItemModel::slotDeviceAdded);
+ connect(notifier, &Solid::DeviceNotifier::deviceRemoved, this, &PlacesItemModel::slotDeviceRemoved);
const QList<Solid::Device>& deviceList = Solid::Device::listFromQuery(m_predicate);
foreach (const Solid::Device& device, deviceList) {
@@ -1087,14 +1087,14 @@ bool PlacesItemModel::equalBookmarkIdentifiers(const KBookmark& b1, const KBookm
}
}
-KUrl PlacesItemModel::createTimelineUrl(const KUrl& url)
+QUrl PlacesItemModel::createTimelineUrl(const QUrl& url)
{
// TODO: Clarify with the Baloo-team whether it makes sense
// provide default-timeline-URLs like 'yesterday', 'this month'
// and 'last month'.
- KUrl timelineUrl;
+ QUrl timelineUrl;
- const QString path = url.pathOrUrl();
+ const QString path = url.toDisplayString(QUrl::PreferLocalFile);
if (path.endsWith(QLatin1String("yesterday"))) {
const QDate date = QDate::currentDate().addDays(-1);
const int year = date.year();
@@ -1135,12 +1135,12 @@ QString PlacesItemModel::timelineDateString(int year, int month, int day)
return date;
}
-KUrl PlacesItemModel::createSearchUrl(const KUrl& url)
+QUrl PlacesItemModel::createSearchUrl(const QUrl& url)
{
- KUrl searchUrl;
+ QUrl searchUrl;
#ifdef HAVE_BALOO
- const QString path = url.pathOrUrl();
+ const QString path = url.toDisplayString(QUrl::PreferLocalFile);
if (path.endsWith(QLatin1String("documents"))) {
searchUrl = searchUrlForType("Document");
} else if (path.endsWith(QLatin1String("images"))) {
@@ -1160,7 +1160,7 @@ KUrl PlacesItemModel::createSearchUrl(const KUrl& url)
}
#ifdef HAVE_BALOO
-KUrl PlacesItemModel::searchUrlForType(const QString& type)
+QUrl PlacesItemModel::searchUrlForType(const QString& type)
{
Baloo::Query query;
query.addType("File");
@@ -1173,25 +1173,25 @@ KUrl PlacesItemModel::searchUrlForType(const QString& type)
#ifdef PLACESITEMMODEL_DEBUG
void PlacesItemModel::showModelState()
{
- kDebug() << "=================================";
- kDebug() << "Model:";
- kDebug() << "hidden-index model-index text";
+ qCDebug(DolphinDebug) << "=================================";
+ qCDebug(DolphinDebug) << "Model:";
+ qCDebug(DolphinDebug) << "hidden-index model-index text";
int modelIndex = 0;
for (int i = 0; i < m_bookmarkedItems.count(); ++i) {
if (m_bookmarkedItems[i]) {
- kDebug() << i << "(Hidden) " << " " << m_bookmarkedItems[i]->dataValue("text").toString();
+ qCDebug(DolphinDebug) << i << "(Hidden) " << " " << m_bookmarkedItems[i]->dataValue("text").toString();
} else {
if (item(modelIndex)) {
- kDebug() << i << " " << modelIndex << " " << item(modelIndex)->dataValue("text").toString();
+ qCDebug(DolphinDebug) << i << " " << modelIndex << " " << item(modelIndex)->dataValue("text").toString();
} else {
- kDebug() << i << " " << modelIndex << " " << "(not available yet)";
+ qCDebug(DolphinDebug) << i << " " << modelIndex << " " << "(not available yet)";
}
++modelIndex;
}
}
- kDebug();
- kDebug() << "Bookmarks:";
+ qCDebug(DolphinDebug);
+ qCDebug(DolphinDebug) << "Bookmarks:";
int bookmarkIndex = 0;
KBookmarkGroup root = m_bookmarkManager->root();
@@ -1200,9 +1200,9 @@ void PlacesItemModel::showModelState()
const QString udi = bookmark.metaDataItem("UDI");
const QString text = udi.isEmpty() ? bookmark.text() : udi;
if (bookmark.metaDataItem("IsHidden") == QLatin1String("true")) {
- kDebug() << bookmarkIndex << "(Hidden)" << text;
+ qCDebug(DolphinDebug) << bookmarkIndex << "(Hidden)" << text;
} else {
- kDebug() << bookmarkIndex << " " << text;
+ qCDebug(DolphinDebug) << bookmarkIndex << " " << text;
}
bookmark = root.next(bookmark);
@@ -1211,4 +1211,3 @@ void PlacesItemModel::showModelState()
}
#endif
-#include "placesitemmodel.moc"
diff --git a/src/panels/places/placesitemmodel.h b/src/panels/places/placesitemmodel.h
index 7cbf99e95..aa8bb16fe 100644
--- a/src/panels/places/placesitemmodel.h
+++ b/src/panels/places/placesitemmodel.h
@@ -24,7 +24,7 @@
#include <kitemviews/kstandarditemmodel.h>
-#include <KUrl>
+#include <QUrl>
#include <QHash>
#include <QList>
#include <QSet>
@@ -58,7 +58,7 @@ public:
* attributes.
*/
PlacesItem* createPlacesItem(const QString& text,
- const KUrl& url,
+ const QUrl& url,
const QString& iconName = QString());
PlacesItem* placesItem(int index) const;
@@ -87,7 +87,7 @@ public:
* range of the URL. -1 is returned if no closest item
* could be found.
*/
- int closestItem(const KUrl& url) const;
+ int closestItem(const QUrl& url) const;
/**
* Appends the item \a item as last element of the group
@@ -107,11 +107,9 @@ public:
bool storageSetupNeeded(int index) const;
void requestStorageSetup(int index);
- /** @reimp */
- virtual QMimeData* createMimeData(const KItemSet& indexes) const;
+ virtual QMimeData* createMimeData(const KItemSet& indexes) const Q_DECL_OVERRIDE;
- /** @reimp */
- virtual bool supportsDropping(int index) const;
+ virtual bool supportsDropping(int index) const Q_DECL_OVERRIDE;
void dropMimeDataBefore(int index, const QMimeData* mimeData);
@@ -121,9 +119,9 @@ public:
* the corresponding IO-slave. Virtual URLs for bookmarks are used to
* be independent from internal format changes.
*/
- static KUrl convertedUrl(const KUrl& url);
+ static QUrl convertedUrl(const QUrl& url);
- virtual void clear();
+ virtual void clear() Q_DECL_OVERRIDE;
/**
* Saves the bookmarks and indicates to other applications that the
@@ -137,9 +135,9 @@ signals:
void storageSetupDone(int index, bool success);
protected:
- virtual void onItemInserted(int index);
- virtual void onItemRemoved(int index, KStandardItem* removedItem);
- virtual void onItemChanged(int index, const QSet<QByteArray>& changedRoles);
+ virtual void onItemInserted(int index) Q_DECL_OVERRIDE;
+ virtual void onItemRemoved(int index, KStandardItem* removedItem) Q_DECL_OVERRIDE;
+ virtual void onItemChanged(int index, const QSet<QByteArray>& changedRoles) Q_DECL_OVERRIDE;
private slots:
void slotDeviceAdded(const QString& udi);
@@ -219,7 +217,7 @@ private:
/**
* @return URL using the timeline-protocol for searching (see convertedUrl()).
*/
- static KUrl createTimelineUrl(const KUrl& url);
+ static QUrl createTimelineUrl(const QUrl& url);
/**
* Helper method for createTimelineUrl().
@@ -233,7 +231,7 @@ private:
* for a given term. The URL \a url represents a places-internal
* URL like e.g. "search:/documents" (see convertedUrl()).
*/
- static KUrl createSearchUrl(const KUrl& url);
+ static QUrl createSearchUrl(const QUrl& url);
#ifdef HAVE_BALOO
/**
@@ -241,7 +239,7 @@ private:
* @return URL that can be listed by KIO and results in searching
* for the given type
*/
- static KUrl searchUrlForType(const QString& type);
+ static QUrl searchUrlForType(const QString& type);
#endif
#ifdef PLACESITEMMODEL_DEBUG
@@ -258,17 +256,17 @@ private:
struct SystemBookmarkData
{
- SystemBookmarkData(const KUrl& url,
+ SystemBookmarkData(const QUrl& url,
const QString& icon,
const QString& text) :
url(url), icon(icon), text(text) {}
- KUrl url;
+ QUrl url;
QString icon;
QString text;
};
QList<SystemBookmarkData> m_systemBookmarks;
- QHash<KUrl, int> m_systemBookmarksIndexes;
+ QHash<QUrl, int> m_systemBookmarksIndexes;
// Contains hidden and unhidden items that are stored as
// bookmark (the model itself only contains items that
diff --git a/src/panels/places/placesitemsignalhandler.cpp b/src/panels/places/placesitemsignalhandler.cpp
index 54a916de7..c9bc0db3f 100644
--- a/src/panels/places/placesitemsignalhandler.cpp
+++ b/src/panels/places/placesitemsignalhandler.cpp
@@ -47,4 +47,3 @@ void PlacesItemSignalHandler::onTrashDirListerCompleted()
}
}
-#include "placesitemsignalhandler.moc"
diff --git a/src/panels/places/placesitemsignalhandler.h b/src/panels/places/placesitemsignalhandler.h
index d767b58d3..af66568ad 100644
--- a/src/panels/places/placesitemsignalhandler.h
+++ b/src/panels/places/placesitemsignalhandler.h
@@ -29,7 +29,7 @@ class PlacesItem;
* and performing a corresponding action.
*
* PlacesItem is derived from KStandardItem, which is no QObject-class
- * on purpose. To be able to internally listening to signals and performing a
+ * on purpose. To be able to internally listen to signals and performing a
* corresponding action, PlacesItemSignalHandler is used.
*
* E.g. if the PlacesItem wants to react on accessibility-changes of a storage-access,
diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp
index 6b840ef57..50ed7e73a 100644
--- a/src/panels/places/placespanel.cpp
+++ b/src/panels/places/placespanel.cpp
@@ -25,17 +25,22 @@
#include "dolphin_generalsettings.h"
-#include <KDebug>
+#include <KFileItem>
+#include "dolphindebug.h"
#include <KDirNotify>
-#include <KIcon>
+#include <QIcon>
#include <KIO/Job>
+#include <KIO/DropJob>
+#include <KIO/EmptyTrashJob>
#include <KIO/JobUiDelegate>
-#include <KLocale>
+#include <KJobWidgets>
+#include <KLocalizedString>
+#include <KIconLoader>
#include <kitemviews/kitemlistcontainer.h>
#include <kitemviews/kitemlistcontroller.h>
#include <kitemviews/kitemlistselectionmanager.h>
#include <kitemviews/kstandarditem.h>
-#include <KMenu>
+#include <QMenu>
#include <KMessageBox>
#include <KNotification>
#include "placesitem.h"
@@ -48,6 +53,7 @@
#include <QGraphicsSceneDragDropEvent>
#include <QVBoxLayout>
#include <QShowEvent>
+#include <QMimeData>
PlacesPanel::PlacesPanel(QWidget* parent) :
Panel(parent),
@@ -67,7 +73,7 @@ PlacesPanel::~PlacesPanel()
bool PlacesPanel::urlChanged()
{
- if (!url().isValid() || url().protocol().contains("search")) {
+ if (!url().isValid() || url().scheme().contains("search")) {
// Skip results shown by a search, as possible identical
// directory names are useless without parent-path information.
return false;
@@ -101,8 +107,8 @@ void PlacesPanel::showEvent(QShowEvent* event)
// used at all and stays invisible.
m_model = new PlacesItemModel(this);
m_model->setGroupedSorting(true);
- connect(m_model, SIGNAL(errorMessage(QString)),
- this, SIGNAL(errorMessage(QString)));
+ connect(m_model, &PlacesItemModel::errorMessage,
+ this, &PlacesPanel::errorMessage);
m_view = new PlacesView();
m_view->setWidgetCreator(new KItemListWidgetCreator<PlacesItemListWidget>());
@@ -112,14 +118,14 @@ void PlacesPanel::showEvent(QShowEvent* event)
m_controller->setSelectionBehavior(KItemListController::SingleSelection);
m_controller->setSingleClickActivationEnforced(true);
- readSettings();
+ readSettings();
- connect(m_controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int)));
- connect(m_controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));
- connect(m_controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF)));
- connect(m_controller, SIGNAL(viewContextMenuRequested(QPointF)), this, SLOT(slotViewContextMenuRequested(QPointF)));
- connect(m_controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*)));
- connect(m_controller, SIGNAL(aboveItemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotAboveItemDropEvent(int,QGraphicsSceneDragDropEvent*)));
+ connect(m_controller, &KItemListController::itemActivated, this, &PlacesPanel::slotItemActivated);
+ connect(m_controller, &KItemListController::itemMiddleClicked, this, &PlacesPanel::slotItemMiddleClicked);
+ connect(m_controller, &KItemListController::itemContextMenuRequested, this, &PlacesPanel::slotItemContextMenuRequested);
+ connect(m_controller, &KItemListController::viewContextMenuRequested, this, &PlacesPanel::slotViewContextMenuRequested);
+ connect(m_controller, &KItemListController::itemDropEvent, this, &PlacesPanel::slotItemDropEvent);
+ connect(m_controller, &KItemListController::aboveItemDropEvent, this, &PlacesPanel::slotAboveItemDropEvent);
KItemListContainer* container = new KItemListContainer(m_controller, this);
container->setEnabledFrame(false);
@@ -151,7 +157,7 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
return;
}
- KMenu menu(this);
+ QMenu menu(this);
QAction* emptyTrashAction = 0;
QAction* addAction = 0;
@@ -180,26 +186,26 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
mainSeparator = menu.addSeparator();
}
} else {
- if (item->url() == KUrl("trash:/")) {
- emptyTrashAction = menu.addAction(KIcon("trash-empty"), i18nc("@action:inmenu", "Empty Trash"));
+ if (item->url() == QUrl("trash:/")) {
+ emptyTrashAction = menu.addAction(QIcon::fromTheme("trash-empty"), i18nc("@action:inmenu", "Empty Trash"));
emptyTrashAction->setEnabled(item->icon() == "user-trash-full");
menu.addSeparator();
}
- addAction = menu.addAction(KIcon("document-new"), i18nc("@item:inmenu", "Add Entry..."));
+ addAction = menu.addAction(QIcon::fromTheme("document-new"), i18nc("@item:inmenu", "Add Entry..."));
mainSeparator = menu.addSeparator();
- editAction = menu.addAction(KIcon("document-properties"), i18nc("@item:inmenu", "Edit '%1'...", label));
+ editAction = menu.addAction(QIcon::fromTheme("document-properties"), i18nc("@item:inmenu", "Edit '%1'...", label));
}
if (!addAction) {
- addAction = menu.addAction(KIcon("document-new"), i18nc("@item:inmenu", "Add Entry..."));
+ addAction = menu.addAction(QIcon::fromTheme("document-new"), i18nc("@item:inmenu", "Add Entry..."));
}
QAction* openInNewTabAction = menu.addAction(i18nc("@item:inmenu", "Open '%1' in New Tab", label));
- openInNewTabAction->setIcon(KIcon("tab-new"));
+ openInNewTabAction->setIcon(QIcon::fromTheme("tab-new"));
QAction* removeAction = 0;
if (!isDevice && !item->isSystemItem()) {
- removeAction = menu.addAction(KIcon("edit-delete"), i18nc("@item:inmenu", "Remove '%1'", label));
+ removeAction = menu.addAction(QIcon::fromTheme("edit-delete"), i18nc("@item:inmenu", "Remove '%1'", label));
}
QAction* hideAction = menu.addAction(i18nc("@item:inmenu", "Hide '%1'", label));
@@ -217,7 +223,7 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
}
menu.addSeparator();
- KMenu* iconSizeSubMenu = new KMenu(i18nc("@item:inmenu", "Icon Size"), &menu);
+ QMenu* iconSizeSubMenu = new QMenu(i18nc("@item:inmenu", "Icon Size"), &menu);
struct IconSizeInfo
{
@@ -301,9 +307,9 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
void PlacesPanel::slotViewContextMenuRequested(const QPointF& pos)
{
- KMenu menu(this);
+ QMenu menu(this);
- QAction* addAction = menu.addAction(KIcon("document-new"), i18nc("@item:inmenu", "Add Entry..."));
+ QAction* addAction = menu.addAction(QIcon::fromTheme("document-new"), i18nc("@item:inmenu", "Add Entry..."));
QAction* showAllAction = 0;
if (m_model->hiddenCount() > 0) {
@@ -342,8 +348,8 @@ void PlacesPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
}
if (m_model->storageSetupNeeded(index)) {
- connect(m_model, SIGNAL(storageSetupDone(int,bool)),
- this, SLOT(slotItemDropEventStorageSetupDone(int,bool)));
+ connect(m_model, &PlacesItemModel::storageSetupDone,
+ this, &PlacesPanel::slotItemDropEventStorageSetupDone);
m_itemDropEventIndex = index;
@@ -365,34 +371,25 @@ void PlacesPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
return;
}
- KUrl destUrl = destItem->url();
+ QUrl destUrl = destItem->url();
QDropEvent dropEvent(event->pos().toPoint(),
event->possibleActions(),
event->mimeData(),
event->buttons(),
event->modifiers());
- QString error;
- DragAndDropHelper::dropUrls(KFileItem(), destUrl, &dropEvent, error);
- if (!error.isEmpty()) {
- emit errorMessage(error);
- }
+ slotUrlsDropped(destUrl, &dropEvent, this);
}
void PlacesPanel::slotItemDropEventStorageSetupDone(int index, bool success)
{
- disconnect(m_model, SIGNAL(storageSetupDone(int,bool)),
- this, SLOT(slotItemDropEventStorageSetupDone(int,bool)));
+ disconnect(m_model, &PlacesItemModel::storageSetupDone,
+ this, &PlacesPanel::slotItemDropEventStorageSetupDone);
if ((index == m_itemDropEventIndex) && m_itemDropEvent && m_itemDropEventMimeData) {
if (success) {
- KUrl destUrl = m_model->placesItem(index)->url();
-
- QString error;
- DragAndDropHelper::dropUrls(KFileItem(), destUrl, m_itemDropEvent, error);
- if (!error.isEmpty()) {
- emit errorMessage(error);
- }
+ QUrl destUrl = m_model->placesItem(index)->url();
+ slotUrlsDropped(destUrl, m_itemDropEvent, this);
}
delete m_itemDropEventMimeData;
@@ -410,15 +407,12 @@ void PlacesPanel::slotAboveItemDropEvent(int index, QGraphicsSceneDragDropEvent*
m_model->saveBookmarks();
}
-void PlacesPanel::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent)
+void PlacesPanel::slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent)
{
- Q_UNUSED(parent);
- QString error;
- DragAndDropHelper::dropUrls(KFileItem(), dest, event, error);
- if (!error.isEmpty()) {
- emit errorMessage(error);
+ KIO::DropJob *job = DragAndDropHelper::dropUrls(dest, event, parent);
+ if (job) {
+ connect(job, &KIO::DropJob::result, this, [this](KJob *job) { if (job->error()) emit errorMessage(job->errorString()); });
}
-
}
void PlacesPanel::slotTrashUpdated(KJob* job)
@@ -426,13 +420,14 @@ void PlacesPanel::slotTrashUpdated(KJob* job)
if (job->error()) {
emit errorMessage(job->errorString());
}
- org::kde::KDirNotify::emitFilesAdded("trash:/");
+ // as long as KIO doesn't do this, do it ourselves
+ KNotification::event("Trash: emptied", QString(), QPixmap(), 0, KNotification::DefaultEvent);
}
void PlacesPanel::slotStorageSetupDone(int index, bool success)
{
- disconnect(m_model, SIGNAL(storageSetupDone(int,bool)),
- this, SLOT(slotStorageSetupDone(int,bool)));
+ disconnect(m_model, &PlacesItemModel::storageSetupDone,
+ this, &PlacesPanel::slotStorageSetupDone);
if (m_triggerStorageSetupButton == Qt::NoButton) {
return;
@@ -444,37 +439,28 @@ void PlacesPanel::slotStorageSetupDone(int index, bool success)
m_triggerStorageSetupButton = Qt::NoButton;
} else {
setUrl(m_storageSetupFailedUrl);
- m_storageSetupFailedUrl = KUrl();
+ m_storageSetupFailedUrl = QUrl();
}
}
void PlacesPanel::emptyTrash()
{
- const QString text = i18nc("@info", "Do you really want to empty the Trash? All items will be deleted.");
- const bool del = KMessageBox::warningContinueCancel(window(),
- text,
- QString(),
- KGuiItem(i18nc("@action:button", "Empty Trash"),
- KIcon("user-trash"))
- ) == KMessageBox::Continue;
- if (del) {
- QByteArray packedArgs;
- QDataStream stream(&packedArgs, QIODevice::WriteOnly);
- stream << int(1);
- KIO::Job *job = KIO::special(KUrl("trash:/"), packedArgs);
- KNotification::event("Trash: emptied", QString() , QPixmap() , 0, KNotification::DefaultEvent);
- job->ui()->setWindow(parentWidget());
- connect(job, SIGNAL(result(KJob*)), SLOT(slotTrashUpdated(KJob*)));
+ KIO::JobUiDelegate uiDelegate;
+ uiDelegate.setWindow(window());
+ if (uiDelegate.askDeleteConfirmation(QList<QUrl>(), KIO::JobUiDelegate::EmptyTrash, KIO::JobUiDelegate::DefaultConfirmation)) {
+ KIO::Job* job = KIO::emptyTrash();
+ KJobWidgets::setWindow(job, window());
+ connect(job, &KIO::Job::result, this, &PlacesPanel::slotTrashUpdated);
}
}
void PlacesPanel::addEntry()
{
const int index = m_controller->selectionManager()->currentItem();
- const KUrl url = m_model->data(index).value("url").value<KUrl>();
+ const QUrl url = m_model->data(index).value("url").value<QUrl>();
QPointer<PlacesItemEditDialog> dialog = new PlacesItemEditDialog(this);
- dialog->setCaption(i18nc("@title:window", "Add Places Entry"));
+ dialog->setWindowTitle(i18nc("@title:window", "Add Places Entry"));
dialog->setAllowGlobal(true);
dialog->setUrl(url);
if (dialog->exec() == QDialog::Accepted) {
@@ -491,10 +477,10 @@ void PlacesPanel::editEntry(int index)
QHash<QByteArray, QVariant> data = m_model->data(index);
QPointer<PlacesItemEditDialog> dialog = new PlacesItemEditDialog(this);
- dialog->setCaption(i18nc("@title:window", "Edit Places Entry"));
+ dialog->setWindowTitle(i18nc("@title:window", "Edit Places Entry"));
dialog->setIcon(data.value("iconName").toString());
dialog->setText(data.value("text").toString());
- dialog->setUrl(data.value("url").value<KUrl>());
+ dialog->setUrl(data.value("url").value<QUrl>());
dialog->setAllowGlobal(true);
if (dialog->exec() == QDialog::Accepted) {
PlacesItem* oldItem = m_model->placesItem(index);
@@ -529,14 +515,14 @@ void PlacesPanel::triggerItem(int index, Qt::MouseButton button)
m_triggerStorageSetupButton = button;
m_storageSetupFailedUrl = url();
- connect(m_model, SIGNAL(storageSetupDone(int,bool)),
- this, SLOT(slotStorageSetupDone(int,bool)));
+ connect(m_model, &PlacesItemModel::storageSetupDone,
+ this, &PlacesPanel::slotStorageSetupDone);
m_model->requestStorageSetup(index);
} else {
m_triggerStorageSetupButton = Qt::NoButton;
- const KUrl url = m_model->data(index).value("url").value<KUrl>();
+ const QUrl url = m_model->data(index).value("url").value<QUrl>();
if (!url.isEmpty()) {
if (button == Qt::MiddleButton) {
emit placeMiddleClicked(PlacesItemModel::convertedUrl(url));
@@ -546,6 +532,3 @@ void PlacesPanel::triggerItem(int index, Qt::MouseButton button)
}
}
}
-
-
-#include "placespanel.moc"
diff --git a/src/panels/places/placespanel.h b/src/panels/places/placespanel.h
index 16112e8b2..81aeedb28 100644
--- a/src/panels/places/placespanel.h
+++ b/src/panels/places/placespanel.h
@@ -21,16 +21,16 @@
#ifndef PLACESPANEL_H
#define PLACESPANEL_H
-#include <KUrl>
+#include <QUrl>
+#include <QMimeData>
#include <panels/panel.h>
class KItemListController;
-class PlacesItemEditDialog;
class PlacesItem;
class PlacesItemModel;
class PlacesView;
class QGraphicsSceneDragDropEvent;
-
+class KJob;
/**
* @brief Combines bookmarks and mounted devices as list.
*/
@@ -43,13 +43,13 @@ public:
virtual ~PlacesPanel();
signals:
- void placeActivated(const KUrl& url);
- void placeMiddleClicked(const KUrl& url);
+ void placeActivated(const QUrl& url);
+ void placeMiddleClicked(const QUrl& url);
void errorMessage(const QString& error);
protected:
- virtual bool urlChanged();
- virtual void showEvent(QShowEvent* event);
+ virtual bool urlChanged() Q_DECL_OVERRIDE;
+ virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
public slots:
virtual void readSettings();
@@ -62,7 +62,7 @@ private slots:
void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
void slotItemDropEventStorageSetupDone(int index, bool success);
void slotAboveItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
- void slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent);
+ void slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent);
void slotTrashUpdated(KJob* job);
void slotStorageSetupDone(int index, bool success);
@@ -84,7 +84,7 @@ private:
PlacesItemModel* m_model;
PlacesView* m_view;
- KUrl m_storageSetupFailedUrl;
+ QUrl m_storageSetupFailedUrl;
Qt::MouseButton m_triggerStorageSetupButton;
int m_itemDropEventIndex;
diff --git a/src/panels/places/placesview.cpp b/src/panels/places/placesview.cpp
index a298a5250..d755d46b5 100644
--- a/src/panels/places/placesview.cpp
+++ b/src/panels/places/placesview.cpp
@@ -35,7 +35,7 @@ void PlacesView::setIconSize(int size)
if (size != iconSize()) {
PlacesPanelSettings* settings = PlacesPanelSettings::self();
settings->setIconSize(size);
- settings->writeConfig();
+ settings->save();
KItemListStyleOption option = styleOption();
option.iconSize = size;
@@ -49,4 +49,3 @@ int PlacesView::iconSize() const
return option.iconSize;
}
-#include "placesview.moc"
diff --git a/src/panels/terminal/terminalpanel.cpp b/src/panels/terminal/terminalpanel.cpp
index f827503a2..ee88bd4c5 100644
--- a/src/panels/terminal/terminalpanel.cpp
+++ b/src/panels/terminal/terminalpanel.cpp
@@ -24,15 +24,16 @@
#include <KPluginLoader>
#include <KPluginFactory>
#include <KService>
-#include <kde_terminal_interface_v2.h>
-#include <KParts/Part>
+#include <kde_terminal_interface.h>
+#include <KParts/ReadOnlyPart>
#include <KShell>
#include <KIO/Job>
#include <KIO/JobUiDelegate>
+#include <KJobWidgets>
-#include <QBoxLayout>
#include <QDir>
#include <QShowEvent>
+#include <QVBoxLayout>
TerminalPanel::TerminalPanel(QWidget* parent) :
Panel(parent),
@@ -70,7 +71,7 @@ void TerminalPanel::dockVisibilityChanged()
this, SLOT(slotKonsolePartCurrentDirectoryChanged(QString)));
// Make sure this terminal does not prevent unmounting any removable drives
- changeDir(KUrl::fromPath("/"));
+ changeDir(QUrl::fromLocalFile("/"));
// Because we have disconnected from the part's currentDirectoryChanged()
// signal, we have to update m_konsolePartCurrentDirectory manually. If this
@@ -110,10 +111,10 @@ void TerminalPanel::showEvent(QShowEvent* event)
}
m_konsolePart = factory ? (factory->create<KParts::ReadOnlyPart>(this)) : 0;
if (m_konsolePart) {
- connect(m_konsolePart, SIGNAL(destroyed(QObject*)), this, SLOT(terminalExited()));
+ connect(m_konsolePart, &KParts::ReadOnlyPart::destroyed, this, &TerminalPanel::terminalExited);
m_terminalWidget = m_konsolePart->widget();
m_layout->addWidget(m_terminalWidget);
- m_terminal = qobject_cast<TerminalInterfaceV2 *>(m_konsolePart);
+ m_terminal = qobject_cast<TerminalInterface*>(m_konsolePart);
}
}
if (m_terminal) {
@@ -127,7 +128,7 @@ void TerminalPanel::showEvent(QShowEvent* event)
Panel::showEvent(event);
}
-void TerminalPanel::changeDir(const KUrl& url)
+void TerminalPanel::changeDir(const QUrl& url)
{
delete m_mostLocalUrlJob;
m_mostLocalUrlJob = 0;
@@ -137,9 +138,9 @@ void TerminalPanel::changeDir(const KUrl& url)
} else {
m_mostLocalUrlJob = KIO::mostLocalUrl(url, KIO::HideProgressInfo);
if (m_mostLocalUrlJob->ui()) {
- m_mostLocalUrlJob->ui()->setWindow(this);
+ KJobWidgets::setWindow(m_mostLocalUrlJob, this);
}
- connect(m_mostLocalUrlJob, SIGNAL(result(KJob*)), this, SLOT(slotMostLocalUrlResult(KJob*)));
+ connect(m_mostLocalUrlJob, &KIO::StatJob::result, this, &TerminalPanel::slotMostLocalUrlResult);
}
}
@@ -178,7 +179,7 @@ void TerminalPanel::sendCdToTerminal(const QString& dir)
void TerminalPanel::slotMostLocalUrlResult(KJob* job)
{
KIO::StatJob* statJob = static_cast<KIO::StatJob *>(job);
- const KUrl url = statJob->mostLocalUrl();
+ const QUrl url = statJob->mostLocalUrl();
if (url.isLocalFile()) {
sendCdToTerminal(url.toLocalFile());
}
@@ -198,7 +199,6 @@ void TerminalPanel::slotKonsolePartCurrentDirectoryChanged(const QString& dir)
}
}
- emit changeUrl(dir);
+ const QUrl url(QUrl::fromLocalFile(dir));
+ emit changeUrl(url);
}
-
-#include "terminalpanel.moc"
diff --git a/src/panels/terminal/terminalpanel.h b/src/panels/terminal/terminalpanel.h
index b65239baf..75e198e1a 100644
--- a/src/panels/terminal/terminalpanel.h
+++ b/src/panels/terminal/terminalpanel.h
@@ -24,7 +24,7 @@
#include <QQueue>
-class TerminalInterfaceV2;
+class TerminalInterface;
class QVBoxLayout;
class QWidget;
@@ -35,7 +35,7 @@ namespace KIO {
namespace KParts {
class ReadOnlyPart;
}
-
+class KJob;
/**
* @brief Shows the terminal which is synchronized with the URL of the
* active view.
@@ -58,21 +58,19 @@ signals:
/**
* Is emitted if the an URL change is requested.
*/
- void changeUrl(const KUrl& url);
+ void changeUrl(const QUrl& url);
protected:
- /** @see Panel::urlChanged() */
- virtual bool urlChanged();
+ virtual bool urlChanged() Q_DECL_OVERRIDE;
- /** @see QWidget::showEvent() */
- virtual void showEvent(QShowEvent* event);
+ virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
private slots:
void slotMostLocalUrlResult(KJob* job);
void slotKonsolePartCurrentDirectoryChanged(const QString& dir);
private:
- void changeDir(const KUrl& url);
+ void changeDir(const QUrl& url);
void sendCdToTerminal(const QString& path);
private:
@@ -80,7 +78,7 @@ private:
KIO::StatJob* m_mostLocalUrlJob;
QVBoxLayout* m_layout;
- TerminalInterfaceV2* m_terminal;
+ TerminalInterface* m_terminal;
QWidget* m_terminalWidget;
KParts::ReadOnlyPart* m_konsolePart;
QString m_konsolePartCurrentDirectory;