← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-10 into lp:ubuntu-filemanager-app

 

Carlos Jose Mazieri has proposed merging lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-10 into lp:ubuntu-filemanager-app with lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-09 as a prerequisite.

Commit message:
C++ UI test updated

Requested reviews:
  Ubuntu File Manager Developers (ubuntu-filemanager-dev)

For more details, see:
https://code.launchpad.net/~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-10/+merge/252981

Updated C++ simple view to test Samba browsing and authentication.
-- 
Your team Ubuntu File Manager Developers is requested to review the proposed merge of lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-10 into lp:ubuntu-filemanager-app.
=== modified file 'src/plugin/folderlistmodel/dirmodel.cpp'
--- src/plugin/folderlistmodel/dirmodel.cpp	2015-03-14 19:33:43 +0000
+++ src/plugin/folderlistmodel/dirmodel.cpp	2015-03-14 19:33:43 +0000
@@ -296,6 +296,23 @@
             {
                 icon =  QFileIconProvider().icon(mDirectoryContents.at(index.row()).diskFileInfo());
             }
+#if defined(SIMPLE_UI)
+            else
+            if (mDirectoryContents.at(index.row()).isHost())
+            {
+               return QIcon(":/resources/resources/server.png");
+            }
+            else
+            if (mDirectoryContents.at(index.row()).isWorkGroup())
+            {
+               return QIcon(":/resources/resources/workgroup.png");
+            }
+            else
+            if (mDirectoryContents.at(index.row()).isShare())
+            {
+               return QIcon(":/resources/resources/samba_folder.png");
+            }
+#endif
             else
             if (mDirectoryContents.at(index.row()).isDir())
             {

=== removed file 'src/plugin/test_folderlistmodel/simpleUI/actionprogress.cpp'
--- src/plugin/test_folderlistmodel/simpleUI/actionprogress.cpp	2014-12-30 18:23:15 +0000
+++ src/plugin/test_folderlistmodel/simpleUI/actionprogress.cpp	1970-01-01 00:00:00 +0000
@@ -1,48 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2014 Canonical Ltd.
- * Copyright 2014 Carlos J Mazieri <carlos.mazieri@xxxxxxxxx>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- * File: actionprogress.cpp
- * Date: 30/12/2014
- */
-
-#include "actionprogress.h"
-#include <QProgressBar>
-#include <QPushButton>
-#include <QVBoxLayout>
-
-ActionProgress::ActionProgress(QWidget *parent) :QDialog(parent)
-{
-    m_pbar = new QProgressBar(this);
-    m_pbar->setMaximum(100);
-    m_pbar->setMinimum(0);
-    QPushButton *btn = new QPushButton("Cancel", this);
-    connect(btn, SIGNAL(clicked()), this, SIGNAL(cancel()));
-    QVBoxLayout *layout = new QVBoxLayout(this);
-    layout->addWidget(m_pbar);
-    layout->addWidget(btn);
-}
-
-
-void ActionProgress::setValue(int v )
-{
-    m_pbar->setValue(v);
-}
-
-void ActionProgress::reset()
-{
-   m_pbar->reset();
-}

=== removed file 'src/plugin/test_folderlistmodel/simpleUI/actionprogress.h'
--- src/plugin/test_folderlistmodel/simpleUI/actionprogress.h	2014-12-30 18:23:15 +0000
+++ src/plugin/test_folderlistmodel/simpleUI/actionprogress.h	1970-01-01 00:00:00 +0000
@@ -1,43 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2014 Canonical Ltd.
- * Copyright 2014 Carlos J Mazieri <carlos.mazieri@xxxxxxxxx>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- * File: actionprogress.h
- * Date: 30/12/2014
- */
-
-#ifndef ACTIONPROGRESS_H
-#define ACTIONPROGRESS_H
-
-#include <QDialog>
-
-class QProgressBar;
-
-class ActionProgress : public QDialog
-{
-    Q_OBJECT
-public:
-   ActionProgress(QWidget *parent = 0);
-signals:
-       void    cancel();
-public slots:
-   void setValue(int v);
-   void reset() ;
-private:
-   QProgressBar * m_pbar;
-};
-
-#endif // ACTIONPROGRESS_H

=== added file 'src/plugin/test_folderlistmodel/simpleUI/authenticationdialog.ui'
--- src/plugin/test_folderlistmodel/simpleUI/authenticationdialog.ui	1970-01-01 00:00:00 +0000
+++ src/plugin/test_folderlistmodel/simpleUI/authenticationdialog.ui	2015-03-14 19:33:43 +0000
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>AuthenticationDialog</class>
+ <widget class="QDialog" name="AuthenticationDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>338</width>
+    <height>295</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Authentication Information</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QGridLayout" name="gridLayout">
+     <item row="0" column="0">
+      <widget class="QLabel" name="label_4">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text">
+        <string>User</string>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="1">
+      <widget class="QComboBox" name="comboBoxUser">
+       <property name="editable">
+        <bool>true</bool>
+       </property>
+       <property name="insertPolicy">
+        <enum>QComboBox::InsertAlphabetically</enum>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="0">
+      <widget class="QLabel" name="label_3">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text">
+        <string>Password</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="1">
+      <widget class="QLineEdit" name="lineEditPassword">
+       <property name="echoMode">
+        <enum>QLineEdit::PasswordEchoOnEdit</enum>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType">
+      <enum>QSizePolicy::Minimum</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>50</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text">
+        <string>Url</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="lineEditUrl">
+       <property name="readOnly">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QCheckBox" name="checkBox">
+     <property name="text">
+      <string>Save Password</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <spacer name="verticalSpacer_2">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType">
+      <enum>QSizePolicy::Minimum</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>50</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>AuthenticationDialog</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>AuthenticationDialog</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>

=== modified file 'src/plugin/test_folderlistmodel/simpleUI/placesmodel.cpp'
--- src/plugin/test_folderlistmodel/simpleUI/placesmodel.cpp	2014-08-13 15:25:21 +0000
+++ src/plugin/test_folderlistmodel/simpleUI/placesmodel.cpp	2015-03-14 19:33:43 +0000
@@ -49,6 +49,8 @@
     addPlace("Root", ":/resources/resources/red_folder.png", QStringList(QDir::rootPath()));
 
     addPlace("Trash", ":/resources/resources/recyclebin_full.png", QStringList(LocationUrl::TrashRootURL));
+
+    addPlace("samba/cifs", ":/resources/resources/workgroup.png", QStringList(LocationUrl::SmbURL));
 }
 
 

