summaryrefslogtreecommitdiffstats
path: root/kdeui/tests/kdockwidgetdemo.h
blob: e81162eb01dead8012b151b94540d23c5c2f3622 (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
#ifndef KDOCKWIDGETDEMO_H
#define KDOCKWIDGETDEMO_H

#include <kdockwidget.h>

#include <qdialog.h>
#include <qlistview.h>
#include <qstring.h>
#include <qfile.h>
#include <qfileinfo.h>
#include <qtimer.h>
#include <qscrollview.h>
#include <qfiledialog.h>
#include <qwidgetstack.h>
#include <qvbox.h>
#include <qurl.h>
#include <qpixmap.h>

class QMultiLineEdit;
class QTextView;
class QToolButton;
class QSpinBox;
class QShowEvent;
class QPopupMenu;

class DirectoryView;
class CustomFileDialog;
class Preview;
class DirectoryView;

class SFileDialog : public QDialog
{Q_OBJECT

public:
	SFileDialog( QString initially = QString::null,
                                  const QStringList& filter = "All Files ( * )", const char* name = 0 );
	~SFileDialog();

  static QString getOpenFileName( QString initially = QString::null,
                                  const QStringList& filter = "All Files ( * )",
                                  const QString caption = QString::null, const char* name = 0 );

  static QStringList getOpenFileNames( QString initially = QString::null,
                                  const QStringList& filter = "All Files ( * )",
                                  const QString caption = QString::null, const char* name = 0 );


protected:
  void showEvent( QShowEvent *e );

protected slots:
  void dockChange();
  void setDockDefaultPos( KDockWidget* );
  void changeDir( const QString& );

private:
  DirectoryView* dirView;
  CustomFileDialog* fd;
  Preview* preview;

  KDockManager* dockManager;
  KDockWidget* d_dirView;
  KDockWidget* d_preview;
  KDockWidget* d_fd;

  QToolButton *b_tree;
  QToolButton *b_preview;
};
/******************************************************************************************************/
class Directory : public QListViewItem
{
public:
    Directory( QListView * parent, const QString& filename );
    Directory( Directory * parent, const QString& filename );

    QString text( int column ) const;

    QString fullName();

    void setOpen( bool );
    void setup();

private:
    QFile f;
    Directory * p;
    bool readable;
};

class DirectoryView : public QListView
{Q_OBJECT
public:
  DirectoryView( QWidget *parent = 0, const char *name = 0 );
  virtual void setOpen ( QListViewItem *, bool );

  QString selectedDir();

public slots:
  void setDir( const QString & );

signals:
  void folderSelected( const QString & );

protected slots:
  void slotFolderSelected( QListViewItem * );

private:
  QString fullPath(QListViewItem* item);
};
/******************************************************************************************************/
class PixmapView : public QScrollView
{Q_OBJECT
public:
  PixmapView( QWidget *parent );
  void setPixmap( const QPixmap &pix );
  void drawContents( QPainter *p, int, int, int, int );

private:
  QPixmap pixmap;
};

class Preview : public QWidgetStack
{Q_OBJECT
public:
  Preview( QWidget *parent );

public slots:
  void showPreview( const QString& );

private:
  QMultiLineEdit *normalText;
  QTextView *html;
  PixmapView *pixmap;
};

class CustomFileDialog : public QFileDialog
{Q_OBJECT
public:
  CustomFileDialog( QWidget* parent );
  ~CustomFileDialog();

  void addToolButton( QButton * b, bool separator = false ){ QFileDialog::addToolButton(b,separator); }
  void setBookmark( QStringList& );
  QStringList getBookmark(){ return bookmarkList; }

public slots:
  void setDir2( const QString & );

signals:
  void signalDone( int );

protected slots:
  void bookmarkChosen( int i );
  void goHome();
  virtual void done( int );

private:
  QPopupMenu *bookmarkMenu;
  QStringList bookmarkList;
  int addId, clearId;
};

#endif