mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-24 07:08:07 +00:00
feat(app): remove all slots, use Q_INVOKABLE instead.
This commit is contained in:
parent
9813baf1d6
commit
555bf66047
12 changed files with 55 additions and 64 deletions
|
|
@ -33,8 +33,7 @@ public:
|
|||
return &m_engine;
|
||||
}
|
||||
|
||||
public slots:
|
||||
QString locale () const {
|
||||
Q_INVOKABLE QString locale () const {
|
||||
return m_locale;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,9 +56,8 @@ public:
|
|||
QString getSipAddress () const;
|
||||
void setSipAddress (const QString &sip_address);
|
||||
|
||||
public slots:
|
||||
void removeEntry (int id);
|
||||
void removeAllEntries ();
|
||||
Q_INVOKABLE void removeEntry (int id);
|
||||
Q_INVOKABLE void removeAllEntries ();
|
||||
|
||||
signals:
|
||||
void sipAddressChanged (const QString &sip_address);
|
||||
|
|
|
|||
|
|
@ -43,12 +43,11 @@ class ChatProxyModel : public QSortFilterProxyModel {
|
|||
public:
|
||||
ChatProxyModel (QObject *parent = Q_NULLPTR);
|
||||
|
||||
public slots:
|
||||
void loadMoreEntries ();
|
||||
void setEntryTypeFilter (ChatModel::EntryType type);
|
||||
void removeEntry (int id);
|
||||
Q_INVOKABLE void loadMoreEntries ();
|
||||
Q_INVOKABLE void setEntryTypeFilter (ChatModel::EntryType type);
|
||||
Q_INVOKABLE void removeEntry (int id);
|
||||
|
||||
void removeAllEntries () {
|
||||
Q_INVOKABLE void removeAllEntries () {
|
||||
static_cast<ChatModel *>(m_chat_model_filter.sourceModel())->removeAllEntries();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,10 +26,9 @@ public:
|
|||
return m_vcard;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void startEdit ();
|
||||
void endEdit ();
|
||||
void abortEdit ();
|
||||
Q_INVOKABLE void startEdit ();
|
||||
Q_INVOKABLE void endEdit ();
|
||||
Q_INVOKABLE void abortEdit ();
|
||||
|
||||
signals:
|
||||
void contactUpdated ();
|
||||
|
|
|
|||
|
|
@ -27,27 +27,26 @@ public:
|
|||
QString getUsername () const;
|
||||
QVariantList getSipAddresses () const;
|
||||
|
||||
public slots:
|
||||
bool addSipAddress (const QString &sip_address);
|
||||
void removeSipAddress (const QString &sip_address);
|
||||
bool updateSipAddress (const QString &old_sip_address, const QString &sip_address);
|
||||
Q_INVOKABLE bool addSipAddress (const QString &sip_address);
|
||||
Q_INVOKABLE void removeSipAddress (const QString &sip_address);
|
||||
Q_INVOKABLE bool updateSipAddress (const QString &old_sip_address, const QString &sip_address);
|
||||
|
||||
bool addCompany (const QString &company);
|
||||
void removeCompany (const QString &company);
|
||||
bool updateCompany (const QString &old_company, const QString &company);
|
||||
Q_INVOKABLE bool addCompany (const QString &company);
|
||||
Q_INVOKABLE void removeCompany (const QString &company);
|
||||
Q_INVOKABLE bool updateCompany (const QString &old_company, const QString &company);
|
||||
|
||||
bool addEmail (const QString &email);
|
||||
void removeEmail (const QString &email);
|
||||
bool updateEmail (const QString &old_email, const QString &email);
|
||||
Q_INVOKABLE bool addEmail (const QString &email);
|
||||
Q_INVOKABLE void removeEmail (const QString &email);
|
||||
Q_INVOKABLE bool updateEmail (const QString &old_email, const QString &email);
|
||||
|
||||
bool addUrl (const QString &url);
|
||||
void removeUrl (const QString &url);
|
||||
bool updateUrl (const QString &old_url, const QString &url);
|
||||
Q_INVOKABLE bool addUrl (const QString &url);
|
||||
Q_INVOKABLE void removeUrl (const QString &url);
|
||||
Q_INVOKABLE bool updateUrl (const QString &old_url, const QString &url);
|
||||
|
||||
void setStreet (const QString &street);
|
||||
void setLocality (const QString &locality);
|
||||
void setPostalCode (const QString &postal_code);
|
||||
void setCountry (const QString &country);
|
||||
Q_INVOKABLE void setStreet (const QString &street);
|
||||
Q_INVOKABLE void setLocality (const QString &locality);
|
||||
Q_INVOKABLE void setPostalCode (const QString &postal_code);
|
||||
Q_INVOKABLE void setCountry (const QString &country);
|
||||
|
||||
signals:
|
||||
void vcardUpdated ();
|
||||
|
|
|
|||
|
|
@ -25,9 +25,8 @@ public:
|
|||
bool removeRow (int row, const QModelIndex &parent = QModelIndex());
|
||||
bool removeRows (int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
|
||||
public slots:
|
||||
ContactModel *addContact (VcardModel *vcard);
|
||||
void removeContact (ContactModel *contact);
|
||||
Q_INVOKABLE ContactModel *addContact (VcardModel *vcard);
|
||||
Q_INVOKABLE void removeContact (ContactModel *contact);
|
||||
|
||||
signals:
|
||||
void contactAdded (ContactModel *contact);
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@ public:
|
|||
ContactsListProxyModel (QObject *parent = Q_NULLPTR);
|
||||
~ContactsListProxyModel () = default;
|
||||
|
||||
public slots:
|
||||
void setFilter (const QString &pattern);
|
||||
Q_INVOKABLE void setFilter (const QString &pattern);
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override;
|
||||
|
|
|
|||
|
|
@ -34,10 +34,9 @@ public:
|
|||
return m_instance;
|
||||
}
|
||||
|
||||
public slots:
|
||||
// Must be used in a qml scene.
|
||||
// Warning: The ownership of `VcardModel` is `QQmlEngine::JavaScriptOwnership` by default.
|
||||
VcardModel *createDetachedVcardModel ();
|
||||
Q_INVOKABLE VcardModel *createDetachedVcardModel ();
|
||||
|
||||
private:
|
||||
CoreManager (QObject *parent = Q_NULLPTR);
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@ public:
|
|||
MaxNbTypes
|
||||
};
|
||||
|
||||
public slots:
|
||||
void showCallMessage (int timeout, const QString &sip_address);
|
||||
Q_INVOKABLE void showCallMessage (int timeout, const QString &sip_address);
|
||||
|
||||
private:
|
||||
QObject *createNotification (NotificationType type);
|
||||
|
|
|
|||
|
|
@ -83,6 +83,26 @@ ContactModel *SipAddressesModel::mapSipAddressToContact (const QString &sip_addr
|
|||
return it->value("contact").value<ContactModel *>();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
ContactObserver *SipAddressesModel::getContactObserver (const QString &sip_address) {
|
||||
ContactObserver *model = new ContactObserver(sip_address);
|
||||
model->setContact(mapSipAddressToContact(sip_address));
|
||||
|
||||
m_observers.insert(sip_address, model);
|
||||
QObject::connect(
|
||||
model, &ContactObserver::destroyed, this, [this, model]() {
|
||||
const QString &sip_address = model->getSipAddress();
|
||||
if (m_observers.remove(sip_address, model) == 0)
|
||||
qWarning() << QStringLiteral("Unable to remove sip address `%1` from observers.").arg(sip_address);
|
||||
}
|
||||
);
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void SipAddressesModel::handleAllHistoryEntriesRemoved () {
|
||||
QObject *sender = QObject::sender();
|
||||
if (!sender)
|
||||
|
|
@ -115,24 +135,6 @@ void SipAddressesModel::handleAllHistoryEntriesRemoved () {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
ContactObserver *SipAddressesModel::getContactObserver (const QString &sip_address) {
|
||||
ContactObserver *model = new ContactObserver(sip_address);
|
||||
model->setContact(mapSipAddressToContact(sip_address));
|
||||
|
||||
m_observers.insert(sip_address, model);
|
||||
QObject::connect(
|
||||
model, &ContactObserver::destroyed, this, [this, model]() {
|
||||
const QString &sip_address = model->getSipAddress();
|
||||
if (m_observers.remove(sip_address, model) == 0)
|
||||
qWarning() << QStringLiteral("Unable to remove sip address `%1` from observers.").arg(sip_address);
|
||||
}
|
||||
);
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool SipAddressesModel::removeRow (int row, const QModelIndex &parent) {
|
||||
return removeRows(row, 1, parent);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,11 +20,10 @@ public:
|
|||
QHash<int, QByteArray> roleNames () const override;
|
||||
QVariant data (const QModelIndex &index, int role) const override;
|
||||
|
||||
public slots:
|
||||
ContactModel *mapSipAddressToContact (const QString &sip_address) const;
|
||||
void handleAllHistoryEntriesRemoved ();
|
||||
Q_INVOKABLE ContactModel *mapSipAddressToContact (const QString &sip_address) const;
|
||||
Q_INVOKABLE ContactObserver *getContactObserver (const QString &sip_address);
|
||||
|
||||
ContactObserver *getContactObserver (const QString &sip_address);
|
||||
Q_INVOKABLE void handleAllHistoryEntriesRemoved ();
|
||||
|
||||
private:
|
||||
bool removeRow (int row, const QModelIndex &parent = QModelIndex());
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ public:
|
|||
|
||||
QHash<int, QByteArray> roleNames () const override;
|
||||
|
||||
public slots:
|
||||
void setFilter (const QString &pattern);
|
||||
Q_INVOKABLE void setFilter (const QString &pattern);
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue