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