summaryrefslogtreecommitdiffstats
path: root/ksquirrel/sq_widgetstack.cpp
blob: 6394a936db9c07c2ef7669476e696327174cf14d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
/***************************************************************************
                          sq_widgetstack.cpp  -  description
                             -------------------
    begin                : Mon Mar 15 2004
    copyright            : (C) 2004 by Baryshev Dmitry
    email                : ksquirrel.iv@gmail.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <tqlabel.h>
#include <tqbuttongroup.h>
#include <tqpushbutton.h>
#include <tqtoolbutton.h>
#include <tqtimer.h>
#include <tqapplication.h>

#include <kaction.h>
#include <kcombobox.h>
#include <kstandarddirs.h>
#include <kstdaccel.h>
#include <klocale.h>
#include <kio/job.h>
#include <kfiledialog.h>
#include <kmessagebox.h>
#include <kstringhandler.h>

#include "ksquirrel.h"
#include "sq_config.h"
#include "sq_fileiconview.h"
#include "sq_filethumbview.h"
#include "sq_filedetailview.h"
#include "sq_widgetstack.h"
#include "sq_externaltool.h"
#include "sq_treeview.h"
#include "sq_hloptions.h"
#include "sq_archivehandler.h"
#include "sq_glview.h"
#include "sq_glwidget.h"
#include "sq_libraryhandler.h"
#include "sq_diroperator.h"
#include "sq_bookmarkowner.h"
#include "sq_thumbnailsize.h"
#include "sq_progressbox.h"
#include "sq_thumbnailloadjob.h"
#include "sq_pixmapcache.h"
#include "sq_selectdeselectgroup.h"
#include "sq_navigatordropmenu.h"

SQ_WidgetStack * SQ_WidgetStack::m_instance = 0;

SQ_WidgetStack::SQ_WidgetStack(TQWidget *tqparent, const int id) : TQObject(tqparent)
{
    m_instance = this;

    SQ_DirOperator::ViewT m_type = static_cast<SQ_DirOperator::ViewT>(id);

    KURL url;

    // Check Options for path
    SQ_Config::instance()->setGroup("Fileview");

    if(SQ_HLOptions::instance()->dir.isEmpty())
    {
        switch(SQ_Config::instance()->readNumEntry("set path", 0))
        {
            case 0: url = KURL::fromPathOrURL(SQ_Config::instance()->readEntry("last visited", "/")); break;
            case 1: url = KURL::fromPathOrURL(TQDir::current().path()); break;
            case 2: url = KURL::fromPathOrURL(SQ_Config::instance()->readEntry("custom directory", "/")); break;

            default: url = KURL::fromPathOrURL("/");
        }
    }
    else // path from command line
        url = SQ_HLOptions::instance()->dir;

    dirop = new SQ_DirOperator(url, static_cast<SQ_DirOperator::ViewT>(id), tqparent);

    raiseWidget(m_type, false);

    connect(KSquirrel::app(), TQT_SIGNAL(thumbSizeChanged(const TQString&)), dirop, TQT_SLOT(slotSetThumbSize(const TQString&)));
    connect(dirop, TQT_SIGNAL(runSeparately(KFileItem *)), this, TQT_SLOT(slotRunSeparately()));

    KSquirrel::app()->historyCombo()->setEditText(url.isLocalFile() ? url.path() : url.prettyURL());

    timerShowProgress = new TQTimer(this);
    connect(timerShowProgress, TQT_SIGNAL(timeout()), this, TQT_SLOT(slotDelayedShowProgress()));
}

SQ_WidgetStack::~SQ_WidgetStack()
{}

/*
 *  Get current url of visible diroperator.
 */
KURL SQ_WidgetStack::url() const
{
    return dirop->url();
}

void SQ_WidgetStack::init()
{
    SQ_Config::instance()->setGroup("Fileview");

    fileaction = static_cast<SQ_WidgetStack::FileAction>(SQ_Config::instance()->readNumEntry("last_action", SQ_WidgetStack::Unknown));
    KURL uu = KURL::fromPathOrURL(SQ_Config::instance()->readEntry("last_url"));

    connect(SQ_NavigatorDropMenu::instance(), TQT_SIGNAL(done(const KURL &, int)),
            this, TQT_SLOT(slotTreeMenuDone(const KURL &, int)));

    emitNewLastURL(uu);
}

