diff --git a/src/qt/forms/kevadialog.ui b/src/qt/forms/kevadialog.ui index ce651c074..cea7b9bb5 100644 --- a/src/qt/forms/kevadialog.ui +++ b/src/qt/forms/kevadialog.ui @@ -84,7 +84,7 @@ - + 0 @@ -92,19 +92,19 @@ - Bookmark this namespace + Create a new namespace - &Bookmark + &Create namespace - :/icons/address-book:/icons/address-book + :/icons/add:/icons/add - + 0 @@ -112,19 +112,19 @@ - Create a new namespace + List my namepsaces - &Create + &My Namespaces - :/icons/add:/icons/add + :/icons/editpaste:/icons/editpaste - + 0 @@ -132,14 +132,14 @@ - List my namepsaces + Show bookmarks - &My Namespaces + &Bookmarks - :/icons/editpaste:/icons/editpaste + :/icons/address-book:/icons/address-book diff --git a/src/qt/forms/kevanewnamespacedialog.ui b/src/qt/forms/kevanewnamespacedialog.ui index 6ba5546d1..25b9738d4 100644 --- a/src/qt/forms/kevanewnamespacedialog.ui +++ b/src/qt/forms/kevanewnamespacedialog.ui @@ -57,38 +57,4 @@ - - - buttonBox - accepted() - KevaNewNamespaceDialog - accept() - - - 20 - 20 - - - 20 - 20 - - - - - buttonBox - rejected() - KevaNewNamespaceDialog - reject() - - - 20 - 20 - - - 20 - 20 - - - - diff --git a/src/qt/kevadialog.cpp b/src/qt/kevadialog.cpp index 563af90a7..e4e0dfe37 100644 --- a/src/qt/kevadialog.cpp +++ b/src/qt/kevadialog.cpp @@ -222,11 +222,26 @@ void KevaDialog::on_removeButton_clicked() std::string nameSpace = ui->nameSpace->text().toStdString(); std::string key = keyStr.toStdString(); - if (this->model->deleteKevaEntry(nameSpace, key)) { - // correct for selection mode ContiguousSelection - QModelIndex firstIndex = selection.at(0); - model->getKevaTableModel()->removeRows(firstIndex.row(), selection.length(), firstIndex.parent()); + int ret = this->model->deleteKevaEntry(nameSpace, key); + if (ret > 0) { + QString msg; + switch (ret) { + case WalletModel::InvalidNamespace: + msg = tr("Invalid namespace \"%1\"").arg(ui->nameSpace->text()); + break; + case WalletModel::KeyNotFound: + msg = tr("Key not found: \"%1\".").arg(keyStr); + break; + default: + msg = tr("Unknown error."); + } + QMessageBox::critical(this, tr("Error"), msg, QMessageBox::Ok); + return; } + + // correct for selection mode ContiguousSelection + QModelIndex firstIndex = selection.at(0); + model->getKevaTableModel()->removeRows(firstIndex.row(), selection.length(), firstIndex.parent()); } // We override the virtual resizeEvent of the QWidget to adjust tables column @@ -324,9 +339,18 @@ int KevaDialog::createNamespace(std::string displayName, std::string& namespaceI return 0; } - if (!this->model->createNamespace(displayName, namespaceId)) { - // TODO: show error message. - return 1; + int ret = this->model->createNamespace(displayName, namespaceId); + if (ret > 0) { + QString msg; + switch (ret) { + case WalletModel::NamespaceTooLong: + msg = tr("Namespace too long \"%1\"").arg(QString::fromStdString(displayName)); + break; + default: + msg = tr("Unknown error."); + } + QMessageBox::critical(this, tr("Error"), msg, QMessageBox::Ok); + return 0; } return 1; } diff --git a/src/qt/kevamynamespacesdialog.cpp b/src/qt/kevamynamespacesdialog.cpp index ad0ce3da3..f9d712e67 100644 --- a/src/qt/kevamynamespacesdialog.cpp +++ b/src/qt/kevamynamespacesdialog.cpp @@ -17,6 +17,7 @@ KevaMyNamespacesDialog::KevaMyNamespacesDialog(QWidget *parent) : { ui->setupUi(this); ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); + ui->buttonBox->button(QDialogButtonBox::Apply)->setText(tr("Show")); connect(ui->buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked()), this, SLOT(reject())); connect(ui->buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply())); } diff --git a/src/qt/kevanamespacemodel.cpp b/src/qt/kevanamespacemodel.cpp index f25294c37..ae88e1b4a 100644 --- a/src/qt/kevanamespacemodel.cpp +++ b/src/qt/kevanamespacemodel.cpp @@ -45,7 +45,15 @@ QVariant KevaNamespaceModel::data(const QModelIndex &index, int role) const if(!index.isValid() || index.row() >= list.length()) return QVariant(); - if(role == Qt::DisplayRole || role == Qt::EditRole) + if (role == Qt::TextColorRole) + { + const NamespaceEntry *rec = &list[index.row()]; + if (!rec->confirmed) { + return QVariant(QBrush (QColor(Qt::gray))); + } + return QVariant(); + } + else if(role == Qt::DisplayRole || role == Qt::EditRole) { const NamespaceEntry *rec = &list[index.row()]; switch(index.column()) @@ -105,12 +113,7 @@ bool KevaNamespaceModel::removeRows(int row, int count, const QModelIndex &paren Qt::ItemFlags KevaNamespaceModel::flags(const QModelIndex &index) const { - const NamespaceEntry *rec = &list[index.row()]; - if (rec->confirmed) { - return Qt::ItemIsSelectable | Qt::ItemIsEnabled; - } else { - return Qt::ItemIsSelectable; - } + return Qt::ItemIsSelectable | Qt::ItemIsEnabled; } // actually add to table in GUI diff --git a/src/qt/kevanewnamespacedialog.cpp b/src/qt/kevanewnamespacedialog.cpp index 2e004697b..7a54df968 100644 --- a/src/qt/kevanewnamespacedialog.cpp +++ b/src/qt/kevanewnamespacedialog.cpp @@ -16,8 +16,8 @@ KevaNewNamespaceDialog::KevaNewNamespaceDialog(QWidget *parent) : ui(new Ui::KevaNewNamespaceDialog) { ui->setupUi(this); - connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject())); - connect(ui->buttonBox->button(QDialogButtonBox::Save), SIGNAL(clicked()), this, SLOT(accept())); + connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(close())); + connect(ui->buttonBox->button(QDialogButtonBox::Save), SIGNAL(clicked()), this, SLOT(create())); connect(ui->namespaceText, SIGNAL(textChanged(const QString &)), this, SLOT(onNamespaceChanged(const QString &))); ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(false); } @@ -29,21 +29,22 @@ void KevaNewNamespaceDialog::onNamespaceChanged(const QString & ns) ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(enabled); } -void KevaNewNamespaceDialog::accept() +void KevaNewNamespaceDialog::create() { KevaDialog* dialog = (KevaDialog*)this->parentWidget(); QString nsText = ui->namespaceText->text(); std::string namespaceId; if (!dialog->createNamespace(nsText.toStdString(), namespaceId)) { - //TODO: error message. + QDialog::close(); return; } dialog->showNamespace(QString::fromStdString(namespaceId)); - QDialog::accept(); + QDialog::close(); } -void KevaNewNamespaceDialog::reject() +void KevaNewNamespaceDialog::close() { + QDialog::close(); } KevaNewNamespaceDialog::~KevaNewNamespaceDialog() diff --git a/src/qt/kevanewnamespacedialog.h b/src/qt/kevanewnamespacedialog.h index 041b1707b..00407ef91 100644 --- a/src/qt/kevanewnamespacedialog.h +++ b/src/qt/kevanewnamespacedialog.h @@ -25,8 +25,8 @@ public: ~KevaNewNamespaceDialog(); public Q_SLOTS: - void accept(); - void reject(); + void create(); + void close(); void onNamespaceChanged(const QString & ns); private: diff --git a/src/qt/kevatablemodel.cpp b/src/qt/kevatablemodel.cpp index 50abb1e09..08327be60 100644 --- a/src/qt/kevatablemodel.cpp +++ b/src/qt/kevatablemodel.cpp @@ -48,7 +48,15 @@ QVariant KevaTableModel::data(const QModelIndex &index, int role) const if(!index.isValid() || index.row() >= list.length()) return QVariant(); - if(role == Qt::DisplayRole || role == Qt::EditRole) + if (role == Qt::TextColorRole) + { + const KevaEntry *rec = &list[index.row()]; + if (rec->block < 0) { + return QVariant(QBrush (QColor(Qt::gray))); + } + return QVariant(); + } + else if(role == Qt::DisplayRole || role == Qt::EditRole) { const KevaEntry *rec = &list[index.row()]; switch(index.column()) diff --git a/src/qt/locale/bitcoin_en.ts b/src/qt/locale/bitcoin_en.ts index f32c15590..154690ae6 100644 --- a/src/qt/locale/bitcoin_en.ts +++ b/src/qt/locale/bitcoin_en.ts @@ -1167,7 +1167,7 @@ - + Value for %1 @@ -1175,18 +1175,18 @@ KevaDialog - + Show the selected request (does the same as double clicking an entry) - - + + Show - + The namespace ID with a prefix "N". @@ -1208,22 +1208,32 @@ - Bookmark this namespace + Create a new namespace - &Bookmark + &Create namespace - Create a new namespace + List my namepsaces - &Create + &My Namespaces + + + + + Show bookmarks + + + + + &Bookmarks @@ -1242,7 +1252,7 @@ - + Copy URI @@ -1261,6 +1271,82 @@ Copy amount + + + Warning + Warning + + + + Delete the key "%1"? + + + + + Invalid namespace "%1" + + + + + Key not found: "%1". + + + + + + Unknown error. + + + + + + Error + Error + + + + Namespace too long "%1" + + + + + KevaMyNamespacesDialog + + + Show + + + + + KevaNamespaceModel + + + Id + + + + + Name + + + + + KevaNewNamespaceDialog + + + The name of the namespace. + + + + + Name: + + + + + This pane allows the creation of a new Keva namespace + + KevaTableModel @@ -1285,7 +1371,7 @@ - + Requested @@ -4020,12 +4106,12 @@ WalletModel - + Send Coins Send Coins - + Fee bump error diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 38fc3827e..e5cb2cef3 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -863,7 +863,7 @@ void WalletModel::getNamespaceEntries(std::vector& vNamespaceEnt for (auto ns: unconfirmedNamespaces) { NamespaceEntry entry; - entry.id = ValtypeToString(std::get<0>(ns)); + entry.id = EncodeBase58Check(std::get<0>(ns)); entry.name = ValtypeToString(std::get<1>(ns)); entry.confirmed = false; vNamespaceEntries.push_back(std::move(entry)); @@ -886,7 +886,7 @@ int WalletModel::createNamespace(std::string displayNameStr, std::string& namesp { const valtype displayName = ValtypeFromString (displayNameStr); if (displayName.size() > MAX_NAMESPACE_LENGTH) { - return 0; + return NamespaceTooLong; } CReserveKey keyName(wallet); @@ -915,7 +915,7 @@ int WalletModel::createNamespace(std::string displayNameStr, std::string& namesp keyName.KeepKey(); namespaceId = EncodeBase58Check(kevaNamespace); - return 1; + return 0; } @@ -923,14 +923,12 @@ int WalletModel::deleteKevaEntry(std::string namespaceStr, std::string keyStr) { valtype nameSpace; if (!DecodeKevaNamespace(namespaceStr, Params(), nameSpace)) { - //TODO: show error message. - return 0; + return InvalidNamespace; } const valtype key = ValtypeFromString(keyStr); if (key.size() > MAX_KEY_LENGTH) { - //TODO: show error message. - return 0; + return KeyTooLong; } bool hasKey = false; @@ -949,8 +947,7 @@ int WalletModel::deleteKevaEntry(std::string namespaceStr, std::string keyStr) } if (!hasKey) { - //TODO: show error message. - return 0; + return KeyNotFound; } COutput output; @@ -980,5 +977,5 @@ int WalletModel::deleteKevaEntry(std::string namespaceStr, std::string keyStr) KEVA_LOCKED_AMOUNT, false, wtx, coinControl); keyName.KeepKey(); - return 1; + return 0; } \ No newline at end of file diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index cd3948dbd..e0f4030f0 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -120,7 +120,13 @@ public: TransactionCreationFailed, // Error returned when wallet is still locked TransactionCommitFailed, AbsurdFee, - PaymentRequestExpired + PaymentRequestExpired, + + // Keva status + InvalidNamespace, + KeyTooLong, + NamespaceTooLong, + KeyNotFound }; enum EncryptionStatus