Merge pull request #11 from strider-paff-shell/chat
update// added rederfcuntion to contactlist (causes segfaul on compil…
This commit is contained in:
@@ -68,7 +68,8 @@ SOURCES += \
|
|||||||
src/camount.cpp \
|
src/camount.cpp \
|
||||||
src/chatbubbleme.cpp \
|
src/chatbubbleme.cpp \
|
||||||
src/chatbubblepartner.cpp \
|
src/chatbubblepartner.cpp \
|
||||||
src/chatmodel.cpp
|
src/chatmodel.cpp \
|
||||||
|
src/contactmodel.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/firsttimewizard.h \
|
src/firsttimewizard.h \
|
||||||
@@ -100,7 +101,8 @@ HEADERS += \
|
|||||||
lib/silentdragonlitelib.h \
|
lib/silentdragonlitelib.h \
|
||||||
src/chatbubbleme.h \
|
src/chatbubbleme.h \
|
||||||
src/chatbubblepartner.h \
|
src/chatbubblepartner.h \
|
||||||
src/chatmodel.h
|
src/chatmodel.h \
|
||||||
|
src/contactmodel.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
src/encryption.ui \
|
src/encryption.ui \
|
||||||
|
|||||||
@@ -42,6 +42,12 @@ void AddressBookModel::addNewLabel(QString label, QString addr, QString myAddr)
|
|||||||
{
|
{
|
||||||
//labels.push_back(QPair<QString, QString>(label, addr));
|
//labels.push_back(QPair<QString, QString>(label, addr));
|
||||||
AddressBook::getInstance()->addAddressLabel(label, addr, myAddr);
|
AddressBook::getInstance()->addAddressLabel(label, addr, myAddr);
|
||||||
|
updateUi();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddressBookModel::updateUi()
|
||||||
|
{
|
||||||
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));
|
||||||
@@ -175,8 +181,22 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
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
|
||||||
|
|
||||||
model.addNewLabel(newLabel, ab.addr->text(), "");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Import Button
|
// Import Button
|
||||||
@@ -284,6 +304,7 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
|
|||||||
|
|
||||||
// Refresh after the dialog is closed to update the labels everywhere.
|
// Refresh after the dialog is closed to update the labels everywhere.
|
||||||
parent->getRPC()->refresh(true);
|
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
|
// Convert old addressbook format v1 to v2
|
||||||
QList<QList<QString>> stuff;
|
QList<QList<QString>> stuff;
|
||||||
in >> stuff;
|
in >> stuff;
|
||||||
qDebug() << "Stuff: " << stuff;
|
//qDebug() << "Stuff: " << stuff;
|
||||||
for (int i=0; i < stuff.size(); i++)
|
for (int i=0; i < stuff.size(); i++)
|
||||||
{
|
{
|
||||||
//qDebug() << "0:" << stuff[i][0];
|
//qDebug() << "0:" << stuff[i][0];
|
||||||
//qDebug() << "1:" << stuff[i][1];
|
//qDebug() << "1:" << stuff[i][1];
|
||||||
//qDebug() << "2:" << stuff[i][2];
|
//qDebug() << "2:" << stuff[i][2];
|
||||||
ContactItem contact = ContactItem(stuff[i][2], stuff[i][1], stuff[i][0]);
|
ContactItem contact = ContactItem(stuff[i][2], stuff[i][1], stuff[i][0]);
|
||||||
qDebug() << "contact=" << contact.toQTString();
|
//qDebug() << "contact=" << contact.toQTString();
|
||||||
allLabels.push_back(contact);
|
allLabels.push_back(contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public:
|
|||||||
~AddressBookModel();
|
~AddressBookModel();
|
||||||
|
|
||||||
void addNewLabel(QString label, QString address, QString myAddr);
|
void addNewLabel(QString label, QString address, QString myAddr);
|
||||||
|
void updateUi();
|
||||||
void removeItemAt(int row);
|
void removeItemAt(int row);
|
||||||
//QPair<QString, QString> itemAt(int row);
|
//QPair<QString, QString> itemAt(int row);
|
||||||
ContactItem itemAt(int row);
|
ContactItem itemAt(int row);
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ void ChatModel::renderChatBox(QListWidget *view)
|
|||||||
QDateTime myDateTime;
|
QDateTime myDateTime;
|
||||||
|
|
||||||
myDateTime.setTime_t(c.second.getTimestamp());
|
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("[") + myDateTime.toString("dd.MM.yyyy hh:mm:ss ") + QString("] ");
|
||||||
line += QString("<") + QString(c.second.getContact()) + QString("> :\n");
|
line += QString("<") + QString(c.second.getContact()) + QString("> :\n");
|
||||||
line += QString(c.second.getMemo()) + QString("\n");
|
line += QString(c.second.getMemo()) + QString("\n");
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
#include "contactmodel.h"
|
#include "contactmodel.h"
|
||||||
|
#include "addressbook.h"
|
||||||
|
|
||||||
void ContactModel::renderContactList(QListWidget* view)
|
void ContactModel::renderContactList(QListWidget* view)
|
||||||
{
|
{
|
||||||
for(auto &c : this->_contacts)
|
for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
|
||||||
{
|
{
|
||||||
view->addItem(c.getName());
|
view->addItem(c.getName());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -984,16 +984,23 @@ void Controller::refreshTransactions()
|
|||||||
// Update model data, which updates the table view
|
// Update model data, which updates the table view
|
||||||
transactionsTableModel->replaceData(txdata);
|
transactionsTableModel->replaceData(txdata);
|
||||||
chatModel->renderChatBox(ui->listChatMemo);
|
chatModel->renderChatBox(ui->listChatMemo);
|
||||||
//chatModel->showMessages();
|
refreshContacts(
|
||||||
|
ui->listContactWidget
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::refreshChat(QListWidget *listWidget)
|
void Controller::refreshChat(QListWidget *listWidget)
|
||||||
{
|
{
|
||||||
qDebug() << "Called Controller::refreshChat(QListWidget *listWidget)";
|
|
||||||
chatModel->renderChatBox(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
|
// 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)
|
void Controller::unlockIfEncrypted(std::function<void(void)> cb, std::function<void(void)> error)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ public:
|
|||||||
void refreshAUDCAP();
|
void refreshAUDCAP();
|
||||||
|
|
||||||
void refreshChat(QListWidget *listWidget);
|
void refreshChat(QListWidget *listWidget);
|
||||||
|
void refreshContacts(QListWidget *listWidget);
|
||||||
|
|
||||||
void executeStandardUITransaction(Tx tx);
|
void executeStandardUITransaction(Tx tx);
|
||||||
|
|
||||||
|
|||||||
@@ -1033,10 +1033,15 @@ void ChatMemoEdit::setSendChatButton(QPushButton* button) {
|
|||||||
|
|
||||||
void MainWindow::updateChat()
|
void MainWindow::updateChat()
|
||||||
{
|
{
|
||||||
qDebug() << "Called MainWindow::updateChat()";
|
|
||||||
rpc->refreshChat(ui->listChatMemo);
|
rpc->refreshChat(ui->listChatMemo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::updateContacts()
|
||||||
|
{
|
||||||
|
qDebug() << "Called MainWindow::updateContacts()";
|
||||||
|
rpc->refreshContacts(ui->listContactWidget);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::addNewZaddr(bool sapling) {
|
void MainWindow::addNewZaddr(bool sapling) {
|
||||||
rpc->createNewZaddr(sapling, [=] (json reply) {
|
rpc->createNewZaddr(sapling, [=] (json reply) {
|
||||||
QString addr = QString::fromStdString(reply.get<json::array_t>()[0]);
|
QString addr = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ private:
|
|||||||
void setuphushdTab();
|
void setuphushdTab();
|
||||||
void setupchatTab();
|
void setupchatTab();
|
||||||
void updateChat();
|
void updateChat();
|
||||||
|
void updateContacts();
|
||||||
|
|
||||||
void setupSettingsModal();
|
void setupSettingsModal();
|
||||||
void setupStatusBar();
|
void setupStatusBar();
|
||||||
|
|||||||
Reference in New Issue
Block a user