Commit d3aa3ade authored by Alexandre Lision's avatar Alexandre Lision

lrc: adapt to API changes

Tuleap: #44
Change-Id: I0b005b7019d204e049a280819aac5f29558cafea
parent c8d9f0ba
......@@ -126,7 +126,7 @@
[publishedPortField setTag:PUBLICPORT_TAG];
[publishedAddrField setTag:PUBLICADDR_TAG];
QObject::connect(AccountModel::instance()->selectionModel(),
QObject::connect(AccountModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex &current, const QModelIndex &previous) {
if(!current.isValid())
......@@ -138,8 +138,8 @@
- (Account*) currentAccount
{
auto accIdx = AccountModel::instance()->selectionModel()->currentIndex();
return AccountModel::instance()->getAccountByModelIndex(accIdx);
auto accIdx = AccountModel::instance().selectionModel()->currentIndex();
return AccountModel::instance().getAccountByModelIndex(accIdx);
}
- (void)loadAccount
......
......@@ -53,7 +53,7 @@
- (void)awakeFromNib
{
NSLog(@"INIT Audio VC");
QObject::connect(AccountModel::instance()->selectionModel(),
QObject::connect(AccountModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex &current, const QModelIndex &previous) {
if(!current.isValid())
......@@ -64,8 +64,8 @@
- (Account*) currentAccount
{
auto accIdx = AccountModel::instance()->selectionModel()->currentIndex();
return AccountModel::instance()->getAccountByModelIndex(accIdx);
auto accIdx = AccountModel::instance().selectionModel()->currentIndex();
return AccountModel::instance().getAccountByModelIndex(accIdx);
}
- (void)loadAccount
......
......@@ -86,7 +86,7 @@
[passwordTextField setTag:PASSWORD_TAG];
[userAgentTextField setTag:USERAGENT_TAG];
QObject::connect(AccountModel::instance()->selectionModel(),
QObject::connect(AccountModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex &current, const QModelIndex &previous) {
if(!current.isValid())
......@@ -97,8 +97,8 @@
- (Account*) currentAccount
{
auto accIdx = AccountModel::instance()->selectionModel()->currentIndex();
return AccountModel::instance()->getAccountByModelIndex(accIdx);
auto accIdx = AccountModel::instance().selectionModel()->currentIndex();
return AccountModel::instance().getAccountByModelIndex(accIdx);
}
- (IBAction)toggleUpnp:(NSButton *)sender {
......
......@@ -73,7 +73,7 @@
[userAgentTextField setTag:USERAGENT_TAG];
[bootstrapField setTag:HOSTNAME_TAG];
QObject::connect(AccountModel::instance()->selectionModel(),
QObject::connect(AccountModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex &current, const QModelIndex &previous) {
if(!current.isValid())
......@@ -84,8 +84,8 @@
- (Account*) currentAccount
{
auto accIdx = AccountModel::instance()->selectionModel()->currentIndex();
return AccountModel::instance()->getAccountByModelIndex(accIdx);
auto accIdx = AccountModel::instance().selectionModel()->currentIndex();
return AccountModel::instance().getAccountByModelIndex(accIdx);
}
- (void)loadAccount
......
......@@ -79,7 +79,7 @@
[tlsNegotiationTimeoutStepper setTag:TLS_NEGOTIATION_TAG];
[tlsNegotiationTimeout setTag:TLS_NEGOTIATION_TAG];
QObject::connect(AccountModel::instance()->selectionModel(),
QObject::connect(AccountModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex &current, const QModelIndex &previous) {
if(!current.isValid())
......@@ -90,8 +90,8 @@
- (Account*) currentAccount
{
auto accIdx = AccountModel::instance()->selectionModel()->currentIndex();
return AccountModel::instance()->getAccountByModelIndex(accIdx);
auto accIdx = AccountModel::instance().selectionModel()->currentIndex();
return AccountModel::instance().getAccountByModelIndex(accIdx);
}
- (void)loadAccount
......
......@@ -59,7 +59,7 @@
- (void)awakeFromNib
{
NSLog(@"INIT Video VC");
QObject::connect(AccountModel::instance()->selectionModel(),
QObject::connect(AccountModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex &current, const QModelIndex &previous) {
if(!current.isValid())
......@@ -70,8 +70,8 @@
- (Account*) currentAccount
{
auto accIdx = AccountModel::instance()->selectionModel()->currentIndex();
return AccountModel::instance()->getAccountByModelIndex(accIdx);
auto accIdx = AccountModel::instance().selectionModel()->currentIndex();
return AccountModel::instance().getAccountByModelIndex(accIdx);
}
- (void)loadAccount
......
......@@ -104,7 +104,7 @@ public:
- (void)awakeFromNib
{
treeController = [[QNSTreeController alloc] initWithQModel:AccountModel::instance()];
treeController = [[QNSTreeController alloc] initWithQModel:&AccountModel::instance()];
[treeController setAvoidsEmptySelection:NO];
[treeController setAlwaysUsesMultipleValuesMarker:YES];
[treeController setChildrenKeyPath:@"children"];
......@@ -113,7 +113,7 @@ public:
[accountsListView bind:@"sortDescriptors" toObject:treeController withKeyPath:@"sortDescriptors" options:nil];
[accountsListView bind:@"selectionIndexPaths" toObject:treeController withKeyPath:@"selectionIndexPaths" options:nil];
QObject::connect(AccountModel::instance(),
QObject::connect(&AccountModel::instance(),
&QAbstractItemModel::dataChanged,
[=](const QModelIndex &topLeft, const QModelIndex &bottomRight) {
[accountsListView reloadDataForRowIndexes:
......@@ -121,12 +121,12 @@ public:
columnIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, accountsListView.tableColumns.count)]];
});
AccountModel::instance()->selectionModel()->clearCurrentIndex();
AccountModel::instance().selectionModel()->clearCurrentIndex();
proxyProtocolModel = new ActiveProtocolModel(AccountModel::instance()->protocolModel());
QModelIndex qProtocolIdx = AccountModel::instance()->protocolModel()->selectionModel()->currentIndex();
proxyProtocolModel = new ActiveProtocolModel(AccountModel::instance().protocolModel());
QModelIndex qProtocolIdx = AccountModel::instance().protocolModel()->selectionModel()->currentIndex();
[self.protocolList addItemWithTitle:
AccountModel::instance()->protocolModel()->data(qProtocolIdx, Qt::DisplayRole).toString().toNSString()];
AccountModel::instance().protocolModel()->data(qProtocolIdx, Qt::DisplayRole).toString().toNSString()];
self.generalVC = [[AccGeneralVC alloc] initWithNibName:@"AccGeneral" bundle:nil];
[[self.generalVC view] setFrame:[self.generalTabItem.view frame]];
......@@ -165,36 +165,36 @@ public:
}
- (IBAction)moveUp:(id)sender {
AccountModel::instance()->moveUp();
AccountModel::instance().moveUp();
}
- (IBAction)moveDown:(id)sender {
AccountModel::instance()->moveDown();
AccountModel::instance().moveDown();
}
- (IBAction)removeAccount:(id)sender {
if(treeController.selectedNodes.count > 0) {
QModelIndex qIdx = [treeController toQIdx:[treeController selectedNodes][0]];
AccountModel::instance()->remove(qIdx);
AccountModel::instance()->save();
AccountModel::instance().remove(qIdx);
AccountModel::instance().save();
}
}
- (IBAction)addAccount:(id)sender {
QModelIndex qIdx = AccountModel::instance()->protocolModel()->selectionModel()->currentIndex();
QModelIndex qIdx = AccountModel::instance().protocolModel()->selectionModel()->currentIndex();
auto newAccName = [[NSString alloc] initWithFormat:@"%@ account",
AccountModel::instance()->protocolModel()->data(qIdx, Qt::DisplayRole).toString().toNSString(), nil];
auto acc = AccountModel::instance()->add([newAccName UTF8String], qIdx);
AccountModel::instance().protocolModel()->data(qIdx, Qt::DisplayRole).toString().toNSString(), nil];
auto acc = AccountModel::instance().add([newAccName UTF8String], qIdx);
acc->setDisplayName(acc->alias());
AccountModel::instance()->save();
AccountModel::instance().save();
}
- (IBAction)protocolSelectedChanged:(id)sender {
int index = [sender indexOfSelectedItem];
QModelIndex proxyIdx = proxyProtocolModel->index(index, 0);
AccountModel::instance()->protocolModel()->selectionModel()->setCurrentIndex(
AccountModel::instance().protocolModel()->selectionModel()->setCurrentIndex(
proxyProtocolModel->mapToSource(proxyIdx), QItemSelectionModel::ClearAndSelect);
}
......@@ -247,8 +247,8 @@ public:
NSTableColumn* col = [sender.tableColumns objectAtIndex:[sender clickedColumn]];
if([col.identifier isEqualToString:COLUMNID_ENABLE]) {
NSInteger row = [sender clickedRow];
QModelIndex accIdx = AccountModel::instance()->index(row);
Account* toToggle = AccountModel::instance()->getAccountByModelIndex(accIdx);
QModelIndex accIdx = AccountModel::instance().index(row);
Account* toToggle = AccountModel::instance().getAccountByModelIndex(accIdx);
NSButtonCell *cell = [col dataCellForRow:row];
toToggle->setEnabled(cell.state == NSOnState ? NO : YES);
toToggle << Account::EditAction::SAVE;
......@@ -275,7 +275,7 @@ public:
QModelIndex qIdx = [treeController toQIdx:((NSTreeNode*)item)];
// Prevent user from enabling/disabling IP2IP account
if ([[tableColumn identifier] isEqualToString:COLUMNID_ENABLE] &&
AccountModel::instance()->ip2ip()->index() == qIdx) {
AccountModel::instance().ip2ip()->index() == qIdx) {
return [[NSCell alloc] init];
} else {
......@@ -323,7 +323,7 @@ public:
cell.title = qIdx.data(Qt::DisplayRole).toString().toNSString();
} else if([[tableColumn identifier] isEqualToString:COLUMNID_STATE]) {
NSTextFieldCell* stateCell = cell;
auto account = AccountModel::instance()->getAccountByModelIndex(qIdx);
auto account = AccountModel::instance().getAccountByModelIndex(qIdx);
auto humanState = account->toHumanStateName();
[stateCell setTitle:humanState.toNSString()];
......@@ -358,8 +358,8 @@ public:
if([[treeController selectedNodes] count] > 0) {
auto qIdx = [treeController toQIdx:[treeController selectedNodes][0]];
//Update details view
auto acc = AccountModel::instance()->getAccountByModelIndex(qIdx);
AccountModel::instance()->selectionModel()->setCurrentIndex(qIdx, QItemSelectionModel::ClearAndSelect);
auto acc = AccountModel::instance().getAccountByModelIndex(qIdx);
AccountModel::instance().selectionModel()->setCurrentIndex(qIdx, QItemSelectionModel::ClearAndSelect);
switch (acc->protocol()) {
case Account::Protocol::SIP:
......@@ -381,7 +381,7 @@ public:
[self.accountDetailsView setHidden:NO];
} else {
[self.accountDetailsView setHidden:YES];
AccountModel::instance()->selectionModel()->clearCurrentIndex();
AccountModel::instance().selectionModel()->clearCurrentIndex();
}
}
......@@ -390,7 +390,7 @@ public:
- (BOOL)menu:(NSMenu *)menu updateItem:(NSMenuItem *)item atIndex:(NSInteger)index shouldCancel:(BOOL)shouldCancel
{
QModelIndex proxyIdx = proxyProtocolModel->index(index, 0);
QModelIndex qIdx = AccountModel::instance()->protocolModel()->index(proxyProtocolModel->mapToSource(proxyIdx).row());
QModelIndex qIdx = AccountModel::instance().protocolModel()->index(proxyProtocolModel->mapToSource(proxyIdx).row());
[item setTitle:qIdx.data(Qt::DisplayRole).toString().toNSString()];
return YES;
......
......@@ -63,7 +63,7 @@
- (void) connect
{
QObject::connect(CallModel::instance(),
QObject::connect(&CallModel::instance(),
&CallModel::incomingCall,
[=](Call* call) {
BOOL shouldComeToForeground = [[NSUserDefaults standardUserDefaults] boolForKey:Preferences::WindowBehaviour];
......@@ -120,9 +120,9 @@
- (BOOL) checkForRingAccount
{
BOOL foundRingAcc = NO;
for (int i = 0 ; i < AccountModel::instance()->rowCount() ; ++i) {
QModelIndex idx = AccountModel::instance()->index(i);
Account* acc = AccountModel::instance()->getAccountByModelIndex(idx);
for (int i = 0 ; i < AccountModel::instance().rowCount() ; ++i) {
QModelIndex idx = AccountModel::instance().index(i);
Account* acc = AccountModel::instance().getAccountByModelIndex(idx);
if(acc->protocol() == Account::Protocol::RING) {
if (acc->displayName().isEmpty())
acc->setDisplayName(acc->alias());
......@@ -160,7 +160,7 @@
BOOL valid = [[ringID stringByTrimmingCharactersInSet:hexSet] isEqualToString:@""];
if(valid && ringID.length == 40) {
Call* c = CallModel::instance()->dialingCall();
Call* c = CallModel::instance().dialingCall();
c->setDialNumber(QString::fromNSString([NSString stringWithFormat:@"ring:%@",ringID]));
c << Call::Action::ACCEPT;
} else {
......@@ -185,13 +185,13 @@
- (void)handleQuitEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAppleEventDescriptor*)replyEvent
{
delete CallModel::instance()->QObject::parent();
delete CallModel::instance().QObject::parent();
[[NSApplication sharedApplication] terminate:self];
}
-(void)applicationWillTerminate:(NSNotification *)notification
{
delete CallModel::instance()->QObject::parent();
delete CallModel::instance().QObject::parent();
[[NSApplication sharedApplication] terminate:self];
}
......
......@@ -57,55 +57,55 @@
{
[super loadView];
QModelIndex qInputIdx = Audio::Settings::instance()->inputDeviceModel()->selectionModel()->currentIndex();
QModelIndex qOutputIdx = Audio::Settings::instance()->outputDeviceModel()->selectionModel()->currentIndex();
QModelIndex qInputIdx = Audio::Settings::instance().inputDeviceModel()->selectionModel()->currentIndex();
QModelIndex qOutputIdx = Audio::Settings::instance().outputDeviceModel()->selectionModel()->currentIndex();
[self.outputDeviceList addItemWithTitle:
Audio::Settings::instance()->outputDeviceModel()->data(qOutputIdx, Qt::DisplayRole).toString().toNSString()];
Audio::Settings::instance().outputDeviceModel()->data(qOutputIdx, Qt::DisplayRole).toString().toNSString()];
[self.inputDeviceList addItemWithTitle:
Audio::Settings::instance()->inputDeviceModel()->data(qInputIdx, Qt::DisplayRole).toString().toNSString()];
Audio::Settings::instance().inputDeviceModel()->data(qInputIdx, Qt::DisplayRole).toString().toNSString()];
[self.alwaysRecordingButton setState:
Media::RecordingModel::instance()->isAlwaysRecording() ? NSOnState:NSOffState];
Media::RecordingModel::instance().isAlwaysRecording() ? NSOnState:NSOffState];
[self.muteDTMFButton setState:
Audio::Settings::instance()->areDTMFMuted()?NSOnState:NSOffState];
Audio::Settings::instance().areDTMFMuted()?NSOnState:NSOffState];
if([[Media::RecordingModel::instance()->recordPath().toNSURL() absoluteString] isEqualToString:@""]) {
if([[Media::RecordingModel::instance().recordPath().toNSURL() absoluteString] isEqualToString:@""]) {
NSArray * pathComponentArray = [self pathComponentArray];
[recordingsPathControl setPathComponentCells:pathComponentArray];
} else {
[recordingsPathControl setURL:Media::RecordingModel::instance()->recordPath().toNSURL()];
[recordingsPathControl setURL:Media::RecordingModel::instance().recordPath().toNSURL()];
}
}
- (IBAction)toggleMuteDTMF:(NSButton *)sender
{
Audio::Settings::instance()->setDTMFMuted([sender state] == NSOnState);
Audio::Settings::instance().setDTMFMuted([sender state] == NSOnState);
}
- (IBAction)toggleAlwaysRecording:(NSButton *)sender
{
Media::RecordingModel::instance()->setAlwaysRecording([sender state] == NSOnState);
Media::RecordingModel::instance().setAlwaysRecording([sender state] == NSOnState);
}
- (IBAction)pathControlSingleClick:(id)sender {
// Select that chosen component of the path.
[self.recordingsPathControl setURL:[[self.recordingsPathControl clickedPathComponentCell] URL]];
Media::RecordingModel::instance()->setRecordPath(QUrl::fromNSURL(self.recordingsPathControl.URL));
Media::RecordingModel::instance().setRecordPath(QUrl::fromNSURL(self.recordingsPathControl.URL));
}
- (IBAction)chooseOutput:(id)sender {
int index = [sender indexOfSelectedItem];
QModelIndex qIdx = Audio::Settings::instance()->outputDeviceModel()->index(index, 0);
Audio::Settings::instance()->outputDeviceModel()->selectionModel()->setCurrentIndex(
QModelIndex qIdx = Audio::Settings::instance().outputDeviceModel()->index(index, 0);
Audio::Settings::instance().outputDeviceModel()->selectionModel()->setCurrentIndex(
qIdx, QItemSelectionModel::ClearAndSelect);
}
- (IBAction)chooseInput:(id)sender {
int index = [sender indexOfSelectedItem];
QModelIndex qIdx = Audio::Settings::instance()->inputDeviceModel()->index(index, 0);
Audio::Settings::instance()->inputDeviceModel()->selectionModel()->setCurrentIndex(
QModelIndex qIdx = Audio::Settings::instance().inputDeviceModel()->index(index, 0);
Audio::Settings::instance().inputDeviceModel()->selectionModel()->setCurrentIndex(
qIdx, QItemSelectionModel::ClearAndSelect);
}
......@@ -191,12 +191,12 @@
if([menu.title isEqualToString:@"inputlist"])
{
qIdx = Audio::Settings::instance()->inputDeviceModel()->index(index);
[item setTitle:Audio::Settings::instance()->inputDeviceModel()->data(qIdx, Qt::DisplayRole).toString().toNSString()];
qIdx = Audio::Settings::instance().inputDeviceModel()->index(index);
[item setTitle:Audio::Settings::instance().inputDeviceModel()->data(qIdx, Qt::DisplayRole).toString().toNSString()];
} else
{
qIdx = Audio::Settings::instance()->outputDeviceModel()->index(index);
[item setTitle:Audio::Settings::instance()->outputDeviceModel()->data(qIdx, Qt::DisplayRole).toString().toNSString()];
qIdx = Audio::Settings::instance().outputDeviceModel()->index(index);
[item setTitle:Audio::Settings::instance().outputDeviceModel()->data(qIdx, Qt::DisplayRole).toString().toNSString()];
}
return YES;
......@@ -205,9 +205,9 @@
- (NSInteger)numberOfItemsInMenu:(NSMenu *)menu
{
if([menu.title isEqualToString:@"inputlist"])
return Audio::Settings::instance()->inputDeviceModel()->rowCount();
return Audio::Settings::instance().inputDeviceModel()->rowCount();
else
return Audio::Settings::instance()->outputDeviceModel()->rowCount();
return Audio::Settings::instance().outputDeviceModel()->rowCount();
}
@end
......@@ -47,7 +47,7 @@
- (void)viewWillAppear
{
// Get the first video codec of the selected call and use this value as default
auto selectedCall = CallModel::instance()->selectedCall();
auto selectedCall = CallModel::instance().selectedCall();
if (selectedCall) {
int bitrate = selectedCall->account()->codecModel()->videoCodecs()->index(0,0).data(static_cast<int>(CodecModel::Role::BITRATE)).toInt();
[self.bitrateSlider setNumberOfTickMarks:4];
......@@ -58,7 +58,7 @@
- (IBAction)valueChanged:(id)sender
{
if (const auto& codecModel = CallModel::instance()->selectedCall()->account()->codecModel()) {
if (const auto& codecModel = CallModel::instance().selectedCall()->account()->codecModel()) {
const auto& videoCodecs = codecModel->videoCodecs();
for (int i=0; i < videoCodecs->rowCount();i++) {
const auto& idx = videoCodecs->index(i,0);
......
......@@ -72,7 +72,7 @@
mediaHolder = [[MediaConnectionsHolder alloc] init];
QObject::connect(CallModel::instance()->selectionModel(),
QObject::connect(CallModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex &current, const QModelIndex &previous) {
[self setupChat];
......@@ -90,12 +90,12 @@
QObject::disconnect(mediaHolder.newMediaAdded);
QObject::disconnect(mediaHolder.newMessage);
QModelIndex callIdx = CallModel::instance()->selectionModel()->currentIndex();
QModelIndex callIdx = CallModel::instance().selectionModel()->currentIndex();
if (!callIdx.isValid())
return;
Call* call = CallModel::instance()->getCall(callIdx);
Call* call = CallModel::instance().getCall(callIdx);
/* check if text media is already present */
if (call->hasMedia(Media::Media::Type::TEXT, Media::Media::Direction::IN)) {
......@@ -173,8 +173,8 @@
- (IBAction)sendMessage:(id)sender {
QModelIndex callIdx = CallModel::instance()->selectionModel()->currentIndex();
Call* call = CallModel::instance()->getCall(callIdx);
QModelIndex callIdx = CallModel::instance().selectionModel()->currentIndex();
Call* call = CallModel::instance().getCall(callIdx);
/* make sure there is text to send */
NSString* text = self.message;
......
This diff is collapsed.
......@@ -84,7 +84,7 @@
}
- (IBAction)clearHistory:(id)sender {
CategorizedHistoryModel::instance()->clearAllCollections();
CategorizedHistoryModel::instance().clearAllCollections();
[historyChangedLabel setHidden:NO];
}
......
......@@ -52,8 +52,8 @@ NSInteger const DETAILS_TAG = 300;
- (void)awakeFromNib
{
NSLog(@"INIT HVC");
historyProxyModel = new QSortFilterProxyModel(CategorizedHistoryModel::instance());
historyProxyModel->setSourceModel(CategorizedHistoryModel::instance());
historyProxyModel = new QSortFilterProxyModel(&CategorizedHistoryModel::instance());
historyProxyModel->setSourceModel(&CategorizedHistoryModel::instance());
historyProxyModel->setSortRole(static_cast<int>(Call::Role::Date));
historyProxyModel->sort(0,Qt::DescendingOrder);
treeController = [[QNSTreeController alloc] initWithQModel:historyProxyModel];
......@@ -69,7 +69,7 @@ NSInteger const DETAILS_TAG = 300;
[historyView setContextMenuDelegate:self];
[historyView setShortcutsDelegate:self];
QObject::connect(CallModel::instance(),
QObject::connect(&CallModel::instance(),
&CategorizedHistoryModel::dataChanged,
[=](const QModelIndex &topLeft, const QModelIndex &bottomRight) {
[historyView reloadDataForRowIndexes:
......@@ -98,7 +98,7 @@ NSInteger const DETAILS_TAG = 300;
QVariant var = historyProxyModel->data(qIdx, (int)Call::Role::ContactMethod);
ContactMethod* m = qvariant_cast<ContactMethod*>(var);
if(m){
Call* c = CallModel::instance()->dialingCall();
Call* c = CallModel::instance().dialingCall();
c->setPeerContactMethod(m);
c << Call::Action::ACCEPT;
}
......
......@@ -83,7 +83,7 @@ NSInteger const DETAILS_TAG = 300;
[categoryComboBox selectItemAtIndex:0];
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);
......@@ -104,9 +104,9 @@ NSInteger const DETAILS_TAG = 300;
- (IBAction)addToContact:(id)sender
{
/* get the selected number category */
const auto& idx = NumberCategoryModel::instance()->index([categoryComboBox indexOfSelectedItem]);
const auto& idx = NumberCategoryModel::instance().index([categoryComboBox indexOfSelectedItem]);
if (idx.isValid()) {
auto category = NumberCategoryModel::instance()->getCategory(idx.data().toString());
auto category = NumberCategoryModel::instance().getCategory(idx.data().toString());
self.methodToLink->setCategory(category);
}
......@@ -151,9 +151,9 @@ NSInteger const DETAILS_TAG = 300;
- (IBAction)createContact:(id)sender
{
/* get the selected number category */
const auto& idx = NumberCategoryModel::instance()->index([categoryComboBox indexOfSelectedItem]);
const auto& idx = NumberCategoryModel::instance().index([categoryComboBox indexOfSelectedItem]);
if (idx.isValid()) {
auto category = NumberCategoryModel::instance()->getCategory(idx.data().toString());
auto category = NumberCategoryModel::instance().getCategory(idx.data().toString());
self.methodToLink->setCategory(category);
}
......@@ -167,7 +167,7 @@ NSInteger const DETAILS_TAG = 300;
numbers << self.methodToLink;
p->setContactMethods(numbers);
self.methodToLink->setPerson(p);
PersonModel::instance()->addNewPerson(p);
PersonModel::instance().addNewPerson(p);
[self.contactLinkedDelegate contactLinked];
}
......@@ -257,12 +257,12 @@ NSInteger const DETAILS_TAG = 300;
- (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox
{
return NumberCategoryModel::instance()->rowCount();
return NumberCategoryModel::instance().rowCount();
}
- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)index
{
return NumberCategoryModel::instance()->index(index).data().toString().toNSString();
return NumberCategoryModel::instance().index(index).data().toString().toNSString();
}
@end
......@@ -74,7 +74,7 @@ NSInteger const CALL_BUTTON_TAG = 400;
-(void) awakeFromNib
{
NSLog(@"INIT PersonsVC");
contactProxyModel = new ReachablePersonModel(CategorizedContactModel::instance());
contactProxyModel = new ReachablePersonModel(&CategorizedContactModel::instance());
contactProxyModel->setSortRole(static_cast<int>(Qt::DisplayRole));
contactProxyModel->sort(0,Qt::AscendingOrder);
treeController = [[QNSTreeController alloc] initWithQModel:contactProxyModel];
......@@ -88,7 +88,7 @@ NSInteger const CALL_BUTTON_TAG = 400;
[personsView setTarget:self];
[personsView setDoubleAction:@selector(callContact:)];
CategorizedContactModel::instance()->setUnreachableHidden(YES);
CategorizedContactModel::instance().setUnreachableHidden(YES);
}
- (void) dealloc
......@@ -119,7 +119,7 @@ NSInteger const CALL_BUTTON_TAG = 400;
}
if(m){
Call* c = CallModel::instance()->dialingCall();
Call* c = CallModel::instance().dialingCall();
c->setPeerContactMethod(m);
c << Call::Action::ACCEPT;
}
......
......@@ -51,7 +51,7 @@ static NSString* const kVideoPrefsIdentifer = @"VideoPrefsIdentifer";
- (void)windowWillClose:(NSNotification *)notification
{
AccountModel::instance()->save();
AccountModel::instance().save();
}
- (IBAction)displayGeneral:(NSToolbarItem *)sender
......
......@@ -58,7 +58,7 @@ static NSString* const kPreferencesIdentifier = @"PreferencesIdentifier";
[self updateRingID];
// Update Ring ID label based on account model changes
QObject::connect(AccountModel::instance(),
QObject::connect(&AccountModel::instance(),
&AccountModel::dataChanged,
[=] {
[self updateRingID];
......@@ -76,7 +76,7 @@ static NSString* const kPreferencesIdentifier = @"PreferencesIdentifier";
Account* finalChoice = nullptr;
[ringIDLabel setStringValue:@""];
auto ringList = AccountModel::instance()->getAccountsByProtocol(Account::Protocol::RING);
auto ringList = AccountModel::instance().getAccountsByProtocol(Account::Protocol::RING);
for (int i = 0 ; i < ringList.size() && !registered ; ++i) {
Account* acc = ringList.value(i);
if (acc->isEnabled()) {
......
......@@ -62,11 +62,11 @@ NSInteger const NICKNAME_TAG = 1;
[self.window setLevel:NSStatusWindowLevel];
[self.window makeMainWindow];
if(![self checkForRingAccount]) {
accountToCreate = AccountModel::instance()->add("", Account::Protocol::RING);
accountToCreate = AccountModel::instance().add("", Account::Protocol::RING);
} else {
[indicationLabel setStringValue:NSLocalizedString(@"Ring is already ready to work",
@"Display message to user")];
auto accList = AccountModel::instance()->getAccountsByProtocol(Account::Protocol::RING);
auto accList = AccountModel::instance().getAccountsByProtocol(Account::Protocol::RING);
[self displayHash:accList[0]->username().toNSString()];
}
......@@ -77,9 +77,9 @@ NSInteger const NICKNAME_TAG = 1;
- (BOOL) checkForRingAccount
{
for (int i = 0 ; i < AccountModel::instance()->rowCount() ; ++i) {
QModelIndex idx = AccountModel::instance()->index(i);
Account* acc = AccountModel::instance()->getAccountByModelIndex(idx);
for (int i = 0 ; i < AccountModel::instance().rowCount() ; ++i) {
QModelIndex idx = AccountModel::instance().index(i);
Account* acc = AccountModel::instance().getAccountByModelIndex(idx);
if(acc->protocol() == Account::Protocol::RING) {
return YES;
}
......@@ -116,7 +116,7 @@ NSInteger const NICKNAME_TAG = 1;
[indicationLabel setStringValue:NSLocalizedString(@"Just a moment...",
@"Indication for user")];
QModelIndex qIdx = AccountModel::instance()->protocolModel()->selectionModel()->currentIndex();
QModelIndex qIdx = AccountModel::instance().protocolModel()->selectionModel()->currentIndex();
[self setCallback];
if (isExpanded) {
......@@ -149,7 +149,7 @@ NSInteger const NICKNAME_TAG = 1;
- (void) setCallback
{
QObject::connect(AccountModel::instance(),
QObject::connect(&AccountModel::instance(),
&AccountModel::accountStateChanged,
[=](Account *account, const Account::RegistrationState state) {
NSLog(@"Account created!");
......
......@@ -67,7 +67,7 @@ NSInteger const TXT_BUTTON_TAG = 500;
NSLog(@"INIT SmartView VC");
isShowingContacts = false;
treeController = [[QNSTreeController alloc] initWithQModel:RecentModel::instance()->peopleProxy()];
treeController = [[QNSTreeController alloc] initWithQModel:RecentModel::instance().peopleProxy()];
[treeController setAvoidsEmptySelection:NO];
[treeController setChildrenKeyPath:@"children"];
......@@ -78,7 +78,7 @@ NSInteger const TXT_BUTTON_TAG = 500;
[smartView setTarget:self];
[smartView setDoubleAction:@selector(placeCall:)];
QObject::connect(RecentModel::instance()->peopleProxy(),
QObject::connect(RecentModel::instance().peopleProxy(),
&QAbstractItemModel::dataChanged,
[self](const QModelIndex &topLeft, const QModelIndex &bottomRight) {
for(int row = topLeft.row() ; row <= bottomRight.row() ; ++row)
......@@ -124,8 +124,8 @@ NSInteger const TXT_BUTTON_TAG = 500;
// Before calling check if we properly extracted a contact method and that
// there is NOT already an ongoing call for this index (e.g: no children for this node)
if(m && !RecentModel::instance()->peopleProxy()->index(0, 0, qIdx).isValid()){
Call* c = CallModel::instance()->dialingCall();
if(m && !RecentModel::instance().peopleProxy()->index(0, 0, qIdx).isValid()){
Call* c = CallModel::instance().dialingCall();
c->setPeerContactMethod(m);
c << Call::Action::ACCEPT;
......@@ -185,19 +185,19 @@ NSInteger const TXT_BUTTON_TAG = 500;
- (void)outlineViewSelectionDidChange:(NSNotification *)notification
{
if ([treeController selectedNodes].count <= 0) {
CallModel::instance()->selectionModel()->clearCurrentIndex();
CallModel::instance().selectionModel()->clearCurrentIndex();
return;
}
QModelIndex qIdx = [treeController toQIdx:[treeController selectedNodes][0]];
// ask the tree controller for the current selection
if (auto selected = RecentModel::instance()->getActiveCall(RecentModel::instance()->peopleProxy()->mapToSource(qIdx))) {
CallModel::instance()->selectCall(selected);
} else if (auto selected = RecentModel::instance()->getActiveCall(RecentModel::instance()->peopleProxy()->mapToSource(qIdx.parent()))){
CallModel::instance()->selectCall(selected);
if (auto selected = RecentModel::instance().getActiveCall(RecentModel::instance().peopleProxy()->mapToSource(qIdx))) {
CallModel::instance().selectCall(selected);
} else if (auto selected = RecentModel::instance().getActiveCall(RecentModel::instance().peopleProxy()->mapToSource(qIdx.parent()))){
CallModel::instance().selectCall(selected);
} else {
CallModel::instance()->selectionModel()->clearCurrentIndex();
CallModel::instance().selectionModel()->clearCurrentIndex();
}
}
......@@ -213,7 +213,7 @@ NSInteger const TXT_BUTTON_TAG = 500;
[((ContextualTableCellView*) result) setContextualsControls:[NSMutableArray arrayWithObject:[result viewWithTag:CALL_BUTTON_TAG]]];
if (auto call = RecentModel::instance()->getActiveCall(RecentModel::instance()->peopleProxy()->mapToSource(qIdx))) {
if (auto call = RecentModel::instance().getActiveCall(RecentModel::instance().peopleProxy()->mapToSource(qIdx))) {
[details setStringValue:call->roleData((int)Ring::Role::FormattedState).toString().toNSString()];
[((ContextualTableCellView*) result) setActiveState:YES];
} else {
......@@ -246,7 +246,7 @@ NSInteger const TXT_BUTTON_TAG = 500;
- (IBAction)hangUpClickedAtRow:(id)sender {
NSInteger row = [smartView rowForView:sender];
[smartView selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
CallModel::instance()->getCall(CallModel::instance()->selectionModel()->currentIndex()) << Call::Action::REFUSE;
CallModel::instance().getCall(CallModel::instance().selectionModel()->currentIndex()) << Call::Action::REFUSE;
}
/* View Based OutlineView: See the delegate method -tableView:rowViewForRow: in NSTableView.
......@@ -279,7 +279,7 @@ NSInteger const TXT_BUTTON_TAG = 500;
- (void) placeCallFromSearchField
{
Call* c = CallModel::instance()->dialingCall();
Call* c = CallModel::instance().dialingCall();
// check for a valid ring hash
NSCharacterSet *hexSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789abcdefABCDEF"];
BOOL valid = [[[searchField stringValue] stringByTrimmingCharactersInSet:hexSet] isEqualToString:@""];
......@@ -293,7 +293,7 @@ NSInteger const TXT_BUTTON_TAG = 500;
c << Call::Action::ACCEPT;
[searchField setStringValue:@""];
RecentModel::instance()->peopleProxy()->
RecentModel::instance().peopleProxy()->
setFilterRegExp(QRegExp(QString::fromNSString([searchField stringValue]), Qt::CaseInsensitive, QRegExp::FixedString));
}
......@@ -313,7 +313,7 @@ NSInteger const TXT_BUTTON_TAG = 500;
- (void)controlTextDidChange:(NSNotification *) notification
{
RecentModel::instance()->peopleProxy()->
RecentModel::instance().peopleProxy()->
setFilterRegExp(QRegExp(QString::fromNSString([searchField stringValue]), Qt::CaseInsensitive, QRegExp::FixedString));
}
......
This diff is collapsed.
......@@ -125,7 +125,7 @@ void AddressBookBackend::handleNotification(NSNotification* ns)
for (NSString* r in ns.userInfo[kABUpdatedRecords]) {
NSLog(@"Updated record : %@", r);
if ([[[ABAddressBook sharedAddressBook] recordClassFromUniqueId:r] containsString:@"ABPerson"]) {
Person* toUpdate = PersonModel::instance()->getPersonByUid([r UTF8String]);
Person* toUpdate = PersonModel::instance().getPersonByUid([r UTF8String]);
if (toUpdate) {
ABPerson* updated = [[ABAddressBook sharedAddressBook] recordForUniqueId:r];
toUpdate->updateFromVCard(QByteArray::fromNSData(updated.vCardRepresentation));
......@@ -289,7 +289,7 @@ bool AddressBookBackend::addNewPerson(Person *item)
bool AddressBookBackend::removePerson(NSString* uid)
{
auto found = PersonModel::instance()->getPersonByUid([uid UTF8String]);
auto found = PersonModel::instance().getPersonByUid([uid UTF8String]);
if (found) {
deactivate(found);
editor<Person>()->remove(found);
......
......@@ -61,16 +61,16 @@ int main(int argc, const char *argv[]) {
}
}
CategorizedHistoryModel::instance()->addCollection<LocalHistoryCollection>(LoadOptions::FORCE_ENABLED);
CategorizedHistoryModel::instance().addCollection<LocalHistoryCollection>(LoadOptions::FORCE_ENABLED);
/* make sure basic number categories exist, in case user has no contacts
* from which these would be automatically created
*/
NumberCategoryModel::instance()->addCategory("work", QVariant());
NumberCategoryModel::instance()->addCategory("home", QVariant());
NumberCategoryModel::instance().addCategory("work", QVariant());
NumberCategoryModel::instance().addCategory("home", QVariant());
GlobalInstances::setPixmapManipulator(std::unique_ptr<Interfaces::ImageManipulationDelegate>(new Interfaces::ImageManipulationDelegate()));
PersonModel::instance()->addCollection<AddressBookBackend>(LoadOptions::FORCE_ENABLED);
PersonModel::instance().addCollection<AddressBookBackend>(LoadOptions::FORCE_ENABLED);
return NSApplicationMain(argc, argv);