[Pkg-owncloud-commits] [owncloud-client] 146/470: ActivityListModel: Code cleanups

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu May 12 16:24:56 UTC 2016


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 9d219a18f36b2d1d4ab39b1a8eef8a29306708c7
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Mon Mar 14 15:40:39 2016 +0100

    ActivityListModel: Code cleanups
    
    based on review feedback.
---
 src/gui/activitylistmodel.cpp         | 18 ++++++------------
 src/gui/activitywidget.cpp            | 13 ++++++-------
 src/gui/notificationwidget.cpp        |  2 +-
 src/gui/servernotificationhandler.cpp |  7 ++-----
 4 files changed, 15 insertions(+), 25 deletions(-)

diff --git a/src/gui/activitylistmodel.cpp b/src/gui/activitylistmodel.cpp
index 8fa3ff4..a16eafe 100644
--- a/src/gui/activitylistmodel.cpp
+++ b/src/gui/activitylistmodel.cpp
@@ -44,9 +44,6 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
     AccountStatePtr ast = AccountManager::instance()->account(a._accName);
     QStringList list;
 
-    if (role == Qt::EditRole)
-        return QVariant();
-
     switch (role) {
     case ActivityItemDelegate::PathRole:
         list = FolderMan::instance()->findFileInLocalFolders(a._file, ast->account());
@@ -134,19 +131,17 @@ void ActivityListModel::startFetchJob(AccountState* s)
     job->addQueryParams(params);
 
     _currentlyFetching.insert(s);
-    qDebug() << "Start fetching activities for " << s->account()->displayName();
+    qDebug() << Q_FUNC_INFO << "Start fetching activities for " << s->account()->displayName();
     job->start();
 }
 
 void ActivityListModel::slotActivitiesReceived(const QVariantMap& json, int statusCode)
 {
     auto activities = json.value("ocs").toMap().value("data").toList();
-    // qDebug() << "*** activities" << activities;
 
     ActivityList list;
     AccountState* ast = qvariant_cast<AccountState*>(sender()->property("AccountStatePtr"));
     _currentlyFetching.remove(ast);
-    list.setAccountName( ast->account()->displayName());
 
     foreach( auto activ, activities ) {
         auto json = activ.toMap();
@@ -182,7 +177,11 @@ void ActivityListModel::combineActivityLists()
 
     std::sort( resultList.begin(), resultList.end() );
 
-    beginInsertRows(QModelIndex(), 0, resultList.count()-1);
+    beginRemoveRows(QModelIndex(), 0, _finalList.count() );
+    _finalList.clear();
+    endRemoveRows();
+
+    beginInsertRows(QModelIndex(), 0, resultList.count());
     _finalList = resultList;
     endInsertRows();
 }
@@ -192,13 +191,9 @@ void ActivityListModel::fetchMore(const QModelIndex &)
     QList<AccountStatePtr> accounts = AccountManager::instance()->accounts();
 
     foreach (AccountStatePtr asp, accounts) {
-        bool newItem = false;
 
         if( !_activityLists.contains(asp.data()) && asp->isConnected() ) {
             _activityLists[asp.data()] = ActivityList();
-            newItem = true;
-        }
-        if( newItem ) {
             startFetchJob(asp.data());
         }
     }
@@ -207,7 +202,6 @@ void ActivityListModel::fetchMore(const QModelIndex &)
 void ActivityListModel::slotRefreshActivity(AccountState *ast)
 {
     if(ast && _activityLists.contains(ast)) {
-        qDebug() << "**** Refreshing Activity list for" << ast->account()->displayName();
         _activityLists.remove(ast);
     }
     startFetchJob(ast);
diff --git a/src/gui/activitywidget.cpp b/src/gui/activitywidget.cpp
index decefdb..463d2fe 100644
--- a/src/gui/activitywidget.cpp
+++ b/src/gui/activitywidget.cpp
@@ -110,7 +110,7 @@ void ActivityWidget::slotRefresh(AccountState *ptr)
 
         snh->slotFetchNotifications(ptr);
     } else {
-        qDebug() << "========> notification request counter not zero.";
+        qDebug() << Q_FUNC_INFO << "========> notification request counter not zero.";
     }
 }
 
