summaryrefslogtreecommitdiffstats
path: root/kplato/kptwbsdefinition.h
blob: f27c4d7ce12bcaefdc745c005fb75c38db5bff79 (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
/* This file is part of the KDE project
   Copyright (C) 2005 Dag Andersen <[email protected]>

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

   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 KPTWBSDEFINITION_H
#define KPTWBSDEFINITION_H

#include <qstring.h>
#include <qmap.h>
#include <qpair.h>
#include <qvaluelist.h>

class QStringList;

namespace KPlato
{

class Part;

class WBSDefinition {

public:
    WBSDefinition();
    ~WBSDefinition();

    class CodeDef {
        public:
            CodeDef() {}
            CodeDef(QString c, QString s) { code = c; separator = s; }
            ~CodeDef() {}
            void clear() { code = separator = QString(); }
            bool isEmpty() { return code.isEmpty(); }
            QString code;
            QString separator;
    };
    
    void clear();
    
    /// Return wbs string.
    QString wbs(uint index, int level);
    /// Return wbs code.
    QString code(uint index, int level);
    /// Return wbs separator.
    QString separator(int level);
    
    CodeDef &defaultDef() { return m_defaultDef; }
    void setDefaultDef(CodeDef def) { m_defaultDef = def; }
    
    bool isLevelsDefEnabled() const { return m_levelsEnabled; }
    bool level0Enabled();
    void setLevelsDefEnabled(bool on) { m_levelsEnabled = on; }
    void clearLevelsDef() { m_levelsDef.clear(); }
    const QMap<int, CodeDef> &levelsDef() const { return m_levelsDef; }
    void setLevelsDef(QMap<int, CodeDef> def);
    CodeDef levelsDef(int level) const;
    void setLevelsDef(int level, CodeDef def);
    void setLevelsDef(int level, QString c, QString s);
    
    QStringList codeList();
    int defaultCodeIndex() const;
    bool setDefaultCode(uint index);
    QString defaultSeparator() const { return m_defaultDef.separator; }
    void setDefaultSeparator(QString s);

protected:
    QString code(CodeDef &def, uint index);
    QString toRoman(int n, bool upper = false);
    
private:
    CodeDef m_defaultDef;
    
    bool m_levelsEnabled;
    QMap<int, CodeDef> m_levelsDef;

    QValueList<QPair<QString, QString> > m_codeLists;
};

} //namespace KPlato

#endif //WBSDEFINITION_H