Commit 1e523a1d authored by Scott Wheeler's avatar Scott Wheeler

Fixing some of the damage from the last commit, a few minor cleanups and

accidentally made the width guessing a lot faster.

svn path=/trunk/kdemultimedia/juk/; revision=260658
parent 2e938cc5
......@@ -53,7 +53,9 @@ const Tag *PlaylistItem::tag() const
QString PlaylistItem::text(int column) const
{
switch(column) {
int offset = static_cast<Playlist *>(listView())->columnOffset();
switch(column - offset) {
case TrackColumn:
return m_data->tag()->track();
case ArtistColumn:
......@@ -73,12 +75,21 @@ QString PlaylistItem::text(int column) const
case FileNameColumn:
return m_data->tag()->absFilePath();
default:
return QString::null;
return KListViewItem::text(column);
}
}
// Some forwarding methods - these can't be inlined because the Data class
// isn't defined yet.
void PlaylistItem::setText(int column, const QString &text)
{
int offset = static_cast<Playlist *>(listView())->columnOffset();
if(column - offset >= 0 && column + offset <= lastColumn()) {
KListViewItem::setText(column, QString::null);
return;
}
KListViewItem::setText(column, text);
emit signalColumnWidthChanged(column);
}
QString PlaylistItem::fileName() const
{
......@@ -164,7 +175,7 @@ void PlaylistItem::slotRefresh()
// This signal will be received by the "parent" CollectionListItem which will
// in turn call slotRefreshImpl() for all of its children, including this item.
emit(signalRefreshed());
emit signalRefreshed();
}
void PlaylistItem::slotRefreshFromDisk()
......@@ -221,11 +232,6 @@ 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 &)
{
emit signalColumnWidthChanged(column);
}
int PlaylistItem::compare(QListViewItem *item, int column, bool ascending) const
{
// reimplemented from QListViewItem
......@@ -304,7 +310,10 @@ void PlaylistItem::slotRefreshImpl()
for(int i = 0; i < columns; i++) {
m_data->setLocal8BitLower(i, text(i).lower().local8Bit());
m_data->setCachedWidth(i, width(listView()->fontMetrics(), listView(), i));
int newWidth = width(listView()->fontMetrics(), listView(), i);
m_data->setCachedWidth(i, newWidth);
if(newWidth != m_data->cachedWidth(i))
emit signalColumnWidthChanged(i);
}
}
......
......@@ -68,9 +68,15 @@ class PlaylistItem : public QObject, public KListViewItem
Q_OBJECT
public:
enum ColumnType { TrackColumn = 0, ArtistColumn = 1, AlbumColumn = 2, TrackNumberColumn = 3,
GenreColumn = 4, YearColumn = 5, LengthColumn = 6, CommentColumn = 7,
FileNameColumn = 8 };
enum ColumnType { TrackColumn = 0,
ArtistColumn = 1,
AlbumColumn = 2,
TrackNumberColumn = 3,
GenreColumn = 4,
YearColumn = 5,
LengthColumn = 6,
CommentColumn = 7,
FileNameColumn = 8 };
static int lastColumn() { return FileNameColumn; }
......@@ -79,6 +85,7 @@ public:
const Tag *tag() const;
virtual QString text(int column) const;
virtual void setText(int column, const QString &text);
// These are just forwarding methods to PlaylistItem::Data, a QFileInfo
// subclass.
......@@ -140,7 +147,6 @@ protected:
void setData(Data *d) { m_data = d; }
virtual void paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int align);
virtual void setText(int column, const QString &text);
virtual int compare(QListViewItem *item, int column, bool ascending) const;
int compare(const PlaylistItem *firstItem, const PlaylistItem *secondItem, int column, bool ascending) const;
......
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