summaryrefslogtreecommitdiffstats
path: root/tdeui/ktimezonewidget.h
blob: 03764d2465fe44e50d3de422f3a2f05225cdd5c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
    Copyright (C) 2005, S.R.Haque <srhaque@iee.org>.
    This file is part of the KDE project

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License version 2, as published by the Free Software Foundation.

    This library 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
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
*/

#ifndef KTIMEZONEWIDGET_H
#define KTIMEZONEWIDGET_H

#include <kdelibs_export.h>
#include <klistview.h>
#include <tqstring.h>

class KTimezone;
class KTimezones;
class KTimezoneWidgetPrivate;

/**
 * @brief A timezone selection widget.
 *
 * \b Detail:
 *
 * This class provides for selection of one or more timezones.
 *
 * \b Example:
 *
 * To use the class to implement a system timezone selection feature:
 * \code
 *
 *  // This adds a timezone widget to a dialog.
 *  m_timezones =  new KTimezoneWidget(this, "Timezones");
 *  ...
 * \endcode
 *
 * To use the class to implement a multiple-choice custom timezone selector:
 * \code
 *
 *  m_timezones =  new KTimezoneWidget(this, "Timezones", vcalendarTimezones);
 *  m_timezones->setSelectionModeExt(KListView::Multi);
 *  ...
 * \endcode
 *
 * @author S.R.Haque <srhaque@iee.org>
 * @since 3.5
 */
class TDEUI_EXPORT KTimezoneWidget :
    public KListView
{
    Q_OBJECT

public:
    /**
     * Constructs a timezone selection widget.
     *
     * @param parent The parent widget.
     * @param name The name of this widget.
     * @param db The timezone database to use. If 0, the system timezone
     *           database is used.
     */
    KTimezoneWidget(TQWidget *parent = 0, const char *name = 0, KTimezones *db = 0);

    /**
     * Destroys the timezone selection widget.
     */
    virtual ~KTimezoneWidget();

    /**
     * Returns the currently selected timezones. See TQListView::selectionChanged().
     *
     * @return a list of timezone names, in the format used by the database
     *         supplied to the {@link KTimezoneWidget() } constructor.
     */
    TQStringList selection() const;

    /**
     * Select/deselect the named timezone.
     *
     * @param zone The timezone name to be selected. Ignored if not recognised!
     * @param selected The new selection state.
     */
    void setSelected(const TQString &zone, bool selected);

    /**
     * Format a timezone name in a standardised manner. The returned value is
     * transformed via an i18n lookup, so the caller should previously have
     * set the timezone catalogue:
     * \code
     * KGlobal::locale()->insertCatalogue("timezones");
     * \endcode
     *
     * @return formatted timezone name.
     */
    static TQString displayName(const KTimezone *zone);

private:
    KTimezoneWidgetPrivate *d;
};

#endif