switch to listview for contacts
This commit is contained in:
@@ -99,7 +99,7 @@ void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView *view)
|
||||
{
|
||||
|
||||
|
||||
QStandardItemModel* myModel = new QStandardItemModel();
|
||||
QStandardItemModel* chat = new QStandardItemModel();
|
||||
|
||||
|
||||
for (auto &c : this->chatItems)
|
||||
@@ -121,7 +121,7 @@ void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView *view)
|
||||
|
||||
QStandardItem* Items = new QStandardItem(c.second.toChatLine());
|
||||
Items->setData("Incoming", Qt::UserRole +1);
|
||||
myModel->appendRow(Items);
|
||||
chat->appendRow(Items);
|
||||
|
||||
|
||||
ui->listChat->setResizeMode(QListView::Adjust);
|
||||
@@ -129,7 +129,7 @@ void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView *view)
|
||||
ui->listChat->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
ui->listChat->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
ui->listChat->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
ui->listChat->setModel(myModel);
|
||||
ui->listChat->setModel(chat);
|
||||
ui->listChat->setMinimumSize(200,350);
|
||||
ui->listChat->setItemDelegate(new ListViewDelegate());
|
||||
// ui->listChat->setStyleSheet("background-image: url(res/hushdark.png)"); /////Todo set an png as Watermark backgroung in listChat
|
||||
@@ -148,7 +148,7 @@ void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView *view)
|
||||
|
||||
QStandardItem* Items1 = new QStandardItem(c.second.toChatLine());
|
||||
Items1->setData("Outgoing", Qt::UserRole +1);
|
||||
myModel->appendRow(Items1);
|
||||
chat->appendRow(Items1);
|
||||
qDebug()<<Items1->text();
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView *view)
|
||||
ui->listChat->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
ui->listChat->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
ui->listChat->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
ui->listChat->setModel(myModel);
|
||||
ui->listChat->setModel(chat);
|
||||
ui->listChat->setMinimumSize(200,350);
|
||||
ui->listChat->setItemDelegate(new ListViewDelegate());
|
||||
ui->listChat->show();
|
||||
|
||||
@@ -2,15 +2,28 @@
|
||||
#include "addressbook.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
void ContactModel::renderContactList(QListWidget* view)
|
||||
void ContactModel::renderContactList(QListView* view)
|
||||
{
|
||||
while(view->count() > 0)
|
||||
{
|
||||
view->takeItem(0);
|
||||
}
|
||||
QStandardItemModel* contact = new QStandardItemModel();
|
||||
//}
|
||||
for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
|
||||
{
|
||||
view->addItem(c.getName());
|
||||
// view->addItem(c.getName());
|
||||
|
||||
|
||||
QStandardItem* Items = new QStandardItem(c.getName());
|
||||
contact->appendRow(Items);
|
||||
// view->setItemDelegate({text: contact})
|
||||
// width: view->width })
|
||||
// height: avatar.implicitHeight,
|
||||
// leftPadding: avatar.implicitWidth + 32})
|
||||
|
||||
// Image {
|
||||
// id: avatar
|
||||
// source: "qrc:/" + modelData.replace(" ", "_") + ".png"
|
||||
// }
|
||||
//}
|
||||
view->setModel(contact);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class ContactModel
|
||||
{
|
||||
public:
|
||||
ContactModel() {}
|
||||
void renderContactList(QListWidget* view);
|
||||
void renderContactList(QListView* view);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1029,7 +1029,7 @@ void Controller::refreshChat(QListView *listWidget)
|
||||
|
||||
}
|
||||
|
||||
void Controller::refreshContacts(QListWidget *listWidget)
|
||||
void Controller::refreshContacts(QListView *listWidget)
|
||||
{
|
||||
contactModel->renderContactList(listWidget);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
void refreshAUDCAP();
|
||||
|
||||
void refreshChat(QListView *listWidget);
|
||||
void refreshContacts(QListWidget *listWidget);
|
||||
void refreshContacts(QListView *listWidget);
|
||||
|
||||
void executeStandardUITransaction(Tx tx);
|
||||
|
||||
|
||||
@@ -1328,7 +1328,7 @@
|
||||
<attribute name="title">
|
||||
<string>HushChat</string>
|
||||
</attribute>
|
||||
<widget class="QListWidget" name="listContactWidget">
|
||||
<widget class="QListView" name="listContactWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
|
||||
Reference in New Issue
Block a user