~ubuntu-branches/ubuntu/trusty/digikam/trusty

« back to all changes in this revision

Viewing changes to extra/kipi-plugins/dlnaexport/extra/hupnp_av/src/cds_model/hdatetimerange.cpp

  • Committer: Package Import Robot
  • Author(s): Rohan Garg
  • Date: 2012-11-26 18:24:20 UTC
  • mfrom: (1.9.1) (3.1.23 experimental)
  • Revision ID: package-import@ubuntu.com-20121126182420-qoy6z0nx4ai0wzcl
Tags: 4:3.0.0~beta3-0ubuntu1
* New upstream release
  - Add build-deps :  libhupnp-dev, libqtgstreamer-dev, libmagickcore-dev
* Merge from debian, remaining changes:
  - Make sure libqt4-opengl-dev, libgl1-mesa-dev and libglu1-mesa-dev only
    install on i386,amd64 and powerpc
  - Depend on libtiff-dev instead of libtiff4-dev
  - Drop digikam breaks/replaces kipi-plugins-common since we're past the
    LTS release now
  - digikam to recommend mplayerthumbs | ffmpegthumbs. We currently only
    have latter in the archives, even though former is also supposed to
    be part of kdemultimedia. (LP: #890059)
  - kipi-plugins to recommend www-browser rather than konqueror directly
    since 2.8 no direct usage of konqueror is present in the flickr
    plugin anymore (LP: #1011211)
  - Keep kubuntu_mysqld_executable_name.diff
  - Don't install libkipi translations
  - Keep deps on libcv-dev, libcvaux-dev
  - Keep split packaging of libraries
  - Replace icons from KDE 3 time in debian/xpm.d/*.xpm with the new
    versions (LP: #658047)
* Update debian/not-installed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (C) 2011 Tuomo Penttinen, all rights reserved.
 
3
 *
 
4
 *  Author: Tuomo Penttinen <tp@herqq.org>
 
5
 *
 
6
 *  This file is part of Herqq UPnP Av (HUPnPAv) library.
 
7
 *
 
8
 *  Herqq UPnP Av is free software: you can redistribute it and/or modify
 
9
 *  it under the terms of the GNU General Public License as published by
 
10
 *  the Free Software Foundation, either version 3 of the License, or
 
11
 *  (at your option) any later version.
 
12
 *
 
13
 *  Herqq UPnP Av 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
 
16
 *  GNU General Public License for more details.
 
17
 *
 
18
 *  You should have received a copy of the GNU General Public License
 
19
 *  along with Herqq UPnP Av. If not, see <http://www.gnu.org/licenses/>.
 
20
 */
 
21
 
 
22
#include "hdatetimerange.h"
 
23
 
 
24
#include <QtCore/QDateTime>
 
25
 
 
26
static bool registerMetaTypes()
 
27
{
 
28
    qRegisterMetaType<Herqq::Upnp::Av::HDateTimeRange>(
 
29
        "Herqq::Upnp::Av::HDateTimeRange");
 
30
 
 
31
    return true;
 
32
}
 
33
 
 
34
static bool regMetaT = registerMetaTypes();
 
35
 
 
36
namespace Herqq
 
37
{
 
38
 
 
39
namespace Upnp
 
40
{
 
41
 
 
42
namespace Av
 
43
{
 
44
 
 
45
class HDateTimeRangePrivate :
 
46
    public QSharedData
 
47
{
 
48
H_DISABLE_ASSIGN(HDateTimeRangePrivate)
 
49
 
 
50
public:
 
51
 
 
52
    QDateTime m_startTime, m_endTime;
 
53
    HDaylightSaving m_dlSaving;
 
54
 
 
55
    HDateTimeRangePrivate() :
 
56
        m_startTime(), m_endTime(), m_dlSaving(Unknown_DaylightSaving)
 
57
    {
 
58
    }
 
59
};
 
60
 
 
61
HDateTimeRange::HDateTimeRange() :
 
62
    h_ptr(new HDateTimeRangePrivate())
 
63
{
 
64
}
 
65
 
 
66
HDateTimeRange::HDateTimeRange(const QString& value, HDaylightSaving dlSaving) :
 
67
    h_ptr(new HDateTimeRangePrivate())
 
68
{
 
69
    int index = value.indexOf('/');
 
70
    if (index > 0)
 
71
    {
 
72
        QDateTime start = QDateTime::fromString(value.left(index), Qt::ISODate);
 
73
        if (start.isValid())
 
74
        {
 
75
            QDateTime end = QDateTime::fromString(value.mid(index+1), Qt::ISODate);
 
76
            if (end.isValid())
 
77
            {
 
78
                h_ptr->m_startTime = start;
 
79
                h_ptr->m_endTime = end;
 
80
                h_ptr->m_dlSaving = dlSaving;
 
81
            }
 
82
        }
 
83
    }
 
84
}
 
85
 
 
86
HDateTimeRange::HDateTimeRange(const HDateTimeRange& other) :
 
87
    h_ptr(other.h_ptr)
 
88
{
 
89
    Q_ASSERT(&other != this);
 
90
}
 
91
 
 
92
HDateTimeRange& HDateTimeRange::operator=(const HDateTimeRange& other)
 
93
{
 
94
    Q_ASSERT(&other != this);
 
95
    h_ptr = other.h_ptr;
 
96
    return *this;
 
97
}
 
98
 
 
99
HDateTimeRange::~HDateTimeRange()
 
100
{
 
101
}
 
102
 
 
103
bool HDateTimeRange::isValid() const
 
104
{
 
105
    return h_ptr->m_startTime.isValid() && h_ptr->m_endTime.isValid();
 
106
}
 
107
 
 
108
QDateTime HDateTimeRange::startTime() const
 
109
{
 
110
    return h_ptr->m_startTime;
 
111
}
 
112
 
 
113
QDateTime HDateTimeRange::endTime() const
 
114
{
 
115
    return h_ptr->m_endTime;
 
116
}
 
117
 
 
118
HDaylightSaving HDateTimeRange::daylightSaving() const
 
119
{
 
120
    return h_ptr->m_dlSaving;
 
121
}
 
122
 
 
123
QString HDateTimeRange::toString() const
 
124
{
 
125
    if (!isValid())
 
126
    {
 
127
        return QString();
 
128
    }
 
129
    return QString("%1/%2").arg(
 
130
            startTime().toString(Qt::ISODate), endTime().toString(Qt::ISODate));
 
131
}
 
132
 
 
133
void HDateTimeRange::setStartTime(const QDateTime& value)
 
134
{
 
135
    h_ptr->m_startTime = value;
 
136
}
 
137
 
 
138
void HDateTimeRange::setEndTime(const QDateTime& value)
 
139
{
 
140
    h_ptr->m_endTime = value;
 
141
}
 
142
 
 
143
void HDateTimeRange::setDaylightSaving(HDaylightSaving dlSaving)
 
144
{
 
145
    h_ptr->m_dlSaving = dlSaving;
 
146
}
 
147
 
 
148
bool operator==(const HDateTimeRange& obj1, const HDateTimeRange& obj2)
 
149
{
 
150
    return obj1.toString() == obj2.toString() &&
 
151
           obj1.daylightSaving() == obj2.daylightSaving();
 
152
}
 
153
 
 
154
}
 
155
}
 
156
}
 
157