void SQ_WidgetStack::slotTreeMenuDone(const KURL &url, int a)
{
    if(a == SQ_NavigatorDropMenu::Copy)
        fileaction = SQ_WidgetStack::Copy;
    else if(a == SQ_NavigatorDropMenu::Move)
        fileaction = SQ_WidgetStack::Cut;
    else if(a == SQ_NavigatorDropMenu::Link)
        fileaction = SQ_WidgetStack::Link;

    lastURL = url;

    emitNewLastURL(lastURL);
}

void SQ_WidgetStack::setURL(const KURL &newurl, bool parseTree)
{
    KURL url = newurl;
    url.adjustPath(+1);

    // update bookmarks' url
    if(SQ_BookmarkOwner::instance())
        SQ_BookmarkOwner::instance()->setURL(url);

    // update history combobox
    KSquirrel::app()->historyCombo()->setEditText(url.isLocalFile() ? url.path() : url.prettyURL());
    KSquirrel::app()->historyCombo()->addToHistory(url.isLocalFile() ? url.path() : url.prettyURL());

    // set url for file tree
    if(SQ_TreeView::instance() && parseTree)
    {
        SQ_Config::instance()->setGroup("Fileview");
        int sync_type = SQ_Config::instance()->readNumEntry("sync type", 0);

        if(sync_type != 2)
            SQ_TreeView::instance()->emitNewURL(url);
    }
}

/*
 *  Select next/prevous supported image in filemanager.
 *  Do nothing, if no more supported images found in given
 *  direction.
 */
int SQ_WidgetStack::moveTo(Direction direction, KFileItem *it, bool useSupported)
{
    KFileView *local;
    KFileItem *item;

    // current fileview
    local = dirop->view();

    if(it)
        item = it;
    else
        item = (direction == SQ_WidgetStack::Next)?
                    local->nextItem(local->currentFileItem()):
                    local->prevItem(local->currentFileItem());

    if(!item)
        return moveFailed;

    if(useSupported)
    {
        while(true)
        {
            if(item->isFile())
                // supported image type ?
//                if(SQ_LibraryHandler::instance()->libraryForFile(item->url().path()))
                if(SQ_LibraryHandler::instance()->maybeSupported(item->url()) != SQ_LibraryHandler::No)
                    break;

            item = (direction == SQ_WidgetStack::Next)?
                    (local->nextItem(item)):
                    (local->prevItem(item));

            if(!item)
                return moveFailed;
        }
    }

    // set current file, select it
    dirop->setCurrentItem(item);

    return moveSuccess;
}

/*
 *  Set filter.
 */
void SQ_WidgetStack::setNameFilter(const TQString &f)
{
    dirop->setNameFilter(f);
    dirop->actionCollection()->action("reload")->activate();
}

/*
 *  Get current filter.
 */
TQString SQ_WidgetStack::nameFilter() const
{
    return dirop->nameFilter();
}

/*
 *  Change view type. See SQ_DirOperator::ViewT for more.
 */
void SQ_WidgetStack::raiseWidget(SQ_DirOperator::ViewT id, bool doUpdate)
{
    if(doUpdate) dirop->stopThumbnailUpdate();

    dirop->removeCdUpItem();
    dirop->prepareView(id);

    switch(id)
    {
        case SQ_DirOperator::TypeList:
        case SQ_DirOperator::TypeIcons:
        {
            SQ_FileIconView *iv = dynamic_cast<SQ_FileIconView *>(dirop->preparedView());

            dirop->setPreparedView();
            iv->setSelectionMode(KFile::Extended);
            action("short view")->activate();

            if(id == SQ_DirOperator::TypeList)
                iv->actionCollection()->action("small columns")->activate();
            else
                iv->actionCollection()->action("large rows")->activate();
        }
        break;

        case SQ_DirOperator::TypeDetailed:
        {
            SQ_FileDetailView *dv = dynamic_cast<SQ_FileDetailView *>(dirop->preparedView());

            dirop->setPreparedView();
            dv->setSelectionMode(KFile::Extended);
        }
        break;

        case SQ_DirOperator::TypeThumbs:
        {
            SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(dirop->preparedView());
            tv->actionCollection()->action("large rows")->activate();
            dirop->setPreparedView();
            action("short view")->activate();
            tv->setSelectionMode(KFile::Extended);
            updateGrid(true);
            if(doUpdate) dirop->startOrNotThumbnailUpdate();
        }
        break;
    }

    // enable/disable menu with thumbnail sizes
    KSquirrel::app()->enableThumbsMenu(id == SQ_DirOperator::TypeThumbs);
    dirop->enableThumbnailActions(id == SQ_DirOperator::TypeThumbs);
    dirop->selectOld();
}

