summaryrefslogtreecommitdiff
path: root/libopie2/opieui/fileselector
Unidiff
Diffstat (limited to 'libopie2/opieui/fileselector') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofiledialog.cpp4
-rw-r--r--libopie2/opieui/fileselector/ofileselector.cpp14
2 files changed, 9 insertions, 9 deletions
diff --git a/libopie2/opieui/fileselector/ofiledialog.cpp b/libopie2/opieui/fileselector/ofiledialog.cpp
index 2a89c5d..e7daead 100644
--- a/libopie2/opieui/fileselector/ofiledialog.cpp
+++ b/libopie2/opieui/fileselector/ofiledialog.cpp
@@ -66,98 +66,98 @@ void saveLastDir( const QString& key, const QString& file )
66{ 66{
67 if ( qApp->argc() < 1 ) 67 if ( qApp->argc() < 1 )
68 return; 68 return;
69 69
70 Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); 70 Config cfg( QFileInfo(qApp->argv()[0]).fileName() );
71 cfg.setGroup( key ); 71 cfg.setGroup( key );
72 QFileInfo inf( file ); 72 QFileInfo inf( file );
73 cfg.writeEntry("LastDir", inf.dirPath( true ) ); 73 cfg.writeEntry("LastDir", inf.dirPath( true ) );
74} 74}
75}; 75};
76 76
77/** 77/**
78 * This constructs a modal dialog 78 * This constructs a modal dialog
79 * 79 *
80 * @param caption The caption of the dialog 80 * @param caption The caption of the dialog
81 * @param wid The parent widget 81 * @param wid The parent widget
82 * @param mode The mode of the OFileSelector @see OFileSelector 82 * @param mode The mode of the OFileSelector @see OFileSelector
83 * @param selector The selector of the OFileSelector 83 * @param selector The selector of the OFileSelector
84 * @param dirName the dir or resource to start from 84 * @param dirName the dir or resource to start from
85 * @param fileName a proposed or existing filename 85 * @param fileName a proposed or existing filename
86 * @param mimetypes The mimeTypes 86 * @param mimetypes The mimeTypes
87 */ 87 */
88OFileDialog::OFileDialog(const QString &caption, 88OFileDialog::OFileDialog(const QString &caption,
89 QWidget *wid, int mode, int selector, 89 QWidget *wid, int mode, int selector,
90 const QString &dirName, 90 const QString &dirName,
91 const QString &fileName, 91 const QString &fileName,
92 const QMap<QString,QStringList>& mimetypes ) 92 const QMap<QString,QStringList>& mimetypes )
93 : QDialog( wid, "OFileDialog", true ) 93 : QDialog( wid, "OFileDialog", true )
94{ 94{
95 // QVBoxLayout *lay = new QVBoxLayout(this); 95 // QVBoxLayout *lay = new QVBoxLayout(this);
96 //showMaximized(); 96 //showMaximized();
97 QVBoxLayout *lay = new QVBoxLayout(this ); 97 QVBoxLayout *lay = new QVBoxLayout(this );
98 file = new OFileSelector(this , mode, selector, 98 file = new OFileSelector(this , mode, selector,
99 dirName, fileName, 99 dirName, fileName,
100 mimetypes ); 100 mimetypes );
101 lay->addWidget( file ); 101 lay->addWidget( file );
102 102
103 //lay->addWidget( file ); 103 //lay->addWidget( file );
104 //showFullScreen(); 104 //showFullScreen();
105 setCaption( caption.isEmpty() ? tr("FileDialog") : caption ); 105 setCaption( caption.isEmpty() ? tr("FileDialog") : caption );
106 connect(file, SIGNAL(fileSelected(const QString&) ), 106 connect(file, SIGNAL(fileSelected(const QString&) ),
107 this, SLOT(slotFileSelected(const QString&) ) ); 107 this, SLOT(slotFileSelected(const QString&) ) );
108 connect(file, SIGNAL(ok() ), 108 connect(file, SIGNAL(ok() ),
109 this, SLOT(slotSelectorOk()) ) ; 109 this, SLOT(slotSelectorOk()) ) ;
110 110
111 connect(file, SIGNAL(dirSelected(const QString&) ), this, SLOT(slotDirSelected(const QString&) ) ); 111 connect(file, SIGNAL(dirSelected(const QString&) ), this, SLOT(slotDirSelected(const QString&) ) );
112 112
113#if 0 113#if 0
114 connect(file, SIGNAL(dirSelected(const QString &) ), 114 connect(file, SIGNAL(dirSelected(const QString&) ),
115 this, SLOT(slotDirSelected(const QString &) ) ); 115 this, SLOT(slotDirSelected(const QString&) ) );
116#endif 116#endif
117} 117}
118/** 118/**
119 * @returns the mimetype of the selected 119 * @returns the mimetype of the selected
120 * currently it return QString::null 120 * currently it return QString::null
121 */ 121 */
122QString OFileDialog::mimetype()const 122QString OFileDialog::mimetype()const
123{ 123{
124 return QString::null; 124 return QString::null;
125} 125}
126 126
127/** 127/**
128 * @return the fileName 128 * @return the fileName
129 */ 129 */
130QString OFileDialog::fileName()const 130QString OFileDialog::fileName()const
131{ 131{
132 return file->selectedName(); 132 return file->selectedName();
133} 133}
134 134
135/** 135/**
136 * return a DocLnk to the current file 136 * return a DocLnk to the current file
137 */ 137 */
138DocLnk OFileDialog::selectedDocument()const 138DocLnk OFileDialog::selectedDocument()const
139{ 139{
140 return file->selectedDocument(); 140 return file->selectedDocument();
141} 141}
142 142
143/** 143/**
144 * This opens up a filedialog in Open mode 144 * This opens up a filedialog in Open mode
145 * 145 *
146 * @param selector the Selector Mode 146 * @param selector the Selector Mode
147 * @param startDir Where to start from 147 * @param startDir Where to start from
148 * @param file A proposed filename 148 * @param file A proposed filename
149 * @param mimes A list of MimeTypes 149 * @param mimes A list of MimeTypes
150 * @param wid the parent 150 * @param wid the parent
151 * @param caption of the dialog if QString::null tr("Open") will be used 151 * @param caption of the dialog if QString::null tr("Open") will be used
152 * @return the fileName or QString::null 152 * @return the fileName or QString::null
153 */ 153 */
154QString OFileDialog::getOpenFileName(int selector, 154QString OFileDialog::getOpenFileName(int selector,
155 const QString &_startDir, 155 const QString &_startDir,
156 const QString &file, 156 const QString &file,
157 const MimeTypes &mimes, 157 const MimeTypes &mimes,
158 QWidget *wid, 158 QWidget *wid,
159 const QString &caption ) 159 const QString &caption )
160{ 160{
161 QString ret; 161 QString ret;
162 QString startDir = _startDir; 162 QString startDir = _startDir;
163 if (startDir.isEmpty() ) 163 if (startDir.isEmpty() )
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();