From: unknown Date: Sat, 28 Mar 2009 13:47:42 +0000 (+0100) Subject: - Make DirectoryPlaylist work X-Git-Url: https://gitweb.tyo.aptx.org/?a=commitdiff_plain;h=fff19e8e3eaf02bc8b3ed1fe5e49a90678e86920;p=aniplayer-old.git - Make DirectoryPlaylist work --- diff --git a/src/directoryplaylist.cpp b/src/directoryplaylist.cpp index 450da39..ce69fc5 100644 --- a/src/directoryplaylist.cpp +++ b/src/directoryplaylist.cpp @@ -1,5 +1,7 @@ #include "directoryplaylist.h" +#include + DirectoryPlaylist::DirectoryPlaylist(QObject *parent) : AbstractPlaylist(parent), m_currentIndex(-1) { @@ -17,25 +19,30 @@ DirectoryPlaylist::~DirectoryPlaylist() void DirectoryPlaylist::setDirectory(QDir directory) { + if (m_directory == directory) + return; + m_directory = directory; - m_currentIndex = 2; - emit currentChanged(m_currentIndex - 2); - emit currentChanged(m_directory[m_currentIndex]); + entryList = m_directory.entryInfoList(QDir::Files | QDir::Readable, QDir::Name); + m_currentIndex = 0; } int DirectoryPlaylist::indexOfFile(const QString &file) const { - return m_directory.entryList().indexOf(file); +qDebug() << file; + int tmp = entryList.indexOf(file); +qDebug() << "indexOfFile" << tmp; + return tmp; } bool DirectoryPlaylist::isEmpty() const { - return m_directory.count() == 2; + return entryList.count(); } int DirectoryPlaylist::count() const { - return m_directory.count() - 2; + return m_directory.count(); } int DirectoryPlaylist::currentIndex() const @@ -47,20 +54,20 @@ void DirectoryPlaylist::next() { ++m_currentIndex; if (m_currentIndex == count()) - m_currentIndex = 2; + m_currentIndex = 0; - emit currentChanged(m_currentIndex - 2); - emit currentChanged(m_directory[m_currentIndex]); + emit currentChanged(m_currentIndex); + emit currentChanged(entryList[m_currentIndex].absoluteFilePath()); } void DirectoryPlaylist::previous() { --m_currentIndex; if (m_currentIndex == 1) - m_currentIndex = m_directory.count() - 1; + m_currentIndex = entryList.count() - 1; - emit currentChanged(m_currentIndex - 2); - emit currentChanged(m_directory[m_currentIndex]); + emit currentChanged(m_currentIndex); + emit currentChanged(entryList[m_currentIndex].absoluteFilePath()); } void DirectoryPlaylist::setCurrent(int index) @@ -68,11 +75,11 @@ void DirectoryPlaylist::setCurrent(int index) if (index == m_currentIndex) return; - if (index < 0 || index > count() - 2) + if (index < 0 || index > count() - 1) return; - m_currentIndex = index + 2; + m_currentIndex = index; - emit currentChanged(m_currentIndex - 2); - emit currentChanged(m_directory[m_currentIndex]); + emit currentChanged(m_currentIndex); + emit currentChanged(entryList[m_currentIndex].absoluteFilePath()); } diff --git a/src/directoryplaylist.h b/src/directoryplaylist.h index aa501e1..d7b1e28 100644 --- a/src/directoryplaylist.h +++ b/src/directoryplaylist.h @@ -3,6 +3,7 @@ #include "abstractplaylist.h" #include +#include class DirectoryPlaylist : public AbstractPlaylist { @@ -34,6 +35,8 @@ signals: private: QDir m_directory; + QFileInfoList entryList; + int m_currentIndex; }; diff --git a/src/videowindow.cpp b/src/videowindow.cpp index fa85c1e..377ef65 100644 --- a/src/videowindow.cpp +++ b/src/videowindow.cpp @@ -84,8 +84,8 @@ VideoWindow::VideoWindow(QWidget *parent) : QMainWindow(parent) addAction("play", "Play", QKeySequence("P")); addAction("pause", "Pause", QKeySequence("W")); addAction("stop", "Stop", QKeySequence("X")); -// addAction("next", "Next", QKeySequence(".")); -// addAction("previous", "Previous", QKeySequence(",")); + addAction("next", "Next", QKeySequence("CTRL+.")); + addAction("previous", "Previous", QKeySequence("CTRL+,")); #ifndef BROWSERPLUGIN_BUILD addAction("togglePinMenu", "Pin Menu", QKeySequence(), true); addAction("toggleStayOnTop", "Stay on top", QKeySequence("T"), true); @@ -138,9 +138,9 @@ VideoWindow::VideoWindow(QWidget *parent) : QMainWindow(parent) connect(videoWidget, SIGNAL(menuToggleRequested()), this, SLOT(toggleMenu())); connect(videoWidget, SIGNAL(volumeChangeRequested(int)), this, SLOT(changeVolume(int))); -// connect(m_actions["next"], SIGNAL(triggered()), playlist, SLOT(next())); -// connect(m_actions["previous"], SIGNAL(triggered()), playlist, SLOT(previous())); -// connect(playlist, SIGNAL(currentChanged(QString)), this, SLOT(play(QString))); + connect(m_actions["next"], SIGNAL(triggered()), playlist, SLOT(next())); + connect(m_actions["previous"], SIGNAL(triggered()), playlist, SLOT(previous())); + connect(playlist, SIGNAL(currentChanged(QString)), this, SLOT(play(QString))); #ifndef BROWSERPLUGIN_BUILD connect(menu, SIGNAL(positionChanged()), this, SLOT(moveWithMenu())); #endif @@ -164,7 +164,7 @@ VideoWindow::VideoWindow(QWidget *parent) : QMainWindow(parent) anidb->setCompression(true); anidb->setIdlePolicy(AniDBUdpClient::LogoutIdlePolicy); - +qDebug() << m_currentFile; open(m_currentFile); } @@ -223,7 +223,7 @@ void VideoWindow::open(const QString &file, bool closeOnStop) { if (file == "") return; - +qDebug() << "open => " << file; QFileInfo fileInfo(file); if (!fileInfo.exists()) { @@ -275,8 +275,6 @@ void VideoWindow::play(const QString &file, bool closeOnStop) play(closeOnStop); } -void play(const QString &file); - void VideoWindow::togglePlay() { Phonon::State state = mediaObject->state();