mirror of
https://github.com/savoirfairelinux/jami-client-qt.git
synced 2026-01-04 11:03:06 +08:00
misc: avoid using magic numbers
- register SmartListModel - acces to AccountListModel and SmartListModel registered enumerations Change-Id: Idbc943a3b6a6f2989be7d20f5fe4259402a5adeb
This commit is contained in:
@@ -35,8 +35,8 @@ ContactAdapter::getContactSelectableModel(int type)
|
||||
* Called from qml every time contact picker refreshes.
|
||||
*/
|
||||
listModeltype_ = static_cast<SmartListModel::Type>(type);
|
||||
smartListModel_.reset(new SmartListModel(LRCInstance::getCurrAccId(),
|
||||
this,
|
||||
smartListModel_.reset(new SmartListModel(this,
|
||||
LRCInstance::getCurrAccId(),
|
||||
listModeltype_,
|
||||
LRCInstance::getCurrentConvUid()));
|
||||
selectableProxyModel_->setSourceModel(smartListModel_.get());
|
||||
|
||||
@@ -35,7 +35,7 @@ ConversationsAdapter::ConversationsAdapter(QObject* parent)
|
||||
void
|
||||
ConversationsAdapter::safeInit()
|
||||
{
|
||||
conversationSmartListModel_ = new SmartListModel(LRCInstance::getCurrAccId(), this);
|
||||
conversationSmartListModel_ = new SmartListModel(this, LRCInstance::getCurrAccId());
|
||||
|
||||
emit modelChanged(QVariant::fromValue(conversationSmartListModel_));
|
||||
|
||||
|
||||
@@ -42,11 +42,13 @@ ComboBox {
|
||||
|
||||
function onModelReset() {
|
||||
userImageRoot.source = "data:image/png;base64," + accountListModel.data(
|
||||
accountListModel.index(0, 0), 259)
|
||||
accountListModel.index(0, 0), AccountListModel.Picture)
|
||||
currentAccountPresenseCycle.accountStatus =
|
||||
accountListModel.data(accountListModel.index(0, 0), 261)
|
||||
textMetricsUserAliasRoot.text = accountListModel.data(accountListModel.index(0,0), 257)
|
||||
textMetricsUsernameRoot.text = accountListModel.data(accountListModel.index(0,0), 258)
|
||||
accountListModel.data(accountListModel.index(0, 0), AccountListModel.Status)
|
||||
textMetricsUserAliasRoot.text = accountListModel.data(accountListModel.index(0,0),
|
||||
AccountListModel.Alias)
|
||||
textMetricsUsernameRoot.text = accountListModel.data(accountListModel.index(0,0),
|
||||
AccountListModel.Username)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +74,7 @@ ComboBox {
|
||||
|
||||
// Base 64 format
|
||||
source: "data:image/png;base64," + accountListModel.data(
|
||||
accountListModel.index(0, 0), 259)
|
||||
accountListModel.index(0, 0), AccountListModel.Picture)
|
||||
mipmap: true
|
||||
|
||||
AccountPresenceCycle {
|
||||
@@ -83,7 +85,8 @@ ComboBox {
|
||||
anchors.bottom: userImageRoot.bottom
|
||||
anchors.bottomMargin: -2
|
||||
|
||||
accountStatus: accountListModel.data(accountListModel.index(0, 0), 261)
|
||||
accountStatus: accountListModel.data(accountListModel.index(0, 0),
|
||||
AccountListModel.Status)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,8 +136,7 @@ ComboBox {
|
||||
elideWidth: root.width - userImageRoot.width - settingsButton.width
|
||||
- arrowDropDown.width - qrCodeGenerateButton.width - 55
|
||||
|
||||
// Role::Alias
|
||||
text: accountListModel.data(accountListModel.index(0,0), 257)
|
||||
text: accountListModel.data(accountListModel.index(0,0), AccountListModel.Alias)
|
||||
}
|
||||
|
||||
TextMetrics {
|
||||
@@ -145,10 +147,8 @@ ComboBox {
|
||||
elideWidth: root.width - userImageRoot.width - settingsButton.width
|
||||
- qrCodeGenerateButton.width - 55
|
||||
|
||||
|
||||
|
||||
// Role::Username
|
||||
text: accountListModel.data(accountListModel.index(0,0), 258)
|
||||
text: accountListModel.data(accountListModel.index(0,0),
|
||||
AccountListModel.Username)
|
||||
}
|
||||
|
||||
HoverableButton {
|
||||
|
||||
@@ -68,7 +68,8 @@ Popup {
|
||||
|
||||
// Role::Picture
|
||||
source: {
|
||||
var data = accountListModel.data(accountListModel.index(index, 0), 259)
|
||||
var data = accountListModel.data(accountListModel.index(index, 0),
|
||||
AccountListModel.Picture)
|
||||
if (data === undefined) {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ ListView {
|
||||
updateListView()
|
||||
for (var i = 0; i < count; i++) {
|
||||
if (root.model.data(
|
||||
root.model.index(i, 0), 261) === uri) {
|
||||
root.model.index(i, 0), SmartListModel.URI) === uri) {
|
||||
root.currentIndex = i
|
||||
break
|
||||
}
|
||||
|
||||
@@ -111,6 +111,7 @@ registerTypes()
|
||||
QML_REGISTERTYPE("net.jami.Models", VideoFormatResolutionModel, 1, 0);
|
||||
QML_REGISTERTYPE("net.jami.Models", VideoFormatFpsModel, 1, 0);
|
||||
QML_REGISTERTYPE("net.jami.Models", PluginListPreferenceModel, 1, 0);
|
||||
QML_REGISTERTYPE("net.jami.Models", SmartListModel, 1, 0);
|
||||
|
||||
/*
|
||||
* QQuickItems
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
SmartListModel::SmartListModel(const QString& accId,
|
||||
QObject* parent,
|
||||
SmartListModel::SmartListModel(QObject* parent,
|
||||
const QString& accId,
|
||||
SmartListModel::Type listModelType,
|
||||
const QString& convUid)
|
||||
: QAbstractListModel(parent)
|
||||
|
||||
@@ -60,9 +60,10 @@ public:
|
||||
AccountId,
|
||||
Draft
|
||||
};
|
||||
Q_ENUM(Role)
|
||||
|
||||
explicit SmartListModel(const QString& accId,
|
||||
QObject* parent = 0,
|
||||
explicit SmartListModel(QObject* parent = 0,
|
||||
const QString& accId = {},
|
||||
SmartListModel::Type listModelType = Type::CONVERSATION,
|
||||
const QString& convUid = {});
|
||||
~SmartListModel();
|
||||
|
||||
Reference in New Issue
Block a user