Commit 13c74be2 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/views/App/Calls/ConferenceManager): in progress

parent b943d423
......@@ -25,6 +25,7 @@
#include "../../app/App.hpp"
#include "../../Utils.hpp"
#include "../conference/ConferenceHelperModel.hpp"
#include "../core/CoreManager.hpp"
#include "CallsListModel.hpp"
......@@ -195,7 +196,7 @@ void CallsListModel::removeCall (const shared_ptr<linphone::Call> &call) {
try {
callModel = &call->getData<CallModel>("call-model");
} catch (const out_of_range &) {
// Can be a bug. Or the call model not exists because the linphone call state
// The call model not exists because the linphone call state
// `CallStateIncomingReceived`/`CallStateOutgoingInit` was not notified.
qWarning() << QStringLiteral("Unable to found linphone call:") << call.get();
return;
......@@ -209,8 +210,10 @@ void CallsListModel::removeCall (const shared_ptr<linphone::Call> &call) {
if (index == -1 || !removeRow(index))
qWarning() << QStringLiteral("Unable to remove call:") << callModel;
if (mList.empty())
if (mList.empty() && ConferenceHelperModel::getInstancesNumber() == 0) {
qInfo() << QStringLiteral("Last call terminated, close calls window.");
App::getInstance()->getCallsWindow()->close();
}
}
);
}
......@@ -114,8 +114,11 @@ bool ConferenceHelperModel::ConferenceAddModel::removeFromConference (const QStr
void ConferenceHelperModel::ConferenceAddModel::update () {
list<shared_ptr<linphone::Address> > linphoneAddresses;
for (const auto &map : mRefs)
linphoneAddresses.push_back(map->value("__linphoneAddress").value<shared_ptr<linphone::Address> > ());
for (const auto &map : mRefs) {
shared_ptr<linphone::Address> linphoneAddress = map->value("__linphoneAddress").value<shared_ptr<linphone::Address> >();
Q_ASSERT(linphoneAddress != nullptr);
linphoneAddresses.push_back(linphoneAddress);
}
mConferenceHelperModel->mConference->inviteParticipants(
linphoneAddresses,
......
......@@ -31,6 +31,8 @@ using namespace std;
// =============================================================================
int ConferenceHelperModel::mInstancesNumber = 0;
ConferenceHelperModel::ConferenceHelperModel (QObject *parent) : QSortFilterProxyModel(parent) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
......@@ -42,6 +44,18 @@ ConferenceHelperModel::ConferenceHelperModel (QObject *parent) : QSortFilterProx
App::getInstance()->getEngine()->setObjectOwnership(mConferenceAddModel, QQmlEngine::CppOwnership);
setSourceModel(new SipAddressesProxyModel(this));
mInstancesNumber++;
}
ConferenceHelperModel::~ConferenceHelperModel () {
mInstancesNumber--;
Q_ASSERT(mInstancesNumber >= 0);
if (mInstancesNumber == 0 && CoreManager::getInstance()->getCallsListModel()->rowCount() == 0) {
qInfo() << QStringLiteral("Conference terminated and no calls, close calls window.");
App::getInstance()->getCallsWindow()->close();
}
}
QHash<int, QByteArray> ConferenceHelperModel::roleNames () const {
......
......@@ -45,10 +45,14 @@ public:
class ConferenceAddModel;
ConferenceHelperModel (QObject *parent = Q_NULLPTR);
~ConferenceHelperModel () = default;
~ConferenceHelperModel ();
QHash<int, QByteArray> roleNames () const override;
static int getInstancesNumber () {
return mInstancesNumber;
}
Q_INVOKABLE void setFilter (const QString &pattern);
protected:
......@@ -62,6 +66,8 @@ private:
ConferenceAddModel *mConferenceAddModel;
std::shared_ptr<linphone::Conference> mConference;
static int mInstancesNumber;
};
#endif // CONFERENCE_HELPER_MODEL_H_
......@@ -8,6 +8,8 @@ import Common.Styles 1.0
Rectangle {
id: field
property bool readOnly: false
default property alias _content: content.data
color: TextFieldStyle.background.color.normal
......@@ -30,4 +32,12 @@ Rectangle {
color: 'transparent'
radius: field.radius
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
visible: field.readOnly
onWheel: wheel.accepted = true
}
}
......@@ -9,6 +9,11 @@ import App.Styles 1.0
// =============================================================================
DialogPlus {
id: conferenceManager
readonly property int maxParticipants: 10
readonly property int minParticipants: 2
buttons: [
TextButtonA {
text: qsTr('cancel')
......@@ -16,6 +21,7 @@ DialogPlus {
onClicked: exit(0)
},
TextButtonB {
enabled: toAddView.count >= conferenceManager.minParticipants
text: qsTr('confirm')
onClicked: {
......@@ -68,6 +74,8 @@ DialogPlus {
Layout.fillHeight: true
Layout.fillWidth: true
readOnly: toAddView.count >= conferenceManager.maxParticipants
SipAddressesView {
anchors.fill: parent
......@@ -113,6 +121,8 @@ DialogPlus {
Layout.topMargin: filter.height + ConferenceManagerStyle.columns.selector.spacing
SipAddressesView {
id: toAddView
anchors.fill: parent
actions: [{
......@@ -123,6 +133,8 @@ DialogPlus {
}]
model: conferenceHelperModel.toAdd
onEntryClicked: actions[0].handler(entry)
}
}
}
......
linphone @ 38638e54
Subproject commit 2b6bcbc7f46423d17c18f2e2eafe52ac245e337f
Subproject commit 38638e543d1641ff637f32c4424f61684c861cea
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