~ubuntu-branches/ubuntu/maverick/knemo/maverick

« back to all changes in this revision

Viewing changes to src/kcm/kdateedit.h

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2010-01-06 17:16:51 UTC
  • mfrom: (1.1.9 upstream) (2.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100106171651-ff58ryfnav4l1zbm
Tags: 0.6.0-1
* New upstream release 
  - Fixes "FTBFS: sysbackend.cpp:362: error: 'KILO' was not declared in
  this scope" (Closes: #560496)
  - Fixes "context menu does not appear" (Closes: #504791)
* Add Build-Depends: libnl-dev - Linux netlink sockets library

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  This file is part of libkdepim.
 
3
 
 
4
  Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
 
5
  Copyright (c) 2002 David Jarvie <software@astrojar.org.uk>
 
6
  Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
 
7
 
 
8
  This library is free software; you can redistribute it and/or
 
9
  modify it under the terms of the GNU Library General Public
 
10
  License as published by the Free Software Foundation; either
 
11
  version 2 of the License, or (at your option) any later version.
 
12
 
 
13
  This library is distributed in the hope that it will be useful,
 
14
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
  Library General Public License for more details.
 
17
 
 
18
  You should have received a copy of the GNU Library General Public License
 
19
  along with this library; see the file COPYING.LIB.  If not, write to
 
20
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
21
  Boston, MA 02110-1301, USA.
 
22
*/
 
23
 
 
24
#ifndef KDATEEDIT_H
 
25
#define KDATEEDIT_H
 
26
 
 
27
#include "kdatepickerpopup.h"
 
28
 
 
29
#include <QComboBox>
 
30
#include <QDateTime>
 
31
#include <QEvent>
 
32
#include <QMap>
 
33
#include <QMouseEvent>
 
34
 
 
35
class QEvent;
 
36
 
 
37
/**
 
38
  A date editing widget that consists of an editable combo box.
 
39
  The combo box contains the date in text form, and clicking the combo
 
40
  box arrow will display a 'popup' style date picker.
 
41
 
 
42
  This widget also supports advanced features like allowing the user
 
43
  to type in the day name to get the date. The following keywords
 
44
  are supported (in the native language): tomorrow, yesterday, today,
 
45
  monday, tuesday, wednesday, thursday, friday, saturday, sunday.
 
46
 
 
47
  @image html kdateedit.png "This is how it looks"
 
48
 
 
49
  @author Cornelius Schumacher <schumacher@kde.org>
 
50
  @author Mike Pilone <mpilone@slac.com>
 
51
  @author David Jarvie <software@astrojar.org.uk>
 
52
  @author Tobias Koenig <tokoe@kde.org>
 
53
*/
 
54
class KDateEdit : public QComboBox
 
55
{
 
56
  Q_OBJECT
 
57
 
 
58
  public:
 
59
    explicit KDateEdit( QWidget *parent = 0, const char *name = 0 );
 
60
    virtual ~KDateEdit();
 
61
 
 
62
    /**
 
63
      @return The date entered. This date could be invalid,
 
64
              you have to check validity yourself.
 
65
     */
 
66
    QDate date() const;
 
67
 
 
68
    /**
 
69
      Sets whether the widget is read-only for the user. If read-only, the
 
70
      date pop-up is inactive, and the displayed date cannot be edited.
 
71
 
 
72
      @param readOnly True to set the widget read-only, false to set it read-write.
 
73
     */
 
74
    void setReadOnly( bool readOnly );
 
75
 
 
76
    /**
 
77
      @return True if the widget is read-only, false if read-write.
 
78
     */
 
79
    bool isReadOnly() const;
 
80
 
 
81
    virtual void showPopup();
 
82
 
 
83
  Q_SIGNALS:
 
84
    /**
 
85
      This signal is emitted whenever the user has entered a new date.
 
86
      When the user changes the date by editing the line edit field,
 
87
      the signal is not emitted until focus leaves the line edit field.
 
88
      The passed date can be invalid.
 
89
     */
 
90
    void dateEntered( const QDate &date );
 
91
 
 
92
    /**
 
93
      This signal is emitted whenever the user modifies the date.
 
94
      The passed date can be invalid.
 
95
     */
 
96
    void dateChanged( const QDate &date );
 
97
 
 
98
  public Q_SLOTS:
 
99
    /**
 
100
      Sets the date.
 
101
 
 
102
      @param date The new date to display. This date must be valid or
 
103
                  it will not be set
 
104
     */
 
105
    void setDate( const QDate &date );
 
106
 
 
107
  protected Q_SLOTS:
 
108
    void lineEnterPressed();
 
109
    void slotTextChanged( const QString & );
 
110
    void dateSelected( const QDate & );
 
111
 
 
112
  protected:
 
113
    virtual bool eventFilter( QObject *, QEvent * );
 
114
    virtual void mousePressEvent( QMouseEvent * );
 
115
    virtual void focusOutEvent( QFocusEvent * );
 
116
    virtual void keyPressEvent( QKeyEvent * );
 
117
 
 
118
    /**
 
119
      Sets the date, without altering the display.
 
120
      This method is used internally to set the widget's date value.
 
121
      As a virtual method, it allows derived classes to perform additional
 
122
      validation on the date value before it is set. Derived classes should
 
123
      return true if QDate::isValid(@p date) returns false.
 
124
 
 
125
      @param date The new date to set.
 
126
      @return True if the date was set, false if it was considered invalid and
 
127
              remains unchanged.
 
128
     */
 
129
    virtual bool assignDate( const QDate &date );
 
130
 
 
131
    /**
 
132
      Fills the keyword map. Reimplement it if you want additional keywords.
 
133
     */
 
134
    void setupKeywords();
 
135
 
 
136
  private:
 
137
    QDate parseDate( bool *replaced = 0 ) const;
 
138
    void updateView();
 
139
 
 
140
    KDatePickerPopup *mPopup;
 
141
 
 
142
    QDate mDate;
 
143
    bool mReadOnly;
 
144
    bool mTextChanged;
 
145
    bool mDiscardNextMousePress;
 
146
 
 
147
    QMap<QString, int> mKeywordMap;
 
148
};
 
149
 
 
150
#endif