~ubuntu-branches/ubuntu/wily/kid3/wily

« back to all changes in this revision

Viewing changes to src/core/tags/frame.h

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2015-05-12 18:56:41 UTC
  • mfrom: (1.1.19) (2.3.3 sid)
  • Revision ID: package-import@ubuntu.com-20150512185641-hgeys2pingwq9mwn
Tags: 3.2.1-1
* New upstream release.
  - Add new build dependency qt4-dev-tools.
* Uploading to unstable.
* Switch to DEP5 debian/copyright format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
/** Generalized frame. */
38
38
class KID3_CORE_EXPORT Frame {
 
39
  Q_GADGET
 
40
  Q_ENUMS(Type)
 
41
  Q_ENUMS(FieldId)
 
42
  Q_ENUMS(TextEncoding)
 
43
  Q_ENUMS(PictureType)
 
44
  Q_ENUMS(TagVersion)
39
45
public:
40
46
  /** Generalized frame types. */
41
47
  enum Type {
92
98
    FT_UnknownFrame
93
99
  };
94
100
 
 
101
  /**
 
102
   * Types of fields in a frame, must be the same as id3lib's ID3_FieldID.
 
103
   **/
 
104
  enum FieldId {
 
105
    ID_NoField,
 
106
    ID_TextEnc,
 
107
    ID_Text,
 
108
    ID_Url,
 
109
    ID_Data,
 
110
    ID_Description,
 
111
    ID_Owner,
 
112
    ID_Email,
 
113
    ID_Rating,
 
114
    ID_Filename,
 
115
    ID_Language,
 
116
    ID_PictureType,
 
117
    ID_ImageFormat,
 
118
    ID_MimeType,
 
119
    ID_Counter,
 
120
    ID_Id,
 
121
    ID_VolumeAdj,
 
122
    ID_NumBits,
 
123
    ID_VolChgRight,
 
124
    ID_VolChgLeft,
 
125
    ID_PeakVolRight,
 
126
    ID_PeakVolLeft,
 
127
    ID_TimestampFormat,
 
128
    ID_ContentType,
 
129
 
 
130
    // These are additional fields used by TagLib
 
131
    ID_Price,
 
132
    ID_Date,
 
133
    ID_Seller,
 
134
 
 
135
    // Additional field for METADATA_BLOCK_PICTURE
 
136
    ID_ImageProperties
 
137
  };
 
138
 
 
139
  /** Text encoding for fields of type ID_TextEnc. */
 
140
  enum TextEncoding {
 
141
    TE_ISO8859_1 = 0,
 
142
    TE_UTF16 = 1,
 
143
    TE_UTF16BE = 2,
 
144
    TE_UTF8 = 3
 
145
  };
 
146
 
 
147
  /** Picture type, compatible with ID3v2 and FLAC. */
 
148
  enum PictureType {
 
149
    PT_Other = 0,
 
150
    PT_Png32Icon = 1,
 
151
    PT_OtherIcon = 2,
 
152
    PT_CoverFront = 3,
 
153
    PT_CoverBack = 4,
 
154
    PT_LeafletPage = 5,
 
155
    PT_Media = 6,
 
156
    PT_LeadArtist = 7,
 
157
    PT_Artist = 8,
 
158
    PT_Conductor = 9,
 
159
    PT_Band = 10,
 
160
    PT_Composer = 11,
 
161
    PT_Lyricist = 12,
 
162
    PT_RecordingLocation = 13,
 
163
    PT_DuringRecording = 14,
 
164
    PT_DuringPerformance = 15,
 
165
    PT_Video = 16,
 
166
    PT_Fish = 17,
 
167
    PT_Illustration = 18,
 
168
    PT_ArtistLogo = 19,
 
169
    PT_PublisherLogo = 20
 
170
  };
 
171
 
 
172
  /** Tag version contained in track data. */
 
173
  enum TagVersion {
 
174
    TagNone = 0, /**< Empty or imported and not from a tag */
 
175
    TagV1 = 1,   /**< Tag 1 */
 
176
    TagV2 = 2,   /**< Tag 2 */
 
177
    /** Tag 1 and 2 or merged from tag 2 and tag 1 (where tag 2 is not set) */
 
178
    TagV2V1 = TagV1 | TagV2
 
179
  };
 
180
 
95
181
  /** Field in frame. */
96
 
  struct Field {
97
 
    /**
98
 
     * Types of fields in a frame, must be the same as id3lib's ID3_FieldID.
99
 
     **/
100
 
    enum Id {
101
 
      ID_NoField,
102
 
      ID_TextEnc,
103
 
      ID_Text,
104
 
      ID_Url,
105
 
      ID_Data,
106
 
      ID_Description,
107
 
      ID_Owner,
108
 
      ID_Email,
109
 
      ID_Rating,
110
 
      ID_Filename,
111
 
      ID_Language,
112
 
      ID_PictureType,
113
 
      ID_ImageFormat,
114
 
      ID_MimeType,
115
 
      ID_Counter,
116
 
      ID_Id,
117
 
      ID_VolumeAdj,
118
 
      ID_NumBits,
119
 
      ID_VolChgRight,
120
 
