Proper const usage
authorRoeland Jago Douma <rullzer@owncloud.com>
Thu, 29 Oct 2015 12:48:53 +0000 (13:48 +0100)
committerRoeland Jago Douma <rullzer@owncloud.com>
Thu, 29 Oct 2015 14:42:25 +0000 (15:42 +0100)
src/gui/share.cpp
src/gui/share.h

index 1c44a60587917e8bad3065cfa5333e118adab30d..8e63d00a5a750e995f8fab13b738d2f03c9a9046 100644 (file)
@@ -31,17 +31,17 @@ Share::Share(AccountPtr account, const QString& id, const QString& path, int sha
 
 }
 
-const QString Share::getId()
+QString Share::getId() const
 {
     return _id;
 }
 
-int Share::getShareType()
+int Share::getShareType() const
 {
     return _shareType;
 }
 
-int Share::getPermissions()
+int Share::getPermissions() const
 {
     return _permissions;
 }
@@ -64,17 +64,17 @@ void Share::slotDeleted(const QVariantMap &reply)
     emit shareDeleted();
 }
 
-const QUrl LinkShare::getLink()
+QUrl LinkShare::getLink() const
 {
     return _url;
 }
 
-const QDate LinkShare::getExpireDate()
+QDate LinkShare::getExpireDate() const
 {
     return _expireDate;
 }
 
-bool LinkShare::isPasswordSet()
+bool LinkShare::isPasswordSet() const
 {
     return _passwordSet;
 }
@@ -254,12 +254,11 @@ void ShareManager::slotSharesFetched(const QVariantMap &reply)
 
 LinkShare *ShareManager::parseLinkShare(const QVariantMap &data) {
     QUrl url;
-    const QString versionString = _account->serverVersion();
 
     // From ownCloud server 8.2 the url field is always set for public shares
     if (data.contains("url")) {
         url = QUrl(data.value("url").toString());
-    } else if (versionString.contains('.') && versionString.split('.')[0].toInt() >= 8) {
+    } else if (_account->serverVersionInt() >= (8 << 16)) {
         // From ownCloud server version 8 on, a different share link scheme is used.
         url = QUrl(Account::concatUrlPath(_account->url(), QString("index.php/s/%1").arg(data.value("token").toString())).toString());
     } else {
index 92f4406172b65be92ad02f909fde6c51f9ad11c0..3fb445831aa2637b9f0e0f8cd95729da9f145acb 100644 (file)
@@ -31,7 +31,7 @@ class Share : public QObject {
 public:
 
     /*
-     * Constructor for link shares
+     * Constructor for shares
      */
     explicit Share(AccountPtr account,
                    const QString& id,
@@ -43,17 +43,17 @@ public:
     /*
      * Get the id
      */
-    const QString getId();
+    QString getId() const;
 
     /*
      * Get the shareType
      */
-    int getShareType();
+    int getShareType() const;
 
     /*
      * Get permissions
      */
-    int getPermissions();
+    int getPermissions() const;
 
     /*
      * Set the permissions of a share
@@ -110,7 +110,7 @@ public:
     /*
      * Get the share link
      */
-    const QUrl getLink();
+    QUrl getLink() const;
 
     /*
      * Get the publicUpload status of this share
@@ -137,12 +137,12 @@ public:
     /*
      * Is the password set?
      */
-    bool isPasswordSet();
+    bool isPasswordSet() const;
 
     /*
      * Get the expiration date
      */
-    const QDate getExpireDate();
+    QDate getExpireDate() const;
 
     /*
      * Set the expiration date