[Pkg-owncloud-commits] [owncloud-client] 314/484: ActivityWidget: Take the account state (connected or not) in account.

Sandro Knauß hefee-guest at moszumanska.debian.org
Wed Dec 16 00:37:58 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 731a13cfd133edb2bbae01c4eafaf9e16fb7b5c7
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Thu Nov 12 17:52:00 2015 +0100

    ActivityWidget: Take the account state (connected or not) in account.
    
    Display the activity entries in a different mode if the account is not
    longer connected.
---
 src/gui/activityitemdelegate.cpp | 11 ++++++++++-
 src/gui/activityitemdelegate.h   |  5 ++++-
 src/gui/activitywidget.cpp       | 26 +++++++++++++++++---------
 3 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/src/gui/activityitemdelegate.cpp b/src/gui/activityitemdelegate.cpp
index cbb8513..e0953ee 100644
--- a/src/gui/activityitemdelegate.cpp
+++ b/src/gui/activityitemdelegate.cpp
@@ -89,6 +89,7 @@ void ActivityItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
     QString remoteLink    = qvariant_cast<QString>(index.data(LinkRole));
     QString timeText      = qvariant_cast<QString>(index.data(PointInTimeRole));
     QString accountRole   = qvariant_cast<QString>(index.data(AccountRole));
+    bool    accountOnline = qvariant_cast<bool>   (index.data(AccountConnectedRole));
 
     QRect actionIconRect = option.rect;
     QRect userIconRect   = option.rect;
@@ -132,8 +133,16 @@ void ActivityItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
     if( atPos > -1 )  {
         accountRole.remove(0, atPos+1);
     }
-    const QString timeStr = tr("%1 on %2").arg(timeText).arg(accountRole);
+
+    QString timeStr = tr("%1 on %2").arg(timeText).arg(accountRole);
+    if( !accountOnline ) {
+        QPalette p = option.palette;
+        painter->setBrush(p.brush(QPalette::Inactive, QPalette::WindowText));
+        timeStr.append(" ");
+        timeStr.append(tr("(disconnected)"));
+    }
     const QString elidedTime = fm.elidedText(timeStr, Qt::ElideRight, timeBox.width());
+
     painter->drawText(timeBox, elidedTime);
     painter->restore();
 
diff --git a/src/gui/activityitemdelegate.h b/src/gui/activityitemdelegate.h
index 7ef5cef..82919ee 100644
--- a/src/gui/activityitemdelegate.h
+++ b/src/gui/activityitemdelegate.h
@@ -33,7 +33,9 @@ public:
                     ActionTextRole,
                     PathRole,
                     LinkRole,
-                    PointInTimeRole };
+                    PointInTimeRole,
+                    AccountConnectedRole };
+
     void paint( QPainter*, const QStyleOptionViewItem&, const QModelIndex& ) const Q_DECL_OVERRIDE;
     QSize sizeHint( const QStyleOptionViewItem&, const QModelIndex& ) const Q_DECL_OVERRIDE;
     bool editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option,
@@ -41,6 +43,7 @@ public:
 
     static int rowHeight();
     static int iconHeight();
+
 private:
     static int _margin;
     static int _iconHeight;
diff --git a/src/gui/activitywidget.cpp b/src/gui/activitywidget.cpp
index 9aa5736..2204faa 100644
--- a/src/gui/activitywidget.cpp
+++ b/src/gui/activitywidget.cpp
@@ -65,6 +65,7 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
         return QVariant();
 
     a = _finalList.at(index.row());
+    AccountStatePtr ast = AccountManager::instance()->account(a._accName);
 
     if (role == Qt::EditRole)
         return QVariant();
@@ -72,11 +73,6 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
     switch (role) {
     case Qt::ToolTipRole:
         return QVariant();
-    case Qt::DisplayRole:
-        // return tr("Account %1 at %2: %3").arg(a._accName).arg(a._dateTime.toString(Qt::SystemLocaleShortDate)).arg(a._subject);
-        break;
-    case Qt::DecorationRole:
-        return QVariant();
         break;
     case ActivityItemDelegate::ActionIconRole:
         return QVariant(); // FIXME once the action can be quantified, display on Icon
@@ -88,16 +84,22 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
         return a._subject;
         break;
     case ActivityItemDelegate::PathRole:
-            return a._file;
+        return a._file;
         break;
     case ActivityItemDelegate::LinkRole:
-            return a._link;
+        return a._link;
         break;
     case ActivityItemDelegate::AccountRole:
-            return a._accName;
+        return a._accName;
         break;
     case ActivityItemDelegate::PointInTimeRole:
         return timeSpanFromNow(a._dateTime);
+        break;
+    case ActivityItemDelegate::AccountConnectedRole:
+        return (ast && ast->isConnected());
+        break;
+    default:
+        return QVariant();
 
     }
     return QVariant();
@@ -137,8 +139,11 @@ bool ActivityListModel::canFetchMore(const QModelIndex& ) const
     QMap<AccountState*, ActivityList>::const_iterator i = _activityLists.begin();
     while (i != _activityLists.end()) {
         AccountState *ast = i.key();
+        if( !ast->isConnected() ) {
+            return false;
+        }
         ActivityList activities = i.value();
-        if( ast->isConnected() && activities.count() == 0 &&
+        if( activities.count() == 0 &&
                 ! _currentlyFetching.contains(ast) ) {
             return true;
         }
@@ -150,6 +155,9 @@ bool ActivityListModel::canFetchMore(const QModelIndex& ) const
 
 void ActivityListModel::startFetchJob(AccountState* s)
 {
+    if( !s->isConnected() ) {
+        return;
+    }
     JsonApiJob *job = new JsonApiJob(s->account(), QLatin1String("ocs/v1.php/cloud/activity"), this);
     QObject::connect(job, SIGNAL(jsonRecieved(QVariantMap)), this, SLOT(slotActivitiesReceived(QVariantMap)));
     job->setProperty("AccountStatePtr", QVariant::fromValue<AccountState*>(s));

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