Commit 2299f7f0 authored by Scott Wheeler's avatar Scott Wheeler

API cleanups for the PlaylistSplitter class. Just one class a day can...

svn path=/trunk/kdemultimedia/juk/; revision=209723
parent fa4716b1
......@@ -124,7 +124,7 @@ void CollectionList::decode(QMimeSource *s)
files.append((*it).path());
if(playlistSplitter())
playlistSplitter()->add(files, this);
playlistSplitter()->addToPlaylist(files, this);
}
void CollectionList::contentsDropEvent(QDropEvent *e)
......
......@@ -76,15 +76,15 @@ void JuK::setupLayout()
setCentralWidget(splitter);
// playlist item activation connection
connect(splitter, SIGNAL(doubleClicked()), this, SLOT(playSelectedFile()));
connect(splitter, SIGNAL(listBoxDoubleClicked()), this, SLOT(playFirstFile()));
connect(splitter, SIGNAL(signalDoubleClicked()), this, SLOT(playSelectedFile()));
connect(splitter, SIGNAL(signalListBoxDoubleClicked()), this, SLOT(playFirstFile()));
// create status bar
statusLabel = new StatusLabel(statusBar());
statusBar()->addWidget(statusLabel, 1);
connect(splitter, SIGNAL(selectedPlaylistCountChanged(int)), statusLabel, SLOT(setPlaylistCount(int)));
connect(statusLabel, SIGNAL(jumpButtonClicked()), splitter, SLOT(selectPlaying()));
connect(splitter, SIGNAL(signalSelectedPlaylistCountChanged(int)), statusLabel, SLOT(setPlaylistCount(int)));
connect(statusLabel, SIGNAL(jumpButtonClicked()), splitter, SLOT(slotSelectPlaying()));
splitter->setFocus();
......@@ -94,17 +94,17 @@ void JuK::setupLayout()
void JuK::setupActions()
{
// file menu
KStdAction::openNew(splitter, SLOT(createPlaylist()), actionCollection());
KStdAction::open(splitter, SLOT(open()), actionCollection());
new KAction(i18n("Open &Directory..."), "fileopen", 0, splitter, SLOT(openDirectory()), actionCollection(), "openDirectory");
KStdAction::openNew(splitter, SLOT(slotCreatePlaylist()), actionCollection());
KStdAction::open(splitter, SLOT(slotOpen()), actionCollection());
new KAction(i18n("Open &Directory..."), "fileopen", 0, splitter, SLOT(slotOpenDirectory()), actionCollection(), "openDirectory");
renamePlaylistAction = new KAction(i18n("Rename..."), 0, splitter, SLOT(renamePlaylist()),
renamePlaylistAction = new KAction(i18n("Rename..."), 0, splitter, SLOT(slotRenamePlaylist()),
actionCollection(), "renamePlaylist");
new KAction(i18n("Duplicate..."), "editcopy", 0, splitter, SLOT(duplicatePlaylist()), actionCollection(), "duplicatePlaylist");
new KAction(i18n("Duplicate..."), "editcopy", 0, splitter, SLOT(slotDuplicatePlaylist()), actionCollection(), "duplicatePlaylist");
savePlaylistAction = KStdAction::save(splitter, SLOT(savePlaylist()), actionCollection());
saveAsPlaylistAction = KStdAction::saveAs(splitter, SLOT(saveAsPlaylist()), actionCollection());
deleteItemPlaylistAction = new KAction(i18n("Remove"), "edittrash", 0, splitter, SLOT(deleteItemPlaylist()),
savePlaylistAction = KStdAction::save(splitter, SLOT(slotSavePlaylist()), actionCollection());
saveAsPlaylistAction = KStdAction::saveAs(splitter, SLOT(slotSaveAsPlaylist()), actionCollection());
deleteItemPlaylistAction = new KAction(i18n("Remove"), "edittrash", 0, splitter, SLOT(slotDeletePlaylist()),
actionCollection(), "deleteItemPlaylist");
KStdAction::quit(this, SLOT(close()), actionCollection());
......@@ -118,8 +118,8 @@ void JuK::setupActions()
// view menu
showEditorAction = new KToggleAction(i18n("Show Tag Editor"), "edit", 0, actionCollection(), "showEditor");
connect(showEditorAction, SIGNAL(toggled(bool)), splitter, SLOT(setEditorVisible(bool)));
KStdAction::redisplay(splitter, SLOT(refresh()), actionCollection());
connect(showEditorAction, SIGNAL(toggled(bool)), splitter, SLOT(slotSetEditorVisible(bool)));
KStdAction::redisplay(splitter, SLOT(slotRefresh()), actionCollection());
actionCollection()->insert(splitter->columnVisibleAction());
// play menu
......@@ -131,8 +131,8 @@ void JuK::setupActions()
forwardAction = new KAction(i18n("Skip &Forward"), "player_end", 0, this, SLOT(forward()), actionCollection(), "forward");
// tagger menu
new KAction(i18n("Save"), "filesave", "CTRL+t", splitter, SLOT(saveItem()), actionCollection(), "saveItem");
new KAction(i18n("Delete"), "editdelete", 0, splitter, SLOT(removeSelectedItems()), actionCollection(), "removeItem");
new KAction(i18n("Save"), "filesave", "CTRL+t", splitter, SLOT(slotSaveTag()), actionCollection(), "saveItem");
new KAction(i18n("Delete"), "editdelete", 0, splitter, SLOT(slotDeleteSelectedItems()), actionCollection(), "removeItem");
// settings menu
......@@ -162,7 +162,7 @@ void JuK::setupActions()
sliderAction->updateOrientation();
connect(this, SIGNAL(dockWindowPositionChanged(QDockWindow *)), sliderAction, SLOT(updateOrientation(QDockWindow *)));
connect(splitter, SIGNAL(playlistChanged()), this, SLOT(playlistChanged()));
connect(splitter, SIGNAL(signalPlaylistChanged()), this, SLOT(playlistChanged()));
}
void JuK::setupSystemTray()
......@@ -264,7 +264,7 @@ void JuK::readConfig()
KConfigGroupSaver saver(config, "View");
bool showEditor = config->readBoolEntry("ShowEditor", false);
showEditorAction->setChecked(showEditor);
splitter->setEditorVisible(showEditor);
splitter->slotSetEditorVisible(showEditor);
}
{ // general settings
KConfigGroupSaver saver(config, "Settings");
......
......@@ -335,7 +335,7 @@ void Playlist::decode(QMimeSource *s)
fileList.append((*it).path());
if(splitter)
splitter->add(fileList, this);
splitter->addToPlaylist(fileList, this);
}
bool Playlist::eventFilter(QObject* watched, QEvent* e)
......
......@@ -216,7 +216,7 @@ void PlaylistBox::duplicate(Item *item)
QLineEdit::Normal, m_splitter->uniquePlaylistName(item->text(), true), &ok);
if(ok) {
Playlist *p = m_splitter->createPlaylist(name);
m_splitter->add(item->playlist()->files(), p);
m_splitter->addToPlaylist(item->playlist()->files(), p);
}
}
}
......@@ -268,7 +268,7 @@ void PlaylistBox::decode(QMimeSource *s, Item *item)
for(KURL::List::Iterator it = urls.begin(); it != urls.end(); it++)
files.append((*it).path());
m_splitter->add(files, item->playlist());
m_splitter->addToPlaylist(files, item->playlist());
}
}
......@@ -385,9 +385,9 @@ void PlaylistBox::slotContextDeleteItem()
////////////////////////////////////////////////////////////////////////////////
PlaylistBox::Item::Item(PlaylistBox *listbox, const QPixmap &pix, const QString &text, Playlist *l)
: QObject(listbox), ListBoxPixmap(listbox, pix, text)
: QObject(listbox), ListBoxPixmap(listbox, pix, text),
list(l)
{
list = l;
setOrientation(Qt::Vertical);
listbox->addName(text);
......@@ -395,9 +395,9 @@ PlaylistBox::Item::Item(PlaylistBox *listbox, const QPixmap &pix, const QString
}
PlaylistBox::Item::Item(PlaylistBox *listbox, const QString &text, Playlist *l)
: ListBoxPixmap(listbox, SmallIcon("midi", 32), text)
: ListBoxPixmap(listbox, SmallIcon("midi", 32), text),
list(l)
{
list = l;
setOrientation(Qt::Vertical);
}
......@@ -406,16 +406,6 @@ PlaylistBox::Item::~Item()
}
Playlist *PlaylistBox::Item::playlist() const
{
return list;
}
PlaylistBox *PlaylistBox::Item::listBox() const
{
return dynamic_cast<PlaylistBox *>(ListBoxPixmap::listBox());
}
void PlaylistBox::Item::setName(const QString &name)
{
if(listBox()) {
......
......@@ -127,8 +127,8 @@ public:
Item(PlaylistBox *listbox, const QString &text, Playlist *l = 0);
virtual ~Item();
Playlist *playlist() const;
PlaylistBox *listBox() const;
Playlist *playlist() const { return list; }
PlaylistBox *listBox() const { return static_cast<PlaylistBox *>(ListBoxPixmap::listBox()); }
public slots:
void setName(const QString &name);
......
This diff is collapsed.
......@@ -46,7 +46,7 @@ class PlaylistSplitter : public QSplitter
Q_OBJECT
public:
PlaylistSplitter(QWidget *parent, bool restoreOnLoad = true, const char *name = 0);
PlaylistSplitter(QWidget *parent, bool restore = true, const char *name = 0);
virtual ~PlaylistSplitter();
......@@ -102,11 +102,6 @@ public:
QString playingTrack() const;
QString playingList() const;
/**
* Returns a list of the extensions that are used for playlists.
*/
QStringList playlistExtensions() const { return listExtensions; }
/**
* Returns the name of the currently selected playlist.
*/
......@@ -120,17 +115,17 @@ public:
/**
* Add the file to the playlist.
*/
void add(const QString &file, Playlist *list);
void addToPlaylist(const QString &file, Playlist *list);
/**
* Adds the files to the playlist.
*/
void add(const QStringList &files, Playlist *list);
void addToPlaylist(const QStringList &files, Playlist *list);
/**
* Returns true if the the collection list is the visible playlist.
*/
bool collectionListSelected() const { return visiblePlaylist() == CollectionList::instance(); }
bool collectionListSelected() const { return visiblePlaylist() == m_collection; }
/**
* Open each of \a files, where \a files is a list of playlists and music
......@@ -145,7 +140,12 @@ public:
QStringList columnNames() const { return m_columnNames; }
KActionMenu *columnVisibleAction() const { return collection->columnVisibleAction(); }
KActionMenu *columnVisibleAction() const { return m_collection->columnVisibleAction(); }
/**
* Create a playlist with the named \a name.
*/
Playlist *createPlaylist(const QString &name);
// static methods
......@@ -156,6 +156,12 @@ public:
*/
static QString extensionsString(const QStringList &extensions, const QString &type = QString::null);
/**
* Returns a list of the extensions that are used for playlists.
*/
static QStringList playlistExtensions() { return *m_listExtensions; }
public slots:
// File slots
......@@ -163,77 +169,67 @@ public slots:
/**
* Open files or playlists.
*/
void open();
void slotOpen();
/**
* Open a directory recursively, grabbing all of the music and playlist files
* in it's heirarchy.
*/
void openDirectory();
void slotOpenDirectory();
// Tagger slots
/**
* Save.
*/
void saveItem() { editor->save(); }
void slotSaveTag() { m_editor->save(); }
// Playlist slots
/**
* Create a playlist and prompt the user for a name.
*/
Playlist *createPlaylist();
/**
* Create a playlist with the named \a name.
*/
Playlist *createPlaylist(const QString &name);
Playlist *slotCreatePlaylist();
/**
* Sets the selection to the currently playing item and ensures that it is
* visible.
*/
void selectPlaying();
void slotSelectPlaying();
// Other slots
/**
* Deletes the selected items from the hard disk.
*/
void removeSelectedItems();
void slotDeleteSelectedItems();
/**
* Refresh the contents of the currently visible playlist. This will cause
* all of the audio meta data to be reread from disk.
*/
void refresh() { visiblePlaylist()->refresh(); }
/**
* Removes the selected items from the playlist.
*/
void clearSelectedItems();
void slotRefresh() { visiblePlaylist()->refresh(); }
/**
* Show or hide the editor.
*/
void setEditorVisible(bool visible);
void slotSetEditorVisible(bool visible);
// PlaylistBox forwarding slots
void savePlaylist() { playlistBox->save(); }
void saveAsPlaylist() { playlistBox->saveAs(); }
void renamePlaylist() { playlistBox->rename(); }
void duplicatePlaylist() { playlistBox->duplicate(); }
void deleteItemPlaylist() { playlistBox->deleteItem(); }
void slotSavePlaylist() { m_playlistBox->save(); }
void slotSaveAsPlaylist() { m_playlistBox->saveAs(); }
void slotRenamePlaylist() { m_playlistBox->rename(); }
void slotDuplicatePlaylist() { m_playlistBox->duplicate(); }
void slotDeletePlaylist() { m_playlistBox->deleteItem(); }
void slotToggleColumnVisible(int column);
signals:
void doubleClicked();
void listBoxDoubleClicked();
void playlistChanged();
void selectedPlaylistCountChanged(int);
void signalDoubleClicked();
void signalListBoxDoubleClicked();
void signalPlaylistChanged();
void signalSelectedPlaylistCountChanged(int);
private:
/**
......@@ -247,7 +243,7 @@ private:
*/
PlaylistItem *playlistFirstItem() const { return static_cast<PlaylistItem *>(visiblePlaylist()->firstChild()); }
Playlist *visiblePlaylist() const { return static_cast<Playlist *>(playlistStack->visibleWidget()); }
Playlist *visiblePlaylist() const { return static_cast<Playlist *>(m_playlistStack->visibleWidget()); }
void setupLayout();
void readConfig();
......@@ -263,47 +259,46 @@ private:
void setupColumns(Playlist *p);
private slots:
void changePlaylist(Playlist *p);
void playlistCountChanged(Playlist *p);
void slotChangePlaylist(Playlist *p);
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 queueDirectory(const QString &directory) { directoryQueue.append(directory); }
void slotQueueDirectory(const QString &directory) { m_directoryQueue.append(directory); }
/**
* Add a directory to the queue
*/
void queueDirectoryRemove(const QString &directory) { directoryQueueRemove.append(directory); }
void slotQueueDirectoryRemove(const QString &directory) { m_directoryQueueRemove.append(directory); }
/**
* This should be connected to Playlist::aboutToRemove()
*/
void playlistItemRemoved(PlaylistItem *item);
void slotPlaylistItemRemoved(PlaylistItem *item);
private:
PlaylistItem *playingItem;
PlaylistBox *playlistBox;
QWidgetStack *playlistStack;
TagEditor *editor;
PlaylistItem *m_playingItem;
PlaylistBox *m_playlistBox;
QWidgetStack *m_playlistStack;
TagEditor *m_editor;
CollectionList *collection;
CollectionList *m_collection;
StringHash playlistFiles;
StringHash m_playlistFiles;
QStringList mediaExtensions;
QStringList listExtensions;
static QStringList *m_mediaExtensions;
static QStringList *m_listExtensions;
QStringList directoryList;
QStringList directoryQueue;
QStringList directoryQueueRemove;
QStringList m_directoryList;
QStringList m_directoryQueue;
QStringList m_directoryQueueRemove;
QValueVector<bool> m_visibleColumns;
QStringList m_columnNames;
bool showEditor;
bool restore;
bool m_restore;
};
#endif
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