Skip to content

Commit 039efde

Browse files
committed
style(integration): rename from declarativeui to integration.
- remove DeclarativeUi files. - add return default value in switch. - add const. Signed-off-by: Camila Ayres <hello@camilasan.com>
1 parent d1f63ae commit 039efde

15 files changed

Lines changed: 73 additions & 190 deletions

resources.qrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@
6161
<file>src/gui/ConflictItemFileInfo.qml</file>
6262
<file>src/gui/macOS/ui/FileProviderSettings.qml</file>
6363
<file>src/gui/macOS/ui/FileProviderFileDelegate.qml</file>
64-
<file>src/gui/declarativeui/FileActionsWindow.qml</file>
64+
<file>src/gui/integration/FileActionsWindow.qml</file>
6565
</qresource>
6666
</RCC>

src/gui/CMakeLists.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,8 @@ set(client_SRCS
258258
wizard/linklabel.cpp
259259
wizard/wizardproxysettingsdialog.h
260260
wizard/wizardproxysettingsdialog.cpp
261-
declarativeui/declarativeuimodel.h
262-
declarativeui/declarativeuimodel.cpp
263-
declarativeui/declarativeui.h
264-
declarativeui/declarativeui.cpp
265-
declarativeui/fileactionsmodel.h
266-
declarativeui/fileactionsmodel.cpp
261+
integration/fileactionsmodel.h
262+
integration/fileactionsmodel.cpp
267263
)
268264

269265
if (NOT DISABLE_ACCOUNT_MIGRATION)

src/gui/declarativeui/declarativeui.cpp

Lines changed: 0 additions & 68 deletions
This file was deleted.

src/gui/declarativeui/declarativeui.h

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/gui/declarativeui/FileActionsWindow.qml renamed to src/gui/integration/FileActionsWindow.qml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ ApplicationWindow {
160160

161161
Image {
162162
source: "image://svgimage-custom-color/backup.svg/" + palette.windowText
163-
// Layout.preferredWidth: Style.accountAvatarStateIndicatorSize
164-
// Layout.preferredHeight: Style.accountAvatarStateIndicatorSize
165163
Layout.minimumWidth: Style.accountAvatarStateIndicatorSize
166164
Layout.minimumHeight: Style.accountAvatarStateIndicatorSize
167165
fillMode: Image.PreserveAspectFit
File renamed without changes.
File renamed without changes.

src/gui/declarativeui/fileactionsmodel.cpp renamed to src/gui/integration/fileactionsmodel.cpp

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ QVariant FileActionsModel::data(const QModelIndex &index, int role) const
3131
case FileActionMethodRole:
3232
return _fileActions.at(row).method; // GET
3333
case FileActionParamsRole:
34-
return QVariant::fromValue<QList<QueryItem>>(_fileActions.at(row).params);
34+
return QVariant::fromValue<QueryList>(_fileActions.at(row).params);
35+
case FileActionResponseLabelRole:
36+
return _response.label;
37+
case FileActionResponseUrlRole:
38+
return _response.url;
39+
default:
40+
return QVariant();
3541
}
3642

3743
return {};
@@ -54,6 +60,8 @@ QHash<int, QByteArray> FileActionsModel::roleNames() const
5460
roles[FileActionUrlRole] = "url";
5561
roles[FileActionMethodRole] = "method";
5662
roles[FileActionParamsRole] = "params";
63+
roles[FileActionResponseLabelRole] = "responseLabel";
64+
roles[FileActionResponseUrlRole] = "responseUrl";
5765

5866
return roles;
5967
}
@@ -83,7 +91,6 @@ QString FileActionsModel::localPath() const
8391
return _localPath;
8492
}
8593

