Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 70fe134d authored by Michael Pyne's avatar Michael Pyne

Complete porting away from KUrl, reenable Add Folders dialog

parent 2067e46b
......@@ -83,9 +83,7 @@ int DirectoryList::exec()
{
m_result.status = static_cast<DialogCode>(KDialog::exec());
m_result.addPlaylists = m_base->importPlaylistsCheckBox->isChecked();
// FIXME signal
//return m_result;
return 0;
return m_result.status;
}
////////////////////////////////////////////////////////////////////////////////
......
......@@ -49,8 +49,9 @@ public:
QWidget *parent = 0);
virtual ~DirectoryList();
Result dialogResult() const { return m_result; }
public slots:
// FIXME signal
int exec();
signals:
......
......@@ -20,11 +20,9 @@
#include <algorithm>
#include <kurl.h>
#include <kurlrequester.h>
#include <kiconloader.h>
#include <knuminput.h>
#include <kstandarddirs.h>
#include <kio/job.h>
#include <kio/netaccess.h>
#include <kdesktopfile.h>
......@@ -39,6 +37,7 @@
#include <QTimer>
#include <QCheckBox>
#include <QDir>
#include <QUrl>
#include <QLabel>
#include <QSignalMapper>
#include <QPixmap>
......@@ -290,7 +289,7 @@ void FileRenamerWidget::loadConfig()
}
QString path = config.readEntry("MusicFolder", "${HOME}/music");
m_ui->m_musicFolder->setUrl(KUrl(path));
m_ui->m_musicFolder->setUrl(QUrl::fromLocalFile(path));
m_ui->m_musicFolder->setMode(KFile::Directory |
KFile::ExistingOnly |
KFile::LocalOnly);
......@@ -907,7 +906,7 @@ void FileRenamer::rename(const PlaylistItemList &items)
itemMap[it.key()]->setFile(it.value());
itemMap[it.key()]->refresh();
setFolderIcon(it.value(), itemMap[it.key()]);
setFolderIcon(QUrl::fromLocalFile(it.value()), itemMap[it.key()]);
}
else
errorFiles << i18n("%1 to %2", it.key(), it.value());
......@@ -924,38 +923,24 @@ bool FileRenamer::moveFile(const QString &src, const QString &dest)
{
qCDebug(JUK_LOG) << "Moving file " << src << " to " << dest;
if(src == dest)
return false;
// Escape URL.
KUrl srcURL = KUrl(src);
KUrl dstURL = KUrl(dest);
QUrl srcURL = QUrl::fromLocalFile(src);
QUrl dstURL = QUrl::fromLocalFile(dest);
// Clean it.
srcURL.cleanPath();
dstURL.cleanPath();
// Make sure it is valid.
if(!srcURL.isValid() || !dstURL.isValid())
if(!srcURL.isValid() || !dstURL.isValid() || srcURL == dstURL)
return false;
// Get just the directory.
KUrl dir = dstURL;
dir.setFileName(QString());
// Create the directory.
if(!KStandardDirs::exists(dir.path()))
if(!KStandardDirs::makeDir(dir.path())) {
qCCritical(JUK_LOG) << "Unable to create directory " << dir.path();
return false;
}
QUrl dir = dstURL.resolved(QUrl::fromUserInput(".")); // resolves to path w/out filename
if(!QDir().mkpath(dir.path())) {
qCCritical(JUK_LOG) << "Unable to create directory " << dir.path();
return false;
}
// Move the file.
KIO::Job *job = KIO::file_move(srcURL, dstURL);
return KIO::NetAccess::synchronousRun(job, 0);
}
void FileRenamer::setFolderIcon(const KUrl &dst, const PlaylistItem *item)
void FileRenamer::setFolderIcon(const QUrl &dstURL, const PlaylistItem *item)
{
if(item->file().tag()->album().isEmpty() ||
!item->file().coverInfo()->hasCover())
......@@ -963,19 +948,17 @@ void FileRenamer::setFolderIcon(const KUrl &dst, const PlaylistItem *item)
return;
}
KUrl dstURL = dst;
dstURL.cleanPath();
// Split path, and go through each path element. If a path element has
// the album information, set its folder icon.
QStringList elements = dstURL.directory().split('/', QString::SkipEmptyParts);
QStringList elements = dstURL.path().split('/', QString::SkipEmptyParts);
QString path;
for(QStringList::ConstIterator it = elements.constBegin(); it != elements.constEnd(); ++it) {
path.append('/' + (*it));
qCDebug(JUK_LOG) << "Checking path: " << path;
if((*it).contains(item->file().tag()->album() ) &&
if((*it).contains(item->file().tag()->album()) &&
QDir(path).exists() &&
!QFile::exists(path + "/.directory"))
{
// Seems to be a match, let's set the folder icon for the current
......
......@@ -22,8 +22,6 @@
#include <QVector>
#include <QMap>
#include <KUrl>
#include "ui_filerenamerbase.h"
#include "categoryreaderinterface.h"
#include "tagrenameroptions.h"
......@@ -31,6 +29,7 @@
class QCheckBox;
class QPushButton;
class QSignalMapper;
class QUrl;
class ExampleOptionsDialog;
class PlaylistItem;
......@@ -535,7 +534,7 @@ private:
* there is not already a folder icon set, and if the folder's name has
* the album name.
*/
void setFolderIcon(const KUrl &dst, const PlaylistItem *item);
void setFolderIcon(const QUrl &dst, const PlaylistItem *item);
/**
* Attempts to rename the file from \a src to \a dest. Returns true if the
......
......@@ -712,14 +712,14 @@ void Playlist::synchronizePlayingItems(const PlaylistList &sources, bool setMast
void Playlist::copy()
{
PlaylistItemList items = selectedItems();
KUrl::List urls;
QList<QUrl> urls;
foreach(PlaylistItem *item, items) {
urls << KUrl::fromPath(item->file().absFilePath());
urls << QUrl::fromLocalFile(item->file().absFilePath());
}
QMimeData *mimeData = new QMimeData;
urls.populateMimeData(mimeData);
mimeData->setUrls(urls);
QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
}
......@@ -822,9 +822,12 @@ void Playlist::slotAddCover(bool retrieveLocal)
return;
}
KUrl file = KFileDialog::getImageOpenUrl(
KUrl( "kfiledialog://homedir" ), this, i18n("Select Cover Image File"));
QUrl file = QFileDialog::getOpenFileUrl(
this, i18n("Select Cover Image File"),
QUrl::fromLocalFile(QDir::home().path()),
i18n("Images (*.png *.jpg)"), nullptr,
0, QStringList() << QStringLiteral("file")
);
if(file.isEmpty())
return;
......@@ -997,24 +1000,17 @@ void Playlist::dragEnterEvent(QDragEnterEvent *e)
return;
}
//setDropHighlighter(false);
setDropIndicatorShown(true);
const KUrl::List urls = KUrl::List::fromMimeData(e->mimeData());
if (urls.isEmpty()) {
e->ignore();
return;
}
if(e->mimeData()->hasUrls())
if(e->mimeData()->hasUrls() && !e->mimeData()->urls().isEmpty())
e->acceptProposedAction();
return;
else
e->ignore();
}
bool Playlist::acceptDrag(QDropEvent *e) const
{
return CoverDrag::isCover(e->mimeData()) || KUrl::List::canDecode(e->mimeData());
return CoverDrag::isCover(e->mimeData()) || e->mimeData()->hasUrls();
}
void Playlist::decode(const QMimeData *s, PlaylistItem *item)
......@@ -1091,13 +1087,12 @@ QStringList Playlist::mimeTypes() const
QMimeData* Playlist::mimeData(const QList<QTreeWidgetItem *> items) const
{
KUrl::List urls;
QList<QUrl> urls;
foreach(QTreeWidgetItem *item, items) {
urls << KUrl::fromPath(static_cast<PlaylistItem*>(item)->file().absFilePath());
urls << QUrl::fromLocalFile(static_cast<PlaylistItem*>(item)->file().absFilePath());
}
QMimeData *urlDrag = new QMimeData();
urlDrag->setUrls(urls);
return urlDrag;
......
......@@ -373,12 +373,10 @@ void PlaylistCollection::open(const QString &playlist, const QStringList &files)
void PlaylistCollection::addFolder()
{
DirectoryList l(m_folderList, m_excludedFolderList, m_importPlaylists, JuK::JuKInstance());
// FIXME signal result
//DirectoryList::Result result = l.exec();
/*if(result.status == QDialog::Accepted) {
if(l.exec() == QDialog::Accepted) {
m_dirLister.blockSignals(true);
DirectoryList::Result result = l.dialogResult();
const bool reload = m_importPlaylists != result.addPlaylists;
......@@ -386,12 +384,12 @@ void PlaylistCollection::addFolder()
m_excludedFolderList = canonicalizeFolderPaths(result.excludedDirs);
foreach(const QString &dir, result.addedDirs) {
m_dirLister.openUrl(KUrl::fromPath(dir), KDirLister::Keep);
m_dirLister.openUrl(QUrl::fromLocalFile(dir), KDirLister::Keep);
m_folderList.append(dir);
}
foreach(const QString &dir, result.removedDirs) {
m_dirLister.stop(KUrl::fromPath(dir));
m_dirLister.stop(QUrl::fromLocalFile(dir));
m_folderList.removeAll(dir);
}
......@@ -405,7 +403,7 @@ void PlaylistCollection::addFolder()
saveConfig();
m_dirLister.blockSignals(false);
}*/
}
}
void PlaylistCollection::rename()
......
......@@ -28,7 +28,6 @@ template<class T>
class QList;
class KJob;
class KUrl;
class FileHandle;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment