~ubuntu-branches/ubuntu/trusty/krusader/trusty

« back to all changes in this revision

Viewing changes to krusader/Panel/krview.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-08-08 13:47:36 UTC
  • mfrom: (1.2.19 upstream)
  • Revision ID: james.westby@ubuntu.com-20110808134736-8e630ivgd2c3sgg5
Tags: 1:2.4.0~beta1-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include <QtGui/QPixmap>
34
34
#include <QtCore/QVariant>
35
35
#include <QtCore/QHash>
 
36
#include <QtCore/QRegExp>
36
37
#include <QDropEvent>
37
38
#include <QList>
38
39
#include <QModelIndex>
40
41
#include "../krglobal.h"
41
42
#include "../VFS/vfile.h"
42
43
#include "../VFS/krquery.h"
 
44
#include "../Filter/filtersettings.h"
43
45
 
44
46
#include <kdebug.h>
45
47
 
46
48
#define MAX_BRIEF_COLS 5
47
49
 
48
 
 
49
50
class KrView;
50
51
class KrViewItem;
51
52
class KrQuickSearch;
82
83
        numberOfColumns(1)
83
84
    {}
84
85
 
 
86
    enum PropertyType { NoProperty = 0x0, PropIconSize = 0x1, PropShowPreviews = 0x2,
 
87
                        PropSortMode = 0x4, PropColumns = 0x8, PropFilter = 0x10,
 
88
                        AllProperties = PropIconSize | PropShowPreviews | PropSortMode | PropColumns | PropFilter
 
89
                      };
85
90
    enum ColumnType { NoColumn = -1, Name = 0x0, Ext = 0x1, Size = 0x2, Type = 0x3, Modified = 0x4,
86
91
                      Permissions = 0x5, KrPermissions = 0x6, Owner = 0x7, Group = 0x8, MAX_COLUMNS = 0x09
87
92
                    };
88
93
    enum SortOptions { Descending = 0x200, DirsFirst = 0x400, IgnoreCase = 0x800,
89
 
                    AlwaysSortDirsByName = 0x1000, LocaleAwareSort = 0x2000
90
 
                  };
 
94
                       AlwaysSortDirsByName = 0x1000, LocaleAwareSort = 0x2000
 
95
                     };
91
96
    enum SortMethod { Alphabetical = 0x1, AlphabeticalNumbers = 0x2,
92
97
                      CharacterCode = 0x4, CharacterCodeNumbers = 0x8, Krusader = 0x10
93
98
                    };
100
105
    SortMethod sortMethod;  // sort method for names and extensions
101
106
    FilterSpec filter; // what items to show (all, custom, exec)
102
107
    KRQuery filterMask; // what items to show (*.cpp, *.h etc)
 
108
    FilterSettings filterSettings;
103
109
    bool filterApplysToDirs;
104
110
    bool localeAwareCompareIsCaseSensitive; // mostly, it is not! depends on LC_COLLATE
105
111
    bool humanReadableSize;  // display size as KB, MB or just as a long number
195
201
    bool isMassSelectionUpdate() {
196
202
        return _massSelectionUpdate;
197
203
    }
198
 
    void settingsChanged();
 
204
    void settingsChanged(KrViewProperties::PropertyType properties);
199
205
 
200
206
public slots:
201
207
    void emitSelectionChanged() {
202
 
        if (!_massSelectionUpdate) emit selectionChanged();
 
208
        if (!_massSelectionUpdate)
 
209
            emit selectionChanged();
203
210
    }
204
211
    void quickSearch(const QString &, int = 0);
205
212
    void stopQuickSearch(QKeyEvent*);
248
255
    QuickFilter *_quickFilter;
249
256
    bool _massSelectionUpdate;
250
257
    QTimer _saveDefaultSettingsTimer;
 
258
    static KrViewProperties::PropertyType _changedProperties;
 
259
    static KrView *_changedView;
251
260
};
252
261
 
