~ubuntu-branches/ubuntu/feisty/kid3/feisty

« back to all changes in this revision

Viewing changes to kid3/importselector.h

  • Committer: Bazaar Package Importer
  • Author(s): Aurelien Jarno
  • Date: 2004-04-29 02:11:57 UTC
  • Revision ID: james.westby@ubuntu.com-20040429021157-omrdcw8270prqiun
Tags: upstream-0.4
ImportĀ upstreamĀ versionĀ 0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * \file importselector.h
 
3
 * Import selector widget.
 
4
 *
 
5
 * \b Project: Kid3
 
6
 * \author Urs Fleisch
 
7
 * \date 17 Sep 2003
 
8
 */
 
9
 
 
10
#ifndef IMPORTSELECTOR_H
 
11
#define IMPORTSELECTOR_H
 
12
 
 
13
#include <qvbox.h>
 
14
#include <qstring.h>
 
15
#include <qstringlist.h>
 
16
 
 
17
class QPushButton;
 
18
class QTable;
 
19
class QComboBox;
 
20
class QLineEdit;
 
21
class ImportParser;
 
22
class StandardTags;
 
23
class FreedbDialog;
 
24
class FreedbConfig;
 
25
 
 
26
/**
 
27
 * Import selector widget.
 
28
 */
 
29
class ImportSelector : public QVBox
 
30
{
 
31
Q_OBJECT
 
32
 
 
33
public:
 
34
        /** Import destinations */
 
35
        enum Destination { DestV1, DestV2 };
 
36
 
 
37
        /**
 
38
         * Constructor.
 
39
         *
 
40
         * @param parent parent widget
 
41
         * @param name   Qt name
 
42
         * @param f      window flags
 
43
         */
 
44
        ImportSelector(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
 
45
        /**
 
46
         * Destructor.
 
47
         */
 
48
        ~ImportSelector();
 
49
        /**
 
50
         * Look for album specific information (artist, album, year, genre) in
 
51
         * a header (e.g. in a freedb header).
 
52
         *
 
53
         * @param st standard tags to put resulting values in,
 
54
         *           fields which are not found are not touched.
 
55
         *
 
56
         * @return true if one or more field were found.
 
57
         */
 
58
        bool parseHeader(StandardTags &st);
 
59
        /**
 
60
         * Get next line as standardtags from imported file or clipboard.
 
61
         *
 
62
         * @param st standard tags
 
63
         * @param start true to start with the first line, false for all
 
64
         *              other lines
 
65
         *
 
66
         * @return true if ok (result in st),
 
67
         *         false if end of file reached.
 
68
         */
 
69
        bool getNextTags(StandardTags &st, bool start);
 
70
        /**
 
71
         * Set ID3v1 or ID3v2 tags as import destination.
 
72
         *
 
73
         * @param dest DestV1 or DestV2 for ID3v1 or ID3v2
 
74
         */
 
75
        void setDestination(ImportSelector::Destination dest);
 
76
        /**
 
77
         * Get import destination.
 
78
         *
 
79
         * @return DestV1 or DestV2 for ID3v1 or ID3v2.
 
80
         */
 
81
        Destination getDestination();
 
82
        /**
 
83
         * Set import format regexp.
 
84
         *
 
85
         * @param names   import format names list
 
86
         * @param headers import format header regexps
 
87
         * @param tracks  import format track regexps
 
88
         * @param idx     selected index
 
89
         */
 
90
        void setImportFormat(const QStringList &names,
 
91
                                                 const QStringList &headers,
 
92
                                                 const QStringList &tracks,
 
93
                                                 int idx);
 
94
        /**
 
95
         * Get import format regexp.
 
96
         *
 
97
         * @param name   import format name
 
98
         * @param header import format header regexp
 
99
         * @param track  import format track regexp
 
100
         *
 
101
         * @return index of current selection.
 
102
         */
 
103
        int getImportFormat(QString &names,
 
104
                                                QString &headers,
 
105
                                                QString &tracks) const;
 
106
        /**
 
107
         * Set freedb.org configuration.
 
108
         *
 
109
         * @param cfg freedb configuration.
 
110
         */
 
111
        void setFreedbConfig(const FreedbConfig *cfg);
 
112
        /**
 
113
         * Get freedb.org configuration.
 
114
         *
 
115
         * @param cfg freedb configuration.
 
116
         */
 
117
        void getFreedbConfig(FreedbConfig *cfg) const;
 
118
        /**
 
119
         * List with line formats.
 
120
         * The following codes are used before the () expressions.
 
121
         * %s title (song)
 
122
         * %l album
 
123
         * %a artist
 
124
         * %c comment
 
125
         * %y year
 
126
         * %t track
 
127
         * %g genre
 
128
         */
 
129
        static const char **lineFmtList;
 
130
 
 
131
public slots:
 
132
        /**
 
133
         * Let user select file, assign file contents to text and preview in
 
134
         * table.
 
135
         */
 
136
        void fromFile();
 
137
        /**
 
138
         * Assign clipboard contents to text and preview in table.
 
139
         */
 
140
        void fromClipboard();
 
141
        /**
 
142
         * Import from freedb.org and preview in table.
 
143
         */
 
144
        void fromFreedb();
 
145
        /**
 
146
         * Set the format lineedits to the format selected in the combo box.
 
147
         *
 
148
         * @param index current index of the combo box
 
149
         */
 
150
        void setFormatLineEdit(int index);
 
151
        /**
 
152
         * Called when freedb.org album data is received.
 
153
         *
 
154
         * @param txt text containing album data from freedb.org
 
155
         */
 
156
        void freedbAlbumDataReceived(QString txt);
 
157
private:
 
158
        enum TabColumn {
 
159
                TrackColumn, TitleColumn, ArtistColumn, AlbumColumn,
 
160
                YearColumn, GenreColumn, CommentColumn, NumColumns
 
161
        };
 
162
        enum ImportSource {
 
163
            None, File, Clipboard, Freedb
 
164
        };
 
165
        /**
 
166
         * Show fields to import in text as preview in table.
 
167
         *
 
168
         * @return true if tags were found.
 
169
         */
 
170
        bool showPreview();
 
171
        /** From File button */
 
172
        QPushButton *fileButton;
 
173
        /** From Clipboard button */
 
174
        QPushButton *clipButton;
 
175
        /** From freedb.org button */
 
176
        QPushButton *freedbButton;
 
177
        /** Preview table */
 
178
        QTable *tab;
 
179
        /** contents of imported file/clipboard */
 
180
        QString text;
 
181
        /** combobox with import destinations */
 
182
        QComboBox *destComboBox;
 
183
        /** combobox with import formats */
 
184
        QComboBox *formatComboBox;
 
185
        /** LineEdit for header regexp */
 
186
        QLineEdit *headerLineEdit;
 
187
        /** LineEdit for track regexp */
 
188
        QLineEdit *trackLineEdit;
 
189
        /** header parser object */
 
190
        ImportParser *header_parser;
 
191
        /** track parser object */
 
192
        ImportParser *track_parser;
 
193
        /** header format regexps */
 
194
        QStringList formatHeaders;
 
195
        /** track format regexps */
 
196
        QStringList formatTracks;
 
197
        /** freedb.org import dialog */
 
198
        FreedbDialog *freedbDialog;
 
199
        /** import source */
 
200
        ImportSource importSource;
 
201
        /** freedb config */
 
202
        const FreedbConfig *freedbCfg;
 
203
};
 
204
 
 
205
#endif