21 #ifndef __qSlicerExtensionsManagerModel_h 22 #define __qSlicerExtensionsManagerModel_h 26 #include <QStringList> 30 #include <QVariantMap> 33 #include <ctkErrorLogModel.h> 36 #include "qSlicerBaseQTCoreExport.h" 40 class qSlicerExtensionsManagerModelPrivate;
41 class QStandardItemModel;
50 Q_PROPERTY(
int numberOfInstalledExtensions READ numberOfInstalledExtensions NOTIFY modelUpdated)
51 Q_PROPERTY(
int installedExtensionsCount READ installedExtensionsCount NOTIFY modelUpdated)
53 Q_PROPERTY(
int managedExtensionsCount READ managedExtensionsCount NOTIFY modelUpdated)
55 Q_PROPERTY(QStringList managedExtensions READ managedExtensions NOTIFY modelUpdated)
57 Q_PROPERTY(QStringList bookmarkedExtensions READ bookmarkedExtensions NOTIFY modelUpdated)
58 Q_PROPERTY(QStringList installedExtensions READ installedExtensions NOTIFY modelUpdated)
59 Q_PROPERTY(QStringList enabledExtensions READ enabledExtensions NOTIFY modelUpdated)
61 Q_PROPERTY(QStringList availableUpdateExtensions READ availableUpdateExtensions NOTIFY modelUpdated)
62 Q_PROPERTY(
bool newExtensionEnabledByDefault READ newExtensionEnabledByDefault WRITE setNewExtensionEnabledByDefault NOTIFY newExtensionEnabledByDefaultChanged)
63 Q_PROPERTY(
bool interactive READ interactive WRITE setInteractive NOTIFY interactiveChanged)
64 Q_PROPERTY(QString extensionsSettingsFilePath READ extensionsSettingsFilePath WRITE setExtensionsSettingsFilePath NOTIFY extensionsSettingsFilePathChanged)
65 Q_PROPERTY(QString slicerRevision READ slicerRevision WRITE setSlicerRevision NOTIFY slicerRevisionChanged)
66 Q_PROPERTY(QString slicerOs READ slicerOs WRITE setSlicerOs NOTIFY slicerOsChanged)
67 Q_PROPERTY(QString slicerArch READ slicerArch WRITE setSlicerArch NOTIFY slicerArchChanged)
69 Q_PROPERTY(
bool autoUpdateCheck READ autoUpdateCheck WRITE setAutoUpdateCheck NOTIFY autoUpdateSettingsChanged)
71 Q_PROPERTY(
bool autoUpdateInstall READ autoUpdateInstall WRITE setAutoUpdateInstall NOTIFY autoUpdateSettingsChanged)
73 Q_PROPERTY(
bool autoInstallDependencies READ autoInstallDependencies WRITE setAutoInstallDependencies NOTIFY autoUpdateSettingsChanged)
80 typedef qSlicerExtensionsManagerModelPrivate
Pimpl;
103 int serverAPI()
const;
108 static QString serverAPIToString(
int serverAPI);
113 static int serverAPIFromString(
const QString& str);
121 Q_INVOKABLE QUrl serverUrl()
const;
129 Q_INVOKABLE QUrl frontendServerUrl()
const;
132 Q_INVOKABLE QUrl extensionsListUrl()
const;
134 Q_INVOKABLE QString extensionsInstallPath()
const;
136 Q_INVOKABLE QString extensionInstallPath(
const QString& extensionName)
const;
138 Q_INVOKABLE QStringList extensionModulePaths(
const QString& extensionName)
const;
140 Q_INVOKABLE QString extensionDescriptionFile(
const QString& extensionName)
const;
142 void setNewExtensionEnabledByDefault(
bool value);
143 bool newExtensionEnabledByDefault()
const;
145 bool autoUpdateCheck()
const;
146 bool autoUpdateInstall()
const;
147 bool autoInstallDependencies()
const;
151 bool interactive()
const;
159 Q_INVOKABLE ExtensionMetadataType extensionMetadata(
const QString& extensionName,
int source = MetadataAll)
const;
161 Q_INVOKABLE QString extensionDescription(
const QString& extensionName)
const;
165 int managedExtensionsCount()
const;
168 QStringList managedExtensions()
const;
171 bool isExtensionLoaded(
const QString& extensionName)
const;
175 Q_INVOKABLE
bool isExtensionInstalled(
const QString& extensionName)
const;
179 int installedExtensionsCount()
const;
183 int numberOfInstalledExtensions()
const;
187 QStringList installedExtensions()
const;
192 Q_INVOKABLE
bool isExtensionBookmarked(
const QString& extensionName)
const;
196 Q_INVOKABLE
bool isExtensionEnabled(
const QString& extensionName)
const;
202 QStringList scheduledForUpdateExtensions()
const;
210 Q_INVOKABLE
bool isExtensionUpdateAvailable(
const QString& extensionName)
const;
214 QStringList availableUpdateExtensions()
const;
221 Q_INVOKABLE
bool isExtensionScheduledForUpdate(
const QString& extensionName)
const;
225 QStringList scheduledForUninstallExtensions()
const;
229 Q_INVOKABLE
bool isExtensionScheduledForUninstall(
const QString& extensionName)
const;
233 QStringList bookmarkedExtensions()
const;
237 QStringList enabledExtensions()
const;
242 QString extensionsSettingsFilePath()
const;
243 void setExtensionsSettingsFilePath(
const QString& extensionsSettingsFilePath);
248 QString slicerRevision()
const;
249 void setSlicerRevision(
const QString& revision);
254 QString slicerOs()
const;
255 void setSlicerOs(
const QString& os);
260 QString slicerArch()
const;
261 void setSlicerArch(
const QString& arch);
270 void setSlicerRequirements(
const QString& revision,
const QString& os,
const QString& arch);
272 QString slicerVersion()
const;
273 void setSlicerVersion(
const QString&
version);
279 Q_INVOKABLE QStringList isExtensionCompatible(
const QString& extensionName,
const QString& slicerRevision,
280 const QString& slicerOs,
const QString& slicerArch)
const;
288 Q_INVOKABLE QStringList isExtensionCompatible(
const QString& extensionName)
const;
297 Q_INVOKABLE
bool installExtension(
const QString &archiveFile,
bool installDependencies =
true);
306 Q_INVOKABLE
bool installExtension(
const QString& extensionName,
307 ExtensionMetadataType extensionMetadata,
308 const QString &archiveFile,
bool installDependencies =
true);
315 bool uninstallExtension(
const QString& extensionName);
318 Q_INVOKABLE
bool extractExtensionArchive(
const QString& extensionName,
319 const QString& archiveFile,
320 const QString &destinationPath);
323 Q_INVOKABLE
const QStandardItemModel * model()
const;
327 QDateTime lastUpdateTimeExtensionsMetadataFromServer();
330 QStringList activeTasks()
const;
334 static QHash<QString, QString> serverToExtensionDescriptionKey(
int serverAPI);
338 static ExtensionMetadataType convertExtensionMetadata(
const ExtensionMetadataType &extensionMetadata,
int serverAPI);
342 static QStringList serverKeysToIgnore(
int serverAPI);
346 static ExtensionMetadataType filterExtensionMetadata(
const ExtensionMetadataType &extensionMetadata,
int serverAPI);
348 static QStringList readArrayValues(QSettings& settings,
349 const QString& arrayName,
const QString fieldName);
351 static void writeArrayValues(QSettings& settings,
const QStringList& values,
352 const QString& arrayName,
const QString fieldName);
354 static bool writeExtensionDescriptionFile(
const QString& file,
355 const ExtensionMetadataType& metadata);
357 static ExtensionMetadataType parseExtensionDescriptionFile(
const QString& file);
363 void setExtensionBookmarked(
const QString& extensionName,
bool value);
368 void setExtensionEnabled(
const QString& extensionName,
bool value);
373 bool downloadAndInstallExtension(
const QString& extensionId,
bool installDependencies=
true);
379 bool downloadAndInstallExtensionByName(
const QString& extensionId,
bool installDependencies=
true);
386 bool scheduleExtensionForUninstall(
const QString& extensionName);
391 bool cancelExtensionScheduledForUninstall(
const QString& extensionName);
400 bool updateExtensionsMetadataFromServer(
bool force=
false,
bool waitForCompletion=
false);
405 void checkForExtensionsUpdates();
413 bool scheduleExtensionForUpdate(
const QString& extensionName);
418 bool cancelExtensionScheduledForUpdate(
const QString& extensionName);
428 bool updateScheduledExtensions(QStringList &updatedExtensions);
435 bool updateScheduledExtensions();
445 bool uninstallScheduledExtensions(QStringList &uninstalledExtensions);
452 bool uninstallScheduledExtensions();
454 void identifyIncompatibleExtensions();
456 bool exportExtensionList(QString& exportFilePath);
458 QStringList checkInstallPrerequisites()
const;
464 void aboutToLoadExtensions();
469 void setAutoUpdateCheck(
bool enable);
470 void setAutoUpdateInstall(
bool enable);
471 void setAutoInstallDependencies(
bool enable);
472 void setInteractive(
bool value);
476 void downloadStarted(QNetworkReply * reply);
478 void downloadFinished(QNetworkReply * reply);
480 void updateDownloadProgress(
const QString& extensionName,
481 qint64 received, qint64 total);
486 void updateExtensionsMetadataFromServerCompleted(
bool success);
488 void extensionUpdateAvailable(
const QString& extensionName);
491 void extensionUpdatesAvailable(
bool available);
493 void extensionInstalled(
const QString& extensionName);
495 void extensionUpdated(
const QString& extensionName);
498 void extensionMetadataUpdated(
const QString& extensionName);
500 void extensionScheduledForUninstall(
const QString& extensionName);
502 void extensionCancelledScheduleForUninstall(
const QString& extensionName);
504 void extensionScheduledForUpdate(
const QString& extensionName);
506 void extensionCancelledScheduleForUpdate(
const QString& extensionName);
508 void extensionUninstalled(
const QString& extensionName);
511 void extensionBookmarkedChanged(
const QString& extensionName,
bool value);
513 void extensionEnabledChanged(
const QString& extensionName,
bool value);
515 void extensionIdentifedAsIncompatible(
const QString& extensionName);
517 void newExtensionEnabledByDefaultChanged(
bool value);
519 void slicerRequirementsChanged(
const QString& revision,
const QString& os,
const QString& arch);
520 void slicerArchChanged(
const QString& slicerArch);
521 void slicerOsChanged(
const QString& slicerOs);
522 void slicerRevisionChanged(
const QString& slicerRevision);
524 void interactiveChanged(
bool interactive);
526 void slicerVersionChanged(
const QString& slicerVersion);
528 void messageLogged(
const QString& text, ctkErrorLogLevel::LogLevels level)
const;
530 void installDownloadProgress(
const QString& extensionName, qint64 received, qint64 total);
532 void extensionsSettingsFilePathChanged(
const QString& extensionsSettingsFilePath);
535 void autoUpdateSettingsChanged();
548 qint64 received, qint64 total);
550 bool onExtensionsMetadataFromServerQueryFinished(
const QUuid& requestId);
553 QScopedPointer<qSlicerExtensionsManagerModelPrivate>
d_ptr;
Q_DECLARE_METATYPE(qSlicerExtensionsManagerModel::ServerAPI)
QScopedPointer< qSlicerExtensionsManagerModelPrivate > d_ptr
QObject Superclass
Superclass typedef.
Class querying and storing extensions data.
qSlicerExtensionsManagerModelPrivate Pimpl
Pimpl typedef.
return local metadata (stored in s4ext files in the extensions folder)