86-
8794
void FileActionsModel::setLocalPath(const QString &localPath)
8895
{
8996
if (localPath.isEmpty()) {
@@ -168,33 +175,41 @@ void FileActionsModel::setResponse(const Response &response)
168175
void FileActionsModel::parseEndpoints()
169176
{
170177
if (!_accountState->isConnected()) {
171-
qCWarning(lcFileActions) << "The account is not connected" << _accountUrl;
172-
setResponse({ tr("Your account is offline %1.", "account url").arg(_accountUrl), _accountUrl });
178+
qCWarning(lcFileActions) << "The account is not connected"
179+
<< _accountUrl;
180+
setResponse({ tr("Your account is offline %1.", "account url").arg(_accountUrl),
181+
_accountUrl });
173182
return;
174183
}
175184

176185
if (_fileId.isEmpty()) {
177-
qCWarning(lcFileActions) << "The file id is empty, not initialized" << _localPath;
178-
setResponse({ tr("The file id is empty for %1.", "file name").arg(_localPath), _accountUrl });
186+
qCWarning(lcFileActions) << "The file id is empty, not initialized"
187+
<< _localPath;
188+
setResponse({ tr("The file id is empty for %1.", "file name").arg(_localPath),
189+
_accountUrl });
179190
return;
180191
}
181192

182193
if (!_mimeType.isValid()) {
183-
qCWarning(lcFileActions) << "The mime type found for the file is not valid" << _localPath;
184-
setResponse({ tr("The file type for %1 is not valid.", "file name").arg(_localPath), _accountUrl });
194+
qCWarning(lcFileActions) << "The mime type found for the file is not valid"
195+
<< _localPath;
196+
setResponse({ tr("The file type for %1 is not valid.", "file name").arg(_localPath),
197+
_accountUrl });
185198
return;
186199
}
187200

188-
const auto contextMenuList = _accountState->account()->capabilities().contextMenuByMimeType(_mimeType);
189-
//const QList<QVariantMap> contextMenuList;
201+
const auto contextMenuList = _accountState->account()->capabilities().fileActionsByMimeType(_mimeType);
190202
if (contextMenuList.isEmpty()) {
191-
qCWarning(lcFileActions) << "contextMenuByMimeType is empty, nothing was returned by capabilities" << _localPath;
192-
setResponse({ tr("No file actions were returned by the server for %1 files.", "file mymetype").arg(_mimeType.filterString()), _accountUrl });
203+
qCWarning(lcFileActions) << "contextMenuByMimeType is empty, nothing was returned by capabilities"
204+
<< _localPath;
205+
setResponse({ tr("No file actions were returned by the server for %1 files.", "file mymetype")
206+
.arg(_mimeType.filterString()),
207+
_accountUrl });
193208
return;
194209
}
195210

196211
for (const auto &contextMenu : contextMenuList) {
197-
ParamsList queryParams;
212+
QueryList queryList;
198213
const auto paramsMap = contextMenu.value("params").toMap();
199214
for (auto param = paramsMap.cbegin(), end = paramsMap.cend(); param != end; ++param) {
200215
const auto name = param.key();
@@ -208,18 +223,20 @@ void FileActionsModel::parseEndpoints()
208223
}
209224

210225
if (!value.isEmpty()) {
211-
queryParams.append( QueryItem{ name, value } );
226+
queryList.append( QueryItem{ name, value } );
212227
}
213228
}
214229

215230
_fileActions.append({ parseIcon(contextMenu.value("icon").toString()),
216231
contextMenu.value("name").toString(),
217232
contextMenu.value("url").toString(),
218233
contextMenu.value("method").toString(),
219-
queryParams });
234+
queryList });
220235
}
221236

222-
qCDebug(lcFileActions) << "File" << _localPath << "has" << _fileActions.size() << "actions available.";
237+
qCDebug(lcFileActions) << "File" << _localPath << "has"
238+
<< _fileActions.size()
239+
<< "actions available.";
223240
Q_EMIT fileActionModelChanged();
224241
}
225242

@@ -242,7 +259,8 @@ QString FileActionsModel::parseIcon(const QString &icon) const
242259
void FileActionsModel::createRequest(const int row)
243260
{
244261
if (!_accountState) {
245-
qCWarning(lcFileActions) << "No account state for" << _localPath;
262+
qCWarning(lcFileActions) << "No account state for"
263+
<< _localPath;
246264
return;
247265
}
248266

@@ -252,7 +270,7 @@ void FileActionsModel::createRequest(const int row)
252270
this);
253271
connect(job, &JsonApiJob::jsonReceived,
254272
this, &FileActionsModel::processRequest);
255-
for (const auto &param : _fileActions.at(row).params) {
273+
for (const auto &param : std::as_const(_fileActions.at(row).params)) {
256274
QUrlQuery query;
257275
query.addQueryItem(param.name, param.value);
258276
job->addQueryParams(query);
Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ class FileActionsModel : public QAbstractListModel {
3434
FileActionNameRole,
3535
FileActionUrlRole,
3636
FileActionMethodRole,
37-
FileActionParamsRole
37+
FileActionParamsRole,
38+
FileActionResponseLabelRole,
39+
FileActionResponseUrlRole
3840
};
3941
Q_ENUM(DataRole)
4042

@@ -47,7 +49,16 @@ class FileActionsModel : public QAbstractListModel {
4749
QString name;
4850
QByteArray value;
4951
};
50-
using ParamsList = QList<QueryItem>;
52+
using QueryList = QList<QueryItem>;
53+
54+
struct FileAction {
55+
QString icon;
56+
QString name;
57+
QString url;
58+
QString method;
59+
QueryList params;
60+
};
61+
using ActionList = QList<FileAction>;
5162

5263
[[nodiscard]] AccountState *accountState() const;
5364
void setAccountState(AccountState *accountState);
@@ -84,14 +95,7 @@ public slots:
8495

8596
private:
8697
Response _response;
87-
struct FileAction {
88-
QString icon;
89-
QString name;
90-
QString url;
91-
QString method;
92-
ParamsList params;
93-
};
94-
QList<FileAction> _fileActions;
98+
ActionList _fileActions;
9599
AccountState *_accountState;
96100
QString _localPath;
97101
QByteArray _fileId;
@@ -107,5 +111,5 @@ public slots:
107111
};
108112
}
109113

110-
Q_DECLARE_METATYPE(OCC::FileActionsModel::ParamsList)
111-
Q_DECLARE_METATYPE(OCC::FileActionsModel::QueryItem)
114+
Q_DECLARE_METATYPE(OCC::FileActionsModel::QueryList)
115+
Q_DECLARE_METATYPE(OCC::FileActionsModel::ActionList)

src/gui/owncloudgui.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "tray/sortedactivitylistmodel.h"
3434
#include "tray/syncstatussummary.h"
3535
#include "tray/unifiedsearchresultslistmodel.h"
36-
#include "declarativeui/fileactionsmodel.h"
36+
#include "integration/fileactionsmodel.h"
3737
#include "filesystem.h"
3838

3939
#ifdef WITH_LIBCLOUDPROVIDERS

0 commit comments

Comments
 (0)