~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to parts/fileselector/fileselector_widget.h

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2006-05-23 18:39:42 UTC
  • Revision ID: james.westby@ubuntu.com-20060523183942-hucifbvh68k2bwz7
Tags: upstream-3.3.2
Import upstream version 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 2003 Roberto Raggi <roberto@kdevelop.org>
 
3
   Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
 
4
   Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
 
5
   Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
 
6
 
 
7
   This library is free software; you can redistribute it and/or
 
8
   modify it under the terms of the GNU Library General Public
 
9
   License version 2 as published by the Free Software Foundation.
 
10
 
 
11
   This library is distributed in the hope that it will be useful,
 
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
   Library General Public License for more details.
 
15
 
 
16
   You should have received a copy of the GNU Library General Public License
 
17
   along with this library; see the file COPYING.LIB.  If not, write to
 
18
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
19
   Boston, MA 02111-1307, USA.
 
20
*/
 
21
 
 
22
#ifndef FILESELECTOR_WIDGET_H
 
23
#define FILESELECTOR_WIDGET_H
 
24
 
 
25
#include <qwidget.h>
 
26
#include <kfile.h>
 
27
#include <kurl.h>
 
28
#include <ktoolbar.h>
 
29
#include <qframe.h>
 
30
#include <kdiroperator.h>
 
31
 
 
32
class KDevMainWindow;
 
33
class KDevPartController;
 
34
class FileSelectorPart;
 
35
class KActionCollection;
 
36
class KActionSelector;
 
37
class KDirOperator;
 
38
class KURLComboBox;
 
39
class KHistoryCombo;
 
40
 
 
41
namespace KParts
 
42
{
 
43
    class Part;
 
44
}
 
45
 
 
46
namespace KTextEditor
 
47
{
 
48
    class Document;
 
49
}
 
50
 
 
51
/*
 
52
    The KDev file selector presents a directory view, in which the default action is
 
53
    to open the activated file.
 
54
    Additinally, a toolbar for managing the kdiroperator widget + sync that to
 
55
    the directory of the current file is available, as well as a filter widget
 
56
    allowing to filter the displayed files using a name filter.
 
57
*/
 
58
 
 
59
/* I think this fix for not moving toolbars is better */
 
60
class KDevFileSelectorToolBar: public KToolBar
 
61
{
 
62
    Q_OBJECT
 
63
public:
 
64
    KDevFileSelectorToolBar(QWidget *parent);
 
65
    virtual ~KDevFileSelectorToolBar();
 
66
 
 
67
    virtual void setMovingEnabled( bool b );
 
68
};
 
69
 
 
70
class KDevFileSelectorToolBarParent: public QFrame
 
71
{
 
72
    Q_OBJECT
 
73
public:
 
74
    KDevFileSelectorToolBarParent(QWidget *parent);
 
75
    ~KDevFileSelectorToolBarParent();
 
76
    void setToolBar(KDevFileSelectorToolBar *tb);
 
77
 
 
78
private:
 
79
    KDevFileSelectorToolBar *m_tb;
 
80
 
 
81
protected:
 
82
    virtual void resizeEvent ( QResizeEvent * );
 
83
};
 
84
 
 
85
class KDevDirOperator: public KDirOperator
 
86
{
 
87
    Q_OBJECT
 
88
public:
 
89
    KDevDirOperator(FileSelectorPart *part, const KURL &urlName=KURL(), QWidget *parent=0, const char *name=0)
 
90
        :KDirOperator(urlName, parent, name), m_part(part)
 
91
    {
 
92
    }
 
93
 
 
94
protected slots:
 
95
    virtual void activatedMenu (const KFileItem *fi, const QPoint &pos);
 
96
 
 
97
private:
 
98
    FileSelectorPart *m_part;
 
99
};
 
100
 
 
101
class KDevFileSelector : public QWidget
 
