| 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 | |