Just Wonder
5 years ago
43 changed files with 3538 additions and 113 deletions
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>KevaAddKeyDialog</class> |
||||
<widget class="QDialog" name="KevaAddKeyDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>800</width> |
||||
<height>400</height> |
||||
</rect> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string notr="true">Add New Key-Value Pair</string> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<widget class="QLabel" name="label_1"> |
||||
<property name="text"> |
||||
<string>Key</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QLineEdit" name="keyText"> |
||||
<property name="toolTip"> |
||||
<string>New value</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<spacer name="horizontalSpacer"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>40</width> |
||||
<height>15</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
<item> |
||||
<widget class="QLabel" name="label_2"> |
||||
<property name="text"> |
||||
<string>Value</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QTextEdit" name="valueText"> |
||||
<property name="toolTip"> |
||||
<string>New value</string> |
||||
</property> |
||||
</widget> |
||||
</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> |
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>KevaBookmarksDialog</class> |
||||
<widget class="QDialog" name="KevaBookmarksDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>800</width> |
||||
<height>400</height> |
||||
</rect> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string notr="true">Namespace Bookmarks</string> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<widget class="QTableView" name="namespaceView"> |
||||
<property name="contextMenuPolicy"> |
||||
<enum>Qt::CustomContextMenu</enum> |
||||
</property> |
||||
<property name="tabKeyNavigation"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="sortingEnabled"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="standardButtons"> |
||||
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<resources/> |
||||
</ui> |
@ -0,0 +1,74 @@
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>KevaDetailDialog</class> |
||||
<widget class="QDialog" name="KevaDetailDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>800</width> |
||||
<height>400</height> |
||||
</rect> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string notr="true">Value</string> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<widget class="QTextEdit" name="detailText"> |
||||
<property name="toolTip"> |
||||
<string>This pane shows the value associated with a give key</string> |
||||
</property> |
||||
<property name="readOnly"> |
||||
<bool>false</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="standardButtons"> |
||||
<set>QDialogButtonBox::Close|QDialogButtonBox::Save</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<resources/> |
||||
<connections> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>accepted()</signal> |
||||
<receiver>KevaDetailDialog</receiver> |
||||
<slot>accept()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>20</x> |
||||
<y>20</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>20</x> |
||||
<y>20</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>rejected()</signal> |
||||
<receiver>KevaDetailDialog</receiver> |
||||
<slot>reject()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>20</x> |
||||
<y>20</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>20</x> |
||||
<y>20</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
</connections> |
||||
</ui> |
@ -0,0 +1,329 @@
@@ -0,0 +1,329 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>KevaDialog</class> |
||||
<widget class="QWidget" name="KevaDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>776</width> |
||||
<height>396</height> |
||||
</rect> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,1"> |
||||
<item> |
||||
<widget class="QFrame" name="frame2"> |
||||
<property name="sizePolicy"> |
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> |
||||
<horstretch>0</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<property name="frameShape"> |
||||
<enum>QFrame::StyledPanel</enum> |
||||
</property> |
||||
<property name="frameShadow"> |
||||
<enum>QFrame::Sunken</enum> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout_3"> |
||||
<item> |
||||
<layout class="QGridLayout" name="gridLayout"> |
||||
<item row="4" column="2"> |
||||
<widget class="QLineEdit" name="nameSpace"> |
||||
<property name="toolTip"> |
||||
<string>The namespace ID with a prefix "N".</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="2"> |
||||
<widget class="QLabel" name="label_5"> |
||||
<property name="text"> |
||||
<string>Use this form to perform Keva database operations.</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="4" column="0"> |
||||
<widget class="QLabel" name="label_2"> |
||||
<property name="toolTip"> |
||||
<string>The namespace ID with a prefix "N".</string> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Namespace:</string> |
||||
</property> |
||||
<property name="alignment"> |
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
||||
</property> |
||||
<property name="buddy"> |
||||
<cstring>namespace</cstring> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="7" column="2"> |
||||
<layout class="QHBoxLayout" name="horizontalLayout"> |
||||
<item> |
||||
<widget class="QPushButton" name="showContent"> |
||||
<property name="sizePolicy"> |
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> |
||||
<horstretch>0</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<property name="toolTip"> |
||||
<string>Show content of the namespace.</string> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Show</string> |
||||
</property> |
||||
<property name="icon"> |
||||
<iconset resource="../bitcoin.qrc"> |
||||
<normaloff>:/icons/eye</normaloff>:/icons/eye</iconset> |
||||
</property> |
||||
<property name="autoDefault"> |
||||
<bool>false</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QPushButton" name="createNamespace"> |
||||
<property name="sizePolicy"> |
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> |
||||
<horstretch>0</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<property name="toolTip"> |
||||
<string>Create a new namespace</string> |
||||
</property> |
||||
<property name="text"> |
||||
<string>&Create namespace</string> |
||||
</property> |
||||
<property name="icon"> |
||||
<iconset resource="../bitcoin.qrc"> |
||||
<normaloff>:/icons/add</normaloff>:/icons/add</iconset> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QPushButton" name="listNamespaces"> |
||||
<property name="sizePolicy"> |
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> |
||||
<horstretch>0</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<property name="toolTip"> |
||||
<string>List my namespaces</string> |
||||
</property> |
||||
<property name="text"> |
||||
<string>&My Namespaces</string> |
||||
</property> |
||||
<property name="icon"> |
||||
<iconset resource="../bitcoin.qrc"> |
||||
<normaloff>:/icons/editpaste</normaloff>:/icons/editpaste</iconset> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QPushButton" name="bookmarksButton"> |
||||
<property name="sizePolicy"> |
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> |
||||
<horstretch>0</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<property name="toolTip"> |
||||
<string>Show bookmarks</string> |
||||
</property> |
||||
<property name="text"> |
||||
<string>&Bookmarks</string> |
||||
</property> |
||||
<property name="icon"> |
||||
<iconset resource="../bitcoin.qrc"> |
||||
<normaloff>:/icons/address-book</normaloff>:/icons/address-book</iconset> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<spacer name="horizontalSpacer"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>40</width> |
||||
<height>20</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item row="7" column="0"> |
||||
<widget class="QLabel" name="label_7"> |
||||
<property name="text"> |
||||
<string/> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<spacer name="verticalSpacer_2"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Vertical</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>20</width> |
||||
<height>10</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
<item> |
||||
<widget class="QFrame" name="frame"> |
||||
<property name="sizePolicy"> |
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> |
||||
<horstretch>0</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<property name="frameShape"> |
||||
<enum>QFrame::StyledPanel</enum> |
||||
</property> |
||||
<property name="frameShadow"> |
||||
<enum>QFrame::Raised</enum> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout_2"> |
||||
<item> |
||||
<widget class="QLabel" name="label_6"> |
||||
<property name="font"> |
||||
<font> |
||||
<weight>75</weight> |
||||
<bold>true</bold> |
||||
</font> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Content of namespace</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QTableView" name="kevaView"> |
||||
<property name="contextMenuPolicy"> |
||||
<enum>Qt::CustomContextMenu</enum> |
||||
</property> |
||||
<property name="tabKeyNavigation"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="sortingEnabled"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout_2"> |
||||
<item> |
||||
<widget class="QPushButton" name="showValueButton"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="toolTip"> |
||||
<string>Show the selected request (does the same as double clicking an entry)</string> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Show</string> |
||||
</property> |
||||
<property name="icon"> |
||||
<iconset resource="../bitcoin.qrc"> |
||||
<normaloff>:/icons/edit</normaloff>:/icons/edit</iconset> |
||||
</property> |
||||
<property name="autoDefault"> |
||||
<bool>false</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QPushButton" name="removeButton"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="toolTip"> |
||||
<string>Remove the selected entries from the list</string> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Remove</string> |
||||
</property> |
||||
<property name="icon"> |
||||
<iconset resource="../bitcoin.qrc"> |
||||
<normaloff>:/icons/remove</normaloff>:/icons/remove</iconset> |
||||
</property> |
||||
<property name="autoDefault"> |
||||
<bool>false</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QPushButton" name="addKVButton"> |
||||
<property name="enabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="toolTip"> |
||||
<string>Add new key-value pair</string> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Add key-value</string> |
||||
</property> |
||||
<property name="icon"> |
||||
<iconset resource="../bitcoin.qrc"> |
||||
<normaloff>:/icons/add</normaloff>:/icons/add</iconset> |
||||
</property> |
||||
<property name="autoDefault"> |
||||
<bool>false</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<spacer name="horizontalSpacer_2"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>40</width> |
||||
<height>20</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<customwidgets> |
||||
<customwidget> |
||||
<class>BitcoinAmountField</class> |
||||
<extends>QLineEdit</extends> |
||||
<header>qt/bitcoinamountfield.h</header> |
||||
<container>1</container> |
||||
</customwidget> |
||||
</customwidgets> |
||||
<tabstops> |
||||
<tabstop>reqMessage</tabstop> |
||||
<tabstop>receiveButton</tabstop> |
||||
<tabstop>clearButton</tabstop> |
||||
<tabstop>recentRequestsView</tabstop> |
||||
<tabstop>showValueButton</tabstop> |
||||
<tabstop>removeButton</tabstop> |
||||
</tabstops> |
||||
<resources> |
||||
<include location="../bitcoin.qrc"/> |
||||
</resources> |
||||
<connections/> |
||||
</ui> |
@ -0,0 +1,77 @@
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>KevaMyNamespacesDialog</class> |
||||
<widget class="QDialog" name="KevaMyNamespacesDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>800</width> |
||||
<height>400</height> |
||||
</rect> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string notr="true">My Namespaces</string> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<widget class="QTableView" name="namespaceView"> |
||||
<property name="contextMenuPolicy"> |
||||
<enum>Qt::CustomContextMenu</enum> |
||||
</property> |
||||
<property name="tabKeyNavigation"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="sortingEnabled"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="standardButtons"> |
||||
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<resources/> |
||||
<connections> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>accepted()</signal> |
||||
<receiver>KevaMyNamespacesDialog</receiver> |
||||
<slot>accept()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>20</x> |
||||
<y>20</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>20</x> |
||||
<y>20</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>rejected()</signal> |
||||
<receiver>KevaMyNamespacesDialog</receiver> |
||||
<slot>reject()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>20</x> |
||||
<y>20</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>20</x> |
||||
<y>20</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
</connections> |
||||
</ui> |
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>KevaNewNamespaceDialog</class> |
||||
<widget class="QDialog" name="KevaNewNamespaceDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>400</width> |
||||
<height>100</height> |
||||
</rect> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string notr="true">Create New Namespace</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>The name of the namespace.</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>namespaceText</cstring> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="2"> |
||||
<widget class="QLineEdit" name="namespaceText"> |
||||
<property name="toolTip"> |
||||
<string>This pane allows the creation of a new Keva namespace</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> |
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
// 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/kevaaddkeydialog.h> |
||||
#include <qt/forms/ui_kevaaddkeydialog.h> |
||||
|
||||
#include <qt/kevatablemodel.h> |
||||
#include <qt/kevadialog.h> |
||||
|
||||
#include <QPushButton> |
||||
|
||||
KevaAddKeyDialog::KevaAddKeyDialog(QWidget *parent, QString &nameSpace) : |
||||
QDialog(parent), |
||||
ui(new Ui::KevaAddKeyDialog) |
||||
{ |
||||
ui->setupUi(this); |
||||
this->nameSpace = nameSpace; |
||||
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(cancel())); |
||||
connect(ui->buttonBox->button(QDialogButtonBox::Save), SIGNAL(clicked()), this, SLOT(create())); |
||||
connect(ui->keyText, SIGNAL(textChanged(const QString &)), this, SLOT(onKeyChanged(const QString &))); |
||||
connect(ui->valueText, SIGNAL(textChanged()), this, SLOT(onValueChanged())); |
||||
ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(false); |
||||
} |
||||
|
||||
KevaAddKeyDialog::~KevaAddKeyDialog() |
||||
{ |
||||
delete ui; |
||||
} |
||||
|
||||
void KevaAddKeyDialog::create() |
||||
{ |
||||
KevaDialog* dialog = (KevaDialog*)this->parentWidget(); |
||||
std::string keyText = ui->keyText->text().toStdString(); |
||||
std::string valueText = ui->valueText->toPlainText().toStdString(); |
||||
std::string ns = nameSpace.toStdString(); |
||||
if (!dialog->addKeyValue(ns, keyText, valueText)) { |
||||
QDialog::close(); |
||||
return; |
||||
} |
||||
dialog->showNamespace(nameSpace); |
||||
QDialog::close(); |
||||
} |
||||
|
||||
void KevaAddKeyDialog::cancel() |
||||
{ |
||||
QDialog::close(); |
||||
} |
||||
|
||||
void KevaAddKeyDialog::onKeyChanged(const QString& key) |
||||
{ |
||||
bool enabled = key.length() > 0 && ui->valueText->toPlainText().length() > 0; |
||||
ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(enabled); |
||||
} |
||||
|
||||
void KevaAddKeyDialog::onValueChanged() |
||||
{ |
||||
bool enabled = ui->valueText->toPlainText().length() > 0 && ui->keyText->text().length() > 0; |
||||
ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(enabled); |
||||
} |
@ -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_KEVAADDKEYDIALOG_H |
||||
#define BITCOIN_QT_KEVAADDKEYDIALOG_H |
||||
|
||||
#include <QObject> |
||||
#include <QString> |
||||
|
||||
#include <QDialog> |
||||
|
||||
namespace Ui { |
||||
class KevaAddKeyDialog; |
||||
} |
||||
|
||||
QT_BEGIN_NAMESPACE |
||||
class QModelIndex; |
||||
QT_END_NAMESPACE |
||||
|
||||
/** Dialog add new key-value pair. */ |
||||
class KevaAddKeyDialog : public QDialog |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit KevaAddKeyDialog(QWidget *parent, QString &nameSpace); |
||||
~KevaAddKeyDialog(); |
||||
|
||||
private: |
||||
Ui::KevaAddKeyDialog *ui; |
||||
QString nameSpace; |
||||
|
||||
public Q_SLOTS: |
||||
void create(); |
||||
void cancel(); |
||||
void onKeyChanged(const QString& key); |
||||
void onValueChanged(); |
||||
}; |
||||
|
||||
#endif // BITCOIN_QT_KEVAADDKEYDIALOG_H
|
@ -0,0 +1,78 @@
@@ -0,0 +1,78 @@
|
||||
// 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/kevabookmarksdialog.h> |
||||
#include <qt/forms/ui_kevabookmarksdialog.h> |
||||
|
||||
#include <qt/kevabookmarksmodel.h> |
||||
#include <qt/kevadialog.h> |
||||
|
||||
#include <QPushButton> |
||||
#include <QModelIndex> |
||||
|
||||
KevaBookmarksDialog::KevaBookmarksDialog(QWidget *parent) : |
||||
QDialog(parent), |
||||
ui(new Ui::KevaBookmarksDialog) |
||||
{ |
||||
ui->setupUi(this); |
||||
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); |
||||
ui->buttonBox->button(QDialogButtonBox::Apply)->setText(tr("Show")); |
||||
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject())); |
||||
connect(ui->buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply())); |
||||
} |
||||
|
||||
void KevaBookmarksDialog::setModel(WalletModel *_model) |
||||
{ |
||||
this->model = _model; |
||||
|
||||
if(_model && _model->getOptionsModel()) |
||||
{ |
||||
_model->getKevaBookmarksModel()->sort(KevaBookmarksModel::Name, Qt::DescendingOrder); |
||||
QTableView* tableView = ui->namespaceView; |
||||
|
||||
tableView->verticalHeader()->hide(); |
||||
tableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
||||
tableView->setModel(_model->getKevaBookmarksModel()); |
||||
tableView->setAlternatingRowColors(true); |
||||
tableView->setSelectionBehavior(QAbstractItemView::SelectRows); |
||||
tableView->setSelectionMode(QAbstractItemView::ContiguousSelection); |
||||
tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); |
||||
|
||||
connect(tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), |
||||
this, SLOT(namespaceView_selectionChanged())); |
||||
} |
||||
} |
||||
|
||||
|
||||
void KevaBookmarksDialog::namespaceView_selectionChanged() |
||||
{ |
||||
bool enable = !ui->namespaceView->selectionModel()->selectedRows().isEmpty(); |
||||
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(enable); |
||||
|
||||
if (enable) { |
||||
selectedIndex = ui->namespaceView->selectionModel()->currentIndex(); |
||||
} else { |
||||
QModelIndex empty; |
||||
selectedIndex = empty; |
||||
} |
||||
} |
||||
|
||||
void KevaBookmarksDialog::apply() |
||||
{ |
||||
QModelIndex idIdx = selectedIndex.sibling(selectedIndex.row(), KevaBookmarksModel::Id); |
||||
QString idStr = idIdx.data(Qt::DisplayRole).toString(); |
||||
KevaDialog* dialog = (KevaDialog*)this->parentWidget(); |
||||
dialog->showNamespace(idStr); |
||||
QDialog::close(); |
||||
} |
||||
|
||||
void KevaBookmarksDialog::reject() |
||||
{ |
||||
QDialog::reject(); |
||||
} |
||||
|
||||
KevaBookmarksDialog::~KevaBookmarksDialog() |
||||
{ |
||||
delete ui; |
||||
} |
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
// 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_KEVABOOKMARKSDIALOG_H |
||||
#define BITCOIN_QT_KEVABOOKMARKSDIALOG_H |
||||
|
||||
#include <QObject> |
||||
#include <QString> |
||||
|
||||
#include <QDialog> |
||||
#include <QItemSelection> |
||||
#include <QAbstractItemView> |
||||
|
||||
class WalletModel; |
||||
|
||||
namespace Ui { |
||||
class KevaBookmarksDialog; |
||||
} |
||||
|
||||
|
||||
/** Dialog showing namepsace creation. */ |
||||
class KevaBookmarksDialog : public QDialog |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
enum ColumnWidths { |
||||
ID_COLUMN_WIDTH = 260, |
||||
NAME_COLUMN_WIDTH = 260, |
||||
MINIMUM_COLUMN_WIDTH = 260 |
||||
}; |
||||
|
||||
public: |
||||
explicit KevaBookmarksDialog(QWidget *parent = 0); |
||||
~KevaBookmarksDialog(); |
||||
void setModel(WalletModel *_model); |
||||
|
||||
public Q_SLOTS: |
||||
void apply(); |
||||
void reject(); |
||||
|
||||
private Q_SLOTS: |
||||
void namespaceView_selectionChanged(); |
||||
|
||||
private: |
||||
Ui::KevaBookmarksDialog *ui; |
||||
WalletModel *model; |
||||
QModelIndex selectedIndex; |
||||
}; |
||||
|
||||
#endif // BITCOIN_QT_KEVABOOKMARKSDIALOG_H
|
@ -0,0 +1,242 @@
@@ -0,0 +1,242 @@
|
||||
// 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/kevabookmarksmodel.h> |
||||
|
||||
#include <qt/bitcoinunits.h> |
||||
#include <qt/guiutil.h> |
||||
#include <qt/optionsmodel.h> |
||||
|
||||
#include <util.h> |
||||
|
||||
#include <clientversion.h> |
||||
#include <streams.h> |
||||
|
||||
#include <QFile> |
||||
#include <QJsonDocument> |
||||
#include <QJsonArray> |
||||
#include <QDir> |
||||
|
||||
|
||||
KevaBookmarksModel::KevaBookmarksModel(CWallet *wallet, WalletModel *parent) : |
||||
QAbstractTableModel(parent), walletModel(parent) |
||||
{ |
||||
Q_UNUSED(wallet) |
||||
|
||||
/* These columns must match the indices in the ColumnIndex enumeration */ |
||||
columns << tr("Id") << tr("Name"); |
||||
} |
||||
|
||||
KevaBookmarksModel::~KevaBookmarksModel() |
||||
{ |
||||
/* Intentionally left empty */ |
||||
} |
||||
|
||||
int KevaBookmarksModel::rowCount(const QModelIndex &parent) const |
||||
{ |
||||
Q_UNUSED(parent); |
||||
|
||||
return list.length(); |
||||
} |
||||
|
||||
int KevaBookmarksModel::columnCount(const QModelIndex &parent) const |
||||
{ |
||||
Q_UNUSED(parent); |
||||
|
||||
return columns.length(); |
||||
} |
||||
|
||||
QVariant KevaBookmarksModel::data(const QModelIndex &index, int role) const |
||||
{ |
||||
if(!index.isValid() || index.row() >= list.length()) |
||||
return QVariant(); |
||||
|
||||
if (role == Qt::TextColorRole) |
||||
{ |
||||
return QVariant(); |
||||
} |
||||
else if(role == Qt::DisplayRole || role == Qt::EditRole) |
||||
{ |
||||
const BookmarkEntry *rec = &list[index.row()]; |
||||
switch(index.column()) |
||||
{ |
||||
case Id: |
||||
return QString::fromStdString(rec->id); |
||||
case Name: |
||||
return QString::fromStdString(rec->name); |
||||
} |
||||
} |
||||
else if (role == Qt::TextAlignmentRole) |
||||
{ |
||||
return (int)(Qt::AlignLeft|Qt::AlignVCenter); |
||||
} |
||||
return QVariant(); |
||||
} |
||||
|
||||
bool KevaBookmarksModel::setData(const QModelIndex &index, const QVariant &value, int role) |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
QVariant KevaBookmarksModel::headerData(int section, Qt::Orientation orientation, int role) const |
||||
{ |
||||
if(orientation == Qt::Horizontal) |
||||
{ |
||||
if(role == Qt::DisplayRole && section < columns.size()) |
||||
{ |
||||
return columns[section]; |
||||
} |
||||
} |
||||
return QVariant(); |
||||
} |
||||
|
||||
|
||||
QModelIndex KevaBookmarksModel::index(int row, int column, const QModelIndex &parent) const |
||||
{ |
||||
Q_UNUSED(parent); |
||||
|
||||
return createIndex(row, column); |
||||
} |
||||
|
||||
bool KevaBookmarksModel::removeRows(int row, int count, const QModelIndex &parent) |
||||
{ |
||||
Q_UNUSED(parent); |
||||
|
||||
if(count > 0 && row >= 0 && (row+count) <= list.size()) |
||||
{ |
||||
beginRemoveRows(parent, row, row + count - 1); |
||||
list.erase(list.begin() + row, list.begin() + row + count); |
||||
endRemoveRows(); |
||||
return true; |
||||
} else { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
Qt::ItemFlags KevaBookmarksModel::flags(const QModelIndex &index) const |
||||
{ |
||||
return Qt::ItemIsSelectable | Qt::ItemIsEnabled; |
||||
} |
||||
|
||||
// actually add to table in GUI
|
||||
void KevaBookmarksModel::setBookmarks(std::vector<BookmarkEntry> vBookmarEntries) |
||||
{ |
||||
// Remove the old ones.
|
||||
removeRows(0, list.size()); |
||||
list.clear(); |
||||
|
||||
for (auto it = vBookmarEntries.begin(); it != vBookmarEntries.end(); it++) { |
||||
beginInsertRows(QModelIndex(), 0, 0); |
||||
list.prepend(*it); |
||||
endInsertRows(); |
||||
} |
||||
} |
||||
|
||||
void KevaBookmarksModel::setBookmarks(QJsonArray &array) |
||||
{ |
||||
std::vector<BookmarkEntry> vBookmarEntries; |
||||
for (int i = 0; i < array.size(); ++i) { |
||||
QJsonObject obj = array[i].toObject(); |
||||
BookmarkEntry entry; |
||||
entry.id = obj["id"].toString().toStdString(); |
||||
entry.name = obj["name"].toString().toStdString(); |
||||
vBookmarEntries.push_back(entry); |
||||
} |
||||
setBookmarks(std::move(vBookmarEntries)); |
||||
} |
||||
|
||||
void KevaBookmarksModel::sort(int column, Qt::SortOrder order) |
||||
{ |
||||
qSort(list.begin(), list.end(), BookmarkEntryLessThan(column, order)); |
||||
Q_EMIT dataChanged(index(0, 0, QModelIndex()), index(list.size() - 1, NUMBER_OF_COLUMNS - 1, QModelIndex())); |
||||
} |
||||
|
||||
|
||||
QString KevaBookmarksModel::getBookmarkFile() |
||||
{ |
||||
QString dataDir = GUIUtil::boostPathToQString(GetDataDir()); |
||||
return dataDir + QDir::separator() + QStringLiteral(BOOKMARK_FILE); |
||||
} |
||||
|
||||
int KevaBookmarksModel::loadBookmarks() |
||||
{ |
||||
QJsonArray json; |
||||
if (loadBookmarks(json)) { |
||||
setBookmarks(json); |
||||
return 1; |
||||
} |
||||
|
||||
// No bookmark file. Save and load the default ones.
|
||||
QJsonObject entry0; |
||||
entry0["id"] = "NgKBKkBAJMtzsuit85TpTpo5Xj6UQUg1wr"; |
||||
entry0["name"] = "Kevacoin Official Blog"; |
||||
|
||||
QJsonObject entry1; |
||||
entry1["id"] = "NV9GkLpCLMh4Nd6nZRkch8iNbuV8w9khTm"; |
||||
entry1["name"] = "Kevacoin官方博客"; |
||||
|
||||
QJsonObject entry2; |
||||
entry2["id"] = "NfFPgVqzk3H9afHjX8FDoyhkwtwGNanjyG"; |
||||
entry2["name"] = "Официальный блог Kevacoin"; |
||||
|
||||
QJsonArray array; |
||||
array.append(entry0); |
||||
array.append(entry1); |
||||
array.append(entry2); |
||||
|
||||
if (!saveBookmarks(array)) { |
||||
return 0; |
||||
} |
||||
|
||||
// Load the bookmarks again.
|
||||
if (loadBookmarks(json)) { |
||||
setBookmarks(json); |
||||
return 1; |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
|
||||
int KevaBookmarksModel::loadBookmarks(QJsonArray &json) |
||||
{ |
||||
QFile loadFile(getBookmarkFile()); |
||||
if (!loadFile.open(QIODevice::ReadOnly)) { |
||||
return 0; |
||||
} |
||||
QByteArray saveData = loadFile.readAll(); |
||||
QJsonDocument loadDoc(QJsonDocument::fromBinaryData(saveData)); |
||||
json = loadDoc.array(); |
||||
return 1; |
||||
} |
||||
|
||||
int KevaBookmarksModel::saveBookmarks(QJsonArray &json) |
||||
{ |
||||
QFile saveFile(getBookmarkFile()); |
||||
if (!saveFile.open(QIODevice::WriteOnly)) { |
||||
return 0; |
||||
} |
||||
|
||||
QJsonDocument saveDoc(json); |
||||
saveFile.write(saveDoc.toBinaryData()); |
||||
return 1; |
||||
} |
||||
|
||||
|
||||
bool BookmarkEntryLessThan::operator()(BookmarkEntry &left, BookmarkEntry &right) const |
||||
{ |
||||
BookmarkEntry *pLeft = &left; |
||||
BookmarkEntry *pRight = &right; |
||||
if (order == Qt::DescendingOrder) |
||||
std::swap(pLeft, pRight); |
||||
|
||||
switch(column) |
||||
{ |
||||
case KevaBookmarksModel::Id: |
||||
return pLeft->id < pRight->id; |
||||
case KevaBookmarksModel::Name: |
||||
return pLeft->name < pRight->name; |
||||
default: |
||||
return pLeft->id < pRight->id; |
||||
} |
||||
} |
@ -0,0 +1,90 @@
@@ -0,0 +1,90 @@
|
||||
// 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.
|
||||
|
||||
#ifndef BITCOIN_QT_KEVABOOKMARKSMODEL_H |
||||
#define BITCOIN_QT_KEVABOOKMARKSMODEL_H |
||||
|
||||
#include <qt/walletmodel.h> |
||||
|
||||
#include <QAbstractTableModel> |
||||
#include <QStringList> |
||||
#include <QDateTime> |
||||
#include <QJsonObject> |
||||
#include <QJsonArray> |
||||
|
||||
#define BOOKMARK_FILE "bookmarks.dat" |
||||
|
||||
class CWallet; |
||||
|
||||
class BookmarkEntry |
||||
{ |
||||
public: |
||||
BookmarkEntry() { } |
||||
|
||||
std::string id; |
||||
std::string name; |
||||
}; |
||||
|
||||
class BookmarkEntryLessThan |
||||
{ |
||||
public: |
||||
BookmarkEntryLessThan(int nColumn, Qt::SortOrder fOrder): |
||||
column(nColumn), order(fOrder) {} |
||||
bool operator()(BookmarkEntry &left, BookmarkEntry &right) const; |
||||
|
||||
private: |
||||
int column; |
||||
Qt::SortOrder order; |
||||
}; |
||||
|
||||
/** Model for list of recently generated payment requests / bitcoin: URIs.
|
||||
* Part of wallet model. |
||||
*/ |
||||
class KevaBookmarksModel: public QAbstractTableModel |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit KevaBookmarksModel(CWallet *wallet, WalletModel *parent); |
||||
~KevaBookmarksModel(); |
||||
|
||||
enum ColumnIndex { |
||||
Id = 0, |
||||
Name = 1, |
||||
NUMBER_OF_COLUMNS |
||||
}; |
||||
|
||||
/** @name Methods overridden from QAbstractTableModel
|
||||
@{*/ |
||||
int rowCount(const QModelIndex &parent) const; |
||||
int columnCount(const QModelIndex &parent) const; |
||||
QVariant data(const QModelIndex &index, int role) const; |
||||
bool setData(const QModelIndex &index, const QVariant &value, int role); |
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const; |
||||
QModelIndex index(int row, int column, const QModelIndex &parent) const; |
||||
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); |
||||
Qt::ItemFlags flags(const QModelIndex &index) const; |
||||
/*@}*/ |
||||
|
||||
const BookmarkEntry &entry(int row) const { return list[row]; } |
||||
void setBookmarks(std::vector<BookmarkEntry> vBookmarkEntries); |
||||
void setBookmarks(QJsonArray &json); |
||||
|
||||
int loadBookmarks(); |
||||
int loadBookmarks(QJsonArray &json); |
||||
int saveBookmarks(QJsonArray &json); |
||||
|
||||
public Q_SLOTS: |
||||
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); |
||||
|
||||
private: |
||||
WalletModel *walletModel; |
||||
QStringList columns; |
||||
QList<BookmarkEntry> list; |
||||
int64_t nReceiveRequestsMaxId; |
||||
|
||||
QString getBookmarkFile(); |
||||
}; |
||||
|
||||
#endif // BITCOIN_QT_KEVABOOKMARKSMODEL_H
|
@ -0,0 +1,56 @@
@@ -0,0 +1,56 @@
|
||||
// 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/kevadetaildialog.h> |
||||
#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, 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); |
||||
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(); |
||||
} |
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
// 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_KEVADETAILDIALOG_H |
||||
#define BITCOIN_QT_KEVADETAILDIALOG_H |
||||
|
||||
#include <QObject> |
||||
#include <QString> |
||||
|
||||
#include <QDialog> |
||||
|
||||
namespace Ui { |
||||
class KevaDetailDialog; |
||||
} |
||||
|
||||
QT_BEGIN_NAMESPACE |
||||
class QModelIndex; |
||||
QT_END_NAMESPACE |
||||
|
||||
/** Dialog showing transaction details. */ |
||||
class KevaDetailDialog : public QDialog |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
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
|
@ -0,0 +1,425 @@
@@ -0,0 +1,425 @@
|
||||
// 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 <wallet/wallet.h> |
||||
#include <keva/common.h> |
||||
|
||||
#include <qt/kevadialog.h> |
||||
#include <qt/forms/ui_kevadialog.h> |
||||
|
||||
#include <qt/addressbookpage.h> |
||||
#include <qt/addresstablemodel.h> |
||||
#include <qt/bitcoinunits.h> |
||||
#include <qt/optionsmodel.h> |
||||
#include <qt/platformstyle.h> |
||||
#include <qt/kevatablemodel.h> |
||||
#include <qt/kevanamespacemodel.h> |
||||
#include <qt/kevabookmarksmodel.h> |
||||
#include <qt/kevadetaildialog.h> |
||||
#include <qt/kevaaddkeydialog.h> |
||||
#include <qt/kevabookmarksdialog.h> |
||||
#include <qt/kevanewnamespacedialog.h> |
||||
#include <qt/kevamynamespacesdialog.h> |
||||
#include <qt/walletmodel.h> |
||||
|
||||
#include <QAction> |
||||
#include <QCursor> |
||||
#include <QMessageBox> |
||||
#include <QScrollBar> |
||||
#include <QTextDocument> |
||||
|
||||
KevaDialog::KevaDialog(const PlatformStyle *_platformStyle, QWidget *parent) : |
||||
QDialog(parent), |
||||
ui(new Ui::KevaDialog), |
||||
columnResizingFixer(0), |
||||
model(0), |
||||
platformStyle(_platformStyle) |
||||
{ |
||||
ui->setupUi(this); |
||||
|
||||
if (!_platformStyle->getImagesOnButtons()) { |
||||
ui->bookmarksButton->setIcon(QIcon()); |
||||
ui->showValueButton->setIcon(QIcon()); |
||||
ui->removeButton->setIcon(QIcon()); |
||||
} else { |
||||
ui->bookmarksButton->setIcon(_platformStyle->SingleColorIcon(":/icons/address-book")); |
||||
ui->showValueButton->setIcon(_platformStyle->SingleColorIcon(":/icons/edit")); |
||||
ui->removeButton->setIcon(_platformStyle->SingleColorIcon(":/icons/remove")); |
||||
ui->addKVButton->setIcon(_platformStyle->SingleColorIcon(":/icons/add")); |
||||
} |
||||
|
||||
// context menu actions
|
||||
QAction *copyURIAction = new QAction(tr("Copy URI"), this); |
||||
QAction *copyLabelAction = new QAction(tr("Copy label"), this); |
||||
QAction *copyMessageAction = new QAction(tr("Copy message"), this); |
||||
QAction *copyAmountAction = new QAction(tr("Copy amount"), this); |
||||
|
||||
// context menu
|
||||
contextMenu = new QMenu(this); |
||||
contextMenu->addAction(copyURIAction); |
||||
contextMenu->addAction(copyLabelAction); |
||||
contextMenu->addAction(copyMessageAction); |
||||
contextMenu->addAction(copyAmountAction); |
||||
|
||||
// context menu signals
|
||||
connect(ui->kevaView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showMenu(QPoint))); |
||||
connect(copyURIAction, SIGNAL(triggered()), this, SLOT(copyURI())); |
||||
connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel())); |
||||
connect(copyMessageAction, SIGNAL(triggered()), this, SLOT(copyMessage())); |
||||
connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount())); |
||||
|
||||
connect(ui->nameSpace, SIGNAL(textChanged(const QString &)), this, SLOT(onNamespaceChanged(const QString &))); |
||||
} |
||||
|
||||
void KevaDialog::setModel(WalletModel *_model) |
||||
{ |
||||
this->model = _model; |
||||
|
||||
if(_model && _model->getOptionsModel()) |
||||
{ |
||||
_model->getKevaTableModel()->sort(KevaTableModel::Block, Qt::DescendingOrder); |
||||
QTableView* tableView = ui->kevaView; |
||||
|
||||
tableView->verticalHeader()->hide(); |
||||
tableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
||||
tableView->setModel(_model->getKevaTableModel()); |
||||
tableView->setAlternatingRowColors(true); |
||||
tableView->setSelectionBehavior(QAbstractItemView::SelectRows); |
||||
tableView->setSelectionMode(QAbstractItemView::ContiguousSelection); |
||||
tableView->setColumnWidth(KevaTableModel::Date, DATE_COLUMN_WIDTH); |
||||
tableView->setColumnWidth(KevaTableModel::Key, KEY_COLUMN_WIDTH); |
||||
tableView->setColumnWidth(KevaTableModel::Block, BLOCK_MINIMUM_COLUMN_WIDTH); |
||||
|
||||
connect(ui->kevaView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), |
||||
this, SLOT(kevaView_selectionChanged())); |
||||
|
||||
// Last 2 columns are set by the columnResizingFixer, when the table geometry is ready.
|
||||
columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(tableView, BLOCK_MINIMUM_COLUMN_WIDTH, DATE_COLUMN_WIDTH, this); |
||||
} |
||||
} |
||||
|
||||
void KevaDialog::showNamespace(QString ns) |
||||
{ |
||||
ui->nameSpace->setText(ns); |
||||
on_showContent_clicked(); |
||||
} |
||||
|
||||
KevaDialog::~KevaDialog() |
||||
{ |
||||
delete ui; |
||||
} |
||||
|
||||
void KevaDialog::clear() |
||||
{ |
||||
ui->nameSpace->setText(""); |
||||
updateDisplayUnit(); |
||||
} |
||||
|
||||
void KevaDialog::reject() |
||||
{ |
||||
clear(); |
||||
} |
||||
|
||||
void KevaDialog::accept() |
||||
{ |
||||
clear(); |
||||
} |
||||
|
||||
void KevaDialog::updateDisplayUnit() |
||||
{ |
||||
if(model && model->getOptionsModel()) |
||||
{ |
||||
} |
||||
} |
||||
|
||||
void KevaDialog::on_createNamespace_clicked() |
||||
{ |
||||
if(!model || !model->getKevaTableModel()) |
||||
return; |
||||
|
||||
KevaNewNamespaceDialog *dialog = new KevaNewNamespaceDialog(this); |
||||
dialog->setAttribute(Qt::WA_DeleteOnClose); |
||||
dialog->show(); |
||||
} |
||||
|
||||
void KevaDialog::onNamespaceChanged(const QString& nameSpace) |
||||
{ |
||||
std::string namespaceStr = nameSpace.toStdString(); |
||||
valtype nameSpaceVal; |
||||
if (DecodeKevaNamespace(namespaceStr, Params(), nameSpaceVal)) { |
||||
ui->addKVButton->setEnabled(true); |
||||
} else { |
||||
ui->addKVButton->setEnabled(false); |
||||
} |
||||
} |
||||
|
||||
|
||||
void KevaDialog::on_listNamespaces_clicked() |
||||
{ |
||||
if(!model || !model->getKevaTableModel()) |
||||
return; |
||||
|
||||
KevaMyNamespacesDialog *dialog = new KevaMyNamespacesDialog(this); |
||||
|
||||
std::vector<NamespaceEntry> vNamespaceEntries; |
||||
model->getNamespaceEntries(vNamespaceEntries); |
||||
model->getKevaNamespaceModel()->setNamespace(std::move(vNamespaceEntries)); |
||||
model->getKevaNamespaceModel()->sort(KevaNamespaceModel::Name, Qt::DescendingOrder); |
||||
|
||||
dialog->setModel(model); |
||||
dialog->setAttribute(Qt::WA_DeleteOnClose); |
||||
dialog->show(); |
||||
} |
||||
|
||||
void KevaDialog::on_bookmarksButton_clicked() |
||||
{ |
||||
if(!model || !model->getKevaTableModel()) |
||||
return; |
||||
|
||||
KevaBookmarksDialog *dialog = new KevaBookmarksDialog(this); |
||||
|
||||
model->getKevaBookmarksModel()->loadBookmarks(); |
||||
model->getKevaBookmarksModel()->sort(KevaBookmarksModel::Name, Qt::DescendingOrder); |
||||
|
||||
dialog->setModel(model); |
||||
dialog->setAttribute(Qt::WA_DeleteOnClose); |
||||
dialog->show(); |
||||
} |
||||
|
||||
void KevaDialog::on_showContent_clicked() |
||||
{ |
||||
if(!model || !model->getKevaTableModel()) |
||||
return; |
||||
|
||||
valtype namespaceVal; |
||||
QString nameSpace = ui->nameSpace->text(); |
||||
if (!DecodeKevaNamespace(nameSpace.toStdString(), Params(), namespaceVal)) { |
||||
// TODO: show error dialog
|
||||
return; |
||||
} |
||||
|
||||
std::vector<KevaEntry> vKevaEntries; |
||||
model->getKevaEntries(vKevaEntries, ValtypeToString(namespaceVal)); |
||||
model->getKevaTableModel()->setKeva(std::move(vKevaEntries)); |
||||
model->getKevaTableModel()->sort(KevaTableModel::Date, Qt::DescendingOrder); |
||||
} |
||||
|
||||
void KevaDialog::on_kevaView_doubleClicked(const QModelIndex &index) |
||||
{ |
||||
QString nameSpace = ui->nameSpace->text(); |
||||
KevaDetailDialog *dialog = new KevaDetailDialog(index, this, nameSpace); |
||||
dialog->setAttribute(Qt::WA_DeleteOnClose); |
||||
dialog->show(); |
||||
} |
||||
|
||||
void KevaDialog::kevaView_selectionChanged() |
||||
{ |
||||
// Enable Show/Remove buttons only if anything is selected.
|
||||
bool enable = !ui->kevaView->selectionModel()->selectedRows().isEmpty(); |
||||
ui->showValueButton->setEnabled(enable); |
||||
ui->removeButton->setEnabled(enable); |
||||
ui->addKVButton->setEnabled(enable); |
||||
} |
||||
|
||||
void KevaDialog::on_showValueButton_clicked() |
||||
{ |
||||
if(!model || !model->getKevaTableModel() || !ui->kevaView->selectionModel()) |
||||
return; |
||||
QModelIndexList selection = ui->kevaView->selectionModel()->selectedRows(); |
||||
|
||||
for (const QModelIndex& index : selection) { |
||||
on_kevaView_doubleClicked(index); |
||||
} |
||||
} |
||||
|
||||
void KevaDialog::on_removeButton_clicked() |
||||
{ |
||||
if(!model || !model->getKevaTableModel() || !ui->kevaView->selectionModel()) |
||||
return; |
||||
QModelIndexList selection = ui->kevaView->selectionModel()->selectedRows(); |
||||
if(selection.empty()) |
||||
return; |
||||
|
||||
QMessageBox::StandardButton reply; |
||||
QModelIndex index = selection.at(0); |
||||
QModelIndex keyIdx = index.sibling(index.row(), KevaTableModel::Key); |
||||
QString keyStr = keyIdx.data(Qt::DisplayRole).toString(); |
||||
reply = QMessageBox::warning(this, tr("Warning"), tr("Delete the key \"%1\"?").arg(keyStr), |
||||
QMessageBox::Cancel|QMessageBox::Ok); |
||||
|
||||
if (reply == QMessageBox::Cancel) { |
||||
return; |
||||
} |
||||
|
||||
std::string nameSpace = ui->nameSpace->text().toStdString(); |
||||
std::string key = keyStr.toStdString(); |
||||
|
||||
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()); |
||||
} |
||||
|
||||
void KevaDialog::on_addKVButton_clicked() |
||||
{ |
||||
QString ns = ui->nameSpace->text(); |
||||
KevaAddKeyDialog *dialog = new KevaAddKeyDialog(this, ns); |
||||
dialog->setAttribute(Qt::WA_DeleteOnClose); |
||||
dialog->show(); |
||||
} |
||||
|
||||
// We override the virtual resizeEvent of the QWidget to adjust tables column
|
||||
// sizes as the tables width is proportional to the dialogs width.
|
||||
void KevaDialog::resizeEvent(QResizeEvent *event) |
||||
{ |
||||
QWidget::resizeEvent(event); |
||||
columnResizingFixer->stretchColumnWidth(KevaTableModel::Block); |
||||
} |
||||
|
||||
void KevaDialog::keyPressEvent(QKeyEvent *event) |
||||
{ |
||||
if (event->key() == Qt::Key_Return) |
||||
{ |
||||
// press return -> submit form
|
||||
if (ui->nameSpace->hasFocus()) |
||||
{ |
||||
event->ignore(); |
||||
on_showContent_clicked(); |
||||
return; |
||||
} |
||||
} |
||||
|
||||
this->QDialog::keyPressEvent(event); |
||||
} |
||||
|
||||
QModelIndex KevaDialog::selectedRow() |
||||
{ |
||||
if(!model || !model->getKevaTableModel() || !ui->kevaView->selectionModel()) |
||||
return QModelIndex(); |
||||
QModelIndexList selection = ui->kevaView->selectionModel()->selectedRows(); |
||||
if(selection.empty()) |
||||
return QModelIndex(); |
||||
// correct for selection mode ContiguousSelection
|
||||
QModelIndex firstIndex = selection.at(0); |
||||
return firstIndex; |
||||
} |
||||
|
||||
// copy column of selected row to clipboard
|
||||
void KevaDialog::copyColumnToClipboard(int column) |
||||
{ |
||||
QModelIndex firstIndex = selectedRow(); |
||||
if (!firstIndex.isValid()) { |
||||
return; |
||||
} |
||||
GUIUtil::setClipboard(model->getKevaTableModel()->data(firstIndex.child(firstIndex.row(), column), Qt::EditRole).toString()); |
||||
} |
||||
|
||||
// context menu
|
||||
void KevaDialog::showMenu(const QPoint &point) |
||||
{ |
||||
if (!selectedRow().isValid()) { |
||||
return; |
||||
} |
||||
contextMenu->exec(QCursor::pos()); |
||||
} |
||||
|
||||
// context menu action: copy URI
|
||||
void KevaDialog::copyURI() |
||||
{ |
||||
#if 0 |
||||
QModelIndex sel = selectedRow(); |
||||
if (!sel.isValid()) { |
||||
return; |
||||
} |
||||
|
||||
const KevaTableModel * const submodel = model->getKevaTableModel(); |
||||
const QString uri = GUIUtil::formatBitcoinURI(submodel->entry(sel.row()).recipient); |
||||
GUIUtil::setClipboard(uri); |
||||
#endif |
||||
} |
||||
|
||||
// context menu action: copy label
|
||||
void KevaDialog::copyLabel() |
||||
{ |
||||
copyColumnToClipboard(KevaTableModel::Key); |
||||
} |
||||
|
||||
// context menu action: copy message
|
||||
void KevaDialog::copyMessage() |
||||
{ |
||||
copyColumnToClipboard(KevaTableModel::Value); |
||||
} |
||||
|
||||
// context menu action: copy amount
|
||||
void KevaDialog::copyAmount() |
||||
{ |
||||
copyColumnToClipboard(KevaTableModel::Block); |
||||
} |
||||
|
||||
|
||||
int KevaDialog::createNamespace(std::string displayName, std::string& namespaceId) |
||||
{ |
||||
if (!this->model) { |
||||
return 0; |
||||
} |
||||
|
||||
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; |
||||
} |
||||
|
||||
int KevaDialog::addKeyValue(std::string& namespaceId, std::string& key, std::string& value) |
||||
{ |
||||
if (!this->model) { |
||||
return 0; |
||||
} |
||||
|
||||
int ret = this->model->addKeyValue(namespaceId, key, value); |
||||
if (ret > 0) { |
||||
QString msg; |
||||
switch (ret) { |
||||
case WalletModel::CannotUpdate: |
||||
msg = tr("Cannot add key-value. Make sure you own this namespace."); |
||||
break; |
||||
case WalletModel::KeyTooLong: |
||||
msg = tr("Key too long."); |
||||
break; |
||||
case WalletModel::ValueTooLong: |
||||
msg = tr("Value too long."); |
||||
break; |
||||
default: |
||||
msg = tr("Unknown error."); |
||||
} |
||||
QMessageBox::critical(this, tr("Error"), msg, QMessageBox::Ok); |
||||
return 0; |
||||
} |
||||
return 1; |
||||
} |
@ -0,0 +1,88 @@
@@ -0,0 +1,88 @@
|
||||
// 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.
|
||||
|
||||
#ifndef BITCOIN_QT_KEVADIALOG_H |
||||
#define BITCOIN_QT_KEVADIALOG_H |
||||
|
||||
#include <qt/guiutil.h> |
||||
|
||||
#include <QDialog> |
||||
#include <QHeaderView> |
||||
#include <QItemSelection> |
||||
#include <QKeyEvent> |
||||
#include <QMenu> |
||||
#include <QPoint> |
||||
#include <QVariant> |
||||
|
||||
class PlatformStyle; |
||||
class WalletModel; |
||||
|
||||
namespace Ui { |
||||
class KevaDialog; |
||||
} |
||||
|
||||
QT_BEGIN_NAMESPACE |
||||
class QModelIndex; |
||||
QT_END_NAMESPACE |
||||
|
||||
/** Dialog for requesting payment of bitcoins */ |
||||
class KevaDialog : public QDialog |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
enum ColumnWidths { |
||||
DATE_COLUMN_WIDTH = 130, |
||||
KEY_COLUMN_WIDTH = 120, |
||||
BLOCK_MINIMUM_COLUMN_WIDTH = 100, |
||||
MINIMUM_COLUMN_WIDTH = 100 |
||||
}; |
||||
|
||||
explicit KevaDialog(const PlatformStyle *platformStyle, QWidget *parent = 0); |
||||
~KevaDialog(); |
||||
|
||||
void setModel(WalletModel *model); |
||||
void showNamespace(QString ns); |
||||
int createNamespace(std::string displayName, std::string& namespaceId); |
||||
int addKeyValue(std::string& namespaceId, std::string& key, std::string& Value); |
||||
|
||||
public Q_SLOTS: |
||||
void clear(); |
||||
void reject(); |
||||
void accept(); |
||||
void onNamespaceChanged(const QString& nameSpace); |
||||
|
||||
protected: |
||||
virtual void keyPressEvent(QKeyEvent *event); |
||||
|
||||
private: |
||||
Ui::KevaDialog *ui; |
||||
GUIUtil::TableViewLastColumnResizingFixer *columnResizingFixer; |
||||
WalletModel *model; |
||||
QMenu *contextMenu; |
||||
const PlatformStyle *platformStyle; |
||||
|
||||
QModelIndex selectedRow(); |
||||
void copyColumnToClipboard(int column); |
||||
virtual void resizeEvent(QResizeEvent *event); |
||||
|
||||
private Q_SLOTS: |
||||
void on_showContent_clicked(); |
||||
void on_createNamespace_clicked(); |
||||
void on_listNamespaces_clicked(); |
||||
void on_showValueButton_clicked(); |
||||
void on_removeButton_clicked(); |
||||
void on_addKVButton_clicked(); |
||||
void on_kevaView_doubleClicked(const QModelIndex &index); |
||||
void kevaView_selectionChanged(); |
||||
void on_bookmarksButton_clicked(); |
||||
void updateDisplayUnit(); |
||||
void showMenu(const QPoint &point); |
||||
void copyURI(); |
||||
void copyLabel(); |
||||
void copyMessage(); |
||||
void copyAmount(); |
||||
}; |
||||
|
||||
#endif // BITCOIN_QT_KEVADIALOG_H
|
@ -0,0 +1,80 @@
@@ -0,0 +1,80 @@
|
||||
// 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/kevamynamespacesdialog.h> |
||||
#include <qt/forms/ui_kevamynamespacesdialog.h> |
||||
|
||||
#include <qt/kevanamespacemodel.h> |
||||
#include <qt/kevadialog.h> |
||||
|
||||
#include <QPushButton> |
||||
#include <QModelIndex> |
||||
|
||||
KevaMyNamespacesDialog::KevaMyNamespacesDialog(QWidget *parent) : |
||||
QDialog(parent), |
||||
ui(new Ui::KevaMyNamespacesDialog) |
||||
{ |
||||
ui->setupUi(this); |
||||
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); |
||||
ui->buttonBox->button(QDialogButtonBox::Apply)->setText(tr("Show")); |
||||
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject())); |
||||
connect(ui->buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply())); |
||||
} |
||||
|
||||
void KevaMyNamespacesDialog::setModel(WalletModel *_model) |
||||
{ |
||||
this->model = _model; |
||||
|
||||
if(_model && _model->getOptionsModel()) |
||||
{ |
||||
_model->getKevaNamespaceModel()->sort(KevaNamespaceModel::Name, Qt::DescendingOrder); |
||||
QTableView* tableView = ui->namespaceView; |
||||
|
||||
tableView->verticalHeader()->hide(); |
||||
tableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
||||
tableView->setModel(_model->getKevaNamespaceModel()); |
||||
tableView->setAlternatingRowColors(true); |
||||
tableView->setSelectionBehavior(QAbstractItemView::SelectRows); |
||||
tableView->setSelectionMode(QAbstractItemView::ContiguousSelection); |
||||
//tableView->setColumnWidth(KevaNamespaceModel::Id, ID_COLUMN_WIDTH);
|
||||
//tableView->setColumnWidth(KevaNamespaceModel::Name, NAME_COLUMN_WIDTH);
|
||||
tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); |
||||
|
||||
connect(tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), |
||||
this, SLOT(namespaceView_selectionChanged())); |
||||
} |
||||
} |
||||
|
||||
|
||||
void KevaMyNamespacesDialog::namespaceView_selectionChanged() |
||||
{ |
||||
bool enable = !ui->namespaceView->selectionModel()->selectedRows().isEmpty(); |
||||
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(enable); |
||||
|
||||
if (enable) { |
||||
selectedIndex = ui->namespaceView->selectionModel()->currentIndex(); |
||||
} else { |
||||
QModelIndex empty; |
||||
selectedIndex = empty; |
||||
} |
||||
} |
||||
|
||||
void KevaMyNamespacesDialog::apply() |
||||
{ |
||||
QModelIndex idIdx = selectedIndex.sibling(selectedIndex.row(), KevaNamespaceModel::Id); |
||||
QString idStr = idIdx.data(Qt::DisplayRole).toString(); |
||||
KevaDialog* dialog = (KevaDialog*)this->parentWidget(); |
||||
dialog->showNamespace(idStr); |
||||
QDialog::close(); |
||||
} |
||||
|
||||
void KevaMyNamespacesDialog::reject() |
||||
{ |
||||
QDialog::reject(); |
||||
} |
||||
|
||||
KevaMyNamespacesDialog::~KevaMyNamespacesDialog() |
||||
{ |
||||
delete ui; |
||||
} |
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
// 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_KEVAMYNMAESPACESDIALOG_H |
||||
#define BITCOIN_QT_KEVAMYNMAESPACESDIALOG_H |
||||
|
||||
#include <QObject> |
||||
#include <QString> |
||||
|
||||
#include <QDialog> |
||||
#include <QItemSelection> |
||||
#include <QAbstractItemView> |
||||
|
||||
class WalletModel; |
||||
|
||||
namespace Ui { |
||||
class KevaMyNamespacesDialog; |
||||
} |
||||
|
||||
|
||||
/** Dialog showing namepsace creation. */ |
||||
class KevaMyNamespacesDialog : public QDialog |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
enum ColumnWidths { |
||||
ID_COLUMN_WIDTH = 260, |
||||
NAME_COLUMN_WIDTH = 260, |
||||
MINIMUM_COLUMN_WIDTH = 260 |
||||
}; |
||||
|
||||
public: |
||||
explicit KevaMyNamespacesDialog(QWidget *parent = 0); |
||||
~KevaMyNamespacesDialog(); |
||||
void setModel(WalletModel *_model); |
||||
|
||||
public Q_SLOTS: |
||||
void apply(); |
||||
void reject(); |
||||
|
||||
private Q_SLOTS: |
||||
void namespaceView_selectionChanged(); |
||||
|
||||
private: |
||||
Ui::KevaMyNamespacesDialog *ui; |
||||
WalletModel *model; |
||||
QModelIndex selectedIndex; |
||||
}; |
||||
|
||||
#endif // BITCOIN_QT_KEVAMYNMAESPACESDIALOG_H
|
@ -0,0 +1,156 @@
@@ -0,0 +1,156 @@
|
||||
// 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/kevanamespacemodel.h> |
||||
|
||||
#include <qt/bitcoinunits.h> |
||||
#include <qt/guiutil.h> |
||||
#include <qt/optionsmodel.h> |
||||
|
||||
#include <clientversion.h> |
||||
#include <streams.h> |
||||
|
||||
|
||||
KevaNamespaceModel::KevaNamespaceModel(CWallet *wallet, WalletModel *parent) : |
||||
QAbstractTableModel(parent), walletModel(parent) |
||||
{ |
||||
Q_UNUSED(wallet) |
||||
|
||||
/* These columns must match the indices in the ColumnIndex enumeration */ |
||||
columns << tr("Id") << tr("Name"); |
||||
} |
||||
|
||||
KevaNamespaceModel::~KevaNamespaceModel() |
||||
{ |
||||
/* Intentionally left empty */ |
||||
} |
||||
|
||||
int KevaNamespaceModel::rowCount(const QModelIndex &parent) const |
||||
{ |
||||
Q_UNUSED(parent); |
||||
|
||||
return list.length(); |
||||
} |
||||
|
||||
int KevaNamespaceModel::columnCount(const QModelIndex &parent) const |
||||
{ |
||||
Q_UNUSED(parent); |
||||
|
||||
return columns.length(); |
||||
} |
||||
|
||||
QVariant KevaNamespaceModel::data(const QModelIndex &index, int role) const |
||||
{ |
||||
if(!index.isValid() || index.row() >= list.length()) |
||||
return QVariant(); |
||||
|
||||
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()) |
||||
{ |
||||
case Id: |
||||
return QString::fromStdString(rec->id); |
||||
case Name: |
||||
return QString::fromStdString(rec->name); |
||||
} |
||||
} |
||||
else if (role == Qt::TextAlignmentRole) |
||||
{ |
||||
return (int)(Qt::AlignLeft|Qt::AlignVCenter); |
||||
} |
||||
return QVariant(); |
||||
} |
||||
|
||||
bool KevaNamespaceModel::setData(const QModelIndex &index, const QVariant &value, int role) |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
QVariant KevaNamespaceModel::headerData(int section, Qt::Orientation orientation, int role) const |
||||
{ |
||||
if(orientation == Qt::Horizontal) |
||||
{ |
||||
if(role == Qt::DisplayRole && section < columns.size()) |
||||
{ |
||||
return columns[section]; |
||||
} |
||||
} |
||||
return QVariant(); |
||||
} |
||||
|
||||
|
||||
QModelIndex KevaNamespaceModel::index(int row, int column, const QModelIndex &parent) const |
||||
{ |
||||
Q_UNUSED(parent); |
||||
|
||||
return createIndex(row, column); |
||||
} |
||||
|
||||
bool KevaNamespaceModel::removeRows(int row, int count, const QModelIndex &parent) |
||||
{ |
||||
Q_UNUSED(parent); |
||||
|
||||
if(count > 0 && row >= 0 && (row+count) <= list.size()) |
||||
{ |
||||
beginRemoveRows(parent, row, row + count - 1); |
||||
list.erase(list.begin() + row, list.begin() + row + count); |
||||
endRemoveRows(); |
||||
return true; |
||||
} else { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
Qt::ItemFlags KevaNamespaceModel::flags(const QModelIndex &index) const |
||||
{ |
||||
return Qt::ItemIsSelectable | Qt::ItemIsEnabled; |
||||
} |
||||
|
||||
// actually add to table in GUI
|
||||
void KevaNamespaceModel::setNamespace(std::vector<NamespaceEntry> vNamespaceEntries) |
||||
{ |
||||
// Remove the old ones.
|
||||
removeRows(0, list.size()); |
||||
list.clear(); |
||||
|
||||
for (auto it = vNamespaceEntries.begin(); it != vNamespaceEntries.end(); it++) { |
||||
beginInsertRows(QModelIndex(), 0, 0); |
||||
list.prepend(*it); |
||||
endInsertRows(); |
||||
} |
||||
} |
||||
|
||||
void KevaNamespaceModel::sort(int column, Qt::SortOrder order) |
||||
{ |
||||
qSort(list.begin(), list.end(), NamespaceEntryLessThan(column, order)); |
||||
Q_EMIT dataChanged(index(0, 0, QModelIndex()), index(list.size() - 1, NUMBER_OF_COLUMNS - 1, QModelIndex())); |
||||
} |
||||
|
||||
|
||||
bool NamespaceEntryLessThan::operator()(NamespaceEntry &left, NamespaceEntry &right) const |
||||
{ |
||||
NamespaceEntry *pLeft = &left; |
||||
NamespaceEntry *pRight = &right; |
||||
if (order == Qt::DescendingOrder) |
||||
std::swap(pLeft, pRight); |
||||
|
||||
switch(column) |
||||
{ |
||||
case KevaNamespaceModel::Id: |
||||
return pLeft->id < pRight->id; |
||||
case KevaNamespaceModel::Name: |
||||
return pLeft->name < pRight->name; |
||||
default: |
||||
return pLeft->id < pRight->id; |
||||
} |
||||
} |
@ -0,0 +1,80 @@
@@ -0,0 +1,80 @@
|
||||
// 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.
|
||||
|
||||
#ifndef BITCOIN_QT_KEVANAMESPACEMODEL_H |
||||
#define BITCOIN_QT_KEVANAMESPACEMODEL_H |
||||
|
||||
#include <qt/walletmodel.h> |
||||
|
||||
#include <QAbstractTableModel> |
||||
#include <QStringList> |
||||
#include <QDateTime> |
||||
|
||||
class CWallet; |
||||
|
||||
class NamespaceEntry |
||||
{ |
||||
public: |
||||
NamespaceEntry():confirmed(true) { } |
||||
|
||||
std::string id; |
||||
std::string name; |
||||
bool confirmed; |
||||
}; |
||||
|
||||
class NamespaceEntryLessThan |
||||
{ |
||||
public: |
||||
NamespaceEntryLessThan(int nColumn, Qt::SortOrder fOrder): |
||||
column(nColumn), order(fOrder) {} |
||||
bool operator()(NamespaceEntry &left, NamespaceEntry &right) const; |
||||
|
||||
private: |
||||
int column; |
||||
Qt::SortOrder order; |
||||
}; |
||||
|
||||
/** Model for list of recently generated payment requests / bitcoin: URIs.
|
||||
* Part of wallet model. |
||||
*/ |
||||
class KevaNamespaceModel: public QAbstractTableModel |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit KevaNamespaceModel(CWallet *wallet, WalletModel *parent); |
||||
~KevaNamespaceModel(); |
||||
|
||||
enum ColumnIndex { |
||||
Id = 0, |
||||
Name = 1, |
||||
NUMBER_OF_COLUMNS |
||||
}; |
||||
|
||||
/** @name Methods overridden from QAbstractTableModel
|
||||
@{*/ |
||||
int rowCount(const QModelIndex &parent) const; |
||||
int columnCount(const QModelIndex &parent) const; |
||||
QVariant data(const QModelIndex &index, int role) const; |
||||
bool setData(const QModelIndex &index, const QVariant &value, int role); |
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const; |
||||
QModelIndex index(int row, int column, const QModelIndex &parent) const; |
||||
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); |
||||
Qt::ItemFlags flags(const QModelIndex &index) const; |
||||
/*@}*/ |
||||
|
||||
const NamespaceEntry &entry(int row) const { return list[row]; } |
||||
void setNamespace(std::vector<NamespaceEntry> vNamespaceEntries); |
||||
|
||||
public Q_SLOTS: |
||||
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); |
||||
|
||||
private: |
||||
WalletModel *walletModel; |
||||
QStringList columns; |
||||
QList<NamespaceEntry> list; |
||||
int64_t nReceiveRequestsMaxId; |
||||
}; |
||||
|
||||
#endif // BITCOIN_QT_KEVANAMESPACEMODEL_H
|
@ -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/kevanewnamespacedialog.h> |
||||
#include <qt/forms/ui_kevanewnamespacedialog.h> |
||||
|
||||
#include <qt/kevatablemodel.h> |
||||
#include <qt/kevadialog.h> |
||||
|
||||
#include <QPushButton> |
||||
#include <QModelIndex> |
||||
|
||||
KevaNewNamespaceDialog::KevaNewNamespaceDialog(QWidget *parent) : |
||||
QDialog(parent), |
||||
ui(new Ui::KevaNewNamespaceDialog) |
||||
{ |
||||
ui->setupUi(this); |
||||
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); |
||||
} |
||||
|
||||
void KevaNewNamespaceDialog::onNamespaceChanged(const QString & ns) |
||||
{ |
||||
int length = ns.length(); |
||||
bool enabled = length > 0; |
||||
ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(enabled); |
||||
} |
||||
|
||||
void KevaNewNamespaceDialog::create() |
||||
{ |
||||
KevaDialog* dialog = (KevaDialog*)this->parentWidget(); |
||||
QString nsText = ui->namespaceText->text(); |
||||
std::string namespaceId; |
||||
if (!dialog->createNamespace(nsText.toStdString(), namespaceId)) { |
||||
QDialog::close(); |
||||
return; |
||||
} |
||||
dialog->showNamespace(QString::fromStdString(namespaceId)); |
||||
QDialog::close(); |
||||
} |
||||
|
||||
void KevaNewNamespaceDialog::close() |
||||
{ |
||||
QDialog::close(); |
||||
} |
||||
|
||||
KevaNewNamespaceDialog::~KevaNewNamespaceDialog() |
||||
{ |
||||
delete ui; |
||||
} |
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
// 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_KEVANEWNMAESPACEDIALOG_H |
||||
#define BITCOIN_QT_KEVANEWNMAESPACEDIALOG_H |
||||
|
||||
#include <QObject> |
||||
#include <QString> |
||||
|
||||
#include <QDialog> |
||||
|
||||
namespace Ui { |
||||
class KevaNewNamespaceDialog; |
||||
} |
||||
|
||||
|
||||
/** Dialog showing namepsace creation. */ |
||||
class KevaNewNamespaceDialog : public QDialog |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit KevaNewNamespaceDialog(QWidget *parent = 0); |
||||
~KevaNewNamespaceDialog(); |
||||
|
||||
public Q_SLOTS: |
||||
void create(); |
||||
void close(); |
||||
void onNamespaceChanged(const QString & ns); |
||||
|
||||
private: |
||||
Ui::KevaNewNamespaceDialog *ui; |
||||
}; |
||||
|
||||
#endif // BITCOIN_QT_KEVANEWNMAESPACEDIALOG_H
|
@ -0,0 +1,177 @@
@@ -0,0 +1,177 @@
|
||||
// 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/kevatablemodel.h> |
||||
|
||||
#include <qt/bitcoinunits.h> |
||||
#include <qt/guiutil.h> |
||||
#include <qt/optionsmodel.h> |
||||
|
||||
#include <clientversion.h> |
||||
#include <streams.h> |
||||
|
||||
|
||||
KevaTableModel::KevaTableModel(CWallet *wallet, WalletModel *parent) : |
||||
QAbstractTableModel(parent), walletModel(parent) |
||||
{ |
||||
Q_UNUSED(wallet) |
||||
|
||||
/* These columns must match the indices in the ColumnIndex enumeration */ |
||||
columns << tr("Date") << tr("Key") << tr("Value") << tr("Block"); |
||||
|
||||
// TODO: display new keva entry when it arrives.
|
||||
// connect(walletModel->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
|
||||
} |
||||
|
||||
KevaTableModel::~KevaTableModel() |
||||
{ |
||||
/* Intentionally left empty */ |
||||
} |
||||
|
||||
int KevaTableModel::rowCount(const QModelIndex &parent) const |
||||
{ |
||||
Q_UNUSED(parent); |
||||
|
||||
return list.length(); |
||||
} |
||||
|
||||
int KevaTableModel::columnCount(const QModelIndex &parent) const |
||||
{ |
||||
Q_UNUSED(parent); |
||||
|
||||
return columns.length(); |
||||
} |
||||
|
||||
QVariant KevaTableModel::data(const QModelIndex &index, int role) const |
||||
{ |
||||
if(!index.isValid() || index.row() >= list.length()) |
||||
return QVariant(); |
||||
|
||||
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()) |
||||
{ |
||||
case Date: |
||||
return GUIUtil::dateTimeStr(rec->date); |
||||
case Key: |
||||
return QString::fromStdString(rec->key); |
||||
case Value: |
||||
return QString::fromStdString(rec->value); |
||||
case Block: |
||||
return QString::number(rec->block); |
||||
} |
||||
} |
||||
else if (role == Qt::TextAlignmentRole) |
||||
{ |
||||
if (index.column() == Block) |
||||
return (int)(Qt::AlignRight|Qt::AlignVCenter); |
||||
} |
||||
return QVariant(); |
||||
} |
||||
|
||||
bool KevaTableModel::setData(const QModelIndex &index, const QVariant &value, int role) |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
QVariant KevaTableModel::headerData(int section, Qt::Orientation orientation, int role) const |
||||
{ |
||||
if(orientation == Qt::Horizontal) |
||||
{ |
||||
if(role == Qt::DisplayRole && section < columns.size()) |
||||
{ |
||||
return columns[section]; |
||||
} |
||||
} |
||||
return QVariant(); |
||||
} |
||||
|
||||
/** Gets title for amount column including current display unit if optionsModel reference available. */ |
||||
QString KevaTableModel::getAmountTitle() |
||||
{ |
||||
return (this->walletModel->getOptionsModel() != nullptr) ? tr("Requested") + " ("+BitcoinUnits::shortName(this->walletModel->getOptionsModel()->getDisplayUnit()) + ")" : ""; |
||||
} |
||||
|
||||
QModelIndex KevaTableModel::index(int row, int column, const QModelIndex &parent) const |
||||
{ |
||||
Q_UNUSED(parent); |
||||
|
||||
return createIndex(row, column); |
||||
} |
||||
|
||||
bool KevaTableModel::removeRows(int row, int count, const QModelIndex &parent) |
||||
{ |
||||
Q_UNUSED(parent); |
||||
|
||||
if(count > 0 && row >= 0 && (row+count) <= list.size()) |
||||
{ |
||||
beginRemoveRows(parent, row, row + count - 1); |
||||
list.erase(list.begin() + row, list.begin() + row + count); |
||||
endRemoveRows(); |
||||
return true; |
||||
} else { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
Qt::ItemFlags KevaTableModel::flags(const QModelIndex &index) const |
||||
{ |
||||
return Qt::ItemIsSelectable | Qt::ItemIsEnabled; |
||||
} |
||||
|
||||
|
||||
// actually add to table in GUI
|
||||
void KevaTableModel::setKeva(std::vector<KevaEntry> vKevaEntries) |
||||
{ |
||||
// Remove the old ones.
|
||||
removeRows(0, list.size()); |
||||
list.clear(); |
||||
|
||||
for (auto it = vKevaEntries.begin(); it != vKevaEntries.end(); it++) { |
||||
beginInsertRows(QModelIndex(), 0, 0); |
||||
list.prepend(*it); |
||||
endInsertRows(); |
||||
} |
||||
} |
||||
|
||||
void KevaTableModel::sort(int column, Qt::SortOrder order) |
||||
{ |
||||
qSort(list.begin(), list.end(), KevaEntryLessThan(column, order)); |
||||
Q_EMIT dataChanged(index(0, 0, QModelIndex()), index(list.size() - 1, NUMBER_OF_COLUMNS - 1, QModelIndex())); |
||||
} |
||||
|
||||
void KevaTableModel::updateDisplayUnit() |
||||
{ |
||||
} |
||||
|
||||
bool KevaEntryLessThan::operator()(KevaEntry &left, KevaEntry &right) const |
||||
{ |
||||
KevaEntry *pLeft = &left; |
||||
KevaEntry *pRight = &right; |
||||
if (order == Qt::DescendingOrder) |
||||
std::swap(pLeft, pRight); |
||||
|
||||
switch(column) |
||||
{ |
||||
case KevaTableModel::Date: |
||||
return pLeft->date.toTime_t() < pRight->date.toTime_t(); |
||||
case KevaTableModel::Block: |
||||
return pLeft->block < pRight->block; |
||||
case KevaTableModel::Key: |
||||
return pLeft->key < pRight->key; |
||||
case KevaTableModel::Value: |
||||
return pLeft->value < pRight->value; |
||||
default: |
||||
return pLeft->block < pRight->block; |
||||
} |
||||
} |
@ -0,0 +1,89 @@
@@ -0,0 +1,89 @@
|
||||
// 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.
|
||||
|
||||
#ifndef BITCOIN_QT_KEVATABLEMODEL_H |
||||
#define BITCOIN_QT_KEVATABLEMODEL_H |
||||
|
||||
#include <qt/walletmodel.h> |
||||
|
||||
#include <QAbstractTableModel> |
||||
#include <QStringList> |
||||
#include <QDateTime> |
||||
|
||||
class CWallet; |
||||
|
||||
class KevaEntry |
||||
{ |
||||
public: |
||||
KevaEntry() { } |
||||
|
||||
std::string key; |
||||
std::string value; |
||||
int64_t block; |
||||
QDateTime date; |
||||
}; |
||||
|
||||
class KevaEntryLessThan |
||||
{ |
||||
public: |
||||
KevaEntryLessThan(int nColumn, Qt::SortOrder fOrder): |
||||
column(nColumn), order(fOrder) {} |
||||
bool operator()(KevaEntry &left, KevaEntry &right) const; |
||||
|
||||
private: |
||||
int column; |
||||
Qt::SortOrder order; |
||||
}; |
||||
|
||||
/** Model for list of recently generated payment requests / bitcoin: URIs.
|
||||
* Part of wallet model. |
||||
*/ |
||||
class KevaTableModel: public QAbstractTableModel |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit KevaTableModel(CWallet *wallet, WalletModel *parent); |
||||
~KevaTableModel(); |
||||
|
||||
enum ColumnIndex { |
||||
Date = 0, |
||||
Key = 1, |
||||
Value = 2, |
||||
Block = 3, |
||||
NUMBER_OF_COLUMNS |
||||
}; |
||||
|
||||
/** @name Methods overridden from QAbstractTableModel
|
||||
@{*/ |
||||
int rowCount(const QModelIndex &parent) const; |
||||
int columnCount(const QModelIndex &parent) const; |
||||
QVariant data(const QModelIndex &index, int role) const; |
||||
bool setData(const QModelIndex &index, const QVariant &value, int role); |
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const; |
||||
QModelIndex index(int row, int column, const QModelIndex &parent) const; |
||||
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); |
||||
Qt::ItemFlags flags(const QModelIndex &index) const; |
||||
/*@}*/ |
||||
|
||||
const KevaEntry &entry(int row) const { return list[row]; } |
||||
void setKeva(std::vector<KevaEntry> vKevaEntries); |
||||
|
||||
public Q_SLOTS: |
||||
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); |
||||
void updateDisplayUnit(); |
||||
|
||||
private: |
||||
WalletModel *walletModel; |
||||
QStringList columns; |
||||
QList<KevaEntry> list; |
||||
int64_t nReceiveRequestsMaxId; |
||||
|
||||
/** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */ |
||||
void updateAmountColumnTitle(); |
||||
/** Gets title for amount column including current display unit if optionsModel reference available. */ |
||||
QString getAmountTitle(); |
||||
}; |
||||
|
||||
#endif // BITCOIN_QT_KEVATABLEMODEL_H
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 63 KiB |
Loading…
Reference in new issue