summaryrefslogtreecommitdiffabout
path: root/microkde/ofileselector_p.cpp
Unidiff
Diffstat (limited to 'microkde/ofileselector_p.cpp') (more/less context) (show whitespace changes)
-rw-r--r--microkde/ofileselector_p.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/microkde/ofileselector_p.cpp b/microkde/ofileselector_p.cpp
index e2af32b..488dee2 100644
--- a/microkde/ofileselector_p.cpp
+++ b/microkde/ofileselector_p.cpp
@@ -112,106 +112,107 @@ void ODocumentFileView::reread() {
112 if (!m_selector) 112 if (!m_selector)
113 return; 113 return;
114 114
115 m_selector->setNewVisible( showNew() ); 115 m_selector->setNewVisible( showNew() );
116 m_selector->setCloseVisible( showClose() ); 116 m_selector->setCloseVisible( showClose() );
117 m_selector->filter = currentMimeType().join(";"); 117 m_selector->filter = currentMimeType().join(";");
118 m_selector->reread(); 118 m_selector->reread();
119} 119}
120int ODocumentFileView::fileCount()const { 120int ODocumentFileView::fileCount()const {
121 if (!m_selector) 121 if (!m_selector)
122 return -1; 122 return -1;
123 123
124 return m_selector->fileCount(); 124 return m_selector->fileCount();
125} 125}
126 126
127DocLnk ODocumentFileView::selectedDocument()const { 127DocLnk ODocumentFileView::selectedDocument()const {
128 if (!m_selector) 128 if (!m_selector)
129 return DocLnk(); 129 return DocLnk();
130 DocLnk lnk = *m_selector->selected(); 130 DocLnk lnk = *m_selector->selected();
131 return lnk; 131 return lnk;
132} 132}
133 133
134QWidget* ODocumentFileView::widget( QWidget* parent ) { 134QWidget* ODocumentFileView::widget( QWidget* parent ) {
135 if (!m_selector ) { 135 if (!m_selector ) {
136 m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); 136 m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() );
137 QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ), 137 QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ),
138 selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); 138 selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) );
139 QObject::connect(m_selector, SIGNAL(closeMe() ), 139 QObject::connect(m_selector, SIGNAL(closeMe() ),
140 selector(), SIGNAL(closeMe() ) ); 140 selector(), SIGNAL(closeMe() ) );
141 QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ), 141 QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ),
142 selector(), SIGNAL(newSelected(const DocLnk& ) ) ); 142 selector(), SIGNAL(newSelected(const DocLnk& ) ) );
143 } 143 }
144 144
145 return m_selector; 145 return m_selector;
146} 146}
147 147
148/* 148/*
149 * This is the file system view used 149 * This is the file system view used
150 * we use a QListView + QListViewItems for it 150 * we use a QListView + QListViewItems for it
151 */ 151 */
152 152
153OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, 153OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap,
154 const QString& path, const QString& date, 154 const QString& path, const QString& date,
155 const QString& size, const QString& dir, 155 const QString& size, const QString& dir,
156 bool isLocked, bool isDir ) 156 bool isLocked, bool isDir )
157 : QListViewItem( view ) 157 : QListViewItem( view )
158{ 158{
159 159
160 QString kind; 160 QString kind = "dir";;
161 QString _path = path; 161 QString _path = path;
162 if ( isDir ) 162 if ( !isDir ){
163 kind = "dir"; 163 int arrow = path.findRev( "." ,-1);
164 else 164 if (arrow > 0 ) {
165 kind = "file"; 165 kind = path.mid(arrow+1);
166 }
167 }
166 setPixmap(0, pixmap ); 168 setPixmap(0, pixmap );
167 int arrow = path.find( "->" ); 169 int arrow = path.find( "->" );
168 if (arrow > 0 ) { 170 if (arrow > 0 ) {
169 kind += path.mid( arrow );
170 _path = path.left(arrow); 171 _path = path.left(arrow);
171 } 172 }
172 setText(1, _path ); 173 setText(1, _path );
173 setText(2, size ); 174 setText(2, size );
174 setText(3, date ); 175 setText(3, date );
175 setText(4, kind ); 176 setText(4, kind );
176 m_isDir = isDir; 177 m_isDir = isDir;
177 m_dir = dir; 178 m_dir = dir;
178 m_locked = isLocked; 179 m_locked = isLocked;
179} 180}
180OFileSelectorItem::~OFileSelectorItem() { 181OFileSelectorItem::~OFileSelectorItem() {
181 182
182} 183}
183bool OFileSelectorItem::isLocked()const { 184bool OFileSelectorItem::isLocked()const {
184 return m_locked; 185 return m_locked;
185} 186}
186QString OFileSelectorItem::directory()const { 187QString OFileSelectorItem::directory()const {
187 return m_dir; 188 return m_dir;
188} 189}
189bool OFileSelectorItem::isDir()const { 190bool OFileSelectorItem::isDir()const {
190 return m_isDir; 191 return m_isDir;
191} 192}
192QString OFileSelectorItem::path()const { 193QString OFileSelectorItem::path()const {
193 return text( 1 ); 194 return text( 1 );
194} 195}
195QString OFileSelectorItem::key( int id, bool )const { 196QString OFileSelectorItem::key( int id, bool )const {
196 QString ke; 197 QString ke;
197 if( id == 0 || id == 1 ){ // name 198 if( id == 0 || id == 1 ){ // name
198 if( m_isDir ){ 199 if( m_isDir ){
199 ke.append("0" ); 200 ke.append("0" );
200 ke.append( text(1) ); 201 ke.append( text(1) );
201 }else{ 202 }else{
202 ke.append("1" ); 203 ke.append("1" );
203 ke.append( text(1) ); 204 ke.append( text(1) );
204 } 205 }
205 return ke; 206 return ke;
206 } else if ( id == 2 ) { 207 } else if ( id == 2 ) {
207 QString sort = "00000000"; 208 QString sort = "00000000";
208 sort = sort.left( 9-text( 2 ).length()) + text( 2 ); 209 sort = sort.left( 9-text( 2 ).length()) + text( 2 );
209 return sort; 210 return sort;
210 211
211 } else 212 } else
212 return text( id ); 213 return text( id );
213 214
214} 215}
215 216
216OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, 217OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir,
217 OFileSelector* sel) 218 OFileSelector* sel)
@@ -246,99 +247,99 @@ OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& st
246 247
247 btn = new QToolButton( box ); 248 btn = new QToolButton( box );
248 btn->setIconSet( Resource::loadPixmap("DocsIcon") ); 249 btn->setIconSet( Resource::loadPixmap("DocsIcon") );
249 connect(btn, SIGNAL(clicked() ), 250 connect(btn, SIGNAL(clicked() ),
250 this, SLOT(cdDoc() ) ); 251 this, SLOT(cdDoc() ) );
251 252
252 m_btnNew = new QToolButton( box ); 253 m_btnNew = new QToolButton( box );
253 m_btnNew->setIconSet( Resource::loadPixmap("new") ); 254 m_btnNew->setIconSet( Resource::loadPixmap("new") );
254 connect(m_btnNew, SIGNAL(clicked() ), 255 connect(m_btnNew, SIGNAL(clicked() ),
255 this, SLOT(slotNew() ) ); 256 this, SLOT(slotNew() ) );
256 257
257 258
258 m_btnClose = new QToolButton( box ); 259 m_btnClose = new QToolButton( box );
259 m_btnClose->setIconSet( Resource::loadPixmap("close") ); 260 m_btnClose->setIconSet( Resource::loadPixmap("close") );
260 connect(m_btnClose, SIGNAL(clicked() ), 261 connect(m_btnClose, SIGNAL(clicked() ),
261 selector(), SIGNAL(closeMe() ) ); 262 selector(), SIGNAL(closeMe() ) );
262 263
263 btn = new QToolButton( box ); 264 btn = new QToolButton( box );
264 btn->setIconSet( Resource::loadPixmap("cardmon/pcmcia") ); 265 btn->setIconSet( Resource::loadPixmap("cardmon/pcmcia") );
265 266
266 /* let's fill device parts */ 267 /* let's fill device parts */
267 QPopupMenu* pop = new QPopupMenu(this); 268 QPopupMenu* pop = new QPopupMenu(this);
268 connect(pop, SIGNAL( activated(int) ), 269 connect(pop, SIGNAL( activated(int) ),
269 this, SLOT(slotFSActivated(int) ) ); 270 this, SLOT(slotFSActivated(int) ) );
270 271
271 StorageInfo storage; 272 StorageInfo storage;
272 const QList<FileSystem> &fs = storage.fileSystems(); 273 const QList<FileSystem> &fs = storage.fileSystems();
273 QListIterator<FileSystem> it(fs); 274 QListIterator<FileSystem> it(fs);
274 for ( ; it.current(); ++it ) { 275 for ( ; it.current(); ++it ) {
275 const QString disk = (*it)->name(); 276 const QString disk = (*it)->name();
276 const QString path = (*it)->path(); 277 const QString path = (*it)->path();
277 m_dev.insert( disk, path ); 278 m_dev.insert( disk, path );
278 pop->insertItem( disk ); 279 pop->insertItem( disk );
279 } 280 }
280 m_fsPop = pop; 281 m_fsPop = pop;
281 282
282 283
283 btn->setPopup( pop ); 284 btn->setPopup( pop );
284 btn->setPopupDelay ( 0 ); 285 btn->setPopupDelay ( 0 );
285 lay->addWidget( box ); 286 lay->addWidget( box );
286 287
287 m_view = new QListView( this ); 288 m_view = new QListView( this );
288 289
289 m_view->installEventFilter(this); 290 m_view->installEventFilter(this);
290 291
291 QPEApplication::setStylusOperation( m_view->viewport(), 292 QPEApplication::setStylusOperation( m_view->viewport(),
292 QPEApplication::RightOnHold); 293 QPEApplication::RightOnHold);
293 m_view->addColumn(" " ); 294 m_view->addColumn(" " );
294 m_view->addColumn(i18n("Name"), 135 ); 295 m_view->addColumn(i18n("Name"), 150 );
295 m_view->addColumn(i18n("Size"), -1 ); 296 m_view->addColumn(i18n("Size"), -1 );
296 m_view->addColumn(i18n("Date"), 60 ); 297 m_view->addColumn(i18n("Date"), -1 );
297 m_view->addColumn(i18n("Mime Type"), -1 ); 298 m_view->addColumn(i18n("Mime Type"), -1 );
298 299
299 300
300 m_view->setSorting( 1 ); 301 m_view->setSorting( 1 );
301 m_view->setAllColumnsShowFocus( TRUE ); 302 m_view->setAllColumnsShowFocus( TRUE );
302 303
303 lay->addWidget( m_view, 1000 ); 304 lay->addWidget( m_view, 1000 );
304 connectSlots(); 305 connectSlots();
305} 306}
306OFileViewFileListView::~OFileViewFileListView() { 307OFileViewFileListView::~OFileViewFileListView() {
307} 308}
308void OFileViewFileListView::slotNew() { 309void OFileViewFileListView::slotNew() {
309 DocLnk lnk; 310 DocLnk lnk;
310 emit selector()->newSelected( lnk ); 311 emit selector()->newSelected( lnk );
311} 312}
312OFileSelectorItem* OFileViewFileListView::currentItem()const{ 313OFileSelectorItem* OFileViewFileListView::currentItem()const{
313 QListViewItem* item = m_view->currentItem(); 314 QListViewItem* item = m_view->currentItem();
314 if (!item ) 315 if (!item )
315 return 0l; 316 return 0l;
316 317
317 return static_cast<OFileSelectorItem*>(item); 318 return static_cast<OFileSelectorItem*>(item);
318} 319}
319void OFileViewFileListView::reread( bool all ) { 320void OFileViewFileListView::reread( bool all ) {
320 m_view->clear(); 321 m_view->clear();
321 322
322 if (selector()->showClose() ) 323 if (selector()->showClose() )
323 m_btnClose->show(); 324 m_btnClose->show();
324 else 325 else
325 m_btnClose->hide(); 326 m_btnClose->hide();
326 327
327 if (selector()->showNew() ) 328 if (selector()->showNew() )
328 m_btnNew->show(); 329 m_btnNew->show();
329 else 330 else
330 m_btnNew->hide(); 331 m_btnNew->hide();
331 332
332 m_mimes = selector()->currentMimeType(); 333 m_mimes = selector()->currentMimeType();
333 m_all = all; 334 m_all = all;
334 335
335 QDir dir( m_currentDir ); 336 QDir dir( m_currentDir );
336 if (!dir.exists() ) 337 if (!dir.exists() )
337 return; 338 return;
338 topLevelWidget()->setCaption( dir.path() ); 339 topLevelWidget()->setCaption( dir.path() );
339 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); 340 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed );
340 int filter; 341 int filter;
341 if (m_all ) 342 if (m_all )
342 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; 343 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
343 else 344 else
344 filter = QDir::Files | QDir::Dirs | QDir::All; 345 filter = QDir::Files | QDir::Dirs | QDir::All;