| 10 | #include "ui_batchoperatedialog.h" |
| 11 | |
| 12 | BatchOperateDialog::BatchOperateDialog(RedisCluster *redisClient, QWidget *parent) : |
| 13 | QDialog(parent), |
| 14 | ui(new Ui::BatchOperateDialog) |
| 15 | { |
| 16 | ui->setupUi(this); |
| 17 | setWindowTitle(tr("批量操作")); |
| 18 | _vTaskId.clear(); |
| 19 | _isRun = false; |
| 20 | _workThread = nullptr; |
| 21 | _redisCluster = redisClient; |
| 22 | _isCalculateTimeout = PubLib::getConfigB("calculateTimeOut",true); |
| 23 | ui->_batchComboBox->addItem("Delete"); |
| 24 | ui->_batchComboBox->addItem("Scan key"); |
| 25 | ui->_batchComboBox->addItem("Import from oracle"); |
| 26 | ui->_batchComboBox->addItem("Import from mysql"); |
| 27 | ui->_batchComboBox->addItem("Export to oracle"); |
| 28 | ui->_batchComboBox->addItem("Export to mysql"); |
| 29 | ui->_batchComboBox->addItem("Delete oracle key"); |
| 30 | ui->_batchComboBox->addItem("Delete mysql key"); |
| 31 | ui->_progressBar->setMinimum(0); |
| 32 | ui->_progressBar->setMaximum(100); |
| 33 | ui->_progressBar->setValue(0); |
| 34 | QRegExp regx("[0-9]+$"); |
| 35 | QValidator *validator = new QRegExpValidator(regx, ui->_patternCountLineEdit); |
| 36 | ui->_patternCountLineEdit->setValidator(validator); |
| 37 | |
| 38 | ui->_patternCountLineEdit->setPlaceholderText("2"); |
| 39 | ui->_patternSeparatorLineEdit->setPlaceholderText("|"); |
| 40 | ui->_patternlineEdit->setPlaceholderText("a*|b*"); |
| 41 | ui->_tablelineEdit->setPlaceholderText("database table"); |
| 42 | |
| 43 | if(_redisCluster) { |
| 44 | _isClusterMode = _redisCluster->getClusterMode(); |
| 45 | if(_isClusterMode) { |
| 46 | _idbNums = 1; |
| 47 | } else { |
| 48 | if(!_redisCluster->getDbNum(_idbNums)) { |
| 49 | _idbNums = 1; |
| 50 | QMessageBox::information(this, tr("错误"), tr("获取DB个数失败!")); |
| 51 | } |
| 52 | } |
| 53 | _vMasterClients = _redisCluster->getClients(true); |
| 54 | for(int i = 0; i < _vMasterClients.size(); ++i) { |
| 55 | _vMasterClients[i]._client = nullptr; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | _threadPool = QThreadPool::globalInstance(); |
| 60 | _threadPool->setMaxThreadCount(MAX_THREAD_COUNT); |
| 61 | _threadPool->setExpiryTimeout(5000); //5s |
| 62 | |
| 63 | connect(ui->_batchComboBox, SIGNAL(currentTextChanged(const QString)), this, |
| 64 | SLOT(changeOperate(const QString))); |
| 65 | emit ui->_batchComboBox->currentTextChanged(ui->_batchComboBox->currentText()); |
| 66 | } |
| 67 | |
| 68 | BatchOperateDialog::~BatchOperateDialog() |
| 69 | { |
nothing calls this directly
no test coverage detected