Slicer  4.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qSlicerExtensionsManagerModel.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Copyright (c) Kitware Inc.
6 
7  See COPYRIGHT.txt
8  or http://www.slicer.org/copyright/copyright.txt for details.
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16  This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
17  and was partially funded by NIH grant 3P41RR013218-12S1
18 
19 ==============================================================================*/
20 
21 #ifndef __qSlicerExtensionsManagerModel_h
22 #define __qSlicerExtensionsManagerModel_h
23 
24 // Qt includes
25 #include <QHash>
26 #include <QStringList>
27 #include <QUrl>
28 #include <QSettings>
29 #include <QUuid>
30 #include <QVariantMap>
31 
32 // CTK includes
33 #include <ctkErrorLogModel.h>
34 
35 // QtGUI includes
36 #include "qSlicerBaseQTCoreExport.h"
38 
39 class QNetworkReply;
40 class qSlicerExtensionsManagerModelPrivate;
41 class QStandardItemModel;
42 
43 class Q_SLICER_BASE_QTCORE_EXPORT qSlicerExtensionsManagerModel : public QObject
44 {
45  Q_OBJECT
46  Q_PROPERTY(int numberOfInstalledExtensions READ numberOfInstalledExtensions NOTIFY modelUpdated)
47  Q_PROPERTY(int installedExtensionsCount READ installedExtensionsCount NOTIFY modelUpdated)
48  Q_PROPERTY(QStringList installedExtensions READ installedExtensions NOTIFY modelUpdated)
49  Q_PROPERTY(QStringList enabledExtensions READ enabledExtensions NOTIFY modelUpdated)
50  Q_PROPERTY(bool newExtensionEnabledByDefault READ newExtensionEnabledByDefault WRITE setNewExtensionEnabledByDefault NOTIFY newExtensionEnabledByDefaultChanged)
51  Q_PROPERTY(QString extensionsSettingsFilePath READ extensionsSettingsFilePath WRITE setExtensionsSettingsFilePath NOTIFY extensionsSettingsFilePathChanged)
52  Q_PROPERTY(QString extensionsHistorySettingsFilePath READ extensionsHistorySettingsFilePath WRITE setExtensionsHistorySettingsFilePath NOTIFY extensionsHistorySettingsFilePathChanged)
53  Q_PROPERTY(QString slicerRevision READ slicerRevision WRITE setSlicerRevision NOTIFY slicerRevisionChanged)
54  Q_PROPERTY(QString slicerOs READ slicerOs WRITE setSlicerOs NOTIFY slicerOsChanged)
55  Q_PROPERTY(QString slicerArch READ slicerArch WRITE setSlicerArch NOTIFY slicerArchChanged)
56  Q_PROPERTY(QString slicerVersion READ slicerVersion WRITE setSlicerVersion NOTIFY slicerVersionChanged)
57 public:
59  typedef QObject Superclass;
60 
62  typedef qSlicerExtensionsManagerModelPrivate Pimpl;
63 
66 
68  explicit qSlicerExtensionsManagerModel(QObject* parent = nullptr);
69 
72 
75 
76  Q_INVOKABLE QUrl serverUrl()const;
77  Q_INVOKABLE QUrl serverUrlWithPackagePath()const;
78  Q_INVOKABLE QUrl serverUrlWithExtensionsStorePath()const;
79 
80  Q_INVOKABLE QString extensionsInstallPath()const;
81 
82  Q_INVOKABLE QString extensionInstallPath(const QString& extensionName) const;
83 
84  Q_INVOKABLE QStringList extensionModulePaths(const QString& extensionName)const;
85 
86  Q_INVOKABLE QString extensionDescriptionFile(const QString& extensionName) const;
87 
88  void setNewExtensionEnabledByDefault(bool value);
89  bool newExtensionEnabledByDefault()const;
90 
91  Q_INVOKABLE ExtensionMetadataType extensionMetadata(const QString& extensionName)const;
92 
95  Q_INVOKABLE bool isExtensionInstalled(const QString& extensionName)const;
96 
99  int installedExtensionsCount()const;
100 
103  int numberOfInstalledExtensions()const;
104 
107  QStringList installedExtensions()const;
108 
111  Q_INVOKABLE bool isExtensionEnabled(const QString& extensionName)const;
112 
117  QStringList scheduledForUpdateExtensions() const;
118 
125  Q_INVOKABLE bool isExtensionUpdateAvailable(const QString& extensionName)const;
126 
132  Q_INVOKABLE bool isExtensionScheduledForUpdate(const QString& extensionName)const;
133 
136  QStringList scheduledForUninstallExtensions() const;
137 
140  Q_INVOKABLE bool isExtensionScheduledForUninstall(const QString& extensionName)const;
141 
144  QStringList enabledExtensions()const;
145 
149  QString extensionsSettingsFilePath()const;
150  void setExtensionsSettingsFilePath(const QString& extensionsSettingsFilePath);
151 
155  QString extensionsHistorySettingsFilePath()const;
156  void setExtensionsHistorySettingsFilePath(const QString& extensionsHistorySettingsFilePath);
157 
158  QVariantMap extensionsHistoryInformation()const;
159 
163  QString slicerRevision()const;
164  void setSlicerRevision(const QString& revision);
165 
169  QString slicerOs()const;
170  void setSlicerOs(const QString& os);
171 
175  QString slicerArch()const;
176  void setSlicerArch(const QString& arch);
177 
185  void setSlicerRequirements(const QString& revision, const QString& os, const QString& arch);
186 
187  QString slicerVersion()const;
188  void setSlicerVersion(const QString& version);
189 
194  Q_INVOKABLE QStringList isExtensionCompatible(const QString& extensionName, const QString& slicerRevision,
195  const QString& slicerOs, const QString& slicerArch) const;
196 
203  Q_INVOKABLE QStringList isExtensionCompatible(const QString& extensionName) const;
204 
207  Q_INVOKABLE ExtensionMetadataType retrieveExtensionMetadata(const QString& extensionId);
208 
211  Q_INVOKABLE ExtensionMetadataType retrieveExtensionMetadataByName(const QString& extensionName);
212 
220  Q_INVOKABLE bool installExtension(const QString &archiveFile);
221 
229  Q_INVOKABLE bool installExtension(const QString& extensionName,
230  ExtensionMetadataType extensionMetadata,
231  const QString &archiveFile);
232 
234  Q_INVOKABLE bool extractExtensionArchive(const QString& extensionName,
235  const QString& archiveFile,
236  const QString &destinationPath);
237 
239  Q_INVOKABLE const QStandardItemModel * model()const;
240 
241  static QHash<QString, QString> serverToExtensionDescriptionKey();
242 
243  static QStringList serverKeysToIgnore();
244 
245  static ExtensionMetadataType filterExtensionMetadata(const ExtensionMetadataType &extensionMetadata);
246 
247  static QStringList readArrayValues(QSettings& settings,
248  const QString& arrayName, const QString fieldName);
249 
250  static void writeArrayValues(QSettings& settings, const QStringList& values,
251  const QString& arrayName, const QString fieldName);
252 
253  static bool writeExtensionDescriptionFile(const QString& file,
254  const ExtensionMetadataType& metadata);
255 
256  static ExtensionMetadataType parseExtensionDescriptionFile(const QString& file);
257 
258 public slots:
259 
263  void setExtensionEnabled(const QString& extensionName, bool value);
264 
268  bool downloadAndInstallExtension(const QString& extensionId);
269 
275  bool scheduleExtensionForUninstall(const QString& extensionName);
276 
280  bool cancelExtensionScheduledForUninstall(const QString& extensionName);
281 
287  void checkForUpdates(bool installUpdates);
288 
295  bool scheduleExtensionForUpdate(const QString& extensionName);
296 
300  bool cancelExtensionScheduledForUpdate(const QString& extensionName);
301 
310  bool updateScheduledExtensions(QStringList &updatedExtensions);
311 
317  bool updateScheduledExtensions();
318 
327  bool uninstallScheduledExtensions(QStringList &uninstalledExtensions);
328 
334  bool uninstallScheduledExtensions();
335 
336  void gatherExtensionsHistoryInformationOnStartup();
337 
338  QVariantMap getExtensionHistoryInformation();
339 
340  void identifyIncompatibleExtensions();
341 
342  bool exportExtensionList(QString& exportFilePath);
343 
344  QStringList checkInstallPrerequisites() const;
345 
346  void updateModel();
347 
349  QStringList activeTasks() const;
350 
351 signals:
352 
353  void downloadStarted(QNetworkReply * reply);
354 
355  void downloadFinished(QNetworkReply * reply);
356 
357  void updateDownloadProgress(const QString& extensionName,
358  qint64 received, qint64 total);
359 
360  void modelUpdated();
361 
362  void extensionUpdateAvailable(const QString& extensionName);
363 
364  void extensionInstalled(const QString& extensionName);
365 
366  void extensionUpdated(const QString& extensionName);
367 
368  void extensionScheduledForUninstall(const QString& extensionName);
369 
370  void extensionCancelledScheduleForUninstall(const QString& extensionName);
371 
372  void extensionScheduledForUpdate(const QString& extensionName);
373 
374  void extensionCancelledScheduleForUpdate(const QString& extensionName);
375 
376  void extensionUninstalled(const QString& extensionName);
377 
378  void extensionEnabledChanged(const QString& extensionName, bool value);
379 
380  void extensionIdentifedAsIncompatible(const QString& extensionName);
381 
382  void newExtensionEnabledByDefaultChanged(bool value);
383 
384  void slicerRequirementsChanged(const QString& revision, const QString& os, const QString& arch);
385  void slicerArchChanged(const QString& slicerArch);
386  void slicerOsChanged(const QString& slicerOs);
387  void slicerRevisionChanged(const QString& slicerRevision);
388 
389  void slicerVersionChanged(const QString& slicerVersion);
390 
391  void messageLogged(const QString& text, ctkErrorLogLevel::LogLevels level) const;
392 
393  void extensionHistoryGatheredOnStartup(const QVariantMap&);
394 
395  void installDownloadProgress(const QString& extensionName, qint64 received, qint64 total);
396 
397  void extensionsSettingsFilePathChanged(const QString& extensionsSettingsFilePath);
398 
399  void extensionsHistorySettingsFilePathChanged(const QString& extensionsHistorySettingsFilePath);
400 
401 protected slots:
402 
403  void onInstallDownloadProgress(qSlicerExtensionDownloadTask* task, qint64 received, qint64 total);
404 
406  void onInstallDownloadFinished(qSlicerExtensionDownloadTask* task);
407 
409  void onUpdateDownloadFinished(qSlicerExtensionDownloadTask* task);
410 
411  void onUpdateDownloadProgress(qSlicerExtensionDownloadTask* task,
412  qint64 received, qint64 total);
413 
414  void onUpdateCheckComplete(const QUuid& requestId,
415  const QList<QVariantMap>& results);
416  void onUpdateCheckFailed(const QUuid& requestId);
417 
418 protected:
419  QScopedPointer<qSlicerExtensionsManagerModelPrivate> d_ptr;
420 
421 private:
422  Q_DECLARE_PRIVATE(qSlicerExtensionsManagerModel);
423  Q_DISABLE_COPY(qSlicerExtensionsManagerModel);
424 };
425 
426 // Metatype already declared in qSlicerIO.h
427 //Q_DECLARE_METATYPE(qSlicerExtensionsManagerModel::ExtensionMetadataType)
428 
429 #endif
QObject Superclass
Superclass typedef.
string version
Definition: conf.py:67
qSlicerExtensionsManagerModelPrivate Pimpl
Pimpl typedef.