author | zecke <zecke> | 2002-04-11 20:30:22 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-04-11 20:30:22 (UTC) |
commit | 2599e347d9444cfa6282fec9f2bfb9df4743d6d2 (patch) (unidiff) | |
tree | f7459dc0763e2023a4cbc9171241fa3e37b3731a | |
parent | 4db8a0f808c4fd931d10af203d94f693e92519f5 (diff) | |
download | opie-2599e347d9444cfa6282fec9f2bfb9df4743d6d2.zip opie-2599e347d9444cfa6282fec9f2bfb9df4743d6d2.tar.gz opie-2599e347d9444cfa6282fec9f2bfb9df4743d6d2.tar.bz2 |
OFileSelector const QStringList -> const QSTringList&
OFileDialog initial version
the layout is broken but don't ask me. I played with the parent
played with manual relayouting.
Currently the setYesCancelVisisble crashes but that's ok for now
OFileDialog provides static methods for
OpenFileName, SaveFileName and DIrFileName
Multiple selection will follow
Maybe a dwarf fixes the problems for me overnight
-rw-r--r-- | libopie/ofiledialog.cc | 110 | ||||
-rw-r--r-- | libopie/ofiledialog.h | 77 | ||||
-rw-r--r-- | libopie/ofileselector.cc | 2 | ||||
-rw-r--r-- | libopie/ofileselector.h | 7 |
4 files changed, 192 insertions, 4 deletions
diff --git a/libopie/ofiledialog.cc b/libopie/ofiledialog.cc new file mode 100644 index 0000000..92b0d0a --- a/dev/null +++ b/libopie/ofiledialog.cc | |||
@@ -0,0 +1,110 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 <> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include <qpe/applnk.h> | ||
30 | #include <qstring.h> | ||
31 | #include <qapplication.h> | ||
32 | #include <qlayout.h> | ||
33 | |||
34 | #include "ofiledialog.h" | ||
35 | |||
36 | OFileDialog::OFileDialog(const QString &caption, | ||
37 | QWidget *wid, int mode, int selector, | ||
38 | const QString &dirName, | ||
39 | const QString &fileName, | ||
40 | const QStringList &mimetypes ) | ||
41 | : QDialog( wid, "OFileDialog", true ) | ||
42 | { | ||
43 | QVBoxLayout *lay = new QVBoxLayout(this); | ||
44 | |||
45 | file = new OFileSelector(0 , mode, selector, | ||
46 | dirName, fileName, | ||
47 | mimetypes ); | ||
48 | lay->addWidget( file ); | ||
49 | //showFullScreen(); | ||
50 | setCaption( caption.isEmpty() ? tr("FileDialog") : caption ); | ||
51 | connect(file, SIGNAL(fileSelected(const QString&) ), | ||
52 | this, SLOT(slotFileSelected(const QString&) ) ); | ||
53 | |||
54 | connect(file, SIGNAL(dirSelected(const QString &) ), | ||
55 | this, SLOT(slotDirSelected(const QString &) ) ); | ||
56 | showMaximized(); | ||
57 | file->setYesCancelVisible( false ); // relayout | ||
58 | } | ||
59 | QString OFileDialog::mimetype()const | ||
60 | { | ||
61 | return QString::null; | ||
62 | } | ||
63 | QString OFileDialog::fileName()const | ||
64 | { | ||
65 | return file->selectedName(); | ||
66 | } | ||
67 | DocLnk OFileDialog::selectedDocument()const | ||
68 | { | ||
69 | return file->selectedDocument(); | ||
70 | } | ||
71 | QString OFileDialog::getOpenFileName(int selector, | ||
72 | const QString &startDir, | ||
73 | const QString &file, | ||
74 | const QStringList &mimes, | ||
75 | QWidget *wid, | ||
76 | const QString &caption ) | ||
77 | { | ||
78 | QString ret; | ||
79 | OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption, | ||
80 | wid, OFileSelector::OPEN, selector, startDir, file, mimes); | ||
81 | if( dlg.exec() ) | ||
82 | ret = dlg.fileName(); | ||
83 | |||
84 | return ret; | ||
85 | } | ||
86 | QString OFileDialog::getSaveFileName(int selector, | ||
87 | const QString &startDir, | ||
88 | const QString &file, | ||
89 | const QStringList &mimes, | ||
90 | QWidget *wid, | ||
91 | const QString &caption ) | ||
92 | { | ||
93 | QString ret; | ||
94 | OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption, | ||
95 | wid, OFileSelector::SAVE, selector, startDir, file, mimes); | ||
96 | if( dlg.exec() ) | ||
97 | ret = dlg.fileName(); | ||
98 | |||
99 | return ret; | ||
100 | } | ||
101 | |||
102 | void OFileDialog::slotFileSelected(const QString & ) | ||
103 | { | ||
104 | accept(); | ||
105 | } | ||
106 | void OFileDialog::slotDirSelected(const QString & ) | ||
107 | { | ||
108 | // if mode | ||
109 | //accept(); | ||
110 | } | ||
diff --git a/libopie/ofiledialog.h b/libopie/ofiledialog.h new file mode 100644 index 0000000..40d147e --- a/dev/null +++ b/libopie/ofiledialog.h | |||
@@ -0,0 +1,77 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 zecke <zecke@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | |||
30 | #ifndef OpieFileDialog_h | ||
31 | #define OpieFileDialog_h | ||
32 | |||
33 | #include <qdialog.h> | ||
34 | |||
35 | #include <opie/ofileselector.h> | ||
36 | |||
37 | class OFileDialog : public QDialog { | ||
38 | Q_OBJECT | ||
39 | public: | ||
40 | OFileDialog(const QString &caption, | ||
41 | QWidget *, int mode, int selector, | ||
42 | const QString &dirName, | ||
43 | const QString &fileName = QString::null, | ||
44 | const QStringList &mimetypes = QStringList() ); | ||
45 | QString mimetype() const; | ||
46 | QString fileName() const; | ||
47 | DocLnk selectedDocument()const; | ||
48 | |||
49 | // static methods | ||
50 | static QString getOpenFileName(int selector, | ||
51 | const QString& startDir = QString::null, | ||
52 | const QString &fileName = QString::null, | ||
53 | const QStringList& mimefilter = QStringList(), | ||
54 | QWidget *wid = 0, | ||
55 | const QString &caption = QString::null ); | ||
56 | |||
57 | static QString getSaveFileName(int selector, | ||
58 | const QString& startDir = QString::null, | ||
59 | const QString& fileName = QString::null, | ||
60 | const QStringList& mimefilter = QStringList(), | ||
61 | QWidget *wid = 0, | ||
62 | const QString &caption = QString::null ); | ||
63 | |||
64 | //let's OFileSelector catch up first | ||
65 | //static QString getExistingDirectory(const QString& startDir = QString::null, | ||
66 | // QWidget *parent = 0, | ||
67 | // const QString& caption = QString::null ); | ||
68 | private: | ||
69 | class OFileDialogPrivate; | ||
70 | OFileDialogPrivate *d; | ||
71 | OFileSelector *file; | ||
72 | |||
73 | private slots: | ||
74 | void slotFileSelected( const QString & ); | ||
75 | void slotDirSelected(const QString & ); | ||
76 | }; | ||
77 | #endif | ||
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index fbe69ed..bc7c6c2 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -1,1080 +1,1080 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 3 | .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <qnamespace.h> | 29 | #include <qnamespace.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qcombobox.h> | 31 | #include <qcombobox.h> |
32 | #include <qhbox.h> | 32 | #include <qhbox.h> |
33 | #include <qvbox.h> | 33 | #include <qvbox.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qwidgetstack.h> | 35 | #include <qwidgetstack.h> |
36 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
37 | #include <qcheckbox.h> | 37 | #include <qcheckbox.h> |
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | #include <qheader.h> | 39 | #include <qheader.h> |
40 | #include <qdir.h> | 40 | #include <qdir.h> |
41 | #include <qpainter.h> | 41 | #include <qpainter.h> |
42 | #include <qaction.h> | 42 | #include <qaction.h> |
43 | #include <qpopupmenu.h> | 43 | #include <qpopupmenu.h> |
44 | #include <qcursor.h> | 44 | #include <qcursor.h> |
45 | 45 | ||
46 | #include <qpe/qpeapplication.h> | 46 | #include <qpe/qpeapplication.h> |
47 | #include <qpe/fileselector.h> | 47 | #include <qpe/fileselector.h> |
48 | #include <qpe/applnk.h> | 48 | #include <qpe/applnk.h> |
49 | #include <qpe/global.h> | 49 | #include <qpe/global.h> |
50 | #include <qpe/mimetype.h> | 50 | #include <qpe/mimetype.h> |
51 | #include <qpe/resource.h> | 51 | #include <qpe/resource.h> |
52 | #include <qpe/storage.h> | 52 | #include <qpe/storage.h> |
53 | 53 | ||
54 | #include <unistd.h> | 54 | #include <unistd.h> |
55 | #include <stdlib.h> | 55 | #include <stdlib.h> |
56 | #include <sys/stat.h> | 56 | #include <sys/stat.h> |
57 | 57 | ||
58 | #include "ofileselector.h" | 58 | #include "ofileselector.h" |
59 | 59 | ||
60 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; | 60 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; |
61 | 61 | ||
62 | namespace { | 62 | namespace { |
63 | 63 | ||
64 | int indexByString( const QComboBox *box, const QString &str ){ | 64 | int indexByString( const QComboBox *box, const QString &str ){ |
65 | int index= -1; | 65 | int index= -1; |
66 | for(int i= 0; i < box->count(); i++ ){ | 66 | for(int i= 0; i < box->count(); i++ ){ |
67 | qWarning("str T%sT boxT%sT", str.latin1(), box->text(i).latin1() ); | 67 | qWarning("str T%sT boxT%sT", str.latin1(), box->text(i).latin1() ); |
68 | if( str == box->text(i ) ){ | 68 | if( str == box->text(i ) ){ |
69 | index= i; | 69 | index= i; |
70 | break; | 70 | break; |
71 | } | 71 | } |
72 | } | 72 | } |
73 | return index; | 73 | return index; |
74 | } | 74 | } |
75 | 75 | ||
76 | }; | 76 | }; |
77 | 77 | ||
78 | 78 | ||
79 | OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, | 79 | OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, |
80 | const QString &fileName, const QStringList mimetypes ) : QWidget( wid ) | 80 | const QString &fileName, const QStringList &mimetypes ) : QWidget( wid ) |
81 | { | 81 | { |
82 | m_selector = selector; | 82 | m_selector = selector; |
83 | m_currentDir = dirName; | 83 | m_currentDir = dirName; |
84 | m_name = fileName; | 84 | m_name = fileName; |
85 | m_mimetypes = mimetypes; | 85 | m_mimetypes = mimetypes; |
86 | if( mimetypes.isEmpty() ) | 86 | if( mimetypes.isEmpty() ) |
87 | m_autoMime = true; | 87 | m_autoMime = true; |
88 | 88 | ||
89 | m_mode = mode; | 89 | m_mode = mode; |
90 | m_shTool = true; | 90 | m_shTool = true; |
91 | m_shPerm = true; | 91 | m_shPerm = true; |
92 | m_shLne = true; | 92 | m_shLne = true; |
93 | m_shChooser = true; | 93 | m_shChooser = true; |
94 | m_shYesNo = true; | 94 | m_shYesNo = true; |
95 | // for FILESELECTOR only view is interesting | 95 | // for FILESELECTOR only view is interesting |
96 | m_location = 0; | 96 | m_location = 0; |
97 | m_homeButton = 0; | 97 | m_homeButton = 0; |
98 | m_docButton = 0; | 98 | m_docButton = 0; |
99 | m_hideButton = 0; | 99 | m_hideButton = 0; |
100 | m_ok = 0; | 100 | m_ok = 0; |
101 | m_cancel = 0; | 101 | m_cancel = 0; |
102 | m_reread = 0; | 102 | m_reread = 0; |
103 | m_up = 0; | 103 | m_up = 0; |
104 | m_View = 0; | 104 | m_View = 0; |
105 | m_select = 0; | 105 | m_select = 0; |
106 | m_stack = 0; | 106 | m_stack = 0; |
107 | 107 | ||
108 | m_select = 0; | 108 | m_select = 0; |
109 | m_stack = 0; | 109 | m_stack = 0; |
110 | m_lay = 0; | 110 | m_lay = 0; |
111 | m_boxToolbar = 0; | 111 | m_boxToolbar = 0; |
112 | m_boxOk = 0; | 112 | m_boxOk = 0; |
113 | m_edit = 0; | 113 | m_edit = 0; |
114 | 114 | ||
115 | m_fnLabel = 0; | 115 | m_fnLabel = 0; |
116 | m_checkPerm = 0; | 116 | m_checkPerm = 0; |
117 | m_mimeCheck = 0; | 117 | m_mimeCheck = 0; |
118 | m_viewCheck = 0; | 118 | m_viewCheck = 0; |
119 | 119 | ||
120 | m_pseudo = 0; | 120 | m_pseudo = 0; |
121 | m_pseudoLayout = 0; | 121 | m_pseudoLayout = 0; |
122 | 122 | ||
123 | m_dir = true; | 123 | m_dir = true; |
124 | m_files = true; | 124 | m_files = true; |
125 | m_custom = 0; | 125 | m_custom = 0; |
126 | m_showPopup = true; | 126 | m_showPopup = true; |
127 | 127 | ||
128 | if(m_pixmaps == 0 ) // init the pixmaps | 128 | if(m_pixmaps == 0 ) // init the pixmaps |
129 | initPics(); | 129 | initPics(); |
130 | 130 | ||
131 | m_lay = new QVBoxLayout(this); | 131 | m_lay = new QVBoxLayout(this); |
132 | init(); | 132 | init(); |
133 | m_edit->setText( fileName ); | 133 | m_edit->setText( fileName ); |
134 | } | 134 | } |
135 | void OFileSelector::initPics() | 135 | void OFileSelector::initPics() |
136 | { | 136 | { |
137 | qWarning("init pics" ); | 137 | qWarning("init pics" ); |
138 | m_pixmaps = new QMap<QString,QPixmap>; | 138 | m_pixmaps = new QMap<QString,QPixmap>; |
139 | QPixmap pm = Resource::loadPixmap( "folder" ); | 139 | QPixmap pm = Resource::loadPixmap( "folder" ); |
140 | QPixmap lnk = Resource::loadPixmap( "symlink" ); | 140 | QPixmap lnk = Resource::loadPixmap( "symlink" ); |
141 | QPainter painter( &pm ); | 141 | QPainter painter( &pm ); |
142 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 142 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
143 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 143 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
144 | m_pixmaps->insert("dirsymlink", pm ); | 144 | m_pixmaps->insert("dirsymlink", pm ); |
145 | 145 | ||
146 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); | 146 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); |
147 | QPainter pen(&pm2 ); | 147 | QPainter pen(&pm2 ); |
148 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); | 148 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); |
149 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); | 149 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); |
150 | m_pixmaps->insert("symlinkedlocked", pm2 ); | 150 | m_pixmaps->insert("symlinkedlocked", pm2 ); |
151 | 151 | ||
152 | }; | 152 | }; |
153 | // let's initialize the gui | 153 | // let's initialize the gui |
154 | /** | 154 | /** |
155 | -------------------- | 155 | -------------------- |
156 | | cmbBox Button | | 156 | | cmbBox Button | |
157 | -------------------- | 157 | -------------------- |
158 | | FileSlector | | 158 | | FileSlector | |
159 | | or | | 159 | | or | |
160 | | OSelector | | 160 | | OSelector | |
161 | | | | 161 | | | |
162 | | | | 162 | | | |
163 | ____________________ | 163 | ____________________ |
164 | | LineEdit | | 164 | | LineEdit | |
165 | ____________________ | 165 | ____________________ |
166 | | Permission Bar | | 166 | | Permission Bar | |
167 | ____________________ | 167 | ____________________ |
168 | | ViewChoose | | 168 | | ViewChoose | |
169 | ____________________ | 169 | ____________________ |
170 | | Save Cancel| | 170 | | Save Cancel| |
171 | ____________________ | 171 | ____________________ |
172 | */ | 172 | */ |
173 | void OFileSelector::delItems() | 173 | void OFileSelector::delItems() |
174 | { | 174 | { |
175 | QLayoutIterator it = m_lay->iterator(); | 175 | QLayoutIterator it = m_lay->iterator(); |
176 | while ( it.current() != 0 ){ | 176 | while ( it.current() != 0 ){ |
177 | it.deleteCurrent(); | 177 | it.deleteCurrent(); |
178 | } | 178 | } |
179 | } | 179 | } |
180 | void OFileSelector::init() | 180 | void OFileSelector::init() |
181 | { | 181 | { |
182 | 182 | ||
183 | m_stack = new QWidgetStack(this, "wstack" ); | 183 | m_stack = new QWidgetStack(this, "wstack" ); |
184 | if( m_selector == NORMAL ){ | 184 | if( m_selector == NORMAL ){ |
185 | QString currMime; | 185 | QString currMime; |
186 | if( m_mimeCheck != 0 ) | 186 | if( m_mimeCheck != 0 ) |
187 | currMime = m_mimeCheck->currentText(); | 187 | currMime = m_mimeCheck->currentText(); |
188 | 188 | ||
189 | updateMimes(); | 189 | updateMimes(); |
190 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); | 190 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); |
191 | m_stack->addWidget(m_select, NORMAL ); | 191 | m_stack->addWidget(m_select, NORMAL ); |
192 | m_lay->addWidget(m_stack ); | 192 | m_lay->addWidget(m_stack ); |
193 | m_stack->raiseWidget(NORMAL ); | 193 | m_stack->raiseWidget(NORMAL ); |
194 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); | 194 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); |
195 | }else { | 195 | }else { |
196 | initializeListView(); | 196 | initializeListView(); |
197 | } | 197 | } |
198 | 198 | ||
199 | if(m_shLne ){ | 199 | if(m_shLne ){ |
200 | initializeName(); | 200 | initializeName(); |
201 | } | 201 | } |
202 | 202 | ||
203 | if(m_shPerm ){ | 203 | if(m_shPerm ){ |
204 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); | 204 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); |
205 | m_checkPerm->setChecked( false ); | 205 | m_checkPerm->setChecked( false ); |
206 | m_lay->addWidget(m_checkPerm ); | 206 | m_lay->addWidget(m_checkPerm ); |
207 | } | 207 | } |
208 | 208 | ||
209 | if( m_shChooser ) | 209 | if( m_shChooser ) |
210 | initializeChooser(); | 210 | initializeChooser(); |
211 | 211 | ||
212 | if(m_shYesNo ) | 212 | if(m_shYesNo ) |
213 | initializeYes(); | 213 | initializeYes(); |
214 | 214 | ||
215 | 215 | ||
216 | }; | 216 | }; |
217 | 217 | ||
218 | void OFileSelector::setYesCancelVisible( bool show ) | 218 | void OFileSelector::setYesCancelVisible( bool show ) |
219 | { | 219 | { |
220 | if ( show == m_shYesNo ) | 220 | if ( show == m_shYesNo ) |
221 | return; | 221 | return; |
222 | m_shYesNo = show; | 222 | m_shYesNo = show; |
223 | if( !show ){ | 223 | if( !show ){ |
224 | delete m_ok; | 224 | delete m_ok; |
225 | delete m_cancel; | 225 | delete m_cancel; |
226 | m_ok = 0; | 226 | m_ok = 0; |
227 | m_cancel = 0; | 227 | m_cancel = 0; |
228 | // delete m_boxOk; all ready deleted in delItems | 228 | // delete m_boxOk; all ready deleted in delItems |
229 | } | 229 | } |
230 | updateLay(); // recreate it and save the other states | 230 | updateLay(); // recreate it and save the other states |
231 | } | 231 | } |
232 | 232 | ||
233 | void OFileSelector::setToolbarVisible( bool show ) | 233 | void OFileSelector::setToolbarVisible( bool show ) |
234 | { | 234 | { |
235 | if ( m_shTool == show ) | 235 | if ( m_shTool == show ) |
236 | return; | 236 | return; |
237 | if(!m_shTool ){ | 237 | if(!m_shTool ){ |
238 | delete m_boxToolbar; | 238 | delete m_boxToolbar; |
239 | delete m_homeButton; | 239 | delete m_homeButton; |
240 | delete m_docButton; | 240 | delete m_docButton; |
241 | delete m_location; | 241 | delete m_location; |
242 | delete m_up; | 242 | delete m_up; |
243 | m_boxToolbar = 0; | 243 | m_boxToolbar = 0; |
244 | m_homeButton = 0; | 244 | m_homeButton = 0; |
245 | m_docButton = 0; | 245 | m_docButton = 0; |
246 | m_location = 0; | 246 | m_location = 0; |
247 | m_up = 0; | 247 | m_up = 0; |
248 | }; | 248 | }; |
249 | updateLay();// overkill fix it | 249 | updateLay();// overkill fix it |
250 | } | 250 | } |
251 | 251 | ||
252 | void OFileSelector::setPermissionBarVisible( bool show ) | 252 | void OFileSelector::setPermissionBarVisible( bool show ) |
253 | { | 253 | { |
254 | if( show == m_shPerm ) | 254 | if( show == m_shPerm ) |
255 | return; | 255 | return; |
256 | 256 | ||
257 | m_shPerm = show; | 257 | m_shPerm = show; |
258 | 258 | ||
259 | updateLay(); | 259 | updateLay(); |
260 | } | 260 | } |
261 | void OFileSelector::setLineEditVisible( bool show ) | 261 | void OFileSelector::setLineEditVisible( bool show ) |
262 | { | 262 | { |
263 | if( show == m_shLne ) | 263 | if( show == m_shLne ) |
264 | return; | 264 | return; |
265 | 265 | ||
266 | m_shLne = show; | 266 | m_shLne = show; |
267 | if( !show ){ | 267 | if( !show ){ |
268 | delete m_edit; | 268 | delete m_edit; |
269 | delete m_fnLabel; | 269 | delete m_fnLabel; |
270 | m_edit = 0; | 270 | m_edit = 0; |
271 | m_fnLabel = 0; | 271 | m_fnLabel = 0; |
272 | //delete m_boxName; will be deleted | 272 | //delete m_boxName; will be deleted |
273 | } | 273 | } |
274 | updateLay(); | 274 | updateLay(); |
275 | } | 275 | } |
276 | void OFileSelector::setChooserVisible( bool show ) | 276 | void OFileSelector::setChooserVisible( bool show ) |
277 | { | 277 | { |
278 | if( show = m_shChooser ) | 278 | if( show = m_shChooser ) |
279 | return; | 279 | return; |
280 | m_shChooser = show; | 280 | m_shChooser = show; |
281 | if( !show ){ | 281 | if( !show ){ |
282 | delete m_mimeCheck; | 282 | delete m_mimeCheck; |
283 | delete m_viewCheck; | 283 | delete m_viewCheck; |
284 | m_mimeCheck = 0; | 284 | m_mimeCheck = 0; |
285 | m_viewCheck = 0; | 285 | m_viewCheck = 0; |
286 | } | 286 | } |
287 | updateLay(); | 287 | updateLay(); |
288 | } | 288 | } |
289 | QCheckBox* OFileSelector::permissionCheckbox( ) | 289 | QCheckBox* OFileSelector::permissionCheckbox( ) |
290 | { | 290 | { |
291 | return m_checkPerm; | 291 | return m_checkPerm; |
292 | } | 292 | } |
293 | void OFileSelector::setCaseSensetive( bool caSe ) | 293 | void OFileSelector::setCaseSensetive( bool caSe ) |
294 | { | 294 | { |
295 | m_case = caSe; | 295 | m_case = caSe; |
296 | reparse(); | 296 | reparse(); |
297 | } | 297 | } |
298 | void OFileSelector::setShowFiles(bool files ){ | 298 | void OFileSelector::setShowFiles(bool files ){ |
299 | m_files = files; | 299 | m_files = files; |
300 | reparse(); | 300 | reparse(); |
301 | } | 301 | } |
302 | void OFileSelector::setPopupMenu(QPopupMenu *pop ) | 302 | void OFileSelector::setPopupMenu(QPopupMenu *pop ) |
303 | { | 303 | { |
304 | //delete oldpopup; | 304 | //delete oldpopup; |
305 | m_custom = pop; | 305 | m_custom = pop; |
306 | } | 306 | } |
307 | bool OFileSelector::setPermission( ) const | 307 | bool OFileSelector::setPermission( ) const |
308 | { | 308 | { |
309 | if( m_checkPerm == 0 ) | 309 | if( m_checkPerm == 0 ) |
310 | return false; | 310 | return false; |
311 | else | 311 | else |
312 | return m_checkPerm->isChecked(); | 312 | return m_checkPerm->isChecked(); |
313 | } | 313 | } |
314 | void OFileSelector::setPermissionChecked( bool check ) | 314 | void OFileSelector::setPermissionChecked( bool check ) |
315 | { | 315 | { |
316 | if( m_checkPerm == 0 ) | 316 | if( m_checkPerm == 0 ) |
317 | return; | 317 | return; |
318 | m_checkPerm->setChecked( check ); | 318 | m_checkPerm->setChecked( check ); |
319 | } | 319 | } |
320 | QString OFileSelector::selectedName( )const | 320 | QString OFileSelector::selectedName( )const |
321 | { | 321 | { |
322 | QString string; | 322 | QString string; |
323 | if( m_selector == NORMAL ){ | 323 | if( m_selector == NORMAL ){ |
324 | const DocLnk *lnk = m_select->selected(); | 324 | const DocLnk *lnk = m_select->selected(); |
325 | string = lnk->file(); | 325 | string = lnk->file(); |
326 | }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | 326 | }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { |
327 | QListViewItem *item = m_View->currentItem(); | 327 | QListViewItem *item = m_View->currentItem(); |
328 | if(item != 0 ){ | 328 | if(item != 0 ){ |
329 | string = item->text( 1 ); | 329 | string = item->text( 1 ); |
330 | } | 330 | } |
331 | } | 331 | } |
332 | return string; | 332 | return string; |
333 | } | 333 | } |
334 | QStringList OFileSelector::selectedNames()const | 334 | QStringList OFileSelector::selectedNames()const |
335 | { | 335 | { |
336 | QStringList list; | 336 | QStringList list; |
337 | return list; | 337 | return list; |
338 | } | 338 | } |
339 | DocLnk OFileSelector::selectedDocument( )const | 339 | DocLnk OFileSelector::selectedDocument( )const |
340 | { | 340 | { |
341 | DocLnk lnk; | 341 | DocLnk lnk; |
342 | return lnk; | 342 | return lnk; |
343 | } | 343 | } |
344 | void OFileSelector::updateLay() | 344 | void OFileSelector::updateLay() |
345 | { | 345 | { |
346 | /* if( m_shTool ) | 346 | /* if( m_shTool ) |
347 | // | 347 | // |
348 | else | 348 | else |
349 | // hide | 349 | // hide |
350 | */ | 350 | */ |
351 | // save the state | 351 | // save the state |
352 | bool check = false; | 352 | bool check = false; |
353 | if( m_checkPerm != 0 ) | 353 | if( m_checkPerm != 0 ) |
354 | check = m_checkPerm->isChecked(); | 354 | check = m_checkPerm->isChecked(); |
355 | QString text; | 355 | QString text; |
356 | 356 | ||
357 | if( m_edit != 0 ) | 357 | if( m_edit != 0 ) |
358 | text = m_edit->text(); | 358 | text = m_edit->text(); |
359 | // save current mimetype | 359 | // save current mimetype |
360 | 360 | ||
361 | delItems(); | 361 | delItems(); |
362 | delete m_checkPerm; | 362 | delete m_checkPerm; |
363 | m_checkPerm = 0; | 363 | m_checkPerm = 0; |
364 | delete m_edit; | 364 | delete m_edit; |
365 | m_edit = 0; | 365 | m_edit = 0; |
366 | delete m_fnLabel; | 366 | delete m_fnLabel; |
367 | m_fnLabel = 0; | 367 | m_fnLabel = 0; |
368 | delete m_ok; | 368 | delete m_ok; |
369 | m_ok = 0; | 369 | m_ok = 0; |
370 | delete m_cancel; | 370 | delete m_cancel; |
371 | m_cancel = 0; | 371 | m_cancel = 0; |
372 | delete m_mimeCheck; | 372 | delete m_mimeCheck; |
373 | m_mimeCheck = 0; | 373 | m_mimeCheck = 0; |
374 | delete m_viewCheck; | 374 | delete m_viewCheck; |
375 | m_viewCheck = 0; | 375 | m_viewCheck = 0; |
376 | delete m_select; // test | 376 | delete m_select; // test |
377 | delete m_stack; | 377 | delete m_stack; |
378 | //delete m_list; | 378 | //delete m_list; |
379 | init(); | 379 | init(); |
380 | if( m_shLne ) | 380 | if( m_shLne ) |
381 | m_edit->setText(text ); | 381 | m_edit->setText(text ); |
382 | if( m_shPerm ) | 382 | if( m_shPerm ) |
383 | m_checkPerm->setChecked(check ); | 383 | m_checkPerm->setChecked(check ); |
384 | } | 384 | } |
385 | // let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve | 385 | // let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve |
386 | // insert QListViewItems with the right options | 386 | // insert QListViewItems with the right options |
387 | bool OFileSelector::compliesMime(const QString &path, const QString &mime ) | 387 | bool OFileSelector::compliesMime(const QString &path, const QString &mime ) |
388 | { | 388 | { |
389 | if( mime == "All" ) | 389 | if( mime == "All" ) |
390 | return true; | 390 | return true; |
391 | MimeType type( path ); | 391 | MimeType type( path ); |
392 | if( type.id() == mime ) | 392 | if( type.id() == mime ) |
393 | return true; | 393 | return true; |
394 | return false; | 394 | return false; |
395 | } | 395 | } |
396 | 396 | ||
397 | void OFileSelector::reparse() | 397 | void OFileSelector::reparse() |
398 | { | 398 | { |
399 | if(m_View== 0 || m_selector == NORMAL) | 399 | if(m_View== 0 || m_selector == NORMAL) |
400 | return; | 400 | return; |
401 | 401 | ||
402 | m_View->clear(); | 402 | m_View->clear(); |
403 | 403 | ||
404 | 404 | ||
405 | QString currMime =m_mimeCheck->currentText(); | 405 | QString currMime =m_mimeCheck->currentText(); |
406 | // update the mimetype now | 406 | // update the mimetype now |
407 | if( m_autoMime ) { | 407 | if( m_autoMime ) { |
408 | QDir dir( m_currentDir ); | 408 | QDir dir( m_currentDir ); |
409 | m_mimetypes.clear(); | 409 | m_mimetypes.clear(); |
410 | m_mimeCheck->clear(); | 410 | m_mimeCheck->clear(); |
411 | dir.setFilter( QDir::Files | QDir::Readable ); | 411 | dir.setFilter( QDir::Files | QDir::Readable ); |
412 | dir.setSorting(QDir::Size ); | 412 | dir.setSorting(QDir::Size ); |
413 | const QFileInfoList *list = dir.entryInfoList(); | 413 | const QFileInfoList *list = dir.entryInfoList(); |
414 | QFileInfoListIterator it( *list ); | 414 | QFileInfoListIterator it( *list ); |
415 | QFileInfo *fi; | 415 | QFileInfo *fi; |
416 | while( (fi=it.current()) ){ | 416 | while( (fi=it.current()) ){ |
417 | if(fi->extension() == QString::fromLatin1("desktop") ){ | 417 | if(fi->extension() == QString::fromLatin1("desktop") ){ |
418 | ++it; | 418 | ++it; |
419 | continue; | 419 | continue; |
420 | } | 420 | } |
421 | MimeType type(fi->filePath() ); | 421 | MimeType type(fi->filePath() ); |
422 | if( !m_mimetypes.contains( type.id() ) ) | 422 | if( !m_mimetypes.contains( type.id() ) ) |
423 | m_mimetypes.append( type.id() ); | 423 | m_mimetypes.append( type.id() ); |
424 | 424 | ||
425 | ++it; | 425 | ++it; |
426 | } | 426 | } |
427 | m_mimetypes.prepend("All" ); | 427 | m_mimetypes.prepend("All" ); |
428 | m_mimeCheck->insertStringList(m_mimetypes ); | 428 | m_mimeCheck->insertStringList(m_mimetypes ); |
429 | // set it to the current mimetype | 429 | // set it to the current mimetype |
430 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); | 430 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); |
431 | }; | 431 | }; |
432 | QDir dir( m_currentDir ); | 432 | QDir dir( m_currentDir ); |
433 | //dir.setFilter(-1 ); | 433 | //dir.setFilter(-1 ); |
434 | int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed; | 434 | int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed; |
435 | if( m_case ) | 435 | if( m_case ) |
436 | sort = QDir::IgnoreCase; | 436 | sort = QDir::IgnoreCase; |
437 | dir.setSorting( sort ); | 437 | dir.setSorting( sort ); |
438 | 438 | ||
439 | int filter; | 439 | int filter; |
440 | /* if( m_dir && !m_files) | 440 | /* if( m_dir && !m_files) |
441 | filter |= QDir::Dirs; | 441 | filter |= QDir::Dirs; |
442 | else if( !m_dir && m_files ) | 442 | else if( !m_dir && m_files ) |
443 | filter |= QDir::Files; | 443 | filter |= QDir::Files; |
444 | else | 444 | else |
445 | filter |= QDir::All; | 445 | filter |= QDir::All; |
446 | */ | 446 | */ |
447 | if( m_selector == EXTENDED_ALL ) | 447 | if( m_selector == EXTENDED_ALL ) |
448 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 448 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
449 | else | 449 | else |
450 | filter = QDir::Files | QDir::Dirs | QDir::All; | 450 | filter = QDir::Files | QDir::Dirs | QDir::All; |
451 | dir.setFilter( filter ); | 451 | dir.setFilter( filter ); |
452 | 452 | ||
453 | const QFileInfoList *list = dir.entryInfoList(); | 453 | const QFileInfoList *list = dir.entryInfoList(); |
454 | QFileInfoListIterator it( *list ); | 454 | QFileInfoListIterator it( *list ); |
455 | QFileInfo *fi; | 455 | QFileInfo *fi; |
456 | while( (fi=it.current()) ){ | 456 | while( (fi=it.current()) ){ |
457 | if(fi->fileName() == ".." || fi->fileName() == "." ){ | 457 | if(fi->fileName() == ".." || fi->fileName() == "." ){ |
458 | ++it; | 458 | ++it; |
459 | continue; | 459 | continue; |
460 | } | 460 | } |
461 | qWarning("Test: %s", fi->fileName().latin1() ); | 461 | qWarning("Test: %s", fi->fileName().latin1() ); |
462 | if(fi->isSymLink() ){ | 462 | if(fi->isSymLink() ){ |
463 | qWarning("Symlink %s", fi->fileName().latin1() ); | 463 | qWarning("Symlink %s", fi->fileName().latin1() ); |
464 | QString file = fi->dirPath(true)+"/"+ fi->readLink(); | 464 | QString file = fi->dirPath(true)+"/"+ fi->readLink(); |
465 | qWarning("File ->%s", file.latin1() ); | 465 | qWarning("File ->%s", file.latin1() ); |
466 | for(int i=0; i<=4; i++ ){ // prepend from dos | 466 | for(int i=0; i<=4; i++ ){ // prepend from dos |
467 | QFileInfo info( file ); | 467 | QFileInfo info( file ); |
468 | if( !info.exists() ){ | 468 | if( !info.exists() ){ |
469 | qWarning("does not exist" ); | 469 | qWarning("does not exist" ); |
470 | addSymlink(currMime, fi, TRUE ); | 470 | addSymlink(currMime, fi, TRUE ); |
471 | break; | 471 | break; |
472 | }else if( info.isDir() ){ | 472 | }else if( info.isDir() ){ |
473 | qWarning("isDir" ); | 473 | qWarning("isDir" ); |
474 | addDir(currMime, fi, TRUE ); | 474 | addDir(currMime, fi, TRUE ); |
475 | break; | 475 | break; |
476 | }else if( info.isFile() ){ | 476 | }else if( info.isFile() ){ |
477 | qWarning("isFile" ); | 477 | qWarning("isFile" ); |
478 | addFile(currMime, fi, TRUE ); | 478 | addFile(currMime, fi, TRUE ); |
479 | break; | 479 | break; |
480 | }else if( info.isSymLink() ){ | 480 | }else if( info.isSymLink() ){ |
481 | file = info.dirPath(true)+ "/"+ info.readLink(); | 481 | file = info.dirPath(true)+ "/"+ info.readLink(); |
482 | qWarning("isSymlink again %s", file.latin1() ); | 482 | qWarning("isSymlink again %s", file.latin1() ); |
483 | }else if( i == 4 ){ // just insert it and have the symlink symbol | 483 | }else if( i == 4 ){ // just insert it and have the symlink symbol |
484 | addSymlink(currMime, fi ); | 484 | addSymlink(currMime, fi ); |
485 | qWarning("level too deep" ); | 485 | qWarning("level too deep" ); |
486 | } | 486 | } |
487 | } | 487 | } |
488 | }else if( fi->isDir() ){ | 488 | }else if( fi->isDir() ){ |
489 | addDir(currMime, fi ); | 489 | addDir(currMime, fi ); |
490 | }else if( fi->isFile() ) { // file ? | 490 | }else if( fi->isFile() ) { // file ? |
491 | addFile(currMime, fi ); | 491 | addFile(currMime, fi ); |
492 | } | 492 | } |
493 | ++it; | 493 | ++it; |
494 | } | 494 | } |
495 | m_View->sort(); | 495 | m_View->sort(); |
496 | } | 496 | } |
497 | QString OFileSelector::directory()const | 497 | QString OFileSelector::directory()const |
498 | { | 498 | { |
499 | return m_currentDir; | 499 | return m_currentDir; |
500 | } | 500 | } |
501 | int OFileSelector::fileCount() | 501 | int OFileSelector::fileCount() |
502 | { | 502 | { |
503 | return 0; | 503 | return 0; |
504 | } | 504 | } |
505 | void OFileSelector::slotOk( ) | 505 | void OFileSelector::slotOk( ) |
506 | { | 506 | { |
507 | emit ok(); | 507 | emit ok(); |
508 | } | 508 | } |
509 | void OFileSelector::slotCancel( ) | 509 | void OFileSelector::slotCancel( ) |
510 | { | 510 | { |
511 | emit cancel(); | 511 | emit cancel(); |
512 | } | 512 | } |
513 | 513 | ||
514 | void OFileSelector::initializeName() | 514 | void OFileSelector::initializeName() |
515 | { | 515 | { |
516 | m_boxName = new QHBoxLayout(this ); | 516 | m_boxName = new QHBoxLayout(this ); |
517 | m_edit = new QLineEdit(this ); | 517 | m_edit = new QLineEdit(this ); |
518 | m_fnLabel = new QLabel(this ); | 518 | m_fnLabel = new QLabel(this ); |
519 | m_fnLabel->setText(tr("Name:") ); | 519 | m_fnLabel->setText(tr("Name:") ); |
520 | m_boxName->addWidget(m_fnLabel ); | 520 | m_boxName->addWidget(m_fnLabel ); |
521 | m_boxName->insertSpacing(1, 8 ); | 521 | m_boxName->insertSpacing(1, 8 ); |
522 | m_boxName->addWidget(m_edit, 100 ); | 522 | m_boxName->addWidget(m_edit, 100 ); |
523 | 523 | ||
524 | m_lay->addLayout(m_boxName); | 524 | m_lay->addLayout(m_boxName); |
525 | } | 525 | } |
526 | void OFileSelector::initializeYes() | 526 | void OFileSelector::initializeYes() |
527 | { | 527 | { |
528 | m_ok = new QPushButton("&Save", this, "save" ); | 528 | m_ok = new QPushButton("&Save", this, "save" ); |
529 | m_cancel = new QPushButton("C&ancel", this, "cancel" ); | 529 | m_cancel = new QPushButton("C&ancel", this, "cancel" ); |
530 | m_boxOk = new QHBoxLayout(this ); | 530 | m_boxOk = new QHBoxLayout(this ); |
531 | m_boxOk->addWidget( m_ok, Qt::AlignHCenter ); | 531 | m_boxOk->addWidget( m_ok, Qt::AlignHCenter ); |
532 | m_boxOk->insertSpacing(1, 8 ); | 532 | m_boxOk->insertSpacing(1, 8 ); |
533 | m_boxOk->addWidget( m_cancel, Qt::AlignHCenter); | 533 | m_boxOk->addWidget( m_cancel, Qt::AlignHCenter); |
534 | m_lay->addLayout(m_boxOk ); | 534 | m_lay->addLayout(m_boxOk ); |
535 | connect(m_ok, SIGNAL(clicked() ), | 535 | connect(m_ok, SIGNAL(clicked() ), |
536 | this, SLOT(slotOk() ) ); | 536 | this, SLOT(slotOk() ) ); |
537 | connect(m_cancel, SIGNAL(clicked() ), | 537 | connect(m_cancel, SIGNAL(clicked() ), |
538 | this, SLOT(slotCancel() ) ); | 538 | this, SLOT(slotCancel() ) ); |
539 | 539 | ||
540 | } | 540 | } |
541 | void OFileSelector::initializeChooser() | 541 | void OFileSelector::initializeChooser() |
542 | { | 542 | { |
543 | m_boxView = new QHBoxLayout(this ); | 543 | m_boxView = new QHBoxLayout(this ); |
544 | 544 | ||
545 | m_mimeCheck = new QComboBox(this, "mime check"); | 545 | m_mimeCheck = new QComboBox(this, "mime check"); |
546 | m_viewCheck = new QComboBox(this, "view check"); | 546 | m_viewCheck = new QComboBox(this, "view check"); |
547 | m_boxView->addWidget(m_viewCheck, 0 ); | 547 | m_boxView->addWidget(m_viewCheck, 0 ); |
548 | m_boxView->insertSpacing(1, 8 ); | 548 | m_boxView->insertSpacing(1, 8 ); |
549 | m_boxView->addWidget(m_mimeCheck, 0 ); | 549 | m_boxView->addWidget(m_mimeCheck, 0 ); |
550 | m_lay->addLayout(m_boxView ); | 550 | m_lay->addLayout(m_boxView ); |
551 | 551 | ||
552 | m_viewCheck->insertItem(tr("Documents") ); | 552 | m_viewCheck->insertItem(tr("Documents") ); |
553 | m_viewCheck->insertItem(tr("Files") ); | 553 | m_viewCheck->insertItem(tr("Files") ); |
554 | m_viewCheck->insertItem(tr("All Files") ); | 554 | m_viewCheck->insertItem(tr("All Files") ); |
555 | 555 | ||
556 | if(!m_autoMime ) | 556 | if(!m_autoMime ) |
557 | m_mimeCheck->insertItem(m_mimetypes.join("," ) ); | 557 | m_mimeCheck->insertItem(m_mimetypes.join("," ) ); |
558 | else{ // check | 558 | else{ // check |
559 | updateMimes(); | 559 | updateMimes(); |
560 | m_mimeCheck->insertStringList( m_mimetypes ); | 560 | m_mimeCheck->insertStringList( m_mimetypes ); |
561 | } | 561 | } |
562 | 562 | ||
563 | connect( m_viewCheck, SIGNAL(activated(const QString &) ), | 563 | connect( m_viewCheck, SIGNAL(activated(const QString &) ), |
564 | this, SLOT(slotViewCheck(const QString & ) ) ); | 564 | this, SLOT(slotViewCheck(const QString & ) ) ); |
565 | 565 | ||
566 | connect( m_mimeCheck, SIGNAL(activated(const QString &) ), | 566 | connect( m_mimeCheck, SIGNAL(activated(const QString &) ), |
567 | this, SLOT(slotMimeCheck(const QString & ) ) ); | 567 | this, SLOT(slotMimeCheck(const QString & ) ) ); |
568 | } | 568 | } |
569 | void OFileSelector::slotMimeCheck(const QString &view ){ | 569 | void OFileSelector::slotMimeCheck(const QString &view ){ |
570 | if(m_selector == NORMAL ){ | 570 | if(m_selector == NORMAL ){ |
571 | delete m_select; | 571 | delete m_select; |
572 | m_select = new FileSelector(view == "All" ? QString::null : view | 572 | m_select = new FileSelector(view == "All" ? QString::null : view |
573 | , m_stack, "fileselector", FALSE, FALSE ); | 573 | , m_stack, "fileselector", FALSE, FALSE ); |
574 | m_stack->addWidget( m_select, NORMAL ); | 574 | m_stack->addWidget( m_select, NORMAL ); |
575 | m_stack->raiseWidget( NORMAL ); | 575 | m_stack->raiseWidget( NORMAL ); |
576 | }else{ | 576 | }else{ |
577 | reparse(); | 577 | reparse(); |
578 | } | 578 | } |
579 | } | 579 | } |
580 | 580 | ||
581 | void OFileSelector::slotViewCheck(const QString &view ){ | 581 | void OFileSelector::slotViewCheck(const QString &view ){ |
582 | qWarning("changed: show %s", view.latin1() ); | 582 | qWarning("changed: show %s", view.latin1() ); |
583 | // if the current view is the one | 583 | // if the current view is the one |
584 | QString currMime = m_mimeCheck->currentText(); | 584 | QString currMime = m_mimeCheck->currentText(); |
585 | if( view == QString::fromLatin1("Documents") ){ | 585 | if( view == QString::fromLatin1("Documents") ){ |
586 | // get the mimetype now | 586 | // get the mimetype now |
587 | // check if we're the current widget and return | 587 | // check if we're the current widget and return |
588 | if( m_View != 0) { // delete 0 shouldn't crash but it did :( | 588 | if( m_View != 0) { // delete 0 shouldn't crash but it did :( |
589 | delete m_View; | 589 | delete m_View; |
590 | delete m_boxToolbar; | 590 | delete m_boxToolbar; |
591 | delete m_homeButton; | 591 | delete m_homeButton; |
592 | delete m_docButton; | 592 | delete m_docButton; |
593 | delete m_location; | 593 | delete m_location; |
594 | delete m_up; | 594 | delete m_up; |
595 | delete m_pseudo; | 595 | delete m_pseudo; |
596 | delete m_pseudoLayout; | 596 | delete m_pseudoLayout; |
597 | } | 597 | } |
598 | m_View = 0; | 598 | m_View = 0; |
599 | m_boxToolbar = 0; | 599 | m_boxToolbar = 0; |
600 | m_homeButton = 0; | 600 | m_homeButton = 0; |
601 | m_docButton = 0; | 601 | m_docButton = 0; |
602 | m_location = 0; | 602 | m_location = 0; |
603 | m_up = 0; | 603 | m_up = 0; |
604 | m_pseudo = 0; | 604 | m_pseudo = 0; |
605 | m_pseudoLayout = 0; | 605 | m_pseudoLayout = 0; |
606 | 606 | ||
607 | delete m_select; | 607 | delete m_select; |
608 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime, | 608 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime, |
609 | m_stack,"fileselector", FALSE, FALSE ); | 609 | m_stack,"fileselector", FALSE, FALSE ); |
610 | m_stack->addWidget( m_select, NORMAL ); | 610 | m_stack->addWidget( m_select, NORMAL ); |
611 | m_mimeCheck->clear(); | 611 | m_mimeCheck->clear(); |
612 | m_selector = NORMAL; | 612 | m_selector = NORMAL; |
613 | updateMimes(); | 613 | updateMimes(); |
614 | m_mimeCheck->insertStringList( m_mimetypes ); | 614 | m_mimeCheck->insertStringList( m_mimetypes ); |
615 | m_stack->raiseWidget( NORMAL ); | 615 | m_stack->raiseWidget( NORMAL ); |
616 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); | 616 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); |
617 | 617 | ||
618 | }else if(view == QString::fromLatin1("Files") ){ | 618 | }else if(view == QString::fromLatin1("Files") ){ |
619 | // remove from the stack | 619 | // remove from the stack |
620 | delete m_select; | 620 | delete m_select; |
621 | m_select = 0; | 621 | m_select = 0; |
622 | delete m_View; | 622 | delete m_View; |
623 | m_View = 0; | 623 | m_View = 0; |
624 | 624 | ||
625 | delete m_boxToolbar; | 625 | delete m_boxToolbar; |
626 | delete m_homeButton; | 626 | delete m_homeButton; |
627 | delete m_docButton; | 627 | delete m_docButton; |
628 | delete m_location; | 628 | delete m_location; |
629 | delete m_up; | 629 | delete m_up; |
630 | delete m_pseudo; | 630 | delete m_pseudo; |
631 | delete m_pseudoLayout; | 631 | delete m_pseudoLayout; |
632 | m_boxToolbar = 0; | 632 | m_boxToolbar = 0; |
633 | m_homeButton = 0; | 633 | m_homeButton = 0; |
634 | m_docButton = 0; | 634 | m_docButton = 0; |
635 | m_location = 0; | 635 | m_location = 0; |
636 | m_up = 0; | 636 | m_up = 0; |
637 | m_pseudo = 0; | 637 | m_pseudo = 0; |
638 | m_pseudoLayout = 0; | 638 | m_pseudoLayout = 0; |
639 | 639 | ||
640 | m_selector = EXTENDED; | 640 | m_selector = EXTENDED; |
641 | // create the ListView or IconView | 641 | // create the ListView or IconView |
642 | initializeListView(); | 642 | initializeListView(); |
643 | 643 | ||
644 | reparse(); | 644 | reparse(); |
645 | }else if(view == QString::fromLatin1("All Files") ) { | 645 | }else if(view == QString::fromLatin1("All Files") ) { |
646 | // remove from the stack | 646 | // remove from the stack |
647 | delete m_select; | 647 | delete m_select; |
648 | m_select = 0; | 648 | m_select = 0; |
649 | delete m_View; | 649 | delete m_View; |
650 | m_View = 0; | 650 | m_View = 0; |
651 | delete m_boxToolbar; | 651 | delete m_boxToolbar; |
652 | delete m_homeButton; | 652 | delete m_homeButton; |
653 | delete m_docButton; | 653 | delete m_docButton; |
654 | delete m_location; | 654 | delete m_location; |
655 | delete m_up; | 655 | delete m_up; |
656 | delete m_pseudo; | 656 | delete m_pseudo; |
657 | delete m_pseudoLayout; | 657 | delete m_pseudoLayout; |
658 | m_boxToolbar = 0; | 658 | m_boxToolbar = 0; |
659 | m_homeButton = 0; | 659 | m_homeButton = 0; |
660 | m_docButton = 0; | 660 | m_docButton = 0; |
661 | m_location = 0; | 661 | m_location = 0; |
662 | m_up = 0; | 662 | m_up = 0; |
663 | m_pseudo = 0; | 663 | m_pseudo = 0; |
664 | m_pseudoLayout = 0; | 664 | m_pseudoLayout = 0; |
665 | 665 | ||
666 | m_selector = EXTENDED_ALL; | 666 | m_selector = EXTENDED_ALL; |
667 | initializeListView(); | 667 | initializeListView(); |
668 | reparse(); | 668 | reparse(); |
669 | }; | 669 | }; |
670 | }; | 670 | }; |
671 | 671 | ||
672 | 672 | ||
673 | void OFileSelector::updateMimes() // lets check which mode is active | 673 | void OFileSelector::updateMimes() // lets check which mode is active |
674 | // check the current dir for items then | 674 | // check the current dir for items then |
675 | { | 675 | { |
676 | m_mimetypes.clear(); | 676 | m_mimetypes.clear(); |
677 | m_mimetypes.append("All" ); | 677 | m_mimetypes.append("All" ); |
678 | if( m_selector == NORMAL ){ | 678 | if( m_selector == NORMAL ){ |
679 | DocLnkSet set; | 679 | DocLnkSet set; |
680 | Global::findDocuments(&set, QString::null ); | 680 | Global::findDocuments(&set, QString::null ); |
681 | QListIterator<DocLnk> dit( set.children() ); | 681 | QListIterator<DocLnk> dit( set.children() ); |
682 | for ( ; dit.current(); ++dit ) { | 682 | for ( ; dit.current(); ++dit ) { |
683 | if( !m_mimetypes.contains((*dit)->type() ) ) | 683 | if( !m_mimetypes.contains((*dit)->type() ) ) |
684 | m_mimetypes.append( (*dit)->type() ); | 684 | m_mimetypes.append( (*dit)->type() ); |
685 | } | 685 | } |
686 | }else{ | 686 | }else{ |
687 | // should be allreday updatet | 687 | // should be allreday updatet |
688 | ; | 688 | ; |
689 | } | 689 | } |
690 | }; | 690 | }; |
691 | void OFileSelector::initializeListView() | 691 | void OFileSelector::initializeListView() |
692 | { | 692 | { |
693 | // just to make sure but clean it up better FIXME | 693 | // just to make sure but clean it up better FIXME |
694 | delete m_View; | 694 | delete m_View; |
695 | m_View = 0; | 695 | m_View = 0; |
696 | delete m_boxToolbar; | 696 | delete m_boxToolbar; |
697 | delete m_homeButton; | 697 | delete m_homeButton; |
698 | delete m_docButton; | 698 | delete m_docButton; |
699 | delete m_location; | 699 | delete m_location; |
700 | delete m_up; | 700 | delete m_up; |
701 | delete m_pseudo; | 701 | delete m_pseudo; |
702 | delete m_pseudoLayout; | 702 | delete m_pseudoLayout; |
703 | m_boxToolbar = 0; | 703 | m_boxToolbar = 0; |
704 | m_homeButton = 0; | 704 | m_homeButton = 0; |
705 | m_docButton = 0; | 705 | m_docButton = 0; |
706 | m_location = 0; | 706 | m_location = 0; |
707 | m_up = 0; | 707 | m_up = 0; |
708 | m_pseudo = 0; | 708 | m_pseudo = 0; |
709 | m_pseudoLayout = 0; | 709 | m_pseudoLayout = 0; |
710 | // time for the toolbar | 710 | // time for the toolbar |
711 | m_pseudo = new QWidget(m_stack, "Pseudo Widget"); | 711 | m_pseudo = new QWidget(m_stack, "Pseudo Widget"); |
712 | m_pseudoLayout = new QVBoxLayout(m_pseudo ); | 712 | m_pseudoLayout = new QVBoxLayout(m_pseudo ); |
713 | if(m_shTool ){ | 713 | if(m_shTool ){ |
714 | m_boxToolbar = new QHBoxLayout( ); | 714 | m_boxToolbar = new QHBoxLayout( ); |
715 | m_boxToolbar->setAutoAdd( true ); | 715 | m_boxToolbar->setAutoAdd( true ); |
716 | m_location = new QComboBox(m_pseudo ); | 716 | m_location = new QComboBox(m_pseudo ); |
717 | 717 | ||
718 | m_up = new QPushButton(Resource::loadIconSet("up"),"", m_pseudo,"cdUpButton"); | 718 | m_up = new QPushButton(Resource::loadIconSet("up"),"", m_pseudo,"cdUpButton"); |
719 | m_up->setMinimumSize( QSize( 20, 20 ) ); | 719 | m_up->setMinimumSize( QSize( 20, 20 ) ); |
720 | m_up->setMaximumSize( QSize( 20, 20 ) ); | 720 | m_up->setMaximumSize( QSize( 20, 20 ) ); |
721 | connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); | 721 | connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); |
722 | m_up->setFlat(TRUE); | 722 | m_up->setFlat(TRUE); |
723 | 723 | ||
724 | m_homeButton = new QPushButton(Resource::loadIconSet("home") , "", m_pseudo); | 724 | m_homeButton = new QPushButton(Resource::loadIconSet("home") , "", m_pseudo); |
725 | m_homeButton->setMinimumSize( QSize( 20, 20 ) ); | 725 | m_homeButton->setMinimumSize( QSize( 20, 20 ) ); |
726 | m_homeButton->setMaximumSize( QSize( 20, 20 ) ); | 726 | m_homeButton->setMaximumSize( QSize( 20, 20 ) ); |
727 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); | 727 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); |
728 | m_homeButton->setFlat(TRUE); | 728 | m_homeButton->setFlat(TRUE); |
729 | 729 | ||
730 | m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", m_pseudo,"docsButton"); | 730 | m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", m_pseudo,"docsButton"); |
731 | m_docButton->setMinimumSize( QSize( 20, 20 ) ); | 731 | m_docButton->setMinimumSize( QSize( 20, 20 ) ); |
732 | m_docButton->setMaximumSize( QSize( 20, 20 ) ); | 732 | m_docButton->setMaximumSize( QSize( 20, 20 ) ); |
733 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); | 733 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); |
734 | m_docButton->setFlat(TRUE); | 734 | m_docButton->setFlat(TRUE); |
735 | 735 | ||
736 | m_boxToolbar->addWidget(m_location ); | 736 | m_boxToolbar->addWidget(m_location ); |
737 | m_boxToolbar->addWidget(m_up ); | 737 | m_boxToolbar->addWidget(m_up ); |
738 | m_boxToolbar->addWidget(m_homeButton ); | 738 | m_boxToolbar->addWidget(m_homeButton ); |
739 | m_boxToolbar->addWidget(m_docButton ); | 739 | m_boxToolbar->addWidget(m_docButton ); |
740 | m_pseudoLayout->addLayout(m_boxToolbar ); | 740 | m_pseudoLayout->addLayout(m_boxToolbar ); |
741 | // lets fill the combobox | 741 | // lets fill the combobox |
742 | StorageInfo storage; | 742 | StorageInfo storage; |
743 | const QList<FileSystem> &fs = storage.fileSystems(); | 743 | const QList<FileSystem> &fs = storage.fileSystems(); |
744 | QListIterator<FileSystem> it ( fs ); | 744 | QListIterator<FileSystem> it ( fs ); |
745 | for( ; it.current(); ++it ){ | 745 | for( ; it.current(); ++it ){ |
746 | const QString disk = (*it)->name(); | 746 | const QString disk = (*it)->name(); |
747 | const QString path = (*it)->path(); | 747 | const QString path = (*it)->path(); |
748 | m_location->insertItem(path+ "<-"+disk ); | 748 | m_location->insertItem(path+ "<-"+disk ); |
749 | } | 749 | } |
750 | int count = m_location->count(); | 750 | int count = m_location->count(); |
751 | m_location->insertItem(m_currentDir ); | 751 | m_location->insertItem(m_currentDir ); |
752 | m_location->setCurrentItem( count ); | 752 | m_location->setCurrentItem( count ); |
753 | }; | 753 | }; |
754 | m_View = new QListView(m_pseudo, "Extended view" ); | 754 | m_View = new QListView(m_pseudo, "Extended view" ); |
755 | m_stack->addWidget( m_pseudo, EXTENDED ); | 755 | m_stack->addWidget( m_pseudo, EXTENDED ); |
756 | m_stack->raiseWidget( EXTENDED ); | 756 | m_stack->raiseWidget( EXTENDED ); |
757 | m_pseudoLayout->addWidget(m_View ); | 757 | m_pseudoLayout->addWidget(m_View ); |
758 | QPEApplication::setStylusOperation( m_View->viewport(),QPEApplication::RightOnHold); | 758 | QPEApplication::setStylusOperation( m_View->viewport(),QPEApplication::RightOnHold); |
759 | // set up the stuff | 759 | // set up the stuff |
760 | // Pixmap Name Date Size mime | 760 | // Pixmap Name Date Size mime |
761 | //(m_View->header() )->hide(); | 761 | //(m_View->header() )->hide(); |
762 | //m_View->setRootIsDecorated(false); | 762 | //m_View->setRootIsDecorated(false); |
763 | m_View->addColumn(" "); | 763 | m_View->addColumn(" "); |
764 | m_View->addColumn(tr("Name") ); | 764 | m_View->addColumn(tr("Name") ); |
765 | m_View->addColumn(tr("Size") ); | 765 | m_View->addColumn(tr("Size") ); |
766 | m_View->addColumn(tr("Date"), 60 ); | 766 | m_View->addColumn(tr("Date"), 60 ); |
767 | m_View->addColumn(tr("Mime Type") ); | 767 | m_View->addColumn(tr("Mime Type") ); |
768 | QHeader *header = m_View->header(); | 768 | QHeader *header = m_View->header(); |
769 | header->hide(); | 769 | header->hide(); |
770 | m_View->setSorting(1 ); | 770 | m_View->setSorting(1 ); |
771 | // connect now | 771 | // connect now |
772 | connect(m_View, SIGNAL(selectionChanged() ), this, SLOT(slotSelectionChanged() ) ); | 772 | connect(m_View, SIGNAL(selectionChanged() ), this, SLOT(slotSelectionChanged() ) ); |
773 | connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); | 773 | connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); |
774 | connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), | 774 | connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), |
775 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); | 775 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); |
776 | connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), | 776 | connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), |
777 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); | 777 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); |
778 | 778 | ||
779 | 779 | ||
780 | }; | 780 | }; |
781 | /* If a item is locked depends on the mode | 781 | /* If a item is locked depends on the mode |
782 | if we're in OPEN !isReadable is locked | 782 | if we're in OPEN !isReadable is locked |
783 | if we're in SAVE !isWriteable is locked | 783 | if we're in SAVE !isWriteable is locked |
784 | 784 | ||
785 | 785 | ||
786 | */ | 786 | */ |
787 | 787 | ||
788 | 788 | ||
789 | void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){ | 789 | void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){ |
790 | qWarning("Add Files" ); | 790 | qWarning("Add Files" ); |
791 | if( !m_files ){ | 791 | if( !m_files ){ |
792 | qWarning("not mfiles" ); | 792 | qWarning("not mfiles" ); |
793 | return; | 793 | return; |
794 | } | 794 | } |
795 | 795 | ||
796 | MimeType type( info->filePath() ); | 796 | MimeType type( info->filePath() ); |
797 | QString name; | 797 | QString name; |
798 | QString dir; | 798 | QString dir; |
799 | bool locked= false; | 799 | bool locked= false; |
800 | if(mime == "All" ){ | 800 | if(mime == "All" ){ |
801 | ; | 801 | ; |
802 | }else if( type.id() != mime ) { | 802 | }else if( type.id() != mime ) { |
803 | return; | 803 | return; |
804 | } | 804 | } |
805 | QPixmap pix = type.pixmap(); | 805 | QPixmap pix = type.pixmap(); |
806 | if(pix.isNull() ) | 806 | if(pix.isNull() ) |
807 | pix = Resource::loadPixmap( "UnknownDocument-14" ); | 807 | pix = Resource::loadPixmap( "UnknownDocument-14" ); |
808 | dir = info->dirPath( true ); | 808 | dir = info->dirPath( true ); |
809 | if( symlink ) { // check if the readLink is readable | 809 | if( symlink ) { // check if the readLink is readable |
810 | // do it right later | 810 | // do it right later |
811 | name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); | 811 | name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); |
812 | }else{ // keep track of the icons | 812 | }else{ // keep track of the icons |
813 | name = info->fileName(); | 813 | name = info->fileName(); |
814 | if( m_mode == OPEN ){ | 814 | if( m_mode == OPEN ){ |
815 | if( !info->isReadable() ){ | 815 | if( !info->isReadable() ){ |
816 | locked = true; | 816 | locked = true; |
817 | pix = Resource::loadPixmap("locked" ); | 817 | pix = Resource::loadPixmap("locked" ); |
818 | } | 818 | } |
819 | }else if( m_mode == SAVE ){ | 819 | }else if( m_mode == SAVE ){ |
820 | if( !info->isWritable() ){ | 820 | if( !info->isWritable() ){ |
821 | locked = true; | 821 | locked = true; |
822 | pix = Resource::loadPixmap("locked" ); | 822 | pix = Resource::loadPixmap("locked" ); |
823 | } | 823 | } |
824 | } | 824 | } |
825 | } | 825 | } |
826 | new OFileSelectorItem( m_View, pix, name, | 826 | new OFileSelectorItem( m_View, pix, name, |
827 | info->lastModified().toString(), | 827 | info->lastModified().toString(), |
828 | QString::number( info->size() ), | 828 | QString::number( info->size() ), |
829 | dir, locked ); | 829 | dir, locked ); |
830 | } | 830 | } |
831 | void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) | 831 | void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) |
832 | { | 832 | { |
833 | if(!m_dir ) | 833 | if(!m_dir ) |
834 | return; | 834 | return; |
835 | //if( showDirs ) | 835 | //if( showDirs ) |
836 | { | 836 | { |
837 | bool locked=false; | 837 | bool locked=false; |
838 | QString name; | 838 | QString name; |
839 | QPixmap pix; | 839 | QPixmap pix; |
840 | if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ | 840 | if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ |
841 | locked = true; | 841 | locked = true; |
842 | if( symlink ){ | 842 | if( symlink ){ |
843 | pix = (*m_pixmaps)["symlinkedlocked"]; | 843 | pix = (*m_pixmaps)["symlinkedlocked"]; |
844 | }else{ | 844 | }else{ |
845 | pix = Resource::loadPixmap("lockedfolder" ); | 845 | pix = Resource::loadPixmap("lockedfolder" ); |
846 | } | 846 | } |
847 | }else{ | 847 | }else{ |
848 | if( symlink ){ | 848 | if( symlink ){ |
849 | pix = (*m_pixmaps)["dirsymlink" ]; | 849 | pix = (*m_pixmaps)["dirsymlink" ]; |
850 | }else{ | 850 | }else{ |
851 | pix = Resource::loadPixmap("folder" ); | 851 | pix = Resource::loadPixmap("folder" ); |
852 | } | 852 | } |
853 | } | 853 | } |
854 | if( symlink){ | 854 | if( symlink){ |
855 | name = info->fileName()+ "->"+ info->dirPath(true) +"/" +info->readLink(); | 855 | name = info->fileName()+ "->"+ info->dirPath(true) +"/" +info->readLink(); |
856 | 856 | ||
857 | }else{ | 857 | }else{ |
858 | //if(info->isReadable() ) | 858 | //if(info->isReadable() ) |
859 | name = info->fileName(); | 859 | name = info->fileName(); |
860 | } | 860 | } |
861 | 861 | ||
862 | new OFileSelectorItem(m_View, pix, | 862 | new OFileSelectorItem(m_View, pix, |
863 | name, info->lastModified().toString(), | 863 | name, info->lastModified().toString(), |
864 | QString::number(info->size() ),info->dirPath(true), locked, true ); | 864 | QString::number(info->size() ),info->dirPath(true), locked, true ); |
865 | 865 | ||
866 | } | 866 | } |
867 | } | 867 | } |
868 | void OFileSelector::setShowDirs(bool dir ) | 868 | void OFileSelector::setShowDirs(bool dir ) |
869 | { | 869 | { |
870 | m_dir = dir; | 870 | m_dir = dir; |
871 | reparse(); | 871 | reparse(); |
872 | } | 872 | } |
873 | 873 | ||
874 | void OFileSelector::slotFileSelected(const QString &string ) | 874 | void OFileSelector::slotFileSelected(const QString &string ) |
875 | { | 875 | { |
876 | if(m_shLne ) | 876 | if(m_shLne ) |
877 | m_edit->setText( string ); | 877 | m_edit->setText( string ); |
878 | 878 | ||
879 | emit fileSelected( string ); | 879 | emit fileSelected( string ); |
880 | // do AppLnk stuff | 880 | // do AppLnk stuff |
881 | } | 881 | } |
882 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) | 882 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) |
883 | { | 883 | { |
884 | slotFileSelected(lnk.name() ); | 884 | slotFileSelected(lnk.name() ); |
885 | emit fileSelected( lnk ); | 885 | emit fileSelected( lnk ); |
886 | } | 886 | } |
887 | void OFileSelector::slotSelectionChanged() // get the current items | 887 | void OFileSelector::slotSelectionChanged() // get the current items |
888 | // fixme | 888 | // fixme |
889 | { | 889 | { |
890 | qWarning("selection changed" ); | 890 | qWarning("selection changed" ); |
891 | } | 891 | } |
892 | void OFileSelector::slotCurrentChanged(QListViewItem *item ) | 892 | void OFileSelector::slotCurrentChanged(QListViewItem *item ) |
893 | { | 893 | { |
894 | qWarning("current changed" ); | 894 | qWarning("current changed" ); |
895 | if( item == 0 ) | 895 | if( item == 0 ) |
896 | return; | 896 | return; |
897 | 897 | ||
898 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | 898 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ |
899 | OFileSelectorItem *sel = (OFileSelectorItem*)item; | 899 | OFileSelectorItem *sel = (OFileSelectorItem*)item; |
900 | if(!sel->isDir() ){ | 900 | if(!sel->isDir() ){ |
901 | qWarning("is not dir" ); | 901 | qWarning("is not dir" ); |
902 | if(m_shLne ){ | 902 | if(m_shLne ){ |
903 | m_edit->setText(sel->text(1) ); | 903 | m_edit->setText(sel->text(1) ); |
904 | qWarning("setTexy" ); | 904 | qWarning("setTexy" ); |
905 | } | 905 | } |
906 | } | 906 | } |
907 | }else { | 907 | }else { |
908 | qWarning("mode not extended" ); | 908 | qWarning("mode not extended" ); |
909 | } | 909 | } |
910 | } | 910 | } |
911 | // either select or change dir | 911 | // either select or change dir |
912 | void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &point, int ) | 912 | void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &point, int ) |
913 | { | 913 | { |
914 | if( item == 0 ) | 914 | if( item == 0 ) |
915 | return; | 915 | return; |
916 | 916 | ||
917 | if( button != Qt::LeftButton ) | 917 | if( button != Qt::LeftButton ) |
918 | return; | 918 | return; |
919 | 919 | ||
920 | qWarning("clicked" ); | 920 | qWarning("clicked" ); |
921 | if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | 921 | if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ |
922 | qWarning("inside" ); | 922 | qWarning("inside" ); |
923 | OFileSelectorItem *sel = (OFileSelectorItem*)item; | 923 | OFileSelectorItem *sel = (OFileSelectorItem*)item; |
924 | if(!sel->isLocked() ){ // not locked either changedir or open | 924 | if(!sel->isLocked() ){ // not locked either changedir or open |
925 | QStringList str = QStringList::split("->", sel->text(1) ); | 925 | QStringList str = QStringList::split("->", sel->text(1) ); |
926 | if(sel->isDir() ){ | 926 | if(sel->isDir() ){ |
927 | cd( sel->directory() + "/" + str[0] ); | 927 | cd( sel->directory() + "/" + str[0] ); |
928 | }else{ | 928 | }else{ |
929 | qWarning("file" ); | 929 | qWarning("file" ); |
930 | if(m_shLne ) | 930 | if(m_shLne ) |
931 | m_edit->setText(str[0] ); | 931 | m_edit->setText(str[0] ); |
932 | emit fileSelected(str[0] ); | 932 | emit fileSelected(str[0] ); |
933 | // emit DocLnk need to do it | 933 | // emit DocLnk need to do it |
934 | } | 934 | } |
935 | }else{ | 935 | }else{ |
936 | qWarning( "locked" ); | 936 | qWarning( "locked" ); |
937 | } | 937 | } |
938 | }; | 938 | }; |
939 | } | 939 | } |
940 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) | 940 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) |
941 | { | 941 | { |
942 | if (item == 0 ) | 942 | if (item == 0 ) |
943 | return; | 943 | return; |
944 | 944 | ||
945 | if( button != Qt::RightButton ) | 945 | if( button != Qt::RightButton ) |
946 | return; | 946 | return; |
947 | qWarning("right button" ); | 947 | qWarning("right button" ); |
948 | slotContextMenu(item); | 948 | slotContextMenu(item); |
949 | } | 949 | } |
950 | void OFileSelector::slotContextMenu(QListViewItem *item) | 950 | void OFileSelector::slotContextMenu(QListViewItem *item) |
951 | { | 951 | { |
952 | qWarning("context menu" ); | 952 | qWarning("context menu" ); |
953 | if( item ==0 || !m_showPopup ) | 953 | if( item ==0 || !m_showPopup ) |
954 | return; | 954 | return; |
955 | 955 | ||
956 | if( m_custom !=0){ | 956 | if( m_custom !=0){ |
957 | m_custom->exec(); | 957 | m_custom->exec(); |
958 | }else{ | 958 | }else{ |
959 | QPopupMenu menu; | 959 | QPopupMenu menu; |
960 | QAction up; | 960 | QAction up; |
961 | up.setText("cd up"); | 961 | up.setText("cd up"); |
962 | up.addTo( &menu ); | 962 | up.addTo( &menu ); |
963 | connect(&up, SIGNAL(activated() ), | 963 | connect(&up, SIGNAL(activated() ), |
964 | this, SLOT(cdUP() ) ); | 964 | this, SLOT(cdUP() ) ); |
965 | 965 | ||
966 | QAction act; | 966 | QAction act; |
967 | OFileSelectorItem *sel = (OFileSelectorItem*)item; | 967 | OFileSelectorItem *sel = (OFileSelectorItem*)item; |
968 | if(sel->isDir() ){ | 968 | if(sel->isDir() ){ |
969 | act.setText( tr("Change Directory") ); | 969 | act.setText( tr("Change Directory") ); |
970 | act.addTo(&menu ); | 970 | act.addTo(&menu ); |
971 | connect(&act, SIGNAL(activated() ), | 971 | connect(&act, SIGNAL(activated() ), |
972 | this, SLOT(slotChangedDir() ) ); | 972 | this, SLOT(slotChangedDir() ) ); |
973 | }else{ | 973 | }else{ |
974 | act.setText( tr("Open file" ) ); | 974 | act.setText( tr("Open file" ) ); |
975 | act.addTo( &menu ); | 975 | act.addTo( &menu ); |
976 | connect(&act, SIGNAL(activated() ), | 976 | connect(&act, SIGNAL(activated() ), |
977 | this, SLOT(slotOpen() ) ); | 977 | this, SLOT(slotOpen() ) ); |
978 | } | 978 | } |
979 | QAction rescan; | 979 | QAction rescan; |
980 | rescan.setText( tr("Rescan") ); | 980 | rescan.setText( tr("Rescan") ); |
981 | rescan.addTo( &menu ); | 981 | rescan.addTo( &menu ); |
982 | connect(&rescan, SIGNAL(activated() ), | 982 | connect(&rescan, SIGNAL(activated() ), |
983 | this, SLOT(slotRescan() ) ); | 983 | this, SLOT(slotRescan() ) ); |
984 | 984 | ||
985 | QAction rename; | 985 | QAction rename; |
986 | rename.setText( tr("Rename") ); | 986 | rename.setText( tr("Rename") ); |
987 | rename.addTo( &menu ); | 987 | rename.addTo( &menu ); |
988 | connect(&rename, SIGNAL(activated() ), | 988 | connect(&rename, SIGNAL(activated() ), |
989 | this, SLOT(slotRename() ) ); | 989 | this, SLOT(slotRename() ) ); |
990 | 990 | ||
991 | menu.insertSeparator(); | 991 | menu.insertSeparator(); |
992 | QAction delItem; | 992 | QAction delItem; |
993 | delItem.setText( tr("Delete") ); | 993 | delItem.setText( tr("Delete") ); |
994 | delItem.addTo(&menu ); | 994 | delItem.addTo(&menu ); |
995 | connect(&delItem, SIGNAL(activated() ), | 995 | connect(&delItem, SIGNAL(activated() ), |
996 | this, SLOT(slotDelete() ) ); | 996 | this, SLOT(slotDelete() ) ); |
997 | 997 | ||
998 | menu.exec(QCursor::pos() ); | 998 | menu.exec(QCursor::pos() ); |
999 | } | 999 | } |
1000 | } | 1000 | } |
1001 | bool OFileSelector::cd(const QString &str ) | 1001 | bool OFileSelector::cd(const QString &str ) |
1002 | { | 1002 | { |
1003 | qWarning(" dir %s", str.latin1() ); | 1003 | qWarning(" dir %s", str.latin1() ); |
1004 | QDir dir( str); | 1004 | QDir dir( str); |
1005 | if(dir.exists() ){ | 1005 | if(dir.exists() ){ |
1006 | m_currentDir = str; | 1006 | m_currentDir = str; |
1007 | reparse(); | 1007 | reparse(); |
1008 | if(m_shTool ){ | 1008 | if(m_shTool ){ |
1009 | int count = m_location->count(); | 1009 | int count = m_location->count(); |
1010 | m_location->insertItem(str ); | 1010 | m_location->insertItem(str ); |
1011 | m_location->setCurrentItem( count ); | 1011 | m_location->setCurrentItem( count ); |
1012 | } | 1012 | } |
1013 | return true; | 1013 | return true; |
1014 | } | 1014 | } |
1015 | return false; | 1015 | return false; |
1016 | } | 1016 | } |
1017 | 1017 | ||
1018 | void OFileSelector::slotChangedDir() | 1018 | void OFileSelector::slotChangedDir() |
1019 | { | 1019 | { |
1020 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 1020 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
1021 | if(sel->isDir() ){ | 1021 | if(sel->isDir() ){ |
1022 | QStringList str = QStringList::split("->", sel->text(1) ); | 1022 | QStringList str = QStringList::split("->", sel->text(1) ); |
1023 | cd( sel->directory() + "/" + str[0] ); | 1023 | cd( sel->directory() + "/" + str[0] ); |
1024 | } | 1024 | } |
1025 | } | 1025 | } |
1026 | void OFileSelector::slotOpen() | 1026 | void OFileSelector::slotOpen() |
1027 | { | 1027 | { |
1028 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 1028 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
1029 | if(!sel->isDir() ){ | 1029 | if(!sel->isDir() ){ |
1030 | QStringList str = QStringList::split("->", sel->text(1) ); | 1030 | QStringList str = QStringList::split("->", sel->text(1) ); |
1031 | slotFileSelected( str[0] ); | 1031 | slotFileSelected( str[0] ); |
1032 | } | 1032 | } |
1033 | } | 1033 | } |
1034 | void OFileSelector::slotRescan() | 1034 | void OFileSelector::slotRescan() |
1035 | { | 1035 | { |
1036 | reparse(); | 1036 | reparse(); |
1037 | } | 1037 | } |
1038 | void OFileSelector::slotRename() | 1038 | void OFileSelector::slotRename() |
1039 | { | 1039 | { |
1040 | // rename inline | 1040 | // rename inline |
1041 | } | 1041 | } |
1042 | void OFileSelector::slotDelete() | 1042 | void OFileSelector::slotDelete() |
1043 | { | 1043 | { |
1044 | qWarning("delete slot" ); | 1044 | qWarning("delete slot" ); |
1045 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 1045 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
1046 | QStringList list = QStringList::split("->", sel->text(1) ); | 1046 | QStringList list = QStringList::split("->", sel->text(1) ); |
1047 | if( sel->isDir() ){ | 1047 | if( sel->isDir() ){ |
1048 | QString str = QString::fromLatin1("rm -rf ") + list[0]; | 1048 | QString str = QString::fromLatin1("rm -rf ") + list[0]; |
1049 | ::system(str.utf8().data() ); | 1049 | ::system(str.utf8().data() ); |
1050 | }else{ | 1050 | }else{ |
1051 | QFile::remove( list[0] ); | 1051 | QFile::remove( list[0] ); |
1052 | } | 1052 | } |
1053 | m_View->takeItem( sel ); | 1053 | m_View->takeItem( sel ); |
1054 | delete sel; | 1054 | delete sel; |
1055 | } | 1055 | } |
1056 | 1056 | ||
1057 | void OFileSelector::cdUP() | 1057 | void OFileSelector::cdUP() |
1058 | { | 1058 | { |
1059 | QDir dir( m_currentDir ); | 1059 | QDir dir( m_currentDir ); |
1060 | dir.cdUp(); | 1060 | dir.cdUp(); |
1061 | if(dir.exists() ){ | 1061 | if(dir.exists() ){ |
1062 | m_currentDir = dir.absPath(); | 1062 | m_currentDir = dir.absPath(); |
1063 | reparse(); | 1063 | reparse(); |
1064 | int count = m_location->count(); | 1064 | int count = m_location->count(); |
1065 | m_location->insertItem(m_currentDir ); | 1065 | m_location->insertItem(m_currentDir ); |
1066 | m_location->setCurrentItem( count ); | 1066 | m_location->setCurrentItem( count ); |
1067 | } | 1067 | } |
1068 | } | 1068 | } |
1069 | void OFileSelector::slotHome() | 1069 | void OFileSelector::slotHome() |
1070 | { | 1070 | { |
1071 | cd(QDir::homeDirPath() ); | 1071 | cd(QDir::homeDirPath() ); |
1072 | } | 1072 | } |
1073 | void OFileSelector::slotDoc() | 1073 | void OFileSelector::slotDoc() |
1074 | { | 1074 | { |
1075 | cd(QDir::homeDirPath() + "/Documents" ); | 1075 | cd(QDir::homeDirPath() + "/Documents" ); |
1076 | } | 1076 | } |
1077 | void OFileSelector::slotNavigate() | 1077 | void OFileSelector::slotNavigate() |
1078 | { | 1078 | { |
1079 | 1079 | ||
1080 | } | 1080 | } |
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h index bf3cb48..5e98a1e 100644 --- a/libopie/ofileselector.h +++ b/libopie/ofileselector.h | |||
@@ -1,277 +1,278 @@ | |||
1 | /* | 1 | /* |
2 | This is based on code and idea of | 2 | This is based on code and idea of |
3 | L. J. Potter ljp@llornkcor.com | 3 | L. J. Potter ljp@llornkcor.com |
4 | Thanks a lot | 4 | Thanks a lot |
5 | 5 | ||
6 | 6 | ||
7 | =. This file is part of the OPIE Project | 7 | =. This file is part of the OPIE Project |
8 | .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 8 | .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This library is free software; you can | 10 | _;:, .> :=|. This library is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This library is distributed in the hope that | 17 | .i_,=:_. -<s. This library is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef opiefileselector_h | 34 | #ifndef opiefileselector_h |
35 | #define opiefileselector_h | 35 | #define opiefileselector_h |
36 | 36 | ||
37 | #include <qwidget.h> | 37 | #include <qwidget.h> |
38 | #include <qstring.h> | 38 | #include <qstring.h> |
39 | #include <qpixmap.h> | 39 | #include <qpixmap.h> |
40 | #include <qstringlist.h> | 40 | #include <qstringlist.h> |
41 | #include <qmap.h> | 41 | #include <qmap.h> |
42 | #include <qvaluelist.h> | 42 | #include <qvaluelist.h> |
43 | 43 | ||
44 | #include <qpe/applnk.h> | 44 | #include <qpe/applnk.h> |
45 | #include <qlistview.h> | 45 | #include <qlistview.h> |
46 | /** This is OPIEs FileDialog Widget. You can use it | 46 | /** This is OPIEs FileDialog Widget. You can use it |
47 | * as a dropin replacement of the fileselector and | 47 | * as a dropin replacement of the fileselector and |
48 | * or use any of the new features. | 48 | * or use any of the new features. |
49 | * This is also a complete FileSave and FileLoad widget | 49 | * This is also a complete FileSave and FileLoad widget |
50 | * If you look for a Dialog check OFileDialog | 50 | * If you look for a Dialog check OFileDialog |
51 | * | 51 | * |
52 | */ | 52 | */ |
53 | class DocLnk; | 53 | class DocLnk; |
54 | class QCheckBox; | 54 | class QCheckBox; |
55 | class QComboBox; | 55 | class QComboBox; |
56 | class QPushButton; | 56 | class QPushButton; |
57 | class FileSelector; | 57 | class FileSelector; |
58 | class QGridLayout; | 58 | class QGridLayout; |
59 | class QLineEdit; | 59 | class QLineEdit; |
60 | class QLabel; | 60 | class QLabel; |
61 | class QWidgetStack; | 61 | class QWidgetStack; |
62 | class QHBoxLayout; | 62 | class QHBoxLayout; |
63 | class QVBoxLayout; | 63 | class QVBoxLayout; |
64 | class QPopupMenu; | 64 | class QPopupMenu; |
65 | class QFileInfo; | 65 | class QFileInfo; |
66 | // | 66 | // |
67 | class OFileSelectorItem : public QListViewItem { | 67 | class OFileSelectorItem : public QListViewItem { |
68 | public: | 68 | public: |
69 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, | 69 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, |
70 | const QString &date, const QString &size, const QString &mDir, | 70 | const QString &date, const QString &size, const QString &mDir, |
71 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { | 71 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { |
72 | setPixmap(0, pixmap ); | 72 | setPixmap(0, pixmap ); |
73 | setText(1, path ); | 73 | setText(1, path ); |
74 | setText(2, size ); | 74 | setText(2, size ); |
75 | setText(3, date ); | 75 | setText(3, date ); |
76 | //setText(4, mDir ); | 76 | //setText(4, mDir ); |
77 | m_dir = mDir; | 77 | m_dir = mDir; |
78 | dir = isDir; | 78 | dir = isDir; |
79 | mLocked = isLocked; | 79 | mLocked = isLocked; |
80 | } | 80 | } |
81 | bool isLocked() const{ | 81 | bool isLocked() const{ |
82 | return mLocked; | 82 | return mLocked; |
83 | } | 83 | } |
84 | QString directory()const{ | 84 | QString directory()const{ |
85 | return m_dir; | 85 | return m_dir; |
86 | } | 86 | } |
87 | bool isDir()const{ | 87 | bool isDir()const{ |
88 | return dir; | 88 | return dir; |
89 | } | 89 | } |
90 | QString path()const{ | 90 | QString path()const{ |
91 | return text(1 ); | 91 | return text(1 ); |
92 | } | 92 | } |
93 | QString key(int id, bool )const { | 93 | QString key(int id, bool )const { |
94 | QString ke; | 94 | QString ke; |
95 | if( id == 0 || id == 1 ){ // name | 95 | if( id == 0 || id == 1 ){ // name |
96 | if( dir ){ | 96 | if( dir ){ |
97 | ke.append("0" ); | 97 | ke.append("0" ); |
98 | ke.append( text(1) ); | 98 | ke.append( text(1) ); |
99 | }else{ | 99 | }else{ |
100 | ke.append("1" ); | 100 | ke.append("1" ); |
101 | ke.append( text(1) ); | 101 | ke.append( text(1) ); |
102 | } | 102 | } |
103 | }else if( id == 2 ){ // size | 103 | }else if( id == 2 ){ // size |
104 | return text(2); | 104 | return text(2); |
105 | }else if( id == 3 ){ // date | 105 | }else if( id == 3 ){ // date |
106 | return text(3); | 106 | return text(3); |
107 | } | 107 | } |
108 | return ke; | 108 | return ke; |
109 | }; | 109 | }; |
110 | private: | 110 | private: |
111 | bool mLocked:1; | 111 | bool mLocked:1; |
112 | bool dir:1; | 112 | bool dir:1; |
113 | QString m_dir; | 113 | QString m_dir; |
114 | }; | 114 | }; |
115 | 115 | ||
116 | class OFileSelector : public QWidget { | 116 | class OFileSelector : public QWidget { |
117 | Q_OBJECT | 117 | Q_OBJECT |
118 | public: | 118 | public: |
119 | enum Mode {OPEN=1, SAVE, FILESELECTOR }; | 119 | enum Mode {OPEN=1, SAVE=2, FILESELECTOR=4, DIR=8 }; |
120 | enum Selector{NORMAL=1, EXTENDED = 2, EXTENDED_ALL =4 }; | 120 | enum Selector{NORMAL=1, EXTENDED = 2, EXTENDED_ALL =4 }; |
121 | enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 }; | 121 | enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 }; |
122 | OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, const QString &fileName = QString::null, const QStringList mimetypes = QStringList() ); | 122 | OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, const QString &fileName = QString::null, const QStringList &mimetypes = QStringList() ); |
123 | 123 | ~OFileSelector() {}; | |
124 | bool isToolbarVisible() const { return m_shTool; }; | 124 | bool isToolbarVisible() const { return m_shTool; }; |
125 | bool isPermissionBarVisible() const { return m_shPerm; }; | 125 | bool isPermissionBarVisible() const { return m_shPerm; }; |
126 | bool isLineEditVisible()const { return m_shLne; }; | 126 | bool isLineEditVisible()const { return m_shLne; }; |
127 | bool isChooserVisible( )const { return m_shChooser; }; | 127 | bool isChooserVisible( )const { return m_shChooser; }; |
128 | bool isYesCancelVisible()const { return m_shYesNo; }; | 128 | bool isYesCancelVisible()const { return m_shYesNo; }; |
129 | void setYesCancelVisible( bool show ); | 129 | void setYesCancelVisible( bool show ); |
130 | void setToolbarVisible( bool show ); | 130 | void setToolbarVisible( bool show ); |
131 | void setPermissionBarVisible( bool show ); | 131 | void setPermissionBarVisible( bool show ); |
132 | void setLineEditVisible(bool show) ; | 132 | void setLineEditVisible(bool show) ; |
133 | void setChooserVisible( bool chooser ); | 133 | void setChooserVisible( bool chooser ); |
134 | 134 | ||
135 | QCheckBox* permissionCheckbox(); | 135 | QCheckBox* permissionCheckbox(); |
136 | bool setPermission() const; | 136 | bool setPermission() const; |
137 | void setPermissionChecked( bool check ); | 137 | void setPermissionChecked( bool check ); |
138 | 138 | ||
139 | void setMode( int ); | 139 | void setMode( int ); |
140 | 140 | ||
141 | bool showDirs()const { return m_dir; } | 141 | bool showDirs()const { return m_dir; } |
142 | void setShowDirs(bool ); | 142 | void setShowDirs(bool ); |
143 | 143 | ||
144 | const QListView* listView() { return m_View; }; | 144 | const QListView* listView() { return m_View; }; |
145 | 145 | ||
146 | bool isCaseSensetive()const { return m_case; } | 146 | bool isCaseSensetive()const { return m_case; } |
147 | void setCaseSensetive(bool caSe ); | 147 | void setCaseSensetive(bool caSe ); |
148 | 148 | ||
149 | bool showFiles()const { return m_files; }; | 149 | bool showFiles()const { return m_files; }; |
150 | void setShowFiles(bool ); | 150 | void setShowFiles(bool ); |
151 | bool cd(const QString &path ); | 151 | bool cd(const QString &path ); |
152 | 152 | ||
153 | 153 | ||
154 | int mode()const { return m_mode; }; | 154 | int mode()const { return m_mode; }; |
155 | int selector()const { return m_selector; }; | 155 | int selector()const { return m_selector; }; |
156 | void setSelector( int ); | 156 | void setSelector( int ); |
157 | 157 | ||
158 | bool showPopup()const { return m_showPopup; }; | 158 | bool showPopup()const { return m_showPopup; }; |
159 | void setShowPopup( bool pop ) { m_showPopup = pop; }; | 159 | void setShowPopup( bool pop ) { m_showPopup = pop; }; |
160 | void setPopupMenu( QPopupMenu * ); | 160 | void setPopupMenu( QPopupMenu * ); |
161 | 161 | ||
162 | void updateLay(); | 162 | void updateLay(); |
163 | 163 | ||
164 | void reparse(); // re reads the dir | 164 | void reparse(); // re reads the dir |
165 | 165 | ||
166 | QString selectedName( )const; | 166 | QString selectedName( )const; |
167 | QStringList selectedNames()const; | 167 | QStringList selectedNames()const; |
168 | 168 | ||
169 | QString selectedPath() const; | 169 | QString selectedPath() const; |
170 | QStringList selectedPaths() const; | 170 | QStringList selectedPaths() const; |
171 | 171 | ||
172 | QString directory()const; | 172 | QString directory()const; |
173 | int fileCount(); | 173 | int fileCount(); |
174 | 174 | ||
175 | /* the user needs to delete it */ | 175 | /* the user needs to delete it */ |
176 | DocLnk selectedDocument()const; | 176 | DocLnk selectedDocument()const; |
177 | /* the user needs to delete it */ | 177 | /* the user needs to delete it */ |
178 | QValueList<DocLnk> selectedDocuments()const; | 178 | QValueList<DocLnk> selectedDocuments()const; |
179 | 179 | ||
180 | signals: | 180 | signals: |
181 | void fileSelected( const DocLnk & ); | 181 | void fileSelected( const DocLnk & ); |
182 | void fileSelected( const QString & ); | 182 | void fileSelected( const QString & ); |
183 | void dirSelected(const QString &dir ); | ||
183 | void closeMe(); | 184 | void closeMe(); |
184 | void ok(); | 185 | void ok(); |
185 | void cancel(); | 186 | void cancel(); |
186 | 187 | ||
187 | protected slots: | 188 | protected slots: |
188 | void slotOk(); | 189 | void slotOk(); |
189 | void slotCancel(); | 190 | void slotCancel(); |
190 | void slotViewCheck(const QString & ); | 191 | void slotViewCheck(const QString & ); |
191 | void slotMimeCheck(const QString & ); | 192 | void slotMimeCheck(const QString & ); |
192 | protected: | 193 | protected: |
193 | void init(); | 194 | void init(); |
194 | void updateMimes(); | 195 | void updateMimes(); |
195 | 196 | ||
196 | protected: | 197 | protected: |
197 | 198 | ||
198 | private: | 199 | private: |
199 | int m_mode, m_selector; | 200 | int m_mode, m_selector; |
200 | QComboBox *m_location, *m_mimeCheck, *m_viewCheck; | 201 | QComboBox *m_location, *m_mimeCheck, *m_viewCheck; |
201 | QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; | 202 | QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; |
202 | QPushButton *m_reread, *m_up; | 203 | QPushButton *m_reread, *m_up; |
203 | QListView *m_View; | 204 | QListView *m_View; |
204 | QCheckBox *m_checkPerm; | 205 | QCheckBox *m_checkPerm; |
205 | QWidget *m_pseudo; | 206 | QWidget *m_pseudo; |
206 | QVBoxLayout *m_pseudoLayout; | 207 | QVBoxLayout *m_pseudoLayout; |
207 | 208 | ||
208 | QString m_currentDir; | 209 | QString m_currentDir; |
209 | QString m_name; | 210 | QString m_name; |
210 | QStringList m_mimetypes; | 211 | QStringList m_mimetypes; |
211 | 212 | ||
212 | FileSelector *m_select; | 213 | FileSelector *m_select; |
213 | QWidgetStack *m_stack; | 214 | QWidgetStack *m_stack; |
214 | QVBoxLayout *m_lay; | 215 | QVBoxLayout *m_lay; |
215 | QGridLayout *m_Oselector; | 216 | QGridLayout *m_Oselector; |
216 | 217 | ||
217 | QHBoxLayout *m_boxToolbar; | 218 | QHBoxLayout *m_boxToolbar; |
218 | QHBoxLayout *m_boxOk; | 219 | QHBoxLayout *m_boxOk; |
219 | QHBoxLayout *m_boxName; | 220 | QHBoxLayout *m_boxName; |
220 | QHBoxLayout *m_boxView; | 221 | QHBoxLayout *m_boxView; |
221 | 222 | ||
222 | QPopupMenu *m_custom; | 223 | QPopupMenu *m_custom; |
223 | 224 | ||
224 | QLineEdit *m_edit; | 225 | QLineEdit *m_edit; |
225 | QLabel *m_fnLabel; | 226 | QLabel *m_fnLabel; |
226 | bool m_shTool:1; | 227 | bool m_shTool:1; |
227 | bool m_shPerm:1; | 228 | bool m_shPerm:1; |
228 | bool m_shLne:1; | 229 | bool m_shLne:1; |
229 | bool m_shChooser:1; | 230 | bool m_shChooser:1; |
230 | bool m_shYesNo:1; | 231 | bool m_shYesNo:1; |
231 | bool m_boCheckPerm:1; | 232 | bool m_boCheckPerm:1; |
232 | bool m_autoMime:1; | 233 | bool m_autoMime:1; |
233 | bool m_case:1; | 234 | bool m_case:1; |
234 | bool m_dir:1; | 235 | bool m_dir:1; |
235 | bool m_files:1; | 236 | bool m_files:1; |
236 | bool m_showPopup:1; | 237 | bool m_showPopup:1; |
237 | 238 | ||
238 | // implementation todo | 239 | // implementation todo |
239 | virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE ); | 240 | virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE ); |
240 | virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE ); | 241 | virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE ); |
241 | virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){}; | 242 | virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){}; |
242 | void delItems(); | 243 | void delItems(); |
243 | void initializeName(); | 244 | void initializeName(); |
244 | void initializeYes(); | 245 | void initializeYes(); |
245 | void initializeChooser(); | 246 | void initializeChooser(); |
246 | void initializeListView(); | 247 | void initializeListView(); |
247 | void initPics(); | 248 | void initPics(); |
248 | bool compliesMime(const QString &path, const QString &mime); | 249 | bool compliesMime(const QString &path, const QString &mime); |
249 | 250 | ||
250 | class OFileSelectorPrivate; | 251 | class OFileSelectorPrivate; |
251 | OFileSelectorPrivate *d; | 252 | OFileSelectorPrivate *d; |
252 | static QMap<QString,QPixmap> *m_pixmaps; | 253 | static QMap<QString,QPixmap> *m_pixmaps; |
253 | 254 | ||
254 | private slots: | 255 | private slots: |
255 | void slotFileSelected(const QString & ); // not really meant to be a slot | 256 | void slotFileSelected(const QString & ); // not really meant to be a slot |
256 | void slotFileBridgeSelected( const DocLnk & ); | 257 | void slotFileBridgeSelected( const DocLnk & ); |
257 | virtual void slotSelectionChanged(); | 258 | virtual void slotSelectionChanged(); |
258 | virtual void slotCurrentChanged(QListViewItem* ); | 259 | virtual void slotCurrentChanged(QListViewItem* ); |
259 | virtual void slotClicked( int, QListViewItem *item, const QPoint &, int); | 260 | virtual void slotClicked( int, QListViewItem *item, const QPoint &, int); |
260 | virtual void slotRightButton(int, QListViewItem *, const QPoint &, int ); | 261 | virtual void slotRightButton(int, QListViewItem *, const QPoint &, int ); |
261 | virtual void slotContextMenu( QListViewItem *item); | 262 | virtual void slotContextMenu( QListViewItem *item); |
262 | // listview crap see above | 263 | // listview crap see above |
263 | // PopupMenu crap | 264 | // PopupMenu crap |
264 | virtual void slotChangedDir(); | 265 | virtual void slotChangedDir(); |
265 | virtual void slotOpen(); | 266 | virtual void slotOpen(); |
266 | virtual void slotRescan(); | 267 | virtual void slotRescan(); |
267 | virtual void slotRename(); | 268 | virtual void slotRename(); |
268 | virtual void slotDelete(); | 269 | virtual void slotDelete(); |
269 | virtual void cdUP(); | 270 | virtual void cdUP(); |
270 | virtual void slotHome(); | 271 | virtual void slotHome(); |
271 | virtual void slotDoc(); | 272 | virtual void slotDoc(); |
272 | virtual void slotNavigate( ); | 273 | virtual void slotNavigate( ); |
273 | }; | 274 | }; |
274 | 275 | ||
275 | 276 | ||
276 | #endif | 277 | #endif |
277 | 278 | ||