Commit a895d1ad authored by Scott Wheeler's avatar Scott Wheeler

Yay for interfaces. Remove a lot of code that isn't needed anymore since

it's easy and clean enough to pass around a PlaylistInterface pointer.

svn path=/trunk/kdemultimedia/juk/; revision=311090
parent 08c9b60a
......@@ -124,10 +124,6 @@ void JuK::setupLayout()
statusBar()->addWidget(m_statusLabel, 1);
connect(m_splitter, SIGNAL(signalSelectedPlaylistCountChanged(int)),
m_statusLabel, SLOT(setPlaylistCount(int)));
connect(m_splitter, SIGNAL(signalSelectedPlaylistTimeChanged(int)),
m_statusLabel, SLOT(setPlaylistTime(int)));
connect(m_statusLabel, SIGNAL(jumpButtonClicked()),
m_splitter, SLOT(slotSelectPlaying()));
......@@ -513,13 +509,6 @@ bool JuK::queryClose()
return true;
}
void JuK::updatePlaylistInfo()
{
m_statusLabel->setPlaylistInfo(m_splitter->visiblePlaylistName(),
m_splitter->selectedPlaylistCount(),
m_splitter->selectedPlaylistTotalTime());
}
KAction *JuK::createSplitterAction(const QString &text, const char *slot,
const char *name, const QString &pix,
const KShortcut &shortcut)
......@@ -547,7 +536,7 @@ void JuK::slotShowHide()
void JuK::slotPlaylistChanged()
{
updatePlaylistInfo();
m_statusLabel->setPlaylist(m_splitter);
}
void JuK::slotQuit()
......
......@@ -80,8 +80,6 @@ private:
virtual bool queryExit();
virtual bool queryClose();
void updatePlaylistInfo();
void openFile(const QString &file);
void openFile(const QStringList &files);
......
......@@ -31,6 +31,9 @@ public:
virtual FileHandle nextFile() = 0;
virtual FileHandle currentFile() = 0;
virtual FileHandle previousFile() = 0;
virtual int time() const = 0;
virtual int count() const = 0;
};
#endif
......@@ -701,7 +701,7 @@ void PlaylistSplitter::setupPlaylist(Playlist *p, bool raise, const char *icon,
this, SLOT(slotPlayCurrent()));
connect(p, SIGNAL(signalCountChanged(Playlist *)),
this, SLOT(slotPlaylistCountChanged(Playlist *)));
this, SIGNAL(signalPlaylistChanged()));
connect(p, SIGNAL(signalAboutToRemove(PlaylistItem *)),
this, SLOT(slotPlaylistItemRemoved(PlaylistItem *)));
......@@ -995,14 +995,6 @@ void PlaylistSplitter::slotChangePlaylist(const PlaylistList &l)
emit signalPlaylistChanged();
}
void PlaylistSplitter::slotPlaylistCountChanged(Playlist *p)
{
if(p && p == m_playlistStack->visibleWidget()) {
emit signalSelectedPlaylistCountChanged(p->childCount());
emit signalSelectedPlaylistTimeChanged(p->totalTime());
}
}
void PlaylistSplitter::slotPlaylistItemRemoved(PlaylistItem *item)
{
if(item == m_playingItem)
......
......@@ -64,27 +64,14 @@ public:
virtual FileHandle nextFile();
virtual FileHandle currentFile();
virtual FileHandle previousFile();
virtual int count() const { return visiblePlaylist()->childCount(); }
virtual int time() const { return visiblePlaylist()->totalTime(); }
/**
* Fills the menu passed in with the recently played history
*/
void populatePlayHistoryMenu(QPopupMenu *menu, bool random);
/**
* Returns the name of the currently visible playlist.
*/
QString visiblePlaylistName() const { return visiblePlaylist()->name(); }
/**
* Returns the number of items in the currently selected playlist.
*/
int selectedPlaylistCount() const { return visiblePlaylist()->childCount(); }
/**
* Returns the combined time of all the itens in the currently selected playlist.
*/
int selectedPlaylistTotalTime() const { return visiblePlaylist()->totalTime(); }
/**
* Open each of \a files, where \a files is a list of playlists and music
* files.
......@@ -211,8 +198,6 @@ public slots:
signals:
void signalPlaylistChanged();
void signalSelectedPlaylistCountChanged(int);
void signalSelectedPlaylistTimeChanged(int);
private:
......@@ -277,12 +262,6 @@ private slots:
*/
void slotChangePlaylist(const PlaylistList &l);
/**
* This slot is called when the total numbers in the playlist splitter has
* changed.
*/
void slotPlaylistCountChanged(Playlist *p);
/**
* This should be connected to Playlist::aboutToRemove()
*/
......
......@@ -36,7 +36,6 @@
StatusLabel::StatusLabel(QWidget *parent, const char *name) :
QHBox(parent, name),
mode(PlaylistInfo),
m_playlistCount(0),
m_showTimeRemaining(false)
{
QFrame *trackAndPlaylist = new QFrame(this);
......@@ -94,21 +93,12 @@ StatusLabel::~StatusLabel()
}
void StatusLabel::setPlaylistInfo(const QString &name, int count, int totalTime)
void StatusLabel::setPlaylist(PlaylistInterface *playlist)
{
m_playlistName = name;
m_playlistCount = count;
m_playlistTotalTime = totalTime;
if(mode != PlaylistInfo)
return;
m_playlistLabel->setText(m_playlistName);
int days = totalTime / (60 * 60 * 24);
int hours = totalTime / (60 * 60) % 24;
int minutes = totalTime / 60 % 60;
int seconds = totalTime % 60;
int days = playlist->time() / (60 * 60 * 24);
int hours = playlist->time() / (60 * 60) % 24;
int minutes = playlist->time() / 60 % 60;
int seconds = playlist->time() % 60;
QString time;
......@@ -122,17 +112,13 @@ void StatusLabel::setPlaylistInfo(const QString &name, int count, int totalTime)
else
time.append(QString().sprintf("%1d:%02d", minutes, seconds));
m_trackLabel->setText(i18n("1 item", "%n items", count) + " - " + time);
}
m_playlistLength = i18n("1 item", "%n items", playlist->count()) + " - " + time;
m_playlistName = playlist->name();
void StatusLabel::setPlaylistTime(int totalTime)
{
setPlaylistInfo(m_playlistName, m_playlistCount, totalTime);
}
void StatusLabel::setPlaylistCount(int c)
{
setPlaylistInfo(m_playlistName, c, m_playlistTotalTime);
if(mode == PlaylistInfo) {
m_playlistLabel->setText(m_playlistName);
m_trackLabel->setText(m_playlistLength);
}
}
void StatusLabel::setPlayingItemInfo(const FileHandle &file, const PlaylistInterface *playlist)
......@@ -147,14 +133,13 @@ void StatusLabel::setPlayingItemInfo(const FileHandle &file, const PlaylistInter
void StatusLabel::clear()
{
m_playlistLabel->clear();
m_trackLabel->clear();
setItemTotalTime(0);
setItemCurrentTime(0);
mode = PlaylistInfo;
setPlaylistInfo(m_playlistName, m_playlistCount, m_playlistTotalTime);
m_playlistLabel->setText(m_playlistName);
m_trackLabel->setText(m_playlistLength);
}
////////////////////////////////////////////////////////////////////////////////
......
......@@ -36,14 +36,8 @@ public:
virtual ~StatusLabel();
public slots:
/**
* Set the playlist name. This text will only be used when there is not an
* item playing.
*/
void setPlaylistCount(int c);
void setPlayingItemInfo(const FileHandle &file, const PlaylistInterface *playlist);
void setPlaylistInfo(const QString &name, int count, int totalTime);
void setPlaylistTime(int totalTime);
void setPlaylist(PlaylistInterface *playlist);
/**
* This clears the information about the playing items and frees that status
......@@ -71,10 +65,10 @@ private:
enum Mode { PlayingItemInfo, PlaylistInfo } mode;
QString m_playlistName;
int m_playlistCount;
QString m_playlistLength;
int m_itemTotalTime;
int m_itemCurrentTime;
int m_playlistTotalTime;
bool m_showTimeRemaining;
KSqueezedTextLabel *m_playlistLabel;
......
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