Changeset View
Changeset View
Standalone View
Standalone View
src/file-io/collection.cpp
Show All 19 Lines | |||||
20 | #include "collection_p.h" | 20 | #include "collection_p.h" | ||
21 | #include "components.h" | 21 | #include "components.h" | ||
22 | #include "puzzle.h" | 22 | #include "puzzle.h" | ||
23 | 23 | | |||
24 | #include <QtCore/QFile> | 24 | #include <QtCore/QFile> | ||
25 | #include <QtCore/QFileInfo> | 25 | #include <QtCore/QFileInfo> | ||
26 | #include <QtCore/QFutureWatcher> | 26 | #include <QtCore/QFutureWatcher> | ||
27 | #include <QtCore/QUuid> | 27 | #include <QtCore/QUuid> | ||
28 | #include <QtCore/QStandardPaths> | ||||
28 | #include <KConfig> | 29 | #include <KConfig> | ||
29 | #include <KConfigGroup> | 30 | #include <KConfigGroup> | ||
30 | #include <KLocalizedString> | 31 | #include <KLocalizedString> | ||
31 | #include <KStandardDirs> | | |||
32 | 32 | | |||
33 | //BEGIN Palapeli::Collection::Item | 33 | //BEGIN Palapeli::Collection::Item | ||
34 | 34 | | |||
35 | Palapeli::Collection::Item::Item(Palapeli::Puzzle* puzzle) | 35 | Palapeli::Collection::Item::Item(Palapeli::Puzzle* puzzle) | ||
36 | : m_puzzle(puzzle) | 36 | : m_puzzle(puzzle) | ||
37 | { | 37 | { | ||
38 | //NOTE: Previously, the metadata.modifyProtection flag was used to decide | 38 | //NOTE: Previously, the metadata.modifyProtection flag was used to decide | ||
39 | //whether the puzzle is deletable. The current implementation uses the | 39 | //whether the puzzle is deletable. The current implementation uses the | ||
Show All 37 Lines | |||||
77 | 77 | | |||
78 | static QString readPseudoUrl(const QString& path_, bool local = false) | 78 | static QString readPseudoUrl(const QString& path_, bool local = false) | ||
79 | { | 79 | { | ||
80 | if (path_.startsWith(QLatin1String("palapeli:/"))) | 80 | if (path_.startsWith(QLatin1String("palapeli:/"))) | ||
81 | { | 81 | { | ||
82 | QString path(path_); | 82 | QString path(path_); | ||
83 | path.remove(QRegExp("^palapeli:/*")); | 83 | path.remove(QRegExp("^palapeli:/*")); | ||
84 | if (local) | 84 | if (local) | ||
85 | return KStandardDirs::locateLocal("appdata", path); | 85 | return QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, path); | ||
86 | else | 86 | else | ||
87 | return KStandardDirs::locate("appdata", path); | 87 | return QStandardPaths::locate(QStandardPaths::AppDataLocation, path); | ||
88 | } | 88 | } | ||
89 | else | 89 | else | ||
90 | return path_; | 90 | return path_; | ||
91 | } | 91 | } | ||
92 | 92 | | |||
93 | Palapeli::Collection::Collection() | 93 | Palapeli::Collection::Collection() | ||
94 | : m_config(new KConfig("palapeli-collectionrc", KConfig::CascadeConfig)) | 94 | : m_config(new KConfig("palapeli-collectionrc", KConfig::CascadeConfig)) | ||
95 | , m_group(new KConfigGroup(m_config, "Palapeli Collection")) | 95 | , m_group(new KConfigGroup(m_config, "Palapeli Collection")) | ||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 134 | { | |||
145 | return 0; | 145 | return 0; | ||
146 | } | 146 | } | ||
147 | 147 | | |||
148 | void Palapeli::Collection::importPuzzle(Palapeli::Puzzle* puzzle) | 148 | void Palapeli::Collection::importPuzzle(Palapeli::Puzzle* puzzle) | ||
149 | { | 149 | { | ||
150 | //determine new location | 150 | //determine new location | ||
151 | const QString id = puzzle->identifier(); | 151 | const QString id = puzzle->identifier(); | ||
152 | const QString fileName = QString::fromLatin1("collection/%1.puzzle").arg(id); | 152 | const QString fileName = QString::fromLatin1("collection/%1.puzzle").arg(id); | ||
153 | puzzle->setLocation(KStandardDirs::locateLocal("appdata", fileName)); | 153 | puzzle->setLocation(QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, fileName)); | ||
154 | //store puzzle | 154 | //store puzzle | ||
155 | puzzle->get(Palapeli::PuzzleComponent::ArchiveStorage).waitForFinished(); | 155 | puzzle->get(Palapeli::PuzzleComponent::ArchiveStorage).waitForFinished(); | ||
156 | //create the config group for this puzzle (use pseudo-URL to avoid problems | 156 | //create the config group for this puzzle (use pseudo-URL to avoid problems | ||
157 | //when the configuration directory is moved) | 157 | //when the configuration directory is moved) | ||
158 | KConfigGroup puzzleGroup(m_group, id); | 158 | KConfigGroup puzzleGroup(m_group, id); | ||
159 | puzzleGroup.writeEntry("Location", QString("palapeli:///%1").arg(fileName)); | 159 | puzzleGroup.writeEntry("Location", QString("palapeli:///%1").arg(fileName)); | ||
160 | m_config->sync(); | 160 | m_config->sync(); | ||
161 | //add to the model | 161 | //add to the model | ||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |