[Pkg-owncloud-commits] [owncloud-client] 92/120: Show a shortened version of the path in the account settings and activity

Sandro Knauß hefee-guest at moszumanska.debian.org
Mon Aug 24 00:02:50 UTC 2015


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 7ca80407884181474dc66d63ea362c0b59a0d1e9
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Mon Aug 17 11:39:45 2015 +0200

    Show a shortened version of the path in the account settings and activity
    
    Issue #3576, #3567
---
 src/gui/folder.cpp            | 22 +++++++++++++++++-----
 src/gui/folder.h              | 10 +++++-----
 src/gui/folderstatusmodel.cpp |  2 +-
 src/gui/protocolwidget.cpp    | 14 ++++++++++----
 4 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp
index 87388c8..5b0f4b0 100644
--- a/src/gui/folder.cpp
+++ b/src/gui/folder.cpp
@@ -204,6 +204,23 @@ QString Folder::path() const
     return p;
 }
 
+QString Folder::shortGuiPath() const
+{
+    QString p = _definition.localPath;
+    QString home = QDir::homePath();
+    if( ! home.endsWith('/') ) {
+        home.append('/');
+    }
+    if (p.startsWith(home)) {
+        p = p.mid(home.length());
+    }
+    if (p.length() > 1 && p.endsWith('/')) {
+        p.chop(1);
+    }
+    return QDir::toNativeSeparators(p);
+}
+
+
 bool Folder::ignoreHiddenFiles()
 {
     bool re(_definition.ignoreHiddenFiles);
@@ -241,11 +258,6 @@ QUrl Folder::remoteUrl() const
     return Account::concatUrlPath(_accountState->account()->davUrl(), remotePath());
 }
 
-QString Folder::nativePath() const
-{
-    return QDir::toNativeSeparators(path());
-}
-
 bool Folder::syncPaused() const
 {
   return _definition.paused;
diff --git a/src/gui/folder.h b/src/gui/folder.h
index 3d01b38..34a0a94 100644
--- a/src/gui/folder.h
+++ b/src/gui/folder.h
@@ -104,6 +104,11 @@ public:
     QString aliasGui() const; // since 2.0 we don't want to show aliases anymore, show the path instead
 
     /**
+     * short path to display on the GUI  (native separators)
+     */
+    QString shortGuiPath() const;
+
+    /**
      * local folder path
      */
     QString path() const;
@@ -124,11 +129,6 @@ public:
     QUrl remoteUrl() const;
 
     /**
-     * local folder path with native separators
-     */
-    QString nativePath() const;
-
-    /**
      * switch sync on or off
      * If the sync is switched off, the startSync method is not going to
      * be called.
diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp
index d567f27..da41de0 100644
--- a/src/gui/folderstatusmodel.cpp
+++ b/src/gui/folderstatusmodel.cpp
@@ -154,7 +154,7 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
     const bool accountConnected = _accountState->isConnected();
 
     switch (role) {
-    case FolderStatusDelegate::FolderPathRole         : return  f->nativePath();
+    case FolderStatusDelegate::FolderPathRole         : return  f->shortGuiPath();
     case FolderStatusDelegate::FolderSecondPathRole   : return  f->remotePath();
     case FolderStatusDelegate::HeaderRole             : return  f->aliasGui();
     case FolderStatusDelegate::FolderAliasRole        : return  f->alias();
diff --git a/src/gui/protocolwidget.cpp b/src/gui/protocolwidget.cpp
index 1ffd9b6..69829a4 100644
--- a/src/gui/protocolwidget.cpp
+++ b/src/gui/protocolwidget.cpp
@@ -99,7 +99,7 @@ void ProtocolWidget::copyToClipboard()
             << qSetFieldWidth(64)
             << child->data(1,Qt::DisplayRole).toString()
                 // folder
-            << qSetFieldWidth(15)
+            << qSetFieldWidth(30)
             << child->data(2, Qt::DisplayRole).toString()
                 // action
             << qSetFieldWidth(15)
@@ -161,7 +161,7 @@ void ProtocolWidget::cleanIgnoreItems(const QString& folder)
     for( int cnt = itemCnt-1; cnt >=0 ; cnt-- ) {
         QTreeWidgetItem *item = _ui->_treeWidget->topLevelItem(cnt);
         bool isErrorItem = item->data(0, IgnoredIndicatorRole).toBool();
-        QString itemFolder = item->data(2, Qt::DisplayRole).toString();
+        QString itemFolder = item->data(2, Qt::UserRole).toString();
         if( isErrorItem && itemFolder == folder ) {
             delete item;
         }
@@ -179,7 +179,7 @@ QString ProtocolWidget::timeString(QDateTime dt, QLocale::FormatType format) con
 
 void ProtocolWidget::slotOpenFile( QTreeWidgetItem *item, int )
 {
-    QString folderName = item->text(2);
+    QString folderName = item->data(2, Qt::UserRole).toString();
     QString fileName = item->text(1);
 
     Folder *folder = FolderMan::instance()->folder(folderName);
@@ -203,6 +203,11 @@ QString ProtocolWidget::fixupFilename( const QString& name )
 
 QTreeWidgetItem* ProtocolWidget::createCompletedTreewidgetItem(const QString& folder, const SyncFileItem& item)
 {
+    auto f = FolderMan::instance()->folder(folder);
+    if (!f) {
+        return 0;
+    }
+
     QStringList columns;
     QDateTime timestamp = QDateTime::currentDateTime();
     const QString timeStr = timeString(timestamp);
@@ -210,7 +215,7 @@ QTreeWidgetItem* ProtocolWidget::createCompletedTreewidgetItem(const QString& fo
 
     columns << timeStr;
     columns << fixupFilename(item._originalFile);
-    columns << folder;
+    columns << f->shortGuiPath();
 
     // If the error string is set, it's prefered because it is a useful user message.
     QString message = item._errorString;
@@ -241,6 +246,7 @@ QTreeWidgetItem* ProtocolWidget::createCompletedTreewidgetItem(const QString& fo
     twitem->setToolTip(0, longTimeStr);
     twitem->setToolTip(1, item._file);
     twitem->setToolTip(3, message );
+    twitem->setData(2,  Qt::UserRole, folder);
     return twitem;
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list