mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-03-13 06:01:45 +00:00
WIP: allow modification of value.
This commit is contained in:
parent
41d9bc8301
commit
a0581f28aa
@ -20,7 +20,7 @@
|
||||
<string>This pane shows the value associated with a give key</string>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -30,7 +30,7 @@
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
<set>QDialogButtonBox::Close|QDialogButtonBox::Save</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -6,23 +6,51 @@
|
||||
#include <qt/forms/ui_kevadetaildialog.h>
|
||||
|
||||
#include <qt/kevatablemodel.h>
|
||||
#include <qt/kevadialog.h>
|
||||
|
||||
#include <QModelIndex>
|
||||
#include <QPushButton>
|
||||
|
||||
KevaDetailDialog::KevaDetailDialog(const QModelIndex &idx, QWidget *parent) :
|
||||
|
||||
KevaDetailDialog::KevaDetailDialog(const QModelIndex &idx, QWidget *parent, const QString &nameSpace) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::KevaDetailDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QModelIndex keyIdx = idx.sibling(idx.row(), KevaTableModel::Key);
|
||||
QModelIndex valueIdx = idx.sibling(idx.row(), KevaTableModel::Value);
|
||||
setWindowTitle(tr("Value for %1").arg(keyIdx.data(Qt::DisplayRole).toString()));
|
||||
this->nameSpace = nameSpace;
|
||||
key = keyIdx.data(Qt::DisplayRole).toString();
|
||||
setWindowTitle(tr("Value for %1").arg(key));
|
||||
QString desc = valueIdx.data(Qt::DisplayRole).toString();
|
||||
connect(ui->detailText, SIGNAL(textChanged()), this, SLOT(onValueChanged()));
|
||||
//ui->detailText->setHtml(desc);
|
||||
ui->detailText->setPlainText(desc);
|
||||
ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(false);
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Save), SIGNAL(clicked()), this, SLOT(onSave()));
|
||||
}
|
||||
|
||||
KevaDetailDialog::~KevaDetailDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
}
|
||||
|
||||
void KevaDetailDialog::onValueChanged()
|
||||
{
|
||||
bool enabled = ui->detailText->toPlainText().length() > 0;
|
||||
ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(enabled);
|
||||
}
|
||||
|
||||
void KevaDetailDialog::onSave()
|
||||
{
|
||||
KevaDialog* dialog = (KevaDialog*)this->parentWidget();
|
||||
std::string keyText = key.toStdString();
|
||||
std::string valueText = ui->detailText->toPlainText().toStdString();
|
||||
std::string ns = nameSpace.toStdString();
|
||||
if (!dialog->addKeyValue(ns, keyText, valueText)) {
|
||||
QDialog::close();
|
||||
return;
|
||||
}
|
||||
dialog->showNamespace(nameSpace);
|
||||
QDialog::close();
|
||||
}
|
||||
|
@ -24,11 +24,17 @@ class KevaDetailDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit KevaDetailDialog(const QModelIndex &idx, QWidget *parent = 0);
|
||||
explicit KevaDetailDialog(const QModelIndex &idx, QWidget *parent, const QString &nameSpace);
|
||||
~KevaDetailDialog();
|
||||
|
||||
public Q_SLOTS:
|
||||
void onValueChanged();
|
||||
void onSave();
|
||||
|
||||
private:
|
||||
Ui::KevaDetailDialog *ui;
|
||||
QString nameSpace;
|
||||
QString key;
|
||||
};
|
||||
|
||||
#endif // BITCOIN_QT_KEVADETAILDIALOG_H
|
||||
|
@ -207,7 +207,8 @@ void KevaDialog::on_showContent_clicked()
|
||||
|
||||
void KevaDialog::on_kevaView_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
KevaDetailDialog *dialog = new KevaDetailDialog(index, this);
|
||||
QString nameSpace = ui->nameSpace->text();
|
||||
KevaDetailDialog *dialog = new KevaDetailDialog(index, this, nameSpace);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dialog->show();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user