author | llornkcor <llornkcor> | 2002-03-24 14:17:21 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-24 14:17:21 (UTC) |
commit | 927d5f33cc4c36541d7fb7dde036bdd22f5d7253 (patch) (unidiff) | |
tree | cd846d8b462131c8c06c2ddf5787171449b8521e | |
parent | 807ea39f3ccfbc26e769fc16a79d459327e13437 (diff) | |
download | opie-927d5f33cc4c36541d7fb7dde036bdd22f5d7253.zip opie-927d5f33cc4c36541d7fb7dde036bdd22f5d7253.tar.gz opie-927d5f33cc4c36541d7fb7dde036bdd22f5d7253.tar.bz2 |
changed things in filebrowser
-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 237 | ||||
-rw-r--r-- | core/apps/textedit/fileBrowser.h | 30 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 4 |
3 files changed, 220 insertions, 51 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp index 1fdf9d9..c9366e7 100644 --- a/core/apps/textedit/fileBrowser.cpp +++ b/core/apps/textedit/fileBrowser.cpp | |||
@@ -1,376 +1,531 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** copyright 2001 ljp ljp@llornkcor.com | 2 | ** copyright 2001 ljp ljp@llornkcor.com |
3 | ** Created: Fri Dec 14 08:16:46 2001 | 3 | ** Created: Fri Dec 14 08:16:46 2001 |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ****************************************************************************/ | 13 | ****************************************************************************/ |
14 | #include "fileBrowser.h" | 14 | #include "fileBrowser.h" |
15 | #include "inputDialog.h" | 15 | #include "inputDialog.h" |
16 | 16 | ||
17 | #include <qpe/config.h> | 17 | #include <qpe/config.h> |
18 | #include <qpe/resource.h> | 18 | #include <qpe/resource.h> |
19 | #include <qpe/fileselector.h> | 19 | #include <qpe/fileselector.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/menubutton.h> | ||
21 | 22 | ||
23 | #include <qdict.h> | ||
22 | #include <qwidgetstack.h> | 24 | #include <qwidgetstack.h> |
23 | #include <qlistview.h> | 25 | #include <qlistview.h> |
24 | #include <qcombo.h> | 26 | #include <qcombo.h> |
25 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
26 | #include <qfile.h> | 28 | #include <qfile.h> |
27 | #include <qmessagebox.h> | 29 | #include <qmessagebox.h> |
28 | #include <qlayout.h> | 30 | #include <qlayout.h> |
29 | #include <unistd.h> | 31 | #include <unistd.h> |
30 | #include <qpopupmenu.h> | 32 | #include <qpopupmenu.h> |
31 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
34 | #include <qstringlist.h> | ||
32 | 35 | ||
33 | #include <unistd.h> | 36 | #include <unistd.h> |
34 | #include <stdlib.h> | 37 | #include <stdlib.h> |
35 | 38 | ||
36 | static int u_id = 1; | 39 | static int u_id = 1; |
37 | static int get_unique_id() | 40 | static int get_unique_id() |
38 | { | 41 | { |
39 | return u_id++; | 42 | return u_id++; |
40 | } | 43 | } |
41 | 44 | ||
42 | fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter ) | 45 | fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter ) |
43 | : QDialog( parent, name, modal, fl ) | 46 | : QDialog( parent, name, modal, fl ) |
44 | { | 47 | { |
45 | if ( !name ) | 48 | if ( !name ) |
46 | setName( "fileBrowser" ); | 49 | setName( "fileBrowser" ); |
47 | setCaption(tr( name ) ); | 50 | setCaption(tr( name ) ); |
48 | filterStr=filter; | 51 | filterStr=filter; |
49 | 52 | ||
53 | // channel = new QCopChannel( "QPE/fileDialog", this ); | ||
54 | // connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | ||
55 | // this, SLOT(receive(const QCString&, const QByteArray&)) ); | ||
56 | |||
50 | QGridLayout *layout = new QGridLayout( this ); | 57 | QGridLayout *layout = new QGridLayout( this ); |
51 | layout->setSpacing( 4 ); | 58 | layout->setSpacing( 4 ); |
52 | layout->setMargin( 4 ); | 59 | layout->setMargin( 4 ); |
53 | 60 | ||
61 | dirPathCombo = new QComboBox( FALSE, this, "dorPathCombo" ); | ||
62 | dirPathCombo->setEditable(TRUE); | ||
63 | |||
64 | connect( dirPathCombo, SIGNAL( activated( const QString & ) ), | ||
65 | this, SLOT( dirPathComboActivated( const QString & ) ) ); | ||
66 | |||
67 | connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ), | ||
68 | this, SLOT( dirPathEditPressed( ) ) ); | ||
69 | |||
70 | dirPathStringList << "/"; | ||
71 | // we can get the storage here | ||
72 | |||
73 | layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 ); | ||
74 | |||
75 | cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); | ||
76 | cdUpButton ->setMinimumSize( QSize( 20, 20 ) ); | ||
77 | cdUpButton ->setMaximumSize( QSize( 20, 20 ) ); | ||
78 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); | ||
79 | cdUpButton ->setFlat(TRUE); | ||
80 | layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 ); | ||
54 | 81 | ||
55 | dirLabel = new QLabel(this, "DirLabel"); | ||
56 | dirLabel->setText(currentDir.canonicalPath()); | ||
57 | dirLabel->setMinimumSize( QSize( 50, 15 ) ); | ||
58 | dirLabel->setMaximumSize( QSize( 250, 15 ) ); | ||
59 | layout->addWidget( dirLabel, 0, 0 ); | ||
60 | 82 | ||
61 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); | 83 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); |
62 | docButton->setMinimumSize( QSize( 25, 25 ) ); | 84 | docButton->setMinimumSize( QSize( 20, 20 ) ); |
63 | docButton->setMaximumSize( QSize( 25, 25 ) ); | 85 | docButton->setMaximumSize( QSize( 20, 20 ) ); |
64 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 86 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
65 | docButton->setFlat(TRUE); | 87 | docButton->setFlat(TRUE); |
66 | layout->addWidget( docButton, 0, 1 ); | 88 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); |
67 | 89 | ||
68 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); | 90 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); |
69 | homeButton->setMinimumSize( QSize( 25, 25 ) ); | 91 | homeButton->setMinimumSize( QSize( 20, 20 ) ); |
70 | homeButton->setMaximumSize( QSize( 25, 25 ) ); | 92 | homeButton->setMaximumSize( QSize( 20, 20 ) ); |
71 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 93 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
72 | homeButton->setFlat(TRUE); | 94 | homeButton->setFlat(TRUE); |
73 | layout->addWidget( homeButton, 0, 2 ); | 95 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 ); |
74 | 96 | ||
75 | FileStack = new QWidgetStack( this ); | 97 | FileStack = new QWidgetStack( this ); |
76 | 98 | ||
99 | |||
77 | ListView = new QListView( this, "ListView" ); | 100 | ListView = new QListView( this, "ListView" ); |
78 | ListView->setMinimumSize( QSize( 100, 25 ) ); | 101 | ListView->setMinimumSize( QSize( 100, 25 ) ); |
79 | ListView->addColumn( tr( "Name" ) ); | 102 | ListView->addColumn( tr( "Name" ) ); |
80 | ListView->setColumnWidth(0,120); | 103 | ListView->setColumnWidth(0,120); |
81 | ListView->setSorting( 2, FALSE); | 104 | ListView->setSorting( 2, FALSE); |
82 | ListView->addColumn( tr( "Size" ) ); | 105 | ListView->addColumn( tr( "Size" ) ); |
83 | ListView->setColumnWidth(1,-1); | 106 | ListView->setColumnWidth(1,-1); |
84 | ListView->addColumn( "Date",-1); | 107 | ListView->addColumn( "Date",-1); |
85 | // ListView->addColumn( tr( "" ) ); | 108 | |
86 | ListView->setColumnWidthMode(0,QListView::Manual); | 109 | ListView->setColumnWidthMode(0,QListView::Manual); |
87 | ListView->setColumnAlignment(1,QListView::AlignRight); | 110 | ListView->setColumnAlignment(1,QListView::AlignRight); |
88 | ListView->setColumnAlignment(2,QListView::AlignRight); | 111 | ListView->setColumnAlignment(2,QListView::AlignRight); |
89 | ListView->setAllColumnsShowFocus( TRUE ); | 112 | ListView->setAllColumnsShowFocus( TRUE ); |
90 | 113 | ||
91 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); | 114 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); |
92 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 115 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
93 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 116 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
94 | 117 | ||
95 | connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 118 | connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
96 | 119 | ||
97 | FileStack->addWidget( ListView, get_unique_id() ); | 120 | FileStack->addWidget( ListView, get_unique_id() ); |
98 | 121 | mimeType="text/*"; | |
99 | fileSelector = new FileSelector( "text/*", FileStack, "fileselector" , FALSE, FALSE); //buggy | 122 | fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy |
100 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); | 123 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); |
101 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 124 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
102 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); | 125 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); |
103 | layout->addMultiCellWidget( FileStack, 1, 1, 0, 2 ); | 126 | layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 ); |
104 | 127 | ||
105 | SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" ); | 128 | SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" ); |
106 | SelectionCombo->setMinimumSize( QSize( 200, 25 ) ); | ||
107 | SelectionCombo->insertItem( tr( "Documents" ) ); | 129 | SelectionCombo->insertItem( tr( "Documents" ) ); |
108 | SelectionCombo->insertItem( tr( "All files" ) ); | 130 | SelectionCombo->insertItem( tr( "All files" ) ); |
109 | SelectionCombo->insertItem( tr( "All files (incl. hidden)" ) ); | 131 | SelectionCombo->insertItem( tr( "Hidden files" ) ); |
110 | layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 2 ); | 132 | // SelectionCombo->setMaximumWidth(120); |
133 | layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 ); | ||
134 | |||
111 | connect( SelectionCombo, SIGNAL( activated( const QString & ) ), | 135 | connect( SelectionCombo, SIGNAL( activated( const QString & ) ), |
112 | this, SLOT( selectionChanged( const QString & ) ) ); | 136 | this, SLOT( selectionChanged( const QString & ) ) ); |
113 | 137 | ||
138 | typemb = new MenuButton(this); | ||
139 | typemb->setLabel(tr("Type: %1")); | ||
140 | typemb->setMinimumWidth(110); | ||
141 | typemb->setFixedHeight(22); | ||
142 | layout->addMultiCellWidget( typemb, 2, 2, 4, 7 ); | ||
143 | updateMimeTypeMenu() ; | ||
144 | |||
114 | currentDir.setPath(QDir::currentDirPath()); | 145 | currentDir.setPath(QDir::currentDirPath()); |
115 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); | 146 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); |
116 | 147 | ||
117 | populateList(); | 148 | populateList(); |
118 | move(0,15); | 149 | move(0,15); |
119 | } | 150 | } |
120 | 151 | ||
121 | fileBrowser::~fileBrowser() | 152 | fileBrowser::~fileBrowser() |
122 | { | 153 | { |
123 | } | 154 | } |
124 | 155 | ||
125 | void fileBrowser::setFileView( int selection ) | 156 | void fileBrowser::setFileView( int selection ) |
126 | { | 157 | { |
127 | SelectionCombo->setCurrentItem( selection ); | 158 | SelectionCombo->setCurrentItem( selection ); |
128 | selectionChanged( SelectionCombo->currentText() ); | 159 | selectionChanged( SelectionCombo->currentText() ); |
129 | } | 160 | } |
130 | 161 | ||
131 | void fileBrowser::populateList() | 162 | void fileBrowser::populateList() |
132 | { | 163 | { |
133 | ListView->clear(); | 164 | ListView->clear(); |
134 | bool isDir=FALSE; | 165 | bool isDir=FALSE; |
135 | //qDebug(currentDir.canonicalPath()); | 166 | //qDebug(currentDir.canonicalPath()); |
136 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 167 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
137 | currentDir.setMatchAllDirs(TRUE); | 168 | currentDir.setMatchAllDirs(TRUE); |
138 | 169 | ||
139 | currentDir.setNameFilter(filterStr); | 170 | currentDir.setNameFilter(filterStr); |
140 | // currentDir.setNameFilter("*.txt;*.etx"); | 171 | // currentDir.setNameFilter("*.txt;*.etx"); |
141 | QString fileL, fileS, fileDate; | 172 | QString fileL, fileS, fileDate; |
142 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 173 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
143 | QFileInfoListIterator it(*list); | 174 | QFileInfoListIterator it(*list); |
144 | QFileInfo *fi; | 175 | QFileInfo *fi; |
145 | while ( (fi=it.current()) ) { | 176 | while ( (fi=it.current()) ) { |
146 | 177 | ||
147 | if (fi->isSymLink() ){ | 178 | if (fi->isSymLink() ){ |
148 | QString symLink=fi->readLink(); | 179 | QString symLink=fi->readLink(); |
149 | // qDebug("Symlink detected "+symLink); | 180 | // qDebug("Symlink detected "+symLink); |
150 | QFileInfo sym( symLink); | 181 | QFileInfo sym( symLink); |
151 | fileS.sprintf( "%10li", sym.size() ); | 182 | fileS.sprintf( "%10li", sym.size() ); |
152 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 183 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
153 | fileDate = sym.lastModified().toString(); | 184 | fileDate = sym.lastModified().toString(); |
154 | } else { | 185 | } else { |
155 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 186 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
156 | fileS.sprintf( "%10li", fi->size() ); | 187 | fileS.sprintf( "%10li", fi->size() ); |
157 | fileL.sprintf( "%s",fi->fileName().data() ); | 188 | fileL.sprintf( "%s",fi->fileName().data() ); |
158 | fileDate= fi->lastModified().toString(); | 189 | fileDate= fi->lastModified().toString(); |
159 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 190 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
160 | fileL+="/"; | 191 | fileL+="/"; |
161 | isDir=TRUE; | 192 | isDir=TRUE; |
162 | // qDebug( fileL); | 193 | // qDebug( fileL); |
163 | } | 194 | } |
164 | } | 195 | } |
165 | if(fileL !="./") { | 196 | if(fileL !="./") { |
166 | item= new QListViewItem( ListView,fileL,fileS , fileDate); | 197 | item= new QListViewItem( ListView,fileL,fileS , fileDate); |
167 | if(isDir || fileL.find("/",0,TRUE) != -1) | 198 | if(isDir || fileL.find("/",0,TRUE) != -1) |
168 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); | 199 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); |
169 | else | 200 | else |
170 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | 201 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); |
171 | } | 202 | } |
172 | isDir=FALSE; | 203 | isDir=FALSE; |
173 | ++it; | 204 | ++it; |
174 | } | 205 | } |
175 | // ListView->setSorting( 2, FALSE); | ||
176 | ListView->setSorting( 3, FALSE); | 206 | ListView->setSorting( 3, FALSE); |
177 | dirLabel->setText(currentDir.canonicalPath()); | 207 | QString currentPath = currentDir.canonicalPath(); |
208 | |||
209 | fillCombo( (const QString &)currentPath); | ||
210 | // dirPathCombo->lineEdit()->setText(currentPath); | ||
211 | |||
212 | // if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | ||
213 | // dirPathCombo->clear(); | ||
214 | // dirPathStringList.prepend(currentPath ); | ||
215 | // dirPathCombo->insertStringList( dirPathStringList,-1); | ||
216 | // } | ||
178 | } | 217 | } |
179 | 218 | ||
180 | void fileBrowser::upDir() | 219 | void fileBrowser::upDir() |
181 | { | 220 | { |
182 | // qDebug(currentDir.canonicalPath()); | 221 | QString current = currentDir.canonicalPath(); |
222 | QDir dir(current); | ||
223 | dir.cdUp(); | ||
224 | current = dir.canonicalPath(); | ||
225 | chdir( current.latin1() ); | ||
226 | currentDir.cd( current, TRUE); | ||
227 | populateList(); | ||
228 | update(); | ||
183 | } | 229 | } |
184 | 230 | ||
185 | // you may want to switch these 2 functions. I like single clicks | 231 | // you may want to switch these 2 functions. I like single clicks |
186 | void fileBrowser::listClicked(QListViewItem *selectedItem) | 232 | void fileBrowser::listClicked(QListViewItem *selectedItem) |
187 | { | 233 | { |
188 | QString strItem=selectedItem->text(0); | 234 | QString strItem=selectedItem->text(0); |
189 | QString strSize=selectedItem->text(1); | 235 | QString strSize=selectedItem->text(1); |
190 | // qDebug("strItem is "+strItem); | 236 | // qDebug("strItem is "+strItem); |
191 | strSize.stripWhiteSpace(); | 237 | strSize.stripWhiteSpace(); |
192 | // qDebug(strSize); | 238 | // qDebug(strSize); |
193 | 239 | ||
194 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 240 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
195 | // is symlink | 241 | // is symlink |
196 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); | 242 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); |
197 | // qDebug("strItem symlink is "+strItem2); | 243 | // qDebug("strItem symlink is "+strItem2); |
198 | if(QDir(strItem2).exists() ) { | 244 | if(QDir(strItem2).exists() ) { |
199 | currentDir.cd(strItem2, TRUE); | 245 | currentDir.cd(strItem2, TRUE); |
200 | populateList(); | 246 | populateList(); |
201 | } | 247 | } |
202 | } else { // not a symlink | 248 | } else { // not a symlink |
203 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 249 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
204 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 250 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
205 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 251 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
206 | currentDir.cd(strItem,FALSE); | 252 | currentDir.cd(strItem,FALSE); |
207 | // qDebug("Path is "+strItem); | 253 | // qDebug("Path is "+strItem); |
208 | populateList(); | 254 | populateList(); |
209 | } else { | 255 | } else { |
210 | currentDir.cdUp(); | 256 | currentDir.cdUp(); |
211 | populateList(); | 257 | populateList(); |
212 | } | 258 | } |
213 | if(QDir(strItem).exists()){ | 259 | if(QDir(strItem).exists()){ |
214 | currentDir.cd(strItem, TRUE); | 260 | currentDir.cd(strItem, TRUE); |
215 | populateList(); | 261 | populateList(); |
216 | } | 262 | } |
217 | } else { | 263 | } else { |
218 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 264 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
219 | if( QFile::exists(strItem ) ) { | 265 | if( QFile::exists(strItem ) ) { |
220 | //currentDir.canonicalPath() | 266 | //currentDir.canonicalPath() |
221 | qDebug("We found our files!!"+strItem); | 267 | qDebug("We found our files!!"+strItem); |
222 | OnOK(); | 268 | OnOK(); |
223 | } | 269 | } |
224 | } //end not symlink | 270 | } //end not symlink |
225 | chdir(strItem.latin1()); | 271 | chdir(strItem.latin1()); |
226 | } | 272 | } |
227 | } | 273 | } |
228 | 274 | ||
229 | void fileBrowser::OnOK() | 275 | void fileBrowser::OnOK() |
230 | { | 276 | { |
231 | QListViewItemIterator it1( ListView); | 277 | QListViewItemIterator it1( ListView); |
232 | for ( ; it1.current(); ++it1 ) { | 278 | for ( ; it1.current(); ++it1 ) { |
233 | if ( it1.current()->isSelected() ) { | 279 | if ( it1.current()->isSelected() ) { |
234 | selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); | 280 | selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); |
235 | qDebug("selected filename is "+selectedFileName); | 281 | qDebug("selected filename is "+selectedFileName); |
236 | fileList.append( selectedFileName ); | 282 | fileList.append( selectedFileName ); |
237 | } | 283 | } |
238 | } | 284 | } |
239 | accept(); | 285 | accept(); |
240 | } | 286 | } |
241 | 287 | ||
242 | void fileBrowser::homeButtonPushed() { | 288 | void fileBrowser::homeButtonPushed() { |
243 | chdir( QDir::homeDirPath().latin1() ); | 289 | QString current = QDir::homeDirPath(); |
244 | currentDir.cd( QDir::homeDirPath(), TRUE); | 290 | chdir( current.latin1() ); |
245 | populateList(); | 291 | currentDir.cd( current, TRUE); |
246 | update(); | 292 | populateList(); |
293 | update(); | ||
247 | } | 294 | } |
248 | 295 | ||
249 | void fileBrowser::docButtonPushed() { | 296 | void fileBrowser::docButtonPushed() { |
250 | chdir( QString(QPEApplication::documentDir()+"/text").latin1() ); | 297 | QString current = QPEApplication::documentDir(); |
251 | currentDir.cd( QPEApplication::documentDir()+"/text", TRUE); | 298 | chdir( current.latin1() ); |
252 | populateList(); | 299 | currentDir.cd( current, TRUE); |
253 | update(); | 300 | populateList(); |
301 | update(); | ||
254 | 302 | ||
255 | } | 303 | } |
256 | 304 | ||
257 | void fileBrowser::selectionChanged( const QString &select ) | 305 | void fileBrowser::selectionChanged( const QString &select ) |
258 | { | 306 | { |
259 | if ( select == "Documents") | 307 | if ( select == "Documents") { |
260 | { | ||
261 | FileStack->raiseWidget( fileSelector ); | 308 | FileStack->raiseWidget( fileSelector ); |
262 | dirLabel->hide(); | 309 | dirPathCombo->hide(); |
310 | cdUpButton->hide(); | ||
263 | docButton->hide(); | 311 | docButton->hide(); |
264 | homeButton->hide(); | 312 | homeButton->hide(); |
265 | } | 313 | } else { |
266 | else | ||
267 | { | ||
268 | if ( select == "All files" ) | 314 | if ( select == "All files" ) |
269 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All); | 315 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All); |
270 | else | 316 | else |
271 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 317 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
272 | 318 | ||
273 | populateList(); | 319 | populateList(); |
274 | update(); | 320 | update(); |
275 | dirLabel->show(); | 321 | dirPathCombo->show(); |
322 | cdUpButton->show(); | ||
276 | docButton->show(); | 323 | docButton->show(); |
277 | homeButton->show(); | 324 | homeButton->show(); |
278 | FileStack->raiseWidget( ListView ); | 325 | FileStack->raiseWidget( ListView ); |
279 | } | 326 | } |
280 | } | 327 | } |
281 | 328 | ||
282 | void fileBrowser::docOpen( const DocLnk &doc ) | 329 | void fileBrowser::docOpen( const DocLnk &doc ) |
283 | { | 330 | { |
284 | fileList.append( doc.file().latin1() ); | 331 | fileList.append( doc.file().latin1() ); |
285 | accept(); | 332 | accept(); |
286 | } | 333 | } |
287 | 334 | ||
288 | void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 335 | void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
289 | { | 336 | { |
290 | switch (mouse) { | 337 | switch (mouse) { |
291 | case 1: | 338 | case 1: |
292 | break; | 339 | break; |
293 | case 2: | 340 | case 2: |
294 | showListMenu(item); | 341 | showListMenu(item); |
295 | break; | 342 | break; |
296 | }; | 343 | }; |
297 | } | 344 | } |
298 | 345 | ||
299 | void fileBrowser::showListMenu(QListViewItem *item) { | 346 | void fileBrowser::showListMenu(QListViewItem *item) { |
300 | 347 | ||
301 | QPopupMenu m;// = new QPopupMenu( Local_View ); | 348 | QPopupMenu m;// = new QPopupMenu( Local_View ); |
302 | if( item->text(0).find("/",0,TRUE)) | 349 | if( item->text(0).find("/",0,TRUE)) |
303 | m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); | 350 | m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); |
304 | else | 351 | else |
305 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); | 352 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); |
353 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList()() )); | ||
306 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 354 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
307 | m.insertSeparator(); | 355 | m.insertSeparator(); |
308 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 356 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
309 | m.exec( QCursor::pos() ); | 357 | m.exec( QCursor::pos() ); |
310 | 358 | ||
311 | } | 359 | } |
312 | 360 | ||
313 | void fileBrowser::doCd() { | 361 | void fileBrowser::doCd() { |
314 | listClicked( ListView->currentItem()); | 362 | listClicked( ListView->currentItem()); |
315 | } | 363 | } |
316 | 364 | ||
317 | void fileBrowser::makDir() { | 365 | void fileBrowser::makDir() { |
318 | InputDialog *fileDlg; | 366 | InputDialog *fileDlg; |
319 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); | 367 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); |
320 | fileDlg->exec(); | 368 | fileDlg->exec(); |
321 | if( fileDlg->result() == 1 ) { | 369 | if( fileDlg->result() == 1 ) { |
322 | QString filename = fileDlg->LineEdit1->text(); | 370 | QString filename = fileDlg->LineEdit1->text(); |
323 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 371 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
324 | } | 372 | } |
325 | populateList(); | 373 | populateList(); |
326 | } | 374 | } |
327 | 375 | ||
328 | void fileBrowser::localRename() { | 376 | void fileBrowser::localRename() { |
329 | QString curFile = ListView->currentItem()->text(0); | 377 | QString curFile = ListView->currentItem()->text(0); |
330 | InputDialog *fileDlg; | 378 | InputDialog *fileDlg; |
331 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); | 379 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); |
332 | fileDlg->inputText = curFile; | 380 | fileDlg->inputText = curFile; |
333 | fileDlg->exec(); | 381 | fileDlg->exec(); |
334 | if( fileDlg->result() == 1 ) { | 382 | if( fileDlg->result() == 1 ) { |
335 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 383 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
336 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 384 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
337 | if( rename(oldname.latin1(), newName.latin1())== -1) | 385 | if( rename(oldname.latin1(), newName.latin1())== -1) |
338 | QMessageBox::message("Note","Could not rename"); | 386 | QMessageBox::message("Note","Could not rename"); |
339 | } | 387 | } |
340 | populateList(); | 388 | populateList(); |
341 | } | 389 | } |
342 | 390 | ||
343 | void fileBrowser::localDelete() { | 391 | void fileBrowser::localDelete() { |
344 | QString f = ListView->currentItem()->text(0); | 392 | QString f = ListView->currentItem()->text(0); |
345 | if(QDir(f).exists() ) { | 393 | if(QDir(f).exists() ) { |
346 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ | 394 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ |
347 | " ?\nIt must be empty","Yes","No",0,0,1) ) { | 395 | " ?\nIt must be empty","Yes","No",0,0,1) ) { |
348 | case 0: { | 396 | case 0: { |
349 | f=currentDir.canonicalPath()+"/"+f; | 397 | f=currentDir.canonicalPath()+"/"+f; |
350 | QString cmd="rmdir "+f; | 398 | QString cmd="rmdir "+f; |
351 | system( cmd.latin1()); | 399 | system( cmd.latin1()); |
352 | populateList(); | 400 | populateList(); |
353 | } | 401 | } |
354 | break; | 402 | break; |
355 | case 1: | 403 | case 1: |
356 | // exit | 404 | // exit |
357 | break; | 405 | break; |
358 | }; | 406 | }; |
359 | 407 | ||
360 | } else { | 408 | } else { |
361 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f | 409 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f |
362 | +" ?","Yes","No",0,0,1) ) { | 410 | +" ?","Yes","No",0,0,1) ) { |
363 | case 0: { | 411 | case 0: { |
364 | f=currentDir.canonicalPath()+"/"+f; | 412 | f=currentDir.canonicalPath()+"/"+f; |
365 | QString cmd="rm "+f; | 413 | QString cmd="rm "+f; |
366 | system( cmd.latin1()); | 414 | system( cmd.latin1()); |
367 | populateList(); | 415 | populateList(); |
368 | } | 416 | } |
369 | break; | 417 | break; |
370 | case 1: | 418 | case 1: |
371 | // exit | 419 | // exit |
372 | break; | 420 | break; |
373 | }; | 421 | }; |
374 | } | 422 | } |
423 | } | ||
424 | |||
425 | void fileBrowser::updateMimeTypeMenu() { | ||
426 | |||
427 | disconnect( typemb, SIGNAL(selected(const QString&)), | ||
428 | this, SLOT(showType(const QString&)) ); | ||
429 | |||
430 | QString prev; | ||
431 | |||
432 | // Type filter | ||
433 | QStringList types; | ||
434 | types << tr("All"); | ||
435 | types << "--"; | ||
436 | types += getMimeTypes(); | ||
437 | prev = typemb->currentText(); | ||
438 | typemb->clear(); | ||
439 | typemb->insertItems(types); | ||
440 | // typemb->select(prev); | ||
441 | |||
442 | connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&))); | ||
443 | } | ||
444 | |||
445 | void fileBrowser::showType(const QString &t) { | ||
446 | |||
447 | qDebug(t); | ||
448 | mimeType = t+"/*"; | ||
449 | // if(fileSelector) { | ||
450 | // disconnect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); | ||
451 | // delete fileSelector; | ||
452 | } | ||
453 | // fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy | ||
454 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); | ||
455 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | ||
456 | // connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); | ||
457 | fileSelector->reread(); | ||
458 | repaint(); | ||
459 | // if ( t == tr("All") ) { | ||
460 | // icons->setTypeFilter("",TRUE); | ||
461 | // } else { | ||
462 | // icons->setTypeFilter(t+"/*",TRUE); | ||
463 | // } | ||
464 | |||
465 | } | ||
466 | |||
467 | QStringList fileBrowser::getMimeTypes() { | ||
468 | QStringList r; | ||
469 | AppLnkSet apps( QPEApplication::qpeDir() + "apps" ); | ||
470 | QFile file( QPEApplication::qpeDir()+"etc/available.mime"); | ||
471 | file.open( IO_WriteOnly|IO_Truncate);//) | ||
472 | for ( QListIterator<AppLnk> it( apps.children() ); it.current(); ++it ) { | ||
473 | AppLnk* l; | ||
474 | l = it.current(); | ||
475 | QStringList maj = l->mimeTypes(); | ||
476 | QStringList::ConstIterator f; | ||
477 | for ( f = maj.begin(); f != maj.end(); f++ ) { | ||
478 | QString temp = *f; | ||
479 | int sl = temp.find('/'); | ||
480 | if (sl >= 0) { | ||
481 | QString k = temp.left(sl); | ||
482 | if( r.grep(k,TRUE).isEmpty() ) { | ||
483 | r << k; | ||
484 | k+="\n"; | ||
485 | file.writeBlock( k.latin1(), k.length()); | ||
486 | } | ||
487 | } | ||
488 | } | ||
489 | } | ||
490 | r.sort(); | ||
491 | file.close(); | ||
492 | return r; | ||
493 | } | ||
494 | |||
495 | void fileBrowser::receive( const QCString &msg, const QByteArray &data ) { | ||
496 | // QDataStream stream( data, IO_ReadOnly ); | ||
497 | // if (msg == "keyRegister(int key, QString channel, QString message)") | ||
498 | // { | ||
499 | // int k; | ||
500 | // QString c, m; | ||
501 | // stream >> k; | ||
502 | // stream >> c; | ||
503 | // stream >> m; | ||
504 | } | ||
505 | |||
506 | void fileBrowser::dirPathComboActivated( const QString & current) { | ||
507 | chdir( current.latin1() ); | ||
508 | currentDir.cd( current, TRUE); | ||
509 | populateList(); | ||
510 | update(); | ||
511 | } | ||
512 | |||
513 | void fileBrowser::dirPathEditPressed() { | ||
514 | QString current = dirPathCombo->lineEdit()->text(); | ||
515 | chdir( current.latin1() ); | ||
516 | currentDir.cd( current, TRUE); | ||
517 | populateList(); | ||
518 | update(); | ||
519 | } | ||
520 | |||
521 | void fileBrowser::fillCombo(const QString ¤tPath) { | ||
522 | |||
523 | dirPathCombo->lineEdit()->setText(currentPath); | ||
524 | |||
525 | if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | ||
526 | dirPathCombo->clear(); | ||
527 | dirPathStringList.prepend(currentPath ); | ||
528 | dirPathCombo->insertStringList( dirPathStringList,-1); | ||
529 | } | ||
375 | 530 | ||
376 | } | 531 | } |
diff --git a/core/apps/textedit/fileBrowser.h b/core/apps/textedit/fileBrowser.h index 4f765dd..8a98365 100644 --- a/core/apps/textedit/fileBrowser.h +++ b/core/apps/textedit/fileBrowser.h | |||
@@ -1,87 +1,101 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** | 2 | ** |
3 | ** Created: Fri Dec 14 08:16:02 2001 | 3 | ** Created: Fri Dec 14 08:16:02 2001 |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | copyright Sun 02-17-2002 22:28:23 L. J. Potter ljp@llornkcor.com | 13 | copyright Sun 02-17-2002 22:28:23 L. J. Potter ljp@llornkcor.com |
14 | ****************************************************************************/ | 14 | ****************************************************************************/ |
15 | #ifndef FILEBROWSER_H | 15 | #ifndef FILEBROWSER_H |
16 | #define FILEBROWSER_H | 16 | #define FILEBROWSER_H |
17 | 17 | ||
18 | //#include <qvariant.h> | 18 | //#include <qvariant.h> |
19 | #include <qdialog.h> | 19 | #include <qdialog.h> |
20 | #include <qfile.h> | 20 | #include <qfile.h> |
21 | #include <qdir.h> | 21 | #include <qdir.h> |
22 | #include <qstringlist.h> | 22 | #include <qstringlist.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qdict.h> | ||
25 | 26 | ||
26 | #include <qpe/filemanager.h> | 27 | #include <qpe/filemanager.h> |
27 | 28 | ||
28 | class QVBoxLayout; | 29 | class QVBoxLayout; |
29 | class QHBoxLayout; | 30 | class QHBoxLayout; |
30 | class QGridLayout; | 31 | class QGridLayout; |
31 | class QListView; | 32 | class QListView; |
32 | class QListViewItem; | 33 | class QListViewItem; |
33 | class QPushButton; | 34 | class QPushButton; |
34 | class QComboBox; | 35 | class QComboBox; |
35 | class QWidgetStack; | 36 | class QWidgetStack; |
36 | class FileSelector; | 37 | class FileSelector; |
37 | class QPoint; | 38 | class QPoint; |
39 | class MenuButton; | ||
40 | class QRegExp; | ||
41 | |||
38 | 42 | ||
39 | class fileBrowser : public QDialog | 43 | class fileBrowser : public QDialog |
40 | { | 44 | { |
41 | Q_OBJECT | 45 | Q_OBJECT |
42 | 46 | ||
43 | public: | 47 | public: |
44 | void populateList(); | 48 | void populateList(); |
45 | fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0); | 49 | fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0); |
46 | ~fileBrowser(); | 50 | ~fileBrowser(); |
47 | 51 | ||
48 | void setFileView( int ); | 52 | void setFileView( int ); |
49 | 53 | ||
50 | QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton; | 54 | QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton, *cdUpButton; |
51 | QListView* ListView; | 55 | QListView* ListView; |
52 | 56 | ||
53 | QLabel *dirLabel; | 57 | QLabel *dirLabel; |
54 | QString selectedFileName, filterStr; | 58 | QString selectedFileName, filterStr; |
55 | QDir currentDir; | 59 | QDir currentDir; |
56 | QFile file; | 60 | QFile file; |
57 | QStringList fileList; | 61 | QStringList fileList, dirPathStringList; |
58 | QListViewItem * item; | 62 | QListViewItem * item; |
59 | QComboBox *SelectionCombo; | 63 | QComboBox *SelectionCombo, *dirPathCombo; |
64 | MenuButton *typemb; | ||
60 | QWidgetStack *FileStack; | 65 | QWidgetStack *FileStack; |
61 | FileSelector *fileSelector; | 66 | FileSelector *fileSelector; |
62 | 67 | QString mimeType; | |
63 | public slots: | 68 | public slots: |
69 | |||
70 | private: | ||
71 | // QDict<void> mimes; | ||
72 | QRegExp tf; | ||
73 | QStringList getMimeTypes(); | ||
74 | void fillCombo( const QString&); | ||
75 | private slots: | ||
64 | void homeButtonPushed(); | 76 | void homeButtonPushed(); |
65 | void docButtonPushed(); | 77 | void docButtonPushed(); |
66 | void ListPressed( int, QListViewItem *, const QPoint&, int); | 78 | void ListPressed( int, QListViewItem *, const QPoint&, int); |
67 | void showListMenu(QListViewItem*); | 79 | void showListMenu(QListViewItem*); |
68 | void doCd(); | 80 | void doCd(); |
69 | void makDir(); | 81 | void makDir(); |
70 | void localRename(); | 82 | void localRename(); |
71 | void localDelete(); | 83 | void localDelete(); |
72 | private: | 84 | void receive( const QCString &msg, const QByteArray &data ); |
73 | 85 | void dirPathComboActivated( const QString & ); | |
74 | private slots: | ||
75 | void upDir(); | 86 | void upDir(); |
76 | void listClicked( QListViewItem * ); | 87 | void listClicked( QListViewItem * ); |
77 | void selectionChanged( const QString & ); | 88 | void selectionChanged( const QString & ); |
78 | void OnOK(); | 89 | void OnOK(); |
79 | void docOpen( const DocLnk & ); | 90 | void docOpen( const DocLnk & ); |
80 | 91 | void updateMimeTypeMenu(); | |
92 | void showType(const QString &); | ||
93 | void dirPathEditPressed(); | ||
94 | |||
81 | protected slots: | 95 | protected slots: |
82 | 96 | ||
83 | protected: | 97 | protected: |
84 | 98 | ||
85 | }; | 99 | }; |
86 | 100 | ||
87 | #endif // FILEBROWSER_H | 101 | #endif // FILEBROWSER_H |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 1a1b186..da74893 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -308,386 +308,386 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
308 | 308 | ||
309 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 309 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
310 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 310 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
311 | zout->addTo( font ); | 311 | zout->addTo( font ); |
312 | 312 | ||
313 | font->insertSeparator(); | 313 | font->insertSeparator(); |
314 | 314 | ||
315 | #if 0 | 315 | #if 0 |
316 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); | 316 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); |
317 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); | 317 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); |
318 | ba->setToggleAction(TRUE); | 318 | ba->setToggleAction(TRUE); |
319 | ba->addTo( font ); | 319 | ba->addTo( font ); |
320 | 320 | ||
321 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); | 321 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); |
322 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); | 322 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); |
323 | ia->setToggleAction(TRUE); | 323 | ia->setToggleAction(TRUE); |
324 | ia->addTo( font ); | 324 | ia->addTo( font ); |
325 | 325 | ||
326 | ba->setOn(defb); | 326 | ba->setOn(defb); |
327 | ia->setOn(defi); | 327 | ia->setOn(defi); |
328 | 328 | ||
329 | font->insertSeparator(); | 329 | font->insertSeparator(); |
330 | #endif | 330 | #endif |
331 | 331 | ||
332 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); | 332 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); |
333 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); | 333 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); |
334 | wa->setToggleAction(TRUE); | 334 | wa->setToggleAction(TRUE); |
335 | wa->addTo( font ); | 335 | wa->addTo( font ); |
336 | 336 | ||
337 | font->insertSeparator(); | 337 | font->insertSeparator(); |
338 | font->insertItem("Font", this, SLOT(changeFont()) ); | 338 | font->insertItem("Font", this, SLOT(changeFont()) ); |
339 | 339 | ||
340 | font->insertSeparator(); | 340 | font->insertSeparator(); |
341 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); | 341 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); |
342 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); | 342 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); |
343 | nStart->setToggleAction(TRUE); | 343 | nStart->setToggleAction(TRUE); |
344 | nStart->addTo( font ); | 344 | nStart->addTo( font ); |
345 | 345 | ||
346 | mb->insertItem( tr( "File" ), file ); | 346 | mb->insertItem( tr( "File" ), file ); |
347 | mb->insertItem( tr( "Edit" ), edit ); | 347 | mb->insertItem( tr( "Edit" ), edit ); |
348 | mb->insertItem( tr( "View" ), font ); | 348 | mb->insertItem( tr( "View" ), font ); |
349 | 349 | ||
350 | searchBar = new QPEToolBar(this); | 350 | searchBar = new QPEToolBar(this); |
351 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 351 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
352 | 352 | ||
353 | searchBar->setHorizontalStretchable( TRUE ); | 353 | searchBar->setHorizontalStretchable( TRUE ); |
354 | 354 | ||
355 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 355 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
356 | searchBar->setStretchableWidget( searchEdit ); | 356 | searchBar->setStretchableWidget( searchEdit ); |
357 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 357 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
358 | this, SLOT( search() ) ); | 358 | this, SLOT( search() ) ); |
359 | 359 | ||
360 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | 360 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); |
361 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 361 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
362 | a->addTo( searchBar ); | 362 | a->addTo( searchBar ); |
363 | a->addTo( edit ); | 363 | a->addTo( edit ); |
364 | 364 | ||
365 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 365 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
366 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 366 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
367 | a->addTo( searchBar ); | 367 | a->addTo( searchBar ); |
368 | 368 | ||
369 | edit->insertSeparator(); | 369 | edit->insertSeparator(); |
370 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 370 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
371 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 371 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
372 | a->addTo( edit ); | 372 | a->addTo( edit ); |
373 | 373 | ||
374 | searchBar->hide(); | 374 | searchBar->hide(); |
375 | 375 | ||
376 | editor = new QpeEditor( this ); | 376 | editor = new QpeEditor( this ); |
377 | setCentralWidget( editor ); | 377 | setCentralWidget( editor ); |
378 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 378 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
379 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); | 379 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); |
380 | 380 | ||
381 | resize( 200, 300 ); | 381 | resize( 200, 300 ); |
382 | 382 | ||
383 | // setFontSize(defsize,TRUE); | 383 | // setFontSize(defsize,TRUE); |
384 | FontDatabase fdb; | 384 | FontDatabase fdb; |
385 | QFont defaultFont=editor->font(); | 385 | QFont defaultFont=editor->font(); |
386 | QFontInfo fontInfo(defaultFont); | 386 | QFontInfo fontInfo(defaultFont); |
387 | 387 | ||
388 | cfg.setGroup("Font"); | 388 | cfg.setGroup("Font"); |
389 | QString family = cfg.readEntry("Family", fontInfo.family()); | 389 | QString family = cfg.readEntry("Family", fontInfo.family()); |
390 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 390 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
391 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 391 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
392 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 392 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
393 | 393 | ||
394 | defaultFont = fdb.font(family,style,i_size,charSet); | 394 | defaultFont = fdb.font(family,style,i_size,charSet); |
395 | editor->setFont( defaultFont); | 395 | editor->setFont( defaultFont); |
396 | 396 | ||
397 | wa->setOn(wrap); | 397 | wa->setOn(wrap); |
398 | updateCaption(); | 398 | updateCaption(); |
399 | 399 | ||
400 | cfg.setGroup("View"); | 400 | cfg.setGroup("View"); |
401 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { | 401 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { |
402 | nStart->setOn(TRUE); | 402 | nStart->setOn(TRUE); |
403 | fileNew(); | 403 | fileNew(); |
404 | } else { | 404 | } else { |
405 | fileOpen(); | 405 | fileOpen(); |
406 | } | 406 | } |
407 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 407 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
408 | } | 408 | } |
409 | 409 | ||
410 | void TextEdit::cleanUp() | 410 | void TextEdit::cleanUp() |
411 | { | 411 | { |
412 | // save(); | 412 | // save(); |
413 | Config cfg("TextEdit"); | 413 | Config cfg("TextEdit"); |
414 | cfg.setGroup("View"); | 414 | cfg.setGroup("View"); |
415 | QFont f = editor->font(); | 415 | QFont f = editor->font(); |
416 | cfg.writeEntry("FontSize",f.pointSize()); | 416 | cfg.writeEntry("FontSize",f.pointSize()); |
417 | cfg.writeEntry("Bold",f.bold()); | 417 | cfg.writeEntry("Bold",f.bold()); |
418 | cfg.writeEntry("Italic",f.italic()); | 418 | cfg.writeEntry("Italic",f.italic()); |
419 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); | 419 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); |
420 | cfg.writeEntry( "FileView", viewSelection ); | 420 | cfg.writeEntry( "FileView", viewSelection ); |
421 | 421 | ||
422 | } | 422 | } |
423 | 423 | ||
424 | TextEdit::~TextEdit() | 424 | TextEdit::~TextEdit() |
425 | { | 425 | { |
426 | } | 426 | } |
427 | 427 | ||
428 | void TextEdit::zoomIn() | 428 | void TextEdit::zoomIn() |
429 | { | 429 | { |
430 | setFontSize(editor->font().pointSize()+1,FALSE); | 430 | setFontSize(editor->font().pointSize()+1,FALSE); |
431 | } | 431 | } |
432 | 432 | ||
433 | void TextEdit::zoomOut() | 433 | void TextEdit::zoomOut() |
434 | { | 434 | { |
435 | setFontSize(editor->font().pointSize()-1,TRUE); | 435 | setFontSize(editor->font().pointSize()-1,TRUE); |
436 | } | 436 | } |
437 | 437 | ||
438 | 438 | ||
439 | void TextEdit::setFontSize(int sz, bool round_down_not_up) | 439 | void TextEdit::setFontSize(int sz, bool round_down_not_up) |
440 | { | 440 | { |
441 | int s=10; | 441 | int s=10; |
442 | for (int i=0; i<nfontsizes; i++) { | 442 | for (int i=0; i<nfontsizes; i++) { |
443 | if ( fontsize[i] == sz ) { | 443 | if ( fontsize[i] == sz ) { |
444 | s = sz; | 444 | s = sz; |
445 | break; | 445 | break; |
446 | } else if ( round_down_not_up ) { | 446 | } else if ( round_down_not_up ) { |
447 | if ( fontsize[i] < sz ) | 447 | if ( fontsize[i] < sz ) |
448 | s = fontsize[i]; | 448 | s = fontsize[i]; |
449 | } else { | 449 | } else { |
450 | if ( fontsize[i] > sz ) { | 450 | if ( fontsize[i] > sz ) { |
451 | s = fontsize[i]; | 451 | s = fontsize[i]; |
452 | break; | 452 | break; |
453 | } | 453 | } |
454 | } | 454 | } |
455 | } | 455 | } |
456 | 456 | ||
457 | QFont f = editor->font(); | 457 | QFont f = editor->font(); |
458 | f.setPointSize(s); | 458 | f.setPointSize(s); |
459 | editor->setFont(f); | 459 | editor->setFont(f); |
460 | 460 | ||
461 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 461 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
462 | zout->setEnabled(s != fontsize[0]); | 462 | zout->setEnabled(s != fontsize[0]); |
463 | } | 463 | } |
464 | 464 | ||
465 | void TextEdit::setBold(bool y) | 465 | void TextEdit::setBold(bool y) |
466 | { | 466 | { |
467 | QFont f = editor->font(); | 467 | QFont f = editor->font(); |
468 | f.setBold(y); | 468 | f.setBold(y); |
469 | editor->setFont(f); | 469 | editor->setFont(f); |
470 | } | 470 | } |
471 | 471 | ||
472 | void TextEdit::setItalic(bool y) | 472 | void TextEdit::setItalic(bool y) |
473 | { | 473 | { |
474 | QFont f = editor->font(); | 474 | QFont f = editor->font(); |
475 | f.setItalic(y); | 475 | f.setItalic(y); |
476 | editor->setFont(f); | 476 | editor->setFont(f); |
477 | } | 477 | } |
478 | 478 | ||
479 | void TextEdit::setWordWrap(bool y) | 479 | void TextEdit::setWordWrap(bool y) |
480 | { | 480 | { |
481 | bool state = editor->edited(); | 481 | bool state = editor->edited(); |
482 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 482 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
483 | editor->setEdited( state ); | 483 | editor->setEdited( state ); |
484 | } | 484 | } |
485 | 485 | ||
486 | void TextEdit::fileNew() | 486 | void TextEdit::fileNew() |
487 | { | 487 | { |
488 | if( !bFromDocView ) { | 488 | if( !bFromDocView ) { |
489 | saveAs(); | 489 | saveAs(); |
490 | } | 490 | } |
491 | newFile(DocLnk()); | 491 | newFile(DocLnk()); |
492 | } | 492 | } |
493 | 493 | ||
494 | void TextEdit::fileOpen() | 494 | void TextEdit::fileOpen() |
495 | { | 495 | { |
496 | browseForFiles=new fileBrowser(this,"Open File",TRUE,0, "*"); | 496 | browseForFiles=new fileBrowser(this,"Open File",TRUE,0, "*"); |
497 | browseForFiles->setFileView( viewSelection ); | 497 | browseForFiles->setFileView( viewSelection ); |
498 | browseForFiles->showMaximized(); | 498 | browseForFiles->showMaximized(); |
499 | if( browseForFiles->exec() != -1 ) { | 499 | if( browseForFiles->exec() != -1 ) { |
500 | QString selFile= browseForFiles->selectedFileName; | 500 | QString selFile = browseForFiles->selectedFileName; |
501 | QStringList fileList=browseForFiles->fileList; | 501 | QStringList fileList = browseForFiles->fileList; |
502 | qDebug(selFile); | 502 | qDebug(selFile); |
503 | QStringList::ConstIterator f; | 503 | QStringList::ConstIterator f; |
504 | QString fileTemp; | 504 | QString fileTemp; |
505 | for ( f = fileList.begin(); f != fileList.end(); f++ ) { | 505 | for ( f = fileList.begin(); f != fileList.end(); f++ ) { |
506 | fileTemp = *f; | 506 | fileTemp = *f; |
507 | fileTemp.right( fileTemp.length()-5); | 507 | fileTemp.right( fileTemp.length()-5); |
508 | QString fileName = fileTemp; | 508 | QString fileName = fileTemp; |
509 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { | 509 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { |
510 | currentFileName = fileName; | 510 | currentFileName = fileName; |
511 | qDebug("please open "+currentFileName); | 511 | qDebug("please open "+currentFileName); |
512 | openFile(fileName ); | 512 | openFile(fileName ); |
513 | } | 513 | } |
514 | } | 514 | } |
515 | viewSelection = browseForFiles->SelectionCombo->currentItem(); | 515 | viewSelection = browseForFiles->SelectionCombo->currentItem(); |
516 | } | 516 | } |
517 | delete browseForFiles; | 517 | delete browseForFiles; |
518 | editor->setEdited( FALSE); | 518 | editor->setEdited( FALSE); |
519 | edited1=FALSE; | 519 | edited1=FALSE; |
520 | edited=FALSE; | 520 | edited=FALSE; |
521 | if(caption().left(1)=="*") | 521 | if(caption().left(1)=="*") |
522 | setCaption(caption().right(caption().length()-1)); | 522 | setCaption(caption().right(caption().length()-1)); |
523 | doSearchBar(); | 523 | doSearchBar(); |
524 | } | 524 | } |
525 | 525 | ||
526 | void TextEdit::doSearchBar() | 526 | void TextEdit::doSearchBar() |
527 | { | 527 | { |
528 | Config cfg("TextEdit"); | 528 | Config cfg("TextEdit"); |
529 | cfg.setGroup("View"); | 529 | cfg.setGroup("View"); |
530 | if(cfg.readEntry("SearchBar","Closed") != "Opened") | 530 | if(cfg.readEntry("SearchBar","Closed") != "Opened") |
531 | searchBar->hide(); | 531 | searchBar->hide(); |
532 | } | 532 | } |
533 | 533 | ||
534 | #if 0 | 534 | #if 0 |
535 | void TextEdit::slotFind() | 535 | void TextEdit::slotFind() |
536 | { | 536 | { |
537 | FindDialog frmFind( "Text Editor", this ); | 537 | FindDialog frmFind( "Text Editor", this ); |
538 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 538 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
539 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 539 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
540 | 540 | ||
541 | //case sensitive, backwards, [category] | 541 | //case sensitive, backwards, [category] |
542 | 542 | ||
543 | connect( editor, SIGNAL(notFound()), | 543 | connect( editor, SIGNAL(notFound()), |
544 | &frmFind, SLOT(slotNotFound()) ); | 544 | &frmFind, SLOT(slotNotFound()) ); |
545 | connect( editor, SIGNAL(searchWrapped()), | 545 | connect( editor, SIGNAL(searchWrapped()), |
546 | &frmFind, SLOT(slotWrapAround()) ); | 546 | &frmFind, SLOT(slotWrapAround()) ); |
547 | 547 | ||
548 | frmFind.exec(); | 548 | frmFind.exec(); |
549 | 549 | ||
550 | 550 | ||
551 | } | 551 | } |
552 | #endif | 552 | #endif |
553 | 553 | ||
554 | void TextEdit::fileRevert() | 554 | void TextEdit::fileRevert() |
555 | { | 555 | { |
556 | clear(); | 556 | clear(); |
557 | fileOpen(); | 557 | fileOpen(); |
558 | } | 558 | } |
559 | 559 | ||
560 | void TextEdit::editCut() | 560 | void TextEdit::editCut() |
561 | { | 561 | { |
562 | #ifndef QT_NO_CLIPBOARD | 562 | #ifndef QT_NO_CLIPBOARD |
563 | editor->cut(); | 563 | editor->cut(); |
564 | #endif | 564 | #endif |
565 | } | 565 | } |
566 | 566 | ||
567 | void TextEdit::editCopy() | 567 | void TextEdit::editCopy() |
568 | { | 568 | { |
569 | #ifndef QT_NO_CLIPBOARD | 569 | #ifndef QT_NO_CLIPBOARD |
570 | editor->copy(); | 570 | editor->copy(); |
571 | #endif | 571 | #endif |
572 | } | 572 | } |
573 | 573 | ||
574 | void TextEdit::editPaste() | 574 | void TextEdit::editPaste() |
575 | { | 575 | { |
576 | #ifndef QT_NO_CLIPBOARD | 576 | #ifndef QT_NO_CLIPBOARD |
577 | editor->paste(); | 577 | editor->paste(); |
578 | #endif | 578 | #endif |
579 | } | 579 | } |
580 | 580 | ||
581 | void TextEdit::editFind() | 581 | void TextEdit::editFind() |
582 | { | 582 | { |
583 | searchBar->show(); | 583 | searchBar->show(); |
584 | searchVisible = TRUE; | 584 | searchVisible = TRUE; |
585 | searchEdit->setFocus(); | 585 | searchEdit->setFocus(); |
586 | Config cfg("TextEdit"); | 586 | Config cfg("TextEdit"); |
587 | cfg.setGroup("View"); | 587 | cfg.setGroup("View"); |
588 | cfg.writeEntry("SearchBar","Opened"); | 588 | cfg.writeEntry("SearchBar","Opened"); |
589 | 589 | ||
590 | } | 590 | } |
591 | 591 | ||
592 | void TextEdit::findNext() | 592 | void TextEdit::findNext() |
593 | { | 593 | { |
594 | editor->find( searchEdit->text(), FALSE, FALSE ); | 594 | editor->find( searchEdit->text(), FALSE, FALSE ); |
595 | 595 | ||
596 | } | 596 | } |
597 | 597 | ||
598 | void TextEdit::findClose() | 598 | void TextEdit::findClose() |
599 | { | 599 | { |
600 | searchVisible = FALSE; | 600 | searchVisible = FALSE; |
601 | searchBar->hide(); | 601 | searchBar->hide(); |
602 | Config cfg("TextEdit"); | 602 | Config cfg("TextEdit"); |
603 | cfg.setGroup("View"); | 603 | cfg.setGroup("View"); |
604 | cfg.writeEntry("SearchBar","Closed"); | 604 | cfg.writeEntry("SearchBar","Closed"); |
605 | cfg.write(); | 605 | cfg.write(); |
606 | } | 606 | } |
607 | 607 | ||
608 | void TextEdit::search() | 608 | void TextEdit::search() |
609 | { | 609 | { |
610 | editor->find( searchEdit->text(), FALSE, FALSE ); | 610 | editor->find( searchEdit->text(), FALSE, FALSE ); |
611 | } | 611 | } |
612 | 612 | ||
613 | void TextEdit::newFile( const DocLnk &f ) | 613 | void TextEdit::newFile( const DocLnk &f ) |
614 | { | 614 | { |
615 | DocLnk nf = f; | 615 | DocLnk nf = f; |
616 | nf.setType("text/plain"); | 616 | nf.setType("text/plain"); |
617 | clear(); | 617 | clear(); |
618 | setWState (WState_Reserved1 ); | 618 | setWState (WState_Reserved1 ); |
619 | editor->setFocus(); | 619 | editor->setFocus(); |
620 | doc = new DocLnk(nf); | 620 | doc = new DocLnk(nf); |
621 | qDebug("newFile "+currentFileName); | 621 | qDebug("newFile "+currentFileName); |
622 | updateCaption(currentFileName); | 622 | updateCaption(currentFileName); |
623 | } | 623 | } |
624 | 624 | ||
625 | void TextEdit::openFile( const QString &f ) | 625 | void TextEdit::openFile( const QString &f ) |
626 | { | 626 | { |
627 | 627 | ||
628 | bFromDocView = TRUE; | 628 | bFromDocView = TRUE; |
629 | DocLnk nf; | 629 | DocLnk nf; |
630 | nf.setType("text/plain"); | 630 | nf.setType("text/plain"); |
631 | nf.setFile(f); | 631 | nf.setFile(f); |
632 | currentFileName=f; | 632 | currentFileName=f; |
633 | QFileInfo fi( currentFileName); | 633 | QFileInfo fi( currentFileName); |
634 | nf.setName(fi.baseName()); | 634 | nf.setName(fi.baseName()); |
635 | qDebug("openFile string"+currentFileName); | 635 | qDebug("openFile string"+currentFileName); |
636 | 636 | ||
637 | openFile(nf); | 637 | openFile(nf); |
638 | showEditTools(); | 638 | showEditTools(); |
639 | // Show filename in caption | 639 | // Show filename in caption |
640 | QString name = f; | 640 | QString name = f; |
641 | int sep = name.findRev( '/' ); | 641 | int sep = name.findRev( '/' ); |
642 | if ( sep > 0 ) | 642 | if ( sep > 0 ) |
643 | name = name.mid( sep+1 ); | 643 | name = name.mid( sep+1 ); |
644 | updateCaption( name ); | 644 | updateCaption( name ); |
645 | } | 645 | } |
646 | 646 | ||
647 | void TextEdit::openFile( const DocLnk &f ) | 647 | void TextEdit::openFile( const DocLnk &f ) |
648 | { | 648 | { |
649 | // clear(); | 649 | // clear(); |
650 | bFromDocView = TRUE; | 650 | bFromDocView = TRUE; |
651 | FileManager fm; | 651 | FileManager fm; |
652 | QString txt; | 652 | QString txt; |
653 | currentFileName=f.name(); | 653 | currentFileName=f.name(); |
654 | qDebug("openFile doclnk " + currentFileName); | 654 | qDebug("openFile doclnk " + currentFileName); |
655 | if ( !fm.loadFile( f, txt ) ) { | 655 | if ( !fm.loadFile( f, txt ) ) { |
656 | // ####### could be a new file | 656 | // ####### could be a new file |
657 | qDebug( "Cannot open file" ); | 657 | qDebug( "Cannot open file" ); |
658 | 658 | ||
659 | //return; | 659 | //return; |
660 | } | 660 | } |
661 | 661 | ||
662 | fileNew(); | 662 | fileNew(); |
663 | if ( doc ) | 663 | if ( doc ) |
664 | delete doc; | 664 | delete doc; |
665 | doc = new DocLnk(f); | 665 | doc = new DocLnk(f); |
666 | editor->setText(txt); | 666 | editor->setText(txt); |
667 | editor->setEdited( FALSE); | 667 | editor->setEdited( FALSE); |
668 | edited1=FALSE; | 668 | edited1=FALSE; |
669 | edited=FALSE; | 669 | edited=FALSE; |
670 | 670 | ||
671 | qDebug("openFile doclnk "+currentFileName); | 671 | qDebug("openFile doclnk "+currentFileName); |
672 | doc->setName(currentFileName); | 672 | doc->setName(currentFileName); |
673 | updateCaption(); | 673 | updateCaption(); |
674 | } | 674 | } |
675 | 675 | ||
676 | void TextEdit::showEditTools() | 676 | void TextEdit::showEditTools() |
677 | { | 677 | { |
678 | // if ( !doc ) | 678 | // if ( !doc ) |
679 | // close(); | 679 | // close(); |
680 | // clear(); | 680 | // clear(); |
681 | menu->show(); | 681 | menu->show(); |
682 | editBar->show(); | 682 | editBar->show(); |
683 | if ( searchVisible ) | 683 | if ( searchVisible ) |
684 | searchBar->show(); | 684 | searchBar->show(); |
685 | // updateCaption(); | 685 | // updateCaption(); |
686 | setWState (WState_Reserved1 ); | 686 | setWState (WState_Reserved1 ); |
687 | } | 687 | } |
688 | 688 | ||
689 | /*! | 689 | /*! |
690 | unprompted save */ | 690 | unprompted save */ |
691 | bool TextEdit::save() | 691 | bool TextEdit::save() |
692 | { | 692 | { |
693 | QString file = doc->file(); | 693 | QString file = doc->file(); |