[Pkg-owncloud-commits] [owncloud-client] 60/498: Account settings: show the folder of the right account
Sandro Knauß
hefee-guest at moszumanska.debian.org
Tue Aug 11 14:48:34 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 f81918173b1bf7d2c513e7344e19c1bc0404f7b9
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Mon Apr 27 19:09:48 2015 +0200
Account settings: show the folder of the right account
---
src/gui/folderstatusmodel.cpp | 46 +++++++++++++++++++++----------------------
src/gui/folderstatusmodel.h | 5 +++--
2 files changed, 25 insertions(+), 26 deletions(-)
diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp
index 0c38540..1c023f7 100644
--- a/src/gui/folderstatusmodel.cpp
+++ b/src/gui/folderstatusmodel.cpp
@@ -14,6 +14,7 @@
#include "folderstatusmodel.h"
#include "folderman.h"
+#include "accountstate.h"
#include "utility.h"
#include <theme.h>
#include <account.h>
@@ -45,6 +46,19 @@ void FolderStatusModel::setAccount(const AccountPtr& account)
_dirty = false;
_folders.clear();
_account = account;
+
+ auto folders = FolderMan::instance()->map();
+ foreach (auto f, folders) {
+ if (f->accountState()->account() != account)
+ continue;
+ SubFolderInfo info;
+ info._pathIdx << _folders.size();
+ info._name = f->alias();
+ info._path = "/";
+ info._folder = f;
+ _folders << info;
+ }
+
endResetModel();
}
@@ -93,8 +107,7 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
break;
}
- auto folderList = FolderMan::instance()->map().values();
- auto f = folderList.at(index.row());
+ auto f = _folders.at(index.row())._folder;
if (!f)
return QVariant();
@@ -221,7 +234,7 @@ int FolderStatusModel::columnCount(const QModelIndex&) const
int FolderStatusModel::rowCount(const QModelIndex& parent) const
{
if (!parent.isValid()) {
- return FolderMan::instance()->map().count() + 1;
+ return _folders.count() + 1;
}
auto info = infoForIndex(parent);
@@ -235,9 +248,7 @@ FolderStatusModel::ItemType FolderStatusModel::classify(const QModelIndex& index
if (index.internalPointer()) {
return SubFolder;
}
- //FIXME:
- auto folderList = FolderMan::instance()->map(); //.values();
- if (index.row() < folderList.count()) {
+ if (index.row() < _folders.count()) {
return RootFolder;
}
return AddButton;
@@ -250,22 +261,11 @@ FolderStatusModel::SubFolderInfo* FolderStatusModel::infoForIndex(const QModelIn
if (auto parentInfo = index.internalPointer()) {
return &static_cast<SubFolderInfo*>(parentInfo)->_subs[index.row()];
} else {
- auto folders = FolderMan::instance()->map(); // FIXME
- if (index.row() >= folders.count()) {
+ if (index.row() >= _folders.count()) {
// AddButton
return 0;
}
- if (_folders.size() <= index.row()) {
- _folders.resize(index.row() + 1);
- }
- auto info = &_folders[index.row()];
- if (info->_pathIdx.isEmpty()) {
- info->_pathIdx << index.row();
- info->_name = folders.values().at(index.row())->alias();
- info->_path = "/";
- info->_folder = folders.values().at(index.row());
- }
- return info;
+ return const_cast<SubFolderInfo *>(&_folders[index.row()]);
}
}
@@ -404,7 +404,7 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list_)
if (parentInfo->_checked == Qt::Unchecked) {
newInfo._checked = Qt::Unchecked;
} else {
- auto *f = FolderMan::instance()->map().values().at(parentInfo->_pathIdx.first());
+ auto *f = _folders.at(parentInfo->_pathIdx.first())._folder;
foreach(const QString &str , f->selectiveSyncBlackList()) {
if (str == path || str == QLatin1String("/")) {
newInfo._checked = Qt::Unchecked;
@@ -464,12 +464,10 @@ void FolderStatusModel::slotApplySelectiveSync()
{
if (!_dirty)
return;
- auto folderList = FolderMan::instance()->map().values(); //FIXME
- for (int i = 0; i < folderList.count(); ++i) {
- if (i >= _folders.count()) break;
+ for (int i = 0; i < _folders.count(); ++i) {
if (!_folders[i]._fetched) continue;
- auto folder = folderList.at(i);
+ auto folder = _folders.at(i)._folder;
auto oldBlackList = folder->selectiveSyncBlackList();
QStringList blackList = createBlackList(&_folders[i], oldBlackList);
diff --git a/src/gui/folderstatusmodel.h b/src/gui/folderstatusmodel.h
index 804f1f0..9658e47 100644
--- a/src/gui/folderstatusmodel.h
+++ b/src/gui/folderstatusmodel.h
@@ -59,12 +59,13 @@ public:
Folder *_folder;
};
- mutable QVector<SubFolderInfo> _folders;
+ QVector<SubFolderInfo> _folders;
enum ItemType { RootFolder, SubFolder, AddButton/*, SelectiveSyncText*/ };
ItemType classify(const QModelIndex &index) const;
SubFolderInfo *infoForIndex(const QModelIndex &index) const;
+ // If the selective sync check boxes were changed
bool isDirty() { return _dirty; }
struct ProgressInfo {
@@ -89,7 +90,7 @@ private:
QStringList createBlackList(OCC::FolderStatusModel::SubFolderInfo* root,
const QStringList& oldBlackList) const;
AccountPtr _account;
- bool _dirty = false;
+ bool _dirty = false; // If the selective sync checkboxes were changed
signals:
void dirtyChanged();
--
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