Added user home menu item, in case a users home set home folder is unavailable
[vlc-remote] / browsemainwindow.cpp
index 51437de..13a85e4 100644 (file)
@@ -55,6 +55,7 @@ BrowseMainWindow::BrowseMainWindow(QWidget *parent) :
     connect(ui->playButton,SIGNAL(clicked()),this,SLOT(onPlay()));
     connect(ui->listWidget, SIGNAL(itemSelectionChanged()), this, SLOT(onListSelectionChanged()));
 
+    connect(ui->actionGoUserHome, SIGNAL(triggered()), this, SLOT(showUserHomeFolder()));
     connect(ui->actionGoHome, SIGNAL(triggered()), this, SLOT(showHomeFolder()));
     connect(ui->actionSetHome, SIGNAL(triggered()), this, SLOT(setHomeFolder()));
     connect(ui->actionViewFavourites, SIGNAL(triggered()), this, SLOT(showFavourites()));
@@ -98,6 +99,9 @@ void BrowseMainWindow::changeEvent(QEvent *e)
 void BrowseMainWindow::showHomeFolder() {
     browseDirectory(AppSettings::getHomeDirectory().path);
 }
+void BrowseMainWindow::showUserHomeFolder() {
+    browseDirectory("~/");
+}
 void BrowseMainWindow::setHomeFolder() {
     if (0 < mCurrentDir.length()) {
         VlcDirectory dir;
@@ -123,7 +127,7 @@ void BrowseMainWindow::onListSelectionChanged() {
         }
         else {
             // can we browse?
-            if (0 == QString::compare("directory", mCurrentElement.type)) {
+            if (0 == QString::compare("directory", mCurrentElement.type) || 0 == QString::compare("dir", mCurrentElement.type)) {
                 ui->browseButton->setDisabled(false);
             }
             else {
@@ -148,7 +152,7 @@ VlcBrowseElement BrowseMainWindow::getElementFromText(QString text) {
 
 void BrowseMainWindow::onBrowse() {
     // check for directory
-    if (0 == QString::compare("directory", mCurrentElement.type)) {
+    if (0 == QString::compare("directory", mCurrentElement.type) || 0 == QString::compare("dir", mCurrentElement.type)) {
         // call browseDirectory
         mCurrentDir = mCurrentElement.path;
         browseDirectory(mCurrentDir);
@@ -204,6 +208,7 @@ void BrowseMainWindow::finished(QNetworkReply * reply) {
 #if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5)
     this->setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
 #endif
+    delete reply;
 }
 void BrowseMainWindow::parseXmlDirectory() {
     QDomDocument doc;
@@ -226,7 +231,7 @@ void BrowseMainWindow::parseXmlDirectory() {
             dir->name = node.attributes().namedItem("name").nodeValue();
             dir->extension = getExtension(dir->path, node.attributes().namedItem("extension").nodeValue());
             ++idx;
-            if (0 != QString::compare("directory", dir->type)) {
+            if (0 != QString::compare("directory", dir->type) && 0 != QString::compare("dir", dir->type)) {
                 files->append(*dir);
             }
             else if (0 == QString::compare("..", dir->name)) {
@@ -270,15 +275,6 @@ QString BrowseMainWindow::getExtension(QString path, QString extension) {
     }
 }
 
-void BrowseMainWindow::writeFile(QString path, QByteArray text) {
-    QFile file(path);
-    if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
-        return;
-
-    QTextStream out(&file);
-    out << text;
-}
-
 void BrowseMainWindow::updateList() {
     ui->listWidget->clear();
     int ct = this->mContents->count();
@@ -295,7 +291,7 @@ void BrowseMainWindow::updateList() {
             VlcBrowseElement dir = mContents->at(idx);
             QListWidgetItem* item;
             bool item_good = false;
-            if (0 == QString::compare("directory", dir.type)) {
+            if (0 == QString::compare("directory", dir.type) || 0 == QString::compare("dir", dir.type)) {
                 if (0 == QString::compare("..", dir.name)) {
                     item = new QListWidgetItem(icon_up, dir.name, ui->listWidget, 0);
                     item_good = true;