Add direct chat && fix compilation issue.

This commit is contained in:
Black Hat 2018-07-18 22:16:03 +08:00
parent ac12a9a3c3
commit 1ddfbddc74
7 changed files with 28 additions and 5 deletions

5
qml/Setting.qml Normal file
View File

@ -0,0 +1,5 @@
import QtQuick 2.9
Item {
}

View File

@ -100,11 +100,13 @@ Item {
} }
proxyRoles: [ proxyRoles: [
ExpressionRole { name: "isFavorite"; expression: category === "Favorites" }, ExpressionRole { name: "isFavorite"; expression: category === "Favorites" },
ExpressionRole { name: "isDirectChat"; expression: category === "People" },
ExpressionRole { name: "isLowPriority"; expression: category === "Low Priorities" } ExpressionRole { name: "isLowPriority"; expression: category === "Low Priorities" }
] ]
sorters: [ sorters: [
RoleSorter { roleName: "isFavorite"; sortOrder: Qt.DescendingOrder }, RoleSorter { roleName: "isFavorite"; sortOrder: Qt.DescendingOrder },
RoleSorter { roleName: "isLowPriority" }, RoleSorter { roleName: "isLowPriority" },
RoleSorter { roleName: "isDirectChat" },
StringSorter { roleName: "name" } StringSorter { roleName: "name" }
] ]
} }

5
qml/form/SettingForm.qml Normal file
View File

@ -0,0 +1,5 @@
import QtQuick 2.9
Item {
}

View File

@ -3,7 +3,7 @@ import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import QtQuick.Controls.Material 2.2 import QtQuick.Controls.Material 2.2
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import Qt.labs.settings 1.0 import Qt.labs.settings 1.0 as Settings
import Qt.labs.platform 1.0 as Platform import Qt.labs.platform 1.0 as Platform
import Matrique 0.1 import Matrique 0.1
@ -21,7 +21,7 @@ ApplicationWindow {
FontLoader { id: materialFont; source: "qrc:/asset/font/material.ttf" } FontLoader { id: materialFont; source: "qrc:/asset/font/material.ttf" }
Settings { Settings.Settings {
id: setting id: setting
property alias homeserver: matriqueController.homeserver property alias homeserver: matriqueController.homeserver
property alias userID: matriqueController.userID property alias userID: matriqueController.userID

View File

@ -25,5 +25,7 @@
<file>qml/component/AvatarContainer.qml</file> <file>qml/component/AvatarContainer.qml</file>
<file>qml/form/RoomListForm.qml</file> <file>qml/form/RoomListForm.qml</file>
<file>qml/component/AudioBubble.qml</file> <file>qml/component/AudioBubble.qml</file>
<file>qml/form/SettingForm.qml</file>
<file>qml/Setting.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -12,10 +12,10 @@ void RoomListModel::setConnection(QMatrixClient::Connection* connection) {
Q_ASSERT(connection); Q_ASSERT(connection);
using QMatrixClient::Room; using QMatrixClient::Room;
beginResetModel();
m_connection = connection; m_connection = connection;
m_rooms.clear();
connect(connection, &QMatrixClient::Connection::connected, this,
&RoomListModel::doResetModel);
connect(connection, &QMatrixClient::Connection::invitedRoom, this, connect(connection, &QMatrixClient::Connection::invitedRoom, this,
&RoomListModel::updateRoom); &RoomListModel::updateRoom);
connect(connection, &QMatrixClient::Connection::joinedRoom, this, connect(connection, &QMatrixClient::Connection::joinedRoom, this,
@ -25,8 +25,13 @@ void RoomListModel::setConnection(QMatrixClient::Connection* connection) {
connect(connection, &QMatrixClient::Connection::aboutToDeleteRoom, this, connect(connection, &QMatrixClient::Connection::aboutToDeleteRoom, this,
&RoomListModel::deleteRoom); &RoomListModel::deleteRoom);
for (auto r : connection->roomMap()) doAddRoom(r); doResetModel();
}
void RoomListModel::doResetModel() {
beginResetModel();
m_rooms.clear();
for (auto r : m_connection->roomMap()) doAddRoom(r);
endResetModel(); endResetModel();
} }
@ -129,7 +134,10 @@ QVariant RoomListModel::data(const QModelIndex& index, int role) const {
return room->topic(); return room->topic();
} }
if (role == CategoryRole) { if (role == CategoryRole) {
// if (!room->isDirectChat())
// qDebug() << room->displayName() << "is not direct.";
if (room->isFavourite()) return "Favorites"; if (room->isFavourite()) return "Favorites";
if (room->isDirectChat()) return "People";
if (room->isLowPriority()) return "Low Priorities"; if (room->isLowPriority()) return "Low Priorities";
return "Rooms"; return "Rooms";
} }

View File

@ -24,6 +24,7 @@ class RoomListModel : public QAbstractListModel {
QMatrixClient::Connection* getConnection() { return m_connection; } QMatrixClient::Connection* getConnection() { return m_connection; }
void setConnection(QMatrixClient::Connection* connection); void setConnection(QMatrixClient::Connection* connection);
void doResetModel();
Q_INVOKABLE QMatrixClient::Room* roomAt(int row); Q_INVOKABLE QMatrixClient::Room* roomAt(int row);