Commit 8572347b authored by Ronan Abhamon's avatar Ronan Abhamon

feat(App): remove reference on `const var &foo = expr`

parent 64b45e2d
......@@ -524,7 +524,7 @@ void App::openAppAfterInit () {
// Execute command argument if needed.
{
const QString &commandArgument = getCommandArgument();
const QString commandArgument = getCommandArgument();
if (!commandArgument.isEmpty())
executeCommand(commandArgument);
}
......
......@@ -89,7 +89,7 @@ void Cli::addCommand (const QString &functionName, const QString &description, F
// -----------------------------------------------------------------------------
void Cli::executeCommand (const QString &command) noexcept {
const QString &functionName = parseFunctionName(command);
const QString functionName = parseFunctionName(command);
if (functionName.isEmpty())
return;
......@@ -106,7 +106,7 @@ void Cli::executeCommand (const QString &command) noexcept {
const QString Cli::parseFunctionName (const QString &command) noexcept {
mRegExpFunctionName.indexIn(command);
const QStringList &texts = mRegExpFunctionName.capturedTexts();
const QStringList texts = mRegExpFunctionName.capturedTexts();
if (texts.size() < 2) {
qWarning() << QStringLiteral("Unable to parse function name of command: `%1`.").arg(command);
return QString("");
......
......@@ -176,7 +176,7 @@ string Paths::getCapturesDirPath () {
}
string Paths::getConfigFilePath (const QString &configPath, bool writable) {
const QString &path = configPath.isEmpty()
const QString path = configPath.isEmpty()
? ::getAppConfigFilePath()
: QFileInfo(configPath).absoluteFilePath();
......
......@@ -188,7 +188,7 @@ bool AssistantModel::addOtherSipAccount (const QVariantMap &map) {
shared_ptr<linphone::Core> core = coreManager->getCore();
shared_ptr<linphone::ProxyConfig> proxyConfig = core->createProxyConfig();
const QString &domain = map["sipDomain"].toString();
const QString domain = map["sipDomain"].toString();
QString sipAddress = QStringLiteral("sip:%1@%2")
.arg(map["username"].toString()).arg(domain);
......
......@@ -31,17 +31,15 @@ using namespace std;
CallsListProxyModel::CallsListProxyModel (QObject *parent) : QSortFilterProxyModel(parent) {
CallsListModel *callsListModel = CoreManager::getInstance()->getCallsListModel();
QObject::connect(
callsListModel, &CallsListModel::callRunning, this, [this](int index, CallModel *callModel) {
QObject::connect(callsListModel, &CallsListModel::callRunning, this, [this](int index, CallModel *callModel) {
emit callRunning(index, callModel);
}
);
});
setSourceModel(callsListModel);
sort(0);
}
bool CallsListProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const {
const QModelIndex &index = sourceModel()->index(sourceRow, 0, sourceParent);
const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
return !index.data().value<CallModel *>()->isInConference();
}
......@@ -58,7 +58,7 @@ inline QString getDownloadPath (const shared_ptr<linphone::ChatMessage> &message
}
inline bool fileWasDownloaded (const shared_ptr<linphone::ChatMessage> &message) {
const QString &path = ::getDownloadPath(message);
const QString path = ::getDownloadPath(message);
return !path.isEmpty() && QFileInfo(path).isFile();
}
......@@ -354,8 +354,8 @@ void ChatModel::resendMessage (int id) {
return;
}
const ChatEntryData &entry = mEntries[id];
const QVariantMap &map = entry.first;
const ChatEntryData entry = mEntries[id];
const QVariantMap map = entry.first;
if (map["type"] != EntryType::MessageEntry) {
qWarning() << QStringLiteral("Unable to resend entry %1. It's not a message.").arg(id);
......@@ -413,7 +413,7 @@ void ChatModel::sendFileMessage (const QString &path) {
// -----------------------------------------------------------------------------
void ChatModel::downloadFile (int id) {
const ChatEntryData &entry = getFileMessageEntry(id);
const ChatEntryData entry = getFileMessageEntry(id);
if (!entry.second)
return;
......@@ -432,7 +432,7 @@ void ChatModel::downloadFile (int id) {
}
bool soFarSoGood;
const QString &safeFilePath = ::Utils::getSafeFilePath(
const QString safeFilePath = ::Utils::getSafeFilePath(
QStringLiteral("%1%2")
.arg(CoreManager::getInstance()->getSettingsModel()->getDownloadFolder())
.arg(entry.first["fileName"].toString()),
......@@ -452,7 +452,7 @@ void ChatModel::downloadFile (int id) {
}
void ChatModel::openFile (int id, bool showDirectory) {
const ChatEntryData &entry = getFileMessageEntry(id);
const ChatEntryData entry = getFileMessageEntry(id);
if (!entry.second)
return;
......@@ -469,7 +469,7 @@ void ChatModel::openFile (int id, bool showDirectory) {
}
bool ChatModel::fileWasDownloaded (int id) {
const ChatEntryData &entry = getFileMessageEntry(id);
const ChatEntryData entry = getFileMessageEntry(id);
return entry.second && ::fileWasDownloaded(static_pointer_cast<linphone::ChatMessage>(entry.second));
}
......@@ -484,7 +484,7 @@ const ChatModel::ChatEntryData ChatModel::getFileMessageEntry (int id) {
return ChatEntryData();
}
const ChatEntryData &entry = mEntries[id];
const ChatEntryData entry = mEntries[id];
if (entry.first["type"] != EntryType::MessageEntry) {
qWarning() << QStringLiteral("Unable to download entry %1. It's not a message.").arg(id);
return ChatEntryData();
......
......@@ -48,7 +48,7 @@ protected:
return true;
QModelIndex index = sourceModel()->index(sourceRow, 0, QModelIndex());
const QVariantMap &data = index.data().toMap();
const QVariantMap data = index.data().toMap();
return data["type"].toInt() == mEntryTypeFilter;
}
......
......@@ -71,7 +71,7 @@ QVariant ConferenceHelperModel::ConferenceAddModel::data (const QModelIndex &ind
// -----------------------------------------------------------------------------
bool ConferenceHelperModel::ConferenceAddModel::addToConference (const shared_ptr<const linphone::Address> &linphoneAddress) {
const QString &sipAddress = ::Utils::coreStringToAppString(linphoneAddress->asStringUriOnly());
const QString sipAddress = ::Utils::coreStringToAppString(linphoneAddress->asStringUriOnly());
if (mSipAddresses.contains(sipAddress))
return false;
......@@ -145,7 +145,7 @@ void ConferenceHelperModel::ConferenceAddModel::update () {
if (!call->getParams()->getLocalConferenceMode())
continue;
const QString &sipAddress = ::Utils::coreStringToAppString(call->getRemoteAddress()->asStringUriOnly());
const QString sipAddress = ::Utils::coreStringToAppString(call->getRemoteAddress()->asStringUriOnly());
if (!mSipAddresses.contains(sipAddress))
call->terminate();
}
......@@ -180,7 +180,7 @@ void ConferenceHelperModel::ConferenceAddModel::handleDataChanged (
int limit = bottomRight.row();
for (int row = topLeft.row(); row <= limit; ++row) {
const QVariantMap &map = sipAddressesModel->data(sipAddressesModel->index(row, 0)).toMap();
const QVariantMap map = sipAddressesModel->data(sipAddressesModel->index(row, 0)).toMap();
auto it = mSipAddresses.find(map["sipAddress"].toString());
if (it != mSipAddresses.end()) {
......
......@@ -67,8 +67,8 @@ void ConferenceHelperModel::setFilter (const QString &pattern) {
// -----------------------------------------------------------------------------
bool ConferenceHelperModel::filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const {
const QModelIndex &index = sourceModel()->index(sourceRow, 0, sourceParent);
const QVariantMap &data = index.data().toMap();
const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
const QVariantMap data = index.data().toMap();
return !mConferenceAddModel->contains(data["sipAddress"].toString());
}
......
......@@ -45,12 +45,11 @@ ConferenceModel::ConferenceModel (QObject *parent) : QSortFilterProxyModel(paren
QObject::connect(
CoreManager::getInstance()->getHandlers().get(), &CoreHandlers::callStateChanged,
this, [this] { emit conferenceChanged(); }
);
this, [this] { emit conferenceChanged(); });
}
bool ConferenceModel::filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const {
const QModelIndex &index = sourceModel()->index(sourceRow, 0, sourceParent);
const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
const CallModel *callModel = index.data().value<CallModel *>();
return callModel->getCall()->getParams()->getLocalConferenceMode();
......
......@@ -108,7 +108,7 @@ void ContactModel::updateSipAddresses (VcardModel *oldVcardModel) {
for (const auto &variantA : oldSipAddresses) {
next:
const QString &sipAddress = variantA.toString();
const QString sipAddress = variantA.toString();
if (done.contains(sipAddress))
continue;
done.insert(sipAddress);
......@@ -125,7 +125,7 @@ next:
oldSipAddresses.clear();
for (const auto &variant : sipAddresses) {
const QString &sipAddress = variant.toString();
const QString sipAddress = variant.toString();
if (done.contains(sipAddress))
continue;
done.insert(sipAddress);
......@@ -159,7 +159,7 @@ void ContactModel::mergeVcardModel (VcardModel *vcardModel) {
// 3. Merge address.
{
const QVariantMap &oldAddress = vcardModel->getAddress();
const QVariantMap oldAddress = vcardModel->getAddress();
QVariantMap newAddress = vcardModel->getAddress();
static const char *attributes[4] = { "street", "locality", "postalCode", "country" };
......
......@@ -73,7 +73,7 @@ bool ContactsListProxyModel::filterAcceptsRow (
int sourceRow,
const QModelIndex &sourceParent
) const {
const QModelIndex &index = sourceModel()->index(sourceRow, 0, sourceParent);
const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
const ContactModel *contact = index.data().value<ContactModel *>();
mWeights[contact] = static_cast<unsigned int>(round(computeContactWeight(contact)));
......
......@@ -188,7 +188,7 @@ void AccountSettingsModel::eraseAllPasswords () {
QString AccountSettingsModel::getUsername () const {
shared_ptr<const linphone::Address> address = getUsedSipAddress();
const string &displayName = address->getDisplayName();
const string displayName = address->getDisplayName();
return ::Utils::coreStringToAppString(
displayName.empty() ? address->getUsername() : displayName
......
......@@ -589,7 +589,7 @@ void SettingsModel::setTurnPassword (const QString &password) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::NatPolicy> natPolicy = core->getNatPolicy();
const string &username = natPolicy->getStunServerUsername();
const string username = natPolicy->getStunServerUsername();
shared_ptr<const linphone::AuthInfo> authInfo = core->findAuthInfo(username, "", "");
if (authInfo) {
......
......@@ -130,7 +130,7 @@ SipAddressObserver *SipAddressesModel::getSipAddressObserver (const QString &sip
mObservers.insert(sipAddress, model);
QObject::connect(
model, &SipAddressObserver::destroyed, this, [this, model]() {
const QString &sipAddress = model->getSipAddress();
const QString sipAddress = model->getSipAddress();
if (mObservers.remove(sipAddress, model) == 0)
qWarning() << QStringLiteral("Unable to remove sip address `%1` from observers.").arg(sipAddress);
});
......@@ -255,7 +255,7 @@ void SipAddressesModel::handleSipAddressRemoved (ContactModel *contact, const QS
}
void SipAddressesModel::handleMessageReceived (const shared_ptr<linphone::ChatMessage> &message) {
const QString &sipAddress = ::Utils::coreStringToAppString(message->getFromAddress()->asStringUriOnly());
const QString sipAddress = ::Utils::coreStringToAppString(message->getFromAddress()->asStringUriOnly());
addOrUpdateSipAddress(sipAddress, message);
}
......@@ -459,7 +459,7 @@ void SipAddressesModel::initSipAddresses () {
// Get sip addresses from calls.
QSet<QString> addressDone;
for (const auto &callLog : core->getCallLogs()) {
const QString &sipAddress = ::Utils::coreStringToAppString(callLog->getRemoteAddress()->asStringUriOnly());
const QString sipAddress = ::Utils::coreStringToAppString(callLog->getRemoteAddress()->asStringUriOnly());
if (addressDone.contains(sipAddress))
continue; // Already used.
......
......@@ -51,16 +51,16 @@ void SipAddressesProxyModel::setFilter (const QString &pattern) {
// -----------------------------------------------------------------------------
bool SipAddressesProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const {
const QModelIndex &index = sourceModel()->index(sourceRow, 0, sourceParent);
const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
return computeEntryWeight(index.data().toMap()) > 0;
}
bool SipAddressesProxyModel::lessThan (const QModelIndex &left, const QModelIndex &right) const {
const QVariantMap &mapA = sourceModel()->data(left).toMap();
const QVariantMap &mapB = sourceModel()->data(right).toMap();
const QVariantMap mapA = sourceModel()->data(left).toMap();
const QVariantMap mapB = sourceModel()->data(right).toMap();
const QString &sipAddressA = mapA["sipAddress"].toString();
const QString &sipAddressB = mapB["sipAddress"].toString();
const QString sipAddressA = mapA["sipAddress"].toString();
const QString sipAddressB = mapB["sipAddress"].toString();
// TODO: Use a cache, do not compute the same value as `filterAcceptsRow`.
int weightA = computeEntryWeight(mapA);
......
......@@ -42,7 +42,7 @@ QHash<int, QByteArray> TimelineModel::roleNames () const {
// -----------------------------------------------------------------------------
bool TimelineModel::filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const {
const QModelIndex &index = sourceModel()->index(sourceRow, 0, sourceParent);
const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
return index.data().toMap().contains("timestamp");
}
......
......@@ -53,8 +53,8 @@ QString Utils::getSafeFilePath (const QString &filePath, bool *soFarSoGood) {
if (!info.exists())
return filePath;
const QString &prefix = QStringLiteral("%1/%2").arg(info.absolutePath()).arg(info.baseName());
const QString &ext = info.completeSuffix();
const QString prefix = QStringLiteral("%1/%2").arg(info.absolutePath()).arg(info.baseName());
const QString ext = info.completeSuffix();
for (int i = 1; i < SAFE_FILE_PATH_LIMIT; ++i) {
QString safePath = QStringLiteral("%1 (%3).%4").arg(prefix).arg(i).arg(ext);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment