Commit a075ac73 authored by Scott Wheeler's avatar Scott Wheeler

Fixing up the PlaylistBox RMB menu a bit (per some users requests) and

removing some code that isn't used anymore.

svn path=/trunk/kdemultimedia/juk/; revision=225174
parent 9489b16d
......@@ -507,7 +507,7 @@ void JuK::play(const QString &file)
void JuK::slotPlaylistChanged()
{
if(m_splitter->collectionListSelected()) {
if(m_splitter->collectionListSelected() || !m_splitter->hasListSelected()) {
actionCollection()->action("file_save")->setEnabled(false);
actionCollection()->action("file_save_as")->setEnabled(false);
actionCollection()->action("renamePlaylist")->setEnabled(false);
......@@ -519,6 +519,11 @@ void JuK::slotPlaylistChanged()
actionCollection()->action("renamePlaylist")->setEnabled(true);
actionCollection()->action("deleteItemPlaylist")->setEnabled(true);
}
if(m_splitter->hasListSelected())
actionCollection()->action("duplicatePlaylist")->setEnabled(true);
else
actionCollection()->action("duplicatePlaylist")->setEnabled(false);
updatePlaylistInfo();
}
......@@ -632,10 +637,8 @@ void JuK::back()
void JuK::back(int howMany)
{
for (--howMany; howMany > 0; --howMany)
{
for(--howMany; howMany > 0; --howMany)
m_splitter->playPreviousFile(m_randomPlayAction->isChecked());
}
play(m_splitter->playPreviousFile(m_randomPlayAction->isChecked()));
}
......
......@@ -38,7 +38,8 @@
PlaylistBox::PlaylistBox(PlaylistSplitter *parent, const char *name) : KListView(parent, name),
m_splitter(parent),
m_updatePlaylistStack(true),
m_viewMode(Compact)
m_viewMode(Compact),
m_hasSelection(false)
{
readConfig();
addColumn("Playlists", width());
......@@ -72,7 +73,7 @@ PlaylistBox::PlaylistBox(PlaylistSplitter *parent, const char *name) : KListView
// add the view modes stuff
m_viewModeAction = new KSelectAction(m_contextMenu, "viewModeMenu");
m_viewModeAction = new KSelectAction(actions, "viewModeMenu");
m_viewModeAction->setText(i18n("View Modes"));
QStringList modes;
......@@ -365,13 +366,16 @@ void PlaylistBox::setSingleItem(QListViewItem *item)
void PlaylistBox::slotPlaylistChanged()
{
QValueList<Item *> items = selectedItems();
if(m_updatePlaylistStack && !items.isEmpty()) {
QValueList<Playlist *> playlists;
for(QValueList<Item *>::iterator i = items.begin(); i != items.end(); ++i)
playlists.append((*i)->playlist());
m_hasSelection = items.count() > 0;
emit signalCurrentChanged(playlists);
}
if(!m_updatePlaylistStack)
return;
QValueList<Playlist *> playlists;
for(QValueList<Item *>::iterator i = items.begin(); i != items.end(); ++i)
playlists.append((*i)->playlist());
emit signalCurrentChanged(playlists);
}
void PlaylistBox::slotDoubleClicked(QListViewItem *)
......@@ -379,43 +383,11 @@ void PlaylistBox::slotDoubleClicked(QListViewItem *)
emit signalDoubleClicked();
}
void PlaylistBox::slotShowContextMenu(QListViewItem *item, const QPoint &point, int)
void PlaylistBox::slotShowContextMenu(QListViewItem *, const QPoint &point, int)
{
m_contextMenu->popup(point);
}
void PlaylistBox::slotContextSave()
{
save(m_contextMenuOn);
}
void PlaylistBox::slotContextSaveAs()
{
saveAs(m_contextMenuOn);
}
void PlaylistBox::slotContextRename()
{
rename(m_contextMenuOn);
}
void PlaylistBox::slotContextDuplicate()
{
duplicate(m_contextMenuOn);
}
void PlaylistBox::slotContextDeleteItem()
{
deleteItem(m_contextMenuOn);
m_contextMenuOn = 0;
}
void PlaylistBox::slotContextReload()
{
reload(m_contextMenuOn);
m_contextMenuOn = 0;
}
void PlaylistBox::slotSetViewMode(int viewMode)
{
if(viewMode != m_viewMode) {
......
......@@ -60,6 +60,8 @@ public:
void duplicate();
void deleteItem();
bool hasSelection() const { return m_hasSelection; }
ViewMode viewMode() const { return m_viewMode; }
class Item;
......@@ -105,26 +107,18 @@ private slots:
*/
void slotPlaylistChanged();
void slotDoubleClicked(QListViewItem *);
void slotShowContextMenu(QListViewItem *item, const QPoint &point, int);
// context menu entries
void slotContextSave();
void slotContextSaveAs();
void slotContextRename();
void slotContextDuplicate();
void slotContextDeleteItem();
void slotContextReload();
void slotShowContextMenu(QListViewItem *, const QPoint &point, int);
void slotSetViewMode(int viewMode);
private:
PlaylistSplitter *m_splitter;
QStringList m_names;
KPopupMenu *m_contextMenu;
Item *m_contextMenuOn;
bool m_updatePlaylistStack;
QPtrDict<Item> m_playlistDict;
ViewMode m_viewMode;
KSelectAction *m_viewModeAction;
bool m_hasSelection;
};
......
......@@ -597,8 +597,10 @@ QString PlaylistSplitter::play(PlaylistItem *item)
void PlaylistSplitter::slotChangePlaylist(const PlaylistList &l)
{
if(l.isEmpty())
if(l.isEmpty()) {
emit signalPlaylistChanged();
return;
}
Playlist *current = m_dynamicList;
......@@ -610,7 +612,6 @@ void PlaylistSplitter::slotChangePlaylist(const PlaylistList &l)
m_playlistStack->raiseWidget(l.first());
m_editor->slotSetItems(playlistSelection());
m_dynamicList = 0;
emit signalPlaylistChanged();
}
else {
m_dynamicList = new DynamicPlaylist(l, m_playlistStack, i18n("Dynamic List"));
......@@ -619,6 +620,8 @@ void PlaylistSplitter::slotChangePlaylist(const PlaylistList &l)
if(current)
delete current;
emit signalPlaylistChanged();
}
void PlaylistSplitter::slotPlaylistCountChanged(Playlist *p)
......@@ -661,14 +664,10 @@ void PlaylistSplitter::slotShowSearchResults(const QString &query, bool caseSens
PlaylistSearch::Component *component;
if (regExp)
{
if(regExp)
component = new PlaylistSearch::Component(QRegExp(query, caseSensitive), m_searchWidget->searchedColumns(0));
}
else
{
component = new PlaylistSearch::Component(query, caseSensitive, m_searchWidget->searchedColumns(0));
}
PlaylistSearch::ComponentList components;
components.append(*component);
......
......@@ -131,6 +131,8 @@ public:
*/
bool collectionListSelected() const { return visiblePlaylist() == m_collection; }
bool hasListSelected() const { return m_playlistBox->hasSelection(); }
/**
* Open each of \a files, where \a files is a list of playlists and music
* files.
......
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