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)
74 Q_PROPERTY(QStringList activeTasks READ activeTasks NOTIFY activeTasksChanged DESIGNABLE false)
81 typedef qSlicerExtensionsManagerModelPrivate
Pimpl;
104 int serverAPI()
const;
109 static QString serverAPIToString(
int serverAPI);
114 static int serverAPIFromString(
const QString& str);
122 Q_INVOKABLE QUrl serverUrl()
const;
130 Q_INVOKABLE QUrl frontendServerUrl()
const;
133 Q_INVOKABLE QUrl extensionsListUrl()
const;
135 Q_INVOKABLE QString extensionsInstallPath()
const;
137 Q_INVOKABLE QString extensionInstallPath(
const QString& extensionName)
const;
139 Q_INVOKABLE QStringList extensionModulePaths(
const QString& extensionName)
const;
141 Q_INVOKABLE QString extensionDescriptionFile(
const QString& extensionName)
const;
143 void setNewExtensionEnabledByDefault(
bool value);
144 bool newExtensionEnabledByDefault()
const;
146 bool autoUpdateCheck()
const;
147 bool autoUpdateInstall()
const;
148 bool autoInstallDependencies()
const;
152 bool interactive()
const;
160 Q_INVOKABLE ExtensionMetadataType extensionMetadata(
const QString& extensionName,
int source = MetadataAll)
const;
162 Q_INVOKABLE QString extensionDescription(
const QString& extensionName)
const;
166 int managedExtensionsCount()
const;
169 QStringList managedExtensions()
const;
172 bool isExtensionLoaded(
const QString& extensionName)
const;
176 Q_INVOKABLE
bool isExtensionInstalled(
const QString& extensionName)
const;
180 int installedExtensionsCount()
const;
184 int numberOfInstalledExtensions()
const;
188 QStringList installedExtensions()
const;
193 Q_INVOKABLE
bool isExtensionBookmarked(
const QString& extensionName)
const;
197 Q_INVOKABLE
bool isExtensionEnabled(
const QString& extensionName)
const;
203 QStringList scheduledForUpdateExtensions()
const;
211 Q_INVOKABLE
bool isExtensionUpdateAvailable(
const QString& extensionName)
const;
215 QStringList availableUpdateExtensions()
const;
222 Q_INVOKABLE
bool isExtensionScheduledForUpdate(
const QString& extensionName)
const;
226 QStringList scheduledForUninstallExtensions()
const;
230 Q_INVOKABLE
bool isExtensionScheduledForUninstall(
const QString& extensionName)
const;
234 QStringList bookmarkedExtensions()
const;
238 QStringList enabledExtensions()
const;
243 QString extensionsSettingsFilePath()
const;
244 void setExtensionsSettingsFilePath(
const QString& extensionsSettingsFilePath);
249 QString slicerRevision()
const;
250 void setSlicerRevision(
const QString& revision);
255 QString slicerOs()
const;
256 void setSlicerOs(
const QString& os);
261 QString slicerArch()
const;
262 void setSlicerArch(
const QString& arch);
271 void setSlicerRequirements(
const QString& revision,
const QString& os,
const QString& arch);
273 QString slicerVersion()
const;
274 void setSlicerVersion(
const QString&
version);
280 Q_INVOKABLE QStringList isExtensionCompatible(
const QString& extensionName,
const QString& slicerRevision,
281 const QString& slicerOs,
const QString& slicerArch)
const;
289 Q_INVOKABLE QStringList isExtensionCompatible(
const QString& extensionName)
const;
298 Q_INVOKABLE
bool installExtension(
const QString &archiveFile,
bool installDependencies =
true,
bool waitForCompletion =
false);
307 Q_INVOKABLE
bool installExtension(
const QString& extensionName,
308 ExtensionMetadataType extensionMetadata,
309 const QString &archiveFile,
bool installDependencies =
true,
310 bool waitForCompletion =
false);
317 bool uninstallExtension(
const QString& extensionName);
320 Q_INVOKABLE
bool extractExtensionArchive(
const QString& extensionName,
321 const QString& archiveFile,
322 const QString &destinationPath);
325 Q_INVOKABLE
const QStandardItemModel * model()
const;
329 QDateTime lastUpdateTimeExtensionsMetadataFromServer();
332 QStringList activeTasks()
const;
336 static QHash<QString, QString> serverToExtensionDescriptionKey(
int serverAPI);
340 static ExtensionMetadataType convertExtensionMetadata(
const ExtensionMetadataType &extensionMetadata,
int serverAPI);
344 static QStringList serverKeysToIgnore(
int serverAPI);
348 static ExtensionMetadataType filterExtensionMetadata(
const ExtensionMetadataType &extensionMetadata,
int serverAPI);
350 static QStringList readArrayValues(QSettings& settings,
351 const QString& arrayName,
const QString fieldName);
353 static void writeArrayValues(QSettings& settings,
const QStringList& values,
354 const QString& arrayName,
const QString fieldName);
356 static bool writeExtensionDescriptionFile(
const QString& file,
357 const ExtensionMetadataType& metadata);
359 static ExtensionMetadataType parseExtensionDescriptionFile(
const QString& file);
365 void setExtensionBookmarked(
const QString& extensionName,
bool value);
370 void setExtensionEnabled(
const QString& extensionName,
bool value);
375 bool downloadAndInstallExtension(
const QString& extensionId,
bool installDependencies =
true,
bool waitForCompletion =
false);
381 bool downloadAndInstallExtensionByName(
const QString& extensionName,
bool installDependencies =
true,
bool waitForCompletion =
false);
388 bool scheduleExtensionForUninstall(
const QString& extensionName);
393 bool cancelExtensionScheduledForUninstall(
const QString& extensionName);
402 bool updateExtensionsMetadataFromServer(
bool force =
false,
bool waitForCompletion =
false);
407 void checkForExtensionsUpdates();
415 bool scheduleExtensionForUpdate(
const QString& extensionName);
420 bool cancelExtensionScheduledForUpdate(
const QString& extensionName);
430 bool updateScheduledExtensions(QStringList &updatedExtensions);
437 bool updateScheduledExtensions();
447 bool uninstallScheduledExtensions(QStringList &uninstalledExtensions);
454 bool uninstallScheduledExtensions();
456 void identifyIncompatibleExtensions();
458 bool exportExtensionList(QString& exportFilePath);
460 QStringList checkInstallPrerequisites()
const;
466 void aboutToLoadExtensions();
471 void setAutoUpdateCheck(
bool enable);
472 void setAutoUpdateInstall(
bool enable);
473 void setAutoInstallDependencies(
bool enable);
474 void setInteractive(
bool value);
479 Q_INVOKABLE
bool waitForAllTasksCompletion(
int timeoutMsec = -1)
const;
483 void downloadStarted(QNetworkReply * reply);
485 void downloadFinished(QNetworkReply * reply);
487 void updateDownloadProgress(
const QString& extensionName,
488 qint64 received, qint64 total);
493 void updateExtensionsMetadataFromServerCompleted(
bool success);
495 void extensionUpdateAvailable(
const QString& extensionName);
498 void extensionUpdatesAvailable(
bool available);
500 void extensionInstalled(
const QString& extensionName);
502 void extensionUpdated(
const QString& extensionName);
505 void extensionMetadataUpdated(
const QString& extensionName);
507 void extensionScheduledForUninstall(
const QString& extensionName);
509 void extensionCancelledScheduleForUninstall(
const QString& extensionName);
511 void extensionScheduledForUpdate(
const QString& extensionName);
513 void extensionCancelledScheduleForUpdate(
const QString& extensionName);
515 void extensionUninstalled(
const QString& extensionName);
518 void extensionBookmarkedChanged(
const QString& extensionName,
bool value);
520 void extensionEnabledChanged(
const QString& extensionName,
bool value);
522 void extensionIdentifedAsIncompatible(
const QString& extensionName);
524 void newExtensionEnabledByDefaultChanged(
bool value);
526 void slicerRequirementsChanged(
const QString& revision,
const QString& os,
const QString& arch);
527 void slicerArchChanged(
const QString& slicerArch);
528 void slicerOsChanged(
const QString& slicerOs);
529 void slicerRevisionChanged(
const QString& slicerRevision);
531 void interactiveChanged(
bool interactive);
533 void slicerVersionChanged(
const QString& slicerVersion);
535 void messageLogged(
const QString& text, ctkErrorLogLevel::LogLevels level)
const;
537 void installDownloadProgress(
const QString& extensionName, qint64 received, qint64 total);
539 void extensionsSettingsFilePathChanged(
const QString& extensionsSettingsFilePath);
542 void autoUpdateSettingsChanged();
545 void activeTasksChanged();
558 qint64 received, qint64 total);
560 bool onExtensionsMetadataFromServerQueryFinished(
const QUuid& requestId);
563 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)