mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-03-12 13:41:52 +00:00
Allowed updating bookmark name.
This commit is contained in:
parent
bdcee37f49
commit
5e5867c3b6
@ -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 = \
|
||||
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 = \
|
||||
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 = \
|
||||
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
Normal file
60
src/qt/forms/kevaeditbookmarkdialog.ui
Normal file
@ -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>
|
@ -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) :
|
||||
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()
|
||||
|
||||
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()
|
||||
|
@ -18,7 +18,6 @@ namespace Ui {
|
||||
class KevaBookmarksDialog;
|
||||
}
|
||||
|
||||
|
||||
/** Dialog showing namepsace creation. */
|
||||
class KevaBookmarksDialog : public QDialog
|
||||
{
|
||||
@ -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
Normal file
53
src/qt/kevaeditbookmarkdialog.cpp
Normal file
@ -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
Normal file
41
src/qt/kevaeditbookmarkdialog.h
Normal file
@ -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
|
@ -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);
|
||||
|
@ -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>&Edit</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
@ -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 @@
|
||||
<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 "N".</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 @@
|
||||
<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 @@
|
||||
<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 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+81"/>
|
||||
<location line="+88"/>
|
||||
<source>Requested</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -928,6 +928,10 @@
|
||||
<source>Show</source>
|
||||
<translation>显示</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&Edit</source>
|
||||
<translation>编辑</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>KevaBookmarksModel</name>
|
||||
|
Loading…
x
Reference in New Issue
Block a user