~ubuntu-branches/ubuntu/intrepid/kid3/intrepid

« back to all changes in this revision

Viewing changes to kid3/filelistitem.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michele Angrisano
  • Date: 2008-01-09 23:20:54 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20080109232054-gtcjxz4ahdnzbt01
Tags: 0.10-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/rules:
    + Use dh_icons instead dh_iconcache.
  - debian/control:
    + Update maintainer field.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 * \b Project: Kid3
6
6
 * \author Urs Fleisch
7
7
 * \date 02 Oct 2006
 
8
 *
 
9
 * Copyright (C) 2006-2007  Urs Fleisch
 
10
 *
 
11
 * This file is part of Kid3.
 
12
 *
 
13
 * Kid3 is free software; you can redistribute it and/or modify
 
14
 * it under the terms of the GNU General Public License as published by
 
15
 * the Free Software Foundation; either version 2 of the License, or
 
16
 * (at your option) any later version.
 
17
 *
 
18
 * Kid3 is distributed in the hope that it will be useful,
 
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
21
 * GNU General Public License for more details.
 
22
 *
 
23
 * You should have received a copy of the GNU General Public License
 
24
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
8
25
 */
9
26
 
10
27
#include "filelistitem.h"
117
134
/** picture with V1 and V2 */
118
135
static const char* const v1v2_xpm[] = {
119
136
        "16 16 3 1",
120
 
        "       c None",
121
 
        ".      c #000000",
122
 
        "+      c #FFFFFF",
123
 
        "                ",
124
 
        "                ",
125
 
        "   .   .   .    ",
126
 
        "   .   .  ..    ",
127
 
        "    . .  . .    ",
128
 
        "    . .    .    ",
129
 
        "     .     .    ",
130
 
        "                ",
131
 
        "                ",
132
 
        "   .   .  ..    ",
133
 
        "   .   . .  .   ",
134
 
        "    . .    .    ",
135
 
        "    . .   .     ",
136
 
        "     .   ....   ",
 
137
        "  c None",
 
138
        ". c #FFFFFF",
 
139
        "+ c #000000",
 
140
        "                ",
 
141
        "  ..  ..   .    ",
 
142
        "  .+  .+  .+    ",
 
143
        "  .+  .+ .++    ",
 
144
        "   .+.+ .+.+    ",
 
145
        "   .+.+   .+    ",
 
146
        "    .+    .+    ",
 
147
        "                ",
 
148
        "  ..  ..  ..    ",
 
149
        "  .+  .+ .++.   ",
 
150
        "  .+  .+.+ .+   ",
 
151
        "   .+.+   .+    ",
 
152
        "   .+.+  .+..   ",
 
153
        "    .+  .++++   ",
137
154
        "                ",
138
155
        "                "};
139
156
 
140
157
/** picture with V1 */
141
158
static const char* const v1_xpm[] = {
142
159
        "16 16 3 1",
143
 
        "       c None",
144
 
        ".      c #000000",
145
 
        "+      c #FFFFFF",
146
 
        "                ",
147
 
        "                ",
148
 
        "   .   .   .    ",
149
 
        "   .   .  ..    ",
150
 
        "    . .  . .    ",
151
 
        "    . .    .    ",
152
 
        "     .     .    ",
 
160
        "  c None",
 
161
        ". c #FFFFFF",
 
162
        "+ c #000000",
 
163
        "                ",
 
164
        "  ..  ..   .    ",
 
165
        "  .+  .+  .+    ",
 
166
        "  .+  .+ .++    ",
 
167
        "   .+.+ .+.+    ",
 
168
        "   .+.+   .+    ",
 
169
        "    .+    .+    ",
153
170
        "                ",
154
171
        "                ",
155
172
        "                ",
163
180
/** picture with V2 */
164
181
static const char* const v2_xpm[] = {
165
182
        "16 16 3 1",
166
 
        "       c None",
167
 
        ".      c #000000",
168
 
        "+      c #FFFFFF",
169
 
        "                ",
170
 
        "                ",
171
 
        "                ",
172
 
        "                ",
173
 
        "                ",
174
 
        "                ",
175
 
        "                ",
176
 
        "                ",
177
 
        "                ",
178
 
        "   .   .  ..    ",
179
 
        "   .   . .  .   ",
180
 
        "    . .    .    ",
181
 
        "    . .   .     ",
182
 
        "     .   ....   ",
 
183
        "  c None",
 
184
        ". c #FFFFFF",
 
185
        "+ c #000000",
 
186
        "                ",
 
187
        "                ",
 
188
        "                ",
 
189
        "                ",
 
190
        "                ",
 
191
        "                ",
 
192
        "                ",
 
193
        "                ",
 
194
        "  ..  ..  ..    ",
 
195
        "  .+  .+ .++.   ",
 
196
        "  .+  .+.+ .+   ",
 
197
        "   .+.+   .+    ",
 
198
        "   .+.+  .+..   ",
 
199
        "    .+  .++++   ",
183
200
        "                ",
184
201
        "                "};
185
202
 
186
203
/** picture with NO TAG */
187
204
static const char* const notag_xpm[] = {
188
205
        "16 16 3 1",
189
 
        "       c None",
190
 
        ".      c #000000",
191
 
        "+      c #FFFFFF",
192
 
        "                ",
193
 
        "                ",
194
 
        "   .   .  ..    ",
195
 
        "   ..  . .  .   ",
196
 
        "   . . . .  .   ",
197
 
        "   .  .. .  .   ",
198
 
        "   .   .  ..    ",
199
 
        "                ",
200
 
        "                ",
201
 
        "  ...  .   ..   ",
202
 
        "   .  . . .     ",
203
 
        "   .  ... . ..  ",
204
 
        "   .  . . .  .  ",
205
 
        "   .  . .  ..   ",
 
206
        "  c None",
 
207
        ". c #FFFFFF",
 
208
        "+ c #000000",
 
209
        "                ",
 
210
        "  ..  ..  ..    ",
 
211
        "  .+. .+ .++.   ",
 
212
        "  .++..+.+ .+   ",
 
213
        "  .+.+.+.+ .+   ",
 
214
        "  .+ .++.+..+   ",
 
215
        "  .+  .+ .++    ",
 
216
        "                ",
 
217
        " ....  .   ..   ",
 
218
        " .+++ .+. .++   ",
 
219
        "  .+ .+.+.+ ..  ",
 
220
        "  .+ .+++.+.++  ",
 
221
        "  .+ .+.+.+..+  ",
 
222
        "  .+ .+.+ .++   ",
206
223
        "                ",
207
224
        "                "};
208
225
 
209
226
/** picture with closed folder */
210
227
static const char* folder_closed_xpm[]={
211
228
        "16 16 10 1",
212
 
        "       c #0E279A",
213
 
        ".      c #2852AF",
214
 
        "+      c #2B66D3",
215
 
        "@      c #2A83FE",
216
 
        "#      c #627CB1",
217
 
        "$      c #5FA1FC",
218
 
        "%      c #B0B2CA",
219
 
        "&      c #89BEF9",
220
 
        "*      c #CDE9FD",
221
 
        "=      c #FCFFFC",
 
229
        "  c #0E279A",
 
230
        ". c #2852AF",
 
231
        "+ c #2B66D3",
 
232
        "@ c #2A83FE",
 
233
        "# c #627CB1",
 
234
        "$ c #5FA1FC",
 
235
        "% c #B0B2CA",
 
236
        "& c #89BEF9",
 
237
        "* c #CDE9FD",
 
238
        "= c #FCFFFC",
222
239
        "==++++++========",
223
240
        "=+======+=======",
224
241
        "+==*=*==#++++++=",
239
256
/** picture with open folder */
240
257
static const char* folder_open_xpm[]={
241
258
        "16 16 10 1",
242
 
        "       c #0E279A",
243
 
        ".      c #2852AF",
244
 
        "+      c #2B66D3",
245
 
        "@      c #2A83FE",
246
 
        "#      c #627CB1",
247
 
        "$      c #5FA1FC",
248
 
        "%      c #B0B2CA",
249
 
        "&      c #89BEF9",
250
 
        "*      c #CDE9FD",
251
 
        "=      c #FCFFFC",
 
259
        "  c #0E279A",
 
260
        ". c #2852AF",
 
261
        "+ c #2B66D3",
 
262
        "@ c #2A83FE",
 
263
        "# c #627CB1",
 
264
        "$ c #5FA1FC",
 
265
        "% c #B0B2CA",
 
266
        "& c #89BEF9",
 
267
        "* c #CDE9FD",
 
268
        "= c #FCFFFC",
252
269
        "==++++++========",
253
270
        "=+======+=======",
254
271
        "+==*=*==#++++++=",
275
292
 */
276
293
FileListItem::FileListItem(FileList* parent, FileListItem* after,
277
294
                                                                                                         TaggedFile* file) :
278
 
        Q3ListViewItem(parent, after), m_file(file), m_dirInfo(0)
 
295
#if QT_VERSION >= 0x040000
 
296
        QTreeWidgetItem(parent, after),
 
297
#else
 
298
        QListViewItem(parent, after),
 
299
#endif
 
300
        m_file(file), m_dirInfo(0)
279
301
{
280
302
        init();
281
303
}
289
311
 */
290
312
FileListItem::FileListItem(FileListItem* parent, FileListItem* after,
291
313
                                                                                                         TaggedFile* file) :
292
 
        Q3ListViewItem(parent, after), m_file(file), m_dirInfo(0)
 
314
#if QT_VERSION >= 0x040000
 
315
        QTreeWidgetItem(parent, after), m_isOpen(false),
 
316
#else
 
317
        QListViewItem(parent, after),
 
318
#endif
 
319
        m_file(file), m_dirInfo(0)
293
320
{
294
321
        init();
295
322
}
345
372
        delete m_dirInfo;
346
373
}
347
374
 
 
375
#if QT_VERSION >= 0x040000
 
376
/**
 
377
 * Opens or closes an item.
 
378
 *
 
379
 * @param o true to open
 
380
 */
 
381
void FileListItem::setOpen(bool o)
 
382
{
 
383
        if (m_dirInfo) {
 
384
                m_isOpen = o;
 
385
                setIcon(0, o ? *folderOpenPixmap : *folderClosedPixmap);
 
386
 
 
387
                if (o  && !childCount()) {
 
388
                        treeWidget()->setUpdatesEnabled(false);
 
389
                        FileList::readSubDirectory(m_dirInfo, this, 0);
 
390
                        treeWidget()->setUpdatesEnabled(true);
 
391
                }
 
392
                updateIcons();
 
393
        }
 
394
}
 
395
#else
348
396
/**
349
397
 * Paints the contents of one column of an item.
350
398
 *
360
408
        if (Kid3App::s_miscCfg.m_markTruncations &&
361
409
                        column == 0 && m_file && m_file->getTruncationFlags() != 0) {
362
410
                QColorGroup g(cg);
363
 
#if QT_VERSION >= 0x040000
364
 
                g.setColor(QPalette::Window, Qt::red);
365
 
#else
366
411
                g.setColor(QColorGroup::Base, Qt::red);
367
 
#endif
368
 
                Q3ListViewItem::paintCell(p, g, column, width, align);
 
412
                QListViewItem::paintCell(p, g, column, width, align);
369
413
        } else {
370
 
                Q3ListViewItem::paintCell(p, cg, column, width, align);
 
414
                QListViewItem::paintCell(p, cg, column, width, align);
371
415
        }
372
416
}
373
417
 
401
445
        }
402
446
        QListViewItem::setup();
403
447
}
 
448
#endif
404
449
 
405
450
/**
406
451
 * Set tagged file.
449
494
{
450
495
        if (m_file) {
451
496
                if (m_file->isChanged()) {
452
 
                        setPixmap(0, *modifiedPixmap);
 
497
                        QCM_setIcon(0, *modifiedPixmap);
453
498
                } else {
454
499
                        static const QPixmap* tagpm[] = {
455
500
                                notagPixmap, v1Pixmap, v2Pixmap, v1v2Pixmap, nullPixmap
466
511
                                        tagpmIdx |= 2;
467
512
                                }
468
513
                        }
469
 
                        setPixmap(0, *tagpm[tagpmIdx]);
470
 
                }
 
514
                        QCM_setIcon(0, *tagpm[tagpmIdx]);
 
515
                }
 
516
#if QT_VERSION >= 0x040200
 
517
                if (Kid3App::s_miscCfg.m_markTruncations &&
 
518
                                m_file->getTruncationFlags() != 0) {
 
519
                        setBackground(0, Qt::red);
 
520
                } else {
 
521
                        setBackground(0, Qt::NoBrush);
 
522
                }
 
523
#elif QT_VERSION >= 0x040000
 
524
                if (Kid3App::s_miscCfg.m_markTruncations &&
 
525
                                m_file->getTruncationFlags() != 0) {
 
526
                        setBackgroundColor(0, Qt::red);
 
527
                } else {
 
528
                        setBackgroundColor(0, QColor());
 
529
                }
 
530
#endif
471
531
        }
472
532
}
473
533
 
496
556
                setOpen(false);
497
557
        }
498
558
}
 
559
 
 
560
#if QT_VERSION >= 0x040000
 
561
/**
 
562
 * Check if QTreeWidgetItem is selected.
 
563
 *
 
564
 * @return true if selected.
 
565
 */
 
566
bool FileListItem::isSelected() const
 
567
{
 
568
        const QTreeWidget* tree = treeWidget();
 
569
        return tree && tree->isItemSelected(this);
 
570
}
 
571
#endif