Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Paweł Wegner
libcloudstorage
Commits
0b4d610c
Commit
0b4d610c
authored
Jul 13, 2016
by
Paweł Wegner
Browse files
Cloudbrowser: settings in string, not QVariantMap.
parent
a9f6f8e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
examples/cloudbrowser/Window.cpp
View file @
0b4d610c
...
...
@@ -25,6 +25,8 @@
#include
<QDebug>
#include
<QDir>
#include
<QJsonDocument>
#include
<QJsonObject>
#include
<QMetaEnum>
#include
<QMetaObject>
#include
<QQmlContext>
...
...
@@ -97,10 +99,11 @@ void Window::initializeCloud(QString name) {
std
::
cerr
<<
"[DIAG] Trying to authorize with "
<<
settings
.
value
(
name
).
toString
().
toStdString
()
<<
std
::
endl
;
}
ICloudProvider
::
Hints
hints
=
fromQMap
(
settings
.
value
(
name
+
"_hints"
).
toMap
());
cloud_provider_
->
initialize
(
settings
.
value
(
name
).
toString
().
toStdString
(),
make_unique
<
CloudProviderCallback
>
(
this
),
hints
);
QString
json
=
settings
.
value
(
name
+
"_hints"
).
toString
();
QJsonObject
data
=
QJsonDocument
::
fromJson
(
json
.
toLocal8Bit
()).
object
();
cloud_provider_
->
initialize
(
settings
.
value
(
"name"
).
toString
().
toStdString
(),
make_unique
<
CloudProviderCallback
>
(
this
),
fromJson
(
data
));
current_directory_
=
cloud_provider_
->
rootDirectory
();
emit
runListDirectory
();
}
...
...
@@ -161,8 +164,11 @@ void Window::saveCloudAccessToken() {
if
(
cloud_provider_
)
{
clearCurrentDirectoryList
();
QSettings
settings
;
std
::
string
data
=
QJsonDocument
(
toJson
(
cloud_provider_
->
hints
()))
.
toJson
(
QJsonDocument
::
Compact
)
.
toStdString
();
settings
.
setValue
((
cloud_provider_
->
name
()
+
"_hints"
).
c_str
(),
toQMap
(
cloud_provider_
->
hints
()
));
data
.
c_str
(
));
}
}
...
...
@@ -192,16 +198,15 @@ void Window::startDirectoryClear(std::function<void()> f) {
});
}
ICloudProvider
::
Hints
Window
::
fromQMap
(
const
QMap
<
QString
,
QVariant
>&
map
)
const
{
ICloudProvider
::
Hints
result
;
for
(
auto
it
=
map
.
begin
();
it
!=
map
.
end
();
it
++
)
result
[
it
.
key
().
toStdString
()]
=
it
.
value
().
toString
().
toStdString
();
return
result
;
ICloudProvider
::
Hints
Window
::
fromJson
(
const
QJsonObject
&
json
)
const
{
ICloudProvider
::
Hints
hints
;
for
(
QString
key
:
json
.
keys
())
hints
[
key
.
toStdString
()]
=
json
[
key
].
toString
().
toStdString
();
return
hints
;
}
Q
Map
<
QString
,
QVariant
>
Window
::
to
QMap
(
const
ICloudProvider
::
Hints
&
map
)
const
{
Q
Map
<
QString
,
QVariant
>
result
;
Q
JsonObject
Window
::
to
Json
(
const
ICloudProvider
::
Hints
&
map
)
const
{
Q
JsonObject
result
;
for
(
auto
it
=
map
.
begin
();
it
!=
map
.
end
();
it
++
)
result
[
it
->
first
.
c_str
()]
=
it
->
second
.
c_str
();
return
result
;
...
...
examples/cloudbrowser/Window.h
View file @
0b4d610c
...
...
@@ -143,8 +143,8 @@ class Window : public QQuickView {
void
initializeMediaPlayer
();
void
startDirectoryClear
(
std
::
function
<
void
()
>
);
ICloudProvider
::
Hints
from
QMap
(
const
Q
Map
<
QString
,
QVariant
>
&
)
const
;
Q
Map
<
QString
,
QVariant
>
toQMap
(
const
ICloudProvider
::
Hints
&
)
const
;
ICloudProvider
::
Hints
from
Json
(
const
Q
JsonObject
&
)
const
;
Q
JsonObject
toJson
(
const
ICloudProvider
::
Hints
&
)
const
;
ICloudProvider
::
Pointer
cloud_provider_
;
IItem
::
Pointer
current_directory_
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment