Browse Source

Allowed updating bookmark name.

keva-gui
Just Wonder 5 years ago
parent
commit
5e5867c3b6
  1. 4
      src/Makefile.qt.include
  2. 60
      src/qt/forms/kevaeditbookmarkdialog.ui
  3. 33
      src/qt/kevabookmarksdialog.cpp
  4. 2
      src/qt/kevabookmarksdialog.h
  5. 53
      src/qt/kevaeditbookmarkdialog.cpp
  6. 41
      src/qt/kevaeditbookmarkdialog.h
  7. 2
      src/qt/kevatablemodel.cpp
  8. 39
      src/qt/locale/bitcoin_en.ts
  9. 4
      src/qt/locale/bitcoin_zh_CN.ts

4
src/Makefile.qt.include

@ -140,6 +140,7 @@ QT_FORMS_UI = \ @@ -140,6 +140,7 @@ QT_FORMS_UI = \
qt/forms/kevaaddkeydialog.ui \
qt/forms/kevabookmarksdialog.ui \
qt/forms/kevanewnamespacedialog.ui \
qt/forms/kevaeditbookmarkdialog.ui \
qt/forms/kevamynamespacesdialog.ui \
qt/forms/debugwindow.ui \
qt/forms/sendcoinsdialog.ui \
@ -186,6 +187,7 @@ QT_MOC_CPP = \ @@ -186,6 +187,7 @@ QT_MOC_CPP = \
qt/moc_kevaaddkeydialog.cpp \
qt/moc_kevabookmarksdialog.cpp \
qt/moc_kevanewnamespacedialog.cpp \
qt/moc_kevaeditbookmarkdialog.cpp \
qt/moc_kevamynamespacesdialog.cpp \
qt/moc_rpcconsole.cpp \
qt/moc_sendcoinsdialog.cpp \
@ -281,6 +283,7 @@ BITCOIN_QT_H = \ @@ -281,6 +283,7 @@ BITCOIN_QT_H = \
qt/kevaaddkeydialog.h \
qt/kevabookmarksdialog.h \
qt/kevanewnamespacedialog.h \
qt/kevaeditbookmarkdialog.h \
qt/kevamynamespacesdialog.h \
qt/utilitydialog.h \
qt/walletframe.h \
@ -405,6 +408,7 @@ BITCOIN_QT_WALLET_CPP = \ @@ -405,6 +408,7 @@ BITCOIN_QT_WALLET_CPP = \
qt/kevaaddkeydialog.cpp \
qt/kevabookmarksdialog.cpp \
qt/kevanewnamespacedialog.cpp \
qt/kevaeditbookmarkdialog.cpp \
qt/kevamynamespacesdialog.cpp \
qt/walletframe.cpp \
qt/walletmodel.cpp \

60
src/qt/forms/kevaeditbookmarkdialog.ui

@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KevaEditBookmarkDialog</class>
<widget class="QDialog" name="KevaEditBookmarkDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>100</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Bookmark Name</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="toolTip">
<string>Bookmark name.</string>
</property>
<property name="text">
<string>Name:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>bookmarkName</cstring>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="bookmarkName">
<property name="toolTip">
<string>This pane allows change of bookmark name</string>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
</ui>

