Commit 2e938cc5 authored by Scott Wheeler's avatar Scott Wheeler

Reimplementing QListViewItem::text() so that I don't maintain a copy of the

data both in the listview and in the data structure behind it.  Shaves off
about 18% of the memory consumption for 11000 items here...

svn path=/trunk/kdemultimedia/juk/; revision=260542
parent 25ea4fa0
......@@ -51,6 +51,32 @@ const Tag *PlaylistItem::tag() const
return m_data->tag();
QString PlaylistItem::text(int column) const
switch(column) {
case TrackColumn:
return m_data->tag()->track();
case ArtistColumn:
return m_data->tag()->artist();
case AlbumColumn:
return m_data->tag()->album();
case TrackNumberColumn:
return m_data->tag()->trackNumberString();
case GenreColumn:
return m_data->tag()->genre().name();
case YearColumn:
return m_data->tag()->yearString();
case LengthColumn:
return m_data->tag()->lengthString();
case CommentColumn:
return m_data->tag()->comment();
case FileNameColumn:
return m_data->tag()->absFilePath();
return QString::null;
// Some forwarding methods - these can't be inlined because the Data class
// isn't defined yet.
......@@ -195,9 +221,8 @@ void PlaylistItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int
QListViewItem::paintCell(p, colorGroup, column, width, align);
void PlaylistItem::setText(int column, const QString &text)
void PlaylistItem::setText(int column, const QString &)
KListViewItem::setText(column, text);
emit signalColumnWidthChanged(column);
......@@ -273,26 +298,7 @@ bool PlaylistItem::isValid() const
void PlaylistItem::slotRefreshImpl()
// This should be the only function that needs to be rewritten if the structure of
// PlaylistItemData changes.
int offset = static_cast<Playlist *>(listView())->columnOffset();
setText(TrackColumn + offset, tag()->track());
setText(ArtistColumn + offset, tag()->artist());
setText(AlbumColumn + offset, tag()->album());
setText(TrackNumberColumn + offset, tag()->trackNumberString());
setText(GenreColumn + offset, tag()->genre().name());
setText(YearColumn + offset, tag()->yearString());
setText(LengthColumn + offset, tag()->lengthString());
setText(FileNameColumn + offset, filePath());
QString shortComment = tag()->comment().simplifyWhiteSpace();
if(shortComment.length() > 50)
shortComment = shortComment.left(47) + "...";
setText(CommentColumn + offset, shortComment);
int columns = lastColumn() + offset + 1;
......@@ -78,6 +78,7 @@ public:
Tag *tag();
const Tag *tag() const;
virtual QString text(int column) const;
// These are just forwarding methods to PlaylistItem::Data, a QFileInfo
// subclass.
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