fix meeting list ui
This commit is contained in:
parent
3863365863
commit
7608fbcfdb
7 changed files with 123 additions and 148 deletions
|
|
@ -188,8 +188,9 @@ void ConferenceInfoCore::setSelf(QSharedPointer<ConferenceInfoCore> me) {
|
||||||
mConfInfoModelConnection->makeConnectToCore(&ConferenceInfoCore::lDeleteConferenceInfo, [this]() {
|
mConfInfoModelConnection->makeConnectToCore(&ConferenceInfoCore::lDeleteConferenceInfo, [this]() {
|
||||||
mConfInfoModelConnection->invokeToModel([this] { mConferenceInfoModel->deleteConferenceInfo(); });
|
mConfInfoModelConnection->invokeToModel([this] { mConferenceInfoModel->deleteConferenceInfo(); });
|
||||||
});
|
});
|
||||||
mConfInfoModelConnection->makeConnectToModel(&ConferenceInfoModel::conferenceInfoDeleted,
|
mConfInfoModelConnection->makeConnectToModel(&ConferenceInfoModel::conferenceInfoDeleted, [this] {
|
||||||
&ConferenceInfoCore::removed);
|
mConfInfoModelConnection->invokeToCore([this] { removed(this); });
|
||||||
|
});
|
||||||
|
|
||||||
mConfInfoModelConnection->makeConnectToModel(
|
mConfInfoModelConnection->makeConnectToModel(
|
||||||
&ConferenceInfoModel::schedulerStateChanged, [this](linphone::ConferenceScheduler::State state) {
|
&ConferenceInfoModel::schedulerStateChanged, [this](linphone::ConferenceScheduler::State state) {
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ signals:
|
||||||
void saveFailed();
|
void saveFailed();
|
||||||
|
|
||||||
void invitationsSent();
|
void invitationsSent();
|
||||||
void removed();
|
void removed(ConferenceInfoCore* confInfo);
|
||||||
|
|
||||||
void lCancelConferenceInfo();
|
void lCancelConferenceInfo();
|
||||||
void lDeleteConferenceInfo(); // Remove completly this conference info from DB
|
void lDeleteConferenceInfo(); // Remove completly this conference info from DB
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#include "ConferenceInfoGui.hpp"
|
#include "ConferenceInfoGui.hpp"
|
||||||
#include "core/App.hpp"
|
#include "core/App.hpp"
|
||||||
#include "model/object/VariantObject.hpp"
|
#include "model/object/VariantObject.hpp"
|
||||||
|
#include "model/tool/ToolModel.hpp"
|
||||||
#include "tool/Utils.hpp"
|
#include "tool/Utils.hpp"
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <linphone++/linphone.hh>
|
#include <linphone++/linphone.hh>
|
||||||
|
|
@ -52,8 +53,8 @@ void ConferenceInfoList::setSelf(QSharedPointer<ConferenceInfoList> me) {
|
||||||
mCoreModelConnection = QSharedPointer<SafeConnection<ConferenceInfoList, CoreModel>>(
|
mCoreModelConnection = QSharedPointer<SafeConnection<ConferenceInfoList, CoreModel>>(
|
||||||
new SafeConnection<ConferenceInfoList, CoreModel>(me, CoreModel::getInstance()), &QObject::deleteLater);
|
new SafeConnection<ConferenceInfoList, CoreModel>(me, CoreModel::getInstance()), &QObject::deleteLater);
|
||||||
|
|
||||||
mCoreModelConnection->makeConnectToCore(&ConferenceInfoList::lUpdate, [this]() {
|
mCoreModelConnection->makeConnectToCore(&ConferenceInfoList::lUpdate, [this](bool isInitialization) {
|
||||||
mCoreModelConnection->invokeToModel([this]() {
|
mCoreModelConnection->invokeToModel([this, isInitialization]() {
|
||||||
QList<QSharedPointer<ConferenceInfoCore>> *items = new QList<QSharedPointer<ConferenceInfoCore>>();
|
QList<QSharedPointer<ConferenceInfoCore>> *items = new QList<QSharedPointer<ConferenceInfoCore>>();
|
||||||
mustBeInLinphoneThread(getClassName());
|
mustBeInLinphoneThread(getClassName());
|
||||||
auto defaultAccount = CoreModel::getInstance()->getCore()->getDefaultAccount();
|
auto defaultAccount = CoreModel::getInstance()->getCore()->getDefaultAccount();
|
||||||
|
|
@ -69,27 +70,22 @@ void ConferenceInfoList::setSelf(QSharedPointer<ConferenceInfoList> me) {
|
||||||
auto confInfoCore = build(conferenceInfo);
|
auto confInfoCore = build(conferenceInfo);
|
||||||
// Cancelled conference organized ourself me must be hidden
|
// Cancelled conference organized ourself me must be hidden
|
||||||
if (confInfoCore) {
|
if (confInfoCore) {
|
||||||
qDebug() << log().arg("Add conf") << confInfoCore->getSubject() << "with state"
|
// qDebug() << log().arg("Add conf") << confInfoCore->getSubject() << "with state"
|
||||||
<< confInfoCore->getConferenceInfoState();
|
// << confInfoCore->getConferenceInfoState();
|
||||||
items->push_back(confInfoCore);
|
items->push_back(confInfoCore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mCoreModelConnection->invokeToCore([this, items]() {
|
mCoreModelConnection->invokeToCore([this, items, isInitialization]() {
|
||||||
mustBeInMainThread(getClassName());
|
mustBeInMainThread(getClassName());
|
||||||
int currentDateIndex = sort(*items);
|
for (auto &item : *items) {
|
||||||
auto itemAfterDummy = currentDateIndex < items->size() - 1 ? items->at(currentDateIndex + 1) : nullptr;
|
connectItem(item);
|
||||||
updateHaveCurrentDate(itemAfterDummy);
|
}
|
||||||
resetData<ConferenceInfoCore>(*items);
|
resetData<ConferenceInfoCore>(*items);
|
||||||
if (mLastConfInfoInserted) {
|
updateHaveCurrentDate();
|
||||||
int index = -1;
|
|
||||||
// TODO : uncomment when linphone conference scheduler updated
|
|
||||||
// and model returns the scheduler conferenceInfo uri
|
|
||||||
index = findConfInfoIndexByUri(mLastConfInfoInserted->getUri());
|
|
||||||
if (index != -1) setCurrentDateIndex(index);
|
|
||||||
else setCurrentDateIndex(mHaveCurrentDate ? currentDateIndex : currentDateIndex + 1);
|
|
||||||
mLastConfInfoInserted = nullptr;
|
|
||||||
} else setCurrentDateIndex(mHaveCurrentDate ? currentDateIndex : currentDateIndex + 1);
|
|
||||||
delete items;
|
delete items;
|
||||||
|
if (isInitialization) {
|
||||||
|
emit initialized();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -104,35 +100,43 @@ void ConferenceInfoList::setSelf(QSharedPointer<ConferenceInfoList> me) {
|
||||||
if (defaultAccount) {
|
if (defaultAccount) {
|
||||||
mCurrentAccountCore = AccountCore::create(defaultAccount);
|
mCurrentAccountCore = AccountCore::create(defaultAccount);
|
||||||
connect(mCurrentAccountCore.get(), &AccountCore::registrationStateChanged, this,
|
connect(mCurrentAccountCore.get(), &AccountCore::registrationStateChanged, this,
|
||||||
&ConferenceInfoList::lUpdate);
|
[this] { emit lUpdate(); });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
mCoreModelConnection->makeConnectToModel(&CoreModel::defaultAccountChanged, connectModel);
|
mCoreModelConnection->makeConnectToModel(&CoreModel::defaultAccountChanged, connectModel);
|
||||||
connectModel();
|
connectModel();
|
||||||
|
|
||||||
mCoreModelConnection->makeConnectToModel(
|
auto addConference = [this](const std::shared_ptr<linphone::ConferenceInfo> &confInfo) {
|
||||||
&CoreModel::conferenceInfoCreated, [this](const std::shared_ptr<linphone::ConferenceInfo> &confInfo) {
|
auto list = getSharedList<ConferenceInfoCore>();
|
||||||
auto confInfoCore = ConferenceInfoCore::create(confInfo);
|
|
||||||
auto haveConf =
|
auto haveConf =
|
||||||
std::find_if(mList.begin(), mList.end(), [confInfoCore](const QSharedPointer<QObject> &item) {
|
std::find_if(list.begin(), list.end(), [confInfo](const QSharedPointer<ConferenceInfoCore> &item) {
|
||||||
auto isConfInfo = item.objectCast<ConferenceInfoCore>();
|
std::shared_ptr<linphone::Address> confAddr = nullptr;
|
||||||
if (!isConfInfo) return false;
|
if (item) ToolModel::interpretUrl(item->getUri());
|
||||||
return isConfInfo->getUri() == confInfoCore->getUri();
|
return confInfo->getUri()->weakEqual(confAddr);
|
||||||
|
});
|
||||||
|
if (haveConf == list.end()) {
|
||||||
|
auto confInfoCore = build(confInfo);
|
||||||
|
mCoreModelConnection->invokeToCore([this, confInfoCore] {
|
||||||
|
add(confInfoCore);
|
||||||
|
connectItem(confInfoCore);
|
||||||
|
updateHaveCurrentDate();
|
||||||
|
emit confInfoInserted(getCount() - 1, new ConferenceInfoGui(confInfoCore));
|
||||||
});
|
});
|
||||||
if (haveConf == mList.end()) {
|
|
||||||
mLastConfInfoInserted = confInfoCore;
|
|
||||||
emit lUpdate();
|
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
mCoreModelConnection->makeConnectToModel(
|
||||||
|
&CoreModel::conferenceInfoCreated,
|
||||||
|
[addConference](const std::shared_ptr<linphone::ConferenceInfo> &confInfo) { addConference(confInfo); });
|
||||||
mCoreModelConnection->makeConnectToModel(
|
mCoreModelConnection->makeConnectToModel(
|
||||||
&CoreModel::conferenceInfoReceived,
|
&CoreModel::conferenceInfoReceived,
|
||||||
[this](const std::shared_ptr<linphone::Core> &core,
|
[this, addConference](const std::shared_ptr<linphone::Core> &core,
|
||||||
const std::shared_ptr<const linphone::ConferenceInfo> &conferenceInfo) {
|
const std::shared_ptr<const linphone::ConferenceInfo> &conferenceInfo) {
|
||||||
lDebug() << log().arg("conference info received") << conferenceInfo->getSubject();
|
lDebug() << log().arg("conference info received") << conferenceInfo->getSubject();
|
||||||
emit lUpdate();
|
addConference(conferenceInfo->clone());
|
||||||
});
|
});
|
||||||
emit lUpdate();
|
emit lUpdate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConferenceInfoList::haveCurrentDate() const {
|
bool ConferenceInfoList::haveCurrentDate() const {
|
||||||
|
|
@ -147,43 +151,24 @@ void ConferenceInfoList::setHaveCurrentDate(bool have) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConferenceInfoList::updateHaveCurrentDate() {
|
void ConferenceInfoList::updateHaveCurrentDate() {
|
||||||
auto today = QDateTime::currentDateTimeUtc().date();
|
auto today = QDate::currentDate();
|
||||||
for (auto item : mList) {
|
auto confInfoList = getSharedList<ConferenceInfoCore>();
|
||||||
auto model = item.objectCast<ConferenceInfoCore>();
|
auto haveCurrent =
|
||||||
if (model && model->getDateTimeUtc().date() == today) {
|
std::find_if(confInfoList.begin(), confInfoList.end(), [today](const QSharedPointer<ConferenceInfoCore> &item) {
|
||||||
setHaveCurrentDate(true);
|
return item && item->getDateTimeUtc().date() == today;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setHaveCurrentDate(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConferenceInfoList::updateHaveCurrentDate(QSharedPointer<ConferenceInfoCore> itemToCompare) {
|
|
||||||
setHaveCurrentDate(itemToCompare &&
|
|
||||||
itemToCompare->getDateTimeUtc().date() == QDateTime::currentDateTimeUtc().date());
|
|
||||||
}
|
|
||||||
|
|
||||||
int ConferenceInfoList::getCurrentDateIndex() const {
|
|
||||||
return mCurrentDateIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConferenceInfoList::setCurrentDateIndex(int index) {
|
|
||||||
mCurrentDateIndex = index;
|
|
||||||
emit currentDateIndexChanged(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ConferenceInfoList::findConfInfoIndexByUri(const QString &uri) {
|
|
||||||
auto confInList = std::find_if(mList.begin(), mList.end(), [uri](const QSharedPointer<QObject> &item) {
|
|
||||||
auto isConfInfo = item.objectCast<ConferenceInfoCore>();
|
|
||||||
if (!isConfInfo) return false;
|
|
||||||
return isConfInfo->getUri() == uri;
|
|
||||||
});
|
});
|
||||||
|
setHaveCurrentDate(haveCurrent != confInfoList.end());
|
||||||
|
}
|
||||||
|
|
||||||
return (confInList == mList.end() ? -1 : std::distance(mList.begin(), confInList));
|
int ConferenceInfoList::getCurrentDateIndex() {
|
||||||
|
// Dummy item (nullptr) is QDate::currentDate()
|
||||||
|
auto confInfoList = getSharedList<ConferenceInfoCore>();
|
||||||
|
auto it = std::find(confInfoList.begin(), confInfoList.end(), nullptr);
|
||||||
|
return it == confInfoList.end() ? -1 : std::distance(confInfoList.begin(), it);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<ConferenceInfoCore>
|
QSharedPointer<ConferenceInfoCore>
|
||||||
ConferenceInfoList::build(const std::shared_ptr<linphone::ConferenceInfo> &conferenceInfo) const {
|
ConferenceInfoList::build(const std::shared_ptr<linphone::ConferenceInfo> &conferenceInfo) {
|
||||||
auto me = CoreModel::getInstance()->getCore()->getDefaultAccount()->getParams()->getIdentityAddress();
|
auto me = CoreModel::getInstance()->getCore()->getDefaultAccount()->getParams()->getIdentityAddress();
|
||||||
std::list<std::shared_ptr<linphone::ParticipantInfo>> participants = conferenceInfo->getParticipantInfos();
|
std::list<std::shared_ptr<linphone::ParticipantInfo>> participants = conferenceInfo->getParticipantInfos();
|
||||||
bool haveMe = conferenceInfo->getOrganizer()->weakEqual(me);
|
bool haveMe = conferenceInfo->getOrganizer()->weakEqual(me);
|
||||||
|
|
@ -193,12 +178,18 @@ ConferenceInfoList::build(const std::shared_ptr<linphone::ConferenceInfo> &confe
|
||||||
return me->weakEqual(p->getAddress());
|
return me->weakEqual(p->getAddress());
|
||||||
}) != participants.end());
|
}) != participants.end());
|
||||||
if (haveMe) {
|
if (haveMe) {
|
||||||
auto conferenceModel = ConferenceInfoCore::create(conferenceInfo);
|
auto confInfoCore = ConferenceInfoCore::create(conferenceInfo);
|
||||||
connect(conferenceModel.get(), &ConferenceInfoCore::removed, this, &ConferenceInfoList::lUpdate);
|
return confInfoCore;
|
||||||
return conferenceModel;
|
|
||||||
} else return nullptr;
|
} else return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConferenceInfoList::connectItem(QSharedPointer<ConferenceInfoCore> confInfoCore) {
|
||||||
|
connect(confInfoCore.get(), &ConferenceInfoCore::removed, this, [this](ConferenceInfoCore *confInfo) {
|
||||||
|
remove(confInfo);
|
||||||
|
updateHaveCurrentDate();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
QHash<int, QByteArray> ConferenceInfoList::roleNames() const {
|
QHash<int, QByteArray> ConferenceInfoList::roleNames() const {
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
roles[Qt::DisplayRole] = "$modelData";
|
roles[Qt::DisplayRole] = "$modelData";
|
||||||
|
|
@ -225,19 +216,3 @@ QVariant ConferenceInfoList::data(const QModelIndex &index, int role) const {
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ConferenceInfoList::sort(QList<QSharedPointer<ConferenceInfoCore>> &listToSort) {
|
|
||||||
auto nowDate = QDateTime(QDate::currentDate(), QTime(0, 0, 0)).toUTC().date();
|
|
||||||
std::sort(listToSort.begin(), listToSort.end(),
|
|
||||||
[nowDate](const QSharedPointer<QObject> &a, const QSharedPointer<QObject> &b) {
|
|
||||||
auto l = a.objectCast<ConferenceInfoCore>();
|
|
||||||
auto r = b.objectCast<ConferenceInfoCore>();
|
|
||||||
if (!l || !r) { // sort on date
|
|
||||||
return !l ? nowDate <= r->getDateTimeUtc().date() : l->getDateTimeUtc().date() < nowDate;
|
|
||||||
} else {
|
|
||||||
return l->getDateTimeUtc() < r->getDateTimeUtc();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
auto it = std::find(listToSort.begin(), listToSort.end(), nullptr);
|
|
||||||
return it == listToSort.end() ? -1 : it - listToSort.begin();
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -42,34 +42,30 @@ public:
|
||||||
|
|
||||||
bool haveCurrentDate() const;
|
bool haveCurrentDate() const;
|
||||||
void setHaveCurrentDate(bool have);
|
void setHaveCurrentDate(bool have);
|
||||||
|
|
||||||
void updateHaveCurrentDate();
|
void updateHaveCurrentDate();
|
||||||
void updateHaveCurrentDate(QSharedPointer<ConferenceInfoCore> itemToCompare);
|
|
||||||
|
|
||||||
int getCurrentDateIndex() const;
|
int getCurrentDateIndex();
|
||||||
void setCurrentDateIndex(int index);
|
|
||||||
|
|
||||||
int findConfInfoIndexByUri(const QString &uri);
|
QSharedPointer<ConferenceInfoCore> build(const std::shared_ptr<linphone::ConferenceInfo> &conferenceInfo);
|
||||||
|
void connectItem(QSharedPointer<ConferenceInfoCore> confInfoCore);
|
||||||
QSharedPointer<ConferenceInfoCore> build(const std::shared_ptr<linphone::ConferenceInfo> &conferenceInfo) const;
|
|
||||||
|
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
static int sort(QList<QSharedPointer<ConferenceInfoCore>> &listToSort); // return the index of null item.
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void lUpdate();
|
void lUpdate(bool isInitialization = false);
|
||||||
|
void initialized();
|
||||||
void addCurrentDateChanged();
|
void addCurrentDateChanged();
|
||||||
void haveCurrentDateChanged();
|
void haveCurrentDateChanged();
|
||||||
void currentDateIndexChanged(int index);
|
void currentDateIndexChanged(int index);
|
||||||
|
void confInfoInserted(int index, ConferenceInfoGui *data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedPointer<SafeConnection<ConferenceInfoList, CoreModel>> mCoreModelConnection;
|
QSharedPointer<SafeConnection<ConferenceInfoList, CoreModel>> mCoreModelConnection;
|
||||||
std::shared_ptr<CoreModel> mCoreModel;
|
|
||||||
QSharedPointer<ConferenceInfoCore> mLastConfInfoInserted;
|
|
||||||
QSharedPointer<AccountCore> mCurrentAccountCore;
|
QSharedPointer<AccountCore> mCurrentAccountCore;
|
||||||
bool mHaveCurrentDate = false;
|
bool mHaveCurrentDate = false;
|
||||||
int mCurrentDateIndex = -1;
|
|
||||||
DECLARE_ABSTRACT_OBJECT
|
DECLARE_ABSTRACT_OBJECT
|
||||||
};
|
};
|
||||||
#endif // CONFERENCE_INFO_LIST_H_
|
#endif // CONFERENCE_INFO_LIST_H_
|
||||||
|
|
|
||||||
|
|
@ -27,21 +27,26 @@ DEFINE_ABSTRACT_OBJECT(ConferenceInfoProxy)
|
||||||
|
|
||||||
ConferenceInfoProxy::ConferenceInfoProxy(QObject *parent) : LimitProxy(parent) {
|
ConferenceInfoProxy::ConferenceInfoProxy(QObject *parent) : LimitProxy(parent) {
|
||||||
mList = ConferenceInfoList::create();
|
mList = ConferenceInfoList::create();
|
||||||
setSourceModels(new SortFilterList(mList.get()));
|
setSourceModels(new SortFilterList(mList.get(), Qt::AscendingOrder));
|
||||||
connect(
|
|
||||||
this, &ConferenceInfoProxy::filterTextChanged, this, [this] { updateCurrentDateIndex(); },
|
|
||||||
Qt::QueuedConnection);
|
|
||||||
connect(
|
connect(
|
||||||
mList.get(), &ConferenceInfoList::haveCurrentDateChanged, this,
|
mList.get(), &ConferenceInfoList::haveCurrentDateChanged, this,
|
||||||
[this] {
|
[this] {
|
||||||
invalidate();
|
auto sortModel = dynamic_cast<SortFilterList *>(sourceModel());
|
||||||
updateCurrentDateIndex();
|
sortModel->invalidate();
|
||||||
},
|
},
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
connect(mList.get(), &ConferenceInfoList::haveCurrentDateChanged, this,
|
connect(
|
||||||
&ConferenceInfoProxy::haveCurrentDateChanged, Qt::QueuedConnection);
|
mList.get(), &ConferenceInfoList::confInfoInserted, this,
|
||||||
connect(mList.get(), &ConferenceInfoList::currentDateIndexChanged, this,
|
[this](int index, ConferenceInfoGui *data) {
|
||||||
&ConferenceInfoProxy::updateCurrentDateIndex, Qt::QueuedConnection);
|
auto sortModel = dynamic_cast<SortFilterList *>(sourceModel());
|
||||||
|
if (sortModel) {
|
||||||
|
auto proxyIndex = sortModel->mapFromSource(mList->index(index, 0)).row();
|
||||||
|
if (proxyIndex >= getMaxDisplayItems()) setMaxDisplayItems(proxyIndex + 1);
|
||||||
|
emit conferenceInfoCreated(proxyIndex);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
connect(mList.get(), &ConferenceInfoList::initialized, this, &ConferenceInfoProxy::initialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConferenceInfoProxy::~ConferenceInfoProxy() {
|
ConferenceInfoProxy::~ConferenceInfoProxy() {
|
||||||
|
|
@ -51,16 +56,6 @@ bool ConferenceInfoProxy::haveCurrentDate() const {
|
||||||
return mList->haveCurrentDate();
|
return mList->haveCurrentDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ConferenceInfoProxy::getCurrentDateIndex() const {
|
|
||||||
return mCurrentDateIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConferenceInfoProxy::updateCurrentDateIndex() {
|
|
||||||
int newIndex = mapFromSource(sourceModel()->index(mList->getCurrentDateIndex(), 0)).row();
|
|
||||||
mCurrentDateIndex = newIndex;
|
|
||||||
emit currentDateIndexChanged(newIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ConferenceInfoProxy::SortFilterList::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const {
|
bool ConferenceInfoProxy::SortFilterList::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const {
|
||||||
auto list = qobject_cast<ConferenceInfoList *>(sourceModel());
|
auto list = qobject_cast<ConferenceInfoList *>(sourceModel());
|
||||||
auto ciCore = list->getAt<ConferenceInfoCore>(sourceRow);
|
auto ciCore = list->getAt<ConferenceInfoCore>(sourceRow);
|
||||||
|
|
@ -84,12 +79,30 @@ bool ConferenceInfoProxy::SortFilterList::filterAcceptsRow(int sourceRow, const
|
||||||
return res;
|
return res;
|
||||||
} else return mFilterType == -1;
|
} else return mFilterType == -1;
|
||||||
} else {
|
} else {
|
||||||
return !list->haveCurrentDate() && list->getCount() > 1 && mFilterText.isEmpty();
|
|
||||||
// if mlist count == 1 there is only the dummy row which we don't display alone
|
// if mlist count == 1 there is only the dummy row which we don't display alone
|
||||||
|
return !list->haveCurrentDate() && list->getCount() > 1 && mFilterText.isEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ConferenceInfoProxy::getCurrentDateIndex() const {
|
||||||
|
auto sortModel = dynamic_cast<SortFilterList *>(sourceModel());
|
||||||
|
auto modelIndex = mList->getCurrentDateIndex();
|
||||||
|
auto proxyIndex = sortModel->mapFromSource(mList->index(modelIndex, 0)).row();
|
||||||
|
return proxyIndex;
|
||||||
|
}
|
||||||
|
|
||||||
bool ConferenceInfoProxy::SortFilterList::lessThan(const QModelIndex &sourceLeft,
|
bool ConferenceInfoProxy::SortFilterList::lessThan(const QModelIndex &sourceLeft,
|
||||||
const QModelIndex &sourceRight) const {
|
const QModelIndex &sourceRight) const {
|
||||||
return true; // Not used
|
auto l = getItemAtSource<ConferenceInfoList, ConferenceInfoCore>(sourceLeft.row());
|
||||||
|
auto r = getItemAtSource<ConferenceInfoList, ConferenceInfoCore>(sourceRight.row());
|
||||||
|
if (!l && !r) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
auto nowDate = QDate::currentDate();
|
||||||
|
if (!l || !r) { // sort on date
|
||||||
|
auto rdate = r ? r->getDateTimeUtc().date() : QDate::currentDate();
|
||||||
|
return !l ? nowDate <= r->getDateTimeUtc().date() : l->getDateTimeUtc().date() < nowDate;
|
||||||
|
} else {
|
||||||
|
return l->getDateTimeUtc() < r->getDateTimeUtc();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ class ConferenceInfoProxy : public LimitProxy, public AbstractObject {
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool haveCurrentDate READ haveCurrentDate NOTIFY haveCurrentDateChanged)
|
Q_PROPERTY(bool haveCurrentDate READ haveCurrentDate NOTIFY haveCurrentDateChanged)
|
||||||
Q_PROPERTY(int currentDateIndex READ getCurrentDateIndex NOTIFY currentDateIndexChanged)
|
// Q_PROPERTY(int currentDateIndex READ getCurrentDateIndex NOTIFY currentDateIndexChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum ConferenceInfoFiltering { None = 0, Future = 1 };
|
enum ConferenceInfoFiltering { None = 0, Future = 1 };
|
||||||
|
|
@ -43,12 +43,12 @@ public:
|
||||||
|
|
||||||
bool haveCurrentDate() const;
|
bool haveCurrentDate() const;
|
||||||
|
|
||||||
int getCurrentDateIndex() const;
|
Q_INVOKABLE int getCurrentDateIndex() const;
|
||||||
void updateCurrentDateIndex();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void haveCurrentDateChanged();
|
void haveCurrentDateChanged();
|
||||||
void currentDateIndexChanged(int index);
|
void conferenceInfoCreated(int index);
|
||||||
|
void initialized();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedPointer<ConferenceInfoList> mList;
|
QSharedPointer<ConferenceInfoList> mList;
|
||||||
|
|
|
||||||
|
|
@ -17,41 +17,31 @@ ListView {
|
||||||
property ConferenceInfoGui selectedConference: model && currentIndex != -1 ? model.getAt(currentIndex) : null
|
property ConferenceInfoGui selectedConference: model && currentIndex != -1 ? model.getAt(currentIndex) : null
|
||||||
|
|
||||||
spacing: 8 * DefaultStyle.dp
|
spacing: 8 * DefaultStyle.dp
|
||||||
currentIndex: confInfoProxy.currentDateIndex
|
highlightFollowsCurrentItem: true
|
||||||
// using highlight doesn't center, take time before moving and don't work for not visible item (like not loaded)
|
highlightMoveVelocity: 1500
|
||||||
highlightFollowsCurrentItem: false
|
|
||||||
|
|
||||||
onCountChanged: {
|
onCountChanged: {
|
||||||
selectedConference = model && currentIndex != -1 && currentIndex < model.count ? model.getAt(currentIndex) : null
|
selectedConference = model && currentIndex != -1 && currentIndex < model.count ? model.getAt(currentIndex) : null
|
||||||
}
|
}
|
||||||
Connections {
|
|
||||||
target: confInfoProxy
|
|
||||||
function onCurrentDateIndexChanged(index) {
|
|
||||||
mainItem.currentIndex = index
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onCurrentIndexChanged: {
|
onCurrentIndexChanged: {
|
||||||
selectedConference = model.getAt(currentIndex) || null
|
selectedConference = model.getAt(currentIndex) || null
|
||||||
if (currentIndex != -1) positionViewAtIndex(currentIndex, ListView.Contain)
|
|
||||||
}
|
|
||||||
onVisibleChanged: if( visible) {
|
|
||||||
mainItem.positionViewAtIndex(currentIndex, ListView.Center)// First approximative move
|
|
||||||
delayMove.restart() // Move to exact position after load.
|
|
||||||
}
|
}
|
||||||
onAtYEndChanged: if(atYEnd) confInfoProxy.displayMore()
|
onAtYEndChanged: if(atYEnd) confInfoProxy.displayMore()
|
||||||
|
|
||||||
Timer{
|
|
||||||
id: delayMove
|
|
||||||
interval: 60
|
|
||||||
onTriggered: mainItem.positionViewAtIndex(currentIndex, ListView.Center)
|
|
||||||
}
|
|
||||||
|
|
||||||
model: ConferenceInfoProxy {
|
model: ConferenceInfoProxy {
|
||||||
id: confInfoProxy
|
id: confInfoProxy
|
||||||
filterText: searchBarText
|
filterText: searchBarText
|
||||||
filterType: ConferenceInfoProxy.None
|
filterType: ConferenceInfoProxy.None
|
||||||
initialDisplayItems: mainItem.height / (63 * DefaultStyle.dp) + 5
|
initialDisplayItems: mainItem.height / (63 * DefaultStyle.dp) + 5
|
||||||
displayItemsStep: initialDisplayItems/2
|
displayItemsStep: initialDisplayItems/2
|
||||||
|
onConferenceInfoCreated: (index) => {
|
||||||
|
mainItem.currentIndex = index
|
||||||
|
}
|
||||||
|
onInitialized: {
|
||||||
|
var initIndex = confInfoProxy.getCurrentDateIndex()
|
||||||
|
if (initIndex >= maxDisplayItems) maxDisplayItems = initIndex + 1
|
||||||
|
mainItem.currentIndex = initIndex
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
section {
|
section {
|
||||||
|
|
@ -85,7 +75,7 @@ ListView {
|
||||||
property int topOffset: (dateDay.visible && !isFirst? 8 * DefaultStyle.dp : 0)
|
property int topOffset: (dateDay.visible && !isFirst? 8 * DefaultStyle.dp : 0)
|
||||||
property var endDateTime: $modelData ? $modelData.core.endDateTime : UtilsCpp.getCurrentDateTime()
|
property var endDateTime: $modelData ? $modelData.core.endDateTime : UtilsCpp.getCurrentDateTime()
|
||||||
property var haveModel: !!$modelData && $modelData != undefined && $modelData.core.haveModel || false
|
property var haveModel: !!$modelData && $modelData != undefined && $modelData.core.haveModel || false
|
||||||
property bool isCanceled: $modelData.core.state === LinphoneEnums.ConferenceInfoState.Cancelled
|
property bool isCanceled: $modelData?.core.state === LinphoneEnums.ConferenceInfoState.Cancelled || false
|
||||||
Component.onCompleted: if (!isFirst && dateDay.visible) {
|
Component.onCompleted: if (!isFirst && dateDay.visible) {
|
||||||
height = (63+topOffset)*DefaultStyle.dp
|
height = (63+topOffset)*DefaultStyle.dp
|
||||||
delegateIn.anchors.topMargin = topOffset
|
delegateIn.anchors.topMargin = topOffset
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue