Diffstat (limited to 'microkde/ofileselector_p.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/ofileselector_p.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/microkde/ofileselector_p.cpp b/microkde/ofileselector_p.cpp index f4f112e..0f95c84 100644 --- a/microkde/ofileselector_p.cpp +++ b/microkde/ofileselector_p.cpp | |||
@@ -172,193 +172,193 @@ OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, | |||
172 | } | 172 | } |
173 | setText(1, _path ); | 173 | setText(1, _path ); |
174 | setText(2, size ); | 174 | setText(2, size ); |
175 | setText(3, date ); | 175 | setText(3, date ); |
176 | setText(4, kind ); | 176 | setText(4, kind ); |
177 | m_isDir = isDir; | 177 | m_isDir = isDir; |
178 | m_dir = dir; | 178 | m_dir = dir; |
179 | m_locked = isLocked; | 179 | m_locked = isLocked; |
180 | } | 180 | } |
181 | OFileSelectorItem::~OFileSelectorItem() { | 181 | OFileSelectorItem::~OFileSelectorItem() { |
182 | 182 | ||
183 | } | 183 | } |
184 | bool OFileSelectorItem::isLocked()const { | 184 | bool OFileSelectorItem::isLocked()const { |
185 | return m_locked; | 185 | return m_locked; |
186 | } | 186 | } |
187 | QString OFileSelectorItem::directory()const { | 187 | QString OFileSelectorItem::directory()const { |
188 | return m_dir; | 188 | return m_dir; |
189 | } | 189 | } |
190 | bool OFileSelectorItem::isDir()const { | 190 | bool OFileSelectorItem::isDir()const { |
191 | return m_isDir; | 191 | return m_isDir; |
192 | } | 192 | } |
193 | QString OFileSelectorItem::path()const { | 193 | QString OFileSelectorItem::path()const { |
194 | return text( 1 ); | 194 | return text( 1 ); |
195 | } | 195 | } |
196 | QString OFileSelectorItem::key( int id, bool )const { | 196 | QString OFileSelectorItem::key( int id, bool )const { |
197 | QString ke; | 197 | QString ke; |
198 | if( id == 0 || id == 1 ){ // name | 198 | if( id == 0 || id == 1 ){ // name |
199 | if( m_isDir ){ | 199 | if( m_isDir ){ |
200 | ke.append("0" ); | 200 | ke.append("0" ); |
201 | ke.append( text(1) ); | 201 | ke.append( text(1) ); |
202 | }else{ | 202 | }else{ |
203 | ke.append("1" ); | 203 | ke.append("1" ); |
204 | ke.append( text(1) ); | 204 | ke.append( text(1) ); |
205 | } | 205 | } |
206 | return ke; | 206 | return ke; |
207 | } else if ( id == 2 ) { | 207 | } else if ( id == 2 ) { |
208 | QString sort = "00000000"; | 208 | QString sort = "00000000"; |
209 | sort = sort.left( 9-text( 2 ).length()) + text( 2 ); | 209 | sort = sort.left( 9-text( 2 ).length()) + text( 2 ); |
210 | return sort; | 210 | return sort; |
211 | 211 | ||
212 | } else | 212 | } else |
213 | return text( id ); | 213 | return text( id ); |
214 | 214 | ||
215 | } | 215 | } |
216 | 216 | ||
217 | OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, | 217 | OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, |
218 | OFileSelector* sel) | 218 | OFileSelector* sel) |
219 | : QWidget( parent ), m_sel( sel ) { | 219 | : QWidget( parent ), m_sel( sel ) { |
220 | m_all = false; | 220 | m_all = false; |
221 | QVBoxLayout* lay = new QVBoxLayout( this ); | 221 | QVBoxLayout* lay = new QVBoxLayout( this ); |
222 | m_currentDir = startDir; | 222 | m_currentDir = startDir; |
223 | 223 | ||
224 | /* | 224 | /* |
225 | * now we add a special bar | 225 | * now we add a special bar |
226 | * One Button For Up | 226 | * One Button For Up |
227 | * Home | 227 | * Home |
228 | * Doc | 228 | * Doc |
229 | * And a dropdown menu with FileSystems | 229 | * And a dropdown menu with FileSystems |
230 | * FUTURE: one to change dir with lineedit | 230 | * FUTURE: one to change dir with lineedit |
231 | * Bookmarks | 231 | * Bookmarks |
232 | * Create Dir | 232 | * Create Dir |
233 | */ | 233 | */ |
234 | QHBox* box = new QHBox(this ); | 234 | QHBox* box = new QHBox(this ); |
235 | box->setBackgroundMode( PaletteButton ); | 235 | box->setBackgroundMode( PaletteButton ); |
236 | box->setSpacing( 0 ); | 236 | box->setSpacing( 0 ); |
237 | 237 | ||
238 | QToolButton *btn = new QToolButton( box ); | 238 | QToolButton *btn = new QToolButton( box ); |
239 | btn->setIconSet( Resource::loadPixmap("up") ); | 239 | btn->setIconSet( Resource::loadPixmap("up") ); |
240 | connect(btn, SIGNAL(clicked() ), | 240 | connect(btn, SIGNAL(clicked() ), |
241 | this, SLOT( cdUP() ) ); | 241 | this, SLOT( cdUP() ) ); |
242 | 242 | ||
243 | btn = new QToolButton( box ); | 243 | btn = new QToolButton( box ); |
244 | btn->setIconSet( Resource::loadPixmap("home") ); | 244 | btn->setIconSet( Resource::loadPixmap("home") ); |
245 | connect(btn, SIGNAL(clicked() ), | 245 | connect(btn, SIGNAL(clicked() ), |
246 | this, SLOT( cdHome() ) ); | 246 | this, SLOT( cdHome() ) ); |
247 | 247 | ||
248 | btn = new QToolButton( box ); | 248 | btn = new QToolButton( box ); |
249 | btn->setIconSet( Resource::loadPixmap("DocsIcon") ); | 249 | btn->setIconSet( Resource::loadPixmap("DocsIcon") ); |
250 | connect(btn, SIGNAL(clicked() ), | 250 | connect(btn, SIGNAL(clicked() ), |
251 | this, SLOT(cdDoc() ) ); | 251 | this, SLOT(cdDoc() ) ); |
252 | 252 | ||
253 | m_btnNew = new QToolButton( box ); | 253 | m_btnNew = new QToolButton( box ); |
254 | m_btnNew->setIconSet( Resource::loadPixmap("new") ); | 254 | m_btnNew->setIconSet( Resource::loadPixmap("new") ); |
255 | connect(m_btnNew, SIGNAL(clicked() ), | 255 | connect(m_btnNew, SIGNAL(clicked() ), |
256 | this, SLOT(slotNew() ) ); | 256 | this, SLOT(slotNew() ) ); |
257 | 257 | ||
258 | 258 | ||
259 | m_btnClose = new QToolButton( box ); | 259 | m_btnClose = new QToolButton( box ); |
260 | m_btnClose->setIconSet( Resource::loadPixmap("close") ); | 260 | m_btnClose->setIconSet( Resource::loadPixmap("close") ); |
261 | connect(m_btnClose, SIGNAL(clicked() ), | 261 | connect(m_btnClose, SIGNAL(clicked() ), |
262 | selector(), SIGNAL(closeMe() ) ); | 262 | selector(), SIGNAL(closeMe() ) ); |
263 | 263 | ||
264 | btn = new QToolButton( box ); | 264 | btn = new QToolButton( box ); |
265 | btn->setIconSet( Resource::loadPixmap("cardmon/pcmcia") ); | 265 | btn->setIconSet( Resource::loadPixmap("cardmon/pcmcia") ); |
266 | 266 | ||
267 | /* let's fill device parts */ | 267 | /* let's fill device parts */ |
268 | QPopupMenu* pop = new QPopupMenu(this); | 268 | Q3PopupMenu* pop = new Q3PopupMenu(this); |
269 | connect(pop, SIGNAL( activated(int) ), | 269 | connect(pop, SIGNAL( activated(int) ), |
270 | this, SLOT(slotFSActivated(int) ) ); | 270 | this, SLOT(slotFSActivated(int) ) ); |
271 | 271 | ||
272 | StorageInfo storage; | 272 | StorageInfo storage; |
273 | const QList<FileSystem> &fs = storage.fileSystems(); | 273 | const QList<FileSystem> &fs = storage.fileSystems(); |
274 | QListIterator<FileSystem> it(fs); | 274 | QListIterator<FileSystem> it(fs); |
275 | for ( ; it.current(); ++it ) { | 275 | for ( ; it.current(); ++it ) { |
276 | const QString disk = (*it)->name(); | 276 | const QString disk = (*it)->name(); |
277 | const QString path = (*it)->path(); | 277 | const QString path = (*it)->path(); |
278 | m_dev.insert( disk, path ); | 278 | m_dev.insert( disk, path ); |
279 | pop->insertItem( disk ); | 279 | pop->insertItem( disk ); |
280 | } | 280 | } |
281 | m_fsPop = pop; | 281 | m_fsPop = pop; |
282 | 282 | ||
283 | 283 | ||
284 | btn->setPopup( pop ); | 284 | btn->setPopup( pop ); |
285 | btn->setPopupDelay ( 0 ); | 285 | btn->setPopupDelay ( 0 ); |
286 | lay->addWidget( box ); | 286 | lay->addWidget( box ); |
287 | 287 | ||
288 | m_view = new QListView( this ); | 288 | m_view = new QListView( this ); |
289 | 289 | ||
290 | m_view->installEventFilter(this); | 290 | m_view->installEventFilter(this); |
291 | 291 | ||
292 | QPEApplication::setStylusOperation( m_view->viewport(), | 292 | QPEApplication::setStylusOperation( m_view->viewport(), |
293 | QPEApplication::RightOnHold); | 293 | QPEApplication::RightOnHold); |
294 | m_view->addColumn(" " ); | 294 | m_view->addColumn(" " ); |
295 | m_view->addColumn(i18n("Name"), 150 ); | 295 | m_view->addColumn(i18n("Name"), 150 ); |
296 | m_view->addColumn(i18n("Size"), -1 ); | 296 | m_view->addColumn(i18n("Size"), -1 ); |
297 | m_view->addColumn(i18n("Date"), -1 ); | 297 | m_view->addColumn(i18n("Date"), -1 ); |
298 | m_view->addColumn(i18n("Mime Type"), -1 ); | 298 | m_view->addColumn(i18n("Mime Type"), -1 ); |
299 | 299 | ||
300 | 300 | ||
301 | m_view->setSorting( 1 ); | 301 | m_view->setSorting( 1 ); |
302 | m_view->setAllColumnsShowFocus( TRUE ); | 302 | m_view->setAllColumnsShowFocus( TRUE ); |
303 | 303 | ||
304 | lay->addWidget( m_view, 1000 ); | 304 | lay->addWidget( m_view, 1000 ); |
305 | connectSlots(); | 305 | connectSlots(); |
306 | } | 306 | } |
307 | OFileViewFileListView::~OFileViewFileListView() { | 307 | OFileViewFileListView::~OFileViewFileListView() { |
308 | } | 308 | } |
309 | void OFileViewFileListView::slotNew() { | 309 | void OFileViewFileListView::slotNew() { |
310 | DocLnk lnk; | 310 | DocLnk lnk; |
311 | emit selector()->newSelected( lnk ); | 311 | emit selector()->newSelected( lnk ); |
312 | } | 312 | } |
313 | OFileSelectorItem* OFileViewFileListView::currentItem()const{ | 313 | OFileSelectorItem* OFileViewFileListView::currentItem()const{ |
314 | QListViewItem* item = m_view->currentItem(); | 314 | QListViewItem* item = m_view->currentItem(); |
315 | if (!item ) | 315 | if (!item ) |
316 | return 0l; | 316 | return 0l; |
317 | 317 | ||
318 | return static_cast<OFileSelectorItem*>(item); | 318 | return static_cast<OFileSelectorItem*>(item); |
319 | } | 319 | } |
320 | void OFileViewFileListView::reread( bool all ) { | 320 | void OFileViewFileListView::reread( bool all ) { |
321 | m_view->clear(); | 321 | m_view->clear(); |
322 | 322 | ||
323 | if (selector()->showClose() ) | 323 | if (selector()->showClose() ) |
324 | m_btnClose->show(); | 324 | m_btnClose->show(); |
325 | else | 325 | else |
326 | m_btnClose->hide(); | 326 | m_btnClose->hide(); |
327 | 327 | ||
328 | if (selector()->showNew() ) | 328 | if (selector()->showNew() ) |
329 | m_btnNew->show(); | 329 | m_btnNew->show(); |
330 | else | 330 | else |
331 | m_btnNew->hide(); | 331 | m_btnNew->hide(); |
332 | 332 | ||
333 | m_mimes = selector()->currentMimeType(); | 333 | m_mimes = selector()->currentMimeType(); |
334 | m_all = all; | 334 | m_all = all; |
335 | 335 | ||
336 | QDir dir( m_currentDir ); | 336 | QDir dir( m_currentDir ); |
337 | if (!dir.exists() ) | 337 | if (!dir.exists() ) |
338 | return; | 338 | return; |
339 | topLevelWidget()->setCaption( dir.path() ); | 339 | topLevelWidget()->setCaption( dir.path() ); |
340 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 340 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
341 | int filter; | 341 | int filter; |
342 | if (m_all ) | 342 | if (m_all ) |
343 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 343 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
344 | else | 344 | else |
345 | filter = QDir::Files | QDir::Dirs | QDir::All; | 345 | filter = QDir::Files | QDir::Dirs | QDir::All; |
346 | dir.setFilter( filter ); | 346 | dir.setFilter( filter ); |
347 | 347 | ||
348 | // now go through all files | 348 | // now go through all files |
349 | const QFileInfoList *list = dir.entryInfoList(); | 349 | const QFileInfoList *list = dir.entryInfoList(); |
350 | if (!list) { | 350 | if (!list) { |
351 | cdUP(); | 351 | cdUP(); |
352 | return; | 352 | return; |
353 | } | 353 | } |
354 | QFileInfoListIterator it( *list ); | 354 | QFileInfoListIterator it( *list ); |
355 | QFileInfo *fi; | 355 | QFileInfo *fi; |
356 | while( (fi=it.current() ) ){ | 356 | while( (fi=it.current() ) ){ |
357 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ | 357 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ |
358 | ++it; | 358 | ++it; |
359 | continue; | 359 | continue; |
360 | } | 360 | } |
361 | 361 | ||
362 | /* | 362 | /* |
363 | * It is a symlink we try to resolve it now but don't let us attack by DOS | 363 | * It is a symlink we try to resolve it now but don't let us attack by DOS |
364 | * | 364 | * |