Commit 12636b34 authored by Ronan Abhamon's avatar Ronan Abhamon

fix(app): coding style

parent 2df59f19
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
using namespace std; using namespace std;
// =================================================================== // =============================================================================
QHash<int, QByteArray> ChatModel::roleNames () const { QHash<int, QByteArray> ChatModel::roleNames () const {
QHash<int, QByteArray> roles; QHash<int, QByteArray> roles;
...@@ -62,7 +62,7 @@ bool ChatModel::removeRows (int row, int count, const QModelIndex &parent) { ...@@ -62,7 +62,7 @@ bool ChatModel::removeRows (int row, int count, const QModelIndex &parent) {
return true; return true;
} }
// ------------------------------------------------------------------- // -----------------------------------------------------------------------------
void ChatModel::removeEntry (int id) { void ChatModel::removeEntry (int id) {
qInfo() << QStringLiteral("Removing chat entry: %1 of %2.") qInfo() << QStringLiteral("Removing chat entry: %1 of %2.")
...@@ -85,7 +85,7 @@ void ChatModel::removeAllEntries () { ...@@ -85,7 +85,7 @@ void ChatModel::removeAllEntries () {
endResetModel(); endResetModel();
} }
// ------------------------------------------------------------------- // -----------------------------------------------------------------------------
void ChatModel::fillMessageEntry ( void ChatModel::fillMessageEntry (
QVariantMap &dest, QVariantMap &dest,
...@@ -125,7 +125,7 @@ void ChatModel::fillCallEndEntry ( ...@@ -125,7 +125,7 @@ void ChatModel::fillCallEndEntry (
dest["isStart"] = false; dest["isStart"] = false;
} }
// ------------------------------------------------------------------- // -----------------------------------------------------------------------------
void ChatModel::removeEntry (ChatEntryData &pair) { void ChatModel::removeEntry (ChatEntryData &pair) {
int type = pair.first["type"].toInt(); int type = pair.first["type"].toInt();
......
#ifndef CHAT_MODEL_H_ #ifndef CHAT_MODEL_H_
#define CHAT_MODEL_H_ #define CHAT_MODEL_H_
#include <QAbstractListModel>
#include <linphone++/linphone.hh> #include <linphone++/linphone.hh>
#include <QAbstractListModel>
// =================================================================== // =============================================================================
// Fetch all N messages of a ChatRoom. // Fetch all N messages of a ChatRoom.
// =================================================================== // =============================================================================
class ChatModel : public QAbstractListModel { class ChatModel : public QAbstractListModel {
friend class ChatProxyModel; friend class ChatProxyModel;
...@@ -20,9 +20,6 @@ class ChatModel : public QAbstractListModel { ...@@ -20,9 +20,6 @@ class ChatModel : public QAbstractListModel {
NOTIFY sipAddressChanged NOTIFY sipAddressChanged
); );
signals:
void sipAddressChanged (const QString &sipAddress);
public: public:
typedef QPair<QVariantMap, std::shared_ptr<void> > ChatEntryData; typedef QPair<QVariantMap, std::shared_ptr<void> > ChatEntryData;
...@@ -36,6 +33,7 @@ public: ...@@ -36,6 +33,7 @@ public:
MessageEntry, MessageEntry,
CallEntry CallEntry
}; };
Q_ENUM(EntryType); Q_ENUM(EntryType);
enum CallStatus { enum CallStatus {
...@@ -43,6 +41,7 @@ public: ...@@ -43,6 +41,7 @@ public:
CallStatusMissed = linphone::CallStatusMissed, CallStatusMissed = linphone::CallStatusMissed,
CallStatusSuccess = linphone::CallStatusSuccess CallStatusSuccess = linphone::CallStatusSuccess
}; };
Q_ENUM(CallStatus); Q_ENUM(CallStatus);
ChatModel (QObject *parent = Q_NULLPTR) : QAbstractListModel(parent) {} ChatModel (QObject *parent = Q_NULLPTR) : QAbstractListModel(parent) {}
...@@ -59,6 +58,9 @@ public slots: ...@@ -59,6 +58,9 @@ public slots:
void removeEntry (int id); void removeEntry (int id);
void removeAllEntries (); void removeAllEntries ();
signals:
void sipAddressChanged (const QString &sipAddress);
private: private:
void fillMessageEntry ( void fillMessageEntry (
QVariantMap &dest, QVariantMap &dest,
......
#include "ChatProxyModel.hpp" #include "ChatProxyModel.hpp"
// =================================================================== // =============================================================================
ChatModelFilter::ChatModelFilter (QObject *parent) : QSortFilterProxyModel(parent) { ChatModelFilter::ChatModelFilter (QObject *parent) : QSortFilterProxyModel(parent) {
setSourceModel(&m_chat_model); setSourceModel(&m_chat_model);
...@@ -11,9 +11,7 @@ bool ChatModelFilter::filterAcceptsRow (int source_row, const QModelIndex &) con ...@@ -11,9 +11,7 @@ bool ChatModelFilter::filterAcceptsRow (int source_row, const QModelIndex &) con
return true; return true;
QModelIndex index = sourceModel()->index(source_row, 0, QModelIndex()); QModelIndex index = sourceModel()->index(source_row, 0, QModelIndex());
const QVariantMap &data = qvariant_cast<QVariantMap>( const QVariantMap &data = qvariant_cast<QVariantMap>(index.data());
index.data()
);
return data["type"].toInt() == m_entry_type_filter; return data["type"].toInt() == m_entry_type_filter;
} }
...@@ -23,7 +21,7 @@ void ChatModelFilter::setEntryTypeFilter (ChatModel::EntryType type) { ...@@ -23,7 +21,7 @@ void ChatModelFilter::setEntryTypeFilter (ChatModel::EntryType type) {
invalidateFilter(); invalidateFilter();
} }
// =================================================================== // =============================================================================
const unsigned int ChatProxyModel::ENTRIES_CHUNK_SIZE = 50; const unsigned int ChatProxyModel::ENTRIES_CHUNK_SIZE = 50;
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
#include "ChatModel.hpp" #include "ChatModel.hpp"
// =================================================================== // =============================================================================
// Fetch the L last filtered chat entries. // Fetch the L last filtered chat entries.
// =================================================================== // =============================================================================
// Cannot be used as a nested class by Qt and `Q_OBJECT` macro // Cannot be used as a nested class by Qt and `Q_OBJECT` macro
// must be used in header c++ file. // must be used in header c++ file.
...@@ -28,7 +28,7 @@ private: ...@@ -28,7 +28,7 @@ private:
ChatModel::EntryType m_entry_type_filter = ChatModel::EntryType::GenericEntry; ChatModel::EntryType m_entry_type_filter = ChatModel::EntryType::GenericEntry;
}; };
// =================================================================== // =============================================================================
class ChatProxyModel : public QSortFilterProxyModel { class ChatProxyModel : public QSortFilterProxyModel {
Q_OBJECT; Q_OBJECT;
...@@ -40,11 +40,6 @@ class ChatProxyModel : public QSortFilterProxyModel { ...@@ -40,11 +40,6 @@ class ChatProxyModel : public QSortFilterProxyModel {
NOTIFY sipAddressChanged NOTIFY sipAddressChanged
); );
signals:
void sipAddressChanged (const QString &sipAddress);
void moreEntriesLoaded (int n);
void entryTypeFilterChanged (ChatModel::EntryType type);
public: public:
ChatProxyModel (QObject *parent = Q_NULLPTR); ChatProxyModel (QObject *parent = Q_NULLPTR);
...@@ -59,6 +54,11 @@ public slots: ...@@ -59,6 +54,11 @@ public slots:
static_cast<ChatModel *>(m_chat_model_filter.sourceModel())->removeAllEntries(); static_cast<ChatModel *>(m_chat_model_filter.sourceModel())->removeAllEntries();
} }
signals:
void sipAddressChanged (const QString &sipAddress);
void moreEntriesLoaded (int n);
void entryTypeFilterChanged (ChatModel::EntryType type);
protected: protected:
bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override; bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override;
...@@ -74,7 +74,6 @@ private: ...@@ -74,7 +74,6 @@ private:
} }
ChatModelFilter m_chat_model_filter; ChatModelFilter m_chat_model_filter;
int m_n_max_displayed_entries = ENTRIES_CHUNK_SIZE; int m_n_max_displayed_entries = ENTRIES_CHUNK_SIZE;
static const unsigned int ENTRIES_CHUNK_SIZE; static const unsigned int ENTRIES_CHUNK_SIZE;
......
#include <QtDebug>
#include "../../app/App.hpp" #include "../../app/App.hpp"
#include "ContactModel.hpp" #include "ContactModel.hpp"
......
...@@ -37,7 +37,7 @@ public slots: ...@@ -37,7 +37,7 @@ public slots:
} }
void abortEdit () { void abortEdit () {
// TODO. // TODO: call linphone friend abort function.
// m_linphone_friend->abort(); // m_linphone_friend->abort();
} }
......
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