~ubuntu-branches/ubuntu/breezy/kdemultimedia/breezy

« back to all changes in this revision

Viewing changes to noatun/noatun/modules/splitplaylist/view.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-03-24 04:48:58 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050324044858-8ff88o9jxej6ii3d
Tags: 4:3.4.0-0ubuntu3
Add kubuntu_02_hide_arts_menu_entries.diff to hide artsbuilder and artscontrol k-menu entries

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * Copyright (c) 2000-2001 Charles Samuels <charles@kde.org>
3
 
 *               2000-2001 Neil Stevens <neil@qualityassistant.com>
4
 
 *
5
 
 * Copyright (c) from the patches of:
6
 
 *               2001 Klas Kalass <klas.kalass@gmx.de>
7
 
 *               2001 Anno v. Heimburg <doktor.dos@gmx.de>
8
 
 **/
9
 
 
10
 
 
11
 
// Abandon All Hope, Ye Who Enter Here
12
 
 
13
 
 
14
 
#include <iostream.h>
15
 
#include <qmap.h>
16
 
 
17
 
#include <qlayout.h>
18
 
#include <klocale.h>
19
 
#include <kdebug.h>
20
 
#include <kstdaction.h>
21
 
#include <qheader.h>
22
 
#include <qdragobject.h>
23
 
#include <kaction.h>
24
 
#include <kmenubar.h>
25
 
#include <kfiledialog.h>
26
 
#include <qtextstream.h>
27
 
#include <noatunapp.h>
28
 
#include <player.h>
29
 
#include <kio/netaccess.h>
30
 
#include <kio/job.h>
31
 
#include <ksimpleconfig.h>
32
 
#include <kstddirs.h>
33
 
#include <kurldrag.h>
34
 
 
35
 
#include "playlist.h"
36
 
#include "view.h"
37
 
#include "find.h"
38
 
 
39
 
#define SPL SplitPlaylist::SPL()
40
 
 
41
 
SafeListViewItem::SafeListViewItem(QListView *parent, QListViewItem *after, const KURL &text)
42
 
        : QCheckListItem(parent,0, QCheckListItem::CheckBox), PlaylistItem(text)
43
 
{
44
 
        
45
 
        static_cast<KListView*>(parent)->moveItem(this, 0, after);
46
 
        setOn(true);
47
 
        setText(0,title());
48
 
        if (!isDownloaded()) setText(1, "0%");
49
 
 
50
 
        SplitPlaylist *p=SPL;
51
 
        if (!(p->currentItem || p->nextItem || p->previousItem))
52
 
                p->setCurrent(this);
53
 
        if (p->currentItem==(SafeListViewItem*)itemAbove())
54
 
                p->setNext(this);
55
 
        if (p->currentItem==(SafeListViewItem*)itemBelow())
56
 
                p->setPrevious(this);
57
 
}
58
 
 
59
 
SafeListViewItem::~SafeListViewItem()
60
 
{
61
 
        if (SPL->nextItem==this)
62
 
                SPL->setNext(static_cast<SafeListViewItem*>(itemBelow()));
63
 
        if (SPL->currentItem==this)
64
 
                SPL->setCurrent(0), SPL->setNext(static_cast<SafeListViewItem*>(itemBelow()));
65
 
        if (SPL->previousItem==this)
66
 
                SPL->setPrevious(static_cast<SafeListViewItem*>(itemAbove()));
67
 
}
68
 
 
69
 
void SafeListViewItem::downloaded(int percent)
70
 
{
71
 
        setText(1, QString::number(percent)+'%');
72
 
}
73
 
 
74
 
void SafeListViewItem::modified()
75
 
{
76
 
        setText(0, title());
77
 
        if (isDownloaded() && length()!=-1)
78
 
                setText(1, lengthString());
79
 
        else if (isDownloaded())
80
 
                setText(1, "");
81
 
}
82
 
 
83
 
void SafeListViewItem::stateChange(bool s)
84
 
{
85
 
        // if you uncheck this, uncheck thet others that
86
 
        // are selected too
87
 
 
88
 
        QList<QListViewItem> list=SPL->view->listView()->selectedItems();
89
 
 
90
 
        // but not if I'm not selected
91
 
        if (list.containsRef(this))
92
 
                for (QListViewItem *i=list.first(); i != 0; i=list.next())
93
 
                        static_cast<QCheckListItem*>(i)->setOn(s);
94
 
        else
95
 
                QCheckListItem::stateChange(s);
96
 
}
97
 
 
98
 
