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 110120c5 authored by Scott Wheeler's avatar Scott Wheeler

Add a checkbox for not importing m3u files.

CCMAIL:63770-done@bugs.kde.org

svn path=/trunk/kdemultimedia/juk/; revision=293891
parent 0aa2f4b0
......@@ -20,6 +20,8 @@
#include <klistview.h>
#include <kpushbutton.h>
#include <qcheckbox.h>
#include "directorylistbase.h"
#include "directorylist.h"
......@@ -27,10 +29,11 @@
// public methods
////////////////////////////////////////////////////////////////////////////////
DirectoryList::DirectoryList(const QStringList &directories, QWidget *parent,
const char *name) :
DirectoryList::DirectoryList(const QStringList &directories, bool importPlaylists,
QWidget *parent, const char *name) :
KDialogBase(parent, name, true, i18n("Folder List"), Ok | Cancel, Ok, true),
m_dirList(directories)
m_dirList(directories),
m_importPlaylists(importPlaylists)
{
m_base = new DirectoryListBase(this);
......@@ -47,8 +50,10 @@ DirectoryList::DirectoryList(const QStringList &directories, QWidget *parent,
for(; it != directories.end(); ++it)
new KListViewItem(m_base->directoryListView, *it);
m_base->importPlaylistsCheckBox->setChecked(importPlaylists);
QSize sz = sizeHint();
setMinimumSize(QMAX(350, sz.width()), QMAX(250, sz.height()));
setMinimumSize(kMax(350, sz.width()), kMax(250, sz.height()));
resize(sizeHint());
}
......@@ -57,6 +62,17 @@ DirectoryList::~DirectoryList()
}
////////////////////////////////////////////////////////////////////////////////
// public slots
////////////////////////////////////////////////////////////////////////////////
DirectoryList::Result DirectoryList::exec()
{
m_result.status = static_cast<DialogCode>(KDialogBase::exec());
m_result.addPlaylists = m_base->importPlaylistsCheckBox->isChecked();
return m_result;
}
////////////////////////////////////////////////////////////////////////////////
// private slots
////////////////////////////////////////////////////////////////////////////////
......@@ -67,7 +83,7 @@ void DirectoryList::slotAddDirectory()
if(!dir.isEmpty() && m_dirList.find(dir) == m_dirList.end()) {
m_dirList.append(dir);
new KListViewItem(m_base->directoryListView, dir);
emit signalDirectoryAdded(dir);
m_result.addedDirs.append(dir);
}
}
......@@ -78,7 +94,7 @@ void DirectoryList::slotRemoveDirectory()
QString dir = m_base->directoryListView->selectedItem()->text(0);
m_dirList.remove(dir);
emit signalDirectoryRemoved(dir);
m_result.removedDirs.append(dir);
delete m_base->directoryListView->selectedItem();
}
......
......@@ -27,9 +27,21 @@ class DirectoryList : public KDialogBase
Q_OBJECT
public:
DirectoryList(const QStringList &directories, QWidget *parent = 0, const char *name = 0);
struct Result
{
QStringList addedDirs;
QStringList removedDirs;
DialogCode status;
bool addPlaylists;
};
DirectoryList(const QStringList &directories, bool importPlaylists,
QWidget *parent = 0, const char *name = 0);
virtual ~DirectoryList();
public slots:
Result exec();
signals:
void signalDirectoryAdded(const QString &directory);
void signalDirectoryRemoved(const QString &directory);
......@@ -40,7 +52,9 @@ private slots:
private:
QStringList m_dirList;
bool m_importPlaylists;
DirectoryListBase *m_base;
Result m_result;
};
#endif
......
<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
<class>DirectoryListBase</class>
<widget class="QWidget">
<property name="name">
......@@ -84,6 +84,17 @@
</size>
</property>
</spacer>
<widget class="QCheckBox">
<property name="name">
<cstring>importPlaylistsCheckBox</cstring>
</property>
<property name="text">
<string>Import Playlists</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</vbox>
</widget>
</hbox>
......
......@@ -120,7 +120,7 @@ private:
PlaylistSplitter::PlaylistSplitter(QWidget *parent, const char *name) :
QSplitter(Qt::Horizontal, parent, name),
m_playingItem(0), m_searchWidget(0), m_history(0),
m_dynamicList(0), m_nextPlaylistItem(0)
m_dynamicList(0), m_importPlaylists(true), m_nextPlaylistItem(0)
{
#ifndef NO_DEBUG
m_restore = KCmdLineArgs::parsedArgs()->isSet("restore");
......@@ -383,28 +383,32 @@ void PlaylistSplitter::slotOpen()
void PlaylistSplitter::slotOpenDirectory()
{
DirectoryList l(m_directoryList, this, "directoryList");
DirectoryList l(m_directoryList, m_importPlaylists, this, "directoryList");
DirectoryList::Result result = l.exec();
m_directoryQueue.clear();
m_directoryQueueRemove.clear();
if(result.status == QDialog::Accepted) {
connect(&l, SIGNAL(signalDirectoryAdded(const QString &)),
this, SLOT(slotQueueDirectory(const QString &)));
connect(&l, SIGNAL(signalDirectoryRemoved(const QString &)),
this, SLOT(slotQueueDirectoryRemove(const QString &)));
if(l.exec() == QDialog::Accepted) {
open(m_directoryQueue);
for(QStringList::Iterator it = m_directoryQueue.begin(); it != m_directoryQueue.end(); it++)
for(QStringList::Iterator it = result.addedDirs.begin();
it != result.addedDirs.end(); it++)
{
m_dirWatch.addDir(*it, false, true);
m_directoryList.append(*it);
}
m_directoryList += m_directoryQueue;
QStringList::Iterator it = m_directoryQueueRemove.begin();
for(; it != m_directoryQueueRemove.end(); it++) {
for(QStringList::Iterator it = result.removedDirs.begin();
it != result.removedDirs.end(); it++)
{
m_dirWatch.removeDir(*it);
m_directoryList.remove(*it);
}
if(result.addPlaylists && !m_importPlaylists)
open(m_directoryList);
else
open(result.addedDirs);
m_importPlaylists = result.addPlaylists;
}
}
......@@ -640,6 +644,8 @@ void PlaylistSplitter::readConfig()
readPlaylists();
m_importPlaylists = config->readBoolEntry("ImportPlaylists", true);
m_directoryList = config->readPathListEntry("DirectoryList");
QTimer::singleShot(0, this, SLOT(slotScanDirectories()));
......@@ -681,6 +687,7 @@ void PlaylistSplitter::saveConfig()
{ // block for Playlists group
KConfigGroupSaver saver(config, "Playlists");
config->writeEntry("ImportPlaylists", m_importPlaylists);
config->writePathEntry("DirectoryList", m_directoryList);
config->writeEntry("SortColumn", m_collection->sortColumn());
config->writeEntry("PlaylistSplitterSizes", sizes());
......@@ -701,7 +708,7 @@ PlaylistItem *PlaylistSplitter::addImpl(const QString &file, Playlist *list, Pla
if(MediaFiles::isMediaFile(file))
return list->createItem(fileInfo, QString::null, after, false);
if(MediaFiles::isPlaylistFile(file)) {
if(m_importPlaylists && MediaFiles::isPlaylistFile(file)) {
openPlaylist(fileInfo.absFilePath());
return after;
}
......
......@@ -347,17 +347,6 @@ private slots:
* changed.
*/
void slotPlaylistCountChanged(Playlist *p);
/**
* Add a directory to the directory list queue. We need to queue these
* rather than processing them when they become available because the user
* could cancel the action.
*/
void slotQueueDirectory(const QString &directory) { m_directoryQueue.append(directory); }
/**
* Add a directory to the queue
*/
void slotQueueDirectoryRemove(const QString &directory) { m_directoryQueueRemove.append(directory); }
/**
* This should be connected to Playlist::aboutToRemove()
......@@ -426,14 +415,11 @@ private:
Playlist *m_dynamicList;
StringHash m_playlistFiles;
QStringList m_directoryList;
QStringList m_directoryQueue;
QStringList m_directoryQueueRemove;
QStringList m_columnNames;
bool m_restore;
bool m_importPlaylists;
PlaylistItem *m_nextPlaylistItem;
......
......@@ -36,7 +36,7 @@ static bool copyImage(QImage &dest, QImage &src, int x, int y);
////////////////////////////////////////////////////////////////////////////////
SystemTray::SystemTray(QWidget *parent, const char *name) : KSystemTray(parent, name),
m_popup(0)
m_popup(0)
{
m_appPix = loadIcon("juk_dock");
......
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