添加API调用接口,添加读取分类,添加SpkUtils实用函数

使用了SpkSidebarTree子类实现对TreeWidget的特殊要求:不能取消选择,不能拖拽选择。

API调用接口暂时写死。API会获取

配置文件已添加但暂不使用。
This commit is contained in:
RigoLigoRLC
2021-07-17 19:22:31 +08:00
parent 48c9046993
commit e3c43198b9
17 changed files with 317 additions and 110 deletions

View File

@@ -1,8 +1,9 @@
#pragma once
#include <QMap>
#include <QJsonDocument>
#include <QString>
#include <QSettings>
#include <QtNetwork/QNetworkReply>
#include <QtNetwork/QNetworkAccessManager>
@@ -20,35 +21,19 @@ class SpkStore : public QObject
Q_OBJECT
public:
static SpkStore *Instance;
QSettings *mCfg;
SpkStore(bool aCli, QString &aLogPath);
~SpkStore();
SpkMainWindow* GetRootWindow() { return mMainWindow; }
void SetApiResuestUrl(QString aUrlStr) { mApiRequestUrl = aUrlStr; }
QString GetApiRequestUrl() { return mApiRequestUrl; }
QNetworkReply *SendApiRequest(QString path, QJsonDocument param = QJsonDocument());
private:
SpkLogger *mLogger;
SpkMainWindow *mMainWindow = nullptr;
QNetworkAccessManager *mNetMgr = nullptr;
// Following are stationary signal-slot bindings between UI and Store, mostly for handling
// API calls and resource downloading.
public slots:
// void RequestStoreMetadata(); ///< All required metadata the store needs when launched
// void RequestCategoryPage(int aCategoryId);
// void RequestApplicationMetadata(int aAppId);
// void RequestRefreshApiUrls(QString aCustomUrl);
signals:
void StatusStoreMetadata(QNetworkReply::NetworkError, QString);
void StatusCategoryPage(QNetworkReply::NetworkError, QString);
void StatusApplicationMetadata(QNetworkReply::NetworkError, QString);
void StatusRefreshApiUrls(QNetworkReply::NetworkError, QString);
private:
// Store manages all kinds of possible replies, and the caller can only get JSON they need
QNetworkReply *mReplyStoreMetadata = nullptr,
*mReplyCategory = nullptr,
*mReplyAppMetadata = nullptr,
*mReplyApiUrls = nullptr;
QString mDistroName, mApiRequestUrl, mUserAgentStr;
};