33
src/qt/kevabookmarksdialog.cpp

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
#include <qt/kevabookmarksdialog.h>
#include <qt/forms/ui_kevabookmarksdialog.h>
#include <qt/kevaeditbookmarkdialog.h>
#include <qt/kevabookmarksmodel.h>
#include <qt/kevadialog.h>
@ -16,9 +17,10 @@ KevaBookmarksDialog::KevaBookmarksDialog(QWidget *parent) : @@ -16,9 +17,10 @@ KevaBookmarksDialog::KevaBookmarksDialog(QWidget *parent) :
ui(new Ui::KevaBookmarksDialog)
{
ui->setupUi(this);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(false);
ui->buttonBox->button(QDialogButtonBox::Save)->setText(tr("Edit"));
ui->buttonBox->button(QDialogButtonBox::Save)->setText(tr("&Edit"));
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(apply()));
connect(ui->buttonBox->button(QDialogButtonBox::Save), SIGNAL(clicked()), this, SLOT(rename()));
@ -78,6 +80,35 @@ void KevaBookmarksDialog::apply() @@ -78,6 +80,35 @@ void KevaBookmarksDialog::apply()
void KevaBookmarksDialog::rename()
{
QModelIndex idIdx = selectedIndex.sibling(selectedIndex.row(), KevaBookmarksModel::Id);
QString idStr = idIdx.data(Qt::DisplayRole).toString();
QModelIndex nameIdx = selectedIndex.sibling(selectedIndex.row(), KevaBookmarksModel::Name);
QString nameStr = nameIdx.data(Qt::DisplayRole).toString();
KevaEditBookmarkDialog *dialog = new KevaEditBookmarkDialog(this, idStr, nameStr);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
}
void KevaBookmarksDialog::saveName(const QString& id, const QString& name)
{
QJsonArray array;
KevaBookmarksModel* bookmarksModel = this->model->getKevaBookmarksModel();
bookmarksModel->loadBookmarks(array);
for (int i = 0; i < array.size(); ++i) {
QJsonObject obj = array[i].toObject();
BookmarkEntry entry;
QString idStr = obj["id"].toString();
if (idStr == id) {
QJsonObject entry;
entry["id"] = id;
entry["name"] = name;
array.replace(i, entry);
break;
}
}
bookmarksModel->saveBookmarks(array);
bookmarksModel->loadBookmarks();
}
void KevaBookmarksDialog::reject()

2
src/qt/kevabookmarksdialog.h

@ -18,7 +18,6 @@ namespace Ui { @@ -18,7 +18,6 @@ namespace Ui {
class KevaBookmarksDialog;
}
/** Dialog showing namepsace creation. */
class KevaBookmarksDialog : public QDialog
{
@ -39,6 +38,7 @@ public Q_SLOTS: @@ -39,6 +38,7 @@ public Q_SLOTS:
void apply();
void reject();
void rename();
void saveName(const QString& id, const QString& name);
private Q_SLOTS:
void namespaceView_selectionChanged();

53
src/qt/kevaeditbookmarkdialog.cpp

@ -0,0 +1,53 @@ @@ -0,0 +1,53 @@
// Copyright (c) 2011-2017 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <qt/kevaeditbookmarkdialog.h>
#include <qt/forms/ui_kevaeditbookmarkdialog.h>
#include <qt/kevabookmarksdialog.h>
#include <qt/kevatablemodel.h>
#include <qt/kevadialog.h>
#include <QPushButton>
#include <QModelIndex>
KevaEditBookmarkDialog::KevaEditBookmarkDialog(QWidget *parent, const QString& id, const QString& name) :
QDialog(parent), id(id), name(name),
ui(new Ui::KevaEditBookmarkDialog)
{
ui->setupUi(this);
ui->bookmarkName->setText(name);
this->parentDialog = (KevaBookmarksDialog*)parent;
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(close()));
connect(ui->buttonBox->button(QDialogButtonBox::Save), SIGNAL(clicked()), this, SLOT(save()));
connect(ui->bookmarkName, SIGNAL(textChanged(const QString &)), this, SLOT(onNameChanged(const QString &)));
ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(false);
}
void KevaEditBookmarkDialog::onNameChanged(const QString & name)
{
int length = name.length();
bool enabled = length > 0;
ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(enabled);
this->name = name;
}
void KevaEditBookmarkDialog::save()
{
KevaDialog* dialog = (KevaDialog*)this->parentWidget();
QString bookmarkText = ui->bookmarkName->text();
this->parentDialog->saveName(id, name);
QDialog::close();
}
void KevaEditBookmarkDialog::close()
{
QDialog::close();
}
KevaEditBookmarkDialog::~KevaEditBookmarkDialog()
{
delete ui;
}

41
src/qt/kevaeditbookmarkdialog.h

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
// Copyright (c) 2011-2014 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_QT_KEVAEDITBOOKMARKDIALOG_H
#define BITCOIN_QT_KEVAEDITBOOKMARKDIALOG_H
#include <QObject>
#include <QString>
#include <QDialog>
namespace Ui {
class KevaEditBookmarkDialog;
}
class KevaBookmarksDialog;
/** Dialog showing namepsace creation. */
class KevaEditBookmarkDialog : public QDialog
{
Q_OBJECT
public:
explicit KevaEditBookmarkDialog(QWidget *parent, const QString& id, const QString& name);
~KevaEditBookmarkDialog();
public Q_SLOTS:
void save();
void close();
void onNameChanged(const QString & ns);
private:
Ui::KevaEditBookmarkDialog *ui;
QString id;
QString name;
KevaBookmarksDialog* parentDialog;
};
#endif // BITCOIN_QT_KEVAEDITBOOKMARKDIALOG_H

2
src/qt/kevatablemodel.cpp

@ -76,7 +76,7 @@ QVariant KevaTableModel::data(const QModelIndex &index, int role) const @@ -76,7 +76,7 @@ QVariant KevaTableModel::data(const QModelIndex &index, int role) const
if (index.column() == Block)
return (int)(Qt::AlignRight|Qt::AlignVCenter);
else if (index.column() == Value) {
#if (QT_VERSION <= QT_VERSION_CHECK(5, 9, 5))
#if (QT_VERSION <= QT_VERSION_CHECK(5, 12, 0))
return (int)(Qt::AlignLeft|Qt::AlignVCenter);
#else
return (int)(Qt::AlignLeft|Qt::AlignTop);

39
src/qt/locale/bitcoin_en.ts

@ -1181,8 +1181,8 @@ @@ -1181,8 +1181,8 @@
<context>
<name>KevaBookmarksDialog</name>
<message>
<location filename="../kevabookmarksdialog.cpp" line="+20"/>
<source>Show</source>
<location filename="../kevabookmarksdialog.cpp" line="+23"/>
<source>&amp;Edit</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -1215,7 +1215,7 @@ @@ -1215,7 +1215,7 @@
<context>
<name>KevaDialog</name>
<message>
<location filename="../forms/kevadialog.ui" line="+235"/>
<location filename="../forms/kevadialog.ui" line="+267"/>
<source>Show the selected request (does the same as double clicking an entry)</source>
<translation type="unfinished"></translation>
</message>
@ -1226,13 +1226,18 @@ @@ -1226,13 +1226,18 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="-204"/>
<location line="+14"/>
<location line="-234"/>
<location line="+44"/>
<source>The namespace ID with a prefix &quot;N&quot;.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-7"/>
<location line="-34"/>
<source>Bookmark this namespace</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+27"/>
<source>Use this form to perform Keva database operations.</source>
<translation type="unfinished"></translation>
</message>
@ -1322,7 +1327,7 @@ @@ -1322,7 +1327,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+192"/>
<location line="+259"/>
<source>Warning</source>
<translation type="unfinished">Warning</translation>
</message>
@ -1376,6 +1381,24 @@ @@ -1376,6 +1381,24 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>KevaEditBookmarkDialog</name>
<message>
<location filename="../forms/kevaeditbookmarkdialog.ui" line="+22"/>
<source>Bookmark name.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+3"/>
<source>Name:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+13"/>
<source>This pane allows change of bookmark name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>KevaMyNamespacesDialog</name>
<message>
@ -1438,7 +1461,7 @@ @@ -1438,7 +1461,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+81"/>
<location line="+88"/>
<source>Requested</source>
<translation type="unfinished"></translation>
</message>

4
src/qt/locale/bitcoin_zh_CN.ts

@ -928,6 +928,10 @@ @@ -928,6 +928,10 @@
<source>Show</source>
<translation></translation>
</message>
<message>
<source>&amp;Edit</source>
<translation></translation>
</message>
</context>
<context>
<name>KevaBookmarksModel</name>

Loading…
Cancel
Save