Browse Source

WIP: allow modification of value.

kevaview
Just Wonder 5 years ago
parent
commit
a0581f28aa
  1. 4
      src/qt/forms/kevadetaildialog.ui
  2. 34
      src/qt/kevadetaildialog.cpp
  3. 8
      src/qt/kevadetaildialog.h
  4. 3
      src/qt/kevadialog.cpp

4
src/qt/forms/kevadetaildialog.ui

@ -20,7 +20,7 @@ @@ -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 @@ @@ -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>

34
src/qt/kevadetaildialog.cpp

@ -6,23 +6,51 @@ @@ -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();
}

8
src/qt/kevadetaildialog.h

@ -24,11 +24,17 @@ class KevaDetailDialog : public QDialog @@ -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

3
src/qt/kevadialog.cpp

@ -207,7 +207,8 @@ void KevaDialog::on_showContent_clicked() @@ -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…
Cancel
Save