author | llornkcor <llornkcor> | 2002-04-02 00:33:22 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-02 00:33:22 (UTC) |
commit | 83d80c254e77aee34e579fc01679ffb0bfa4599b (patch) (unidiff) | |
tree | 20acc40793f439a00cbf28fa48b74372569ac807 | |
parent | 56b0e9e47fb776ccf78026b3243101415669e8b4 (diff) | |
download | opie-83d80c254e77aee34e579fc01679ffb0bfa4599b.zip opie-83d80c254e77aee34e579fc01679ffb0bfa4599b.tar.gz opie-83d80c254e77aee34e579fc01679ffb0bfa4599b.tar.bz2 |
opps forgot to comment out some stuff
-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp index 652f830..b655c96 100644 --- a/core/apps/textedit/fileBrowser.cpp +++ b/core/apps/textedit/fileBrowser.cpp | |||
@@ -1,574 +1,575 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** copyright 2001 ljp ljp@llornkcor.com | 2 | ** copyright 2001 ljp ljp@llornkcor.com |
3 | ** Created: Fri Dec 14 08:16:46 2001 | 3 | ** Created: Fri Dec 14 08:16:46 2001 |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ****************************************************************************/ | 13 | ****************************************************************************/ |
14 | //#define QTOPIA_INTERNAL_MIMEEXT | 14 | //#define QTOPIA_INTERNAL_MIMEEXT |
15 | #include "fileBrowser.h" | 15 | #include "fileBrowser.h" |
16 | //#include "inputDialog.h" | 16 | //#include "inputDialog.h" |
17 | 17 | ||
18 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
19 | #include <qpe/resource.h> | 19 | #include <qpe/resource.h> |
20 | #include <qpe/fileselector.h> | 20 | #include <qpe/fileselector.h> |
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/menubutton.h> | 22 | #include <qpe/menubutton.h> |
23 | #include <qpe/mimetype.h> | 23 | #include <qpe/mimetype.h> |
24 | 24 | ||
25 | #include <qdict.h> | 25 | #include <qdict.h> |
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | #include <qlistview.h> | 27 | #include <qlistview.h> |
28 | #include <qcombo.h> | 28 | #include <qcombo.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qlayout.h> | 32 | #include <qlayout.h> |
33 | #include <unistd.h> | 33 | #include <unistd.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qlineedit.h> | 35 | #include <qlineedit.h> |
36 | #include <qstringlist.h> | 36 | #include <qstringlist.h> |
37 | 37 | ||
38 | #include <unistd.h> | 38 | #include <unistd.h> |
39 | #include <stdlib.h> | 39 | #include <stdlib.h> |
40 | 40 | ||
41 | static int u_id = 1; | 41 | static int u_id = 1; |
42 | static int get_unique_id() | 42 | static int get_unique_id() |
43 | { | 43 | { |
44 | return u_id++; | 44 | return u_id++; |
45 | } | 45 | } |
46 | 46 | ||
47 | fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString mimeFilter ) | 47 | fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString mimeFilter ) |
48 | : QDialog( parent, name, modal, fl ) | 48 | : QDialog( parent, name, modal, fl ) |
49 | { | 49 | { |
50 | if ( !name ) | 50 | if ( !name ) |
51 | setName( "fileBrowser" ); | 51 | setName( "fileBrowser" ); |
52 | setCaption(tr( name ) ); | 52 | setCaption(tr( name ) ); |
53 | // mimeType = mimeFilter; | 53 | // mimeType = mimeFilter; |
54 | // MimeType mt( mimeType); | 54 | // MimeType mt( mimeType); |
55 | // if( mt.extension().isEmpty()) | 55 | // if( mt.extension().isEmpty()) |
56 | QStringList filterList; | 56 | // QStringList filterList; |
57 | filterList=QStringList::split(";",mimeFilter,FALSE); | 57 | // filterList=QStringList::split(";",mimeFilter,FALSE); |
58 | for ( QStringList::Iterator it = filterList.begin(); it != filterList.end(); ++it ) { | 58 | // for ( QStringList::Iterator it = filterList.begin(); it != filterList.end(); ++it ) { |
59 | printf( "%s \n", (*it).latin1() ); | 59 | // printf( "%s \n", (*it).latin1() ); |
60 | } | 60 | // } |
61 | 61 | ||
62 | filterStr = mimeFilter.right(mimeFilter.length()- mimeFilter.find("/",0,TRUE) - 1);// "*"; | 62 | filterStr = mimeFilter.right(mimeFilter.length() - mimeFilter.find("/",0,TRUE) - 1);// "*"; |
63 | |||
63 | qDebug(filterStr); | 64 | qDebug(filterStr); |
64 | // else | 65 | // else |
65 | // filterStr = "*."+ mt.extension(); | 66 | // filterStr = "*."+ mt.extension(); |
66 | // qDebug("description "+mt.description()); | 67 | // qDebug("description "+mt.description()); |
67 | // qDebug( "id "+mt.id()); | 68 | // qDebug( "id "+mt.id()); |
68 | // qDebug("extension "+mt.extension()); | 69 | // qDebug("extension "+mt.extension()); |
69 | 70 | ||
70 | // channel = new QCopChannel( "QPE/fileDialog", this ); | 71 | // channel = new QCopChannel( "QPE/fileDialog", this ); |
71 | // connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 72 | // connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
72 | // this, SLOT(receive(const QCString&, const QByteArray&)) ); | 73 | // this, SLOT(receive(const QCString&, const QByteArray&)) ); |
73 | 74 | ||
74 | QGridLayout *layout = new QGridLayout( this ); | 75 | QGridLayout *layout = new QGridLayout( this ); |
75 | layout->setSpacing( 4 ); | 76 | layout->setSpacing( 4 ); |
76 | layout->setMargin( 4 ); | 77 | layout->setMargin( 4 ); |
77 | 78 | ||
78 | dirPathCombo = new QComboBox( FALSE, this, "dirPathCombo" ); | 79 | dirPathCombo = new QComboBox( FALSE, this, "dirPathCombo" ); |
79 | dirPathCombo->setEditable(TRUE); | 80 | dirPathCombo->setEditable(TRUE); |
80 | 81 | ||
81 | connect( dirPathCombo, SIGNAL( activated( const QString & ) ), | 82 | connect( dirPathCombo, SIGNAL( activated( const QString & ) ), |
82 | this, SLOT( dirPathComboActivated( const QString & ) ) ); | 83 | this, SLOT( dirPathComboActivated( const QString & ) ) ); |
83 | 84 | ||
84 | connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ), | 85 | connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ), |
85 | this, SLOT( dirPathEditPressed( ) ) ); | 86 | this, SLOT( dirPathEditPressed( ) ) ); |
86 | 87 | ||
87 | dirPathStringList << "/"; | 88 | dirPathStringList << "/"; |
88 | // we can get the storage here | 89 | // we can get the storage here |
89 | 90 | ||
90 | layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 ); | 91 | layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 ); |
91 | 92 | ||
92 | cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); | 93 | cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); |
93 | cdUpButton ->setMinimumSize( QSize( 20, 20 ) ); | 94 | cdUpButton ->setMinimumSize( QSize( 20, 20 ) ); |
94 | cdUpButton ->setMaximumSize( QSize( 20, 20 ) ); | 95 | cdUpButton ->setMaximumSize( QSize( 20, 20 ) ); |
95 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); | 96 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); |
96 | cdUpButton ->setFlat(TRUE); | 97 | cdUpButton ->setFlat(TRUE); |
97 | layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 ); | 98 | layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 ); |
98 | 99 | ||
99 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); | 100 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); |
100 | docButton->setMinimumSize( QSize( 20, 20 ) ); | 101 | docButton->setMinimumSize( QSize( 20, 20 ) ); |
101 | docButton->setMaximumSize( QSize( 20, 20 ) ); | 102 | docButton->setMaximumSize( QSize( 20, 20 ) ); |
102 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 103 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
103 | docButton->setFlat(TRUE); | 104 | docButton->setFlat(TRUE); |
104 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); | 105 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); |
105 | 106 | ||
106 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); | 107 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); |
107 | homeButton->setMinimumSize( QSize( 20, 20 ) ); | 108 | homeButton->setMinimumSize( QSize( 20, 20 ) ); |
108 | homeButton->setMaximumSize( QSize( 20, 20 ) ); | 109 | homeButton->setMaximumSize( QSize( 20, 20 ) ); |
109 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 110 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
110 | homeButton->setFlat(TRUE); | 111 | homeButton->setFlat(TRUE); |
111 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 ); | 112 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 ); |
112 | 113 | ||
113 | FileStack = new QWidgetStack( this ); | 114 | FileStack = new QWidgetStack( this ); |
114 | 115 | ||
115 | ListView = new QListView( this, "ListView" ); | 116 | ListView = new QListView( this, "ListView" ); |
116 | // ListView->setMinimumSize( QSize( 100, 25 ) ); | 117 | // ListView->setMinimumSize( QSize( 100, 25 ) ); |
117 | ListView->addColumn( tr( "Name" ) ); | 118 | ListView->addColumn( tr( "Name" ) ); |
118 | ListView->setColumnWidth(0,120); | 119 | ListView->setColumnWidth(0,120); |
119 | ListView->setSorting( 2, FALSE); | 120 | ListView->setSorting( 2, FALSE); |
120 | ListView->addColumn( tr( "Size" ) ); | 121 | ListView->addColumn( tr( "Size" ) ); |
121 | ListView->setColumnWidth(1,-1); | 122 | ListView->setColumnWidth(1,-1); |
122 | ListView->addColumn( "Date",-1); | 123 | ListView->addColumn( "Date",-1); |
123 | 124 | ||
124 | ListView->setColumnWidthMode(0,QListView::Manual); | 125 | ListView->setColumnWidthMode(0,QListView::Manual); |
125 | ListView->setColumnAlignment(1,QListView::AlignRight); | 126 | ListView->setColumnAlignment(1,QListView::AlignRight); |
126 | ListView->setColumnAlignment(2,QListView::AlignRight); | 127 | ListView->setColumnAlignment(2,QListView::AlignRight); |
127 | ListView->setAllColumnsShowFocus( TRUE ); | 128 | ListView->setAllColumnsShowFocus( TRUE ); |
128 | 129 | ||
129 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); | 130 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); |
130 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 131 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
131 | this, SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 132 | this, SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
132 | 133 | ||
133 | connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 134 | connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
134 | 135 | ||
135 | FileStack->addWidget( ListView, get_unique_id() ); | 136 | FileStack->addWidget( ListView, get_unique_id() ); |
136 | 137 | ||
137 | fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy | 138 | fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy |
138 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); | 139 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); |
139 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 140 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
140 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), | 141 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), |
141 | this, SLOT( docOpen( const DocLnk & ) ) ); | 142 | this, SLOT( docOpen( const DocLnk & ) ) ); |
142 | layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 ); | 143 | layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 ); |
143 | 144 | ||
144 | SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" ); | 145 | SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" ); |
145 | SelectionCombo->insertItem( tr( "Documents" ) ); | 146 | SelectionCombo->insertItem( tr( "Documents" ) ); |
146 | SelectionCombo->insertItem( tr( "All files" ) ); | 147 | SelectionCombo->insertItem( tr( "All files" ) ); |
147 | SelectionCombo->insertItem( tr( "Hidden files" ) ); | 148 | SelectionCombo->insertItem( tr( "Hidden files" ) ); |
148 | // SelectionCombo->setMaximumWidth(120); | 149 | // SelectionCombo->setMaximumWidth(120); |
149 | layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 ); | 150 | layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 ); |
150 | 151 | ||
151 | connect( SelectionCombo, SIGNAL( activated( const QString & ) ), | 152 | connect( SelectionCombo, SIGNAL( activated( const QString & ) ), |
152 | this, SLOT( selectionChanged( const QString & ) ) ); | 153 | this, SLOT( selectionChanged( const QString & ) ) ); |
153 | 154 | ||
154 | typemb = new MenuButton(this); | 155 | typemb = new MenuButton(this); |
155 | typemb->setLabel(tr("Type: %1")); | 156 | typemb->setLabel(tr("Type: %1")); |
156 | typemb->setMinimumWidth(110); | 157 | typemb->setMinimumWidth(110); |
157 | typemb->setFixedHeight(22); | 158 | typemb->setFixedHeight(22); |
158 | layout->addMultiCellWidget( typemb, 2, 2, 4, 7 ); | 159 | layout->addMultiCellWidget( typemb, 2, 2, 4, 7 ); |
159 | updateMimeTypeMenu() ; | 160 | updateMimeTypeMenu() ; |
160 | 161 | ||
161 | currentDir.setPath(QDir::currentDirPath()); | 162 | currentDir.setPath(QDir::currentDirPath()); |
162 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); | 163 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); |
163 | currentDir.setNameFilter(filterStr); | 164 | currentDir.setNameFilter(filterStr); |
164 | 165 | ||
165 | populateList(); | 166 | populateList(); |
166 | move(0,15); | 167 | move(0,15); |
167 | } | 168 | } |
168 | 169 | ||
169 | fileBrowser::~fileBrowser() | 170 | fileBrowser::~fileBrowser() |
170 | { | 171 | { |
171 | } | 172 | } |
172 | 173 | ||
173 | void fileBrowser::setFileView( int selection ) | 174 | void fileBrowser::setFileView( int selection ) |
174 | { | 175 | { |
175 | SelectionCombo->setCurrentItem( selection ); | 176 | SelectionCombo->setCurrentItem( selection ); |
176 | selectionChanged( SelectionCombo->currentText() ); | 177 | selectionChanged( SelectionCombo->currentText() ); |
177 | } | 178 | } |
178 | 179 | ||
179 | void fileBrowser::populateList() | 180 | void fileBrowser::populateList() |
180 | { | 181 | { |
181 | ListView->clear(); | 182 | ListView->clear(); |
182 | QListViewItem * item; | 183 | QListViewItem * item; |
183 | bool isDir=FALSE; | 184 | bool isDir=FALSE; |
184 | //qDebug(currentDir.canonicalPath()); | 185 | //qDebug(currentDir.canonicalPath()); |
185 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 186 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
186 | currentDir.setMatchAllDirs(TRUE); | 187 | currentDir.setMatchAllDirs(TRUE); |
187 | 188 | ||
188 | // currentDir.setNameFilter("*.txt;*.etx"); | 189 | // currentDir.setNameFilter("*.txt;*.etx"); |
189 | QString fileL, fileS, fileDate; | 190 | QString fileL, fileS, fileDate; |
190 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 191 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
191 | QFileInfoListIterator it(*list); | 192 | QFileInfoListIterator it(*list); |
192 | QFileInfo *fi; | 193 | QFileInfo *fi; |
193 | while ( (fi=it.current()) ) { | 194 | while ( (fi=it.current()) ) { |
194 | if (fi->isSymLink() ){ | 195 | if (fi->isSymLink() ){ |
195 | QString symLink=fi->readLink(); | 196 | QString symLink=fi->readLink(); |
196 | // qDebug("Symlink detected "+symLink); | 197 | // qDebug("Symlink detected "+symLink); |
197 | QFileInfo sym( symLink); | 198 | QFileInfo sym( symLink); |
198 | fileS.sprintf( "%10li", sym.size() ); | 199 | fileS.sprintf( "%10li", sym.size() ); |
199 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 200 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
200 | fileDate = sym.lastModified().toString(); | 201 | fileDate = sym.lastModified().toString(); |
201 | } else { | 202 | } else { |
202 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 203 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
203 | fileS.sprintf( "%10li", fi->size() ); | 204 | fileS.sprintf( "%10li", fi->size() ); |
204 | fileL.sprintf( "%s",fi->fileName().data() ); | 205 | fileL.sprintf( "%s",fi->fileName().data() ); |
205 | fileDate= fi->lastModified().toString(); | 206 | fileDate= fi->lastModified().toString(); |
206 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 207 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
207 | fileL+="/"; | 208 | fileL+="/"; |
208 | isDir=TRUE; | 209 | isDir=TRUE; |
209 | // qDebug( fileL); | 210 | // qDebug( fileL); |
210 | } | 211 | } |
211 | } | 212 | } |
212 | if(fileL !="./" && fi->exists()) { | 213 | if(fileL !="./" && fi->exists()) { |
213 | item= new QListViewItem( ListView,fileL,fileS , fileDate); | 214 | item= new QListViewItem( ListView,fileL,fileS , fileDate); |
214 | QPixmap pm; | 215 | QPixmap pm; |
215 | 216 | ||
216 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 217 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
217 | if( !QDir( fi->filePath() ).isReadable()) | 218 | if( !QDir( fi->filePath() ).isReadable()) |
218 | pm = Resource::loadPixmap( "lockedfolder" ); | 219 | pm = Resource::loadPixmap( "lockedfolder" ); |
219 | else | 220 | else |
220 | pm= Resource::loadPixmap( "folder" ); | 221 | pm= Resource::loadPixmap( "folder" ); |
221 | item->setPixmap( 0,pm ); | 222 | item->setPixmap( 0,pm ); |
222 | } else { | 223 | } else { |
223 | if( !fi->isReadable() ) | 224 | if( !fi->isReadable() ) |
224 | pm = Resource::loadPixmap( "locked" ); | 225 | pm = Resource::loadPixmap( "locked" ); |
225 | else { | 226 | else { |
226 | MimeType mt(fi->filePath()); | 227 | MimeType mt(fi->filePath()); |
227 | pm=mt.pixmap();// sets the pixmap for the mimetype | 228 | pm=mt.pixmap();// sets the pixmap for the mimetype |
228 | if(pm.isNull()) | 229 | if(pm.isNull()) |
229 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 230 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
230 | item->setPixmap( 0,pm); | 231 | item->setPixmap( 0,pm); |
231 | } | 232 | } |
232 | } | 233 | } |
233 | if( fileL.find("->",0,TRUE) != -1) { | 234 | if( fileL.find("->",0,TRUE) != -1) { |
234 | // overlay link image | 235 | // overlay link image |
235 | pm= Resource::loadPixmap( "folder" ); | 236 | pm= Resource::loadPixmap( "folder" ); |
236 | QPixmap lnk = Resource::loadPixmap( "symlink" ); | 237 | QPixmap lnk = Resource::loadPixmap( "symlink" ); |
237 | QPainter painter( &pm ); | 238 | QPainter painter( &pm ); |
238 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 239 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
239 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 240 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
240 | item->setPixmap( 0, pm); | 241 | item->setPixmap( 0, pm); |
241 | } | 242 | } |
242 | } | 243 | } |
243 | isDir=FALSE; | 244 | isDir=FALSE; |
244 | ++it; | 245 | ++it; |
245 | // } | 246 | // } |
246 | } | 247 | } |
247 | ListView->setSorting( 3, FALSE); | 248 | ListView->setSorting( 3, FALSE); |
248 | QString currentPath = currentDir.canonicalPath(); | 249 | QString currentPath = currentDir.canonicalPath(); |
249 | 250 | ||
250 | fillCombo( (const QString &)currentPath); | 251 | fillCombo( (const QString &)currentPath); |
251 | // dirPathCombo->lineEdit()->setText(currentPath); | 252 | // dirPathCombo->lineEdit()->setText(currentPath); |
252 | 253 | ||
253 | // if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 254 | // if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
254 | // dirPathCombo->clear(); | 255 | // dirPathCombo->clear(); |
255 | // dirPathStringList.prepend(currentPath ); | 256 | // dirPathStringList.prepend(currentPath ); |
256 | // dirPathCombo->insertStringList( dirPathStringList,-1); | 257 | // dirPathCombo->insertStringList( dirPathStringList,-1); |
257 | // } | 258 | // } |
258 | } | 259 | } |
259 | 260 | ||
260 | void fileBrowser::upDir() | 261 | void fileBrowser::upDir() |
261 | { | 262 | { |
262 | QString current = currentDir.canonicalPath(); | 263 | QString current = currentDir.canonicalPath(); |
263 | QDir dir(current); | 264 | QDir dir(current); |
264 | dir.cdUp(); | 265 | dir.cdUp(); |
265 | current = dir.canonicalPath(); | 266 | current = dir.canonicalPath(); |
266 | chdir( current.latin1() ); | 267 | chdir( current.latin1() ); |
267 | currentDir.cd( current, TRUE); | 268 | currentDir.cd( current, TRUE); |
268 | populateList(); | 269 | populateList(); |
269 | update(); | 270 | update(); |
270 | } | 271 | } |
271 | 272 | ||
272 | // you may want to switch these 2 functions. I like single clicks | 273 | // you may want to switch these 2 functions. I like single clicks |
273 | void fileBrowser::listClicked(QListViewItem *selectedItem) | 274 | void fileBrowser::listClicked(QListViewItem *selectedItem) |
274 | { | 275 | { |
275 | if(selectedItem) { | 276 | if(selectedItem) { |
276 | QString strItem=selectedItem->text(0); | 277 | QString strItem=selectedItem->text(0); |
277 | QString strSize=selectedItem->text(1); | 278 | QString strSize=selectedItem->text(1); |
278 | // qDebug("strItem is "+strItem); | 279 | // qDebug("strItem is "+strItem); |
279 | strSize.stripWhiteSpace(); | 280 | strSize.stripWhiteSpace(); |
280 | // qDebug(strSize); | 281 | // qDebug(strSize); |
281 | 282 | ||
282 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 283 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
283 | // is symlink | 284 | // is symlink |
284 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); | 285 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); |
285 | // qDebug("strItem symlink is "+strItem2); | 286 | // qDebug("strItem symlink is "+strItem2); |
286 | if(QDir(strItem2).exists() ) { | 287 | if(QDir(strItem2).exists() ) { |
287 | currentDir.cd(strItem2, TRUE); | 288 | currentDir.cd(strItem2, TRUE); |
288 | populateList(); | 289 | populateList(); |
289 | } | 290 | } |
290 | } else { // not a symlink | 291 | } else { // not a symlink |
291 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 292 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
292 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 293 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
293 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 294 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
294 | currentDir.cd(strItem,FALSE); | 295 | currentDir.cd(strItem,FALSE); |
295 | // qDebug("Path is "+strItem); | 296 | // qDebug("Path is "+strItem); |
296 | populateList(); | 297 | populateList(); |
297 | } else { | 298 | } else { |
298 | currentDir.cdUp(); | 299 | currentDir.cdUp(); |
299 | populateList(); | 300 | populateList(); |
300 | } | 301 | } |
301 | if(QDir(strItem).exists()){ | 302 | if(QDir(strItem).exists()){ |
302 | currentDir.cd(strItem, TRUE); | 303 | currentDir.cd(strItem, TRUE); |
303 | populateList(); | 304 | populateList(); |
304 | } | 305 | } |
305 | } else { | 306 | } else { |
306 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 307 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
307 | if( QFile::exists(strItem ) ) { | 308 | if( QFile::exists(strItem ) ) { |
308 | //currentDir.canonicalPath() | 309 | //currentDir.canonicalPath() |
309 | qDebug("We found our files!!"+strItem); | 310 | qDebug("We found our files!!"+strItem); |
310 | OnOK(); | 311 | OnOK(); |
311 | } | 312 | } |
312 | } //end not symlink | 313 | } //end not symlink |
313 | chdir(strItem.latin1()); | 314 | chdir(strItem.latin1()); |
314 | } | 315 | } |
315 | } | 316 | } |
316 | } | 317 | } |
317 | 318 | ||
318 | void fileBrowser::OnOK() | 319 | void fileBrowser::OnOK() |
319 | { | 320 | { |
320 | QListViewItemIterator it1( ListView); | 321 | QListViewItemIterator it1( ListView); |
321 | for ( ; it1.current(); ++it1 ) { | 322 | for ( ; it1.current(); ++it1 ) { |
322 | if ( it1.current()->isSelected() ) { | 323 | if ( it1.current()->isSelected() ) { |
323 | selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); | 324 | selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); |
324 | qDebug("selected filename is "+selectedFileName); | 325 | qDebug("selected filename is "+selectedFileName); |
325 | fileList.append( selectedFileName ); | 326 | fileList.append( selectedFileName ); |
326 | } | 327 | } |
327 | } | 328 | } |
328 | accept(); | 329 | accept(); |
329 | } | 330 | } |
330 | 331 | ||
331 | void fileBrowser::homeButtonPushed() { | 332 | void fileBrowser::homeButtonPushed() { |
332 | QString current = QDir::homeDirPath(); | 333 | QString current = QDir::homeDirPath(); |
333 | chdir( current.latin1() ); | 334 | chdir( current.latin1() ); |
334 | currentDir.cd( current, TRUE); | 335 | currentDir.cd( current, TRUE); |
335 | populateList(); | 336 | populateList(); |
336 | update(); | 337 | update(); |
337 | } | 338 | } |
338 | 339 | ||
339 | void fileBrowser::docButtonPushed() { | 340 | void fileBrowser::docButtonPushed() { |
340 | QString current = QPEApplication::documentDir(); | 341 | QString current = QPEApplication::documentDir(); |
341 | chdir( current.latin1() ); | 342 | chdir( current.latin1() ); |
342 | currentDir.cd( current, TRUE); | 343 | currentDir.cd( current, TRUE); |
343 | populateList(); | 344 | populateList(); |
344 | update(); | 345 | update(); |
345 | 346 | ||
346 | } | 347 | } |
347 | 348 | ||
348 | void fileBrowser::selectionChanged( const QString &select ) | 349 | void fileBrowser::selectionChanged( const QString &select ) |
349 | { | 350 | { |
350 | if ( select == "Documents") { | 351 | if ( select == "Documents") { |
351 | FileStack->raiseWidget( fileSelector ); | 352 | FileStack->raiseWidget( fileSelector ); |
352 | dirPathCombo->hide(); | 353 | dirPathCombo->hide(); |
353 | cdUpButton->hide(); | 354 | cdUpButton->hide(); |
354 | docButton->hide(); | 355 | docButton->hide(); |
355 | homeButton->hide(); | 356 | homeButton->hide(); |
356 | } else { | 357 | } else { |
357 | if ( select == "All files" ) | 358 | if ( select == "All files" ) |
358 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All); | 359 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All); |
359 | else | 360 | else |
360 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 361 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
361 | 362 | ||
362 | populateList(); | 363 | populateList(); |
363 | update(); | 364 | update(); |
364 | dirPathCombo->show(); | 365 | dirPathCombo->show(); |
365 | cdUpButton->show(); | 366 | cdUpButton->show(); |
366 | docButton->show(); | 367 | docButton->show(); |
367 | homeButton->show(); | 368 | homeButton->show(); |
368 | FileStack->raiseWidget( ListView ); | 369 | FileStack->raiseWidget( ListView ); |
369 | } | 370 | } |
370 | } | 371 | } |
371 | 372 | ||
372 | void fileBrowser::docOpen( const DocLnk &doc ) | 373 | void fileBrowser::docOpen( const DocLnk &doc ) |
373 | { | 374 | { |
374 | fileList.append( doc.file().latin1() ); | 375 | fileList.append( doc.file().latin1() ); |
375 | accept(); | 376 | accept(); |
376 | } | 377 | } |
377 | 378 | ||
378 | void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 379 | void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
379 | { | 380 | { |
380 | switch (mouse) { | 381 | switch (mouse) { |
381 | case 1: | 382 | case 1: |
382 | break; | 383 | break; |
383 | case 2: | 384 | case 2: |
384 | showListMenu(item); | 385 | showListMenu(item); |
385 | break; | 386 | break; |
386 | }; | 387 | }; |
387 | } | 388 | } |
388 | 389 | ||
389 | void fileBrowser::showListMenu(QListViewItem *item) { | 390 | void fileBrowser::showListMenu(QListViewItem *item) { |
390 | 391 | ||
391 | QPopupMenu m;// = new QPopupMenu( Local_View ); | 392 | QPopupMenu m;// = new QPopupMenu( Local_View ); |
392 | if(item) { | 393 | if(item) { |
393 | if( item->text(0).find("/",0,TRUE)) | 394 | if( item->text(0).find("/",0,TRUE)) |
394 | m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); | 395 | m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); |
395 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); | 396 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); |
396 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); | 397 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); |
397 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 398 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
398 | m.insertSeparator(); | 399 | m.insertSeparator(); |
399 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 400 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
400 | } else { | 401 | } else { |
401 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); | 402 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); |
402 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); | 403 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); |
403 | 404 | ||
404 | } | 405 | } |
405 | m.exec( QCursor::pos() ); | 406 | m.exec( QCursor::pos() ); |
406 | } | 407 | } |
407 | 408 | ||
408 | void fileBrowser::doCd() { | 409 | void fileBrowser::doCd() { |
409 | listClicked( ListView->currentItem()); | 410 | listClicked( ListView->currentItem()); |
410 | } | 411 | } |
411 | 412 | ||
412 | void fileBrowser::makDir() { | 413 | void fileBrowser::makDir() { |
413 | InputDialog *fileDlg; | 414 | InputDialog *fileDlg; |
414 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); | 415 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); |
415 | fileDlg->exec(); | 416 | fileDlg->exec(); |
416 | if( fileDlg->result() == 1 ) { | 417 | if( fileDlg->result() == 1 ) { |
417 | QString filename = fileDlg->LineEdit1->text(); | 418 | QString filename = fileDlg->LineEdit1->text(); |
418 | qDebug("Make dir"); | 419 | qDebug("Make dir"); |
419 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 420 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
420 | } | 421 | } |
421 | populateList(); | 422 | populateList(); |
422 | } | 423 | } |
423 | 424 | ||
424 | void fileBrowser::localRename() { | 425 | void fileBrowser::localRename() { |
425 | QString curFile = ListView->currentItem()->text(0); | 426 | QString curFile = ListView->currentItem()->text(0); |
426 | InputDialog *fileDlg; | 427 | InputDialog *fileDlg; |
427 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); | 428 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); |
428 | fileDlg->setTextEdit((const QString &) curFile); | 429 | fileDlg->setTextEdit((const QString &) curFile); |
429 | fileDlg->exec(); | 430 | fileDlg->exec(); |
430 | if( fileDlg->result() == 1 ) { | 431 | if( fileDlg->result() == 1 ) { |
431 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 432 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
432 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 433 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
433 | if( rename(oldname.latin1(), newName.latin1())== -1) | 434 | if( rename(oldname.latin1(), newName.latin1())== -1) |
434 | QMessageBox::message("Note","Could not rename"); | 435 | QMessageBox::message("Note","Could not rename"); |
435 | } | 436 | } |
436 | populateList(); | 437 | populateList(); |
437 | } | 438 | } |
438 | 439 | ||
439 | void fileBrowser::localDelete() { | 440 | void fileBrowser::localDelete() { |
440 | QString f = ListView->currentItem()->text(0); | 441 | QString f = ListView->currentItem()->text(0); |
441 | if(QDir(f).exists() ) { | 442 | if(QDir(f).exists() ) { |
442 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ | 443 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ |
443 | " ?\nIt must be empty","Yes","No",0,0,1) ) { | 444 | " ?\nIt must be empty","Yes","No",0,0,1) ) { |
444 | case 0: { | 445 | case 0: { |
445 | f=currentDir.canonicalPath()+"/"+f; | 446 | f=currentDir.canonicalPath()+"/"+f; |
446 | QString cmd="rmdir "+f; | 447 | QString cmd="rmdir "+f; |
447 | system( cmd.latin1()); | 448 | system( cmd.latin1()); |
448 | populateList(); | 449 | populateList(); |
449 | } | 450 | } |
450 | break; | 451 | break; |
451 | case 1: | 452 | case 1: |
452 | // exit | 453 | // exit |
453 | break; | 454 | break; |
454 | }; | 455 | }; |
455 | } else { | 456 | } else { |
456 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f | 457 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f |
457 | +" ?","Yes","No",0,0,1) ) { | 458 | +" ?","Yes","No",0,0,1) ) { |
458 | case 0: { | 459 | case 0: { |
459 | f=currentDir.canonicalPath()+"/"+f; | 460 | f=currentDir.canonicalPath()+"/"+f; |
460 | QString cmd="rm "+f; | 461 | QString cmd="rm "+f; |
461 | system( cmd.latin1()); | 462 | system( cmd.latin1()); |
462 | populateList(); | 463 | populateList(); |
463 | } | 464 | } |
464 | break; | 465 | break; |
465 | case 1: | 466 | case 1: |
466 | // exit | 467 | // exit |
467 | break; | 468 | break; |
468 | }; | 469 | }; |
469 | } | 470 | } |
470 | } | 471 | } |
471 | 472 | ||
472 | void fileBrowser::updateMimeTypeMenu() { | 473 | void fileBrowser::updateMimeTypeMenu() { |
473 | 474 | ||
474 | disconnect( typemb, SIGNAL(selected(const QString&)), | 475 | disconnect( typemb, SIGNAL(selected(const QString&)), |
475 | this, SLOT(showType(const QString&)) ); | 476 | this, SLOT(showType(const QString&)) ); |
476 | 477 | ||
477 | QString prev; | 478 | QString prev; |
478 | 479 | ||
479 | // Type filter | 480 | // Type filter |
480 | QStringList types; | 481 | QStringList types; |
481 | types << tr("All"); | 482 | types << tr("All"); |
482 | types << "--"; | 483 | types << "--"; |
483 | types += getMimeTypes(); | 484 | types += getMimeTypes(); |
484 | prev = typemb->currentText(); | 485 | prev = typemb->currentText(); |
485 | typemb->clear(); | 486 | typemb->clear(); |
486 | typemb->insertItems(types); | 487 | typemb->insertItems(types); |
487 | // typemb->select(prev); | 488 | // typemb->select(prev); |
488 | 489 | ||
489 | connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&))); | 490 | connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&))); |
490 | } | 491 | } |
491 | 492 | ||
492 | void fileBrowser::showType(const QString &t) { | 493 | void fileBrowser::showType(const QString &t) { |
493 | 494 | ||
494 | qDebug(t); | 495 | qDebug(t); |
495 | if(t.find("All",0,TRUE) != -1) { | 496 | if(t.find("All",0,TRUE) != -1) { |
496 | filterStr = "*"; | 497 | filterStr = "*"; |
497 | } else { | 498 | } else { |
498 | QStringList list = mimetypes.grep( t,TRUE); | 499 | QStringList list = mimetypes.grep( t,TRUE); |
499 | QString ext; | 500 | QString ext; |
500 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 501 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
501 | mimeType =(*it); | 502 | mimeType =(*it); |
502 | MimeType mt( mimeType); | 503 | MimeType mt( mimeType); |
503 | // qDebug("mime "+mimeType); | 504 | // qDebug("mime "+mimeType); |
504 | // qDebug("description "+mt.description()); | 505 | // qDebug("description "+mt.description()); |
505 | // qDebug( "id "+mt.id()); | 506 | // qDebug( "id "+mt.id()); |
506 | // qDebug("extension "+mt.extension()); | 507 | // qDebug("extension "+mt.extension()); |
507 | // if( mt.extension().isEmpty()) | 508 | // if( mt.extension().isEmpty()) |
508 | filterStr = "*"; | 509 | filterStr = "*"; |
509 | // else | 510 | // else |
510 | // filterStr = "*."+ mt.extension()+" "; | 511 | // filterStr = "*."+ mt.extension()+" "; |
511 | // printf( "%s \n", (*it).latin1() ); | 512 | // printf( "%s \n", (*it).latin1() ); |
512 | } | 513 | } |
513 | } | 514 | } |
514 | currentDir.setNameFilter(filterStr); | 515 | currentDir.setNameFilter(filterStr); |
515 | 516 | ||
516 | populateList(); | 517 | populateList(); |
517 | update(); | 518 | update(); |
518 | // if(fileSelector) { | 519 | // if(fileSelector) { |
519 | // disconnect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); | 520 | // disconnect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); |
520 | // delete fileSelector; | 521 | // delete fileSelector; |
521 | // } | 522 | // } |
522 | // fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy | 523 | // fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy |
523 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); | 524 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); |
524 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 525 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
525 | // connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); | 526 | // connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); |
526 | // fileSelector->reread(); | 527 | // fileSelector->reread(); |
527 | // if ( t == tr("All") ) { | 528 | // if ( t == tr("All") ) { |
528 | // icons->setTypeFilter("",TRUE); | 529 | // icons->setTypeFilter("",TRUE); |
529 | // } else { | 530 | // } else { |
530 | // icons->setTypeFilter(t+"/*",TRUE); | 531 | // icons->setTypeFilter(t+"/*",TRUE); |
531 | // } | 532 | // } |
532 | 533 | ||
533 | } | 534 | } |
534 | 535 | ||
535 | QStringList fileBrowser::getMimeTypes() { | 536 | QStringList fileBrowser::getMimeTypes() { |
536 | 537 | ||
537 | QStringList r; | 538 | QStringList r; |
538 | AppLnkSet apps( QPEApplication::qpeDir() + "apps" ); | 539 | AppLnkSet apps( QPEApplication::qpeDir() + "apps" ); |
539 | QFile file( QPEApplication::qpeDir()+"etc/available.mime"); | 540 | QFile file( QPEApplication::qpeDir()+"etc/available.mime"); |
540 | file.open( IO_WriteOnly|IO_Truncate);//) | 541 | file.open( IO_WriteOnly|IO_Truncate);//) |
541 | for ( QListIterator<AppLnk> it( apps.children() ); it.current(); ++it ) { | 542 | for ( QListIterator<AppLnk> it( apps.children() ); it.current(); ++it ) { |
542 | AppLnk* l; | 543 | AppLnk* l; |
543 | l = it.current(); | 544 | l = it.current(); |
544 | QStringList maj = l->mimeTypes(); | 545 | QStringList maj = l->mimeTypes(); |
545 | QStringList::ConstIterator f; | 546 | QStringList::ConstIterator f; |
546 | for ( f = maj.begin(); f != maj.end(); f++ ) { | 547 | for ( f = maj.begin(); f != maj.end(); f++ ) { |
547 | QString temp = *f; | 548 | QString temp = *f; |
548 | mimetypes << temp; | 549 | mimetypes << temp; |
549 | int sl = temp.find('/'); | 550 | int sl = temp.find('/'); |
550 | if (sl >= 0) { | 551 | if (sl >= 0) { |
551 | QString k = temp.left(sl); | 552 | QString k = temp.left(sl); |
552 | if( r.grep(k,TRUE).isEmpty() ) { | 553 | if( r.grep(k,TRUE).isEmpty() ) { |
553 | r << k; | 554 | r << k; |
554 | k+="\n"; | 555 | k+="\n"; |
555 | file.writeBlock( k.latin1(), k.length()); | 556 | file.writeBlock( k.latin1(), k.length()); |
556 | } | 557 | } |
557 | } | 558 | } |
558 | } | 559 | } |
559 | } | 560 | } |
560 | r.sort(); | 561 | r.sort(); |
561 | file.close(); | 562 | file.close(); |
562 | return r; | 563 | return r; |
563 | } | 564 | } |
564 | 565 | ||
565 | void fileBrowser::receive( const QCString &msg, const QByteArray &data ) { | 566 | void fileBrowser::receive( const QCString &msg, const QByteArray &data ) { |
566 | // QDataStream stream( data, IO_ReadOnly ); | 567 | // QDataStream stream( data, IO_ReadOnly ); |
567 | // if (msg == "keyRegister(int key, QString channel, QString message)") | 568 | // if (msg == "keyRegister(int key, QString channel, QString message)") |
568 | // { | 569 | // { |
569 | // int k; | 570 | // int k; |
570 | // QString c, m; | 571 | // QString c, m; |
571 | // stream >> k; | 572 | // stream >> k; |
572 | // stream >> c; | 573 | // stream >> c; |
573 | // stream >> m; | 574 | // stream >> m; |
574 | } | 575 | } |