presence: display status in SmartList

Add green circle in the SmartList if contact is online.

Change-Id: I911d48239d9c95644111183edc620c6342c5ec63
Reviewed-by: Anthony Léonard <anthony.leonard@savoirfairelinux.com>
diff --git a/src/SmartViewVC.mm b/src/SmartViewVC.mm
index 8a5f9dd..2d42005 100644
--- a/src/SmartViewVC.mm
+++ b/src/SmartViewVC.mm
@@ -74,6 +74,7 @@
 NSInteger const TXT_BUTTON_TAG      = 500;
 NSInteger const CANCEL_BUTTON_TAG   = 600;
 NSInteger const RING_ID_LABEL       = 700;
+NSInteger const PRESENCE_TAG        = 800;
 
 - (void)awakeFromNib
 {
@@ -276,6 +277,13 @@
     NSImageView* photoView = [result viewWithTag:IMAGE_TAG];
 
     [photoView setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(qIdx.data(Qt::DecorationRole)))];
+
+    NSView* presenceView = [result viewWithTag:PRESENCE_TAG];
+    if (qIdx.data(static_cast<int>(Ring::Role::IsPresent)).value<bool>()) {
+        [presenceView setHidden:NO];
+    } else {
+        [presenceView setHidden:YES];
+    }
     return result;
 }
 
diff --git a/src/views/RoundedTextField.h b/src/views/RoundedTextField.h
new file mode 100644
index 0000000..dafbc35
--- /dev/null
+++ b/src/views/RoundedTextField.h
@@ -0,0 +1,41 @@
+/*
+ *  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 RoundedTextField : NSTextField
+
+/*
+ * default value : [NSColor controlColor]
+ */
+
+@property (nonatomic, strong) NSColor* bgColor;
+
+/*
+ * default value : [bgColor darkenColorByValue:0.1];
+ */
+@property (nonatomic, strong) NSColor* borderColor;
+
+/*
+ * default value : (self.frame) / 2;
+ */
+@property (nonatomic, strong) NSNumber* cornerRadius;
+
+
+@end
diff --git a/src/views/RoundedTextField.mm b/src/views/RoundedTextField.mm
new file mode 100644
index 0000000..536cec3
--- /dev/null
+++ b/src/views/RoundedTextField.mm
@@ -0,0 +1,66 @@
+/*
+ *  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 "RoundedTextField.h"
+#import "NSColor+RingTheme.h"
+
+@implementation RoundedTextField
+
+-(void) awakeFromNib {
+    if (!self.bgColor) {
+        self.bgColor = [NSColor controlColor];
+    }
+
+    if (!self.cornerRadius) {
+        self.cornerRadius = @(NSWidth(self.frame) / 2);
+    }
+
+    if(!self.borderColor) {
+        self.borderColor = [self.bgColor darkenColorByValue:0.1];
+    }
+
+    self.backgroundColor = [NSColor controlColor];
+}
+
+- (void)drawRect:(NSRect)dirtyRect {
+    [super drawRect:dirtyRect];
+
+    NSColor* backgroundColor = self.bgColor;
+    NSColor* borderColor = self.borderColor;
+
+    NSBezierPath* ovalPath = [NSBezierPath bezierPathWithRoundedRect: dirtyRect xRadius:[self.cornerRadius floatValue] yRadius:[self.cornerRadius floatValue]];
+
+    [backgroundColor setFill];
+    [ovalPath fill];
+    [borderColor setStroke];
+    [ovalPath setLineWidth: 0.5];
+    [ovalPath stroke];
+    NSDictionary *att = nil;
+
+    NSMutableParagraphStyle *style =
+    [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
+    [style setLineBreakMode:NSLineBreakByWordWrapping];
+    [style setAlignment:NSCenterTextAlignment];
+    att = [[NSDictionary alloc] initWithObjectsAndKeys:
+           style, NSParagraphStyleAttributeName,
+           [self textColor],
+           NSForegroundColorAttributeName, nil];
+    [[self stringValue] drawInRect:dirtyRect withAttributes:att];
+}
+
+@end