Refactoring of signal/slots connection to new qt syntax

This commit is contained in:
Blue 2019-11-03 21:46:40 +03:00
parent 9d491e9e93
commit 0b57e6a77f
16 changed files with 81 additions and 83 deletions

View File

@ -30,15 +30,15 @@ Core::Conference::Conference(const QString& p_jid, const QString& p_account, boo
muc = true;
name = p_name;
connect(room, SIGNAL(joined()), this, SLOT(onRoomJoined()));
connect(room, SIGNAL(left()), this, SLOT(onRoomLeft()));
connect(room, SIGNAL(nameChanged(const QString&)), this, SLOT(onRoomNameChanged(const QString&)));
connect(room, SIGNAL(subjectChanged(const QString&)), this, SLOT(onRoomSubjectChanged(const QString&)));
connect(room, SIGNAL(participantAdded(const QString&)), this, SLOT(onRoomParticipantAdded(const QString&)));
connect(room, SIGNAL(participantChanged(const QString&)), this, SLOT(onRoomParticipantChanged(const QString&)));
connect(room, SIGNAL(participantRemoved(const QString&)), this, SLOT(onRoomParticipantRemoved(const QString&)));
connect(room, SIGNAL(nickNameChanged(const QString&)), this, SLOT(onRoomNickNameChanged(const QString&)));
connect(room, SIGNAL(error(const QXmppStanza::Error&)), this, SLOT(onRoomError(const QXmppStanza::Error&)));
connect(room, &QXmppMucRoom::joined, this, &Conference::onRoomJoined);
connect(room, &QXmppMucRoom::left, this, &Conference::onRoomLeft);
connect(room, &QXmppMucRoom::nameChanged, this, &Conference::onRoomNameChanged);
connect(room, &QXmppMucRoom::subjectChanged, this, &Conference::onRoomSubjectChanged);
connect(room, &QXmppMucRoom::participantAdded, this, &Conference::onRoomParticipantAdded);
connect(room, &QXmppMucRoom::participantChanged, this, &Conference::onRoomParticipantChanged);
connect(room, &QXmppMucRoom::participantRemoved, this, &Conference::onRoomParticipantRemoved);
connect(room, &QXmppMucRoom::nickNameChanged, this, &Conference::onRoomNickNameChanged);
connect(room, &QXmppMucRoom::error, this, &Conference::onRoomError);
room->setNickName(nick);
if (autoJoin) {

View File

@ -323,9 +323,9 @@ void Core::NetworkAccess::startDownload(const QString& messageId, const QString&
Download* dwn = new Download({{messageId}, 0, 0, true});
QNetworkRequest req(url);
dwn->reply = manager->get(req);
connect(dwn->reply, SIGNAL(downloadProgress(qint64, qint64)), SLOT(onDownloadProgress(qint64, qint64)));
connect(dwn->reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(onRequestError(QNetworkReply::NetworkError)));
connect(dwn->reply, SIGNAL(finished()), SLOT(onRequestFinished()));
connect(dwn->reply, &QNetworkReply::downloadProgress, this, &NetworkAccess::onDownloadProgress);
connect(dwn->reply, qOverload<QNetworkReply::NetworkError>(&QNetworkReply::error), this, &NetworkAccess::onRequestError);
connect(dwn->reply, &QNetworkReply::finished, this, &NetworkAccess::onRequestFinished);
downloads.insert(std::make_pair(url, dwn));
emit downloadFileProgress(messageId, 0);
}

View File

@ -38,7 +38,7 @@ SignalCatcher::SignalCatcher(QCoreApplication *p_app, QObject *parent):
}
snInt = new QSocketNotifier(sigintFd[1], QSocketNotifier::Read, this);
connect(snInt, SIGNAL(activated(int)), this, SLOT(handleSigInt()));
connect(snInt, &QSocketNotifier::activated, this, &SignalCatcher::handleSigInt);
}
SignalCatcher::~SignalCatcher()

View File