/*
 *  Selected items in currently visible diroperator.
 */
const KFileItemList* SQ_WidgetStack::selectedItems() const
{
    return dirop->view()->selectedItems();
}

/*
 *  All items in currently visible diroperator.
 */
const KFileItemList* SQ_WidgetStack::items() const
{
    return dirop->view()->items();
}

void SQ_WidgetStack::emitNextSelected()
{
    if(moveTo(SQ_WidgetStack::Next) == SQ_WidgetStack::moveSuccess)
    {
        KFileItem *fi = dirop->view()->currentFileItem();
        SQ_GLWidget::window()->setExpectedURL(fi->url());
        dirop->execute(fi);
    }
}

void SQ_WidgetStack::emitPreviousSelected()
{
    if(moveTo(SQ_WidgetStack::Previous) == SQ_WidgetStack::moveSuccess)
    {
        KFileItem *fi = dirop->view()->currentFileItem();
        SQ_GLWidget::window()->setExpectedURL(fi->url());
        dirop->execute(fi);
    }
}

void SQ_WidgetStack::slotSelectFirstFile()
{
    moveToFirstLast(SQ_WidgetStack::Next, false);
}

void SQ_WidgetStack::slotSelectLastFile()
{
    moveToFirstLast(SQ_WidgetStack::Previous, false);
}

// Go to first file
void SQ_WidgetStack::firstFile()
{
    moveToFirstLast(SQ_WidgetStack::Next);
}

// Go to last file
void SQ_WidgetStack::lastFile()
{
    moveToFirstLast(SQ_WidgetStack::Previous);
}

void SQ_WidgetStack::moveToFirstLast(Direction direct, bool exec)
{
    KFileView *local_view = dirop->view();
    KFileItemList *list = const_cast<KFileItemList*>(local_view->items());

    if(list)
    {
        KFileItem *item = (direct == SQ_WidgetStack::Next) ? list->first() : list->last();

        if(!item || moveTo(direct, item) == moveFailed)
            return;

        item = local_view->currentFileItem();

        if(item)
        {
            dirop->setCurrentItem(item);
            SQ_GLWidget::window()->setExpectedURL(item->url());
            if(exec) dirop->execute(item);
        }
    }
}

/*
 *  Update grid for thumbnail view. New grid is calcalated from item
 *  margins (from Options).
 */
void SQ_WidgetStack::updateGrid(bool arrange)
{
    if(dirop->viewType() != SQ_DirOperator::TypeThumbs)
        return;

    SQ_Config::instance()->setGroup("Thumbnails");
    int newgrid = SQ_ThumbnailSize::instance()->extended() ?
                    SQ_ThumbnailSize::instance()->extendedSize().width()
                    : SQ_ThumbnailSize::instance()->pixelSize();

    newgrid += (SQ_Config::instance()->readNumEntry("margin", 2) + 2);

    SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(dirop->view());

    // different grid ?
    if(tv->gridX() != newgrid)
    {
        tv->setGridX(newgrid);

        if(arrange)
            tv->arrangeItemsInGrid();
    }
}

void SQ_WidgetStack::thumbnailsUpdateEnded()
{
    if(dirop->viewType() != SQ_DirOperator::TypeThumbs)
        return;

    SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(dirop->view());

    if(!tv) return;

    timerShowProgress->stop();
    tv->progressBox()->hide();
    tv->progressBox()->flush();
    tv->progressBox()->startButtonPixmap();
}

void SQ_WidgetStack::thumbnailUpdateStart(int count)
{
    SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(dirop->view());

    if(!tv) return;

    tv->progressBox()->setTotalSteps(count);
    tv->progressBox()->stopButtonPixmap();

    timerShowProgress->start(1000, true);
}

void SQ_WidgetStack::slotDelayedShowProgress()
{
    SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(dirop->view());

    if(tv)
        tv->progressBox()->show();
}

void SQ_WidgetStack::thumbnailProcess()
{
    SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(dirop->view());

    if(tv)
        tv->progressBox()->advance();
}

