Bladeren bron

Moved the ctkXnatLoginProfile class to XNAT/Core.

Sascha Zelzer 11 jaren geleden
bovenliggende
commit
106a2693d6

+ 1 - 0
Libs/XNAT/Core/CMakeLists.txt

@@ -12,6 +12,7 @@ set(KIT_SRCS
   ctkXnatException.cpp
   ctkXnatExperiment.cpp
   ctkXnatFile.cpp
+  ctkXnatLoginProfile.cpp
   ctkXnatObject.cpp
   ctkXnatObjectPrivate.cpp
   ctkXnatProject.cpp

+ 6 - 13
Libs/XNAT/Widgets/ctkXnatLoginProfile.cpp

@@ -27,7 +27,7 @@ public:
   ctkXnatLoginProfilePrivate();
 
   QString Name;
-  QString ServerUri;
+  QUrl ServerUrl;
   QString UserName;
   QString Password;
   bool Default;
@@ -46,15 +46,8 @@ ctkXnatLoginProfile::ctkXnatLoginProfile()
 }
 
 ctkXnatLoginProfile::ctkXnatLoginProfile(const ctkXnatLoginProfile& otherLoginProfile)
-  : d_ptr(new ctkXnatLoginProfilePrivate())
+  : d_ptr(new ctkXnatLoginProfilePrivate(*otherLoginProfile.d_ptr.data()))
 {
-  Q_D(ctkXnatLoginProfile);
-
-  d->Name = otherLoginProfile.name();
-  d->ServerUri = otherLoginProfile.serverUri();
-  d->UserName = otherLoginProfile.userName();
-  d->Password = otherLoginProfile.password();
-  d->Default = false;
 }
 
 ctkXnatLoginProfile::~ctkXnatLoginProfile()
@@ -75,18 +68,18 @@ void ctkXnatLoginProfile::setName(const QString& name)
   d->Name = name;
 }
 
-QString ctkXnatLoginProfile::serverUri() const
+QUrl ctkXnatLoginProfile::serverUrl() const
 {
   Q_D(const ctkXnatLoginProfile);
 
-  return d->ServerUri;
+  return d->ServerUrl;
 }
 
-void ctkXnatLoginProfile::setServerUri(const QString& serverUri)
+void ctkXnatLoginProfile::setServerUrl(const QUrl& serverUrl)
 {
   Q_D(ctkXnatLoginProfile);
 
-  d->ServerUri = serverUri;
+  d->ServerUrl = serverUrl;
 }
 
 QString ctkXnatLoginProfile::userName() const

+ 57 - 8
Libs/XNAT/Widgets/ctkXnatLoginProfile.h

@@ -22,40 +22,89 @@
 #ifndef ctkXnatLoginProfile_h
 #define ctkXnatLoginProfile_h
 
-#include "ctkXNATWidgetsExport.h"
+#include "ctkXNATCoreExport.h"
 
 #include <QScopedPointer>
-#include <QString>
+#include <QUrl>
 
 class ctkXnatLoginProfilePrivate;
 
-class CTK_XNAT_WIDGETS_EXPORT ctkXnatLoginProfile
+/**
+ * @brief A login profile for XNAT sessions
+ */
+class CTK_XNAT_CORE_EXPORT ctkXnatLoginProfile
 {
 public:
   ctkXnatLoginProfile();
   ctkXnatLoginProfile(const ctkXnatLoginProfile& otherLoginProfile);
-  virtual ~ctkXnatLoginProfile();
+  ~ctkXnatLoginProfile();
 
+  /**
+   * @brief Get the name for this profile.
+   * @return The profile name.
+   */
   QString name() const;
-  void setName(const QString& profileName);
 
-  QString serverUri() const;
-  void setServerUri(const QString& serverUri);
+  /**
+   * @brief Set the name for this profile.
+   * @param profileName The new profile name.
+   */
+  void setName(const QString& profileName);
 
+  /**
+   * @brief Get the XNAT server URL.
+   * @return The XNAT server URL.
+   */
+  QUrl serverUrl() const;
+
+  /**
+   * @brief Set the XNAT server URL.
+   * @param serverUri The new XNAT server URL.
+   */
+  void setServerUrl(const QUrl& serverUri);
+
+  /**
+   * @brief Get the login user name.
+   * @return The user name.
+   */
   QString userName() const;
+
+  /**
+   * @brief Set the login user name.
+   * @param userName The new user name.
+   */
   void setUserName(const QString& userName);
 
+  /**
+   * @brief Get the login password.
+   * @return The password.
+   */
   QString password() const;
+
+  /**
+   * @brief Set the login password.
+   * @param password The new password.
+   */
   void setPassword(const QString& password);
 
+  /**
+   * @brief Returns a boolean value indicating if this login profile is the default profile.
+   * @return \c true if this is the default login profile, \c false
+   *         otherwise.
+   */
   bool isDefault() const;
+
+  /**
+   * @brief Set the default login profile to this profile.
+   * @param default_ If \c true, marks this login profile as the default profile.
+   */
   void setDefault(bool default_);
 
 private:
   /// \brief d pointer of the pimpl pattern
   QScopedPointer<ctkXnatLoginProfilePrivate> d_ptr;
 
-  Q_DECLARE_PRIVATE(ctkXnatLoginProfile);
+  Q_DECLARE_PRIVATE(ctkXnatLoginProfile)
 };
 
 #endif

+ 0 - 1
Libs/XNAT/Widgets/CMakeLists.txt

@@ -8,7 +8,6 @@ set(KIT_export_directive "CTK_XNAT_WIDGETS_EXPORT")
 
 set(KIT_SRCS
   ctkXnatLoginDialog.cpp
-  ctkXnatLoginProfile.cpp
   ctkXnatTreeItem.cpp
   ctkXnatProjectListModel.cpp
   ctkXnatTreeModel.cpp

+ 2 - 2
Libs/XNAT/Widgets/ctkXnatLoginDialog.cpp

@@ -354,7 +354,7 @@ void ctkXnatLoginDialog::loadProfile(const ctkXnatLoginProfile& profile)
   this->blockSignalsOfFields(true);
 
   ui->edtProfileName->setText(profile.name());
-  ui->edtServerUri->setText(profile.serverUri());
+  ui->edtServerUri->setText(profile.serverUrl().toString());
   ui->edtUserName->setText(profile.userName());
   ui->edtPassword->setText(profile.password());
   ui->cbxDefaultProfile->setChecked(profile.isDefault());
@@ -365,7 +365,7 @@ void ctkXnatLoginDialog::loadProfile(const ctkXnatLoginProfile& profile)
 void ctkXnatLoginDialog::storeProfile(ctkXnatLoginProfile& profile)
 {
   profile.setName(ui->edtProfileName->text());
-  profile.setServerUri(ui->edtServerUri->text());
+  profile.setServerUrl(ui->edtServerUri->text());
   profile.setUserName(ui->edtUserName->text());
   profile.setPassword(ui->edtPassword->text());
   profile.setDefault(ui->cbxDefaultProfile->isChecked());