~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to mobile/lib/AgentInstanceListDelegate.qml

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  Copyright (C) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
 
3
  Copyright (C) 2010 Volker Krause <vkrause@kde.org>
 
4
 
 
5
    This library is free software; you can redistribute it and/or modify it
 
6
    under the terms of the GNU Library General Public License as published by
 
7
    the Free Software Foundation; either version 2 of the License, or (at your
 
8
    option) any later version.
 
9
 
 
10
    This library is distributed in the hope that it will be useful, but WITHOUT
 
11
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
12
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
 
13
    License for more details.
 
14
 
 
15
    You should have received a copy of the GNU Library General Public License
 
16
    along with this library; see the file COPYING.LIB.  If not, write to the
 
17
    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
18
    02110-1301, USA.
 
19
*/
 
20
 
 
21
import Qt 4.7 as QML
 
22
import org.kde 4.5
 
23
import org.kde.pim.mobileui 4.5
 
24
 
 
25
QML.Item {
 
26
  id: _delegateTopLevel
 
27
  clip: true
 
28
  width: QML.ListView.width
 
29
  height: 100
 
30
 
 
31
  function iconForStatus( online, status )
 
32
  {
 
33
    if ( !online ) {
 
34
      return "images/status/offline.png";
 
35
    }
 
36
 
 
37
    if ( status == 0 ) {
 
38
      return "images/status/online.png"
 
39
    } else if ( status == 1 ) {
 
40
      return "images/status/receiving.png";
 
41
    } else {
 
42
      return KDE.iconPath( "dialog-warning", 26 );
 
43
    }
 
44
  }
 
45
 
 
46
  function statusMessage( msg, progress )
 
47
  {
 
48
    if ( progress <= 0 || progress >= 100 )
 
49
      return msg;
 
50
    return KDE.i18nc( "status message (50%)", "%1 (%2%)", msg, progress );
 
51
  }
 
52
 
 
53
  QML.Rectangle {
 
54
    id: background
 
55
    anchors.fill: parent
 
56
    opacity: (_delegateTopLevel.QML.ListView.isCurrentItem ? 0.25 : 0)
 
57
    color: "lightsteelblue"
 
58
  }
 
59
 
 
60
  QML.Item {
 
61
    anchors.margins: 4
 
62
    anchors.fill: parent
 
63
 
 
64
    QML.Image {
 
65
      id: statusIcon
 
66
      anchors { top: parent.top; left: parent.left }
 
67
      source: iconForStatus( model.online, model.status )
 
68
    }
 
69
 
 
70
    QML.Text {
 
71
      id: nameLabel
 
72
      anchors { verticalCenter: statusIcon.verticalCenter; left: statusIcon.right }
 
73
      width: parent.width - statusIcon.width
 
74
      elide: QML.Text.ElideRight
 
75
      text : model.display
 
76
    }
 
77
 
 
78
    QML.Text {
 
79
      id: statusLabel
 
80
      anchors { left: nameLabel.left; top: nameLabel.bottom; topMargin: 2 }
 
81
      width: nameLabel.width
 
82
      font.pixelSize: 16
 
83
      elide: QML.Text.ElideRight
 
84
      text: statusMessage( model.statusMessage, model.progress )
 
85
    }
 
86
 
 
87
  }
 
88
 
 
89
  QML.MouseArea {
 
90
    anchors.fill: parent
 
91
    onClicked: { _delegateTopLevel.QML.ListView.view.currentIndex = model.index; }
 
92
  }
 
93
}