Commit 07fb12bf authored by Scott Wheeler's avatar Scott Wheeler

Do The Right Thing (tm) when one of the tree view categories is selected

rather than a real playlist -- mark disabled the appropriate context menu
items.

This code was moved directly into the PlaylistBox class rather than trying
to push the information up through the PlaylistSplitter class in to the JuK
API.  This allowed several PlaylistSplitter methods to be removed.

Sadly this change is too invasive (and based too heavily on other changes)
and the bug too obscure to bother spent the time trying to backport it (it
would have to be a completely different fix), but this will be fixed in 3.3.

CCMAIL:73972-done@bugs.kde.org

svn path=/trunk/kdemultimedia/juk/; revision=303817
parent 6f3ce800
......@@ -544,32 +544,6 @@ void JuK::slotShowHide()
void JuK::slotPlaylistChanged()
{
if(m_splitter->collectionListSelected() ||
!m_splitter->hasListSelected() ||
m_splitter->readOnlyListSelected())
{
action("file_save")->setEnabled(false);
action("file_save_as")->setEnabled(false);
action("renamePlaylist")->setEnabled(false);
action("reloadPlaylist")->setEnabled(m_splitter->collectionListSelected());
action("deleteItemPlaylist")->setEnabled(false);
}
else {
action("file_save")->setEnabled(true);
action("file_save_as")->setEnabled(true);
action("renamePlaylist")->setEnabled(true);
action("deleteItemPlaylist")->setEnabled(true);
if(m_splitter->fileBasedListSelected() || m_splitter->dynamicListSelected())
action("reloadPlaylist")->setEnabled(true);
else
action("reloadPlaylist")->setEnabled(false);
}
if(m_splitter->hasListSelected())
action("duplicatePlaylist")->setEnabled(true);
else
action("duplicatePlaylist")->setEnabled(false);
updatePlaylistInfo();
}
......
......@@ -495,11 +495,36 @@ void PlaylistBox::slotPlaylistChanged()
if(!m_updatePlaylistStack)
return;
bool allowReload = false;
PlaylistList playlists;
for(ItemList::ConstIterator i = items.begin(); i != items.end(); ++i) {
if((*i)->playlist())
playlists.append((*i)->playlist());
for(ItemList::ConstIterator it = items.begin(); it != items.end(); ++it) {
Playlist *p = (*it)->playlist();
if(p) {
if(p == CollectionList::instance() || !p->fileName().isNull())
allowReload = true;
playlists.append(p);
}
}
if(playlists.isEmpty() ||
(playlists.count() == 1 &&
(playlists.front() == CollectionList::instance() ||
playlists.front()->readOnly())))
{
action("file_save")->setEnabled(false);
action("file_save_as")->setEnabled(false);
action("renamePlaylist")->setEnabled(false);
action("deleteItemPlaylist")->setEnabled(false);
}
else {
action("file_save")->setEnabled(true);
action("file_save_as")->setEnabled(true);
action("renamePlaylist")->setEnabled(playlists.count() == 1);
action("deleteItemPlaylist")->setEnabled(true);
}
action("reloadPlaylist")->setEnabled(allowReload);
action("duplicatePlaylist")->setEnabled(!playlists.isEmpty());
emit signalCurrentChanged(playlists);
}
......
......@@ -398,7 +398,7 @@ void PlaylistSplitter::slotDeleteSelectedItems()
void PlaylistSplitter::slotReloadPlaylist()
{
if(collectionListSelected())
if(visiblePlaylist() == m_collection)
slotScanDirectories();
else
visiblePlaylist()->slotReload();
......
......@@ -84,30 +84,6 @@ public:
* Returns the combined time of all the itens in the currently selected playlist.
*/
int selectedPlaylistTotalTime() const { return visiblePlaylist()->totalTime(); }
/**
* Returns true if the the collection list is the visible playlist.
*/
bool collectionListSelected() const { return visiblePlaylist() == m_collection; }
/**
* Returns true if the selected list has a file associated with it.
*/
bool fileBasedListSelected() { return !visiblePlaylist()->fileName().isNull(); }
/**
* Returns true if the selected list is read only.
*/
bool readOnlyListSelected() { return visiblePlaylist()->readOnly(); }
/**
* Returns true if the currently selected playlist is a dynamic list.
*/
bool dynamicListSelected() { return m_dynamicList && visiblePlaylist() == m_dynamicList; }
/**
* Returns true if the playlist selection widget has a currently selected item.
*/
bool hasListSelected() const { return m_playlistBox->hasSelection(); }
/**
* Open each of \a files, where \a files is a list of playlists and music
......@@ -230,7 +206,6 @@ private:
enum PlaylistType { Normal = 0, Search = 1, History = 2 };
static const int playlistCacheVersion = 2;
/**
* Returns a PlaylistItemList of the selected PlaylistItems in the top playlist in
* the QWidgetStack of playlists.
......
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