Browse Source

show timestamp of incoming contact request #194

pull/195/head
DenioD 4 years ago
parent
commit
89579022ef
  1. 49
      src/chatmodel.cpp
  2. 262
      src/requestContactDialog.ui

49
src/chatmodel.cpp

@ -112,26 +112,38 @@ void MainWindow::renderContactRequest(){
QStandardItemModel* contactRequest = new QStandardItemModel();
///////// Tableview for incoming contact request
int requestsize = DataStore::getChatDataStore()->getAllNewContactRequests().size();
requestContact.requestContact->setRowCount(requestsize);
requestContact.requestContact->setColumnCount(2);
QStringList request_TableHeader;
request_TableHeader<<"Address"<<"Date";
requestContact.requestContact->setHorizontalHeaderLabels(request_TableHeader);
requestContact.requestContact->setShowGrid(false);
requestContact.requestContact->setEditTriggers(QAbstractItemView::NoEditTriggers);
requestContact.requestContact->setSelectionBehavior(QAbstractItemView::SelectRows);
requestContact.requestContact->setSelectionMode(QAbstractItemView::SingleSelection);
requestContact.requestContact->setColumnWidth(0,205);
int i=0;
for (auto &c : DataStore::getChatDataStore()->getAllNewContactRequests())
{
QStandardItem* Items = new QStandardItem(QString(c.second.getRequestZaddr()));
contactRequest->appendRow(Items);
requestContact.requestContact->setModel(contactRequest);
Items->setData(QIcon(addnewAddrIcon),Qt::DecorationRole);
requestContact.requestContact->setIconSize(QSize(40,50));
requestContact.requestContact->setUniformItemSizes(true);
requestContact.requestContact->show();
int timestamp = c.second.getTimestamp();
QDateTime myDateTime;
myDateTime.setTime_t(timestamp);
QString timestamphtml = myDateTime.toString("yyyy-MM-dd");
requestContact.requestContact->setItem(i, 0, new QTableWidgetItem(c.second.getRequestZaddr()));
requestContact.requestContact->setItem(i, 1, new QTableWidgetItem(timestamphtml));
requestContact.zaddrnew->setVisible(false);
requestContact.zaddrnew->setText(c.second.getRequestZaddr());
requestContact.requestContact->sortByColumn(1, Qt::DescendingOrder);
i++;
}
@ -146,11 +158,8 @@ void MainWindow::renderContactRequest(){
requestContact.zaddrold->setVisible(false);
requestContact.zaddrold->setText(c.second.getRequestZaddr());
}
QObject::connect(requestContact.requestContact, &QTableView::clicked, [&] () {
for (auto &c : DataStore::getChatDataStore()->getAllRawChatItems()){
@ -158,10 +167,6 @@ void MainWindow::renderContactRequest(){
QString label_contact = index.data(Qt::DisplayRole).toString();
QStandardItemModel* contactMemo = new QStandardItemModel();
if ((c.second.isOutgoing() == false) && (label_contact == c.second.getRequestZaddr() && (c.second.getMemo().startsWith("{") == false)))
{
@ -184,8 +189,6 @@ void MainWindow::renderContactRequest(){
});
QObject::connect(requestContact.requestContactOld, &QTableView::clicked, [&] () {
for (auto &c : DataStore::getChatDataStore()->getAllRawChatItems()){
@ -212,8 +215,6 @@ void MainWindow::renderContactRequest(){
}
}
});
QObject::connect(requestContact.pushButton, &QPushButton::clicked, [&] () {
@ -247,8 +248,6 @@ void MainWindow::renderContactRequest(){
);
return;
}
AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid, avatar);
rpc->refreshContacts(
ui->listContactWidget);

262
src/requestContactDialog.ui

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>850</width>
<width>764</width>
<height>495</height>
</rect>
</property>
@ -18,26 +18,44 @@
</property>
<property name="minimumSize">
<size>
<width>850</width>
<width>600</width>
<height>495</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>764</width>
<height>495</height>
</size>
</property>
<property name="windowTitle">
<string>Incoming Contact Request</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>360</x>
<y>10</y>
<width>151</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;Memo of the request&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="6">
<widget class="QListView" name="requestMemo">
<property name="geometry">
<rect>
<x>355</x>
<y>32</y>
<width>400</width>
<height>231</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<width>400</width>
<height>231</height>
</size>
</property>
@ -66,16 +84,28 @@
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>9</x>
<y>9</y>
<width>161</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;Open requests&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;Open requests from:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="3" column="0" rowspan="8">
<widget class="QListView" name="requestContactOld">
<property name="geometry">
<rect>
<x>9</x>
<y>294</y>
<width>162</width>
<height>192</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
@ -84,7 +114,7 @@
</property>
<property name="minimumSize">
<size>
<width>225</width>
<width>150</width>
<height>190</height>
</size>
</property>
@ -101,12 +131,18 @@
<enum>QAbstractItemView::SingleSelection</enum>
</property>
</widget>
</item>
<item row="4" column="4" colspan="3">
<widget class="QLineEdit" name="requestZaddr">
<property name="geometry">
<rect>
<x>299</x>
<y>328</y>
<width>450</width>
<height>25</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>351</width>
<width>450</width>
<height>25</height>
</size>
</property>
@ -117,9 +153,15 @@
</size>
</property>
</widget>
</item>
<item row="4" column="1" colspan="3">
<widget class="QLabel" name="label_8">
<property name="geometry">
<rect>
<x>177</x>
<y>343</y>
<width>97</width>
<height>17</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -130,9 +172,15 @@
<string>Request from:</string>
</property>
</widget>
</item>
<item row="6" column="4" colspan="2">
<widget class="QLineEdit" name="requestLabel">
<property name="geometry">
<rect>
<x>299</x>
<y>399</y>
<width>142</width>
<height>25</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -149,16 +197,28 @@
<number>25</number>
</property>
</widget>
</item>
<item row="10" column="3">
<widget class="QLabel" name="zaddrnew">
<property name="geometry">
<rect>
<x>480</x>
<y>461</y>
<width>16</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="10" column="6">
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>628</x>
<y>461</y>
<width>127</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Add New Contact</string>
</property>
@ -166,16 +226,28 @@
<bool>false</bool>
</property>
</widget>
</item>
<item row="10" column="2">
<widget class="QLabel" name="requestCID">
<property name="geometry">
<rect>
<x>417</x>
<y>461</y>
<width>16</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="7" column="1" colspan="3">
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>177</x>
<y>430</y>
<width>233</width>
<height>17</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -186,9 +258,15 @@
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Choose an avatar for your contact:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="5" column="1" colspan="2">
<widget class="QLabel" name="label_7">
<property name="geometry">
<rect>
<x>177</x>
<y>368</y>
<width>68</width>
<height>17</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -199,16 +277,28 @@
<string>My Zaddr:</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QLabel" name="zaddrold">
<property name="geometry">
<rect>
<x>340</x>
<y>461</y>
<width>16</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item row="10" column="5">
<widget class="QPushButton" name="cancel">
<property name="geometry">
<rect>
<x>542</x>
<y>461</y>
<width>80</width>
<height>25</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -231,9 +321,15 @@
<bool>false</bool>
</property>
</widget>
</item>
<item row="7" column="4">
<widget class="QComboBox" name="comboBoxAvatar">
<property name="geometry">
<rect>
<x>417</x>
<y>430</y>
<width>106</width>
<height>25</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>106</width>
@ -377,38 +473,28 @@
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QListView" name="requestContact">
<property name="minimumSize">
<size>
<width>225</width>
<height>231</height>
</size>
</property>
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="editTriggers">
<set>QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked</set>
</property>
<property name="alternatingRowColors">
<bool>false</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>9</x>
<y>271</y>
<width>179</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;Recently closed requests&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="3">
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>177</x>
<y>294</y>
<width>157</width>
<height>17</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -419,9 +505,15 @@
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;Details of the request&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="6" column="1" colspan="3">
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>177</x>
<y>399</y>
<width>116</width>
<height>17</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -432,12 +524,18 @@
<string>Give a Nickname:</string>
</property>
</widget>
</item>
<item row="5" column="4" colspan="3">
<widget class="QLineEdit" name="requestMyAddr">
<property name="geometry">
<rect>
<x>299</x>
<y>368</y>
<width>450</width>
<height>25</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>351</width>
<width>450</width>
<height>25</height>
</size>
</property>
@ -448,8 +546,34 @@
</size>
</property>
</widget>
</item>
</layout>
<widget class="QTableWidget" name="requestContact">
<property name="geometry">
<rect>
<x>9</x>
<y>32</y>
<width>321</width>
<height>231</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>231</height>
</size>
</property>
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="editTriggers">
<set>QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked</set>
</property>
<property name="alternatingRowColors">
<bool>false</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
</widget>
</widget>
<resources/>
<connections>

Loading…
Cancel
Save