List::List(View *parent)
99
 
        : KListView(parent), recursiveAddAfter(0), listJob(0)
100
 
{
101
 
        addColumn(i18n("File"));
102
 
        addColumn(i18n("Time"));
103
 
        setAcceptDrops(true);
104
 
        setSorting(-1);
105
 
        setDropVisualizer(true);
106
 
        setDragEnabled(true);
107
 
        setItemsMovable(true);
108
 
        setSelectionMode(QListView::Extended);
109
 
        connect(this, SIGNAL(dropped(QDropEvent*, QListViewItem*)), SLOT(dropEvent(QDropEvent*, QListViewItem*)));
110
 
        connect(this, SIGNAL(moved(QList<QListViewItem>&,QList<QListViewItem>&,QList<QListViewItem>&)), SLOT(move(QList<QListViewItem>&,QList<QListViewItem>&,QList<QListViewItem>&)));
111
 
        connect(this, SIGNAL(aboutToMove()), parent, SLOT(setNoSorting()));
112
 
}
113
 
 
114
 
List::~List()
115
 
{
116
 
}
117
 
 
118
 
void List::move(QList<QListViewItem>& item, QList<QListViewItem>&, QList<QListViewItem>&)
119
 
{
120
 
        bool bidimerge=static_cast<bool>(item.containsRef(static_cast<SafeListViewItem*>(SPL->currentItem)));
121
 
        bool current=SPL->currentItem;
122
 
        if (current)
123
 
        {
124
 
                if (bidimerge || item.containsRef(static_cast<SafeListViewItem*>(SPL->previousItem))
125
 
                              || (current && item.containsRef(static_cast<SafeListViewItem*>(SPL->currentItem)->itemAbove())))
126
 
                        SPL->setPrevious(static_cast<SafeListViewItem*>(static_cast<SafeListViewItem*>(SPL->currentItem)->itemAbove()));
127
 
        
128
 
                if (bidimerge || item.containsRef(static_cast<SafeListViewItem*>(SPL->nextItem))
129
 
                              || item.containsRef(static_cast<SafeListViewItem*>(static_cast<SafeListViewItem*>(SPL->currentItem)->itemBelow())))
130
 
                        SPL->setNext(static_cast<SafeListViewItem*>(static_cast<SafeListViewItem*>(SPL->currentItem)->itemBelow()));
131
 
        }
132
 
 
133
 
        
134
 
        emit modified();
135
 
}
136
 
 
137
 
bool List::acceptDrag(QDropEvent *event) const
138
 
{
139
 
        return QUriDrag::canDecode(event) || KListView::acceptDrag(event);
140
 
}
141
 
 
142
 
void List::dropEvent(QDropEvent *event, QListViewItem *after)
143
 
{
144
 
        static_cast<View*>(parent())->setNoSorting();
145
 
        KURL::List textlist;
146
 
        if (!KURLDrag::decode(event, textlist)) return;
147
 
        event->acceptAction();
148
 
        
149
 
        for (KURL::List::Iterator i=textlist.begin(); i != textlist.end(); ++i)
150
 
        {
151
 
                after= addFile(*i, false, after);
152
 
        }
153
 
 
154
 
        emit modified();
155
 
}
156
 
 
157
 
void List::viewportPaintEvent(QPaintEvent *e)
158
 
{
159
 
        KListView::viewportPaintEvent(e);
160
 
        
161
 
        static bool recurse=false;
162
 
        if (!recurse)
163
 
        {
164
 
                QListViewItem *current=static_cast<SafeListViewItem*>(SPL->current());
165
 
                QRect item(itemRect(current).intersect(e->rect()));
166
 
                if (item.isEmpty()) return;
167
 
 
168
 
                QPixmap pix(e->rect().width(), e->rect().height());
169
 
                pix.fill(QColor(255,255,255));
170
 
                
171
 
                recurse=true;
172
 
                viewport()->repaint(item,true);
173
 
                recurse=false;
174
 
        
175
 
                bitBlt(viewport(), item.topLeft(), &pix, QRect(0,0, item.width(), item.height()), XorROP,false);
176
 
        }
177
 
}
178
 
 
179
 
 
180
 
 
181
 
// for m3u files
182
 
