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