author | zecke <zecke> | 2002-04-27 22:49:18 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-04-27 22:49:18 (UTC) |
commit | db95cde435e507833f58111237f86cb9f9ac927a (patch) (unidiff) | |
tree | ffc8883ee58398e99d47e5209affd5a451d579ed | |
parent | 8e3c0aa915801b862f97ba7a7598ef5f3bd350aa (diff) | |
download | opie-db95cde435e507833f58111237f86cb9f9ac927a.zip opie-db95cde435e507833f58111237f86cb9f9ac927a.tar.gz opie-db95cde435e507833f58111237f86cb9f9ac927a.tar.bz2 |
View Interface
-rw-r--r-- | libopie/libopie.pro | 2 | ||||
-rw-r--r-- | libopie/ofileselector.cc | 1 | ||||
-rw-r--r-- | libopie/ofileview.h | 79 |
3 files changed, 81 insertions, 1 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro index b2ecd07..ba64bda 100644 --- a/libopie/libopie.pro +++ b/libopie/libopie.pro | |||
@@ -1,8 +1,8 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qte warn_on release | 2 | CONFIG += qte warn_on release |
3 | HEADERS = ofontmenu.h ofileselector.h ofiledialog.h tododb.h todoevent.h todoresource.h todovcalresource.h xmltree.h colordialog.h colorpopupmenu.h | 3 | HEADERS = ofontmenu.h ofileselector.h ofiledialog.h ofileview.h tododb.h todoevent.h todoresource.h todovcalresource.h xmltree.h colordialog.h colorpopupmenu.h |
4 | SOURCES = ofontmenu.cc ofileselector.cc ofiledialog.cc xmltree.cc tododb.cpp todoevent.cpp todovcalresource.cpp colordialog.cpp colorpopupmenu.cpp | 4 | SOURCES = ofontmenu.cc ofileselector.cc ofiledialog.cc xmltree.cc tododb.cpp todoevent.cpp todovcalresource.cpp colordialog.cpp colorpopupmenu.cpp |
5 | TARGET = opie | 5 | TARGET = opie |
6 | INCLUDEPATH += $(OPIEDIR)/include | 6 | INCLUDEPATH += $(OPIEDIR)/include |
7 | DESTDIR = $(QTDIR)/lib$(PROJMAK) | 7 | DESTDIR = $(QTDIR)/lib$(PROJMAK) |
8 | #VERSION = 1.0.0 | 8 | #VERSION = 1.0.0 |
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index 0a6e595..0e508af 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -1,572 +1,573 @@ | |||
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 | #include <qstringlist.h> | 45 | #include <qstringlist.h> |
46 | #include <qmessagebox.h> | 46 | #include <qmessagebox.h> |
47 | 47 | ||
48 | #include <qpe/qpeapplication.h> | 48 | #include <qpe/qpeapplication.h> |
49 | #include <qpe/fileselector.h> | 49 | #include <qpe/fileselector.h> |
50 | #include <qpe/applnk.h> | 50 | #include <qpe/applnk.h> |
51 | #include <qpe/global.h> | 51 | #include <qpe/global.h> |
52 | #include <qpe/mimetype.h> | 52 | #include <qpe/mimetype.h> |
53 | #include <qpe/resource.h> | 53 | #include <qpe/resource.h> |
54 | #include <qpe/storage.h> | 54 | #include <qpe/storage.h> |
55 | 55 | ||
56 | #include <unistd.h> | 56 | #include <unistd.h> |
57 | #include <stdlib.h> | 57 | #include <stdlib.h> |
58 | #include <sys/stat.h> | 58 | #include <sys/stat.h> |
59 | 59 | ||
60 | #include "ofileselector.h" | 60 | #include "ofileselector.h" |
61 | //#include "ofileview.h" | ||
61 | 62 | ||
62 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; | 63 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; |
63 | 64 | ||
64 | namespace { | 65 | namespace { |
65 | 66 | ||
66 | int indexByString( const QComboBox *box, const QString &str ){ | 67 | int indexByString( const QComboBox *box, const QString &str ){ |
67 | int index= -1; | 68 | int index= -1; |
68 | for(int i= 0; i < box->count(); i++ ){ | 69 | for(int i= 0; i < box->count(); i++ ){ |
69 | if( str == box->text(i ) ){ | 70 | if( str == box->text(i ) ){ |
70 | index= i; | 71 | index= i; |
71 | break; | 72 | break; |
72 | } | 73 | } |
73 | } | 74 | } |
74 | return index; | 75 | return index; |
75 | } | 76 | } |
76 | class OFileSelectorItem : public QListViewItem { | 77 | class OFileSelectorItem : public QListViewItem { |
77 | public: | 78 | public: |
78 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, | 79 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, |
79 | const QString &date, const QString &size, const QString &mDir, | 80 | const QString &date, const QString &size, const QString &mDir, |
80 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { | 81 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { |
81 | setPixmap(0, pixmap ); | 82 | setPixmap(0, pixmap ); |
82 | setText(1, path ); | 83 | setText(1, path ); |
83 | setText(2, size ); | 84 | setText(2, size ); |
84 | setText(3, date ); | 85 | setText(3, date ); |
85 | //setText(4, mDir ); | 86 | //setText(4, mDir ); |
86 | m_dir = mDir; | 87 | m_dir = mDir; |
87 | dir = isDir; | 88 | dir = isDir; |
88 | mLocked = isLocked; | 89 | mLocked = isLocked; |
89 | } | 90 | } |
90 | bool isLocked() const{ | 91 | bool isLocked() const{ |
91 | return mLocked; | 92 | return mLocked; |
92 | } | 93 | } |
93 | QString directory()const{ | 94 | QString directory()const{ |
94 | return m_dir; | 95 | return m_dir; |
95 | } | 96 | } |
96 | bool isDir()const{ | 97 | bool isDir()const{ |
97 | return dir; | 98 | return dir; |
98 | } | 99 | } |
99 | QString path()const{ | 100 | QString path()const{ |
100 | return text(1 ); | 101 | return text(1 ); |
101 | } | 102 | } |
102 | QString key(int id, bool )const { | 103 | QString key(int id, bool )const { |
103 | QString ke; | 104 | QString ke; |
104 | if( id == 0 || id == 1 ){ // name | 105 | if( id == 0 || id == 1 ){ // name |
105 | if( dir ){ | 106 | if( dir ){ |
106 | ke.append("0" ); | 107 | ke.append("0" ); |
107 | ke.append( text(1) ); | 108 | ke.append( text(1) ); |
108 | }else{ | 109 | }else{ |
109 | ke.append("1" ); | 110 | ke.append("1" ); |
110 | ke.append( text(1) ); | 111 | ke.append( text(1) ); |
111 | } | 112 | } |
112 | }else if( id == 2 ){ // size | 113 | }else if( id == 2 ){ // size |
113 | return text(2); | 114 | return text(2); |
114 | }else if( id == 3 ){ // date | 115 | }else if( id == 3 ){ // date |
115 | return text(3); | 116 | return text(3); |
116 | } | 117 | } |
117 | return ke; | 118 | return ke; |
118 | }; | 119 | }; |
119 | private: | 120 | private: |
120 | bool mLocked:1; | 121 | bool mLocked:1; |
121 | bool dir:1; | 122 | bool dir:1; |
122 | QString m_dir; | 123 | QString m_dir; |
123 | }; | 124 | }; |
124 | }; | 125 | }; |
125 | 126 | ||
126 | 127 | ||
127 | OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, | 128 | OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, |
128 | const QString &fileName, const QStringList &mimetypes ) : QWidget( wid ) | 129 | const QString &fileName, const QStringList &mimetypes ) : QWidget( wid ) |
129 | { | 130 | { |
130 | if(wid!=0) | 131 | if(wid!=0) |
131 | resize(wid->width(),wid->height()); | 132 | resize(wid->width(),wid->height()); |
132 | m_selector = selector; | 133 | m_selector = selector; |
133 | m_currentDir = dirName; | 134 | m_currentDir = dirName; |
134 | m_name = fileName; | 135 | m_name = fileName; |
135 | m_mimetypes = mimetypes; | 136 | m_mimetypes = mimetypes; |
136 | 137 | ||
137 | if( mimetypes.isEmpty() ) | 138 | if( mimetypes.isEmpty() ) |
138 | m_autoMime = true; | 139 | m_autoMime = true; |
139 | 140 | ||
140 | qWarning("OFileSelector mimetypes %s", mimetypes.join(" ").latin1() ); | 141 | qWarning("OFileSelector mimetypes %s", mimetypes.join(" ").latin1() ); |
141 | m_mode = mode; | 142 | m_mode = mode; |
142 | m_shTool = true; | 143 | m_shTool = true; |
143 | m_shPerm = true; | 144 | m_shPerm = true; |
144 | m_shLne = true; | 145 | m_shLne = true; |
145 | m_shChooser = true; | 146 | m_shChooser = true; |
146 | m_shYesNo = true; | 147 | m_shYesNo = true; |
147 | 148 | ||
148 | // for FILESELECTOR only view is interesting | 149 | // for FILESELECTOR only view is interesting |
149 | m_location = 0; | 150 | m_location = 0; |
150 | m_homeButton = 0; | 151 | m_homeButton = 0; |
151 | m_docButton = 0; | 152 | m_docButton = 0; |
152 | m_hideButton = 0; | 153 | m_hideButton = 0; |
153 | m_ok = 0; | 154 | m_ok = 0; |
154 | m_cancel = 0; | 155 | m_cancel = 0; |
155 | m_reread = 0; | 156 | m_reread = 0; |
156 | m_up = 0; | 157 | m_up = 0; |
157 | m_View = 0; | 158 | m_View = 0; |
158 | m_select = 0; | 159 | m_select = 0; |
159 | m_stack = 0; | 160 | m_stack = 0; |
160 | 161 | ||
161 | m_select = 0; | 162 | m_select = 0; |
162 | m_stack = 0; | 163 | m_stack = 0; |
163 | m_lay = 0; | 164 | m_lay = 0; |
164 | m_boxToolbar = 0; | 165 | m_boxToolbar = 0; |
165 | m_boxOk = 0; | 166 | m_boxOk = 0; |
166 | m_edit = 0; | 167 | m_edit = 0; |
167 | 168 | ||
168 | m_fnLabel = 0; | 169 | m_fnLabel = 0; |
169 | m_checkPerm = 0; | 170 | m_checkPerm = 0; |
170 | m_mimeCheck = 0; | 171 | m_mimeCheck = 0; |
171 | m_viewCheck = 0; | 172 | m_viewCheck = 0; |
172 | 173 | ||
173 | m_pseudo = 0; | 174 | m_pseudo = 0; |
174 | m_pseudoLayout = 0; | 175 | m_pseudoLayout = 0; |
175 | 176 | ||
176 | m_dir = true; | 177 | m_dir = true; |
177 | m_files = true; | 178 | m_files = true; |
178 | m_custom = 0; | 179 | m_custom = 0; |
179 | m_showPopup = true; | 180 | m_showPopup = true; |
180 | 181 | ||
181 | if(m_pixmaps == 0 ) // init the pixmaps | 182 | if(m_pixmaps == 0 ) // init the pixmaps |
182 | initPics(); | 183 | initPics(); |
183 | 184 | ||
184 | m_lay = new QVBoxLayout(this); | 185 | m_lay = new QVBoxLayout(this); |
185 | init(); | 186 | init(); |
186 | m_edit->setText( fileName ); | 187 | m_edit->setText( fileName ); |
187 | } | 188 | } |
188 | 189 | ||
189 | void OFileSelector::initPics() | 190 | void OFileSelector::initPics() |
190 | { | 191 | { |
191 | qWarning("init pics" ); | 192 | qWarning("init pics" ); |
192 | m_pixmaps = new QMap<QString,QPixmap>; | 193 | m_pixmaps = new QMap<QString,QPixmap>; |
193 | QPixmap pm = Resource::loadPixmap( "folder" ); | 194 | QPixmap pm = Resource::loadPixmap( "folder" ); |
194 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 195 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
195 | QPainter painter( &pm ); | 196 | QPainter painter( &pm ); |
196 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 197 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
197 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 198 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
198 | m_pixmaps->insert("dirsymlink", pm ); | 199 | m_pixmaps->insert("dirsymlink", pm ); |
199 | 200 | ||
200 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); | 201 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); |
201 | QPainter pen(&pm2 ); | 202 | QPainter pen(&pm2 ); |
202 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); | 203 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); |
203 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); | 204 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); |
204 | m_pixmaps->insert("symlinkedlocked", pm2 ); | 205 | m_pixmaps->insert("symlinkedlocked", pm2 ); |
205 | 206 | ||
206 | } | 207 | } |
207 | 208 | ||
208 | // let's initialize the gui | 209 | // let's initialize the gui |
209 | /** | 210 | /** |
210 | -------------------- | 211 | -------------------- |
211 | | cmbBox Button | | 212 | | cmbBox Button | |
212 | -------------------- | 213 | -------------------- |
213 | | FileSlector | | 214 | | FileSlector | |
214 | | or | | 215 | | or | |
215 | | OSelector | | 216 | | OSelector | |
216 | | | | 217 | | | |
217 | | | | 218 | | | |
218 | ____________________ | 219 | ____________________ |
219 | | LineEdit | | 220 | | LineEdit | |
220 | ____________________ | 221 | ____________________ |
221 | | Permission Bar | | 222 | | Permission Bar | |
222 | ____________________ | 223 | ____________________ |
223 | | ViewChoose | | 224 | | ViewChoose | |
224 | ____________________ | 225 | ____________________ |
225 | | Save Cancel| | 226 | | Save Cancel| |
226 | ____________________ | 227 | ____________________ |
227 | */ | 228 | */ |
228 | void OFileSelector::delItems() | 229 | void OFileSelector::delItems() |
229 | { | 230 | { |
230 | QLayoutIterator it = m_lay->iterator(); | 231 | QLayoutIterator it = m_lay->iterator(); |
231 | while ( it.current() != 0 ){ | 232 | while ( it.current() != 0 ){ |
232 | it.deleteCurrent(); | 233 | it.deleteCurrent(); |
233 | } | 234 | } |
234 | } | 235 | } |
235 | 236 | ||
236 | void OFileSelector::init() | 237 | void OFileSelector::init() |
237 | { | 238 | { |
238 | // qDebug("init"); | 239 | // qDebug("init"); |
239 | m_stack = new QWidgetStack(this, "wstack" ); | 240 | m_stack = new QWidgetStack(this, "wstack" ); |
240 | if( m_selector == NORMAL ){ | 241 | if( m_selector == NORMAL ){ |
241 | QString currMime; | 242 | QString currMime; |
242 | if( m_mimeCheck != 0 ) | 243 | if( m_mimeCheck != 0 ) |
243 | currMime = m_mimeCheck->currentText(); | 244 | currMime = m_mimeCheck->currentText(); |
244 | updateMimes(); | 245 | updateMimes(); |
245 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , | 246 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , |
246 | m_stack, "fileselector", FALSE, FALSE ); | 247 | m_stack, "fileselector", FALSE, FALSE ); |
247 | m_stack->addWidget(m_select, NORMAL ); | 248 | m_stack->addWidget(m_select, NORMAL ); |
248 | m_lay->addWidget(m_stack ); | 249 | m_lay->addWidget(m_stack ); |
249 | m_stack->raiseWidget(NORMAL ); | 250 | m_stack->raiseWidget(NORMAL ); |
250 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), | 251 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), |
251 | this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); | 252 | this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); |
252 | m_pseudoLayout = 0l; | 253 | m_pseudoLayout = 0l; |
253 | 254 | ||
254 | } else { | 255 | } else { |
255 | initializeListView(); | 256 | initializeListView(); |
256 | } | 257 | } |
257 | if(m_shLne ){ | 258 | if(m_shLne ){ |
258 | initializeName(); | 259 | initializeName(); |
259 | } | 260 | } |
260 | if(m_shPerm ){ | 261 | if(m_shPerm ){ |
261 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); | 262 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); |
262 | m_checkPerm->setChecked( false ); | 263 | m_checkPerm->setChecked( false ); |
263 | m_lay->addWidget(m_checkPerm ); | 264 | m_lay->addWidget(m_checkPerm ); |
264 | } | 265 | } |
265 | if( m_shChooser ) | 266 | if( m_shChooser ) |
266 | initializeChooser(); | 267 | initializeChooser(); |
267 | if(m_shYesNo ) | 268 | if(m_shYesNo ) |
268 | initializeYes(); | 269 | initializeYes(); |
269 | 270 | ||
270 | // m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, requestedMimeTypesList.first()) ); | 271 | // m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, requestedMimeTypesList.first()) ); |
271 | // reparse(); | 272 | // reparse(); |
272 | 273 | ||
273 | } | 274 | } |
274 | 275 | ||
275 | void OFileSelector::setYesCancelVisible( bool show ) | 276 | void OFileSelector::setYesCancelVisible( bool show ) |
276 | { | 277 | { |
277 | if ( show == m_shYesNo ) | 278 | if ( show == m_shYesNo ) |
278 | return; | 279 | return; |
279 | m_shYesNo = show; | 280 | m_shYesNo = show; |
280 | if( !show ){ | 281 | if( !show ){ |
281 | delete m_ok; | 282 | delete m_ok; |
282 | delete m_cancel; | 283 | delete m_cancel; |
283 | m_ok = 0; | 284 | m_ok = 0; |
284 | m_cancel = 0; | 285 | m_cancel = 0; |
285 | // delete m_boxOk; all ready deleted in delItems | 286 | // delete m_boxOk; all ready deleted in delItems |
286 | } | 287 | } |
287 | updateLay(); // recreate it and save the other states | 288 | updateLay(); // recreate it and save the other states |
288 | } | 289 | } |
289 | 290 | ||
290 | void OFileSelector::setToolbarVisible( bool show ) | 291 | void OFileSelector::setToolbarVisible( bool show ) |
291 | { | 292 | { |
292 | if ( m_shTool == show ) | 293 | if ( m_shTool == show ) |
293 | return; | 294 | return; |
294 | if(!m_shTool ){ | 295 | if(!m_shTool ){ |
295 | delete m_boxToolbar; | 296 | delete m_boxToolbar; |
296 | delete m_homeButton; | 297 | delete m_homeButton; |
297 | delete m_docButton; | 298 | delete m_docButton; |
298 | delete m_location; | 299 | delete m_location; |
299 | delete m_up; | 300 | delete m_up; |
300 | m_boxToolbar = 0; | 301 | m_boxToolbar = 0; |
301 | m_homeButton = 0; | 302 | m_homeButton = 0; |
302 | m_docButton = 0; | 303 | m_docButton = 0; |
303 | m_location = 0; | 304 | m_location = 0; |
304 | m_up = 0; | 305 | m_up = 0; |
305 | }; | 306 | }; |
306 | updateLay();// overkill fix it | 307 | updateLay();// overkill fix it |
307 | } | 308 | } |
308 | 309 | ||
309 | void OFileSelector::setPermissionBarVisible( bool show ) | 310 | void OFileSelector::setPermissionBarVisible( bool show ) |
310 | { | 311 | { |
311 | if( show == m_shPerm ) | 312 | if( show == m_shPerm ) |
312 | return; | 313 | return; |
313 | 314 | ||
314 | m_shPerm = show; | 315 | m_shPerm = show; |
315 | 316 | ||
316 | updateLay(); | 317 | updateLay(); |
317 | } | 318 | } |
318 | 319 | ||
319 | void OFileSelector::setLineEditVisible( bool show ) | 320 | void OFileSelector::setLineEditVisible( bool show ) |
320 | { | 321 | { |
321 | if( show == m_shLne ) | 322 | if( show == m_shLne ) |
322 | return; | 323 | return; |
323 | 324 | ||
324 | m_shLne = show; | 325 | m_shLne = show; |
325 | if( !show ){ | 326 | if( !show ){ |
326 | delete m_edit; | 327 | delete m_edit; |
327 | delete m_fnLabel; | 328 | delete m_fnLabel; |
328 | m_edit = 0; | 329 | m_edit = 0; |
329 | m_fnLabel = 0; | 330 | m_fnLabel = 0; |
330 | //delete m_boxName; will be deleted | 331 | //delete m_boxName; will be deleted |
331 | } | 332 | } |
332 | updateLay(); | 333 | updateLay(); |
333 | } | 334 | } |
334 | 335 | ||
335 | void OFileSelector::setChooserVisible( bool show ) | 336 | void OFileSelector::setChooserVisible( bool show ) |
336 | { | 337 | { |
337 | if( show = m_shChooser ) | 338 | if( show = m_shChooser ) |
338 | return; | 339 | return; |
339 | m_shChooser = show; | 340 | m_shChooser = show; |
340 | if( !show ){ | 341 | if( !show ){ |
341 | delete m_mimeCheck; | 342 | delete m_mimeCheck; |
342 | delete m_viewCheck; | 343 | delete m_viewCheck; |
343 | m_mimeCheck = 0; | 344 | m_mimeCheck = 0; |
344 | m_viewCheck = 0; | 345 | m_viewCheck = 0; |
345 | } | 346 | } |
346 | updateLay(); | 347 | updateLay(); |
347 | } | 348 | } |
348 | 349 | ||
349 | QCheckBox* OFileSelector::permissionCheckbox( ) | 350 | QCheckBox* OFileSelector::permissionCheckbox( ) |
350 | { | 351 | { |
351 | return m_checkPerm; | 352 | return m_checkPerm; |
352 | } | 353 | } |
353 | 354 | ||
354 | void OFileSelector::setCaseSensetive( bool caSe ) | 355 | void OFileSelector::setCaseSensetive( bool caSe ) |
355 | { | 356 | { |
356 | m_case = caSe; | 357 | m_case = caSe; |
357 | reparse(); | 358 | reparse(); |
358 | } | 359 | } |
359 | 360 | ||
360 | void OFileSelector::setShowFiles(bool files ){ | 361 | void OFileSelector::setShowFiles(bool files ){ |
361 | m_files = files; | 362 | m_files = files; |
362 | reparse(); | 363 | reparse(); |
363 | } | 364 | } |
364 | 365 | ||
365 | void OFileSelector::setPopupMenu(QPopupMenu *pop ) | 366 | void OFileSelector::setPopupMenu(QPopupMenu *pop ) |
366 | { | 367 | { |
367 | //delete oldpopup; | 368 | //delete oldpopup; |
368 | m_custom = pop; | 369 | m_custom = pop; |
369 | } | 370 | } |
370 | 371 | ||
371 | bool OFileSelector::setPermission( ) const | 372 | bool OFileSelector::setPermission( ) const |
372 | { | 373 | { |
373 | if( m_checkPerm == 0 ) | 374 | if( m_checkPerm == 0 ) |
374 | return false; | 375 | return false; |
375 | else | 376 | else |
376 | return m_checkPerm->isChecked(); | 377 | return m_checkPerm->isChecked(); |
377 | } | 378 | } |
378 | 379 | ||
379 | void OFileSelector::setPermissionChecked( bool check ) | 380 | void OFileSelector::setPermissionChecked( bool check ) |
380 | { | 381 | { |
381 | if( m_checkPerm == 0 ) | 382 | if( m_checkPerm == 0 ) |
382 | return; | 383 | return; |
383 | m_checkPerm->setChecked( check ); | 384 | m_checkPerm->setChecked( check ); |
384 | } | 385 | } |
385 | 386 | ||
386 | QString OFileSelector::selectedName( )const | 387 | QString OFileSelector::selectedName( )const |
387 | { | 388 | { |
388 | QString string; | 389 | QString string; |
389 | if( m_selector == NORMAL ){ | 390 | if( m_selector == NORMAL ){ |
390 | const DocLnk *lnk = m_select->selected(); | 391 | const DocLnk *lnk = m_select->selected(); |
391 | string = lnk->file(); | 392 | string = lnk->file(); |
392 | }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | 393 | }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { |
393 | QListViewItem *item = m_View->currentItem(); | 394 | QListViewItem *item = m_View->currentItem(); |
394 | if(item != 0 ){ | 395 | if(item != 0 ){ |
395 | string = m_currentDir + "/" + item->text( 1 ); | 396 | string = m_currentDir + "/" + item->text( 1 ); |
396 | } | 397 | } |
397 | } | 398 | } |
398 | return string; | 399 | return string; |
399 | } | 400 | } |
400 | 401 | ||
401 | QStringList OFileSelector::selectedNames()const | 402 | QStringList OFileSelector::selectedNames()const |
402 | { | 403 | { |
403 | QStringList list; | 404 | QStringList list; |
404 | return list; | 405 | return list; |
405 | } | 406 | } |
406 | 407 | ||
407 | DocLnk OFileSelector::selectedDocument( )const | 408 | DocLnk OFileSelector::selectedDocument( )const |
408 | { | 409 | { |
409 | DocLnk lnk; | 410 | DocLnk lnk; |
410 | return lnk; | 411 | return lnk; |
411 | } | 412 | } |
412 | void OFileSelector::updateLay() | 413 | void OFileSelector::updateLay() |
413 | { | 414 | { |
414 | /* if( m_shTool ) | 415 | /* if( m_shTool ) |
415 | // | 416 | // |
416 | else | 417 | else |
417 | // hide | 418 | // hide |
418 | */ | 419 | */ |
419 | // save the state | 420 | // save the state |
420 | bool check = false; | 421 | bool check = false; |
421 | if( m_checkPerm != 0 ) | 422 | if( m_checkPerm != 0 ) |
422 | check = m_checkPerm->isChecked(); | 423 | check = m_checkPerm->isChecked(); |
423 | QString text; | 424 | QString text; |
424 | 425 | ||
425 | if( m_edit != 0 ) | 426 | if( m_edit != 0 ) |
426 | text = m_edit->text(); | 427 | text = m_edit->text(); |
427 | // save current mimetype | 428 | // save current mimetype |
428 | 429 | ||
429 | delItems(); | 430 | delItems(); |
430 | delete m_checkPerm; | 431 | delete m_checkPerm; |
431 | m_checkPerm = 0; | 432 | m_checkPerm = 0; |
432 | delete m_edit; | 433 | delete m_edit; |
433 | m_edit = 0; | 434 | m_edit = 0; |
434 | delete m_fnLabel; | 435 | delete m_fnLabel; |
435 | m_fnLabel = 0; | 436 | m_fnLabel = 0; |
436 | delete m_ok; | 437 | delete m_ok; |
437 | m_ok = 0; | 438 | m_ok = 0; |
438 | delete m_cancel; | 439 | delete m_cancel; |
439 | m_cancel = 0; | 440 | m_cancel = 0; |
440 | delete m_mimeCheck; | 441 | delete m_mimeCheck; |
441 | m_mimeCheck = 0; | 442 | m_mimeCheck = 0; |
442 | delete m_viewCheck; | 443 | delete m_viewCheck; |
443 | m_viewCheck = 0; | 444 | m_viewCheck = 0; |
444 | delete m_select; // test | 445 | delete m_select; // test |
445 | delete m_stack; | 446 | delete m_stack; |
446 | //delete m_list; | 447 | //delete m_list; |
447 | init(); | 448 | init(); |
448 | if( m_shLne ) | 449 | if( m_shLne ) |
449 | m_edit->setText(text ); | 450 | m_edit->setText(text ); |
450 | if( m_shPerm ) | 451 | if( m_shPerm ) |
451 | m_checkPerm->setChecked(check ); | 452 | m_checkPerm->setChecked(check ); |
452 | } | 453 | } |
453 | 454 | ||
454 | // let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve | 455 | // let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve |
455 | // insert QListViewItems with the right options | 456 | // insert QListViewItems with the right options |
456 | bool OFileSelector::compliesMime(const QString &path, const QString &mime ) | 457 | bool OFileSelector::compliesMime(const QString &path, const QString &mime ) |
457 | { | 458 | { |
458 | if( mime == "All" ) | 459 | if( mime == "All" ) |
459 | return true; | 460 | return true; |
460 | MimeType type( path ); | 461 | MimeType type( path ); |
461 | if( type.id() == mime ) | 462 | if( type.id() == mime ) |
462 | return true; | 463 | return true; |
463 | return false; | 464 | return false; |
464 | } | 465 | } |
465 | 466 | ||
466 | void OFileSelector::reparse() | 467 | void OFileSelector::reparse() |
467 | { | 468 | { |
468 | qDebug("reparse"); | 469 | qDebug("reparse"); |
469 | if(m_View== 0 || m_selector == NORMAL) | 470 | if(m_View== 0 || m_selector == NORMAL) |
470 | return; | 471 | return; |
471 | m_View->clear(); | 472 | m_View->clear(); |
472 | QString currMime =m_mimeCheck->currentText(); | 473 | QString currMime =m_mimeCheck->currentText(); |
473 | // update the mimetype now | 474 | // update the mimetype now |
474 | if( m_autoMime ) { | 475 | if( m_autoMime ) { |
475 | QDir dir( m_currentDir ); | 476 | QDir dir( m_currentDir ); |
476 | m_mimetypes.clear(); | 477 | m_mimetypes.clear(); |
477 | m_mimeCheck->clear(); | 478 | m_mimeCheck->clear(); |
478 | dir.setFilter( QDir::Files | QDir::Readable ); | 479 | dir.setFilter( QDir::Files | QDir::Readable ); |
479 | dir.setSorting(QDir::Size ); | 480 | dir.setSorting(QDir::Size ); |
480 | const QFileInfoList *list = dir.entryInfoList(); | 481 | const QFileInfoList *list = dir.entryInfoList(); |
481 | QFileInfoListIterator it( *list ); | 482 | QFileInfoListIterator it( *list ); |
482 | QFileInfo *fi; | 483 | QFileInfo *fi; |
483 | while( (fi=it.current()) ){ | 484 | while( (fi=it.current()) ){ |
484 | if(fi->extension() == QString::fromLatin1("desktop") ){ | 485 | if(fi->extension() == QString::fromLatin1("desktop") ){ |
485 | ++it; | 486 | ++it; |
486 | continue; | 487 | continue; |
487 | } | 488 | } |
488 | MimeType type(fi->filePath() ); | 489 | MimeType type(fi->filePath() ); |
489 | if( !m_mimetypes.contains( type.id() ) ) | 490 | if( !m_mimetypes.contains( type.id() ) ) |
490 | m_mimetypes.append( type.id() ); | 491 | m_mimetypes.append( type.id() ); |
491 | 492 | ||
492 | ++it; | 493 | ++it; |
493 | } | 494 | } |
494 | m_mimetypes.prepend("All" ); | 495 | m_mimetypes.prepend("All" ); |
495 | m_mimeCheck->insertStringList(m_mimetypes ); | 496 | m_mimeCheck->insertStringList(m_mimetypes ); |
496 | // set it to the current mimetype | 497 | // set it to the current mimetype |
497 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); | 498 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); |
498 | }else{ | 499 | }else{ |
499 | m_mimeCheck->clear(); | 500 | m_mimeCheck->clear(); |
500 | m_mimeCheck->insertItem( m_mimetypes.join(";") ); | 501 | m_mimeCheck->insertItem( m_mimetypes.join(";") ); |
501 | } | 502 | } |
502 | 503 | ||
503 | QDir dir( m_currentDir ); | 504 | QDir dir( m_currentDir ); |
504 | //dir.setFilter(-1 ); | 505 | //dir.setFilter(-1 ); |
505 | int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed; | 506 | int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed; |
506 | if( m_case ) | 507 | if( m_case ) |
507 | sort = QDir::IgnoreCase; | 508 | sort = QDir::IgnoreCase; |
508 | dir.setSorting( sort ); | 509 | dir.setSorting( sort ); |
509 | 510 | ||
510 | int filter; | 511 | int filter; |
511 | /* if( m_dir && !m_files) | 512 | /* if( m_dir && !m_files) |
512 | filter |= QDir::Dirs; | 513 | filter |= QDir::Dirs; |
513 | else if( !m_dir && m_files ) | 514 | else if( !m_dir && m_files ) |
514 | filter |= QDir::Files; | 515 | filter |= QDir::Files; |
515 | else | 516 | else |
516 | filter |= QDir::All; | 517 | filter |= QDir::All; |
517 | */ | 518 | */ |
518 | if( m_selector == EXTENDED_ALL ) | 519 | if( m_selector == EXTENDED_ALL ) |
519 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 520 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
520 | else | 521 | else |
521 | filter = QDir::Files | QDir::Dirs | QDir::All; | 522 | filter = QDir::Files | QDir::Dirs | QDir::All; |
522 | dir.setFilter( filter ); | 523 | dir.setFilter( filter ); |
523 | qDebug("infoList"); | 524 | qDebug("infoList"); |
524 | const QFileInfoList *list = dir.entryInfoList(); | 525 | const QFileInfoList *list = dir.entryInfoList(); |
525 | QFileInfoListIterator it( *list ); | 526 | QFileInfoListIterator it( *list ); |
526 | QFileInfo *fi; | 527 | QFileInfo *fi; |
527 | while( (fi=it.current()) ){ | 528 | while( (fi=it.current()) ){ |
528 | if(fi->fileName() == ".." || fi->fileName() == "." ){ | 529 | if(fi->fileName() == ".." || fi->fileName() == "." ){ |
529 | ++it; | 530 | ++it; |
530 | continue; | 531 | continue; |
531 | } | 532 | } |
532 | // qWarning("Test: %s", fi->fileName().latin1() ); | 533 | // qWarning("Test: %s", fi->fileName().latin1() ); |
533 | if(fi->isSymLink() ){ | 534 | if(fi->isSymLink() ){ |
534 | // qWarning("Symlink %s", fi->fileName().latin1() ); | 535 | // qWarning("Symlink %s", fi->fileName().latin1() ); |
535 | QString file = fi->dirPath(true)+"/"+ fi->readLink(); | 536 | QString file = fi->dirPath(true)+"/"+ fi->readLink(); |
536 | // qWarning("File ->%s", file.latin1() ); | 537 | // qWarning("File ->%s", file.latin1() ); |
537 | for(int i=0; i<=4; i++ ){ // prepend from dos | 538 | for(int i=0; i<=4; i++ ){ // prepend from dos |
538 | QFileInfo info( file ); | 539 | QFileInfo info( file ); |
539 | if( !info.exists() ){ | 540 | if( !info.exists() ){ |
540 | // qWarning("does not exist" ); | 541 | // qWarning("does not exist" ); |
541 | addSymlink(currMime, fi, TRUE ); | 542 | addSymlink(currMime, fi, TRUE ); |
542 | break; | 543 | break; |
543 | }else if( info.isDir() ){ | 544 | }else if( info.isDir() ){ |
544 | // qWarning("isDir" ); | 545 | // qWarning("isDir" ); |
545 | addDir(currMime, fi, TRUE ); | 546 | addDir(currMime, fi, TRUE ); |
546 | break; | 547 | break; |
547 | }else if( info.isFile() ){ | 548 | }else if( info.isFile() ){ |
548 | // qWarning("isFile" ); | 549 | // qWarning("isFile" ); |
549 | addFile(currMime, fi, TRUE ); | 550 | addFile(currMime, fi, TRUE ); |
550 | break; | 551 | break; |
551 | }else if( info.isSymLink() ){ | 552 | }else if( info.isSymLink() ){ |
552 | file = info.dirPath(true)+ "/"+ info.readLink(); | 553 | file = info.dirPath(true)+ "/"+ info.readLink(); |
553 | // qWarning("isSymlink again %s", file.latin1() ); | 554 | // qWarning("isSymlink again %s", file.latin1() ); |
554 | }else if( i == 4 ){ // just insert it and have the symlink symbol | 555 | }else if( i == 4 ){ // just insert it and have the symlink symbol |
555 | addSymlink(currMime, fi ); | 556 | addSymlink(currMime, fi ); |
556 | // qWarning("level too deep" ); | 557 | // qWarning("level too deep" ); |
557 | } | 558 | } |
558 | } | 559 | } |
559 | }else if( fi->isDir() ){ | 560 | }else if( fi->isDir() ){ |
560 | addDir(currMime, fi ); | 561 | addDir(currMime, fi ); |
561 | }else if( fi->isFile() ) { // file ? | 562 | }else if( fi->isFile() ) { // file ? |
562 | addFile(currMime, fi ); | 563 | addFile(currMime, fi ); |
563 | } | 564 | } |
564 | ++it; | 565 | ++it; |
565 | } | 566 | } |
566 | m_View->sort(); | 567 | m_View->sort(); |
567 | // m_View->ensureItemVisible(); | 568 | // m_View->ensureItemVisible(); |
568 | } | 569 | } |
569 | 570 | ||
570 | QString OFileSelector::directory()const | 571 | QString OFileSelector::directory()const |
571 | { | 572 | { |
572 | QDir d( m_currentDir); | 573 | QDir d( m_currentDir); |
diff --git a/libopie/ofileview.h b/libopie/ofileview.h new file mode 100644 index 0000000..48a71ca --- a/dev/null +++ b/libopie/ofileview.h | |||
@@ -0,0 +1,79 @@ | |||
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 | #ifndef ofileview_h | ||
30 | #define ofileview_h | ||
31 | |||
32 | #include <qobject.h> | ||
33 | #include <qwidget.h> | ||
34 | |||
35 | class QFileInfo; | ||
36 | class QDir; | ||
37 | class DocLnk; | ||
38 | class OFileSelectorView : public QWidget { | ||
39 | Q_OBJECT | ||
40 | public: | ||
41 | OFileSelectorView(QWidget *widget, | ||
42 | const char *name ) | ||
43 | : QWidget(widget, name ) | ||
44 | { }; | ||
45 | virtual ~OFileSelectorView(); | ||
46 | |||
47 | virtual void addFile(const QString &mine, | ||
48 | QFileInfo *info, | ||
49 | bool isSymlink = FALSE ) = 0; | ||
50 | |||
51 | virtual void addDir (const QString &mine, | ||
52 | QFileInfo *info, | ||
53 | bool isSymlink = FALSE ) = 0; | ||
54 | |||
55 | virtual void addSymlink(const QString &mime, | ||
56 | QFileInfo *info, | ||
57 | bool isSymlink = FALSE ) = 0; | ||
58 | |||
59 | virtual void cd(const QString &path ); | ||
60 | signals: | ||
61 | void fileSelected(const QString &); | ||
62 | void fileSelected(const DocLnk & ); | ||
63 | void contextMenu(); | ||
64 | void changedDir(const QString &); | ||
65 | void changedDir(const QDir & ); | ||
66 | }; | ||
67 | |||
68 | class OFileViewFactory { | ||
69 | // Q_OBJECT | ||
70 | public: | ||
71 | OFileViewFactory() {} ; | ||
72 | virtual ~OFileViewFactory(); | ||
73 | |||
74 | OFileSelectorView* newView(QWidget *parent, const char *name ); | ||
75 | QString name()const; | ||
76 | }; | ||
77 | |||
78 | |||
79 | #endif | ||