QListViewItem *List::openGlobal(const KURL &u, QListViewItem *after)
183
 
{
184
 
        QString local;
185
 
        if(KIO::NetAccess::download(u, local))
186
 
        {
187
 
                QFile saver(local);
188
 
                saver.open(IO_ReadOnly);
189
 
                QTextStream t(&saver);
190
 
                QString file;
191
 
                while (!t.eof())
192
 
                {
193
 
                        file=t.readLine();
194
 
                        if (!file.isNull())
195
 
                        {
196
 
                                KURL u1;
197
 
                                if (file.find('/')) // we have to deal with a relative path
198
 
                                {
199
 
                                        u1.setPath(u.path(0));
200
 
                                        u1.setFileName(file);
201
 
                                }
202
 
                                else
203
 
                                        u1.setPath(file);
204
 
                                after=addFile(u1, false, after);
205
 
                        }
206
 
                }
207
 
                
208
 
                KIO::NetAccess::removeTempFile(local);
209
 
        }
210
 
        return after;
211
 
}
212
 
 
213
 
QListViewItem *List::addFile(const KURL& url, bool play, QListViewItem *after)
214
 
{
215
 
        // when a new item is added, we don't want to sort anymore
216
 
        SPL->view->setNoSorting();
217
 
 
218
 
        // TODO: there must be a better way.. this isn't windows
219
 
        if (url.path().right(4).lower()==".m3u")
220
 
        {
221
 
                // a playlist is requested
222
 
                return openGlobal(url, after);
223
 
        }
224
 
        else
225
 
        {
226
 
                if (!after) after=lastItem();
227
 
                KFileItem fileItem(-1,-1,url);
228
 
                if (fileItem.isDir())
229
 
                {
230
 
                        addDirectoryRecursive(url, after);
231
 
                        return after; // don't (and can't) know better!?
232
 
                }
233
 
                else
234
 
                {
235
 
                        QListViewItem *i=new SafeListViewItem(this, after, url);
236
 
                        if (play)
237
 
                                SPL->listItemSelected(i);
238
 
                        emit modified();
239
 
                        return i;
240
 
                }
241
 
        }
242
 
}
243
 
 
244
 
// starts a new listJob if there is no active but work to do
245
 
void List::addNextPendingDirectory()
246
 
{
247
 
        KURL::List::Iterator pendingIt= pendingAddDirectories.begin();
248
 
        if (!listJob && (pendingIt!= pendingAddDirectories.end()))
249
 
        {
250
 
                currentJobURL= *pendingIt;
251
 
                listJob= KIO::listRecursive(currentJobURL, false);
252
 
                connect(listJob, SIGNAL(entries(KIO::Job*, const KIO::UDSEntryList&)),
253
 
                                SLOT(slotEntries(KIO::Job*, const KIO::UDSEntryList&)));
254
 
                connect(listJob, SIGNAL(result(KIO::Job *)),
255
 
                                SLOT(slotResult(KIO::Job *)));
256
 
                connect(listJob, SIGNAL(redirection(KIO::Job *, const KURL &)),
257
 
                                SLOT(slotRedirection(KIO::Job *, const KURL &)));
258
 
                pendingAddDirectories.remove(pendingIt);
259
 
        }
260
 
}
261
 
 
262
 
void List::addDirectoryRecursive(const KURL &dir, QListViewItem *after)
263
 
{
264
 
        if (!after) after=lastItem();
265
 
        recursiveAddAfter= after;
266
 
        pendingAddDirectories.append(dir);
267
 
        addNextPendingDirectory();
268
 
}
269
 
 
270
 
void List::slotResult(KIO::Job *job)
271
 
{
272
 
        listJob= 0;
273
 
        if (job && job->error())
274
 
                job->showErrorDialog();
275
 
        addNextPendingDirectory();
276
 
}
277
 
 
278
 
void List::slotEntries(KIO::Job *job, const KIO::UDSEntryList &entries)
279
 
{
280
 
        QMap<QString,KURL> __list; // temp list to sort entries
281
 
        
282
 
        KIO::UDSEntryListConstIterator it = entries.begin();
283
 
        KIO::UDSEntryListConstIterator end = entries.end();
284
 
 
285
 
        for (; it != end; ++it)
286
 
        {
287
 
                KFileItem file(*it, currentJobURL, false /* no mimetype detection */, true);
288
 
                // "prudhomm:
289
 
                // insert the path + url in the map to sort automatically by path
290
 
                // note also that you use audiocd to rip your CDs then it will be sorted the right way
291
 
                // now it is an easy fix to have a nice sort BUT it is not the best
292
 
                // we should sort based on the tracknumber"
293
 
                // - copied over from old kdirlister hack <hans_meine@gmx.de>
294
 
                if (!file.isDir())
295
 
                        __list.insert(file.url().path(), file.url());
296
 
        }
297
 
        QMap<QString,KURL>::Iterator __it;
298
 
        for( __it = __list.begin(); __it != __list.end(); ++__it )
299
 
        {
300
 
                recursiveAddAfter= addFile(__it.data(), false, recursiveAddAfter);
301
 
        }
302
 
}
303
 
 
304
 
void List::slotRedirection(KIO::Job *, const KURL & url)
305
 
{
306
 
        currentJobURL= url;
307
 
}
308
 
 
309
 
View::View(SplitPlaylist *)
310
 
        : KMainWindow(0,0)
311
 
{
312
 
        list=new List(this);
313
 
        list->show();
314
 
        setCentralWidget(list);
315
 
        connect(list, SIGNAL(modified(void)), this, SLOT(setModified(void)) );
316
 
        // connect the click on the header with sorting
317
 
        connect(list->header(),SIGNAL(clicked(int)),this,SLOT(headerClicked(int)) );
318
 
 
319
 
        tb = new KToolBar( this );
320
 
        addToolBar(tb);
321
 
 
322
 
        (mOpen=new KAction(i18n("Add &Files"), "queue", 0, this, SLOT(addFiles()),this, "open"))->plug(tb);
323
 
        (mDelete=new KAction(i18n("Delete"), "editdelete", Qt::Key_Delete, this, SLOT(deleteSelected()), this, "delete"))->plug(tb);
324
 
        (new KAction(i18n("Add &Directories"), "folder", 0, this, SLOT(addDirectory()), this, "add_dir"))->plug(tb);
325
 
 
326
 
        (new KActionSeparator(this))->plug(tb);
327
 
 
328
 
        (mFind=KStdAction::find(this, SLOT(find()), this, "find"))->plug(tb);
329
 
 
330
 
        (new KActionSeparator(this))->plug(tb);
331
 
 
332
 
        (mSave=KStdAction::save(this, SLOT(save()), this, "save"))->plug(tb);
333
 
        (mSaveAs=KStdAction::saveAs(this, SLOT(saveAs()), this, "saveas"))->plug(tb);
334
 
        (mOpenpl=KStdAction::open(this, SLOT(open()), this, "open"))->plug(tb);
335
 
        (mOpenNew=KStdAction::openNew(this, SLOT(openNew()), this, "openNew"))->plug(tb);
336
 
        (new KAction(i18n("Shuffle"), "misc", 0, SPL, SLOT( randomize() ), this, "clear"))->plug(tb);
337
 
//      (new KAction(i18n("Sort"),"queue",0,SPL,SLOT(sort()),this))->plug(tb);
338
 
        (new KAction(i18n("Clear"), "fileclose", 0, this, SLOT( clearView() ), this, "clear"))->plug(tb);
339
 
        list->setFocus();
340
 
}
341
 
 
342
 
void View::find()
343
 
{
344
 
        Finder *f=new Finder(this);
345
 
        f->show();
346
 
        connect(f, SIGNAL(search(Finder*)), SLOT(findIt(Finder*)));
347
 
}
348
 
 
349
 
static bool testWord(QListViewItem *i, const QString &finder)
350
 
{
351
 
        PlaylistItem *item=static_cast<SafeListViewItem*>(i);
352
 
        if (item->title().find(finder, 0, false) >=0)
353
 
                return true;
354
 
        if (item->file().find(finder, 0, false) >=0)
355
 
                return true;
356
 
        if (item->url().path().find(finder.local8Bit(), 0, false) >=0)
357
 
                return true;
358
 
        if (item->lengthString().find(finder, 0, false) >=0)
359
 
                return true;
360
 
        if (item->mimetype().find(finder.local8Bit(), 0, false) >=0)
361
 
                return true;
362
 
        return false;
363
 
}
364
 
 
365
 
static bool testWord(QListViewItem *i, const QRegExp &finder)
366
 
