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

« back to all changes in this revision

Viewing changes to mobile/notes/NoteView.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,
 
3
        a KDAB Group company, info@kdab.net,
 
4
        author Stephen Kelly <stephen@kdab.com>
 
5
 
 
6
    This library is free software; you can redistribute it and/or modify it
 
7
    under the terms of the GNU Library General Public License as published by
 
8
    the Free Software Foundation; either version 2 of the License, or (at your
 
9
    option) any later version.
 
10
 
 
11
    This library is distributed in the hope that it will be useful, but WITHOUT
 
12
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
13
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
 
14
    License for more details.
 
15
 
 
16
    You should have received a copy of the GNU Library General Public License
 
17
    along with this library; see the file COPYING.LIB.  If not, write to the
 
18
    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
19
    02110-1301, USA.
 
20
*/
 
21
 
 
22
import Qt 4.7
 
23
 
 
24
Rectangle {
 
25
  id : _topContext
 
26
  color: "#00000000" // Set a transparant color.
 
27
  property int currentNoteRow : -1
 
28
  anchors.fill : parent
 
29
 
 
30
  onCurrentNoteRowChanged : {
 
31
    titleInput.text = application.noteTitle( currentNoteRow );
 
32
    contentEdit.text = application.noteContent( currentNoteRow );
 
33
  }
 
34
 
 
35
  function saveNote()
 
36
  {
 
37
    application.saveNote(titleInput.text, contentEdit.text);
 
38
  }
 
39
 
 
40
  Rectangle {
 
41
    border { color: "grey"; width: 2; }
 
42
    color: "#00000000"
 
43
    id : titleWrapper
 
44
    anchors.top : parent.top
 
45
    anchors.left : parent.left
 
46
    anchors.right : parent.right
 
47
    height : 30
 
48
    radius : 8
 
49
    TextInput {
 
50
      id : titleInput
 
51
      color : "#000001" // yes, not exactly black, since QML maps black to white on the N900...
 
52
      anchors.left : parent.left
 
53
      anchors.right: parent.right
 
54
      anchors.verticalCenter: parent.verticalCenter
 
55
      anchors.leftMargin : 10
 
56
      anchors.rightMargin : 10
 
57
 
 
58
      /*
 
59
      onClicked : {
 
60
        application.saveCurrentNoteContent(contentEdit.text);
 
61
      } */
 
62
    }
 
63
 
 
64
  }
 
65
 
 
66
  Rectangle {
 
67
    border { color: "grey"; width: 2; }
 
68
    color: "#00000000"
 
69
    anchors.top : titleWrapper.bottom
 
70
    anchors.left : parent.left
 
71
    anchors.right : parent.right
 
72
    anchors.bottom : parent.bottom
 
73
    anchors.topMargin: 8
 
74
    radius : 8
 
75
    Flickable {
 
76
      id: flick
 
77
 
 
78
      anchors.fill : parent
 
79
      anchors.topMargin : 8
 
80
      anchors.bottomMargin : 8
 
81
      anchors.leftMargin : 10
 
82
      anchors.rightMargin : 10
 
83
 
 
84
      clip: true
 
85
 
 
86
      function ensureVisible(r)
 
87
      {
 
88
          if (contentX >= r.x)
 
89
              contentX = r.x;
 
90
          else if (contentX+width <= r.x+r.width)
 
91
              contentX = r.x+r.width-width;
 
92
          if (contentY >= r.y)
 
93
              contentY = r.y;
 
94
          else if (contentY+height <= r.y+r.height)
 
95
              contentY = r.y+r.height-height;
 
96
      }
 
97
 
 
98
      TextEdit {
 
99
        id : contentEdit
 
100
        color : "#000001" // yes, not exactly black, since QML maps black to white on the N900...
 
101
        anchors.fill : parent
 
102
 
 
103
        wrapMode: TextEdit.Wrap
 
104
        onCursorRectangleChanged: flick.ensureVisible(cursorRectangle)
 
105
      }
 
106
    }
 
107
  }
 
108
}