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

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

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