{
367
 
        PlaylistItem *item=static_cast<SafeListViewItem*>(i);
368
 
        if (item->title().find(finder) >=0)
369
 
                return true;
370
 
        if (item->file().find(finder) >=0)
371
 
                return true;
372
 
        if (item->url().path().find(finder) >=0)
373
 
                return true;
374
 
        if (item->lengthString().find(finder) >=0)
375
 
                return true;
376
 
        if (item->mimetype().find(finder) >=0)
377
 
                return true;
378
 
        return false;
379
 
}
380
 
 
381
 
void View::findIt(Finder *f)
382
 
{
383
 
        QListViewItem *search=list->currentItem();
384
 
                
385
 
        if (!search)
386
 
                if (f->isForward())
387
 
                        search=list->firstChild();
388
 
                else
389
 
                        search=list->lastChild();
390
 
 
391
 
        while (search)
392
 
        {
393
 
                if (f->isForward())
394
 
                        search=search->itemBelow();
395
 
                else
396
 
                        search=search->itemAbove();
397
 
 
398
 
                if (!search) return;
399
 
                if (f->regexp())
400
 
                {
401
 
                        if (testWord(search, QRegExp(f->string(), false)))
402
 
                                break;
403
 
                }
404
 
                else
405
 
                {       
406
 
                        if (testWord(search, f->string()))
407
 
                                break;
408
 
                }
409
 
 
410
 
        }
411
 
 
412
 
        if (search)
413
 
        {
414
 
                { // select none
415
 
                        QList<QListViewItem> sel=list->selectedItems();
416
 
                        for (QListViewItem *i=sel.first(); i!=0; i=sel.next())
417
 
                                list->setSelected(i, false);
418
 
                }
419
 
                list->setSelected(search, true);
420
 
                list->setCurrentItem(search);
421
 
                list->ensureItemVisible(search);
422
 
        }
423
 
}
424
 
 
425
 
View::~View()
426
 
{
427
 
        hide();
428
 
        saveState();
429
 
        delete list;
430
 
        delete tb;
431
 
        mOpen->unplug(tb);
432
 
        mDelete->unplug(tb);
433
 
}
434
 
 
435
 
void View::init()
436
 
{
437
 
        KURL internalURL;
438
 
        internalURL.setPath(napp->dirs()->saveLocation("data", "noatun/") + "splitplaylistdata");
439
 
        list->openGlobal(internalURL);
440
 
 
441
 
        KConfig &config = *KGlobal::config();
442
 
        config.setGroup("splitplaylist");
443
 
 
444
 
        // this has to come after openGlobal, since openGlobal emits modified()
445
 
        setModified(config.readBoolEntry("modified", false));
446
 
        mPlaylistFile.setPath(config.readEntry("file", QString::null));
447
 
 
448
 
        SPL->reset();
449
 
        int saved = config.readNumEntry("current", 0);
450
 
 
451
 
        PlaylistItem *item=SPL->getFirst();
452
 
        for(int i = 0 ; i < saved ; i++)
453
 
        {
454
 
                item=SPL->getAfter(item);
455
 
        }
456
 
        if (item)
457
 
                SPL->setCurrent(item);
458
 
}
459
 
 
460
 
void View::save()
461
 
{
462
 
        if (mPlaylistFile.isMalformed()) { saveAs(); return; }
463
 
        saveToURL(mPlaylistFile);
464
 
        setModified(false);
465
 
}
466
 
 
467
 
void View::saveAs()
468
 
{
469
 
        KURL u=KFileDialog::getSaveURL(0, "*.m3u\n*", this, i18n("Save Playlist"));
470
 
        if (u.isMalformed()) return;
471
 
        mPlaylistFile = u;
472
 
        save();
473
 
}
474
 
 
475
 
void View::open()
476
 
{
477
 
        KURL u=KFileDialog::getOpenURL(0, "*.m3u\n*", this, i18n("Insert Playlist"));
478
 
        if (u.isMalformed()) return;
479
 
        list->openGlobal(u);
480
 
        setModified(false);
481
 
}
482
 
 
483
 
void View::openNew()
484
 
{
485
 
        KURL u=KFileDialog::getOpenURL(0, "*.m3u\n*", this, i18n("Open New Playlist"));
486
 
        if (u.isMalformed()) return;
487
 
        mPlaylistFile = u;
488
 
 
489
 
        listView()->clear();
490
 
        list->openGlobal(mPlaylistFile);
491
 
 
492
 
        setModified(false);
493
 
}
494
 
 
495
 
