Commit 77e9390e authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

contact request: add list of blocked contacts.

In preferences add new tab for banned contact. The list contain
contact's bestID and button to perform unban.

Change-Id: I376f63420ec0573e47574a79923c798b50148a31
Reviewed-by: default avatarAnthony Léonard <anthony.leonard@savoirfairelinux.com>
parent 3c960bf6
......@@ -166,6 +166,8 @@ SET(ringclient_CONTROLLERS
src/ContactRequestVC.mm
src/SendContactRequestWC.h
src/SendContactRequestWC.mm
src/AccBannedContactsVC.h
src/AccBannedContactsVC.mm
)
SET(ringclient_BACKENDS
......@@ -249,6 +251,7 @@ SET(ringclient_XIBS
ContactRequestList
ContactRequest
SendContactRequest
AccBannedContacts
)
# Icons
......
/*
* Copyright (C) 2015-2017 Savoir-faire Linux Inc.
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import <Cocoa/Cocoa.h>
@interface AccBannedContactsVC : NSViewController
@property (nonatomic) BOOL bannedListIsEmpty;
@end
/*
* Copyright (C) 2015-2017 Savoir-faire Linux Inc.
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
//Qt
#import <QItemSelectionModel>
//LRC
#import <account.h>
#import <availableAccountModel.h>
#import <contactmethod.h>
#import <bannedContactmodel.h>
#import "AccBannedContactsVC.h"
#import "QNSTreeController.h"
@interface AccBannedContactsVC ()
@property QNSTreeController* bannedContactsTreeController;
@property (unsafe_unretained) IBOutlet NSOutlineView* banedContactsView;
@end
@implementation AccBannedContactsVC
@synthesize bannedContactsTreeController;
@synthesize banedContactsView;
NSInteger const TAG_NAME = 100;
NSInteger const TAG_RINGID = 200;
- (void)awakeFromNib
{
QObject::connect(AccountModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex &current, const QModelIndex &previous) {
if(!current.isValid())
return;
[self loadAccount];
});
}
- (void)loadAccount
{
auto account = AccountModel::instance().selectedAccount();
self.bannedContactsTreeController = [[QNSTreeController alloc] initWithQModel:(QAbstractItemModel*)account->bannedContactModel()];
[self.bannedContactsTreeController setAvoidsEmptySelection:NO];
[self.bannedContactsTreeController setChildrenKeyPath:@"children"];
[self.banedContactsView bind:@"content" toObject:self.bannedContactsTreeController withKeyPath:@"arrangedObjects" options:nil];
[self.banedContactsView bind:@"sortDescriptors" toObject:self.bannedContactsTreeController withKeyPath:@"sortDescriptors" options:nil];
[self.banedContactsView bind:@"selectionIndexPaths" toObject:self.bannedContactsTreeController withKeyPath:@"selectionIndexPaths" options:nil];
NSLog(@"numberofRowsBanned, %d", account->bannedContactModel()->rowCount());
self.bannedListIsEmpty = banedContactsView.numberOfRows == 0;
}
- (IBAction)unbanContact:(NSView*)sender
{
NSInteger row = [self.banedContactsView rowForView:sender];
if(row < 0) {
return;
}
auto account = AccountModel::instance().selectedAccount();
id item = [self.banedContactsView itemAtRow:row];
QModelIndex qIdx = [self.bannedContactsTreeController toQIdx:((NSTreeNode*)item)];
if(!qIdx.isValid()) {
return;
}
auto cm = qIdx.data(static_cast<int>(ContactMethod::Role::Object)).value<ContactMethod*>();
if( account && cm) {
account->bannedContactModel()->remove(cm);
}
self.bannedListIsEmpty = banedContactsView.numberOfRows == 0;
}
#pragma mark - NSOutlineViewDelegate methods
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item
{
return YES;
}
- (NSTableRowView *)outlineView:(NSOutlineView *)outlineView rowViewForItem:(id)item
{
return [outlineView makeViewWithIdentifier:@"HoverRowView" owner:nil];
}
- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
NSTableView* result = [outlineView makeViewWithIdentifier:@"BannedContactsCellView" owner:self];
QModelIndex qIdx = [self.bannedContactsTreeController toQIdx:((NSTreeNode*)item)];
if(!qIdx.isValid())
return result;
NSTextField* nameLabel = [result viewWithTag:TAG_NAME];
NSTextField* deviceIDLabel = [result viewWithTag:TAG_RINGID];
auto account = AccountModel::instance().selectedAccount();
NSString* stringID = account->bannedContactModel()->data(qIdx,Qt::DisplayRole).toString().toNSString();
[nameLabel setStringValue:stringID];
[deviceIDLabel setStringValue:stringID];
return result;
}
@end
......@@ -40,6 +40,7 @@
#import "BackupAccountWC.h"
#import "RestoreAccountWC.h"
#import "RingWizardWC.h"
#import "AccBannedContactsVC.h"
@interface AccountsVC () <BackupAccountDelegate, RestoreAccountDelegate>
......@@ -52,6 +53,7 @@
@property (retain) IBOutlet NSTabViewItem *securityTabItem;
@property (retain) IBOutlet NSTabViewItem *ringTabItem;
@property (retain) IBOutlet NSTabViewItem *ringDevicesTabItem;
@property (retain) IBOutlet NSTabViewItem *bannedListTabItem;
@property QNSTreeController *treeController;
@property (assign) IBOutlet NSOutlineView *accountsListView;
......@@ -63,6 +65,7 @@
@property AccGeneralVC* generalVC;
@property AccMediaVC* audioVC;
@property AccAdvancedVC* advancedVC;
@property AccBannedContactsVC* bannedContactsVC;
@property AccSecurityVC* securityVC;
@property AbstractLoadingWC* accountModal;
@property RingWizardWC* wizard;
......@@ -83,6 +86,7 @@
@synthesize treeController;
@synthesize accountModal;
@synthesize wizard;
@synthesize bannedListTabItem;
NSInteger const TAG_CHECK = 100;
NSInteger const TAG_NAME = 200;
......@@ -166,6 +170,11 @@ NSInteger const TAG_TYPE = 400;
[[self.devicesVC view] setFrame:[self.ringDevicesTabItem.view frame]];
[[self.devicesVC view] setBounds:[self.ringDevicesTabItem.view bounds]];
[self.ringDevicesTabItem setView:self.devicesVC.view];
self.bannedContactsVC = [[AccBannedContactsVC alloc] initWithNibName:@"AccBannedContacts" bundle:nil];
[[self.bannedContactsVC view] setFrame:[self.bannedListTabItem.view frame]];
[[self.bannedContactsVC view] setBounds:[self.bannedListTabItem.view bounds]];
[self.bannedListTabItem setView:self.bannedContactsVC.view];
}
- (void) setupSIPPanels
......@@ -191,6 +200,7 @@ NSInteger const TAG_TYPE = 400;
[configPanels insertTabViewItem:ringDevicesTabItem atIndex:1];
[configPanels insertTabViewItem:mediaTabItem atIndex:2];
[configPanels insertTabViewItem:advancedTabItem atIndex:3];
[configPanels insertTabViewItem:bannedListTabItem atIndex:4];
}
- (IBAction)toggleAccount:(NSButton*)sender {
......
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11201" systemVersion="16B2553a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16D30a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11201"/>
<development version="7000" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="AccountsVC">
......@@ -9,6 +10,7 @@
<outlet property="accountDetailsView" destination="Jki-s4-F1W" id="8zf-XP-bql"/>
<outlet property="accountsListView" destination="jXv-6I-P9R" id="MzW-0C-PN1"/>
<outlet property="advancedTabItem" destination="RT7-u6-bhe" id="eAT-ce-MyD"/>
<outlet property="bannedListTabItem" destination="b7Z-2X-diH" id="Gvp-uP-Vgw"/>
<outlet property="configPanels" destination="Jki-s4-F1W" id="nY4-dc-CQg"/>
<outlet property="generalTabItem" destination="tPR-Ac-N5Y" id="39S-pz-1Xs"/>
<outlet property="mediaTabItem" destination="lxr-my-vH8" id="BhJ-cS-yVi"/>
......@@ -64,6 +66,12 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
</tabViewItem>
<tabViewItem label="Banned" identifier="" id="b7Z-2X-diH">
<view key="view" id="tHP-tb-Jl4">
<rect key="frame" x="10" y="33" width="576" height="442"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
</tabViewItem>
</tabViewItems>
<connections>
<outlet property="delegate" destination="-2" id="hfK-WK-DJT"/>
......
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