diff --git a/src/accountadapter.cpp b/src/accountadapter.cpp index 7305d7516b910958198560a59bfd1a8fdeeeb1cd..23f141b0f47099a96f13c6944026ca1d9cbaff58 100644 --- a/src/accountadapter.cpp +++ b/src/accountadapter.cpp @@ -97,7 +97,7 @@ AccountAdapter::createJamiAccount(QString registeredName, if (!registeredName.isEmpty()) { Utils::oneShotConnect(&LRCInstance::accountModel(), &lrc::api::NewAccountModel::nameRegistrationEnded, - [this, showBackup](const QString &accountId) { + [this, showBackup](const QString& accountId) { emit LRCInstance::instance().accountListChanged(); emit accountAdded(showBackup, LRCInstance::accountModel() diff --git a/src/accountlistmodel.cpp b/src/accountlistmodel.cpp index 4d61e43d9af73dacb64d49c97e1e94aa282285aa..389037a666a0533c83d4cfa653bd0f96520242a1 100644 --- a/src/accountlistmodel.cpp +++ b/src/accountlistmodel.cpp @@ -27,14 +27,14 @@ #include "pixbufmanipulator.h" #include "utils.h" -AccountListModel::AccountListModel(QObject *parent) +AccountListModel::AccountListModel(QObject* parent) : QAbstractListModel(parent) {} AccountListModel::~AccountListModel() {} int -AccountListModel::rowCount(const QModelIndex &parent) const +AccountListModel::rowCount(const QModelIndex& parent) const { if (!parent.isValid()) { /* @@ -49,7 +49,7 @@ AccountListModel::rowCount(const QModelIndex &parent) const } int -AccountListModel::columnCount(const QModelIndex &parent) const +AccountListModel::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent); /* @@ -59,14 +59,14 @@ AccountListModel::columnCount(const QModelIndex &parent) const } QVariant -AccountListModel::data(const QModelIndex &index, int role) const +AccountListModel::data(const QModelIndex& index, int role) const { auto accountList = LRCInstance::accountModel().getAccountList(); if (!index.isValid() || accountList.size() <= index.row()) { return QVariant(); } - auto &accountInfo = LRCInstance::accountModel().getAccountInfo(accountList.at(index.row())); + auto& accountInfo = LRCInstance::accountModel().getAccountInfo(accountList.at(index.row())); switch (role) { case Role::Alias: @@ -74,8 +74,7 @@ AccountListModel::data(const QModelIndex &index, int role) const case Role::Username: return QVariant(Utils::secondBestNameForAccount(accountInfo)); case Role::Type: - return QVariant( - static_cast<int>(accountInfo.profileInfo.type)); + return QVariant(static_cast<int>(accountInfo.profileInfo.type)); case Role::Status: return QVariant(static_cast<int>(accountInfo.status)); case Role::Picture: @@ -101,7 +100,7 @@ AccountListModel::roleNames() const } QModelIndex -AccountListModel::index(int row, int column, const QModelIndex &parent) const +AccountListModel::index(int row, int column, const QModelIndex& parent) const { Q_UNUSED(parent); if (column != 0) { @@ -115,14 +114,14 @@ AccountListModel::index(int row, int column, const QModelIndex &parent) const } QModelIndex -AccountListModel::parent(const QModelIndex &child) const +AccountListModel::parent(const QModelIndex& child) const { Q_UNUSED(child); return QModelIndex(); } Qt::ItemFlags -AccountListModel::flags(const QModelIndex &index) const +AccountListModel::flags(const QModelIndex& index) const { auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable; if (!index.isValid()) { diff --git a/src/accountlistmodel.h b/src/accountlistmodel.h index 134a31e2088afca960e4f298328c82537dcf1dac..976d116e3053b46be56f8972ee95041397918e65 100644 --- a/src/accountlistmodel.h +++ b/src/accountlistmodel.h @@ -32,22 +32,22 @@ class AccountListModel : public QAbstractListModel public: enum Role { Alias = Qt::UserRole + 1, Username, Picture, Type, Status, ID }; - explicit AccountListModel(QObject *parent = 0); + explicit AccountListModel(QObject* parent = 0); ~AccountListModel(); /* * QAbstractListModel override. */ - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex& parent) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; /* * Override role name as access point in qml. */ QHash<int, QByteArray> roleNames() const override; - QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; - Qt::ItemFlags flags(const QModelIndex &index) const; + QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex& child) const; + Qt::ItemFlags flags(const QModelIndex& index) const; /* * This function is to reset the model when there's new account added. diff --git a/src/accountstomigratelistmodel.cpp b/src/accountstomigratelistmodel.cpp index 8123eec1052e4dac29ef875fe87e7cc32127bbb2..98fd1a99cf2294f45df788b10075dedcec50234c 100644 --- a/src/accountstomigratelistmodel.cpp +++ b/src/accountstomigratelistmodel.cpp @@ -18,14 +18,14 @@ #include "accountstomigratelistmodel.h" -AccountsToMigrateListModel::AccountsToMigrateListModel(QObject *parent) +AccountsToMigrateListModel::AccountsToMigrateListModel(QObject* parent) : QAbstractListModel(parent) {} AccountsToMigrateListModel::~AccountsToMigrateListModel() {} int -AccountsToMigrateListModel::rowCount(const QModelIndex &parent) const +AccountsToMigrateListModel::rowCount(const QModelIndex& parent) const { if (!parent.isValid()) { /* @@ -35,7 +35,7 @@ AccountsToMigrateListModel::rowCount(const QModelIndex &parent) const int countAccountToMigrate = 0; - for (const QString &i : accountList) { + for (const QString& i : accountList) { auto accountStatus = LRCInstance::accountModel().getAccountInfo(i).status; if (accountStatus == lrc::api::account::Status::ERROR_NEED_MIGRATION) { countAccountToMigrate++; @@ -51,7 +51,7 @@ AccountsToMigrateListModel::rowCount(const QModelIndex &parent) const } int -AccountsToMigrateListModel::columnCount(const QModelIndex &parent) const +AccountsToMigrateListModel::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent); /* @@ -61,7 +61,7 @@ AccountsToMigrateListModel::columnCount(const QModelIndex &parent) const } QVariant -AccountsToMigrateListModel::data(const QModelIndex &index, int role) const +AccountsToMigrateListModel::data(const QModelIndex& index, int role) const { auto accountList = LRCInstance::accountModel().getAccountList(); if (!index.isValid() || accountList.size() <= index.row()) { @@ -79,7 +79,7 @@ AccountsToMigrateListModel::data(const QModelIndex &index, int role) const QString accountId = accountToMigrateList.at(index.row()); - auto &avatarInfo = LRCInstance::accountModel().getAccountInfo(accountId); + auto& avatarInfo = LRCInstance::accountModel().getAccountInfo(accountId); switch (role) { case Role::Account_ID: @@ -113,7 +113,7 @@ AccountsToMigrateListModel::roleNames() const } QModelIndex -AccountsToMigrateListModel::index(int row, int column, const QModelIndex &parent) const +AccountsToMigrateListModel::index(int row, int column, const QModelIndex& parent) const { Q_UNUSED(parent); if (column != 0) { @@ -127,14 +127,14 @@ AccountsToMigrateListModel::index(int row, int column, const QModelIndex &parent } QModelIndex -AccountsToMigrateListModel::parent(const QModelIndex &child) const +AccountsToMigrateListModel::parent(const QModelIndex& child) const { Q_UNUSED(child); return QModelIndex(); } Qt::ItemFlags -AccountsToMigrateListModel::flags(const QModelIndex &index) const +AccountsToMigrateListModel::flags(const QModelIndex& index) const { auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable; if (!index.isValid()) { diff --git a/src/accountstomigratelistmodel.h b/src/accountstomigratelistmodel.h index b865d00b254e177f55959abe2ee8c2daf582f60d..71abed754fb6d89f25fd7696a1fc115d540b659b 100644 --- a/src/accountstomigratelistmodel.h +++ b/src/accountstomigratelistmodel.h @@ -41,22 +41,22 @@ public: }; Q_ENUM(Role) - explicit AccountsToMigrateListModel(QObject *parent = 0); + explicit AccountsToMigrateListModel(QObject* parent = 0); ~AccountsToMigrateListModel(); /* * QAbstractListModel override. */ - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex& parent) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; /* * Override role name as access point in qml. */ QHash<int, QByteArray> roleNames() const override; - QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; - Qt::ItemFlags flags(const QModelIndex &index) const; + QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex& child) const; + Qt::ItemFlags flags(const QModelIndex& index) const; /* * This function is to reset the model when there's new account added. diff --git a/src/appsettingsmanager.h b/src/appsettingsmanager.h index 491f5636897d6d7c008bc4157dba3634bc0de261..a44aea2fdff55cbdd1829a88424638142be53104 100644 --- a/src/appsettingsmanager.h +++ b/src/appsettingsmanager.h @@ -27,9 +27,10 @@ #include <QString> #include <QStandardPaths> -const QString defaultDownloadPath = - QStandardPaths::writableLocation(QStandardPaths::DownloadLocation); +const QString defaultDownloadPath = QStandardPaths::writableLocation( + QStandardPaths::DownloadLocation); +// clang-format off #define KEYS \ X(MinimizeOnClose, true) \ X(DownloadPath, defaultDownloadPath) \ @@ -78,6 +79,7 @@ private: Settings() = delete; }; Q_DECLARE_METATYPE(Settings::Key) +// clang-format on /* * A singleton object to manage settings access. @@ -88,39 +90,32 @@ class AppSettingsManager : public QObject public: virtual ~AppSettingsManager() = default; - static AppSettingsManager &instance() + static AppSettingsManager& instance() { - static AppSettingsManager *instance_ = - new AppSettingsManager(nullptr); + static AppSettingsManager* instance_ = new AppSettingsManager(nullptr); return *instance_; } - static QVariant - getValue(const Settings::Key key) + static QVariant getValue(const Settings::Key key) { auto settings = instance().settings_; - auto value = settings->value(Settings::toString(key), - Settings::defaultValue(key)); + auto value = settings->value(Settings::toString(key), Settings::defaultValue(key)); - if (QString(value.typeName()) == "QString" && - (value.toString() == "false" || value.toString() == "true")) + if (QString(value.typeName()) == "QString" + && (value.toString() == "false" || value.toString() == "true")) return value.toBool(); return value; } - static void - setValue(const Settings::Key key, const QVariant& value) + static void setValue(const Settings::Key key, const QVariant& value) { instance().settings_->setValue(Settings::toString(key), value); } - static void - initValues() + static void initValues() { - for (int i = 0; - i < static_cast<int>(Settings::Key::COUNT__); - ++i) { + for (int i = 0; i < static_cast<int>(Settings::Key::COUNT__); ++i) { auto key = static_cast<Settings::Key>(i); if (!instance().settings_->contains(Settings::toString(key))) setValue(key, Settings::defaultValue(key)); @@ -128,8 +123,9 @@ public: } private: - explicit AppSettingsManager(QObject *) - : settings_(new QSettings("jami.net", "Jami", this)) {} + explicit AppSettingsManager(QObject*) + : settings_(new QSettings("jami.net", "Jami", this)) + {} - QSettings *settings_; + QSettings* settings_; }; diff --git a/src/audiocodeclistmodel.cpp b/src/audiocodeclistmodel.cpp index cf097ad48cc0193fa853fd33759084acfac95fe2..1943bb1361e77662c4d067de66f04436d3ef27c7 100644 --- a/src/audiocodeclistmodel.cpp +++ b/src/audiocodeclistmodel.cpp @@ -18,14 +18,14 @@ #include "audiocodeclistmodel.h" -AudioCodecListModel::AudioCodecListModel(QObject *parent) +AudioCodecListModel::AudioCodecListModel(QObject* parent) : QAbstractListModel(parent) {} AudioCodecListModel::~AudioCodecListModel() {} int -AudioCodecListModel::rowCount(const QModelIndex &parent) const +AudioCodecListModel::rowCount(const QModelIndex& parent) const { if (!parent.isValid()) { return LRCInstance::getCurrentAccountInfo().codecModel->getAudioCodecs().size(); @@ -34,7 +34,7 @@ AudioCodecListModel::rowCount(const QModelIndex &parent) const } int -AudioCodecListModel::columnCount(const QModelIndex &parent) const +AudioCodecListModel::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent); /* @@ -44,7 +44,7 @@ AudioCodecListModel::columnCount(const QModelIndex &parent) const } QVariant -AudioCodecListModel::data(const QModelIndex &index, int role) const +AudioCodecListModel::data(const QModelIndex& index, int role) const { auto audioCodecList = LRCInstance::getCurrentAccountInfo().codecModel->getAudioCodecs(); if (!index.isValid() || audioCodecList.size() <= index.row()) { @@ -76,7 +76,7 @@ AudioCodecListModel::roleNames() const } QModelIndex -AudioCodecListModel::index(int row, int column, const QModelIndex &parent) const +AudioCodecListModel::index(int row, int column, const QModelIndex& parent) const { Q_UNUSED(parent); if (column != 0) { @@ -90,14 +90,14 @@ AudioCodecListModel::index(int row, int column, const QModelIndex &parent) const } QModelIndex -AudioCodecListModel::parent(const QModelIndex &child) const +AudioCodecListModel::parent(const QModelIndex& child) const { Q_UNUSED(child); return QModelIndex(); } Qt::ItemFlags -AudioCodecListModel::flags(const QModelIndex &index) const +AudioCodecListModel::flags(const QModelIndex& index) const { auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled; diff --git a/src/audiocodeclistmodel.h b/src/audiocodeclistmodel.h index fc58ee1ae7b8918378522b2dd33c22ee5e6c1c4b..f0a5292678b8a03a16b99990b20a6b637bcdb752 100644 --- a/src/audiocodeclistmodel.h +++ b/src/audiocodeclistmodel.h @@ -34,20 +34,20 @@ public: enum Role { AudioCodecName = Qt::UserRole + 1, IsEnabled, AudioCodecID, Samplerate }; Q_ENUM(Role) - explicit AudioCodecListModel(QObject *parent = 0); + explicit AudioCodecListModel(QObject* parent = 0); ~AudioCodecListModel(); /* * QAbstractListModel override. */ - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex& parent) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; /* * Override role name as access point in qml. */ QHash<int, QByteArray> roleNames() const override; - QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; - Qt::ItemFlags flags(const QModelIndex &index) const; + QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex& child) const; + Qt::ItemFlags flags(const QModelIndex& index) const; }; diff --git a/src/audioinputdevicemodel.cpp b/src/audioinputdevicemodel.cpp index 0687c4e42223a38566aecafc2babcc0e3afdb6c3..df491ad8b781490cddcc568c670ff7ffad3565f4 100644 --- a/src/audioinputdevicemodel.cpp +++ b/src/audioinputdevicemodel.cpp @@ -18,14 +18,14 @@ #include "audioinputdevicemodel.h" -AudioInputDeviceModel::AudioInputDeviceModel(QObject *parent) +AudioInputDeviceModel::AudioInputDeviceModel(QObject* parent) : QAbstractListModel(parent) {} AudioInputDeviceModel::~AudioInputDeviceModel() {} int -AudioInputDeviceModel::rowCount(const QModelIndex &parent) const +AudioInputDeviceModel::rowCount(const QModelIndex& parent) const { if (!parent.isValid()) { /* @@ -40,7 +40,7 @@ AudioInputDeviceModel::rowCount(const QModelIndex &parent) const } int -AudioInputDeviceModel::columnCount(const QModelIndex &parent) const +AudioInputDeviceModel::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent); /* @@ -50,7 +50,7 @@ AudioInputDeviceModel::columnCount(const QModelIndex &parent) const } QVariant -AudioInputDeviceModel::data(const QModelIndex &index, int role) const +AudioInputDeviceModel::data(const QModelIndex& index, int role) const { auto deviceList = LRCInstance::avModel().getAudioInputDevices(); if (!index.isValid() || deviceList.size() <= index.row()) { @@ -76,7 +76,7 @@ AudioInputDeviceModel::roleNames() const } QModelIndex -AudioInputDeviceModel::index(int row, int column, const QModelIndex &parent) const +AudioInputDeviceModel::index(int row, int column, const QModelIndex& parent) const { Q_UNUSED(parent); if (column != 0) { @@ -90,14 +90,14 @@ AudioInputDeviceModel::index(int row, int column, const QModelIndex &parent) con } QModelIndex -AudioInputDeviceModel::parent(const QModelIndex &child) const +AudioInputDeviceModel::parent(const QModelIndex& child) const { Q_UNUSED(child); return QModelIndex(); } Qt::ItemFlags -AudioInputDeviceModel::flags(const QModelIndex &index) const +AudioInputDeviceModel::flags(const QModelIndex& index) const { auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable; if (!index.isValid()) { diff --git a/src/audioinputdevicemodel.h b/src/audioinputdevicemodel.h index 03836bed23c449b22ff6c4d20755236916d5013a..5593beb2f9dfefa61beeb1cc041df3839c711d8c 100644 --- a/src/audioinputdevicemodel.h +++ b/src/audioinputdevicemodel.h @@ -34,22 +34,22 @@ public: enum Role { Device_ID = Qt::UserRole + 1, ID_UTF8 }; Q_ENUM(Role) - explicit AudioInputDeviceModel(QObject *parent = 0); + explicit AudioInputDeviceModel(QObject* parent = 0); ~AudioInputDeviceModel(); /* * QAbstractListModel override. */ - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex& parent) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; /* * Override role name as access point in qml. */ QHash<int, QByteArray> roleNames() const override; - QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; - Qt::ItemFlags flags(const QModelIndex &index) const; + QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex& child) const; + Qt::ItemFlags flags(const QModelIndex& index) const; /* * This function is to reset the model when there's new account added. diff --git a/src/audiomanagerlistmodel.cpp b/src/audiomanagerlistmodel.cpp index a28480bf225e4d42fa7fd880e4d20fd5649fe787..866a882f50774d983a6185c1d1d390591bf5cd9c 100644 --- a/src/audiomanagerlistmodel.cpp +++ b/src/audiomanagerlistmodel.cpp @@ -18,14 +18,14 @@ #include "audiomanagerlistmodel.h" -AudioManagerListModel::AudioManagerListModel(QObject *parent) +AudioManagerListModel::AudioManagerListModel(QObject* parent) : QAbstractListModel(parent) {} AudioManagerListModel::~AudioManagerListModel() {} int -AudioManagerListModel::rowCount(const QModelIndex &parent) const +AudioManagerListModel::rowCount(const QModelIndex& parent) const { if (!parent.isValid()) { /* @@ -40,7 +40,7 @@ AudioManagerListModel::rowCount(const QModelIndex &parent) const } int -AudioManagerListModel::columnCount(const QModelIndex &parent) const +AudioManagerListModel::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent); /* @@ -50,7 +50,7 @@ AudioManagerListModel::columnCount(const QModelIndex &parent) const } QVariant -AudioManagerListModel::data(const QModelIndex &index, int role) const +AudioManagerListModel::data(const QModelIndex& index, int role) const { auto managerList = LRCInstance::avModel().getSupportedAudioManagers(); if (!index.isValid() || managerList.size() <= index.row()) { @@ -76,7 +76,7 @@ AudioManagerListModel::roleNames() const } QModelIndex -AudioManagerListModel::index(int row, int column, const QModelIndex &parent) const +AudioManagerListModel::index(int row, int column, const QModelIndex& parent) const { Q_UNUSED(parent); if (column != 0) { @@ -90,14 +90,14 @@ AudioManagerListModel::index(int row, int column, const QModelIndex &parent) con } QModelIndex -AudioManagerListModel::parent(const QModelIndex &child) const +AudioManagerListModel::parent(const QModelIndex& child) const { Q_UNUSED(child); return QModelIndex(); } Qt::ItemFlags -AudioManagerListModel::flags(const QModelIndex &index) const +AudioManagerListModel::flags(const QModelIndex& index) const { auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable; if (!index.isValid()) { diff --git a/src/audiomanagerlistmodel.h b/src/audiomanagerlistmodel.h index 56f0b3ba233a73f141ad921043e2a78e994c8887..96da803ace9ac62f609db48e31640898e15bfdee 100644 --- a/src/audiomanagerlistmodel.h +++ b/src/audiomanagerlistmodel.h @@ -34,22 +34,22 @@ public: enum Role { AudioManagerID = Qt::UserRole + 1, ID_UTF8 }; Q_ENUM(Role) - explicit AudioManagerListModel(QObject *parent = 0); + explicit AudioManagerListModel(QObject* parent = 0); ~AudioManagerListModel(); /* * QAbstractListModel override. */ - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex& parent) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; /* * Override role name as access point in qml. */ QHash<int, QByteArray> roleNames() const override; - QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; - Qt::ItemFlags flags(const QModelIndex &index) const; + QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex& child) const; + Qt::ItemFlags flags(const QModelIndex& index) const; /* * This function is to reset the model when there's new account added. diff --git a/src/audiooutputdevicemodel.cpp b/src/audiooutputdevicemodel.cpp index 733cc6d751b913d0d16a154867b277ca6b4707e5..fc3c92a24fcddabab553451f859e5ccbff1a9496 100644 --- a/src/audiooutputdevicemodel.cpp +++ b/src/audiooutputdevicemodel.cpp @@ -18,14 +18,14 @@ #include "audiooutputdevicemodel.h" -AudioOutputDeviceModel::AudioOutputDeviceModel(QObject *parent) +AudioOutputDeviceModel::AudioOutputDeviceModel(QObject* parent) : QAbstractListModel(parent) {} AudioOutputDeviceModel::~AudioOutputDeviceModel() {} int -AudioOutputDeviceModel::rowCount(const QModelIndex &parent) const +AudioOutputDeviceModel::rowCount(const QModelIndex& parent) const { if (!parent.isValid()) { /* @@ -40,7 +40,7 @@ AudioOutputDeviceModel::rowCount(const QModelIndex &parent) const } int -AudioOutputDeviceModel::columnCount(const QModelIndex &parent) const +AudioOutputDeviceModel::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent); /* @@ -50,7 +50,7 @@ AudioOutputDeviceModel::columnCount(const QModelIndex &parent) const } QVariant -AudioOutputDeviceModel::data(const QModelIndex &index, int role) const +AudioOutputDeviceModel::data(const QModelIndex& index, int role) const { auto deviceList = LRCInstance::avModel().getAudioOutputDevices(); if (!index.isValid() || deviceList.size() <= index.row()) { @@ -76,7 +76,7 @@ AudioOutputDeviceModel::roleNames() const } QModelIndex -AudioOutputDeviceModel::index(int row, int column, const QModelIndex &parent) const +AudioOutputDeviceModel::index(int row, int column, const QModelIndex& parent) const { Q_UNUSED(parent); if (column != 0) { @@ -90,14 +90,14 @@ AudioOutputDeviceModel::index(int row, int column, const QModelIndex &parent) co } QModelIndex -AudioOutputDeviceModel::parent(const QModelIndex &child) const +AudioOutputDeviceModel::parent(const QModelIndex& child) const { Q_UNUSED(child); return QModelIndex(); } Qt::ItemFlags -AudioOutputDeviceModel::flags(const QModelIndex &index) const +AudioOutputDeviceModel::flags(const QModelIndex& index) const { auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable; if (!index.isValid()) { diff --git a/src/audiooutputdevicemodel.h b/src/audiooutputdevicemodel.h index e0148a1e3f0d473cf2b8626a9f5d1fb39d411014..376e3636acea40ec0f00fbfa2f9528c46109242a 100644 --- a/src/audiooutputdevicemodel.h +++ b/src/audiooutputdevicemodel.h @@ -35,22 +35,22 @@ public: enum Role { Device_ID = Qt::UserRole + 1, ID_UTF8 }; Q_ENUM(Role) - explicit AudioOutputDeviceModel(QObject *parent = 0); + explicit AudioOutputDeviceModel(QObject* parent = 0); ~AudioOutputDeviceModel(); /* * QAbstractListModel override. */ - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex& parent) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; /* * Override role name as access point in qml. */ QHash<int, QByteArray> roleNames() const override; - QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; - Qt::ItemFlags flags(const QModelIndex &index) const; + QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex& child) const; + Qt::ItemFlags flags(const QModelIndex& index) const; /* * This function is to reset the model when there's new account added. diff --git a/src/avadapter.cpp b/src/avadapter.cpp index 4f82a86a982dcee923f0f0142604826090524edf..2633ea0c6da0b16f70d09629806d50fa0de9e179 100644 --- a/src/avadapter.cpp +++ b/src/avadapter.cpp @@ -25,7 +25,7 @@ #include <QApplication> #include <QScreen> -AvAdapter::AvAdapter(QObject *parent) +AvAdapter::AvAdapter(QObject* parent) : QmlAdapterBase(parent) {} @@ -64,7 +64,7 @@ AvAdapter::populateVideoDeviceContextMenuItem() } void -AvAdapter::onVideoContextMenuDeviceItemClicked(const QString &deviceName) +AvAdapter::onVideoContextMenuDeviceItemClicked(const QString& deviceName) { auto deviceId = LRCInstance::avModel().getDeviceIdFromName(deviceName); if (deviceId.isEmpty()) { @@ -78,7 +78,7 @@ AvAdapter::onVideoContextMenuDeviceItemClicked(const QString &deviceName) void AvAdapter::shareEntireScreen(int screenNumber) { - QScreen *screen = qApp->screens().at(screenNumber); + QScreen* screen = qApp->screens().at(screenNumber); if (!screen) return; QRect rect = screen ? screen->geometry() : qApp->primaryScreen()->geometry(); @@ -88,7 +88,7 @@ AvAdapter::shareEntireScreen(int screenNumber) const QString AvAdapter::captureScreen(int screenNumber) { - QScreen *screen = qApp->screens().at(screenNumber); + QScreen* screen = qApp->screens().at(screenNumber); if (!screen) return QString(""); /* @@ -103,7 +103,7 @@ AvAdapter::captureScreen(int screenNumber) } void -AvAdapter::shareFile(const QString &filePath) +AvAdapter::shareFile(const QString& filePath) { LRCInstance::avModel().setInputFile(filePath); } @@ -111,7 +111,7 @@ AvAdapter::shareFile(const QString &filePath) void AvAdapter::shareScreenArea(int screenNumber, int x, int y, int width, int height) { - QScreen *screen = qApp->screens().at(screenNumber); + QScreen* screen = qApp->screens().at(screenNumber); if (!screen) return; QRect rect = screen ? screen->geometry() : qApp->primaryScreen()->geometry(); diff --git a/src/avadapter.h b/src/avadapter.h index cda3382d517eb45d3c4b43fd3c0c633ddc867044..111a5b473918494b8d1f0dc7c0174b8d95414fc6 100644 --- a/src/avadapter.h +++ b/src/avadapter.h @@ -29,7 +29,7 @@ class AvAdapter final : public QmlAdapterBase Q_OBJECT public: - explicit AvAdapter(QObject *parent = nullptr); + explicit AvAdapter(QObject* parent = nullptr); ~AvAdapter() = default; protected: @@ -43,7 +43,7 @@ protected: /* * Preview video input switching. */ - Q_INVOKABLE void onVideoContextMenuDeviceItemClicked(const QString &deviceName); + Q_INVOKABLE void onVideoContextMenuDeviceItemClicked(const QString& deviceName); /* * Share the screen specificed by screen number. @@ -58,11 +58,10 @@ protected: /* * Share a media file. */ - Q_INVOKABLE void shareFile(const QString &filePath); + Q_INVOKABLE void shareFile(const QString& filePath); /* * Select screen area to display. */ Q_INVOKABLE void shareScreenArea(int screenNumber, int x, int y, int width, int height); - }; diff --git a/src/bannedlistmodel.cpp b/src/bannedlistmodel.cpp index bfc0a19d25259e46f1dc560e9e741e932e85eb53..b07e6cb64dc19eb9542dcda2ebc5b4e77254a1c4 100644 --- a/src/bannedlistmodel.cpp +++ b/src/bannedlistmodel.cpp @@ -20,14 +20,14 @@ #include "bannedlistmodel.h" #include "lrcinstance.h" -BannedListModel::BannedListModel(QObject *parent) +BannedListModel::BannedListModel(QObject* parent) : QAbstractListModel(parent) {} BannedListModel::~BannedListModel() {} int -BannedListModel::rowCount(const QModelIndex &parent) const +BannedListModel::rowCount(const QModelIndex& parent) const { if (!parent.isValid()) { return LRCInstance::getCurrentAccountInfo().contactModel->getBannedContacts().size(); @@ -36,7 +36,7 @@ BannedListModel::rowCount(const QModelIndex &parent) const } int -BannedListModel::columnCount(const QModelIndex &parent) const +BannedListModel::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent); /* @@ -46,7 +46,7 @@ BannedListModel::columnCount(const QModelIndex &parent) const } QVariant -BannedListModel::data(const QModelIndex &index, int role) const +BannedListModel::data(const QModelIndex& index, int role) const { auto contactList = LRCInstance::getCurrentAccountInfo().contactModel->getBannedContacts(); if (!index.isValid() || contactList.size() <= index.row()) { @@ -82,7 +82,7 @@ BannedListModel::roleNames() const } QModelIndex -BannedListModel::index(int row, int column, const QModelIndex &parent) const +BannedListModel::index(int row, int column, const QModelIndex& parent) const { Q_UNUSED(parent); if (column != 0) { @@ -96,14 +96,14 @@ BannedListModel::index(int row, int column, const QModelIndex &parent) const } QModelIndex -BannedListModel::parent(const QModelIndex &child) const +BannedListModel::parent(const QModelIndex& child) const { Q_UNUSED(child); return QModelIndex(); } Qt::ItemFlags -BannedListModel::flags(const QModelIndex &index) const +BannedListModel::flags(const QModelIndex& index) const { auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable; if (!index.isValid()) { diff --git a/src/bannedlistmodel.h b/src/bannedlistmodel.h index 8dbb7a0feed7931b333eb78456ab4737f742a15e..f664b9b55bc7f0e5445629812e53bdf31c63143c 100644 --- a/src/bannedlistmodel.h +++ b/src/bannedlistmodel.h @@ -24,28 +24,28 @@ class BannedListModel : public QAbstractListModel { Q_OBJECT - BannedListModel(const BannedListModel &cpy); + BannedListModel(const BannedListModel& cpy); public: enum Role { ContactName = Qt::UserRole + 1, ContactID, ContactPicture }; Q_ENUM(Role) - explicit BannedListModel(QObject *parent = nullptr); + explicit BannedListModel(QObject* parent = nullptr); ~BannedListModel(); /* * QAbstractListModel override. */ - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex& parent) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; /* * Override role name as access point in qml. */ QHash<int, QByteArray> roleNames() const override; - QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; - Qt::ItemFlags flags(const QModelIndex &index) const; + QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex& child) const; + Qt::ItemFlags flags(const QModelIndex& index) const; /* * This function is to reset the model when there's new account added. diff --git a/src/calladapter.cpp b/src/calladapter.cpp index e0a257530de77a6a8beca44208d8d0813a92090c..97835d5e03ea5b888bf61a0454153ac0b62346b9 100644 --- a/src/calladapter.cpp +++ b/src/calladapter.cpp @@ -319,7 +319,8 @@ CallAdapter::connectCallModel(const QString& accountId) bestName = Utils::bestNameForContact(contact); if (participant["videoMuted"] == "true") data["avatar"] = contact.profileInfo.avatar; - } catch (...) {} + } catch (...) { + } } data["bestName"] = bestName; map.push_back(QVariant(data)); diff --git a/src/calladapter.h b/src/calladapter.h index d39d8427c205e117d5dcd2eb20195d943b101f56..498f45705f7bdf3a106f08ae948c5362cd3c321c 100644 --- a/src/calladapter.h +++ b/src/calladapter.h @@ -55,7 +55,7 @@ public: Q_INVOKABLE void minimizeParticipant(); Q_INVOKABLE void hangUpThisCall(); Q_INVOKABLE bool isCurrentMaster() const; - Q_INVOKABLE int getCurrentLayoutType() const; + Q_INVOKABLE int getCurrentLayoutType() const; Q_INVOKABLE void holdThisCallToggle(); Q_INVOKABLE void muteThisCallToggle(); Q_INVOKABLE void recordThisCallToggle(); @@ -83,7 +83,7 @@ signals: /* * For Call Overlay */ - void updateTimeText(const QString &time); + void updateTimeText(const QString& time); void showOnHoldLabel(bool isPaused); void updateOverlay(bool isPaused, bool isAudioOnly, diff --git a/src/connectivitymonitor.cpp b/src/connectivitymonitor.cpp index 0446223d4cddc4304c774f40160e47ee854e8b41..04c048acd58e6fb3728faef2cd2e2b673f0df9c8 100644 --- a/src/connectivitymonitor.cpp +++ b/src/connectivitymonitor.cpp @@ -28,30 +28,27 @@ class NetworkEventHandler : public INetworkListManagerEvents { public: NetworkEventHandler() - : m_lRefCnt(1){}; - virtual ~NetworkEventHandler(){}; + : m_lRefCnt(1) {}; + virtual ~NetworkEventHandler() {}; - HRESULT STDMETHODCALLTYPE - QueryInterface(REFIID riid, void **ppvObject) + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) { HRESULT hr = S_OK; if (IsEqualIID(riid, IID_IUnknown)) { - *ppvObject = (IUnknown *) this; + *ppvObject = (IUnknown*) this; } else if (IsEqualIID(riid, IID_INetworkListManagerEvents)) { - *ppvObject = (INetworkListManagerEvents *) this; + *ppvObject = (INetworkListManagerEvents*) this; } else { hr = E_NOINTERFACE; } return hr; }; - ULONG STDMETHODCALLTYPE - AddRef() + ULONG STDMETHODCALLTYPE AddRef() { return (ULONG) InterlockedIncrement(&m_lRefCnt); }; - ULONG STDMETHODCALLTYPE - Release() + ULONG STDMETHODCALLTYPE Release() { LONG res = InterlockedDecrement(&m_lRefCnt); if (res == 0) { @@ -60,8 +57,7 @@ public: return (ULONG) res; }; - virtual HRESULT STDMETHODCALLTYPE - ConnectivityChanged(NLM_CONNECTIVITY newConnectivity) + virtual HRESULT STDMETHODCALLTYPE ConnectivityChanged(NLM_CONNECTIVITY newConnectivity) { qDebug() << "connectivity changed: " << newConnectivity; if (connectivityChangedCb_) { @@ -70,8 +66,7 @@ public: return S_OK; }; - void - setOnConnectivityChangedCallBack(std::function<void()> &&cb) + void setOnConnectivityChangedCallBack(std::function<void()>&& cb) { connectivityChangedCb_ = cb; }; @@ -82,24 +77,24 @@ private: std::function<void()> connectivityChangedCb_; }; -ConnectivityMonitor::ConnectivityMonitor(QObject *parent) +ConnectivityMonitor::ConnectivityMonitor(QObject* parent) : QObject(parent) { CoInitialize(NULL); - IUnknown *pUnknown = NULL; + IUnknown* pUnknown = NULL; HRESULT hr = CoCreateInstance(CLSID_NetworkListManager, NULL, CLSCTX_ALL, IID_IUnknown, - (void **) &pUnknown); + (void**) &pUnknown); if (FAILED(hr)) { return; } pNetworkListManager_ = NULL; - hr = pUnknown->QueryInterface(IID_INetworkListManager, (void **) &pNetworkListManager_); + hr = pUnknown->QueryInterface(IID_INetworkListManager, (void**) &pNetworkListManager_); if (FAILED(hr)) { destroy(); pUnknown->Release(); @@ -108,7 +103,7 @@ ConnectivityMonitor::ConnectivityMonitor(QObject *parent) pCPContainer_ = NULL; hr = pNetworkListManager_->QueryInterface(IID_IConnectionPointContainer, - (void **) &pCPContainer_); + (void**) &pCPContainer_); if (FAILED(hr)) { destroy(); pUnknown->Release(); @@ -121,7 +116,7 @@ ConnectivityMonitor::ConnectivityMonitor(QObject *parent) cookie_ = NULL; netEventHandler_ = new NetworkEventHandler; netEventHandler_->setOnConnectivityChangedCallBack([this] { emit connectivityChanged(); }); - hr = pConnectPoint_->Advise((IUnknown *) netEventHandler_, &cookie_); + hr = pConnectPoint_->Advise((IUnknown*) netEventHandler_, &cookie_); } else { destroy(); } diff --git a/src/connectivitymonitor.h b/src/connectivitymonitor.h index 62865dd8d8453138a05675d23a73931097687f34..916b4666c00da6350aad16d8b48de111e2deef5a 100644 --- a/src/connectivitymonitor.h +++ b/src/connectivitymonitor.h @@ -26,7 +26,7 @@ class ConnectivityMonitor : public QObject Q_OBJECT public: - explicit ConnectivityMonitor(QObject *parent = 0); + explicit ConnectivityMonitor(QObject* parent = 0); ~ConnectivityMonitor(); bool isOnline(); @@ -37,10 +37,10 @@ signals: private: void destroy(); - struct INetworkListManager *pNetworkListManager_; - struct IConnectionPointContainer *pCPContainer_; - struct IConnectionPoint *pConnectPoint_; - class NetworkEventHandler *netEventHandler_; + struct INetworkListManager* pNetworkListManager_; + struct IConnectionPointContainer* pCPContainer_; + struct IConnectionPoint* pConnectPoint_; + class NetworkEventHandler* netEventHandler_; unsigned long cookie_; }; #endif // Q_OS_WIN \ No newline at end of file diff --git a/src/contactadapter.cpp b/src/contactadapter.cpp index b8224f98beba02c789cf2d251d077a886dc134f9..fd7252b8a882bf8b51aa0616f913be143a450956 100644 --- a/src/contactadapter.cpp +++ b/src/contactadapter.cpp @@ -22,7 +22,7 @@ #include "lrcinstance.h" -ContactAdapter::ContactAdapter(QObject *parent) +ContactAdapter::ContactAdapter(QObject* parent) : QmlAdapterBase(parent) { selectableProxyModel_.reset(new SelectableProxyModel(smartListModel_.get())); @@ -46,12 +46,12 @@ ContactAdapter::getContactSelectableModel(int type) */ switch (listModeltype_) { case SmartListModel::Type::CONFERENCE: - selectableProxyModel_->setPredicate([this](const QModelIndex &index, const QRegExp &) { + selectableProxyModel_->setPredicate([this](const QModelIndex& index, const QRegExp&) { return index.data(SmartListModel::Presence).toBool(); }); break; case SmartListModel::Type::TRANSFER: - selectableProxyModel_->setPredicate([this](const QModelIndex &index, const QRegExp ®exp) { + selectableProxyModel_->setPredicate([this](const QModelIndex& index, const QRegExp& regexp) { /* * Regex to remove current callee. */ @@ -76,7 +76,7 @@ ContactAdapter::getContactSelectableModel(int type) } void -ContactAdapter::setSearchFilter(const QString &filter) +ContactAdapter::setSearchFilter(const QString& filter) { if (listModeltype_ == SmartListModel::Type::CONFERENCE) { smartListModel_->setConferenceableFilter(filter); @@ -99,7 +99,8 @@ ContactAdapter::contactSelected(int index) /* * Conference. */ - const auto sectionName = contactIndex.data(SmartListModel::Role::SectionName).value<QString>(); + const auto sectionName = contactIndex.data(SmartListModel::Role::SectionName) + .value<QString>(); if (!sectionName.isEmpty()) { smartListModel_->toggleSection(sectionName); return; @@ -135,7 +136,8 @@ ContactAdapter::contactSelected(int index) if (conversation.uid.isEmpty()) { return; } - const auto callId = conversation.confId.isEmpty() ? conversation.callId : conversation.confId; + const auto callId = conversation.confId.isEmpty() ? conversation.callId + : conversation.confId; QString destCallId; @@ -145,7 +147,7 @@ ContactAdapter::contactSelected(int index) */ const auto callInfo = callModel->getCallFromURI(contactUri, true); destCallId = callInfo.id; - } catch (std::exception &e) { + } catch (std::exception& e) { qDebug().noquote() << e.what(); destCallId = ""; } @@ -169,7 +171,7 @@ ContactAdapter::contactSelected(int index) } void -ContactAdapter::setCalleeDisplayName(const QString &name) +ContactAdapter::setCalleeDisplayName(const QString& name) { calleeDisplayName_ = name; } diff --git a/src/contactadapter.h b/src/contactadapter.h index 9f3aae43225d5b56cbdb23e39f9f8c13d999b372..09e67a8ce8ee14efd49a0e2ee2bf39f7a81d7085 100644 --- a/src/contactadapter.h +++ b/src/contactadapter.h @@ -37,23 +37,21 @@ class SelectableProxyModel final : public QSortFilterProxyModel { public: - using FilterPredicate = std::function<bool(const QModelIndex &, const QRegExp &)>; + using FilterPredicate = std::function<bool(const QModelIndex&, const QRegExp&)>; - explicit SelectableProxyModel(QAbstractItemModel *parent) + explicit SelectableProxyModel(QAbstractItemModel* parent) : QSortFilterProxyModel(parent) { setSourceModel(parent); } ~SelectableProxyModel() {} - void - setPredicate(FilterPredicate filterPredicate) + void setPredicate(FilterPredicate filterPredicate) { filterPredicate_ = filterPredicate; } - virtual bool - filterAcceptsRow(int source_row, const QModelIndex &source_parent) const + virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const { /* * Accept all contacts in conversation list filtered with account type, except those in a call. @@ -65,7 +63,7 @@ public: } private: - std::function<bool(const QModelIndex &, const QRegExp &)> filterPredicate_; + std::function<bool(const QModelIndex&, const QRegExp&)> filterPredicate_; }; class ContactAdapter final : public QmlAdapterBase @@ -73,16 +71,16 @@ class ContactAdapter final : public QmlAdapterBase Q_OBJECT public: - explicit ContactAdapter(QObject *parent = nullptr); + explicit ContactAdapter(QObject* parent = nullptr); ~ContactAdapter() = default; protected: void safeInit() override {}; Q_INVOKABLE QVariant getContactSelectableModel(int type); - Q_INVOKABLE void setSearchFilter(const QString &filter); + Q_INVOKABLE void setSearchFilter(const QString& filter); Q_INVOKABLE void contactSelected(int index); - Q_INVOKABLE void setCalleeDisplayName(const QString &name); + Q_INVOKABLE void setCalleeDisplayName(const QString& name); private: SmartListModel::Type listModeltype_; diff --git a/src/deviceitemlistmodel.cpp b/src/deviceitemlistmodel.cpp index 6b2739c0168847253fed4b950ba348f28e75ce11..fb61b1824bcf829f6d78c8d3b4da468deaa8f496 100644 --- a/src/deviceitemlistmodel.cpp +++ b/src/deviceitemlistmodel.cpp @@ -18,14 +18,14 @@ #include "deviceitemlistmodel.h" -DeviceItemListModel::DeviceItemListModel(QObject *parent) +DeviceItemListModel::DeviceItemListModel(QObject* parent) : QAbstractListModel(parent) {} DeviceItemListModel::~DeviceItemListModel() {} int -DeviceItemListModel::rowCount(const QModelIndex &parent) const +DeviceItemListModel::rowCount(const QModelIndex& parent) const { if (!parent.isValid()) { /* @@ -40,7 +40,7 @@ DeviceItemListModel::rowCount(const QModelIndex &parent) const } int -DeviceItemListModel::columnCount(const QModelIndex &parent) const +DeviceItemListModel::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent); /* @@ -50,7 +50,7 @@ DeviceItemListModel::columnCount(const QModelIndex &parent) const } QVariant -DeviceItemListModel::data(const QModelIndex &index, int role) const +DeviceItemListModel::data(const QModelIndex& index, int role) const { auto deviceList = LRCInstance::getCurrentAccountInfo().deviceModel->getAllDevices(); if (!index.isValid() || deviceList.size() <= index.row()) { @@ -79,7 +79,7 @@ DeviceItemListModel::roleNames() const } QModelIndex -DeviceItemListModel::index(int row, int column, const QModelIndex &parent) const +DeviceItemListModel::index(int row, int column, const QModelIndex& parent) const { Q_UNUSED(parent); if (column != 0) { @@ -93,14 +93,14 @@ DeviceItemListModel::index(int row, int column, const QModelIndex &parent) const } QModelIndex -DeviceItemListModel::parent(const QModelIndex &child) const +DeviceItemListModel::parent(const QModelIndex& child) const { Q_UNUSED(child); return QModelIndex(); } Qt::ItemFlags -DeviceItemListModel::flags(const QModelIndex &index) const +DeviceItemListModel::flags(const QModelIndex& index) const { auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable; if (!index.isValid()) { diff --git a/src/deviceitemlistmodel.h b/src/deviceitemlistmodel.h index ff560710893e1ff5af3ec42eeebd9e2bde49d8fb..0aed35b876bf3f318628f514f70e63e183d0ff44 100644 --- a/src/deviceitemlistmodel.h +++ b/src/deviceitemlistmodel.h @@ -35,22 +35,22 @@ public: enum Role { DeviceName = Qt::UserRole + 1, DeviceID, IsCurrent }; Q_ENUM(Role) - explicit DeviceItemListModel(QObject *parent = 0); + explicit DeviceItemListModel(QObject* parent = 0); ~DeviceItemListModel(); /* * QAbstractListModel override. */ - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex& parent) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; /* * Override role name as access point in qml. */ QHash<int, QByteArray> roleNames() const override; - QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; - Qt::ItemFlags flags(const QModelIndex &index) const; + QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex& child) const; + Qt::ItemFlags flags(const QModelIndex& index) const; /* * This function is to reset the model when there's new account added. diff --git a/src/distantrenderer.cpp b/src/distantrenderer.cpp index 37b3d4413eaad7f921b46d4c405f406ae0f16771..7e5b37519786ec3837a77919a5a7bf568c3a213a 100644 --- a/src/distantrenderer.cpp +++ b/src/distantrenderer.cpp @@ -21,7 +21,7 @@ #include "lrcinstance.h" -DistantRenderer::DistantRenderer(QQuickItem *parent) +DistantRenderer::DistantRenderer(QQuickItem* parent) : QQuickPaintedItem(parent) { setAntialiasing(true); @@ -29,14 +29,14 @@ DistantRenderer::DistantRenderer(QQuickItem *parent) setRenderTarget(QQuickPaintedItem::FramebufferObject); setPerformanceHint(QQuickPaintedItem::FastFBOResizing); - connect(LRCInstance::renderer(), &RenderManager::distantFrameUpdated, [this](const QString &id) { + connect(LRCInstance::renderer(), &RenderManager::distantFrameUpdated, [this](const QString& id) { if (distantRenderId_ == id) update(QRect(0, 0, width(), height())); }); connect(LRCInstance::renderer(), &RenderManager::distantRenderingStopped, - [this](const QString &id) { + [this](const QString& id) { if (distantRenderId_ == id) update(QRect(0, 0, width(), height())); }); @@ -45,7 +45,7 @@ DistantRenderer::DistantRenderer(QQuickItem *parent) DistantRenderer::~DistantRenderer() {} void -DistantRenderer::setRendererId(const QString &id) +DistantRenderer::setRendererId(const QString& id) { distantRenderId_ = id; update(QRect(0, 0, width(), height())); @@ -76,20 +76,24 @@ DistantRenderer::getScaledHeight() const } void -DistantRenderer::paint(QPainter *painter) +DistantRenderer::paint(QPainter* painter) { auto distantImage = LRCInstance::renderer()->getFrame(distantRenderId_); if (distantImage) { auto scaledDistant = distantImage->scaled(size().toSize(), Qt::KeepAspectRatio); - auto tempScaledWidth = static_cast<int>(scaledWidth_*1000); - auto tempScaledHeight = static_cast<int>(scaledHeight_*1000); + auto tempScaledWidth = static_cast<int>(scaledWidth_ * 1000); + auto tempScaledHeight = static_cast<int>(scaledHeight_ * 1000); auto tempXOffset = xOffset_; auto tempYOffset = yOffset_; - scaledWidth_ = static_cast<double>(scaledDistant.width())/static_cast<double>(distantImage->width()); - scaledHeight_ = static_cast<double>(scaledDistant.height())/static_cast<double>(distantImage->height()); + scaledWidth_ = static_cast<double>(scaledDistant.width()) + / static_cast<double>(distantImage->width()); + scaledHeight_ = static_cast<double>(scaledDistant.height()) + / static_cast<double>(distantImage->height()); xOffset_ = (width() - scaledDistant.width()) / 2; yOffset_ = (height() - scaledDistant.height()) / 2; - if (tempXOffset != xOffset_ or tempYOffset != yOffset_ or static_cast<int>(scaledWidth_*1000) != tempScaledWidth or static_cast<int>(scaledHeight_*1000) != tempScaledHeight) { + if (tempXOffset != xOffset_ or tempYOffset != yOffset_ + or static_cast<int>(scaledWidth_ * 1000) != tempScaledWidth + or static_cast<int>(scaledHeight_ * 1000) != tempScaledHeight) { emit offsetChanged(); } painter->drawImage(QRect(xOffset_, yOffset_, scaledDistant.width(), scaledDistant.height()), diff --git a/src/distantrenderer.h b/src/distantrenderer.h index 81281e5ef155ae5efc9721ec2df31bf7db5659a7..5de622da33ec68bf7283b9013134f65b30e8157d 100644 --- a/src/distantrenderer.h +++ b/src/distantrenderer.h @@ -30,10 +30,10 @@ class DistantRenderer : public QQuickPaintedItem { Q_OBJECT public: - explicit DistantRenderer(QQuickItem *parent = 0); + explicit DistantRenderer(QQuickItem* parent = 0); ~DistantRenderer(); - Q_INVOKABLE void setRendererId(const QString &id); + Q_INVOKABLE void setRendererId(const QString& id); Q_INVOKABLE int getXOffset() const; Q_INVOKABLE int getYOffset() const; Q_INVOKABLE double getScaledWidth() const; @@ -43,7 +43,7 @@ signals: void offsetChanged(); private: - void paint(QPainter *painter); + void paint(QPainter* painter); /* * Unique DistantRenderId for each call. diff --git a/src/globalsystemtray.cpp b/src/globalsystemtray.cpp index a1271c5e945dd8ce40ed58815b50577657ae7285..ae98ff2910802ee70e830998a29ea8b1a4de8412 100644 --- a/src/globalsystemtray.cpp +++ b/src/globalsystemtray.cpp @@ -21,24 +21,24 @@ GlobalSystemTray::GlobalSystemTray() {} void -GlobalSystemTray::setTriggeredAccountId(const QString &accountId) +GlobalSystemTray::setTriggeredAccountId(const QString& accountId) { triggeredAccountId_ = accountId; } -const QString & +const QString& GlobalSystemTray::getTriggeredAccountId() { return triggeredAccountId_; } void -GlobalSystemTray::setPossibleOnGoingConversationInfo(const lrc::api::conversation::Info &convInfo) +GlobalSystemTray::setPossibleOnGoingConversationInfo(const lrc::api::conversation::Info& convInfo) { triggeredOnGoingConvInfo_ = convInfo; } -const lrc::api::conversation::Info & +const lrc::api::conversation::Info& GlobalSystemTray::getPossibleOnGoingConversationInfo() { return triggeredOnGoingConvInfo_; diff --git a/src/globalsystemtray.h b/src/globalsystemtray.h index 5f14abccdbc23117ba0efa20a0c6d6d86f645163..3c84808e58fd559c3867230223a3fbeae6952774 100644 --- a/src/globalsystemtray.h +++ b/src/globalsystemtray.h @@ -27,10 +27,9 @@ class GlobalSystemTray : public QSystemTrayIcon Q_OBJECT public: - static GlobalSystemTray & - instance() + static GlobalSystemTray& instance() { - static GlobalSystemTray *instance_ = new GlobalSystemTray(); + static GlobalSystemTray* instance_ = new GlobalSystemTray(); return *instance_; } @@ -38,13 +37,13 @@ public: * Remember the last triggering account for the notification, * safe since user cannot activate previous notifications. */ - void setTriggeredAccountId(const QString &accountId); + void setTriggeredAccountId(const QString& accountId); - const QString &getTriggeredAccountId(); + const QString& getTriggeredAccountId(); - void setPossibleOnGoingConversationInfo(const lrc::api::conversation::Info &convInfo); + void setPossibleOnGoingConversationInfo(const lrc::api::conversation::Info& convInfo); - const lrc::api::conversation::Info &getPossibleOnGoingConversationInfo(); + const lrc::api::conversation::Info& getPossibleOnGoingConversationInfo(); private: GlobalSystemTray(); diff --git a/src/jamiavatartheme.h b/src/jamiavatartheme.h index 08e721a1cafeae84aa228927a3c63328fba89d1d..13196963451accab3653723b765d81c444610aaf 100644 --- a/src/jamiavatartheme.h +++ b/src/jamiavatartheme.h @@ -21,23 +21,23 @@ #pragma once namespace JamiAvatarTheme { -static const QColor defaultAvatarColor_ = {"#ff9e9e9e"}; //Grey -static const QColor avatarColors_[]{ - {"#fff44336"}, //Red - {"#ffe91e63"}, //Pink - {"#ff9c27b0"}, //Purple - {"#ff673ab7"}, //Deep Purple - {"#ff3f51b5"}, //Indigo - {"#ff2196f3"}, //Blue - {"#ff00bcd4"}, //Cyan - {"#ff009688"}, //Teal - {"#ff4caf50"}, //Green - {"#ff8bc34a"}, //Light Green - {"#ff9e9e9e"}, //Grey - {"#ffcddc39"}, //Lime - {"#ffffc107"}, //Amber - {"#ffff5722"}, //Deep Orange - {"#ff795548"}, //Brown - {"#ff607d8b"} //Blue Grey +static const QColor defaultAvatarColor_ = {"#ff9e9e9e"}; // Grey +static const QColor avatarColors_[] { + {"#fff44336"}, // Red + {"#ffe91e63"}, // Pink + {"#ff9c27b0"}, // Purple + {"#ff673ab7"}, // Deep Purple + {"#ff3f51b5"}, // Indigo + {"#ff2196f3"}, // Blue + {"#ff00bcd4"}, // Cyan + {"#ff009688"}, // Teal + {"#ff4caf50"}, // Green + {"#ff8bc34a"}, // Light Green + {"#ff9e9e9e"}, // Grey + {"#ffcddc39"}, // Lime + {"#ffffc107"}, // Amber + {"#ffff5722"}, // Deep Orange + {"#ff795548"}, // Brown + {"#ff607d8b"} // Blue Grey }; } // namespace JamiAvatarTheme diff --git a/src/lrcinstance.h b/src/lrcinstance.h index e66cdac96f69fab68e6498cd9252f784acaa05b2..811ff568701f4217e528b2ed66fb9fc4a2f23e44 100644 --- a/src/lrcinstance.h +++ b/src/lrcinstance.h @@ -76,19 +76,23 @@ public: instance(willMigrate, didMigrate); } - static Lrc& getAPI() { + static Lrc& getAPI() + { return *(instance().lrc_); } - static RenderManager* renderer() { + static RenderManager* renderer() + { return instance().renderer_.get(); } - static void connectivityChanged() { + static void connectivityChanged() + { instance().lrc_->connectivityChanged(); } - static NewAccountModel& accountModel() { + static NewAccountModel& accountModel() + { return instance().lrc_->getAccountModel(); } diff --git a/src/main.cpp b/src/main.cpp index d4b2debe12d0b63e3b9cf5b47f0b83d8d8dd92e6..12a7fbd4b90988f49de1f5e530a959f012878f41 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -44,7 +44,7 @@ parseInputArgument(int& argc, char* argv[], char* argToParse) } int -main(int argc, char *argv[]) +main(int argc, char* argv[]) { setlocale(LC_ALL, "en_US.utf8"); #ifdef Q_OS_LINUX @@ -72,7 +72,7 @@ main(int argc, char *argv[]) /* * Runguard to make sure that only one instance runs at a time. * Note: needs to be after the creation of the application - */ + */ QCryptographicHash appData(QCryptographicHash::Sha256); appData.addData(QApplication::applicationName().toUtf8()); appData.addData(QApplication::organizationDomain().toUtf8()); diff --git a/src/mainapplication.cpp b/src/mainapplication.cpp index 198a810a907735cf8eabce763717646413af1a6d..cf7f7cbb257dc2bdfe87bda9775f1a6480c463bc 100644 --- a/src/mainapplication.cpp +++ b/src/mainapplication.cpp @@ -276,16 +276,14 @@ MainApplication::initSystray() QMenu* systrayMenu = new QMenu(); QAction* exitAction = new QAction(tr("Exit"), this); - connect(exitAction, &QAction::triggered, - [this]{ - engine_->quit(); - cleanup(); - }); - connect(&sysIcon, &QSystemTrayIcon::activated, - [](QSystemTrayIcon::ActivationReason reason) { - if (reason != QSystemTrayIcon::ActivationReason::Context) - emit LRCInstance::instance().restoreAppRequested(); - }); + connect(exitAction, &QAction::triggered, [this] { + engine_->quit(); + cleanup(); + }); + connect(&sysIcon, &QSystemTrayIcon::activated, [](QSystemTrayIcon::ActivationReason reason) { + if (reason != QSystemTrayIcon::ActivationReason::Context) + emit LRCInstance::instance().restoreAppRequested(); + }); systrayMenu->addAction(exitAction); sysIcon.setContextMenu(systrayMenu); diff --git a/src/mainapplication.h b/src/mainapplication.h index 9723ca070d40370edb6df0e8a0fb3f7249dad3d4..95e656b1815a195d166e360a8ed501a21811a294 100644 --- a/src/mainapplication.h +++ b/src/mainapplication.h @@ -32,7 +32,7 @@ class MainApplication : public QApplication Q_OBJECT public: - explicit MainApplication(int &argc, char **argv); + explicit MainApplication(int& argc, char** argv); ~MainApplication() = default; void init(); @@ -40,7 +40,7 @@ public: private: void loadTranslations(); void initLrc(); - void parseArguments(bool &startMinimized); + void parseArguments(bool& startMinimized); void setApplicationFont(); void initQmlEngine(); void initSettings(); @@ -49,6 +49,5 @@ private: private: QScopedPointer<QFile> debugFile_; - QQmlApplicationEngine *engine_; - + QQmlApplicationEngine* engine_; }; diff --git a/src/messagesadapter.cpp b/src/messagesadapter.cpp index 4e8b92765f7df914b48281d9abc3a92ff91d4499..5f97f084cee9ced85e3684c136c73796b75c2832 100644 --- a/src/messagesadapter.cpp +++ b/src/messagesadapter.cpp @@ -34,29 +34,27 @@ #include <QList> #include <QUrl> -MessagesAdapter::MessagesAdapter(QObject *parent) +MessagesAdapter::MessagesAdapter(QObject* parent) : QmlAdapterBase(parent) {} void -MessagesAdapter::safeInit() { - connect(&LRCInstance::instance(), - &LRCInstance::currentAccountChanged, - [this](){ - connectConversationModel(); - }); +MessagesAdapter::safeInit() +{ + connect(&LRCInstance::instance(), &LRCInstance::currentAccountChanged, [this]() { + connectConversationModel(); + }); connectConversationModel(); } void -MessagesAdapter::setupChatView(const QString &uid) +MessagesAdapter::setupChatView(const QString& uid) { - auto* convModel = LRCInstance::getCurrentConversationModel(); if (convModel == nullptr) { return; } - const auto &convInfo = convModel->getConversationForUID(uid); + const auto& convInfo = convModel->getConversationForUID(uid); if (convInfo.uid.isEmpty() || convInfo.participants.isEmpty()) { return; } @@ -65,7 +63,7 @@ MessagesAdapter::setupChatView(const QString &uid) bool isContact = false; auto selectedAccountId = LRCInstance::getCurrAccId(); - auto &accountInfo = LRCInstance::accountModel().getAccountInfo(selectedAccountId); + auto& accountInfo = LRCInstance::accountModel().getAccountInfo(selectedAccountId); lrc::api::profile::Type contactType; try { @@ -92,7 +90,7 @@ MessagesAdapter::setupChatView(const QString &uid) contactIsComposing(convInfo.uid, "", false); connect(LRCInstance::getCurrentConversationModel(), &ConversationModel::composingStatusChanged, - [this](const QString &uid, const QString &contactUri, bool isComposing) { + [this](const QString& uid, const QString& contactUri, bool isComposing) { contactIsComposing(uid, contactUri, isComposing); }); @@ -100,9 +98,9 @@ MessagesAdapter::setupChatView(const QString &uid) * Draft and message content set up. */ Utils::oneShotConnect(qmlObj_, - SIGNAL(sendMessageContentSaved(const QString &)), + SIGNAL(sendMessageContentSaved(const QString&)), this, - SLOT(slotSendMessageContentSaved(const QString &))); + SLOT(slotSendMessageContentSaved(const QString&))); requestSendMessageContent(); } @@ -116,27 +114,31 @@ MessagesAdapter::connectConversationModel() QObject::disconnect(interactionRemovedConnection_); QObject::disconnect(interactionStatusUpdatedConnection_); - newInteractionConnection_ = QObject::connect(currentConversationModel, - &lrc::api::ConversationModel::newInteraction, - [this](const QString &convUid, uint64_t interactionId, - const lrc::api::interaction::Info &interaction) { - auto accountId = LRCInstance::getCurrAccId(); - newInteraction(accountId, convUid, interactionId, interaction); - }); + newInteractionConnection_ + = QObject::connect(currentConversationModel, + &lrc::api::ConversationModel::newInteraction, + [this](const QString& convUid, + uint64_t interactionId, + const lrc::api::interaction::Info& interaction) { + auto accountId = LRCInstance::getCurrAccId(); + newInteraction(accountId, convUid, interactionId, interaction); + }); - interactionStatusUpdatedConnection_ = QObject::connect(currentConversationModel, - &lrc::api::ConversationModel::interactionStatusUpdated, - [this](const QString &convUid, uint64_t interactionId, - const lrc::api::interaction::Info &interaction) { - auto currentConversationModel = LRCInstance::getCurrentConversationModel(); - currentConversationModel->clearUnreadInteractions(convUid); - updateInteraction(*currentConversationModel, interactionId, interaction); - }); + interactionStatusUpdatedConnection_ = QObject::connect( + currentConversationModel, + &lrc::api::ConversationModel::interactionStatusUpdated, + [this](const QString& convUid, + uint64_t interactionId, + const lrc::api::interaction::Info& interaction) { + auto currentConversationModel = LRCInstance::getCurrentConversationModel(); + currentConversationModel->clearUnreadInteractions(convUid); + updateInteraction(*currentConversationModel, interactionId, interaction); + }); interactionRemovedConnection_ = QObject::connect(currentConversationModel, &lrc::api::ConversationModel::interactionRemoved, - [this](const QString &convUid, uint64_t interactionId) { + [this](const QString& convUid, uint64_t interactionId) { Q_UNUSED(convUid); removeInteraction(interactionId); }); @@ -165,7 +167,7 @@ MessagesAdapter::updateConversationForAddedContact() } void -MessagesAdapter::slotSendMessageContentSaved(const QString &content) +MessagesAdapter::slotSendMessageContentSaved(const QString& content) { if (!LastConvUid_.isEmpty()) { LRCInstance::setContentDraft(LastConvUid_, LRCInstance::getCurrAccId(), content); @@ -183,7 +185,7 @@ MessagesAdapter::slotSendMessageContentSaved(const QString &content) } void -MessagesAdapter::slotUpdateDraft(const QString &content) +MessagesAdapter::slotUpdateDraft(const QString& content) { if (!LastConvUid_.isEmpty()) { LRCInstance::setContentDraft(LastConvUid_, LRCInstance::getCurrAccId(), content); @@ -211,7 +213,7 @@ MessagesAdapter::slotMessagesLoaded() } void -MessagesAdapter::sendMessage(const QString &message) +MessagesAdapter::sendMessage(const QString& message) { try { const auto convUid = LRCInstance::getCurrentConvUid(); @@ -222,7 +224,7 @@ MessagesAdapter::sendMessage(const QString &message) } void -MessagesAdapter::sendImage(const QString &message) +MessagesAdapter::sendImage(const QString& message) { if (message.startsWith("data:image/png;base64,")) { /* @@ -278,7 +280,7 @@ MessagesAdapter::sendImage(const QString &message) } void -MessagesAdapter::sendFile(const QString &message) +MessagesAdapter::sendFile(const QString& message) { QFileInfo fi(message); QString fileName = fi.fileName(); @@ -291,7 +293,7 @@ MessagesAdapter::sendFile(const QString &message) } void -MessagesAdapter::retryInteraction(const QString &arg) +MessagesAdapter::retryInteraction(const QString& arg) { bool ok; uint64_t interactionUid = arg.toULongLong(&ok); @@ -304,7 +306,7 @@ MessagesAdapter::retryInteraction(const QString &arg) } void -MessagesAdapter::setNewMessagesContent(const QString &path) +MessagesAdapter::setNewMessagesContent(const QString& path) { if (path.length() == 0) return; @@ -318,7 +320,7 @@ MessagesAdapter::setNewMessagesContent(const QString &path) } void -MessagesAdapter::deleteInteraction(const QString &arg) +MessagesAdapter::deleteInteraction(const QString& arg) { bool ok; uint64_t interactionUid = arg.toULongLong(&ok); @@ -331,7 +333,7 @@ MessagesAdapter::deleteInteraction(const QString &arg) } void -MessagesAdapter::openFile(const QString &arg) +MessagesAdapter::openFile(const QString& arg) { QUrl fileUrl("file:///" + arg); if (!QDesktopServices::openUrl(fileUrl)) { @@ -340,7 +342,7 @@ MessagesAdapter::openFile(const QString &arg) } void -MessagesAdapter::openUrl(const QString &url) +MessagesAdapter::openUrl(const QString& url) { if (!QDesktopServices::openUrl(url)) { qDebug() << "Couldn't open url: " << url; @@ -348,7 +350,7 @@ MessagesAdapter::openUrl(const QString &url) } void -MessagesAdapter::acceptFile(const QString &arg) +MessagesAdapter::acceptFile(const QString& arg) { try { auto interactionUid = arg.toLongLong(); @@ -360,7 +362,7 @@ MessagesAdapter::acceptFile(const QString &arg) } void -MessagesAdapter::refuseFile(const QString &arg) +MessagesAdapter::refuseFile(const QString& arg) { try { auto interactionUid = arg.toLongLong(); @@ -374,7 +376,7 @@ MessagesAdapter::refuseFile(const QString &arg) void MessagesAdapter::pasteKeyDetected() { - const QMimeData *mimeData = QApplication::clipboard()->mimeData(); + const QMimeData* mimeData = QApplication::clipboard()->mimeData(); if (mimeData->hasImage()) { /* @@ -391,8 +393,8 @@ MessagesAdapter::pasteKeyDetected() } else if (mimeData->hasUrls()) { QList<QUrl> urlList = mimeData->urls(); /* - * Extract the local paths of the files. - */ + * Extract the local paths of the files. + */ for (int i = 0; i < urlList.size(); ++i) { /* * Trim file:/// from url. @@ -425,7 +427,7 @@ MessagesAdapter::onComposing(bool isComposing) } void -MessagesAdapter::setConversationProfileData(const lrc::api::conversation::Info &convInfo) +MessagesAdapter::setConversationProfileData(const lrc::api::conversation::Info& convInfo) { auto* convModel = LRCInstance::getCurrentConversationModel(); auto accInfo = &LRCInstance::getCurrentAccountInfo(); @@ -440,7 +442,7 @@ MessagesAdapter::setConversationProfileData(const lrc::api::conversation::Info & return; } try { - auto &contact = accInfo->contactModel->getContact(contactUri); + auto& contact = accInfo->contactModel->getContact(contactUri); auto bestName = Utils::bestNameForConversation(convInfo, *convModel); setInvitation(contact.profileInfo.type == lrc::api::profile::Type::PENDING, bestName, @@ -460,15 +462,15 @@ MessagesAdapter::setConversationProfileData(const lrc::api::conversation::Info & } void -MessagesAdapter::newInteraction(const QString &accountId, - const QString &convUid, +MessagesAdapter::newInteraction(const QString& accountId, + const QString& convUid, uint64_t interactionId, - const interaction::Info &interaction) + const interaction::Info& interaction) { Q_UNUSED(interactionId); try { - auto &accountInfo = LRCInstance::getAccountInfo(accountId); - auto &convModel = accountInfo.conversationModel; + auto& accountInfo = LRCInstance::getAccountInfo(accountId); + auto& convModel = accountInfo.conversationModel; const auto conversation = convModel->getConversationForUID(convUid); if (conversation.uid.isEmpty()) { @@ -493,9 +495,9 @@ void MessagesAdapter::updateDraft() { Utils::oneShotConnect(qmlObj_, - SIGNAL(sendMessageContentSaved(const QString &)), + SIGNAL(sendMessageContentSaved(const QString&)), this, - SLOT(slotUpdateDraft(const QString &))); + SLOT(slotUpdateDraft(const QString&))); requestSendMessageContent(); } @@ -518,7 +520,7 @@ MessagesAdapter::requestSendMessageContent() } void -MessagesAdapter::setInvitation(bool show, const QString &contactUri, const QString &contactId) +MessagesAdapter::setInvitation(bool show, const QString& contactUri, const QString& contactId) { QString s = show @@ -536,7 +538,7 @@ MessagesAdapter::clear() } void -MessagesAdapter::printHistory(lrc::api::ConversationModel &conversationModel, +MessagesAdapter::printHistory(lrc::api::ConversationModel& conversationModel, const std::map<uint64_t, lrc::api::interaction::Info> interactions) { auto interactionsStr = interactionsToJsonArrayObject(conversationModel, interactions).toUtf8(); @@ -545,7 +547,7 @@ MessagesAdapter::printHistory(lrc::api::ConversationModel &conversationModel, } void -MessagesAdapter::setSenderImage(const QString &sender, const QString &senderImage) +MessagesAdapter::setSenderImage(const QString& sender, const QString& senderImage) { QJsonObject setSenderImageObject = QJsonObject(); setSenderImageObject.insert("sender_contact_method", QJsonValue(sender)); @@ -559,9 +561,9 @@ MessagesAdapter::setSenderImage(const QString &sender, const QString &senderImag } void -MessagesAdapter::printNewInteraction(lrc::api::ConversationModel &conversationModel, +MessagesAdapter::printNewInteraction(lrc::api::ConversationModel& conversationModel, uint64_t msgId, - const lrc::api::interaction::Info &interaction) + const lrc::api::interaction::Info& interaction) { auto interactionObject = interactionToJsonInteractionObject(conversationModel, msgId, interaction).toUtf8(); @@ -573,9 +575,9 @@ MessagesAdapter::printNewInteraction(lrc::api::ConversationModel &conversationMo } void -MessagesAdapter::updateInteraction(lrc::api::ConversationModel &conversationModel, +MessagesAdapter::updateInteraction(lrc::api::ConversationModel& conversationModel, uint64_t msgId, - const lrc::api::interaction::Info &interaction) + const lrc::api::interaction::Info& interaction) { auto interactionObject = interactionToJsonInteractionObject(conversationModel, msgId, interaction).toUtf8(); @@ -587,7 +589,7 @@ MessagesAdapter::updateInteraction(lrc::api::ConversationModel &conversationMode } void -MessagesAdapter::setMessagesImageContent(const QString &path, bool isBased64) +MessagesAdapter::setMessagesImageContent(const QString& path, bool isBased64) { if (isBased64) { QString param = QString("addImage_base64('file://%1')").arg(path); @@ -599,7 +601,7 @@ MessagesAdapter::setMessagesImageContent(const QString &path, bool isBased64) } void -MessagesAdapter::setMessagesFileContent(const QString &path) +MessagesAdapter::setMessagesFileContent(const QString& path) { qint64 fileSize = QFileInfo(path).size(); QString fileName = QFileInfo(path).fileName(); @@ -623,14 +625,14 @@ MessagesAdapter::removeInteraction(uint64_t interactionId) } void -MessagesAdapter::setSendMessageContent(const QString &content) +MessagesAdapter::setSendMessageContent(const QString& content) { QString s = QString::fromLatin1("setSendMessageContent(`%1`);").arg(content); QMetaObject::invokeMethod(qmlObj_, "webViewRunJavaScript", Q_ARG(QVariant, s)); } void -MessagesAdapter::contactIsComposing(const QString &uid, const QString &contactUri, bool isComposing) +MessagesAdapter::contactIsComposing(const QString& uid, const QString& contactUri, bool isComposing) { if (LRCInstance::getCurrentConvUid() == uid) { QString s @@ -640,14 +642,14 @@ MessagesAdapter::contactIsComposing(const QString &uid, const QString &contactUr } void -MessagesAdapter::acceptInvitation(const QString &convUid) +MessagesAdapter::acceptInvitation(const QString& convUid) { const auto currentConvUid = convUid.isEmpty() ? LRCInstance::getCurrentConvUid() : convUid; LRCInstance::getCurrentConversationModel()->makePermanent(currentConvUid); } void -MessagesAdapter::refuseInvitation(const QString &convUid) +MessagesAdapter::refuseInvitation(const QString& convUid) { const auto currentConvUid = convUid.isEmpty() ? LRCInstance::getCurrentConvUid() : convUid; LRCInstance::getCurrentConversationModel()->removeConversation(currentConvUid, false); @@ -655,7 +657,7 @@ MessagesAdapter::refuseInvitation(const QString &convUid) } void -MessagesAdapter::blockConversation(const QString &convUid) +MessagesAdapter::blockConversation(const QString& convUid) { const auto currentConvUid = convUid.isEmpty() ? LRCInstance::getCurrentConvUid() : convUid; LRCInstance::getCurrentConversationModel()->removeConversation(currentConvUid, true); diff --git a/src/messagesadapter.h b/src/messagesadapter.h index 5f066a538fe826eac42ca088438bf4cafad9c641..4e60710a5ba7177bf089fc6c7bfc2adf8087e19e 100644 --- a/src/messagesadapter.h +++ b/src/messagesadapter.h @@ -28,13 +28,13 @@ class MessagesAdapter final : public QmlAdapterBase { Q_OBJECT public: - explicit MessagesAdapter(QObject *parent = 0); + explicit MessagesAdapter(QObject* parent = 0); ~MessagesAdapter() = default; protected: void safeInit() override; - Q_INVOKABLE void setupChatView(const QString &uid); + Q_INVOKABLE void setupChatView(const QString& uid); Q_INVOKABLE void connectConversationModel(); Q_INVOKABLE void sendContactRequest(); Q_INVOKABLE void updateConversationForAddedContact(); @@ -42,19 +42,19 @@ protected: /* * JS Q_INVOKABLE. */ - Q_INVOKABLE void acceptInvitation(const QString &convUid = ""); - Q_INVOKABLE void refuseInvitation(const QString &convUid = ""); - Q_INVOKABLE void blockConversation(const QString &convUid = ""); - Q_INVOKABLE void setNewMessagesContent(const QString &path); - Q_INVOKABLE void sendMessage(const QString &message); - Q_INVOKABLE void sendImage(const QString &message); - Q_INVOKABLE void sendFile(const QString &message); - Q_INVOKABLE void retryInteraction(const QString &arg); - Q_INVOKABLE void deleteInteraction(const QString &arg); - Q_INVOKABLE void openUrl(const QString &url); - Q_INVOKABLE void openFile(const QString &arg); - Q_INVOKABLE void acceptFile(const QString &arg); - Q_INVOKABLE void refuseFile(const QString &arg); + Q_INVOKABLE void acceptInvitation(const QString& convUid = ""); + Q_INVOKABLE void refuseInvitation(const QString& convUid = ""); + Q_INVOKABLE void blockConversation(const QString& convUid = ""); + Q_INVOKABLE void setNewMessagesContent(const QString& path); + Q_INVOKABLE void sendMessage(const QString& message); + Q_INVOKABLE void sendImage(const QString& message); + Q_INVOKABLE void sendFile(const QString& message); + Q_INVOKABLE void retryInteraction(const QString& arg); + Q_INVOKABLE void deleteInteraction(const QString& arg); + Q_INVOKABLE void openUrl(const QString& url); + Q_INVOKABLE void openFile(const QString& arg); + Q_INVOKABLE void acceptFile(const QString& arg); + Q_INVOKABLE void refuseFile(const QString& arg); Q_INVOKABLE void pasteKeyDetected(); Q_INVOKABLE void onComposing(bool isComposing); @@ -68,38 +68,38 @@ protected: */ void setMessagesVisibility(bool visible); void requestSendMessageContent(); - void setInvitation(bool show, const QString &contactUri = "", const QString &contactId = ""); + void setInvitation(bool show, const QString& contactUri = "", const QString& contactId = ""); void clear(); - void printHistory(lrc::api::ConversationModel &conversationModel, + void printHistory(lrc::api::ConversationModel& conversationModel, const std::map<uint64_t, lrc::api::interaction::Info> interactions); - void setSenderImage(const QString &sender, const QString &senderImage); - void printNewInteraction(lrc::api::ConversationModel &conversationModel, + void setSenderImage(const QString& sender, const QString& senderImage); + void printNewInteraction(lrc::api::ConversationModel& conversationModel, uint64_t msgId, - const lrc::api::interaction::Info &interaction); - void updateInteraction(lrc::api::ConversationModel &conversationModel, + const lrc::api::interaction::Info& interaction); + void updateInteraction(lrc::api::ConversationModel& conversationModel, uint64_t msgId, - const lrc::api::interaction::Info &interaction); - void setMessagesImageContent(const QString &path, bool isBased64 = false); - void setMessagesFileContent(const QString &path); + const lrc::api::interaction::Info& interaction); + void setMessagesImageContent(const QString& path, bool isBased64 = false); + void setMessagesFileContent(const QString& path); void removeInteraction(uint64_t interactionId); - void setSendMessageContent(const QString &content); - void contactIsComposing(const QString &uid, const QString &contactUri, bool isComposing); + void setSendMessageContent(const QString& content); + void contactIsComposing(const QString& uid, const QString& contactUri, bool isComposing); signals: void needToUpdateSmartList(); public slots: - void slotSendMessageContentSaved(const QString &content); - void slotUpdateDraft(const QString &content); + void slotSendMessageContentSaved(const QString& content); + void slotUpdateDraft(const QString& content); void slotMessagesCleared(); void slotMessagesLoaded(); private: - void setConversationProfileData(const lrc::api::conversation::Info &convInfo); - void newInteraction(const QString &accountId, - const QString &convUid, + void setConversationProfileData(const lrc::api::conversation::Info& convInfo); + void newInteraction(const QString& accountId, + const QString& convUid, uint64_t interactionId, - const interaction::Info &interaction); + const interaction::Info& interaction); QString LastConvUid_; diff --git a/src/pixbufmanipulator.cpp b/src/pixbufmanipulator.cpp index e8aea9550d76bbaa06dde9b2952b4f08fce1da95..4860e722114f2d12ebf80c045db710c9a79c5f74 100644 --- a/src/pixbufmanipulator.cpp +++ b/src/pixbufmanipulator.cpp @@ -40,7 +40,7 @@ #undef interface QVariant -PixbufManipulator::personPhoto(const QByteArray &data, const QString &type) +PixbufManipulator::personPhoto(const QByteArray& data, const QString& type) { QImage avatar; const bool ret = avatar.loadFromData(QByteArray::fromBase64(data), type.toLatin1()); @@ -52,8 +52,8 @@ PixbufManipulator::personPhoto(const QByteArray &data, const QString &type) } QVariant -PixbufManipulator::numberCategoryIcon(const QVariant &p, - const QSize &size, +PixbufManipulator::numberCategoryIcon(const QVariant& p, + const QSize& size, bool displayPresence, bool isPresent) { @@ -65,7 +65,7 @@ PixbufManipulator::numberCategoryIcon(const QVariant &p, } QByteArray -PixbufManipulator::toByteArray(const QVariant &pxm) +PixbufManipulator::toByteArray(const QVariant& pxm) { auto image = pxm.value<QImage>(); QByteArray ba = Utils::QImageToByteArray(image); @@ -73,22 +73,22 @@ PixbufManipulator::toByteArray(const QVariant &pxm) } QVariant -PixbufManipulator::userActionIcon(const UserActionElement &state) const +PixbufManipulator::userActionIcon(const UserActionElement& state) const { Q_UNUSED(state) return QVariant(); } QVariant -PixbufManipulator::decorationRole(const QModelIndex &index) +PixbufManipulator::decorationRole(const QModelIndex& index) { Q_UNUSED(index) return QVariant(); } QVariant -PixbufManipulator::decorationRole(const lrc::api::conversation::Info &conversationInfo, - const lrc::api::account::Info &accountInfo) +PixbufManipulator::decorationRole(const lrc::api::conversation::Info& conversationInfo, + const lrc::api::account::Info& accountInfo) { QImage photo; auto contacts = conversationInfo.participants; diff --git a/src/pixbufmanipulator.h b/src/pixbufmanipulator.h index 5325f15b2109c39db289b61022b7c3997de09829..7788f6526ca6e65fe6962080fb51428157e0ef42 100644 --- a/src/pixbufmanipulator.h +++ b/src/pixbufmanipulator.h @@ -32,18 +32,18 @@ QByteArray QImageToByteArray(QImage image); class PixbufManipulator : public Interfaces::PixmapManipulatorI { public: - QVariant personPhoto(const QByteArray &data, const QString &type = "PNG") override; + QVariant personPhoto(const QByteArray& data, const QString& type = "PNG") override; /* * TODO: the following methods return an empty QVariant/QByteArray. */ - QVariant numberCategoryIcon(const QVariant &p, - const QSize &size, + QVariant numberCategoryIcon(const QVariant& p, + const QSize& size, bool displayPresence = false, bool isPresent = false) override; - QByteArray toByteArray(const QVariant &pxm) override; - QVariant userActionIcon(const UserActionElement &state) const override; - QVariant decorationRole(const QModelIndex &index) override; - QVariant decorationRole(const lrc::api::conversation::Info &conversation, - const lrc::api::account::Info &accountInfo) override; + QByteArray toByteArray(const QVariant& pxm) override; + QVariant userActionIcon(const UserActionElement& state) const override; + QVariant decorationRole(const QModelIndex& index) override; + QVariant decorationRole(const lrc::api::conversation::Info& conversation, + const lrc::api::account::Info& accountInfo) override; }; diff --git a/src/pluginlistpreferencemodel.h b/src/pluginlistpreferencemodel.h index 15641883fa7bcc961131622c56914572e7925cf1..66e1d57b7d0d88e0b16c239e2ea8df28b22a844b 100644 --- a/src/pluginlistpreferencemodel.h +++ b/src/pluginlistpreferencemodel.h @@ -36,22 +36,22 @@ public: enum Role { PreferenceValue = Qt::UserRole + 1, PreferenceEntryValue }; Q_ENUM(Role) - explicit PluginListPreferenceModel(QObject *parent = 0); + explicit PluginListPreferenceModel(QObject* parent = 0); ~PluginListPreferenceModel(); /* * QAbstractListModel override. */ - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex& parent) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; /* * Override role name as access point in qml. */ QHash<int, QByteArray> roleNames() const override; - QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; - Qt::ItemFlags flags(const QModelIndex &index) const; + QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex& child) const; + Qt::ItemFlags flags(const QModelIndex& index) const; /* * This function is to reset the model when there's new account added. @@ -64,18 +64,31 @@ public: Q_INVOKABLE void populateLists(); - void setPreferenceNewValue(const QString preferenceNewValue) { preferenceNewValue_ = preferenceNewValue; } - void setPreferenceKey(const QString preferenceKey) { preferenceKey_ = preferenceKey; } + void setPreferenceNewValue(const QString preferenceNewValue) + { + preferenceNewValue_ = preferenceNewValue; + } + void setPreferenceKey(const QString preferenceKey) + { + preferenceKey_ = preferenceKey; + } void setPluginId(const QString pluginId) { pluginId_ = pluginId; populateLists(); } - void setIdx(const int index) { idx_ = index; } + void setIdx(const int index) + { + idx_ = index; + } - int idx() { return idx_; } - QString preferenceCurrentValue() { + int idx() + { + return idx_; + } + QString preferenceCurrentValue() + { return LRCInstance::pluginModel().getPluginPreferencesValues(pluginId_)[preferenceKey_]; } @@ -84,12 +97,20 @@ public: preferenceNewValue_ = preferenceValuesList_[idx_]; return preferenceNewValue_; } - QString preferenceKey() { return preferenceKey_; } - QString pluginId() { return pluginId_; } - int optSize() { return preferenceValuesList_.size(); } + QString preferenceKey() + { + return preferenceKey_; + } + QString pluginId() + { + return pluginId_; + } + int optSize() + { + return preferenceValuesList_.size(); + } private: - QString pluginId_ = ""; QString preferenceKey_ = ""; QString preferenceNewValue_ = ""; diff --git a/src/previewrenderer.cpp b/src/previewrenderer.cpp index 773b23fd1ab2ab70abdb5081f89ff32b73b96ff3..d5c72a14cb3f67f17f77a229af929cc4fe152b39 100644 --- a/src/previewrenderer.cpp +++ b/src/previewrenderer.cpp @@ -21,7 +21,7 @@ #include "lrcinstance.h" -PreviewRenderer::PreviewRenderer(QQuickItem *parent) +PreviewRenderer::PreviewRenderer(QQuickItem* parent) : QQuickPaintedItem(parent) { setAntialiasing(true); @@ -44,7 +44,7 @@ PreviewRenderer::~PreviewRenderer() } void -PreviewRenderer::paint(QPainter *painter) +PreviewRenderer::paint(QPainter* painter) { auto previewImage = LRCInstance::renderer()->getPreviewFrame(); if (previewImage) { @@ -60,7 +60,7 @@ PreviewRenderer::paint(QPainter *painter) * auto parent = qobject_cast<QWidget*>(this->parent()); * auto xPos = (parent->width() - previewWidth) / 2; * setGeometry(QRect(QPoint(xPos, this->pos().y()), QSize(previewWidth, previewHeight))); - */ + */ setWidth(previewWidth); setHeight(previewHeight); @@ -70,7 +70,7 @@ PreviewRenderer::paint(QPainter *painter) } } -VideoCallPreviewRenderer::VideoCallPreviewRenderer(QQuickItem *parent) +VideoCallPreviewRenderer::VideoCallPreviewRenderer(QQuickItem* parent) : PreviewRenderer(parent) {} @@ -88,7 +88,7 @@ VideoCallPreviewRenderer::getPreviewImageScalingFactor() } void -VideoCallPreviewRenderer::paint(QPainter *painter) +VideoCallPreviewRenderer::paint(QPainter* painter) { auto previewImage = LRCInstance::renderer()->getPreviewFrame(); @@ -102,7 +102,7 @@ VideoCallPreviewRenderer::paint(QPainter *painter) } } -PhotoboothPreviewRender::PhotoboothPreviewRender(QQuickItem *parent) +PhotoboothPreviewRender::PhotoboothPreviewRender(QQuickItem* parent) : PreviewRenderer(parent) { connect(LRCInstance::renderer(), &RenderManager::previewRenderingStopped, [this]() { @@ -131,7 +131,7 @@ PhotoboothPreviewRender::takeCroppedPhotoToBase64(int size) } void -PhotoboothPreviewRender::paint(QPainter *painter) +PhotoboothPreviewRender::paint(QPainter* painter) { painter->setRenderHint(QPainter::Antialiasing, true); diff --git a/src/previewrenderer.h b/src/previewrenderer.h index 408416c2b69f072a6b57e05ffee35ec9080f8589..6a2a668680c3cc47eef1aa33d157309182978ef5 100644 --- a/src/previewrenderer.h +++ b/src/previewrenderer.h @@ -29,11 +29,11 @@ class PreviewRenderer : public QQuickPaintedItem { Q_OBJECT public: - explicit PreviewRenderer(QQuickItem *parent = 0); + explicit PreviewRenderer(QQuickItem* parent = 0); ~PreviewRenderer(); protected: - void paint(QPainter *painter) override; + void paint(QPainter* painter) override; private: QMetaObject::Connection previewFrameUpdatedConnection_; @@ -44,7 +44,7 @@ class VideoCallPreviewRenderer : public PreviewRenderer { Q_OBJECT public: - explicit VideoCallPreviewRenderer(QQuickItem *parent = 0); + explicit VideoCallPreviewRenderer(QQuickItem* parent = 0); virtual ~VideoCallPreviewRenderer(); Q_INVOKABLE qreal getPreviewImageScalingFactor(); @@ -53,14 +53,14 @@ signals: void previewImageAvailable(); private: - void paint(QPainter *painter) override final; + void paint(QPainter* painter) override final; }; class PhotoboothPreviewRender : public PreviewRenderer { Q_OBJECT public: - explicit PhotoboothPreviewRender(QQuickItem *parent = 0); + explicit PhotoboothPreviewRender(QQuickItem* parent = 0); virtual ~PhotoboothPreviewRender(); QImage takePhoto(); @@ -70,5 +70,5 @@ signals: void hideBooth(); private: - void paint(QPainter *painter) override final; + void paint(QPainter* painter) override final; }; diff --git a/src/qmladapterbase.h b/src/qmladapterbase.h index 750c09e60a032aed85dfe554930dac0e07e25008..1ac0753bea22d68ed0401b2e51227183be5e3c89 100644 --- a/src/qmladapterbase.h +++ b/src/qmladapterbase.h @@ -28,7 +28,7 @@ class QmlAdapterBase : public QObject { Q_OBJECT public: - explicit QmlAdapterBase(QObject *parent = nullptr) + explicit QmlAdapterBase(QObject* parent = nullptr) : QObject(parent) , qmlObj_(nullptr) {}; @@ -38,7 +38,7 @@ public: * This function should be called in the Component.onCompleted slot * in the qml component that this adapter should attach to. */ - Q_INVOKABLE void setQmlObject(QObject *obj) + Q_INVOKABLE void setQmlObject(QObject* obj) { qmlObj_ = obj; safeInit(); @@ -53,5 +53,5 @@ protected: /* * Object pointer. */ - QObject *qmlObj_; + QObject* qmlObj_; }; diff --git a/src/qtutils.h b/src/qtutils.h index 141831e088461cf680a55dda45041eefdb2fda03..577127b426099f42d8868bbc1719cf79d85fb960 100644 --- a/src/qtutils.h +++ b/src/qtutils.h @@ -28,13 +28,13 @@ namespace Utils { template<typename Func1, typename Func2> void -oneShotConnect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, +oneShotConnect(const typename QtPrivate::FunctionPointer<Func1>::Object* sender, Func1 signal, Func2 slot) { - QMetaObject::Connection *const connection = new QMetaObject::Connection; + QMetaObject::Connection* const connection = new QMetaObject::Connection; *connection = QObject::connect(sender, signal, slot); - QMetaObject::Connection *const disconnectConnection = new QMetaObject::Connection; + QMetaObject::Connection* const disconnectConnection = new QMetaObject::Connection; *disconnectConnection = QObject::connect(sender, signal, [connection, disconnectConnection] { if (connection) { QObject::disconnect(*connection); @@ -49,14 +49,14 @@ oneShotConnect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, template<typename Func1, typename Func2> void -oneShotConnect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, +oneShotConnect(const typename QtPrivate::FunctionPointer<Func1>::Object* sender, Func1 signal, - const typename QtPrivate::FunctionPointer<Func2>::Object *receiver, + const typename QtPrivate::FunctionPointer<Func2>::Object* receiver, Func2 slot) { - QMetaObject::Connection *const connection = new QMetaObject::Connection; + QMetaObject::Connection* const connection = new QMetaObject::Connection; *connection = QObject::connect(sender, signal, receiver, slot); - QMetaObject::Connection *const disconnectConnection = new QMetaObject::Connection; + QMetaObject::Connection* const disconnectConnection = new QMetaObject::Connection; *disconnectConnection = QObject::connect(sender, signal, [connection, disconnectConnection] { if (connection) { QObject::disconnect(*connection); @@ -73,24 +73,20 @@ class OneShotConnection final : public QObject { Q_OBJECT public: - explicit OneShotConnection(const QObject *sender, - const char *signal, - QMetaObject::Connection *connection, - QObject *parent = nullptr) + explicit OneShotConnection(const QObject* sender, + const char* signal, + QMetaObject::Connection* connection, + QObject* parent = nullptr) : QObject(parent) { connection_ = connection; disconnectConnection_ = new QMetaObject::Connection; - *disconnectConnection_ = QObject::connect(sender, - signal, - this, - SLOT(onTriggered())); + *disconnectConnection_ = QObject::connect(sender, signal, this, SLOT(onTriggered())); } ~OneShotConnection() = default; public slots: - void - onTriggered() + void onTriggered() { if (connection_) { QObject::disconnect(*connection_); @@ -104,17 +100,16 @@ public slots: } private: - QMetaObject::Connection *connection_; - QMetaObject::Connection *disconnectConnection_; - + QMetaObject::Connection* connection_; + QMetaObject::Connection* disconnectConnection_; }; inline void -oneShotConnect(const QObject *sender, const char *signal, const QObject *receiver, const char *slot) +oneShotConnect(const QObject* sender, const char* signal, const QObject* receiver, const char* slot) { - QMetaObject::Connection *const connection = new QMetaObject::Connection; + QMetaObject::Connection* const connection = new QMetaObject::Connection; *connection = QObject::connect(sender, signal, receiver, slot); - new OneShotConnection(sender, signal, connection); + new OneShotConnection(sender, signal, connection); } -} +} // namespace Utils diff --git a/src/rendermanager.cpp b/src/rendermanager.cpp index dfd095bbbf98341ae07f427a279302ad33474c84..15fd25ed9f5a4a6bc997025fec49ffd0dd25c528 100644 --- a/src/rendermanager.cpp +++ b/src/rendermanager.cpp @@ -25,7 +25,7 @@ using namespace lrc::api; -FrameWrapper::FrameWrapper(AVModel &avModel, const QString &id) +FrameWrapper::FrameWrapper(AVModel& avModel, const QString& id) : avModel_(avModel) , id_(id) , isRendering_(false) @@ -52,8 +52,8 @@ bool FrameWrapper::startRendering() { try { - renderer_ = const_cast<video::Renderer *>(&avModel_.getRenderer(id_)); - } catch (std::out_of_range &e) { + renderer_ = const_cast<video::Renderer*>(&avModel_.getRenderer(id_)); + } catch (std::out_of_range& e) { qWarning() << e.what(); return false; } @@ -74,7 +74,7 @@ FrameWrapper::startRendering() return true; } -QImage * +QImage* FrameWrapper::getFrame() { return image_.get(); @@ -87,7 +87,7 @@ FrameWrapper::isRendering() } void -FrameWrapper::slotRenderingStarted(const QString &id) +FrameWrapper::slotRenderingStarted(const QString& id) { if (id != id_) { return; @@ -104,7 +104,7 @@ FrameWrapper::slotRenderingStarted(const QString &id) } void -FrameWrapper::slotFrameUpdated(const QString &id) +FrameWrapper::slotFrameUpdated(const QString& id) { if (id != id_) { return; @@ -130,7 +130,7 @@ FrameWrapper::slotFrameUpdated(const QString &id) */ if (size != 0 && size == width * height * 4) { buffer_ = std::move(frame_.storage); - image_.reset(new QImage((uchar *) buffer_.data(), + image_.reset(new QImage((uchar*) buffer_.data(), width, height, QImage::Format_ARGB32_Premultiplied)); @@ -145,7 +145,7 @@ FrameWrapper::slotFrameUpdated(const QString &id) } void -FrameWrapper::slotRenderingStopped(const QString &id) +FrameWrapper::slotRenderingStopped(const QString& id) { if (id != id_) { return; @@ -167,7 +167,7 @@ FrameWrapper::slotRenderingStopped(const QString &id) emit renderingStopped(id); } -RenderManager::RenderManager(AVModel &avModel) +RenderManager::RenderManager(AVModel& avModel) : avModel_(avModel) { deviceListSize_ = avModel_.getDevices().size(); @@ -177,19 +177,19 @@ RenderManager::RenderManager(AVModel &avModel) QObject::connect(previewFrameWrapper_.get(), &FrameWrapper::renderingStarted, - [this](const QString &id) { + [this](const QString& id) { Q_UNUSED(id); emit previewRenderingStarted(); }); QObject::connect(previewFrameWrapper_.get(), &FrameWrapper::frameUpdated, - [this](const QString &id) { + [this](const QString& id) { Q_UNUSED(id); emit previewFrameUpdated(); }); QObject::connect(previewFrameWrapper_.get(), &FrameWrapper::renderingStopped, - [this](const QString &id) { + [this](const QString& id) { Q_UNUSED(id); emit previewRenderingStopped(); }); @@ -201,7 +201,7 @@ RenderManager::~RenderManager() { previewFrameWrapper_.reset(); - for (auto &dfw : distantFrameWrapperMap_) { + for (auto& dfw : distantFrameWrapperMap_) { dfw.second.reset(); } } @@ -212,7 +212,7 @@ RenderManager::isPreviewing() return previewFrameWrapper_->isRendering(); } -QImage * +QImage* RenderManager::getPreviewFrame() { return previewFrameWrapper_->getFrame(); @@ -252,8 +252,8 @@ RenderManager::startPreviewing(bool force, bool async) } } -QImage * -RenderManager::getFrame(const QString &id) +QImage* +RenderManager::getFrame(const QString& id) { auto dfwIt = distantFrameWrapperMap_.find(id); if (dfwIt != distantFrameWrapperMap_.end()) { @@ -263,7 +263,7 @@ RenderManager::getFrame(const QString &id) } void -RenderManager::addDistantRenderer(const QString &id) +RenderManager::addDistantRenderer(const QString& id) { /* * Check if a FrameWrapper with this id exists. @@ -281,17 +281,17 @@ RenderManager::addDistantRenderer(const QString &id) */ distantConnectionMap_[id].started = QObject::connect(dfw.get(), &FrameWrapper::renderingStarted, - [this](const QString &id) { + [this](const QString& id) { emit distantRenderingStarted(id); }); distantConnectionMap_[id].updated = QObject::connect(dfw.get(), &FrameWrapper::frameUpdated, - [this](const QString &id) { + [this](const QString& id) { emit distantFrameUpdated(id); }); distantConnectionMap_[id].stopped = QObject::connect(dfw.get(), &FrameWrapper::renderingStopped, - [this](const QString &id) { + [this](const QString& id) { emit distantRenderingStopped(id); }); @@ -308,7 +308,7 @@ RenderManager::addDistantRenderer(const QString &id) } void -RenderManager::removeDistantRenderer(const QString &id) +RenderManager::removeDistantRenderer(const QString& id) { auto dfwIt = distantFrameWrapperMap_.find(id); if (dfwIt != distantFrameWrapperMap_.end()) { @@ -340,7 +340,7 @@ RenderManager::slotDeviceEvent() auto deviceList = avModel_.getDevices(); auto currentDeviceListSize = deviceList.size(); - DeviceEvent deviceEvent{DeviceEvent::None}; + DeviceEvent deviceEvent {DeviceEvent::None}; if (currentDeviceListSize > deviceListSize_) { deviceEvent = DeviceEvent::Added; } else if (currentDeviceListSize < deviceListSize_) { diff --git a/src/rendermanager.h b/src/rendermanager.h index f93e5e613a0952534f225c3be214ac50dd295ca2..6ea24cb5d9b3b3499fb19fa74bf5d9a74c53472c 100644 --- a/src/rendermanager.h +++ b/src/rendermanager.h @@ -46,8 +46,7 @@ class FrameWrapper final : public QObject Q_OBJECT; public: - FrameWrapper(AVModel &avModel, - const QString &id = video::PREVIEW_RENDERER_ID); + FrameWrapper(AVModel& avModel, const QString& id = video::PREVIEW_RENDERER_ID); ~FrameWrapper(); /* @@ -66,7 +65,7 @@ public: * Get the most recently rendered frame as a QImage. * @return the rendered image of this object's id */ - QImage *getFrame(); + QImage* getFrame(); /* * Check if the object is updating actively. @@ -78,34 +77,34 @@ signals: * Emitted once in slotRenderingStarted. * @param id of the renderer */ - void renderingStarted(const QString &id); + void renderingStarted(const QString& id); /* * Emitted each time a frame is ready to be displayed. * @param id of the renderer */ - void frameUpdated(const QString &id); + void frameUpdated(const QString& id); /* * Emitted once in slotRenderingStopped. * @param id of the renderer */ - void renderingStopped(const QString &id); + void renderingStopped(const QString& id); private slots: /* * Used to listen to AVModel::rendererStarted. * @param id of the renderer */ - void slotRenderingStarted(const QString &id = video::PREVIEW_RENDERER_ID); + void slotRenderingStarted(const QString& id = video::PREVIEW_RENDERER_ID); /* * Used to listen to AVModel::frameUpdated. * @param id of the renderer */ - void slotFrameUpdated(const QString &id = video::PREVIEW_RENDERER_ID); + void slotFrameUpdated(const QString& id = video::PREVIEW_RENDERER_ID); /* * Used to listen to AVModel::renderingStopped. * @param id of the renderer */ - void slotRenderingStopped(const QString &id = video::PREVIEW_RENDERER_ID); + void slotRenderingStopped(const QString& id = video::PREVIEW_RENDERER_ID); private: /* @@ -116,7 +115,7 @@ private: /* * A pointer to the lrc renderer object. */ - video::Renderer *renderer_; + video::Renderer* renderer_; /* * A local copy of the renderer's current frame. @@ -146,7 +145,7 @@ private: /* * Convenience ref to avmodel */ - AVModel &avModel_; + AVModel& avModel_; /* * Connections to the underlying renderer signals in avmodel @@ -166,7 +165,7 @@ class RenderManager final : public QObject Q_OBJECT; public: - explicit RenderManager(AVModel &avModel); + explicit RenderManager(AVModel& avModel); ~RenderManager(); /* @@ -177,7 +176,7 @@ public: * Get the most recently rendered preview frame as a QImage. * @return the rendered preview image */ - QImage *getPreviewFrame(); + QImage* getPreviewFrame(); /* * Start capturing and rendering preview frames. * @param force if the capture device should be started @@ -195,19 +194,19 @@ public: * as a QImage. * @return the rendered preview image */ - QImage *getFrame(const QString &id); + QImage* getFrame(const QString& id); /* * Add and connect a distant renderer for a given id * to a FrameWrapper object * @param id */ - void addDistantRenderer(const QString &id); + void addDistantRenderer(const QString& id); /* * Disconnect and remove a FrameWrapper object connected to a * distant renderer for a given id * @param id */ - void removeDistantRenderer(const QString &id); + void removeDistantRenderer(const QString& id); signals: /* @@ -233,17 +232,17 @@ signals: /* * Emitted when a distant renderer is started for a given id. */ - void distantRenderingStarted(const QString &id); + void distantRenderingStarted(const QString& id); /* * Emitted when a distant renderer has a new frame ready for a given id. */ - void distantFrameUpdated(const QString &id); + void distantFrameUpdated(const QString& id); /* * Emitted when a distant renderer is stopped for a given id. */ - void distantRenderingStopped(const QString &id); + void distantRenderingStopped(const QString& id); private slots: /* @@ -276,6 +275,6 @@ private: /* * Convenience ref to avmodel. */ - AVModel &avModel_; + AVModel& avModel_; }; -Q_DECLARE_METATYPE(RenderManager *) +Q_DECLARE_METATYPE(RenderManager*) diff --git a/src/runguard.cpp b/src/runguard.cpp index b3c126edc6864550c1419fa20ebe5ff4212e0450..2ec2d3d9b49ae1728433810d102312df37934898 100644 --- a/src/runguard.cpp +++ b/src/runguard.cpp @@ -26,7 +26,7 @@ namespace { QString -generateKeyHash(const QString &key, const QString &salt) +generateKeyHash(const QString& key, const QString& salt) { QByteArray data; @@ -39,7 +39,7 @@ generateKeyHash(const QString &key, const QString &salt) } // namespace -RunGuard::RunGuard(const QString &key) +RunGuard::RunGuard(const QString& key) : key_(key) , memLockKey_(generateKeyHash(key, "_memLockKey")) , sharedmemKey_(generateKeyHash(key, "_sharedmemKey")) diff --git a/src/runguard.h b/src/runguard.h index 6e0f0d767d21ff4339f6a97de94a35954f5ac087..29b7ad41903e388b95537fc9d94feae2a1996b2e 100644 --- a/src/runguard.h +++ b/src/runguard.h @@ -30,7 +30,7 @@ class RunGuard : public QObject Q_OBJECT; public: - RunGuard(const QString &key); + RunGuard(const QString& key); ~RunGuard(); bool isAnotherRunning(); @@ -48,8 +48,8 @@ private: QSharedMemory sharedMem_; QSystemSemaphore memLock_; - QLocalSocket *socket_; - QLocalServer *server_; + QLocalSocket* socket_; + QLocalServer* server_; Q_DISABLE_COPY(RunGuard) }; \ No newline at end of file diff --git a/src/settingsadapter.cpp b/src/settingsadapter.cpp index 3e025f931ad7429a865d3abf94966e5f17a880dd..8b6213ac7718266d8aa2fdee2f05b0373d271314 100644 --- a/src/settingsadapter.cpp +++ b/src/settingsadapter.cpp @@ -20,12 +20,12 @@ #include "api/newdevicemodel.h" -SettingsAdapter::SettingsAdapter(QObject *parent) +SettingsAdapter::SettingsAdapter(QObject* parent) : QObject(parent) {} -///Singleton -SettingsAdapter & +/// Singleton +SettingsAdapter& SettingsAdapter::instance() { static auto instance = new SettingsAdapter; @@ -42,7 +42,8 @@ SettingsAdapter::getDir_Document() QString SettingsAdapter::getDir_Download() { - QString downloadPath = QDir::toNativeSeparators(LRCInstance::dataTransferModel().downloadDirectory); + QString downloadPath = QDir::toNativeSeparators( + LRCInstance::dataTransferModel().downloadDirectory); if (downloadPath.isEmpty()) { downloadPath = lrc::api::DataTransferModel::createDefaultDirectory(); setDownloadPath(downloadPath); @@ -98,13 +99,13 @@ SettingsAdapter::get_ResRateList(lrc::api::video::Channel channel, QString devic } int -SettingsAdapter::get_DeviceCapabilitiesSize(const QString &device) +SettingsAdapter::get_DeviceCapabilitiesSize(const QString& device) { return get_DeviceCapabilities(device).size(); } QVector<QString> -SettingsAdapter::getResolutions(const QString &device) +SettingsAdapter::getResolutions(const QString& device) { QVector<QString> resolutions; @@ -122,7 +123,7 @@ SettingsAdapter::getResolutions(const QString &device) } QVector<int> -SettingsAdapter::getFrameRates(const QString &device) +SettingsAdapter::getFrameRates(const QString& device) { QVector<int> rates; @@ -140,13 +141,13 @@ SettingsAdapter::getFrameRates(const QString &device) } lrc::api::video::Capabilities -SettingsAdapter::get_DeviceCapabilities(const QString &device) +SettingsAdapter::get_DeviceCapabilities(const QString& device) { return LRCInstance::avModel().getDeviceCapabilities(device); } QString -SettingsAdapter::get_Video_Settings_Channel(const QString &deviceId) +SettingsAdapter::get_Video_Settings_Channel(const QString& deviceId) { auto settings = LRCInstance::avModel().getDeviceSettings(deviceId); @@ -154,7 +155,7 @@ SettingsAdapter::get_Video_Settings_Channel(const QString &deviceId) } QString -SettingsAdapter::get_Video_Settings_Name(const QString &deviceId) +SettingsAdapter::get_Video_Settings_Name(const QString& deviceId) { auto settings = LRCInstance::avModel().getDeviceSettings(deviceId); @@ -162,7 +163,7 @@ SettingsAdapter::get_Video_Settings_Name(const QString &deviceId) } QString -SettingsAdapter::get_Video_Settings_Id(const QString &deviceId) +SettingsAdapter::get_Video_Settings_Id(const QString& deviceId) { auto settings = LRCInstance::avModel().getDeviceSettings(deviceId); @@ -170,7 +171,7 @@ SettingsAdapter::get_Video_Settings_Id(const QString &deviceId) } qreal -SettingsAdapter::get_Video_Settings_Rate(const QString &deviceId) +SettingsAdapter::get_Video_Settings_Rate(const QString& deviceId) { auto settings = LRCInstance::avModel().getDeviceSettings(deviceId); @@ -178,7 +179,7 @@ SettingsAdapter::get_Video_Settings_Rate(const QString &deviceId) } QString -SettingsAdapter::get_Video_Settings_Size(const QString &deviceId) +SettingsAdapter::get_Video_Settings_Size(const QString& deviceId) { auto settings = LRCInstance::avModel().getDeviceSettings(deviceId); @@ -186,9 +187,9 @@ SettingsAdapter::get_Video_Settings_Size(const QString &deviceId) } void -SettingsAdapter::set_Video_Settings_Rate_And_Resolution(const QString &deviceId, +SettingsAdapter::set_Video_Settings_Rate_And_Resolution(const QString& deviceId, qreal rate, - const QString &resolution) + const QString& resolution) { auto settings = LRCInstance::avModel().getDeviceSettings(deviceId); settings.rate = rate; @@ -196,25 +197,25 @@ SettingsAdapter::set_Video_Settings_Rate_And_Resolution(const QString &deviceId, LRCInstance::avModel().setDeviceSettings(settings); } -const lrc::api::account::Info & +const lrc::api::account::Info& SettingsAdapter::getCurrentAccountInfo() { return LRCInstance::getCurrentAccountInfo(); } -const Q_INVOKABLE lrc::api::profile::Info & +const Q_INVOKABLE lrc::api::profile::Info& SettingsAdapter::getCurrentAccount_Profile_Info() { return LRCInstance::getCurrentAccountInfo().profileInfo; } -lrc::api::ContactModel * +lrc::api::ContactModel* SettingsAdapter::getContactModel() { return getCurrentAccountInfo().contactModel.get(); } -lrc::api::NewDeviceModel * +lrc::api::NewDeviceModel* SettingsAdapter::getDeviceModel() { return getCurrentAccountInfo().deviceModel.get(); @@ -265,7 +266,7 @@ SettingsAdapter::getAccountBestName() QString SettingsAdapter::getAvatarImage_Base64(int avatarSize) { - auto &accountInfo = LRCInstance::getCurrentAccountInfo(); + auto& accountInfo = LRCInstance::getCurrentAccountInfo(); auto avatar = Utils::accountPhoto(accountInfo, {avatarSize, avatarSize}); return QString::fromLatin1(Utils::QImageToByteArray(avatar).toBase64().data()); @@ -274,7 +275,7 @@ SettingsAdapter::getAvatarImage_Base64(int avatarSize) bool SettingsAdapter::getIsDefaultAvatar() { - auto &accountInfo = LRCInstance::getCurrentAccountInfo(); + auto& accountInfo = LRCInstance::getCurrentAccountInfo(); return accountInfo.profileInfo.avatar.isEmpty(); } @@ -305,7 +306,8 @@ SettingsAdapter::getAccountConfig() lrc::api::account::ConfProperties_t res; try { res = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); - } catch (...) {} + } catch (...) { + } return res; } @@ -641,7 +643,6 @@ SettingsAdapter::setIsRendezVous(bool state) LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps); } - void SettingsAdapter::setAutoAnswerCalls(bool state) { @@ -924,7 +925,7 @@ SettingsAdapter::videoRTPMaxPortSpinBoxEditFinished(int value) } void -SettingsAdapter::tlsProtocolComboBoxIndexChanged(const int &index) +SettingsAdapter::tlsProtocolComboBoxIndexChanged(const int& index) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); diff --git a/src/settingsadapter.h b/src/settingsadapter.h index 9532160edbc25bde4083aedb54b43d5545bc24b3..78a5164ffcd760ff2b1957a87071ce550918a297 100644 --- a/src/settingsadapter.h +++ b/src/settingsadapter.h @@ -31,10 +31,10 @@ class SettingsAdapter : public QObject { Q_OBJECT public: - explicit SettingsAdapter(QObject *parent = nullptr); + explicit SettingsAdapter(QObject* parent = nullptr); - //Singleton - static SettingsAdapter &instance(); + // Singleton + static SettingsAdapter& instance(); /* * getters of directories */ @@ -50,38 +50,38 @@ public: /* * getters of devices' Info and options */ - Q_INVOKABLE lrc::api::video::Capabilities get_DeviceCapabilities(const QString &device); + Q_INVOKABLE lrc::api::video::Capabilities get_DeviceCapabilities(const QString& device); Q_INVOKABLE lrc::api::video::ResRateList get_ResRateList(lrc::api::video::Channel channel, QString device); - Q_INVOKABLE int get_DeviceCapabilitiesSize(const QString &device); + Q_INVOKABLE int get_DeviceCapabilitiesSize(const QString& device); /* * getters of resolution and frame rates of current device */ - Q_INVOKABLE QVector<QString> getResolutions(const QString &device); - Q_INVOKABLE QVector<int> getFrameRates(const QString &device); + Q_INVOKABLE QVector<QString> getResolutions(const QString& device); + Q_INVOKABLE QVector<int> getFrameRates(const QString& device); /* * getters and setters: lrc video::setting */ - Q_INVOKABLE QString get_Video_Settings_Channel(const QString &deviceId); - Q_INVOKABLE QString get_Video_Settings_Name(const QString &deviceId); - Q_INVOKABLE QString get_Video_Settings_Id(const QString &deviceId); - Q_INVOKABLE qreal get_Video_Settings_Rate(const QString &deviceId); - Q_INVOKABLE QString get_Video_Settings_Size(const QString &deviceId); + Q_INVOKABLE QString get_Video_Settings_Channel(const QString& deviceId); + Q_INVOKABLE QString get_Video_Settings_Name(const QString& deviceId); + Q_INVOKABLE QString get_Video_Settings_Id(const QString& deviceId); + Q_INVOKABLE qreal get_Video_Settings_Rate(const QString& deviceId); + Q_INVOKABLE QString get_Video_Settings_Size(const QString& deviceId); - Q_INVOKABLE void set_Video_Settings_Rate_And_Resolution(const QString &deviceId, + Q_INVOKABLE void set_Video_Settings_Rate_And_Resolution(const QString& deviceId, qreal rate, - const QString &resolution); + const QString& resolution); /* * getters and setters of current account Info */ - const Q_INVOKABLE lrc::api::account::Info &getCurrentAccountInfo(); - const Q_INVOKABLE lrc::api::profile::Info &getCurrentAccount_Profile_Info(); + const Q_INVOKABLE lrc::api::account::Info& getCurrentAccountInfo(); + const Q_INVOKABLE lrc::api::profile::Info& getCurrentAccount_Profile_Info(); - Q_INVOKABLE lrc::api::ContactModel *getContactModel(); - Q_INVOKABLE lrc::api::NewDeviceModel *getDeviceModel(); + Q_INVOKABLE lrc::api::ContactModel* getContactModel(); + Q_INVOKABLE lrc::api::NewDeviceModel* getDeviceModel(); Q_INVOKABLE QString get_CurrentAccountInfo_RegisteredName(); Q_INVOKABLE QString get_CurrentAccountInfo_Id(); @@ -211,7 +211,7 @@ public: Q_INVOKABLE void videoRTPMinPortSpinBoxEditFinished(int value); Q_INVOKABLE void videoRTPMaxPortSpinBoxEditFinished(int value); - Q_INVOKABLE void tlsProtocolComboBoxIndexChanged(const int &index); + Q_INVOKABLE void tlsProtocolComboBoxIndexChanged(const int& index); Q_INVOKABLE void setDeviceName(QString text); @@ -230,6 +230,5 @@ public: Q_INVOKABLE void set_FileCACert(QString text); Q_INVOKABLE void set_FileUserCert(QString text); Q_INVOKABLE void set_FilePrivateKey(QString text); - }; -Q_DECLARE_METATYPE(SettingsAdapter *) +Q_DECLARE_METATYPE(SettingsAdapter*) diff --git a/src/smartlistmodel.cpp b/src/smartlistmodel.cpp index b16d3a227d7ced89c3a0497ae5b2862f581a0d7b..33a1194d34104d7e39c2c30deaac28a71329851a 100644 --- a/src/smartlistmodel.cpp +++ b/src/smartlistmodel.cpp @@ -29,10 +29,10 @@ #include <QDateTime> -SmartListModel::SmartListModel(const QString &accId, - QObject *parent, +SmartListModel::SmartListModel(const QString& accId, + QObject* parent, SmartListModel::Type listModelType, - const QString &convUid) + const QString& convUid) : QAbstractListModel(parent) , accountId_(accId) , listModelType_(listModelType) @@ -46,11 +46,11 @@ SmartListModel::SmartListModel(const QString &accId, SmartListModel::~SmartListModel() {} int -SmartListModel::rowCount(const QModelIndex &parent) const +SmartListModel::rowCount(const QModelIndex& parent) const { if (!parent.isValid()) { - auto &accInfo = LRCInstance::accountModel().getAccountInfo(accountId_); - auto &convModel = accInfo.conversationModel; + auto& accInfo = LRCInstance::accountModel().getAccountInfo(accountId_); + auto& convModel = accInfo.conversationModel; if (listModelType_ == Type::TRANSFER) { auto filterType = accInfo.profileInfo.type; return convModel->getFilteredConversations(filterType).size(); @@ -71,22 +71,22 @@ SmartListModel::rowCount(const QModelIndex &parent) const } int -SmartListModel::columnCount(const QModelIndex &parent) const +SmartListModel::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent); return 1; } QVariant -SmartListModel::data(const QModelIndex &index, int role) const +SmartListModel::data(const QModelIndex& index, int role) const { if (!index.isValid()) { return QVariant(); } try { - auto &accountInfo = LRCInstance::accountModel().getAccountInfo(accountId_); - auto &convModel = accountInfo.conversationModel; + auto& accountInfo = LRCInstance::accountModel().getAccountInfo(accountId_); + auto& convModel = accountInfo.conversationModel; lrc::api::conversation::Info item; if (listModelType_ == Type::TRANSFER) { auto filterType = accountInfo.profileInfo.type; @@ -95,7 +95,7 @@ SmartListModel::data(const QModelIndex &index, int role) const } else if (listModelType_ == Type::CONFERENCE) { auto calls = conferenceables_[ConferenceableItem::CALL]; auto contacts = conferenceables_[ConferenceableItem::CONTACT]; - QString itemConvUid{}, itemAccId{}; + QString itemConvUid {}, itemAccId {}; if (calls.size() == 0) { itemConvUid = contacts.at(index.row()).at(0).convId; itemAccId = contacts.at(index.row()).at(0).accountId; @@ -131,14 +131,14 @@ SmartListModel::data(const QModelIndex &index, int role) const return QVariant(itemAccId); } - auto &itemAccountInfo = LRCInstance::accountModel().getAccountInfo(itemAccId); + auto& itemAccountInfo = LRCInstance::accountModel().getAccountInfo(itemAccId); item = itemAccountInfo.conversationModel->getConversationForUID(itemConvUid); return getConversationItemData(item, itemAccountInfo, role); } else if (listModelType_ == Type::CONVERSATION) { item = conversations_.at(index.row()); return getConversationItemData(item, accountInfo, role); } - } catch (const std::exception &e) { + } catch (const std::exception& e) { qWarning() << e.what(); } return QVariant(); @@ -169,11 +169,11 @@ SmartListModel::roleNames() const } void -SmartListModel::setConferenceableFilter(const QString &filter) +SmartListModel::setConferenceableFilter(const QString& filter) { beginResetModel(); - auto &accountInfo = LRCInstance::accountModel().getAccountInfo(accountId_); - auto &convModel = accountInfo.conversationModel; + auto& accountInfo = LRCInstance::accountModel().getAccountInfo(accountId_); + auto& convModel = accountInfo.conversationModel; conferenceables_ = convModel->getConferenceableConversations(convUid_, filter); sectionState_[tr("Calls")] = true; sectionState_[tr("Contacts")] = true; @@ -198,10 +198,10 @@ SmartListModel::fillConversationsList() } void -SmartListModel::updateConversation(const QString &convUid) +SmartListModel::updateConversation(const QString& convUid) { auto* convModel = LRCInstance::getCurrentConversationModel(); - for (lrc::api::conversation::Info &conversation : conversations_) { + for (lrc::api::conversation::Info& conversation : conversations_) { if (conversation.uid == convUid) { conversation = convModel->getConversationForUID(convUid); return; @@ -210,7 +210,7 @@ SmartListModel::updateConversation(const QString &convUid) } void -SmartListModel::toggleSection(const QString §ion) +SmartListModel::toggleSection(const QString& section) { beginResetModel(); if (section.contains(tr("Calls"))) { @@ -234,14 +234,14 @@ SmartListModel::currentUidSmartListModelIndex() } QVariant -SmartListModel::getConversationItemData(const conversation::Info &item, - const account::Info &accountInfo, +SmartListModel::getConversationItemData(const conversation::Info& item, + const account::Info& accountInfo, int role) const { if (item.participants.size() <= 0) { return QVariant(); } - auto &contactModel = accountInfo.contactModel; + auto& contactModel = accountInfo.contactModel; switch (role) { case Role::Picture: { auto contactImage @@ -250,28 +250,28 @@ SmartListModel::getConversationItemData(const conversation::Info &item, } case Role::DisplayName: { if (!item.participants.isEmpty()) { - auto &contact = contactModel->getContact(item.participants[0]); + auto& contact = contactModel->getContact(item.participants[0]); return QVariant(Utils::bestNameForContact(contact)); } return QVariant(""); } case Role::DisplayID: { if (!item.participants.isEmpty()) { - auto &contact = contactModel->getContact(item.participants[0]); + auto& contact = contactModel->getContact(item.participants[0]); return QVariant(Utils::bestIdForContact(contact)); } return QVariant(""); } case Role::Presence: { if (!item.participants.isEmpty()) { - auto &contact = contactModel->getContact(item.participants[0]); + auto& contact = contactModel->getContact(item.participants[0]); return QVariant(contact.isPresent); } return QVariant(false); } case Role::URI: { if (!item.participants.isEmpty()) { - auto &contact = contactModel->getContact(item.participants[0]); + auto& contact = contactModel->getContact(item.participants[0]); return QVariant(contact.profileInfo.uri); } return QVariant(""); @@ -280,7 +280,7 @@ SmartListModel::getConversationItemData(const conversation::Info &item, return QVariant(item.unreadMessages); case Role::LastInteractionDate: { if (!item.interactions.empty()) { - auto &date = item.interactions.at(item.lastMessageUid).timestamp; + auto& date = item.interactions.at(item.lastMessageUid).timestamp; return QVariant(QString::fromStdString(Utils::formatTimeString(date))); } return QVariant(""); @@ -293,14 +293,13 @@ SmartListModel::getConversationItemData(const conversation::Info &item, } case Role::LastInteractionType: { if (!item.interactions.empty()) { - return QVariant( - static_cast<int>(item.interactions.at(item.lastMessageUid).type)); + return QVariant(static_cast<int>(item.interactions.at(item.lastMessageUid).type)); } return QVariant(0); } case Role::ContactType: { if (!item.participants.isEmpty()) { - auto &contact = contactModel->getContact(item.participants[0]); + auto& contact = contactModel->getContact(item.participants[0]); return QVariant(static_cast<int>(contact.profileInfo.type)); } return QVariant(0); @@ -373,7 +372,7 @@ SmartListModel::getConversationItemData(const conversation::Info &item, } QModelIndex -SmartListModel::index(int row, int column, const QModelIndex &parent) const +SmartListModel::index(int row, int column, const QModelIndex& parent) const { Q_UNUSED(parent); if (column != 0) { @@ -387,14 +386,14 @@ SmartListModel::index(int row, int column, const QModelIndex &parent) const } QModelIndex -SmartListModel::parent(const QModelIndex &child) const +SmartListModel::parent(const QModelIndex& child) const { Q_UNUSED(child); return QModelIndex(); } Qt::ItemFlags -SmartListModel::flags(const QModelIndex &index) const +SmartListModel::flags(const QModelIndex& index) const { auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable; auto type = static_cast<lrc::api::profile::Type>(data(index, Role::ContactType).value<int>()); @@ -408,7 +407,7 @@ SmartListModel::flags(const QModelIndex &index) const } void -SmartListModel::setAccount(const QString &accountId) +SmartListModel::setAccount(const QString& accountId) { accountId_ = accountId; } diff --git a/src/smartlistmodel.h b/src/smartlistmodel.h index 3128d706d30d648408116e3b862c4a696bf948b7..1c70bd4ffd8fefb1a172bdfd2cbacad7ef587967 100644 --- a/src/smartlistmodel.h +++ b/src/smartlistmodel.h @@ -61,35 +61,35 @@ public: Draft }; - explicit SmartListModel(const QString &accId, - QObject *parent = 0, + explicit SmartListModel(const QString& accId, + QObject* parent = 0, SmartListModel::Type listModelType = Type::CONVERSATION, - const QString &convUid = {}); + const QString& convUid = {}); ~SmartListModel(); /* * QAbstractListModel. */ - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex& parent) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; QHash<int, QByteArray> roleNames() const override; - QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; - Qt::ItemFlags flags(const QModelIndex &index) const; + QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex& child) const; + Qt::ItemFlags flags(const QModelIndex& index) const; - Q_INVOKABLE void setAccount(const QString &accId); - Q_INVOKABLE void setConferenceableFilter(const QString &filter = {}); - Q_INVOKABLE void toggleSection(const QString §ion); + Q_INVOKABLE void setAccount(const QString& accId); + Q_INVOKABLE void setConferenceableFilter(const QString& filter = {}); + Q_INVOKABLE void toggleSection(const QString& section); Q_INVOKABLE int currentUidSmartListModelIndex(); Q_INVOKABLE void fillConversationsList(); - Q_INVOKABLE void updateConversation(const QString &conv); + Q_INVOKABLE void updateConversation(const QString& conv); private: QString accountId_; - QVariant getConversationItemData(const ConversationInfo &item, - const AccountInfo &accountInfo, + QVariant getConversationItemData(const ConversationInfo& item, + const AccountInfo& accountInfo, int role) const; /* * List sectioning. diff --git a/src/tintedbuttonimageprovider.h b/src/tintedbuttonimageprovider.h index 384989be2e7dab9048ccfc747b923eb23e04d568..ce6149c70e7e2719feec28c670b06986ca2dbc46 100644 --- a/src/tintedbuttonimageprovider.h +++ b/src/tintedbuttonimageprovider.h @@ -35,8 +35,7 @@ public: QQmlImageProviderBase::ForceAsynchronousImageLoading) {} - QPixmap - requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) override + QPixmap requestPixmap(const QString& id, QSize* size, const QSize& requestedSize) override { Q_UNUSED(size); diff --git a/src/utils.cpp b/src/utils.cpp index c2d63fb81570b86efbe20d74491dca9230b8d68c..7cfdc54c321cf09d3c8f361784a57d43701351c2 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -281,8 +281,8 @@ Utils::getCirclePhoto(const QImage original, int sizePhoto) } void -Utils::showSystemNotification(QWidget *widget, - const QString &message, +Utils::showSystemNotification(QWidget* widget, + const QString& message, long delay, const QString& triggeredAccountId) { @@ -525,7 +525,7 @@ Utils::secondBestNameForAccount(const lrc::api::account::Info& account) auto infoHash = account.profileInfo.uri; if (alias.length() != 0) { - if (registeredName.length() != 0) { + if (registeredName.length() != 0) { return registeredName; } else { return infoHash; @@ -632,9 +632,7 @@ Utils::getAvatarColor(const QString& canonicalUri) * color. */ QImage -Utils::fallbackAvatar(const QString &canonicalUriStr, - const QString &letterStr, - const QSize &size) +Utils::fallbackAvatar(const QString& canonicalUriStr, const QString& letterStr, const QSize& size) { /* * We start with a transparent avatar. @@ -704,13 +702,9 @@ Utils::fallbackAvatar(const QString &canonicalUriStr, } QImage -Utils::fallbackAvatar(const std::string &alias, - const std::string &uri, - const QSize &size) +Utils::fallbackAvatar(const std::string& alias, const std::string& uri, const QSize& size) { - return fallbackAvatar(QString::fromStdString(uri), - QString::fromStdString(alias), - size); + return fallbackAvatar(QString::fromStdString(uri), QString::fromStdString(alias), size); } QByteArray @@ -749,10 +743,10 @@ QImage Utils::setupQRCode(QString ringID, int margin) { auto qrcode = QRcode_encodeString(ringID.toStdString().c_str(), - 0, // Let the version be decided by libqrencode - QR_ECLEVEL_L, // Lowest level of error correction - QR_MODE_8, // 8-bit data mode - 1); + 0, // Let the version be decided by libqrencode + QR_ECLEVEL_L, // Lowest level of error correction + QR_MODE_8, // 8-bit data mode + 1); if (not qrcode) { qWarning() << "Failed to generate QR code"; return QImage(); @@ -766,10 +760,10 @@ Utils::setupQRCode(QString ringID, int margin) painter.setPen(QPen(Qt::black, 0.1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); painter.setBrush(Qt::black); painter.fillRect(QRect(0, 0, qrwidth, qrwidth), Qt::white); - unsigned char *p; + unsigned char* p; p = qrcode->data; for (int y = 0; y < qrcode->width; y++) { - unsigned char *row = (p + (y * qrcode->width)); + unsigned char* row = (p + (y * qrcode->width)); for (int x = 0; x < qrcode->width; x++) { if (*(row + x) & 0x1) { painter.drawRect(margin + x, margin + y, 1, 1); @@ -889,7 +883,8 @@ Utils::humanFileSize(qint64 fileSize) return QString::number(fileSizeF) + " " + units[unit_position]; } -bool Utils::isImage(const QString &fileExt) +bool +Utils::isImage(const QString& fileExt) { if (fileExt == "png" || fileExt == "jpg" || fileExt == "jpeg") return true; diff --git a/src/utils.h b/src/utils.h index e4cba7cdc774ebb543eb512e73aad7bf9fd5a543..5f8095aa302f4835a8958916a7854e753804b477 100644 --- a/src/utils.h +++ b/src/utils.h @@ -61,13 +61,13 @@ namespace Utils { bool CreateStartupLink(const std::wstring& wstrAppName); void DeleteStartupLink(const std::wstring& wstrAppName); bool CreateLink(LPCWSTR lpszPathObj, LPCWSTR lpszPathLink); -bool CheckStartupLink(const std::wstring &wstrAppName); -const char *WinGetEnv(const char *name); +bool CheckStartupLink(const std::wstring& wstrAppName); +const char* WinGetEnv(const char* name); QString GetRingtonePath(); QString GenGUID(); QString GetISODate(); -void showSystemNotification(QWidget *widget, - const QString &message, +void showSystemNotification(QWidget* widget, + const QString& message, long delay = 5000, const QString& triggeredAccountId = ""); void showSystemNotification(QWidget* widget, @@ -96,46 +96,47 @@ void applyUpdates(bool updateToBeta, QWidget* parent = nullptr); /* * LRC helpers */ -QString bestIdForConversation(const lrc::api::conversation::Info &conv, - const lrc::api::ConversationModel &model); -QString bestIdForAccount(const lrc::api::account::Info &account); -QString bestNameForAccount(const lrc::api::account::Info &account); -QString bestIdForContact(const lrc::api::contact::Info &contact); -QString bestNameForContact(const lrc::api::contact::Info &contact); -QString bestNameForConversation(const lrc::api::conversation::Info &conv, - const lrc::api::ConversationModel &model); -QString secondBestNameForAccount(const lrc::api::account::Info &account); -lrc::api::profile::Type profileType(const lrc::api::conversation::Info &conv, - const lrc::api::ConversationModel &model); -std::string formatTimeString(const std::time_t ×tamp); -bool isInteractionGenerated(const lrc::api::interaction::Type &interaction); -bool isContactValid(const QString &contactUid, const lrc::api::ConversationModel &model); -bool getReplyMessageBox(QWidget *widget, const QString &title, const QString &text); +QString bestIdForConversation(const lrc::api::conversation::Info& conv, + const lrc::api::ConversationModel& model); +QString bestIdForAccount(const lrc::api::account::Info& account); +QString bestNameForAccount(const lrc::api::account::Info& account); +QString bestIdForContact(const lrc::api::contact::Info& contact); +QString bestNameForContact(const lrc::api::contact::Info& contact); +QString bestNameForConversation(const lrc::api::conversation::Info& conv, + const lrc::api::ConversationModel& model); +QString secondBestNameForAccount(const lrc::api::account::Info& account); +lrc::api::profile::Type profileType(const lrc::api::conversation::Info& conv, + const lrc::api::ConversationModel& model); +std::string formatTimeString(const std::time_t& timestamp); +bool isInteractionGenerated(const lrc::api::interaction::Type& interaction); +bool isContactValid(const QString& contactUid, const lrc::api::ConversationModel& model); +bool getReplyMessageBox(QWidget* widget, const QString& title, const QString& text); /* * Image manipulation */ -static const QSize defaultAvatarSize { 128, 128 }; -QString getContactImageString(const QString &accountId, const QString &uid); +static const QSize defaultAvatarSize {128, 128}; +QString getContactImageString(const QString& accountId, const QString& uid); QImage getCirclePhoto(const QImage original, int sizePhoto); QImage conversationPhoto(const QString& convUid, const lrc::api::account::Info& accountInfo, bool filtered = false); -QColor getAvatarColor(const QString &canonicalUri); -QImage fallbackAvatar(const QString &canonicalUriStr, - const QString &letterStr = QString(), - const QSize &size = defaultAvatarSize); -QImage fallbackAvatar(const std::string &alias, - const std::string &uri, - const QSize &size = defaultAvatarSize); +QColor getAvatarColor(const QString& canonicalUri); +QImage fallbackAvatar(const QString& canonicalUriStr, + const QString& letterStr = QString(), + const QSize& size = defaultAvatarSize); +QImage fallbackAvatar(const std::string& alias, + const std::string& uri, + const QSize& size = defaultAvatarSize); QByteArray QImageToByteArray(QImage image); -QByteArray QByteArrayFromFile(const QString &filename); -QPixmap generateTintedPixmap(const QString &filename, QColor color); -QPixmap generateTintedPixmap(const QPixmap &pix, QColor color); -QImage scaleAndFrame(const QImage photo, const QSize &size = defaultAvatarSize); -QImage accountPhoto(const lrc::api::account::Info &accountInfo, const QSize &size = defaultAvatarSize); -QImage cropImage(const QImage &img); -QPixmap pixmapFromSvg(const QString &svg_resource, const QSize &size); +QByteArray QByteArrayFromFile(const QString& filename); +QPixmap generateTintedPixmap(const QString& filename, QColor color); +QPixmap generateTintedPixmap(const QPixmap& pix, QColor color); +QImage scaleAndFrame(const QImage photo, const QSize& size = defaultAvatarSize); +QImage accountPhoto(const lrc::api::account::Info& accountInfo, + const QSize& size = defaultAvatarSize); +QImage cropImage(const QImage& img); +QPixmap pixmapFromSvg(const QString& svg_resource, const QSize& size); QImage setupQRCode(QString ringID, int margin); bool isImage(const QString& fileExt); @@ -146,5 +147,3 @@ QString formattedTime(int seconds); QString humanFileSize(qint64 fileSize); } // namespace Utils - - diff --git a/src/utilsadapter.cpp b/src/utilsadapter.cpp index 88dee99e4017c5bd07958516a62d088ba8749d5f..993498f7762d6268b4b9ea4b04151bb6fb52d6e3 100644 --- a/src/utilsadapter.cpp +++ b/src/utilsadapter.cpp @@ -30,7 +30,7 @@ #include <QClipboard> #include <QFileInfo> -UtilsAdapter::UtilsAdapter(QObject *parent) +UtilsAdapter::UtilsAdapter(QObject* parent) : QObject(parent) , clipboard_(QApplication::clipboard()) {} diff --git a/src/version.h b/src/version.h index d5eea6dca4edad4e2e25b2cf87dff653dddafde1..aea611a49e0a834321a8b40146778c0e2f5ef1ce 100644 --- a/src/version.h +++ b/src/version.h @@ -1,5 +1,6 @@ #pragma once +// clang-format off #define BUILD_YEAR_CH0 (__DATE__[ 7]) #define BUILD_YEAR_CH1 (__DATE__[ 8]) #define BUILD_YEAR_CH2 (__DATE__[ 9]) @@ -54,4 +55,5 @@ const char VERSION_STRING[] = { BUILD_HOUR_CH0, BUILD_HOUR_CH1, BUILD_MIN_CH0, BUILD_MIN_CH1, '\0' -}; \ No newline at end of file +}; +// clang-format on diff --git a/src/videocodeclistmodel.cpp b/src/videocodeclistmodel.cpp index d77a207cf3521d84e6501bb5c76df77f6dd4a176..f3de621df314fc3e173d6ded0d0c0720bb705e1b 100644 --- a/src/videocodeclistmodel.cpp +++ b/src/videocodeclistmodel.cpp @@ -20,14 +20,14 @@ #include <QList> -VideoCodecListModel::VideoCodecListModel(QObject *parent) +VideoCodecListModel::VideoCodecListModel(QObject* parent) : QAbstractListModel(parent) {} VideoCodecListModel::~VideoCodecListModel() {} int -VideoCodecListModel::rowCount(const QModelIndex &parent) const +VideoCodecListModel::rowCount(const QModelIndex& parent) const { if (!parent.isValid()) { /* @@ -51,7 +51,7 @@ VideoCodecListModel::rowCount(const QModelIndex &parent) const } int -VideoCodecListModel::columnCount(const QModelIndex &parent) const +VideoCodecListModel::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent); /* @@ -61,7 +61,7 @@ VideoCodecListModel::columnCount(const QModelIndex &parent) const } QVariant -VideoCodecListModel::data(const QModelIndex &index, int role) const +VideoCodecListModel::data(const QModelIndex& index, int role) const { auto videoCodecList = LRCInstance::getCurrentAccountInfo().codecModel->getVideoCodecs(); if (!index.isValid() || videoCodecList.size() <= index.row()) { @@ -98,7 +98,7 @@ VideoCodecListModel::roleNames() const } QModelIndex -VideoCodecListModel::index(int row, int column, const QModelIndex &parent) const +VideoCodecListModel::index(int row, int column, const QModelIndex& parent) const { Q_UNUSED(parent); if (column != 0) { @@ -112,14 +112,14 @@ VideoCodecListModel::index(int row, int column, const QModelIndex &parent) const } QModelIndex -VideoCodecListModel::parent(const QModelIndex &child) const +VideoCodecListModel::parent(const QModelIndex& child) const { Q_UNUSED(child); return QModelIndex(); } Qt::ItemFlags -VideoCodecListModel::flags(const QModelIndex &index) const +VideoCodecListModel::flags(const QModelIndex& index) const { auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled; diff --git a/src/videocodeclistmodel.h b/src/videocodeclistmodel.h index 96a34a7108e25b83cc5ab96d89de230439cdd63a..ec1f7aab9fd8fefc01544c13eb546cb14710fa5d 100644 --- a/src/videocodeclistmodel.h +++ b/src/videocodeclistmodel.h @@ -34,20 +34,20 @@ public: enum Role { VideoCodecName = Qt::UserRole + 1, IsEnabled, VideoCodecID }; Q_ENUM(Role) - explicit VideoCodecListModel(QObject *parent = 0); + explicit VideoCodecListModel(QObject* parent = 0); ~VideoCodecListModel(); /* * QAbstractListModel override. */ - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex& parent) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; /* * Override role name as access point in qml. */ QHash<int, QByteArray> roleNames() const override; - QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; - Qt::ItemFlags flags(const QModelIndex &index) const; + QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex& child) const; + Qt::ItemFlags flags(const QModelIndex& index) const; }; diff --git a/src/videoformatfpsmodel.cpp b/src/videoformatfpsmodel.cpp index 4c5fe15ee26e55e6143b02f2818a8cc0532109c4..6d1dbac03c8e3d96bb71529998e9f37f1711ce0b 100644 --- a/src/videoformatfpsmodel.cpp +++ b/src/videoformatfpsmodel.cpp @@ -18,14 +18,14 @@ #include "videoformatfpsmodel.h" -VideoFormatFpsModel::VideoFormatFpsModel(QObject *parent) +VideoFormatFpsModel::VideoFormatFpsModel(QObject* parent) : QAbstractListModel(parent) { try { QString currentDeviceId = LRCInstance::avModel().getCurrentVideoCaptureDevice(); auto currentSettings = LRCInstance::avModel().getDeviceSettings(currentDeviceId); currentResolution_ = currentSettings.size; - } catch (const std::exception &e) { + } catch (const std::exception& e) { qWarning() << "Constructor of VideoFormatFpsModel, exception: " << e.what(); } } @@ -33,7 +33,7 @@ VideoFormatFpsModel::VideoFormatFpsModel(QObject *parent) VideoFormatFpsModel::~VideoFormatFpsModel() {} int -VideoFormatFpsModel::rowCount(const QModelIndex &parent) const +VideoFormatFpsModel::rowCount(const QModelIndex& parent) const { if (!parent.isValid()) { /* @@ -65,7 +65,7 @@ VideoFormatFpsModel::rowCount(const QModelIndex &parent) const auto fpsList = channelCaps[indexOfCurrentResolutionInResRateList].second; return fpsList.size(); } - } catch (const std::exception &e) { + } catch (const std::exception& e) { qWarning() << e.what(); } return 0; @@ -77,7 +77,7 @@ VideoFormatFpsModel::rowCount(const QModelIndex &parent) const } int -VideoFormatFpsModel::columnCount(const QModelIndex &parent) const +VideoFormatFpsModel::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent); /* @@ -87,7 +87,7 @@ VideoFormatFpsModel::columnCount(const QModelIndex &parent) const } QVariant -VideoFormatFpsModel::data(const QModelIndex &index, int role) const +VideoFormatFpsModel::data(const QModelIndex& index, int role) const { try { QString currentDeviceId = LRCInstance::avModel().getCurrentVideoCaptureDevice(); @@ -124,7 +124,7 @@ VideoFormatFpsModel::data(const QModelIndex &index, int role) const return QVariant(rateDisplayUtf8.toUtf8()); } - } catch (const std::exception &e) { + } catch (const std::exception& e) { qWarning() << e.what(); } @@ -141,7 +141,7 @@ VideoFormatFpsModel::roleNames() const } QModelIndex -VideoFormatFpsModel::index(int row, int column, const QModelIndex &parent) const +VideoFormatFpsModel::index(int row, int column, const QModelIndex& parent) const { Q_UNUSED(parent); if (column != 0) { @@ -155,14 +155,14 @@ VideoFormatFpsModel::index(int row, int column, const QModelIndex &parent) const } QModelIndex -VideoFormatFpsModel::parent(const QModelIndex &child) const +VideoFormatFpsModel::parent(const QModelIndex& child) const { Q_UNUSED(child); return QModelIndex(); } Qt::ItemFlags -VideoFormatFpsModel::flags(const QModelIndex &index) const +VideoFormatFpsModel::flags(const QModelIndex& index) const { auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable; if (!index.isValid()) { @@ -192,7 +192,7 @@ VideoFormatFpsModel::getCurrentSettingIndex() resultRowIndex = resultList[0].row(); } - } catch (const std::exception &e) { + } catch (const std::exception& e) { qWarning() << e.what(); } diff --git a/src/videoformatfpsmodel.h b/src/videoformatfpsmodel.h index cd165ccf9adce8bbbb854e404bda8410d709df5e..9b5c18f1145343bd5097886fb36838ee9696f982 100644 --- a/src/videoformatfpsmodel.h +++ b/src/videoformatfpsmodel.h @@ -37,22 +37,22 @@ public: enum Role { FPS = Qt::UserRole + 1, FPS_ToDisplay_UTF8 }; Q_ENUM(Role) - explicit VideoFormatFpsModel(QObject *parent = 0); + explicit VideoFormatFpsModel(QObject* parent = 0); ~VideoFormatFpsModel(); /* * QAbstractListModel override. */ - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex& parent) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; /* * Override role name as access point in qml. */ QHash<int, QByteArray> roleNames() const override; - QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; - Qt::ItemFlags flags(const QModelIndex &index) const; + QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex& child) const; + Qt::ItemFlags flags(const QModelIndex& index) const; /* * This function is to reset the model when there's new account added. diff --git a/src/videoformatresolutionmodel.cpp b/src/videoformatresolutionmodel.cpp index dea96358fe36acfd8e8a3fdeb9d692a67bd9c2d2..ebf07656ceacde4b8af42fc18007b7bc4819de4b 100644 --- a/src/videoformatresolutionmodel.cpp +++ b/src/videoformatresolutionmodel.cpp @@ -18,14 +18,14 @@ #include "videoformatresolutionmodel.h" -VideoFormatResolutionModel::VideoFormatResolutionModel(QObject *parent) +VideoFormatResolutionModel::VideoFormatResolutionModel(QObject* parent) : QAbstractListModel(parent) {} VideoFormatResolutionModel::~VideoFormatResolutionModel() {} int -VideoFormatResolutionModel::rowCount(const QModelIndex &parent) const +VideoFormatResolutionModel::rowCount(const QModelIndex& parent) const { if (!parent.isValid()) { /* @@ -43,7 +43,7 @@ VideoFormatResolutionModel::rowCount(const QModelIndex &parent) const auto channelCaps = deviceCapabilities[currentChannel]; return channelCaps.size(); - } catch (const std::exception &e) { + } catch (const std::exception& e) { qWarning() << e.what(); return 0; } @@ -55,7 +55,7 @@ VideoFormatResolutionModel::rowCount(const QModelIndex &parent) const } int -VideoFormatResolutionModel::columnCount(const QModelIndex &parent) const +VideoFormatResolutionModel::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent); /* @@ -65,7 +65,7 @@ VideoFormatResolutionModel::columnCount(const QModelIndex &parent) const } QVariant -VideoFormatResolutionModel::data(const QModelIndex &index, int role) const +VideoFormatResolutionModel::data(const QModelIndex& index, int role) const { try { QString currentDeviceId = LRCInstance::avModel().getCurrentVideoCaptureDevice(); @@ -88,7 +88,7 @@ VideoFormatResolutionModel::data(const QModelIndex &index, int role) const return QVariant(channelCaps.at(index.row()).first.toUtf8()); } - } catch (const std::exception &e) { + } catch (const std::exception& e) { qWarning() << e.what(); } @@ -105,7 +105,7 @@ VideoFormatResolutionModel::roleNames() const } QModelIndex -VideoFormatResolutionModel::index(int row, int column, const QModelIndex &parent) const +VideoFormatResolutionModel::index(int row, int column, const QModelIndex& parent) const { Q_UNUSED(parent); if (column != 0) { @@ -119,14 +119,14 @@ VideoFormatResolutionModel::index(int row, int column, const QModelIndex &parent } QModelIndex -VideoFormatResolutionModel::parent(const QModelIndex &child) const +VideoFormatResolutionModel::parent(const QModelIndex& child) const { Q_UNUSED(child); return QModelIndex(); } Qt::ItemFlags -VideoFormatResolutionModel::flags(const QModelIndex &index) const +VideoFormatResolutionModel::flags(const QModelIndex& index) const { auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable; if (!index.isValid()) { @@ -156,7 +156,7 @@ VideoFormatResolutionModel::getCurrentSettingIndex() resultRowIndex = resultList[0].row(); } - } catch (const std::exception &e) { + } catch (const std::exception& e) { qWarning() << e.what(); } diff --git a/src/videoformatresolutionmodel.h b/src/videoformatresolutionmodel.h index 8a3c8032b720f0f9198e859bf7f58dfd7611654b..c79a8311351a0b252a3c1398e2dd2e01b8c24b98 100644 --- a/src/videoformatresolutionmodel.h +++ b/src/videoformatresolutionmodel.h @@ -34,22 +34,22 @@ public: enum Role { Resolution = Qt::UserRole + 1, Resolution_UTF8 }; Q_ENUM(Role) - explicit VideoFormatResolutionModel(QObject *parent = 0); + explicit VideoFormatResolutionModel(QObject* parent = 0); ~VideoFormatResolutionModel(); /* * QAbstractListModel override. */ - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex& parent) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; /* * Override role name as access point in qml. */ QHash<int, QByteArray> roleNames() const override; - QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; - Qt::ItemFlags flags(const QModelIndex &index) const; + QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex& child) const; + Qt::ItemFlags flags(const QModelIndex& index) const; /* * This function is to reset the model when there's new account added. diff --git a/src/videoinputdevicemodel.cpp b/src/videoinputdevicemodel.cpp index dfc349b3293c0828f595dbd387ef4a880566ba77..e768df6e77f71fe9aeb90ec7d1ba9c3b71a65873 100644 --- a/src/videoinputdevicemodel.cpp +++ b/src/videoinputdevicemodel.cpp @@ -18,14 +18,14 @@ #include "videoinputdevicemodel.h" -VideoInputDeviceModel::VideoInputDeviceModel(QObject *parent) +VideoInputDeviceModel::VideoInputDeviceModel(QObject* parent) : QAbstractListModel(parent) {} VideoInputDeviceModel::~VideoInputDeviceModel() {} int -VideoInputDeviceModel::rowCount(const QModelIndex &parent) const +VideoInputDeviceModel::rowCount(const QModelIndex& parent) const { if (!parent.isValid()) { /* @@ -45,7 +45,7 @@ VideoInputDeviceModel::rowCount(const QModelIndex &parent) const } int -VideoInputDeviceModel::columnCount(const QModelIndex &parent) const +VideoInputDeviceModel::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent); /* @@ -55,7 +55,7 @@ VideoInputDeviceModel::columnCount(const QModelIndex &parent) const } QVariant -VideoInputDeviceModel::data(const QModelIndex &index, int role) const +VideoInputDeviceModel::data(const QModelIndex& index, int role) const { auto deviceList = LRCInstance::avModel().getDevices(); if (!index.isValid()) { @@ -108,7 +108,7 @@ VideoInputDeviceModel::roleNames() const } QModelIndex -VideoInputDeviceModel::index(int row, int column, const QModelIndex &parent) const +VideoInputDeviceModel::index(int row, int column, const QModelIndex& parent) const { Q_UNUSED(parent); if (column != 0) { @@ -122,14 +122,14 @@ VideoInputDeviceModel::index(int row, int column, const QModelIndex &parent) con } QModelIndex -VideoInputDeviceModel::parent(const QModelIndex &child) const +VideoInputDeviceModel::parent(const QModelIndex& child) const { Q_UNUSED(child); return QModelIndex(); } Qt::ItemFlags -VideoInputDeviceModel::flags(const QModelIndex &index) const +VideoInputDeviceModel::flags(const QModelIndex& index) const { auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable; if (!index.isValid()) { diff --git a/src/videoinputdevicemodel.h b/src/videoinputdevicemodel.h index 99d5898e1b6dd10899bf6054d15e28dcc8543055..99343b5ac7195590c386d232af805314db893f3b 100644 --- a/src/videoinputdevicemodel.h +++ b/src/videoinputdevicemodel.h @@ -41,22 +41,22 @@ public: }; Q_ENUM(Role) - explicit VideoInputDeviceModel(QObject *parent = 0); + explicit VideoInputDeviceModel(QObject* parent = 0); ~VideoInputDeviceModel(); /* * QAbstractListModel override. */ - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex& parent) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; /* * Override role name as access point in qml. */ QHash<int, QByteArray> roleNames() const override; - QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; - Qt::ItemFlags flags(const QModelIndex &index) const; + QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex& child) const; + Qt::ItemFlags flags(const QModelIndex& index) const; /* * This function is to reset the model when there's new account added. diff --git a/src/webchathelpers.cpp b/src/webchathelpers.cpp index 273948c35feb7d8c71aaed09bc634b2b54b7a258..1524d15c2cb5e1a75d1a71945347f574e1dadfe3 100644 --- a/src/webchathelpers.cpp +++ b/src/webchathelpers.cpp @@ -22,15 +22,14 @@ #include "webchathelpers.h" QJsonObject -buildInteractionJson(lrc::api::ConversationModel &conversationModel, +buildInteractionJson(lrc::api::ConversationModel& conversationModel, const uint64_t msgId, - const lrc::api::interaction::Info &inter) + const lrc::api::interaction::Info& inter) { - QRegExp reg(".(jpeg|jpg|gif|png)$"); auto interaction = inter; - if (interaction.type == lrc::api::interaction::Type::DATA_TRANSFER && - interaction.body.toLower().contains(reg)) { + if (interaction.type == lrc::api::interaction::Type::DATA_TRANSFER + && interaction.body.toLower().contains(reg)) { interaction.body = "file://" + interaction.body; } @@ -125,20 +124,20 @@ buildInteractionJson(lrc::api::ConversationModel &conversationModel, } QString -interactionToJsonInteractionObject(lrc::api::ConversationModel &conversationModel, +interactionToJsonInteractionObject(lrc::api::ConversationModel& conversationModel, const uint64_t msgId, - const lrc::api::interaction::Info &interaction) + const lrc::api::interaction::Info& interaction) { auto interactionObject = buildInteractionJson(conversationModel, msgId, interaction); return QString(QJsonDocument(interactionObject).toJson(QJsonDocument::Compact)); } QString -interactionsToJsonArrayObject(lrc::api::ConversationModel &conversationModel, +interactionsToJsonArrayObject(lrc::api::ConversationModel& conversationModel, const std::map<uint64_t, lrc::api::interaction::Info> interactions) { QJsonArray array; - for (const auto &interaction : interactions) { + for (const auto& interaction : interactions) { auto interactionObject = buildInteractionJson(conversationModel, interaction.first, interaction.second); diff --git a/src/webchathelpers.h b/src/webchathelpers.h index f44dd6204bcb7d1f8ae923896d89791f01d47d8b..0354bc06069223864912b3c4b97f5286d6f06859 100644 --- a/src/webchathelpers.h +++ b/src/webchathelpers.h @@ -28,12 +28,12 @@ #include "api/conversationmodel.h" -QJsonObject buildInteractionJson(lrc::api::ConversationModel &conversationModel, +QJsonObject buildInteractionJson(lrc::api::ConversationModel& conversationModel, const uint64_t msgId, - const lrc::api::interaction::Info &interaction); -QString interactionToJsonInteractionObject(lrc::api::ConversationModel &conversationModel, + const lrc::api::interaction::Info& interaction); +QString interactionToJsonInteractionObject(lrc::api::ConversationModel& conversationModel, const uint64_t msgId, - const lrc::api::interaction::Info &interaction); + const lrc::api::interaction::Info& interaction); QString interactionsToJsonArrayObject( - lrc::api::ConversationModel &conversationModel, + lrc::api::ConversationModel& conversationModel, const std::map<uint64_t, lrc::api::interaction::Info> interactions);