~ubuntu-branches/ubuntu/gutsy/kid3/gutsy

« back to all changes in this revision

Viewing changes to kid3/standardtags.h

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Mercatante
  • Date: 2007-07-01 00:31:03 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070701003103-2qownnv49a7jdqm3
Tags: 0.9-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
/** Set of standard tags */
16
16
class StandardTags {
17
17
 public:
 
18
        /** Flags for formatString(), replacePercentCodes(). */
 
19
        enum FormatStringFlags {
 
20
                FSF_SupportUrlEncode = 1
 
21
        };
 
22
 
 
23
        /** Flags for truncation. */
 
24
        enum TruncationFlag {
 
25
                TF_Title   = (1 << 0),
 
26
                TF_Artist  = (1 << 1),
 
27
                TF_Album   = (1 << 2),
 
28
                TF_Comment = (1 << 3),
 
29
                TF_Year    = (1 << 4),
 
30
                TF_Track   = (1 << 5),
 
31
                TF_Genre   = (1 << 6)
 
32
        };
 
33
 
18
34
        /**
19
35
         * Constructor.
20
36
         */
21
37
        StandardTags();
 
38
 
22
39
        /**
23
40
         * Set values which are different inactive.
24
41
         *
25
42
         * @param st tags to compare
26
43
         */
27
44
        void filterDifferent(const StandardTags& st);
 
45
 
28
46
        /**
29
47
         * Set tags inactive.
30
48
         */
31
49
        void setInactive();
 
50
 
32
51
        /**
33
52
         * Copy all tags which are not inactive.
34
53
         *
35
54
         * @param dest standard tags to copy into
36
55
         */
37
 
        void copyActiveTags(StandardTags &dest) const;
 
56
        void copyActiveTags(StandardTags& dest) const;
 
57
 
38
58
        /**
39
59
         * Set tags empty.
40
60
         */
41
61
        void setEmpty();
 
62
 
 
63
        /**
 
64
         * Copy tags which are empty or inactive from other tags.
 
65
         * This can be used to merge two tags.
 
66
         *
 
67
         * @param st other tags
 
68
         */
 
69
        void merge(const StandardTags& st);
 
70
 
 
71
        /**
 
72
         * Check if the tags are empty or inactive.
 
73
         *
 
74
         * @return true if empty or inactive.
 
75
         */
 
76
        bool isEmptyOrInactive() const;
 
77
 
 
78
        /**
 
79
         * Format a string from tag data.
 
80
         * Supported format fields:
 
81
         * %s title (song)
 
82
         * %l album
 
83
         * %a artist
 
84
         * %c comment
 
85
         * %y year
 
86
         * %t track, two digits, i.e. leading zero if < 10
 
87
         * %T track, without leading zeroes
 
88
         * %g genre
 
89
         *
 
90
         * @param format format specification
 
91
         * @param flags  flags: FSF_SupportUrlEncode to support modifier u
 
92
         *               (with code c "%uc") to URL encode
 
93
         *
 
94
         * @return formatted string.
 
95
         */
 
96
        QString formatString(const QString& format, unsigned flags = 0) const;
 
97
 
 
98
        /**
 
99
         * Replace escaped characters in a string.
 
100
         *
 
101
         * @param format string with escaped two-character-sequences
 
102
         *               ("\n", "\t", "\r", "\\", "\a", "\b", "\f", "\v")
 
103
         *
 
104
         * @return string with escaped sequences replaced by characters.
 
105
         */
 
106
        static QString replaceEscapedChars(const QString& format);
 
107
 
 
108
        /**
 
109
         * Replace percent codes in a string.
 
110
         *
 
111
         * @param format string with percent codes
 
112
         *               (% followed by a single character)
 
113
         * @param codes        characters following percent
 
114
         * @param replacements strings with replacements for codes
 
115
         * @param numCodes     number of elements in codes and replacements
 
116
         * @param flags        flags: FSF_SupportUrlEncode to support modifier u
 
117
         *                     (with code c "%uc") to URL encode
 
118
         *
 
119
         * @return string with percent codes replaced
 
120
         */
 
121
        static QString replacePercentCodes(
 
122
                const QString& format, const QChar* codes,
 
123
                const QString* replacements, int numCodes,
 
124
                unsigned flags = 0);
 
125
 
42
126
        /** Title, empty if "", inactive if QString::null */
43
127
        QString title;
44
128
        /** Artist, empty if "", inactive if QString::null */
51
135
        int year;
52
136
        /** Track, empty if 0, inactive if -1 */
53
137
        int track;
54
 
        /** Genre, empty if 0xff, inactive if -1 */
55
 
        int genre;
56
 
        /** Genre without number, inactive if QString::null or genre != 0xff,
57
 
                        empty if "" */
58
 
        QString genreStr;
 
138
        /** Genre, inactive if QString::null, empty if "" */
 
139
        QString genre;
59
140
};
60
141
 
61
142
/**
80
161
   */
81
162
  bool areAllTrue() const;
82
163
 
83
 
        bool m_enableTitle;
84
 
        bool m_enableArtist;
85
 
        bool m_enableAlbum;
86
 
        bool m_enableComment;
87
 
        bool m_enableYear;
88
 
        bool m_enableTrack;
89
 
        bool m_enableGenre;
 
164
        bool m_enableTitle;   /**< true if title enabled */
 
165
        bool m_enableArtist;  /**< true if artist enabled */
 
166
        bool m_enableAlbum;   /**< true if album enabled */
 
167
        bool m_enableComment; /**< true if comment enabled */
 
168
        bool m_enableYear;    /**< true if year enabled */
 
169
        bool m_enableTrack;   /**< true if track enabled */
 
170
        bool m_enableGenre;   /**< true if genre enabled */
90
171
};
91
172
 
92
173
#endif // STANDARDTAGS_H