=== modified file 'src/plugin/test_folderlistmodel/simpleUI/res.qrc'
--- src/plugin/test_folderlistmodel/simpleUI/res.qrc	2014-08-13 15:25:21 +0000
+++ src/plugin/test_folderlistmodel/simpleUI/res.qrc	2015-03-14 19:33:43 +0000
@@ -19,5 +19,8 @@
     <file>resources/red_folder.png</file>
     <file>resources/document_folder.png</file>
     <file>resources/downloads_folder.png</file>
+    <file>resources/server.png</file>
+    <file>resources/workgroup.png</file>
+    <file>resources/samba_folder.png</file>
   </qresource>
 </RCC>

=== added file 'src/plugin/test_folderlistmodel/simpleUI/resources/samba_folder.png'
Binary files src/plugin/test_folderlistmodel/simpleUI/resources/samba_folder.png	1970-01-01 00:00:00 +0000 and src/plugin/test_folderlistmodel/simpleUI/resources/samba_folder.png	2015-03-14 19:33:43 +0000 differ
=== added file 'src/plugin/test_folderlistmodel/simpleUI/resources/server.png'
Binary files src/plugin/test_folderlistmodel/simpleUI/resources/server.png	1970-01-01 00:00:00 +0000 and src/plugin/test_folderlistmodel/simpleUI/resources/server.png	2015-03-14 19:33:43 +0000 differ
=== added file 'src/plugin/test_folderlistmodel/simpleUI/resources/workgroup.png'
Binary files src/plugin/test_folderlistmodel/simpleUI/resources/workgroup.png	1970-01-01 00:00:00 +0000 and src/plugin/test_folderlistmodel/simpleUI/resources/workgroup.png	2015-03-14 19:33:43 +0000 differ
=== modified file 'src/plugin/test_folderlistmodel/simpleUI/simplelist.cpp'
--- src/plugin/test_folderlistmodel/simpleUI/simplelist.cpp	2014-12-30 18:23:15 +0000
+++ src/plugin/test_folderlistmodel/simpleUI/simplelist.cpp	2015-03-14 19:33:43 +0000
@@ -24,7 +24,7 @@
 #include "dirmodel.h"
 #include "dirselection.h"
 #include "placesmodel.h"