@ -89,7 +89,7 @@ void Models::Accounts::addAccount(Account* account)
}
accs.insert(before, account);
connect(account, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onAccountChanged(Models::Item*, int, int)));
connect(account, &Account::childChanged, this, &Accounts::onAccountChanged);
endInsertRows();
emit sizeChanged(accs.size());
@ -143,7 +143,7 @@ void Models::Accounts::removeAccount(int index)
{
Account* account = accs[index];
beginRemoveRows(QModelIndex(), index, index);
disconnect(account, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onAccountChanged(Models::Item*, int, int)));
disconnect(account, &Account::childChanged, this, &Accounts::onAccountChanged);
accs.erase(accs.begin() + index);
endRemoveRows();

View File

@ -229,7 +229,7 @@ void Models::Contact::refresh()
void Models::Contact::_removeChild(int index)
{
Item* child = childItems[index];
disconnect(child, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh()));
disconnect(child, &Item::childChanged, this, &Contact::refresh);
Item::_removeChild(index);
refresh();
}
@ -237,7 +237,7 @@ void Models::Contact::_removeChild(int index)
void Models::Contact::appendChild(Models::Item* child)
{
Item::appendChild(child);
connect(child, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh()));
connect(child, &Item::childChanged, this, &Contact::refresh);
refresh();
}
@ -324,7 +324,7 @@ void Models::Contact::toOfflineState()
emit childIsAboutToBeRemoved(this, 0, childItems.size());
for (int i = 0; i < childItems.size(); ++i) {
Item* item = childItems[i];
disconnect(item, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh()));
disconnect(item, &Item::childChanged, this, &Contact::refresh);
Item::_removeChild(i);
item->deleteLater();
}
@ -363,7 +363,7 @@ Models::Contact::Contact(const Models::Contact& other):
Presence* pCopy = new Presence(*pres);
presences.insert(pCopy->getName(), pCopy);
Item::appendChild(pCopy);
connect(pCopy, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh()));
connect(pCopy, &Item::childChanged, this, &Contact::refresh);
}
refresh();

View File

@ -32,7 +32,7 @@ Models::Group::~Group()
void Models::Group::appendChild(Models::Item* child)
{
Item::appendChild(child);
connect(child, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh()));
connect(child, &Item::childChanged, this, &Group::refresh);
changed(1);
refresh();
}
@ -59,7 +59,7 @@ QVariant Models::Group::data(int column) const
void Models::Group::_removeChild(int index)
{
Item* child = childItems[index];
disconnect(child, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh()));
disconnect(child, &Item::childChanged, this, &Group::refresh);
Item::_removeChild(index);
changed(1);
refresh();

View File

