summaryrefslogtreecommitdiffstats
path: root/cervisia/loginfo.h
blob: df88947fc20dc9ccddc782c7559e0e4f6b4105a4 (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
 * Copyright (c) 2003-2007 André Wöbbeking <Woebbeking@kde.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */


#ifndef CERVISIA_LOGINFO_H
#define CERVISIA_LOGINFO_H


#include <tqdatetime.h>
#include <tqstring.h>
#include <tqvaluelist.h>


namespace Cervisia
{


/**
 * Dumb data struct to store informations of a tag plus some
 * convenience methods. The struct is used by the LogInfo struct.
 */
struct TagInfo
{
    /**
     * The types of a tag.
     */
    enum Type
    {
        /**
         * Branchpoint.
         */
        Branch   = 1 << 0,

        /**
         * This type is for internal use. If the revision is in a branch
         * this tag represents the branch.
         */
        OnBranch = 1 << 1,

        /**
         * Normal tag.
         */
        Tag      = 1 << 2
    };

    explicit TagInfo(const TQString& name = TQString(), Type type = Tag);

    /**
     * @param prefixWithType prefix the string with the type of the tag
     * (e.g. Tag: KDE_3_1_3_RELEASE).
     *
     * @return tag as string.
     */
    TQString toString(bool prefixWithType = true) const;

    /**
     * @return type of tag as string.
     */
    TQString typeToString() const;

    /**
     * The name of the tag.
     */
    TQString m_name;

    /**
     * The type of the tag.
     */
    Type m_type;
};


/**
 * Dumb data struct to store the results of the log command plus some
 * convenience methods.
 */
struct LogInfo
{
    typedef TQValueList<TagInfo> TTagInfoSeq;

    /**
     * @param showTime show commit time in tooltip.
     *
     * @return rich text formatted tooltip text.
     */
    TQString createToolTipText(bool showTime = true) const;

    /**
     * Calls TDELocale::formatDateTime() to create a formatted string.
     *
     * @param showTime show commit time in tooltip.
     * @param shortFormat using the short date format.
     *
     * @return The date/time formatted to the user's locale's conventions.
     */
    TQString dateTimeToString(bool showTime = true, bool shortFormat = true) const;

    enum
    {
        NoTagType   = 0,
        AllTagTypes = TagInfo::Branch | TagInfo::OnBranch | TagInfo::Tag
    };

    /**
     * Creates a single string from alls tags.
     *
     * @param types tags that should be taken into account.
     * @param prefixWithType tags that should be prefixed with their type
     * (see TagInfo::toString()).
     * @param separator string to separate the tags.
     *
     * @return string of joined tags.
     */
    TQString tagsToString(unsigned int types = AllTagTypes,
                         unsigned int prefixWithType = AllTagTypes,
                         const TQString& separator = TQString(TQChar('\n'))) const;

    /**
     * The revision of this entry.
     */
    TQString m_revision;

    /**
     * The author who committed.
     */
    TQString m_author;

    /**
     * The commit message.
     */
    TQString m_comment;

    /**
     * The date/time of the commit.
     */
    TQDateTime m_dateTime;

    /**
     * Sequence of tags of this entry.
     */
    TTagInfoSeq m_tags;
};


} // namespace Cervisia


#endif // CERVISIA_LOGINFO_H