Use braced initialiser where possible for folderstatusmodel

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-02-26 17:42:06 +08:00
parent c070ed2b6d
commit e7a99a8e9a

View file

@ -137,23 +137,20 @@ Qt::ItemFlags FolderStatusModel::flags(const QModelIndex &index) const
QVariant FolderStatusModel::data(const QModelIndex &index, int role) const QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
{ {
if (!index.isValid()) if (!index.isValid() || (role == Qt::EditRole))
return QVariant(); return {};
if (role == Qt::EditRole)
return QVariant();
switch (classify(index)) { switch (classify(index)) {
case AddButton: { case AddButton: {
if (role == FolderStatusDelegate::AddButton) { if (role == FolderStatusDelegate::AddButton) {
return QVariant(true); return true;
} else if (role == Qt::ToolTipRole) { } else if (role == Qt::ToolTipRole) {
if (!_accountState->isConnected()) { if (!_accountState->isConnected()) {
return tr("You need to be connected to add a folder"); return tr("You need to be connected to add a folder");
} }
return tr("Click this button to add a folder to synchronize."); return tr("Click this button to add a folder to synchronize.");
} }
return QVariant(); return {};
} }
case SubFolder: { case SubFolder: {
const auto &subfolderInfo = static_cast<SubFolderInfo *>(index.internalPointer())->_subs.at(index.row()); const auto &subfolderInfo = static_cast<SubFolderInfo *>(index.internalPointer())->_subs.at(index.row());
@ -174,7 +171,7 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
if (supportsSelectiveSync) { if (supportsSelectiveSync) {
return subfolderInfo._checked; return subfolderInfo._checked;
} else { } else {
return QVariant(); return {};
} }
case Qt::DecorationRole: { case Qt::DecorationRole: {
if (subfolderInfo._isNonDecryptable && subfolderInfo._checked) { if (subfolderInfo._isNonDecryptable && subfolderInfo._checked) {
@ -216,7 +213,7 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
} }
break; break;
default: default:
return QVariant(); return {};
} }
} }
case RootFolder: case RootFolder:
@ -311,7 +308,7 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
return tr("Synchronizing with local folder"); return tr("Synchronizing with local folder");
} }
} }
return QVariant(); return {};
} }
bool FolderStatusModel::setData(const QModelIndex &index, const QVariant &value, int role) bool FolderStatusModel::setData(const QModelIndex &index, const QVariant &value, int role)
@ -865,9 +862,9 @@ QStringList FolderStatusModel::createBlackList(const FolderStatusModel::SubFolde
{ {
switch (root._checked) { switch (root._checked) {
case Qt::Unchecked: case Qt::Unchecked:
return QStringList(root._path); return {root._path};
case Qt::Checked: case Qt::Checked:
return QStringList(); return {};
case Qt::PartiallyChecked: case Qt::PartiallyChecked:
break; break;
} }