| 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<void(QComboBox::*)(const QString &)> |
| 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(); |
nothing calls this directly
no outgoing calls
no test coverage detected