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