31 if (parent.isValid()) {
34 return m_roomInfoList.size();
40 if (parent.isValid()) {
49 if (!index.isValid()) {
53 if (index.row() >= m_roomInfoList.count()) {
57 const int row = index.row();
58 const Tp::RoomInfo &roomInfo = m_roomInfoList.at(row);
62 if (index.column() == PasswordColumn) {
64 case Qt::DecorationRole:
65 if (roomInfo.info.value(QLatin1String(
"password")).toBool()) {
66 return KIcon(QLatin1String(
"object-locked"));
71 if (roomInfo.info.value(QLatin1String(
"password")).toBool()) {
72 return i18n(
"Password required");
74 return i18n(
"No password required");
81 switch (index.column()) {
85 return roomInfo.info.value(QLatin1String(
"name"));
86 case DescriptionColumn:
87 return roomInfo.info.value(QLatin1String(
"description"));
89 return roomInfo.info.value(QLatin1String(
"members"));
92 switch (index.column()) {
94 return i18n(
"Member count");
97 return roomInfo.info.value(QLatin1String(
"handle-name"));
105 if (role != Qt::DisplayRole && role != Qt::DecorationRole) {
109 if (orientation == Qt::Horizontal) {
111 case Qt::DisplayRole:
114 return i18nc(
"Chatrooms name",
"Name");
115 case DescriptionColumn:
116 return i18nc(
"Chatrooms description",
"Description");
118 case Qt::DecorationRole:
121 return KIcon(QLatin1String(
"object-locked"));
123 return KIcon(QLatin1String(
"meeting-participant"));
133 if (newRoomList.size() > 0) {
134 beginInsertRows(QModelIndex(), m_roomInfoList.size(), m_roomInfoList.size() + newRoomList.size() - 1);
135 m_roomInfoList.append(newRoomList);
142 if (m_roomInfoList.size() > 0) {
143 beginRemoveRows(QModelIndex(), 0, m_roomInfoList.size() - 1);
144 m_roomInfoList.clear();
156 if (parent.isValid()) {
159 return m_favoriteRoomsList.size();
165 if (parent.isValid()) {
174 if (!index.isValid()) {
178 if (index.row() >= m_favoriteRoomsList.size()) {
182 const int row = index.row();
183 const QVariantMap &room = m_favoriteRoomsList.at(row);
186 case Qt::DisplayRole:
187 switch (index.column()) {
189 return room.value(QLatin1String(
"name"));
190 case HandleNameColumn:
191 return room.value(QLatin1String(
"handle-name"));
192 case AccountIdentifierColumn:
193 return room.value(QLatin1String(
"account-identifier"));
195 case Qt::ToolTipRole:
196 return room.value(QLatin1String(
"handle-name"));
198 return room.value(QLatin1String(
"handle-name"));
200 return QVariant::fromValue<QVariantMap>(room);
208 if (newRoomList.size() > 0) {
209 beginInsertRows(QModelIndex(), m_favoriteRoomsList.size(), m_favoriteRoomsList.size() + newRoomList.size() - 1);
210 m_favoriteRoomsList.append(newRoomList);
217 beginInsertRows(QModelIndex(), m_favoriteRoomsList.size(), m_favoriteRoomsList.size());
218 m_favoriteRoomsList.append(room);
224 int row = m_favoriteRoomsList.indexOf(room);
225 beginRemoveRows(QModelIndex(), row, row);
226 m_favoriteRoomsList.removeOne(room);
232 bool contains =
false;
234 Q_FOREACH(
const QVariantMap &room, m_favoriteRoomsList) {
235 if ((room.value(QLatin1String(
"handle-name")) == handle) && (room.value(QLatin1String(
"account-identifier")) == account)) {
247 Q_FOREACH (
const QVariantMap &room, m_favoriteRoomsList) {
248 if (room.value(QLatin1String(
"account-identifier")) == account) {