├── .gitignore
├── README.md
├── example0.png
├── example1.png
├── example2.png
├── example3.png
├── example4.png
├── example5.png
├── example6.jpg
├── example6.png
├── example7.png
└── src
└── RedisView
├── AppView
├── AddIndexDialog.cpp
├── AddIndexDialog.h
├── AppMain.cpp
├── BatchOperateDialog.cpp
├── BatchOperateDialog.h
├── CheckCodeDialog.cpp
├── CheckCodeDialog.h
├── ClientDialog.cpp
├── ClientDialog.h
├── ContributorDialog.cpp
├── ContributorDialog.h
├── DataView.cpp
├── DataView.h
├── DbCfgDialog.cpp
├── DbCfgDialog.h
├── Donation.cpp
├── Donation.h
├── FeedBack.cpp
├── FeedBack.h
├── InputDialog.cpp
├── InputDialog.h
├── Instructions.cpp
├── Instructions.h
├── KeyDialog.cpp
├── KeyDialog.h
├── LoginDialog.cpp
├── LoginDialog.h
├── LoginSet.cpp
├── LoginSet.h
├── MainWidget.cpp
├── MainWidget.h
├── MainWindow.cpp
├── MainWindow.h
├── PubsubDialog.cpp
├── PubsubDialog.h
├── RedisInfoDialog.cpp
├── RedisInfoDialog.h
├── UpdateSystem.cpp
├── UpdateSystem.h
├── ValueDialog.cpp
├── ValueDialog.h
├── VersionHistory.cpp
├── VersionHistory.h
├── batchoperatedialog.ui
├── checkcodedialog.ui
├── clientdialog.ui
├── contributordialog.ui
├── dataview.ui
├── donation.ui
├── inputdialog.ui
├── instructions.ui
├── mainwidget.ui
├── pubsubdialog.ui
├── redisinfodialog.ui
├── valuedialog.ui
└── versionhistory.ui
├── Model
├── ItemDelegate.cpp
├── ItemDelegate.h
├── KeyTreeItem.cpp
├── KeyTreeItem.h
├── KeyTreeModel.cpp
├── KeyTreeModel.h
├── ValueTableItem.cpp
├── ValueTableItem.h
├── ValueTableModel.cpp
└── ValueTableModel.h
├── Public
├── AesEncrypt.cpp
├── AesEncrypt.h
├── DbMgr.cpp
├── DbMgr.h
├── Define.cpp
├── Define.h
├── Log.cpp
├── Log.h
├── Publib.cpp
├── Publib.h
├── QaesEncryption.cpp
├── QaesEncryption.h
├── WorkThread.cpp
└── WorkThread.h
├── RedisLib
├── RedisClient.cpp
├── RedisClient.h
├── RedisCluster.cpp
├── RedisCluster.h
├── RedisDefine.h
├── RedisRespParser.cpp
├── RedisRespParser.h
├── RedisRoute.cpp
├── RedisRoute.h
├── RedisTransMgr.cpp
└── RedisTransMgr.h
├── RedisView.pro
├── Resources
├── DarkTheme.qss
├── DeepDarkTheme.qss
├── GrayTheme.qss
├── PinkTheme.qss
├── about.ico
├── add.ico
├── adddb.ico
├── alipay.png
├── alter.ico
├── batchop.ico
├── cn.ico
├── cn.qm
├── commit.ico
├── contributor.ico
├── count.ico
├── db.ico
├── delete.ico
├── delhead.ico
├── delkey.ico
├── deltail.ico
├── details.ico
├── display.ico
├── donate.ico
├── en.ico
├── en.qm
├── encode.ico
├── exit.ico
├── feedback.ico
├── flush.ico
├── hide.ico
├── history.ico
├── info.ico
├── inhead.ico
├── instruction.ico
├── intail.ico
├── key.ico
├── keyflush.ico
├── language.ico
├── login.ico
├── reconnect.ico
├── redisinfo.ico
├── run.ico
├── save.ico
├── see.ico
├── select.ico
├── sort.ico
├── subcribe.ico
├── tabpage.ico
├── tray.ico
├── type.ico
├── update.ico
├── view.ico
├── wait.gif
└── weiPay.png
├── cn.ts
├── en.ts
└── icon.qrc
/.gitignore:
--------------------------------------------------------------------------------
1 | *.user
2 |
3 |
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | RedisView
2 | -------
3 | RedisView is a redis open source,cross-platform and high performance gui tool. provides simple add, delete, alter and basic commands, supports cluster mode. Copy set or cluster mode only need to fill out an IP and port.
4 |
5 | Function:
6 | -------
7 | 1.RedisView implements open source, cross-platform and high performance Redis interface tools through self-written RESP protocol parsing, self-written tree model and thread pool
8 | 2.Redis database view tool, providing CURD functionality
9 | 3.provide basic command operation
10 | 4.support singleton and replication and cluster model
11 | 5.suppport subscribe and publish mode
12 | 6.support batch delete
13 | 7.Supporting one-time access to tens of millions of levels of data, key mode scanning to support billions of levels of database, telecom operator level cache measurement
14 | 8.Support set language and encoding
15 |
16 |
17 |
18 | RedisView
19 | -------
20 | RedisView是开源、跨平台、高性能的Redis数据库图形化界面工具,提供简单的增删改查和基本命令,支持集群模式。复制集或是集群模式只需要填写一个ip和端口即可。
21 |
22 | 功能:
23 | -------
24 | 1、RedisView通过自写RESP协议解析、自写树模型、线程池实现开源、跨平台、高性能Redis界面工具
25 | 2、Redis数据库视图工具,提供CURD功能
26 | 3、提供基本命令运行
27 | 4、支持单例、复制集、集群模式
28 | 5、支持订阅发布模式
29 | 6、支持批量删除、Oracle和Mysql导入导出操作
30 | 7、支持一次性获取千万级别数据量,键模式扫描支持亿级数据库,运营商级别缓存实测
31 | 8、支持设置语言和编码
32 |
33 |
34 |
35 | Donate
36 | -------
37 | Power the RedisView Community with your donation by scanning WeiPay or AliPay two-dimension code,Please leave your nonation information when donating.
38 | 
39 | AliPay↑
40 | 
41 | WeiPay↑
42 |
43 |
44 |
45 | Thanks
46 | -------
47 | *才
48 |
49 |
50 |
51 | More use information
52 | -------
53 | https://blog.csdn.net/cc20110101/article/details/87301562
54 |
--------------------------------------------------------------------------------
/example0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/example0.png
--------------------------------------------------------------------------------
/example1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/example1.png
--------------------------------------------------------------------------------
/example2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/example2.png
--------------------------------------------------------------------------------
/example3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/example3.png
--------------------------------------------------------------------------------
/example4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/example4.png
--------------------------------------------------------------------------------
/example5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/example5.png
--------------------------------------------------------------------------------
/example6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/example6.jpg
--------------------------------------------------------------------------------
/example6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/example6.png
--------------------------------------------------------------------------------
/example7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/example7.png
--------------------------------------------------------------------------------
/src/RedisView/AppView/AddIndexDialog.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file AddIndexDialog.cpp
3 | * @brief 添加数据库索引数对话框
4 | * @author 王长春
5 | * @date 2021-06-21
6 | * @version 001
7 | * @copyright Copyright (c) 2021
8 | */
9 | #include "AppView/AddIndexDialog.h"
10 |
11 | AddIndexDialog::AddIndexDialog(QWidget *parent) :
12 | QDialog(parent) {
13 |
14 | setWindowTitle(tr("添加索引数"));
15 |
16 | _labelDbNum = new QLabel(tr("索引数: "));
17 | _editDbNum = new QLineEdit();
18 | _buttonOk= new QPushButton(tr("确定"));
19 | _buttonNo = new QPushButton(tr("取消"));
20 |
21 | _grid = new QGridLayout(this);
22 | _grid->addWidget(_labelDbNum,0,0,1,1);
23 | _grid->addWidget(_editDbNum,0,1,1,9);
24 | _grid->addWidget(_buttonOk,2,6,1,2);
25 | _grid->addWidget(_buttonNo,2,8,1,2);
26 |
27 | connect(_buttonOk, SIGNAL(clicked()), this, SLOT(onOK()));
28 | connect(_buttonNo, SIGNAL(clicked()), this, SLOT(onExit()));
29 | }
30 |
31 | void AddIndexDialog::init() {
32 | _editDbNum->clear();
33 | }
34 |
35 | int AddIndexDialog::dbNum() const
36 | {
37 | return _dbNum;
38 | }
39 |
40 | void AddIndexDialog::onOK() {
41 | _dbNum = _editDbNum->text().trimmed().toInt();
42 | accept();
43 | }
44 |
45 | void AddIndexDialog::onExit() {
46 | reject();
47 | }
48 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/AddIndexDialog.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file AddIndexDialog.h
3 | * @brief 添加数据库索引数对话框
4 | * @author 王长春
5 | * @date 2021-06-21
6 | * @version 001
7 | * @copyright Copyright (c) 2021
8 | */
9 | #ifndef AddINDEXDIALOG_H
10 | #define AddINDEXDIALOG_H
11 |
12 | #include "Public/Publib.h"
13 |
14 | class AddIndexDialog : public QDialog {
15 | Q_OBJECT
16 | public:
17 | explicit AddIndexDialog(QWidget *parent = nullptr);
18 | void init();
19 | int dbNum() const;
20 |
21 | private:
22 |
23 | int _dbNum;
24 | QLineEdit *_editDbNum;
25 | QLabel *_labelDbNum;
26 | QPushButton *_buttonOk;
27 | QPushButton *_buttonNo;
28 | QGridLayout *_grid;
29 |
30 | signals:
31 |
32 | public slots:
33 | void onOK();
34 | void onExit();
35 |
36 | };
37 |
38 | #endif // AddINDEXDIALOG_H
39 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/AppMain.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file AppMain.cpp
3 | * @brief 程序主函数入口
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "AppView/MainWindow.h"
10 | #include "AppView/CheckCodeDialog.h"
11 | #include "Public/Log.h"
12 |
13 | // PLEASE USE UTF-8 CODE BROWSE CODE
14 | int main(int argc, char *argv[]) {
15 | // 程序框架
16 | QApplication app(argc, argv);
17 |
18 | // 初始化资源
19 | Q_INIT_RESOURCE(icon);
20 | QCoreApplication::setOrganizationName(OrganizationName);
21 | QCoreApplication::setApplicationName(ApplicationName);
22 | QCoreApplication::setApplicationVersion(ApplicationVersion);
23 |
24 | // 安装语言包
25 | Global::gTrans = new QTranslator();
26 | QString sLanguage = PubLib::getConfig("language", "cn");
27 | if(sLanguage == "cn") {
28 | Global::gTrans->load(":/Resources/cn.qm");
29 | } else {
30 | Global::gTrans->load(":/Resources/en.qm");
31 | }
32 | app.installTranslator(Global::gTrans);
33 |
34 | // 获取主题
35 | QString sTheme = PubLib::getConfig("Theme", PINK_THEME);
36 | Global::gTheme = sTheme;
37 | if(sTheme == DARK_THEME) {
38 | sTheme = DARK_THEME_FILE;
39 | } else if(sTheme == GRAY_THEME) {
40 | sTheme = GRAY_THEME_FILE;
41 | } else if(sTheme == PINK_THEME) {
42 | sTheme = PINK_THEME_FILE;
43 | } else if(sTheme == DEEPDARK_THEME) {
44 | sTheme = DEEPDARK_THEME_FILE;
45 | }
46 |
47 | // 安装样式表
48 | if(sTheme != NO_THEME) {
49 | QFile styleSheet(sTheme);
50 | if (styleSheet.open(QIODevice::ReadOnly)) {
51 | app.setStyleSheet(QLatin1String(styleSheet.readAll()));
52 | styleSheet.close();
53 | } else {
54 | Log::Error("install style sheet failed");
55 | }
56 | }
57 |
58 | // 登入验证
59 | LoginDialog loginDialog;
60 | if(loginDialog.exec() != QDialog::Accepted) {
61 | exit(0);
62 | }
63 |
64 | // 设置编码
65 | Global::gEncode = loginDialog.getEncode();
66 | Global::gConnectName = loginDialog.getLableName();
67 | Global::gEncode = Global::gEncode.isEmpty() ? "GB18030" : Global::gEncode;
68 | QTextCodec::setCodecForLocale(QTextCodec::codecForName(Global::gEncode.toLatin1()));
69 |
70 | // 主窗口
71 | MainWindow w(loginDialog.getClient());
72 | w.show();
73 |
74 | return app.exec();
75 | }
76 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/BatchOperateDialog.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file BatchOperateDialog.h
3 | * @brief 批量操作
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef BATCHOPERATEDIALOG_H
10 | #define BATCHOPERATEDIALOG_H
11 |
12 | #include "AppView/DbCfgDialog.h"
13 | #include "Public/WorkThread.h"
14 |
15 | namespace Ui {
16 | class BatchOperateDialog;
17 | }
18 |
19 | class BatchOperateDialog : public QDialog
20 | {
21 | Q_OBJECT
22 |
23 | public:
24 | explicit BatchOperateDialog(RedisCluster *redisClient = nullptr, QWidget *parent = nullptr);
25 | ~BatchOperateDialog();
26 |
27 | private:
28 | bool checkTable();
29 |
30 | private:
31 | bool _isRun;
32 | bool _isClusterMode;
33 | bool _isCustomMode;
34 | bool _isCalculateTimeout;
35 | int _dbType;
36 | int _idbNums;
37 | int _patternCount;
38 | int _processValue;
39 | int _nowOperate;
40 | qlonglong _KeyNum;
41 | qlonglong _NowKeyNum;
42 | QString _operate;
43 | QString _patternSeparator;
44 | QString _keyPattern;
45 | QString _tableName;
46 | TaskMsg *_taskMsg;
47 | QThreadPool *_threadPool;
48 | WorkThread *_workThread;
49 | RedisCluster *_redisCluster;
50 | Ui::BatchOperateDialog *ui;
51 | QReadWriteLock _TASK_LOCK;
52 | QList _vTaskId;
53 | QList _vMasterClients;
54 |
55 | private slots:
56 | void on__cancelPushButton_clicked();
57 | void on__okPushButton_clicked();
58 | void on__exitPushButton_clicked();
59 | void recvData(const TaskMsg taskMsg);
60 | void runError(const int taskid, const QString & error);
61 | void finishWork(const int taskid);
62 | void changeOperate(const QString operate);
63 | void on__setPushButton_clicked();
64 | void on__radioButton_toggled(bool checked);
65 |
66 | signals:
67 | void cancelWork(const int taskid);
68 |
69 | };
70 |
71 | #endif // BATCHOPERATEDIALOG_H
72 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/CheckCodeDialog.cpp:
--------------------------------------------------------------------------------
1 | #include "CheckCodeDialog.h"
2 | #include "ui_checkcodedialog.h"
3 |
4 | CheckCodeDialog::CheckCodeDialog(QWidget *parent) :
5 | QDialog(parent),
6 | ui(new Ui::CheckCodeDialog)
7 | {
8 | ui->setupUi(this);
9 | setWindowTitle(tr("注册"));
10 | ui->_lineEdit_1->setText(QString("%1:%2").arg(tr("软件码")).arg(PubLib::getSoftCode()));
11 | ui->_lineEdit_1->setReadOnly(true);
12 | ui->_lineEdit->setPlaceholderText(tr("请输入注册码"));
13 | ui->_lineEdit->setFocus();
14 | }
15 |
16 | CheckCodeDialog::~CheckCodeDialog()
17 | {
18 | delete ui;
19 | }
20 |
21 | void CheckCodeDialog::on__okButton_clicked()
22 | {
23 | QString md5 = ui->_lineEdit->text().trimmed();
24 | // if(md5 == PubLib::getCode().trimmed()) {
25 | // PubLib::saveCode(md5);
26 | // accept();
27 | // } else {
28 | // QMessageBox::critical(this, tr("注册失败"), "无效注册码,请重新输入!");
29 | // }
30 | if(md5 == PubLib::getCode().trimmed()) {
31 | PubLib::setConfig("_sys_c", md5);
32 | accept();
33 | } else {
34 | QMessageBox::critical(this, tr("注册失败"), "无效注册码,请重新输入!");
35 | }
36 | }
37 |
38 | void CheckCodeDialog::on__cancelButton_clicked()
39 | {
40 | reject();
41 | }
42 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/CheckCodeDialog.h:
--------------------------------------------------------------------------------
1 | #ifndef CHECKCODEDIALOG_H
2 | #define CHECKCODEDIALOG_H
3 |
4 | #include "Public/Publib.h"
5 |
6 | namespace Ui {
7 | class CheckCodeDialog;
8 | }
9 |
10 | class CheckCodeDialog : public QDialog
11 | {
12 | Q_OBJECT
13 |
14 | public:
15 | explicit CheckCodeDialog(QWidget *parent = nullptr);
16 | ~CheckCodeDialog();
17 |
18 | private slots:
19 |
20 | void on__okButton_clicked();
21 |
22 | void on__cancelButton_clicked();
23 |
24 | private:
25 | Ui::CheckCodeDialog *ui;
26 | };
27 |
28 | #endif // CHECKCODEDIALOG_H
29 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/ClientDialog.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file ClientDialog.cpp
3 | * @brief 客户端信息
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "ClientDialog.h"
10 | #include "ui_clientdialog.h"
11 |
12 | ClientDialog::ClientDialog(RedisCluster *redisClient, QWidget *parent) :
13 | QDialog(parent),
14 | ui(new Ui::ClientDialog)
15 | {
16 | ui->setupUi(this);
17 | setWindowTitle(tr("客户端信息"));
18 |
19 | QRect availableGeometry = QApplication::desktop()->availableGeometry(this);
20 | resize(availableGeometry.width() * 6 / 7, availableGeometry.height() * 5 / 7);
21 | move((availableGeometry.width() - width()) / 2,
22 | (availableGeometry.height() - height()) / 2);
23 |
24 | QStringList header;
25 | header<<"Node"<<"Ip"<<"Port"<<"Passwd"<<"Role"<<"Start Slot"<<"End Slot"<<"Slot Num";
26 | if(!redisClient) {
27 | QMessageBox::critical(this, tr("提示"), tr("客户端连接为空!"));
28 | return;
29 | }
30 |
31 | QList clientInfo = redisClient->getClients(false);
32 | ui->_tableWidget->setColumnCount(8);
33 | ui->_tableWidget->setRowCount(clientInfo.size());
34 | ui->_tableWidget->setHorizontalHeaderLabels(header);
35 | ui->_tableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
36 | ui->_tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
37 | ui->_tableWidget->verticalHeader()->setVisible(false);
38 | ui->_tableWidget->horizontalHeader()->setVisible(true);
39 | ui->_tableWidget->horizontalHeader()->setStretchLastSection(true);
40 | ui->_tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
41 | ui->_tableWidget->setFrameShape(QFrame::NoFrame);
42 |
43 | for(int i = 0; i < clientInfo.size(); ++i) {
44 | ui->_tableWidget->setItem(i,0,new QTableWidgetItem(clientInfo[i]._nodeId.isEmpty() ? "Empty" : clientInfo[i]._nodeId));
45 | ui->_tableWidget->setItem(i,1,new QTableWidgetItem(clientInfo[i]._host));
46 | ui->_tableWidget->setItem(i,2,new QTableWidgetItem(QString::number(clientInfo[i]._port)));
47 | ui->_tableWidget->setItem(i,3,new QTableWidgetItem(clientInfo[i]._passwd));
48 | ui->_tableWidget->setItem(i,4,new QTableWidgetItem(clientInfo[i]._master ? "Master" : "Slave"));
49 | ui->_tableWidget->setItem(i,5,new QTableWidgetItem(QString::number(clientInfo[i]._startSlot)));
50 | ui->_tableWidget->setItem(i,6,new QTableWidgetItem(QString::number(clientInfo[i]._endSlot)));
51 | ui->_tableWidget->setItem(i,7,new QTableWidgetItem(QString::number(clientInfo[i]._slotNum)));
52 | }
53 | }
54 |
55 | ClientDialog::~ClientDialog()
56 | {
57 | delete ui;
58 | }
59 |
60 | void ClientDialog::on__pushButton_clicked()
61 | {
62 | accept();
63 | }
64 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/ClientDialog.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file ClientDialog.h
3 | * @brief 客户端信息
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef CLIENTDIALOG_H
10 | #define CLIENTDIALOG_H
11 |
12 | #include "Public/Define.h"
13 |
14 | namespace Ui {
15 | class ClientDialog;
16 | }
17 |
18 | class ClientDialog : public QDialog
19 | {
20 | Q_OBJECT
21 |
22 | public:
23 | explicit ClientDialog(RedisCluster *redisClient = nullptr, QWidget *parent = 0);
24 | ~ClientDialog();
25 |
26 | private slots:
27 | void on__pushButton_clicked();
28 |
29 | private:
30 | Ui::ClientDialog *ui;
31 | };
32 |
33 | #endif // CLIENTDIALOG_H
34 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/ContributorDialog.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file ContributorDialog.cpp
3 | * @brief 贡献者信息
4 | * @author 王长春
5 | * @date 2019-05-15
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "ContributorDialog.h"
10 | #include "ui_contributordialog.h"
11 |
12 | ContributorDialog::ContributorDialog(QWidget *parent) :
13 | QDialog(parent),
14 | ui(new Ui::ContributorDialog)
15 | {
16 | ui->setupUi(this);
17 | setWindowTitle(tr("鸣谢"));
18 | setFixedSize(this->size());
19 | ui->_textBrowser->setEnabled(false);
20 | ui->_textBrowser->setText("
Sponsor:
"
21 | " *才"
22 | " *帅"
23 | " *惜"
24 | " 列"
25 | );
26 | }
27 |
28 | ContributorDialog::~ContributorDialog()
29 | {
30 | delete ui;
31 | }
32 |
33 | void ContributorDialog::on__pushButton_clicked()
34 | {
35 | accept();
36 | }
37 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/ContributorDialog.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file ContributorDialog.h
3 | * @brief 贡献者信息
4 | * @author 王长春
5 | * @date 2019-05-15
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef CONTRIBUTORDIALOG_H
10 | #define CONTRIBUTORDIALOG_H
11 |
12 | #include "Public/Define.h"
13 |
14 | namespace Ui {
15 | class ContributorDialog;
16 | }
17 |
18 | class ContributorDialog : public QDialog
19 | {
20 | Q_OBJECT
21 |
22 | public:
23 | explicit ContributorDialog(QWidget *parent = nullptr);
24 | ~ContributorDialog();
25 |
26 | private slots:
27 | void on__pushButton_clicked();
28 |
29 | private:
30 | Ui::ContributorDialog *ui;
31 | };
32 |
33 | #endif // CONTRIBUTORDIALOG_H
34 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/DataView.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file DataView.h
3 | * @brief 键值视图
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef DATAVIEW_H
10 | #define DATAVIEW_H
11 |
12 | #include "AppView/InputDialog.h"
13 | #include "AppView/ValueDialog.h"
14 | #include "Model/ValueTableModel.h"
15 | #include "Model/ItemDelegate.h"
16 |
17 | namespace Ui {
18 | class DataView;
19 | }
20 |
21 | class DataView : public QWidget
22 | {
23 | Q_OBJECT
24 |
25 | public:
26 | explicit DataView(QWidget *parent = nullptr);
27 | ~DataView();
28 |
29 | void clearData();
30 | void initValueListData();
31 | void appendValue(const TaskMsg & taskMsg, const int flag);
32 | void setDbIndex(const int &index);
33 | void setIndex(const int &index);
34 | void setKey(const QString &key);
35 | void setValue(const QString &value);
36 | void setType(const int &type);
37 | void setTimeMs(const qlonglong &timeMs);
38 | void setEncode(const QByteArray &encode);
39 | void setRefcount(const qlonglong &count);
40 | void setIdleTimeS(const qlonglong ×);
41 | void setRecvEnd(bool recvEnd);
42 | void setValuePattern(QString valuePattern);
43 | QString getKey();
44 | QString getValuePattern();
45 |
46 | private:
47 | bool _recvEnd; //暂时未使用
48 | int _clientIndex;
49 | int _dbIndex;
50 | int _type;
51 | QString _valuePattern;
52 | QString _key;
53 | QString _value;
54 | qlonglong _time;
55 | qlonglong _listIndex;
56 | qlonglong _longLong;
57 | QByteArray _byteArray;
58 | InitValueMsg _initValueMsg;
59 | CmdMsg _cmdMsg;
60 | QList _vCmdMsg;
61 | QAction *_resetAc;
62 | QAction *_addAc;
63 | QAction *_delAc;
64 | QAction *_seeAc;
65 | QAction *_commitAc;
66 | QAction *_inheadAc;
67 | QAction *_intailAc;
68 | QAction *_delheadAc;
69 | QAction *_deltailAc;
70 | QAction *_countAc;
71 | Ui::DataView *ui;
72 | QHBoxLayout *_headHLayout;
73 | QVBoxLayout *_rightVlayout;
74 | QVBoxLayout *_leftVlayout;
75 | QHBoxLayout *_bodyHLayout;
76 | QHBoxLayout *_searchHLayout;
77 | QVBoxLayout *_mainHLayout;
78 | QLineEdit *_valueScanPattern;
79 | QLineEdit *_keyLineEdit;
80 | QLineEdit *_timeLineEdit;
81 | QLineEdit *_typeLineEdit;
82 | QLineEdit *_refcountLineEdit;
83 | QLineEdit *_encodLineEdit;
84 | QLineEdit *_idletimeLineEdit;
85 | QPushButton *_bodyOkButton;
86 | QPushButton *_bodyAddButton;
87 | QPushButton *_bodyDelButton;
88 | QPushButton *_bodyRefreshButton;
89 | QPushButton *_bodyAddHeadButton;
90 | QPushButton *_bodyAddTailButton;
91 | QPushButton *_bodyDelHeadButton;
92 | QPushButton *_bodyDelTailButton;
93 | ValueTableModel* _itemTableModel;
94 | QTableView *_tableView;
95 | InputDialog *_inputDialog;
96 | ValueDialog *_valueDialog;
97 | ValueTableItem *_tableItemValue;
98 | ValueTableItem *_tableSubItem;
99 | QVector vRowData;
100 |
101 | signals:
102 | //注意!要使用信号,采用QObejct 和 QRunnable多继承,记得QObject要放在前面
103 | void getData(const InitValueMsg &initValueMsg);
104 | void commitData(QList &cmd);
105 |
106 | public slots:
107 | void valueChanged(ValueTableItem *item, int column);
108 | void commit();
109 | void del();
110 | void see();
111 | void add();
112 | void addHead();
113 | void addTail();
114 | void delHead();
115 | void delTail();
116 | void flush();
117 | void count();
118 | };
119 |
120 | #endif // DATAVIEW_H
121 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/DbCfgDialog.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file DbCfgdialog.cpp
3 | * @brief 数据库配置
4 | * @author 王长春
5 | * @date 2019-06-26
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "DbCfgDialog.h"
10 |
11 | DbCfgDialog::DbCfgDialog(int dbtype, QWidget *parent) :
12 | QDialog(parent) {
13 | setWindowTitle(tr("数据库配置"));
14 | _dbtype = dbtype;
15 |
16 | QLabel *labelUserName = new QLabel("用 户 ");
17 | QLabel *labelPassword = new QLabel("密 码 ");
18 | QLabel *labelPort = new QLabel("端 口 ");
19 | QLabel *labelDatabase = new QLabel("实例名 ");
20 | QLabel *labelHostName = new QLabel("主机IP ");
21 | QLabel *labelTagName = new QLabel("标签名 ");
22 |
23 | _username = new QLineEdit;
24 | _password = new QLineEdit;
25 | _port = new QLineEdit;
26 | _hostname = new QLineEdit;
27 | _tagname = new QComboBox;
28 | _tagname->setEditable(true);
29 | _database = new QLineEdit;
30 | _password->setEchoMode(QLineEdit::Password);
31 |
32 | QPushButton *OK = new QPushButton("确定");
33 | QPushButton *Exit = new QPushButton("取消");
34 | connect(OK, SIGNAL(clicked()), this, SLOT(onOK()));
35 | connect(Exit, SIGNAL(clicked()), this, SLOT(onExit()));
36 |
37 | QVBoxLayout *vBox = new QVBoxLayout;
38 | QHBoxLayout *hBox = new QHBoxLayout;
39 | QGridLayout *grid = new QGridLayout;
40 | QGridLayout *mainLayout = new QGridLayout;
41 | vBox->addLayout(grid);
42 | vBox->addWidget(new QLabel(" "));
43 | vBox->addLayout(hBox);
44 |
45 | mainLayout->addWidget(new QLabel(" "), 0, 0);
46 | mainLayout->addLayout(vBox, 0, 1);
47 | mainLayout->addWidget(new QLabel(" "), 0, 2);
48 | setLayout(mainLayout);
49 |
50 | grid->addWidget(labelUserName, 0, 0);
51 | grid->addWidget(labelPassword, 1, 0);
52 | grid->addWidget(labelPort, 2, 0);
53 | grid->addWidget(labelDatabase, 3, 0);
54 | grid->addWidget(labelHostName, 4, 0);
55 | grid->addWidget(labelTagName, 5, 0);
56 |
57 | grid->addWidget(_username, 0, 1);
58 | grid->addWidget(_password, 1, 1);
59 | grid->addWidget(_port, 2, 1);
60 | grid->addWidget(_database, 3, 1);
61 | grid->addWidget(_hostname, 4, 1);
62 | grid->addWidget(_tagname, 5, 1);
63 |
64 | hBox->addWidget(OK);
65 | hBox->addWidget(Exit);
66 |
67 | if(_dbtype == ORACLE_DB) {
68 | labelDatabase->setText("实例名 ");
69 | } else if(_dbtype == MYSQL_DB) {
70 | labelDatabase->setText("数据库 ");
71 | }
72 |
73 | QString sPath = QCoreApplication::applicationDirPath() + "/" + IniFileName;
74 | QSettings settings(sPath, QSettings::IniFormat);
75 | settings.setIniCodec("UTF-8");
76 |
77 | QString lasttag = settings.value(QString("lastUseTag%1").arg(_dbtype)).toString();
78 | int lastIndex = 0;
79 | int size = 0;
80 |
81 | if(_dbtype == ORACLE_DB)
82 | size = settings.beginReadArray(CORACLE_DB);
83 | else if(_dbtype == MYSQL_DB)
84 | size = settings.beginReadArray(CMYSQL_DB);
85 |
86 | // 读取配置初始化
87 | _loginInfo.clear();
88 | for(int i = 0; i < size; ++i) {
89 | settings.setArrayIndex(i);
90 | DbCfg login;
91 | login.userName = settings.value("userName").toString().trimmed();
92 | login.encodePasswd = settings.value("passWord").toByteArray();
93 | login.password = AesEncrypt::CBC256Decrypt(login.encodePasswd).trimmed();
94 | login.database = settings.value("dataBase").toString().trimmed();
95 | login.encodeHostname = settings.value("hostName").toByteArray();
96 | login.hostname = AesEncrypt::CBC256Decrypt(login.encodeHostname).trimmed();
97 | login.port = settings.value("dbPort").toString().trimmed();
98 | login.tagname = settings.value("tagname").toString().trimmed();
99 | if(!login.tagname.isEmpty()) {
100 | if(login.tagname == lasttag)
101 | lastIndex = i;
102 | _loginInfo.insert(login.tagname, login);
103 | _tagname->addItem(login.tagname);
104 | }
105 | }
106 | settings.endArray();
107 |
108 | connect(_tagname, static_cast
109 | (&QComboBox::currentIndexChanged),
110 | [ = ](int index) {
111 | _tagname->setCurrentIndex(index);
112 | QString text = _tagname->currentText();
113 | if(!text.isEmpty()) {
114 | _username->setText(_loginInfo[text].userName);
115 | _password->setText(_loginInfo[text].password);
116 | _port->setText(_loginInfo[text].port);
117 | _database->setText(_loginInfo[text].database);
118 | _hostname->setText(_loginInfo[text].hostname);
119 | _tagname->setCurrentText(_loginInfo[text].tagname);
120 | }
121 | }
122 | );
123 | // 发信号触发一次曹函数来初始化
124 | emit _tagname->currentIndexChanged(lastIndex);
125 | }
126 |
127 | void DbCfgDialog::onOK() {
128 |
129 | QString strUsername = _username->text().trimmed();
130 | QString strPassword = _password->text().trimmed();
131 | QString strHostname = _hostname->text().trimmed();
132 | QString strDatabase = _database->text().trimmed();
133 | QString strDbPort = _port->text().trimmed();
134 | QString strTagname = _tagname->currentText().trimmed();
135 |
136 | if(strUsername.length() == 0) {
137 | QMessageBox::critical(this, "错误", "用户名不能为空! ");
138 | _username->setFocus();
139 | return;
140 | }
141 | if(strPassword.length() == 0) {
142 | QMessageBox::critical(this, "错误", "密码不能为空! ");
143 | _password->setFocus();
144 | return;
145 | }
146 | if(strDatabase.length() == 0) {
147 | QMessageBox::critical(this, "错误", "数据库名不能为空! ");
148 | _database->setFocus();
149 | return;
150 | }
151 | if(strHostname.length() == 0) {
152 | QMessageBox::critical(this, "错误", "数据库主机不能为空! ");
153 | _hostname->setFocus();
154 | return;
155 | }
156 | if(strDbPort.length() == 0) {
157 | QMessageBox::critical(this, "错误", "数据库端口不能为空! ");
158 | _port->setFocus();
159 | return;
160 | }
161 | if(strTagname.length() == 0) {
162 | QMessageBox::critical(this, "错误", "数据库说明标签不能为空! ");
163 | _tagname->setFocus();
164 | return;
165 | }
166 |
167 | QString sPath = QCoreApplication::applicationDirPath() + "/" + IniFileName;
168 | //settings.setPath(QSettings::IniFormat, QSettings::SystemScope, sPath);
169 | QSettings settings(sPath, QSettings::IniFormat);
170 | settings.setIniCodec("UTF-8");
171 | DbCfg login;
172 | login.userName = strUsername;
173 | login.password = strPassword;
174 | login.database = strDatabase;
175 | login.hostname = strHostname;
176 | login.port = strDbPort;
177 | login.tagname = strTagname;
178 | _loginInfo.insert(login.tagname, login);
179 |
180 | settings.setValue(QString("lastUseTag%1").arg(_dbtype), login.tagname);
181 | if(_dbtype == ORACLE_DB) {
182 | settings.remove(CORACLE_DB);
183 | settings.beginWriteArray(CORACLE_DB);
184 | } else if(_dbtype == MYSQL_DB) {
185 | settings.remove(CMYSQL_DB);
186 | settings.beginWriteArray(CMYSQL_DB);
187 | }
188 | int i = 0;
189 | foreach(DbCfg value, _loginInfo) {
190 | settings.setArrayIndex(i);
191 | i++;
192 | settings.setValue("userName", value.userName);
193 | value.encodePasswd = AesEncrypt::CBC256Crypt(value.password);
194 | settings.setValue("passWord", value.encodePasswd);
195 | settings.setValue("dataBase", value.database);
196 | value.encodeHostname = AesEncrypt::CBC256Crypt(value.hostname);
197 | settings.setValue("hostName", value.encodeHostname);
198 | settings.setValue("dbPort", value.port);
199 | settings.setValue("tagname", value.tagname);
200 | }
201 | settings.endArray();
202 | accept();
203 | }
204 |
205 | // exit login
206 | void DbCfgDialog::onExit() {
207 | reject();
208 | }
209 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/DbCfgDialog.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file DbCfgdialog.h
3 | * @brief 数据库配置
4 | * @author 王长春
5 | * @date 2019-06-26
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 |
10 | #ifndef DBCFGDIALOG_H
11 | #define DBCFGDIALOG_H
12 |
13 | #include "Public/Publib.h"
14 |
15 | class DbCfgDialog : public QDialog {
16 | Q_OBJECT
17 | public:
18 | explicit DbCfgDialog(int dbtype = 0, QWidget *parent = nullptr);
19 | QLineEdit *_username;
20 | QLineEdit *_password;
21 | QLineEdit *_port;
22 | QLineEdit *_hostname;
23 | QLineEdit *_database;
24 | QComboBox *_tagname;
25 |
26 | bool loginDatabase(const QString &host,
27 | const QString &user,
28 | const QString &passwd,
29 | const QString &_database,
30 | const QString &dbport);
31 | private:
32 |
33 | QMap _loginInfo;
34 | int _dbtype;
35 |
36 | signals:
37 |
38 | public slots:
39 | void onOK();
40 | void onExit();
41 |
42 | };
43 |
44 | #endif // DBCFGDIALOG_H
45 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/Donation.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file Donation.cpp
3 | * @brief 捐赠类
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "AppView/Donation.h"
10 | #include "ui_donation.h"
11 |
12 | Donation::Donation(QWidget *parent) :
13 | QDialog(parent),
14 | ui(new Ui::Donation)
15 | {
16 | ui->setupUi(this);
17 | setWindowTitle(tr("捐赠"));
18 | setFixedSize(this->size());
19 | }
20 |
21 | Donation::~Donation()
22 | {
23 | delete ui;
24 | }
25 |
26 | void Donation::on__donationButton_clicked()
27 | {
28 | accept();
29 | }
30 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/Donation.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file Donation.h
3 | * @brief 捐赠类
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef DONATION_H
10 | #define DONATION_H
11 |
12 | #include
13 |
14 | namespace Ui {
15 | class Donation;
16 | }
17 |
18 | class Donation : public QDialog
19 | {
20 | Q_OBJECT
21 |
22 | public:
23 | explicit Donation(QWidget *parent = nullptr);
24 | ~Donation();
25 |
26 | private slots:
27 | void on__donationButton_clicked();
28 |
29 | private:
30 | Ui::Donation *ui;
31 | };
32 |
33 | #endif // DONATION_H
34 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/FeedBack.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file FeedBack.cpp
3 | * @brief 反馈信息对话框
4 | * @author 王长春
5 | * @date 2019-05-31
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "FeedBack.h"
10 |
11 | FeedBack::FeedBack(QWidget *parent) :
12 | QDialog(parent) {
13 |
14 | setWindowTitle(tr("反馈信息"));
15 | QHBoxLayout *hBox_LB = new QHBoxLayout;
16 | QLabel *lb_say = new QLabel(tr("请输入你要提交的内容..."));
17 | hBox_LB->addWidget(lb_say);
18 |
19 | QHBoxLayout *hBox_ED = new QHBoxLayout;
20 | QTextEdit *te_infomation = new QTextEdit;
21 | QString sPlaceholderText = tr("1、这个问题的详细描述,有何现象?");
22 | sPlaceholderText += "\r\n";
23 | sPlaceholderText += tr("2、是如何产生的,造成了什么影响?");
24 | te_infomation->setPlaceholderText(sPlaceholderText);
25 | hBox_ED->addWidget(te_infomation);
26 |
27 | QHBoxLayout *hBox_LE = new QHBoxLayout;
28 | QLabel *lb_contact = new QLabel(tr("联系方式: "));
29 | QLineEdit *le_contact = new QLineEdit;
30 | le_contact->setPlaceholderText(tr("留下您的QQ或手机号"));
31 | hBox_LE->addWidget(lb_contact, 1);
32 | hBox_LE->addWidget(le_contact, 3);
33 |
34 | QHBoxLayout *hBox_BT = new QHBoxLayout;
35 | QPushButton *OK = new QPushButton(tr("确定"));
36 | QPushButton *Exit = new QPushButton(tr("取消"));
37 | hBox_BT->addWidget(OK);
38 | hBox_BT->addWidget(Exit);
39 |
40 | QGridLayout *mainLayout = new QGridLayout;
41 | mainLayout->addLayout(hBox_LB, 0, 0, 1, 6);
42 | mainLayout->addLayout(hBox_ED, 1, 0, 5, 6);
43 | mainLayout->addLayout(hBox_LE, 6, 0, 1, 6);
44 | mainLayout->addLayout(hBox_BT, 7, 4, 1, 2);
45 | // mainLayout->setRowStretch(3, 1);
46 | // mainLayout->setColumnStretch(0, 1);
47 | // mainLayout->setColumnStretch(2, 1);
48 |
49 | setLayout(mainLayout);
50 |
51 | connect(OK, SIGNAL(clicked()), this, SLOT(onOK()));
52 | connect(Exit, SIGNAL(clicked()), this, SLOT(onExit()));
53 |
54 | te_infomation->setText(tr("感谢反馈,但是鉴于服务端成本压力,此功能暂时不实现,请到下载网站进行反馈,谢谢"));
55 | }
56 |
57 | void FeedBack::onOK() {
58 | //发送信息,服务端很容易,但开源软件成本问题此处不实现
59 | accept();
60 | }
61 |
62 | void FeedBack::onExit() {
63 | reject();
64 | }
65 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/FeedBack.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file FeedBack.h
3 | * @brief 反馈信息对话框
4 | * @author 王长春
5 | * @date 2019-05-31
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef FEEDBACK_H
10 | #define FEEDBACK_H
11 |
12 | #include "Public/Define.h"
13 |
14 | class FeedBack : public QDialog {
15 | Q_OBJECT
16 | public:
17 | explicit FeedBack(QWidget *parent = nullptr);
18 |
19 | signals:
20 |
21 | public slots:
22 | void onOK();
23 | void onExit();
24 | };
25 |
26 | #endif // FEEDBACK_H
27 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/InputDialog.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file InputDialog.cpp
3 | * @brief 键值设置输入
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "AppView/InputDialog.h"
10 | #include "ui_inputdialog.h"
11 |
12 | InputDialog::InputDialog(QWidget *parent) :
13 | QDialog(parent),
14 | ui(new Ui::InputDialog)
15 | {
16 | ui->setupUi(this);
17 | setWindowTitle(tr("插入"));
18 | setFixedSize(this->size());
19 | }
20 |
21 | InputDialog::~InputDialog()
22 | {
23 | delete ui;
24 | }
25 |
26 | QString InputDialog::getText() {
27 | return ui->_inputTextEdit->document()->toPlainText().trimmed();
28 | }
29 |
30 | QList InputDialog::getTextList() {
31 | return _textList;
32 | }
33 |
34 | void InputDialog::setTip(const QString & info) {
35 | ui->_inputTextEdit->setPlaceholderText(info);
36 | }
37 |
38 | void InputDialog::setType(const int & type) {
39 | _type = type;
40 | }
41 |
42 | void InputDialog::on__pushButtonY_clicked()
43 | {
44 | _text = getText();
45 | if(_text.trimmed().isEmpty()) {
46 | QMessageBox::critical(this, tr("错误"), tr("数据为空,请重新输入!"));
47 | return;
48 | }
49 |
50 | if(_type == KEY_HASH) {
51 | _textList.clear();
52 | PubLib::getList(_text,_textList);
53 | if(_textList.size() % 2) {
54 | QMessageBox::critical(this, tr("错误"), tr("数据错误,哈希字段值个数不匹配"));
55 | return;
56 | }
57 | } else if(_type == KEY_SET || _type == KEY_LIST) {
58 | _textList.clear();
59 | PubLib::getList(_text,_textList);
60 | } else if(_type == KEY_ZSET) {
61 | _textList.clear();
62 | PubLib::getList(_text,_textList);
63 | if(_textList.size() % 2) {
64 | QMessageBox::critical(this, tr("错误"), tr("数据错误,有序集合成员分数个数不匹配"));
65 | return;
66 | }
67 |
68 | QChar c;
69 | for(int i =0 ; i < _textList.size(); ++++i) {
70 | for(int j = 0; j < _textList[i+1].size(); ++j) {
71 | c = _textList[i+1].at(j);
72 | if(!c.isDigit()) {
73 | QMessageBox::critical(this, tr("错误"), tr("数据错误,分数不是有效数值"));
74 | return;
75 | }
76 | }
77 | }
78 | }
79 |
80 | accept();
81 | }
82 |
83 | void InputDialog::clear() {
84 | _textList.clear();
85 | ui->_inputTextEdit->clear();
86 | }
87 |
88 | void InputDialog::on__pushButtonN_clicked()
89 | {
90 | reject();
91 | }
92 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/InputDialog.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file InputDialog.h
3 | * @brief 键值设置输入
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef INPUTDIALOG_H
10 | #define INPUTDIALOG_H
11 |
12 | #include "Public/Publib.h"
13 |
14 | namespace Ui {
15 | class InputDialog;
16 | }
17 |
18 | class InputDialog : public QDialog
19 | {
20 | Q_OBJECT
21 |
22 | public:
23 | explicit InputDialog(QWidget *parent = nullptr);
24 | ~InputDialog();
25 |
26 | void setTip(const QString & info);
27 | void setType(const int &type);
28 | void clear();
29 | QString getText();
30 | QList getTextList();
31 |
32 | private slots:
33 | void on__pushButtonY_clicked();
34 |
35 | void on__pushButtonN_clicked();
36 |
37 | private:
38 | Ui::InputDialog *ui;
39 | int _type;
40 | QString _text;
41 | QList _textList;
42 | };
43 |
44 | #endif // INPUTDIALOG_H
45 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/Instructions.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file Instructions.cpp
3 | * @brief 说明信息
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "AppView/Instructions.h"
10 | #include "ui_instructions.h"
11 |
12 | Instructions::Instructions(QWidget *parent) :
13 | QDialog(parent),
14 | ui(new Ui::Instructions)
15 | {
16 | ui->setupUi(this);
17 | setWindowTitle(tr("使用说明"));
18 |
19 | ui->_textBrowser->setOpenExternalLinks(true);
20 | ui->_textBrowser->setText(tr(" RedisView工具为查看Redis数据库视图工具,提供简单的视图对Redis进行增、删、改、查,"
21 | "同时支持基本命令操作。工具支持集群模式,但是集群模式时部分命令无法使用。
"
22 | " 工具使用scan命令扫描键值,不阻塞服务端。软件启动时没进行扫描键,请手工右键点击左边键"
23 | "标签进行刷新,目的为了防止在超大数据量时内存耗尽而没法使用命令方式操作。
"
24 | )
25 | );
26 | ui->_textBrowser->append(tr(" 更多信息"));
27 | ui->_textBrowser->setEnabled(true);
28 | }
29 |
30 | Instructions::~Instructions()
31 | {
32 | delete ui;
33 | }
34 |
35 | void Instructions::on_pushButton_clicked()
36 | {
37 | accept();
38 | }
39 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/Instructions.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file Instructions.h
3 | * @brief 说明信息
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef INSTRUCTIONS_H
10 | #define INSTRUCTIONS_H
11 |
12 | #include
13 |
14 | namespace Ui {
15 | class Instructions;
16 | }
17 |
18 | class Instructions : public QDialog
19 | {
20 | Q_OBJECT
21 |
22 | public:
23 | explicit Instructions(QWidget *parent = nullptr);
24 | ~Instructions();
25 |
26 | private slots:
27 | void on_pushButton_clicked();
28 |
29 | private:
30 | Ui::Instructions *ui;
31 | };
32 |
33 | #endif // INSTRUCTIONS_H
34 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/KeyDialog.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file KeyDialog.cpp
3 | * @brief 键设置输入
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "AppView/KeyDialog.h"
10 |
11 | KeyDialog::KeyDialog(QWidget *parent) :
12 | QDialog(parent) {
13 |
14 | _labelKey = new QLabel("KEY:");
15 | _labelTtl = new QLabel("TTL(ms):");
16 | _labelType = new QLabel("TYPE:");
17 |
18 | _editKey = new QLineEdit();
19 | _editTtl = new QLineEdit();
20 | _combType = new QComboBox();
21 |
22 | _textEdit = new QTextEdit();
23 | _buttonOk= new QPushButton(tr("确定"));
24 | _buttonNo = new QPushButton(tr("取消"));
25 |
26 | _grid = new QGridLayout(this);
27 | _grid->addWidget(_labelKey,0,0,1,1);
28 | _grid->addWidget(_editKey,0,1,1,9);
29 | _grid->addWidget(_labelTtl,0,11,1,1);
30 | _grid->addWidget(_editTtl,0,12,1,5);
31 | _grid->addWidget(_labelType,1,0,1,1);
32 | _grid->addWidget(_combType,1,1,1,9);
33 | _grid->addWidget(_textEdit,2,0,3,17);
34 | _grid->addWidget(_buttonOk,5,13,1,2);
35 | _grid->addWidget(_buttonNo,5,15,1,2);
36 |
37 | _combType->addItem("String");
38 | _combType->addItem("Hash");
39 | _combType->addItem("Set");
40 | _combType->addItem("ZSet");
41 | _combType->addItem("List");
42 | _editTtl->setPlaceholderText(tr("空不修改,负为永久"));
43 |
44 | connect(_buttonOk, SIGNAL(clicked()), this, SLOT(onOK()));
45 | connect(_buttonNo, SIGNAL(clicked()), this, SLOT(onExit()));
46 | connect(_combType, static_cast
47 | (&QComboBox::currentTextChanged),
48 | [ = ](const QString & str) {
49 | _strType = str;
50 | if(_strType == "String") {
51 | _textEdit->setPlaceholderText("value");
52 | } else if(_strType == "Hash") {
53 | _textEdit->setPlaceholderText("filed1 value1 filed2 value2...");
54 | } else if(_strType == "Set") {
55 | _textEdit->setPlaceholderText("member1 member2...");
56 | } else if(_strType == "ZSet") {
57 | _textEdit->setPlaceholderText("member1 score1 member2 score2 ...");
58 | } else if(_strType == "List") {
59 | _textEdit->setPlaceholderText("member1 member2...");
60 | }
61 | });
62 | emit _combType->currentTextChanged("String");
63 | }
64 |
65 | void KeyDialog::init() {
66 | _editKey->clear();
67 | _editTtl->clear();
68 | _textEdit->clear();
69 | }
70 |
71 | QString KeyDialog::getType() const
72 | {
73 | return _strType;
74 | }
75 |
76 | QString KeyDialog::getKey() const
77 | {
78 | return _strKey;
79 | }
80 |
81 | QString KeyDialog::getTtl() const
82 | {
83 | return _strTtl;
84 | }
85 |
86 | QString KeyDialog::getValue() const
87 | {
88 | return _strValue;
89 | }
90 |
91 | QList KeyDialog::getTextList() const
92 | {
93 | return _textList;
94 | }
95 |
96 | void KeyDialog::setKey(const QString &strKey)
97 | {
98 | _strKey = strKey;
99 | }
100 |
101 | void KeyDialog::setFlag(int flag)
102 | {
103 | _flag = flag;
104 | switch(_flag) {
105 | case 0:
106 | _combType->setVisible(true);
107 | _textEdit->setVisible(true);
108 | _labelType->setVisible(true);
109 | break;
110 | case 1:
111 | _combType->setVisible(false);
112 | _textEdit->setVisible(false);
113 | _labelType->setVisible(false);
114 | _editKey->setText(_strKey);
115 | _editTtl->setText(_strTtl);
116 | break;
117 | default:
118 | break;
119 | }
120 | }
121 |
122 | void KeyDialog::setTtl(const QString &strTtl)
123 | {
124 | _strTtl = strTtl;
125 | }
126 |
127 | void KeyDialog::setType(const QString &strType)
128 | {
129 | _strType = strType;
130 | }
131 |
132 | void KeyDialog::onOK() {
133 | _strKey = _editKey->text().trimmed();
134 | if(_strKey.isEmpty()) {
135 | QMessageBox::critical(this, tr("错误"), tr("键不可为空"));
136 | return;
137 | }
138 |
139 | _strTtl = _editTtl->text().trimmed();
140 | QChar c;
141 | _strbTtl = _strTtl.toLocal8Bit();
142 | for(int i = 0; i < _strbTtl.size(); ++i) {
143 | c = _strbTtl.at(i);
144 | if(!c.isDigit()) {
145 | if(c != '-') {
146 | QMessageBox::critical(this, tr("错误"), tr("数据错误,键超时时间不是有效数值"));
147 | return;
148 | }
149 | }
150 | }
151 |
152 | if(!_flag) {
153 | _strValue = _textEdit->document()->toPlainText().trimmed();
154 | if(_strValue.isEmpty()) {
155 | QMessageBox::critical(this, tr("错误"), tr("值不可为空"));
156 | return;
157 | }
158 |
159 | _strType = _combType->currentText();
160 | if(_strType == "Hash") {
161 | _textList.clear();
162 | PubLib::getList(_strValue,_textList);
163 | if(_textList.size() % 2) {
164 | QMessageBox::critical(this, tr("错误"), tr("数据错误,哈希字段值个数不匹配"));
165 | return;
166 | }
167 | } else if(_strType == "Set" || _strType == "List") {
168 | _textList.clear();
169 | PubLib::getList(_strValue,_textList);
170 | } else if(_strType == "ZSet") {
171 | _textList.clear();
172 | PubLib::getList(_strValue,_textList);
173 | if(_textList.size() % 2) {
174 | QMessageBox::critical(this, tr("错误"), tr("数据错误,有序集合成员分数个数不匹配"));
175 | return;
176 | }
177 |
178 | for(int i =0 ; i < _textList.size(); ++++i) {
179 | for(int j = 0; j < _textList[i+1].size(); ++j) {
180 | c = _textList[i+1].at(j);
181 | if(!c.isDigit()) {
182 | QMessageBox::critical(this, tr("错误"), tr("数据错误,分数不是有效数值"));
183 | return;
184 | }
185 | }
186 | }
187 | }
188 | }
189 |
190 | accept();
191 | }
192 |
193 | void KeyDialog::onExit() {
194 | reject();
195 | }
196 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/KeyDialog.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file KeyDialog.h
3 | * @brief 键设置输入
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef KEYDIALOG_H
10 | #define KEYDIALOG_H
11 |
12 | #include "Public/Publib.h"
13 |
14 | class KeyDialog : public QDialog {
15 | Q_OBJECT
16 | public:
17 | explicit KeyDialog(QWidget *parent = nullptr);
18 |
19 | void init();
20 | void setFlag(int flag = 0);
21 | void setTtl(const QString &strTtl);
22 | void setType(const QString &strType);
23 | void setKey(const QString &strKey);
24 | QString getType() const;
25 | QString getKey() const;
26 | QString getTtl() const;
27 | QString getValue() const;
28 | QList getTextList() const;
29 |
30 | private:
31 |
32 | int _flag;
33 | QString _strType;
34 | QString _strKey;
35 | QString _strTtl;
36 | QString _strValue;
37 | QByteArray _strbTtl;
38 | QList _textList;
39 | QLineEdit *_editKey;
40 | QLineEdit *_editTtl;
41 | QComboBox *_combType;
42 | QLabel *_labelKey;
43 | QLabel *_labelTtl;
44 | QLabel *_labelType;
45 | QTextEdit *_textEdit;
46 | QPushButton *_buttonOk;
47 | QPushButton *_buttonNo;
48 | QGridLayout *_grid;
49 |
50 | signals:
51 |
52 | public slots:
53 | void onOK();
54 | void onExit();
55 |
56 | };
57 |
58 | #endif // KEYDIALOG_H
59 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/LoginDialog.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file LoginDialog.h
3 | * @brief 登入对话框
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef LOGINDIALOG_H
10 | #define LOGINDIALOG_H
11 |
12 | #include "AppView/LoginSet.h"
13 |
14 | class LoginDialog : public QDialog
15 | {
16 | Q_OBJECT
17 |
18 | public:
19 | explicit LoginDialog(QWidget *parent = nullptr);
20 | void resizeEvent(QResizeEvent *event);
21 | RedisCluster * getClient();
22 | QString getEncode(QString lableName);
23 | QString getEncode();
24 | QString getLableName() const;
25 |
26 | private:
27 |
28 | QLabel *_labelCreate;
29 | QLabel *_labelEdit;
30 | QLabel *_labelDelte;
31 | QGridLayout *_gBox;
32 |
33 | QPushButton *_btConnect;
34 | QPushButton *_btCancel;
35 |
36 | QTreeWidget *_treeWidget;
37 | QTreeWidgetItem *_treeWidgetItem;
38 |
39 | QMenu* _menu;
40 | QAction* _mConnect;
41 | QAction* _mCreated;
42 | QAction* _mEdit;
43 | QAction* _mDelete;
44 |
45 | ClientInfoDialog _clientInfo;
46 | QList _vClientInfo;
47 | RedisCluster *_redisClient;
48 | QString _lableName;
49 | QByteArray _byteArray;
50 |
51 | private:
52 |
53 | void saveSet(QList &vClientInfo);
54 | void initConnect(int index = 0);
55 |
56 | signals:
57 |
58 | public slots:
59 |
60 | void onOK();
61 | void onExit();
62 | void onConnect();
63 | void onCreate();
64 | void onEdit();
65 | void onDelete();
66 | void onLink(const QString &url);
67 | void showTreeRightMenu(const QPoint &pos);
68 | void treeItemDoubleClicked(QTreeWidgetItem* treeWidgetItem,int column);
69 |
70 | };
71 |
72 | #endif // LOGINDIALOG_H
73 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/LoginSet.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file LoginSet.cpp
3 | * @brief 登入信息设置
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "AppView/LoginSet.h"
10 |
11 | LoginSet::LoginSet(QWidget *parent) :
12 | QDialog(parent) {
13 |
14 | setWindowTitle(tr("连接设置"));
15 | _clientInfo._addr.clear();
16 | _clientInfo._name.clear();
17 | _clientInfo._passwd.clear();
18 |
19 | _lb_name = new QLabel(tr("名称:"));
20 | _le_name = new QLineEdit();
21 |
22 | _lb_addr = new QLabel(tr("地址:"));
23 | _le_addr = new QLineEdit();
24 | _le_addr->setPlaceholderText("ip1:port1,ip2:port2...");
25 |
26 | _lb_passwd = new QLabel(tr("密码:"));
27 | _le_passwd = new QLineEdit();
28 | _le_passwd->setEchoMode(QLineEdit::Password);
29 |
30 | QPushButton *OK = new QPushButton(tr("确定"));
31 | QPushButton *Exit = new QPushButton(tr("取消"));
32 |
33 | QGridLayout *mainLayout = new QGridLayout;
34 | mainLayout->addWidget(_lb_name,0,0,1,1);
35 | mainLayout->addWidget(_le_name,0,1,1,10);
36 |
37 | mainLayout->addWidget(_lb_addr,1,0,1,1);
38 | mainLayout->addWidget(_le_addr,1,1,1,10);
39 |
40 | mainLayout->addWidget(_lb_passwd,2,0,1,1);
41 | mainLayout->addWidget(_le_passwd,2,1,1,10);
42 |
43 | mainLayout->addWidget(OK,3,9,1,1);
44 | mainLayout->addWidget(Exit,3,10,1,1);
45 |
46 | setLayout(mainLayout);
47 |
48 | QRect availableGeometry = QApplication::desktop()->availableGeometry( this);
49 | resize(availableGeometry.width() * 2 / 5, availableGeometry.height() * 1 / 4);
50 | move((availableGeometry.width() - width()) / 2,
51 | (availableGeometry.height() - height()) / 2);
52 |
53 | connect(OK, SIGNAL(clicked()), this, SLOT(onOK()));
54 | connect(Exit, SIGNAL(clicked()), this, SLOT(onExit()));
55 | }
56 |
57 | void LoginSet::getClientInfo(ClientInfoDialog & clientInfo)
58 | {
59 | clientInfo._addr = _clientInfo._addr;
60 | clientInfo._name = _clientInfo._name;
61 | clientInfo._passwd = _clientInfo._passwd;
62 | }
63 |
64 | void LoginSet::setClientInfo(ClientInfoDialog & clientInfo)
65 | {
66 | _clientInfo._addr = clientInfo._addr;
67 | _clientInfo._name = clientInfo._name;
68 | _clientInfo._passwd = clientInfo._passwd;
69 | _le_name->setText(_clientInfo._name);
70 | _le_addr->setText(_clientInfo._addr);
71 | _le_passwd->setText(_clientInfo._passwd);
72 | }
73 |
74 | void LoginSet::onOK() {
75 |
76 | _clientInfo._name = _le_name->text().trimmed();
77 | if(_clientInfo._name.isEmpty()) {
78 | QMessageBox::critical(this, tr("错误"), tr("数据库连接标签名称不可为空!"));
79 | _le_name->setFocus();
80 | return;
81 | }
82 |
83 | _clientInfo._addr = _le_addr->text().trimmed();
84 | if(_clientInfo._addr.isEmpty()) {
85 | QMessageBox::critical(this, tr("错误"), tr("数据库连接串不可为空!"));
86 | _le_addr->setFocus();
87 | return;
88 | }
89 | _clientInfo._passwd = _le_passwd->text().trimmed();
90 |
91 | accept();
92 | }
93 |
94 | void LoginSet::onExit() {
95 | reject();
96 | }
97 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/LoginSet.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file LoginSet.h
3 | * @brief 登入信息设置
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef LOGINSET_H
10 | #define LOGINSET_H
11 |
12 | #include "Public/Define.h"
13 |
14 | class LoginSet : public QDialog {
15 | Q_OBJECT
16 | public:
17 | explicit LoginSet(QWidget *parent = nullptr);
18 |
19 | void getClientInfo(ClientInfoDialog & clientInfo);
20 | void setClientInfo(ClientInfoDialog & clientInfo);
21 |
22 | signals:
23 |
24 | private:
25 | QLabel *_lb_name;
26 | QLineEdit *_le_name;
27 | QLabel *_lb_addr;
28 | QLineEdit *_le_addr;
29 | QLabel *_lb_passwd;
30 | QLineEdit *_le_passwd;
31 | ClientInfoDialog _clientInfo;
32 |
33 | public slots:
34 | void onOK();
35 | void onExit();
36 | };
37 |
38 | #endif // LoginSet_H
39 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/MainWidget.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file MainWidget.h
3 | * @brief 主控件视图
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef MAINWIDGET_H
10 | #define MAINWIDGET_H
11 |
12 | #include "Public/WorkThread.h"
13 | #include "Public/Log.h"
14 | #include "AppView/DataView.h"
15 | #include "AppView/KeyDialog.h"
16 | #include "AppView/AddIndexDialog.h"
17 | #include "Model/KeyTreeModel.h"
18 | #include "AppView/PubsubDialog.h"
19 | #include "ui_mainwidget.h"
20 |
21 | namespace Ui {
22 | class MainWidget;
23 | }
24 |
25 | class MainWidget : public QWidget
26 | {
27 | Q_OBJECT
28 |
29 | public:
30 | explicit MainWidget(RedisCluster *redisClient = nullptr,
31 | QWidget *parent = nullptr);
32 | ~MainWidget();
33 | void openView();
34 | void openMsg();
35 | int getTaskSize();
36 | void reOpenClient();
37 | void resizeEvent(QResizeEvent *event);
38 |
39 | protected:
40 | bool eventFilter(QObject *target, QEvent *event);
41 |
42 | private:
43 |
44 | void initKeyView();
45 | void initView();
46 | void initSlot();
47 | void initSet(RedisCluster *redisClient);
48 | void initKeyListData(int dbIndex = -1);
49 | void initValueListData(const InitValueMsg &initValueMsg);
50 | void commitValue(QList &cmd);
51 | void runWait(bool isRun = false);
52 | void setKeyPattern(QString keyPattern);
53 | QString getKeyPattern();
54 |
55 | signals:
56 | void runStart();
57 | void runEnd(bool bEnd = true);
58 |
59 | public slots:
60 | void run();
61 | void on__pushButtonClear_clicked();
62 | void on_CmdClear();
63 |
64 | private slots:
65 | void closeView();
66 | void closeCmd();
67 | void closeMsg();
68 | void count();
69 | void keySort();
70 | void addDatabase();
71 | void flush();
72 | void del();
73 | void alter();
74 | void add();
75 | void runError(const int taskid, const QString & error);
76 | void recvData(const TaskMsg taskMsg);
77 | void finishWork(const int taskid);
78 | void showTabRightMenu(const QPoint &pos);
79 | void showTreeRightMenu(const QPoint &pos);
80 | void treeClicked(const QModelIndex &index);
81 | void on__pushButtonRun_clicked();
82 | void autoScroll();
83 | void on__checkBoxFomat_stateChanged(int arg1);
84 | void on__checkBoxSplit_stateChanged(int arg1);
85 | void on__radioButtonResp_toggled(bool checked);
86 | void on__radioButtonJson_toggled(bool checked);
87 | void on__radioButtonText_toggled(bool checked);
88 | void on__refreshButton_clicked();
89 | void on__publishButton_clicked();
90 | void on__subscribeButton_clicked();
91 | void on__unSubcribeButton_clicked();
92 | void recvMessage(const RespType &msg);
93 | void on__msgClearButton_clicked();
94 | void on__msgInfoButton_clicked();
95 | void on__enterRadioButton_toggled(bool checked);
96 |
97 | private:
98 | bool _isEnterSend;
99 | bool _isOpen;
100 | bool _isFormat;
101 | bool _isJson;
102 | bool _isResp;
103 | bool _isText;
104 | bool _isCmdSplit;
105 | bool _isClusterMode;
106 | bool _isReplicationMode;
107 | bool _isCustomMode;
108 | bool _haveError;
109 | bool _displayViewTab;
110 | bool _displayCmdTab;
111 | bool _displayMsgTab;
112 | int _tabIndex;
113 | int _idbNums;
114 | int _idbIndex;
115 | int _iRet;
116 | int _iScanKeySeq;
117 | int _iScanValueSeq;
118 | qlonglong _qLongLong;
119 | QString _strCmd;
120 | QString _strCmdSplit;
121 | QString _strConnectName;
122 | QString _keyPattern;
123 | QByteArray _byteArray;
124 | QJsonArray _jsonArray;
125 | QJsonDocument _jsonDocument;
126 | RedisCluster *_redisClient;
127 | RedisClient * _redisSendClient;
128 | RedisClient * _redisRecvClient;
129 | DataView *_dataView;
130 | KeyDialog * _keyDialog;
131 | AddIndexDialog *_addDbDialog;
132 | Ui::MainWidget *ui;
133 | QAction* _mKeySort;
134 | QAction* _mAddDb;
135 | QAction* _mCount;
136 | QAction* _mRefresh;
137 | QAction* _mCreated;
138 | QAction* _mDelete;
139 | QAction* _mAlter;
140 | QAction* _closeView;
141 | QAction* _closeCmd;
142 | QAction* _closeMsg;
143 | QMenu *_treeMenu;
144 | QMenu *_tabMenu;
145 | QTabBar *_tabBar;
146 | QLabel *_waitLabel;
147 | QMovie *_movie;
148 | KeyTreeModel* _itemKeyModel;
149 | KeyTreeItem *_rootKeyTreeItem;
150 | KeyTreeItem *_subKeyTreeItem;
151 | QList _vTreeItemKey;
152 | QThreadPool *_threadPool;
153 | WorkThread *_workThread;
154 | TaskMsg *_taskMsg;
155 | QList _vMasterClients;
156 | QList _vClients;
157 | QList _cmdRsult;
158 | QList _vTaskId;
159 | CmdMsg _cmdMsg;
160 | QList _vCmdMsg;
161 | QMap _vSortMap;
162 | QVector _tabPage;
163 | QReadWriteLock _SCAN_KEY_LOCK;
164 | QReadWriteLock _SCAN_VALUE_LOCK;
165 | };
166 |
167 | #endif // MAINWIDGET_H
168 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/MainWindow.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file MainWindow.h
3 | * @brief 主窗口
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef MAINWINDOW_H
10 | #define MAINWINDOW_H
11 |
12 | #include "AppView/Instructions.h"
13 | #include "AppView/VersionHistory.h"
14 | #include "AppView/Donation.h"
15 | #include "AppView/MainWidget.h"
16 | #include "AppView/ClientDialog.h"
17 | #include "AppView/BatchOperateDialog.h"
18 | #include "AppView/RedisInfoDialog.h"
19 | #include "AppView/LoginDialog.h"
20 | #include "AppView/FeedBack.h"
21 | #include "AppView/UpdateSystem.h"
22 | #include "AppView/ContributorDialog.h"
23 |
24 | // 主窗口
25 | class MainWindow : public QMainWindow {
26 | Q_OBJECT
27 | public:
28 | explicit MainWindow(RedisCluster *redisClient = nullptr,
29 | QWidget *parent = nullptr);
30 |
31 | virtual void keyPressEvent(QKeyEvent *event);
32 | void closeEvent(QCloseEvent *e);
33 |
34 | signals:
35 |
36 | private:
37 |
38 | bool _exitFlag;
39 | MainWidget * _mainWidget;
40 | QAction *_runAct;
41 | RedisCluster *_redisClient;
42 | QSystemTrayIcon *_sysTrayIcon;
43 |
44 | QAction *_nothemeAct;
45 | QAction *_deepdarkthemeAct;
46 | QAction *_darkthemeAct;
47 | QAction *_graythemeAct;
48 | QAction *_pinkthemeAct;
49 |
50 | QAction *_big5Act;
51 | QAction *_big5HkscsAct;
52 | QAction *_cp949Act;
53 | QAction *_eucjpAct;
54 | QAction *_euckrAct;
55 | QAction *_gb18030Act;
56 | QAction *_hproman8Act;
57 | QAction *_ibm850Act;
58 | QAction *_ibm866Act;
59 | QAction *_ibm874Act;
60 | QAction *_iso2022jpAct;
61 | QAction *_iso88591Act;
62 | QAction *_iso88592Act;
63 | QAction *_iso88593Act;
64 | QAction *_iso88594Act;
65 | QAction *_iso88595Act;
66 | QAction *_iso88596Act;
67 | QAction *_iso88597Act;
68 | QAction *_iso88598Act;
69 | QAction *_iso88599Act;
70 | QAction *_iso885910Act;
71 | QAction *_iso885913Act;
72 | QAction *_iso885914Act;
73 | QAction *_iso885915Act;
74 | QAction *_iso885916Act;
75 | QAction *_isciibngAct;
76 | QAction *_isciidevAct;
77 | QAction *_isciigjrAct;
78 | QAction *_isciikndAct;
79 | QAction *_isciimlmAct;
80 | QAction *_isciioriAct;
81 | QAction *_isciipnjAct;
82 | QAction *_isciitlgAct;
83 | QAction *_isciitmlAct;
84 | QAction *_koi8rAct;
85 | QAction *_koi8uAct;
86 | QAction *_macintoshAcy;
87 | QAction *_shiftjisAct;
88 | QAction *_tis620Act;
89 | QAction *_tsciiAct;
90 | QAction *_utf8Act;
91 | QAction *_utf16Act;
92 | QAction *_utf16beAct;
93 | QAction *_utf16leAct;
94 | QAction *_utf32Act;
95 | QAction *_utf32beAct;
96 | QAction *_utf32leAct;
97 | QAction *_windows1250Act;
98 | QAction *_windows1251Act;
99 | QAction *_windows1252Act;
100 | QAction *_windows1253Act;
101 | QAction *_windows1254Act;
102 | QAction *_windows1255Act;
103 | QAction *_windows1256Act;
104 | QAction *_windows1257Act;
105 | QAction *_windows1258Act;
106 |
107 | private:
108 | // 读取窗口位置大小信息
109 | void readSettings();
110 | // 创建菜单和工具条
111 | void createMenu();
112 | // 状态条
113 | void createStatusBar();
114 | // 进入主界面
115 | void mainWidget();
116 | // 创建槽连接
117 | void createSlot();
118 | // 初始化
119 | void init(RedisCluster *redisClient);
120 | // 设置编码
121 | void setEncode(QString encode);
122 | // 设置编码图标
123 | void setEncodeIcon();
124 | // 清理编码图标
125 | void clearEncodeIcon();
126 | // 反馈信息
127 | void feedback();
128 | // 设置主题
129 | void setTheme(QString theme);
130 | // 设置主题图标
131 | void setThemeIcon();
132 | // 清理主题图标
133 | void clearThemeIcon();
134 |
135 | private slots:
136 |
137 | // 设置字体
138 | void setFontAction();
139 | // 使用说明
140 | void instruction();
141 | // 关于系统
142 | void about();
143 | // 版本历史
144 | void history();
145 | // 保存窗口大小位置信息
146 | void writeSettings();
147 | // 退出系统
148 | void exit();
149 | // 命令运行结束
150 | void runEnd(bool bEnd = false);
151 | // 运行命令
152 | void run();
153 | // 运行开始
154 | void runStart();
155 | // 捐赠
156 | void donate();
157 | // 贡献者
158 | void contribute();
159 | // 默认主题
160 | void Notheme();
161 | // 黑色主题
162 | void Darktheme();
163 | // 灰色主题
164 | void Graytheme();
165 | // 粉色主题
166 | void Pinktheme();
167 | // 深黑主题
168 | void DeepDarktheme();
169 | // 删除键值
170 | void batchOprate();
171 | // Redis实例信息
172 | void redisInfo();
173 | // 中文
174 | void langCnAction();
175 | // 英文
176 | void langEnAction();
177 | // 连接信息
178 | void connectInfo();
179 | // 刷新连接
180 | void refreshConnInfo();
181 | // 查看键值
182 | void keyView();
183 | // 订阅发布
184 | void subscribe();
185 | // 连接主机
186 | void connectHost();
187 | // 检测系统更新
188 | void updatesys();
189 | // 托盘退出系统
190 | void trayExit();
191 | // 托盘显示窗口
192 | void trayShowWindow();
193 | // 托盘显示窗口
194 | void trayHideWindow();
195 | // 托盘单击显示隐藏窗口
196 | void slotActivated(QSystemTrayIcon::ActivationReason);
197 | // 修改编码函数
198 | void big5Action();
199 | void big5HkscsAction();
200 | void cp949Action();
201 | void eucjpAction();
202 | void euckrAction();
203 | void gb18030Action();
204 | void hproman8Action();
205 | void ibm850Action();
206 | void ibm866Action();
207 | void ibm874Action();
208 | void iso2022jpAction();
209 | void iso88591Action();
210 | void iso88592Action();
211 | void iso88593Action();
212 | void iso88594Action();
213 | void iso88595Action();
214 | void iso88596Action();
215 | void iso88597Action();
216 | void iso88598Action();
217 | void iso88599Action();
218 | void iso885910Action();
219 | void iso885913Action();
220 | void iso885914Action();
221 | void iso885915Action();
222 | void iso885916Action();
223 | void isciibngAction();
224 | void isciidevAction();
225 | void isciigjrAction();
226 | void isciikndAction();
227 | void isciimlmAction();
228 | void isciioriAction();
229 | void isciipnjAction();
230 | void isciitlgAction();
231 | void isciitmlAction();
232 | void koi8rAction();
233 | void koi8uAction();
234 | void macintoshAction();
235 | void shiftjisAction();
236 | void tis620Action();
237 | void tsciiAction();
238 | void utf8Action();
239 | void utf16Action();
240 | void utf16beAction();
241 | void utf16leAction();
242 | void utf32Action();
243 | void utf32beAction();
244 | void utf32leAction();
245 | void windows1250Action();
246 | void windows1251Action();
247 | void windows1252Action();
248 | void windows1253Action();
249 | void windows1254Action();
250 | void windows1255Action();
251 | void windows1256Action();
252 | void windows1257Action();
253 | void windows1258Action();
254 |
255 | };
256 |
257 | #endif // MAINWINDOW_H
258 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/PubsubDialog.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file PubsubDialog.cpp
3 | * @brief 订阅发布模式
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "PubsubDialog.h"
10 | #include "ui_pubsubdialog.h"
11 |
12 | PubsubDialog::PubsubDialog(RedisClient *redisClient, QWidget *parent) :
13 | QDialog(parent),
14 | ui(new Ui::PubsubDialog)
15 | {
16 | ui->setupUi(this);
17 | _redisClient = redisClient;
18 | setWindowTitle(tr("订阅发布信息"));
19 | setFixedSize(this->size());
20 | ui->_comboBox->addItem("CHANNELS");
21 | ui->_comboBox->addItem("NUMSUB");
22 | ui->_comboBox->addItem("NUMPAT");
23 | emit ui->_comboBox->currentTextChanged(ui->_comboBox->currentText());
24 | }
25 |
26 | PubsubDialog::~PubsubDialog()
27 | {
28 | delete ui;
29 | }
30 |
31 | void PubsubDialog::on__cancelButton_clicked()
32 | {
33 | accept();
34 | }
35 |
36 | void PubsubDialog::on__queryButton_clicked()
37 | {
38 | if(!_redisClient) {
39 | QMessageBox::about(this, tr("错误"), tr("客户端连接为空!"));
40 | return;
41 | }
42 |
43 | if(ui->_comboBox->currentText() == "NUMSUB") {
44 | if(ui->_lineEdit->text().trimmed().isEmpty()) {
45 | QMessageBox::about(this, tr("错误"), tr("命令为NUMSUB时,频道参数不可为空!"));
46 | return;
47 | }
48 | }
49 |
50 | ui->_textBrowser->clear();
51 | RespType respValue;
52 | if(_redisClient->pubsub(ui->_comboBox->currentText(),
53 | ui->_lineEdit->text().trimmed(),respValue)) {
54 | if(respValue._formatType == '*' && respValue._arrayLength == 0) {
55 | ui->_textBrowser->append("The query result is empty");
56 | return;
57 | }
58 |
59 | int iRet = 0;
60 | QByteArray byteArray;
61 | _redisClient->formatToText(respValue, byteArray, iRet);
62 | ui->_textBrowser->append(QTextCodec::codecForLocale()->toUnicode(byteArray));
63 | } else {
64 | QMessageBox::about(this, tr("错误"), _redisClient->getErrorInfo());
65 | return;
66 | }
67 | }
68 |
69 | void PubsubDialog::on__comboBox_currentTextChanged(const QString &arg1)
70 | {
71 | if(arg1 == "CHANNELS") {
72 | ui->_lineEdit->setEnabled(true);
73 | ui->_lineEdit->setPlaceholderText("pattern");
74 | } else if(arg1 == "NUMSUB") {
75 | ui->_lineEdit->setEnabled(true);
76 | ui->_lineEdit->setPlaceholderText("channe");
77 | } else if(arg1 == "NUMPAT") {
78 | ui->_lineEdit->setEnabled(false);
79 | ui->_lineEdit->setPlaceholderText("");
80 | ui->_lineEdit->clear();
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/PubsubDialog.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file PubsubDialog.h
3 | * @brief 订阅发布模式
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef PUBSUBDIALOG_H
10 | #define PUBSUBDIALOG_H
11 |
12 | #include "Public/Define.h"
13 |
14 | namespace Ui {
15 | class PubsubDialog;
16 | }
17 |
18 | class PubsubDialog : public QDialog
19 | {
20 | Q_OBJECT
21 |
22 | public:
23 | explicit PubsubDialog(RedisClient *redisClient = nullptr, QWidget *parent = nullptr);
24 | ~PubsubDialog();
25 |
26 | private slots:
27 | void on__cancelButton_clicked();
28 |
29 | void on__queryButton_clicked();
30 |
31 | void on__comboBox_currentTextChanged(const QString &arg1);
32 |
33 | private:
34 | Ui::PubsubDialog *ui;
35 | RedisClient *_redisClient;
36 | };
37 |
38 | #endif // PUBSUBDIALOG_H
39 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/RedisInfoDialog.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file RedisInfoDialog.h
3 | * @brief Redis服务端信息与分析
4 | * @author 王长春
5 | * @date 2019-05-30
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef REDISINFODIALOG_H
10 | #define REDISINFODIALOG_H
11 |
12 | #include "Public/Define.h"
13 |
14 | namespace Ui {
15 | class RedisInfoDialog;
16 | }
17 |
18 | class RedisInfoDialog : public QDialog
19 | {
20 | Q_OBJECT
21 |
22 | public:
23 | explicit RedisInfoDialog(RedisCluster *redisClient = nullptr,
24 | QWidget *parent = nullptr);
25 | ~RedisInfoDialog();
26 |
27 | private slots:
28 |
29 | void on__queryPushButton_clicked();
30 | void on__exitPushButton_clicked();
31 | void on__hostComboBox_currentTextChanged(const QString &arg1);
32 | void on__itemComboBox_currentTextChanged(const QString &arg1);
33 | void on__textBrowser_textChanged();
34 |
35 | private:
36 |
37 | bool _isClusterMode;
38 | bool _isReplicationMode;
39 | QString _strCmd;
40 | QString _appendInfo;
41 | QByteArray _byteArray;
42 | RedisCluster *_redisClient;
43 | Ui::RedisInfoDialog *ui;
44 | QList _cmdRsult;
45 | QList _vClients;
46 | QList _vMasterClients;
47 | };
48 |
49 | #endif // REDISINFODIALOG_H
50 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/UpdateSystem.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file UpdateSystem.cpp
3 | * @brief 更新系统
4 | * @author 王长春
5 | * @date 2019-05-31
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "UpdateSystem.h"
10 |
11 | UpdateView::UpdateView() {
12 | setWindowTitle(tr("检查更新"));
13 | setWindowFlags(windowFlags() &
14 | ~Qt::WindowMaximizeButtonHint &
15 | ~Qt::WindowMinimizeButtonHint);
16 | setWindowModality(Qt::ApplicationModal);
17 | setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
18 | setFixedSize(333,380);
19 |
20 | UpdateWidget *_native = new UpdateWidget(&_updater, this);
21 | _native->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
22 | _nativeLabel = new QLabel(tr("努力检查中,请稍后..."));
23 | _nativeLabel->setWordWrap(true);
24 | _nativeLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
25 | _nativeLabel->setAlignment(Qt::AlignHCenter);
26 |
27 | QGridLayout *layout = new QGridLayout;
28 | layout->addWidget(_native, 0, 0);
29 | layout->addWidget(_nativeLabel, 1, 0);
30 | setLayout(layout);
31 |
32 | _timer = new QTimer(this);
33 | connect(_timer, &QTimer::timeout, _native, &UpdateWidget::animate);
34 | _timer->start(50);
35 |
36 | QTimer *timer2 = new QTimer(this);
37 | connect(timer2, &QTimer::timeout, this, &UpdateView::noupdate);
38 | timer2->start(5000);
39 | }
40 |
41 | // 没有服务端,此处不实现
42 | void UpdateView::noupdate() {
43 | _nativeLabel->setText(tr("功能不实现,请到下载网站更新..."));
44 | _timer->stop();
45 | }
46 |
47 | Updater::Updater() {
48 | QLinearGradient gradient(QPointF(50, -20), QPointF(80, 20));
49 | gradient.setColorAt(0.0, Qt::white);
50 | gradient.setColorAt(1.0, QColor(0xa6, 0xce, 0x39));
51 | _background = QBrush(QColor(64, 32, 64));
52 | _circleBrush = QBrush(gradient);
53 | _circlePen = QPen(Qt::black);
54 | _circlePen.setWidth(1);
55 | _textPen = QPen(Qt::white);
56 | _textFont.setPixelSize(50);
57 |
58 | }
59 |
60 | void Updater::paint(QPainter *painter, QPaintEvent *event, int elapsed) {
61 | painter->fillRect(event->rect(), _background);
62 | painter->translate(150, 150);
63 |
64 | painter->save();
65 | painter->setBrush(_circleBrush);
66 | painter->setPen(_circlePen);
67 | painter->rotate(elapsed * 0.030);
68 |
69 | qreal r = elapsed / 1000.0;
70 | int n = 35;
71 | for(int i = 0; i < n; ++i) {
72 | painter->rotate(30);
73 | qreal factor = (i + r) / n;
74 | qreal radius = 0 + 120.0 * factor;
75 | qreal circleRadius = 1 + factor * 20;
76 | painter->drawEllipse(QRectF(radius, -circleRadius,
77 | circleRadius * 2.5, circleRadius * 2.5));
78 | }
79 | painter->restore();
80 | painter->setPen(_textPen);
81 | painter->setFont(_textFont);
82 | painter->drawText(QRect(-75, -75, 150, 150), Qt::AlignCenter,
83 | QStringLiteral("RV"));
84 | }
85 |
86 | UpdateWidget::UpdateWidget(Updater *updater, QWidget *parent)
87 | : QWidget(parent), _updater(updater) {
88 | _elapsed = 0;
89 | setFixedSize(300, 300);
90 | }
91 |
92 | void UpdateWidget::animate() {
93 | _elapsed = (_elapsed + qobject_cast(sender())->interval()) % 1000;
94 | update();
95 | }
96 |
97 | void UpdateWidget::paintEvent(QPaintEvent *event) {
98 | QPainter painter;
99 | painter.begin(this);
100 | painter.setRenderHint(QPainter::Antialiasing);
101 | _updater->paint(&painter, event, _elapsed);
102 | painter.end();
103 | }
104 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/UpdateSystem.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file UpdateSystem.h
3 | * @brief 更新系统
4 | * @author 王长春
5 | * @date 2019-05-31
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef UPDATESYSTEM_H
10 | #define UPDATESYSTEM_H
11 |
12 | #include "Public/Define.h"
13 |
14 | class Updater {
15 | public:
16 | Updater();
17 |
18 | public:
19 | void paint(QPainter *painter, QPaintEvent *event, int elapsed);
20 |
21 | private:
22 | QBrush _background;
23 | QBrush _circleBrush;
24 | QFont _textFont;
25 | QPen _circlePen;
26 | QPen _textPen;
27 | };
28 |
29 | class UpdateWidget : public QWidget {
30 | Q_OBJECT
31 |
32 | public: UpdateWidget(Updater *updater, QWidget *parent);
33 |
34 | public slots:
35 | void animate();
36 |
37 | protected:
38 | void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
39 |
40 | private:
41 | Updater *_updater;
42 | int _elapsed;
43 | };
44 |
45 | class UpdateView : public QWidget {
46 | Q_OBJECT
47 |
48 | public:
49 | UpdateView();
50 |
51 | private slots:
52 | // 检查更新接口,菜单项函数
53 | void noupdate();
54 |
55 | private:
56 | Updater _updater;
57 | QLabel *_nativeLabel;
58 | QTimer *_timer;
59 | };
60 |
61 | #endif // UPDATESYSTEM_H
62 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/ValueDialog.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file ValueDialog.cpp
3 | * @brief 键值查看
4 | * @author 王长春
5 | * @date 2021-04-21
6 | * @version 001
7 | * @copyright Copyright (c) 2021
8 | */
9 | #include "AppView/ValueDialog.h"
10 | #include "ui_valuedialog.h"
11 |
12 | ValueDialog::ValueDialog(QWidget *parent) :
13 | QDialog(parent),
14 | ui(new Ui::ValueDialog)
15 | {
16 | ui->setupUi(this);
17 | setWindowTitle(tr("查看"));
18 | ui->_radioButtonJson->setChecked(false);
19 | ui->_radioButtonText->setChecked(true);
20 | ui->_radioButtonXml->setChecked(false);
21 | }
22 |
23 | ValueDialog::~ValueDialog()
24 | {
25 | delete ui;
26 | }
27 |
28 | QString ValueDialog::getText() {
29 | return ui->_valueTextEdit->document()->toPlainText();
30 | }
31 |
32 | void ValueDialog::on__pushButtonY_clicked()
33 | {
34 | accept();
35 | }
36 |
37 | void ValueDialog::clear() {
38 | ui->_valueTextEdit->clear();
39 | }
40 |
41 | void ValueDialog::on__pushButtonN_clicked()
42 | {
43 | reject();
44 | }
45 |
46 | void ValueDialog::setEnableEdit(bool enableEdit)
47 | {
48 | _enableEdit = enableEdit;
49 | ui->_valueTextEdit->setReadOnly(!_enableEdit);
50 | ui->_pushButtonY->setEnabled(_enableEdit);
51 | }
52 |
53 | bool ValueDialog::getEnableEdit() const
54 | {
55 | return _enableEdit;
56 | }
57 |
58 | void ValueDialog::setText(const QString &text)
59 | {
60 | if(ui->_radioButtonJson->isChecked()) {
61 | QJsonDocument jsonDocument = QJsonDocument::fromJson(text.toLocal8Bit().data());
62 | if(jsonDocument.isNull()) {
63 | ui->_radioButtonText->setChecked(true);
64 | ui->_valueTextEdit->setPlainText(text);
65 | } else {
66 | ui->_valueTextEdit->setPlainText(jsonDocument.toJson(QJsonDocument::JsonFormat::Indented));
67 | }
68 | } else if(ui->_radioButtonXml->isChecked()) {
69 | QDomDocument domDocument;
70 | if(domDocument.setContent(text)) {
71 | ui->_valueTextEdit->setPlainText(domDocument.toString(4));
72 | } else {
73 | ui->_radioButtonText->setChecked(true);
74 | ui->_valueTextEdit->setPlainText(text);
75 | }
76 | } else if(ui->_radioButtonHtml->isChecked()) {
77 | ui->_valueTextEdit->setHtml(text);
78 | } else {
79 | ui->_valueTextEdit->setPlainText(text);
80 | }
81 | }
82 |
83 | void ValueDialog::on__radioButtonXml_toggled(bool checked)
84 | {
85 | if(!checked)
86 | return;
87 | QDomDocument domDocument;
88 | if(domDocument.setContent(getText())) {
89 | ui->_valueTextEdit->setPlainText(domDocument.toString(4));
90 | } else {
91 | ui->_radioButtonText->setChecked(true);
92 | QMessageBox::critical(this, tr("错误"), tr("非xml格式"));
93 | }
94 | }
95 |
96 | void ValueDialog::on__radioButtonJson_toggled(bool checked)
97 | {
98 | if(!checked)
99 | return;
100 |
101 | QJsonDocument jsonDocument = QJsonDocument::fromJson(getText().toLocal8Bit().data());
102 | if(jsonDocument.isNull()) {
103 | ui->_radioButtonText->setChecked(true);
104 | QMessageBox::critical(this, tr("错误"), tr("非json格式"));
105 | } else {
106 | ui->_valueTextEdit->setPlainText(jsonDocument.toJson(QJsonDocument::JsonFormat::Indented));
107 | }
108 | }
109 |
110 | void ValueDialog::on__radioButtonText_toggled(bool checked)
111 | {
112 | if(!checked)
113 | return;
114 | }
115 |
116 | void ValueDialog::on__radioButtonHtml_toggled(bool checked)
117 | {
118 | if(!checked)
119 | return;
120 | ui->_valueTextEdit->setHtml(getText());
121 | }
122 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/ValueDialog.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file ValueDialog.h
3 | * @brief 键值查看
4 | * @author 王长春
5 | * @date 2021-04-21
6 | * @version 001
7 | * @copyright Copyright (c) 2021
8 | */
9 | #ifndef VALUEDIALOG_H
10 | #define VALUEDIALOG_H
11 |
12 | #include "Public/Publib.h"
13 |
14 | namespace Ui {
15 | class ValueDialog;
16 | }
17 |
18 | class ValueDialog : public QDialog
19 | {
20 | Q_OBJECT
21 |
22 | public:
23 | explicit ValueDialog(QWidget *parent = nullptr);
24 | ~ValueDialog();
25 |
26 | void clear();
27 | QString getText();
28 | void setText(const QString &text);
29 |
30 | bool getEnableEdit() const;
31 | void setEnableEdit(bool enableEdit);
32 |
33 | private slots:
34 | void on__pushButtonY_clicked();
35 | void on__pushButtonN_clicked();
36 | void on__radioButtonXml_toggled(bool checked);
37 | void on__radioButtonJson_toggled(bool checked);
38 | void on__radioButtonText_toggled(bool checked);
39 | void on__radioButtonHtml_toggled(bool checked);
40 |
41 | private:
42 | Ui::ValueDialog *ui;
43 | QString _text;
44 | bool _enableEdit;
45 | };
46 |
47 | #endif // VALUEDIALOG_H
48 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/VersionHistory.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file VersionHistory.cpp
3 | * @brief 说明信息
4 | * @author 王长春
5 | * @date 2021-04-21
6 | * @version 001
7 | * @copyright Copyright (c) 2021
8 | */
9 | #include "AppView/VersionHistory.h"
10 | #include "ui_versionhistory.h"
11 |
12 | VersionHistory::VersionHistory(int width, int height, QWidget *parent) :
13 | QDialog(parent),
14 | ui(new Ui::VersionHistory)
15 | {
16 | ui->setupUi(this);
17 |
18 | setWindowTitle(tr("版本历史"));
19 | setFixedSize(width * 1 / 2, height * 1 / 2);
20 | ui->_textBrowser->setOpenExternalLinks(true);
21 | ui->_textBrowser->setText(tr(
22 | "
2021/06/21 Version 1.7.2 适配浪潮云redis集群环境.
"
23 | "
2021/04/21 Version 1.7.1 新增键值查看功能.
"
24 | "
2019/06/26 Version 1.7.0 新增主题设置和数据库导入导出.
"
25 | "
2019/06/01 Version 1.6.7 密码AES加密存储.
"
26 | "
2019/05/30 Version 1.6.6 新增集群信息查看分析功能.
"
27 | "
2019/05/08 Version 1.6.5 修复设置含空格值失败Bug.
"
28 | "
2019/04/08 Version 1.6.4 修复值初始化模式Bug.
"
29 | "
2019/04/05 Version 1.6.3 修复键值过长显示不全Bug.
"
30 | "
2019/03/24 Version 1.6.2 增加操作进度提示,修复中文乱码Bug.
"
31 | "
2019/03/15 Version 1.6.1 支持编码选择.
"
32 | "
2019/02/21 Version 1.6.0 支持复制集模式.
"
33 | "
2019/01/20 Version 1.5.0 增加批量删除键功能.
"
34 | "
2019/01/19 Version 1.4.0 增加订阅发布模式.
"
35 | "
2019/01/10 Version 1.3.0 界面调整,增加键值初始化扫描模式.
"
36 | "
2019/01/07 Version 1.2.0 自定义值模型,内存优化;新增Mac、Linux版本.
"
37 | "
2018/12/30 Version 1.1.0 自定义键模型,内存优化.
"
38 | "
2018/12/25 Version 1.0.0 Windows初版发布.
"
39 | )
40 | );
41 | ui->_textBrowser->setEnabled(true);
42 | ui->_textBrowser->setReadOnly(true);
43 | }
44 |
45 | VersionHistory::~VersionHistory()
46 | {
47 | delete ui;
48 | }
49 |
50 | void VersionHistory::on_pushButton_clicked()
51 | {
52 | accept();
53 | }
54 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/VersionHistory.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file VersionHistory.h
3 | * @brief 说明信息
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef VERSIONHISTORY_H
10 | #define VERSIONHISTORY_H
11 |
12 | #include
13 |
14 | namespace Ui {
15 | class VersionHistory;
16 | }
17 |
18 | class VersionHistory : public QDialog
19 | {
20 | Q_OBJECT
21 |
22 | public:
23 | explicit VersionHistory(int width, int height, QWidget *parent = nullptr);
24 | ~VersionHistory();
25 |
26 | private slots:
27 | void on_pushButton_clicked();
28 |
29 | private:
30 | Ui::VersionHistory *ui;
31 | };
32 |
33 | #endif // VERSIONHISTORY_H
34 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/batchoperatedialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | BatchOperateDialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 641
10 | 451
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 | -
18 |
19 |
-
20 |
21 |
-
22 |
23 |
24 | 批量操作:
25 |
26 |
27 |
28 | -
29 |
30 |
31 | -
32 |
33 |
34 | 计算超时
35 |
36 |
37 |
38 | -
39 |
40 |
41 | 设置
42 |
43 |
44 |
45 | -
46 |
47 |
48 | 模式计数:
49 |
50 |
51 |
52 | -
53 |
54 |
55 | -
56 |
57 |
58 | 模式分割:
59 |
60 |
61 |
62 | -
63 |
64 |
65 | -
66 |
67 |
68 | 键值模式:
69 |
70 |
71 |
72 | -
73 |
74 |
75 | -
76 |
77 |
78 | 数据库表:
79 |
80 |
81 |
82 | -
83 |
84 |
85 |
86 |
87 | -
88 |
89 |
90 | Qt::Vertical
91 |
92 |
93 |
94 | 20
95 | 18
96 |
97 |
98 |
99 |
100 | -
101 |
102 |
103 | 24
104 |
105 |
106 |
107 | -
108 |
109 |
110 | -
111 |
112 |
-
113 |
114 |
115 | Qt::Horizontal
116 |
117 |
118 |
119 | 238
120 | 20
121 |
122 |
123 |
124 |
125 | -
126 |
127 |
128 | 取消
129 |
130 |
131 |
132 | -
133 |
134 |
135 | 执行
136 |
137 |
138 |
139 | -
140 |
141 |
142 | 退出
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/checkcodedialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | CheckCodeDialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 400
10 | 119
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 | -
18 |
19 |
-
20 |
21 |
22 | 请输入注册码进行注册:
23 |
24 |
25 |
26 | -
27 |
28 |
29 | -
30 |
31 |
32 | -
33 |
34 |
35 | Qt::Horizontal
36 |
37 |
38 |
39 | 198
40 | 20
41 |
42 |
43 |
44 |
45 | -
46 |
47 |
48 | 确定
49 |
50 |
51 |
52 | -
53 |
54 |
55 | 取消
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/clientdialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | ClientDialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 400
10 | 300
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 | Qt::RightToLeft
18 |
19 |
20 | -
21 |
22 |
-
23 |
24 |
25 | Qt::LeftToRight
26 |
27 |
28 |
29 | -
30 |
31 |
32 | Qt::LeftToRight
33 |
34 |
35 | 确定
36 |
37 |
38 |
39 | -
40 |
41 |
42 | Qt::Horizontal
43 |
44 |
45 |
46 | 278
47 | 20
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/contributordialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | ContributorDialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 400
10 | 300
11 |
12 |
13 |
14 | 鸣谢
15 |
16 |
17 | -
18 |
19 |
-
20 |
21 |
22 | -
23 |
24 |
-
25 |
26 |
27 | Qt::Horizontal
28 |
29 |
30 |
31 | 40
32 | 20
33 |
34 |
35 |
36 |
37 | -
38 |
39 |
40 | 确定
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/dataview.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | DataView
4 |
5 |
6 |
7 | 0
8 | 0
9 | 400
10 | 300
11 |
12 |
13 |
14 | Form
15 |
16 |
17 | -
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/donation.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Donation
4 |
5 |
6 |
7 | 0
8 | 0
9 | 592
10 | 366
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 20
20 | 11
21 | 552
22 | 308
23 |
24 |
25 |
26 | -
27 |
28 |
-
29 |
30 |
31 |
32 |
33 |
34 | :/Resources/weiPay.png
35 |
36 |
37 |
38 | -
39 |
40 |
41 |
42 |
43 |
44 | :/Resources/alipay.png
45 |
46 |
47 |
48 |
49 |
50 | -
51 |
52 |
53 | Qt::Horizontal
54 |
55 |
56 |
57 | 128
58 | 20
59 |
60 |
61 |
62 |
63 | -
64 |
65 |
66 | 感谢支持,祝您万事如意、事事顺心...
67 |
68 |
69 |
70 | -
71 |
72 |
73 | Qt::Horizontal
74 |
75 |
76 |
77 | 68
78 | 20
79 |
80 |
81 |
82 |
83 | -
84 |
85 |
86 | 确定
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/inputdialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | InputDialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 392
10 | 232
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 | -
18 |
19 |
-
20 |
21 |
22 | 输入信息...
23 |
24 |
25 |
26 | -
27 |
28 |
29 | 取消
30 |
31 |
32 |
33 | -
34 |
35 |
36 | 确定
37 |
38 |
39 |
40 | -
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/instructions.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Instructions
4 |
5 |
6 |
7 | 0
8 | 0
9 | 400
10 | 300
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 | -
18 |
19 |
-
20 |
21 |
22 | -
23 |
24 |
25 | Qt::Horizontal
26 |
27 |
28 |
29 | 40
30 | 20
31 |
32 |
33 |
34 |
35 | -
36 |
37 |
38 | 确定
39 |
40 |
41 |
42 | -
43 |
44 |
45 | Qt::Horizontal
46 |
47 |
48 |
49 | 40
50 | 20
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/pubsubdialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | PubsubDialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 400
10 | 300
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 | -
18 |
19 |
-
20 |
21 |
-
22 |
23 |
24 | Pubsub:
25 |
26 |
27 |
28 | -
29 |
30 |
31 | -
32 |
33 |
34 |
35 |
36 | -
37 |
38 |
39 | -
40 |
41 |
-
42 |
43 |
44 | Qt::Horizontal
45 |
46 |
47 |
48 | 188
49 | 20
50 |
51 |
52 |
53 |
54 | -
55 |
56 |
57 | 查询
58 |
59 |
60 |
61 | -
62 |
63 |
64 | 取消
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/redisinfodialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | RedisInfoDialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 598
10 | 409
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 | -
18 |
19 |
-
20 |
21 |
-
22 |
23 |
24 | 主机:
25 |
26 |
27 |
28 | -
29 |
30 |
31 | -
32 |
33 |
34 | 选项:
35 |
36 |
37 |
38 | -
39 |
40 |
41 | -
42 |
43 |
44 | Qt::Horizontal
45 |
46 |
47 |
48 | 40
49 | 20
50 |
51 |
52 |
53 |
54 | -
55 |
56 |
57 | 查询
58 |
59 |
60 |
61 | -
62 |
63 |
64 | 退出
65 |
66 |
67 |
68 |
69 |
70 | -
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/valuedialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | ValueDialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 825
10 | 454
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 | -
18 |
19 |
-
20 |
21 |
22 | 格式化:
23 |
24 |
25 |
26 | -
27 |
28 |
29 | text
30 |
31 |
32 |
33 | -
34 |
35 |
36 | json
37 |
38 |
39 |
40 | -
41 |
42 |
43 | xml
44 |
45 |
46 |
47 | -
48 |
49 |
50 | html
51 |
52 |
53 |
54 | -
55 |
56 |
57 | Qt::Horizontal
58 |
59 |
60 |
61 | 78
62 | 20
63 |
64 |
65 |
66 |
67 |
68 |
69 | -
70 |
71 |
72 | -
73 |
74 |
-
75 |
76 |
77 | Qt::Horizontal
78 |
79 |
80 |
81 | 118
82 | 20
83 |
84 |
85 |
86 |
87 | -
88 |
89 |
90 | 确定
91 |
92 |
93 |
94 | -
95 |
96 |
97 | 关闭
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/src/RedisView/AppView/versionhistory.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | VersionHistory
4 |
5 |
6 |
7 | 0
8 | 0
9 | 400
10 | 300
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 | -
18 |
19 |
-
20 |
21 |
22 | -
23 |
24 |
25 | Qt::Horizontal
26 |
27 |
28 |
29 | 40
30 | 20
31 |
32 |
33 |
34 |
35 | -
36 |
37 |
38 | 确定
39 |
40 |
41 |
42 | -
43 |
44 |
45 | Qt::Horizontal
46 |
47 |
48 |
49 | 40
50 | 20
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/src/RedisView/Model/ItemDelegate.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file ItemDelegate.cpp
3 | * @brief 项代理
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "ItemDelegate.h"
10 |
11 | ValueTableDelegate::ValueTableDelegate(QObject *parent)
12 | : QItemDelegate(parent)
13 | {
14 | }
15 |
16 | void ValueTableDelegate::paint(QPainter* painter,
17 | const QStyleOptionViewItem& option,
18 | const QModelIndex& index) const
19 | {
20 | painter->drawText(option.rect,
21 | Qt::TextWordWrap | Qt::AlignVCenter | Qt::AlignVCenter,
22 | index.model()->data(index,Qt::DisplayRole).toString());
23 | drawFocus(painter, option, option.rect);
24 | }
25 |
--------------------------------------------------------------------------------
/src/RedisView/Model/ItemDelegate.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file ItemDelegate.h
3 | * @brief 项代理
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef ITEMDELEGATE_H
10 | #define ITEMDELEGATE_H
11 |
12 | #include
13 | #include
14 |
15 | class ValueTableDelegate : public QItemDelegate {
16 |
17 | Q_OBJECT
18 |
19 | public:
20 |
21 | ValueTableDelegate(QObject* parent = 0);
22 | virtual void paint(QPainter* painter,
23 | const QStyleOptionViewItem& option,
24 | const QModelIndex& index) const;
25 |
26 | };
27 |
28 | #endif // ITEMDELEGATE_H
29 |
--------------------------------------------------------------------------------
/src/RedisView/Model/KeyTreeItem.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file KeyTreeItem.cpp
3 | * @brief 树项
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "Model/KeyTreeItem.h"
10 |
11 | bool compareTreeItemAsc(KeyTreeItem * &item1, KeyTreeItem * &item2)
12 | {
13 | if (item1->text() < item2->text())
14 | {
15 | return true;
16 | }
17 | return false;
18 | }
19 |
20 | bool compareTreeItemDesc(KeyTreeItem * &item1, KeyTreeItem * &item2)
21 | {
22 | if (item1->text() < item2->text())
23 | {
24 | return false;
25 | }
26 | return true;
27 | }
28 |
29 | KeyTreeItem::KeyTreeItem(const QString &data, KeyTreeItem *parent)
30 | {
31 | parentItem = parent;
32 | itemData = data;
33 | }
34 |
35 | KeyTreeItem::~KeyTreeItem()
36 | {
37 | qDeleteAll(childItems);
38 | childItems.clear();
39 | }
40 |
41 | void KeyTreeItem::clear() {
42 | qDeleteAll(childItems);
43 | childItems.clear();
44 | }
45 |
46 | bool KeyTreeItem::haveIcon() {
47 | return false;
48 | }
49 |
50 | void KeyTreeItem::setIconId(const qint8 &)
51 | {
52 | }
53 |
54 | qint8 KeyTreeItem::getIconId() const
55 | {
56 | return 0;
57 | }
58 |
59 | KeyTreeItem *KeyTreeItem::child(int number)
60 | {
61 | return childItems.value(number);
62 | }
63 |
64 | int KeyTreeItem::childCount() const
65 | {
66 | return childItems.count();
67 | }
68 |
69 | int KeyTreeItem::childNumber() const
70 | {
71 | if (parentItem)
72 | return parentItem->childItems.indexOf(const_cast(this));
73 |
74 | return 0;
75 | }
76 |
77 | int KeyTreeItem::columnCount() const
78 | {
79 | return 1;
80 | }
81 |
82 | QVariant KeyTreeItem::data(int column) const
83 | {
84 | if(column == 0)
85 | return itemData;
86 | else
87 | return QVariant();
88 | }
89 |
90 | QString KeyTreeItem::text() {
91 | return itemData;
92 | }
93 |
94 | void KeyTreeItem::appendChildren(KeyTreeItem * item) {
95 | childItems.insert(childItems.size(), item);
96 | }
97 |
98 | KeyTreeItem *KeyTreeItem::parent()
99 | {
100 | return parentItem;
101 | }
102 |
103 | bool KeyTreeItem::removeChildren(int position, int count)
104 | {
105 | if (position < 0 || position + count > childItems.size())
106 | return false;
107 |
108 | for (int row = 0; row < count; ++row)
109 | delete childItems.takeAt(position);
110 |
111 | return true;
112 | }
113 |
114 | bool KeyTreeItem::setData(int column, const QVariant &value)
115 | {
116 | if(column == 0)
117 | itemData = value.toString();
118 | else
119 | return false;
120 |
121 | return true;
122 | }
123 |
124 | void KeyTreeItem::sort(Qt::SortOrder order) {
125 | if(order == Qt::AscendingOrder)
126 | std::sort(childItems.begin(),childItems.end(),compareTreeItemAsc);
127 | else
128 | std::sort(childItems.begin(),childItems.end(),compareTreeItemDesc);
129 | }
130 |
131 | void KeyDbTreeItem::setIconId(const qint8 &value)
132 | {
133 | iconId = value;
134 | }
135 |
136 | qint8 KeyDbTreeItem::getIconId() const
137 | {
138 | return iconId;
139 | }
140 |
141 | bool KeyDbTreeItem::haveIcon() {
142 | return true;
143 | }
144 |
--------------------------------------------------------------------------------
/src/RedisView/Model/KeyTreeItem.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file KeyTreeItem.h
3 | * @brief 树项
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef KEYTREEITEM_H
10 | #define KEYTREEITEM_H
11 | #include
12 |
13 | class KeyTreeItem
14 | {
15 | public:
16 | explicit KeyTreeItem(const QString &data = "", KeyTreeItem *parent = nullptr);
17 | virtual ~KeyTreeItem();
18 |
19 | KeyTreeItem *child(int number);
20 | int childCount() const;
21 | int columnCount() const;
22 | QVariant data(int column) const;
23 | void appendChildren(KeyTreeItem *item);
24 | KeyTreeItem *parent();
25 | bool removeChildren(int position, int count);
26 | int childNumber() const;
27 | bool setData(int column, const QVariant &value);
28 | QString text();
29 | void clear();
30 | void sort(Qt::SortOrder order = Qt::AscendingOrder);
31 | virtual bool haveIcon();
32 | virtual void setIconId(const qint8 &value);
33 | virtual qint8 getIconId() const;
34 | private:
35 |
36 | QString itemData;
37 | KeyTreeItem *parentItem;
38 | QList childItems;
39 | };
40 |
41 | class KeyDbTreeItem : public KeyTreeItem {
42 | public:
43 | explicit KeyDbTreeItem(const QString &data = "", KeyTreeItem *parent = nullptr)
44 | : KeyTreeItem(data,parent) {}
45 | void setIconId(const qint8 &value);
46 | qint8 getIconId() const;
47 | bool haveIcon();
48 |
49 | private:
50 | qint8 iconId;
51 | };
52 |
53 | #endif // KEYTREEITEM_H
54 |
--------------------------------------------------------------------------------
/src/RedisView/Model/KeyTreeModel.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file KeyTreeModel.cpp
3 | * @brief 树模型
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "Model/KeyTreeModel.h"
10 |
11 | KeyTreeModel::KeyTreeModel(QObject *parent)
12 | : QAbstractItemModel(parent)
13 | {
14 | headerInfo = "KEY";
15 | conicon = new QIcon(ICON_LONGIN);
16 | dbicon = new QIcon(ICON_DB);
17 | keyicon = new QIcon(ICON_KEY);
18 | rootItem = new KeyTreeItem(headerInfo);
19 | }
20 |
21 | KeyTreeModel::~KeyTreeModel()
22 | {
23 | if(rootItem) {
24 | delete rootItem;
25 | rootItem = nullptr;
26 | }
27 | }
28 |
29 | void KeyTreeModel::setRootItem(KeyTreeItem * item) {
30 | beginResetModel();
31 | if(rootItem)
32 | delete rootItem;
33 | rootItem = item;
34 | endResetModel();
35 | }
36 |
37 | void KeyTreeModel::clear() {
38 | beginResetModel();
39 | rootItem->clear();
40 | endResetModel();
41 | }
42 |
43 | int KeyTreeModel::columnCount(const QModelIndex &) const
44 | {
45 | return rootItem->columnCount();
46 | }
47 |
48 | QVariant KeyTreeModel::data(KeyTreeItem * item) const
49 | {
50 | if (!item)
51 | return QVariant();
52 |
53 | return item->data(0);
54 | }
55 |
56 | QVariant KeyTreeModel::data(const QModelIndex &index, int role) const
57 | {
58 | if (!index.isValid())
59 | return QVariant();
60 |
61 | KeyTreeItem *item = getItem(index);
62 | switch(role) {
63 | case Qt::DisplayRole:
64 | case Qt::EditRole:
65 | return item->data(index.column());
66 | case Qt::DecorationRole :
67 | if(item->haveIcon()) {
68 | if(item->getIconId() == 1)
69 | return *conicon;
70 | else if(item->getIconId() == 2) {
71 | return *dbicon;
72 | }
73 | } else {
74 | return *keyicon;
75 | }
76 | }
77 | return QVariant();
78 | }
79 |
80 | void KeyTreeModel::sort(int column, Qt::SortOrder order) {
81 | Q_UNUSED(column)
82 | recurSortItem(rootItem, order);
83 | }
84 |
85 | void KeyTreeModel::recurSortItem(KeyTreeItem *item, Qt::SortOrder order) {
86 | if(item == nullptr)
87 | return;
88 |
89 | if(item->childCount() == 0)
90 | return;
91 |
92 | for(int i = 0; i < item->childCount(); ++i) {
93 | sortItem(item->child(i),order);
94 | recurSortItem(item->child(i));
95 | }
96 | }
97 |
98 | void KeyTreeModel::sortItem(KeyTreeItem *item, Qt::SortOrder order) {
99 |
100 | if(item == nullptr)
101 | return;
102 |
103 | if(item->childCount() == 0)
104 | return;
105 |
106 | QModelIndex index = indexFromItem(item);
107 | if(!index.isValid())
108 | return;
109 |
110 | QList indexs;
111 | indexs << index;
112 | emit layoutAboutToBeChanged(indexs, QAbstractItemModel::VerticalSortHint);
113 | item->sort(order);
114 | emit layoutChanged(indexs, QAbstractItemModel::VerticalSortHint);
115 | }
116 |
117 | Qt::ItemFlags KeyTreeModel::flags(const QModelIndex &index) const
118 | {
119 | if (!index.isValid())
120 | return 0;
121 |
122 | return QAbstractItemModel::flags(index);
123 | }
124 |
125 | KeyTreeItem *KeyTreeModel::itemFromIndex(const QModelIndex &index) const {
126 | return index.isValid() ? getItem(index): nullptr;
127 | }
128 |
129 | QModelIndex KeyTreeModel::indexFromItem(const KeyTreeItem *item) const {
130 | if(!item || item == rootItem)
131 | return QModelIndex();
132 |
133 | return createIndex(item->childNumber(), 0, const_cast(item));
134 | }
135 |
136 | KeyTreeItem *KeyTreeModel::getItem(const QModelIndex &index) const
137 | {
138 | if (index.isValid()) {
139 | KeyTreeItem *item = static_cast(index.internalPointer());
140 | if (item)
141 | return item;
142 | }
143 | return rootItem;
144 | }
145 |
146 | KeyTreeItem *KeyTreeModel::getRootItem() const
147 | {
148 | return rootItem;
149 | }
150 |
151 | QVariant KeyTreeModel::headerData(int section, Qt::Orientation orientation,
152 | int role) const
153 | {
154 | Q_UNUSED(section)
155 | if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
156 | return headerInfo;
157 |
158 | return QVariant();
159 | }
160 |
161 | QModelIndex KeyTreeModel::index(int row, int column, const QModelIndex &parent) const
162 | {
163 | if(!hasIndex(row, column, parent))
164 | return QModelIndex();
165 |
166 | KeyTreeItem *parentItem = getItem(parent);
167 | KeyTreeItem *childItem = parentItem->child(row);
168 | if (childItem)
169 | return createIndex(row, column, childItem);
170 | else
171 | return QModelIndex();
172 | }
173 |
174 | bool KeyTreeModel::removeChild(KeyTreeItem * item, int row) {
175 | if(item) {
176 | QModelIndex itemQModel = indexFromItem(item);
177 | return removeRows(row, 1, itemQModel);
178 | }
179 | return false;
180 | }
181 |
182 | bool KeyTreeModel::removeChild(KeyTreeItem * item) {
183 | if(item) {
184 | QModelIndex itemQModel = indexFromItem(item);
185 | return removeRows(0, item->childCount(),itemQModel);
186 | }
187 | return false;
188 | }
189 |
190 | bool KeyTreeModel::insertRow(KeyTreeItem *item) {
191 | if(item && item->parent()) {
192 | QModelIndex parentQModel = indexFromItem(item->parent());
193 | beginInsertRows(parentQModel, item->parent()->childCount(), item->parent()->childCount());
194 | item->parent()->appendChildren(item);
195 | endInsertRows();
196 | return true;
197 | }
198 | return false;
199 | }
200 |
201 | QModelIndex KeyTreeModel::parent(const QModelIndex &index) const
202 | {
203 | if (!index.isValid())
204 | return QModelIndex();
205 |
206 | KeyTreeItem *childItem = getItem(index);
207 | if(childItem == nullptr)
208 | return QModelIndex();
209 |
210 | KeyTreeItem *parentItem = childItem->parent();
211 |
212 | if (parentItem == nullptr || parentItem == rootItem)
213 | return QModelIndex();
214 |
215 | if(parentItem->parent() == nullptr)
216 | return QModelIndex();
217 |
218 | return createIndex(parentItem->childNumber(), 0, parentItem);
219 | }
220 |
221 | bool KeyTreeModel::removeRows(int position, int rows, const QModelIndex &parent)
222 | {
223 | if(rows <= 0)
224 | return false;
225 |
226 | KeyTreeItem *parentItem = getItem(parent);
227 | bool success = true;
228 |
229 | beginRemoveRows(parent, position, position + rows - 1);
230 | success = parentItem->removeChildren(position, rows);
231 | endRemoveRows();
232 |
233 | return success;
234 | }
235 |
236 | int KeyTreeModel::rowCount(const QModelIndex &parent) const
237 | {
238 | KeyTreeItem *parentItem = getItem(parent);
239 | return parentItem->childCount();
240 | }
241 |
242 | bool KeyTreeModel::setText(KeyTreeItem * item, const QString &value) {
243 | return setData(indexFromItem(item),value,Qt::EditRole);
244 | }
245 |
246 | bool KeyTreeModel::setData(const QModelIndex &index, const QVariant &value, int role)
247 | {
248 | if (role != Qt::EditRole)
249 | return false;
250 |
251 | KeyTreeItem *item = getItem(index);
252 | bool result = item->setData(index.column(), value);
253 |
254 | if (result)
255 | emit dataChanged(index, index);
256 |
257 | return result;
258 | }
259 |
260 | bool KeyTreeModel::setHeaderData(int section, Qt::Orientation orientation,
261 | const QVariant &value, int role)
262 | {
263 | if (role != Qt::EditRole || orientation != Qt::Horizontal)
264 | return false;
265 |
266 | headerInfo = value.toString();
267 | emit headerDataChanged(orientation, section, section);
268 | return true;
269 | }
270 |
--------------------------------------------------------------------------------
/src/RedisView/Model/KeyTreeModel.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file KeyTreeModel.h
3 | * @brief 树模型
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef KEYTREEMODEL_H
10 | #define KEYTREEMODEL_H
11 |
12 | #include "Public/Define.h"
13 | #include "KeyTreeItem.h"
14 |
15 | class KeyTreeModel : public QAbstractItemModel
16 | {
17 | Q_OBJECT
18 |
19 | public:
20 |
21 | KeyTreeModel(QObject *parent = nullptr);
22 | ~KeyTreeModel();
23 | QVariant data(KeyTreeItem * item) const;
24 | QVariant data(const QModelIndex &index, int role) const override;
25 | QVariant headerData(int section, Qt::Orientation orientation,
26 | int role = Qt::DisplayRole) const override;
27 | QModelIndex index(int row, int column,
28 | const QModelIndex &parent = QModelIndex()) const override;
29 | QModelIndex parent(const QModelIndex &index) const override;
30 |
31 | int rowCount(const QModelIndex &parent = QModelIndex()) const override;
32 | int columnCount(const QModelIndex &parent = QModelIndex()) const override;
33 |
34 | Qt::ItemFlags flags(const QModelIndex &index) const override;
35 | bool setData(const QModelIndex &index, const QVariant &value,
36 | int role = Qt::EditRole) override;
37 | bool setHeaderData(int section, Qt::Orientation orientation,
38 | const QVariant &value, int role = Qt::EditRole) override;
39 | bool insertRow(KeyTreeItem * item);
40 | bool removeChild(KeyTreeItem * item);
41 | bool removeChild(KeyTreeItem * item, int row);
42 | bool removeRows(int position, int rows,
43 | const QModelIndex &parent = QModelIndex()) override;
44 | void setRootItem(KeyTreeItem * item);
45 | KeyTreeItem *getRootItem() const;
46 | KeyTreeItem *itemFromIndex(const QModelIndex &index) const;
47 | QModelIndex indexFromItem(const KeyTreeItem *item) const;
48 | bool setText(KeyTreeItem * item, const QString &value);
49 | void clear();
50 | KeyTreeItem *getItem(const QModelIndex &index) const;
51 | void sortItem(KeyTreeItem *item, Qt::SortOrder order = Qt::AscendingOrder);
52 | void recurSortItem(KeyTreeItem *item, Qt::SortOrder order = Qt::AscendingOrder);
53 | void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
54 |
55 | private:
56 |
57 | QIcon * conicon;
58 | QIcon * dbicon;
59 | QIcon * keyicon;
60 | KeyTreeItem *rootItem;
61 | QString headerInfo;
62 | };
63 |
64 | #endif // KEYTREEMODEL_H
65 |
--------------------------------------------------------------------------------
/src/RedisView/Model/ValueTableItem.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file ValueTableItem.cpp
3 | * @brief 表项
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "Model/ValueTableItem.h"
10 |
11 | int globalColumn = 0;
12 |
13 | bool compareTableItemAsc(ValueTableItem * &item1, ValueTableItem * &item2)
14 | {
15 | if (item1->text(globalColumn) < item2->text(globalColumn))
16 | {
17 | return true;
18 | }
19 | return false;
20 | }
21 |
22 | bool compareTableItemDesc(ValueTableItem * &item1, ValueTableItem * &item2)
23 | {
24 | if (item1->text(globalColumn) < item2->text(globalColumn))
25 | {
26 | return false;
27 | }
28 | return true;
29 | }
30 |
31 | ValueTableItem::ValueTableItem() {
32 | }
33 |
34 | ValueTableItem::ValueTableItem(const QString &text) {
35 | if(itemData.size() > 0)
36 | itemData[0] = QVariant(text);
37 | else
38 | itemData.push_back(QVariant(text));
39 | }
40 |
41 | ValueTableItem::ValueTableItem(const QVector &data)
42 | {
43 | itemData = data;
44 | }
45 |
46 | ValueTableItem::~ValueTableItem()
47 | {
48 | qDeleteAll(childItems);
49 | childItems.clear();
50 | }
51 |
52 | void ValueTableItem::setData(const QVector &data) {
53 | itemData.clear();
54 | itemData = data;
55 | }
56 |
57 | ValueTableItem *ValueTableItem::child(int number)
58 | {
59 | if(number >= childItems.count())
60 | return nullptr;
61 | return childItems.value(number);
62 | }
63 |
64 | int ValueTableItem::childCount() const
65 | {
66 | return childItems.count();
67 | }
68 |
69 | int ValueTableItem::columnCount() const
70 | {
71 | return itemData.count();
72 | }
73 |
74 | QVariant ValueTableItem::data(int column) const
75 | {
76 | if(column < 0 || column >= itemData.count())
77 | return QVariant();
78 | return itemData.value(column);
79 | }
80 |
81 | bool ValueTableItem::setData(int column, const QVariant &value)
82 | {
83 | if (column < 0 || column >= itemData.size())
84 | return false;
85 |
86 | itemData[column] = value;
87 | return true;
88 | }
89 |
90 | bool ValueTableItem::insertChildren(int position, ValueTableItem * &item)
91 | {
92 | if (position < 0 || position > childItems.size())
93 | return false;
94 |
95 | childItems.insert(position, item);
96 | return true;
97 | }
98 |
99 | bool ValueTableItem::removeChildren(int position)
100 | {
101 | if (position < 0 || position >= childItems.size())
102 | return false;
103 |
104 | delete childItems.takeAt(position);
105 |
106 | return true;
107 | }
108 |
109 | bool ValueTableItem::removeItem(ValueTableItem *item) {
110 | if(childItems.removeOne(item)) {
111 | if(item) {
112 | delete item;
113 | item = nullptr;
114 | }
115 | } else
116 | return false;
117 | return true;
118 | }
119 |
120 | int ValueTableItem::childNumber(ValueTableItem * item) const
121 | {
122 | return childItems.indexOf(item);
123 | }
124 |
125 | QString ValueTableItem::text(int column) {
126 | if (column < 0 || column >= itemData.size())
127 | return "";
128 | else
129 | return itemData[column].toString();
130 | }
131 |
132 | void ValueTableItem::clear() {
133 | qDeleteAll(childItems);
134 | childItems.clear();
135 | }
136 |
137 | void ValueTableItem::sort(int column, Qt::SortOrder order) {
138 | globalColumn = column;
139 | if(order == Qt::AscendingOrder)
140 | std::sort(childItems.begin(),childItems.end(),compareTableItemAsc);
141 | else
142 | std::sort(childItems.begin(),childItems.end(),compareTableItemDesc);
143 | }
144 |
--------------------------------------------------------------------------------
/src/RedisView/Model/ValueTableItem.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file ValueTableItem.h
3 | * @brief 表项
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef VALUETABLEITEM_H
10 | #define VALUETABLEITEM_H
11 |
12 | #include "Public/Define.h"
13 |
14 | class ValueTableItem
15 | {
16 | public:
17 | explicit ValueTableItem();
18 | explicit ValueTableItem(const QString &text);
19 | explicit ValueTableItem(const QVector &data);
20 | ~ValueTableItem();
21 |
22 | ValueTableItem *child(int number);
23 | int childCount() const;
24 | int columnCount() const;
25 | int childNumber(ValueTableItem *item) const;
26 | QVariant data(int column) const;
27 | bool setData(int column, const QVariant &value);
28 | void setData(const QVector &data);
29 | bool insertChildren(int position, ValueTableItem *&item);
30 | bool removeChildren(int position);
31 | bool removeItem(ValueTableItem *item);
32 | QString text(int column = 0);
33 | void clear();
34 | void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
35 |
36 | private:
37 | QList childItems;
38 | QVector itemData;
39 | };
40 |
41 | #endif // VALUETABLEITEM_H
42 |
--------------------------------------------------------------------------------
/src/RedisView/Model/ValueTableModel.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file ValueTableModel.cpp
3 | * @brief 表模型
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "Model/ValueTableModel.h"
10 |
11 | ValueTableModel::ValueTableModel(QObject *parent) :
12 | QAbstractTableModel(parent)
13 | {
14 | rootItem = new ValueTableItem();
15 | }
16 |
17 | ValueTableModel::~ValueTableModel()
18 | {
19 | if(rootItem) {
20 | delete rootItem;
21 | rootItem = nullptr;
22 | }
23 | }
24 |
25 | int ValueTableModel::rowCount(const QModelIndex &parent) const
26 | {
27 | Q_UNUSED(parent);
28 | return rootItem->childCount();
29 | }
30 |
31 | int ValueTableModel::columnCount(const QModelIndex &parent) const
32 | {
33 | Q_UNUSED(parent);
34 | return _column;
35 | }
36 |
37 | QVariant ValueTableModel::data(const QModelIndex &index, int role) const
38 | {
39 | if (!index.isValid()) {
40 | return QVariant();
41 | }
42 |
43 | if (role == Qt::DisplayRole || role == Qt::EditRole) {
44 | ValueTableItem *item =rootItem->child(index.row());
45 | if(!item)
46 | return QVariant();
47 | return item->data(index.column());
48 | } else {
49 | return QVariant();
50 | }
51 | }
52 |
53 | bool ValueTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
54 | {
55 | if (!index.isValid() || role != Qt::EditRole) {
56 | return false;
57 | }
58 |
59 | ValueTableItem *item = rootItem->child(index.row());
60 | if(!item)
61 | return false;
62 |
63 | if(item->setData(index.column(),value)) {
64 | emit dataChanged(index, index);
65 | emit itemChanged(item, index.column());
66 | return true;
67 | }
68 | return false;
69 | }
70 |
71 | QVariant ValueTableModel::headerData(int section, Qt::Orientation orientation, int role) const
72 | {
73 | if (role != Qt::DisplayRole) {
74 | return QVariant();
75 | }
76 |
77 | if (orientation == Qt::Vertical) {
78 | return section + 1;
79 | }
80 |
81 | if(section < 0 || section >= rootItem->columnCount())
82 | return QVariant();
83 |
84 | return rootItem->data(section);
85 | }
86 |
87 | bool ValueTableModel::setHeaderData(int section, Qt::Orientation orientation,
88 | const QVariant &value, int role)
89 | {
90 | if (role != Qt::EditRole || orientation != Qt::Horizontal)
91 | return false;
92 |
93 | if(rootItem->setData(section,value)) {
94 | emit headerDataChanged(orientation, section, section);
95 | return true;
96 | }
97 | return false;
98 | }
99 |
100 | void ValueTableModel::setColumnCount(int column) {
101 | _column = column;
102 | QVector data;
103 | flagsData.clear();
104 | for(int i = 0; i < column; ++i) {
105 | data.push_back(QVariant());
106 | flagsData.push_back(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
107 | }
108 | rootItem->setData(data);
109 | }
110 |
111 | Qt::ItemFlags ValueTableModel::flags(int column) {
112 | if(column >= flagsData.size())
113 | return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
114 | return flagsData[column];
115 | }
116 |
117 | bool ValueTableModel::setFlags(int column, Qt::ItemFlags flags) {
118 | if(column >= flagsData.size())
119 | return false;
120 | flagsData[column] = flags;
121 | return true;
122 | }
123 |
124 | void ValueTableModel::setHeaderData(const QVector &data) {
125 | rootItem->setData(data);
126 | }
127 |
128 | bool ValueTableModel::insertRow(ValueTableItem *item) {
129 | beginInsertRows(QModelIndex(), rootItem->childCount(), rootItem->childCount());
130 | bool success = rootItem->insertChildren(rootItem->childCount(), item);
131 | endInsertRows();
132 | return success;
133 | }
134 |
135 | bool ValueTableModel::insertRow(int position, ValueTableItem * &item)
136 | {
137 | beginInsertRows(QModelIndex(), position, position);
138 | bool success = rootItem->insertChildren(position, item);
139 | endInsertRows();
140 | return success;
141 | }
142 |
143 | bool ValueTableModel::removeRow(int position)
144 | {
145 | beginRemoveRows(QModelIndex(), position, position);
146 | bool success = rootItem->removeChildren(position);
147 | endRemoveRows();
148 | return success;
149 | }
150 |
151 | bool ValueTableModel::removeItem(ValueTableItem *item)
152 | {
153 | if(!item)
154 | return false;
155 | beginRemoveRows(QModelIndex(), rootItem->childNumber(item), rootItem->childNumber(item));
156 | bool success = rootItem->removeItem(item);
157 | endRemoveRows();
158 | return success;
159 | }
160 |
161 | int ValueTableModel::childNumber(ValueTableItem * item) const
162 | {
163 | return rootItem->childNumber(item);
164 | }
165 |
166 | ValueTableItem * ValueTableModel::item(int row) {
167 | return rootItem->child(row);
168 | }
169 |
170 | void ValueTableModel::clear() {
171 | beginResetModel();
172 | rootItem->clear();
173 | _column = 0;
174 | flagsData.clear();
175 | endResetModel();
176 | }
177 |
178 | Qt::ItemFlags ValueTableModel::flags(const QModelIndex &index) const
179 | {
180 | if (!index.isValid())
181 | return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
182 | if(index.column() >= flagsData.size())
183 | return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
184 | return flagsData[index.column()];
185 | }
186 |
187 | void ValueTableModel::sort(int column, Qt::SortOrder order) {
188 | QList indexs;
189 | indexs << QModelIndex();
190 | emit layoutAboutToBeChanged(indexs, QAbstractItemModel::VerticalSortHint);
191 | rootItem->sort(column, order);
192 | emit layoutChanged(indexs, QAbstractItemModel::VerticalSortHint);
193 | }
194 |
--------------------------------------------------------------------------------
/src/RedisView/Model/ValueTableModel.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file ValueTableModel.h
3 | * @brief 表模型
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef VALUETABLEMODEL_H
10 | #define VALUETABLEMODEL_H
11 |
12 | #include "Model/ValueTableItem.h"
13 |
14 | class ValueTableModel : public QAbstractTableModel
15 | {
16 | Q_OBJECT
17 | public:
18 |
19 | ValueTableModel(QObject *parent = nullptr);
20 | ~ValueTableModel();
21 | int rowCount(const QModelIndex &parent = QModelIndex()) const override;
22 | int columnCount(const QModelIndex &parent = QModelIndex()) const override;
23 | QVariant data(const QModelIndex &index, int role) const override;
24 | bool setData(const QModelIndex &index, const QVariant &value, int role) override;
25 | QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
26 | bool setHeaderData(int section, Qt::Orientation orientation,
27 | const QVariant &value, int role = Qt::EditRole) override;
28 | void setHeaderData(const QVector &data);
29 | bool insertRow(ValueTableItem * item);
30 | bool insertRow(int position, ValueTableItem *&item);
31 | bool removeRow(int position);
32 | bool removeItem(ValueTableItem *item);
33 | int childNumber(ValueTableItem *item) const;
34 | ValueTableItem * item(int row);
35 | void clear();
36 | void setColumnCount(int column);
37 | Qt::ItemFlags flags(const QModelIndex &index) const override;
38 | Qt::ItemFlags flags(int column);
39 | bool setFlags(int column, Qt::ItemFlags flags);
40 | void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
41 |
42 | signals:
43 | void itemChanged(ValueTableItem *item, int column);
44 |
45 | private:
46 |
47 | int _column;
48 | QVector flagsData;
49 | ValueTableItem *rootItem;
50 | };
51 |
52 | #endif // VALUETABLEMODEL_H
53 |
--------------------------------------------------------------------------------
/src/RedisView/Public/AesEncrypt.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file AesEncrypt.cpp
3 | * @brief AES加解密工具
4 | * @author 王长春
5 | * @date 2019-05-31
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "AesEncrypt.h"
10 |
11 | QByteArray AesEncrypt::CBC256Crypt(QString inputStr) {
12 | QaesEncryption encryption(QaesEncryption::AES_256, QaesEncryption::CBC);
13 | return encryption.encode(inputStr.toLocal8Bit(),
14 | _hashKey, _hashIV);
15 | }
16 |
17 | QString AesEncrypt::CBC256Decrypt(QByteArray inputStr) {
18 | QaesEncryption encryption(QaesEncryption::AES_256, QaesEncryption::CBC);
19 | return QString(encryption.removePadding(
20 | encryption.decode(inputStr, _hashKey, _hashIV)));
21 | }
22 |
23 | QString AesEncrypt::_key =
24 | "@D@6`Ht`T`xPXD|6T``TxDPd|@`7x@p1PPHPXTXX@Lld7D|XdHhdgL3dl|XtL"
25 | "DpdhDdl3h|d|TLL|`lHH3xlTpL@|lH`TPxdh@Ptlh0tpHhtdxDtllhPp@h@xP"
26 | "`l|t`4DtDLht`|`Tdt|tDPDTxtHTHp|lD9t@l|h`LtTl`hx3Ll|P`DXDhtXD|"
27 | "ht@dXx|pxdH1t7|`PlP@HH4HP|@xd|LphllXpLlh32xp@3DhXtxtx@dPTtTXH"
28 | "|x@lTtDTt@Tt@TtpPLPxtX3hX`X`Lhxx1l|Hp@pHdhxTLldpdp|DHxDXpHxLP"
29 | "l|@x3PLhpXHT`t@TXldT5TPXPLt@p@@xDtxhXtXHxxT9pDlxH3l@tx|XpDlDX"
30 | "3t|`txH|8X3hLh`|hdhTHPlDH|T|p@@|`6dhpTxDtPt@||`9X|@@hDptT|pHL"
31 | "hdXhhdTDxHphllX`0xxLd|dDHxXp|LLdplT|HDX@PhpP`xhXP|lptX`D`@`1d"
32 | "hDD3p@X@lhdxPXPDxLDhdlxpXdDLTppxD`|ff0e92h3ddv45245f4vfdhgrar";
33 |
34 | QByteArray AesEncrypt::_hashKey = QCryptographicHash::hash(_key.toLocal8Bit(), QCryptographicHash::Sha256);
35 |
36 | QByteArray AesEncrypt::_hashIV = QCryptographicHash::hash(_key.toLocal8Bit(), QCryptographicHash::Md5);
37 |
38 |
39 |
--------------------------------------------------------------------------------
/src/RedisView/Public/AesEncrypt.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file AesEncrypt.h
3 | * @brief AES加解密工具
4 | * @author 王长春
5 | * @date 2019-05-31
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef AESENCRYPT_H
10 | #define AESENCRYPT_H
11 |
12 | #include "Public/QaesEncryption.h"
13 | //加密库crypto
14 | //对称加密(单密钥加密):同一个密钥可以同时用来加密和解密,常用算法低级到高级DES 3DES AES
15 | //非对称加密:公钥与私钥是一对,用公钥对数据进行加密,只有用对应的私钥才能解密,常用算法RSA
16 | //哈希算法(散列算法):md5不是加密,是不可逆的哈希算法
17 | class AesEncrypt
18 | {
19 | public:
20 | static QByteArray CBC256Crypt(QString inputStr);
21 | static QString CBC256Decrypt(QByteArray inputStr);
22 |
23 | private:
24 | static QByteArray _hashKey;
25 | static QByteArray _hashIV;
26 | static QString _key;
27 | };
28 |
29 | #endif // AESENCRYPT_H
30 |
--------------------------------------------------------------------------------
/src/RedisView/Public/DbMgr.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file DbMgr.cpp
3 | * @brief 数据库连接
4 | * @author 王长春
5 | * @date 2019-06-28
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "DbMgr.h"
10 |
11 | DbMgr::DbMgr()
12 | {
13 |
14 | }
15 |
16 | QString DbMgr::host()
17 | {
18 | return _host;
19 | }
20 |
21 | void DbMgr::setHost(const QString &host)
22 | {
23 | _host = host;
24 | }
25 |
26 | QString DbMgr::user()
27 | {
28 | return _user;
29 | }
30 |
31 | void DbMgr::setUser(const QString &user)
32 | {
33 | _user = user;
34 | }
35 |
36 | QString DbMgr::passwd()
37 | {
38 | return _passwd;
39 | }
40 |
41 | void DbMgr::setPasswd(const QString &passwd)
42 | {
43 | _passwd = passwd;
44 | }
45 |
46 | QString DbMgr::database()
47 | {
48 | return _database;
49 | }
50 |
51 | void DbMgr::setDatabase(const QString &database)
52 | {
53 | _database = database;
54 | }
55 |
56 | QString DbMgr::dbport()
57 | {
58 | return _dbport;
59 | }
60 |
61 | void DbMgr::setDbport(const QString &dbport)
62 | {
63 | _dbport = dbport;
64 | }
65 |
66 | QString DbMgr::dbdrive()
67 | {
68 | return _dbdrive;
69 | }
70 |
71 | void DbMgr::setDbdrive(const QString &dbdrive)
72 | {
73 | _dbdrive = dbdrive;
74 | }
75 |
76 | void DbMgr::close(QString lable) {
77 |
78 | if(lable.isEmpty())
79 | lable = _lable;
80 |
81 | if(_lable.isEmpty())
82 | return;
83 |
84 | QMutexLocker locker(&G_DB_MUTEX);
85 |
86 | if(QSqlDatabase::contains(lable)) {
87 | QSqlDatabase::database(lable).close();
88 | QSqlDatabase::removeDatabase(lable);
89 | }
90 | }
91 |
92 | bool DbMgr::getDb(QSqlDatabase *db, QString lable) {
93 |
94 | // 官方说MYSQ线程安全,假的
95 | // Qt动态的加载数据库的plugin,涉及到对本地库文件的管理,出现了竞争
96 | QMutexLocker locker(&G_DB_MUTEX);
97 | if(lable.isEmpty())
98 | lable = _lable;
99 |
100 | if(_lable.isEmpty()) {
101 | setError(QObject::tr("数据库连接名为空"));
102 | return false;
103 | }
104 |
105 | if(QSqlDatabase::contains(lable)) {
106 | *db = QSqlDatabase::database(lable);
107 | return true;
108 | }
109 |
110 | *db = QSqlDatabase::addDatabase(_dbdrive, lable);
111 | db->setHostName(_host);
112 | db->setUserName(_user);
113 | db->setPassword(_passwd);
114 | db->setPort(_dbport.toInt());
115 | db->setDatabaseName(_database);
116 | if(db->open() == false) {
117 | setError(db->lastError().text().toUtf8());
118 | return false;
119 | }
120 | return true;
121 | }
122 |
123 | bool DbMgr::setCfg(int dbtype, QString drive) {
124 | if(drive.isEmpty()) {
125 | setError(QObject::tr("错误,数据库驱动为空"));
126 | return false;
127 | }
128 | setDbtype(dbtype);
129 | setDbdrive(drive);
130 |
131 | QString sPath = QCoreApplication::applicationDirPath() + "/" + IniFileName;
132 | QSettings settings(sPath, QSettings::IniFormat);
133 | settings.setIniCodec("UTF-8");
134 |
135 | QString lasttag = settings.value(QString("lastUseTag%1").arg(_dbtype)).toString();
136 | int size = 0;
137 | DbCfg dbcfg;
138 |
139 | if(_dbtype == ORACLE_DB)
140 | size = settings.beginReadArray(CORACLE_DB);
141 | else if(_dbtype == MYSQL_DB)
142 | size = settings.beginReadArray(CMYSQL_DB);
143 |
144 | for(int i = 0; i < size; ++i) {
145 | settings.setArrayIndex(i);
146 | dbcfg.userName = settings.value("userName").toString().trimmed();
147 | dbcfg.encodePasswd = settings.value("passWord").toByteArray();
148 | dbcfg.password = AesEncrypt::CBC256Decrypt(dbcfg.encodePasswd).trimmed();
149 | dbcfg.database = settings.value("dataBase").toString().trimmed();
150 | dbcfg.encodeHostname = settings.value("hostName").toByteArray();
151 | dbcfg.hostname = AesEncrypt::CBC256Decrypt(dbcfg.encodeHostname).trimmed();
152 | dbcfg.port = settings.value("dbPort").toString().trimmed();
153 | dbcfg.tagname = settings.value("tagname").toString().trimmed();
154 | if(!dbcfg.tagname.isEmpty()) {
155 | if(dbcfg.tagname == lasttag) {
156 | size = -1;
157 | setUser(dbcfg.userName);
158 | setPasswd(dbcfg.password);
159 | setDatabase(dbcfg.database);
160 | setHost(dbcfg.hostname);
161 | setDbport(dbcfg.port);
162 | setLable(dbcfg.tagname);
163 | break;
164 | }
165 | }
166 | }
167 | settings.endArray();
168 |
169 | if(size != -1) {
170 | setError(QObject::tr("错误,数据库配置读取失败"));
171 | return false;
172 | }
173 | return true;
174 | }
175 |
176 | int DbMgr::getDbtype() const
177 | {
178 | return _dbtype;
179 | }
180 |
181 | void DbMgr::setDbtype(int dbtype)
182 | {
183 | _dbtype = dbtype;
184 | }
185 |
186 | QString DbMgr::lable()
187 | {
188 | return _lable;
189 | }
190 |
191 | void DbMgr::setLable(const QString &lable)
192 | {
193 | _lable = lable;
194 | }
195 |
196 | QString DbMgr::error()
197 | {
198 | return _error;
199 | }
200 |
201 | void DbMgr::setError(const QString &error)
202 | {
203 | _error = error;
204 | }
205 |
--------------------------------------------------------------------------------
/src/RedisView/Public/DbMgr.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file DbMgr.h
3 | * @brief 数据库连接
4 | * @author 王长春
5 | * @date 2019-06-28
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef DBMGR_H
10 | #define DBMGR_H
11 |
12 | #include "Public/Define.h"
13 |
14 | class DbMgr
15 | {
16 |
17 | public:
18 | DbMgr();
19 |
20 | QString host();
21 | void setHost(const QString &host);
22 |
23 | QString user();
24 | void setUser(const QString &user);
25 |
26 | QString passwd();
27 | void setPasswd(const QString &passwd);
28 |
29 | QString database();
30 | void setDatabase(const QString &database);
31 |
32 | QString dbport();
33 | void setDbport(const QString &dbport);
34 |
35 | QString dbdrive();
36 | void setDbdrive(const QString &dbdrive);
37 |
38 | QString error();
39 | void setError(const QString &error);
40 |
41 | QString lable();
42 | void setLable(const QString &lable);
43 |
44 | bool getDb(QSqlDatabase *db, QString lable = "");
45 |
46 | int getDbtype() const;
47 | void setDbtype(int dbtype);
48 |
49 | bool setCfg(int dbtype,QString drive);
50 |
51 | void close(QString lable = "");
52 |
53 |
54 | private:
55 | int _dbtype;
56 | QString _lable;
57 | QString _host;
58 | QString _user;
59 | QString _passwd;
60 | QString _database;
61 | QString _dbport;
62 | QString _dbdrive;
63 | QString _error;
64 |
65 | };
66 |
67 | #endif // DBMGR_H
68 |
--------------------------------------------------------------------------------
/src/RedisView/Public/Define.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file Define.cpp
3 | * @brief 公共定义
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "Define.h"
10 |
11 | QMutex G_DB_MUTEX;
12 | QMutex G_SEQUENCE_MUTEX;
13 | QMutex G_PUBLIC_LIB_MUTEX;
14 |
15 | Global::Global() {
16 | }
17 | Global::~Global() {
18 | }
19 |
20 | QString Global::gEncode = "";
21 | QString Global::gConnectName = "";
22 | QString Global::gTheme = "";
23 | QTranslator * Global::gTrans = nullptr;
24 |
25 |
--------------------------------------------------------------------------------
/src/RedisView/Public/Log.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file Log.cpp
3 | * @brief 公共日志库
4 | * @author 王长春
5 | * @date 2022-08-25
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #include "Log.h"
10 |
11 |
12 | void Log::Trace(QString info){
13 | QString message = QString("[%1] [TRACE]: %2\r\n")
14 | .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss"))
15 | .arg(info);
16 | PubLib::log(message);
17 | }
18 |
19 | void Log::Debug(QString info){
20 | QString message = QString("[%1] [DEBUG]: %2\r\n")
21 | .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss"))
22 | .arg(info);
23 | PubLib::log(message);
24 | }
25 |
26 | void Log::Info(QString info){
27 | QString message = QString("[%1] [INFO]: %2\r\n")
28 | .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss"))
29 | .arg(info);
30 | PubLib::log(message);
31 | }
32 |
33 | void Log::Warn(QString info){
34 | QString message = QString("[%1] [WARN]: %2\r\n")
35 | .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss"))
36 | .arg(info);
37 | PubLib::log(message);
38 | }
39 |
40 | void Log::Error(QString info){
41 | QString message = QString("[%1] [ERROR]: %2\r\n")
42 | .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss"))
43 | .arg(info);
44 | PubLib::log(message);
45 | }
46 |
47 | void Log::Fatal(QString info){
48 | QString message = QString("[%1] [FATAL]: %2\r\n")
49 | .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss"))
50 | .arg(info);
51 | PubLib::log(message);
52 | }
53 |
--------------------------------------------------------------------------------
/src/RedisView/Public/Log.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file Log.h
3 | * @brief 公共日志库
4 | * @author 王长春
5 | * @date 2022-08-25
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef LOG_H
10 | #define LOG_H
11 |
12 | #include "Publib.h"
13 |
14 | class Log
15 | {
16 | public:
17 | static void Trace(QString info);
18 | static void Debug(QString info);
19 | static void Info(QString info);
20 | static void Warn(QString info);
21 | static void Error(QString info);
22 | static void Fatal(QString info);
23 | };
24 |
25 | #endif // LOG_H
26 |
--------------------------------------------------------------------------------
/src/RedisView/Public/Publib.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file Publib.h
3 | * @brief 公共函数库
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef PUBLIB_H
10 | #define PUBLIB_H
11 |
12 | #include "Public/Define.h"
13 |
14 | class PubLib
15 | {
16 | public:
17 | static void getList(const QString & str, QList & strList);
18 | static void setConfig(const QString & key, const QString & value);
19 | static QString getConfig(const QString & key, const QString &defaultValue = "");
20 | static void setConfigB(const QString & key, const bool & value);
21 | static bool getConfigB(const QString & key, const bool &defaultValue = false);
22 | static void setSequenceId(qlonglong sequenceId);
23 | static int getKeyType(const QByteArray & type);
24 | static qlonglong getSequenceId();
25 | static void log(QString info);
26 | static QStringList getMacAddr();
27 | static QString getCpuId();
28 | static bool checkCode();
29 | static void saveCode(QString code);
30 | static QString getCode();
31 | static QString getSoftCode();
32 | static void setIndexNums(RedisCluster *redisClient, int indexNums);
33 | static int getIndexNums(RedisCluster *redisClient);
34 |
35 | private:
36 | static void _getcpuid(unsigned int CPUInfo[4], unsigned int InfoType);
37 | static void _getcpuidex(unsigned int CPUInfo[4], unsigned int InfoType, unsigned int ECXValue);
38 | static qlonglong _sequenceId;
39 | };
40 |
41 | #endif // PUBLIB_H
42 |
--------------------------------------------------------------------------------
/src/RedisView/Public/QaesEncryption.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file QaesEncryption.h
3 | * @brief AES加解密
4 | * @author https://github.com/bricke/Qt-AES
5 | * @date 2019-05-31
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef QAESENCRYPTION_H
10 | #define QAESENCRYPTION_H
11 |
12 | #include
13 | #include
14 | #include
15 |
16 | class QaesEncryption : public QObject
17 | {
18 | Q_OBJECT
19 | public:
20 | enum Aes {
21 | AES_128,
22 | AES_192,
23 | AES_256
24 | };
25 |
26 | enum Mode {
27 | ECB,
28 | CBC,
29 | CFB,
30 | OFB
31 | };
32 |
33 | enum Padding {
34 | ZERO,
35 | PKCS7,
36 | ISO
37 | };
38 |
39 | static QByteArray Crypt(QaesEncryption::Aes level, QaesEncryption::Mode mode, const QByteArray &rawText, const QByteArray &key,
40 | const QByteArray &iv = NULL, QaesEncryption::Padding padding = QaesEncryption::ISO);
41 | static QByteArray Decrypt(QaesEncryption::Aes level, QaesEncryption::Mode mode, const QByteArray &rawText, const QByteArray &key,
42 | const QByteArray &iv = NULL, QaesEncryption::Padding padding = QaesEncryption::ISO);
43 | static QByteArray ExpandKey(QaesEncryption::Aes level, QaesEncryption::Mode mode, const QByteArray &key);
44 | static QByteArray RemovePadding(const QByteArray &rawText, QaesEncryption::Padding padding);
45 |
46 | QaesEncryption(QaesEncryption::Aes level, QaesEncryption::Mode mode,
47 | QaesEncryption::Padding padding = QaesEncryption::ISO);
48 |
49 | QByteArray encode(const QByteArray &rawText, const QByteArray &key, const QByteArray &iv = NULL);
50 | QByteArray decode(const QByteArray &rawText, const QByteArray &key, const QByteArray &iv = NULL);
51 | QByteArray removePadding(const QByteArray &rawText);
52 | QByteArray expandKey(const QByteArray &key);
53 |
54 | signals:
55 |
56 | public slots:
57 |
58 | private:
59 | int m_nb;
60 | int m_blocklen;
61 | int m_level;
62 | int m_mode;
63 | int m_nk;
64 | int m_keyLen;
65 | int m_nr;
66 | int m_expandedKey;
67 | int m_padding;
68 | QByteArray* m_state;
69 |
70 | struct AES256{
71 | int nk = 8;
72 | int keylen = 32;
73 | int nr = 14;
74 | int expandedKey = 240;
75 | };
76 |
77 | struct AES192{
78 | int nk = 6;
79 | int keylen = 24;
80 | int nr = 12;
81 | int expandedKey = 209;
82 | };
83 |
84 | struct AES128{
85 | int nk = 4;
86 | int keylen = 16;
87 | int nr = 10;
88 | int expandedKey = 176;
89 | };
90 |
91 | quint8 getSBoxValue(quint8 num){return sbox[num];}
92 | quint8 getSBoxInvert(quint8 num){return rsbox[num];}
93 |
94 | void addRoundKey(const quint8 round, const QByteArray expKey);
95 | void subBytes();
96 | void shiftRows();
97 | void mixColumns();
98 | void invMixColumns();
99 | void invSubBytes();
100 | void invShiftRows();
101 | QByteArray getPadding(int currSize, int alignment);
102 | QByteArray cipher(const QByteArray &expKey, const QByteArray &plainText);
103 | QByteArray invCipher(const QByteArray &expKey, const QByteArray &plainText);
104 | QByteArray byteXor(const QByteArray &in, const QByteArray &iv);
105 |
106 | const quint8 sbox[256] = {
107 | //0 1 2 3 4 5 6 7 8 9 A B C D E F
108 | 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
109 | 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
110 | 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
111 | 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
112 | 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
113 | 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
114 | 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
115 | 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
116 | 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
117 | 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
118 | 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
119 | 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
120 | 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
121 | 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
122 | 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
123 | 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 };
124 |
125 | const quint8 rsbox[256] = {
126 | 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb,
127 | 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb,
128 | 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e,
129 | 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25,
130 | 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92,
131 | 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84,
132 | 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06,
133 | 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b,
134 | 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73,
135 | 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e,
136 | 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b,
137 | 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4,
138 | 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f,
139 | 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef,
140 | 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61,
141 | 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d };
142 |
143 | // The round constant word array, Rcon[i], contains the values given by
144 | // x to th e power (i-1) being powers of x (x is denoted as {02}) in the field GF(2^8)
145 | // Only the first 14 elements are needed
146 | const quint8 Rcon[14] = {
147 | 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab};
148 | };
149 |
150 | #endif // QAESENCRYPTION_H
151 |
--------------------------------------------------------------------------------
/src/RedisView/Public/WorkThread.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file WorkThread.h
3 | * @brief 线程工作类
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 | #ifndef WORKTHREAD_H
10 | #define WORKTHREAD_H
11 |
12 | #include "Public/DbMgr.h"
13 | #include "Public/Log.h"
14 |
15 | class WorkThread : public QObject, public QRunnable
16 | {
17 | Q_OBJECT
18 | public:
19 | explicit WorkThread(TaskMsg *taskMsg = nullptr, QObject *parent = nullptr);
20 | explicit WorkThread(QList &cmd, TaskMsg *taskMsg = nullptr, QObject *parent = nullptr);
21 |
22 | protected:
23 | void run();
24 |
25 | private:
26 | bool prepare(int mode, bool clusterMode, bool customMode);
27 | bool prepare(int mode = WORK_THREAD_MODE0, int cluster = 0);
28 | void destroy(int mode = WORK_THREAD_MODE0);
29 | bool cancle(int mode = WORK_THREAD_MODE0);
30 | int exportData(std::vector &vImpExpData, int taskid);
31 | int imporData(int taskid);
32 | int deleteData(int taskid);
33 |
34 | private:
35 | int _taskid;
36 | int _thread;
37 | int _dbindex;
38 | TaskMsg *_taskMsg;
39 | TaskMsg _sendMsg;
40 | RedisClient *_redisClient;
41 | RedisCluster *_redisClusterClient;
42 | QString _string;
43 | QString _tableName;
44 | QString _sql;
45 | QByteArray _byteArray;
46 | RespType _respValue;
47 | QString _cursor;
48 | qulonglong _count;
49 | QList _cmd;
50 | DbMgr _dbMgr;
51 | QSqlDatabase *_db;
52 |
53 | signals:
54 | //注意!要使用信号,采用QObejct 和 QRunnable多继承,记得QObject要放在前面
55 | void finishWork(const int taskid);
56 | void runError(const int taskid, const QString & error);
57 | void sendData(const TaskMsg taskMsg);
58 |
59 | public slots:
60 | void cancelWork(const int taskid);
61 | void doKeyListWork();
62 | void doValueListWork();
63 | void doCommitValueWork();
64 | void doDelKeyWork();
65 | void doBatchDelKeyWork();
66 | void doBatchScanKeyWork();
67 | void doBatchExportWork(int taskid);
68 | void doBatchDbDeleWork(int taskid);
69 | void doBatchImportWork(int taskid);
70 | };
71 |
72 | #endif // WORKTHREAD_H
73 |
--------------------------------------------------------------------------------
/src/RedisView/RedisLib/RedisCluster.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file RedisCluster.h
3 | * @brief REDIS集群客户端类
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 |
10 | #ifndef REDISCLUSTER_H
11 | #define REDISCLUSTER_H
12 | #include "RedisLib/RedisClient.h"
13 | #include "RedisLib/RedisRoute.h"
14 |
15 | class RedisCluster : public RedisRoute
16 | {
17 | public:
18 |
19 | RedisCluster();
20 | ~RedisCluster();
21 | bool isOpen();
22 | bool openSingel(const QString &hostAddress, const QString passwd = "", int timeOut = 1000);
23 | bool openCluster(const QString &hostAddress, const QString passwd = "", const bool master = true, int timeOut = 1000);
24 | bool openCluster();
25 | bool openClient(const QString &hostAddress, const QString passwd = "", const bool master = true, int timeOut = 1000);
26 | bool openClient();
27 | bool reOpen();
28 | void close();
29 | void setCluster(const bool &isCluster);
30 | bool getCluster() const;
31 | void setTimeOutMs(unsigned int iTimeOutMs);
32 | unsigned int getTimeOutMs() const;
33 | QString getErrorInfo() const;
34 | QList command(QString &str, const QString &split = "", int index = -1);
35 | QList clusterCommand(QString &str);
36 | QByteArray singleCommand(QString &str, int index = -1);
37 | RedisClient * getClient(int index = 0);
38 | RedisClient * getClient(QByteArray &key);
39 | RedisClient * getClient(const QString &key);
40 | bool parseResp(const QByteArray &data, RespType &rResult);
41 | QString getConnectName() const;
42 | void setConnectName(const QString &ConnectName);
43 | void formatToResp(const RespType &inResp, QByteArray &outResp, int spaceNum);
44 | void formatToResp(const QByteArray &inResp, QByteArray &outResp, int spaceNum);
45 | void formatToText(const RespType &inResp, QByteArray &outResp, int spaceNum);
46 | void formatToText(const QByteArray &inResp, QByteArray &outResp, int spaceNum);
47 | void formatToJson(const RespType &inResp, QJsonArray &outJson);
48 | void formatToJson(const QByteArray &inResp, QJsonArray &outJson);
49 | bool copyNewClients(QList &vClients);
50 | QList getClients(bool isMaster = true) const;
51 | bool persist(const QString &key);
52 | bool select(const int &index);
53 | bool renamex(const QString &key, const QString &newkey);
54 | bool get(const QString &key, QByteArray &value);
55 | bool set(const QString &key, const QString &value);
56 | bool del(const QString &key, qlonglong & llRet);
57 | bool hset(const QString &key, const QString &field, const QString &value, qlonglong & llRet);
58 | bool pttl(const QString &key, qlonglong & mseconds);
59 | bool pexpire(const QString &key, uint mseconds);
60 | bool type(const QString &key, QByteArray &value);
61 | bool zadd(const QString &key, const QString &member, const double &score, qlonglong & llRet);
62 | bool sadd(const QString &key, const QString &member, qlonglong & llRet);
63 | bool lpush(const QString &key, const QString &value, qlonglong & llRet);
64 | bool refcount(const QString& key, qlonglong & value);
65 | bool idletime(const QString& key, qlonglong & value);
66 | bool encoding(const QString& key, QByteArray & value);
67 | int getClientIndex() const;
68 | bool getClusterMode() const;
69 | bool getCustomMode() const;
70 | bool getReplicationMode() const;
71 | bool getcfg(const QString& parameter, RespType &value);
72 | bool getDbNum(int &num);
73 | bool dbsize(qlonglong & llRet);
74 |
75 | private:
76 |
77 | bool _isNewOpen;
78 | bool _isClusterMode;
79 | bool _isReplicationMode;
80 | bool _isCustomMode;
81 | bool _onlyMaster;
82 | quint16 _port;
83 | int _dbIndex;
84 | int _timeOut;
85 | int _iClientIndex;
86 | unsigned int _iTimeOut;
87 | QString _host;
88 | QString _passwd;
89 | QString _sErrorInfo;
90 | QString _ConnectName;
91 | QString _hostAddress;
92 | QByteArray _byteArray;
93 | RedisClient * _redisClient;
94 | QList _vClusterClients;
95 | QList _vClusterMasterClients;
96 | RespType _respType;
97 | };
98 |
99 | #endif // REDISCLUSTER_H
100 |
--------------------------------------------------------------------------------
/src/RedisView/RedisLib/RedisDefine.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file redisdefine.h
3 | * @brief REDIS定义类
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 |
10 | #ifndef REDISDEFINE_H
11 | #define REDISDEFINE_H
12 |
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 | class RedisClient;
33 |
34 | enum KeyType {NONE = 0,STRING, LIST, SET, ZSET, HASH};
35 |
36 | class RespType {
37 | public:
38 |
39 | RespType() {
40 | init();
41 | }
42 |
43 | void init() {
44 | _integerValue = 0;
45 | _arrayLength = 0;
46 | _formatLength = 0;
47 | _formatType = '\0';
48 | _arrayValue.clear();
49 | _stringValue.clear();
50 | }
51 |
52 | // 不重载实际也可以用=
53 | RespType &operator=(const RespType &rhs)
54 | {
55 | // 若是本对象本身,则直接返回
56 | if (this == &rhs)
57 | return *this;
58 |
59 | // 复制等号右边的成员到左边的对象中
60 | this->_formatType = rhs._formatType;
61 | this->_arrayLength = rhs._arrayLength;
62 | this->_formatLength = rhs._formatLength;
63 | this->_integerValue = rhs._integerValue;
64 | this->_stringValue = rhs._stringValue;
65 | this->_arrayValue.clear();
66 | this->_arrayValue = rhs._arrayValue;
67 |
68 | // 把等号左边的对象再次传出,支持连等
69 | return *this;
70 | }
71 |
72 | char _formatType; // RESP类型
73 | int _arrayLength; // RESP数组元素数
74 | int _formatLength; // 大字符串类型长度
75 | qlonglong _integerValue; // 整数值
76 | QByteArray _stringValue; // 字符串值
77 | QList _arrayValue; // RESP数组值
78 | };
79 |
80 | Q_DECLARE_METATYPE(RespType)
81 |
82 | class ClusterClient
83 | {
84 | public:
85 |
86 | ClusterClient() {
87 | init();
88 | }
89 |
90 | void init() {
91 | _master = false;
92 | _port = 0;
93 | _startSlot = 0;
94 | _endSlot = 0;
95 | _slotNum = 0;
96 | _client = nullptr;
97 | _host.clear();
98 | _passwd.clear();
99 | _nodeId.clear();
100 | _masterId.clear();
101 | }
102 |
103 | ClusterClient &operator=(const ClusterClient &rhs)
104 | {
105 | if (this == &rhs)
106 | return *this;
107 |
108 | this->_master = rhs._master;
109 | this->_port = rhs._port;
110 | this->_startSlot = rhs._startSlot;
111 | this->_endSlot = rhs._endSlot;
112 | this->_slotNum = rhs._slotNum;
113 | this->_client = rhs._client;
114 | this->_host = rhs._host;
115 | this->_passwd = rhs._passwd;
116 | this->_nodeId = rhs._nodeId;
117 | this->_masterId = rhs._masterId;
118 |
119 | return *this;
120 | }
121 |
122 | bool _master;
123 | quint16 _port;
124 | unsigned int _startSlot;
125 | unsigned int _endSlot;
126 | unsigned int _slotNum;
127 | RedisClient * _client;
128 | QString _host;
129 | QString _passwd;
130 | QString _nodeId;
131 | QString _masterId;
132 | };
133 |
134 | class ClusterCmdRoute
135 | {
136 | public:
137 |
138 | ClusterCmdRoute() {
139 | init();
140 | }
141 |
142 | void init() {
143 | _key.clear();
144 | _value.clear();
145 | _cmd.clear();
146 | }
147 |
148 | ClusterCmdRoute &operator=(const ClusterCmdRoute &rhs)
149 | {
150 | if (this == &rhs)
151 | return *this;
152 |
153 | this->_cmd = rhs._cmd;
154 | this->_key = rhs._key;
155 | this->_value = rhs._value;
156 |
157 | return *this;
158 | }
159 |
160 | QString _cmd;
161 | QString _key;
162 | QString _value;
163 | };
164 |
165 | #endif // REDISDEFINE_H
166 |
--------------------------------------------------------------------------------
/src/RedisView/RedisLib/RedisRespParser.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file RedisRespParser.h
3 | * @brief REDIS客户端RESP解析类
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 |
10 | #ifndef REDISRESPPARSER_H
11 | #define REDISRESPPARSER_H
12 |
13 | #include "RedisLib/RedisDefine.h"
14 |
15 | /**
16 | * Redis内存数据库RESP协议解析打包类
17 | */
18 | class RedisRespParser
19 | {
20 |
21 | public:
22 |
23 | RedisRespParser();
24 |
25 | // 打包成RESP协议格式消息
26 | bool packRespCmd(const QList &vInCmd, QByteArray &sOutRespCmd);
27 | // 打包成RESP协议格式消息
28 | bool packRespCmd(const QString &sInCmd, QByteArray &sOutRespCmd);
29 | // 解析RESP协议单数组
30 | bool parseRespSingelArray(const QByteArray &data, QList &vResult, int &iResult);
31 | // 解析RESP协议数组
32 | bool parseRespArray(const QByteArray &data, QList &vResult, int &iResult);
33 | // 解析RESP协议数组长度
34 | bool parseRespArrayLength(const QByteArray &data, int &pos);
35 | // 解析RESP协议整形
36 | bool parseRespInteger(const QByteArray &data, qlonglong &llResult);
37 | // 解析RESP协议浮点型
38 | bool parseRespDouble(const QByteArray &data, double &dResult);
39 | // 解析RESP协议字符串
40 | bool parseRespString(const QByteArray &data, QByteArray &sResult);
41 | // 解析RESP协议错误
42 | bool parseRespError(const QByteArray &data, QByteArray &sResult);
43 | // 解析RESP协议大字符串
44 | bool parseRespBulkString(const QByteArray &data, QString &sResult, int &iResult);
45 | // 解析RESP协议大字符串
46 | bool parseRespBulkString(const QByteArray &data, QByteArray &sResult, int &iResult);
47 | // 解析RESP协议
48 | bool parseResp(const QByteArray &data, RespType &rResult);
49 | // 解析msg消息是否是完整RESP
50 | bool isValidResp(QByteArray &msg, int &ipos);
51 | // 从TCP获取消息后,解析msg消息是否是完整RESP
52 | bool getTcpResp(QByteArray &msg, int &ipos);
53 | // 获取错误信息
54 | QString getParseInfo() const;
55 | // 格式化RESP类型转RESP协议并格式化
56 | void formatToResp(const RespType &inResp, QByteArray &outResp, int spaceNum);
57 | // 格式化RESP类型转RESP协议并格式化为文本
58 | void formatToText(const RespType &inResp, QByteArray &outResp, int spaceNum);
59 | // 格式化RESP类型为JSON格式
60 | void formatToJson(const RespType &inResp, QJsonArray &outJson);
61 |
62 | private:
63 |
64 | QString _sErrorInfo;
65 | QString _strBuffer;
66 | QList _strList;
67 |
68 | };
69 |
70 |
71 | #endif // REDISRESPPARSER_H
72 |
--------------------------------------------------------------------------------
/src/RedisView/RedisLib/RedisRoute.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file RedisRoute.cpp
3 | * @brief REDIS键值路由类
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 |
10 | #include "RedisLib/RedisRoute.h"
11 |
12 | const unsigned short RedisRoute::_crc16tab[256] = {
13 | 0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7,
14 | 0x8108,0x9129,0xa14a,0xb16b,0xc18c,0xd1ad,0xe1ce,0xf1ef,
15 | 0x1231,0x0210,0x3273,0x2252,0x52b5,0x4294,0x72f7,0x62d6,
16 | 0x9339,0x8318,0xb37b,0xa35a,0xd3bd,0xc39c,0xf3ff,0xe3de,
17 | 0x2462,0x3443,0x0420,0x1401,0x64e6,0x74c7,0x44a4,0x5485,
18 | 0xa56a,0xb54b,0x8528,0x9509,0xe5ee,0xf5cf,0xc5ac,0xd58d,
19 | 0x3653,0x2672,0x1611,0x0630,0x76d7,0x66f6,0x5695,0x46b4,
20 | 0xb75b,0xa77a,0x9719,0x8738,0xf7df,0xe7fe,0xd79d,0xc7bc,
21 | 0x48c4,0x58e5,0x6886,0x78a7,0x0840,0x1861,0x2802,0x3823,
22 | 0xc9cc,0xd9ed,0xe98e,0xf9af,0x8948,0x9969,0xa90a,0xb92b,
23 | 0x5af5,0x4ad4,0x7ab7,0x6a96,0x1a71,0x0a50,0x3a33,0x2a12,
24 | 0xdbfd,0xcbdc,0xfbbf,0xeb9e,0x9b79,0x8b58,0xbb3b,0xab1a,
25 | 0x6ca6,0x7c87,0x4ce4,0x5cc5,0x2c22,0x3c03,0x0c60,0x1c41,
26 | 0xedae,0xfd8f,0xcdec,0xddcd,0xad2a,0xbd0b,0x8d68,0x9d49,
27 | 0x7e97,0x6eb6,0x5ed5,0x4ef4,0x3e13,0x2e32,0x1e51,0x0e70,
28 | 0xff9f,0xefbe,0xdfdd,0xcffc,0xbf1b,0xaf3a,0x9f59,0x8f78,
29 | 0x9188,0x81a9,0xb1ca,0xa1eb,0xd10c,0xc12d,0xf14e,0xe16f,
30 | 0x1080,0x00a1,0x30c2,0x20e3,0x5004,0x4025,0x7046,0x6067,
31 | 0x83b9,0x9398,0xa3fb,0xb3da,0xc33d,0xd31c,0xe37f,0xf35e,
32 | 0x02b1,0x1290,0x22f3,0x32d2,0x4235,0x5214,0x6277,0x7256,
33 | 0xb5ea,0xa5cb,0x95a8,0x8589,0xf56e,0xe54f,0xd52c,0xc50d,
34 | 0x34e2,0x24c3,0x14a0,0x0481,0x7466,0x6447,0x5424,0x4405,
35 | 0xa7db,0xb7fa,0x8799,0x97b8,0xe75f,0xf77e,0xc71d,0xd73c,
36 | 0x26d3,0x36f2,0x0691,0x16b0,0x6657,0x7676,0x4615,0x5634,
37 | 0xd94c,0xc96d,0xf90e,0xe92f,0x99c8,0x89e9,0xb98a,0xa9ab,
38 | 0x5844,0x4865,0x7806,0x6827,0x18c0,0x08e1,0x3882,0x28a3,
39 | 0xcb7d,0xdb5c,0xeb3f,0xfb1e,0x8bf9,0x9bd8,0xabbb,0xbb9a,
40 | 0x4a75,0x5a54,0x6a37,0x7a16,0x0af1,0x1ad0,0x2ab3,0x3a92,
41 | 0xfd2e,0xed0f,0xdd6c,0xcd4d,0xbdaa,0xad8b,0x9de8,0x8dc9,
42 | 0x7c26,0x6c07,0x5c64,0x4c45,0x3ca2,0x2c83,0x1ce0,0x0cc1,
43 | 0xef1f,0xff3e,0xcf5d,0xdf7c,0xaf9b,0xbfba,0x8fd9,0x9ff8,
44 | 0x6e17,0x7e36,0x4e55,0x5e74,0x2e93,0x3eb2,0x0ed1,0x1ef0
45 | };
46 |
47 | RedisRoute::RedisRoute() {
48 | _strBuffer.clear();
49 | _strList.clear();
50 | }
51 |
52 | unsigned short RedisRoute::crc16(const char *buf, int len) {
53 | int counter;
54 | unsigned short crc = 0;
55 | for (counter = 0; counter < len; counter++)
56 | crc = (crc<<8) ^ _crc16tab[((crc>>8) ^ *buf++)&0x00FF];
57 | return crc;
58 | }
59 |
60 | unsigned int RedisRoute::getKeySlot(char *key, int keylen) {
61 | int s, e;
62 |
63 | for (s = 0; s < keylen; s++)
64 | if (key[s] == '{')
65 | break;
66 |
67 | if (s == keylen)
68 | return crc16(key,keylen) & 0x3FFF;
69 |
70 | for (e = s+1; e < keylen; e++)
71 | if (key[e] == '}')
72 | break;
73 |
74 | if (e == keylen || e == s+1)
75 | return crc16(key,keylen) & 0x3FFF;
76 |
77 | return crc16(key+s+1,e-s-1) & 0x3FFF;
78 | }
79 |
80 | QString RedisRoute::getRandKey () {
81 | qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
82 | return QString::number(qrand());
83 | }
84 |
85 | bool RedisRoute::getKey(const QString & str, QList &cmd,
86 | int kpos, int kskip, int vpos, int vskip) {
87 |
88 | if(kpos <= 0)
89 | return false;
90 |
91 | QChar c, nextC;
92 | bool bCheck = false;
93 | ClusterCmdRoute clusterCmdRoute;
94 | cmd.clear();
95 |
96 | for(int i = 0; i < str.length(); ++i) {
97 | c = str.at(i);
98 | if (bCheck) {
99 | nextC = i < str.length() - 1 ? str.at(i + 1) : ' ';
100 | if (c == '\\' && nextC == '"') { // 略过转义\"中的'\'
101 | i++;
102 | continue;
103 | } else if (c == '"') { // 遇到了第二个"
104 | bCheck = false;
105 | }
106 | _strBuffer += c;
107 | } else {
108 | if (!c.isSpace()) {
109 | if (c == '\\' && nextC == '"') { // 略过转义\"中的'\'
110 | i++;
111 | continue;
112 | } else if (c == '"') { // 遇到第一个"
113 | bCheck = true;
114 | }
115 | _strBuffer += c;
116 | } else if (!_strBuffer.isEmpty()) {
117 | _strList << _strBuffer; // 追加一个单词
118 | _strBuffer.clear();
119 | }
120 | }
121 | }
122 | if (!_strBuffer.isEmpty()) // 当最后一个字母不是' '也不是'"'时
123 | _strList << _strBuffer;
124 |
125 | if(_strList.size() < kpos + 1 || _strList.size() < vpos)
126 | return false;
127 |
128 | clusterCmdRoute._cmd = _strList[0];
129 |
130 | for(int j = 1; j < _strList.size(); ++j) {
131 | if(j >= kpos) {
132 | if(kskip > 0) {
133 | if(((kskip + j) % (kskip + 1)) == 0)
134 | clusterCmdRoute._key = _strList[j];
135 | } else if(kskip == 0) {
136 | clusterCmdRoute._key = _strList[j];
137 | }
138 | }
139 |
140 | if(j >= vpos) {
141 | if(vskip > 0) {
142 | if(((vskip + j) % (vskip + 1)) == 0)
143 | clusterCmdRoute._value = _strList[j];
144 | } else if(vskip == 0) {
145 | clusterCmdRoute._value = _strList[j];
146 | }
147 | }
148 |
149 | cmd << clusterCmdRoute;
150 | }
151 |
152 | _strList.clear();
153 | _strBuffer.clear();
154 |
155 | return true;
156 | }
157 |
158 | bool RedisRoute::getKey(const QString & str, QString &key, int pos, int end) {
159 |
160 | if(pos <=0)
161 | return false;
162 |
163 | QChar c, nextC;
164 | bool bCheck = false;
165 |
166 | for(int i = 0; i < str.length(); ++i) {
167 | c = str.at(i);
168 | if (bCheck) {
169 | nextC = i < str.length() - 1 ? str.at(i + 1) : ' ';
170 | if (c == '\\' && nextC == '"') { // 略过转义\"中的'\'
171 | i++;
172 | continue;
173 | } else if (c == '"') { // 遇到了第二个"
174 | bCheck = false;
175 | }
176 | _strBuffer += c;
177 | } else {
178 | if (!c.isSpace()) {
179 | if (c == '\\' && nextC == '"') { // 略过转义\"中的'\'
180 | i++;
181 | continue;
182 | } else if (c == '"') { // 遇到第一个"
183 | bCheck = true;
184 | }
185 | _strBuffer += c;
186 | } else if (!_strBuffer.isEmpty()) {
187 | _strList << _strBuffer; // 追加一个单词
188 | _strBuffer.clear();
189 | }
190 | }
191 | }
192 | if (!_strBuffer.isEmpty()) // 当最后一个字母不是' '也不是'"'时
193 | _strList << _strBuffer;
194 |
195 | if(_strList.size() < pos + 1)
196 | return false;
197 |
198 | if(end == 1) {
199 | if(_strList.size() != pos + 1)
200 | return false;
201 | } else if(end == 0) {
202 | if(_strList.size() <= pos + 1)
203 | return false;
204 | }
205 |
206 | key.clear();
207 | key = _strList[pos];
208 | _strList.clear();
209 | _strBuffer.clear();
210 |
211 | return true;
212 | }
213 |
--------------------------------------------------------------------------------
/src/RedisView/RedisLib/RedisRoute.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file RedisRoute.cpp
3 | * @brief REDIS键值路由类
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 |
10 | #ifndef REDISROUTE_H
11 | #define REDISROUTE_H
12 |
13 | #include "RedisLib/RedisDefine.h"
14 |
15 | class RedisRoute
16 | {
17 | public:
18 | RedisRoute();
19 | // 获取key对应槽
20 | unsigned int getKeySlot(char *key, int keylen);
21 | // 分析str字符串,从kpos位置取key[kpos最小1开始],从vpos位置取value[vpos最小1开始]
22 | // kskip与vskip标识取值时跳过个数,kskip、vskip为0不跳过全取,小余0不取,大于0跳过取
23 | bool getKey(const QString & str, QList & cmd,
24 | int kpos = 1, int kskip = -1, int vpos = 1, int vskip = -1);
25 | // 分析str字符串,从pos位置取key[pos最小1开始],end为key后命令结束标识[0未结束,1结束,2可结束]
26 | bool getKey(const QString & str, QString &key, int pos =1, int end = 1);
27 | // 获取随机KEY
28 | QString getRandKey();
29 | private:
30 | unsigned short crc16(const char *buf, int len);
31 | static const unsigned short _crc16tab[256];
32 | QString _strBuffer;
33 | QList _strList;
34 | };
35 |
36 | #endif // REDISROUTE_H
37 |
--------------------------------------------------------------------------------
/src/RedisView/RedisLib/RedisTransMgr.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file RedisTransMgr.cpp
3 | * @brief REDIS客户端传输类
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 |
10 | #include "RedisLib/RedisTransMgr.h"
11 |
12 | RedisTransMgr::RedisTransMgr(QObject *parent)
13 | : QObject(parent)
14 | {
15 | _socket = nullptr;
16 | _nPort = 0;
17 | _msg.clear();
18 | _hostAddress.clear();
19 | initTransMgr();
20 | }
21 |
22 | RedisTransMgr::RedisTransMgr(const QString &hostAddress, quint16 port, QObject *parent)
23 | : QObject(parent)
24 | {
25 | _socket = nullptr;
26 | _nPort = 0;
27 | _msg.clear();
28 | _hostAddress.clear();
29 | setHostAddress(hostAddress);
30 | setPort(port);
31 | initTransMgr();
32 | }
33 |
34 | RedisTransMgr::~RedisTransMgr()
35 | {
36 | }
37 |
38 | void RedisTransMgr::write(const QByteArray &data)
39 | {
40 | if (!_socket->isValid())
41 | return;
42 | _msg.clear();
43 | // 发送RESP
44 | _socket->write(data);
45 | }
46 |
47 | void RedisTransMgr::write(const QString &str)
48 | {
49 | if (!_socket->isValid())
50 | return;
51 | _msg.clear();
52 | // 发送RESP
53 | QTextStream stream(_socket);
54 | stream << str;
55 | stream.flush();
56 | }
57 |
58 | bool RedisTransMgr::isOpen()
59 | {
60 | return _socket->isValid();
61 | }
62 |
63 | void RedisTransMgr::setHostAddress(const QString &hostAddress)
64 | {
65 | _hostAddress.setAddress(hostAddress);
66 | if (_socket->isValid()) // 如果已连接,重连新的地址
67 | open(_hostAddress, _nPort);
68 | }
69 |
70 | void RedisTransMgr::setPort(quint16 port)
71 | {
72 | _nPort = port;
73 | if (_socket->isValid())
74 | open(_hostAddress, _nPort);
75 | }
76 |
77 | bool RedisTransMgr::open(int timeOut)
78 | {
79 | return open(_hostAddress, _nPort, timeOut);
80 | }
81 |
82 | bool RedisTransMgr::open(const QString &hostAddress, quint16 port, int timeOut)
83 | {
84 | return open(QHostAddress(hostAddress), port, timeOut);
85 | }
86 |
87 | bool RedisTransMgr::open(const QHostAddress & hostAddress, quint16 port, int timeOut)
88 | {
89 | _hostAddress = hostAddress;
90 | _nPort = port;
91 | _socket->connectToHost(hostAddress, port);
92 | if(!_socket->waitForConnected(timeOut)) { // 默认超时1.5秒
93 | emit sigError(_socket->errorString());
94 | return false;
95 | }
96 | return true;
97 | }
98 |
99 | void RedisTransMgr::close()
100 | {
101 | if (_socket->isValid())
102 | _socket->disconnectFromHost();
103 | }
104 |
105 | void RedisTransMgr::initTransMgr()
106 | {
107 | _socket = new QTcpSocket(this);
108 | _socket->setProxy(QNetworkProxy::NoProxy);
109 |
110 | connect(_socket, &QTcpSocket::readyRead, [this]()
111 | {
112 | _length = 0;
113 | _msg.append(_socket->readAll());
114 | if(getTcpResp(_msg,_length)) {
115 | // 接收RESP协议原始消息完成
116 | emit sigReply(_msg.left(_length), _length);
117 | _msg = _msg.mid(_length);
118 | }
119 | });
120 |
121 | connect(_socket, static_cast(&QTcpSocket::error),
122 | [this](QAbstractSocket::SocketError socketError)
123 | {
124 | QString error(QMetaType::typeName(socketError));
125 | emit sigError(error);
126 | });
127 |
128 | connect(_socket, &QTcpSocket::connected, [this]()
129 | {
130 | emit sigConnected();
131 | });
132 |
133 | connect(_socket, &QTcpSocket::disconnected, [this]()
134 | {
135 | emit sigDisconnected();
136 | });
137 | }
138 |
--------------------------------------------------------------------------------
/src/RedisView/RedisLib/RedisTransMgr.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file RedisTransMgr.h
3 | * @brief REDIS客户端传输类
4 | * @author 王长春
5 | * @date 2018-11-24
6 | * @version 001
7 | * @copyright Copyright (c) 2018
8 | */
9 |
10 | #ifndef REDISTRANSMGR_H
11 | #define REDISTRANSMGR_H
12 |
13 | #include
14 |
15 | /**
16 | * Redis内存数据库TCP通信类
17 | */
18 | class RedisTransMgr : public QObject, public RedisRespParser
19 | {
20 | Q_OBJECT
21 |
22 | public:
23 |
24 | RedisTransMgr(const QString &hostAddress, quint16 port, QObject *parent = nullptr);
25 | RedisTransMgr(QObject *parent = nullptr);
26 | ~RedisTransMgr();
27 |
28 | void write(const QByteArray &data);
29 | void write(const QString &str);
30 | bool isOpen();
31 | bool open(int timeOut = 1000);
32 | bool open(const QString &hostAddress, quint16 port, int timeOut = 1000);
33 | bool open(const QHostAddress &hostAddress, quint16 port, int timeOut = 1000);
34 | void close();
35 |
36 | QString getHostAddress() { return _hostAddress.toString(); }
37 | void setHostAddress(const QString &hostAddress);
38 |
39 | int getPort() { return _nPort; }
40 | void setPort(quint16 port);
41 |
42 | private:
43 |
44 | int _length;
45 | quint16 _nPort;
46 | QTcpSocket *_socket;
47 | QByteArray _msg;
48 | QHostAddress _hostAddress;
49 |
50 | private:
51 |
52 | void initTransMgr();
53 |
54 | signals:
55 |
56 | void sigConnected();
57 | void sigDisconnected();
58 | void sigError(const QString &sError);
59 | void sigReply(const QByteArray &msg, const int &length);
60 | };
61 |
62 | #endif // REDISTRANSMGR_H
63 |
--------------------------------------------------------------------------------
/src/RedisView/RedisView.pro:
--------------------------------------------------------------------------------
1 | SOURCES += \
2 | AppView/AddIndexDialog.cpp \
3 | AppView/AppMain.cpp \
4 | AppView/CheckCodeDialog.cpp \
5 | AppView/ContributorDialog.cpp \
6 | AppView/DbCfgDialog.cpp \
7 | AppView/FeedBack.cpp \
8 | AppView/MainWindow.cpp \
9 | AppView/RedisInfoDialog.cpp \
10 | AppView/UpdateSystem.cpp \
11 | AppView/ValueDialog.cpp \
12 | AppView/VersionHistory.cpp \
13 | Public/AesEncrypt.cpp \
14 | Public/DbMgr.cpp \
15 | Public/Define.cpp \
16 | Public/Log.cpp \
17 | Public/QaesEncryption.cpp \
18 | RedisLib/RedisClient.cpp \
19 | RedisLib/RedisRespParser.cpp \
20 | RedisLib/RedisRoute.cpp \
21 | RedisLib/RedisTransMgr.cpp \
22 | RedisLib/RedisCluster.cpp \
23 | AppView/MainWidget.cpp \
24 | AppView/LoginDialog.cpp \
25 | AppView/LoginSet.cpp \
26 | Public/WorkThread.cpp \
27 | AppView/DataView.cpp \
28 | AppView/Donation.cpp \
29 | AppView/InputDialog.cpp \
30 | Public/Publib.cpp \
31 | AppView/KeyDialog.cpp \
32 | AppView/Instructions.cpp \
33 | Model/KeyTreeItem.cpp \
34 | Model/KeyTreeModel.cpp \
35 | Model/ValueTableItem.cpp \
36 | Model/ValueTableModel.cpp \
37 | AppView/ClientDialog.cpp \
38 | AppView/PubsubDialog.cpp \
39 | AppView/BatchOperateDialog.cpp \
40 | Model/ItemDelegate.cpp
41 |
42 |
43 | HEADERS += \
44 | AppView/AddIndexDialog.h \
45 | AppView/CheckCodeDialog.h \
46 | AppView/ContributorDialog.h \
47 | AppView/DbCfgDialog.h \
48 | AppView/FeedBack.h \
49 | AppView/MainWindow.h \
50 | AppView/RedisInfoDialog.h \
51 | AppView/UpdateSystem.h \
52 | AppView/ValueDialog.h \
53 | AppView/VersionHistory.h \
54 | Public/AesEncrypt.h \
55 | Public/DbMgr.h \
56 | Public/Define.h \
57 | Public/Log.h \
58 | Public/QaesEncryption.h \
59 | RedisLib/RedisClient.h \
60 | RedisLib/RedisRespParser.h \
61 | RedisLib/RedisRoute.h \
62 | RedisLib/RedisTransMgr.h \
63 | RedisLib/RedisCluster.h \
64 | RedisLib/RedisDefine.h \
65 | AppView/MainWidget.h \
66 | AppView/LoginDialog.h \
67 | AppView/LoginSet.h \
68 | Public/WorkThread.h \
69 | AppView/DataView.h \
70 | AppView/Donation.h \
71 | AppView/InputDialog.h \
72 | Public/Publib.h \
73 | AppView/KeyDialog.h \
74 | AppView/Instructions.h \
75 | Model/KeyTreeItem.h \
76 | Model/KeyTreeModel.h \
77 | Model/ValueTableItem.h \
78 | Model/ValueTableModel.h \
79 | AppView/ClientDialog.h \
80 | AppView/PubsubDialog.h \
81 | AppView/BatchOperateDialog.h \
82 | Model/ItemDelegate.h
83 |
84 |
85 | TARGET = RedisView
86 |
87 | RESOURCES += icon.qrc
88 |
89 | QT += gui widgets core network sql xml
90 |
91 | RC_ICONS = Resources/tray.ico
92 |
93 | CONFIG += C++11
94 |
95 | FORMS += \
96 | AppView/checkcodedialog.ui \
97 | AppView/contributordialog.ui \
98 | AppView/mainwidget.ui \
99 | AppView/dataview.ui \
100 | AppView/donation.ui \
101 | AppView/inputdialog.ui \
102 | AppView/instructions.ui \
103 | AppView/clientdialog.ui \
104 | AppView/pubsubdialog.ui \
105 | AppView/batchoperatedialog.ui \
106 | AppView/redisinfodialog.ui \
107 | AppView/valuedialog.ui \
108 | AppView/versionhistory.ui
109 |
110 | TRANSLATIONS = en.ts cn.ts
111 |
--------------------------------------------------------------------------------
/src/RedisView/Resources/GrayTheme.qss:
--------------------------------------------------------------------------------
1 | .QWidget {
2 | background: #F2F2F2;
3 | }
4 |
5 | QWidget:window {
6 | background: #F2F2F2;
7 | color: #000000;
8 | }
9 |
10 |
11 | QTreeWidget {
12 | background: #F2F2F2;
13 | color: #000000;
14 | }
15 |
16 | QTreeView {
17 | background: #F2F2F2;
18 | color: #000000;
19 | }
20 |
21 | QTabWidget {
22 | background: #F2F2F2;
23 | color: #000000;
24 | }
25 |
26 | QTableView {
27 | background: #DBDBDB;
28 | color: #000000;
29 | }
30 |
31 | QPlainTextEdit {
32 | background: #F2F2F2;
33 | color: #000000;
34 | }
35 |
36 | QTextBrowser {
37 | background: #F2F2F2;
38 | color: #000000;
39 | }
40 |
41 | QDialog {
42 | background: #F2F2F2;
43 | color: #000000;
44 | }
45 |
46 | QTextEdit {
47 | background: #F2F2F2;
48 | color: #000000;
49 | }
50 |
51 | QProgressBar {
52 | border: 1px solid grey;
53 | text-align: center;
54 | }
55 |
56 | QProgressBar::chunk {
57 | background-color: #53C23C;
58 | width: 20px;
59 | }
60 |
61 | QCheckBox {
62 | background-color: #F5F5F5;
63 | }
64 |
65 | QComboBox::drop-down {
66 | subcontrol-origin: padding;
67 | subcontrol-position: top right;
68 | border-left: 1px solid #DBDBDB;
69 | }
70 |
71 | QComboBox::down-arrow {
72 | border: 2px solid #DBDBDB;
73 | width: 6px;
74 | height: 6px;
75 | background: #C0C0C0;
76 | }
77 |
78 | QComboBox:item {
79 | background: #F2F2F2;
80 | color: #F2F2F2;
81 | }
82 |
83 | QRadioButton:hover, QCheckBox:hover {
84 | background-color: wheat;
85 | }
86 |
87 | QHeaderView::section {
88 | background-color: #F5F5F5;
89 | color: #000000;
90 | border: 0px;
91 | }
92 |
93 | QTableView QAbstractButton {
94 | background-color: #DBDBDB;
95 | border:1px solid #F2F2F2;
96 | }
97 |
98 | QTableView QTableCornerButton::section {
99 | background-color: #DBDBDB;
100 | border:1px;
101 | }
102 |
103 | QTableView QHeaderView {
104 | background-color: #DBDBDB;
105 | border:1px solid #F2F2F2;
106 | }
107 |
108 | QTableView QHeaderView::section {
109 | background-color: #DBDBDB;
110 | color: #000000;
111 | border: 0px;
112 | }
113 |
114 | QTableView QHeaderView::selected {
115 | background-color: #DBDBDB;
116 | color: #000000;
117 | border: 0px;
118 | }
119 |
120 | QTabBar::tab:selected {
121 | background-color: #DBDBDB;
122 | }
123 |
124 | #Donation * {
125 | background: #F2F2F2;
126 | }
127 |
128 | #_donationButton {
129 | background: #F2F2F2;
130 | color: #000000;
131 | }
132 |
133 | .QTextEdit {
134 | background-color: #FFFFFF;
135 | }
136 |
137 | #_plainTextEdit, #_publishPlainTextEdit,#_inputTextEdit,#te_infomation {
138 | background-color: #FFFFFF;
139 | }
--------------------------------------------------------------------------------
/src/RedisView/Resources/PinkTheme.qss:
--------------------------------------------------------------------------------
1 | QWidget {
2 | background: #FFF8DC;
3 | font-family: "Segoe UI";
4 | }
5 |
6 | QToolBar {
7 | background-color: #FFF8DC;
8 | }
9 |
10 | QDialog, QFileDialog {
11 | background-color: #FFF8DC;
12 | }
13 |
14 | QTabWidget::pane { /* The tab widget frame */
15 | border-top: 2px solid #FFF8DC;
16 | }
17 |
18 | QMainWindow::title {
19 | border-color: #FFF8DC;
20 | background-color: #FFF8DC;
21 | }
22 |
23 | QMenu::item:selected {
24 | border-color: #68C5E9;
25 | background: #EEE8AA;
26 | }
27 |
28 | QTabWidget::tab-bar {
29 | left: 5px; /* move to the right by 5px */
30 | }
31 |
32 | QTabBar, QTabWidget {
33 | background-color: beige;
34 | }
35 |
36 |
37 | QTabBar::tab {
38 | background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
39 | stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,
40 | stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
41 | border: 1px solid darkkhaki;
42 | border-bottom-color: #C2C7CB; /* same as the pane color */
43 | border-top-left-radius: 4px;
44 | border-top-right-radius: 4px;
45 | min-width: 8ex;
46 | padding: 2px;
47 | }
48 |
49 | QTabBar::tab:selected, QTabBar::tab:hover {
50 | background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
51 | stop: 0 #fafafa, stop: 0.4 #f4f4f4,
52 | stop: 0.5 #e7e7e7, stop: 1.0 #fafafa);
53 | }
54 |
55 | QTabBar::tab:selected {
56 | border-color: #9B9B9B;
57 | border-bottom-color: #C2C7CB; /* same as pane color */
58 | }
59 |
60 | QTabBar::tab:!selected {
61 | margin-top: 2px; /* make non-selected tabs look smaller */
62 | }
63 |
64 | /* Nice Windows-XP-style password character. */
65 | QLineEdit[echoMode="2"] {
66 | lineedit-password-character: 9679;
67 | }
68 |
69 | QHeaderView::section {
70 | background-color: #FFF8DC;
71 | color: #000000;
72 | padding-left: 1px;
73 | border: 0px solid #6c6c6c;
74 | }
75 |
76 | QTableView QHeaderView::section {
77 | background-color: #EEE8AA;
78 | color: #000000;
79 | border: 0px;
80 | }
81 |
82 | QHeaderView::section:checked
83 | {
84 | background-color: #F8A1A4;
85 | color: #FFFFFF;
86 | }
87 |
88 |
89 | /* We provide a min-width and min-height for push buttons
90 | so that they look elegant regardless of the width of the text. */
91 | QPushButton {
92 | background-color: palegoldenrod;
93 | border-width: 2px;
94 | border-color: darkkhaki;
95 | border-style: solid;
96 | border-radius: 5;
97 | padding: 3px;
98 | min-width: 13ex;
99 | min-height: 5ex;
100 | }
101 |
102 | QPushButton:hover {
103 | background-color: khaki;
104 | }
105 |
106 | /* Increase the padding, so the text is shifted when the button is
107 | pressed. */
108 | QPushButton:pressed {
109 | padding-left: 3px;
110 | padding-top: 3px;
111 | background-color: #d0d67c;
112 | }
113 |
114 | QLabel, QAbstractButton {
115 | font: bold;
116 | }
117 |
118 | /* Mark mandatory fields with a brownish color. */
119 | .mandatory {
120 | color: brown;
121 | }
122 |
123 | /* Bold text on status bar looks awful. */
124 | QStatusBar QLabel {
125 | font: normal;
126 | }
127 |
128 | QStatusBar::item {
129 | border-width: 1;
130 | border-color: darkkhaki;
131 | border-style: solid;
132 | border-radius: 2;
133 | }
134 |
135 | QStackedWidget, QComboBox, QLineEdit, QSpinBox, QListView, QWebView, QTreeView, QHeaderView {
136 | background-color: cornsilk;
137 | selection-color: #0a214c;
138 | selection-background-color: #C19A6B;
139 | }
140 |
141 | QLineEdit {
142 | background-color: #EEE8AA;
143 | }
144 |
145 | QLineEdit:disabled {
146 | background-color: #FFF8DC;
147 | }
148 |
149 | QTextBrowser {
150 | background-color: #FFF8DC;
151 | }
152 |
153 | QListView {
154 | show-decoration-selected: 1;
155 | }
156 |
157 | QListView::item:hover {
158 | background-color: wheat;
159 | }
160 |
161 | /* We reserve 1 pixel space in padding. When we get the focus,
162 | we kill the padding and enlarge the border. This makes the items
163 | glow. */
164 | QLineEdit, QFrame {
165 | border-width: 1px;
166 | padding: 1px;
167 | border-style: solid;
168 | border-color: darkkhaki;
169 | border-radius: 3px;
170 | }
171 |
172 | /* As mentioned above, eliminate the padding and increase the border. */
173 | QLineEdit:focus, QFrame:focus {
174 | border-width: 3px;
175 | padding: 0px;
176 | }
177 |
178 | /* A QLabel is a QFrame */
179 | QLabel {
180 | border: none;
181 | padding: 0;
182 | background: none;
183 | }
184 |
185 | /* A QToolTip is a QLabel */
186 | QToolTip {
187 | border: 0px solid darkkhaki;
188 | padding: 0px;
189 | }
190 |
191 | /* Nice to have the background color change when hovered. */
192 | QRadioButton:hover, QCheckBox:hover {
193 | background-color: wheat;
194 | }
195 |
196 | /* Force the dialog's buttons to follow the Windows guidelines. */
197 | QDialogButtonBox {
198 | button-layout: 0;
199 | }
200 |
201 | QPushButton#_subscribeButton {
202 | min-width: 100px;
203 | }
204 |
205 | QPushButton#_unSubcribeButton {
206 | min-width: 120px;
207 | }
208 |
209 | QTextEdit {
210 | background-color: #EEE8AA;
211 | }
212 |
213 | #_plainTextEdit, #_publishPlainTextEdit,#_inputTextEdit,#te_infomation {
214 | background-color: #EEE8AA;
215 | }
216 |
217 | QProgressBar {
218 | border: 2px solid #EEE8AA;
219 | background-color: #EEE8AA;
220 | text-align: center;
221 | }
222 |
223 | QProgressBar::chunk {
224 | background-color: #F8A1A4;
225 | }
226 |
227 | /* === QTableView === */
228 | QTableView QTableCornerButton::section {
229 | background-color: #EEE8AA;
230 | }
231 |
232 | QAbstractItemView {
233 | background-color: #EEE8AA;
234 | }
235 |
--------------------------------------------------------------------------------
/src/RedisView/Resources/about.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/about.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/add.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/add.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/adddb.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/adddb.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/alipay.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/alipay.png
--------------------------------------------------------------------------------
/src/RedisView/Resources/alter.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/alter.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/batchop.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/batchop.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/cn.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/cn.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/cn.qm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/cn.qm
--------------------------------------------------------------------------------
/src/RedisView/Resources/commit.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/commit.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/contributor.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/contributor.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/count.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/count.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/db.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/db.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/delete.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/delete.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/delhead.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/delhead.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/delkey.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/delkey.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/deltail.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/deltail.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/details.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/details.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/display.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/display.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/donate.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/donate.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/en.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/en.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/en.qm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/en.qm
--------------------------------------------------------------------------------
/src/RedisView/Resources/encode.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/encode.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/exit.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/exit.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/feedback.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/feedback.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/flush.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/flush.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/hide.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/hide.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/history.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/history.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/info.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/info.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/inhead.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/inhead.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/instruction.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/instruction.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/intail.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/intail.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/key.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/key.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/keyflush.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/keyflush.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/language.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/language.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/login.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/login.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/reconnect.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/reconnect.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/redisinfo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/redisinfo.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/run.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/run.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/save.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/save.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/see.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/see.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/select.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/select.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/sort.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/sort.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/subcribe.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/subcribe.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/tabpage.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/tabpage.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/tray.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/tray.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/type.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/type.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/update.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/update.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/view.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/view.ico
--------------------------------------------------------------------------------
/src/RedisView/Resources/wait.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/wait.gif
--------------------------------------------------------------------------------
/src/RedisView/Resources/weiPay.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cc20110101/RedisView/f285ad7c6164d1d1cce0baf7aa39d802fdb6a8ba/src/RedisView/Resources/weiPay.png
--------------------------------------------------------------------------------
/src/RedisView/icon.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | Resources/tray.ico
4 | Resources/exit.ico
5 | Resources/keyflush.ico
6 | Resources/about.ico
7 | Resources/display.ico
8 | Resources/hide.ico
9 | Resources/run.ico
10 | Resources/add.ico
11 | Resources/delete.ico
12 | Resources/alter.ico
13 | Resources/db.ico
14 | Resources/login.ico
15 | Resources/type.ico
16 | Resources/key.ico
17 | Resources/save.ico
18 | Resources/info.ico
19 | Resources/count.ico
20 | Resources/tabpage.ico
21 | Resources/alipay.png
22 | Resources/donate.ico
23 | Resources/flush.ico
24 | Resources/commit.ico
25 | Resources/delhead.ico
26 | Resources/inhead.ico
27 | Resources/intail.ico
28 | Resources/instruction.ico
29 | Resources/en.ico
30 | Resources/cn.ico
31 | Resources/language.ico
32 | Resources/cn.qm
33 | Resources/en.qm
34 | Resources/history.ico
35 | Resources/subcribe.ico
36 | Resources/view.ico
37 | Resources/reconnect.ico
38 | Resources/delkey.ico
39 | Resources/batchop.ico
40 | Resources/encode.ico
41 | Resources/select.ico
42 | Resources/weiPay.png
43 | Resources/wait.gif
44 | Resources/sort.ico
45 | Resources/contributor.ico
46 | Resources/redisinfo.ico
47 | Resources/feedback.ico
48 | Resources/update.ico
49 | Resources/DarkTheme.qss
50 | Resources/GrayTheme.qss
51 | Resources/DeepDarkTheme.qss
52 | Resources/PinkTheme.qss
53 | Resources/details.ico
54 | Resources/deltail.ico
55 | Resources/adddb.ico
56 |
57 |
58 |
--------------------------------------------------------------------------------