~ubuntu-branches/ubuntu/trusty/sflphone/trusty

« back to all changes in this revision

Viewing changes to kde/src/widgets/contactview.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (4.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20140128182336-jrsv0k9u6cawc068
Tags: 1.3.0-1
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2013 Savoir-Faire Linux                                 *
 
3
 *   @author: Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com>*
 
4
 *                                                                         *
 
5
 * This library is free software; you can redistribute it and/or           *
 
6
 * modify it under the terms of the GNU Library General Public             *
 
7
 * License version 2 as published by the Free Software Foundation.         *
 
8
 *                                                                         *
 
9
 * This library is distributed in the hope that it will be useful,         *
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
 
12
 * Library General Public License for more details.                        *
 
13
 *                                                                         *
 
14
 *   You should have received a copy of the GNU General Public License     *
 
15
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
 
16
 **************************************************************************/
 
17
#include "contactview.h"
 
18
 
 
19
#include <QtGui/QPainter>
 
20
#include <QtGui/QPaintEvent>
 
21
 
 
22
#include <lib/contactproxymodel.h>
 
23
#include <lib/abstractcontactbackend.h>
 
24
 
 
25
ContactView::ContactView(QWidget* parent) : CategorizedTreeView(parent)
 
26
{
 
27
   
 
28
}
 
29
 
 
30
QRect ContactView::phoneRect(const QModelIndex& index) const
 
31
{
 
32
   QRect origin = CategorizedTreeView::visualRect(index);
 
33
   const QRect parentRect = visualRect(index.parent());
 
34
   origin.setX(4 + 48 + parentRect.x() + 4);
 
35
   origin.setWidth(parentRect.width()-48-4);
 
36
   return origin;
 
37
}
 
38
 
 
39
QRect ContactView::visualRect(const QModelIndex& index) const
 
40
{
 
41
   //Detect if it is a phone number
 
42
   if (index.parent().parent().isValid()) {
 
43
      return phoneRect(index);
 
44
   }
 
45
   return CategorizedTreeView::visualRect(index);
 
46
}
 
47
 
 
48
bool ContactView::viewportEvent( QEvent * event ) {
 
49
   #pragma GCC diagnostic push
 
50
   #pragma GCC diagnostic ignored "-Wswitch-enum"
 
51
   switch (event->type()) {
 
52
      case QEvent::HoverEnter:
 
53
      case QEvent::HoverLeave:
 
54
      case QEvent::HoverMove: {
 
55
         const QHoverEvent* he     = static_cast<QHoverEvent*>(event);
 
56
         const QModelIndex  oldIdx = indexAt(he->oldPos());
 
57
         const QModelIndex  newIdx = indexAt(he->pos());
 
58
      } break;
 
59
      case QEvent::Drop: {
 
60
         const QDropEvent* de      = static_cast<QDropEvent*>(event);
 
61
         const QModelIndex newIdx  = indexAt(de->pos());
 
62
 
 
63
         //Clear drop state
 
64
         cancelHoverState();
 
65
 
 
66
         //HACK For some reasons, the proxy model fail to forward a valid index to dropMimeData()
 
67
         //force it
 
68
         model()->dropMimeData(de->mimeData(), Qt::TargetMoveAction, newIdx.row(), newIdx.column(), newIdx.parent());
 
69
         return true;
 
70
      } break;
 
71
      default:
 
72
         break;
 
73
   }
 
74
   #pragma GCC diagnostic pop
 
75
   return CategorizedTreeView::viewportEvent(event);
 
76
}