diff --git a/autotests/roomfilterproxymodeltest.cpp b/autotests/roomfilterproxymodeltest.cpp index 9a65a4d3..8fea8485 100644 --- a/autotests/roomfilterproxymodeltest.cpp +++ b/autotests/roomfilterproxymodeltest.cpp @@ -1,63 +1,63 @@ /* Copyright (c) 2018 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "roomfilterproxymodeltest.h" #include "model/roomfilterproxymodel.h" #include "model/roommodel.h" #include QTEST_MAIN(RoomFilterProxyModelTest) RoomFilterProxyModelTest::RoomFilterProxyModelTest(QObject *parent) : QObject(parent) { } void RoomFilterProxyModelTest::shouldHaveDefaultValue() { RoomFilterProxyModel w; RoomModel sourceModel; w.setSourceModel(&sourceModel); QCOMPARE(w.rowCount(), 0); QVERIFY(w.sourceModel()); QCOMPARE(w.sourceModel(), &sourceModel); QHash roles; roles[RoomModel::RoomName] = QByteArrayLiteral("name"); roles[RoomModel::RoomID] = QByteArrayLiteral("room_id"); roles[RoomModel::RoomSelected] = QByteArrayLiteral("selected"); roles[RoomModel::RoomUnread] = QByteArrayLiteral("unread"); roles[RoomModel::RoomType] = QByteArrayLiteral("type"); roles[RoomModel::RoomUserName] = QByteArrayLiteral("username"); roles[RoomModel::RoomUserID] = QByteArrayLiteral("userID"); roles[RoomModel::RoomTopic] = QByteArrayLiteral("topic"); roles[RoomModel::RoomMutedUsers] = QByteArrayLiteral("mutedUsers"); roles[RoomModel::RoomJitsiTimeout] = QByteArrayLiteral("jitsiTimeout"); roles[RoomModel::RoomRo] = QByteArrayLiteral("readOnly"); - roles[RoomModel::RoomAnnoucement] = QByteArrayLiteral("announcement"); + roles[RoomModel::RoomAnnouncement] = QByteArrayLiteral("announcement"); roles[RoomModel::RoomOpen] = QByteArrayLiteral("open"); roles[RoomModel::RoomAlert] = QByteArrayLiteral("alert"); roles[RoomModel::RoomOrder] = QByteArrayLiteral("roomorder"); roles[RoomModel::RoomFavorite] = QByteArrayLiteral("favorite"); roles[RoomModel::RoomSection] = QByteArrayLiteral("sectionname"); roles[RoomModel::RoomIcon] = QByteArrayLiteral("channelicon"); roles[RoomModel::RoomUserMentions] = QByteArrayLiteral("userMentions"); QCOMPARE(w.roleNames(), roles); } diff --git a/autotests/roommodeltest.cpp b/autotests/roommodeltest.cpp index a3db70e3..71c590ae 100644 --- a/autotests/roommodeltest.cpp +++ b/autotests/roommodeltest.cpp @@ -1,526 +1,526 @@ /* Copyright (c) 2017-2018 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "room.h" #include "roomwrapper.h" #include "roommodeltest.h" #include "test_model_helpers.h" #include "model/roommodel.h" #include "ruqola_autotest_helper.h" #include #include #include #include #include #include QTEST_GUILESS_MAIN(RoomModelTest) //TEST signal/slot RoomModelTest::RoomModelTest(QObject *parent) : QObject(parent) { } void RoomModelTest::shouldHaveDefaultValues() { RoomModel sampleModel; QCOMPARE(sampleModel.rowCount(), 0); QHash roles; roles[RoomModel::RoomName] = QByteArrayLiteral("name"); roles[RoomModel::RoomID] = QByteArrayLiteral("room_id"); roles[RoomModel::RoomSelected] = QByteArrayLiteral("selected"); roles[RoomModel::RoomUnread] = QByteArrayLiteral("unread"); roles[RoomModel::RoomType] = QByteArrayLiteral("type"); roles[RoomModel::RoomUserName] = QByteArrayLiteral("username"); roles[RoomModel::RoomUserID] = QByteArrayLiteral("userID"); roles[RoomModel::RoomTopic] = QByteArrayLiteral("topic"); roles[RoomModel::RoomMutedUsers] = QByteArrayLiteral("mutedUsers"); roles[RoomModel::RoomJitsiTimeout] = QByteArrayLiteral("jitsiTimeout"); roles[RoomModel::RoomRo] = QByteArrayLiteral("readOnly"); - roles[RoomModel::RoomAnnoucement] = QByteArrayLiteral("announcement"); + roles[RoomModel::RoomAnnouncement] = QByteArrayLiteral("announcement"); roles[RoomModel::RoomOpen] = QByteArrayLiteral("open"); roles[RoomModel::RoomAlert] = QByteArrayLiteral("alert"); roles[RoomModel::RoomOrder] = QByteArrayLiteral("roomorder"); roles[RoomModel::RoomFavorite] = QByteArrayLiteral("favorite"); roles[RoomModel::RoomSection] = QByteArrayLiteral("sectionname"); roles[RoomModel::RoomIcon] = QByteArrayLiteral("channelicon"); roles[RoomModel::RoomUserMentions] = QByteArrayLiteral("userMentions"); QCOMPARE(sampleModel.roleNames(), roles); } void RoomModelTest::shouldReturnRowCount() { RoomModel sampleModel; QSignalSpy rowInsertedSpy(&sampleModel, &RoomModel::rowsInserted); QSignalSpy rowABTInserted(&sampleModel, &RoomModel::rowsAboutToBeInserted); QSignalSpy rowRemovedSpy(&sampleModel, &RoomModel::rowsRemoved); QSignalSpy rowABTRemoved(&sampleModel, &RoomModel::rowsAboutToBeRemoved); QCOMPARE(sampleModel.rowCount(), 0); sampleModel.addRoom(QStringLiteral("myRoomID1"), QStringLiteral("myRoom1")); QCOMPARE(sampleModel.rowCount(), 1); QCOMPARE(rowInsertedSpy.count(), 1); QCOMPARE(rowABTInserted.count(), 1); QCOMPARE(rowRemovedSpy.count(), 0); QCOMPARE(rowABTRemoved.count(), 0); QCOMPARE(TestModelHelpers::rowSpyToText(rowInsertedSpy), QStringLiteral("0,0")); QCOMPARE(TestModelHelpers::rowSpyToText(rowABTInserted), QStringLiteral("0,0")); rowInsertedSpy.clear(); rowABTInserted.clear(); rowRemovedSpy.clear(); rowABTRemoved.clear(); sampleModel.addRoom(QStringLiteral("myRoomID1"), QStringLiteral("bla bla")); QCOMPARE(sampleModel.rowCount(), 1); //Fix it. We remove + readd after that ! it's not optimal QCOMPARE(rowInsertedSpy.count(), 1); QCOMPARE(rowABTInserted.count(), 1); QCOMPARE(rowRemovedSpy.count(), 0); QCOMPARE(rowABTRemoved.count(), 0); rowInsertedSpy.clear(); rowABTInserted.clear(); rowRemovedSpy.clear(); rowABTRemoved.clear(); sampleModel.addRoom(QStringLiteral("myRoomID2"), QStringLiteral("myRoom2"), true); QCOMPARE(sampleModel.rowCount(), 2); QCOMPARE(rowInsertedSpy.count(), 1); QCOMPARE(rowABTInserted.count(), 1); QCOMPARE(rowRemovedSpy.count(), 0); QCOMPARE(rowABTRemoved.count(), 0); QCOMPARE(TestModelHelpers::rowSpyToText(rowInsertedSpy), QStringLiteral("1,1")); QCOMPARE(TestModelHelpers::rowSpyToText(rowABTInserted), QStringLiteral("1,1")); } void RoomModelTest::shouldFindRoom() { RoomModel sampleModel; RoomWrapper *sampleWrapper = nullptr; sampleModel.addRoom(QStringLiteral("RA15"), QStringLiteral("master")); sampleWrapper = sampleModel.findRoomWrapper(QStringLiteral("RA151100ECE")); QVERIFY(!sampleWrapper); sampleModel.addRoom(QStringLiteral("RA151100ECE"), QStringLiteral("myRoom")); sampleWrapper = sampleModel.findRoomWrapper(QStringLiteral("RA151100ECE")); QVERIFY(sampleWrapper); QCOMPARE(QStringLiteral("myRoom"), sampleWrapper->name()); delete sampleWrapper; } void RoomModelTest::shouldAddRoom() { RoomModel sampleModel; RoomWrapper *sampleWrapper = nullptr; QCOMPARE(sampleModel.rowCount(), 0); sampleModel.addRoom(QStringLiteral("RA151100ECE"), QStringLiteral("myRoom")); QCOMPARE(sampleModel.rowCount(), 1); sampleWrapper = sampleModel.findRoomWrapper(QStringLiteral("RA151100ECE")); QVERIFY(sampleWrapper); QCOMPARE(QStringLiteral("myRoom"), sampleWrapper->name()); delete sampleWrapper; } void RoomModelTest::shouldUpdateRoom() { //FIXME!! /* RoomModel sampleModel; RoomWrapper *sampleWrapper = nullptr; sampleModel.addRoom(QStringLiteral("RA151100ECE"), QStringLiteral("myRoom")); QSignalSpy spy(&sampleModel, &RoomModel::dataChanged); const QString Id = QStringLiteral("RA151100ECE"); const QString name = QStringLiteral("newName"); const QString topic = QStringLiteral("myTopic"); const QString announcement = QStringLiteral("Happy New Year announcement"); const QString description = QStringLiteral("description"); sampleModel.updateRoom(name, Id, topic, announcement, true, description); sampleWrapper = sampleModel.findRoomWrapper(Id); QVERIFY(sampleWrapper); QCOMPARE(sampleWrapper->name(), name); QCOMPARE(sampleWrapper->topic(), topic); QCOMPARE(sampleWrapper->announcement(), announcement); QCOMPARE(sampleWrapper->description(), description); QVERIFY(sampleWrapper->readOnly()); QCOMPARE(spy.count(), 1); delete sampleWrapper; */ } void RoomModelTest::shouldUpdateRoomFromQJsonObject() { RoomModel sampleModel; RoomWrapper *sampleWrapper = nullptr; QJsonObject roomData; const QString name = QStringLiteral("newName"); const QString topic = QStringLiteral("myTopic"); const QString announcement = QStringLiteral("Happy New Year announcement"); roomData.insert(QStringLiteral("rid"), QJsonValue(QLatin1String("RA151100ECE"))); roomData.insert(QStringLiteral("name"), QJsonValue(name)); roomData.insert(QStringLiteral("announcement"), announcement); roomData.insert(QStringLiteral("topic"), topic); QCOMPARE(sampleModel.rowCount(), 0); sampleModel.addRoom(QStringLiteral("RA151100ECE"), QStringLiteral("myRoom")); QCOMPARE(sampleModel.rowCount(), 1); QSignalSpy spy(&sampleModel, &RoomModel::dataChanged); sampleModel.updateRoom(roomData); sampleWrapper = sampleModel.findRoomWrapper(QStringLiteral("RA151100ECE")); QVERIFY(sampleWrapper); QCOMPARE(name, sampleWrapper->name()); QCOMPARE(topic, sampleWrapper->topic()); QCOMPARE(announcement, sampleWrapper->announcement()); QCOMPARE(sampleWrapper->readOnly(), false); QCOMPARE(spy.count(), 1); delete sampleWrapper; } void RoomModelTest::shouldUpdateSubcriptionActionRemoved() { RoomModel sampleModel; QJsonArray input; QJsonObject roomData; roomData.insert(QStringLiteral("rid"), QJsonValue(QLatin1String("RA151100ECE"))); input.append(QJsonValue(QLatin1String("removed"))); input.append(QJsonValue(roomData)); QCOMPARE(sampleModel.rowCount(), 0); sampleModel.addRoom(QStringLiteral("RA151100ECE"), QStringLiteral("myRoom")); QCOMPARE(sampleModel.rowCount(), 1); sampleModel.updateSubscription(input); QCOMPARE(sampleModel.rowCount(), 0); roomData.insert(QStringLiteral("rid"), QJsonValue(QLatin1String("RA151100ECE_NEW"))); input.pop_back(); input.append(QJsonValue(roomData)); sampleModel.updateSubscription(input); QCOMPARE(sampleModel.rowCount(), 0); } void RoomModelTest::shouldUpdateSubcriptionActionInserted() { RoomModel sampleModel; QJsonArray input; QJsonObject roomData; roomData.insert(QStringLiteral("rid"), QJsonValue(QLatin1String("RA151100ECE"))); roomData.insert(QStringLiteral("name"), QJsonValue(QLatin1String("myRoom"))); input.append(QJsonValue(QLatin1String("inserted"))); input.append(QJsonValue(roomData)); QCOMPARE(sampleModel.rowCount(), 0); sampleModel.updateSubscription(input); QCOMPARE(sampleModel.rowCount(), 1); sampleModel.updateSubscription(input); QCOMPARE(sampleModel.rowCount(), 1); } void RoomModelTest::shouldUpdateSubcriptionActionUpdated() { //TODO rename autotests as it's not updatesubscrition but updateroom //Update subscription doesn't update topic and co RoomModel sampleModel; //QJsonArray input; QJsonObject roomData; RoomWrapper *sampleWrapper = nullptr; sampleModel.addRoom(QStringLiteral("RA151100ECE"), QStringLiteral("myRoom")); const QString name = QStringLiteral("newName"); const QString topic = QStringLiteral("myTopic"); const QString announcement = QStringLiteral("Happy New Year announcement"); roomData.insert(QStringLiteral("rid"), QJsonValue(QLatin1String("RA151100ECE"))); roomData.insert(QStringLiteral("name"), QJsonValue(name)); roomData.insert(QStringLiteral("announcement"), announcement); roomData.insert(QStringLiteral("topic"), topic); // input.append(QJsonValue(QLatin1String("updated"))); // input.append(roomData); QCOMPARE(sampleModel.rowCount(), 1); QSignalSpy spy(&sampleModel, &RoomModel::dataChanged); sampleModel.updateRoom(roomData); QCOMPARE(sampleModel.rowCount(), 1); sampleWrapper = sampleModel.findRoomWrapper(QStringLiteral("RA151100ECE")); QVERIFY(sampleWrapper); QCOMPARE(name, sampleWrapper->name()); QCOMPARE(topic, sampleWrapper->topic()); QCOMPARE(announcement, sampleWrapper->announcement()); QCOMPARE(sampleWrapper->readOnly(), false); QCOMPARE(spy.count(), 1); delete sampleWrapper; } void RoomModelTest::shouldClear() { RoomModel sampleModel; QSignalSpy rowInsertedSpy(&sampleModel, &RoomModel::rowsInserted); QSignalSpy rowABTInserted(&sampleModel, &RoomModel::rowsAboutToBeInserted); QSignalSpy rowRemovedSpy(&sampleModel, &RoomModel::rowsRemoved); QSignalSpy rowABTRemoved(&sampleModel, &RoomModel::rowsAboutToBeRemoved); QCOMPARE(sampleModel.rowCount(), 0); sampleModel.addRoom(QStringLiteral("RA151100ECE"), QStringLiteral("myRoom")); QCOMPARE(sampleModel.rowCount(), 1); QCOMPARE(rowInsertedSpy.count(), 1); QCOMPARE(rowABTInserted.count(), 1); QCOMPARE(rowRemovedSpy.count(), 0); QCOMPARE(rowABTRemoved.count(), 0); QCOMPARE(TestModelHelpers::rowSpyToText(rowInsertedSpy), QStringLiteral("0,0")); QCOMPARE(TestModelHelpers::rowSpyToText(rowABTInserted), QStringLiteral("0,0")); rowInsertedSpy.clear(); rowABTInserted.clear(); rowRemovedSpy.clear(); rowABTRemoved.clear(); sampleModel.clear(); QCOMPARE(sampleModel.rowCount(), 0); QCOMPARE(rowInsertedSpy.count(), 0); QCOMPARE(rowABTInserted.count(), 0); QCOMPARE(rowRemovedSpy.count(), 1); QCOMPARE(rowABTRemoved.count(), 1); QCOMPARE(TestModelHelpers::rowSpyToText(rowRemovedSpy), QStringLiteral("0,0")); QCOMPARE(TestModelHelpers::rowSpyToText(rowABTRemoved), QStringLiteral("0,0")); for (int i = 0; i < 15; i++) { sampleModel.addRoom(QStringLiteral("RA151100ECE%1").arg(i), QStringLiteral("myRoom%1").arg(i)); } QCOMPARE(sampleModel.rowCount(), 15); rowInsertedSpy.clear(); rowABTInserted.clear(); rowRemovedSpy.clear(); rowABTRemoved.clear(); sampleModel.clear(); QCOMPARE(rowInsertedSpy.count(), 0); QCOMPARE(rowABTInserted.count(), 0); QCOMPARE(rowRemovedSpy.count(), 1); QCOMPARE(rowABTRemoved.count(), 1); QCOMPARE(TestModelHelpers::rowSpyToText(rowRemovedSpy), QStringLiteral("0,14")); QCOMPARE(TestModelHelpers::rowSpyToText(rowABTRemoved), QStringLiteral("0,14")); } void RoomModelTest::shouldReset() { RoomModel sampleModel; //RoomWrapper *sampleWrapper; const QString Id = QStringLiteral("RA151100ECE"); const QString name = QStringLiteral("myRoom"); QCOMPARE(sampleModel.rowCount(), 0); sampleModel.addRoom(Id, name); QCOMPARE(sampleModel.rowCount(), 1); //TODO: should uncomment this after enabling cache in roomModel /* sampleModel.reset(); QCOMPARE(1, sampleModel.rowCount()); sampleWrapper = sampleModel.findRoomWrapper(Id); QCOMPARE(name, sampleWrapper->name()); */ } void RoomModelTest::shouldReturnDataDefault() { RoomModel sampleModel; QVariant output; QString Id = QStringLiteral("RA151100ECE"); QString name = QStringLiteral("myRoom"); sampleModel.addRoom(Id, name); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomName); QCOMPARE(output.toString(), name); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomID); QCOMPARE(output.toString(), Id); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomSelected); QCOMPARE(output.toBool(), false); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomType); //channel type QVERIFY(output.toString().isEmpty()); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomUserID); QVERIFY(output.toString().isEmpty()); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomUserName); QVERIFY(output.toString().isEmpty()); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomTopic); QVERIFY(output.toString().isEmpty()); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomMutedUsers); QVERIFY(output.toStringList().isEmpty()); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomJitsiTimeout); QCOMPARE(output, QVariant(qint64(-1))); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomRo); QCOMPARE(output.toBool(), false); - output = sampleModel.data(sampleModel.index(0), RoomModel::RoomAnnoucement); + output = sampleModel.data(sampleModel.index(0), RoomModel::RoomAnnouncement); QVERIFY(output.toString().isEmpty()); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomUnread); QCOMPARE(output, QVariant(int(0))); //quint64 not used in room.cpp??? output = sampleModel.data(sampleModel.index(0), RoomModel::RoomFavorite); QCOMPARE(output.toBool(), false); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomOpen); QCOMPARE(output.toBool(), false); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomSection); QVERIFY(output.toString().isEmpty()); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomOrder); QCOMPARE(output, QVariant(int(6))); // not favorite (3) + no channel selected or 'p' (3) = total order(6) output = sampleModel.data(sampleModel.index(0), RoomModel::RoomIcon); QCOMPARE(output, QVariant(QIcon())); } void RoomModelTest::shouldReturnData() { Room *input = new Room(nullptr); const QString Id = QStringLiteral("RA151100ECE"); const QString name = QStringLiteral("myRoom"); const bool selected = true; const QString roomType = QStringLiteral("p"); const QString userId = QStringLiteral("sdfsdfs"); const QString userName = QStringLiteral("pp"); const QString topic = QStringLiteral("topic"); const QStringList mutedUsers = QStringList{QStringLiteral("mutedUsers"), QStringLiteral("muted2")}; const qint64 time = 55; const bool readOnly = true; const QString announcement = QStringLiteral("AA"); const int unread = 66; const bool favorite = true; const bool open = true; input->setRoomId(Id); input->setName(name); input->setSelected(selected); input->setChannelType(roomType); input->setRoomCreatorUserId(userId); input->setRoomCreatorUserName(userName); input->setTopic(topic); input->setMutedUsers(mutedUsers); input->setJitsiTimeout(time); input->setReadOnly(readOnly); input->setAnnouncement(announcement); input->setUnread(unread); input->setFavorite(favorite); input->setOpen(open); RoomModel sampleModel; QVariant output; sampleModel.addRoom(input);//don't pass address. pass pointer variable output = sampleModel.data(sampleModel.index(0), RoomModel::RoomName); QCOMPARE(output.toString(), name); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomID); QCOMPARE(output.toString(), Id); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomSelected); QCOMPARE(output.toBool(), selected); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomType); //channel type QCOMPARE(output.toString(), roomType); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomUserID); QCOMPARE(output.toString(), userId); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomUserName); QCOMPARE(output.toString(), userName); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomTopic); QCOMPARE(output.toString(), topic); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomMutedUsers); QCOMPARE(output.toStringList(), mutedUsers); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomJitsiTimeout); QCOMPARE(output, QVariant(time)); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomRo); QCOMPARE(output.toBool(), readOnly); - output = sampleModel.data(sampleModel.index(0), RoomModel::RoomAnnoucement); + output = sampleModel.data(sampleModel.index(0), RoomModel::RoomAnnouncement); QCOMPARE(output.toString(), announcement); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomUnread); QCOMPARE(output, QVariant(unread)); //quint64 not used in room.cpp??? output = sampleModel.data(sampleModel.index(0), RoomModel::RoomFavorite); QCOMPARE(output.toBool(), favorite); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomOpen); QCOMPARE(output.toBool(), open); output = sampleModel.data(sampleModel.index(0), RoomModel::RoomSection); QCOMPARE(output.toString(), QStringLiteral("Favorites")); //first priority for favrites and then to channels output = sampleModel.data(sampleModel.index(0), RoomModel::RoomOrder); QCOMPARE(output, QVariant(int(1))); // Private room output = sampleModel.data(sampleModel.index(0), RoomModel::RoomIcon); QCOMPARE(output, QVariant(QIcon::fromTheme(QStringLiteral("lock")))); } void RoomModelTest::shouldInsertRoom_data() { QTest::addColumn("insertRoomFileName"); QTest::addColumn("roomId"); QTest::newRow("insertroom1") << QStringLiteral("insertroom1") << QStringLiteral("fooid"); QTest::newRow("insertroom2") << QStringLiteral("insertroom2") << QStringLiteral("bla1"); } void RoomModelTest::shouldInsertRoom() { QFETCH(QString, insertRoomFileName); QFETCH(QString, roomId); const QString originalJsonFile = QLatin1String(RUQOLA_DATA_DIR) + QStringLiteral("/insert-rooms/") + insertRoomFileName + QStringLiteral(".json"); QFile f(originalJsonFile); QVERIFY(f.open(QIODevice::ReadOnly)); const QByteArray content = f.readAll(); f.close(); const QJsonDocument doc = QJsonDocument::fromJson(content); const QJsonObject fields = doc.object(); RoomModel sampleModel; const QString generatedRoomId = sampleModel.insertRoom(fields); QCOMPARE(generatedRoomId, roomId); QCOMPARE(sampleModel.rowCount(), 1); Room *r = sampleModel.findRoom(generatedRoomId); QVERIFY(r); //qDebug() << " fields"< This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "roomwrappertest.h" #include "roomwrapper.h" #include "room.h" #include #include QTEST_GUILESS_MAIN(RoomWrapperTest) RoomWrapperTest::RoomWrapperTest(QObject *parent) : QObject(parent) { } void RoomWrapperTest::shouldHaveDefaultValue() { Room *room = new Room(); RoomWrapper w(room); QVERIFY(w.announcement().isEmpty()); QVERIFY(w.name().isEmpty()); QVERIFY(w.topic().isEmpty()); QVERIFY(w.channelType().isEmpty()); QVERIFY(!w.favorite()); QVERIFY(!w.blocker()); QVERIFY(w.roomCreatorUserId().isEmpty()); QVERIFY(w.rid().isEmpty()); QVERIFY(w.description().isEmpty()); QVERIFY(!w.archived()); delete room; } void RoomWrapperTest::shouldAssignValue() { Room *room = new Room(); RoomWrapper w(room); - QSignalSpy spyRoomAnnoucementChanged(&w, &RoomWrapper::announcementChanged); + QSignalSpy spyRoomAnnouncementChanged(&w, &RoomWrapper::announcementChanged); QSignalSpy spyRoomTopicChanged(&w, &RoomWrapper::topicChanged); QSignalSpy spyRoomNameChanged(&w, &RoomWrapper::nameChanged); QSignalSpy spyRoomFavoriteChanged(&w, &RoomWrapper::favoriteChanged); QSignalSpy spyRoomBlockerChanged(&w, &RoomWrapper::blockerChanged); QSignalSpy spyRoomDescriptionChanged(&w, &RoomWrapper::descriptionChanged); QSignalSpy spyRoomArchivedChanged(&w, &RoomWrapper::archivedChanged); room->setAnnouncement(QStringLiteral("foo")); - QCOMPARE(spyRoomAnnoucementChanged.count(), 1); + QCOMPARE(spyRoomAnnouncementChanged.count(), 1); QCOMPARE(spyRoomTopicChanged.count(), 0); QCOMPARE(spyRoomNameChanged.count(), 0); QCOMPARE(spyRoomFavoriteChanged.count(), 0); QCOMPARE(spyRoomBlockerChanged.count(), 0); QCOMPARE(spyRoomDescriptionChanged.count(), 0); QCOMPARE(spyRoomArchivedChanged.count(), 0); - spyRoomAnnoucementChanged.clear(); + spyRoomAnnouncementChanged.clear(); spyRoomTopicChanged.clear(); spyRoomNameChanged.clear(); spyRoomFavoriteChanged.clear(); spyRoomBlockerChanged.clear(); spyRoomDescriptionChanged.clear(); spyRoomArchivedChanged.clear(); room->setAnnouncement(QStringLiteral("foo")); - QCOMPARE(spyRoomAnnoucementChanged.count(), 0); + QCOMPARE(spyRoomAnnouncementChanged.count(), 0); QCOMPARE(spyRoomTopicChanged.count(), 0); QCOMPARE(spyRoomNameChanged.count(), 0); QCOMPARE(spyRoomFavoriteChanged.count(), 0); QCOMPARE(spyRoomBlockerChanged.count(), 0); QCOMPARE(spyRoomDescriptionChanged.count(), 0); QCOMPARE(spyRoomArchivedChanged.count(), 0); - spyRoomAnnoucementChanged.clear(); + spyRoomAnnouncementChanged.clear(); spyRoomTopicChanged.clear(); spyRoomNameChanged.clear(); spyRoomFavoriteChanged.clear(); spyRoomBlockerChanged.clear(); spyRoomDescriptionChanged.clear(); spyRoomArchivedChanged.clear(); room->setTopic(QStringLiteral("foo")); - QCOMPARE(spyRoomAnnoucementChanged.count(), 0); + QCOMPARE(spyRoomAnnouncementChanged.count(), 0); QCOMPARE(spyRoomTopicChanged.count(), 1); QCOMPARE(spyRoomNameChanged.count(), 0); QCOMPARE(spyRoomFavoriteChanged.count(), 0); QCOMPARE(spyRoomBlockerChanged.count(), 0); QCOMPARE(spyRoomDescriptionChanged.count(), 0); QCOMPARE(spyRoomArchivedChanged.count(), 0); - spyRoomAnnoucementChanged.clear(); + spyRoomAnnouncementChanged.clear(); spyRoomTopicChanged.clear(); spyRoomNameChanged.clear(); spyRoomFavoriteChanged.clear(); spyRoomBlockerChanged.clear(); spyRoomDescriptionChanged.clear(); spyRoomArchivedChanged.clear(); room->setTopic(QStringLiteral("foo")); - QCOMPARE(spyRoomAnnoucementChanged.count(), 0); + QCOMPARE(spyRoomAnnouncementChanged.count(), 0); QCOMPARE(spyRoomTopicChanged.count(), 0); QCOMPARE(spyRoomNameChanged.count(), 0); QCOMPARE(spyRoomFavoriteChanged.count(), 0); QCOMPARE(spyRoomBlockerChanged.count(), 0); QCOMPARE(spyRoomDescriptionChanged.count(), 0); QCOMPARE(spyRoomArchivedChanged.count(), 0); - spyRoomAnnoucementChanged.clear(); + spyRoomAnnouncementChanged.clear(); spyRoomTopicChanged.clear(); spyRoomNameChanged.clear(); spyRoomFavoriteChanged.clear(); spyRoomBlockerChanged.clear(); spyRoomDescriptionChanged.clear(); spyRoomArchivedChanged.clear(); //favorite room->setFavorite(true); - QCOMPARE(spyRoomAnnoucementChanged.count(), 0); + QCOMPARE(spyRoomAnnouncementChanged.count(), 0); QCOMPARE(spyRoomTopicChanged.count(), 0); QCOMPARE(spyRoomNameChanged.count(), 0); QCOMPARE(spyRoomFavoriteChanged.count(), 1); QCOMPARE(spyRoomBlockerChanged.count(), 0); QCOMPARE(spyRoomDescriptionChanged.count(), 0); QCOMPARE(spyRoomArchivedChanged.count(), 0); - spyRoomAnnoucementChanged.clear(); + spyRoomAnnouncementChanged.clear(); spyRoomTopicChanged.clear(); spyRoomNameChanged.clear(); spyRoomFavoriteChanged.clear(); spyRoomBlockerChanged.clear(); spyRoomDescriptionChanged.clear(); spyRoomArchivedChanged.clear(); room->setFavorite(true); - QCOMPARE(spyRoomAnnoucementChanged.count(), 0); + QCOMPARE(spyRoomAnnouncementChanged.count(), 0); QCOMPARE(spyRoomTopicChanged.count(), 0); QCOMPARE(spyRoomNameChanged.count(), 0); QCOMPARE(spyRoomFavoriteChanged.count(), 0); QCOMPARE(spyRoomBlockerChanged.count(), 0); QCOMPARE(spyRoomDescriptionChanged.count(), 0); QCOMPARE(spyRoomArchivedChanged.count(), 0); - spyRoomAnnoucementChanged.clear(); + spyRoomAnnouncementChanged.clear(); spyRoomTopicChanged.clear(); spyRoomNameChanged.clear(); spyRoomFavoriteChanged.clear(); spyRoomBlockerChanged.clear(); spyRoomDescriptionChanged.clear(); spyRoomArchivedChanged.clear(); //blocker room->setBlocker(true); - QCOMPARE(spyRoomAnnoucementChanged.count(), 0); + QCOMPARE(spyRoomAnnouncementChanged.count(), 0); QCOMPARE(spyRoomTopicChanged.count(), 0); QCOMPARE(spyRoomNameChanged.count(), 0); QCOMPARE(spyRoomFavoriteChanged.count(), 0); QCOMPARE(spyRoomBlockerChanged.count(), 1); QCOMPARE(spyRoomDescriptionChanged.count(), 0); QCOMPARE(spyRoomArchivedChanged.count(), 0); - spyRoomAnnoucementChanged.clear(); + spyRoomAnnouncementChanged.clear(); spyRoomTopicChanged.clear(); spyRoomNameChanged.clear(); spyRoomFavoriteChanged.clear(); spyRoomBlockerChanged.clear(); spyRoomDescriptionChanged.clear(); spyRoomArchivedChanged.clear(); room->setBlocker(true); - QCOMPARE(spyRoomAnnoucementChanged.count(), 0); + QCOMPARE(spyRoomAnnouncementChanged.count(), 0); QCOMPARE(spyRoomTopicChanged.count(), 0); QCOMPARE(spyRoomNameChanged.count(), 0); QCOMPARE(spyRoomFavoriteChanged.count(), 0); QCOMPARE(spyRoomBlockerChanged.count(), 0); QCOMPARE(spyRoomDescriptionChanged.count(), 0); QCOMPARE(spyRoomArchivedChanged.count(), 0); - spyRoomAnnoucementChanged.clear(); + spyRoomAnnouncementChanged.clear(); spyRoomTopicChanged.clear(); spyRoomNameChanged.clear(); spyRoomFavoriteChanged.clear(); spyRoomBlockerChanged.clear(); spyRoomDescriptionChanged.clear(); spyRoomArchivedChanged.clear(); room->setBlocker(false); - QCOMPARE(spyRoomAnnoucementChanged.count(), 0); + QCOMPARE(spyRoomAnnouncementChanged.count(), 0); QCOMPARE(spyRoomTopicChanged.count(), 0); QCOMPARE(spyRoomNameChanged.count(), 0); QCOMPARE(spyRoomFavoriteChanged.count(), 0); QCOMPARE(spyRoomBlockerChanged.count(), 1); QCOMPARE(spyRoomDescriptionChanged.count(), 0); QCOMPARE(spyRoomArchivedChanged.count(), 0); - spyRoomAnnoucementChanged.clear(); + spyRoomAnnouncementChanged.clear(); spyRoomTopicChanged.clear(); spyRoomNameChanged.clear(); spyRoomFavoriteChanged.clear(); spyRoomBlockerChanged.clear(); spyRoomDescriptionChanged.clear(); spyRoomArchivedChanged.clear(); //Archived room->setArchived(true); - QCOMPARE(spyRoomAnnoucementChanged.count(), 0); + QCOMPARE(spyRoomAnnouncementChanged.count(), 0); QCOMPARE(spyRoomTopicChanged.count(), 0); QCOMPARE(spyRoomNameChanged.count(), 0); QCOMPARE(spyRoomFavoriteChanged.count(), 0); QCOMPARE(spyRoomBlockerChanged.count(), 0); QCOMPARE(spyRoomDescriptionChanged.count(), 0); QCOMPARE(spyRoomArchivedChanged.count(), 1); - spyRoomAnnoucementChanged.clear(); + spyRoomAnnouncementChanged.clear(); spyRoomTopicChanged.clear(); spyRoomNameChanged.clear(); spyRoomFavoriteChanged.clear(); spyRoomBlockerChanged.clear(); spyRoomDescriptionChanged.clear(); spyRoomArchivedChanged.clear(); room->setArchived(true); - QCOMPARE(spyRoomAnnoucementChanged.count(), 0); + QCOMPARE(spyRoomAnnouncementChanged.count(), 0); QCOMPARE(spyRoomTopicChanged.count(), 0); QCOMPARE(spyRoomNameChanged.count(), 0); QCOMPARE(spyRoomFavoriteChanged.count(), 0); QCOMPARE(spyRoomBlockerChanged.count(), 0); QCOMPARE(spyRoomDescriptionChanged.count(), 0); QCOMPARE(spyRoomArchivedChanged.count(), 0); - spyRoomAnnoucementChanged.clear(); + spyRoomAnnouncementChanged.clear(); spyRoomTopicChanged.clear(); spyRoomNameChanged.clear(); spyRoomFavoriteChanged.clear(); spyRoomBlockerChanged.clear(); spyRoomDescriptionChanged.clear(); spyRoomArchivedChanged.clear(); room->setArchived(false); - QCOMPARE(spyRoomAnnoucementChanged.count(), 0); + QCOMPARE(spyRoomAnnouncementChanged.count(), 0); QCOMPARE(spyRoomTopicChanged.count(), 0); QCOMPARE(spyRoomNameChanged.count(), 0); QCOMPARE(spyRoomFavoriteChanged.count(), 0); QCOMPARE(spyRoomBlockerChanged.count(), 0); QCOMPARE(spyRoomDescriptionChanged.count(), 0); QCOMPARE(spyRoomArchivedChanged.count(), 1); - spyRoomAnnoucementChanged.clear(); + spyRoomAnnouncementChanged.clear(); spyRoomTopicChanged.clear(); spyRoomNameChanged.clear(); spyRoomFavoriteChanged.clear(); spyRoomBlockerChanged.clear(); spyRoomDescriptionChanged.clear(); spyRoomArchivedChanged.clear(); // const QString userId = QStringLiteral("foo"); room->setRoomCreatorUserId(userId); - QCOMPARE(spyRoomAnnoucementChanged.count(), 0); + QCOMPARE(spyRoomAnnouncementChanged.count(), 0); QCOMPARE(spyRoomTopicChanged.count(), 0); QCOMPARE(spyRoomNameChanged.count(), 0); QCOMPARE(spyRoomFavoriteChanged.count(), 0); QCOMPARE(spyRoomBlockerChanged.count(), 0); QCOMPARE(spyRoomDescriptionChanged.count(), 0); QCOMPARE(spyRoomArchivedChanged.count(), 0); QCOMPARE(w.roomCreatorUserId(), userId); const QString rId = QStringLiteral("foo"); room->setRoomId(rId); - QCOMPARE(spyRoomAnnoucementChanged.count(), 0); + QCOMPARE(spyRoomAnnouncementChanged.count(), 0); QCOMPARE(spyRoomTopicChanged.count(), 0); QCOMPARE(spyRoomNameChanged.count(), 0); QCOMPARE(spyRoomFavoriteChanged.count(), 0); QCOMPARE(spyRoomBlockerChanged.count(), 0); QCOMPARE(spyRoomDescriptionChanged.count(), 0); QCOMPARE(spyRoomArchivedChanged.count(), 0); QCOMPARE(w.rid(), rId); delete room; } void RoomWrapperTest::shouldVerifyCanBeModify() { Room *room = new Room(); room->setRoomCreatorUserId(QStringLiteral("foo")); RoomWrapper w(room); QVERIFY(!w.canBeModify()); //TODO check true but we need to add rocketchataccount; delete room; } diff --git a/src/model/roommodel.cpp b/src/model/roommodel.cpp index 25b2bc92..c65e9423 100644 --- a/src/model/roommodel.cpp +++ b/src/model/roommodel.cpp @@ -1,527 +1,527 @@ /* * Copyright 2016 Riccardo Iaconelli * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #include "roommodel.h" #include "ruqola_debug.h" #include "rocketchataccount.h" #include "usersforroommodel.h" #include "roomwrapper.h" #include #include #include #include #include RoomModel::RoomModel(RocketChatAccount *account, QObject *parent) : QAbstractListModel(parent) , mRocketChatAccount(account) { } RoomModel::~RoomModel() { if (mRocketChatAccount) { const QString cachePath = mRocketChatAccount->settings()->cacheBasePath(); if (cachePath.isEmpty()) { qCWarning(RUQOLA_LOG) << " Cache Path is not defined"; return; } QDir cacheDir(cachePath); if (!cacheDir.exists(cacheDir.path())) { cacheDir.mkpath(cacheDir.path()); } QFile f(cacheDir.absoluteFilePath(QStringLiteral("rooms"))); if (f.open(QIODevice::WriteOnly)) { QDataStream out(&f); for (Room *m : qAsConst(mRoomsList)) { qCDebug(RUQOLA_LOG) << " save cache for room " << m->name(); const QByteArray ms = Room::serialize(m); out.writeBytes(ms, ms.size()); } } } qDeleteAll(mRoomsList); } void RoomModel::clear() { if (!mRoomsList.isEmpty()) { beginRemoveRows(QModelIndex(), 0, rowCount() - 1); qDeleteAll(mRoomsList); mRoomsList.clear(); endRemoveRows(); } } Room *RoomModel::findRoom(const QString &roomID) const { foreach (Room *r, qAsConst(mRoomsList)) { if (r->roomId() == roomID) { return r; } } return nullptr; } RoomWrapper *RoomModel::findRoomWrapper(const QString &roomID) const { foreach (Room *r, qAsConst(mRoomsList)) { if (r->roomId() == roomID) { RoomWrapper *wrapper = new RoomWrapper(r); return wrapper; } } return nullptr; } // Clear data and refill it with data in the cache, if there is void RoomModel::reset() { clear(); if (!mRocketChatAccount) { return; } if (mRocketChatAccount->settings()->cacheBasePath().isEmpty()) { return; } //Laurent disable cache for the moment /* QDir cacheDir(Ruqola::self()->cacheBasePath()); // load cache if (cacheDir.exists(cacheDir.path())) { QFile f(cacheDir.absoluteFilePath(QStringLiteral("rooms"))); if (f.open(QIODevice::ReadOnly)) { QDataStream in(&f); while (!f.atEnd()) { char *byteArray; quint32 length; in.readBytes(byteArray, length); QByteArray arr = QByteArray::fromRawData(byteArray, length); Room m = Room::fromJSon(QJsonDocument::fromBinaryData(arr).object()); qDebug() <<" Load from cache room name: " << m.name; addRoom(m.id, m.name, m.selected); } } qCDebug(RUQOLA_LOG) << "Cache Loaded"; } */ } QHash RoomModel::roleNames() const { QHash roles; roles[RoomName] = QByteArrayLiteral("name"); roles[RoomID] = QByteArrayLiteral("room_id"); roles[RoomSelected] = QByteArrayLiteral("selected"); roles[RoomUnread] = QByteArrayLiteral("unread"); roles[RoomType] = QByteArrayLiteral("type"); roles[RoomUserName] = QByteArrayLiteral("username"); roles[RoomUserID] = QByteArrayLiteral("userID"); roles[RoomTopic] = QByteArrayLiteral("topic"); roles[RoomMutedUsers] = QByteArrayLiteral("mutedUsers"); roles[RoomJitsiTimeout] = QByteArrayLiteral("jitsiTimeout"); roles[RoomRo] = QByteArrayLiteral("readOnly"); - roles[RoomAnnoucement] = QByteArrayLiteral("announcement"); + roles[RoomAnnouncement] = QByteArrayLiteral("announcement"); roles[RoomOpen] = QByteArrayLiteral("open"); roles[RoomAlert] = QByteArrayLiteral("alert"); roles[RoomOrder] = QByteArrayLiteral("roomorder"); roles[RoomFavorite] = QByteArrayLiteral("favorite"); roles[RoomSection] = QByteArrayLiteral("sectionname"); roles[RoomIcon] = QByteArrayLiteral("channelicon"); roles[RoomUserMentions] = QByteArrayLiteral("userMentions"); return roles; } int RoomModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent); return mRoomsList.size(); } QVariant RoomModel::data(const QModelIndex &index, int role) const { if (index.row() < 0 || index.row() >= mRoomsList.count()) { return QVariant(); } Room *r = mRoomsList.at(index.row()); switch (role) { case RoomModel::RoomName: return r->name(); case RoomModel::RoomID: return r->roomId(); case RoomModel::RoomSelected: return r->selected(); case RoomModel::RoomType: return r->channelType(); case RoomModel::RoomUserID: return r->roomCreatorUserId(); case RoomModel::RoomUserName: return r->roomCreatorUserName(); case RoomModel::RoomTopic: return r->topic(); case RoomModel::RoomMutedUsers: return r->mutedUsers(); case RoomModel::RoomJitsiTimeout: return r->jitsiTimeout(); case RoomModel::RoomRo: return r->readOnly(); - case RoomModel::RoomAnnoucement: + case RoomModel::RoomAnnouncement: return r->announcement(); case RoomModel::RoomUnread: return r->unread(); case RoomModel::RoomOpen: return r->open(); case RoomModel::RoomAlert: return r->alert(); case RoomModel::RoomFavorite: return r->favorite(); case RoomModel::RoomSection: return sectionName(r); case RoomModel::RoomOrder: return order(r); case RoomModel::RoomIcon: return icon(r); case RoomModel::RoomOtr: //TODO implement it. return {}; case RoomModel::RoomUserMentions: return r->userMentions(); } return {}; } void RoomModel::addRoom(const QString &roomID, const QString &roomName, bool selected) { if (roomID.isEmpty() || roomName.isEmpty()) { qCDebug(RUQOLA_LOG) << " Impossible to add a room"; return; } qCDebug(RUQOLA_LOG) << "Adding room : roomId: " << roomID << " room Name " << roomName << " isSelected : " << selected; Room *r = createNewRoom(); r->setRoomId(roomID); r->setName(roomName); r->setSelected(selected); addRoom(r); } Room *RoomModel::createNewRoom() { Room *r = new Room(mRocketChatAccount); connect(r, &Room::alertChanged, this, &RoomModel::needToUpdateNotification); connect(r, &Room::unreadChanged, this, &RoomModel::needToUpdateNotification); return r; } void RoomModel::getUnreadAlertFromAccount(bool &hasAlert, int &nbUnread) { for (int i = 0; i < mRoomsList.count(); ++i) { if (mRoomsList.at(i)->open()) { if (mRoomsList.at(i)->alert()) { hasAlert = true; } nbUnread += mRoomsList.at(i)->unread(); } } } void RoomModel::updateSubscriptionRoom(const QJsonObject &roomData) { //TODO fix me! //Use "_id" QString rId = roomData.value(QLatin1String("rid")).toString(); if (rId.isEmpty()) { rId = roomData.value(QLatin1String("_id")).toString(); } if (!rId.isEmpty()) { const int roomCount = mRoomsList.size(); for (int i = 0; i < roomCount; ++i) { if (mRoomsList.at(i)->roomId() == rId) { qCDebug(RUQOLA_LOG) << " void RoomModel::updateSubscriptionRoom(const QJsonArray &array) room found"; Room *room = mRoomsList.at(i); room->updateSubscriptionRoom(roomData); Q_EMIT dataChanged(createIndex(i, 0), createIndex(i, 0)); break; } } } else { //qCWarning(RUQOLA_LOG) << "RoomModel::updateRoom incorrect jsonobject "<< roomData; qWarning() << "RoomModel::updateSubscriptionRoom incorrect jsonobject "<< roomData; } } QString RoomModel::insertRoom(const QJsonObject &room) { Room *r = createNewRoom(); r->parseInsertRoom(room); qCDebug(RUQOLA_LOG) << "Inserting room" << r->name() << r->roomId() << r->topic(); addRoom(r); return r->roomId(); } Room *RoomModel::addRoom(const QJsonObject &room) { Room *r = createNewRoom(); r->parseSubscriptionRoom(room); qCDebug(RUQOLA_LOG) << "Adding room subscription" << r->name() << r->roomId() << r->topic(); addRoom(r); return r; } void RoomModel::addRoom(Room *room) { qCDebug(RUQOLA_LOG) << " void RoomModel::addRoom(const Room &room)"<name(); int roomCount = mRoomsList.count(); for (int i = 0; i < roomCount; ++i) { if (mRoomsList.at(i)->roomId() == room->roomId()) { delete mRoomsList.takeAt(i); break; } } roomCount = mRoomsList.count(); beginInsertRows(QModelIndex(), roomCount, roomCount); qCDebug(RUQOLA_LOG) << "Inserting room at position" <roomId() == id) { beginRemoveRows(QModelIndex(), i, i); mRoomsList.remove(i); endRemoveRows(); break; } } } else if (actionName == QStringLiteral("inserted")) { qCDebug(RUQOLA_LOG) << "INSERT ROOM name " << roomData.value(QLatin1String("name")) << " rid " << roomData.value(QLatin1String("rid")); //TODO fix me! addRoom(roomData); //addRoom(roomData.value(QLatin1String("rid")).toString(), roomData.value(QLatin1String("name")).toString(), false); } else if (actionName == QStringLiteral("updated")) { //qCDebug(RUQOLA_LOG) << "UPDATE ROOM name " << roomData.value(QLatin1String("name")).toString() << " rid " << roomData.value(QLatin1String("rid")) << " roomData " << roomData; qDebug() << "UPDATE ROOM name " << roomData.value(QLatin1String("name")).toString() << " rid " << roomData.value(QLatin1String("rid")) << " roomData " << roomData; updateSubscriptionRoom(roomData); } else if (actionName == QStringLiteral("changed")) { //qDebug() << "CHANGED ROOM name " << roomData.value(QLatin1String("name")).toString() << " rid " << roomData.value(QLatin1String("rid")) << " roomData " << roomData; qCDebug(RUQOLA_LOG) << "CHANGED ROOM name " << roomData.value(QLatin1String("name")).toString() << " rid " << roomData.value(QLatin1String("rid")) << " roomData " << roomData; qCDebug(RUQOLA_LOG) << "RoomModel::updateSubscription Not implementer changed room yet" << array; updateRoom(roomData); } else { qCDebug(RUQOLA_LOG) << "RoomModel::updateSubscription Undefined type" << actionName; } } void RoomModel::updateRoom(const QJsonObject &roomData) { qCDebug(RUQOLA_LOG) << " void RoomModel::updateRoom(const QJsonObject &roomData)"; //TODO fix me! //Use "_id" QString rId = roomData.value(QLatin1String("rid")).toString(); if (rId.isEmpty()) { rId = roomData.value(QLatin1String("_id")).toString(); } if (!rId.isEmpty()) { const int roomCount = mRoomsList.size(); for (int i = 0; i < roomCount; ++i) { if (mRoomsList.at(i)->roomId() == rId) { qCDebug(RUQOLA_LOG) << " void RoomModel::updateRoom(const QJsonArray &array) room found"; Room *room = mRoomsList.at(i); room->parseUpdateRoom(roomData); Q_EMIT dataChanged(createIndex(i, 0), createIndex(i, 0)); break; } } } else { //qCWarning(RUQOLA_LOG) << "RoomModel::updateRoom incorrect jsonobject "<< roomData; qWarning() << "RoomModel::updateRoom incorrect jsonobject "<< roomData; } } void RoomModel::userStatusChanged(const User &user) { const int roomCount = mRoomsList.count(); for (int i = 0; i < roomCount; ++i) { Room *room = mRoomsList.at(i); if (room->name() == user.userName()) { const QModelIndex idx = createIndex(i, 0); Q_EMIT dataChanged(idx, idx); } room->usersModelForRoom()->userStatusChanged(user); } } UsersForRoomModel *RoomModel::usersModelForRoom(const QString &roomId) const { const int roomCount = mRoomsList.count(); for (int i = 0; i < roomCount; ++i) { if (mRoomsList.at(i)->roomId() == roomId) { return mRoomsList.at(i)->usersModelForRoom(); } } qCWarning(RUQOLA_LOG) << " Users model for room undefined !"; return nullptr; } UsersForRoomFilterProxyModel *RoomModel::usersForRoomFilterProxyModel(const QString &roomId) const { const int roomCount = mRoomsList.count(); for (int i = 0; i < roomCount; ++i) { if (mRoomsList.at(i)->roomId() == roomId) { return mRoomsList.at(i)->usersModelForRoomProxyModel(); } } return {}; } FilesForRoomFilterProxyModel *RoomModel::filesForRoomFilterProxyModel(const QString &roomId) const { const int roomCount = mRoomsList.count(); for (int i = 0; i < roomCount; ++i) { if (mRoomsList.at(i)->roomId() == roomId) { return mRoomsList.at(i)->filesForRoomFilterProxyModel(); } } return {}; } MessageModel *RoomModel::messageModel(const QString &roomId) const { const int roomCount = mRoomsList.count(); for (int i = 0; i < roomCount; ++i) { if (mRoomsList.at(i)->roomId() == roomId) { return mRoomsList.at(i)->messageModel(); } } return {}; } FilesForRoomModel *RoomModel::filesModelForRoom(const QString &roomId) const { const int roomCount = mRoomsList.count(); for (int i = 0; i < roomCount; ++i) { if (mRoomsList.at(i)->roomId() == roomId) { return mRoomsList.at(i)->filesModelForRoom(); } } return {}; } QString RoomModel::inputMessage(const QString &roomId) const { const int roomCount = mRoomsList.count(); for (int i = 0; i < roomCount; ++i) { if (mRoomsList.at(i)->roomId() == roomId) { return mRoomsList.at(i)->inputMessage(); } } return {}; } void RoomModel::setInputMessage(const QString &roomId, const QString &inputMessage) { const int roomCount = mRoomsList.count(); for (int i = 0; i < roomCount; ++i) { if (mRoomsList.at(i)->roomId() == roomId) { return mRoomsList.at(i)->setInputMessage(inputMessage); } } } QString RoomModel::sectionName(Room *r) const { QString str; if (r->favorite()) { str = i18n("Favorites"); } else { const QString channelTypeStr = r->channelType(); if (channelTypeStr == QLatin1String("c") || channelTypeStr == QLatin1String("p")) { str = i18n("Rooms"); } else if (channelTypeStr == QLatin1String("d")) { str = i18n("Private Message"); } } return str; } int RoomModel::order(Room *r) const { int order = 0; //First item are favorites channels if (!r->favorite()) { order += 3; } const QString channelTypeStr = r->channelType(); if (channelTypeStr == QLatin1String("c") || channelTypeStr == QLatin1String("p")) { order += 1; } else if (channelTypeStr == QLatin1String("d")) { order += 2; } else { qCDebug(RUQOLA_LOG) << r->name() << "has unhandled channel type" << channelTypeStr; order += 3; } return order; } QIcon RoomModel::icon(Room *r) const { if (r->channelType() == QLatin1String("c")) { if (r->unread() > 0 || r->alert()) { return QIcon::fromTheme(QStringLiteral("irc-channel-active")); } else { return QIcon::fromTheme(QStringLiteral("irc-channel-inactive")); } } else if (r->channelType() == QLatin1String("d")) { const QString userStatusIconFileName = mRocketChatAccount ? mRocketChatAccount->userStatusIconFileName(r->name()) : QString(); if (userStatusIconFileName.isEmpty()) { return QIcon::fromTheme(QStringLiteral("user-avaliable")); } else { return QIcon::fromTheme(userStatusIconFileName); } } else if (r->channelType() == QLatin1String("p")) { return QIcon::fromTheme(QStringLiteral("lock")); } return {}; } diff --git a/src/model/roommodel.h b/src/model/roommodel.h index eb1f7872..0aae55b8 100644 --- a/src/model/roommodel.h +++ b/src/model/roommodel.h @@ -1,137 +1,137 @@ /* * Copyright 2016 Riccardo Iaconelli * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #ifndef ROOMMODEL_H #define ROOMMODEL_H #include "libruqolacore_export.h" #include "room.h" #include "user.h" #include #include class RoomWrapper; class RocketChatAccount; class FilesForRoomModel; class FilesForRoomFilterProxyModel; class MessageModel; class LIBRUQOLACORE_EXPORT RoomModel : public QAbstractListModel { Q_OBJECT public: enum RoomRoles { RoomName = Qt::UserRole + 1, RoomSelected, RoomID, RoomUnread, RoomType, RoomUserName, //created by UserName RoomUserID, RoomTopic, RoomMutedUsers, RoomJitsiTimeout, RoomRo, - RoomAnnoucement, + RoomAnnouncement, RoomOpen, RoomAlert, RoomOrder, RoomFavorite, RoomSection, RoomIcon, RoomOtr, RoomUserMentions, }; Q_ENUM(RoomRoles) explicit RoomModel(RocketChatAccount *account = nullptr, QObject *parent = nullptr); ~RoomModel() override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; /** * @brief Constructs room object from @param roomID and @param roomName and @param selected, then calls @method addRoom * * @param roomID The unique room ID * @param roomName The name of the room * @param selected True if room if @param roomID is selected, else false */ Q_INVOKABLE void addRoom(const QString &roomID, const QString &roomName, bool selected = false); /** * @brief Finds a room with @param roomID in m_roomsList * * @param roomID The ID of the room to find * @return RoomWrapper Pointer, The pointer to room with @param roomID in m_roomsList, if exists. Else return a new RoomWrapper object */ RoomWrapper *findRoomWrapper(const QString &roomID) const; //Clear data and refill it with data in the cache, if there is void reset(); void clear(); void updateSubscription(const QJsonArray &array); void updateRoom(const QJsonObject &array); Room *addRoom(const QJsonObject &room); /** * @brief Adds a room to m_roomsList with @param room * * @param room The room to be added */ void addRoom(Room *room); void removeRoom(const QString &roomId); void getUnreadAlertFromAccount(bool &hasAlert, int &nbUnread); void userStatusChanged(const User &user); UsersForRoomModel *usersModelForRoom(const QString &roomId) const; UsersForRoomFilterProxyModel *usersForRoomFilterProxyModel(const QString &roomId) const; FilesForRoomModel *filesModelForRoom(const QString &roomId) const; FilesForRoomFilterProxyModel *filesForRoomFilterProxyModel(const QString &roomId) const; MessageModel *messageModel(const QString &roomId) const; QHash roleNames() const override; QString inputMessage(const QString &roomId) const; void setInputMessage(const QString &roomId, const QString &inputMessage); Room *findRoom(const QString &roomID) const; void updateSubscriptionRoom(const QJsonObject &room); QString insertRoom(const QJsonObject &room); Q_SIGNALS: void needToUpdateNotification(); private: Q_DISABLE_COPY(RoomModel) Room *createNewRoom(); QIcon icon(Room *r) const; int order(Room *r) const; QString sectionName(Room *r) const; RocketChatAccount *mRocketChatAccount = nullptr; QVector mRoomsList; }; #endif // ROOMMODEL_H diff --git a/src/qml/ChannelInfoDialog.qml b/src/qml/ChannelInfoDialog.qml index 37bbea53..187268c6 100644 --- a/src/qml/ChannelInfoDialog.qml +++ b/src/qml/ChannelInfoDialog.qml @@ -1,187 +1,187 @@ /* Copyright (c) 2017-2018 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.9 import QtQuick.Layouts 1.3 import QtQuick.Controls 1.4 import QtQuick.Controls 2.2 as QQC2 import QtQuick.Window 2.0 import KDE.Ruqola.DebugCategory 1.0 import KDE.Ruqola.RocketChatAccount 1.0 import KDE.Ruqola.RoomWrapper 1.0 import "common" QQC2.Dialog { id: channelInfoDialog title: i18n("Info about this channel") standardButtons: QQC2.Dialog.Close modal: true x: parent.width / 2 - width / 2 y: parent.height / 2 - height / 2 property string channelName: "" property QtObject roomInfo signal modifyChannelSetting(string roomId, int type, var newVal, string channelType) signal deleteRoom(string roomId) function initializeAndOpen() { var enabledField = !roomInfo.canBeModify; channelNameField.setReadOnly(enabledField); channelCommentField.setReadOnly(enabledField); - channelAnnoucementField.setReadOnly(enabledField); + channelAnnouncementField.setReadOnly(enabledField); channelDescriptionField.setReadOnly(enabledField); labelReadOnlyRoom.visible = !enabledField readOnlyRoom.visible = !enabledField labelArchiveRoom.visible = !enabledField archiveRoom.visible = !enabledField labelDeleteButton.visible = !enabledField deleteButton.visible = !enabledField labelRoomType.visible = !enabledField roomType.visible = !enabledField open(); } GridLayout { columns: 2 QQC2.Label { text: i18n("Name:"); } TextFieldEditor { id: channelNameField textField: roomInfo === null ? "" : roomInfo.name onUpdateValue: { if (newVal != "") { if (roomInfo.name !== newVal) { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.Name, newVal, roomInfo.channelType) } } else { //see https://doc.qt.io/qt-5/qml-qtqml-loggingcategory.html console.log(RuqolaDebugCategorySingleton.category, "New name is empty. We can't rename room name to empty name.") } } } QQC2.Label { text: i18n("Comment:"); } TextFieldEditor { id: channelCommentField textField: roomInfo === null ? "" : roomInfo.topic onUpdateValue: { if (roomInfo.topic !== newVal) { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.Topic, newVal, roomInfo.channelType) } } } QQC2.Label { - text: i18n("Annoucement:"); + text: i18n("Announcement:"); } TextFieldEditor { - id: channelAnnoucementField + id: channelAnnouncementField textField: roomInfo === null ? "" : roomInfo.announcement; onUpdateValue: { if (roomInfo.announcement !== newVal) { - channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.Annoucement, newVal, roomInfo.channelType) + channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.Announcement, newVal, roomInfo.channelType) } } } QQC2.Label { text: i18n("Description:"); } TextFieldEditor { id: channelDescriptionField textField: roomInfo === null ? "" : roomInfo.description; onUpdateValue: { if (roomInfo.description !== newVal) { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.Description, newVal, roomInfo.channelType) } } } QQC2.Label { id: labelReadOnlyRoom text: i18n("Read-Only:"); } QQC2.Switch { id: readOnlyRoom checked: roomInfo === null ? false : roomInfo.readOnly onClicked: { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.ReadOnly, checked, roomInfo.channelType) } } QQC2.Label { id: labelArchiveRoom text: i18n("Archive:"); } QQC2.Switch { id: archiveRoom checked: roomInfo === null ? false : roomInfo.archived onClicked: { archiveRoomDialog.open() } } QQC2.Label { id: labelRoomType text: i18n("Private:") } QQC2.Switch { id: roomType checked: roomInfo === null ? false : roomInfo.channelType === "p" onClicked: { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.RoomType, checked, roomInfo.channelType) } } QQC2.Label { id: labelDeleteButton text: i18n("Delete Room:"); } DeleteButton { id: deleteButton onDeleteButtonClicked: { deleteRoomDialog.rId = roomInfo.rid deleteRoomDialog.open(); } } } ArchiveRoomDialog { id: archiveRoomDialog onAccepted: { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.Archive, true) } onRejected: { archiveRoom.checked = false } } DeleteRoomDialog { id: deleteRoomDialog rId: channelName onDeleteRoom: { channelInfoDialog.deleteRoom(roomId) } } } diff --git a/src/restapi/groups/changegroupsannouncementjob.cpp b/src/restapi/groups/changegroupsannouncementjob.cpp index 339d197c..fd572b6c 100644 --- a/src/restapi/groups/changegroupsannouncementjob.cpp +++ b/src/restapi/groups/changegroupsannouncementjob.cpp @@ -1,130 +1,130 @@ /* Copyright (c) 2018 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "changegroupsannouncementjob.h" #include "ruqola_restapi_debug.h" #include "restapimethod.h" #include #include #include ChangeGroupsAnnouncementJob::ChangeGroupsAnnouncementJob(QObject *parent) : RestApiAbstractJob(parent) { } ChangeGroupsAnnouncementJob::~ChangeGroupsAnnouncementJob() { } bool ChangeGroupsAnnouncementJob::start() { if (!canStart()) { deleteLater(); return false; } const QByteArray baPostData = json().toJson(QJsonDocument::Compact); addLoggerInfo("ChangeGroupsAnnouncementJob::start: " + baPostData); QNetworkReply *reply = mNetworkAccessManager->post(request(), baPostData); connect(reply, &QNetworkReply::finished, this, &ChangeGroupsAnnouncementJob::slotChangeGroupsannouncementFinished); return true; } void ChangeGroupsAnnouncementJob::slotChangeGroupsannouncementFinished() { QNetworkReply *reply = qobject_cast(sender()); if (reply) { const QByteArray data = reply->readAll(); const QJsonDocument replyJson = QJsonDocument::fromJson(data); const QJsonObject replyObject = replyJson.object(); if (replyObject[QStringLiteral("success")].toBool()) { qCDebug(RUQOLA_RESTAPI_LOG) << "Change announcement success: " << data; - Q_EMIT changeGroupsAnnoucement(); + Q_EMIT changeGroupsAnnouncement(); } else { qCWarning(RUQOLA_RESTAPI_LOG) <<" Problem when we tried to change announcement: " << data; } } deleteLater(); } bool ChangeGroupsAnnouncementJob::requireHttpAuthentication() const { return true; } bool ChangeGroupsAnnouncementJob::canStart() const { if (mAnnouncement.isEmpty()) { qCWarning(RUQOLA_RESTAPI_LOG) << "ChangeGroupsAnnouncementJob: announcement is empty"; return false; } if (mRoomId.isEmpty()) { qCWarning(RUQOLA_RESTAPI_LOG) << "ChangeGroupsAnnouncementJob: RoomId is empty"; return false; } if (!RestApiAbstractJob::canStart()) { qCWarning(RUQOLA_RESTAPI_LOG) << "Impossible to start ChangeGroupsAnnouncementJob job"; return false; } return true; } QJsonDocument ChangeGroupsAnnouncementJob::json() const { QJsonObject jsonObj; jsonObj[QLatin1String("roomId")] = roomId(); jsonObj[QLatin1String("announcement")] = announcement(); const QJsonDocument postData = QJsonDocument(jsonObj); return postData; } QString ChangeGroupsAnnouncementJob::roomId() const { return mRoomId; } void ChangeGroupsAnnouncementJob::setRoomId(const QString &roomId) { mRoomId = roomId; } QString ChangeGroupsAnnouncementJob::announcement() const { return mAnnouncement; } void ChangeGroupsAnnouncementJob::setAnnouncement(const QString &t) { mAnnouncement = t; } QNetworkRequest ChangeGroupsAnnouncementJob::request() const { const QUrl url = mRestApiMethod->generateUrl(RestApiUtil::RestApiUrlType::GroupsSetAnnouncement); QNetworkRequest request(url); addAuthRawHeader(request); request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, true); request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/json")); return request; } diff --git a/src/restapi/groups/changegroupsannouncementjob.h b/src/restapi/groups/changegroupsannouncementjob.h index 6e61f09c..3e6a6263 100644 --- a/src/restapi/groups/changegroupsannouncementjob.h +++ b/src/restapi/groups/changegroupsannouncementjob.h @@ -1,57 +1,57 @@ /* Copyright (c) 2018 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef CHANGEGROUPSANNOUNCEMENTJOB_H #define CHANGEGROUPSANNOUNCEMENTJOB_H #include "restapiabstractjob.h" #include "libruqola_private_export.h" class LIBRUQOLACORE_TESTS_EXPORT ChangeGroupsAnnouncementJob : public RestApiAbstractJob { Q_OBJECT public: explicit ChangeGroupsAnnouncementJob(QObject *parent = nullptr); ~ChangeGroupsAnnouncementJob() override; bool start() override; bool requireHttpAuthentication() const override; bool canStart() const override; QString announcement() const; void setAnnouncement(const QString &topic); QNetworkRequest request() const override; QJsonDocument json() const; QString roomId() const; void setRoomId(const QString &roomId); Q_SIGNALS: - void changeGroupsAnnoucement(); + void changeGroupsAnnouncement(); private: Q_DISABLE_COPY(ChangeGroupsAnnouncementJob) void slotChangeGroupsannouncementFinished(); QString mAnnouncement; QString mRoomId; }; #endif // CHANGECHANNELANNOUNCEMENT_H