Commit a05f548b authored by Scott Wheeler's avatar Scott Wheeler

Enable/disable actions when switching between the tagger and playlist.

Also, I created the ColumnType enum in FileListItem and prefer to use that
instead of int literals.

svn path=/trunk/kdemultimedia/juk/; revision=144182
parent 8c43dae8
......@@ -101,6 +101,7 @@ void FileList::setup()
addColumn(i18n("Track"));
addColumn(i18n("Genre"));
addColumn(i18n("Year"));
addColumn(i18n("Length"));
addColumn(i18n("File Name"));
setAllColumnsShowFocus(true);
......
......@@ -63,13 +63,6 @@ Tag *FileListItem::getTag()
return(tag);
}
/*
void FileListItem::setTag(Tag *itemTag)
{
tag = itemTag;
}
*/
MPEGHeader *FileListItem::getHeader()
{
if(!header) {
......@@ -78,13 +71,6 @@ MPEGHeader *FileListItem::getHeader()
return(header);
}
/*
void FileListItem::setHeader(MPEGHeader *itemHeader)
{
header = itemHeader;
}
*/
void FileListItem::setFile(QString fileName)
{
setFile(fileName);
......@@ -101,13 +87,14 @@ void FileListItem::setFile(QString fileName)
void FileListItem::refresh()
{
setText(0, getTag()->getTrack());
setText(1, getTag()->getArtist());
setText(2, getTag()->getAlbum());
setText(3, getTag()->getTrackNumberString());
setText(4, getTag()->getGenre());
setText(5, getTag()->getYearString());
setText(6, filePath());
setText(TrackColumn, getTag()->getTrack());
setText(ArtistColumn, getTag()->getArtist());
setText(AlbumColumn, getTag()->getAlbum());
setText(TrackNumberColumn, getTag()->getTrackNumberString());
setText(GenreColumn, getTag()->getGenre());
setText(YearColumn, getTag()->getYearString());
setText(LengthColumn, getHeader()->getLengthChar());
setText(FileNameColumn, filePath());
emit(refreshed());
}
......@@ -149,12 +136,12 @@ int FileListItem::compare(QListViewItem *item, int column, bool ascending) const
return(compare(thisFileListItem, fileListItem, column, ascending));
}
else {
for(int i = 1; i <= 3; i++) {
for(int i = ArtistColumn; i <= TrackNumberColumn; i++) {
if(compare(thisFileListItem, fileListItem, i, ascending) != 0)
return(compare(thisFileListItem, fileListItem, i, ascending));
}
if(compare(thisFileListItem, fileListItem, 0, ascending) != 0)
return(compare(thisFileListItem, fileListItem, 0, ascending));
if(compare(thisFileListItem, fileListItem, TrackColumn, ascending) != 0)
return(compare(thisFileListItem, fileListItem, TrackColumn, ascending));
return(0);
}
}
......@@ -164,7 +151,7 @@ int FileListItem::compare(QListViewItem *item, int column, bool ascending) const
int FileListItem::compare(FileListItem *firstItem, FileListItem *secondItem, int column, bool ascending) const
{
if(column == 3) {
if(column == TrackNumberColumn) {
if(firstItem->getTag()->getTrackNumber() > secondItem->getTag()->getTrackNumber())
return(1);
else if(firstItem->getTag()->getTrackNumber() < secondItem->getTag()->getTrackNumber())
......@@ -172,6 +159,14 @@ int FileListItem::compare(FileListItem *firstItem, FileListItem *secondItem, int
else
return(0);
}
else if(column == LengthColumn) {
if(firstItem->getHeader()->getLength() > secondItem->getHeader()->getLength())
return(1);
else if(firstItem->getHeader()->getLength() < secondItem->getHeader()->getLength())
return(-1);
else
return(0);
}
else {
return(firstItem->key(column, ascending).compare(secondItem->key(column, ascending)));
}
......
......@@ -29,15 +29,16 @@
class FileListItem : public QObject, public KListViewItem, public QFileInfo {
Q_OBJECT
public:
enum ColumnType { TrackColumn = 0, ArtistColumn = 1, AlbumColumn = 2, TrackNumberColumn = 3,
GenreColumn = 4, YearColumn = 5, LengthColumn = 6, FileNameColumn = 7 };
FileListItem(QFileInfo *file, KListView *parent);
FileListItem(FileListItem *item, KListView *parent);
~FileListItem();
Tag *getTag();
// void setTag(Tag *itemTag);
MPEGHeader *getHeader();
// void setHeader(MPEGHeader *itemHeader);
void setFile(QString fileName);
public slots:
......
......@@ -61,16 +61,18 @@ void JuK::setupActions()
KStdAction::selectAll(this, SLOT(selectAll()), actionCollection());
// play menu
(void) new KAction(i18n("&Add to Playlist"), "enqueue", 0, this, SLOT(addToPlaylist()), actionCollection(), "addToPlaylist");
(void) new KAction(i18n("&Remove from Playlist"), "dequeue", 0, this, SLOT(removeFromPlaylist()), actionCollection(), "removeFromPlaylist");
addToPlaylistAction = new KAction(i18n("&Add to Playlist"), "enqueue", 0, this,
SLOT(addToPlaylist()), actionCollection(), "addToPlaylist");
removeFromPlaylistAction = new KAction(i18n("&Remove from Playlist"), "dequeue", 0, this,
SLOT(removeFromPlaylist()), actionCollection(), "removeFromPlaylist");
playAction = new KAction(i18n("&Play"), "1rightarrow", 0, this, SLOT(playFile()), actionCollection(), "playFile");
pauseAction = new KAction(i18n("P&ause"), "player_pause", 0, this, SLOT(pauseFile()), actionCollection(), "pauseFile");
stopAction = new KAction(i18n("&Stop"), "player_stop", 0, this, SLOT(stopFile()), actionCollection(), "stopFile");
// function menu
(void) new KAction(i18n("Tagger"), "tag", 0, this, SLOT(showTagger()), actionCollection(), "showTagger");
(void) new KAction(i18n("Playlist Editor"), "edit", 0, this, SLOT(showPlaylist()), actionCollection(), "showPlaylist");
showTaggerAction = new KAction(i18n("Tagger"), "tag", 0, this, SLOT(showTagger()), actionCollection(), "showTagger");
showPlaylistAction = new KAction(i18n("Playlist Editor"), "edit", 0, this, SLOT(showPlaylist()), actionCollection(), "showPlaylist");
// just in the toolbar
......@@ -183,6 +185,12 @@ void JuK::showTagger()
playlist->hide();
tagger->show();
setCentralWidget(tagger);
addToPlaylistAction->setEnabled(true);
removeFromPlaylistAction->setEnabled(false);
showTaggerAction->setEnabled(false);
showPlaylistAction->setEnabled(true);
}
void JuK::showPlaylist()
......@@ -190,6 +198,12 @@ void JuK::showPlaylist()
tagger->hide();
playlist->show();
setCentralWidget(playlist);
addToPlaylistAction->setEnabled(false);
removeFromPlaylistAction->setEnabled(true);
showTaggerAction->setEnabled(true);
showPlaylistAction->setEnabled(false);
}
////////////////////////////////////////////////////////////////////////////////
......
......@@ -56,7 +56,8 @@ private:
// actions
SliderAction *sliderAction;
KAction *playAction, *pauseAction, *stopAction;
KAction *showTaggerAction, *showPlaylistAction;
KAction *addToPlaylistAction, *removeFromPlaylistAction;
QTimer *playTimer;
Player player;
......
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