2020-08-03 13:27:42 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017-2020 by Savoir-faire Linux
|
|
|
|
* Author: Anthony Léonard <anthony.leonard@savoirfairelinux.com>
|
|
|
|
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
|
|
|
|
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
|
|
|
|
*
|
|
|
|
* 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "smartlistmodel.h"
|
|
|
|
|
|
|
|
#include "lrcinstance.h"
|
|
|
|
#include "pixbufmanipulator.h"
|
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
#include "api/contactmodel.h"
|
|
|
|
#include "globalinstances.h"
|
|
|
|
|
|
|
|
#include <QDateTime>
|
|
|
|
|
2020-09-21 18:36:56 +02:00
|
|
|
SmartListModel::SmartListModel(QObject* parent,
|
|
|
|
const QString& accId,
|
2020-08-03 13:27:42 -04:00
|
|
|
SmartListModel::Type listModelType,
|
2020-09-10 17:40:51 -04:00
|
|
|
const QString& convUid)
|
2020-08-03 13:27:42 -04:00
|
|
|
: QAbstractListModel(parent)
|
|
|
|
, listModelType_(listModelType)
|
|
|
|
{
|
|
|
|
if (listModelType_ == Type::CONFERENCE) {
|
|
|
|
setConferenceableFilter();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SmartListModel::~SmartListModel() {}
|
|
|
|
|
|
|
|
int
|
2020-09-10 17:40:51 -04:00
|
|
|
SmartListModel::rowCount(const QModelIndex& parent) const
|
2020-08-03 13:27:42 -04:00
|
|
|
{
|
|
|
|
if (!parent.isValid()) {
|
2020-09-24 14:02:28 -04:00
|
|
|
auto& accInfo = LRCInstance::accountModel().getAccountInfo(LRCInstance::getCurrAccId());
|
2020-09-10 17:40:51 -04:00
|
|
|
auto& convModel = accInfo.conversationModel;
|
2020-08-03 13:27:42 -04:00
|
|
|
if (listModelType_ == Type::TRANSFER) {
|
|
|
|
auto filterType = accInfo.profileInfo.type;
|
|
|
|
return convModel->getFilteredConversations(filterType).size();
|
|
|
|
} else if (listModelType_ == Type::CONFERENCE) {
|
|
|
|
auto calls = conferenceables_[ConferenceableItem::CALL];
|
|
|
|
auto contacts = conferenceables_[ConferenceableItem::CONTACT];
|
|
|
|
auto rowCount = contacts.size();
|
|
|
|
if (calls.size()) {
|
|
|
|
rowCount = 2;
|
|
|
|
rowCount += sectionState_[tr("Calls")] ? calls.size() : 0;
|
|
|
|
rowCount += sectionState_[tr("Contacts")] ? contacts.size() : 0;
|
|
|
|
}
|
|
|
|
return rowCount;
|
|
|
|
}
|
2020-08-25 15:07:57 +02:00
|
|
|
return conversations_.size();
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2020-09-10 17:40:51 -04:00
|
|
|
SmartListModel::columnCount(const QModelIndex& parent) const
|
2020-08-03 13:27:42 -04:00
|
|
|
{
|
|
|
|
Q_UNUSED(parent);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariant
|
2020-09-10 17:40:51 -04:00
|
|
|
SmartListModel::data(const QModelIndex& index, int role) const
|
2020-08-03 13:27:42 -04:00
|
|
|
{
|
|
|
|
if (!index.isValid()) {
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2020-09-24 14:02:28 -04:00
|
|
|
auto& accountInfo = LRCInstance::accountModel().getAccountInfo(LRCInstance::getCurrAccId());
|
2020-09-10 17:40:51 -04:00
|
|
|
auto& convModel = accountInfo.conversationModel;
|
2020-08-03 13:27:42 -04:00
|
|
|
lrc::api::conversation::Info item;
|
|
|
|
if (listModelType_ == Type::TRANSFER) {
|
|
|
|
auto filterType = accountInfo.profileInfo.type;
|
|
|
|
item = convModel->getFilteredConversations(filterType).at(index.row());
|
|
|
|
return getConversationItemData(item, accountInfo, role);
|
|
|
|
} else if (listModelType_ == Type::CONFERENCE) {
|
|
|
|
auto calls = conferenceables_[ConferenceableItem::CALL];
|
|
|
|
auto contacts = conferenceables_[ConferenceableItem::CONTACT];
|
2020-09-10 17:40:51 -04:00
|
|
|
QString itemConvUid {}, itemAccId {};
|
2020-08-03 13:27:42 -04:00
|
|
|
if (calls.size() == 0) {
|
|
|
|
itemConvUid = contacts.at(index.row()).at(0).convId;
|
|
|
|
itemAccId = contacts.at(index.row()).at(0).accountId;
|
|
|
|
} else {
|
|
|
|
bool callsOpen = sectionState_[tr("Calls")];
|
|
|
|
bool contactsOpen = sectionState_[tr("Contacts")];
|
|
|
|
auto callSectionEnd = callsOpen ? calls.size() + 1 : 1;
|
|
|
|
auto contactSectionEnd = contactsOpen ? callSectionEnd + contacts.size() + 1
|
|
|
|
: callSectionEnd + 1;
|
|
|
|
if (index.row() < callSectionEnd) {
|
|
|
|
if (index.row() == 0) {
|
|
|
|
return QVariant(role == Role::SectionName
|
|
|
|
? (callsOpen ? "➖ " : "➕ ") + QString(tr("Calls"))
|
|
|
|
: "");
|
|
|
|
} else {
|
|
|
|
auto idx = index.row() - 1;
|
|
|
|
itemConvUid = calls.at(idx).at(0).convId;
|
|
|
|
itemAccId = calls.at(idx).at(0).accountId;
|
|
|
|
}
|
|
|
|
} else if (index.row() < contactSectionEnd) {
|
|
|
|
if (index.row() == callSectionEnd) {
|
|
|
|
return QVariant(role == Role::SectionName
|
|
|
|
? (contactsOpen ? "➖ " : "➕ ") + QString(tr("Contacts"))
|
|
|
|
: "");
|
|
|
|
} else {
|
|
|
|
auto idx = index.row() - (callSectionEnd + 1);
|
|
|
|
itemConvUid = contacts.at(idx).at(0).convId;
|
|
|
|
itemAccId = contacts.at(idx).at(0).accountId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (role == Role::AccountId) {
|
|
|
|
return QVariant(itemAccId);
|
|
|
|
}
|
2020-08-24 17:46:30 +02:00
|
|
|
|
2020-09-10 17:40:51 -04:00
|
|
|
auto& itemAccountInfo = LRCInstance::accountModel().getAccountInfo(itemAccId);
|
2020-08-18 17:21:28 +02:00
|
|
|
item = itemAccountInfo.conversationModel->getConversationForUID(itemConvUid);
|
2020-08-03 13:27:42 -04:00
|
|
|
return getConversationItemData(item, itemAccountInfo, role);
|
|
|
|
} else if (listModelType_ == Type::CONVERSATION) {
|
2020-08-18 17:21:28 +02:00
|
|
|
item = conversations_.at(index.row());
|
2020-08-03 13:27:42 -04:00
|
|
|
return getConversationItemData(item, accountInfo, role);
|
|
|
|
}
|
2020-09-10 17:40:51 -04:00
|
|
|
} catch (const std::exception& e) {
|
2020-08-03 13:27:42 -04:00
|
|
|
qWarning() << e.what();
|
|
|
|
}
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
|
|
|
|
QHash<int, QByteArray>
|
|
|
|
SmartListModel::roleNames() const
|
|
|
|
{
|
|
|
|
QHash<int, QByteArray> roles;
|
|
|
|
roles[DisplayName] = "DisplayName";
|
|
|
|
roles[DisplayID] = "DisplayID";
|
|
|
|
roles[Picture] = "Picture";
|
|
|
|
roles[Presence] = "Presence";
|
|
|
|
roles[URI] = "URI";
|
|
|
|
roles[UnreadMessagesCount] = "UnreadMessagesCount";
|
|
|
|
roles[LastInteractionDate] = "LastInteractionDate";
|
|
|
|
roles[LastInteraction] = "LastInteraction";
|
|
|
|
roles[ContactType] = "ContactType";
|
|
|
|
roles[UID] = "UID";
|
|
|
|
roles[InCall] = "InCall";
|
|
|
|
roles[IsAudioOnly] = "IsAudioOnly";
|
|
|
|
roles[CallStackViewShouldShow] = "CallStackViewShouldShow";
|
2020-08-24 17:46:30 +02:00
|
|
|
roles[CallState] = "CallState";
|
2020-08-03 13:27:42 -04:00
|
|
|
roles[SectionName] = "SectionName";
|
|
|
|
roles[AccountId] = "AccountId";
|
|
|
|
roles[Draft] = "Draft";
|
|
|
|
return roles;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-09-10 17:40:51 -04:00
|
|
|
SmartListModel::setConferenceableFilter(const QString& filter)
|
2020-08-03 13:27:42 -04:00
|
|
|
{
|
|
|
|
beginResetModel();
|
2020-09-24 14:02:28 -04:00
|
|
|
auto& accountInfo = LRCInstance::accountModel().getAccountInfo(LRCInstance::getCurrAccId());
|
2020-09-10 17:40:51 -04:00
|
|
|
auto& convModel = accountInfo.conversationModel;
|
2020-09-24 14:02:28 -04:00
|
|
|
conferenceables_ = convModel->getConferenceableConversations(LRCInstance::getCurrentConvUid(),
|
|
|
|
filter);
|
2020-08-03 13:27:42 -04:00
|
|
|
sectionState_[tr("Calls")] = true;
|
|
|
|
sectionState_[tr("Contacts")] = true;
|
|
|
|
endResetModel();
|
|
|
|
}
|
|
|
|
|
2020-08-18 17:21:28 +02:00
|
|
|
void
|
|
|
|
SmartListModel::fillConversationsList()
|
|
|
|
{
|
|
|
|
beginResetModel();
|
|
|
|
auto* convModel = LRCInstance::getCurrentConversationModel();
|
|
|
|
conversations_.clear();
|
|
|
|
|
|
|
|
for (auto convSearch : convModel->getAllSearchResults()) {
|
|
|
|
conversations_.emplace_back(convSearch);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto convFilt : convModel->allFilteredConversations()) {
|
|
|
|
conversations_.emplace_back(convFilt);
|
|
|
|
}
|
|
|
|
endResetModel();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-09-10 17:40:51 -04:00
|
|
|
SmartListModel::updateConversation(const QString& convUid)
|
2020-08-18 17:21:28 +02:00
|
|
|
{
|
|
|
|
auto* convModel = LRCInstance::getCurrentConversationModel();
|
2020-09-10 17:40:51 -04:00
|
|
|
for (lrc::api::conversation::Info& conversation : conversations_) {
|
2020-08-18 17:21:28 +02:00
|
|
|
if (conversation.uid == convUid) {
|
|
|
|
conversation = convModel->getConversationForUID(convUid);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-03 13:27:42 -04:00
|
|
|
void
|
2020-09-10 17:40:51 -04:00
|
|
|
SmartListModel::toggleSection(const QString& section)
|
2020-08-03 13:27:42 -04:00
|
|
|
{
|
|
|
|
beginResetModel();
|
|
|
|
if (section.contains(tr("Calls"))) {
|
|
|
|
sectionState_[tr("Calls")] ^= true;
|
|
|
|
} else if (section.contains(tr("Contacts"))) {
|
|
|
|
sectionState_[tr("Contacts")] ^= true;
|
|
|
|
}
|
|
|
|
endResetModel();
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
SmartListModel::currentUidSmartListModelIndex()
|
|
|
|
{
|
2020-08-18 17:21:28 +02:00
|
|
|
const auto convUid = LRCInstance::getCurrentConvUid();
|
2020-08-03 13:27:42 -04:00
|
|
|
for (int i = 0; i < rowCount(); i++) {
|
|
|
|
if (convUid == data(index(i, 0), Role::UID))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariant
|
2020-09-10 17:40:51 -04:00
|
|
|
SmartListModel::getConversationItemData(const conversation::Info& item,
|
|
|
|
const account::Info& accountInfo,
|
2020-08-03 13:27:42 -04:00
|
|
|
int role) const
|
|
|
|
{
|
|
|
|
if (item.participants.size() <= 0) {
|
|
|
|
return QVariant();
|
|
|
|
}
|
2020-09-10 17:40:51 -04:00
|
|
|
auto& contactModel = accountInfo.contactModel;
|
2020-08-03 13:27:42 -04:00
|
|
|
switch (role) {
|
|
|
|
case Role::Picture: {
|
|
|
|
auto contactImage
|
|
|
|
= GlobalInstances::pixmapManipulator().decorationRole(item, accountInfo).value<QImage>();
|
|
|
|
return QString::fromLatin1(Utils::QImageToByteArray(contactImage).toBase64().data());
|
|
|
|
}
|
|
|
|
case Role::DisplayName: {
|
|
|
|
if (!item.participants.isEmpty()) {
|
2020-09-10 17:40:51 -04:00
|
|
|
auto& contact = contactModel->getContact(item.participants[0]);
|
2020-08-03 13:27:42 -04:00
|
|
|
return QVariant(Utils::bestNameForContact(contact));
|
|
|
|
}
|
|
|
|
return QVariant("");
|
|
|
|
}
|
|
|
|
case Role::DisplayID: {
|
|
|
|
if (!item.participants.isEmpty()) {
|
2020-09-10 17:40:51 -04:00
|
|
|
auto& contact = contactModel->getContact(item.participants[0]);
|
2020-08-03 13:27:42 -04:00
|
|
|
return QVariant(Utils::bestIdForContact(contact));
|
|
|
|
}
|
|
|
|
return QVariant("");
|
|
|
|
}
|
|
|
|
case Role::Presence: {
|
|
|
|
if (!item.participants.isEmpty()) {
|
2020-09-10 17:40:51 -04:00
|
|
|
auto& contact = contactModel->getContact(item.participants[0]);
|
2020-08-03 13:27:42 -04:00
|
|
|
return QVariant(contact.isPresent);
|
|
|
|
}
|
|
|
|
return QVariant(false);
|
|
|
|
}
|
|
|
|
case Role::URI: {
|
|
|
|
if (!item.participants.isEmpty()) {
|
2020-09-10 17:40:51 -04:00
|
|
|
auto& contact = contactModel->getContact(item.participants[0]);
|
2020-08-03 13:27:42 -04:00
|
|
|
return QVariant(contact.profileInfo.uri);
|
|
|
|
}
|
|
|
|
return QVariant("");
|
|
|
|
}
|
|
|
|
case Role::UnreadMessagesCount:
|
|
|
|
return QVariant(item.unreadMessages);
|
|
|
|
case Role::LastInteractionDate: {
|
|
|
|
if (!item.interactions.empty()) {
|
2020-09-10 17:40:51 -04:00
|
|
|
auto& date = item.interactions.at(item.lastMessageUid).timestamp;
|
2020-08-03 13:27:42 -04:00
|
|
|
return QVariant(QString::fromStdString(Utils::formatTimeString(date)));
|
|
|
|
}
|
|
|
|
return QVariant("");
|
|
|
|
}
|
|
|
|
case Role::LastInteraction: {
|
|
|
|
if (!item.interactions.empty()) {
|
|
|
|
return QVariant(item.interactions.at(item.lastMessageUid).body);
|
|
|
|
}
|
|
|
|
return QVariant("");
|
|
|
|
}
|
|
|
|
case Role::LastInteractionType: {
|
|
|
|
if (!item.interactions.empty()) {
|
2020-09-10 17:40:51 -04:00
|
|
|
return QVariant(static_cast<int>(item.interactions.at(item.lastMessageUid).type));
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
return QVariant(0);
|
|
|
|
}
|
|
|
|
case Role::ContactType: {
|
|
|
|
if (!item.participants.isEmpty()) {
|
2020-09-10 17:40:51 -04:00
|
|
|
auto& contact = contactModel->getContact(item.participants[0]);
|
2020-09-04 14:51:39 -04:00
|
|
|
return QVariant(static_cast<int>(contact.profileInfo.type));
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
return QVariant(0);
|
|
|
|
}
|
|
|
|
case Role::UID:
|
|
|
|
return QVariant(item.uid);
|
|
|
|
case Role::InCall: {
|
2020-08-18 17:21:28 +02:00
|
|
|
auto* convModel = LRCInstance::getCurrentConversationModel();
|
|
|
|
const auto convInfo = convModel->getConversationForUID(item.uid);
|
2020-08-03 13:27:42 -04:00
|
|
|
if (!convInfo.uid.isEmpty()) {
|
2020-08-18 17:21:28 +02:00
|
|
|
auto* callModel = LRCInstance::getCurrentCallModel();
|
2020-08-03 13:27:42 -04:00
|
|
|
return QVariant(callModel->hasCall(convInfo.callId));
|
|
|
|
}
|
|
|
|
return QVariant(false);
|
|
|
|
}
|
|
|
|
case Role::IsAudioOnly: {
|
2020-08-18 17:21:28 +02:00
|
|
|
auto* convModel = LRCInstance::getCurrentConversationModel();
|
|
|
|
const auto convInfo = convModel->getConversationForUID(item.uid);
|
2020-08-03 13:27:42 -04:00
|
|
|
if (!convInfo.uid.isEmpty()) {
|
2020-08-18 17:21:28 +02:00
|
|
|
auto* call = LRCInstance::getCallInfoForConversation(convInfo);
|
2020-08-03 13:27:42 -04:00
|
|
|
if (call) {
|
|
|
|
return QVariant(call->isAudioOnly);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
case Role::CallStackViewShouldShow: {
|
2020-08-18 17:21:28 +02:00
|
|
|
auto* convModel = LRCInstance::getCurrentConversationModel();
|
|
|
|
const auto convInfo = convModel->getConversationForUID(item.uid);
|
2020-08-03 13:27:42 -04:00
|
|
|
if (!convInfo.uid.isEmpty()) {
|
2020-08-18 17:21:28 +02:00
|
|
|
auto* callModel = LRCInstance::getCurrentCallModel();
|
|
|
|
const auto call = callModel->getCall(convInfo.callId);
|
2020-08-03 13:27:42 -04:00
|
|
|
return QVariant(callModel->hasCall(convInfo.callId)
|
|
|
|
&& ((!call.isOutgoing
|
|
|
|
&& (call.status == lrc::api::call::Status::IN_PROGRESS
|
2020-08-31 13:17:44 +02:00
|
|
|
|| call.status == lrc::api::call::Status::PAUSED
|
|
|
|
|| call.status == lrc::api::call::Status::INCOMING_RINGING))
|
2020-09-24 13:50:04 +02:00
|
|
|
|| (call.isOutgoing
|
|
|
|
&& call.status != lrc::api::call::Status::ENDED)));
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
return QVariant(false);
|
|
|
|
}
|
2020-08-24 17:46:30 +02:00
|
|
|
case Role::CallState: {
|
2020-08-18 17:21:28 +02:00
|
|
|
auto* convModel = LRCInstance::getCurrentConversationModel();
|
|
|
|
const auto convInfo = convModel->getConversationForUID(item.uid);
|
2020-08-03 13:27:42 -04:00
|
|
|
if (!convInfo.uid.isEmpty()) {
|
2020-08-18 17:21:28 +02:00
|
|
|
auto* call = LRCInstance::getCallInfoForConversation(convInfo);
|
2020-08-03 13:27:42 -04:00
|
|
|
if (call) {
|
2020-08-24 17:46:30 +02:00
|
|
|
return QVariant(static_cast<int>(call->status));
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
case Role::SectionName:
|
|
|
|
return QVariant(QString());
|
|
|
|
case Role::Draft: {
|
|
|
|
if (!item.uid.isEmpty()) {
|
2020-08-18 17:21:28 +02:00
|
|
|
const auto draft = LRCInstance::getContentDraft(item.uid, accountInfo.id);
|
2020-08-03 13:27:42 -04:00
|
|
|
if (!draft.isEmpty()) {
|
|
|
|
/*
|
|
|
|
* Pencil Emoji
|
|
|
|
*/
|
|
|
|
uint cp = 0x270F;
|
|
|
|
auto emojiString = QString::fromUcs4(&cp, 1);
|
|
|
|
return emojiString + LRCInstance::getContentDraft(item.uid, accountInfo.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QVariant("");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
|
|
|
|
QModelIndex
|
2020-09-10 17:40:51 -04:00
|
|
|
SmartListModel::index(int row, int column, const QModelIndex& parent) const
|
2020-08-03 13:27:42 -04:00
|
|
|
{
|
|
|
|
Q_UNUSED(parent);
|
|
|
|
if (column != 0) {
|
|
|
|
return QModelIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (row >= 0 && row < rowCount()) {
|
|
|
|
return createIndex(row, column);
|
|
|
|
}
|
|
|
|
return QModelIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
QModelIndex
|
2020-09-10 17:40:51 -04:00
|
|
|
SmartListModel::parent(const QModelIndex& child) const
|
2020-08-03 13:27:42 -04:00
|
|
|
{
|
|
|
|
Q_UNUSED(child);
|
|
|
|
return QModelIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
Qt::ItemFlags
|
2020-09-10 17:40:51 -04:00
|
|
|
SmartListModel::flags(const QModelIndex& index) const
|
2020-08-03 13:27:42 -04:00
|
|
|
{
|
|
|
|
auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable;
|
2020-09-04 14:51:39 -04:00
|
|
|
auto type = static_cast<lrc::api::profile::Type>(data(index, Role::ContactType).value<int>());
|
2020-08-03 13:27:42 -04:00
|
|
|
auto uid = data(index, Role::UID).value<QString>();
|
|
|
|
if (!index.isValid()) {
|
|
|
|
return QAbstractItemModel::flags(index);
|
|
|
|
} else if ((type == lrc::api::profile::Type::TEMPORARY && uid.isEmpty())) {
|
|
|
|
flags &= ~(Qt::ItemIsSelectable);
|
|
|
|
}
|
|
|
|
return flags;
|
|
|
|
}
|