void ValueTab::keyTypeLoaded(Response type) { if (isOperationsAborted()) return destroy(); QString t = type.getValue().toString(); ui->keyTypeLabelValue->setText( ui->keyTypeLabelValue->text() + t.toUpper() ); keyModel = QSharedPointer<KeyModel>(key->getKeyModel(t)); if (keyModel.isNull()) { emit error("Can not load key value. Key was removed or redis-server went away."); return; } connect(keyModel.data(), SIGNAL(valueLoaded()), this, SLOT(valueLoaded())); connect(keyModel.data(), SIGNAL(keyRenameError(const QString&)), this, SIGNAL(error(const QString&))); connect(keyModel.data(), SIGNAL(keyRenamed()), this, SLOT(keyRenamed())); connect(keyModel.data(), SIGNAL(keyDeleteError(const QString&)), this, SIGNAL(error(const QString&))); connect(keyModel.data(), SIGNAL(keyDeleted()), this, SLOT(keyDeleted())); connect(keyModel.data(), SIGNAL(valueUpdateError(const QString&)), this, SIGNAL(error(const QString&))); connect(keyModel.data(), SIGNAL(valueUpdated()), this, SLOT(valueUpdated())); connect(keyModel.data(), SIGNAL(ttlLoaded(Response)), this, SLOT(ttlLoaded(Response))); operationInProgress = true; keyModel->loadValue(); keyModel->loadTTL(); }
void KeyModel::loadedValue(const QVariant& value, QObject *sender) { if (sender != this) { return; } db->disconnect(this); emit valueLoaded(value, this); }
void KeyModel::getValue() { if (keyType == Empty) { getKeyType(); } QString command; switch (keyType) { case KeyModel::String: command = QString("get %1").arg(keyName); break; case KeyModel::Hash: command = QString("hgetall %1").arg(keyName); break; case KeyModel::List: command = QString("LRANGE %1 0 -1").arg(keyName); break; case KeyModel::Set: command = QString("SMEMBERS %1").arg(keyName); break; case KeyModel::ZSet: command = QString("ZRANGE %1 0 -1 WITHSCORES").arg(keyName); break; } if (command.isEmpty()) { emit valueLoaded(QVariant(), this); return; } else { connect(db, SIGNAL(responseResieved(const QVariant&, QObject *)), this, SIGNAL(valueLoaded(const QVariant&, QObject*))); db->addCommand(Command(command, this, dbIndex)); } }