summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
579e559)
In some places, we would explicitly give the type to
QVariant::fromValue(), forgoing automatic type deduction. This is
almost always redundant, and in the cases where it is not, the
input type should be explicitly cast.
Additionally, the implementation of QVariant::fromValue() subtly changed
in Qt 5.14, leading to compile errors when giving a non-decayed type
(as we did in SignalProxy::attachSignal()).
21 files changed:
case Qt::DisplayRole:
return acc.accountName();
case AccountIdRole:
case Qt::DisplayRole:
return acc.accountName();
case AccountIdRole:
- return QVariant::fromValue<AccountId>(acc.accountId());
+ return QVariant::fromValue(acc.accountId());
case UuidRole:
return acc.uuid().toString();
case UuidRole:
return acc.uuid().toString();
if (!redirectedTo.isValid()) {
BufferId redirectedTo = Client::bufferModel()->currentIndex().data(NetworkModel::BufferIdRole).value<BufferId>();
if (redirectedTo.isValid())
if (!redirectedTo.isValid()) {
BufferId redirectedTo = Client::bufferModel()->currentIndex().data(NetworkModel::BufferIdRole).value<BufferId>();
if (redirectedTo.isValid())
- sourceModel()->setData(sourceIdx, QVariant::fromValue<BufferId>(redirectedTo), MessageModel::RedirectedToRole);
+ sourceModel()->setData(sourceIdx, QVariant::fromValue(redirectedTo), MessageModel::RedirectedToRole);
}
if (_validBuffers.contains(redirectedTo))
}
if (_validBuffers.contains(redirectedTo))
switch (role) {
case MessageModel::MessageRole:
switch (role) {
case MessageModel::MessageRole:
- return QVariant::fromValue<Message>(message());
+ return QVariant::fromValue(message());
case MessageModel::MsgIdRole:
case MessageModel::MsgIdRole:
- return QVariant::fromValue<MsgId>(msgId());
+ return QVariant::fromValue(msgId());
case MessageModel::BufferIdRole:
case MessageModel::BufferIdRole:
- return QVariant::fromValue<BufferId>(bufferId());
+ return QVariant::fromValue(bufferId());
case MessageModel::TypeRole:
return msgType();
case MessageModel::FlagsRole:
case MessageModel::TypeRole:
return msgType();
case MessageModel::FlagsRole:
case MessageModel::TimestampRole:
return timestamp();
case MessageModel::RedirectedToRole:
case MessageModel::TimestampRole:
return timestamp();
case MessageModel::RedirectedToRole:
- return qVariantFromValue<BufferId>(_redirectedTo);
+ return QVariant::fromValue(_redirectedTo);
else
return QVariant();
case NetworkModel::NetworkIdRole:
else
return QVariant();
case NetworkModel::NetworkIdRole:
- return qVariantFromValue(_networkId);
+ return QVariant::fromValue(_networkId);
case NetworkModel::ItemTypeRole:
return NetworkModel::NetworkItemType;
case NetworkModel::ItemActiveRole:
case NetworkModel::ItemTypeRole:
return NetworkModel::NetworkItemType;
case NetworkModel::ItemActiveRole:
case NetworkModel::ItemTypeRole:
return NetworkModel::BufferItemType;
case NetworkModel::BufferIdRole:
case NetworkModel::ItemTypeRole:
return NetworkModel::BufferItemType;
case NetworkModel::BufferIdRole:
- return qVariantFromValue(bufferInfo().bufferId());
+ return QVariant::fromValue(bufferInfo().bufferId());
case NetworkModel::NetworkIdRole:
case NetworkModel::NetworkIdRole:
- return qVariantFromValue(bufferInfo().networkId());
+ return QVariant::fromValue(bufferInfo().networkId());
case NetworkModel::BufferInfoRole:
case NetworkModel::BufferInfoRole:
- return qVariantFromValue(bufferInfo());
+ return QVariant::fromValue(bufferInfo());
case NetworkModel::BufferTypeRole:
return int(bufferType());
case NetworkModel::ItemActiveRole:
case NetworkModel::BufferTypeRole:
return int(bufferType());
case NetworkModel::ItemActiveRole:
case NetworkModel::BufferActivityRole:
return (int)activityLevel();
case NetworkModel::BufferFirstUnreadMsgIdRole:
case NetworkModel::BufferActivityRole:
return (int)activityLevel();
case NetworkModel::BufferFirstUnreadMsgIdRole:
- return qVariantFromValue(firstUnreadMsgId());
+ return QVariant::fromValue(firstUnreadMsgId());
case NetworkModel::MarkerLineMsgIdRole:
case NetworkModel::MarkerLineMsgIdRole:
- return qVariantFromValue(markerLineMsgId());
+ return QVariant::fromValue(markerLineMsgId());
default:
return PropertyMapItem::data(column, role);
}
default:
return PropertyMapItem::data(column, role);
}
case Qt::EditRole:
return BufferItem::data(column, Qt::DisplayRole);
case NetworkModel::IrcUserRole:
case Qt::EditRole:
return BufferItem::data(column, Qt::DisplayRole);
case NetworkModel::IrcUserRole:
- return QVariant::fromValue<QObject*>(_ircUser);
+ return QVariant::fromValue(_ircUser);
case NetworkModel::UserAwayRole:
return (bool)_ircUser ? _ircUser->isAway() : false;
default:
case NetworkModel::UserAwayRole:
return (bool)_ircUser ? _ircUser->isAway() : false;
default:
{
switch (role) {
case NetworkModel::IrcChannelRole:
{
switch (role) {
case NetworkModel::IrcChannelRole:
- return QVariant::fromValue<QObject*>(_ircChannel);
+ return QVariant::fromValue(_ircChannel);
default:
return BufferItem::data(column, role);
}
default:
return BufferItem::data(column, role);
}
case NetworkModel::IrcChannelRole:
return parent()->data(column, role);
case NetworkModel::IrcUserRole:
case NetworkModel::IrcChannelRole:
return parent()->data(column, role);
case NetworkModel::IrcUserRole:
- return QVariant::fromValue<QObject*>(_ircUser.data());
+ return QVariant::fromValue(_ircUser.data());
case NetworkModel::UserAwayRole:
return (bool)_ircUser ? _ircUser->isAway() : false;
default:
case NetworkModel::UserAwayRole:
return (bool)_ircUser ? _ircUser->isAway() : false;
default:
QVariantList list;
QHash<BufferId, MsgId>::const_iterator iter = _lastSeenMsg.constBegin();
while (iter != _lastSeenMsg.constEnd()) {
QVariantList list;
QHash<BufferId, MsgId>::const_iterator iter = _lastSeenMsg.constBegin();
while (iter != _lastSeenMsg.constEnd()) {
- list << QVariant::fromValue<BufferId>(iter.key()) << QVariant::fromValue<MsgId>(iter.value());
+ list << QVariant::fromValue(iter.key()) << QVariant::fromValue(iter.value());
QVariantList list;
QHash<BufferId, MsgId>::const_iterator iter = _markerLines.constBegin();
while (iter != _markerLines.constEnd()) {
QVariantList list;
QHash<BufferId, MsgId>::const_iterator iter = _markerLines.constBegin();
while (iter != _markerLines.constEnd()) {
- list << QVariant::fromValue<BufferId>(iter.key()) << QVariant::fromValue<MsgId>(iter.value());
+ list << QVariant::fromValue(iter.key()) << QVariant::fromValue(iter.value());
QVariantList list;
auto iter = _bufferActivities.constBegin();
while (iter != _bufferActivities.constEnd()) {
QVariantList list;
auto iter = _bufferActivities.constBegin();
while (iter != _bufferActivities.constEnd()) {
- list << QVariant::fromValue<BufferId>(iter.key()) << QVariant::fromValue<int>((int)iter.value());
+ list << QVariant::fromValue(iter.key()) << QVariant::fromValue((int)iter.value());
QVariantList list;
auto iter = _highlightCounts.constBegin();
while (iter != _highlightCounts.constEnd()) {
QVariantList list;
auto iter = _highlightCounts.constBegin();
while (iter != _highlightCounts.constEnd()) {
- list << QVariant::fromValue<BufferId>(iter.key()) << QVariant::fromValue<int>((int)iter.value());
+ list << QVariant::fromValue(iter.key()) << QVariant::fromValue((int)iter.value());
i["CodecForServer"] = info.codecForServer;
i["CodecForEncoding"] = info.codecForEncoding;
i["CodecForDecoding"] = info.codecForDecoding;
i["CodecForServer"] = info.codecForServer;
i["CodecForEncoding"] = info.codecForEncoding;
i["CodecForDecoding"] = info.codecForDecoding;
- i["NetworkId"] = QVariant::fromValue<NetworkId>(info.networkId);
- i["Identity"] = QVariant::fromValue<IdentityId>(info.identity);
+ i["NetworkId"] = QVariant::fromValue(info.networkId);
+ i["Identity"] = QVariant::fromValue(info.identity);
i["MessageRateBurstSize"] = info.messageRateBurstSize;
i["MessageRateDelay"] = info.messageRateDelay;
i["AutoReconnectInterval"] = info.autoReconnectInterval;
i["MessageRateBurstSize"] = info.messageRateBurstSize;
i["MessageRateDelay"] = info.messageRateDelay;
i["AutoReconnectInterval"] = info.autoReconnectInterval;
if (!Serializers::deserialize(stream, features, content)) {
return false;
}
if (!Serializers::deserialize(stream, features, content)) {
return false;
}
- data = QVariant::fromValue<T>(content);
+ data = QVariant::fromValue(content);
// Upon signal emission, marshall the signal's arguments into a QVariantList and dispatch an RpcCall message
connect(sender, signal, this, [this, signalName = std::move(name)](auto&&... args) {
// Upon signal emission, marshall the signal's arguments into a QVariantList and dispatch an RpcCall message
connect(sender, signal, this, [this, signalName = std::move(name)](auto&&... args) {
- this->dispatchSignal(std::move(signalName), {QVariant::fromValue<decltype(args)>(args)...});
+ this->dispatchSignal(std::move(signalName), {QVariant::fromValue(args)...});
inline UserId(int _id = 0)
: SignedId(_id)
{}
inline UserId(int _id = 0)
: SignedId(_id)
{}
- // inline operator QVariant() const { return QVariant::fromValue<UserId>(*this); } // no automatic conversion!
+ // inline operator QVariant() const { return QVariant::fromValue(*this); } // no automatic conversion!
};
struct MsgId : public SignedId64
};
struct MsgId : public SignedId64
inline MsgId(qint64 _id = 0)
: SignedId64(_id)
{}
inline MsgId(qint64 _id = 0)
: SignedId64(_id)
{}
- // inline operator QVariant() const { return QVariant::fromValue<MsgId>(*this); }
+ // inline operator QVariant() const { return QVariant::fromValue(*this); }
};
struct BufferId : public SignedId
};
struct BufferId : public SignedId
inline BufferId(int _id = 0)
: SignedId(_id)
{}
inline BufferId(int _id = 0)
: SignedId(_id)
{}
- // inline operator QVariant() const { return QVariant::fromValue<BufferId>(*this); }
+ // inline operator QVariant() const { return QVariant::fromValue(*this); }
};
struct NetworkId : public SignedId
};
struct NetworkId : public SignedId
inline NetworkId(int _id = 0)
: SignedId(_id)
{}
inline NetworkId(int _id = 0)
: SignedId(_id)
{}
- // inline operator QVariant() const { return QVariant::fromValue<NetworkId>(*this); }
+ // inline operator QVariant() const { return QVariant::fromValue(*this); }
};
struct IdentityId : public SignedId
};
struct IdentityId : public SignedId
inline IdentityId(int _id = 0)
: SignedId(_id)
{}
inline IdentityId(int _id = 0)
: SignedId(_id)
{}
- // inline operator QVariant() const { return QVariant::fromValue<IdentityId>(*this); }
+ // inline operator QVariant() const { return QVariant::fromValue(*this); }
};
struct AccountId : public SignedId
};
struct AccountId : public SignedId
{
QVariantList variants;
for (int i = 0; i < list.count(); i++) {
{
QVariantList variants;
for (int i = 0; i < list.count(); i++) {
- variants << QVariant::fromValue<T>(list[i]);
+ variants << QVariant::fromValue(list[i]);
if (_storage) {
QVariantList activeSessions;
for (auto&& user : instance()->_sessions.keys())
if (_storage) {
QVariantList activeSessions;
for (auto&& user : instance()->_sessions.keys())
- activeSessions << QVariant::fromValue<UserId>(user);
+ activeSessions << QVariant::fromValue(user);
_storage->setCoreState(activeSessions);
}
}
_storage->setCoreState(activeSessions);
}
}
case Clickable::Url: {
privateData()->activeClickable = click;
auto action = new Action{icon::get("edit-copy"), tr("Copy Link Address"), menu, &_actionProxy, &ActionProxy::copyLinkToClipboard};
case Clickable::Url: {
privateData()->activeClickable = click;
auto action = new Action{icon::get("edit-copy"), tr("Copy Link Address"), menu, &_actionProxy, &ActionProxy::copyLinkToClipboard};
- action->setData(QVariant::fromValue<void*>(this));
+ action->setData(QVariant::fromValue(static_cast<void*>(this)));
menu->addAction(action);
break;
}
menu->addAction(action);
break;
}
QVariant ChatLineModelItem::data(int column, int role) const
{
if (role == ChatLineModel::MsgLabelRole)
QVariant ChatLineModelItem::data(int column, int role) const
{
if (role == ChatLineModel::MsgLabelRole)
- return QVariant::fromValue<UiStyle::MessageLabel>(messageLabel());
+ return QVariant::fromValue(messageLabel());
QVariant variant;
auto col = (MessageModel::ColumnType)column;
QVariant variant;
auto col = (MessageModel::ColumnType)column;
case ChatLineModel::SelectedBackgroundRole:
return backgroundBrush(UiStyle::FormatType::Timestamp, true);
case ChatLineModel::FormatRole:
case ChatLineModel::SelectedBackgroundRole:
return backgroundBrush(UiStyle::FormatType::Timestamp, true);
case ChatLineModel::FormatRole:
- return QVariant::fromValue<UiStyle::FormatList>(
- {std::make_pair(quint16{0}, UiStyle::Format{UiStyle::formatType(_styledMsg.type()) | UiStyle::FormatType::Timestamp, {}, {}})});
+ return QVariant::fromValue(UiStyle::FormatList{
+ std::make_pair(quint16{0}, UiStyle::Format{UiStyle::formatType(_styledMsg.type()) | UiStyle::FormatType::Timestamp, {}, {}})});
case ChatLineModel::SelectedBackgroundRole:
return backgroundBrush(UiStyle::FormatType::Sender, true);
case ChatLineModel::FormatRole:
case ChatLineModel::SelectedBackgroundRole:
return backgroundBrush(UiStyle::FormatType::Sender, true);
case ChatLineModel::FormatRole:
- return QVariant::fromValue<UiStyle::FormatList>(
- {std::make_pair(quint16{0}, UiStyle::Format{UiStyle::formatType(_styledMsg.type()) | UiStyle::FormatType::Sender, {}, {}})});
+ return QVariant::fromValue(UiStyle::FormatList{
+ std::make_pair(quint16{0}, UiStyle::Format{UiStyle::formatType(_styledMsg.type()) | UiStyle::FormatType::Sender, {}, {}})});
case ChatLineModel::SelectedBackgroundRole:
return backgroundBrush(UiStyle::FormatType::Contents, true);
case ChatLineModel::FormatRole:
case ChatLineModel::SelectedBackgroundRole:
return backgroundBrush(UiStyle::FormatType::Contents, true);
case ChatLineModel::FormatRole:
- return QVariant::fromValue<UiStyle::FormatList>(_styledMsg.contentsFormatList());
+ return QVariant::fromValue(_styledMsg.contentsFormatList());
case ChatLineModel::WrapListRole:
if (_wrapList.isEmpty())
computeWrapList();
case ChatLineModel::WrapListRole:
if (_wrapList.isEmpty())
computeWrapList();
- return QVariant::fromValue<ChatLineModel::WrapList>(_wrapList);
+ return QVariant::fromValue(_wrapList);
QTextCharFormat fmt = QtUi::style()->format({UiStyle::formatType(_styledMsg.type()) | subelement, {}, {}},
messageLabel() | (selected ? UiStyle::MessageLabel::Selected : UiStyle::MessageLabel::None));
if (fmt.hasProperty(QTextFormat::BackgroundBrush))
QTextCharFormat fmt = QtUi::style()->format({UiStyle::formatType(_styledMsg.type()) | subelement, {}, {}},
messageLabel() | (selected ? UiStyle::MessageLabel::Selected : UiStyle::MessageLabel::None));
if (fmt.hasProperty(QTextFormat::BackgroundBrush))
- return QVariant::fromValue<QBrush>(fmt.background());
+ return QVariant::fromValue(fmt.background());
UiStyle::SenderPrefixMode ChatViewSettings::senderPrefixDisplay() const
{
return static_cast<UiStyle::SenderPrefixMode>(
UiStyle::SenderPrefixMode ChatViewSettings::senderPrefixDisplay() const
{
return static_cast<UiStyle::SenderPrefixMode>(
- localValue("SenderPrefixMode", QVariant::fromValue<UiStyle::SenderPrefixMode>(UiStyle::SenderPrefixMode::HighestMode)).toInt());
+ localValue("SenderPrefixMode", QVariant::fromValue(UiStyle::SenderPrefixMode::HighestMode)).toInt());
// Cast the QVariant to an integer, then cast that to the enum class.
// .canConvert<UiStyle::SenderPrefixMode>() returned true, but
// .value<UiStyle::SenderPrefixMode>(); always gave the default value 0.
// Cast the QVariant to an integer, then cast that to the enum class.
// .canConvert<UiStyle::SenderPrefixMode>() returned true, but
// .value<UiStyle::SenderPrefixMode>(); always gave the default value 0.
const Network* net = Client::network(id);
auto* act = new QAction(net->networkName(), this);
act->setObjectName(QString("NetworkAction-%1").arg(id.toInt()));
const Network* net = Client::network(id);
auto* act = new QAction(net->networkName(), this);
act->setObjectName(QString("NetworkAction-%1").arg(id.toInt()));
- act->setData(QVariant::fromValue<NetworkId>(id));
+ act->setData(QVariant::fromValue(id));
connect(net, &SyncableObject::updatedRemotely, this, &MainWin::clientNetworkUpdated);
connect(act, &QAction::triggered, this, &MainWin::connectOrDisconnectFromNet);
connect(net, &SyncableObject::updatedRemotely, this, &MainWin::clientNetworkUpdated);
connect(act, &QAction::triggered, this, &MainWin::connectOrDisconnectFromNet);
else
item = new QTreeWidgetItem(cat, QStringList(sp->title()));
else
item = new QTreeWidgetItem(cat, QStringList(sp->title()));
- item->setData(0, SettingsPageRole, QVariant::fromValue<QObject*>(sp));
+ item->setData(0, SettingsPageRole, QVariant::fromValue(sp));
pageIsLoaded[sp] = false;
if (!ui.settingsTree->selectedItems().count())
ui.settingsTree->setCurrentItem(item);
pageIsLoaded[sp] = false;
if (!ui.settingsTree->selectedItems().count())
ui.settingsTree->setCurrentItem(item);
// save list of active buffers
QVariantList saveableBufferIdList;
foreach (BufferId id, _configActive->bufferList()) {
// save list of active buffers
QVariantList saveableBufferIdList;
foreach (BufferId id, _configActive->bufferList()) {
- saveableBufferIdList << QVariant::fromValue<BufferId>(id);
+ saveableBufferIdList << QVariant::fromValue(id);
}
chatViewSettings.setValue("Buffers", saveableBufferIdList);
}
chatViewSettings.setValue("Buffers", saveableBufferIdList);
if (!item)
item = new QListWidgetItem(disconnectedIcon, info.networkName, ui.networkList);
}
if (!item)
item = new QListWidgetItem(disconnectedIcon, info.networkName, ui.networkList);
}
- item->setData(Qt::UserRole, QVariant::fromValue<NetworkId>(info.networkId));
+ item->setData(Qt::UserRole, QVariant::fromValue(info.networkId));
setItemState(info.networkId, item);
widgetHasChanged();
return item;
setItemState(info.networkId, item);
widgetHasChanged();
return item;
return QVariant();
case ActionRole:
return QVariant();
case ActionRole:
- return QVariant::fromValue<QObject*>(action);
+ return QVariant::fromValue(action);
case DefaultShortcutRole:
return action->shortcut(Action::DefaultShortcut);
case DefaultShortcutRole:
return action->shortcut(Action::DefaultShortcut);
foreach (NetworkId id, Client::networkIds()) {
const Network* net = Client::network(id);
if (net->isConnected()) {
foreach (NetworkId id, Client::networkIds()) {
const Network* net = Client::network(id);
if (net->isConnected()) {
- networks->addItem(net->networkName(), QVariant::fromValue<NetworkId>(id));
+ networks->addItem(net->networkName(), QVariant::fromValue(id));
Action* act = new Action(net->networkName(), this);
_networkActions[id] = act;
act->setObjectName(QString("NetworkAction-%1").arg(id.toInt()));
Action* act = new Action(net->networkName(), this);
_networkActions[id] = act;
act->setObjectName(QString("NetworkAction-%1").arg(id.toInt()));
- act->setData(QVariant::fromValue<NetworkId>(id));
+ act->setData(QVariant::fromValue(id));
connect(net, &Network::updatedRemotely, this, [this]() { networkUpdated(); });
connect(act, &QAction::triggered, this, &ToolBarActionProvider::connectOrDisconnectNet);
networkUpdated(net);
connect(net, &Network::updatedRemotely, this, [this]() { networkUpdated(); });
connect(act, &QAction::triggered, this, &ToolBarActionProvider::connectOrDisconnectNet);
networkUpdated(net);