summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-04-12 00:10:00 (UTC)
committer harlekin <harlekin>2002-04-12 00:10:00 (UTC)
commit26efd0a7135834626b4e6f275e57e85a97abd34f (patch) (unidiff)
treeb803f31e222d68f6acdfef9a10e6ccae683d4cb9
parenta1615d98bdd7430e0533c0325dfdc39bf6627ab2 (diff)
downloadopie-26efd0a7135834626b4e6f275e57e85a97abd34f.zip
opie-26efd0a7135834626b4e6f275e57e85a97abd34f.tar.gz
opie-26efd0a7135834626b4e6f275e57e85a97abd34f.tar.bz2
take parent size
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index bc7c6c2..c3a3514 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -1,273 +1,275 @@
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
60QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; 60QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0;
61 61
62namespace { 62namespace {
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
79OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, 79OFileSelector::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
83 resize(wid->width(),wid->height());
82 m_selector = selector; 84 m_selector = selector;
83 m_currentDir = dirName; 85 m_currentDir = dirName;
84 m_name = fileName; 86 m_name = fileName;
85 m_mimetypes = mimetypes; 87 m_mimetypes = mimetypes;
86 if( mimetypes.isEmpty() ) 88 if( mimetypes.isEmpty() )
87 m_autoMime = true; 89 m_autoMime = true;
88 90
89 m_mode = mode; 91 m_mode = mode;
90 m_shTool = true; 92 m_shTool = true;
91 m_shPerm = true; 93 m_shPerm = true;
92 m_shLne = true; 94 m_shLne = true;
93 m_shChooser = true; 95 m_shChooser = true;
94 m_shYesNo = true; 96 m_shYesNo = true;
95 // for FILESELECTOR only view is interesting 97 // for FILESELECTOR only view is interesting
96 m_location = 0; 98 m_location = 0;
97 m_homeButton = 0; 99 m_homeButton = 0;
98 m_docButton = 0; 100 m_docButton = 0;
99 m_hideButton = 0; 101 m_hideButton = 0;
100 m_ok = 0; 102 m_ok = 0;
101 m_cancel = 0; 103 m_cancel = 0;
102 m_reread = 0; 104 m_reread = 0;
103 m_up = 0; 105 m_up = 0;
104 m_View = 0; 106 m_View = 0;
105 m_select = 0; 107 m_select = 0;
106 m_stack = 0; 108 m_stack = 0;
107 109
108 m_select = 0; 110 m_select = 0;
109 m_stack = 0; 111 m_stack = 0;
110 m_lay = 0; 112 m_lay = 0;
111 m_boxToolbar = 0; 113 m_boxToolbar = 0;
112 m_boxOk = 0; 114 m_boxOk = 0;
113 m_edit = 0; 115 m_edit = 0;
114 116
115 m_fnLabel = 0; 117 m_fnLabel = 0;
116 m_checkPerm = 0; 118 m_checkPerm = 0;
117 m_mimeCheck = 0; 119 m_mimeCheck = 0;
118 m_viewCheck = 0; 120 m_viewCheck = 0;
119 121
120 m_pseudo = 0; 122 m_pseudo = 0;
121 m_pseudoLayout = 0; 123 m_pseudoLayout = 0;
122 124
123 m_dir = true; 125 m_dir = true;
124 m_files = true; 126 m_files = true;
125 m_custom = 0; 127 m_custom = 0;
126 m_showPopup = true; 128 m_showPopup = true;
127 129
128 if(m_pixmaps == 0 ) // init the pixmaps 130 if(m_pixmaps == 0 ) // init the pixmaps
129 initPics(); 131 initPics();
130 132
131 m_lay = new QVBoxLayout(this); 133 m_lay = new QVBoxLayout(this);
132 init(); 134 init();
133 m_edit->setText( fileName ); 135 m_edit->setText( fileName );
134} 136}
135void OFileSelector::initPics() 137void OFileSelector::initPics()
136{ 138{
137 qWarning("init pics" ); 139 qWarning("init pics" );
138 m_pixmaps = new QMap<QString,QPixmap>; 140 m_pixmaps = new QMap<QString,QPixmap>;
139 QPixmap pm = Resource::loadPixmap( "folder" ); 141 QPixmap pm = Resource::loadPixmap( "folder" );
140 QPixmap lnk = Resource::loadPixmap( "symlink" ); 142 QPixmap lnk = Resource::loadPixmap( "symlink" );
141 QPainter painter( &pm ); 143 QPainter painter( &pm );
142 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 144 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
143 pm.setMask( pm.createHeuristicMask( FALSE ) ); 145 pm.setMask( pm.createHeuristicMask( FALSE ) );
144 m_pixmaps->insert("dirsymlink", pm ); 146 m_pixmaps->insert("dirsymlink", pm );
145 147
146 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); 148 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" );
147 QPainter pen(&pm2 ); 149 QPainter pen(&pm2 );
148 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); 150 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk );
149 pm2.setMask( pm2.createHeuristicMask( FALSE ) ); 151 pm2.setMask( pm2.createHeuristicMask( FALSE ) );
150 m_pixmaps->insert("symlinkedlocked", pm2 ); 152 m_pixmaps->insert("symlinkedlocked", pm2 );
151 153
152}; 154};
153// let's initialize the gui 155// let's initialize the gui
154/** 156/**
155 -------------------- 157 --------------------
156 | cmbBox Button | 158 | cmbBox Button |
157 -------------------- 159 --------------------
158 | FileSlector | 160 | FileSlector |
159 | or | 161 | or |
160 | OSelector | 162 | OSelector |
161 | | 163 | |
162 | | 164 | |
163 ____________________ 165 ____________________
164 | LineEdit | 166 | LineEdit |
165 ____________________ 167 ____________________
166 | Permission Bar | 168 | Permission Bar |
167 ____________________ 169 ____________________
168 | ViewChoose | 170 | ViewChoose |
169 ____________________ 171 ____________________
170 | Save Cancel| 172 | Save Cancel|
171 ____________________ 173 ____________________
172 */ 174 */
173void OFileSelector::delItems() 175void OFileSelector::delItems()
174{ 176{
175 QLayoutIterator it = m_lay->iterator(); 177 QLayoutIterator it = m_lay->iterator();
176 while ( it.current() != 0 ){ 178 while ( it.current() != 0 ){
177 it.deleteCurrent(); 179 it.deleteCurrent();
178 } 180 }
179} 181}
180void OFileSelector::init() 182void OFileSelector::init()
181{ 183{
182 184
183 m_stack = new QWidgetStack(this, "wstack" ); 185 m_stack = new QWidgetStack(this, "wstack" );
184 if( m_selector == NORMAL ){ 186 if( m_selector == NORMAL ){
185 QString currMime; 187 QString currMime;
186 if( m_mimeCheck != 0 ) 188 if( m_mimeCheck != 0 )
187 currMime = m_mimeCheck->currentText(); 189 currMime = m_mimeCheck->currentText();
188 190
189 updateMimes(); 191 updateMimes();
190 m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); 192 m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE );
191 m_stack->addWidget(m_select, NORMAL ); 193 m_stack->addWidget(m_select, NORMAL );
192 m_lay->addWidget(m_stack ); 194 m_lay->addWidget(m_stack );
193 m_stack->raiseWidget(NORMAL ); 195 m_stack->raiseWidget(NORMAL );
194 connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); 196 connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) );
195 }else { 197 }else {
196 initializeListView(); 198 initializeListView();
197 } 199 }
198 200
199 if(m_shLne ){ 201 if(m_shLne ){
200 initializeName(); 202 initializeName();
201 } 203 }
202 204
203 if(m_shPerm ){ 205 if(m_shPerm ){
204 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); 206 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" );
205 m_checkPerm->setChecked( false ); 207 m_checkPerm->setChecked( false );
206 m_lay->addWidget(m_checkPerm ); 208 m_lay->addWidget(m_checkPerm );
207 } 209 }
208 210
209 if( m_shChooser ) 211 if( m_shChooser )
210 initializeChooser(); 212 initializeChooser();
211 213
212 if(m_shYesNo ) 214 if(m_shYesNo )
213 initializeYes(); 215 initializeYes();
214 216
215 217
216}; 218};
217 219
218void OFileSelector::setYesCancelVisible( bool show ) 220void OFileSelector::setYesCancelVisible( bool show )
219{ 221{
220 if ( show == m_shYesNo ) 222 if ( show == m_shYesNo )
221 return; 223 return;
222 m_shYesNo = show; 224 m_shYesNo = show;
223 if( !show ){ 225 if( !show ){
224 delete m_ok; 226 delete m_ok;
225 delete m_cancel; 227 delete m_cancel;
226 m_ok = 0; 228 m_ok = 0;
227 m_cancel = 0; 229 m_cancel = 0;
228 // delete m_boxOk; all ready deleted in delItems 230 // delete m_boxOk; all ready deleted in delItems
229 } 231 }
230 updateLay(); // recreate it and save the other states 232 updateLay(); // recreate it and save the other states
231} 233}
232 234
233void OFileSelector::setToolbarVisible( bool show ) 235void OFileSelector::setToolbarVisible( bool show )
234{ 236{
235 if ( m_shTool == show ) 237 if ( m_shTool == show )
236 return; 238 return;
237 if(!m_shTool ){ 239 if(!m_shTool ){
238 delete m_boxToolbar; 240 delete m_boxToolbar;
239 delete m_homeButton; 241 delete m_homeButton;
240 delete m_docButton; 242 delete m_docButton;
241 delete m_location; 243 delete m_location;
242 delete m_up; 244 delete m_up;
243 m_boxToolbar = 0; 245 m_boxToolbar = 0;
244 m_homeButton = 0; 246 m_homeButton = 0;
245 m_docButton = 0; 247 m_docButton = 0;
246 m_location = 0; 248 m_location = 0;
247 m_up = 0; 249 m_up = 0;
248 }; 250 };
249 updateLay();// overkill fix it 251 updateLay();// overkill fix it
250} 252}
251 253
252void OFileSelector::setPermissionBarVisible( bool show ) 254void OFileSelector::setPermissionBarVisible( bool show )
253{ 255{
254 if( show == m_shPerm ) 256 if( show == m_shPerm )
255 return; 257 return;
256 258
257 m_shPerm = show; 259 m_shPerm = show;
258 260
259 updateLay(); 261 updateLay();
260} 262}
261void OFileSelector::setLineEditVisible( bool show ) 263void OFileSelector::setLineEditVisible( bool show )
262{ 264{
263 if( show == m_shLne ) 265 if( show == m_shLne )
264 return; 266 return;
265 267
266 m_shLne = show; 268 m_shLne = show;
267 if( !show ){ 269 if( !show ){
268 delete m_edit; 270 delete m_edit;
269 delete m_fnLabel; 271 delete m_fnLabel;
270 m_edit = 0; 272 m_edit = 0;
271 m_fnLabel = 0; 273 m_fnLabel = 0;
272 //delete m_boxName; will be deleted 274 //delete m_boxName; will be deleted
273 } 275 }