Commit a3e47284 authored by Edric Milaret's avatar Edric Milaret

adapt to lrc api changes

Linked to change 3003

Change-Id: Ib779a04021fdd6ede2dcd99141d7671d34c5c9e1
Tuleap: #44
parent 816cc90c
......@@ -190,7 +190,7 @@ AccountSerializationAdapter::AccountSerializationAdapter(Account* a, QWidget* w)
{
static QHash<QByteArray, int> reverse;
if (reverse.isEmpty()) {
const QHash<int, QByteArray> a = AccountModel::instance()->roleNames();
const QHash<int, QByteArray> a = AccountModel::instance().roleNames();
for (QHash<int, QByteArray>::const_iterator i = a.begin(); i != a.end(); ++i) {
reverse[i.value()] = i.key();
}
......
......@@ -43,7 +43,7 @@ AccountStateDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio
auto font = painter->font() ;
font.setBold(true);
painter->setFont(font);
painter->setPen(AccountModel::instance()->
painter->setPen(AccountModel::instance().
getAccountByModelIndex(index)->stateColorName());
painter->setOpacity(1.0);
painter->drawText(QRect(rect.left()+25, rect.top(),
......
......@@ -74,7 +74,7 @@ CallWidget::CallWidget(QWidget *parent) :
ui->ringLogo->setAlignment(Qt::AlignHCenter);
try {
callModel_ = CallModel::instance();
callModel_ = &CallModel::instance();
connect(callModel_, SIGNAL(incomingCall(Call*)),
this, SLOT(callIncoming(Call*)));
......@@ -83,12 +83,12 @@ CallWidget::CallWidget(QWidget *parent) :
connect(callModel_, SIGNAL(callStateChanged(Call*, Call::State)),
this, SLOT(callStateChanged(Call*, Call::State)));
connect(AccountModel::instance()
connect(&AccountModel::instance()
, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>))
, this
, SLOT(findRingAccount(QModelIndex, QModelIndex, QVector<int>)));
ui->smartList->setModel(RecentModel::instance()->peopleProxy());
ui->smartList->setModel(RecentModel::instance().peopleProxy());
connect(ui->smartList->selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this,
......@@ -97,26 +97,26 @@ CallWidget::CallWidget(QWidget *parent) :
ui->smartList->setItemDelegate(smartListDelegate_);
ui->smartList->setHeaderHidden(true);
PersonModel::instance()->
PersonModel::instance().
addCollection<WindowsContactBackend>(LoadOptions::FORCE_ENABLED);
CategorizedContactModel::instance()->setSortAlphabetical(false);
CategorizedContactModel::instance()->setUnreachableHidden(true);
ui->contactView->setModel(CategorizedContactModel::instance());
CategorizedContactModel::instance().setSortAlphabetical(false);
CategorizedContactModel::instance().setUnreachableHidden(true);
ui->contactView->setModel(&CategorizedContactModel::instance());
contactDelegate_ = new ContactDelegate();
ui->contactView->setItemDelegate(contactDelegate_);
CategorizedHistoryModel::instance()->
CategorizedHistoryModel::instance().
addCollection<LocalHistoryCollection>(LoadOptions::FORCE_ENABLED);
ui->historyList->setModel(CategorizedHistoryModel::SortedProxy::instance()->model());
CategorizedHistoryModel::SortedProxy::instance()->model()->sort(0, Qt::DescendingOrder);
ui->historyList->setModel(CategorizedHistoryModel::SortedProxy::instance().model());
CategorizedHistoryModel::SortedProxy::instance().model()->sort(0, Qt::DescendingOrder);
ui->historyList->setHeaderHidden(true);
historyDelegate_ = new HistoryDelegate();
ui->historyList->setItemDelegate(historyDelegate_);
connect(CategorizedHistoryModel::SortedProxy::instance()->model(), &QSortFilterProxyModel::layoutChanged, [=]() {
auto idx = CategorizedHistoryModel::SortedProxy::instance()->model()->index(0,0);
connect(CategorizedHistoryModel::SortedProxy::instance().model(), &QSortFilterProxyModel::layoutChanged, [=]() {
auto idx = CategorizedHistoryModel::SortedProxy::instance().model()->index(0,0);
if (idx.isValid())
ui->historyList->setExpanded(idx, true);
});
......@@ -170,10 +170,10 @@ CallWidget::findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec
Q_UNUSED(idx2)
Q_UNUSED(vec)
auto a_count = AccountModel::instance()->rowCount();
auto a_count = AccountModel::instance().rowCount();
auto found = false;
for (int i = 0; i < a_count; ++i) {
auto idx = AccountModel::instance()->index(i, 0);
auto idx = AccountModel::instance().index(i, 0);
auto protocol = idx.data(static_cast<int>(Account::Role::Proto));
if ((Account::Protocol)protocol.toUInt() == Account::Protocol::RING) {
auto username = idx.data(static_cast<int>(Account::Role::Username));
......@@ -191,13 +191,13 @@ void
CallWidget::findRingAccount()
{
auto a_count = AccountModel::instance()->rowCount();
auto a_count = AccountModel::instance().rowCount();
auto found = false;
for (int i = 0; i < a_count; ++i) {
auto idx = AccountModel::instance()->index(i, 0);
auto idx = AccountModel::instance().index(i, 0);
auto protocol = idx.data(static_cast<int>(Account::Role::Proto));
if ((Account::Protocol)protocol.toUInt() == Account::Protocol::RING) {
auto account = AccountModel::instance()->getAccountByModelIndex(idx);
auto account = AccountModel::instance().getAccountByModelIndex(idx);
if (account->displayName().isEmpty())
account->displayName() = account->alias();
auto username = account->username();
......@@ -322,7 +322,7 @@ CallWidget::on_contactView_doubleClicked(const QModelIndex &index)
uri = dlg.getSelected();
}
if (uri) {
auto outCall = CallModel::instance()->dialingCall(uri);
auto outCall = CallModel::instance().dialingCall(uri);
outCall->performAction(Call::Action::ACCEPT);
ui->mainTabMenu->setCurrentIndex(0);
ui->smartList->setFocus();
......@@ -338,7 +338,7 @@ CallWidget::on_historyList_doubleClicked(const QModelIndex &index)
auto number = index.data(static_cast<int>(Call::Role::ContactMethod)).value<ContactMethod*>();
if (number) {
auto outCall = CallModel::instance()->dialingCall(number);
auto outCall = CallModel::instance().dialingCall(number);
outCall->performAction(Call::Action::ACCEPT);
ui->mainTabMenu->setCurrentIndex(0);
ui->smartList->setFocus();
......@@ -350,7 +350,7 @@ CallWidget::setActualCall(Call* value)
{
actualCall_ = value;
if (value)
CallModel::instance()->selectCall(value);
CallModel::instance().selectCall(value);
}
void
......@@ -371,8 +371,8 @@ CallWidget::on_cancelButton_clicked()
void
CallWidget::on_smartList_doubleClicked(const QModelIndex &index)
{
auto realIndex = RecentModel::instance()->peopleProxy()->mapToSource(index);
if (RecentModel::instance()->hasActiveCall(realIndex))
auto realIndex = RecentModel::instance().peopleProxy()->mapToSource(index);
if (RecentModel::instance().hasActiveCall(realIndex))
return;
ContactMethod* m = nullptr;
......@@ -383,8 +383,8 @@ CallWidget::on_smartList_doubleClicked(const QModelIndex &index)
m = person->phoneNumbers().first();
}
}
if (m && !RecentModel::instance()->index(0, 0, realIndex).isValid()) {
Call* c = CallModel::instance()->dialingCall(m);
if (m && !RecentModel::instance().index(0, 0, realIndex).isValid()) {
Call* c = CallModel::instance().dialingCall(m);
c->performAction(Call::Action::ACCEPT);
}
}
......@@ -398,7 +398,7 @@ CallWidget::smartListSelectionChanged(const QItemSelection &newSel, const QItemS
if (newIdx.parent().isValid())
return;
auto newIdxCall = RecentModel::instance()->getActiveCall(RecentModel::instance()->peopleProxy()->mapToSource(newIdx));
auto newIdxCall = RecentModel::instance().getActiveCall(RecentModel::instance().peopleProxy()->mapToSource(newIdx));
if (newIdxCall == actualCall_)
return;
......@@ -420,7 +420,7 @@ CallWidget::placeCall()
{
if (ui->searchEdit->text().isEmpty())
return;
Call* c = CallModel::instance()->dialingCall(PhoneDirectoryModel::instance()->getNumber(ui->searchEdit->text()));
Call* c = CallModel::instance().dialingCall(PhoneDirectoryModel::instance().getNumber(ui->searchEdit->text()));
c->performAction(Call::Action::ACCEPT);
ui->searchEdit->clear();
}
......
......@@ -44,8 +44,8 @@
ConfigurationWidget::ConfigurationWidget(QWidget *parent) :
NavWidget(Nav, parent),
ui(new Ui::ConfigurationWidget),
accountModel_(AccountModel::instance()),
deviceModel_(Video::DeviceModel::instance()),
accountModel_(&AccountModel::instance()),
deviceModel_(&Video::DeviceModel::instance()),
accountDetails_(new AccountDetails())
{
ui->setupUi(this);
......@@ -68,19 +68,19 @@ ConfigurationWidget::ConfigurationWidget(QWidget *parent) :
ui->accountTypeBox->setModel(accountModel_->protocolModel());
ui->startupBox->setChecked(Utils::CheckStartupLink());
ui->ringtonesBox->setModel(RingtoneModel::instance());
ui->ringtonesBox->setModel(&RingtoneModel::instance());
ui->historyDaySettingsSpinBox->setValue(
CategorizedHistoryModel::instance()->historyLimit());
CategorizedHistoryModel::instance().historyLimit());
ui->closeOrMinCheckBox->setChecked(settings_.value(
SettingsKey::closeOrMinimized).toBool());
connect(ui->tabWidget, &QTabWidget::currentChanged, [](int index) {
if (index == 1
&& CallModel::instance()->getActiveCalls().size() == 0) {
Video::PreviewManager::instance()->startPreview();
&& CallModel::instance().getActiveCalls().size() == 0) {
Video::PreviewManager::instance().startPreview();
} else {
if (CallModel::instance()->getActiveCalls().size() == 0
&& Video::PreviewManager::instance()->isPreviewing()) {
Video::PreviewManager::instance()->stopPreview();
if (CallModel::instance().getActiveCalls().size() == 0
&& Video::PreviewManager::instance().isPreviewing()) {
Video::PreviewManager::instance().stopPreview();
}
}
});
......@@ -90,16 +90,16 @@ void
ConfigurationWidget::showEvent(QShowEvent *event) {
QWidget::showEvent(event);
if (ui->tabWidget->currentIndex() == 1
&& CallModel::instance()->getActiveCalls().size() == 0) {
Video::PreviewManager::instance()->startPreview();
&& CallModel::instance().getActiveCalls().size() == 0) {
Video::PreviewManager::instance().startPreview();
}
}
void
ConfigurationWidget::atExit() {
if (CallModel::instance()->getActiveCalls().size() == 0
&& Video::PreviewManager::instance()->isPreviewing()) {
Video::PreviewManager::instance()->stopPreview();
if (CallModel::instance().getActiveCalls().size() == 0
&& Video::PreviewManager::instance().isPreviewing()) {
Video::PreviewManager::instance().stopPreview();
}
accountModel_->save();
accountDetails_->save();
......@@ -221,14 +221,14 @@ ConfigurationWidget::on_clearHistoryButton_clicked()
auto ret = confirmationDialog.exec();
if (ret == QMessageBox::Ok)
CategorizedHistoryModel::instance()->clearAllCollections();
CategorizedHistoryModel::instance().clearAllCollections();
}
void
ConfigurationWidget::on_historyDaySettingsSpinBox_valueChanged(int limit)
{
if (CategorizedHistoryModel::instance()->historyLimit() != limit)
CategorizedHistoryModel::instance()->setHistoryLimit(limit);
if (CategorizedHistoryModel::instance().historyLimit() != limit)
CategorizedHistoryModel::instance().setHistoryLimit(limit);
}
void
......
......@@ -37,7 +37,7 @@ ContactPicker::ContactPicker(ContactMethod *number, QWidget *parent) :
this->setWindowFlags(Qt::CustomizeWindowHint);
this->setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);
contactProxyModel_ = new OnlyPersonProxyModel(PersonModel::instance());
contactProxyModel_ = new OnlyPersonProxyModel(&PersonModel::instance());
contactProxyModel_->setSortRole(static_cast<int>(Qt::DisplayRole));
contactProxyModel_->sort(0,Qt::AscendingOrder);
contactProxyModel_->setFilterRole(Qt::DisplayRole);
......@@ -63,12 +63,12 @@ ContactPicker::accept()
{
/* Force LRC to update contact model as adding a number
to a contact without one didn't render him reachable */
CategorizedContactModel::instance()->setUnreachableHidden(false);
CategorizedContactModel::instance().setUnreachableHidden(false);
auto idx = ui->contactView->currentIndex();
//There is only one collection on Windows
auto personCollection = PersonModel::instance()->collections().at(0);
auto personCollection = PersonModel::instance().collections().at(0);
if (not ui->nameLineEdit->text().isEmpty()) {
auto *newPerson = new Person();
......@@ -77,7 +77,7 @@ ContactPicker::accept()
cM.append(number_);
newPerson->setContactMethods(cM);
newPerson->setUid(Utils::GenGUID().toLocal8Bit());
PersonModel::instance()->addNewPerson(newPerson, personCollection);
PersonModel::instance().addNewPerson(newPerson, personCollection);
} else if (idx.isValid()) {
auto p = idx.data(static_cast<int>(Person::Role::Object)).value<Person*>();
Person::ContactMethods cM (p->phoneNumbers());
......@@ -85,7 +85,7 @@ ContactPicker::accept()
p->setContactMethods(cM);
p->save();
}
CategorizedContactModel::instance()->setUnreachableHidden(true);
CategorizedContactModel::instance().setUnreachableHidden(true);
QDialog::accept();
}
......
......@@ -105,9 +105,5 @@ main(int argc, char *argv[])
w.createThumbBar();
QObject::connect(&a, &QApplication::aboutToQuit, [&a]() {
delete CallModel::instance();
});
return a.exec();
}
......@@ -62,7 +62,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(&sysIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(trayActivated(QSystemTrayIcon::ActivationReason)));
connect(CallModel::instance(), SIGNAL(incomingCall(Call*)),
connect(&CallModel::instance(), SIGNAL(incomingCall(Call*)),
this, SLOT(onIncomingCall(Call*)));
navStack_ = new NavStack(ui->bar, ui->stackedWidgetView, this);
......
......@@ -67,7 +67,7 @@ SelectAreaDialog::mouseReleaseEvent(QMouseEvent* event)
if(rubberBand_) {
QApplication::restoreOverrideCursor();
releaseMouse();
Video::SourceModel::instance()->setDisplay(0, rubberBand_->rect());
Video::SourceModel::instance().setDisplay(0, rubberBand_->rect());
delete rubberBand_;
rubberBand_ = nullptr;
reject();
......
......@@ -58,7 +58,7 @@ SmartListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
}
QVariant state = index.data(static_cast<int>(Ring::Role::FormattedState));
if (state.isValid() && RecentModel::instance()->getActiveCall(RecentModel::instance()->peopleProxy()->mapToSource(index))) {
if (state.isValid() && RecentModel::instance().getActiveCall(RecentModel::instance().peopleProxy()->mapToSource(index))) {
painter->drawText(QRect(rect.left()+sizeImage_+5,
rect.top() + rect.height()/2,
rect.width(), rect.height()/2),
......
......@@ -46,7 +46,7 @@ TransferDialog::showEvent(QShowEvent *event)
ui->numberBar->clear();
selectedCall_ = nullptr;
if (not activeProxy_) {
activeProxy_ = new ActiveCallsProxyModel(CallModel::instance());
activeProxy_ = new ActiveCallsProxyModel(&CallModel::instance());
activeProxy_->setDynamicSortFilter(false);
}
ui->activeCallsView->setModel(activeProxy_);
......@@ -58,14 +58,14 @@ TransferDialog::on_transferButton_clicked()
{
removeProxyModel();
auto callList = CallModel::instance()->getActiveCalls();
auto callList = CallModel::instance().getActiveCalls();
for (auto c : callList) {
if (c->state() == Call::State::CURRENT) {
if (not ui->numberBar->text().isEmpty()) {
auto number = PhoneDirectoryModel::instance()->getNumber(ui->numberBar->text());
CallModel::instance()->transfer(c, number);
auto number = PhoneDirectoryModel::instance().getNumber(ui->numberBar->text());
CallModel::instance().transfer(c, number);
} else if (selectedCall_) {
CallModel::instance()->attendedTransfer(c, selectedCall_);
CallModel::instance().attendedTransfer(c, selectedCall_);
}
this->close();
return;
......@@ -87,11 +87,11 @@ TransferDialog::on_activeCallsView_doubleClicked(const QModelIndex &index)
removeProxyModel();
auto callList = CallModel::instance()->getActiveCalls();
auto callList = CallModel::instance().getActiveCalls();
for (auto c : callList) {
if (c->state() == Call::State::CURRENT) {
if (c != selectedCall_) {
CallModel::instance()->attendedTransfer(c, selectedCall_);
CallModel::instance().attendedTransfer(c, selectedCall_);
this->close();
return;
}
......@@ -102,5 +102,5 @@ TransferDialog::on_activeCallsView_doubleClicked(const QModelIndex &index)
void
TransferDialog::on_activeCallsView_clicked(const QModelIndex &index)
{
selectedCall_ = CallModel::instance()->getCall(index);
selectedCall_ = CallModel::instance().getCall(index);
}
......@@ -31,7 +31,7 @@ VideoOverlay::VideoOverlay(QWidget *parent) :
ui->chatButton->setCheckable(true);
ui->transferButton->setCheckable(true);
actionModel_ = CallModel::instance()->userActionModel();
actionModel_ = CallModel::instance().userActionModel();
setAttribute(Qt::WA_NoSystemBackground);
menu_ = new QMenu(this);
......
......@@ -41,7 +41,7 @@ VideoView::VideoView(QWidget *parent) :
{
ui->setupUi(this);
connect(CallModel::instance(), SIGNAL(callStateChanged(Call*, Call::State)),
connect(&CallModel::instance(), SIGNAL(callStateChanged(Call*, Call::State)),
this, SLOT(callStateChanged(Call*, Call::State)));
overlay_ = new VideoOverlay(this);
......@@ -114,7 +114,7 @@ VideoView::callStateChanged(Call* call, Call::State previousState)
void
VideoView::updateCall()
{
auto call = CallModel::instance()->selectedCall();
auto call = CallModel::instance().selectedCall();
overlay_->setName(call->formattedName());
overlay_->setTime(call->length());
}
......@@ -134,7 +134,7 @@ void VideoView::dragEnterEvent(QDragEnterEvent *event)
void VideoView::dropEvent(QDropEvent *event)
{
auto urls = event->mimeData()->urls();
Video::SourceModel::instance()->setFile(urls.at(0));
Video::SourceModel::instance().setFile(urls.at(0));
}
void
......@@ -161,17 +161,17 @@ VideoView::showContextMenu(const QPoint& pos)
QMenu menu;
for (auto device : Video::DeviceModel::instance()->devices()) {
for (auto device : Video::DeviceModel::instance().devices()) {
std::unique_ptr<QAction> deviceAction(new QAction(device->name(), this));
deviceAction->setCheckable(true);
if (device == Video::DeviceModel::instance()->activeDevice())
if (device == Video::DeviceModel::instance().activeDevice())
deviceAction->setChecked(true);
auto ptr = deviceAction.release();
menu.addAction(ptr);
connect(ptr, &QAction::toggled, [=](bool checked) {
if (checked == true) {
Video::SourceModel::instance()->switchTo(device);
Video::DeviceModel::instance()->setActive(device);
Video::SourceModel::instance().switchTo(device);
Video::DeviceModel::instance().setActive(device);
}
});
}
......@@ -181,7 +181,7 @@ VideoView::showContextMenu(const QPoint& pos)
auto shareAction = new QAction(tr("Share entire screen"), this);
menu.addAction(shareAction);
connect(shareAction, &QAction::triggered, [=]() {
Video::SourceModel::instance()->setDisplay(0, QApplication::desktop()->rect());
Video::SourceModel::instance().setDisplay(0, QApplication::desktop()->rect());
});
auto shareAreaAction = new QAction(tr("Share screen area"), this);
menu.addAction(shareAreaAction);
......@@ -198,7 +198,7 @@ VideoView::showContextMenu(const QPoint& pos)
if (!dialog.exec())
return;
fileNames = dialog.selectedFiles();
Video::SourceModel::instance()->setFile(QUrl::fromLocalFile(fileNames.at(0)));
Video::SourceModel::instance().setFile(QUrl::fromLocalFile(fileNames.at(0)));
});
menu.exec(globalPos);
......
......@@ -23,10 +23,10 @@ VideoWidget::VideoWidget(QWidget *parent) :
, previewRenderer_(nullptr)
, renderer_(nullptr)
{
connect(Video::PreviewManager::instance(),
connect(&Video::PreviewManager::instance(),
SIGNAL(previewStarted(Video::Renderer*)),
this, SLOT(previewStarted(Video::Renderer*)));
connect(CallModel::instance(),
connect(&CallModel::instance(),
SIGNAL(rendererAdded(Call*,Video::Renderer*)),
this, SLOT(callInitiated(Call*, Video::Renderer*)),
Qt::ConnectionType::DirectConnection);
......
......@@ -273,7 +273,7 @@ WindowsContactBackend::getPersonFromContactFile(const QDir& contactDir,
QString number = reader.readElementText();
if (not number.isEmpty()) {
ContactMethod *contact =
PhoneDirectoryModel::instance()->getNumber(number,p);
PhoneDirectoryModel::instance().getNumber(number,p);
contactMethod.append(contact);
}
} else if (name == "ContactID") {
......@@ -319,7 +319,7 @@ WindowsContactBackend::getPersonFromContactFile(const QDir& contactDir,
contactFile.close();
return false;
} else {
Person* existing = PersonModel::instance()->getPersonByUid(p->uid());
Person* existing = PersonModel::instance().getPersonByUid(p->uid());
if (existing) {
if (contactMethod.size() > 0)
existing->setContactMethods ( contactMethod );
......
......@@ -57,9 +57,9 @@ WizardDialog::accept()
Utils::CreateStartupLink();
auto account = AccountModel::instance()->add(ui->usernameEdit->text(), Account::Protocol::RING);
auto account = AccountModel::instance().add(ui->usernameEdit->text(), Account::Protocol::RING);
account->setDisplayName(ui->usernameEdit->text());
AccountModel::instance()->ip2ip()->setRingtonePath(Utils::GetRingtonePath());
AccountModel::instance().ip2ip()->setRingtonePath(Utils::GetRingtonePath());
account->setRingtonePath(Utils::GetRingtonePath());
account->setUpnpEnabled(true);
......
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