author | llornkcor <llornkcor> | 2002-03-18 01:43:17 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-18 01:43:17 (UTC) |
commit | d9290bfa0b37c3026dbe0ffbd88663379df44fa2 (patch) (unidiff) | |
tree | 45d17ef84edc8543cdfe1f7b659c76fd36a54311 | |
parent | 4c0bbc662731b8d3e61f43735fd6131746da306f (diff) | |
download | opie-d9290bfa0b37c3026dbe0ffbd88663379df44fa2.zip opie-d9290bfa0b37c3026dbe0ffbd88663379df44fa2.tar.gz opie-d9290bfa0b37c3026dbe0ffbd88663379df44fa2.tar.bz2 |
added a popupmenu to filedialog
-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 106 | ||||
-rw-r--r-- | core/apps/textedit/fileBrowser.h | 8 | ||||
-rw-r--r-- | core/apps/textedit/textedit.pro | 6 |
3 files changed, 113 insertions, 7 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp index 8cb7c38..1fdf9d9 100644 --- a/core/apps/textedit/fileBrowser.cpp +++ b/core/apps/textedit/fileBrowser.cpp | |||
@@ -1,274 +1,376 @@ | |||
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" | ||
16 | |||
15 | #include <qpe/config.h> | 17 | #include <qpe/config.h> |
16 | #include <qpe/resource.h> | 18 | #include <qpe/resource.h> |
17 | #include <qpe/fileselector.h> | 19 | #include <qpe/fileselector.h> |
18 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
19 | 21 | ||
20 | #include <qwidgetstack.h> | 22 | #include <qwidgetstack.h> |
21 | #include <qlistview.h> | 23 | #include <qlistview.h> |
22 | #include <qcombo.h> | 24 | #include <qcombo.h> |
23 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
24 | #include <qfile.h> | 26 | #include <qfile.h> |
25 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
26 | #include <qlayout.h> | 28 | #include <qlayout.h> |
27 | #include <unistd.h> | 29 | #include <unistd.h> |
30 | #include <qpopupmenu.h> | ||
31 | #include <qlineedit.h> | ||
32 | |||
33 | #include <unistd.h> | ||
34 | #include <stdlib.h> | ||
28 | 35 | ||
29 | static int u_id = 1; | 36 | static int u_id = 1; |
30 | static int get_unique_id() | 37 | static int get_unique_id() |
31 | { | 38 | { |
32 | return u_id++; | 39 | return u_id++; |
33 | } | 40 | } |
34 | 41 | ||
35 | fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter ) | 42 | fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter ) |
36 | : QDialog( parent, name, modal, fl ) | 43 | : QDialog( parent, name, modal, fl ) |
37 | { | 44 | { |
38 | if ( !name ) | 45 | if ( !name ) |
39 | setName( "fileBrowser" ); | 46 | setName( "fileBrowser" ); |
40 | setCaption(tr( name ) ); | 47 | setCaption(tr( name ) ); |
41 | filterStr=filter; | 48 | filterStr=filter; |
42 | 49 | ||
43 | QGridLayout *layout = new QGridLayout( this ); | 50 | QGridLayout *layout = new QGridLayout( this ); |
44 | layout->setSpacing( 4 ); | 51 | layout->setSpacing( 4 ); |
45 | layout->setMargin( 4 ); | 52 | layout->setMargin( 4 ); |
46 | 53 | ||
47 | 54 | ||
48 | dirLabel = new QLabel(this, "DirLabel"); | 55 | dirLabel = new QLabel(this, "DirLabel"); |
49 | dirLabel->setText(currentDir.canonicalPath()); | 56 | dirLabel->setText(currentDir.canonicalPath()); |
50 | dirLabel->setMinimumSize( QSize( 50, 15 ) ); | 57 | dirLabel->setMinimumSize( QSize( 50, 15 ) ); |
51 | dirLabel->setMaximumSize( QSize( 250, 15 ) ); | 58 | dirLabel->setMaximumSize( QSize( 250, 15 ) ); |
52 | layout->addWidget( dirLabel, 0, 0 ); | 59 | layout->addWidget( dirLabel, 0, 0 ); |
53 | 60 | ||
54 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); | 61 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); |
55 | docButton->setMinimumSize( QSize( 25, 25 ) ); | 62 | docButton->setMinimumSize( QSize( 25, 25 ) ); |
56 | docButton->setMaximumSize( QSize( 25, 25 ) ); | 63 | docButton->setMaximumSize( QSize( 25, 25 ) ); |
57 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 64 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
58 | docButton->setFlat(TRUE); | 65 | docButton->setFlat(TRUE); |
59 | layout->addWidget( docButton, 0, 1 ); | 66 | layout->addWidget( docButton, 0, 1 ); |
60 | 67 | ||
61 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); | 68 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); |
62 | homeButton->setMinimumSize( QSize( 25, 25 ) ); | 69 | homeButton->setMinimumSize( QSize( 25, 25 ) ); |
63 | homeButton->setMaximumSize( QSize( 25, 25 ) ); | 70 | homeButton->setMaximumSize( QSize( 25, 25 ) ); |
64 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 71 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
65 | homeButton->setFlat(TRUE); | 72 | homeButton->setFlat(TRUE); |
66 | layout->addWidget( homeButton, 0, 2 ); | 73 | layout->addWidget( homeButton, 0, 2 ); |
67 | 74 | ||
68 | FileStack = new QWidgetStack( this ); | 75 | FileStack = new QWidgetStack( this ); |
69 | 76 | ||
70 | ListView = new QListView( this, "ListView" ); | 77 | ListView = new QListView( this, "ListView" ); |
71 | ListView->setMinimumSize( QSize( 100, 25 ) ); | 78 | ListView->setMinimumSize( QSize( 100, 25 ) ); |
72 | ListView->addColumn( tr( "Name" ) ); | 79 | ListView->addColumn( tr( "Name" ) ); |
73 | ListView->setColumnWidth(0,120); | 80 | ListView->setColumnWidth(0,120); |
74 | ListView->setSorting( 2, FALSE); | 81 | ListView->setSorting( 2, FALSE); |
75 | ListView->addColumn( tr( "Size" ) ); | 82 | ListView->addColumn( tr( "Size" ) ); |
76 | ListView->setColumnWidth(1,-1); | 83 | ListView->setColumnWidth(1,-1); |
77 | ListView->addColumn( "Date",-1); | 84 | ListView->addColumn( "Date",-1); |
78 | // ListView->addColumn( tr( "" ) ); | 85 | // ListView->addColumn( tr( "" ) ); |
79 | ListView->setColumnWidthMode(0,QListView::Manual); | 86 | ListView->setColumnWidthMode(0,QListView::Manual); |
80 | ListView->setColumnAlignment(1,QListView::AlignRight); | 87 | ListView->setColumnAlignment(1,QListView::AlignRight); |
81 | ListView->setColumnAlignment(2,QListView::AlignRight); | 88 | ListView->setColumnAlignment(2,QListView::AlignRight); |
82 | ListView->setAllColumnsShowFocus( TRUE ); | 89 | ListView->setAllColumnsShowFocus( TRUE ); |
83 | 90 | ||
84 | connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 91 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); |
92 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | ||
93 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | ||
94 | |||
95 | connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | ||
96 | |||
85 | FileStack->addWidget( ListView, get_unique_id() ); | 97 | FileStack->addWidget( ListView, get_unique_id() ); |
86 | 98 | ||
87 | fileSelector = new FileSelector( "text/*", FileStack, "fileselector" , FALSE, FALSE); //buggy | 99 | fileSelector = new FileSelector( "text/*", FileStack, "fileselector" , FALSE, FALSE); //buggy |
88 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); | 100 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); |
89 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 101 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
90 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); | 102 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); |
91 | layout->addMultiCellWidget( FileStack, 1, 1, 0, 2 ); | 103 | layout->addMultiCellWidget( FileStack, 1, 1, 0, 2 ); |
92 | 104 | ||
93 | SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" ); | 105 | SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" ); |
94 | SelectionCombo->setMinimumSize( QSize( 200, 25 ) ); | 106 | SelectionCombo->setMinimumSize( QSize( 200, 25 ) ); |
95 | SelectionCombo->insertItem( tr( "Documents" ) ); | 107 | SelectionCombo->insertItem( tr( "Documents" ) ); |
96 | SelectionCombo->insertItem( tr( "All files" ) ); | 108 | SelectionCombo->insertItem( tr( "All files" ) ); |
97 | SelectionCombo->insertItem( tr( "All files (incl. hidden)" ) ); | 109 | SelectionCombo->insertItem( tr( "All files (incl. hidden)" ) ); |
98 | layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 2 ); | 110 | layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 2 ); |
99 | connect( SelectionCombo, SIGNAL( activated( const QString & ) ), | 111 | connect( SelectionCombo, SIGNAL( activated( const QString & ) ), |
100 | this, SLOT( selectionChanged( const QString & ) ) ); | 112 | this, SLOT( selectionChanged( const QString & ) ) ); |
101 | 113 | ||
102 | currentDir.setPath(QDir::currentDirPath()); | 114 | currentDir.setPath(QDir::currentDirPath()); |
103 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); | 115 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); |
104 | 116 | ||
105 | populateList(); | 117 | populateList(); |
106 | move(0,15); | 118 | move(0,15); |
107 | } | 119 | } |
108 | 120 | ||
109 | fileBrowser::~fileBrowser() | 121 | fileBrowser::~fileBrowser() |
110 | { | 122 | { |
111 | } | 123 | } |
112 | 124 | ||
113 | void fileBrowser::setFileView( int selection ) | 125 | void fileBrowser::setFileView( int selection ) |
114 | { | 126 | { |
115 | SelectionCombo->setCurrentItem( selection ); | 127 | SelectionCombo->setCurrentItem( selection ); |
116 | selectionChanged( SelectionCombo->currentText() ); | 128 | selectionChanged( SelectionCombo->currentText() ); |
117 | } | 129 | } |
118 | 130 | ||
119 | void fileBrowser::populateList() | 131 | void fileBrowser::populateList() |
120 | { | 132 | { |
121 | ListView->clear(); | 133 | ListView->clear(); |
122 | bool isDir=FALSE; | 134 | bool isDir=FALSE; |
123 | //qDebug(currentDir.canonicalPath()); | 135 | //qDebug(currentDir.canonicalPath()); |
124 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 136 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
125 | currentDir.setMatchAllDirs(TRUE); | 137 | currentDir.setMatchAllDirs(TRUE); |
126 | 138 | ||
127 | currentDir.setNameFilter(filterStr); | 139 | currentDir.setNameFilter(filterStr); |
128 | // currentDir.setNameFilter("*.txt;*.etx"); | 140 | // currentDir.setNameFilter("*.txt;*.etx"); |
129 | QString fileL, fileS, fileDate; | 141 | QString fileL, fileS, fileDate; |
130 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 142 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
131 | QFileInfoListIterator it(*list); | 143 | QFileInfoListIterator it(*list); |
132 | QFileInfo *fi; | 144 | QFileInfo *fi; |
133 | while ( (fi=it.current()) ) { | 145 | while ( (fi=it.current()) ) { |
134 | 146 | ||
135 | if (fi->isSymLink() ){ | 147 | if (fi->isSymLink() ){ |
136 | QString symLink=fi->readLink(); | 148 | QString symLink=fi->readLink(); |
137 | // qDebug("Symlink detected "+symLink); | 149 | // qDebug("Symlink detected "+symLink); |
138 | QFileInfo sym( symLink); | 150 | QFileInfo sym( symLink); |
139 | fileS.sprintf( "%10li", sym.size() ); | 151 | fileS.sprintf( "%10li", sym.size() ); |
140 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 152 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
141 | fileDate = sym.lastModified().toString(); | 153 | fileDate = sym.lastModified().toString(); |
142 | } else { | 154 | } else { |
143 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 155 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
144 | fileS.sprintf( "%10li", fi->size() ); | 156 | fileS.sprintf( "%10li", fi->size() ); |
145 | fileL.sprintf( "%s",fi->fileName().data() ); | 157 | fileL.sprintf( "%s",fi->fileName().data() ); |
146 | fileDate= fi->lastModified().toString(); | 158 | fileDate= fi->lastModified().toString(); |
147 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 159 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
148 | fileL+="/"; | 160 | fileL+="/"; |
149 | isDir=TRUE; | 161 | isDir=TRUE; |
150 | // qDebug( fileL); | 162 | // qDebug( fileL); |
151 | } | 163 | } |
152 | } | 164 | } |
153 | if(fileL !="./") { | 165 | if(fileL !="./") { |
154 | item= new QListViewItem( ListView,fileL,fileS , fileDate); | 166 | item= new QListViewItem( ListView,fileL,fileS , fileDate); |
155 | if(isDir || fileL.find("/",0,TRUE) != -1) | 167 | if(isDir || fileL.find("/",0,TRUE) != -1) |
156 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); | 168 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); |
157 | else | 169 | else |
158 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | 170 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); |
159 | } | 171 | } |
160 | isDir=FALSE; | 172 | isDir=FALSE; |
161 | ++it; | 173 | ++it; |
162 | } | 174 | } |
163 | // ListView->setSorting( 2, FALSE); | 175 | // ListView->setSorting( 2, FALSE); |
164 | ListView->setSorting( 3, FALSE); | 176 | ListView->setSorting( 3, FALSE); |
165 | dirLabel->setText(currentDir.canonicalPath()); | 177 | dirLabel->setText(currentDir.canonicalPath()); |
166 | } | 178 | } |
167 | 179 | ||
168 | void fileBrowser::upDir() | 180 | void fileBrowser::upDir() |
169 | { | 181 | { |
170 | // qDebug(currentDir.canonicalPath()); | 182 | // qDebug(currentDir.canonicalPath()); |
171 | } | 183 | } |
172 | 184 | ||
173 | // you may want to switch these 2 functions. I like single clicks | 185 | // you may want to switch these 2 functions. I like single clicks |
174 | void fileBrowser::listClicked(QListViewItem *selectedItem) | 186 | void fileBrowser::listClicked(QListViewItem *selectedItem) |
175 | { | 187 | { |
176 | QString strItem=selectedItem->text(0); | 188 | QString strItem=selectedItem->text(0); |
177 | QString strSize=selectedItem->text(1); | 189 | QString strSize=selectedItem->text(1); |
178 | // qDebug("strItem is "+strItem); | 190 | // qDebug("strItem is "+strItem); |
179 | strSize.stripWhiteSpace(); | 191 | strSize.stripWhiteSpace(); |
180 | // qDebug(strSize); | 192 | // qDebug(strSize); |
181 | 193 | ||
182 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 194 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
183 | // is symlink | 195 | // is symlink |
184 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); | 196 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); |
185 | // qDebug("strItem symlink is "+strItem2); | 197 | // qDebug("strItem symlink is "+strItem2); |
186 | if(QDir(strItem2).exists() ) { | 198 | if(QDir(strItem2).exists() ) { |
187 | currentDir.cd(strItem2, TRUE); | 199 | currentDir.cd(strItem2, TRUE); |
188 | populateList(); | 200 | populateList(); |
189 | } | 201 | } |
190 | } else { // not a symlink | 202 | } else { // not a symlink |
191 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 203 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
192 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 204 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
193 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 205 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
194 | currentDir.cd(strItem,FALSE); | 206 | currentDir.cd(strItem,FALSE); |
195 | // qDebug("Path is "+strItem); | 207 | // qDebug("Path is "+strItem); |
196 | populateList(); | 208 | populateList(); |
197 | } else { | 209 | } else { |
198 | currentDir.cdUp(); | 210 | currentDir.cdUp(); |
199 | populateList(); | 211 | populateList(); |
200 | } | 212 | } |
201 | if(QDir(strItem).exists()){ | 213 | if(QDir(strItem).exists()){ |
202 | currentDir.cd(strItem, TRUE); | 214 | currentDir.cd(strItem, TRUE); |
203 | populateList(); | 215 | populateList(); |
204 | } | 216 | } |
205 | } else { | 217 | } else { |
206 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 218 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
207 | if( QFile::exists(strItem ) ) { | 219 | if( QFile::exists(strItem ) ) { |
208 | //currentDir.canonicalPath() | 220 | //currentDir.canonicalPath() |
209 | qDebug("We found our files!!"+strItem); | 221 | qDebug("We found our files!!"+strItem); |
210 | OnOK(); | 222 | OnOK(); |
211 | } | 223 | } |
212 | } //end not symlink | 224 | } //end not symlink |
213 | chdir(strItem.latin1()); | 225 | chdir(strItem.latin1()); |
214 | } | 226 | } |
215 | } | 227 | } |
216 | 228 | ||
217 | void fileBrowser::OnOK() | 229 | void fileBrowser::OnOK() |
218 | { | 230 | { |
219 | QListViewItemIterator it1( ListView); | 231 | QListViewItemIterator it1( ListView); |
220 | for ( ; it1.current(); ++it1 ) { | 232 | for ( ; it1.current(); ++it1 ) { |
221 | if ( it1.current()->isSelected() ) { | 233 | if ( it1.current()->isSelected() ) { |
222 | selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); | 234 | selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); |
223 | qDebug("selected filename is "+selectedFileName); | 235 | qDebug("selected filename is "+selectedFileName); |
224 | fileList.append( selectedFileName ); | 236 | fileList.append( selectedFileName ); |
225 | } | 237 | } |
226 | } | 238 | } |
227 | accept(); | 239 | accept(); |
228 | } | 240 | } |
229 | 241 | ||
230 | void fileBrowser::homeButtonPushed() { | 242 | void fileBrowser::homeButtonPushed() { |
231 | chdir( QDir::homeDirPath().latin1() ); | 243 | chdir( QDir::homeDirPath().latin1() ); |
232 | currentDir.cd( QDir::homeDirPath(), TRUE); | 244 | currentDir.cd( QDir::homeDirPath(), TRUE); |
233 | populateList(); | 245 | populateList(); |
234 | update(); | 246 | update(); |
235 | } | 247 | } |
236 | 248 | ||
237 | void fileBrowser::docButtonPushed() { | 249 | void fileBrowser::docButtonPushed() { |
238 | chdir( QString(QPEApplication::documentDir()+"/text").latin1() ); | 250 | chdir( QString(QPEApplication::documentDir()+"/text").latin1() ); |
239 | currentDir.cd( QPEApplication::documentDir()+"/text", TRUE); | 251 | currentDir.cd( QPEApplication::documentDir()+"/text", TRUE); |
240 | populateList(); | 252 | populateList(); |
241 | update(); | 253 | update(); |
242 | 254 | ||
243 | } | 255 | } |
244 | 256 | ||
245 | void fileBrowser::selectionChanged( const QString &select ) | 257 | void fileBrowser::selectionChanged( const QString &select ) |
246 | { | 258 | { |
247 | if ( select == "Documents") | 259 | if ( select == "Documents") |
248 | { | 260 | { |
249 | FileStack->raiseWidget( fileSelector ); | 261 | FileStack->raiseWidget( fileSelector ); |
250 | dirLabel->hide(); | 262 | dirLabel->hide(); |
251 | docButton->hide(); | 263 | docButton->hide(); |
252 | homeButton->hide(); | 264 | homeButton->hide(); |
253 | } | 265 | } |
254 | else | 266 | else |
255 | { | 267 | { |
256 | if ( select == "All files" ) | 268 | if ( select == "All files" ) |
257 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All); | 269 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All); |
258 | else | 270 | else |
259 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 271 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
260 | 272 | ||
261 | populateList(); | 273 | populateList(); |
262 | update(); | 274 | update(); |
263 | dirLabel->show(); | 275 | dirLabel->show(); |
264 | docButton->show(); | 276 | docButton->show(); |
265 | homeButton->show(); | 277 | homeButton->show(); |
266 | FileStack->raiseWidget( ListView ); | 278 | FileStack->raiseWidget( ListView ); |
267 | } | 279 | } |
268 | } | 280 | } |
269 | 281 | ||
270 | void fileBrowser::docOpen( const DocLnk &doc ) | 282 | void fileBrowser::docOpen( const DocLnk &doc ) |
271 | { | 283 | { |
272 | fileList.append( doc.file().latin1() ); | 284 | fileList.append( doc.file().latin1() ); |
273 | accept(); | 285 | accept(); |
274 | } | 286 | } |
287 | |||
288 | void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | ||
289 | { | ||
290 | switch (mouse) { | ||
291 | case 1: | ||
292 | break; | ||
293 | case 2: | ||
294 | showListMenu(item); | ||
295 | break; | ||
296 | }; | ||
297 | } | ||
298 | |||
299 | void fileBrowser::showListMenu(QListViewItem *item) { | ||
300 | |||
301 | QPopupMenu m;// = new QPopupMenu( Local_View ); | ||
302 | if( item->text(0).find("/",0,TRUE)) | ||
303 | m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); | ||
304 | else | ||
305 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); | ||
306 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | ||
307 | m.insertSeparator(); | ||
308 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | ||
309 | m.exec( QCursor::pos() ); | ||
310 | |||
311 | } | ||
312 | |||
313 | void fileBrowser::doCd() { | ||
314 | listClicked( ListView->currentItem()); | ||
315 | } | ||
316 | |||
317 | void fileBrowser::makDir() { | ||
318 | InputDialog *fileDlg; | ||
319 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); | ||
320 | fileDlg->exec(); | ||
321 | if( fileDlg->result() == 1 ) { | ||
322 | QString filename = fileDlg->LineEdit1->text(); | ||
323 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | ||
324 | } | ||
325 | populateList(); | ||
326 | } | ||
327 | |||
328 | void fileBrowser::localRename() { | ||
329 | QString curFile = ListView->currentItem()->text(0); | ||
330 | InputDialog *fileDlg; | ||
331 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); | ||
332 | fileDlg->inputText = curFile; | ||
333 | fileDlg->exec(); | ||
334 | if( fileDlg->result() == 1 ) { | ||
335 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | ||
336 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | ||
337 | if( rename(oldname.latin1(), newName.latin1())== -1) | ||
338 | QMessageBox::message("Note","Could not rename"); | ||
339 | } | ||
340 | populateList(); | ||
341 | } | ||
342 | |||
343 | void fileBrowser::localDelete() { | ||
344 | QString f = ListView->currentItem()->text(0); | ||
345 | if(QDir(f).exists() ) { | ||
346 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ | ||
347 | " ?\nIt must be empty","Yes","No",0,0,1) ) { | ||
348 | case 0: { | ||
349 | f=currentDir.canonicalPath()+"/"+f; | ||
350 | QString cmd="rmdir "+f; | ||
351 | system( cmd.latin1()); | ||
352 | populateList(); | ||
353 | } | ||
354 | break; | ||
355 | case 1: | ||
356 | // exit | ||
357 | break; | ||
358 | }; | ||
359 | |||
360 | } else { | ||
361 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f | ||
362 | +" ?","Yes","No",0,0,1) ) { | ||
363 | case 0: { | ||
364 | f=currentDir.canonicalPath()+"/"+f; | ||
365 | QString cmd="rm "+f; | ||
366 | system( cmd.latin1()); | ||
367 | populateList(); | ||
368 | } | ||
369 | break; | ||
370 | case 1: | ||
371 | // exit | ||
372 | break; | ||
373 | }; | ||
374 | } | ||
375 | |||
376 | } | ||
diff --git a/core/apps/textedit/fileBrowser.h b/core/apps/textedit/fileBrowser.h index d8f0d0d..4f765dd 100644 --- a/core/apps/textedit/fileBrowser.h +++ b/core/apps/textedit/fileBrowser.h | |||
@@ -1,81 +1,87 @@ | |||
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 | 25 | ||
26 | #include <qpe/filemanager.h> | 26 | #include <qpe/filemanager.h> |
27 | 27 | ||
28 | class QVBoxLayout; | 28 | class QVBoxLayout; |
29 | class QHBoxLayout; | 29 | class QHBoxLayout; |
30 | class QGridLayout; | 30 | class QGridLayout; |
31 | class QListView; | 31 | class QListView; |
32 | class QListViewItem; | 32 | class QListViewItem; |
33 | class QPushButton; | 33 | class QPushButton; |
34 | class QComboBox; | 34 | class QComboBox; |
35 | class QWidgetStack; | 35 | class QWidgetStack; |
36 | class FileSelector; | 36 | class FileSelector; |
37 | class QPoint; | ||
37 | 38 | ||
38 | class fileBrowser : public QDialog | 39 | class fileBrowser : public QDialog |
39 | { | 40 | { |
40 | Q_OBJECT | 41 | Q_OBJECT |
41 | 42 | ||
42 | public: | 43 | public: |
43 | void populateList(); | 44 | void populateList(); |
44 | fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0); | 45 | fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0); |
45 | ~fileBrowser(); | 46 | ~fileBrowser(); |
46 | 47 | ||
47 | void setFileView( int ); | 48 | void setFileView( int ); |
48 | 49 | ||
49 | QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton; | 50 | QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton; |
50 | QListView* ListView; | 51 | QListView* ListView; |
51 | 52 | ||
52 | QLabel *dirLabel; | 53 | QLabel *dirLabel; |
53 | QString selectedFileName, filterStr; | 54 | QString selectedFileName, filterStr; |
54 | QDir currentDir; | 55 | QDir currentDir; |
55 | QFile file; | 56 | QFile file; |
56 | QStringList fileList; | 57 | QStringList fileList; |
57 | QListViewItem * item; | 58 | QListViewItem * item; |
58 | QComboBox *SelectionCombo; | 59 | QComboBox *SelectionCombo; |
59 | QWidgetStack *FileStack; | 60 | QWidgetStack *FileStack; |
60 | FileSelector *fileSelector; | 61 | FileSelector *fileSelector; |
61 | 62 | ||
62 | public slots: | 63 | public slots: |
63 | void homeButtonPushed(); | 64 | void homeButtonPushed(); |
64 | void docButtonPushed(); | 65 | void docButtonPushed(); |
65 | 66 | void ListPressed( int, QListViewItem *, const QPoint&, int); | |
67 | void showListMenu(QListViewItem*); | ||
68 | void doCd(); | ||
69 | void makDir(); | ||
70 | void localRename(); | ||
71 | void localDelete(); | ||
66 | private: | 72 | private: |
67 | 73 | ||
68 | private slots: | 74 | private slots: |
69 | void upDir(); | 75 | void upDir(); |
70 | void listClicked( QListViewItem * ); | 76 | void listClicked( QListViewItem * ); |
71 | void selectionChanged( const QString & ); | 77 | void selectionChanged( const QString & ); |
72 | void OnOK(); | 78 | void OnOK(); |
73 | void docOpen( const DocLnk & ); | 79 | void docOpen( const DocLnk & ); |
74 | 80 | ||
75 | protected slots: | 81 | protected slots: |
76 | 82 | ||
77 | protected: | 83 | protected: |
78 | 84 | ||
79 | }; | 85 | }; |
80 | 86 | ||
81 | #endif // FILEBROWSER_H | 87 | #endif // FILEBROWSER_H |
diff --git a/core/apps/textedit/textedit.pro b/core/apps/textedit/textedit.pro index 2c25d43..f019bf7 100644 --- a/core/apps/textedit/textedit.pro +++ b/core/apps/textedit/textedit.pro | |||
@@ -1,16 +1,14 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | 3 | ||
4 | DESTDIR = $(OPIEDIR)/bin | 4 | DESTDIR = $(OPIEDIR)/bin |
5 | 5 | HEADERS = textedit.h fileBrowser.h fontDialog.h fileSaver.h filePermissions.h inputDialog.h | |
6 | HEADERS = textedit.h fileBrowser.h fontDialog.h fileSaver.h filePermissions.h | 6 | SOURCES = main.cpp textedit.cpp fileBrowser.cpp fontDialog.cpp fileSaver.cpp filePermissions.cpp inputDialog.cpp |
7 | |||
8 | SOURCES = main.cpp textedit.cpp fileBrowser.cpp fontDialog.cpp fileSaver.cpp filePermissions.cpp | ||
9 | 7 | ||
10 | INCLUDEPATH += $(OPIEDIR)/include | 8 | INCLUDEPATH += $(OPIEDIR)/include |
11 | DEPENDPATH += $(OPIEDIR)/include | 9 | DEPENDPATH += $(OPIEDIR)/include |
12 | LIBS += -lqpe | 10 | LIBS += -lqpe |
13 | 11 | ||
14 | TARGET = textedit | 12 | TARGET = textedit |
15 | 13 | ||
16 | TRANSLATIONS = ../i18n/de/textedit.ts | 14 | TRANSLATIONS = ../i18n/de/textedit.ts |