diff --git a/src/libs/qtlibs/config.cpp b/src/libs/qtlibs/config.cpp index 2dd6fc91c4e4f50d984319e482bda15af5fb83e9..24002244d70b7c1e7f8863009485a68c01ddf799 100644 --- a/src/libs/qtlibs/config.cpp +++ b/src/libs/qtlibs/config.cpp @@ -17,10 +17,23 @@ namespace qtlibs { -Config::Config(const QString &configDirPath, QObject *parent) : - QObject(parent), configDirPath_(configDirPath) +Config::Config(const QString &configDirPath, QObject *parent) + : QObject(parent), configDirPath_(configDirPath) {} +Config::Config(const Config &other) +{ + this->setParent(other.parent()); + setConfigDirPath(other.configDirPath()); +} + +Config &Config::operator =(const Config &other) +{ + this->setParent(other.parent()); + setConfigDirPath(other.configDirPath()); + return *this; +} + QString Config::configDirPath() const { return configDirPath_; diff --git a/src/libs/qtlibs/config.h b/src/libs/qtlibs/config.h index 567fbfe44f4f8a03f9e4443dd05ed7cd3322805e..5f0df5fdc310e2e3688416dbd8074a2eeca2c467 100644 --- a/src/libs/qtlibs/config.h +++ b/src/libs/qtlibs/config.h @@ -21,7 +21,10 @@ class Config : public QObject Q_OBJECT public: - explicit Config(const QString &configDirPath, QObject *parent = 0); + explicit Config(const QString &configDirPath = QString(), QObject *parent = 0); + + Config(const Config &other); + Config &operator =(const Config &other); QString configDirPath() const; void setConfigDirPath(const QString &configDirPath); diff --git a/src/libs/qtlibs/dir.cpp b/src/libs/qtlibs/dir.cpp index e244881a89d6bb538374d749e478ed8afb4eb99d..e0b579a97f3c6616f9463959c2ace7e8f12729c0 100644 --- a/src/libs/qtlibs/dir.cpp +++ b/src/libs/qtlibs/dir.cpp @@ -18,10 +18,23 @@ namespace qtlibs { -Dir::Dir(const QString &path, QObject *parent) : - QObject(parent), path_(path) +Dir::Dir(const QString &path, QObject *parent) + : QObject(parent), path_(path) {} +Dir::Dir(const Dir &other) +{ + this->setParent(other.parent()); + setPath(other.path()); +} + +Dir &Dir::operator =(const Dir &other) +{ + this->setParent(other.parent()); + setPath(other.path()); + return *this; +} + QString Dir::path() const { return path_; diff --git a/src/libs/qtlibs/dir.h b/src/libs/qtlibs/dir.h index cf0b90797f7017609469087781608d0095941794..31e63a556e58a335a4b5fe808f43751f0f453042 100644 --- a/src/libs/qtlibs/dir.h +++ b/src/libs/qtlibs/dir.h @@ -21,7 +21,10 @@ class Dir : public QObject Q_OBJECT public: - explicit Dir(const QString &path, QObject *parent = 0); + explicit Dir(const QString &path = QString(), QObject *parent = 0); + + Dir(const Dir &other); + Dir &operator =(const Dir &other); QString path() const; void setPath(const QString &path); diff --git a/src/libs/qtlibs/file.cpp b/src/libs/qtlibs/file.cpp index 7bb4ef7796856ff4fdda0d77a360d6d381a8266b..d092cfa776502579fe06ba4f6b4be3b8ccf4820e 100644 --- a/src/libs/qtlibs/file.cpp +++ b/src/libs/qtlibs/file.cpp @@ -17,10 +17,23 @@ namespace qtlibs { -File::File(const QString &path, QObject *parent) : - QObject(parent), path_(path) +File::File(const QString &path, QObject *parent) + : QObject(parent), path_(path) {} +File::File(const File &other) +{ + this->setParent(other.parent()); + setPath(other.path()); +} + +File &File::operator =(const File &other) +{ + this->setParent(other.parent()); + setPath(other.path()); + return *this; +} + QString File::path() const { return path_; diff --git a/src/libs/qtlibs/file.h b/src/libs/qtlibs/file.h index 2e23cdcd961a021d59869bbcb2347708e7977de4..bfc1389045ffcb21db10b13381e763e6105bd18c 100644 --- a/src/libs/qtlibs/file.h +++ b/src/libs/qtlibs/file.h @@ -20,7 +20,10 @@ class File : public QObject Q_OBJECT public: - explicit File(const QString &path, QObject *parent = 0); + explicit File(const QString &path = QString(), QObject *parent = 0); + + File(const File &other); + File &operator =(const File &other); QString path() const; void setPath(const QString &path); diff --git a/src/libs/qtlibs/json.cpp b/src/libs/qtlibs/json.cpp index 2ea9f1c556e0a4477bb9deb6cc548b7316c62f29..1cddfe0f6df31516a78394e85af0f1a62a28dc35 100644 --- a/src/libs/qtlibs/json.cpp +++ b/src/libs/qtlibs/json.cpp @@ -16,28 +16,33 @@ namespace qtlibs { -Json::Json(const QByteArray &json, QObject *parent) : - QObject(parent), json_(json) +Json::Json(const QByteArray &json, QObject *parent) + : QObject(parent), json_(json) {} -Json::Json(const QString &string, QObject *parent) : - QObject(parent) +Json::Json(const QJsonObject &object, QObject *parent) + : QObject(parent) { - setJson(string.toUtf8()); + fromObject(object); } -Json::Json(const QJsonObject &object, QObject *parent) : - QObject(parent) +Json::Json(const QJsonArray &array, QObject *parent) + : QObject(parent) { - QJsonDocument doc(object); - setJson(doc.toJson()); + fromArray(array); } -Json::Json(const QJsonArray &array, QObject *parent) : - QObject(parent) +Json::Json(const Json &other) { - QJsonDocument doc(array); - setJson(doc.toJson()); + this->setParent(other.parent()); + setJson(other.json()); +} + +Json &Json::operator =(const Json &other) +{ + this->setParent(other.parent()); + setJson(other.json()); + return *this; } QByteArray Json::json() const @@ -50,26 +55,16 @@ void Json::setJson(const QByteArray &json) json_ = json; } -bool Json::isValid() +void Json::fromObject(const QJsonObject &object) { - QJsonParseError parseError; - QJsonDocument::fromJson(json(), &parseError); - if (parseError.error == QJsonParseError::NoError) { - return true; - } - return false; -} - -bool Json::isObject() -{ - QJsonDocument doc = QJsonDocument::fromJson(json()); - return doc.isObject(); + QJsonDocument doc(object); + setJson(doc.toJson()); } -bool Json::isArray() +void Json::fromArray(const QJsonArray &array) { - QJsonDocument doc = QJsonDocument::fromJson(json()); - return doc.isArray(); + QJsonDocument doc(array); + setJson(doc.toJson()); } QByteArray Json::toJson() @@ -90,4 +85,26 @@ QJsonArray Json::toArray() return doc.array(); } +bool Json::isValid() +{ + QJsonParseError parseError; + QJsonDocument::fromJson(json(), &parseError); + if (parseError.error == QJsonParseError::NoError) { + return true; + } + return false; +} + +bool Json::isObject() +{ + QJsonDocument doc = QJsonDocument::fromJson(json()); + return doc.isObject(); +} + +bool Json::isArray() +{ + QJsonDocument doc = QJsonDocument::fromJson(json()); + return doc.isArray(); +} + } // namespace qtlibs diff --git a/src/libs/qtlibs/json.h b/src/libs/qtlibs/json.h index ae9bee5ce8087061fbd80326c2fbaf481060198b..9d6cd4e165bee8067b7da2d43801e1e09443a8e0 100644 --- a/src/libs/qtlibs/json.h +++ b/src/libs/qtlibs/json.h @@ -22,20 +22,24 @@ class Json : public QObject Q_OBJECT public: - explicit Json(const QByteArray &json, QObject *parent = 0); - explicit Json(const QString &string, QObject *parent = 0); + explicit Json(const QByteArray &json = QByteArray(), QObject *parent = 0); explicit Json(const QJsonObject &object, QObject *parent = 0); explicit Json(const QJsonArray &array, QObject *parent = 0); + Json(const Json &other); + Json &operator =(const Json &other); + QByteArray json() const; void setJson(const QByteArray &json); - bool isValid(); - bool isObject(); - bool isArray(); + void fromObject(const QJsonObject &object); + void fromArray(const QJsonArray &array); QByteArray toJson(); QJsonObject toObject(); QJsonArray toArray(); + bool isValid(); + bool isObject(); + bool isArray(); private: QByteArray json_; diff --git a/src/libs/qtlibs/networkresource.cpp b/src/libs/qtlibs/networkresource.cpp index 74b24d3ae6bc4a63e583359130b17b592190240f..16238f0f4bdac1686ed462e2d9ff88bd5c52e4d1 100644 --- a/src/libs/qtlibs/networkresource.cpp +++ b/src/libs/qtlibs/networkresource.cpp @@ -17,8 +17,8 @@ namespace qtlibs { -NetworkResource::NetworkResource(const QString &name, const QUrl &url, const bool &async, QObject *parent) : - QObject(parent), name_(name), url_(url), async_(async) +NetworkResource::NetworkResource(const QString &name, const QUrl &url, const bool &async, QObject *parent) + : QObject(parent), name_(name), url_(url), async_(async) { setManager(new QNetworkAccessManager(this)); } @@ -28,6 +28,33 @@ NetworkResource::~NetworkResource() manager()->deleteLater(); } +NetworkResource::NetworkResource(const NetworkResource &other) +{ + this->setParent(other.parent()); + setName(other.name()); + setUrl(other.url()); + setAsync(other.async()); + setRequest(other.request()); + setManager(other.manager()); + setReply(other.reply()); + setMethod(other.method()); +} + +NetworkResource &NetworkResource::operator =(const NetworkResource &other) +{ + manager()->deleteLater(); + + this->setParent(other.parent()); + setName(other.name()); + setUrl(other.url()); + setAsync(other.async()); + setRequest(other.request()); + setManager(other.manager()); + setReply(other.reply()); + setMethod(other.method()); + return *this; +} + QString NetworkResource::name() const { return name_; diff --git a/src/libs/qtlibs/networkresource.h b/src/libs/qtlibs/networkresource.h index 23e11f38977f3db0fe76ebac783d6c16fada6adf..4186ee64de4f3c38c76f7cfaa3dae5348737e1c9 100644 --- a/src/libs/qtlibs/networkresource.h +++ b/src/libs/qtlibs/networkresource.h @@ -24,9 +24,12 @@ class NetworkResource : public QObject Q_OBJECT public: - explicit NetworkResource(const QString &name, const QUrl &url, const bool &async = true, QObject *parent = 0); + explicit NetworkResource(const QString &name = QString(), const QUrl &url = QUrl(), const bool &async = true, QObject *parent = 0); ~NetworkResource(); + NetworkResource(const NetworkResource &other); + NetworkResource &operator =(const NetworkResource &other); + QString name() const; void setName(const QString &name); QUrl url() const; diff --git a/src/libs/qtlibs/package.cpp b/src/libs/qtlibs/package.cpp index 8869b018a8fec6fa26b20129372207b95e09313f..d857f14d3757da60393880615e8fa4d7da6d86ad 100644 --- a/src/libs/qtlibs/package.cpp +++ b/src/libs/qtlibs/package.cpp @@ -23,10 +23,23 @@ namespace qtlibs { -Package::Package(const QString &path, QObject *parent) : - QObject(parent), path_(path) +Package::Package(const QString &path, QObject *parent) + : QObject(parent), path_(path) {} +Package::Package(const Package &other) +{ + this->setParent(other.parent()); + setPath(other.path()); +} + +Package &Package::operator =(const Package &other) +{ + this->setParent(other.parent()); + setPath(other.path()); + return *this; +} + QString Package::path() const { return path_; diff --git a/src/libs/qtlibs/package.h b/src/libs/qtlibs/package.h index 3f22b52c0d1baaddc1a4254427c5554b2e654720..b11e77569696cbba1bc0027a19818d2c78ca5ed6 100644 --- a/src/libs/qtlibs/package.h +++ b/src/libs/qtlibs/package.h @@ -20,7 +20,10 @@ class Package : public QObject Q_OBJECT public: - explicit Package(const QString &path, QObject *parent = 0); + explicit Package(const QString &path = QString(), QObject *parent = 0); + + Package(const Package &other); + Package &operator =(const Package &other); QString path() const; void setPath(const QString &path);