-#include "actionprogress.h"
+#include "ui_authenticationdialog.h"
 
 #include <QDir>
 #include <QMetaType>
@@ -35,21 +35,28 @@
 #include <QTimer>
 #include <QLineEdit>
 #include <QMouseEvent>
+#include <QDialog>
 
 SimpleList::SimpleList(QWidget *parent) :
     QMainWindow(parent),
     ui(new Ui::SimpleList),  
-    m_pbar( new ActionProgress(this) ),
+    m_pbar( new QProgressBar() ),
     m_selection(0),
     m_holdingCtrlKey(false),
     m_holdingShiftKey(false),
     m_button(Qt::NoButton),
-    m_placesModel(new PlacesModel(this))
+    m_placesModel(new PlacesModel(this)),
+    m_authDialog(new QDialog(this)),
+    m_uiAuth(new Ui::AuthenticationDialog)
 {
     //prepare UI
     ui->setupUi(this);
+    m_uiAuth->setupUi(m_authDialog);
+
     ui->tableViewFM->horizontalHeader()->setSortIndicator(0,Qt::AscendingOrder);
     resize(1200,600);
+    m_pbar->setMaximum(100);
+    m_pbar->setMinimum(0);
 
     ui->listViewPlaces->setModel(m_placesModel);
     ui->listViewPlaces->setSpacing(ui->listViewPlaces->spacing() + 7);
@@ -87,7 +94,7 @@
     do_connections();
 
     //start browsing home
-    m_model->goHome(); 
+    m_model->goHome();
 }
 
 
@@ -158,7 +165,13 @@
             this,    SLOT(onError(QString,QString)));
 
     connect(m_model, SIGNAL(awaitingResultsChanged()),
-            this,    SLOT(onStatusChanged()));
+            this,    SLOT(onAwaitingResultsChanged()));
+
+    connect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)),
+            this,    SLOT(onRowsInserted(QModelIndex,int,int)));
+
+    connect(m_model, SIGNAL(needsAuthentication(QString,QString)),
+            this,    SLOT(onNeedsAutentication(QString, QString)));
 
     connect(m_selection,   SIGNAL(selectionChanged(int)),
             this,          SLOT(onSelectionChanged(int)));
@@ -166,7 +179,6 @@
     connect(ui->listViewPlaces,  SIGNAL(clicked(QModelIndex)),
             this,                SLOT(onPlacesClicked(QModelIndex)));
 
-    connect(m_pbar,  SIGNAL(cancel()), this, SLOT(onCancelAction()));
 }
 
 //===================================================================

=== modified file 'src/plugin/test_folderlistmodel/simpleUI/simplelist.h'
--- src/plugin/test_folderlistmodel/simpleUI/simplelist.h	2014-12-30 18:23:15 +0000
+++ src/plugin/test_folderlistmodel/simpleUI/simplelist.h	2015-03-14 19:33:43 +0000
@@ -29,13 +29,13 @@
 class QProgressBar;
 class DirSelection;
 class PlacesModel;
-class ActionProgress;
+class QDialog;
 
 namespace Ui {
-  class SimpleList;
+class SimpleList;
+class AuthenticationDialog;
 }
 
-
 class SimpleList : public QMainWindow
 {
     Q_OBJECT
@@ -55,12 +55,14 @@
 private:
     Ui::SimpleList *ui;
     DirModel       *m_model;   
-    ActionProgress * m_pbar;
+    QProgressBar  * m_pbar;
     DirSelection  * m_selection;
     bool            m_holdingCtrlKey;
     bool            m_holdingShiftKey;
     Qt::MouseButton m_button;
     PlacesModel   * m_placesModel;
+    QDialog       * m_authDialog;
+    Ui::AuthenticationDialog *m_uiAuth;
 
 private slots:   
     void   onNewDir();
@@ -77,8 +79,10 @@
     void   onSelectionChanged(int);
     void   onPlacesClicked(QModelIndex);
     void   onOpenTerminal();
-    void   onCancelAction();
-    void   onStatusChanged();
+    void   onAwaitingResultsChanged();
+    void   onRowsInserted(QModelIndex, int,int);
+    void   onNeedsAutentication(QString, QString);
+    void   onAuthenticaionAccepted();
 };
 
 #endif // SIMPLELIST_H