@@ -204,7 +204,7 @@ void ActivityWidget::storeActivityList( QTextStream& ts )
 
 void ActivityWidget::slotOpenFile(QModelIndex indx)
 {
-    qDebug() << indx.isValid() << indx.data(ActivityItemDelegate::PathRole).toString() << QFile::exists(indx.data(ActivityItemDelegate::PathRole).toString());
+    qDebug() << Q_FUNC_INFO << indx.isValid() << indx.data(ActivityItemDelegate::PathRole).toString() << QFile::exists(indx.data(ActivityItemDelegate::PathRole).toString());
     if( indx.isValid() ) {
         QString fullPath = indx.data(ActivityItemDelegate::PathRole).toString();
 
@@ -299,7 +299,7 @@ void ActivityWidget::slotBuildNotificationDisplay(const ActivityList& list)
 
 void ActivityWidget::slotSendNotificationRequest(const QString& accountName, const QString& link, const QString& verb)
 {
-    qDebug() << "Server Notification Request " << verb << link << "on account" << accountName;
+    qDebug() << Q_FUNC_INFO << "Server Notification Request " << verb << link << "on account" << accountName;
     NotificationWidget *theSender = qobject_cast<NotificationWidget*>(sender());
 
     const QStringList validVerbs = QStringList() << "GET" << "PUT" << "POST" << "DELETE";
@@ -322,7 +322,7 @@ void ActivityWidget::slotSendNotificationRequest(const QString& accountName, con
             _notificationRequests++;
         }
     } else {
-        qDebug() << "Notification Links: Invalid verb:" << verb;
+        qDebug() << Q_FUNC_INFO << "Notification Links: Invalid verb:" << verb;
     }
 }
 
@@ -347,7 +347,7 @@ void ActivityWidget::slotNotifyNetworkError( QNetworkReply *reply)
     }
 
     endNotificationRequest(job->widget(), resultCode);
-    qDebug() << "Server notify job failed.";
+    qDebug() << Q_FUNC_INFO << "Server notify job failed with code " << resultCode;
 
 }
 
@@ -360,7 +360,7 @@ void ActivityWidget::slotNotifyServerFinished( const QString& reply, int replyCo
 
     endNotificationRequest(job->widget(), replyCode);
     // FIXME: remove the  widget after a couple of seconds
-    qDebug() << "Server Notification reply code"<< replyCode << reply;
+    qDebug() << Q_FUNC_INFO << "Server Notification reply code"<< replyCode << reply;
 }
 
 /* ==================================================================== */
@@ -453,7 +453,6 @@ void ActivitySettings::slotRemoveAccount( AccountState *ptr )
 void ActivitySettings::slotRefresh( AccountState* ptr )
 {
     if( ptr && ptr->isConnected() && isVisible()) {
-        qDebug() << "Refreshing Activity list for " << ptr->account()->displayName();
         _progressIndicator->startAnimation();
         _activityWidget->slotRefresh(ptr);
     }
diff --git a/src/gui/notificationwidget.cpp b/src/gui/notificationwidget.cpp
index db94138..4b1fb77 100644
--- a/src/gui/notificationwidget.cpp
+++ b/src/gui/notificationwidget.cpp
@@ -80,7 +80,7 @@ void NotificationWidget::slotButtonClicked()
         // if the button was found, the link must be called
         if( index > -1 && index < _myActivity._links.count() ) {
             ActivityLink triggeredLink = _myActivity._links.at(index);
-            qDebug() << "Notification Link: "<< triggeredLink._verb << triggeredLink._link;
+            qDebug() << Q_FUNC_INFO << "Notification Link: "<< triggeredLink._verb << triggeredLink._link;
             _progressIndi->startAnimation();
             emit sendNotificationRequest( _accountName, triggeredLink._link, triggeredLink._verb );
         }
diff --git a/src/gui/servernotificationhandler.cpp b/src/gui/servernotificationhandler.cpp
index bfd06d7..94ff131 100644
--- a/src/gui/servernotificationhandler.cpp
+++ b/src/gui/servernotificationhandler.cpp
@@ -37,7 +37,7 @@ void ServerNotificationHandler::slotFetchNotifications(AccountState *ptr)
     // not yet valid, its assumed that notifications are available.
     if( ptr->account() && ptr->account()->capabilities().isValid() ) {
         if( ! ptr->account()->capabilities().notificationsAvailable() ) {
-            qDebug() << "Account" << ptr->account()->displayName() << "does not have notifications enabled.";
+            qDebug() << Q_FUNC_INFO << "Account" << ptr->account()->displayName() << "does not have notifications enabled.";
             return;
         }
     }
@@ -48,14 +48,13 @@ void ServerNotificationHandler::slotFetchNotifications(AccountState *ptr)
                      this, SLOT(slotNotificationsReceived(QVariantMap, int)));
     _notificationJob->setProperty("AccountStatePtr", QVariant::fromValue<AccountState*>(ptr));
 
-    qDebug() << "Start fetching notifications for " << ptr->account()->displayName();
     _notificationJob->start();
 }
 
 void ServerNotificationHandler::slotNotificationsReceived(const QVariantMap& json, int statusCode)
 {
     if( statusCode != 200 ) {
-        qDebug() << "Failed for Notifications";
+        qDebug() << Q_FUNC_INFO << "Notifications failed with status code " << statusCode;
         return;
     }
 
@@ -63,8 +62,6 @@ void ServerNotificationHandler::slotNotificationsReceived(const QVariantMap& jso
 
     AccountState* ai = qvariant_cast<AccountState*>(sender()->property("AccountStatePtr"));
 
-    // qDebug() << "Notifications for " << ai->account()->displayName() << notifies;
-
     ActivityList list;
 
     foreach( auto element, notifies ) {

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