summaryrefslogtreecommitdiff
path: root/libopie2/opieui/fileselector/ofileselector.cpp
Unidiff
Diffstat (limited to 'libopie2/opieui/fileselector/ofileselector.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofileselector.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp
index 600daff..15cadd4 100644
--- a/libopie2/opieui/fileselector/ofileselector.cpp
+++ b/libopie2/opieui/fileselector/ofileselector.cpp
@@ -165,102 +165,102 @@ QString ODocumentFileView::selectedName()const
165 if (!m_selector) 165 if (!m_selector)
166 return QString::null; 166 return QString::null;
167 167
168 return m_selector->selectedDocument().file(); 168 return m_selector->selectedDocument().file();
169} 169}
170 170
171QString ODocumentFileView::selectedPath()const 171QString ODocumentFileView::selectedPath()const
172{ 172{
173 return QPEApplication::documentDir(); 173 return QPEApplication::documentDir();
174} 174}
175 175
176QString ODocumentFileView::directory()const 176QString ODocumentFileView::directory()const
177{ 177{
178 return selectedPath(); 178 return selectedPath();
179} 179}
180 180
181void ODocumentFileView::reread() 181void ODocumentFileView::reread()
182{ 182{
183 if (!m_selector) 183 if (!m_selector)
184 return; 184 return;
185 185
186 m_selector->setNewVisible( showNew() ); 186 m_selector->setNewVisible( showNew() );
187 m_selector->setCloseVisible( showClose() ); 187 m_selector->setCloseVisible( showClose() );
188 m_selector->filter = currentMimeType().join(";"); 188 m_selector->filter = currentMimeType().join(";");
189 m_selector->reread(); 189 m_selector->reread();
190} 190}
191 191
192int ODocumentFileView::fileCount()const 192int ODocumentFileView::fileCount()const
193{ 193{
194 if (!m_selector) 194 if (!m_selector)
195 return -1; 195 return -1;
196 196
197 return m_selector->fileCount(); 197 return m_selector->fileCount();
198} 198}
199 199
200DocLnk ODocumentFileView::selectedDocument()const 200DocLnk ODocumentFileView::selectedDocument()const
201{ 201{
202 if (!m_selector) 202 if (!m_selector)
203 return DocLnk(); 203 return DocLnk();
204 204
205 return m_selector->selectedDocument(); 205 return m_selector->selectedDocument();
206} 206}
207 207
208QWidget* ODocumentFileView::widget( QWidget* parent ) 208QWidget* ODocumentFileView::widget( QWidget* parent )
209{ 209{
210 if (!m_selector ) 210 if (!m_selector )
211 { 211 {
212 m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); 212 m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() );
213 QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ), 213 QObject::connect(m_selector, SIGNAL(fileSelected(const DocLnk&) ),
214 selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); 214 selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) );
215 QObject::connect(m_selector, SIGNAL(closeMe() ), 215 QObject::connect(m_selector, SIGNAL(closeMe() ),
216 selector(), SIGNAL(closeMe() ) ); 216 selector(), SIGNAL(closeMe() ) );
217 QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ), 217 QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk&) ),
218 selector(), SIGNAL(newSelected(const DocLnk& ) ) ); 218 selector(), SIGNAL(newSelected(const DocLnk&) ) );
219 } 219 }
220 220
221 return m_selector; 221 return m_selector;
222} 222}
223 223
224/* 224/*
225 * This is the file system view used 225 * This is the file system view used
226 * we use a QListView + QListViewItems for it 226 * we use a QListView + QListViewItems for it
227 */ 227 */
228 228
229OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, 229OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap,
230 const QString& path, const QString& date, 230 const QString& path, const QString& date,
231 const QString& size, const QString& dir, 231 const QString& size, const QString& dir,
232 bool isLocked, bool isDir ) 232 bool isLocked, bool isDir )
233 : QListViewItem( view ) 233 : QListViewItem( view )
234{ 234{
235 setPixmap(0, pixmap ); 235 setPixmap(0, pixmap );
236 setText(1, path ); 236 setText(1, path );
237 setText(2, size ); 237 setText(2, size );
238 setText(3, date ); 238 setText(3, date );
239 m_isDir = isDir; 239 m_isDir = isDir;
240 m_dir = dir; 240 m_dir = dir;
241 m_locked = isLocked; 241 m_locked = isLocked;
242} 242}
243 243
244OFileSelectorItem::~OFileSelectorItem() 244OFileSelectorItem::~OFileSelectorItem()
245{ 245{
246} 246}
247 247
248bool OFileSelectorItem::isLocked()const 248bool OFileSelectorItem::isLocked()const
249{ 249{
250 return m_locked; 250 return m_locked;
251} 251}
252 252
253QString OFileSelectorItem::directory()const 253QString OFileSelectorItem::directory()const
254{ 254{
255 return m_dir; 255 return m_dir;
256} 256}
257 257
258bool OFileSelectorItem::isDir()const 258bool OFileSelectorItem::isDir()const
259{ 259{
260 return m_isDir; 260 return m_isDir;
261} 261}
262 262
263QString OFileSelectorItem::path()const 263QString OFileSelectorItem::path()const
264{ 264{
265 return text( 1 ); 265 return text( 1 );
266} 266}
@@ -479,98 +479,98 @@ void OFileViewFileListView::reread( bool all )
479 { // couldn't resolve symlink add it as symlink 479 { // couldn't resolve symlink add it as symlink
480 addSymlink( fi ); 480 addSymlink( fi );
481 } 481 }
482 } // off for loop for symlink resolving 482 } // off for loop for symlink resolving
483 } 483 }
484 else if( fi->isDir() ) 484 else if( fi->isDir() )
485 addDir( fi ); 485 addDir( fi );
486 else if( fi->isFile() ) 486 else if( fi->isFile() )
487 addFile( fi ); 487 addFile( fi );
488 488
489 ++it; 489 ++it;
490 } // of while loop 490 } // of while loop
491 m_view->sort(); 491 m_view->sort();
492 492
493} 493}
494int OFileViewFileListView::fileCount()const 494int OFileViewFileListView::fileCount()const
495{ 495{
496 return m_view->childCount(); 496 return m_view->childCount();
497} 497}
498 498
499QString OFileViewFileListView::currentDir()const 499QString OFileViewFileListView::currentDir()const
500{ 500{
501 return m_currentDir; 501 return m_currentDir;
502} 502}
503 503
504OFileSelector* OFileViewFileListView::selector() 504OFileSelector* OFileViewFileListView::selector()
505{ 505{
506 return m_sel; 506 return m_sel;
507} 507}
508 508
509bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) 509bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e)
510{ 510{
511 if ( e->type() == QEvent::KeyPress ) 511 if ( e->type() == QEvent::KeyPress )
512 { 512 {
513 QKeyEvent *k = (QKeyEvent *)e; 513 QKeyEvent *k = (QKeyEvent *)e;
514 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) 514 if ( (k->key()==Key_Enter) || (k->key()==Key_Return))
515 { 515 {
516 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); 516 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0);
517 return true; 517 return true;
518 } 518 }
519 } 519 }
520 return false; 520 return false;
521} 521}
522 522
523void OFileViewFileListView::connectSlots() 523void OFileViewFileListView::connectSlots()
524{ 524{
525 connect(m_view, SIGNAL(clicked(QListViewItem*) ), 525 connect(m_view, SIGNAL(clicked(QListViewItem*) ),
526 this, SLOT(slotCurrentChanged(QListViewItem*) ) ); 526 this, SLOT(slotCurrentChanged(QListViewItem*) ) );
527 connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ), 527 connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),
528 this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) ); 528 this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) );
529} 529}
530 530
531void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) 531void OFileViewFileListView::slotCurrentChanged( QListViewItem* item)
532{ 532{
533 if (!item) 533 if (!item)
534 return; 534 return;
535#if 0 535#if 0
536 536
537 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); 537 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
538 538
539 if (!sel->isDir() ) 539 if (!sel->isDir() )
540 { 540 {
541 selector()->m_lneEdit->setText( sel->text(1) ); 541 selector()->m_lneEdit->setText( sel->text(1) );
542 // if in fileselector mode we will emit selected 542 // if in fileselector mode we will emit selected
543 if ( selector()->mode() == OFileSelector::FileSelector ) 543 if ( selector()->mode() == OFileSelector::FileSelector )
544 { 544 {
545 qWarning("slot Current Changed"); 545 qWarning("slot Current Changed");
546 QStringList str = QStringList::split("->", sel->text(1) ); 546 QStringList str = QStringList::split("->", sel->text(1) );
547 QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); 547 QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
548 emit selector()->fileSelected( path ); 548 emit selector()->fileSelected( path );
549 DocLnk lnk( path ); 549 DocLnk lnk( path );
550 emit selector()->fileSelected( lnk ); 550 emit selector()->fileSelected( lnk );
551 } 551 }
552 } 552 }
553#endif 553#endif
554} 554}
555 555
556void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) 556void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int )
557{ 557{
558 if (!item || ( button != Qt::LeftButton) ) 558 if (!item || ( button != Qt::LeftButton) )
559 return; 559 return;
560 560
561 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); 561 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
562 if (!sel->isLocked() ) 562 if (!sel->isLocked() )
563 { 563 {
564 QStringList str = QStringList::split("->", sel->text(1) ); 564 QStringList str = QStringList::split("->", sel->text(1) );
565 if (sel->isDir() ) 565 if (sel->isDir() )
566 { 566 {
567 m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); 567 m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace();
568 emit selector()->dirSelected( m_currentDir ); 568 emit selector()->dirSelected( m_currentDir );
569 reread( m_all ); 569 reread( m_all );
570 } 570 }
571 else 571 else
572 { // file 572 { // file
573 qWarning("slot Clicked"); 573 qWarning("slot Clicked");
574 selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); 574 selector()->m_lneEdit->setText( str[0].stripWhiteSpace() );
575 QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); 575 QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
576 emit selector()->fileSelected( path ); 576 emit selector()->fileSelected( path );
@@ -934,98 +934,98 @@ void OFileSelector::initUI()
934 m_cmbView = new QComboBox( m_cmbBox ); 934 m_cmbView = new QComboBox( m_cmbBox );
935 m_cmbMime = new QComboBox( m_cmbBox ); 935 m_cmbMime = new QComboBox( m_cmbBox );
936 lay->addWidget( m_cmbBox ); 936 lay->addWidget( m_cmbBox );
937} 937}
938 938
939/* 939/*
940 * This will make sure that the return key in the name edit causes dialogs to close 940 * This will make sure that the return key in the name edit causes dialogs to close
941 */ 941 */
942 942
943bool OFileSelector::eventFilter (QObject *o, QEvent *e) 943bool OFileSelector::eventFilter (QObject *o, QEvent *e)
944{ 944{
945 if ( e->type() == QEvent::KeyPress ) 945 if ( e->type() == QEvent::KeyPress )
946 { 946 {
947 QKeyEvent *k = (QKeyEvent *)e; 947 QKeyEvent *k = (QKeyEvent *)e;
948 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) 948 if ( (k->key()==Key_Enter) || (k->key()==Key_Return))
949 { 949 {
950 emit ok(); 950 emit ok();
951 return true; 951 return true;
952 } 952 }
953 } 953 }
954 return false; 954 return false;
955} 955}
956 956
957/* 957/*
958 * This will insert the MimeTypes into the Combo Box 958 * This will insert the MimeTypes into the Combo Box
959 * And also connect the changed signal 959 * And also connect the changed signal
960 * 960 *
961 * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes 961 * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes
962 */ 962 */
963void OFileSelector::initMime() 963void OFileSelector::initMime()
964{ 964{
965 MimeTypes::Iterator it; 965 MimeTypes::Iterator it;
966 for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) 966 for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it )
967 { 967 {
968 m_cmbMime->insertItem( it.key() ); 968 m_cmbMime->insertItem( it.key() );
969 } 969 }
970 m_cmbMime->setCurrentItem( 0 ); 970 m_cmbMime->setCurrentItem( 0 );
971 971
972 connect( m_cmbMime, SIGNAL(activated(int) ), 972 connect( m_cmbMime, SIGNAL(activated(int) ),
973 this, SLOT(slotMimeTypeChanged() ) ); 973 this, SLOT(slotMimeTypeChanged() ) );
974 974
975} 975}
976 976
977void OFileSelector::initViews() 977void OFileSelector::initViews()
978{ 978{
979 m_cmbView->insertItem( QObject::tr("Documents") ); 979 m_cmbView->insertItem( QObject::tr("Documents") );
980 m_cmbView->insertItem( QObject::tr("Files") ); 980 m_cmbView->insertItem( QObject::tr("Files") );
981 m_cmbView->insertItem( QObject::tr("All Files") ); 981 m_cmbView->insertItem( QObject::tr("All Files") );
982 connect(m_cmbView, SIGNAL(activated( const QString& ) ), 982 connect(m_cmbView, SIGNAL(activated(const QString&) ),
983 this, SLOT(slotViewChange( const QString& ) ) ); 983 this, SLOT(slotViewChange(const QString&) ) );
984 984
985 985
986 m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); 986 m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) );
987 987
988 /* see above why add both */ 988 /* see above why add both */
989 OFileViewInterface* in = new OFileViewFileSystem( this ); 989 OFileViewInterface* in = new OFileViewFileSystem( this );
990 m_views.insert( QObject::tr("Files"), in ); 990 m_views.insert( QObject::tr("Files"), in );
991 m_views.insert( QObject::tr("All Files"), in ); 991 m_views.insert( QObject::tr("All Files"), in );
992} 992}
993 993
994/** 994/**
995 * d'tor 995 * d'tor
996 */ 996 */
997OFileSelector::~OFileSelector() 997OFileSelector::~OFileSelector()
998{ 998{
999} 999}
1000 1000
1001 1001
1002 1002
1003/** 1003/**
1004 * Convience function for the fileselector 1004 * Convience function for the fileselector
1005 * make sure to delete the DocLnk 1005 * make sure to delete the DocLnk
1006 * 1006 *
1007 * @see DocLnk 1007 * @see DocLnk
1008 * @todo remove in ODP 1008 * @todo remove in ODP
1009 */ 1009 */
1010const DocLnk* OFileSelector::selected() 1010const DocLnk* OFileSelector::selected()
1011{ 1011{
1012 DocLnk* lnk = new DocLnk( currentView()->selectedDocument() ); 1012 DocLnk* lnk = new DocLnk( currentView()->selectedDocument() );
1013 return lnk; 1013 return lnk;
1014} 1014}
1015 1015
1016/** 1016/**
1017 * 1017 *
1018 * @return the name of the selected file 1018 * @return the name of the selected file
1019 */ 1019 */
1020QString OFileSelector::selectedName()const 1020QString OFileSelector::selectedName()const
1021{ 1021{
1022 return currentView()->selectedName(); 1022 return currentView()->selectedName();
1023} 1023}
1024 1024
1025 1025
1026/** 1026/**
1027 * @return the selected path 1027 * @return the selected path
1028 */ 1028 */
1029QString OFileSelector::selectedPath()const 1029QString OFileSelector::selectedPath()const
1030{ 1030{
1031 return currentView()->selectedPath(); 1031 return currentView()->selectedPath();