chat: update RecentModel selection
Clear RecentModel current index:
- during a call when the call is OVER
- in chat view when clicking on back button
This allow to reselect the previous row, and visually reset
the row (remove highlight state)
Change-Id: I36f531c6304ce48f0be3cc541f28a21d73a05262
Tuleap: #202
diff --git a/src/ConversationVC.h b/src/ConversationVC.h
index 9cecc25..cc170fe 100644
--- a/src/ConversationVC.h
+++ b/src/ConversationVC.h
@@ -23,7 +23,7 @@
-(void) initFrame;
-(void) animateIn;
--(IBAction) animateOut:(id)sender;
+-(void) animateOut;
/**
* Message contained in messageField TextField.
diff --git a/src/ConversationVC.mm b/src/ConversationVC.mm
index 24ae5d9..7d1f7f4 100644
--- a/src/ConversationVC.mm
+++ b/src/ConversationVC.mm
@@ -44,7 +44,6 @@
@interface ConversationVC () <NSOutlineViewDelegate> {
- __unsafe_unretained IBOutlet IconButton* backButton;
__unsafe_unretained IBOutlet NSTextField* messageField;
QVector<ContactMethod*> contactMethods;
NSMutableString* textSelection;
@@ -141,6 +140,11 @@
}
}
+- (IBAction)backPressed:(id)sender {
+ [conversationView setDelegate:nil];
+ RecentModel::instance().selectionModel()->clearCurrentIndex();
+}
+
# pragma mark private IN/OUT animations
-(void) animateIn
@@ -159,7 +163,7 @@
[CATransaction commit];
}
--(IBAction) animateOut:(id)sender
+-(void) animateOut
{
if(self.view.frame.origin.x < 0) {
return;
@@ -359,6 +363,7 @@
treeController = [[QNSTreeController alloc] initWithQModel:txtRecording->instantMessagingModel()];
[treeController setAvoidsEmptySelection:NO];
[treeController setChildrenKeyPath:@"children"];
+ [conversationView setDelegate:self];
[conversationView bind:@"content" toObject:treeController withKeyPath:@"arrangedObjects" options:nil];
[conversationView bind:@"sortDescriptors" toObject:treeController withKeyPath:@"sortDescriptors" options:nil];
[conversationView bind:@"selectionIndexPaths" toObject:treeController withKeyPath:@"selectionIndexPaths" options:nil];
diff --git a/src/CurrentCallVC.mm b/src/CurrentCallVC.mm
index 37b2706..ad6681e 100644
--- a/src/CurrentCallVC.mm
+++ b/src/CurrentCallVC.mm
@@ -266,7 +266,7 @@
[self animateOut];
else if (CallModel::instance().getIndex(c) == current) {
if (c->state() == Call::State::OVER) {
- [self animateOut];
+ RecentModel::instance().selectionModel()->clearCurrentIndex();
} else {
[self updateCall];
}
diff --git a/src/RingWindowController.mm b/src/RingWindowController.mm
index c589d57..b05157f 100644
--- a/src/RingWindowController.mm
+++ b/src/RingWindowController.mm
@@ -88,7 +88,7 @@
[=](const QModelIndex ¤t, const QModelIndex &previous) {
auto call = RecentModel::instance().getActiveCall(current);
if(!current.isValid()) {
- [offlineVC animateOut:self];
+ [offlineVC animateOut];
[currentCallVC animateOut];
return;
}
@@ -98,7 +98,7 @@
[offlineVC animateIn];
} else {
[currentCallVC animateIn];
- [offlineVC animateOut:self];
+ [offlineVC animateOut];
}
});
}
diff --git a/src/SmartViewVC.mm b/src/SmartViewVC.mm
index d026458..405148f 100644
--- a/src/SmartViewVC.mm
+++ b/src/SmartViewVC.mm
@@ -98,8 +98,10 @@
QObject::connect(RecentModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex ¤t, const QModelIndex &previous) {
- if(!current.isValid())
+ if(!current.isValid()) {
+ [smartView deselectAll:nil];
return;
+ }
auto proxyIdx = RecentModel::instance().peopleProxy()->mapFromSource(current);
if (proxyIdx.isValid()) {
diff --git a/ui/Base.lproj/Conversation.xib b/ui/Base.lproj/Conversation.xib
index f685088..f29b95d 100644
--- a/ui/Base.lproj/Conversation.xib
+++ b/ui/Base.lproj/Conversation.xib
@@ -6,7 +6,6 @@
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="ConversationVC">
<connections>
- <outlet property="backButton" destination="ooq-vs-Xt1" id="BKE-0Z-BFy"/>
<outlet property="contactMethodsPopupButton" destination="xdB-aI-PSs" id="BZW-FI-WpH"/>
<outlet property="conversationTitle" destination="ucx-6g-eJw" id="40T-pM-nix"/>
<outlet property="conversationView" destination="bOO-CW-S21" id="NkS-gm-3Qn"/>
@@ -160,7 +159,7 @@
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
- <action selector="animateOut:" target="-2" id="t7C-zL-3sv"/>
+ <action selector="backPressed:" target="-2" id="Vfg-Ve-O7w"/>
</connections>
</button>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xdB-aI-PSs" userLabel="CMs Popup menu">