void SQ_WidgetStack::setURLForCurrent(const TQString &path, bool parseTree)
{
    KURL url = KURL::fromPathOrURL(path);

    setURLForCurrent(url, parseTree);
}

void SQ_WidgetStack::setURLForCurrent(const KURL &url, bool parseTree)
{
    setURL(url, parseTree);
    dirop->setURL(url, true);
}

void SQ_WidgetStack::updateView()
{
    dirop->actionCollection()->action("reload")->activate();
}

void SQ_WidgetStack::slotRunSeparately()
{
    const KFileItemList *selected = selectedItems();
    KFileItemListIterator it(*selected);

    KFileItem *item;

    while((item = it.current()))
    {
        if(item)
            item->run();

        ++it;
    }
}

// recreate selected thumbnails
void SQ_WidgetStack::slotRecreateThumbnail()
{
    // oops, not a thumbnail view
    if(dirop->viewType() != SQ_DirOperator::TypeThumbs)
        return;

    SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(dirop->view());

    if(tv->updateRunning())
        return;

    tv->progressBox()->show();

    TQTimer::singleShot(1, this, TQT_SLOT(slotDelayedRecreateThumbnail()));
}

void SQ_WidgetStack::slotDelayedRecreateThumbnail()
{
    SQ_Thumbnail thumb;

    KFileItemList *list = const_cast<KFileItemList *>(selectedItems());
    SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(dirop->view());

    if(!list || !tv)
        return;

    KFileItemListIterator it(*list);
    KFileItem *item;

    while((item = it.current()))
    {
        SQ_PixmapCache::instance()->removeEntryFull(item->url());
        ++it;
    }

    tv->doStartThumbnailUpdate(*list);
}

/*
 *  Save currently selected items' paths, if any.
 *
 *  Return true, if at least one url was saved.
 */
bool SQ_WidgetStack::prepare()
{
    // clear old files
    files.clear();

    KFileItemList *items = const_cast<KFileItemList *>(selectedItems());
    KFileItem *i;

    if(!items || items->isEmpty())
    {
        KMessageBox::information(dirop, i18n("No files to copy or move"));
        return false;
    }

    i = items->first();

    while(i)
    {
        files.append(i->url());
        i = items->next();
    }

    return true;
}

/*
 *  Slots for file actions: copy, move, cut...
 */
void SQ_WidgetStack::slotFileCopy()
{
    fileaction = (prepare()) ? SQ_WidgetStack::Copy : SQ_WidgetStack::Unknown;
}

void SQ_WidgetStack::slotFileCut()
{
    fileaction = (prepare()) ? SQ_WidgetStack::Cut : SQ_WidgetStack::Unknown;
}

// Paste files
void SQ_WidgetStack::slotFilePaste()
{
    // No files to copy ?
    if(files.isEmpty() || fileaction == SQ_WidgetStack::Unknown)
    {
        KMessageBox::information(dirop, i18n("No files to copy or move"));
        return;
    }

    // get current url
    KURL _url = url();
    emitNewLastURL(_url);
    KIO::Job *job;

    // now copy or move files to current url
    job = (fileaction == SQ_WidgetStack::Copy) ? KIO::copy(files, _url) : KIO::move(files, _url);
    connect(job, TQT_SIGNAL(result(KIO::Job *)), this, TQT_SLOT(slotJobResult(KIO::Job *)));
}

void SQ_WidgetStack::slotJobResult(KIO::Job *job)
{
    if(job && job->error())
        job->showErrorDialog(KSquirrel::app());
}

void SQ_WidgetStack::emitNewLastURL(const KURL &u)
{
    lastURL = u;
    TQString text;

    TQString targ = KStringHandler::csqueeze(u.isLocalFile() ? u.path() : u.prettyURL(), 25);

    if(fileaction == SQ_WidgetStack::Copy)
        text = i18n("Repeat (copy to %1)").tqarg(targ);
    else if(fileaction == SQ_WidgetStack::Cut)
        text = i18n("Repeat (move to %1)").tqarg(targ);
    else if(fileaction == SQ_WidgetStack::Link)
        text = i18n("Repeat (link to %1)").tqarg(targ);

    if(!text.isEmpty())
        emit newLastURL(text);
}

