~mzanetti/unity8/modeswitchwarning

« back to all changes in this revision

Viewing changes to plugins/Utils/timeformatter.h

  • Committer: Michael Zanetti
  • Date: 2015-10-26 16:47:52 UTC
  • mfrom: (1978.2.32 trunk)
  • Revision ID: michael.zanetti@canonical.com-20151026164752-8yt7ngcng344mb67
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2013 Canonical Ltd.
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or modify
5
 
 * it under the terms of the GNU General Public License as published by
6
 
 * the Free Software Foundation; version 3.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful,
9
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
 * GNU General Public License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU General Public License
14
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
 *
16
 
 * Author: Lars Uebernickel <lars.uebernickel@canonical.com>
17
 
 */
18
 
 
19
 
#ifndef TIME_FORMATTER_H
20
 
#define TIME_FORMATTER_H
21
 
 
22
 
#include <QObject>
23
 
 
24
 
// TODO - bug #1260728
25
 
class TimeFormatter : public QObject
26
 
{
27
 
    Q_OBJECT
28
 
    Q_PROPERTY(QString format READ format WRITE setFormat NOTIFY formatChanged)
29
 
    Q_PROPERTY(QString timeString READ timeString NOTIFY timeStringChanged)
30
 
    Q_PROPERTY(qint64 time READ time WRITE setTime NOTIFY timeChanged)
31
 
 
32
 
public:
33
 
    TimeFormatter(QObject *parent = 0);
34
 
    virtual ~TimeFormatter();
35
 
 
36
 
    virtual QString format() const;
37
 
    QString timeString() const;
38
 
    qint64 time() const;
39
 
 
40
 
    void setFormat(const QString &format);
41
 
    void setTime(qint64 time);
42
 
 
43
 
    void update();
44
 
 
45
 
Q_SIGNALS:
46
 
    void formatChanged(const QString &format);
47
 
    void timeStringChanged(const QString &timeString);
48
 
    void timeChanged(qint64 time);
49
 
 
50
 
protected:
51
 
    TimeFormatter(const QString &initialFormat, QObject *parent = 0);
52
 
 
53
 
    virtual QString formatTime() const;
54
 
 
55
 
private:
56
 
    struct TimeFormatterPrivate *priv;
57
 
};
58
 
 
59
 
class GDateTimeFormatter : public TimeFormatter
60
 
{
61
 
public:
62
 
    GDateTimeFormatter(QObject *parent = 0);
63
 
 
64
 
protected:
65
 
    QString formatTime() const override;
66
 
};
67
 
 
68
 
#endif