[Pkg-owncloud-commits] [owncloud-client] 160/484: AccountSettings: Display a link for undecided dirs in the sub text.

Sandro Knauß hefee-guest at moszumanska.debian.org
Wed Dec 16 00:37:33 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 1c1ef52cf13165796d2c7becdc6afdb338d8977b
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Wed Oct 7 18:00:21 2015 +0200

    AccountSettings: Display a link for undecided dirs in the sub text.
    
    This only works in case the index is known. If not, no link is
    shown, but we wait for the next update of the model.
---
 src/gui/accountsettings.cpp | 46 ++++++++++++++++++++++++++++-----------------
 1 file changed, 29 insertions(+), 17 deletions(-)

diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp
index 3175f44..d267f3c 100644
--- a/src/gui/accountsettings.cpp
+++ b/src/gui/accountsettings.cpp
@@ -514,26 +514,33 @@ void AccountSettings::slotAccountStateChanged(int state)
 
 void AccountSettings::slotLinkActivated(const QString& link)
 {
-    qDebug() << "xxxx " << link;
-    int row = -1;
-
-    const QStringList li = link.split(QLatin1String("?indx="));
-    bool ok;
+    // Parse folder alias and filename from the link, calculate the index
+    // and select it if it exists.
+    const QStringList li = link.split(QLatin1String("?folder="));
     if( li.count() > 1) {
-        row = li.at(1).toInt(&ok);
-    }
-    if( ok && row > -1 ) {
-        QModelIndex indx = _model->index(row, 0);
+        QString myFolder = li[0];
+        const QString alias = li[1];
+        if(myFolder.endsWith(QLatin1Char('/'))) myFolder.chop(1);
+
+        Folder *f = FolderMan::instance()->folder(alias);
+        QModelIndex folderIndx = _model->indexForPath(f, QString());
+
+        if( !ui->_folderList->isExpanded(folderIndx)) {
+            ui->_folderList->setExpanded(folderIndx, true);
+            return;
+        }
+
+        QModelIndex indx = _model->indexForPath(f, myFolder);
         if( indx.isValid() ) {
-            QItemSelection selects(indx, indx);
             ui->_folderList->setSelectionMode(QAbstractItemView::SingleSelection);
-            ui->_folderList->selectionModel()->setCurrentIndex(indx, QItemSelectionModel::Select);
-            qDebug() << "Setting current index";
+            ui->_folderList->setCurrentIndex(indx);
+            ui->_folderList->scrollTo(indx);
+        } else {
+            qDebug() << "Unable to find a valid index for " << myFolder;
         }
     }
 }
 
-
 AccountSettings::~AccountSettings()
 {
     delete ui;
@@ -542,7 +549,6 @@ AccountSettings::~AccountSettings()
 void AccountSettings::refreshSelectiveSyncStatus()
 {
     bool shouldBeVisible = _model->isDirty();
-    QStringList undecidedFolder;
     for (int i = 0; !shouldBeVisible && i < _model->rowCount(); ++i) {
         auto index = _model->index(i);
         if (ui->_folderList->isExpanded(index) && _model->rowCount(index) > 0) {
@@ -566,9 +572,15 @@ void AccountSettings::refreshSelectiveSyncStatus()
                 msg += QLatin1String(", ");
             }
             QString myFolder = (it);
-            if(myFolder.endsWith(QLatin1Char('/'))) myFolder.chop(1);
-            QString modelIndexStr = QString::number(_model->indexForPath(folder, myFolder).row());
-            msg += QString::fromLatin1("<a href=\"%1?indx=%2\">%1?indx=%2</a>").arg(myFolder).arg(modelIndexStr);
+            if( myFolder.endsWith('/')) {
+                myFolder.chop(1);
+            }
+            QModelIndex theIndx = _model->indexForPath(folder, myFolder);
+            if(theIndx.isValid()) {
+                msg += QString::fromLatin1("<a href=\"%1?folder=%2\">%1</a>").arg(myFolder).arg(folder->alias());
+            } else {
+                msg += myFolder; // no link because we do not know the index yet.
+            }
         }
     }
 

-- 
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