@ -88,13 +88,13 @@ void Models::Item::appendChild(Models::Item* child)
childItems.insert(before, child);
child->parent = this;
QObject::connect(child, SIGNAL(childChanged(Models::Item*, int, int)), this, SIGNAL(childChanged(Models::Item*, int, int)));
QObject::connect(child, SIGNAL(childIsAboutToBeInserted(Item*, int, int)), this, SIGNAL(childIsAboutToBeInserted(Item*, int, int)));
QObject::connect(child, SIGNAL(childInserted()), this, SIGNAL(childInserted()));
QObject::connect(child, SIGNAL(childIsAboutToBeRemoved(Item*, int, int)), this, SIGNAL(childIsAboutToBeRemoved(Item*, int, int)));
QObject::connect(child, SIGNAL(childRemoved()), this, SIGNAL(childRemoved()));
QObject::connect(child, SIGNAL(childIsAboutToBeMoved(Item*, int, int, Item*, int)), this, SIGNAL(childIsAboutToBeMoved(Item*, int, int, Item*, int)));
QObject::connect(child, SIGNAL(childMoved()), this, SIGNAL(childMoved()));
QObject::connect(child, &Item::childChanged, this, &Item::childChanged);
QObject::connect(child, &Item::childIsAboutToBeInserted, this, &Item::childIsAboutToBeInserted);
QObject::connect(child, &Item::childInserted, this, &Item::childInserted);
QObject::connect(child, &Item::childIsAboutToBeRemoved, this, &Item::childIsAboutToBeRemoved);
QObject::connect(child, &Item::childRemoved, this, &Item::childRemoved);
QObject::connect(child, &Item::childIsAboutToBeMoved, this, &Item::childIsAboutToBeMoved);
QObject::connect(child, &Item::childMoved, this, &Item::childMoved);
if (moving) {
emit childMoved();
@ -168,13 +168,13 @@ void Models::Item::_removeChild(int index)
{
Item* child = childItems[index];
QObject::disconnect(child, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onChildChanged(Models::Item*, int, int)));
QObject::disconnect(child, SIGNAL(childIsAboutToBeInserted(Item*, int, int)), this, SIGNAL(childIsAboutToBeInserted(Item*, int, int)));
QObject::disconnect(child, SIGNAL(childInserted()), this, SIGNAL(childInserted()));
QObject::disconnect(child, SIGNAL(childIsAboutToBeRemoved(Item*, int, int)), this, SIGNAL(childIsAboutToBeRemoved(Item*, int, int)));
QObject::disconnect(child, SIGNAL(childRemoved()), this, SIGNAL(childRemoved()));
QObject::disconnect(child, SIGNAL(childIsAboutToBeMoved(Item*, int, int, Item*, int)), this, SIGNAL(childIsAboutToBeMoved(Item*, int, int, Item*, int)));
QObject::disconnect(child, SIGNAL(childMoved()), this, SIGNAL(childMoved()));
QObject::disconnect(child, &Item::childChanged, this, &Item::childChanged);
QObject::disconnect(child, &Item::childIsAboutToBeInserted, this, &Item::childIsAboutToBeInserted);
QObject::disconnect(child, &Item::childInserted, this, &Item::childInserted);
QObject::disconnect(child, &Item::childIsAboutToBeRemoved, this, &Item::childIsAboutToBeRemoved);
QObject::disconnect(child, &Item::childRemoved, this, &Item::childRemoved);
QObject::disconnect(child, &Item::childIsAboutToBeMoved, this, &Item::childIsAboutToBeMoved);
QObject::disconnect(child, &Item::childMoved, this, &Item::childMoved);
childItems.erase(childItems.begin() + index);
child->parent = 0;

View File

@ -238,7 +238,6 @@ void Models::Room::toOfflineState()
emit childIsAboutToBeRemoved(this, 0, childItems.size());
for (int i = 0; i < childItems.size(); ++i) {
Item* item = childItems[i];
disconnect(item, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh()));
Item::_removeChild(i);
item->deleteLater();
}

View File

