mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
Use sourceModel to set proxy models in order to avoid loading unused data.
This commit is contained in:
parent
075937aa00
commit
18fc4de29d
18 changed files with 87 additions and 53 deletions
|
|
@ -482,8 +482,8 @@ void App::initCore() {
|
|||
mSettings = settings;
|
||||
mEngine->setObjectOwnership(mSettings.get(), QQmlEngine::CppOwnership);
|
||||
mEngine->setObjectOwnership(this, QQmlEngine::CppOwnership);
|
||||
mAccountList = AccountList::create();
|
||||
mCallList = CallList::create();
|
||||
setAccountList(AccountList::create());
|
||||
setCallList(CallList::create());
|
||||
setAutoStart(mSettings->getAutoStart());
|
||||
setQuitOnLastWindowClosed(mSettings->getExitOnClose());
|
||||
connect(mSettings.get(), &SettingsCore::exitOnCloseChanged, this, &App::onExitOnCloseChanged,
|
||||
|
|
@ -561,12 +561,6 @@ void App::initCppInterfaces() {
|
|||
qmlRegisterSingletonType<SettingsCore>(
|
||||
"SettingsCpp", 1, 0, "SettingsCpp",
|
||||
[this](QQmlEngine *engine, QJSEngine *) -> QObject * { return mSettings.get(); });
|
||||
qmlRegisterSingletonType<AccountList>(
|
||||
"LinphoneAccountsCpp", 1, 0, "LinphoneAccountsCpp",
|
||||
[this](QQmlEngine *engine, QJSEngine *) -> QObject * { return mAccountList.get(); });
|
||||
qmlRegisterSingletonType<CallList>(
|
||||
"LinphoneCallsCpp", 1, 0, "LinphoneCallsCpp",
|
||||
[this](QQmlEngine *engine, QJSEngine *) -> QObject * { return mCallList.get(); });
|
||||
|
||||
qmlRegisterType<PhoneNumberProxy>(Constants::MainQmlUri, 1, 0, "PhoneNumberProxy");
|
||||
qmlRegisterType<VariantObject>(Constants::MainQmlUri, 1, 0, "VariantObject");
|
||||
|
|
@ -799,10 +793,32 @@ QSharedPointer<AccountList> App::getAccountList() const {
|
|||
return mAccountList;
|
||||
}
|
||||
|
||||
void App::setAccountList(QSharedPointer<AccountList> data) {
|
||||
if (mAccountList != data) {
|
||||
mAccountList = data;
|
||||
emit accountsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
AccountList *App::getAccounts() const {
|
||||
return mAccountList.get();
|
||||
}
|
||||
|
||||
QSharedPointer<CallList> App::getCallList() const {
|
||||
return mCallList;
|
||||
}
|
||||
|
||||
void App::setCallList(QSharedPointer<CallList> data) {
|
||||
if (mCallList != data) {
|
||||
mCallList = data;
|
||||
emit callsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
CallList *App::getCalls() const {
|
||||
return mCallList.get();
|
||||
}
|
||||
|
||||
QSharedPointer<SettingsCore> App::getSettings() const {
|
||||
return mSettings;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ class QSystemTrayIcon;
|
|||
class App : public SingleApplication, public AbstractObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool coreStarted READ getCoreStarted WRITE setCoreStarted NOTIFY coreStartedChanged)
|
||||
Q_PROPERTY(AccountList *accounts READ getAccounts NOTIFY accountsChanged)
|
||||
Q_PROPERTY(CallList *calls READ getCalls NOTIFY callsChanged)
|
||||
public:
|
||||
App(int &argc, char *argv[]);
|
||||
~App();
|
||||
|
|
@ -124,7 +126,12 @@ public:
|
|||
QQuickWindow *getMainWindow() const;
|
||||
void setMainWindow(QQuickWindow *data);
|
||||
QSharedPointer<AccountList> getAccountList() const;
|
||||
void setAccountList(QSharedPointer<AccountList> data);
|
||||
Q_INVOKABLE AccountList *getAccounts() const;
|
||||
|
||||
QSharedPointer<CallList> getCallList() const;
|
||||
void setCallList(QSharedPointer<CallList> data);
|
||||
Q_INVOKABLE CallList *getCalls() const;
|
||||
QSharedPointer<SettingsCore> getSettings() const;
|
||||
|
||||
void onExitOnCloseChanged(); // Can be used for UniqueConnection
|
||||
|
|
@ -146,6 +153,8 @@ public:
|
|||
signals:
|
||||
void mainWindowChanged();
|
||||
void coreStartedChanged(bool coreStarted);
|
||||
void accountsChanged();
|
||||
void callsChanged();
|
||||
// void executeCommand(QString command);
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -24,17 +24,18 @@
|
|||
#include "core/App.hpp"
|
||||
|
||||
AccountProxy::AccountProxy(QObject *parent) : LimitProxy(parent) {
|
||||
setSourceModel(App::getInstance()->getAccountList().get());
|
||||
connect(this, &AccountProxy::initializedChanged, this, &AccountProxy::resetDefaultAccount);
|
||||
connect(this, &AccountProxy::initializedChanged, this, &AccountProxy::haveAccountChanged);
|
||||
}
|
||||
|
||||
AccountProxy::~AccountProxy() {
|
||||
setSourceModel(nullptr);
|
||||
}
|
||||
|
||||
AccountGui *AccountProxy::getDefaultAccount() {
|
||||
if (!mDefaultAccount)
|
||||
mDefaultAccount = dynamic_cast<AccountList *>(dynamic_cast<SortFilterList *>(sourceModel())->sourceModel())
|
||||
->getDefaultAccountCore();
|
||||
if (!mDefaultAccount) {
|
||||
auto model = getListModel<AccountList>();
|
||||
if (model) mDefaultAccount = model->getDefaultAccountCore();
|
||||
}
|
||||
return new AccountGui(mDefaultAccount);
|
||||
}
|
||||
|
||||
|
|
@ -48,15 +49,21 @@ void AccountProxy::resetDefaultAccount() {
|
|||
}
|
||||
|
||||
AccountGui *AccountProxy::findAccountByAddress(const QString &address) {
|
||||
return getListModel<AccountList>()->findAccountByAddress(address);
|
||||
auto model = getListModel<AccountList>();
|
||||
if (model) return model->findAccountByAddress(address);
|
||||
else return nullptr;
|
||||
}
|
||||
|
||||
AccountGui *AccountProxy::firstAccount() {
|
||||
return getListModel<AccountList>()->firstAccount();
|
||||
auto model = getListModel<AccountList>();
|
||||
if (model) return model->firstAccount();
|
||||
else return nullptr;
|
||||
}
|
||||
|
||||
bool AccountProxy::getHaveAccount() const {
|
||||
return getListModel<AccountList>()->getHaveAccount();
|
||||
auto model = getListModel<AccountList>();
|
||||
if (model) return model->getHaveAccount();
|
||||
else return false;
|
||||
}
|
||||
|
||||
bool AccountProxy::isInitialized() const {
|
||||
|
|
@ -81,7 +88,6 @@ void AccountProxy::setSourceModel(QAbstractItemModel *model) {
|
|||
qDebug() << "AccountProxy initialized";
|
||||
setInitialized(init);
|
||||
});
|
||||
setInitialized(newAccountList->isInitialized());
|
||||
connect(newAccountList, &AccountList::countChanged, this, &AccountProxy::resetDefaultAccount,
|
||||
Qt::QueuedConnection);
|
||||
connect(newAccountList, &AccountList::defaultAccountChanged, this, &AccountProxy::resetDefaultAccount,
|
||||
|
|
@ -90,6 +96,7 @@ void AccountProxy::setSourceModel(QAbstractItemModel *model) {
|
|||
Qt::QueuedConnection);
|
||||
}
|
||||
setSourceModels(new SortFilterList(model, Qt::AscendingOrder));
|
||||
if (newAccountList) setInitialized(newAccountList->isInitialized());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@
|
|||
DEFINE_ABSTRACT_OBJECT(CallProxy)
|
||||
|
||||
CallProxy::CallProxy(QObject *parent) : LimitProxy(parent) {
|
||||
setSourceModel(App::getInstance()->getCallList().get());
|
||||
connect(this, &CallProxy::sourceModelChanged, this, &CallProxy::resetCurrentCall);
|
||||
connect(this, &CallProxy::sourceModelChanged, this, &CallProxy::haveCallChanged);
|
||||
}
|
||||
|
||||
CallProxy::~CallProxy() {
|
||||
|
|
@ -49,7 +50,8 @@ void CallProxy::resetCurrentCall() {
|
|||
}
|
||||
|
||||
bool CallProxy::getHaveCall() const {
|
||||
return getListModel<CallList>()->getHaveCall();
|
||||
auto model = getListModel<CallList>();
|
||||
return model ? model->getHaveCall() : false;
|
||||
}
|
||||
|
||||
void CallProxy::setSourceModel(QAbstractItemModel *model) {
|
||||
|
|
|
|||
|
|
@ -4,10 +4,9 @@ import QtQuick.Effects
|
|||
import QtQml.Models
|
||||
import QtQuick.Controls.Basic as Control
|
||||
import Linphone
|
||||
import EnumsToStringCpp 1.0
|
||||
import UtilsCpp 1.0
|
||||
import SettingsCpp 1.0
|
||||
import LinphoneAccountsCpp
|
||||
import EnumsToStringCpp
|
||||
import UtilsCpp
|
||||
import SettingsCpp
|
||||
// =============================================================================
|
||||
|
||||
Item{
|
||||
|
|
@ -171,6 +170,7 @@ Item{
|
|||
videoEnabled: preview.visible && mainItem.call && mainItem.call.core.localVideoEnabled
|
||||
onVideoEnabledChanged: console.log("P : " +videoEnabled + " / " +visible +" / " +mainItem.call)
|
||||
property AccountProxy accounts: AccountProxy {id: accountProxy
|
||||
sourceModel: AppCpp.accounts
|
||||
}
|
||||
account: accountProxy.findAccountByAddress(mainItem.localAddress)
|
||||
call: mainItem.call
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import QtQuick.Layouts
|
|||
import QtQml.Models
|
||||
|
||||
import Linphone
|
||||
import LinphoneAccountsCpp
|
||||
|
||||
// =============================================================================
|
||||
|
||||
|
|
@ -23,7 +22,9 @@ Mosaic {
|
|||
qmlName: "G"
|
||||
Component.onCompleted: console.log("Loaded : " +allDevices + " = " +allDevices.count)
|
||||
}
|
||||
property AccountProxy accounts: AccountProxy {id: accountProxy
|
||||
property AccountProxy accounts: AccountProxy {
|
||||
id: accountProxy
|
||||
sourceModel: AppCpp.accounts
|
||||
}
|
||||
model: grid.call && grid.call.core.isConference ? participantDevices: [0,1]
|
||||
delegate: Item{
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ ListView {
|
|||
id: mainItem
|
||||
model: CallProxy {
|
||||
id: callProxy
|
||||
sourceModel: AppCpp.calls
|
||||
}
|
||||
implicitHeight: contentHeight
|
||||
spacing: 15 * DefaultStyle.dp
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import QtQuick.Layouts as Layout
|
|||
import QtQuick.Effects
|
||||
import Linphone
|
||||
import UtilsCpp
|
||||
import LinphoneCallsCpp
|
||||
|
||||
FocusScope{
|
||||
id: mainItem
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import QtQuick.Layouts as Layout
|
|||
import QtQuick.Effects
|
||||
import Linphone
|
||||
import UtilsCpp
|
||||
import LinphoneCallsCpp
|
||||
|
||||
Control.Popup {
|
||||
id: mainItem
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import QtQuick.Layouts
|
|||
import QtQuick.Controls.Basic as Control
|
||||
import Linphone
|
||||
import UtilsCpp 1.0
|
||||
import LinphoneAccountsCpp
|
||||
|
||||
// Snippet
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@ import QtQuick
|
|||
import QtQuick.Layouts
|
||||
import QtQuick.Controls.Basic as Control
|
||||
import Linphone
|
||||
import UtilsCpp 1.0
|
||||
import LinphoneAccountsCpp
|
||||
import LinphoneCallsCpp
|
||||
import UtilsCpp
|
||||
|
||||
// Snippet
|
||||
Window {
|
||||
|
|
|
|||
|
|
@ -3,14 +3,16 @@ import QtQuick.Effects
|
|||
import QtQuick.Layouts
|
||||
import QtQuick.Controls.Basic as Control
|
||||
import Linphone
|
||||
import UtilsCpp 1.0
|
||||
import SettingsCpp 1.0
|
||||
import LinphoneAccountsCpp
|
||||
import UtilsCpp
|
||||
import SettingsCpp
|
||||
|
||||
AbstractSettingsMenu {
|
||||
layoutsPath: "qrc:/qt/qml/Linphone/view/Page/Layout/Settings"
|
||||
titleText: qsTr("Mon compte")
|
||||
property AccountProxy accounts: AccountProxy {id: accountProxy}
|
||||
property AccountProxy accounts: AccountProxy {
|
||||
id: accountProxy
|
||||
sourceModel: AppCpp.accounts
|
||||
}
|
||||
property AccountGui account: accountProxy.defaultAccount
|
||||
signal accountRemoved()
|
||||
families: [
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import QtQuick.Effects
|
|||
import Linphone
|
||||
import UtilsCpp
|
||||
import SettingsCpp
|
||||
import LinphoneAccountsCpp
|
||||
|
||||
Item {
|
||||
id: mainItem
|
||||
|
|
@ -70,11 +69,13 @@ Item {
|
|||
|
||||
AccountProxy {
|
||||
id: accountProxy
|
||||
sourceModel: AppCpp.accounts
|
||||
onDefaultAccountChanged: if (tabbar.currentIndex === 0 && defaultAccount) defaultAccount.core?.lResetMissedCalls()
|
||||
}
|
||||
|
||||
CallProxy {
|
||||
id: callsModel
|
||||
sourceModel: AppCpp.calls
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import QtQuick.Dialogs
|
|||
import Linphone
|
||||
import UtilsCpp
|
||||
import SettingsCpp
|
||||
import LinphoneAccountsCpp
|
||||
|
||||
Item {
|
||||
id: mainItem
|
||||
|
|
@ -38,7 +37,7 @@ Item {
|
|||
Layout.preferredHeight: contentHeight
|
||||
Layout.fillWidth: true
|
||||
spacing: mainItem.spacing
|
||||
model: LinphoneAccountsCpp
|
||||
model: AppCpp.accounts
|
||||
delegate: Contact{
|
||||
id: contactItem
|
||||
width: list.width
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import QtQuick.Controls.Basic as Control
|
|||
import Linphone
|
||||
import UtilsCpp
|
||||
import SettingsCpp
|
||||
import LinphoneAccountsCpp
|
||||
|
||||
AbstractMainPage {
|
||||
id: mainItem
|
||||
|
|
@ -22,7 +21,10 @@ AbstractMainPage {
|
|||
|
||||
//Group call properties
|
||||
property ConferenceInfoGui confInfoGui
|
||||
property AccountProxy accounts: AccountProxy {id: accountProxy}
|
||||
property AccountProxy accounts: AccountProxy {
|
||||
id: accountProxy
|
||||
sourceModel: AppCpp.accounts
|
||||
}
|
||||
property AccountGui account: accountProxy.defaultAccount
|
||||
property var state: account && account.core?.registrationState || 0
|
||||
property bool isRegistered: account ? account.core?.registrationState == LinphoneEnums.RegistrationState.Ok : false
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ import QtQuick.Layouts
|
|||
import QtQuick.Effects
|
||||
import QtQuick.Controls.Basic as Control
|
||||
import Linphone
|
||||
import UtilsCpp 1.0
|
||||
import LinphoneAccountsCpp
|
||||
import UtilsCpp
|
||||
|
||||
RowLayout {
|
||||
id: mainItem
|
||||
|
|
@ -32,6 +31,7 @@ RowLayout {
|
|||
mutedStatus: microButton.checked
|
||||
AccountProxy {
|
||||
id: accounts
|
||||
sourceModel: AppCpp.accounts
|
||||
}
|
||||
account: accounts.defaultAccount
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,10 @@ import QtQuick.Layouts
|
|||
import QtQuick.Effects
|
||||
import QtQuick.Controls.Basic as Control
|
||||
import Linphone
|
||||
import EnumsToStringCpp 1.0
|
||||
import UtilsCpp 1.0
|
||||
import SettingsCpp 1.0
|
||||
import DesktopToolsCpp 1.0
|
||||
import LinphoneCallsCpp
|
||||
import EnumsToStringCpp
|
||||
import UtilsCpp
|
||||
import SettingsCpp
|
||||
import DesktopToolsCpp
|
||||
|
||||
AbstractWindow {
|
||||
id: mainWindow
|
||||
|
|
@ -165,6 +164,7 @@ AbstractWindow {
|
|||
|
||||
CallProxy{
|
||||
id: callsModel
|
||||
sourceModel: AppCpp.calls
|
||||
onCurrentCallChanged: {
|
||||
if(currentCall) {
|
||||
mainWindow.call = currentCall
|
||||
|
|
|
|||
|
|
@ -3,9 +3,8 @@ import QtQuick.Layouts
|
|||
import QtQuick.Window
|
||||
import QtQuick.Controls.Basic
|
||||
import Linphone
|
||||
import UtilsCpp 1.0
|
||||
import SettingsCpp 1.0
|
||||
import LinphoneAccountsCpp
|
||||
import UtilsCpp
|
||||
import SettingsCpp
|
||||
|
||||
AbstractWindow {
|
||||
id: mainWindow
|
||||
|
|
@ -17,7 +16,7 @@ AbstractWindow {
|
|||
color: DefaultStyle.grey_0
|
||||
|
||||
signal callCreated()
|
||||
property var accountProxy: accountProxyLoader.item
|
||||
property var accountProxy
|
||||
|
||||
// TODO : use this to make the border transparent
|
||||
// flags: Qt.Window | Qt.FramelessWindowHint | Qt.WindowTitleHint
|
||||
|
|
@ -98,11 +97,11 @@ AbstractWindow {
|
|||
id: accountProxyLoader
|
||||
active: AppCpp.coreStarted
|
||||
sourceComponent: AccountProxy {
|
||||
Component.onCompleted: {
|
||||
sourceModel: AppCpp.accounts
|
||||
onInitializedChanged: {
|
||||
mainWindow.accountProxy = this
|
||||
mainWindow.initStackViewItem()
|
||||
}
|
||||
onInitializedChanged: mainWindow.initStackViewItem()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue