update// added rederfcuntion to contactlist (causes segfaul on compiling)
This commit is contained in:
@@ -68,7 +68,8 @@ SOURCES += \
|
||||
src/camount.cpp \
|
||||
src/chatbubbleme.cpp \
|
||||
src/chatbubblepartner.cpp \
|
||||
src/chatmodel.cpp
|
||||
src/chatmodel.cpp \
|
||||
src/contactmodel.cpp
|
||||
|
||||
HEADERS += \
|
||||
src/firsttimewizard.h \
|
||||
@@ -100,7 +101,8 @@ HEADERS += \
|
||||
lib/silentdragonlitelib.h \
|
||||
src/chatbubbleme.h \
|
||||
src/chatbubblepartner.h \
|
||||
src/chatmodel.h
|
||||
src/chatmodel.h \
|
||||
src/contactmodel.h
|
||||
|
||||
FORMS += \
|
||||
src/encryption.ui \
|
||||
|
||||
@@ -42,6 +42,12 @@ void AddressBookModel::addNewLabel(QString label, QString addr, QString myAddr)
|
||||
{
|
||||
//labels.push_back(QPair<QString, QString>(label, addr));
|
||||
AddressBook::getInstance()->addAddressLabel(label, addr, myAddr);
|
||||
updateUi();
|
||||
|
||||
}
|
||||
|
||||
void AddressBookModel::updateUi()
|
||||
{
|
||||
labels.clear();
|
||||
labels = AddressBook::getInstance()->getAllAddressLabels();
|
||||
dataChanged(index(0, 0), index(labels.size()-1, columnCount(index(0,0))-1));
|
||||
@@ -175,8 +181,22 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
model.addNewLabel(newLabel, ab.addr->text(), "");
|
||||
Controller* rpc = parent->getRPC();
|
||||
bool sapling = true;
|
||||
rpc->createNewZaddr(sapling, [=] (json reply) {
|
||||
QString myAddr = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||
QString message = QString("New Chat Address for your partner: ") + myAddr;
|
||||
QMessageBox::critical(
|
||||
parent,
|
||||
QObject::tr("Success"),
|
||||
message, //todo traslate this shit
|
||||
QMessageBox::Ok
|
||||
);
|
||||
qDebug() << "new generated myAddr" << myAddr;
|
||||
AddressBook::getInstance()->addAddressLabel(newLabel, ab.addr->text(), myAddr);
|
||||
});
|
||||
model.updateUi(); //todo fix updating gui after adding
|
||||
|
||||
});
|
||||
|
||||
// Import Button
|
||||
@@ -284,6 +304,7 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
|
||||
|
||||
// Refresh after the dialog is closed to update the labels everywhere.
|
||||
parent->getRPC()->refresh(true);
|
||||
model.updateUi(); //todo fix updating gui after adding
|
||||
}
|
||||
|
||||
//=============
|
||||
@@ -317,14 +338,14 @@ void AddressBook::readFromStorage()
|
||||
// Convert old addressbook format v1 to v2
|
||||
QList<QList<QString>> stuff;
|
||||
in >> stuff;
|
||||
qDebug() << "Stuff: " << stuff;
|
||||
//qDebug() << "Stuff: " << stuff;
|
||||
for (int i=0; i < stuff.size(); i++)
|
||||
{
|
||||
//qDebug() << "0:" << stuff[i][0];
|
||||
//qDebug() << "1:" << stuff[i][1];
|
||||
//qDebug() << "2:" << stuff[i][2];
|
||||
ContactItem contact = ContactItem(stuff[i][2], stuff[i][1], stuff[i][0]);
|
||||
qDebug() << "contact=" << contact.toQTString();
|
||||
//qDebug() << "contact=" << contact.toQTString();
|
||||
allLabels.push_back(contact);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ public:
|
||||
~AddressBookModel();
|
||||
|
||||
void addNewLabel(QString label, QString address, QString myAddr);
|
||||
void updateUi();
|
||||
void removeItemAt(int row);
|
||||
//QPair<QString, QString> itemAt(int row);
|
||||
ContactItem itemAt(int row);
|
||||
|
||||
@@ -84,7 +84,7 @@ void ChatModel::renderChatBox(QListWidget *view)
|
||||
QDateTime myDateTime;
|
||||
|
||||
myDateTime.setTime_t(c.second.getTimestamp());
|
||||
qDebug() << "[" << myDateTime.toString("dd.MM.yyyy hh:mm:ss ") << "] " << "<" << c.second.getAddress() << "> :" << c.second.getMemo();
|
||||
//qDebug() << "[" << myDateTime.toString("dd.MM.yyyy hh:mm:ss ") << "] " << "<" << c.second.getAddress() << "> :" << c.second.getMemo();
|
||||
line += QString("[") + myDateTime.toString("dd.MM.yyyy hh:mm:ss ") + QString("] ");
|
||||
line += QString("<") + QString(c.second.getContact()) + QString("> :\n");
|
||||
line += QString(c.second.getMemo()) + QString("\n");
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#include "contactmodel.h"
|
||||
#include "addressbook.h"
|
||||
|
||||
void ContactModel::renderContactList(QListWidget* view)
|
||||
{
|
||||
for(auto &c : this->_contacts)
|
||||
for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
|
||||
{
|
||||
view->addItem(c.getName());
|
||||
}
|
||||
|
||||
@@ -984,16 +984,23 @@ void Controller::refreshTransactions()
|
||||
// Update model data, which updates the table view
|
||||
transactionsTableModel->replaceData(txdata);
|
||||
chatModel->renderChatBox(ui->listChatMemo);
|
||||
//chatModel->showMessages();
|
||||
refreshContacts(
|
||||
ui->listContactWidget
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
void Controller::refreshChat(QListWidget *listWidget)
|
||||
{
|
||||
qDebug() << "Called Controller::refreshChat(QListWidget *listWidget)";
|
||||
chatModel->renderChatBox(listWidget);
|
||||
}
|
||||
|
||||
void Controller::refreshContacts(QListWidget *listWidget)
|
||||
{
|
||||
qDebug() << "Called Controller::refreshContacts(QListWidget *listWidget)";
|
||||
contactModel->renderContactList(listWidget);
|
||||
}
|
||||
|
||||
// If the wallet is encrpyted and locked, we need to unlock it
|
||||
void Controller::unlockIfEncrypted(std::function<void(void)> cb, std::function<void(void)> error)
|
||||
{
|
||||
|
||||
@@ -73,6 +73,7 @@ public:
|
||||
void refreshAUDCAP();
|
||||
|
||||
void refreshChat(QListWidget *listWidget);
|
||||
void refreshContacts(QListWidget *listWidget);
|
||||
|
||||
void executeStandardUITransaction(Tx tx);
|
||||
|
||||
|
||||
@@ -985,10 +985,15 @@ void MainWindow::setupTransactionsTab() {
|
||||
|
||||
void MainWindow::updateChat()
|
||||
{
|
||||
qDebug() << "Called MainWindow::updateChat()";
|
||||
rpc->refreshChat(ui->listChatMemo);
|
||||
}
|
||||
|
||||
void MainWindow::updateContacts()
|
||||
{
|
||||
qDebug() << "Called MainWindow::updateContacts()";
|
||||
rpc->refreshContacts(ui->listContactWidget);
|
||||
}
|
||||
|
||||
void MainWindow::addNewZaddr(bool sapling) {
|
||||
rpc->createNewZaddr(sapling, [=] (json reply) {
|
||||
QString addr = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||
|
||||
@@ -91,6 +91,7 @@ private:
|
||||
void setuphushdTab();
|
||||
void setupchatTab();
|
||||
void updateChat();
|
||||
void updateContacts();
|
||||
|
||||
void setupSettingsModal();
|
||||
void setupStatusBar();
|
||||
|
||||
Reference in New Issue
Block a user