@ -69,12 +69,12 @@ void Squawk::onAccounts()
if (accounts == 0) {
accounts = new Accounts(rosterModel.accountsModel, this);
accounts->setAttribute(Qt::WA_DeleteOnClose);
connect(accounts, SIGNAL(destroyed(QObject*)), this, SLOT(onAccountsClosed(QObject*)));
connect(accounts, SIGNAL(newAccount(const QMap<QString, QVariant>&)), this, SIGNAL(newAccountRequest(const QMap<QString, QVariant>&)));
connect(accounts, SIGNAL(changeAccount(const QString&, const QMap<QString, QVariant>&)), this, SIGNAL(modifyAccountRequest(const QString&, const QMap<QString, QVariant>&)));
connect(accounts, SIGNAL(connectAccount(const QString&)), this, SIGNAL(connectAccount(const QString&)));
connect(accounts, SIGNAL(disconnectAccount(const QString&)), this, SIGNAL(disconnectAccount(const QString&)));
connect(accounts, SIGNAL(removeAccount(const QString&)), this, SIGNAL(removeAccountRequest(const QString&)));
connect(accounts, &Accounts::destroyed, this, &Squawk::onAccountsClosed);
connect(accounts, &Accounts::newAccount, this, &Squawk::newAccountRequest);
connect(accounts, &Accounts::changeAccount, this, &Squawk::modifyAccountRequest);
connect(accounts, &Accounts::connectAccount, this, &Squawk::connectAccount);
connect(accounts, &Accounts::disconnectAccount, this, &Squawk::disconnectAccount);
connect(accounts, &Accounts::removeAccount, this, &Squawk::removeAccountRequest);
accounts->show();
} else {
@ -99,8 +99,8 @@ void Squawk::onNewContact()
{
NewContact* nc = new NewContact(rosterModel.accountsModel, this);
connect(nc, SIGNAL(accepted()), this, SLOT(onNewContactAccepted()));
connect(nc, SIGNAL(rejected()), nc, SLOT(deleteLater()));
connect(nc, &NewContact::accepted, this, &Squawk::onNewContactAccepted);
connect(nc, &NewContact::rejected, nc, &NewContact::deleteLater);
nc->exec();
}
@ -109,8 +109,8 @@ void Squawk::onNewConference()
{
JoinConference* jc = new JoinConference(rosterModel.accountsModel, this);
connect(jc, SIGNAL(accepted()), this, SLOT(onJoinConferenceAccepted()));
connect(jc, SIGNAL(rejected()), jc, SLOT(deleteLater()));
connect(jc, &JoinConference::accepted, this, &Squawk::onJoinConferenceAccepted);
connect(jc, &JoinConference::rejected, jc, &JoinConference::deleteLater);
jc->exec();
}
@ -299,12 +299,12 @@ void Squawk::onRosterItemDoubleClicked(const QModelIndex& item)
if (created) {
conv->setAttribute(Qt::WA_DeleteOnClose);
connect(conv, SIGNAL(destroyed(QObject*)), this, SLOT(onConversationClosed(QObject*)));
connect(conv, SIGNAL(sendMessage(const Shared::Message&)), this, SLOT(onConversationMessage(const Shared::Message&)));
connect(conv, SIGNAL(requestArchive(const QString&)), this, SLOT(onConversationRequestArchive(const QString&)));
connect(conv, SIGNAL(requestLocalFile(const QString&, const QString&)), this, SLOT(onConversationRequestLocalFile(const QString&, const QString&)));
connect(conv, SIGNAL(downloadFile(const QString&, const QString&)), this, SLOT(onConversationDownloadFile(const QString&, const QString&)));
connect(conv, SIGNAL(shown()), this, SLOT(onConversationShown()));
connect(conv, &Conversation::destroyed, this, &Squawk::onConversationClosed);
connect(conv, &Conversation::sendMessage, this, &Squawk::onConversationMessage);
connect(conv, &Conversation::requestArchive, this, &Squawk::onConversationRequestArchive);
connect(conv, &Conversation::requestLocalFile, this, &Squawk::onConversationRequestLocalFile);
connect(conv, &Conversation::downloadFile, this, &Squawk::onConversationDownloadFile);
connect(conv, &Conversation::shown, this, &Squawk::onConversationShown);
conversations.insert(std::make_pair(*id, conv));
@ -517,10 +517,10 @@ void Squawk::removeAccount(const QString& account)
Conversations::const_iterator lItr = itr;
++itr;
Conversation* conv = lItr->second;
disconnect(conv, SIGNAL(destroyed(QObject*)), this, SLOT(onConversationClosed(QObject*)));
disconnect(conv, SIGNAL(sendMessage(const Shared::Message&)), this, SLOT(onConversationMessage(const Shared::Message&)));
disconnect(conv, SIGNAL(requestArchive(const QString&)), this, SLOT(onConversationRequestArchive(const QString&)));
disconnect(conv, SIGNAL(shown()), this, SLOT(onConversationShown()));
disconnect(conv, &Conversation::destroyed, this, &Squawk::onConversationClosed);
disconnect(conv, &Conversation::sendMessage, this, &Squawk::onConversationMessage);
disconnect(conv, &Conversation::requestArchive, this, &Squawk::onConversationRequestArchive);
disconnect(conv, &Conversation::shown, this, &Squawk::onConversationShown);
conv->close();
conversations.erase(lItr);
} else {

View File

@ -42,7 +42,7 @@ Badge::Badge(const QString& p_id, const QString& p_text, const QIcon& icon, QWid
layout->setContentsMargins(2, 2, 2, 2);
connect(closeButton, SIGNAL(clicked()), this, SIGNAL(close()));
connect(closeButton, &QPushButton::clicked, this, &Badge::close);
}
Badge::~Badge()

View File

@ -125,7 +125,7 @@ void Message::addDownloadDialog()
fileComment->setText(tr("%1 is offering you to download a file").arg(sender->text()));
}
fileComment->show();
connect(downloadButton, SIGNAL(clicked()), this, SLOT(onDownload()));
connect(downloadButton, &QPushButton::clicked, this, &Message::onDownload);
bodyLayout->insertWidget(2, fileComment);
bodyLayout->insertWidget(3, downloadButton);
hasDownloadButton = true;

View File

@ -127,7 +127,7 @@ MessageLine::Position MessageLine::message(const Shared::Message& msg)
if (msg.hasOutOfBandUrl()) {\
emit requestLocalFile(msg.getId(), msg.getOutOfBandUrl());
connect(message, SIGNAL(downloadFile(const QString&, const QString&)), this, SIGNAL(downloadFile(const QString&, const QString&)));
connect(message, &Message::downloadFile, this, &MessageLine::downloadFile);
}
return res;

View File

@ -29,14 +29,13 @@ Accounts::Accounts(Models::Accounts* p_model, QWidget *parent) :
{
m_ui->setupUi(this);
connect(m_ui->addButton, SIGNAL(clicked(bool)), this, SLOT(onAddButton(bool)));
connect(m_ui->editButton, SIGNAL(clicked(bool)), this, SLOT(onEditButton(bool)));
connect(m_ui->connectButton, SIGNAL(clicked(bool)), this, SLOT(onConnectButton(bool)));
connect(m_ui->deleteButton, SIGNAL(clicked(bool)), this, SLOT(onDeleteButton(bool)));
connect(m_ui->addButton, &QPushButton::clicked, this, &Accounts::onAddButton);
connect(m_ui->editButton, &QPushButton::clicked, this, &Accounts::onEditButton);
connect(m_ui->connectButton, &QPushButton::clicked, this, &Accounts::onConnectButton);
connect(m_ui->deleteButton, &QPushButton::clicked, this, &Accounts::onDeleteButton);
m_ui->tableView->setModel(model);
connect(m_ui->tableView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&)));
connect(p_model, SIGNAL(changed()), this, SLOT(updateConnectButton()));
connect(m_ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &Accounts::onSelectionChanged);
connect(p_model, &Models::Accounts::changed, this, &Accounts::updateConnectButton);
}
Accounts::~Accounts() = default;
@ -44,8 +43,8 @@ Accounts::~Accounts() = default;
void Accounts::onAddButton(bool clicked)
{
Account* acc = new Account();
connect(acc, SIGNAL(accepted()), this, SLOT(onAccountAccepted()));
connect(acc, SIGNAL(rejected()), this, SLOT(onAccountRejected()));
connect(acc, &Account::accepted, this, &Accounts::onAccountAccepted);
connect(acc, &Account::rejected, this, &Accounts::onAccountRejected);
acc->exec();
}
@ -84,8 +83,8 @@ void Accounts::onEditButton(bool clicked)
{"resource", mAcc->getResource()}
});
acc->lockId();
connect(acc, SIGNAL(accepted()), this, SLOT(onAccountAccepted()));
connect(acc, SIGNAL(rejected()), this, SLOT(onAccountRejected()));
connect(acc, &Account::accepted, this, &Accounts::onAccountAccepted);
connect(acc, &Account::rejected, this, &Accounts::onAccountRejected);
editing = true;
acc->exec();
}

