summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp18
-rw-r--r--core/apps/textedit/textedit.cpp2
2 files changed, 15 insertions, 5 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
index eea7144..41e800c 100644
--- a/core/apps/textedit/fileBrowser.cpp
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -134,133 +134,143 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
134 134
135 connect( SelectionCombo, SIGNAL( activated( const QString & ) ), 135 connect( SelectionCombo, SIGNAL( activated( const QString & ) ),
136 this, SLOT( selectionChanged( const QString & ) ) ); 136 this, SLOT( selectionChanged( const QString & ) ) );
137 137
138 typemb = new MenuButton(this); 138 typemb = new MenuButton(this);
139 typemb->setLabel(tr("Type: %1")); 139 typemb->setLabel(tr("Type: %1"));
140 typemb->setMinimumWidth(110); 140 typemb->setMinimumWidth(110);
141 typemb->setFixedHeight(22); 141 typemb->setFixedHeight(22);
142 layout->addMultiCellWidget( typemb, 2, 2, 4, 7 ); 142 layout->addMultiCellWidget( typemb, 2, 2, 4, 7 );
143 updateMimeTypeMenu() ; 143 updateMimeTypeMenu() ;
144 144
145 currentDir.setPath(QDir::currentDirPath()); 145 currentDir.setPath(QDir::currentDirPath());
146 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); 146 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All);
147 147
148 populateList(); 148 populateList();
149 move(0,15); 149 move(0,15);
150} 150}
151 151
152fileBrowser::~fileBrowser() 152fileBrowser::~fileBrowser()
153{ 153{
154} 154}
155 155
156void fileBrowser::setFileView( int selection ) 156void fileBrowser::setFileView( int selection )
157{ 157{
158 SelectionCombo->setCurrentItem( selection ); 158 SelectionCombo->setCurrentItem( selection );
159 selectionChanged( SelectionCombo->currentText() ); 159 selectionChanged( SelectionCombo->currentText() );
160} 160}
161 161
162void fileBrowser::populateList() 162void fileBrowser::populateList()
163{ 163{
164 ListView->clear(); 164 ListView->clear();
165 bool isDir=FALSE; 165 bool isDir=FALSE;
166//qDebug(currentDir.canonicalPath()); 166//qDebug(currentDir.canonicalPath());
167 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 167 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
168 currentDir.setMatchAllDirs(TRUE); 168 currentDir.setMatchAllDirs(TRUE);
169 169
170 currentDir.setNameFilter(filterStr); 170 currentDir.setNameFilter(filterStr);
171// currentDir.setNameFilter("*.txt;*.etx"); 171// currentDir.setNameFilter("*.txt;*.etx");
172 QString fileL, fileS, fileDate; 172 QString fileL, fileS, fileDate;
173 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 173 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
174 QFileInfoListIterator it(*list); 174 QFileInfoListIterator it(*list);
175 QFileInfo *fi; 175 QFileInfo *fi;
176 while ( (fi=it.current()) ) { 176 while ( (fi=it.current()) ) {
177 177
178 if (fi->isSymLink() ){ 178 if (fi->isSymLink() ){
179 QString symLink=fi->readLink(); 179 QString symLink=fi->readLink();
180// qDebug("Symlink detected "+symLink); 180// qDebug("Symlink detected "+symLink);
181 QFileInfo sym( symLink); 181 QFileInfo sym( symLink);
182 fileS.sprintf( "%10li", sym.size() ); 182 fileS.sprintf( "%10li", sym.size() );
183 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 183 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
184 fileDate = sym.lastModified().toString(); 184 fileDate = sym.lastModified().toString();
185 } else { 185 } else {
186// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 186// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
187 fileS.sprintf( "%10li", fi->size() ); 187 fileS.sprintf( "%10li", fi->size() );
188 fileL.sprintf( "%s",fi->fileName().data() ); 188 fileL.sprintf( "%s",fi->fileName().data() );
189 fileDate= fi->lastModified().toString(); 189 fileDate= fi->lastModified().toString();
190 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 190 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
191 fileL+="/"; 191 fileL+="/";
192 isDir=TRUE; 192 isDir=TRUE;
193// qDebug( fileL); 193// qDebug( fileL);
194 } 194 }
195 } 195 }
196 if(fileL !="./") { 196 if(fileL !="./") {
197 item= new QListViewItem( ListView,fileL,fileS , fileDate); 197 item= new QListViewItem( ListView,fileL,fileS , fileDate);
198 if(isDir || fileL.find("/",0,TRUE) != -1) 198 QPixmap pm;
199 item->setPixmap( 0, Resource::loadPixmap( "folder" )); 199 pm= Resource::loadPixmap( "folder" );
200 else 200 if(isDir || fileL.find("/",0,TRUE) != -1)
201 item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); 201 item->setPixmap( 0,pm );
202 else
203 item->setPixmap( 0, Resource::loadPixmap( "fileopen" ));
204 if( fileL.find("->",0,TRUE) != -1) {
205 // overlay link image
206 QPixmap lnk = Resource::loadPixmap( "symlink" );
207 QPainter painter( &pm );
208 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
209 pm.setMask( pm.createHeuristicMask( FALSE ) );
210 item->setPixmap( 0, pm);
202 } 211 }
212 }
203 isDir=FALSE; 213 isDir=FALSE;
204 ++it; 214 ++it;
205 } 215 }
206 ListView->setSorting( 3, FALSE); 216 ListView->setSorting( 3, FALSE);
207 QString currentPath = currentDir.canonicalPath(); 217 QString currentPath = currentDir.canonicalPath();
208 218
209 fillCombo( (const QString &)currentPath); 219 fillCombo( (const QString &)currentPath);
210// dirPathCombo->lineEdit()->setText(currentPath); 220// dirPathCombo->lineEdit()->setText(currentPath);
211 221
212// if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 222// if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
213// dirPathCombo->clear(); 223// dirPathCombo->clear();
214// dirPathStringList.prepend(currentPath ); 224// dirPathStringList.prepend(currentPath );
215// dirPathCombo->insertStringList( dirPathStringList,-1); 225// dirPathCombo->insertStringList( dirPathStringList,-1);
216// } 226// }
217} 227}
218 228
219void fileBrowser::upDir() 229void fileBrowser::upDir()
220{ 230{
221 QString current = currentDir.canonicalPath(); 231 QString current = currentDir.canonicalPath();
222 QDir dir(current); 232 QDir dir(current);
223 dir.cdUp(); 233 dir.cdUp();
224 current = dir.canonicalPath(); 234 current = dir.canonicalPath();
225 chdir( current.latin1() ); 235 chdir( current.latin1() );
226 currentDir.cd( current, TRUE); 236 currentDir.cd( current, TRUE);
227 populateList(); 237 populateList();
228 update(); 238 update();
229} 239}
230 240
231// you may want to switch these 2 functions. I like single clicks 241// you may want to switch these 2 functions. I like single clicks
232void fileBrowser::listClicked(QListViewItem *selectedItem) 242void fileBrowser::listClicked(QListViewItem *selectedItem)
233{ 243{
234 QString strItem=selectedItem->text(0); 244 QString strItem=selectedItem->text(0);
235 QString strSize=selectedItem->text(1); 245 QString strSize=selectedItem->text(1);
236// qDebug("strItem is "+strItem); 246// qDebug("strItem is "+strItem);
237 strSize.stripWhiteSpace(); 247 strSize.stripWhiteSpace();
238// qDebug(strSize); 248// qDebug(strSize);
239 249
240 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 250 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
241 // is symlink 251 // is symlink
242 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); 252 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4);
243// qDebug("strItem symlink is "+strItem2); 253// qDebug("strItem symlink is "+strItem2);
244 if(QDir(strItem2).exists() ) { 254 if(QDir(strItem2).exists() ) {
245 currentDir.cd(strItem2, TRUE); 255 currentDir.cd(strItem2, TRUE);
246 populateList(); 256 populateList();
247 } 257 }
248 } else { // not a symlink 258 } else { // not a symlink
249 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 259 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
250 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 260 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
251 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 261 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
252 currentDir.cd(strItem,FALSE); 262 currentDir.cd(strItem,FALSE);
253// qDebug("Path is "+strItem); 263// qDebug("Path is "+strItem);
254 populateList(); 264 populateList();
255 } else { 265 } else {
256 currentDir.cdUp(); 266 currentDir.cdUp();
257 populateList(); 267 populateList();
258 } 268 }
259 if(QDir(strItem).exists()){ 269 if(QDir(strItem).exists()){
260 currentDir.cd(strItem, TRUE); 270 currentDir.cd(strItem, TRUE);
261 populateList(); 271 populateList();
262 } 272 }
263 } else { 273 } else {
264 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 274 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
265 if( QFile::exists(strItem ) ) { 275 if( QFile::exists(strItem ) ) {
266//currentDir.canonicalPath() 276//currentDir.canonicalPath()
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index da74893..ecebe12 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -317,129 +317,129 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
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
410void TextEdit::cleanUp() 410void 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
424TextEdit::~TextEdit() 424TextEdit::~TextEdit()
425{ 425{
426} 426}
427 427
428void TextEdit::zoomIn() 428void TextEdit::zoomIn()
429{ 429{
430 setFontSize(editor->font().pointSize()+1,FALSE); 430 setFontSize(editor->font().pointSize()+1,FALSE);
431} 431}
432 432
433void TextEdit::zoomOut() 433void TextEdit::zoomOut()
434{ 434{
435 setFontSize(editor->font().pointSize()-1,TRUE); 435 setFontSize(editor->font().pointSize()-1,TRUE);
436} 436}
437 437
438 438
439void TextEdit::setFontSize(int sz, bool round_down_not_up) 439void 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;