Commit 555bf660 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app): remove all slots, use `Q_INVOKABLE` instead.

parent 9813baf1
...@@ -33,8 +33,7 @@ public: ...@@ -33,8 +33,7 @@ public:
return &m_engine; return &m_engine;
} }
public slots: Q_INVOKABLE QString locale () const {
QString locale () const {
return m_locale; return m_locale;
} }
......
...@@ -56,9 +56,8 @@ public: ...@@ -56,9 +56,8 @@ public:
QString getSipAddress () const; QString getSipAddress () const;
void setSipAddress (const QString &sip_address); void setSipAddress (const QString &sip_address);
public slots: Q_INVOKABLE void removeEntry (int id);
void removeEntry (int id); Q_INVOKABLE void removeAllEntries ();
void removeAllEntries ();
signals: signals:
void sipAddressChanged (const QString &sip_address); void sipAddressChanged (const QString &sip_address);
......
...@@ -43,12 +43,11 @@ class ChatProxyModel : public QSortFilterProxyModel { ...@@ -43,12 +43,11 @@ class ChatProxyModel : public QSortFilterProxyModel {
public: public:
ChatProxyModel (QObject *parent = Q_NULLPTR); ChatProxyModel (QObject *parent = Q_NULLPTR);
public slots: Q_INVOKABLE void loadMoreEntries ();
void loadMoreEntries (); Q_INVOKABLE void setEntryTypeFilter (ChatModel::EntryType type);
void setEntryTypeFilter (ChatModel::EntryType type); Q_INVOKABLE void removeEntry (int id);
void removeEntry (int id);
void removeAllEntries () { Q_INVOKABLE void removeAllEntries () {
static_cast<ChatModel *>(m_chat_model_filter.sourceModel())->removeAllEntries(); static_cast<ChatModel *>(m_chat_model_filter.sourceModel())->removeAllEntries();
} }
......
...@@ -26,10 +26,9 @@ public: ...@@ -26,10 +26,9 @@ public:
return m_vcard; return m_vcard;
} }
public slots: Q_INVOKABLE void startEdit ();
void startEdit (); Q_INVOKABLE void endEdit ();
void endEdit (); Q_INVOKABLE void abortEdit ();
void abortEdit ();
signals: signals:
void contactUpdated (); void contactUpdated ();
......
...@@ -27,27 +27,26 @@ public: ...@@ -27,27 +27,26 @@ public:
QString getUsername () const; QString getUsername () const;
QVariantList getSipAddresses () const; QVariantList getSipAddresses () const;
public slots: Q_INVOKABLE bool addSipAddress (const QString &sip_address);
bool addSipAddress (const QString &sip_address); Q_INVOKABLE void removeSipAddress (const QString &sip_address);
void removeSipAddress (const QString &sip_address); Q_INVOKABLE bool updateSipAddress (const QString &old_sip_address, const QString &sip_address);
bool updateSipAddress (const QString &old_sip_address, const QString &sip_address);
Q_INVOKABLE bool addCompany (const QString &company);
bool addCompany (const QString &company); Q_INVOKABLE void removeCompany (const QString &company);
void removeCompany (const QString &company); Q_INVOKABLE bool updateCompany (const QString &old_company, const QString &company);
bool updateCompany (const QString &old_company, const QString &company);
Q_INVOKABLE bool addEmail (const QString &email);
bool addEmail (const QString &email); Q_INVOKABLE void removeEmail (const QString &email);
void removeEmail (const QString &email); Q_INVOKABLE bool updateEmail (const QString &old_email, const QString &email);
bool updateEmail (const QString &old_email, const QString &email);
Q_INVOKABLE bool addUrl (const QString &url);
bool addUrl (const QString &url); Q_INVOKABLE void removeUrl (const QString &url);
void removeUrl (const QString &url); Q_INVOKABLE bool updateUrl (const QString &old_url, const QString &url);
bool updateUrl (const QString &old_url, const QString &url);
Q_INVOKABLE void setStreet (const QString &street);
void setStreet (const QString &street); Q_INVOKABLE void setLocality (const QString &locality);
void setLocality (const QString &locality); Q_INVOKABLE void setPostalCode (const QString &postal_code);
void setPostalCode (const QString &postal_code); Q_INVOKABLE void setCountry (const QString &country);
void setCountry (const QString &country);
signals: signals:
void vcardUpdated (); void vcardUpdated ();
......
...@@ -25,9 +25,8 @@ public: ...@@ -25,9 +25,8 @@ public:
bool removeRow (int row, const QModelIndex &parent = QModelIndex()); bool removeRow (int row, const QModelIndex &parent = QModelIndex());
bool removeRows (int row, int count, const QModelIndex &parent = QModelIndex()) override; bool removeRows (int row, int count, const QModelIndex &parent = QModelIndex()) override;
public slots: Q_INVOKABLE ContactModel *addContact (VcardModel *vcard);
ContactModel *addContact (VcardModel *vcard); Q_INVOKABLE void removeContact (ContactModel *contact);
void removeContact (ContactModel *contact);
signals: signals:
void contactAdded (ContactModel *contact); void contactAdded (ContactModel *contact);
......
...@@ -22,8 +22,7 @@ public: ...@@ -22,8 +22,7 @@ public:
ContactsListProxyModel (QObject *parent = Q_NULLPTR); ContactsListProxyModel (QObject *parent = Q_NULLPTR);
~ContactsListProxyModel () = default; ~ContactsListProxyModel () = default;
public slots: Q_INVOKABLE void setFilter (const QString &pattern);
void setFilter (const QString &pattern);
protected: protected:
bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override; bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override;
......
...@@ -34,10 +34,9 @@ public: ...@@ -34,10 +34,9 @@ public:
return m_instance; return m_instance;
} }
public slots:
// Must be used in a qml scene. // Must be used in a qml scene.
// Warning: The ownership of `VcardModel` is `QQmlEngine::JavaScriptOwnership` by default. // Warning: The ownership of `VcardModel` is `QQmlEngine::JavaScriptOwnership` by default.
VcardModel *createDetachedVcardModel (); Q_INVOKABLE VcardModel *createDetachedVcardModel ();
private: private:
CoreManager (QObject *parent = Q_NULLPTR); CoreManager (QObject *parent = Q_NULLPTR);
......
...@@ -20,8 +20,7 @@ public: ...@@ -20,8 +20,7 @@ public:
MaxNbTypes MaxNbTypes
}; };
public slots: Q_INVOKABLE void showCallMessage (int timeout, const QString &sip_address);
void showCallMessage (int timeout, const QString &sip_address);
private: private:
QObject *createNotification (NotificationType type); QObject *createNotification (NotificationType type);
......
...@@ -83,6 +83,26 @@ ContactModel *SipAddressesModel::mapSipAddressToContact (const QString &sip_addr ...@@ -83,6 +83,26 @@ ContactModel *SipAddressesModel::mapSipAddressToContact (const QString &sip_addr
return it->value("contact").value<ContactModel *>(); 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 () { void SipAddressesModel::handleAllHistoryEntriesRemoved () {
QObject *sender = QObject::sender(); QObject *sender = QObject::sender();
if (!sender) if (!sender)
...@@ -115,24 +135,6 @@ void SipAddressesModel::handleAllHistoryEntriesRemoved () { ...@@ -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) { bool SipAddressesModel::removeRow (int row, const QModelIndex &parent) {
return removeRows(row, 1, parent); return removeRows(row, 1, parent);
} }
......
...@@ -20,11 +20,10 @@ public: ...@@ -20,11 +20,10 @@ public:
QHash<int, QByteArray> roleNames () const override; QHash<int, QByteArray> roleNames () const override;
QVariant data (const QModelIndex &index, int role) const override; QVariant data (const QModelIndex &index, int role) const override;
public slots: Q_INVOKABLE ContactModel *mapSipAddressToContact (const QString &sip_address) const;
ContactModel *mapSipAddressToContact (const QString &sip_address) const; Q_INVOKABLE ContactObserver *getContactObserver (const QString &sip_address);
void handleAllHistoryEntriesRemoved ();
ContactObserver *getContactObserver (const QString &sip_address); Q_INVOKABLE void handleAllHistoryEntriesRemoved ();
private: private:
bool removeRow (int row, const QModelIndex &parent = QModelIndex()); bool removeRow (int row, const QModelIndex &parent = QModelIndex());
......
...@@ -16,8 +16,7 @@ public: ...@@ -16,8 +16,7 @@ public:
QHash<int, QByteArray> roleNames () const override; QHash<int, QByteArray> roleNames () const override;
public slots: Q_INVOKABLE void setFilter (const QString &pattern);
void setFilter (const QString &pattern);
protected: protected:
bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override; bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment