if (currentIndex().isValid())
return;
{
- Network *net = qobject_cast<Network *>(sender());
+ auto *net = qobject_cast<Network *>(sender());
Q_ASSERT(net);
setCurrentIndex(mapFromSource(Client::networkModel()->networkIndex(net->networkId())));
}
void BufferViewOverlay::viewInitialized()
{
- BufferViewConfig *config = qobject_cast<BufferViewConfig *>(sender());
+ auto *config = qobject_cast<BufferViewConfig *>(sender());
Q_ASSERT(config);
viewInitialized(config);
qWarning() << "Creation of already existing network requested!";
return;
}
- Network *net = new Network(id, this);
+ auto *net = new Network(id, this);
addNetwork(net);
}
void Client::coreIdentityCreated(const Identity &other)
{
if (!_identities.contains(other.id())) {
- Identity *identity = new Identity(other, this);
+ auto *identity = new Identity(other, this);
_identities[other.id()] = identity;
identity->setInitialized();
signalProxy()->synchronize(identity);
void Client::networkDestroyed()
{
- Network *net = static_cast<Network *>(sender());
+ auto *net = static_cast<Network *>(sender());
QHash<NetworkId, Network *>::iterator netIter = _networks.begin();
while (netIter != _networks.end()) {
if (*netIter == net) {
CoreAccountSettings s;
#ifdef HAVE_SSL
- QSslSocket *socket = new QSslSocket(this);
+ auto *socket = new QSslSocket(this);
// make sure the warning is shown if we happen to connect without SSL support later
s.setAccountValue("ShowNoClientSslWarning", true);
#else
socket()->read((char *)&reply, 4);
reply = qFromBigEndian<quint32>(reply);
- Protocol::Type type = static_cast<Protocol::Type>(reply & 0xff);
- quint16 protoFeatures = static_cast<quint16>(reply>>8 & 0xffff);
+ auto type = static_cast<Protocol::Type>(reply & 0xff);
+ auto protoFeatures = static_cast<quint16>(reply>>8 & 0xffff);
_connectionFeatures = static_cast<quint8>(reply>>24);
Compressor::CompressionLevel level;
// Make sure the warning is shown next time we don't have SSL in the core
s.setAccountValue("ShowNoCoreSslWarning", true);
- QSslSocket *sslSocket = qobject_cast<QSslSocket *>(socket());
+ auto *sslSocket = qobject_cast<QSslSocket *>(socket());
Q_ASSERT(sslSocket);
connect(sslSocket, SIGNAL(encrypted()), SLOT(onSslSocketEncrypted()));
connect(sslSocket, SIGNAL(sslErrors(QList<QSslError>)), SLOT(onSslErrors()));
void ClientAuthHandler::onSslSocketEncrypted()
{
- QSslSocket *socket = qobject_cast<QSslSocket *>(sender());
+ auto *socket = qobject_cast<QSslSocket *>(sender());
Q_ASSERT(socket);
if (!socket->sslErrors().count()) {
void ClientAuthHandler::onSslErrors()
{
- QSslSocket *socket = qobject_cast<QSslSocket *>(sender());
+ auto *socket = qobject_cast<QSslSocket *>(sender());
Q_ASSERT(socket);
CoreAccountSettings s;
void ClientTransferManager::onTransferInitDone()
{
- Transfer *transfer = qobject_cast<Transfer *>(sender());
+ auto *transfer = qobject_cast<Transfer *>(sender());
Q_ASSERT(transfer);
addTransfer(transfer);
}
void ClientUserInputHandler::handleExec(const BufferInfo &bufferInfo, const QString &execString)
{
- ExecWrapper *exec = new ExecWrapper(this); // gets suicidal when it's done
+ auto *exec = new ExecWrapper(this); // gets suicidal when it's done
exec->start(bufferInfo, execString);
}
void CoreConnection::networkDetectionModeChanged(const QVariant &vmode)
{
CoreConnectionSettings s;
- CoreConnectionSettings::NetworkDetectionMode mode = (CoreConnectionSettings::NetworkDetectionMode)vmode.toInt();
+ auto mode = (CoreConnectionSettings::NetworkDetectionMode)vmode.toInt();
if (mode == CoreConnectionSettings::UsePingTimeout)
Client::signalProxy()->setMaxHeartBeatCount(s.pingTimeoutInterval() / 30);
else {
return;
}
- InternalPeer *peer = new InternalPeer();
+ auto *peer = new InternalPeer();
_peer = peer;
Client::instance()->signalProxy()->addPeer(peer); // sigproxy will take ownership
emit connectionMsg(tr("Initializing..."));
NetworkId netid = networkid.value<NetworkId>();
if (Client::network(netid))
continue;
- Network *net = new Network(netid, Client::instance());
+ auto *net = new Network(netid, Client::instance());
_netsToSync.insert(net);
connect(net, SIGNAL(initDone()), SLOT(networkInitDone()));
connect(net, SIGNAL(destroyed()), SLOT(networkInitDone()));
}
// Mark query as having a quit message inserted
- MessageFilter *that = const_cast<MessageFilter *>(this);
+ auto *that = const_cast<MessageFilter *>(this);
that->_filteredQuitMsgTime.insert(messageTimestamp);
return true;
}
switch (bufferInfo.type()) {
case BufferInfo::ChannelBuffer:
{
- ChannelBufferItem *channelBufferItem = static_cast<ChannelBufferItem *>(bufferItem);
+ auto *channelBufferItem = static_cast<ChannelBufferItem *>(bufferItem);
if (_network) {
IrcChannel *ircChannel = _network->ircChannel(bufferInfo.bufferName());
if (ircChannel)
void NetworkItem::onBeginRemoveChilds(int start, int end)
{
for (int i = start; i <= end; i++) {
- StatusBufferItem *statusBufferItem = qobject_cast<StatusBufferItem *>(child(i));
+ auto *statusBufferItem = qobject_cast<StatusBufferItem *>(child(i));
if (statusBufferItem) {
_statusBufferItem = nullptr;
break;
QString StatusBufferItem::toolTip(int column) const
{
- NetworkItem *networkItem = qobject_cast<NetworkItem *>(parent());
+ auto *networkItem = qobject_cast<NetworkItem *>(parent());
if (networkItem)
return networkItem->toolTip(column);
else
// find the item that needs reparenting
IrcUserItem *ircUserItem = nullptr;
for (int i = 0; i < childCount(); i++) {
- UserCategoryItem *oldCategoryItem = qobject_cast<UserCategoryItem *>(child(i));
+ auto *oldCategoryItem = qobject_cast<UserCategoryItem *>(child(i));
Q_ASSERT(oldCategoryItem);
IrcUserItem *userItem = oldCategoryItem->findIrcUser(ircUser);
if (userItem) {
bool UserCategoryItem::removeUser(IrcUser *ircUser)
{
IrcUserItem *userItem = findIrcUser(ircUser);
- bool success = (bool)userItem;
+ auto success = (bool)userItem;
if (success) {
removeChild(userItem);
emit dataChanged(0);
{
// IrcUserItems are parented to UserCategoryItem, which are parented to ChannelBufferItem.
// We want the channel buffer item in order to get the channel-specific user modes.
- UserCategoryItem *category = qobject_cast<UserCategoryItem *>(parent());
+ auto *category = qobject_cast<UserCategoryItem *>(parent());
if (!category)
return QString();
- ChannelBufferItem *channel = qobject_cast<ChannelBufferItem *>(category->parent());
+ auto *channel = qobject_cast<ChannelBufferItem *>(category->parent());
if (!channel)
return QString();
QMimeData *NetworkModel::mimeData(const QModelIndexList &indexes) const
{
- QMimeData *mimeData = new QMimeData();
+ auto *mimeData = new QMimeData();
QStringList bufferlist;
QString netid, uid, bufferid;
if (!_bufferItemCache.contains(bufferId))
return NetworkId();
- NetworkItem *netItem = qobject_cast<NetworkItem *>(_bufferItemCache[bufferId]->parent());
+ auto *netItem = qobject_cast<NetworkItem *>(_bufferItemCache[bufferId]->parent());
if (netItem)
return netItem->networkId();
else
if (!_bufferItemCache.contains(bufferId))
return QString();
- NetworkItem *netItem = qobject_cast<NetworkItem *>(_bufferItemCache[bufferId]->parent());
+ auto *netItem = qobject_cast<NetworkItem *>(_bufferItemCache[bufferId]->parent());
if (netItem)
return netItem->networkName();
else
return BufferId();
for (int i = 0; i < netItem->childCount(); i++) {
- BufferItem *bufferItem = qobject_cast<BufferItem *>(netItem->child(i));
+ auto *bufferItem = qobject_cast<BufferItem *>(netItem->child(i));
if (bufferItem && !bufferItem->bufferName().compare(bufferName, cs))
return bufferItem->bufferId();
}
void SelectionModelSynchronizer::selectionModelDestroyed(QObject *object)
{
- QItemSelectionModel *model = static_cast<QItemSelectionModel *>(object);
+ auto *model = static_cast<QItemSelectionModel *>(object);
QSet<QItemSelectionModel *>::iterator iter = _selectionModels.begin();
while (iter != _selectionModels.end()) {
if (*iter == model) {
if (!_changeCurrentEnabled)
return;
- QItemSelectionModel *selectionModel = qobject_cast<QItemSelectionModel *>(sender());
+ auto *selectionModel = qobject_cast<QItemSelectionModel *>(sender());
Q_ASSERT(selectionModel);
QModelIndex newSourceCurrent = mapToSource(current, selectionModel);
if (newSourceCurrent.isValid() && newSourceCurrent != currentIndex())
if (!_changeSelectionEnabled)
return;
- QItemSelectionModel *selectionModel = qobject_cast<QItemSelectionModel *>(sender());
+ auto *selectionModel = qobject_cast<QItemSelectionModel *>(sender());
Q_ASSERT(selectionModel);
QItemSelection mappedSelection = selectionModel->selection();
event->accept();
- RemoveChildLaterEvent *removeEvent = static_cast<RemoveChildLaterEvent *>(event);
+ auto *removeEvent = static_cast<RemoveChildLaterEvent *>(event);
int childRow = _childItems.indexOf(removeEvent->child());
if (childRow == -1)
return;
return QModelIndex();
}
- AbstractTreeItem *childItem = static_cast<AbstractTreeItem *>(index.internalPointer());
+ auto *childItem = static_cast<AbstractTreeItem *>(index.internalPointer());
AbstractTreeItem *parentItem = childItem->parent();
Q_ASSERT(parentItem);
if (!index.isValid())
return QVariant();
- AbstractTreeItem *item = static_cast<AbstractTreeItem *>(index.internalPointer());
+ auto *item = static_cast<AbstractTreeItem *>(index.internalPointer());
return item->data(index.column(), role);
}
if (!index.isValid())
return false;
- AbstractTreeItem *item = static_cast<AbstractTreeItem *>(index.internalPointer());
+ auto *item = static_cast<AbstractTreeItem *>(index.internalPointer());
return item->setData(index.column(), value, role);
}
return rootItem->flags() & Qt::ItemIsDropEnabled;
}
else {
- AbstractTreeItem *item = static_cast<AbstractTreeItem *>(index.internalPointer());
+ auto *item = static_cast<AbstractTreeItem *>(index.internalPointer());
return item->flags();
}
}
void TreeModel::itemDataChanged(int column)
{
- AbstractTreeItem *item = qobject_cast<AbstractTreeItem *>(sender());
+ auto *item = qobject_cast<AbstractTreeItem *>(sender());
QModelIndex leftIndex, rightIndex;
if (item == rootItem)
void TreeModel::beginAppendChilds(int firstRow, int lastRow)
{
- AbstractTreeItem *parentItem = qobject_cast<AbstractTreeItem *>(sender());
+ auto *parentItem = qobject_cast<AbstractTreeItem *>(sender());
if (!parentItem) {
qWarning() << "TreeModel::beginAppendChilds(): cannot append Children to unknown parent";
return;
void TreeModel::endAppendChilds()
{
- AbstractTreeItem *parentItem = qobject_cast<AbstractTreeItem *>(sender());
+ auto *parentItem = qobject_cast<AbstractTreeItem *>(sender());
if (!parentItem) {
qWarning() << "TreeModel::endAppendChilds(): cannot append Children to unknown parent";
return;
void TreeModel::beginRemoveChilds(int firstRow, int lastRow)
{
- AbstractTreeItem *parentItem = qobject_cast<AbstractTreeItem *>(sender());
+ auto *parentItem = qobject_cast<AbstractTreeItem *>(sender());
if (!parentItem) {
qWarning() << "TreeModel::beginRemoveChilds(): cannot append Children to unknown parent";
return;
void TreeModel::endRemoveChilds()
{
- AbstractTreeItem *parentItem = qobject_cast<AbstractTreeItem *>(sender());
+ auto *parentItem = qobject_cast<AbstractTreeItem *>(sender());
if (!parentItem) {
qWarning() << "TreeModel::endRemoveChilds(): cannot remove Children from unknown parent";
return;
return nullptr;
}
- EventManager::EventType type = static_cast<EventManager::EventType>(inttype);
+ auto type = static_cast<EventManager::EventType>(inttype);
if (type == EventManager::Invalid || type == EventManager::GenericEvent)
return nullptr;
- EventManager::EventType group = static_cast<EventManager::EventType>(type & EventManager::EventGroupMask);
+ auto group = static_cast<EventManager::EventType>(type & EventManager::EventGroupMask);
Event *e = nullptr;
void EventManager::postEvent(Event *event)
{
if (sender() && sender()->thread() != this->thread()) {
- QueuedQuasselEvent *queuedEvent = new QueuedQuasselEvent(event);
+ auto *queuedEvent = new QueuedQuasselEvent(event);
QCoreApplication::postEvent(this, queuedEvent);
}
else {
void EventManager::customEvent(QEvent *event)
{
if (event->type() == QEvent::User) {
- QueuedQuasselEvent *queuedEvent = static_cast<QueuedQuasselEvent *>(event);
+ auto *queuedEvent = static_cast<QueuedQuasselEvent *>(event);
processEvent(queuedEvent->event);
event->accept();
}
// special handling for numeric IrcEvents
if ((type & ~IrcEventNumericMask) == IrcEventNumeric) {
- ::IrcEventNumeric *numEvent = static_cast< ::IrcEventNumeric *>(event);
+ auto *numEvent = static_cast< ::IrcEventNumeric *>(event);
if (!numEvent)
qWarning() << "Invalid event type for IrcEventNumeric!";
else {
void IrcChannel::ircUserDestroyed()
{
- IrcUser *ircUser = static_cast<IrcUser *>(sender());
+ auto *ircUser = static_cast<IrcUser *>(sender());
Q_ASSERT(ircUser);
_userModes.remove(ircUser);
// no further propagation.
void IrcChannel::ircUserNickSet(QString nick)
{
- IrcUser *ircUser = qobject_cast<IrcUser *>(sender());
+ auto *ircUser = qobject_cast<IrcUser *>(sender());
Q_ASSERT(ircUser);
emit ircUserNickSet(ircUser, nick);
}
void IrcUser::channelDestroyed()
{
// private slot!
- IrcChannel *channel = static_cast<IrcChannel *>(sender());
+ auto *channel = static_cast<IrcChannel *>(sender());
if (_channels.contains(channel)) {
_channels.remove(channel);
if (_channels.isEmpty() && !network()->isMe(this))
void Quassel::loadTranslation(const QLocale &locale)
{
- QTranslator *qtTranslator = QCoreApplication::instance()->findChild<QTranslator *>("QtTr");
- QTranslator *quasselTranslator = QCoreApplication::instance()->findChild<QTranslator *>("QuasselTr");
+ auto *qtTranslator = QCoreApplication::instance()->findChild<QTranslator *>("QtTr");
+ auto *quasselTranslator = QCoreApplication::instance()->findChild<QTranslator *>("QuasselTr");
if (qtTranslator)
qApp->removeTranslator(qtTranslator);
bool Quassel::Features::isEnabled(Feature feature) const
{
- size_t i = static_cast<size_t>(feature);
+ auto i = static_cast<size_t>(feature);
return i < _features.size() ? _features[i] : false;
}
connect(socket, SIGNAL(disconnected()), SIGNAL(disconnected()));
#ifdef HAVE_SSL
- QSslSocket *sslSocket = qobject_cast<QSslSocket *>(socket);
+ auto *sslSocket = qobject_cast<QSslSocket *>(socket);
if (sslSocket)
connect(sslSocket, SIGNAL(encrypted()), SIGNAL(secureStateChanged()));
#endif
if (isLocal())
return true;
#ifdef HAVE_SSL
- QSslSocket *sslSocket = qobject_cast<QSslSocket *>(socket());
+ auto *sslSocket = qobject_cast<QSslSocket *>(socket());
if (sslSocket && sslSocket->isEncrypted())
return true;
#endif
void RemotePeer::writeMessage(const QByteArray &msg)
{
- quint32 size = qToBigEndian<quint32>(msg.size());
+ auto size = qToBigEndian<quint32>(msg.size());
_compressor->write((const char*)&size, 4, Compressor::NoFlush);
_compressor->write(msg.constData(), msg.size());
}
allocated += blockSize;
}
if ((stream.byteOrder() == QDataStream::BigEndian) != (QSysInfo::ByteOrder == QSysInfo::BigEndian)) {
- uint16_t *rawData = reinterpret_cast<uint16_t *>(data.data());
+ auto *rawData = reinterpret_cast<uint16_t *>(data.data());
while (length--) {
*rawData = qbswap(*rawData);
++rawData;
const QMetaObject *SignalProxy::metaObject(const QObject *obj)
{
- if (const SyncableObject *syncObject = qobject_cast<const SyncableObject *>(obj))
+ if (const auto *syncObject = qobject_cast<const SyncableObject *>(obj))
return syncObject->syncMetaObject();
else
return obj->metaObject();
{
switch ((int)event->type()) {
case RemovePeerEvent: {
- ::RemovePeerEvent *e = static_cast< ::RemovePeerEvent *>(event);
+ auto *e = static_cast< ::RemovePeerEvent *>(event);
removePeer(e->peer);
event->accept();
break;
{
if (!reason.isEmpty())
qWarning() << qPrintable(reason);
- QAbstractSocket *sock = qobject_cast<QAbstractSocket *>(dev);
+ auto *sock = qobject_cast<QAbstractSocket *>(dev);
if (sock)
qWarning() << qPrintable(tr("Disconnecting")) << qPrintable(sock->peerAddress().toString());
dev->close();
bool Core::sslSupported()
{
#ifdef HAVE_SSL
- SslServer *sslServer = qobject_cast<SslServer *>(&instance()->_server);
+ auto *sslServer = qobject_cast<SslServer *>(&instance()->_server);
return sslServer && sslServer->isCertValid();
#else
return false;
bool Core::reloadCerts()
{
#ifdef HAVE_SSL
- SslServer *sslServerv4 = qobject_cast<SslServer *>(&_server);
+ auto *sslServerv4 = qobject_cast<SslServer *>(&_server);
bool retv4 = sslServerv4->reloadCerts();
- SslServer *sslServerv6 = qobject_cast<SslServer *>(&_v6server);
+ auto *sslServerv6 = qobject_cast<SslServer *>(&_v6server);
bool retv6 = sslServerv6->reloadCerts();
return retv4 && retv6;
void Core::incomingConnection()
{
- QTcpServer *server = qobject_cast<QTcpServer *>(sender());
+ auto *server = qobject_cast<QTcpServer *>(sender());
Q_ASSERT(server);
while (server->hasPendingConnections()) {
QTcpSocket *socket = server->nextPendingConnection();
- CoreAuthHandler *handler = new CoreAuthHandler(socket, this);
+ auto *handler = new CoreAuthHandler(socket, this);
_connectingClients.insert(handler);
connect(handler, SIGNAL(disconnected()), SLOT(clientDisconnected()));
// Potentially called during the initialization phase (before handing the connection off to the session)
void Core::clientDisconnected()
{
- CoreAuthHandler *handler = qobject_cast<CoreAuthHandler *>(sender());
+ auto *handler = qobject_cast<CoreAuthHandler *>(sender());
Q_ASSERT(handler);
quInfo() << qPrintable(tr("Non-authed client disconnected:")) << qPrintable(handler->socket()->peerAddress().toString());
void Core::setupClientSession(RemotePeer *peer, UserId uid)
{
- CoreAuthHandler *handler = qobject_cast<CoreAuthHandler *>(sender());
+ auto *handler = qobject_cast<CoreAuthHandler *>(sender());
Q_ASSERT(handler);
// From now on everything is handled by the client session
void Core::customEvent(QEvent *event)
{
if (event->type() == AddClientEventId) {
- AddClientEvent *addClientEvent = static_cast<AddClientEvent *>(event);
+ auto *addClientEvent = static_cast<AddClientEvent *>(event);
addClientHelper(addClientEvent->peer, addClientEvent->userId);
return;
}
return;
}
- InternalPeer *corePeer = new InternalPeer(this);
+ auto *corePeer = new InternalPeer(this);
corePeer->setPeer(clientPeer);
clientPeer->setPeer(corePeer);
if (!storage)
return nullptr;
- AbstractSqlStorage *sqlStorage = qobject_cast<AbstractSqlStorage *>(storage);
+ auto *sqlStorage = qobject_cast<AbstractSqlStorage *>(storage);
if (!sqlStorage) {
qDebug() << "Core::migrateDb(): only SQL based backends can be migrated!";
return nullptr;
if (!storage)
return nullptr;
- AbstractSqlStorage *sqlStorage = qobject_cast<AbstractSqlStorage *>(storage);
+ auto *sqlStorage = qobject_cast<AbstractSqlStorage *>(storage);
if (!sqlStorage) {
qDebug() << "Core::migrateDb(): only SQL based backends can be migrated!";
return nullptr;
CoreAliasManager::CoreAliasManager(CoreSession *parent)
: AliasManager(parent)
{
- CoreSession *session = qobject_cast<CoreSession *>(parent);
+ auto *session = qobject_cast<CoreSession *>(parent);
if (!session) {
qWarning() << "CoreAliasManager: unable to load Aliases. Parent is not a Coresession!";
loadDefaults();
void CoreAliasManager::save() const
{
- CoreSession *session = qobject_cast<CoreSession *>(parent());
+ auto *session = qobject_cast<CoreSession *>(parent());
if (!session) {
qWarning() << "CoreAliasManager: unable to save Aliases. Parent is not a Coresession!";
return;
socket()->read((char*)&data, 4);
data = qFromBigEndian<quint32>(data);
- Protocol::Type type = static_cast<Protocol::Type>(data & 0xff);
- quint16 protoFeatures = static_cast<quint16>(data>>8 & 0xffff);
+ auto type = static_cast<Protocol::Type>(data & 0xff);
+ auto protoFeatures = static_cast<quint16>(data>>8 & 0xffff);
_supportedProtos.append(PeerFactory::ProtoDescriptor(type, protoFeatures));
if (data >= 0x80000000) { // last protocol
void CoreAuthHandler::startSsl()
{
#ifdef HAVE_SSL
- QSslSocket *sslSocket = qobject_cast<QSslSocket *>(socket());
+ auto *sslSocket = qobject_cast<QSslSocket *>(socket());
Q_ASSERT(sslSocket);
qDebug() << qPrintable(tr("Starting encryption for Client:")) << _peer->description();
#ifdef HAVE_SSL
void CoreAuthHandler::onSslErrors()
{
- QSslSocket *sslSocket = qobject_cast<QSslSocket *>(socket());
+ auto *sslSocket = qobject_cast<QSslSocket *>(socket());
Q_ASSERT(sslSocket);
sslSocket->ignoreSslErrors();
}
CoreIgnoreListManager::CoreIgnoreListManager(CoreSession *parent)
: IgnoreListManager(parent)
{
- CoreSession *session = qobject_cast<CoreSession *>(parent);
+ auto *session = qobject_cast<CoreSession *>(parent);
if (!session) {
qWarning() << "CoreIgnoreListManager: unable to load IgnoreList. Parent is not a Coresession!";
//loadDefaults();
void CoreIgnoreListManager::save() const
{
- CoreSession *session = qobject_cast<CoreSession *>(parent());
+ auto *session = qobject_cast<CoreSession *>(parent());
if (!session) {
qWarning() << "CoreIgnoreListManager: unable to save IgnoreList. Parent is not a Coresession!";
return;
_cipher = nullptr;
// Get the cipher key from CoreNetwork if present
- CoreNetwork *coreNetwork = qobject_cast<CoreNetwork *>(network);
+ auto *coreNetwork = qobject_cast<CoreNetwork *>(network);
if (coreNetwork) {
QByteArray key = coreNetwork->readChannelCipherKey(channelname);
if (!key.isEmpty()) {
// exists. There is no need to store the empty key if no cipher exists; no
// key was present when instantiating and no key was set during the
// channel's lifetime.
- CoreNetwork *coreNetwork = qobject_cast<CoreNetwork *>(network());
+ auto *coreNetwork = qobject_cast<CoreNetwork *>(network());
if (coreNetwork && _cipher) {
coreNetwork->storeChannelCipherKey(name(), _cipher->key());
}
_cipher = nullptr;
// Get the cipher key from CoreNetwork if present
- CoreNetwork *coreNetwork = qobject_cast<CoreNetwork *>(network);
+ auto *coreNetwork = qobject_cast<CoreNetwork *>(network);
if (coreNetwork) {
QByteArray key = coreNetwork->readChannelCipherKey(nick().toLower());
if (!key.isEmpty()) {
// exists. There is no need to store the empty key if no cipher exists; no
// key was present when instantiating and no key was set during the
// channel's lifetime.
- CoreNetwork *coreNetwork = qobject_cast<CoreNetwork *>(network());
+ auto *coreNetwork = qobject_cast<CoreNetwork *>(network());
if (coreNetwork && _cipher) {
coreNetwork->storeChannelCipherKey(nick().toLower(), _cipher->key());
}
if (!Cipher::neededFeaturesAvailable())
return nullptr;
- CoreIrcChannel *channel = qobject_cast<CoreIrcChannel *>(ircChannel(target));
+ auto *channel = qobject_cast<CoreIrcChannel *>(ircChannel(target));
if (channel) {
return channel->cipher();
}
- CoreIrcUser *user = qobject_cast<CoreIrcUser *>(ircUser(target));
+ auto *user = qobject_cast<CoreIrcUser *>(ircUser(target));
if (user) {
return user->cipher();
} else if (!isChannelName(target)) {
QByteArray CoreNetwork::cipherKey(const QString &target) const
{
- CoreIrcChannel *c = qobject_cast<CoreIrcChannel*>(ircChannel(target));
+ auto *c = qobject_cast<CoreIrcChannel*>(ircChannel(target));
if (c)
return c->cipher()->key();
- CoreIrcUser *u = qobject_cast<CoreIrcUser*>(ircUser(target));
+ auto *u = qobject_cast<CoreIrcUser*>(ircUser(target));
if (u)
return u->cipher()->key();
void CoreNetwork::setCipherKey(const QString &target, const QByteArray &key)
{
- CoreIrcChannel *c = qobject_cast<CoreIrcChannel*>(ircChannel(target));
+ auto *c = qobject_cast<CoreIrcChannel*>(ircChannel(target));
if (c) {
c->setEncrypted(c->cipher()->setKey(key));
coreSession()->setBufferCipher(networkId(), target, key);
return;
}
- CoreIrcUser *u = qobject_cast<CoreIrcUser*>(ircUser(target));
+ auto *u = qobject_cast<CoreIrcUser*>(ircUser(target));
if (!u && !isChannelName(target))
u = qobject_cast<CoreIrcUser*>(newIrcUser(target));
bool CoreNetwork::cipherUsesCBC(const QString &target)
{
- CoreIrcChannel *c = qobject_cast<CoreIrcChannel*>(ircChannel(target));
+ auto *c = qobject_cast<CoreIrcChannel*>(ircChannel(target));
if (c)
return c->cipher()->usesCBC();
- CoreIrcUser *u = qobject_cast<CoreIrcUser*>(ircUser(target));
+ auto *u = qobject_cast<CoreIrcUser*>(ircUser(target));
if (u)
return u->cipher()->usesCBC();
void CoreNetworkConfig::save()
{
- CoreSession *session = qobject_cast<CoreSession *>(parent());
+ auto *session = qobject_cast<CoreSession *>(parent());
if (!session) {
qWarning() << Q_FUNC_INFO << "No CoreSession set, cannot save network configuration!";
return;
void CoreSession::removeClient(Peer *peer)
{
- RemotePeer *p = qobject_cast<RemotePeer *>(peer);
+ auto *p = qobject_cast<RemotePeer *>(peer);
if (p)
quInfo() << qPrintable(tr("Client")) << p->description() << qPrintable(tr("disconnected (UserId: %1).").arg(user().toInt()));
_coreInfo->setConnectedClientData(signalProxy()->peerCount(), signalProxy()->peerData());
void CoreSession::recvStatusMsgFromServer(QString msg)
{
- CoreNetwork *net = qobject_cast<CoreNetwork *>(sender());
+ auto *net = qobject_cast<CoreNetwork *>(sender());
Q_ASSERT(net);
emit displayStatusMsg(net->networkName(), msg);
}
void CoreSession::createIdentity(const CoreIdentity &identity)
{
- CoreIdentity *coreIdentity = new CoreIdentity(identity, this);
+ auto *coreIdentity = new CoreIdentity(identity, this);
_identities[identity.id()] = coreIdentity;
// CoreIdentity has its own synchronize method since its "private" sslManager needs to be synced as well
coreIdentity->synchronize(signalProxy());
void CoreSession::updateIdentityBySender()
{
- CoreIdentity *identity = qobject_cast<CoreIdentity *>(sender());
+ auto *identity = qobject_cast<CoreIdentity *>(sender());
if (!identity)
return;
Core::updateIdentity(user(), *identity);
emit newEvent(new MessageEvent(Message::Error, e->network(), tr("Unable to perform key exchange, missing qca-ossl plugin."), e->prefix(), e->target(), Message::None, e->timestamp()));
return;
}
- CoreNetwork *net = qobject_cast<CoreNetwork*>(e->network());
+ auto *net = qobject_cast<CoreNetwork*>(e->network());
Cipher *c = net->cipher(e->target());
if (!c) // happens when there is no CoreIrcChannel for the target (i.e. never?)
return;
void CoreSessionEventProcessor::handleNetsplitFinished()
{
- Netsplit *n = qobject_cast<Netsplit *>(sender());
+ auto *n = qobject_cast<Netsplit *>(sender());
Q_ASSERT(n);
QHash<QString, Netsplit *> splithash = _netsplits.take(n->network());
splithash.remove(splithash.key(n));
void IdentServer::respond()
{
- QTcpSocket *socket = qobject_cast<QTcpSocket *>(sender());
+ auto *socket = qobject_cast<QTcpSocket *>(sender());
Q_ASSERT(socket);
qint64 transactionId = _socketId;
/* used to be handleServerMsg() */
void IrcParser::processNetworkIncoming(NetworkDataEvent *e)
{
- CoreNetwork *net = qobject_cast<CoreNetwork *>(e->network());
+ auto *net = qobject_cast<CoreNetwork *>(e->network());
if (!net) {
qWarning() << "Received network event without valid network pointer!";
return;
query.bindValue(":lastseenmsgid", lastSeenMsgId.toQint64());
safeExec(query);
watchQuery(query);
- int result = int(0);
+ auto result = int(0);
if (query.first())
result = query.value(0).toInt();
return result;
void SslServer::incomingConnection(qintptr socketDescriptor)
{
- QSslSocket *serverSocket = new QSslSocket(this);
+ auto *serverSocket = new QSslSocket(this);
if (serverSocket->setSocketDescriptor(socketDescriptor)) {
if (isCertValid()) {
serverSocket->setLocalCertificate(_cert);
ActionCollection *coll = QtUi::actionCollection();
- Action *zoomInChatview = coll->add<Action>("ZoomInChatView", this, SLOT(zoomIn()));
+ auto *zoomInChatview = coll->add<Action>("ZoomInChatView", this, SLOT(zoomIn()));
zoomInChatview->setText(tr("Zoom In"));
zoomInChatview->setIcon(icon::get("zoom-in"));
zoomInChatview->setShortcut(QKeySequence::ZoomIn);
- Action *zoomOutChatview = coll->add<Action>("ZoomOutChatView", this, SLOT(zoomOut()));
+ auto *zoomOutChatview = coll->add<Action>("ZoomOutChatView", this, SLOT(zoomOut()));
zoomOutChatview->setIcon(icon::get("zoom-out"));
zoomOutChatview->setText(tr("Zoom Out"));
zoomOutChatview->setShortcut(QKeySequence::ZoomOut);
- Action *zoomOriginalChatview = coll->add<Action>("ZoomOriginalChatView", this, SLOT(zoomOriginal()));
+ auto *zoomOriginalChatview = coll->add<Action>("ZoomOriginalChatView", this, SLOT(zoomOriginal()));
zoomOriginalChatview->setIcon(icon::get("zoom-original"));
zoomOriginalChatview->setText(tr("Actual Size"));
//zoomOriginalChatview->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0)); // used for RTS switching
- Action *setMarkerLine = coll->add<Action>("SetMarkerLineToBottom", this, SLOT(setMarkerLine()));
+ auto *setMarkerLine = coll->add<Action>("SetMarkerLineToBottom", this, SLOT(setMarkerLine()));
setMarkerLine->setText(tr("Set Marker Line"));
setMarkerLine->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));
- Action *jumpToMarkerLine = QtUi::actionCollection("Navigation")->add<Action>("JumpToMarkerLine", this, SLOT(jumpToMarkerLine()));
+ auto *jumpToMarkerLine = QtUi::actionCollection("Navigation")->add<Action>("JumpToMarkerLine", this, SLOT(jumpToMarkerLine()));
jumpToMarkerLine->setText(tr("Go to Marker Line"));
jumpToMarkerLine->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_K));
ui.stackedWidget->setCurrentWidget(ui.page);
}
else {
- ChatView *view = qobject_cast<ChatView *>(_chatViews.value(id));
+ auto *view = qobject_cast<ChatView *>(_chatViews.value(id));
Q_ASSERT(view);
ui.stackedWidget->setCurrentWidget(view);
_chatViewSearchController->setScene(view->scene());
void BufferWidget::scrollToHighlight(QGraphicsItem *highlightItem)
{
- ChatView *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ auto *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
if (view) {
view->centerOn(highlightItem);
}
void BufferWidget::zoomIn()
{
- ChatView *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ auto *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
if (view)
view->zoomIn();
}
void BufferWidget::zoomOut()
{
- ChatView *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ auto *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
if (view)
view->zoomOut();
}
void BufferWidget::zoomOriginal()
{
- ChatView *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ auto *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
if (view)
view->zoomOriginal();
}
if (event->type() != QEvent::KeyPress)
return false;
- QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+ auto *keyEvent = static_cast<QKeyEvent *>(event);
- MultiLineEdit *inputLine = qobject_cast<MultiLineEdit *>(watched);
+ auto *inputLine = qobject_cast<MultiLineEdit *>(watched);
if (!inputLine)
return false;
if (keyEvent == QKeySequence::Copy) {
if (inputLine->hasSelectedText())
return false;
- ChatView *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ auto *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
if (view)
view->scene()->selectionToClipboard();
return true;
void BufferWidget::currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
{
- ChatView *prevView = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ auto *prevView = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
AbstractBufferContainer::currentChanged(current, previous); // switch first to avoid a redraw
// we need to hide the marker line if it's already/still at the bottom of the view (and not scrolled up)
- ChatView *curView = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ auto *curView = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
if (curView) {
BufferId curBufferId = current.data(NetworkModel::BufferIdRole).value<BufferId>();
if (curBufferId.isValid()) {
using Label = UiStyle::MessageLabel;
using Format = UiStyle::Format;
- Label itemLabel = data(ChatLineModel::MsgLabelRole).value<Label>();
+ auto itemLabel = data(ChatLineModel::MsgLabelRole).value<Label>();
const auto &fmtList = formatList();
struct LabelFormat {
ContentsChatItemPrivate *ContentsChatItem::privateData() const
{
if (!_data) {
- ContentsChatItem *that = const_cast<ContentsChatItem *>(this);
+ auto *that = const_cast<ContentsChatItem *>(this);
that->_data = new ContentsChatItemPrivate(ClickableList::fromString(data(ChatLineModel::DisplayRole).toString()), that);
}
return _data;
const QAbstractItemModel *model_ = model();
QModelIndex myIdx = model_->index(row(), 0);
Message::Type type = (Message::Type)myIdx.data(MessageModel::TypeRole).toInt();
- UiStyle::MessageLabel label = myIdx.data(ChatLineModel::MsgLabelRole).value<UiStyle::MessageLabel>();
+ auto label = myIdx.data(ChatLineModel::MsgLabelRole).value<UiStyle::MessageLabel>();
QTextCharFormat msgFmt = QtUi::style()->format({UiStyle::formatType(type), {}, {}}, label);
if (msgFmt.hasProperty(QTextFormat::BackgroundBrush)) {
return QVariant::fromValue<UiStyle::MessageLabel>(messageLabel());
QVariant variant;
- MessageModel::ColumnType col = (MessageModel::ColumnType)column;
+ auto col = (MessageModel::ColumnType)column;
switch (col) {
case ChatLineModel::TimestampColumn:
variant = timestampData(role);
{
using MessageLabel = UiStyle::MessageLabel;
- MessageLabel label = static_cast<MessageLabel>(_styledMsg.senderHash() << 16);
+ auto label = static_cast<MessageLabel>(_styledMsg.senderHash() << 16);
if (_styledMsg.flags() & Message::Self)
label |= MessageLabel::OwnMsg;
if (_styledMsg.flags() & Message::Highlight)
void ChatMonitorView::showFieldsChanged(bool checked)
{
- QAction *showAction = qobject_cast<QAction *>(sender());
+ auto *showAction = qobject_cast<QAction *>(sender());
if (!showAction)
return;
_clickHandled(true),
_leftButtonPressed(false)
{
- MessageFilter *filter = qobject_cast<MessageFilter *>(model);
+ auto *filter = qobject_cast<MessageFilter *>(model);
if (filter && filter->isSingleBufferFilter()) {
_singleBufferId = filter->singleBufferId();
}
QList<ChatLine *>::ConstIterator end = _lines.end();
QList<ChatLine *>::ConstIterator middle;
- int n = int(end - start);
+ auto n = int(end - start);
int half;
while (n > 0) {
ChatItem *ChatScene::chatItemAt(const QPointF &scenePos) const
{
foreach(QGraphicsItem *item, items(scenePos, Qt::IntersectsItemBoundingRect, Qt::AscendingOrder)) {
- ChatLine *line = qgraphicsitem_cast<ChatLine *>(item);
+ auto *line = qgraphicsitem_cast<ChatLine *>(item);
if (line)
return line->itemAt(line->mapFromScene(scenePos));
}
bool ChatScene::containsBuffer(const BufferId &id) const
{
- MessageFilter *filter = qobject_cast<MessageFilter *>(model());
+ auto *filter = qobject_cast<MessageFilter *>(model());
if (filter)
return filter->containsBuffer(id);
else
if (atTop) {
for (int i = end; i >= start; i--) {
- ChatLine *line = new ChatLine(i, model(),
+ auto *line = new ChatLine(i, model(),
width,
timestampWidth, senderWidth, contentsWidth,
senderPos, contentsPos);
}
else {
for (int i = start; i <= end; i++) {
- ChatLine *line = new ChatLine(i, model(),
+ auto *line = new ChatLine(i, model(),
width,
timestampWidth, senderWidth, contentsWidth,
senderPos, contentsPos);
{
int curRow = rowByScenePos(pos);
if (curRow < 0) return;
- int curColumn = (int)columnByScenePos(pos);
- ChatLineModel::ColumnType minColumn = (ChatLineModel::ColumnType)qMin(curColumn, _selectionStartCol);
+ auto curColumn = (int)columnByScenePos(pos);
+ auto minColumn = (ChatLineModel::ColumnType)qMin(curColumn, _selectionStartCol);
if (minColumn != _selectionMinCol) {
_selectionMinCol = minColumn;
for (int l = qMin(_selectionStart, _selectionEnd); l <= qMax(_selectionStart, _selectionEnd); l++) {
void ChatScene::initiateDrag(QWidget *source)
{
- QDrag *drag = new QDrag(source);
- QMimeData *mimeData = new QMimeData;
+ auto *drag = new QDrag(source);
+ auto *mimeData = new QMimeData;
mimeData->setText(selection());
drag->setMimeData(mimeData);
void ChatScene::requestBacklog()
{
- MessageFilter *filter = qobject_cast<MessageFilter *>(model());
+ auto *filter = qobject_cast<MessageFilter *>(model());
if (filter)
return filter->requestBacklog();
return;
// ChatLine should be at the bottom of the list
for (int i = itemList.count()-1; i >= 0; i--) {
- ChatLine *line = qgraphicsitem_cast<ChatLine *>(itemList.at(i));
+ auto *line = qgraphicsitem_cast<ChatLine *>(itemList.at(i));
if (line)
return line->row();
}
{
QList<BufferId> filterList;
filterList.append(bufferId);
- MessageFilter *filter = new MessageFilter(Client::messageModel(), filterList, this);
+ auto *filter = new MessageFilter(Client::messageModel(), filterList, this);
init(filter);
}
bool ChatView::event(QEvent *event)
{
if (event->type() == QEvent::KeyPress) {
- QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+ auto *keyEvent = static_cast<QKeyEvent *>(event);
switch (keyEvent->key()) {
case Qt::Key_Up:
case Qt::Key_Down:
{
QSet<ChatLine *> result;
foreach(QGraphicsItem *item, items(viewport()->rect().adjusted(-1, -1, 1, 1), mode)) {
- ChatLine *line = qgraphicsitem_cast<ChatLine *>(item);
+ auto *line = qgraphicsitem_cast<ChatLine *>(item);
if (line)
result.insert(line);
}
void ChatView::addActionsToMenu(QMenu *menu, const QPointF &pos)
{
// zoom actions
- BufferWidget *bw = qobject_cast<BufferWidget *>(bufferContainer());
+ auto *bw = qobject_cast<BufferWidget *>(bufferContainer());
if (bw) {
bw->addActionsToMenu(menu, pos);
menu->addSeparator();
QAction *toggleSearchBar = coll->action("ToggleSearchBar");
connect(toggleSearchBar, SIGNAL(toggled(bool)), SLOT(setVisible(bool)));
- Action *hideSearchBar = coll->add<Action>("HideSearchBar", toggleSearchBar, SLOT(setChecked(bool)));
+ auto *hideSearchBar = coll->add<Action>("HideSearchBar", toggleSearchBar, SLOT(setChecked(bool)));
hideSearchBar->setShortcutConfigurable(false);
hideSearchBar->setShortcut(Qt::Key_Escape);
if (reuse) {
QSet<ChatLine *> chatLines;
foreach(SearchHighlightItem *highlightItem, _highlightItems) {
- ChatLine *line = qgraphicsitem_cast<ChatLine *>(highlightItem->parentItem());
+ auto *line = qgraphicsitem_cast<ChatLine *>(highlightItem->parentItem());
if (line)
chatLines << line;
}
}
foreach(QGraphicsItem *child, line->childItems()) {
- SearchHighlightItem *highlightItem = qgraphicsitem_cast<SearchHighlightItem *>(child);
+ auto *highlightItem = qgraphicsitem_cast<SearchHighlightItem *>(child);
if (!highlightItem)
continue;
{
QSet<ChatLine *> chatLines;
foreach(SearchHighlightItem *item, _highlightItems) {
- ChatLine *line = qgraphicsitem_cast<ChatLine *>(item->parentItem());
+ auto *line = qgraphicsitem_cast<ChatLine *>(item->parentItem());
if (line)
chatLines << line;
}
{
QList<SearchHighlightItem *> searchHighlights;
foreach(QGraphicsItem *child, line->childItems()) {
- SearchHighlightItem *highlightItem = qgraphicsitem_cast<SearchHighlightItem *>(child);
+ auto *highlightItem = qgraphicsitem_cast<SearchHighlightItem *>(child);
if (highlightItem)
searchHighlights << highlightItem;
}
QVariant value;
switch (std::get<2>(fieldInfo).type()) {
case QVariant::Int: {
- QSpinBox *spinBox = fieldBox->findChild<QSpinBox *>(key);
+ auto *spinBox = fieldBox->findChild<QSpinBox *>(key);
if (spinBox)
value = spinBox->value();
else
break;
}
case QVariant::String: {
- QLineEdit *lineEdit = fieldBox->findChild<QLineEdit *>(key);
+ auto *lineEdit = fieldBox->findChild<QLineEdit *>(key);
if (lineEdit)
value = lineEdit->text();
else
emit completeChanged();
// Fill in sync info about the storage layer.
- StorageSelectionPage *storagePage = qobject_cast<StorageSelectionPage *>(wizard()->page(CoreConfigWizard::StorageSelectionPage));
+ auto *storagePage = qobject_cast<StorageSelectionPage *>(wizard()->page(CoreConfigWizard::StorageSelectionPage));
QString backend = storagePage->backend();
QVariantMap backendProperties = storagePage->backendProperties();
ui.backend->setText(storagePage->displayName());
// Fill in sync info about the authentication layer.
- AuthenticationSelectionPage *authPage = qobject_cast<AuthenticationSelectionPage *>(wizard()->page(CoreConfigWizard::AuthenticationSelectionPage));
+ auto *authPage = qobject_cast<AuthenticationSelectionPage *>(wizard()->page(CoreConfigWizard::AuthenticationSelectionPage));
QString authenticator = authPage->authenticator();
QVariantMap authProperties = authPage->authProperties();
ui.authenticator->setText(authPage->displayName());
setWindowTitle(tr("Connect to Core"));
setWindowIcon(icon::get("network-disconnect"));
- QVBoxLayout *layout = new QVBoxLayout(this);
+ auto *layout = new QVBoxLayout(this);
layout->addWidget(_settingsPage);
- QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
+ auto *buttonBox = new QDialogButtonBox(this);
buttonBox->setStandardButtons(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
layout->addWidget(buttonBox);
{
ui.setupUi(this);
- BufferViewOverlayFilter *filter = new BufferViewOverlayFilter(Client::bufferModel(), Client::bufferViewOverlay());
+ auto *filter = new BufferViewOverlayFilter(Client::bufferModel(), Client::bufferViewOverlay());
filter->setParent(ui.bufferView);
ui.bufferView->resize(610, 300);
ui.bufferView->show();
- QFormLayout *layout = new QFormLayout(ui.overlayProperties);
+ auto *layout = new QFormLayout(ui.overlayProperties);
layout->addRow(tr("BufferViews:"), _bufferViews = new QLineEdit(this));
layout->addRow(tr("All Networks:"), _allNetworks = new QLabel(this));
layout->addRow(tr("Networks:"), _networks = new QLineEdit(this));
DockManagerNotificationBackend::ConfigWidget::ConfigWidget(bool enabled, QWidget *parent)
: SettingsPage("Internal", "DockManagerNotification", parent)
{
- QHBoxLayout *layout = new QHBoxLayout(this);
+ auto *layout = new QHBoxLayout(this);
layout->addWidget(enabledBox = new QCheckBox(tr("Mark dockmanager entry"), this));
enabledBox->setVisible(enabled);
ActionCollection *coll = QtUi::actionCollection();
- Action *activateInputline = coll->add<Action>("FocusInputLine");
+ auto *activateInputline = coll->add<Action>("FocusInputLine");
connect(activateInputline, SIGNAL(triggered()), SLOT(setFocus()));
activateInputline->setText(tr("Focus Input Line"));
activateInputline->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));
if (event->type() != QEvent::KeyPress)
return false;
- QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+ auto *keyEvent = static_cast<QKeyEvent *>(event);
// keys from BufferView should be sent to (and focus) the input line
- BufferView *view = qobject_cast<BufferView *>(watched);
+ auto *view = qobject_cast<BufferView *>(watched);
if (view) {
if (keyEvent->text().length() == 1 && !(keyEvent->modifiers() & (Qt::ControlModifier ^ Qt::AltModifier))) { // normal key press
QChar c = keyEvent->text().at(0);
bool encrypted = false;
- IrcChannel *chan = qobject_cast<IrcChannel *>(Client::bufferModel()->data(selectionModel()->currentIndex(), NetworkModel::IrcChannelRole).value<QObject *>());
+ auto *chan = qobject_cast<IrcChannel *>(Client::bufferModel()->data(selectionModel()->currentIndex(), NetworkModel::IrcChannelRole).value<QObject *>());
if (chan)
encrypted = chan->encrypted();
- IrcUser *user = qobject_cast<IrcUser *>(Client::bufferModel()->data(selectionModel()->currentIndex(), NetworkModel::IrcUserRole).value<QObject *>());
+ auto *user = qobject_cast<IrcUser *>(Client::bufferModel()->data(selectionModel()->currentIndex(), NetworkModel::IrcUserRole).value<QObject *>());
if (user)
encrypted = user->encrypted();
QWizardPage *IrcConnectionWizard::createIntroductionPage(QWidget *parent)
{
- QWizardPage *page = new QWizardPage(parent);
+ auto *page = new QWizardPage(parent);
page->setTitle(QObject::tr("Welcome to Quassel IRC"));
QLabel *label = new QLabel(QObject::tr("This wizard will help you to set up your default identity and your IRC network connection.<br>"
"This only covers basic settings. You can cancel this wizard any time and use the settings dialog for more detailed changes."), page);
label->setWordWrap(true);
- QVBoxLayout *layout = new QVBoxLayout;
+ auto *layout = new QVBoxLayout;
layout->addWidget(label);
page->setLayout(layout);
return page;
void IrcConnectionWizard::identityReady(IdentityId id)
{
disconnect(Client::instance(), SIGNAL(identityCreated(IdentityId)), this, SLOT(identityReady(IdentityId)));
- NetworkPage *networkPage = static_cast<NetworkPage *>(_networkPage);
+ auto *networkPage = static_cast<NetworkPage *>(_networkPage);
NetworkInfo networkInfo = networkPage->networkInfo();
QStringList channels = networkPage->channelList();
networkInfo.identity = id;
_identityEditWidget->displayIdentity(_identity);
_identityEditWidget->showAdvanced(false);
- QVBoxLayout *layout = new QVBoxLayout;
+ auto *layout = new QVBoxLayout;
layout->addWidget(_identityEditWidget);
setLayout(layout);
}
setTitle(tr("Setup Network Connection"));
- QVBoxLayout *layout = new QVBoxLayout;
+ auto *layout = new QVBoxLayout;
layout->addWidget(_networkEditor);
setLayout(layout);
}
MainPage::MainPage(QWidget *parent) : QWidget(parent)
{
- QVBoxLayout *layout = new QVBoxLayout(this);
+ auto *layout = new QVBoxLayout(this);
layout->setAlignment(Qt::AlignCenter);
QLabel *label = new QLabel(this);
label->setPixmap(QPixmap(":/pics/quassel-logo.png"));
return;
config->setLocked(QtUiSettings().value("LockLayout", false).toBool());
- BufferViewDock *dock = new BufferViewDock(config, this);
+ auto *dock = new BufferViewDock(config, this);
//create the view and initialize it's filter
- BufferView *view = new BufferView(dock);
+ auto *view = new BufferView(dock);
view->setFilteredModel(Client::bufferModel(), config);
view->installEventFilter(_inputWidget); // for key presses
// since this isn't our fault and we can't do anything about it, we suppress the resulting calls
return;
}
- QAction *action = qobject_cast<QAction *>(sender());
+ auto *action = qobject_cast<QAction *>(sender());
Q_ASSERT(action);
- BufferViewDock *dock = qobject_cast<BufferViewDock *>(action->parent());
+ auto *dock = qobject_cast<BufferViewDock *>(action->parent());
Q_ASSERT(dock);
// Make sure we don't toggle backlog fetch for a view we've already removed
void MainWin::bufferViewVisibilityChanged(bool visible)
{
Q_UNUSED(visible);
- BufferViewDock *dock = qobject_cast<BufferViewDock *>(sender());
+ auto *dock = qobject_cast<BufferViewDock *>(sender());
Q_ASSERT(dock);
if ((!dock->isHidden() && !activeBufferView()) || (dock->isHidden() && dock->isActive()))
nextBufferView();
VerticalDock *dock = new VerticalDock(tr("Chat Monitor"), this);
dock->setObjectName("ChatMonitorDock");
- ChatMonitorFilter *filter = new ChatMonitorFilter(Client::messageModel(), this);
+ auto *filter = new ChatMonitorFilter(Client::messageModel(), this);
_chatMonitorView = new ChatMonitorView(filter, this);
_chatMonitorView->show();
dock->setWidget(_chatMonitorView);
void MainWin::setupHotList()
{
- FlatProxyModel *flatProxy = new FlatProxyModel(this);
+ auto *flatProxy = new FlatProxyModel(this);
flatProxy->setSourceModel(Client::bufferModel());
_bufferHotList = new BufferHotListFilter(flatProxy);
}
void MainWin::showCoreConfigWizard(const QVariantList &backends, const QVariantList &authenticators)
{
- CoreConfigWizard *wizard = new CoreConfigWizard(Client::coreConnection(), backends, authenticators, this);
+ auto *wizard = new CoreConfigWizard(Client::coreConnection(), backends, authenticators, this);
wizard->show();
}
void MainWin::showChannelList(NetworkId netId, const QString &channelFilters, bool listImmediately)
{
if (!netId.isValid()) {
- QAction *action = qobject_cast<QAction *>(sender());
+ auto *action = qobject_cast<QAction *>(sender());
if (action)
netId = action->data().value<NetworkId>();
if (!netId.isValid()) {
}
}
- ChannelListDlg *channelListDlg = new ChannelListDlg(this);
+ auto *channelListDlg = new ChannelListDlg(this);
channelListDlg->setAttribute(Qt::WA_DeleteOnClose);
channelListDlg->setNetwork(netId);
if (!channelFilters.isEmpty()) {
{
if (_awayLog)
return;
- AwayLogFilter *filter = new AwayLogFilter(Client::messageModel());
+ auto *filter = new AwayLogFilter(Client::messageModel());
_awayLog = new AwayLogView(filter, nullptr);
filter->setParent(_awayLog);
connect(_awayLog, SIGNAL(destroyed()), this, SLOT(awayLogDestroyed()));
void MainWin::showSettingsDlg()
{
- SettingsDlg *dlg = new SettingsDlg(this);
+ auto *dlg = new SettingsDlg();
//Category: Interface
dlg->registerSettingsPage(new AppearanceSettingsPage(dlg));
auto transfer = Client::transferManager()->transfer(transferId);
if (transfer) {
if (transfer->status() == Transfer::Status::New) {
- ReceiveFileDlg *dlg = new ReceiveFileDlg(transfer, this);
+ auto *dlg = new ReceiveFileDlg(transfer, this);
dlg->show();
}
}
void MainWin::closeEvent(QCloseEvent *event)
{
QtUiSettings s;
- QtUiApplication *app = qobject_cast<QtUiApplication *> qApp;
+ auto *app = qobject_cast<QtUiApplication *> qApp;
Q_ASSERT(app);
// On OSX it can happen that the closeEvent occurs twice. (Especially if packaged with Frameworks)
// This messes up MainWinState/MainWinHidden save/restore.
void MainWin::clientNetworkCreated(NetworkId id)
{
const Network *net = Client::network(id);
- QAction *act = new QAction(net->networkName(), this);
+ auto *act = new QAction(net->networkName(), this);
act->setObjectName(QString("NetworkAction-%1").arg(id.toInt()));
act->setData(QVariant::fromValue<NetworkId>(id));
connect(net, SIGNAL(updatedRemotely()), this, SLOT(clientNetworkUpdated()));
void MainWin::clientNetworkUpdated()
{
- const Network *net = qobject_cast<const Network *>(sender());
+ const auto *net = qobject_cast<const Network *>(sender());
if (!net)
return;
- QAction *action = findChild<QAction *>(QString("NetworkAction-%1").arg(net->networkId().toInt()));
+ auto *action = findChild<QAction *>(QString("NetworkAction-%1").arg(net->networkId().toInt()));
if (!action)
return;
void MainWin::clientNetworkRemoved(NetworkId id)
{
- QAction *action = findChild<QAction *>(QString("NetworkAction-%1").arg(id.toInt()));
+ auto *action = findChild<QAction *>(QString("NetworkAction-%1").arg(id.toInt()));
if (!action)
return;
void MainWin::connectOrDisconnectFromNet()
{
- QAction *act = qobject_cast<QAction *>(sender());
+ auto *act = qobject_cast<QAction *>(sender());
if (!act) return;
const Network *net = Client::network(act->data().value<NetworkId>());
if (!net) return;
void MainWin::onJumpKey()
{
- QAction *action = qobject_cast<QAction *>(sender());
+ auto *action = qobject_cast<QAction *>(sender());
if (!action || !Client::bufferModel())
return;
int idx = action->property("Index").toInt();
void MainWin::bindJumpKey()
{
- QAction *action = qobject_cast<QAction *>(sender());
+ auto *action = qobject_cast<QAction *>(sender());
if (!action || !Client::bufferModel())
return;
int idx = action->property("Index").toInt();
void MainWin::on_actionDebugNetworkModel_triggered()
{
- QTreeView *view = new QTreeView;
+ auto *view = new QTreeView;
view->setAttribute(Qt::WA_DeleteOnClose);
view->setWindowTitle("Debug NetworkModel View");
view->setModel(Client::networkModel());
_bufferHotList->invalidate();
_bufferHotList->sort(0, Qt::DescendingOrder);
- QTreeView *view = new QTreeView;
+ auto *view = new QTreeView;
view->setAttribute(Qt::WA_DeleteOnClose);
view->setModel(_bufferHotList);
view->show();
void MainWin::on_actionDebugBufferViewOverlay_triggered()
{
- DebugBufferViewOverlay *overlay = new DebugBufferViewOverlay(nullptr);
+ auto *overlay = new DebugBufferViewOverlay(nullptr);
overlay->setAttribute(Qt::WA_DeleteOnClose);
overlay->show();
}
void MainWin::on_actionDebugMessageModel_triggered()
{
- QTableView *view = new QTableView(nullptr);
- DebugMessageModelFilter *filter = new DebugMessageModelFilter(view);
+ auto *view = new QTableView(nullptr);
+ auto *filter = new DebugMessageModelFilter(view);
filter->setSourceModel(Client::messageModel());
view->setModel(filter);
view->setAttribute(Qt::WA_DeleteOnClose, true);
QDockWidget *NickListWidget::dock() const
{
- QDockWidget *dock = qobject_cast<QDockWidget *>(parent());
+ auto *dock = qobject_cast<QDockWidget *>(parent());
if (dock)
return dock;
else
void NickListWidget::showEvent(QShowEvent *event)
{
- NickView *view = qobject_cast<NickView *>(ui.stackedWidget->currentWidget());
+ auto *view = qobject_cast<NickView *>(ui.stackedWidget->currentWidget());
if (view)
emit nickSelectionChanged(view->selectedIndexes());
}
else {
view = new NickView(this);
- NickViewFilter *filter = new NickViewFilter(newBufferId, Client::networkModel());
+ auto *filter = new NickViewFilter(newBufferId, Client::networkModel());
view->setModel(filter);
QModelIndex source_current = Client::bufferModel()->mapToSource(current);
view->setRootIndex(filter->mapFromSource(source_current));
void NickListWidget::nickSelectionChanged()
{
- NickView *view = qobject_cast<NickView *>(sender());
+ auto *view = qobject_cast<NickView *>(sender());
Q_ASSERT(view);
if (view != ui.stackedWidget->currentWidget()) {
qDebug() << "Nick selection of hidden view changed!";
ui.stackedWidget->removeWidget(nickView);
QAbstractItemModel *model = nickView->model();
nickView->setModel(nullptr);
- if (QSortFilterProxyModel *filter = qobject_cast<QSortFilterProxyModel *>(model))
+ if (auto *filter = qobject_cast<QSortFilterProxyModel *>(model))
filter->setSourceModel(nullptr);
model->deleteLater();
nickView->deleteLater();
ui.stackedWidget->removeWidget(view);
QAbstractItemModel *model = view->model();
view->setModel(nullptr);
- if (QSortFilterProxyModel *filter = qobject_cast<QSortFilterProxyModel *>(model))
+ if (auto *filter = qobject_cast<QSortFilterProxyModel *>(model))
filter->setSourceModel(nullptr);
model->deleteLater();
view->deleteLater();
void SettingsDlg::setItemState(QTreeWidgetItem *item)
{
- SettingsPage *sp = qobject_cast<SettingsPage *>(item->data(0, SettingsPageRole).value<QObject *>());
+ auto *sp = qobject_cast<SettingsPage *>(item->data(0, SettingsPageRole).value<QObject *>());
Q_ASSERT(sp);
bool disabledDueToConnection = !Client::isConnected() && sp->needsCoreConnection();
bool disabledDueToOwnChoice = !sp->isSelectable();
void BufferViewSettingsPage::addBufferView(BufferViewConfig *config)
{
- QListWidgetItem *item = new QListWidgetItem(config->bufferViewName(), ui.bufferViewList);
+ auto *item = new QListWidgetItem(config->bufferViewName(), ui.bufferViewList);
item->setData(Qt::UserRole, qVariantFromValue<QObject *>(qobject_cast<QObject *>(config)));
connect(config, SIGNAL(updatedRemotely()), this, SLOT(updateBufferView()));
connect(config, SIGNAL(destroyed()), this, SLOT(bufferViewDeleted()));
void BufferViewSettingsPage::bufferViewDeleted()
{
- BufferViewConfig *config = static_cast<BufferViewConfig *>(sender());
+ auto *config = static_cast<BufferViewConfig *>(sender());
QObject *obj;
for (int i = 0; i < ui.bufferViewList->count(); i++) {
obj = ui.bufferViewList->item(i)->data(Qt::UserRole).value<QObject *>();
{
// id's of newly created bufferviews are negative (-1, -2... -n)
int fakeId = -1 * (_newBufferViews.count() + 1);
- BufferViewConfig *config = new BufferViewConfig(fakeId);
+ auto *config = new BufferViewConfig(fakeId);
config->setBufferViewName(bufferViewName);
config->setInitialized();
QList<BufferId> bufferIds;
BufferViewConfig *BufferViewSettingsPage::bufferView(int listPos)
{
if (listPos < ui.bufferViewList->count() && listPos >= 0) {
- QObject *obj = ui.bufferViewList->item(listPos)->data(Qt::UserRole).value<QObject *>();
+ auto *obj = ui.bufferViewList->item(listPos)->data(Qt::UserRole).value<QObject *>();
return qobject_cast<BufferViewConfig *>(obj);
}
else {
void BufferViewSettingsPage::updateBufferView()
{
- BufferViewConfig *config = qobject_cast<BufferViewConfig *>(sender());
+ auto *config = qobject_cast<BufferViewConfig *>(sender());
if (!config)
return;
if (ret == QMessageBox::Yes) {
ui.bufferViewList->removeItemWidget(currentItem);
- BufferViewConfig *config = qobject_cast<BufferViewConfig *>(currentItem->data(Qt::UserRole).value<QObject *>());
+ auto *config = qobject_cast<BufferViewConfig *>(currentItem->data(Qt::UserRole).value<QObject *>());
delete currentItem;
if (viewId >= 0) {
_deleteBufferViews << viewId;
if (_changedBufferViews.contains(config))
return _changedBufferViews[config];
- BufferViewConfig *changedConfig = new BufferViewConfig(-1, this);
+ auto *changedConfig = new BufferViewConfig(-1, this);
changedConfig->fromVariantMap(config->toVariantMap());
changedConfig->setInitialized();
_changedBufferViews[config] = changedConfig;
changedConfig->setProperty("OriginalBufferList", toVariantList<BufferId>(config->bufferList()));
// if this is the currently displayed view we have to change the config of the preview filter
- BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(ui.bufferViewPreview->model());
+ auto *filter = qobject_cast<BufferViewFilter *>(ui.bufferViewPreview->model());
if (filter && filter->config() == config)
filter->setConfig(changedConfig);
ui.bufferViewPreview->setConfig(changedConfig);
*/
void ChatMonitorSettingsPage::switchOperationMode(int idx)
{
- ChatViewSettings::OperationMode mode = (ChatViewSettings::OperationMode)(idx + 1);
+ auto mode = (ChatViewSettings::OperationMode)(idx + 1);
if (mode == ChatViewSettings::OptIn) {
ui.labelActiveBuffers->setText(tr("Show:"));
}
enableItem->setCheckState(Qt::Unchecked);
enableItem->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
- QTableWidgetItem *nameItem = new QTableWidgetItem(name);
+ auto *nameItem = new QTableWidgetItem(name);
QTableWidgetItem *regexItem = new QTableWidgetItem("");
if (regex)
csItem->setCheckState(Qt::Unchecked);
csItem->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
- QTableWidgetItem *chanNameItem = new QTableWidgetItem(chanName);
+ auto *chanNameItem = new QTableWidgetItem(chanName);
enableItem->setToolTip(tr("Enable/disable this rule"));
nameItem->setToolTip(tr("Phrase to match"));
void IdentitiesSettingsPage::clientIdentityCreated(IdentityId id)
{
- CertIdentity *identity = new CertIdentity(*Client::identity(id), this);
+ auto *identity = new CertIdentity(*Client::identity(id), this);
#ifdef HAVE_SSL
identity->enableEditSsl(_editSsl);
#endif
if (!identities.keys().contains(-id.toInt())) break;
}
id = -id.toInt();
- CertIdentity *newId = new CertIdentity(id, this);
+ auto *newId = new CertIdentity(id, this);
#ifdef HAVE_SSL
newId->enableEditSsl(_editSsl);
#endif
enableOkButton = true;
}
- IgnoreListEditDlg *dlg = new IgnoreListEditDlg(newItem, this, enableOkButton);
+ auto *dlg = new IgnoreListEditDlg(newItem, this, enableOkButton);
dlg->enableOkButton(enableOkButton);
while (dlg->exec() == QDialog::Accepted) {
if (!_ignoreListModel.newIgnoreRule(dlg->ignoreListItem())) {
void ItemViewSettingsPage::updateBufferViewPreview(QWidget *widget)
{
- ColorButton *button = qobject_cast<ColorButton *>(widget);
+ auto *button = qobject_cast<ColorButton *>(widget);
if (!button)
return;
KeySequenceWidget::KeySequenceWidget(QWidget *parent)
: QWidget(parent)
{
- QHBoxLayout *layout = new QHBoxLayout(this);
+ auto *layout = new QHBoxLayout(this);
layout->setMargin(0);
_keyButton = new KeySequenceButton(this, this);
void NetworksSettingsPage::clientIdentityUpdated()
{
- const Identity *identity = qobject_cast<const Identity *>(sender());
+ const auto *identity = qobject_cast<const Identity *>(sender());
if (!identity) {
qWarning() << "NetworksSettingsPage: Invalid identity to update!";
return;
void NetworksSettingsPage::clientNetworkUpdated()
{
- const Network *net = qobject_cast<const Network *>(sender());
+ const auto *net = qobject_cast<const Network *>(sender());
if (!net) {
qWarning() << "Update request for unknown network received!";
return;
void NetworksSettingsPage::networkConnectionStateChanged(Network::ConnectionState state)
{
Q_UNUSED(state);
- const Network *net = qobject_cast<const Network *>(sender());
+ const auto *net = qobject_cast<const Network *>(sender());
if (!net) return;
/*
if(net->networkId() == currentId) {
void NetworksSettingsPage::clientNetworkCapsUpdated()
{
// Grab the updated network
- const Network *net = qobject_cast<const Network *>(sender());
+ const auto *net = qobject_cast<const Network *>(sender());
if (!net) {
qWarning() << "Update request for unknown network received!";
return;
NotificationsSettingsPage::NotificationsSettingsPage(QWidget *parent)
: SettingsPage(tr("Interface"), tr("Notifications"), parent)
{
- QVBoxLayout *layout = new QVBoxLayout(this);
+ auto *layout = new QVBoxLayout(this);
foreach(AbstractNotificationBackend *backend, QtUi::notificationBackends()) {
SettingsPage *cw = backend->createConfigWidget();
if (cw) {
{
for (int r = 0; r < actionCollections.values().count(); r++) {
ActionCollection *coll = actionCollections.values().at(r);
- Item *item = new Item();
+ auto *item = new Item();
item->row = r;
item->collection = coll;
for (int i = 0; i < coll->actions().count(); i++) {
- Action *action = qobject_cast<Action *>(coll->actions().at(i));
+ auto *action = qobject_cast<Action *>(coll->actions().at(i));
if (!action)
continue;
- Item *actionItem = new Item();
+ auto *actionItem = new Item();
actionItem->parentItem = item;
actionItem->row = i;
actionItem->collection = coll;
if (!child.isValid())
return QModelIndex();
- Item *item = static_cast<Item *>(child.internalPointer());
+ auto *item = static_cast<Item *>(child.internalPointer());
Q_ASSERT(item);
if (!item->parentItem)
if (!parent.isValid())
return 2;
- Item *item = static_cast<Item *>(parent.internalPointer());
+ auto *item = static_cast<Item *>(parent.internalPointer());
Q_ASSERT(item);
if (!item->parentItem)
if (!parent.isValid())
return _categoryItems.count();
- Item *item = static_cast<Item *>(parent.internalPointer());
+ auto *item = static_cast<Item *>(parent.internalPointer());
Q_ASSERT(item);
if (!item->parentItem)
if (!index.isValid())
return QVariant();
- Item *item = static_cast<Item *>(index.internalPointer());
+ auto *item = static_cast<Item *>(index.internalPointer());
Q_ASSERT(item);
if (!item->parentItem) {
}
}
- Action *action = qobject_cast<Action *>(item->action);
+ auto *action = qobject_cast<Action *>(item->action);
Q_ASSERT(action);
switch (role) {
if (!index.parent().isValid())
return false;
- Item *item = static_cast<Item *>(index.internalPointer());
+ auto *item = static_cast<Item *>(index.internalPointer());
Q_ASSERT(item);
QKeySequence newSeq = value.value<QKeySequence>();
SonnetSettingsPage::SonnetSettingsPage(QWidget *parent)
: SettingsPage(tr("Interface"), tr("Spell Checking"), parent)
{
- QVBoxLayout *layout = new QVBoxLayout(this);
+ auto *layout = new QVBoxLayout(this);
_configWidget = new Sonnet::ConfigWidget(this);
layout->addWidget(_configWidget);
connect(_configWidget, SIGNAL(configChanged()), SLOT(widgetHasChanged()));
_showBubbleBox = new QCheckBox(tr("Show a message in a popup"));
_showBubbleBox->setIcon(icon::get("dialog-information"));
connect(_showBubbleBox, SIGNAL(toggled(bool)), this, SLOT(widgetChanged()));
- QHBoxLayout *layout = new QHBoxLayout(this);
+ auto *layout = new QHBoxLayout(this);
layout->addWidget(_showBubbleBox);
}
TaskbarNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) : SettingsPage("Internal", "TaskbarNotification", parent)
{
- QHBoxLayout *layout = new QHBoxLayout(this);
+ auto *layout = new QHBoxLayout(this);
#ifdef Q_OS_MAC
layout->addWidget(enabledBox = new QCheckBox(tr("Activate dock entry, timeout:"), this));
#else
if (event->type() != QEvent::KeyRelease)
return QObject::eventFilter(obj, event);
- QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+ auto *keyEvent = static_cast<QKeyEvent *>(event);
if (keyEvent->key() == Qt::Key_Escape) {
switchPlain();
Action *ActionCollection::addAction(const QString &name, const QObject *receiver, const char *member)
{
- Action *a = new Action(this);
+ auto *a = new Action(this);
if (receiver && member)
connect(a, SIGNAL(triggered(bool)), receiver, member);
return addAction(name, a);
foreach(const QString &name, _actionByName.keys()) {
if (!savedShortcuts.contains(name))
continue;
- Action *action = qobject_cast<Action *>(_actionByName.value(name));
+ auto *action = qobject_cast<Action *>(_actionByName.value(name));
if (action)
action->setShortcut(s.loadShortcut(name), Action::ActiveShortcut);
}
{
ShortcutSettings s;
foreach(const QString &name, _actionByName.keys()) {
- Action *action = qobject_cast<Action *>(_actionByName.value(name));
+ auto *action = qobject_cast<Action *>(_actionByName.value(name));
if (!action)
continue;
if (!action->isShortcutConfigurable())
void ActionCollection::slotActionTriggered()
{
- QAction *action = qobject_cast<QAction *>(sender());
+ auto *action = qobject_cast<QAction *>(sender());
if (action)
emit actionTriggered(action);
}
void ActionCollection::slotActionHovered()
{
- QAction *action = qobject_cast<QAction *>(sender());
+ auto *action = qobject_cast<QAction *>(sender());
if (action)
emit actionHovered(action);
}
void ActionCollection::actionDestroyed(QObject *obj)
{
// remember that this is not an QAction anymore at this point
- QAction *action = static_cast<QAction *>(obj);
+ auto *action = static_cast<QAction *>(obj);
unlistAction(action);
}
template<class ActionType>
ActionType *add(const QString &name, const QObject *receiver = nullptr, const char *member = nullptr)
{
- ActionType *a = new ActionType(this);
+ auto *a = new ActionType(this);
if (receiver && member)
connect(a, SIGNAL(triggered(bool)), receiver, member);
addAction(name, a);
setSelectionMode(QAbstractItemView::ExtendedSelection);
QAbstractItemDelegate *oldDelegate = itemDelegate();
- BufferViewDelegate *tristateDelegate = new BufferViewDelegate(this);
+ auto *tristateDelegate = new BufferViewDelegate(this);
setItemDelegate(tristateDelegate);
delete oldDelegate;
}
void BufferView::setFilteredModel(QAbstractItemModel *model_, BufferViewConfig *config)
{
- BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(model());
+ auto *filter = qobject_cast<BufferViewFilter *>(model());
if (filter) {
filter->setConfig(config);
setConfig(config);
setModel(model_);
}
else {
- BufferViewFilter *filter = new BufferViewFilter(model_, config);
+ auto *filter = new BufferViewFilter(model_, config);
setModel(filter);
connect(filter, SIGNAL(configChanged()), this, SLOT(on_configChanged()));
}
void BufferView::toggleHeader(bool checked)
{
- QAction *action = qobject_cast<QAction *>(sender());
+ auto *action = qobject_cast<QAction *>(sender());
header()->setSectionHidden((action->property("column")).toInt(), !checked);
}
void BufferView::addFilterActions(QMenu *contextMenu, const QModelIndex &index)
{
- BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(model());
+ auto *filter = qobject_cast<BufferViewFilter *>(model());
if (filter) {
QList<QAction *> filterActions = filter->actions(index);
if (!filterActions.isEmpty()) {
void BufferView::filterTextChanged(const QString& filterString)
{
- BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(model());
+ auto *filter = qobject_cast<BufferViewFilter *>(model());
if (!filter) {
return;
}
void BufferView::changeHighlight(BufferView::Direction direction)
{
// If for some weird reason we get a new delegate
- BufferViewDelegate *delegate = qobject_cast<BufferViewDelegate*>(itemDelegate(_currentHighlight));
+ auto delegate = qobject_cast<BufferViewDelegate*>(itemDelegate(_currentHighlight));
if (delegate) {
delegate->currentHighlight = QModelIndex();
}
void BufferView::clearHighlight()
{
// If for some weird reason we get a new delegate
- BufferViewDelegate *delegate = qobject_cast<BufferViewDelegate*>(itemDelegate(_currentHighlight));
+ auto delegate = qobject_cast<BufferViewDelegate*>(itemDelegate(_currentHighlight));
if (delegate) {
delegate->currentHighlight = QModelIndex();
}
initStyleOption(&viewOpt, index);
QRect checkRect = viewOpt.widget->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &viewOpt, viewOpt.widget);
- QMouseEvent *me = static_cast<QMouseEvent *>(event);
+ auto *me = static_cast<QMouseEvent *>(event);
if (me->button() != Qt::LeftButton || !checkRect.contains(me->pos()))
return QStyledItemDelegate::editorEvent(event, model, option, index);
- Qt::CheckState state = static_cast<Qt::CheckState>(value.toInt());
+ auto state = static_cast<Qt::CheckState>(value.toInt());
if (state == Qt::Unchecked)
state = Qt::PartiallyChecked;
else if (state == Qt::PartiallyChecked)
return true;
}
} else if (event->type() == QEvent::KeyRelease) {
- QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
+ auto keyEvent = static_cast<QKeyEvent*>(event);
BufferView *view = bufferView();
if (!view) {
// This DOES mean that it looks like you can merge a buffer into the Status buffer, but that is restricted in BufferView::dropEvent().
if (bufferType == BufferInfo::StatusBuffer) {
// But only if the layout isn't locked!
- ClientBufferViewConfig *clientConf = qobject_cast<ClientBufferViewConfig *>(config());
+ auto *clientConf = qobject_cast<ClientBufferViewConfig *>(config());
if (clientConf && !clientConf->isLocked()) {
flags |= Qt::ItemIsDropEnabled;
}
if (config()->bufferList().contains(bufferId) && !config()->sortAlphabetically()) {
if (config()->bufferList().indexOf(bufferId) < pos)
pos--;
- ClientBufferViewConfig *clientConf = qobject_cast<ClientBufferViewConfig *>(config());
+ auto *clientConf = qobject_cast<ClientBufferViewConfig *>(config());
if (!clientConf || !clientConf->isLocked())
config()->requestMoveBuffer(bufferId, pos);
}
registerAction(ShowNetworkConfig, tr("Configure"));
registerAction(ShowIgnoreList, tr("Show Ignore List"));
- QMenu *hideEventsMenu = new QMenu();
+ auto *hideEventsMenu = new QMenu();
hideEventsMenu->addAction(action(HideJoinPartQuit));
hideEventsMenu->addSeparator();
hideEventsMenu->addAction(action(HideJoin));
_hideEventsMenuAction = new Action(tr("Hide Events"), nullptr);
_hideEventsMenuAction->setMenu(hideEventsMenu);
- QMenu *nickCtcpMenu = new QMenu();
+ auto *nickCtcpMenu = new QMenu();
nickCtcpMenu->addAction(action(NickCtcpPing));
nickCtcpMenu->addAction(action(NickCtcpVersion));
nickCtcpMenu->addAction(action(NickCtcpTime));
_nickCtcpMenuAction = new Action(tr("CTCP"), nullptr);
_nickCtcpMenuAction->setMenu(nickCtcpMenu);
- QMenu *nickModeMenu = new QMenu();
+ auto *nickModeMenu = new QMenu();
nickModeMenu->addAction(action(NickOp));
nickModeMenu->addAction(action(NickDeop));
// this is where the halfops will be placed if available
_nickModeMenuAction = new Action(tr("Actions"), nullptr);
_nickModeMenuAction->setMenu(nickModeMenu);
- QMenu *ignoreMenu = new QMenu();
+ auto *ignoreMenu = new QMenu();
_nickIgnoreMenuAction = new Action(tr("Ignore"), nullptr);
_nickIgnoreMenuAction->setMenu(ignoreMenu);
addAction(_nickModeMenuAction, menu, itemType == NetworkModel::IrcUserItemType);
addAction(_nickCtcpMenuAction, menu);
- IrcUser *ircUser = qobject_cast<IrcUser *>(index.data(NetworkModel::IrcUserRole).value<QObject *>());
+ auto *ircUser = qobject_cast<IrcUser *>(index.data(NetworkModel::IrcUserRole).value<QObject *>());
if (ircUser) {
Network *network = ircUser->network();
// only show entries for usermode +h if server supports it
ignoreMenu->addAction(_ignoreDescriptions.at(1));
while (ruleIter != ignoreMap.constEnd()) {
if (counter < 5) {
- ActionType type = static_cast<ActionType>(NickIgnoreToggleEnabled0 + counter*0x100000);
+ auto type = static_cast<ActionType>(NickIgnoreToggleEnabled0 + counter*0x100000);
Action *act = action(type);
act->setText(ruleIter.key());
act->setProperty("ignoreRule", ruleIter.key());
SourceItem *topLeftItem = nullptr;
SourceItem *bottomRightItem = nullptr;
- SourceItem *currentItem = static_cast<SourceItem *>(range.topLeft().internalPointer());
+ auto *currentItem = static_cast<SourceItem *>(range.topLeft().internalPointer());
int row = range.topLeft().row();
int left = range.topLeft().column();
int right = range.bottomRight().column();
FontSelector::FontSelector(QWidget *parent) : QWidget(parent)
{
- QHBoxLayout *layout = new QHBoxLayout(this);
+ auto *layout = new QHBoxLayout(this);
QPushButton *chooseButton = new QPushButton(tr("Choose..."), this);
connect(chooseButton, SIGNAL(clicked()), SLOT(chooseFont()));
{
if (_actionCollections.contains(category))
return _actionCollections.value(category);
- ActionCollection *coll = new ActionCollection(_mainWidget);
+ auto *coll = new ActionCollection(_mainWidget);
if (!translatedCategory.isEmpty())
coll->setProperty("Category", translatedCategory);
QSize MultiLineEdit::sizeHint() const
{
if (!_sizeHint.isValid()) {
- MultiLineEdit *that = const_cast<MultiLineEdit *>(this);
+ auto *that = const_cast<MultiLineEdit *>(this);
that->updateSizeHint();
}
return _sizeHint;
{
// We need to make sure that global shortcuts aren't eaten
if (e->type() == QEvent::ShortcutOverride) {
- QKeyEvent *event = static_cast<QKeyEvent *>(e);
+ auto *event = static_cast<QKeyEvent *>(e);
QKeySequence key = QKeySequence(event->key() | event->modifiers());
foreach(QAction *action, GraphicalUi::actionCollection()->actions()) {
if (action->shortcuts().contains(key)) {
QString NetworkModelController::nickName(const QModelIndex &index) const
{
- IrcUser *ircUser = qobject_cast<IrcUser *>(index.data(NetworkModel::IrcUserRole).value<QObject *>());
+ auto *ircUser = qobject_cast<IrcUser *>(index.data(NetworkModel::IrcUserRole).value<QObject *>());
if (ircUser)
return ircUser->nick();
break;
case NickIgnoreUser:
{
- IrcUser *ircUser = qobject_cast<IrcUser *>(index.data(NetworkModel::IrcUserRole).value<QObject *>());
+ auto *ircUser = qobject_cast<IrcUser *>(index.data(NetworkModel::IrcUserRole).value<QObject *>());
if (!ircUser)
break;
Client::ignoreListManager()->requestAddIgnoreListItem(IgnoreListManager::SenderIgnore,
}
case NickIgnoreHost:
{
- IrcUser *ircUser = qobject_cast<IrcUser *>(index.data(NetworkModel::IrcUserRole).value<QObject *>());
+ auto *ircUser = qobject_cast<IrcUser *>(index.data(NetworkModel::IrcUserRole).value<QObject *>());
if (!ircUser)
break;
Client::ignoreListManager()->requestAddIgnoreListItem(IgnoreListManager::SenderIgnore,
}
case NickIgnoreDomain:
{
- IrcUser *ircUser = qobject_cast<IrcUser *>(index.data(NetworkModel::IrcUserRole).value<QObject *>());
+ auto *ircUser = qobject_cast<IrcUser *>(index.data(NetworkModel::IrcUserRole).value<QObject *>());
if (!ircUser)
break;
Client::ignoreListManager()->requestAddIgnoreListItem(IgnoreListManager::SenderIgnore,
setWindowIcon(icon::get("irc-join-channel"));
setWindowTitle(tr("Join Channel"));
- QGridLayout *layout = new QGridLayout(this);
+ auto *layout = new QGridLayout(this);
layout->addWidget(new QLabel(tr("Network:")), 0, 0);
layout->addWidget(networks = new QComboBox, 0, 1);
layout->addWidget(new QLabel(tr("Channel:")), 1, 0);
if (index.data(NetworkModel::ItemTypeRole) != NetworkModel::IrcUserItemType)
return;
- IrcUser *ircUser = qobject_cast<IrcUser *>(index.data(NetworkModel::IrcUserRole).value<QObject *>());
+ auto *ircUser = qobject_cast<IrcUser *>(index.data(NetworkModel::IrcUserRole).value<QObject *>());
NetworkId networkId = index.data(NetworkModel::NetworkIdRole).value<NetworkId>();
if (!ircUser || !networkId.isValid())
return;
if (obj != _lineEdit || event->type() != QEvent::KeyPress)
return QObject::eventFilter(obj, event);
- QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+ auto *keyEvent = static_cast<QKeyEvent *>(event);
if (keyEvent->key() == GraphicalUi::actionCollection("General")->action("TabCompletionKey")->shortcut()[0])
complete();
void ToolBarActionProvider::connectOrDisconnectNet()
{
- QAction *act = qobject_cast<QAction *>(sender());
+ auto *act = qobject_cast<QAction *>(sender());
if (!act)
return;
const Network *net = Client::network(act->data().value<NetworkId>());
}
else if (s[pos+1] == 'R') { // Reverse colors
fgChar = (fgChar == 'f' ? 'b' : 'f');
- quint32 orig = static_cast<quint32>(curfmt.type & 0xffc00000);
+ auto orig = static_cast<quint32>(curfmt.type & 0xffc00000);
curfmt.type &= 0x003fffff;
curfmt.type |= (orig & 0x00400000) <<1;
curfmt.type |= (orig & 0x0f000000) <<4;
QDataStream &operator<<(QDataStream &out, const UiStyle::FormatList &formatList)
{
out << static_cast<quint16>(formatList.size());
- UiStyle::FormatList::const_iterator it = formatList.begin();
- while (it != formatList.end()) {
+ auto it = formatList.cbegin();
+ while (it != formatList.cend()) {
out << it->first
<< static_cast<quint32>(it->second.type)
<< it->second.foreground