mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-23 06:38:07 +00:00
feat(src): add timeline component
This commit is contained in:
parent
26e16ba586
commit
606808a636
6 changed files with 68 additions and 3 deletions
|
|
@ -34,6 +34,7 @@ set(SOURCES
|
|||
src/components/notification/Notification.cpp
|
||||
src/components/settings/AccountSettingsModel.cpp
|
||||
src/components/settings/SettingsModel.cpp
|
||||
src/components/timeline/TimelineModel.cpp
|
||||
src/logger.cpp
|
||||
src/main.cpp
|
||||
)
|
||||
|
|
@ -47,6 +48,7 @@ set(HEADERS
|
|||
src/components/presence/Presence.hpp
|
||||
src/components/settings/AccountSettingsModel.hpp
|
||||
src/components/settings/SettingsModel.hpp
|
||||
src/components/timeline/TimelineModel.hpp
|
||||
src/logger.hpp
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
// ===================================================================
|
||||
|
||||
App::App (int &argc, char **argv) : QApplication(argc, argv) {
|
||||
// Try to use default locale.
|
||||
// Try to use default locale. Otherwise use english.
|
||||
if (m_translator.load(QString(LANGUAGES_PATH) + QLocale::system().name()) ||
|
||||
m_translator.load(LANGUAGES_PATH "en")) {
|
||||
this->installTranslator(&m_translator);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// ===================================================================
|
||||
|
||||
class AccountSettingsModel : public QObject {
|
||||
Q_OBJECT
|
||||
Q_OBJECT;
|
||||
|
||||
Q_PROPERTY(
|
||||
QString username
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// ===================================================================
|
||||
|
||||
class SettingsModel : public QObject {
|
||||
Q_OBJECT
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
SettingsModel (QObject *parent = Q_NULLPTR);
|
||||
|
|
|
|||
41
tests/src/components/timeline/TimelineModel.cpp
Normal file
41
tests/src/components/timeline/TimelineModel.cpp
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#include "TimelineModel.hpp"
|
||||
|
||||
// ===================================================================
|
||||
|
||||
TimelineModel::TimelineModel (QObject *parent): QAbstractListModel(parent) {
|
||||
// TMP.
|
||||
m_addresses << "toto.linphone.sip.linphone.org";
|
||||
m_addresses << "toto.linphone.sip.linphone.org";
|
||||
m_addresses << "toto.linphone.sip.linphone.org";
|
||||
m_addresses << "toto.linphone.sip.linphone.org";
|
||||
m_addresses << "toto.linphone.sip.linphone.org";
|
||||
m_addresses << "toto.linphone.sip.linphone.org";
|
||||
m_addresses << "toto.linphone.sip.linphone.org";
|
||||
m_addresses << "toto.linphone.sip.linphone.org";
|
||||
m_addresses << "toto.linphone.sip.linphone.org";
|
||||
m_addresses << "toto.linphone.sip.linphone.org";
|
||||
m_addresses << "toto.linphone.sip.linphone.org";
|
||||
m_addresses << "toto.linphone.sip.linphone.org";
|
||||
}
|
||||
|
||||
int TimelineModel::rowCount (const QModelIndex &) const {
|
||||
return m_addresses.count();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> TimelineModel::roleNames () const {
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[Qt::DisplayRole] = "$address";
|
||||
return roles;
|
||||
}
|
||||
|
||||
QVariant TimelineModel::data (const QModelIndex &index, int role) const {
|
||||
int row = index.row();
|
||||
|
||||
if (row < 0 || row >= m_addresses.count())
|
||||
return QVariant();
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
return QVariant::fromValue(m_addresses[row]);
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
22
tests/src/components/timeline/TimelineModel.hpp
Normal file
22
tests/src/components/timeline/TimelineModel.hpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef TIMELINE_MODEL_H_
|
||||
#define TIMELINE_MODEL_H_
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
// ===================================================================
|
||||
|
||||
class TimelineModel : public QAbstractListModel {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
TimelineModel (QObject *parent = Q_NULLPTR);
|
||||
|
||||
int rowCount (const QModelIndex &) const;
|
||||
QHash<int, QByteArray> roleNames () const;
|
||||
QVariant data (const QModelIndex &index, int role) const;
|
||||
|
||||
private:
|
||||
QStringList m_addresses;
|
||||
};
|
||||
|
||||
#endif // TIMELINE_MODEL_H_
|
||||
Loading…
Add table
Reference in a new issue