'port' the rest of the playlist classes

parent 94c3f8f7
......@@ -19,7 +19,7 @@
#include <kdialog.h>
#include <QList>
#include "playlistsearch.h"
#include "playlist/playlistsearch.h"
class KLineEdit;
class KPushButton;
......
......@@ -43,10 +43,10 @@
#include "actioncollection.h"
#include "advancedsearchdialog.h"
#include "coverinfo.h"
#include "searchplaylist.h"
#include "folderplaylist.h"
#include "historyplaylist.h"
#include "upcomingplaylist.h"
#include "playlist/playlists/searchplaylist.h"
#include "playlist/playlists/folderplaylist.h"
#include "playlist/playlists/historyplaylist.h"
#include "playlist/playlists/upcomingplaylist.h"
#include "directorylist.h"
#include "mediafiles.h"
#include "playermanager.h"
......@@ -480,10 +480,11 @@ void PlaylistCollection::showCoverManager()
visiblePlaylist()->slotShowCoverManager();
}
PlaylistItemList PlaylistCollection::selectedItems()
{
return visiblePlaylist()->selectedItems();
}
// ### TODO: View
// PlaylistItemList PlaylistCollection::selectedItems()
// {
// return visiblePlaylist()->selectedItems();
// }
void PlaylistCollection::scanFolders()
{
......@@ -634,6 +635,7 @@ void PlaylistCollection::raise(Playlist *playlist)
TrackSequenceManager::instance()->setCurrentPlaylist(playlist);
playlist->applySharedSettings();
playlist->setSearchEnabled(m_searchEnabled);
// ### TODO: View
m_playlistStack->setCurrentWidget(playlist);
clearShowMore(false);
dataChanged();
......@@ -659,8 +661,9 @@ void PlaylistCollection::lowerDistraction()
if(!m_distraction)
return;
if(m_belowDistraction)
m_playlistStack->setCurrentWidget(m_belowDistraction);
// ### TODO: View
//if(m_belowDistraction)
// m_playlistStack->setCurrentWidget(m_belowDistraction);
m_belowDistraction = 0;
}
......@@ -682,7 +685,8 @@ void PlaylistCollection::setupPlaylist(Playlist *playlist, const QString &)
if(!playlist->name().isEmpty())
m_playlistNames.insert(playlist->name());
m_playlistStack->addWidget(playlist);
// ### TODO: View
// m_playlistStack->addWidget(playlist);
QObject::connect(playlist, SIGNAL(selectionChanged()),
object(), SIGNAL(signalSelectedItemsChanged()));
}
......
......@@ -55,7 +55,7 @@ DynamicPlaylist::DynamicPlaylist(const PlaylistList &playlists,
collection->setupPlaylist(this, iconName);
setName(name);
setSorting(columns() + 1);
//setSorting(columns() + 1);
for(PlaylistList::ConstIterator it = playlists.constBegin(); it != playlists.constEnd(); ++it)
m_observers.append(new PlaylistDirtyObserver(this, *it));
......@@ -89,32 +89,33 @@ void DynamicPlaylist::slotReload()
checkUpdateItems();
}
void DynamicPlaylist::lower(QWidget *top)
{
if(top == this)
return;
if(playing()) {
PlaylistList l;
l.append(this);
for(PlaylistList::Iterator it = m_playlists.begin();
it != m_playlists.end(); ++it)
{
(*it)->synchronizePlayingItems(l, true);
}
}
PlaylistItemList list = PlaylistItem::playingItems();
for(PlaylistItemList::Iterator it = list.begin(); it != list.end(); ++it) {
if((*it)->playlist() == this) {
list.erase(it);
break;
}
}
if(!list.isEmpty())
TrackSequenceManager::instance()->setCurrentPlaylist(list.front()->playlist());
}
// ### TODO: View
// void DynamicPlaylist::lower(QWidget *top)
// {
// if(top == this)
// return;
//
// if(playing()) {
// PlaylistList l;
// l.append(this);
// for(PlaylistList::Iterator it = m_playlists.begin();
// it != m_playlists.end(); ++it)
// {
// (*it)->synchronizePlayingItems(l, true);
// }
// }
//
// PlaylistItemList list = PlaylistItem::playingItems();
// for(PlaylistItemList::Iterator it = list.begin(); it != list.end(); ++it) {
// if((*it)->playlist() == this) {
// list.erase(it);
// break;
// }
// }
//
// if(!list.isEmpty())
// TrackSequenceManager::instance()->setCurrentPlaylist(list.front()->playlist());
// }
////////////////////////////////////////////////////////////////////////////////
// protected methods
......@@ -126,17 +127,18 @@ PlaylistItemList DynamicPlaylist::items()
return Playlist::items();
}
void DynamicPlaylist::showEvent(QShowEvent *e)
{
checkUpdateItems();
Playlist::showEvent(e);
}
void DynamicPlaylist::paintEvent(QPaintEvent *e)
{
checkUpdateItems();
Playlist::paintEvent(e);
}
// ### TODO: View
// void DynamicPlaylist::showEvent(QShowEvent *e)
// {
// checkUpdateItems();
// Playlist::showEvent(e);
// }
//
// void DynamicPlaylist::paintEvent(QPaintEvent *e)
// {
// checkUpdateItems();
// Playlist::paintEvent(e);
// }
void DynamicPlaylist::updateItems()
{
......@@ -178,7 +180,7 @@ void DynamicPlaylist::checkUpdateItems()
void DynamicPlaylist::slotUpdateItems()
{
// This should be optimized to check to see which items are already in the
// ### TODO: This should be optimized to check to see which items are already in the
// list and just adding those and removing the ones that aren't.
clear();
......
......@@ -13,7 +13,7 @@
***************************************************************************/
#include "folderplaylist.h"
#include "playlistcollection.h"
#include "playlist/playlistcollection.h"
#include "juk-exception.h"
#include <QTimer>
......
......@@ -37,8 +37,8 @@ HistoryPlaylist::HistoryPlaylist(PlaylistCollection *collection) :
m_timer->setSingleShot(true);
connect(m_timer, SIGNAL(timeout()), this, SLOT(slotCreateNewItem()));
setSorting(-1);
setColumnText(0, i18n("Time"));
//setSorting(-1);
setHeaderData(0, Qt::Horizontal, i18n("Time"));
}
HistoryPlaylist::~HistoryPlaylist()
......@@ -47,10 +47,10 @@ HistoryPlaylist::~HistoryPlaylist()
}
HistoryPlaylistItem *HistoryPlaylist::createItem(const FileHandle &file,
Q3ListViewItem *after, bool emitChanged)
HistoryPlaylistItem *after, bool emitChanged)
{
if(!after)
after = lastItem();
after = static_cast<HistoryPlaylistItem*>(lastItem());
return Playlist::createItem<HistoryPlaylistItem>(file, after, emitChanged);
}
......
......@@ -19,7 +19,7 @@
#include <QDateTime>
#include "playlist.h"
#include "playlistitem.h"
#include "playlist/playlistitem.h"
class HistoryPlaylistItem : public PlaylistItem
{
......@@ -43,7 +43,7 @@ public:
HistoryPlaylist(PlaylistCollection *collection);
virtual ~HistoryPlaylist();
virtual HistoryPlaylistItem *createItem(const FileHandle &file, Q3ListViewItem *after = 0,
virtual HistoryPlaylistItem *createItem(const FileHandle &file, HistoryPlaylistItem *after = 0,
bool emitChanged = true);
virtual void createItems(const PlaylistItemList &siblings);
virtual int columnOffset() const { return 1; }
......
......@@ -606,9 +606,12 @@ void Playlist::clearItem(PlaylistItem *item, bool emitChanged)
void Playlist::clearItems(const PlaylistItemList &items)
{
foreach(PlaylistItem *item, items)
foreach(PlaylistItem *item, items) {
m_items.removeAll(item);
delete item;
}
dataChanged();
}
......@@ -627,16 +630,11 @@ QStringList Playlist::files() const
return list;
}
PlaylistItemList Playlist::items()
{
return items(Q3ListViewItemIterator::IteratorFlag(0));
}
PlaylistItemList Playlist::visibleItems()
{
return items(Q3ListViewItemIterator::Visible);
}
// ### TODO: View
// PlaylistItemList Playlist::visibleItems()
// {
// return items(Q3ListViewItemIterator::Visible);
// }
void Playlist::updateLeftColumn()
{
......@@ -1722,10 +1720,10 @@ void Playlist::loadFile(const QString &fileName, const QFileInfo &fileInfo)
if(item.exists() && item.isFile() && item.isReadable() &&
MediaFiles::isMediaFile(item.fileName()))
{
if(after)
after = createItem(FileHandle(item, item.absoluteFilePath()), false);
else
after = createItem(FileHandle(item, item.absoluteFilePath()), false);
// if(after)
after = createItem(FileHandle(item, item.absoluteFilePath()), after, false);
// else
// after = createItem(FileHandle(item, item.absoluteFilePath()), 0, false);
}
}
......@@ -1783,16 +1781,16 @@ bool Playlist::playing() const
// return header()->mapToSection(i);
// }
PlaylistItemList Playlist::items(Q3ListViewItemIterator::IteratorFlag flags)
{
return m_items;
// PlaylistItemList Playlist::items(Q3ListViewItemIterator::IteratorFlag flags)
// {
// return m_items;
// PlaylistItemList list;
//
// for(Q3ListViewItemIterator it(this, flags); it.current(); ++it)
// list.append(static_cast<PlaylistItem *>(it.current()));
//
// return list;
}
// }
// ### TODO: View
// void Playlist::calculateColumnWeights()
......
......@@ -138,6 +138,11 @@ public:
* that the number of items in the list has changed.
*/
virtual void clearItems(const PlaylistItemList &items);
/**
* Removes all items.
*/
void clear() { clearItems(m_items); }
/**
* Accessor function to return a pointer to the currently playing file.
......@@ -152,11 +157,6 @@ public:
*/
QStringList files() const;
/**
* Returns a list of all of the items in the playlist.
*/
virtual PlaylistItemList items();
/**
* Returns a list of all of the \e visible items in the playlist.
*/
......@@ -322,6 +322,11 @@ public:
void read(QDataStream &s);
static void setShuttingDown() { m_shuttingDown = true; }
PlaylistItem *lastItem() { return m_items.last(); }
PlaylistItem *firstItem() { return m_items.first(); }
const PlaylistItemList &items() { return m_items; }
void moveItem(int from, int to) { m_items.move(from, to); }
public slots:
/**
......@@ -495,16 +500,6 @@ private:
*/
int leftMostVisibleColumn() const;
/**
* This method is used internally to provide the backend to the other item
* lists.
*
* \see items()
* \see visibleItems()
* \see selectedItems()
*/
PlaylistItemList items(Q3ListViewItemIterator::IteratorFlag flags);
/**
* Build the column "weights" for the weighted width mode.
*/
......
......@@ -20,7 +20,7 @@
#include <QHash>
#include "playlistitem.h"
#include "playlist/playlistitem.h"
#include "collectionlist.h"
////////////////////////////////////////////////////////////////////////////////
......
......@@ -24,8 +24,8 @@
#include "collectionlist.h"
#include "tag.h"
#include "playlistitem.h"
#include "playlistsearch.h"
#include "playlist/playlistitem.h"
#include "playlist/playlistsearch.h"
#include "tagtransactionmanager.h"
TreeViewItemPlaylist::TreeViewItemPlaylist(PlaylistCollection *collection,
......@@ -50,18 +50,19 @@ void TreeViewItemPlaylist::retag(const QStringList &files, Playlist *)
else if(m_columnType == PlaylistItem::AlbumColumn)
changedTag = i18n("album");
if(KMessageBox::warningContinueCancelList(
this,
i18n("You are about to change the %1 on these files.", changedTag),
files,
i18n("Changing Track Tags"),
KStandardGuiItem::cont(),
KStandardGuiItem::cancel(),
"dragDropRetagWarn"
) == KMessageBox::Cancel)
{
return;
}
// ### TODO: View
// if(KMessageBox::warningContinueCancelList(
// this,
// i18n("You are about to change the %1 on these files.", changedTag),
// files,
// i18n("Changing Track Tags"),
// KStandardGuiItem::cont(),
// KStandardGuiItem::cancel(),
// "dragDropRetagWarn"
// ) == KMessageBox::Cancel)
// {
// return;
// }
QStringList::ConstIterator it;
for(it = files.begin(); it != files.end(); ++it) {
......
......@@ -17,7 +17,7 @@
#define TREEVIEWITEMPLAYLIST_H
#include "searchplaylist.h"
#include "playlistitem.h"
#include "playlist/playlistitem.h"
class QStringList;
......
......@@ -20,8 +20,8 @@
#include <kapplication.h>
#include <kaction.h>
#include "playlistitem.h"
#include "playlistcollection.h"
#include "playlist/playlistitem.h"
#include "playlist/playlistcollection.h"
#include "tracksequencemanager.h"
#include "collectionlist.h"
#include "actioncollection.h"
......@@ -36,7 +36,7 @@ UpcomingPlaylist::UpcomingPlaylist(PlaylistCollection *collection, int defaultSi
{
setName(i18n("Play Queue"));
setAllowDuplicates(true);
setSorting(-1);
// setSorting(-1);
}
UpcomingPlaylist::~UpcomingPlaylist()
......@@ -184,10 +184,12 @@ UpcomingPlaylist::UpcomingSequenceIterator::~UpcomingSequenceIterator()
void UpcomingPlaylist::UpcomingSequenceIterator::advance()
{
PlaylistItem *item = m_playlist->firstChild();
PlaylistItem *item = m_playlist->firstItem();
if(item) {
PlaylistItem *next = static_cast<PlaylistItem *>(item->nextSibling());
PlaylistItem *next = 0;
if (m_playlist->items().size() > 1)
next = m_playlist->items().at(1);
m_playlist->clearItem(item);
setCurrent(next);
}
......@@ -230,11 +232,12 @@ void UpcomingPlaylist::UpcomingSequenceIterator::setCurrent(PlaylistItem *curren
// if(p == m_playlist) {
// Bump this item up to the top
m_playlist->takeItem(currentItem);
m_playlist->insertItem(currentItem);
m_playlist->moveItem(m_playlist->items().indexOf(currentItem), 0);
// m_playlist->takeItem(currentItem);
// m_playlist->insertItem(currentItem);
}
TrackSequenceIterator::setCurrent(m_playlist->firstChild());
TrackSequenceIterator::setCurrent(m_playlist->firstItem());
}
void UpcomingPlaylist::UpcomingSequenceIterator::reset()
......@@ -245,7 +248,7 @@ void UpcomingPlaylist::UpcomingSequenceIterator::reset()
void UpcomingPlaylist::UpcomingSequenceIterator::prepareToPlay(Playlist *)
{
if(!m_playlist->items().isEmpty())
setCurrent(m_playlist->firstChild());
setCurrent(m_playlist->firstItem());
}
QDataStream &operator<<(QDataStream &s, const UpcomingPlaylist &p)
......
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