示例#1
0
    void FastoCommonModel::changeValue(const NDbValue& value)
    {
        QModelIndex ind = index(0, 0);
        if(!ind.isValid()){
            return;
        }

        FastoCommonItem* child = common::utils_qt::item<FastoCommonItem*>(ind);
        if(!child){
            return;
        }

        FastoCommonItem* root = dynamic_cast<FastoCommonItem*>(child->parent());
        if(!root){
            return;
        }

        const QString key = common::convertFromString<QString>(value.keyString());
        const QString val = common::convertFromString<QString>(value.valueString());

        for(int i = 0; i < root->childrenCount(); ++i){
            FastoCommonItem* child = dynamic_cast<FastoCommonItem*>(root->child(i));
            if(!child){
                continue;
            }

            if(child->key() == key){
                child->setValue(val);
                emit dataChanged(index(i, FastoCommonItem::eValue), index(i, FastoCommonItem::eType));
                break;
            }
        }
    }
 void KeysTableModel::changeValue(const NDbValue& value)
 {
     const QString key = common::convertFromString<QString>(value.keyString());
     for(int i = 0; i < data_.size(); ++i) {
         KeyTableItem *it = dynamic_cast<KeyTableItem*>(data_[i]);
         if(it->key() == key){
             it->setDbv(value);
             emit dataChanged(index(i, KeyTableItem::kTTL), index(i, KeyTableItem::kTTL));
             break;
         }
     }
 }