diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2008-11-28 21:19:59 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2008-11-28 21:19:59 +0000 |
| commit | 910c5067e8d7ae22b3fde6bd483391314de1ba16 (patch) | |
| tree | af57d00445efa54a4992ad1609cf71f59cdf9494 /src/ui | |
| parent | 26724c66d4764a77ca653ce6c0a1573e9e97e97c (diff) | |
| download | qmmp-910c5067e8d7ae22b3fde6bd483391314de1ba16.tar.gz qmmp-910c5067e8d7ae22b3fde6bd483391314de1ba16.tar.bz2 qmmp-910c5067e8d7ae22b3fde6bd483391314de1ba16.zip | |
general api changes, removed unused code
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@647 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/eqwidget.cpp | 4 | ||||
| -rw-r--r-- | src/ui/mainwindow.cpp | 42 | ||||
| -rw-r--r-- | src/ui/mainwindow.h | 1 | ||||
| -rw-r--r-- | src/ui/playlistitem.cpp | 74 | ||||
| -rw-r--r-- | src/ui/playlistitem.h | 4 | ||||
| -rw-r--r-- | src/ui/playlistmodel.cpp | 26 |
6 files changed, 43 insertions, 108 deletions
diff --git a/src/ui/eqwidget.cpp b/src/ui/eqwidget.cpp index 8906389f1..659edcb7a 100644 --- a/src/ui/eqwidget.cpp +++ b/src/ui/eqwidget.cpp @@ -316,12 +316,12 @@ void EqWidget::saveAutoPreset() if (!playlist->currentItem()) return; //delete preset if it already exists - EQPreset* preset = findPreset(playlist->currentItem()->fileName()); + EQPreset* preset = findPreset(playlist->currentItem()->url().section("/",-1)); if (preset) deletePreset(preset); //create new preset preset = new EQPreset(); - preset->setText(playlist->currentItem()->fileName()); + preset->setText(playlist->currentItem()->url().section("/",-1)); preset->setPreamp(m_preamp->value()); for (int i = 0; i<10; ++i) { diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 3be819487..8d36b0f4b 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -142,15 +142,8 @@ MainWindow::MainWindow(const QStringList& args, BuiltinCommandLineOption* option m_generalHandler = new GeneralHandler(this); connect(m_generalHandler, SIGNAL(playCalled()), SLOT(play())); - /*connect(m_generalHandler, SIGNAL(nextCalled()), SLOT(next())); - connect(m_generalHandler, SIGNAL(previousCalled()), SLOT(previous())); - connect(m_generalHandler, SIGNAL(stopCalled()), SLOT(stop())); - connect(m_generalHandler, SIGNAL(pauseCalled()), SLOT(pause())); - connect(m_generalHandler, SIGNAL(seekCalled(int)), SLOT(seek(int)));*/ connect(m_generalHandler, SIGNAL(toggleVisibilityCalled()), SLOT(toggleVisibility())); connect(m_generalHandler, SIGNAL(exitCalled()), SLOT(close())); - /*connect(m_generalHandler, SIGNAL(volumeChanged(int, int)), - m_core, SLOT(setVolume(int, int)));*/ m_playListModel->readSettings(); char buf[PATH_MAX + 1]; @@ -180,10 +173,10 @@ void MainWindow::play() if (m_playListModel->count() == 0) return; - m_equalizer->loadPreset(m_playListModel->currentItem()->fileName()); + m_equalizer->loadPreset(m_playListModel->currentItem()->url().section("/",-1)); //m_playListModel->currentItem()->updateTags(); m_playlist->listWidget()->updateList(); - QString s = m_playListModel->currentItem()->path(); + QString s = m_playListModel->currentItem()->url(); if (s.isEmpty()) return; if (m_core->play(s)) @@ -320,14 +313,6 @@ void MainWindow::showState(Qmmp::State state) { case Qmmp::Playing: { - //m_generalHandler->setState(General::Playing); - /*if (m_playListModel->currentItem()) - { - SongInfo info = *m_playListModel->currentItem(); - if (info.isEmpty()) - info.setValue(SongInfo::TITLE, m_playlist->currentItem()->text()); - m_generalHandler->setSongInfo(info); - }*/ if (m_playlist->listWidget()) m_playlist->listWidget()->updateList(); //removes progress message from TextScroller break; @@ -360,34 +345,11 @@ void MainWindow::showMetaData() if (m_playlist->currentItem()) { - SongInfo info; - info.setValue(SongInfo::TITLE, m_core->metaData(Qmmp::TITLE)); - info.setValue(SongInfo::ARTIST, m_core->metaData(Qmmp::ARTIST)); - info.setValue(SongInfo::ALBUM, m_core->metaData(Qmmp::ALBUM)); - info.setValue(SongInfo::COMMENT, m_core->metaData(Qmmp::COMMENT)); - info.setValue(SongInfo::GENRE, m_core->metaData(Qmmp::GENRE)); - info.setValue(SongInfo::YEAR, m_core->metaData(Qmmp::YEAR).toUInt()); - info.setValue(SongInfo::TRACK, m_core->metaData(Qmmp::TRACK).toUInt()); - info.setValue(SongInfo::STREAM, !QFile::exists(m_playlist->currentItem()->path())); - info.setValue(SongInfo::PATH, m_playlist->currentItem()->path()); - info.setValue(SongInfo::LENGTH, m_playlist->currentItem()->length()); - //m_generalHandler->setSongInfo(info); m_playlist->currentItem()->updateMetaData(m_core->metaData()); m_playlist->listWidget()->updateList(); } } -void MainWindow::changeTitle(const QString &title) -{ - if (m_playlist->currentItem()) - m_playlist->currentItem()->setText(title); - m_playlist->listWidget()->updateList(); - SongInfo info; - info.setValue(SongInfo::TITLE, title); - info.setValue(SongInfo::STREAM, TRUE); - //m_generalHandler->setSongInfo(info); -} - void MainWindow::closeEvent ( QCloseEvent *) { writeSettings(); diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h index 0f7890460..7a8562827 100644 --- a/src/ui/mainwindow.h +++ b/src/ui/mainwindow.h @@ -95,7 +95,6 @@ protected: private slots: void showState(Qmmp::State state); void showMetaData(); - void changeTitle(const QString&); void clear(); void startSeek(); void endSeek(); diff --git a/src/ui/playlistitem.cpp b/src/ui/playlistitem.cpp index f287ec0f5..bfbaa354c 100644 --- a/src/ui/playlistitem.cpp +++ b/src/ui/playlistitem.cpp @@ -24,19 +24,16 @@ #include "playlistitem.h" -PlayListItem::PlayListItem() : SongInfo(), m_flag(FREE) +PlayListItem::PlayListItem() : AbstractPlaylistItem(), m_flag(FREE) { m_info = 0; } -//PlayListItem::PlayListItem(const QString& path) : SongInfo(), m_flag(FREE) -PlayListItem::PlayListItem(FileInfo *info, QSettings *settings) : SongInfo(), m_flag(FREE) +PlayListItem::PlayListItem(FileInfo *info, QSettings *settings) : AbstractPlaylistItem(), m_flag(FREE) { m_selected = FALSE; m_current = FALSE; m_info = info; - setValue(SongInfo::PATH, info->path()); //TODO path? - setValue(SongInfo::STREAM, path().startsWith("http://")); //TODO do this inside SongInfo //use external settings or create new QSettings *s = settings; @@ -53,15 +50,10 @@ PlayListItem::PlayListItem(FileInfo *info, QSettings *settings) : SongInfo(), m_ if (!settings) //delete created settings only delete s; - if (m_use_meta && !path().startsWith("http://")) - { - //m_info = Decoder::createFileInfo(path); - readMetadata(); - } - else if (path().startsWith("http://") && m_fullStreamPath) - m_title = path(); - else - m_title = path().split('/',QString::SkipEmptyParts).takeLast (); + setMetaData(info->metaData()); + setMetaData(Qmmp::URL, m_info->path()); + setLength(m_info->length()); + readMetadata(); } PlayListItem::~PlayListItem() @@ -102,25 +94,22 @@ PlayListItem::FLAGS PlayListItem::flag() const void PlayListItem::updateMetaData(const QMap <Qmmp::MetaData, QString> &metaData) { - if (!m_info) - m_info = new FileInfo(); - - m_info->setMetaData(metaData); - m_use_meta = TRUE; + setMetaData(metaData); readMetadata(); } void PlayListItem::updateTags() { - if (path().startsWith("http://")) + if (url().startsWith("http://")) return; if (m_info) { delete m_info; m_info = 0; } - //m_info = Decoder::createFileInfo(path()); - m_info = Decoder::createPlayList(path()).at(0); + m_info = Decoder::createPlayList(url()).at(0); + setMetaData(m_info->metaData()); + setMetaData(Qmmp::URL, m_info->path()); readMetadata(); } @@ -136,37 +125,22 @@ void PlayListItem::setText(const QString &title) void PlayListItem::readMetadata() { - //clear(); - m_title.clear(); - if (m_info) //read length first //TODO fix this - setValue(SongInfo::LENGTH, uint(m_info->length())); - if (m_use_meta && m_info && !m_info->isEmpty()) - { - //fill SongInfo //TODO optimize - setValue(SongInfo::TITLE, m_info->metaData(Qmmp::TITLE)); - setValue(SongInfo::ARTIST, m_info->metaData(Qmmp::ARTIST)); - setValue(SongInfo::ALBUM, m_info->metaData(Qmmp::ALBUM)); - setValue(SongInfo::COMMENT, m_info->metaData(Qmmp::COMMENT)); - setValue(SongInfo::GENRE, m_info->metaData(Qmmp::GENRE)); - setValue(SongInfo::YEAR, m_info->metaData(Qmmp::YEAR).toUInt()); - setValue(SongInfo::TRACK, m_info->metaData(Qmmp::TRACK).toUInt()); - //generate playlist string - m_title = m_format; - m_title = printTag(m_title, "%p", artist()); - m_title = printTag(m_title, "%a", album()); - m_title = printTag(m_title, "%t", title()); - m_title = printTag(m_title, "%n", QString("%1").arg(track())); - m_title = printTag(m_title, "%g", genre()); - m_title = printTag(m_title, "%f", path().section('/',-1)); - m_title = printTag(m_title, "%F", path()); - m_title = printTag(m_title, "%y", QString("%1").arg(year ())); - } + m_title = m_format; + m_title = printTag(m_title, "%p", artist()); + m_title = printTag(m_title, "%a", album()); + m_title = printTag(m_title, "%t", title()); + m_title = printTag(m_title, "%n", QString("%1").arg(track())); + m_title = printTag(m_title, "%g", genre()); + m_title = printTag(m_title, "%f", url().section('/',-1)); + m_title = printTag(m_title, "%F", url()); + m_title = printTag(m_title, "%y", QString("%1").arg(year ())); + if (m_title.isEmpty()) { - if (path().startsWith("http://") && m_fullStreamPath) - m_title = path(); + if (url().startsWith("http://") && m_fullStreamPath) + m_title = url(); else - m_title = path().split('/',QString::SkipEmptyParts).takeLast (); + m_title = url().split('/',QString::SkipEmptyParts).takeLast (); } if (m_info) delete m_info; diff --git a/src/ui/playlistitem.h b/src/ui/playlistitem.h index 842691a68..ce26ca2f5 100644 --- a/src/ui/playlistitem.h +++ b/src/ui/playlistitem.h @@ -20,15 +20,15 @@ #ifndef PLAYLISTITEM_H #define PLAYLISTITEM_H -#include <qmmpui/songinfo.h> #include <qmmp/qmmp.h> +#include <qmmpui/abstractplaylistitem.h> class FileInfo; class QSettings; /** @author Ilya Kotov <forkotov02@hotmail.ru> */ -class PlayListItem : public SongInfo +class PlayListItem : public AbstractPlaylistItem { public: /*! diff --git a/src/ui/playlistmodel.cpp b/src/ui/playlistmodel.cpp index 1259db965..333cd7993 100644 --- a/src/ui/playlistmodel.cpp +++ b/src/ui/playlistmodel.cpp @@ -305,7 +305,7 @@ void PlayListModel::showDetails() { if (m_items.at(i)->isSelected()) { - if (!QFile::exists(m_items.at(i)->path())) + if (!QFile::exists(m_items.at(i)->url())) { PlayListItem *item = m_items.at(i); QString str; @@ -314,19 +314,19 @@ void PlayListModel::showDetails() str.append(tr("Artist:") + " %3\n"); str.append(tr("Album:") + " %4\n"); str.append(tr("Comment:") + " %5"); - str = str.arg(item->path()) + str = str.arg(item->url()) .arg(item->title().isEmpty() ? item->text() : item->title()) .arg(item->artist()) .arg(item->album()) .arg(item->comment()); - QMessageBox::information(0, m_items.at(i)->path(), str); + QMessageBox::information(0, m_items.at(i)->url(), str); return; } - DecoderFactory *fact = Decoder::findByPath(m_items.at(i)->path()); + DecoderFactory *fact = Decoder::findByPath(m_items.at(i)->url()); if (fact) { - QObject* o = fact->showDetails(0, m_items.at(i)->path()); + QObject* o = fact->showDetails(0, m_items.at(i)->url()); if (o) { TagUpdater *updater = new TagUpdater(o,m_items.at(i)); @@ -399,7 +399,7 @@ void PlayListModel::writeSettings() file.open(QIODevice::WriteOnly); foreach(PlayListItem* m, m_items) { - file.write(QString("file=%1").arg(m->path()).toUtf8() +"\n"); + file.write(QString("file=%1").arg(m->url()).toUtf8() +"\n"); file.write(QString("title=%1").arg(m->title()).toUtf8() +"\n"); file.write(QString("artist=%1").arg(m->artist()).toUtf8() +"\n"); file.write(QString("album=%1").arg(m->album()).toUtf8() +"\n"); @@ -694,25 +694,25 @@ static bool _titleGreaterComparator(PlayListItem* s1,PlayListItem* s2) static bool _pathAndFilenameLessComparator(PlayListItem* s1,PlayListItem* s2) { - return s1->path() < s2->path(); + return s1->url() < s2->url(); } static bool _pathAndFilenameGreaterComparator(PlayListItem* s1,PlayListItem* s2) { - return s1->path() > s2->path(); + return s1->url() > s2->url(); } static bool _filenameLessComparator(PlayListItem* s1,PlayListItem* s2) { - QFileInfo i_s1(s1->path()); - QFileInfo i_s2(s2->path()); + QFileInfo i_s1(s1->url()); + QFileInfo i_s2(s2->url()); return i_s1.baseName() < i_s2.baseName(); } static bool _filenameGreaterComparator(PlayListItem* s1,PlayListItem* s2) { - QFileInfo i_s1(s1->path()); - QFileInfo i_s2(s2->path()); + QFileInfo i_s1(s1->url()); + QFileInfo i_s2(s2->url()); return i_s1.baseName() > i_s2.baseName(); } @@ -881,7 +881,7 @@ void PlayListModel::savePlaylist(const QString & f_name) if (file.open(QIODevice::WriteOnly)) { QTextStream ts(&file); - QList <SongInfo *> songs; + QList <AbstractPlaylistItem *> songs; foreach(PlayListItem* item, m_items) songs << item; ts << prs->encode(songs); |