102
{
 
103
    Q_OBJECT
 
104
 
 
105
    friend class KFSConfigPage;
 
106
 
 
107
public:
 
108
    /* When to sync to current document directory */
 
109
    enum AutoSyncEvent { DocumentChanged=1, DocumentOpened=2, GotVisible=4 };
 
110
 
 
111
    KDevFileSelector( FileSelectorPart *part, KDevMainWindow *mainWindow=0, KDevPartController *partController=0,
 
112
                      QWidget * parent = 0, const char * name = 0 );
 
113
    ~KDevFileSelector();
 
114
 
 
115
    void readConfig( KConfig *, const QString & );
 
116
    void writeConfig( KConfig *, const QString & );
 
117
    void setupToolbar( KConfig * );
 
118
    void setView( KFile::FileView );
 
119
    KDevDirOperator *dirOperator(){ return dir; }
 
120
    KActionCollection *actionCollection() { return mActionCollection; };
 
121
 
 
122
public slots:
 
123
    void slotFilterChange(const QString&);
 
124
    void setDir(KURL);
 
125
    void setDir( const QString& url ) { setDir( KURL( url ) ); };
 
126
 
 
127
private slots:
 
128
    void cmbPathActivated( const KURL& u );
 
129
    void cmbPathReturnPressed( const QString& u );
 
130
    void dirUrlEntered( const KURL& u );
 
131
    void dirFinishedLoading();
 
132
    void setActiveDocumentDir();
 
133
    void viewChanged();
 
134
    void btnFilterClick();
 
135
    void autoSync();
 
136
    void autoSync( KParts::Part * );
 
137
        void initialDirChangeHack();
 
138
protected:
 
139
    void focusInEvent( QFocusEvent * );
 
140
    void showEvent( QShowEvent * );
 
141
    bool eventFilter( QObject *, QEvent * );
 
142
    KURL activeDocumentUrl();
 
143
 
 
144
private:
 
145
    class KDevFileSelectorToolBar *toolbar;
 
146
    KActionCollection *mActionCollection;
 
147
    class KBookmarkHandler *bookmarkHandler;
 
148
    KURLComboBox *cmbPath;
 
149
    KDevDirOperator * dir;
 
150
    class KAction *acSyncDir;
 
151
    KHistoryCombo * filter;
 
152
    class QToolButton *btnFilter;
 
153
 
 
154
    FileSelectorPart *m_part;
 
155
    KDevMainWindow *mainwin;
 
156
    KDevPartController *partController;
 
157
 
 
158
    QString lastFilter;
 
159
    int autoSyncEvents; // enabled autosync events
 
160
    QString waitingUrl; // maybe display when we gets visible
 
161
    QString waitingDir;
 
162
};
 
163
 
 
164
/*  @todo anders
 
165
    KFSFilterHelper
 
166
    A popup widget presenting a listbox with checkable items
 
167
    representing the mime types available in the current directory, and
 
168
    providing a name filter based on those.
 
169
*/
 
170
 
 
171
/*
 
172
    Config page for file selector.
 
173
    Allows for configuring the toolbar, the history length
 
174
    of the path and file filter combos, and how to handle
 
175
    user closed session.
 
176
*/
 
177
class KFSConfigPage : public QWidget
 
178
{
 
179
    Q_OBJECT
 
180
public:
 
181
    KFSConfigPage( QWidget* parent=0, const char *name=0, KDevFileSelector *kfs=0);
 
182
    virtual ~KFSConfigPage() {};
 
183
 
 
184
public slots:
 
185
    virtual void apply();
 
186
    virtual void reload();
 
187
    virtual void slotChanged();
 
188
 
 
189
private:
 
190
    void init();
 
191
 
 
192
    KDevFileSelector *fileSelector;
 
193
    bool bDirty;
 
194
    //class QListBox *lbAvailableActions, *lbUsedActions;
 
195
    KActionSelector *acSel;
 
196
    class QSpinBox *sbPathHistLength, *sbFilterHistLength;
 
197
    class QCheckBox *cbSyncOpen, *cbSyncActive, *cbSyncShow;
 
198
    class QCheckBox *cbSesLocation, *cbSesFilter;
 
199
};
 
200
 
 
201
 
 
202
#endif
 
203