ValueTab::ValueTab(RedisKeyItem * key) : key(key), ui(nullptr), isInitialized(false), tabMustBeDestroyed(false), operationInProgress(true) { setObjectName("valueTab"); if (key == nullptr || key->getDbItem() == nullptr || key->getConnection() == nullptr) { return; } ui = QSharedPointer<ValueTabView>(new ValueTabView(key->text(), this)); connect((QObject *)key->getDbItem(), SIGNAL(destroyed(QObject *)), this, SLOT(OnClose())); Command typeCmd = key->getTypeCommand(); typeCmd.setOwner(this); typeCmd.setCallBackName("keyTypeLoaded"); key->getConnection()->addCommand(typeCmd); /** Connect View SIGNALS to Controller SLOTS **/ connect(ui->renameKey, SIGNAL(clicked()), this, SLOT(renameKey())); connect(ui->deleteKey, SIGNAL(clicked()), this, SLOT(deleteKey())); connect(ui.data(), SIGNAL(saveChangedValue(const QString&, const QModelIndex *)), this, SLOT(updateValue(const QString&, const QModelIndex *))); connect(this, SIGNAL(error(const QString&)), this, SLOT(errorOccurred(const QString&))); isInitialized = true; }
/** * @internal * Recursively move all keys in keyset below source to dest. * * Modifies the keyset. * * Example: * ``` * moveKeysRecursive("user/plugins/#0", "user/plugins/#1", config); * ``` * * @param source Root part to replace * @param dest Destination for keys * @param keyset keyset */ static void moveKeysRecursive (const char * source, const char * dest, KeySet * keyset) { Key * sourceBaseKey = keyNew (source, KEY_END); KeySet * newKeys = ksNew (0, KS_END); // Rename keys in keyset Key * sourceKey; ksRewind (keyset); while ((sourceKey = ksNext (keyset)) != NULL) { // Rename all keys below sourceKey if (!keyIsBelowOrSame (sourceBaseKey, sourceKey)) continue; Key * destKey = renameKey (source, dest, sourceKey); ksAppendKey (newKeys, destKey); } // Remove source keys from keyset KeySet * cut = ksCut (keyset, sourceBaseKey); ksDel (cut); ksAppend (keyset, newKeys); ksDel (newKeys); keyDel (sourceBaseKey); }