=== modified file 'src/plugin/test_folderlistmodel/simpleUI/simpleslots.cpp'
--- src/plugin/test_folderlistmodel/simpleUI/simpleslots.cpp	2014-12-30 18:23:15 +0000
+++ src/plugin/test_folderlistmodel/simpleUI/simpleslots.cpp	2015-03-14 19:33:43 +0000
@@ -26,7 +26,7 @@
 #include "dirselection.h"
 #include "placesmodel.h"
 #include "terminalfolderapp.h"
-#include "actionprogress.h"
+#include "ui_authenticationdialog.h"
 
 #include <QDir>
 #include <QMetaType>
@@ -37,6 +37,7 @@
 #include <QTimer>
 #include <QLineEdit>
 #include <QMouseEvent>
+#include <QDialog>
 
 
 void SimpleList::onRowClicked(QModelIndex index)
@@ -81,24 +82,13 @@
 void SimpleList::onClipboardChanged()
 {
     int clipboardCounter = m_model->getClipboardUrlsCounter();
-    int rows             = m_model->rowCount();
-    statusBar()->showMessage(QString("Total Items = %1 Clipboard Items = %2")
-                             .arg(rows)
+    statusBar()->showMessage(QString("clipboard items %1")
                              .arg(clipboardCounter)
                              );
     ui->actionPaste->setEnabled(clipboardCounter > 0);
 }
 
 
-void SimpleList::onStatusChanged()
-{
-    if (!m_model->awaitingResults())
-    {
-        onClipboardChanged();
-    }
-}
-
-
 void SimpleList::onProgress(int cur, int total, int percent)
 {
     QString p;
@@ -195,8 +185,50 @@
 }
 
 
-void SimpleList::onCancelAction()
-{
-    m_model->cancelAction();
-    m_pbar->hide();
+void SimpleList::onAwaitingResultsChanged()
+{
+    if (m_model->awaitingResults())
+    {
+        this->setCursor(Qt::BusyCursor);
+    }
+    else
+    {
+         this->setCursor(Qt::ArrowCursor);
+    }
+}
+
+
+void SimpleList::onRowsInserted(QModelIndex, int, int)
+{
+   ui->tableViewFM->resizeColumnToContents(0);
+}
+
+
+void SimpleList::onNeedsAutentication(QString user, QString url)
+{
+    m_uiAuth->lineEditUrl->setText(url);
+    int index = m_uiAuth->comboBoxUser->findText(user);
+    if (index == -1)
+    {
+          m_uiAuth->comboBoxUser->addItem(user);
+          index = m_uiAuth->comboBoxUser->findText(user);
+    }
+    if (index != -1)
+    {
+      m_uiAuth->comboBoxUser->setCurrentIndex(index);
+    }
+    m_uiAuth->checkBox->setChecked(false);
+    if (m_authDialog->exec() == QDialog::Accepted)
+    {
+        QTimer::singleShot(0, this, SLOT(onAuthenticaionAccepted()));
+    }
+}
+
+
+void SimpleList::onAuthenticaionAccepted()
+{
+    m_model->setPath( m_uiAuth->lineEditUrl->text(),
+                      m_uiAuth->comboBoxUser->currentText(),
+                      m_uiAuth->lineEditPassword->text(),                      
+                      m_uiAuth->checkBox->isChecked() );
 }

=== modified file 'src/plugin/test_folderlistmodel/simpleUI/simpleui.pro'
--- src/plugin/test_folderlistmodel/simpleUI/simpleui.pro	2014-12-30 18:23:15 +0000
+++ src/plugin/test_folderlistmodel/simpleUI/simpleui.pro	2015-03-14 19:33:43 +0000
@@ -13,15 +13,13 @@
    
 TEMPLATE = app
 
-DEFINES += REGRESSION_TEST_FOLDERLISTMODEL
-
-SOURCES += main.cpp  simplelist.cpp simpleslots.cpp   placesmodel.cpp terminalfolderapp.cpp \
-    actionprogress.cpp
-
-HEADERS  += simplelist.h   placesmodel.h terminalfolderapp.h \
-    actionprogress.h
-
-FORMS    += simplelist.ui
+DEFINES += REGRESSION_TEST_FOLDERLISTMODEL SIMPLE_UI
+
+SOURCES += main.cpp  simplelist.cpp simpleslots.cpp   placesmodel.cpp terminalfolderapp.cpp
+
+HEADERS  += simplelist.h   placesmodel.h terminalfolderapp.h
+
+FORMS    += simplelist.ui authenticationdialog.ui
 
 include (../../folderlistmodel/folderlistmodel.pri)
 


Follow ups