void SQ_WidgetStack::repeat()
{
    if(fileaction == SQ_WidgetStack::Copy || fileaction == SQ_WidgetStack::Cut)
        prepare();
    else
        return;

    // No files to copy ?
    if(lastURL.isEmpty() || files.isEmpty())
        return;

    KIO::Job *job = (fileaction == SQ_WidgetStack::Copy) ? KIO::copy(files, lastURL) : KIO::move(files, lastURL);
    connect(job, TQT_SIGNAL(result(KIO::Job *)), this, TQT_SLOT(slotJobResult(KIO::Job *)));
}

// Create links
void SQ_WidgetStack::slotFileLinkTo()
{
    if(!prepare())
        return;

    // select a directory
    KURL url = KFileDialog::getExistingURL(lastURL.url(), dirop);

    if(url.isEmpty())
        return;

    fileaction = SQ_WidgetStack::Link;
    emitNewLastURL(url);

    // create symlinks
    KIO::link(files, url);
}

// Copy to...
void SQ_WidgetStack::slotFileCopyTo()
{
    if(!prepare())
        return;

    // select a directory
    KURL url = KFileDialog::getExistingURL(lastURL.url(), dirop);

    if(url.isEmpty())
        return;

    fileaction = SQ_WidgetStack::Copy;
    emitNewLastURL(url);

    // copy files to selected directory
    KIO::copy(files, url);
}

// Move to...
void SQ_WidgetStack::slotFileMoveTo()
{
    if(!prepare())
        return;

    // select a directory
    KURL url = KFileDialog::getExistingURL(lastURL.url(), dirop);

    if(url.isEmpty())
        return;

    fileaction = SQ_WidgetStack::Cut;
    emitNewLastURL(url);

    // move files to selected directory
    KIO::move(files, url);
}

/*
 *  User wants to select to deselect some files.
 */
void SQ_WidgetStack::slotSelectGroup()
{
    selectDeselectGroup(true);
}

void SQ_WidgetStack::slotDeselectGroup()
{
    selectDeselectGroup(false);
}

/*
 *  Execute SQ_SelectDeselectGroup dialog, and select or
 *  deselect files after it has been closed.
 */
void SQ_WidgetStack::selectDeselectGroup(bool select)
{
    TQString tqmask;

    KFileView *local = dirop->view();

    SQ_SelectDeselectGroup sd(KSquirrel::app());

    sd.setCaption(select ? i18n("Select a group of files") : i18n("Deselect a group of files"));
    sd.pushMask->setText(select ? i18n("Select !") : i18n("Deselect !"));

    if(sd.exec(tqmask) == TQDialog::Accepted)
    {
        if(select)
            local->clearSelection();

        KFileItemList *sd_files = const_cast<KFileItemList *>(items());
        KFileItem *i;
        TQRegExp exp(tqmask);
        exp.setWildcard(true);

        if(!sd_files)
            return;

        i = sd_files->first();

        // go through all files
        while(i)
        {
            // name matched
            if(exp.exactMatch(i->name()))
                local->setSelected(i, select);

            // next file
            i = sd_files->next();
        }
    }
}

/*
 *  Deselect all files.
 */
void SQ_WidgetStack::slotDeselectAll()
{
    dirop->view()->clearSelection();
}

/*
 *  Select all files.
 */
void SQ_WidgetStack::slotSelectAll()
{
    KFileItemList *sd_files = const_cast<KFileItemList *>(items());
    KFileView *local = dirop->view();
    KFileItem *i;

    if(!sd_files)
        return;

    i = sd_files->first();

    // go through files and select them all
    while(i)
    {
        local->setSelected(i, true);
        i = sd_files->next();
    }
}

KAction* SQ_WidgetStack::action(const TQString &name)
{
    return dirop->actionCollection()->action(name);
}

bool SQ_WidgetStack::updateRunning() const
{
    if(dirop->viewType() != SQ_DirOperator::TypeThumbs)
        return false;

    SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(dirop->view());

    if(!tv)
        return false;

    return tv->updateRunning();
}

void SQ_WidgetStack::saveState()
{
    SQ_Config::instance()->writeEntry("last visited", dirop->url().prettyURL());
    SQ_Config::instance()->writeEntry("last_action", static_cast<int>(fileaction));
    SQ_Config::instance()->writeEntry("last_url", lastURL.prettyURL());

    dirop->saveConfig();
}

#include "sq_widgetstack.moc"