DtkCore
DTK Core module
dtimeunitformatter.h
1/*
2 * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef DTIMEUNITFORMATTER_H
19#define DTIMEUNITFORMATTER_H
20
21#include "dtkcore_global.h"
22#include "dabstractunitformatter.h"
23
24DCORE_BEGIN_NAMESPACE
25
26class LIBDTKCORESHARED_EXPORT DTimeUnitFormatter : public DAbstractUnitFormatter
27{
28public:
30
31 enum TimeUnits
32 {
33 Seconds,
34 Minute,
35 Hour,
36 Day,
37 };
38
39 QString unitStr(int unitId) const override;
40
41protected:
42 int unitMax() const override { return Day; }
43 int unitMin() const override { return Seconds; }
44 uint unitConvertRate(int unitId) const override;
45};
46
47DCORE_END_NAMESPACE
48
49#endif // DTIMEUNITFORMATTER_H
DAbstractUnitFormatter 类是对拥有相同类型数据管理的接口类.
Definition: dabstractunitformatter.h:29
virtual QString unitStr(int unitId) const =0
传入id,返回列表中对应的字符串. unitId 单元ID.
virtual uint unitConvertRate(int unitId) const =0
返回当前设置的转换单位. unitId 单元ID.
DTimeUnitFormatter是用来获取时间单位的类, 通过枚举值.
Definition: dtimeunitformatter.h:27
int unitMin() const override
返回最小时间单位的枚举
Definition: dtimeunitformatter.h:43
int unitMax() const override
返回最大时间单位的枚举
Definition: dtimeunitformatter.h:42