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