summaryrefslogtreecommitdiff
path: root/libopie/ofileselector/olister.h
blob: 4adb9f8a09727b4fe5c7c0f6cb30a6d33ccfcb82 (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
#ifndef OPIE_FILE_LISTER_H
#define OPIE_FILE_LISTER_H

#include <qfileinfo.h>
#include <qmap.h>
#include <qstring.h>
#include <qstringlist.h>

class QComboBox;
class OPixmapProvider;
class OFileSelector;

class OListerCmbAccess;
/**
 * lister is something like KIO but very
 * very basic and currently only for
 * populating our views.
 * This is a base class which needs to be implemented.
 * @see OLocalLister for a filesystem based implementation
 */

class OLister {
public:
    OLister( OFileSelector* );
    virtual ~OLister();

    /**
     * if path == QString::null reread current dir
     */
    virtual void reparse(const QString& path = QString::null ) = 0;

    /**
     * return a list of available mimetypes
     */
    virtual QMap<QString, QStringList> mimeTypes( const QString& dir ) = 0;
    void setPixmapProvider( OPixmapProvider* );


    /* some way a slot */
    virtual void fileSelected( const QString& dir, const QString& file, const QString& extra ) = 0;
    virtual void changedDir( const QString& dir, const QString& file, const QString& extra ) = 0;
    virtual QString selectedName()const = 0;
    virtual QStringList selectedNames()const = 0;
protected:
    /**
     * I hate too big classes
     * this is a way to group
     * access to a ComboBox
     * which might exist or
     * not in a secure way
     */
    OListerCmbAccess* comboBox();

    bool showFiles()const;
    bool showDirs()const;
    bool compliesMime( const QString& mime );
    void addFile( const QString& mine,
                  QFileInfo*,
                  const QString& extra = QString::null,
                  bool isSymlink = FALSE );

    void addFile( const QString& mine,
                  const QString& path,
                  const QString& file,
                  const QString& extra = QString::null,
                  bool isSymlink = FALSE );
    void addDir( const QString& mine,
                 QFileInfo*,
                 const QString& extra = QString::null,
                 bool isSymlink = FALSE );
    void addDir( const QString& mine,
                 const QString& path,
                 const QString& dir,
                 const QString& extra = QString::null,
                 bool isSymlink = FALSE );
    void addSymlink( const QString& mine,
                     QFileInfo* info,
                     const QString& extra = QString::null,
                     bool isSymlink = FALSE);
    void addSymlink( const QString& mine,
                     const QString& path,
                     const QString& name,
                     const QString& extra = QString::null,
                     bool isSymlink = FALSE );
    OFileSelector* view();
    OFileSelector* view()const;
    OPixmapProvider* provider();
    void internFileSelected( const QString& file );
    void internChangedDir( const QString& dir );

    /**
     * try to take
     * the text from the mainwindows
     * lineedit
     * if it's not available QString::null
     * will be returned
     */
    QString lineEdit()const;
private:
    OFileSelector* m_view;
    OPixmapProvider* m_prov;
    OListerCmbAccess* m_acc;

    class Private;
    Private *d;
};

class OListerCmbAccess {
    friend class OLister;
public:
    OListerCmbAccess( QComboBox* = 0l);
    ~OListerCmbAccess();

    /**
     * clears the combobox
     */
    void clear();

    /**
     * set's @param add to be the current Item
     * if the item is not present it'll be removed
     */
    void setCurrentItem( const QString& add,  bool FORECE_ADD = TRUE );

    /**
     * inserts the the String at
     * a non predictable position... The position is determined
     * by the QComboBox code
     */
    void insert( const QString& );

    /**
     *
     */
    QString currentText()const;

private:
    class Private;
    Private* d;
    QComboBox* m_cmb;

};

#endif