aboutsummaryrefslogtreecommitdiff
path: root/src/qmmpui
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2010-12-04 09:05:25 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2010-12-04 09:05:25 +0000
commit03082b6a3b6190a14e17459a420a373f2fc1c3b5 (patch)
treecdedd7803880b256a13fcc93927bb2dcb17ccb2b /src/qmmpui
parentaa3f57c0236c77f2fd90415fc1f3062a93b25b93 (diff)
downloadqmmp-03082b6a3b6190a14e17459a420a373f2fc1c3b5.tar.gz
qmmp-03082b6a3b6190a14e17459a420a373f2fc1c3b5.tar.bz2
qmmp-03082b6a3b6190a14e17459a420a373f2fc1c3b5.zip
mpris 2.0 support
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1992 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/qmmpui')
-rw-r--r--src/qmmpui/playlistmodel.cpp39
-rw-r--r--src/qmmpui/playlistmodel.h14
2 files changed, 36 insertions, 17 deletions
diff --git a/src/qmmpui/playlistmodel.cpp b/src/qmmpui/playlistmodel.cpp
index 541fd3f26..2df8d9ef2 100644
--- a/src/qmmpui/playlistmodel.cpp
+++ b/src/qmmpui/playlistmodel.cpp
@@ -112,8 +112,7 @@ void PlayListModel::add(PlayListItem *item)
m_items << item;
m_current = m_items.indexOf(m_currentItem);
- if (m_items.size() == 1)
- emit firstAdded();
+ emit itemAdded(item);
emit listChanged();
}
@@ -124,29 +123,27 @@ void PlayListModel::add(QList <PlayListItem *> items)
if (m_items.isEmpty())
m_currentItem = items.at(0);
- foreach(PlayListItem *item, items)
- m_total_length += item->length();
m_items << items;
-
- if (m_items.size() == items.size())
- emit firstAdded();
m_current = m_items.indexOf(m_currentItem);
+ foreach(PlayListItem *item, items)
+ {
+ m_total_length += item->length();
+ emit itemAdded(item);
+ }
emit listChanged();
}
void PlayListModel::add(const QString &path)
{
QFileInfo f_info(path);
- //if (f_info.exists() || path.contains("://"))
+ if (f_info.isDir())
+ m_loader->loadDirectory(path);
+ else
{
- if (f_info.isDir())
- m_loader->loadDirectory(path);
- else
- {
- m_loader->loadFile(path);
- loadPlaylist(path);
- }
+ m_loader->loadFile(path);
+ loadPlaylist(path);
}
+
}
void PlayListModel::add(const QStringList &paths)
@@ -202,6 +199,13 @@ bool PlayListModel::setCurrent(int c)
return true;
}
+bool PlayListModel::setCurrent(PlayListItem *item)
+{
+ if(!m_items.contains(item))
+ return false;
+ return setCurrent(m_items.indexOf(item));
+}
+
bool PlayListModel::next()
{
if(m_stop_item == currentItem())
@@ -858,6 +862,11 @@ bool PlayListModel::isShuffle() const
return m_shuffle;
}
+bool PlayListModel::isLoaderRunning() const
+{
+ return m_loader->isRunning();
+}
+
void PlayListModel::preparePlayState()
{
m_play_state->prepare();
diff --git a/src/qmmpui/playlistmodel.h b/src/qmmpui/playlistmodel.h
index b44270758..3e4c1219d 100644
--- a/src/qmmpui/playlistmodel.h
+++ b/src/qmmpui/playlistmodel.h
@@ -152,6 +152,11 @@ public:
*/
bool setCurrent (int row);
/*!
+ * Sets current item to \b item.
+ * Returns \b true if success, otherwise returns \b false
+ */
+ bool setCurrent(PlayListItem *item);
+ /*!
* Returns \b true if \b row is selected, otherwise returns \b false
*/
bool isSelected(int row);
@@ -263,6 +268,10 @@ public:
*/
bool isShuffle() const;
/*!
+ * Returns \b true if the file loader thread is active; otherwise returns \b false.
+ */
+ bool isLoaderRunning() const;
+ /*!
* Returns \b true if the playlist contains an item with URL \b url; otherwise returns \b false.
*/
bool contains(const QString &url);
@@ -290,9 +299,10 @@ signals:
*/
void currentChanged();
/*!
- * Emitted when first item has added.
+ * Emitted when new item has added.
+ * @param name New playlist item pointer.
*/
- void firstAdded();
+ void itemAdded(PlayListItem *item);
/*!
* Emitted when playlist name has chanded.
* @param name New playlist name.