Commit 997c3b3c authored by Scott Wheeler's avatar Scott Wheeler

Make drag to collection list work again; minor cleanups

svn path=/trunk/kdemultimedia/juk/; revision=210112
parent 8cecd422
......@@ -131,8 +131,8 @@ void CollectionList::contentsDropEvent(QDropEvent *e)
{
if(e->source() == this)
return;
else
decode(e);
}
void CollectionList::contentsDragMoveEvent(QDragMoveEvent *e)
......@@ -196,7 +196,7 @@ CollectionListItem::~CollectionListItem()
{
CollectionList *l = CollectionList::instance();
if(l)
l->removeFromDict(getData()->absFilePath());
l->removeFromDict(data()->absFilePath());
}
void CollectionListItem::addChildItem(PlaylistItem *child)
......
......@@ -105,51 +105,6 @@ PlaylistItem::PlaylistItem(Playlist *parent) : QObject(parent), KListViewItem(pa
setDragEnabled(true);
}
PlaylistItem::Data *PlaylistItem::getData()
{
return m_data;
}
void PlaylistItem::setData(Data *d)
{
m_data = d;
}
////////////////////////////////////////////////////////////////////////////////
// PlaylistItem protected slots
////////////////////////////////////////////////////////////////////////////////
void PlaylistItem::slotRefreshImpl()
{
// This should be the only function that needs to be rewritten if the structure of
// PlaylistItemData changes.
setText(TrackColumn, tag()->track());
setText(ArtistColumn, tag()->artist());
setText(AlbumColumn, tag()->album());
setText(TrackNumberColumn, tag()->trackNumberString());
setText(GenreColumn, tag()->genre());
setText(YearColumn, tag()->yearString());
setText(LengthColumn, tag()->lengthString());
setText(FileNameColumn, filePath());
}
////////////////////////////////////////////////////////////////////////////////
// PlaylistItem private methods
////////////////////////////////////////////////////////////////////////////////
void PlaylistItem::setup(CollectionListItem *item, Playlist *parent)
{
if(item) {
m_data = item->getData()->newUser();
item->addChildItem(this);
slotRefreshImpl();
connect(this, SIGNAL(signalRefreshed()), parent, SIGNAL(signalDataChanged()));
}
setDragEnabled(true);
}
int PlaylistItem::compare(QListViewItem *item, int column, bool ascending) const
{
// reimplemented from QListViewItem
......@@ -233,6 +188,41 @@ int PlaylistItem::compare(const PlaylistItem *firstItem, const PlaylistItem *sec
}
}
////////////////////////////////////////////////////////////////////////////////
// PlaylistItem protected slots
////////////////////////////////////////////////////////////////////////////////
void PlaylistItem::slotRefreshImpl()
{
// This should be the only function that needs to be rewritten if the structure of
// PlaylistItemData changes.
setText(TrackColumn, tag()->track());
setText(ArtistColumn, tag()->artist());
setText(AlbumColumn, tag()->album());
setText(TrackNumberColumn, tag()->trackNumberString());
setText(GenreColumn, tag()->genre());
setText(YearColumn, tag()->yearString());
setText(LengthColumn, tag()->lengthString());
setText(FileNameColumn, filePath());
}
////////////////////////////////////////////////////////////////////////////////
// PlaylistItem private methods
////////////////////////////////////////////////////////////////////////////////
void PlaylistItem::setup(CollectionListItem *item, Playlist *parent)
{
if(item) {
m_data = item->data()->newUser();
item->addChildItem(this);
slotRefreshImpl();
connect(this, SIGNAL(signalRefreshed()), parent, SIGNAL(signalDataChanged()));
}
setDragEnabled(true);
}
////////////////////////////////////////////////////////////////////////////////
// PlaylistItem::Data public methods
////////////////////////////////////////////////////////////////////////////////
......
......@@ -83,8 +83,11 @@ protected:
PlaylistItem(Playlist *parent);
class Data;
Data *getData();
void setData(Data *d);
Data *data() { return m_data; }
void setData(Data *d) { m_data = d; }
virtual int compare(QListViewItem *item, int column, bool ascending) const;
int compare(const PlaylistItem *firstItem, const PlaylistItem *secondItem, int column, bool ascending) const;
protected slots:
void slotRefreshImpl();
......@@ -94,8 +97,6 @@ signals:
private:
void setup(CollectionListItem *item, Playlist *parent);
virtual int compare(QListViewItem *item, int column, bool ascending) const;
int compare(const PlaylistItem *firstItem, const PlaylistItem *secondItem, int column, bool ascending) const;
Data *m_data;
};
......
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