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

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) ...@@ -131,8 +131,8 @@ void CollectionList::contentsDropEvent(QDropEvent *e)
{ {
if(e->source() == this) if(e->source() == this)
return; return;
else
decode(e);
} }
void CollectionList::contentsDragMoveEvent(QDragMoveEvent *e) void CollectionList::contentsDragMoveEvent(QDragMoveEvent *e)
...@@ -196,7 +196,7 @@ CollectionListItem::~CollectionListItem() ...@@ -196,7 +196,7 @@ CollectionListItem::~CollectionListItem()
{ {
CollectionList *l = CollectionList::instance(); CollectionList *l = CollectionList::instance();
if(l) if(l)
l->removeFromDict(getData()->absFilePath()); l->removeFromDict(data()->absFilePath());
} }
void CollectionListItem::addChildItem(PlaylistItem *child) void CollectionListItem::addChildItem(PlaylistItem *child)
......
...@@ -105,51 +105,6 @@ PlaylistItem::PlaylistItem(Playlist *parent) : QObject(parent), KListViewItem(pa ...@@ -105,51 +105,6 @@ PlaylistItem::PlaylistItem(Playlist *parent) : QObject(parent), KListViewItem(pa
setDragEnabled(true); 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 int PlaylistItem::compare(QListViewItem *item, int column, bool ascending) const
{ {
// reimplemented from QListViewItem // reimplemented from QListViewItem
...@@ -233,6 +188,41 @@ int PlaylistItem::compare(const PlaylistItem *firstItem, const PlaylistItem *sec ...@@ -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 // PlaylistItem::Data public methods
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
......
...@@ -83,8 +83,11 @@ protected: ...@@ -83,8 +83,11 @@ protected:
PlaylistItem(Playlist *parent); PlaylistItem(Playlist *parent);
class Data; class Data;
Data *getData(); Data *data() { return m_data; }
void setData(Data *d); 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: protected slots:
void slotRefreshImpl(); void slotRefreshImpl();
...@@ -94,8 +97,6 @@ signals: ...@@ -94,8 +97,6 @@ signals:
private: private:
void setup(CollectionListItem *item, Playlist *parent); 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; 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