File: ddisksizeformatter.h

package info (click to toggle)
dtk6core 6.0.50-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,828 kB
  • sloc: cpp: 22,748; ansic: 191; python: 68; xml: 58; makefile: 25; sh: 15
file content (41 lines) | stat: -rw-r--r-- 823 bytes parent folder | download | duplicates (2)
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
// SPDX-FileCopyrightText: 2017 - 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#ifndef DISKSIZEFORMATTER_H
#define DISKSIZEFORMATTER_H

#include "dabstractunitformatter.h"

DCORE_BEGIN_NAMESPACE

class LIBDTKCORESHARED_EXPORT DDiskSizeFormatter : public DAbstractUnitFormatter
{
public:
    DDiskSizeFormatter();

    enum DiskUnits
    {
        B,
        K,
        M,
        G,
        T,
    };

    QString unitStr(int unitId) const override;

    DDiskSizeFormatter rate(int rate);

protected:
    int unitMin() const override { return B; }
    int unitMax() const override { return T; }
    uint unitConvertRate(int unitId) const override { Q_UNUSED(unitId); return m_rate; }

private:
    int m_rate = 1000;
};

DCORE_END_NAMESPACE

#endif // DISKSIZEFORMATTER_H