View File

@ -26,7 +26,7 @@ Chat::Chat(Models::Contact* p_contact, QWidget* parent):
updateState();
setStatus(p_contact->getStatus());
connect(contact, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onContactChanged(Models::Item*, int, int)));
connect(contact, &Models::Contact::childChanged, this, &Chat::onContactChanged);
line->setMyName(p_contact->getAccountName());
}

View File

@ -59,15 +59,15 @@ Conversation::Conversation(bool muc, const QString& mJid, const QString mRes, co
statusIcon = m_ui->statusIcon;
statusLabel = m_ui->statusLabel;
connect(&ker, SIGNAL(enterPressed()), this, SLOT(onEnterPressed()));
connect(&res, SIGNAL(resized()), this, SLOT(onScrollResize()));
connect(&vis, SIGNAL(shown()), this, SLOT(onScrollResize()));
connect(&vis, SIGNAL(hidden()), this, SLOT(onScrollResize()));
connect(m_ui->sendButton, SIGNAL(clicked(bool)), this, SLOT(onEnterPressed()));
connect(line, SIGNAL(resize(int)), this, SLOT(onMessagesResize(int)));
connect(line, SIGNAL(downloadFile(const QString&, const QString&)), this, SIGNAL(downloadFile(const QString&, const QString&)));
connect(line, SIGNAL(requestLocalFile(const QString&, const QString&)), this, SIGNAL(requestLocalFile(const QString&, const QString&)));
connect(m_ui->attachButton, SIGNAL(clicked(bool)), this, SLOT(onAttach()));
connect(&ker, &KeyEnterReceiver::enterPressed, this, &Conversation::onEnterPressed);
connect(&res, &Resizer::resized, this, &Conversation::onScrollResize);
connect(&vis, &VisibilityCatcher::shown, this, &Conversation::onScrollResize);
connect(&vis, &VisibilityCatcher::hidden, this, &Conversation::onScrollResize);
connect(m_ui->sendButton, &QPushButton::clicked, this, &Conversation::onEnterPressed);
connect(line, &MessageLine::resize, this, &Conversation::onMessagesResize);
connect(line, &MessageLine::downloadFile, this, &Conversation::downloadFile);
connect(line, &MessageLine::requestLocalFile, this, &Conversation::requestLocalFile);
connect(m_ui->attachButton, &QPushButton::clicked, this, &Conversation::onAttach);
m_ui->messageEditor->installEventFilter(&ker);
@ -76,7 +76,7 @@ Conversation::Conversation(bool muc, const QString& mJid, const QString mRes, co
vs->installEventFilter(&vis);
vs->setBackgroundRole(QPalette::Base);
vs->setAutoFillBackground(true);
connect(vs, SIGNAL(valueChanged(int)), this, SLOT(onSliderValueChanged(int)));
connect(vs, &QScrollBar::valueChanged, this, &Conversation::onSliderValueChanged);
m_ui->scrollArea->installEventFilter(&res);
applyVisualEffects();
@ -317,7 +317,7 @@ void Conversation::addAttachedFile(const QString& path)
Badge* badge = new Badge(path, info.fileName(), QIcon::fromTheme(type.iconName()));
connect(badge, SIGNAL(close()), this, SLOT(onBadgeClose()));
connect(badge, &Badge::close, this, &Conversation::onBadgeClose);
filesToAttach.push_back(badge); //TODO neet to check if there are any duplicated ids
filesLayout->addWidget(badge);
if (filesLayout->count() == 1) {

View File

@ -26,7 +26,7 @@ Room::Room(Models::Room* p_room, QWidget* parent):
line->setMyName(room->getNick());
setStatus(room->getSubject());
connect(room, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onRoomChanged(Models::Item*, int, int)));
connect(room, &Models::Room::childChanged, this, &Room::onRoomChanged);
}
Room::~Room()