      ID_VolChgLeft,
121
 
      ID_PeakVolRight,
122
 
      ID_PeakVolLeft,
123
 
      ID_TimestampFormat,
124
 
      ID_ContentType,
125
 
 
126
 
      // These are additional fields used by TagLib
127
 
      ID_Price,
128
 
      ID_Date,
129
 
      ID_Seller
130
 
    };
131
 
 
132
 
    /** Text encoding for fields of type ID_TextEnc. */
133
 
    enum TextEncoding {
134
 
      TE_ISO8859_1 = 0,
135
 
      TE_UTF16 = 1,
136
 
      TE_UTF16BE = 2,
137
 
      TE_UTF8 = 3
138
 
    };
 
182
  struct KID3_CORE_EXPORT Field {
139
183
 
140
184
#ifdef Q_CC_MSVC
141
185
  /**
151
195
 
152
196
    int m_id;         /**< type of field. */
153
197
    QVariant m_value; /**< value of field. */
 
198
 
 
199
    /**
 
200
     * Get a translated string for a field ID.
 
201
     *
 
202
     * @param type field ID type
 
203
     *
 
204
     * @return field ID type, null string if unknown.
 
205
     */
 
206
    static QString getFieldIdName(FieldId type);
 
207
 
 
208
    /**
 
209
     * List of field ID strings, NULL terminated.
 
210
     */
 
211
    static const char* const* getFieldIdNames();
 
212
 
 
213
    /**
 
214
     * Get a translated string for a text encoding.
 
215
     *
 
216
     * @param type text encoding type
 
217
     *
 
218
     * @return text encoding type, null string if unknown.
 
219
     */
 
220
    static QString getTextEncodingName(TextEncoding type);
 
221
 
 
222
    /**
 
223
     * List of text encoding strings, NULL terminated.
 
224
     */
 
225
    static const char* const* getTextEncodingNames();
 
226
 
 
227
    /**
 
228
     * Get a translated string for a timestamp format.
 
229
     *
 
230
     * @param type timestamp format type
 
231
     *
 
232
     * @return timestamp format type, null string if unknown.
 
233
     */
 
234
    static QString getTimestampFormatName(int type);
 
235
 
 
236
    /**
 
237
     * List of timestamp format strings, NULL terminated.
 
238
     */
 
239
    static const char* const* getTimestampFormatNames();
 
240
 
 
241
    /**
 
242
     * Get a translated string for a content type.
 
243
     *
 
244
     * @param type content type
 
245
     *
 
246
     * @return content type, null string if unknown.
 
247
     */
 
248
    static QString getContentTypeName(int type);
 
249
 
 
250
    /**
 
251
     * List of content type strings, NULL terminated.
 
252
     */
 
253
    static const char* const* getContentTypeNames();
 
254
 
154
255
  };
155
256
 
156
257
  /** list of fields. */
375
476
  void setDifferent() { m_value = differentRepresentation(); }
376
477
 
377
478
  /**
 
479
   * Check if frame is marked.
 
480
   * @return true if marked.
 
481
   */
 
482
  bool isMarked() const { return m_marked; }
 
483
 
 
484
  /**
 
485
   * Mark frame
 
486
   * @param marked true to mark, false to clear mark
 
487
   */
 
488
  void setMarked(bool marked) { m_marked = marked; }
 
489
 
 
490
  /**
378
491
   * Check if value is changed.
379
492
   * @return true if changed.
380
493
   */
428
541
   *
429
542
   * @return field value, invalid if field not found.
430
543
   */
431
 
  QVariant getFieldValue(Field::Id id) const;
 
544
  QVariant getFieldValue(FieldId id) const;
432
545
 
433
546
  /**
434
547
   * Check if the fields in another frame are equal.
479
592
   *
480
593
   * @return true if field found and set.
481
594
   */
482
 
  static bool setField(Frame& frame, Field::Id id, const QVariant& value);
 
595
  static bool setField(Frame& frame, FieldId id, const QVariant& value);
483
596
 
484
597
  /**
485
598
   * Get value of a field.
489
602
   *
490
603
   * @return field value, invalid if not found.
491
604
   */
492
 
  static QVariant getField(const Frame& frame, Field::Id id);
 
605
  static QVariant getField(const Frame& frame, FieldId id);
 
606
 
 
607
  /**
 
608
   * Get type of frame from translated name.
 
609
   *
 
610
   * @param translatedName name, spaces and case are ignored
 
611
   *
 
612
   * @return type.
 
613
   */
 
614
  static Type getTypeFromTranslatedName(const QString& translatedName);
 
615
 
 
616
  /**
 
617
   * Get a translated string for a frame type.
 
618
   *
 
619
   * @param type frame type
 
620
   *
 
621
   * @return frame type, null string if unknown.
 
622
   */
 
623
  static QString getFrameTypeName(Type type);
493
624
 
494
625
private:
495
626
  friend class TaggedFile;
499
630
  QString m_value;
500
631
  FieldList m_fieldList;
501
632
  bool m_valueChanged;
 
633
  bool m_marked;
502
634
};
503
635
 
504
636
/** Filter to enable a subset of frame types. */