253
262
/****************************************************************************
280
289
    {
281
290
    public:
282
291
        IconSizes() : QVector<int>() {
283
 
            *this << 12 << 16 << 22 << 32 << 48;
 
292
            *this << 12 << 16 << 22 << 32 << 48 << 64 << 128 << 256;
284
293
        }
285
294
    };
286
295
 
322
331
    }
323
332
    virtual void        selectRegion(KrViewItem *, KrViewItem *, bool) = 0;
324
333
 
 
334
    virtual uint numSelected() const = 0;
 
335
    virtual KUrl::List selectedUrls() = 0;
 
336
    virtual void setSelection(const KUrl::List urls) = 0;
325
337
    virtual KrViewItem *getFirst() = 0;
326
338
    virtual KrViewItem *getLast() = 0;
327
339
    virtual KrViewItem *getNext(KrViewItem *current) = 0;
347
359
        _operator->prepareForPassive();
348
360
    }
349
361
    virtual void renameCurrentItem(); // Rename current item. returns immediately
350
 
    virtual QString nameInKConfig() const;
351
362
    virtual int  itemsPerPage() {
352
363
        return 0;
353
364
    }
357
368
    virtual KrViewItem *preAddItem(vfile *vf) = 0;
358
369
    virtual void preDelItem(KrViewItem *item) = 0;
359
370
    virtual void preUpdateItem(vfile *vf) = 0;
360
 
    virtual void doSaveSettings(KConfigGroup &group) = 0;
361
 
    virtual void doRestoreSettings(KConfigGroup &group) = 0;
362
371
    virtual void copySettingsFrom(KrView *other) = 0;
363
372
    virtual void populate(const QList<vfile*> &vfiles, vfile *dummy) = 0;
364
 
    virtual uint intSetSelected(const vfile* vf, bool select) = 0;
 
373
    virtual void intSetSelected(const vfile* vf, bool select) = 0;
365
374
    virtual void updatePreviews();
366
375
    virtual void clear();
367
376
 
374
383
    // the following functions are already implemented, //
375
384
    // and normally - should NOT be re-implemented.     //
376
385
    //////////////////////////////////////////////////////
377
 
    virtual uint numSelected() const {
378
 
        return _numSelected;
379
 
    }
380
 
    virtual KIO::filesize_t selectedSize() const {
381
 
        return _selectedSize;
382
 
    }
383
386
    virtual uint numFiles() const {
384
387
        return _count -_numDirs;
385
388
    }
389
392
    virtual uint count() const {
390
393
        return _count;
391
394
    }
392
 
    virtual KIO::filesize_t countSize() const {
393
 
        return _countSize;
394
 
    }
395
395
    virtual void getSelectedItems(QStringList* names);
396
396
    virtual void getItemsByMask(QString mask, QStringList* names, bool dirs = true, bool files = true);
397
397
    virtual void getSelectedKrViewItems(KrViewItemList *items);
454
454
        return _properties->filter;
455
455
    }
456
456
    virtual void setFilter(KrViewProperties::FilterSpec filter);
 
457
    virtual void setFilter(KrViewProperties::FilterSpec filter, FilterSettings customFilter, bool applyToDirs);
457
458
    virtual void customSelection(bool select);
458
459
    virtual int defaultFileIconSize();
459
460
    virtual void setFileIconSize(int size);
463
464
    virtual void zoomIn();
464
465
    virtual void zoomOut();
465
466
 
 
467
    // save this view's settings to be restored after restart
 
468
    virtual void saveSettings(KConfigGroup grp,
 
469
        KrViewProperties::PropertyType properties = KrViewProperties::AllProperties);
 
470
 
466
471
    inline QWidget *widget() {
467
472
        return _widget;
468
473
    }
479
484
        _mainWindow = mainWindow;
480
485
    }
481
486
 
482
 
    // save this view's settings to be restored after restart
483
 
    void saveSettings() {
484
 
        saveSettings(nameInKConfig());
485
 
    }
486
 
    void saveSettings(QString configGroup);
487
487
    // save this view's settings as default for new views of this type
488
 
    void saveDefaultSettings();
489
 
    // call this to restore this view's settings after restart
490
 
    void restoreSettings() {
491
 
        restoreSettings(nameInKConfig());
492
 
    }
493
 
    void restoreSettings(QString configGroup);
 
488
    void saveDefaultSettings(KrViewProperties::PropertyType properties = KrViewProperties::AllProperties);
494
489
    // restore the default settings for this view type
495
490
    void restoreDefaultSettings();
 
491
    // call this to restore this view's settings after restart
 
492
    void restoreSettings(KConfigGroup grp);
 
493
 
 
494
    void saveSelection();
 
495
    void restoreSelection();
 
496
    bool canRestoreSelection() {
 
497
        return !_savedSelection.isEmpty();
 
498
    }
 
499
    void clearSavedSelection();
496
500
 
497
501
    // todo: what about selection modes ???
498
502
    virtual ~KrView();
502
506
    static QString krPermissionString(const vfile * vf);
503
507
 
504
508
protected:
505
 
    KrView(KrViewInstance &instance, const bool &left, KConfig *cfg);
 
509
    KrView(KrViewInstance &instance, KConfig *cfg);
506
510
 
 
511
    virtual void doRestoreSettings(KConfigGroup grp);
 
512
    virtual KIO::filesize_t calcSize() = 0;
 
513
    virtual KIO::filesize_t calcSelectedSize() = 0;
507
514
    bool handleKeyEventInt(QKeyEvent *e);
508
515
    void sortModeUpdated(KrViewProperties::ColumnType sortColumn, bool descending);
509
516
    void saveSortMode(KConfigGroup &group);
512
519
        _widget = w;
513
520
    }
514
521
 
515
 
 
516
522
    KrViewInstance &_instance;
517
523
    VfileContainer *_files;
518
 
    const bool &_left;
519
524
    KConfig *_config;
520
525
    QWidget *_mainWindow;
521
526
    QWidget *_widget;
 
527
    KUrl::List _savedSelection;
522
528
    QString _nameToMakeCurrent;
523
529
    QString _nameToMakeCurrentIfAdded;
524
530
    KrViewProperties *_properties;
527
533
    KrPreviews *_previews;
528
534
    int _fileIconSize;
529
535
    bool _updateDefaultSettings;
530
 
    KRQuery _quickFilterMask;
 
536
    QRegExp _quickFilterMask;
531
537
 
532
538
private:
533
 
    KIO::filesize_t _countSize, _selectedSize;
534
 
    uint _numSelected, _count, _numDirs;
 
539
    uint _count, _numDirs;
535
540
    vfile *_dummyVfile;
536
541
};
537
542