Fixed playlist disappearing on remove or clear.
[vlc-remote] / playlistmainwindow.cpp
index 7fec0ec..8ba4412 100644 (file)
@@ -68,9 +68,10 @@ PlayListMainWindow::PlayListMainWindow(QWidget *parent) :
 void PlayListMainWindow::init()  // CALL WHEN CONFIG CHANGES
 {
     mIp = AccountDialog::currentIp();
+}
+void PlayListMainWindow::showPlayList()  // CALL WHEN SHOWN
+{
     requestPlayList();
-
-
 }
 
 PlayListMainWindow::~PlayListMainWindow()
@@ -108,7 +109,7 @@ void PlayListMainWindow::onListSelectionChanged() {
 void PlayListMainWindow::onRemove() {
     if (0 < this->mCurrentVlcIndex) {
         /*QNetworkReply * reply = */ mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=pl_delete&id=" + QString::number(this->mCurrentVlcIndex))));
-        this->requestPlayList();
+        connect(mNetManager,SIGNAL(finished(QNetworkReply *)),this,SLOT(requestPlayList()));
     }
 }
 void PlayListMainWindow::onPlay() {
@@ -127,7 +128,7 @@ void PlayListMainWindow::onShuffle() {
 }
 void PlayListMainWindow::onClear() {
     /*QNetworkReply * reply = */ mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml?command=pl_empty")));
-                                 this->requestPlayList();
+    connect(mNetManager,SIGNAL(finished(QNetworkReply *)),this,SLOT(requestPlayList()));
 }
 void PlayListMainWindow::requestPlayList() {
   mContents->clear();
@@ -136,6 +137,7 @@ void PlayListMainWindow::requestPlayList() {
   ui->removeButton->setDisabled(true);
   ui->playButton->setDisabled(true);
   QNetworkReply * reply =  mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/playlist.xml")));
+  disconnect(mNetManager,SIGNAL(finished(QNetworkReply *)),this,SLOT(requestPlayList()));
   connect(reply,SIGNAL(readyRead()),this,SLOT(readReady()));
   connect(mNetManager,SIGNAL(finished(QNetworkReply *)),this,SLOT(finished(QNetworkReply *)));
 }