render HushChat Address in Addressbook
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
AddressBookModel::AddressBookModel(QTableView *parent) : QAbstractTableModel(parent)
|
AddressBookModel::AddressBookModel(QTableView *parent) : QAbstractTableModel(parent)
|
||||||
{
|
{
|
||||||
headers << tr("Label") << tr("Address");
|
headers << tr("Label") << tr("Address") << tr("HushChatAddress");
|
||||||
this->parent = parent;
|
this->parent = parent;
|
||||||
loadData();
|
loadData();
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ void AddressBookModel::removeItemAt(int row)
|
|||||||
if (row >= labels.size())
|
if (row >= labels.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AddressBook::getInstance()->removeAddressLabel(labels[row].getName(), labels[row].getPartnerAddress());
|
AddressBook::getInstance()->removeAddressLabel(labels[row].getName(), labels[row].getPartnerAddress(), labels[row].getMyAddress());
|
||||||
labels.clear();
|
labels.clear();
|
||||||
labels = AddressBook::getInstance()->getAllAddressLabels();
|
labels = AddressBook::getInstance()->getAllAddressLabels();
|
||||||
dataChanged(index(0, 0), index(labels.size()-1, columnCount(index(0,0))-1));
|
dataChanged(index(0, 0), index(labels.size()-1, columnCount(index(0,0))-1));
|
||||||
@@ -99,6 +99,7 @@ QVariant AddressBookModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
case 0: return labels.at(index.row()).getName();
|
case 0: return labels.at(index.row()).getName();
|
||||||
case 1: return labels.at(index.row()).getPartnerAddress();
|
case 1: return labels.at(index.row()).getPartnerAddress();
|
||||||
|
case 2: return labels.at(index.row()).getMyAddress();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,6 +193,7 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
|
|||||||
message, //todo traslate this shit
|
message, //todo traslate this shit
|
||||||
QMessageBox::Ok
|
QMessageBox::Ok
|
||||||
);
|
);
|
||||||
|
// ab.addr_chat->setText(myAddr);
|
||||||
qDebug() << "new generated myAddr" << myAddr;
|
qDebug() << "new generated myAddr" << myAddr;
|
||||||
AddressBook::getInstance()->addAddressLabel(newLabel, ab.addr->text(), myAddr);
|
AddressBook::getInstance()->addAddressLabel(newLabel, ab.addr->text(), myAddr);
|
||||||
});
|
});
|
||||||
@@ -245,8 +247,8 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto fnSetTargetLabelAddr = [=] (QLineEdit* target, QString label, QString addr) {
|
auto fnSetTargetLabelAddr = [=] (QLineEdit* target, QString label, QString addr, QString myAddr) {
|
||||||
target->setText(label % "/" % addr);
|
target->setText(label % "/" % addr % myAddr);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Double-Click picks the item
|
// Double-Click picks the item
|
||||||
@@ -260,8 +262,9 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
|
|||||||
|
|
||||||
QString lbl = model.itemAt(index.row()).getName();
|
QString lbl = model.itemAt(index.row()).getName();
|
||||||
QString addr = model.itemAt(index.row()).getPartnerAddress();
|
QString addr = model.itemAt(index.row()).getPartnerAddress();
|
||||||
|
QString myAddr = model.itemAt(index.row()).getMyAddress();
|
||||||
d.accept();
|
d.accept();
|
||||||
fnSetTargetLabelAddr(target, lbl, addr);
|
fnSetTargetLabelAddr(target, lbl, addr, myAddr);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Right-Click
|
// Right-Click
|
||||||
@@ -273,13 +276,14 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
|
|||||||
|
|
||||||
QString lbl = model.itemAt(index.row()).getName();
|
QString lbl = model.itemAt(index.row()).getName();
|
||||||
QString addr = model.itemAt(index.row()).getPartnerAddress();
|
QString addr = model.itemAt(index.row()).getPartnerAddress();
|
||||||
|
QString myAddr = model.itemAt(index.row()).getMyAddress();
|
||||||
|
|
||||||
QMenu menu(parent);
|
QMenu menu(parent);
|
||||||
|
|
||||||
if (target != nullptr)
|
if (target != nullptr)
|
||||||
menu.addAction("Pick", [&] () {
|
menu.addAction("Pick", [&] () {
|
||||||
d.accept();
|
d.accept();
|
||||||
fnSetTargetLabelAddr(target, lbl, addr);
|
fnSetTargetLabelAddr(target, lbl, addr, myAddr);
|
||||||
});
|
});
|
||||||
|
|
||||||
menu.addAction(QObject::tr("Copy address"), [&] () {
|
menu.addAction(QObject::tr("Copy address"), [&] () {
|
||||||
@@ -298,7 +302,7 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
|
|||||||
auto selection = ab.addresses->selectionModel();
|
auto selection = ab.addresses->selectionModel();
|
||||||
if (selection && selection->hasSelection() && selection->selectedRows().size() > 0) {
|
if (selection && selection->hasSelection() && selection->selectedRows().size() > 0) {
|
||||||
auto item = model.itemAt(selection->selectedRows().at(0).row());
|
auto item = model.itemAt(selection->selectedRows().at(0).row());
|
||||||
fnSetTargetLabelAddr(target, item.getName(), item.getPartnerAddress());
|
fnSetTargetLabelAddr(target, item.getName(), item.getMyAddress(), item.getPartnerAddress());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -408,7 +412,7 @@ void AddressBook::addAddressLabel(QString label, QString address, QString myAddr
|
|||||||
// Iterate over the list and remove the label/address
|
// Iterate over the list and remove the label/address
|
||||||
for (int i=0; i < allLabels.size(); i++)
|
for (int i=0; i < allLabels.size(); i++)
|
||||||
if (allLabels[i].getName() == label)
|
if (allLabels[i].getName() == label)
|
||||||
removeAddressLabel(allLabels[i].getName(), allLabels[i].getPartnerAddress());
|
removeAddressLabel(allLabels[i].getName(), allLabels[i].getPartnerAddress(),allLabels[i].getMyAddress());
|
||||||
|
|
||||||
ContactItem item = ContactItem(myAddr, address, label);
|
ContactItem item = ContactItem(myAddr, address, label);
|
||||||
allLabels.push_back(item);
|
allLabels.push_back(item);
|
||||||
@@ -416,7 +420,7 @@ void AddressBook::addAddressLabel(QString label, QString address, QString myAddr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove a new address/label from the database
|
// Remove a new address/label from the database
|
||||||
void AddressBook::removeAddressLabel(QString label, QString address)
|
void AddressBook::removeAddressLabel(QString label, QString address, QString myAddr)
|
||||||
{
|
{
|
||||||
// Iterate over the list and remove the label/address
|
// Iterate over the list and remove the label/address
|
||||||
for (int i=0; i < allLabels.size(); i++)
|
for (int i=0; i < allLabels.size(); i++)
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
void addAddressLabel(QString label, QString address, QString myAddr);
|
void addAddressLabel(QString label, QString address, QString myAddr);
|
||||||
|
|
||||||
// Remove a new address/label from the database
|
// Remove a new address/label from the database
|
||||||
void removeAddressLabel(QString label, QString address);
|
void removeAddressLabel(QString label, QString address, QString myAddr);
|
||||||
|
|
||||||
// Update a label/address
|
// Update a label/address
|
||||||
void updateLabel(QString oldlabel, QString address, QString newlabel);
|
void updateLabel(QString oldlabel, QString address, QString newlabel);
|
||||||
|
|||||||
@@ -13,65 +13,61 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Address Book</string>
|
<string>Address Book</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item>
|
<item row="0" column="0">
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Add New Address</string>
|
<string>Add New Address</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item>
|
<item row="2" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>HushChat Address - give this Address only to your contact</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLineEdit" name="addr_chat"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_1">
|
<widget class="QLabel" name="label_1">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Address (z-Addr or t-Addr)</string>
|
<string>Address (z-Addr or t-Addr)</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="5" column="0">
|
||||||
<widget class="QLineEdit" name="addr"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Label</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="label">
|
<widget class="QLineEdit" name="label">
|
||||||
<property name="maxLength">
|
<property name="maxLength">
|
||||||
<number>40</number>
|
<number>40</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="6" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
||||||
<item>
|
</item>
|
||||||
<spacer name="horizontalSpacer">
|
<item row="4" column="0">
|
||||||
<property name="orientation">
|
<widget class="QLabel" name="label_2">
|
||||||
<enum>Qt::Horizontal</enum>
|
<property name="text">
|
||||||
</property>
|
<string>Label</string>
|
||||||
<property name="sizeHint" stdset="0">
|
</property>
|
||||||
<size>
|
</widget>
|
||||||
<width>40</width>
|
</item>
|
||||||
<height>20</height>
|
<item row="1" column="0">
|
||||||
</size>
|
<widget class="QLineEdit" name="addr"/>
|
||||||
</property>
|
</item>
|
||||||
</spacer>
|
<item row="6" column="1">
|
||||||
</item>
|
<widget class="QPushButton" name="addNew">
|
||||||
<item>
|
<property name="text">
|
||||||
<widget class="QPushButton" name="addNew">
|
<string>Add to Address Book</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Add to Address Book</string>
|
</widget>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="1" column="0">
|
||||||
<widget class="QTableView" name="addresses">
|
<widget class="QTableView" name="addresses">
|
||||||
<property name="selectionMode">
|
<property name="selectionMode">
|
||||||
<enum>QAbstractItemView::SingleSelection</enum>
|
<enum>QAbstractItemView::SingleSelection</enum>
|
||||||
@@ -87,7 +83,7 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="2" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btnImport">
|
<widget class="QPushButton" name="btnImport">
|
||||||
|
|||||||
@@ -1286,7 +1286,7 @@ void MainWindow::setupReceiveTab() {
|
|||||||
|
|
||||||
if (!curLabel.isEmpty() && label.isEmpty()) {
|
if (!curLabel.isEmpty() && label.isEmpty()) {
|
||||||
info = "Removed Label '" % curLabel % "'";
|
info = "Removed Label '" % curLabel % "'";
|
||||||
AddressBook::getInstance()->removeAddressLabel(curLabel, addr);
|
AddressBook::getInstance()->removeAddressLabel(curLabel, addr, "");
|
||||||
}
|
}
|
||||||
else if (!curLabel.isEmpty() && !label.isEmpty()) {
|
else if (!curLabel.isEmpty() && !label.isEmpty()) {
|
||||||
info = "Updated Label '" % curLabel % "' to '" % label % "'";
|
info = "Updated Label '" % curLabel % "' to '" % label % "'";
|
||||||
|
|||||||
@@ -1417,6 +1417,9 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QListWidget" name="listChatMemo">
|
<widget class="QListWidget" name="listChatMemo">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>340</x>
|
<x>340</x>
|
||||||
@@ -1425,6 +1428,18 @@
|
|||||||
<height>371</height>
|
<height>371</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="editTriggers">
|
||||||
|
<set>QAbstractItemView::NoEditTriggers</set>
|
||||||
|
</property>
|
||||||
|
<property name="showDropIndicator" stdset="0">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="defaultDropAction">
|
||||||
|
<enum>Qt::IgnoreAction</enum>
|
||||||
|
</property>
|
||||||
|
<property name="selectionMode">
|
||||||
|
<enum>QAbstractItemView::NoSelection</enum>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QPushButton" name="sendChatButton">
|
<widget class="QPushButton" name="sendChatButton">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
|
|||||||
Reference in New Issue
Block a user