void View::deleteSelected()
496
 
{
497
 
        QList<QListViewItem> items(list->selectedItems());
498
 
        for (QListIterator<QListViewItem> it(items); it.current(); ++it)
499
 
                delete *it;
500
 
 
501
 
        setModified(true);
502
 
}
503
 
 
504
 
void View::addFiles()
505
 
{
506
 
        KURL::List files=KFileDialog::getOpenURLs(0, napp->mimeTypes(), this, i18n("Select a File to Play"));
507
 
 
508
 
        for(KURL::List::Iterator it=files.begin(); it!=files.end(); ++it)
509
 
                addFile(KURL(*it));
510
 
        
511
 
        setModified(true);
512
 
}
513
 
 
514
 
void View::addDirectory()
515
 
{
516
 
        QString file=KFileDialog::getExistingDirectory(0, this, i18n("Select a Directory"));
517
 
 
518
 
        if (!file) return;
519
 
        KURL url;
520
 
        url.setPath(file);
521
 
        list->addDirectoryRecursive(url);
522
 
        
523
 
        setModified(true);
524
 
}
525
 
 
526
 
void View::closeEvent(QCloseEvent*)
527
 
{
528
 
        hide();
529
 
}
530
 
 
531
 
void View::showEvent(QShowEvent *)
532
 
{
533
 
        emit shown();
534
 
}
535
 
 
536
 
void View::hideEvent(QHideEvent *)
537
 
{
538
 
        emit hidden();
539
 
}
540
 
 
541
 
void View::setModified(bool b)
542
 
{
543
 
        modified = b;
544
 
        setCaption(i18n("Playlist"), modified);
545
 
}
546
 
 
547
 
void View::setModified(void)
548
 
{
549
 
        setModified(true);
550
 
}
551
 
 
552
 
void View::saveToURL(const KURL &url)
553
 
{
554
 
        QString local(napp->tempSaveName(url.path()));
555
 
        QFile saver(local);
556
 
        saver.open(IO_ReadWrite | IO_Truncate);
557
 
        QTextStream t(&saver);
558
 
        // navigate the list
559
 
        for (SafeListViewItem *i=static_cast<SafeListViewItem*>(listView()->firstChild());
560
 
             i != 0; i=static_cast<SafeListViewItem*>(i->itemBelow()))
561
 
                t<< *i << '\n';
562
 
        saver.close();
563
 
 
564
 
        KIO::NetAccess::upload(local, url);
565
 
 
566
 
        saver.remove();
567
 
}
568
 
 
569
 
void View::saveState(void)
570
 
{
571
 
        KConfig &config = *KGlobal::config();
572
 
        config.setGroup("splitplaylist");
573
 
 
574
 
        config.writeEntry("modified", modified);
575
 
        config.writeEntry("file", mPlaylistFile.path());
576
 
        saveToURL(napp->dirs()->saveLocation("data", "noatun/") + "splitplaylistdata");
577
 
 
578
 
        int i;
579
 
        PlaylistItem *item=SPL->getFirst();
580
 
        for(i = 0; item != SPL->current(); )
581
 
                item=SPL->getAfter(item), i++;
582
 
 
583
 
        config.writeEntry("current", i);
584
 
 
585
 
        config.sync();
586
 
}
587
 
 
588
 
// turns the sorting on or off
589
 
void View::setSorting(bool on, int column)
590
 
{
591
 
        if (on)
592
 
        {
593
 
                list->setSorting(column,true);
594
 
                list->setShowSortIndicator(true);
595
 
        }
596
 
        else
597
 
        {
598
 
                list->setShowSortIndicator(false);
599
 
                list->setSorting(-1);
600
 
        }
601
 
}
602
 
 
603
 
void View::headerClicked(int column)
604
 
{
605
 
        /* this is to avoid that if we already have it sorted, we sort it again ascendingly
606
 
           this way, clicking on the header a second time will correctly toggle ascending/descending sort */
607
 
        if (list-> showSortIndicator())
608
 
        {
609
 
                return;
610
 
        }
611
 
        else
612
 
        {
613
 
                setSorting(true,column);
614
 
        }
615
 
}
616
 
 
617
 
#include "view.moc"
618