summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp2
-rw-r--r--core/apps/textedit/fileSaver.cpp2
-rw-r--r--core/apps/textedit/textedit.cpp4
3 files changed, 4 insertions, 4 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
index b029e5b..8c1e962 100644
--- a/core/apps/textedit/fileBrowser.cpp
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -1,180 +1,180 @@
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 <qpe/config.h> 15#include <qpe/config.h>
16#include <qpe/resource.h> 16#include <qpe/resource.h>
17 17
18#include <qlistview.h> 18#include <qlistview.h>
19#include <qpushbutton.h> 19#include <qpushbutton.h>
20#include <qfile.h> 20#include <qfile.h>
21#include <qmessagebox.h> 21#include <qmessagebox.h>
22#include <unistd.h> 22#include <unistd.h>
23 23
24fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter ) 24fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter )
25 : QDialog( parent, name, modal, fl ) 25 : QDialog( parent, name, modal, fl )
26{ 26{
27 if ( !name ) 27 if ( !name )
28 setName( "fileBrowser" ); 28 setName( "fileBrowser" );
29 resize( 240, 280 ); 29 resize( 240, 280 );
30 setCaption(tr( "Browse for file" ) ); 30 setCaption(tr( name ) );
31 filterStr=filter; 31 filterStr=filter;
32 32
33 dirLabel = new QLabel(this, "DirLabel"); 33 dirLabel = new QLabel(this, "DirLabel");
34 dirLabel->setText(currentDir.canonicalPath()); 34 dirLabel->setText(currentDir.canonicalPath());
35 dirLabel->setGeometry(10,20,230,15); 35 dirLabel->setGeometry(10,20,230,15);
36 36
37 QPushButton *homeButton; 37 QPushButton *homeButton;
38 homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton"); 38 homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton");
39 homeButton->setGeometry(200,4,25,25); 39 homeButton->setGeometry(200,4,25,25);
40 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); 40 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
41 41
42 ListView = new QListView( this, "ListView" ); 42 ListView = new QListView( this, "ListView" );
43 ListView->addColumn( tr( "Name" ) ); 43 ListView->addColumn( tr( "Name" ) );
44 ListView->setColumnWidth(0,140); 44 ListView->setColumnWidth(0,140);
45 ListView->setSorting( 2, FALSE); 45 ListView->setSorting( 2, FALSE);
46 ListView->addColumn( tr( "Size" ) ); 46 ListView->addColumn( tr( "Size" ) );
47 ListView->setColumnWidth(1,59); 47 ListView->setColumnWidth(1,59);
48// ListView->addColumn( tr( "" ) ); 48// ListView->addColumn( tr( "" ) );
49 ListView->setColumnWidthMode(0,QListView::Manual); 49 ListView->setColumnWidthMode(0,QListView::Manual);
50 ListView->setColumnAlignment(1,QListView::AlignRight); 50 ListView->setColumnAlignment(1,QListView::AlignRight);
51// ListView->setMultiSelection(true); 51// ListView->setMultiSelection(true);
52// ListView->setSelectionMode(QListView::Extended); 52// ListView->setSelectionMode(QListView::Extended);
53 53
54 ListView->setAllColumnsShowFocus( TRUE ); 54 ListView->setAllColumnsShowFocus( TRUE );
55 ListView->setGeometry( QRect( 10, 35, 220, 240 ) ); 55 ListView->setGeometry( QRect( 10, 35, 220, 240 ) );
56 56
57 // signals and slots connections 57 // signals and slots connections
58 connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); 58 connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) );
59 connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); 59 connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
60 currentDir.setPath(QDir::currentDirPath()); 60 currentDir.setPath(QDir::currentDirPath());
61 populateList(); 61 populateList();
62 move(0,15); 62 move(0,15);
63} 63}
64 64
65fileBrowser::~fileBrowser() 65fileBrowser::~fileBrowser()
66{ 66{
67} 67}
68 68
69 69
70void fileBrowser::populateList() 70void fileBrowser::populateList()
71{ 71{
72 ListView->clear(); 72 ListView->clear();
73//qDebug(currentDir.canonicalPath()); 73//qDebug(currentDir.canonicalPath());
74 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 74 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
75 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 75 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
76 currentDir.setMatchAllDirs(TRUE); 76 currentDir.setMatchAllDirs(TRUE);
77 77
78 currentDir.setNameFilter(filterStr); 78 currentDir.setNameFilter(filterStr);
79// currentDir.setNameFilter("*.txt;*.etx"); 79// currentDir.setNameFilter("*.txt;*.etx");
80 QString fileL, fileS; 80 QString fileL, fileS;
81 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 81 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
82 QFileInfoListIterator it(*list); 82 QFileInfoListIterator it(*list);
83 QFileInfo *fi; 83 QFileInfo *fi;
84 while ( (fi=it.current()) ) { 84 while ( (fi=it.current()) ) {
85 85
86 if (fi->isSymLink() ){ 86 if (fi->isSymLink() ){
87 QString symLink=fi->readLink(); 87 QString symLink=fi->readLink();
88// qDebug("Symlink detected "+symLink); 88// qDebug("Symlink detected "+symLink);
89 QFileInfo sym( symLink); 89 QFileInfo sym( symLink);
90 fileS.sprintf( "%10li", sym.size() ); 90 fileS.sprintf( "%10li", sym.size() );
91 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 91 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
92 92
93 } else { 93 } else {
94// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 94// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
95 fileS.sprintf( "%10li", fi->size() ); 95 fileS.sprintf( "%10li", fi->size() );
96 fileL.sprintf( "%s",fi->fileName().data() ); 96 fileL.sprintf( "%s",fi->fileName().data() );
97 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 97 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
98 fileL+="/"; 98 fileL+="/";
99// qDebug( fileL); 99// qDebug( fileL);
100 } 100 }
101 } 101 }
102 item= new QListViewItem( ListView,fileL,fileS ); 102 item= new QListViewItem( ListView,fileL,fileS );
103 ++it; 103 ++it;
104 } 104 }
105 ListView->setSorting( 2, FALSE); 105 ListView->setSorting( 2, FALSE);
106 dirLabel->setText(currentDir.canonicalPath()); 106 dirLabel->setText(currentDir.canonicalPath());
107} 107}
108 108
109void fileBrowser::upDir() 109void fileBrowser::upDir()
110{ 110{
111// qDebug(currentDir.canonicalPath()); 111// qDebug(currentDir.canonicalPath());
112} 112}
113 113
114void fileBrowser::listDoubleClicked(QListViewItem *selectedItem) 114void fileBrowser::listDoubleClicked(QListViewItem *selectedItem)
115{ 115{
116} 116}
117 117
118// you may want to switch these 2 functions. I like single clicks 118// you may want to switch these 2 functions. I like single clicks
119void fileBrowser::listClicked(QListViewItem *selectedItem) 119void fileBrowser::listClicked(QListViewItem *selectedItem)
120{ 120{
121 QString strItem=selectedItem->text(0); 121 QString strItem=selectedItem->text(0);
122 QString strSize=selectedItem->text(1); 122 QString strSize=selectedItem->text(1);
123// qDebug("strItem is "+strItem); 123// qDebug("strItem is "+strItem);
124 strSize.stripWhiteSpace(); 124 strSize.stripWhiteSpace();
125// qDebug(strSize); 125// qDebug(strSize);
126 126
127 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 127 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
128 // is symlink 128 // is symlink
129 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); 129 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4);
130// qDebug("strItem symlink is "+strItem2); 130// qDebug("strItem symlink is "+strItem2);
131 if(QDir(strItem2).exists() ) { 131 if(QDir(strItem2).exists() ) {
132 currentDir.cd(strItem2, TRUE); 132 currentDir.cd(strItem2, TRUE);
133 populateList(); 133 populateList();
134 } 134 }
135 } else { // not a symlink 135 } else { // not a symlink
136 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 136 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
137 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 137 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
138 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 138 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
139 currentDir.cd(strItem,FALSE); 139 currentDir.cd(strItem,FALSE);
140// qDebug("Path is "+strItem); 140// qDebug("Path is "+strItem);
141 populateList(); 141 populateList();
142 } else { 142 } else {
143 currentDir.cdUp(); 143 currentDir.cdUp();
144 populateList(); 144 populateList();
145 } 145 }
146 if(QDir(strItem).exists()){ 146 if(QDir(strItem).exists()){
147 currentDir.cd(strItem, TRUE); 147 currentDir.cd(strItem, TRUE);
148 populateList(); 148 populateList();
149 } 149 }
150 } else { 150 } else {
151 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 151 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
152 if( QFile::exists(strItem ) ) { 152 if( QFile::exists(strItem ) ) {
153//currentDir.canonicalPath() 153//currentDir.canonicalPath()
154 qDebug("We found our files!!"+strItem); 154 qDebug("We found our files!!"+strItem);
155 OnOK(); 155 OnOK();
156 } 156 }
157 } //end not symlink 157 } //end not symlink
158 chdir(strItem.latin1()); 158 chdir(strItem.latin1());
159 } 159 }
160} 160}
161 161
162void fileBrowser::OnOK() 162void fileBrowser::OnOK()
163{ 163{
164 QListViewItemIterator it1( ListView); 164 QListViewItemIterator it1( ListView);
165 for ( ; it1.current(); ++it1 ) { 165 for ( ; it1.current(); ++it1 ) {
166 if ( it1.current()->isSelected() ) { 166 if ( it1.current()->isSelected() ) {
167 selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); 167 selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0));
168 qDebug("selected filename is "+selectedFileName); 168 qDebug("selected filename is "+selectedFileName);
169 fileList.append( selectedFileName ); 169 fileList.append( selectedFileName );
170 } 170 }
171 } 171 }
172 accept(); 172 accept();
173} 173}
174 174
175void fileBrowser::homeButtonPushed() { 175void fileBrowser::homeButtonPushed() {
176 chdir( QDir::homeDirPath().latin1() ); 176 chdir( QDir::homeDirPath().latin1() );
177 currentDir.cd( QDir::homeDirPath(), TRUE); 177 currentDir.cd( QDir::homeDirPath(), TRUE);
178 populateList(); 178 populateList();
179 update(); 179 update();
180} 180}
diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp
index f3be914..d78f2e8 100644
--- a/core/apps/textedit/fileSaver.cpp
+++ b/core/apps/textedit/fileSaver.cpp
@@ -1,202 +1,202 @@
1/**************************************************************************** 1/****************************************************************************
2** copyright 2001 ljp ljp@llornkcor.com 2** copyright 2001 ljp ljp@llornkcor.com
3** Created: Fri Dec 14 08:16:46 2001 fileSaver.cpp 3** Created: Fri Dec 14 08:16:46 2001 fileSaver.cpp
4** 4**
5** This file may be distributed and/or modified under the terms of the 5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13****************************************************************************/ 13****************************************************************************/
14#include "fileSaver.h" 14#include "fileSaver.h"
15#include <qpe/config.h> 15#include <qpe/config.h>
16#include <qpe/resource.h> 16#include <qpe/resource.h>
17 17
18#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
19#include <qlistview.h> 19#include <qlistview.h>
20#include <qpushbutton.h> 20#include <qpushbutton.h>
21#include <qfile.h> 21#include <qfile.h>
22#include <qmessagebox.h> 22#include <qmessagebox.h>
23#include <qlineedit.h> 23#include <qlineedit.h>
24#include <qcheckbox.h> 24#include <qcheckbox.h>
25 25
26#include <unistd.h> 26#include <unistd.h>
27 27
28fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName ) 28fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName )
29 : QDialog( parent, name, modal, fl ) 29 : QDialog( parent, name, modal, fl )
30{ 30{
31 if ( !name ) 31 if ( !name )
32 setName( "fileSaver" ); 32 setName( "fileSaver" );
33 resize( 240, 280 ); 33 resize( 240, 280 );
34 setCaption(tr( "Save file" ) ); 34 setCaption(tr( name ) );
35 QFileInfo fi(currentFileName); 35 QFileInfo fi(currentFileName);
36 QString tmpFileName=fi.fileName(); 36 QString tmpFileName=fi.fileName();
37// qDebug( tmpFileName); 37// qDebug( tmpFileName);
38 dirLabel = new QLabel(this, "DirLabel"); 38 dirLabel = new QLabel(this, "DirLabel");
39 dirLabel->setText(currentDir.canonicalPath()); 39 dirLabel->setText(currentDir.canonicalPath());
40 dirLabel->setGeometry(10,20,230,15); 40 dirLabel->setGeometry(10,20,230,15);
41 41
42 QPushButton *homeButton; 42 QPushButton *homeButton;
43 homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton"); 43 homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton");
44 homeButton->setGeometry(200,4,25,25); 44 homeButton->setGeometry(200,4,25,25);
45 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); 45 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
46 46
47 ListView = new QListView( this, "ListView" ); 47 ListView = new QListView( this, "ListView" );
48 ListView->addColumn( tr( "Name" ) ); 48 ListView->addColumn( tr( "Name" ) );
49 ListView->setColumnWidth(0,140); 49 ListView->setColumnWidth(0,140);
50 ListView->setSorting( 2, FALSE); 50 ListView->setSorting( 2, FALSE);
51 ListView->addColumn( tr( "Size" ) ); 51 ListView->addColumn( tr( "Size" ) );
52 ListView->setColumnWidth(1,59); 52 ListView->setColumnWidth(1,59);
53 ListView->setColumnWidthMode(0,QListView::Manual); 53 ListView->setColumnWidthMode(0,QListView::Manual);
54 ListView->setColumnAlignment(1,QListView::AlignRight); 54 ListView->setColumnAlignment(1,QListView::AlignRight);
55// ListView->setMultiSelection(true); 55// ListView->setMultiSelection(true);
56// ListView->setSelectionMode(QListView::Extended); 56// ListView->setSelectionMode(QListView::Extended);
57 57
58 ListView->setAllColumnsShowFocus( TRUE ); 58 ListView->setAllColumnsShowFocus( TRUE );
59 ListView->setGeometry( QRect( 10,35,220,125)); 59 ListView->setGeometry( QRect( 10,35,220,125));
60 60
61 fileEdit= new QLineEdit(this); 61 fileEdit= new QLineEdit(this);
62 fileEdit->setGeometry( QRect( 10, 162, 205, 17)); 62 fileEdit->setGeometry( QRect( 10, 162, 205, 17));
63 63
64 fileEdit->setText( tmpFileName); 64 fileEdit->setText( tmpFileName);
65 65
66 filePermCheck = new QCheckBox( this, "SetFilePerms" ); 66 filePermCheck = new QCheckBox( this, "SetFilePerms" );
67 filePermCheck->setText("set file permissions"); 67 filePermCheck->setText("set file permissions");
68 filePermCheck->setGeometry(10, 178, 150,17); 68 filePermCheck->setGeometry(10, 178, 150,17);
69 // signals and slots connections 69 // signals and slots connections
70 connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); 70 connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) );
71 connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); 71 connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
72 72
73// tmpFileName=fi.FilePath(); 73// tmpFileName=fi.FilePath();
74// qDebug( tmpFileName); 74// qDebug( tmpFileName);
75 currentDir.setPath( QDir::currentDirPath() ); 75 currentDir.setPath( QDir::currentDirPath() );
76 populateList(); 76 populateList();
77 move(0,15); 77 move(0,15);
78 78
79} 79}
80 80
81fileSaver::~fileSaver() 81fileSaver::~fileSaver()
82{ 82{
83} 83}
84 84
85void fileSaver::populateList() 85void fileSaver::populateList()
86{ 86{
87 ListView->clear(); 87 ListView->clear();
88 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden ); 88 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden );
89 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 89 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
90 currentDir.setMatchAllDirs(TRUE); 90 currentDir.setMatchAllDirs(TRUE);
91 91
92 currentDir.setNameFilter("*"); 92 currentDir.setNameFilter("*");
93 QString fileL, fileS; 93 QString fileL, fileS;
94 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 94 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
95 QFileInfoListIterator it(*list); 95 QFileInfoListIterator it(*list);
96 QFileInfo *fi; 96 QFileInfo *fi;
97 while ( (fi=it.current()) ) { 97 while ( (fi=it.current()) ) {
98 98
99 if (fi->isSymLink() ){ 99 if (fi->isSymLink() ){
100 QString symLink=fi->readLink(); 100 QString symLink=fi->readLink();
101// qDebug("Symlink detected "+symLink); 101// qDebug("Symlink detected "+symLink);
102 QFileInfo sym( symLink); 102 QFileInfo sym( symLink);
103 fileS.sprintf( "%10li", sym.size() ); 103 fileS.sprintf( "%10li", sym.size() );
104 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 104 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
105 105
106 } else { 106 } else {
107// // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 107// // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
108 fileS.sprintf( "%10li", fi->size() ); 108 fileS.sprintf( "%10li", fi->size() );
109 fileL.sprintf( "%s",fi->fileName().data() ); 109 fileL.sprintf( "%s",fi->fileName().data() );
110 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 110 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
111 fileL+="/"; 111 fileL+="/";
112// qDebug(currentDir.canonicalPath()+fileL); 112// qDebug(currentDir.canonicalPath()+fileL);
113 } 113 }
114 } 114 }
115 item= new QListViewItem( ListView,fileL,fileS ); 115 item= new QListViewItem( ListView,fileL,fileS );
116 ++it; 116 ++it;
117 } 117 }
118 ListView->setSorting( 2, FALSE); 118 ListView->setSorting( 2, FALSE);
119 dirLabel->setText(currentDir.canonicalPath()); 119 dirLabel->setText(currentDir.canonicalPath());
120 120
121 121
122} 122}
123 123
124void fileSaver::upDir() 124void fileSaver::upDir()
125{ 125{
126// qDebug(currentDir.canonicalPath()); 126// qDebug(currentDir.canonicalPath());
127} 127}
128 128
129void fileSaver::listDoubleClicked(QListViewItem *selectedItem) 129void fileSaver::listDoubleClicked(QListViewItem *selectedItem)
130{ 130{
131} 131}
132 132
133void fileSaver::listClicked(QListViewItem *selectedItem) 133void fileSaver::listClicked(QListViewItem *selectedItem)
134{ 134{
135 QString strItem=selectedItem->text(0); 135 QString strItem=selectedItem->text(0);
136 QString strSize=selectedItem->text(1); 136 QString strSize=selectedItem->text(1);
137// qDebug("strItem is "+strItem); 137// qDebug("strItem is "+strItem);
138 strSize.stripWhiteSpace(); 138 strSize.stripWhiteSpace();
139// qDebug(strSize); 139// qDebug(strSize);
140 140
141 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 141 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
142 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); 142 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4);
143// qDebug("strItem symlink is "+strItem2); 143// qDebug("strItem symlink is "+strItem2);
144 if(QDir(strItem2).exists() ) { 144 if(QDir(strItem2).exists() ) {
145 currentDir.cd(strItem2, TRUE); 145 currentDir.cd(strItem2, TRUE);
146 populateList(); 146 populateList();
147 } 147 }
148 } else { // not a symlink 148 } else { // not a symlink
149 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 149 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
150 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 150 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
151 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 151 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
152 currentDir.cd(strItem,FALSE); 152 currentDir.cd(strItem,FALSE);
153// qDebug("Path is "+strItem); 153// qDebug("Path is "+strItem);
154 populateList(); 154 populateList();
155 } else { 155 } else {
156 currentDir.cdUp(); 156 currentDir.cdUp();
157 populateList(); 157 populateList();
158 } 158 }
159 if(QDir(strItem).exists()){ 159 if(QDir(strItem).exists()){
160 currentDir.cd(strItem, TRUE); 160 currentDir.cd(strItem, TRUE);
161 populateList(); 161 populateList();
162 } 162 }
163 } // else 163 } // else
164// if( QFile::exists(strItem ) ) { 164// if( QFile::exists(strItem ) ) {
165// qDebug("We found our files!!"); 165// qDebug("We found our files!!");
166 166
167// OnOK(); 167// OnOK();
168 } //end not symlink 168 } //end not symlink
169 chdir(strItem.latin1()); 169 chdir(strItem.latin1());
170 170
171 171
172} 172}
173 173
174 174
175void fileSaver::closeEvent( QCloseEvent *e ) 175void fileSaver::closeEvent( QCloseEvent *e )
176{ 176{
177 if(e->isAccepted()) { 177 if(e->isAccepted()) {
178 e->accept(); 178 e->accept();
179 } else { 179 } else {
180 qDebug("not accepted"); 180 qDebug("not accepted");
181 done(-1); 181 done(-1);
182 } 182 }
183} 183}
184 184
185void fileSaver::accept() { 185void fileSaver::accept() {
186 selectedFileName = fileEdit->text(); 186 selectedFileName = fileEdit->text();
187 QString path = currentDir.canonicalPath()+"/" + selectedFileName; 187 QString path = currentDir.canonicalPath()+"/" + selectedFileName;
188 if( path.find("//",0,TRUE) ==-1 ) { 188 if( path.find("//",0,TRUE) ==-1 ) {
189 selectedFileName = path; 189 selectedFileName = path;
190 } else { 190 } else {
191 selectedFileName = currentDir.canonicalPath()+selectedFileName; 191 selectedFileName = currentDir.canonicalPath()+selectedFileName;
192 } 192 }
193 qDebug("going to save "+selectedFileName); 193 qDebug("going to save "+selectedFileName);
194 done(1); 194 done(1);
195} 195}
196 196
197void fileSaver::homeButtonPushed() { 197void fileSaver::homeButtonPushed() {
198 chdir( QDir::homeDirPath().latin1() ); 198 chdir( QDir::homeDirPath().latin1() );
199 currentDir.cd( QDir::homeDirPath(), TRUE); 199 currentDir.cd( QDir::homeDirPath(), TRUE);
200 populateList(); 200 populateList();
201 update(); 201 update();
202} 202}
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 72cc4d1..f138572 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -143,757 +143,757 @@ static char * filesave_xpm[] = {
143" #34-55;;;;678$+", 143" #34-55;;;;678$+",
144" 90ab=c;dd;e1fg ", 144" 90ab=c;dd;e1fg ",
145" [ahij((kbl0mn$ ", 145" [ahij((kbl0mn$ ",
146" op^q^^7r&]s/$+ ", 146" op^q^^7r&]s/$+ ",
147"@btu;vbwxy]zAB ", 147"@btu;vbwxy]zAB ",
148"CzDEvEv;;DssF$ ", 148"CzDEvEv;;DssF$ ",
149"G.H{E{E{IxsJ$+ ", 149"G.H{E{E{IxsJ$+ ",
150" +...vEKxzLM ", 150" +...vEKxzLM ",
151" +...z]n$ ", 151" +...z]n$ ",
152" +... "}; 152" +... "};
153 153
154 154
155#if QT_VERSION < 300 155#if QT_VERSION < 300
156 156
157class QpeEditor : public QMultiLineEdit 157class QpeEditor : public QMultiLineEdit
158{ 158{
159 // Q_OBJECT 159 // Q_OBJECT
160public: 160public:
161 QpeEditor( QWidget *parent, const char * name = 0 ) 161 QpeEditor( QWidget *parent, const char * name = 0 )
162 : QMultiLineEdit( parent, name ) 162 : QMultiLineEdit( parent, name )
163 { 163 {
164 clearTableFlags(); 164 clearTableFlags();
165 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); 165 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar );
166 } 166 }
167 167
168 //public slots: 168 //public slots:
169 void find( const QString &txt, bool caseSensitive, 169 void find( const QString &txt, bool caseSensitive,
170 bool backwards ); 170 bool backwards );
171 /* 171 /*
172signals: 172signals:
173 void notFound(); 173 void notFound();
174 void searchWrapped(); 174 void searchWrapped();
175 */ 175 */
176 176
177private: 177private:
178 178
179}; 179};
180 180
181 181
182void QpeEditor::find ( const QString &txt, bool caseSensitive, 182void QpeEditor::find ( const QString &txt, bool caseSensitive,
183 bool backwards ) 183 bool backwards )
184{ 184{
185 static bool wrap = FALSE; 185 static bool wrap = FALSE;
186 int line, col; 186 int line, col;
187 if ( wrap ) { 187 if ( wrap ) {
188 if ( !backwards ) 188 if ( !backwards )
189 line = col = 0; 189 line = col = 0;
190 wrap = FALSE; 190 wrap = FALSE;
191 // emit searchWrapped(); 191 // emit searchWrapped();
192 } else { 192 } else {
193 getCursorPosition( &line, &col ); 193 getCursorPosition( &line, &col );
194 } 194 }
195 //ignore backwards for now.... 195 //ignore backwards for now....
196 if ( !backwards ) { 196 if ( !backwards ) {
197 for ( ; ; ) { 197 for ( ; ; ) {
198 if ( line >= numLines() ) { 198 if ( line >= numLines() ) {
199 wrap = TRUE; 199 wrap = TRUE;
200 //emit notFound(); 200 //emit notFound();
201 break; 201 break;
202 } 202 }
203 int findCol = getString( line )->find( txt, col, caseSensitive ); 203 int findCol = getString( line )->find( txt, col, caseSensitive );
204 if ( findCol >= 0 ) { 204 if ( findCol >= 0 ) {
205 setCursorPosition( line, findCol, FALSE ); 205 setCursorPosition( line, findCol, FALSE );
206 col = findCol + txt.length(); 206 col = findCol + txt.length();
207 setCursorPosition( line, col, TRUE ); 207 setCursorPosition( line, col, TRUE );
208 208
209 //found = TRUE; 209 //found = TRUE;
210 break; 210 break;
211 } 211 }
212 line++; 212 line++;
213 col = 0; 213 col = 0;
214 } 214 }
215 215
216 } 216 }
217 217
218} 218}
219 219
220 220
221#else 221#else
222 222
223#error "Must make a QpeEditor that inherits QTextEdit" 223#error "Must make a QpeEditor that inherits QTextEdit"
224 224
225#endif 225#endif
226 226
227 227
228 228
229 229
230static int u_id = 1; 230static int u_id = 1;
231static int get_unique_id() 231static int get_unique_id()
232{ 232{
233 return u_id++; 233 return u_id++;
234} 234}
235 235
236static const int nfontsizes = 6; 236static const int nfontsizes = 6;
237static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; 237static const int fontsize[nfontsizes] = {8,10,12,14,18,24};
238 238
239TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) 239TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
240 : QMainWindow( parent, name, f ), bFromDocView( FALSE ) 240 : QMainWindow( parent, name, f ), bFromDocView( FALSE )
241{ 241{
242 doc = 0; 242 doc = 0;
243 243
244 setToolBarsMovable( FALSE ); 244 setToolBarsMovable( FALSE );
245 245
246 setIcon( Resource::loadPixmap( "TextEditor" ) ); 246 setIcon( Resource::loadPixmap( "TextEditor" ) );
247 247
248 QPEToolBar *bar = new QPEToolBar( this ); 248 QPEToolBar *bar = new QPEToolBar( this );
249 bar->setHorizontalStretchable( TRUE ); 249 bar->setHorizontalStretchable( TRUE );
250 menu = bar; 250 menu = bar;
251 251
252 QPEMenuBar *mb = new QPEMenuBar( bar ); 252 QPEMenuBar *mb = new QPEMenuBar( bar );
253 QPopupMenu *file = new QPopupMenu( this ); 253 QPopupMenu *file = new QPopupMenu( this );
254 QPopupMenu *edit = new QPopupMenu( this ); 254 QPopupMenu *edit = new QPopupMenu( this );
255 QPopupMenu *font = new QPopupMenu( this ); 255 QPopupMenu *font = new QPopupMenu( this );
256 256
257 bar = new QPEToolBar( this ); 257 bar = new QPEToolBar( this );
258 editBar = bar; 258 editBar = bar;
259 259
260 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 260 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
261 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 261 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
262 a->addTo( bar ); 262 a->addTo( bar );
263 a->addTo( file ); 263 a->addTo( file );
264 264
265 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 265 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
266 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 266 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
267// a->addTo( bar ); 267// a->addTo( bar );
268 a->addTo( file ); 268 a->addTo( file );
269 269
270 a = new QAction( tr( "Browse" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 270 a = new QAction( tr( "Browse" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
271 connect( a, SIGNAL( activated() ), this, SLOT( newFileOpen() ) ); 271 connect( a, SIGNAL( activated() ), this, SLOT( newFileOpen() ) );
272 a->addTo( bar ); 272 a->addTo( bar );
273 a->addTo( file ); 273 a->addTo( file );
274 274
275 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); 275 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
276 connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); 276 connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
277// a->addTo( bar ); 277// a->addTo( bar );
278 file->insertSeparator(); 278 file->insertSeparator();
279 a->addTo( file ); 279 a->addTo( file );
280 280
281 a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); 281 a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
282 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); 282 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) );
283 a->addTo( file ); 283 a->addTo( file );
284 284
285 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); 285 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 );
286 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 286 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
287 a->addTo( editBar ); 287 a->addTo( editBar );
288 a->addTo( edit ); 288 a->addTo( edit );
289 289
290 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); 290 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 );
291 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); 291 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
292 a->addTo( editBar ); 292 a->addTo( editBar );
293 a->addTo( edit ); 293 a->addTo( edit );
294 294
295 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 295 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
296 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); 296 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
297 a->addTo( editBar ); 297 a->addTo( editBar );
298 a->addTo( edit ); 298 a->addTo( edit );
299 299
300 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 300 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
301 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); 301 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) );
302 edit->insertSeparator(); 302 edit->insertSeparator();
303 a->addTo( bar ); 303 a->addTo( bar );
304 a->addTo( edit ); 304 a->addTo( edit );
305 305
306 306
307 int defsize; 307 int defsize;
308 bool defb, defi, wrap; 308 bool defb, defi, wrap;
309 309
310 Config cfg("TextEdit"); 310 Config cfg("TextEdit");
311 cfg.setGroup("View"); 311 cfg.setGroup("View");
312 defsize = cfg.readNumEntry("FontSize",10); 312 defsize = cfg.readNumEntry("FontSize",10);
313 defb = cfg.readBoolEntry("Bold",FALSE); 313 defb = cfg.readBoolEntry("Bold",FALSE);
314 defi = cfg.readBoolEntry("Italic",FALSE); 314 defi = cfg.readBoolEntry("Italic",FALSE);
315 wrap = cfg.readBoolEntry("Wrap",TRUE); 315 wrap = cfg.readBoolEntry("Wrap",TRUE);
316 316
317 zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); 317 zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 );
318 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); 318 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) );
319 zin->addTo( font ); 319 zin->addTo( font );
320 320
321 zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); 321 zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 );
322 connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); 322 connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) );
323 zout->addTo( font ); 323 zout->addTo( font );
324 324
325 font->insertSeparator(); 325 font->insertSeparator();
326 326
327#if 0 327#if 0
328 QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); 328 QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 );
329 connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); 329 connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) );
330 ba->setToggleAction(TRUE); 330 ba->setToggleAction(TRUE);
331 ba->addTo( font ); 331 ba->addTo( font );
332 332
333 QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); 333 QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 );
334 connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); 334 connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) );
335 ia->setToggleAction(TRUE); 335 ia->setToggleAction(TRUE);
336 ia->addTo( font ); 336 ia->addTo( font );
337 337
338 ba->setOn(defb); 338 ba->setOn(defb);
339 ia->setOn(defi); 339 ia->setOn(defi);
340 340
341 font->insertSeparator(); 341 font->insertSeparator();
342#endif 342#endif
343 343
344 QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); 344 QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 );
345 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); 345 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) );
346 wa->setToggleAction(TRUE); 346 wa->setToggleAction(TRUE);
347 wa->addTo( font ); 347 wa->addTo( font );
348 348
349 font->insertSeparator(); 349 font->insertSeparator();
350 font->insertItem("Font", this, SLOT(changeFont()) ); 350 font->insertItem("Font", this, SLOT(changeFont()) );
351 351
352 mb->insertItem( tr( "File" ), file ); 352 mb->insertItem( tr( "File" ), file );
353 mb->insertItem( tr( "Edit" ), edit ); 353 mb->insertItem( tr( "Edit" ), edit );
354 mb->insertItem( tr( "View" ), font ); 354 mb->insertItem( tr( "View" ), font );
355 355
356 searchBar = new QPEToolBar(this); 356 searchBar = new QPEToolBar(this);
357 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); 357 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE );
358 358
359 searchBar->setHorizontalStretchable( TRUE ); 359 searchBar->setHorizontalStretchable( TRUE );
360 360
361 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 361 searchEdit = new QLineEdit( searchBar, "searchEdit" );
362 searchBar->setStretchableWidget( searchEdit ); 362 searchBar->setStretchableWidget( searchEdit );
363 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 363 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
364 this, SLOT( search() ) ); 364 this, SLOT( search() ) );
365 365
366 366
367 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); 367 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 );
368 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 368 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
369 a->addTo( searchBar ); 369 a->addTo( searchBar );
370 a->addTo( edit ); 370 a->addTo( edit );
371 371
372 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 372 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
373 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 373 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
374 a->addTo( searchBar ); 374 a->addTo( searchBar );
375 375
376 edit->insertSeparator(); 376 edit->insertSeparator();
377 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 377 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
378 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); 378 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) );
379 a->addTo( edit ); 379 a->addTo( edit );
380 380
381 searchBar->hide(); 381 searchBar->hide();
382 382
383 editorStack = new QWidgetStack( this ); 383 editorStack = new QWidgetStack( this );
384 setCentralWidget( editorStack ); 384 setCentralWidget( editorStack );
385 385
386 searchVisible = FALSE; 386 searchVisible = FALSE;
387 387
388 fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //buggy 388 fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //buggy
389 connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); 389 connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) );
390 connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 390 connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
391 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) ); 391 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) );
392// fileOpen(); 392// fileOpen();
393 393
394 editor = new QpeEditor( editorStack ); 394 editor = new QpeEditor( editorStack );
395 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 395 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
396 editorStack->addWidget( editor, get_unique_id() ); 396 editorStack->addWidget( editor, get_unique_id() );
397 397
398 resize( 200, 300 ); 398 resize( 200, 300 );
399 399
400// setFontSize(defsize,TRUE); 400// setFontSize(defsize,TRUE);
401 FontDatabase fdb; 401 FontDatabase fdb;
402 QFont defaultFont=editor->font(); 402 QFont defaultFont=editor->font();
403 QFontInfo fontInfo(defaultFont); 403 QFontInfo fontInfo(defaultFont);
404 404
405 cfg.setGroup("Font"); 405 cfg.setGroup("Font");
406 QString family = cfg.readEntry("Family", fontInfo.family()); 406 QString family = cfg.readEntry("Family", fontInfo.family());
407 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); 407 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
408 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); 408 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
409 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); 409 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
410 410
411 defaultFont = fdb.font(family,style,i_size,charSet); 411 defaultFont = fdb.font(family,style,i_size,charSet);
412 editor->setFont( defaultFont); 412 editor->setFont( defaultFont);
413 413
414 wa->setOn(wrap); 414 wa->setOn(wrap);
415 updateCaption(); 415 updateCaption();
416 416
417 fileNew(); 417 fileNew();
418} 418}
419 419
420TextEdit::~TextEdit() 420TextEdit::~TextEdit()
421{ 421{
422// save(); 422// save();
423 423
424 Config cfg("TextEdit"); 424 Config cfg("TextEdit");
425 cfg.setGroup("View"); 425 cfg.setGroup("View");
426 QFont f = editor->font(); 426 QFont f = editor->font();
427 cfg.writeEntry("FontSize",f.pointSize()); 427 cfg.writeEntry("FontSize",f.pointSize());
428 cfg.writeEntry("Bold",f.bold()); 428 cfg.writeEntry("Bold",f.bold());
429 cfg.writeEntry("Italic",f.italic()); 429 cfg.writeEntry("Italic",f.italic());
430 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); 430 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth);
431} 431}
432 432
433void TextEdit::zoomIn() 433void TextEdit::zoomIn()
434{ 434{
435 setFontSize(editor->font().pointSize()+1,FALSE); 435 setFontSize(editor->font().pointSize()+1,FALSE);
436} 436}
437 437
438void TextEdit::zoomOut() 438void TextEdit::zoomOut()
439{ 439{
440 setFontSize(editor->font().pointSize()-1,TRUE); 440 setFontSize(editor->font().pointSize()-1,TRUE);
441} 441}
442 442
443 443
444void TextEdit::setFontSize(int sz, bool round_down_not_up) 444void TextEdit::setFontSize(int sz, bool round_down_not_up)
445{ 445{
446 int s=10; 446 int s=10;
447 for (int i=0; i<nfontsizes; i++) { 447 for (int i=0; i<nfontsizes; i++) {
448 if ( fontsize[i] == sz ) { 448 if ( fontsize[i] == sz ) {
449 s = sz; 449 s = sz;
450 break; 450 break;
451 } else if ( round_down_not_up ) { 451 } else if ( round_down_not_up ) {
452 if ( fontsize[i] < sz ) 452 if ( fontsize[i] < sz )
453 s = fontsize[i]; 453 s = fontsize[i];
454 } else { 454 } else {
455 if ( fontsize[i] > sz ) { 455 if ( fontsize[i] > sz ) {
456 s = fontsize[i]; 456 s = fontsize[i];
457 break; 457 break;
458 } 458 }
459 } 459 }
460 } 460 }
461 461
462 QFont f = editor->font(); 462 QFont f = editor->font();
463 f.setPointSize(s); 463 f.setPointSize(s);
464 editor->setFont(f); 464 editor->setFont(f);
465 465
466 zin->setEnabled(s != fontsize[nfontsizes-1]); 466 zin->setEnabled(s != fontsize[nfontsizes-1]);
467 zout->setEnabled(s != fontsize[0]); 467 zout->setEnabled(s != fontsize[0]);
468} 468}
469 469
470void TextEdit::setBold(bool y) 470void TextEdit::setBold(bool y)
471{ 471{
472 QFont f = editor->font(); 472 QFont f = editor->font();
473 f.setBold(y); 473 f.setBold(y);
474 editor->setFont(f); 474 editor->setFont(f);
475} 475}
476 476
477void TextEdit::setItalic(bool y) 477void TextEdit::setItalic(bool y)
478{ 478{
479 QFont f = editor->font(); 479 QFont f = editor->font();
480 f.setItalic(y); 480 f.setItalic(y);
481 editor->setFont(f); 481 editor->setFont(f);
482} 482}
483 483
484void TextEdit::setWordWrap(bool y) 484void TextEdit::setWordWrap(bool y)
485{ 485{
486 bool state = editor->edited(); 486 bool state = editor->edited();
487 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); 487 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
488 editor->setEdited( state ); 488 editor->setEdited( state );
489} 489}
490 490
491void TextEdit::fileNew() 491void TextEdit::fileNew()
492{ 492{
493 if( !bFromDocView ) { 493 if( !bFromDocView ) {
494 saveAs(); 494 saveAs();
495 } 495 }
496 newFile(DocLnk()); 496 newFile(DocLnk());
497} 497}
498 498
499void TextEdit::fileOpen() 499void TextEdit::fileOpen()
500{ 500{
501// if ( !save() ) { 501// if ( !save() ) {
502// if ( QMessageBox::critical( this, tr( "Out of space" ), 502// if ( QMessageBox::critical( this, tr( "Out of space" ),
503// tr( "Text Editor was unable to\n" 503// tr( "Text Editor was unable to\n"
504// "save your changes.\n" 504// "save your changes.\n"
505// "Free some space and try again.\n" 505// "Free some space and try again.\n"
506// "\nContinue anyway?" ), 506// "\nContinue anyway?" ),
507// QMessageBox::Yes|QMessageBox::Escape, 507// QMessageBox::Yes|QMessageBox::Escape,
508// QMessageBox::No|QMessageBox::Default ) 508// QMessageBox::No|QMessageBox::Default )
509// != QMessageBox::Yes ) 509// != QMessageBox::Yes )
510// return; 510// return;
511// else { 511// else {
512// delete doc; 512// delete doc;
513// doc = 0; 513// doc = 0;
514// } 514// }
515// } 515// }
516 menu->hide(); 516 menu->hide();
517 editBar->hide(); 517 editBar->hide();
518 searchBar->hide(); 518 searchBar->hide();
519 clearWState (WState_Reserved1 ); 519 clearWState (WState_Reserved1 );
520 editorStack->raiseWidget( fileSelector ); 520 editorStack->raiseWidget( fileSelector );
521 fileSelector->reread(); 521 fileSelector->reread();
522 updateCaption(); 522 updateCaption();
523} 523}
524 524
525void TextEdit::newFileOpen() 525void TextEdit::newFileOpen()
526{ 526{
527 browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*"); 527 browseForFiles=new fileBrowser(this,"Open File",TRUE,0, "*");
528 if( browseForFiles->exec() != -1 ) { 528 if( browseForFiles->exec() != -1 ) {
529 QString selFile= browseForFiles->selectedFileName; 529 QString selFile= browseForFiles->selectedFileName;
530 QStringList fileList=browseForFiles->fileList; 530 QStringList fileList=browseForFiles->fileList;
531 qDebug(selFile); 531 qDebug(selFile);
532 QStringList::ConstIterator f; 532 QStringList::ConstIterator f;
533 QString fileTemp; 533 QString fileTemp;
534 for ( f = fileList.begin(); f != fileList.end(); f++ ) { 534 for ( f = fileList.begin(); f != fileList.end(); f++ ) {
535 fileTemp = *f; 535 fileTemp = *f;
536 fileTemp.right( fileTemp.length()-5); 536 fileTemp.right( fileTemp.length()-5);
537 QString fileName = fileTemp; 537 QString fileName = fileTemp;
538 if( fileName != "Unnamed" || fileName != "Empty Text" ) { 538 if( fileName != "Unnamed" || fileName != "Empty Text" ) {
539 currentFileName = fileName; 539 currentFileName = fileName;
540 qDebug("please open "+currentFileName); 540 qDebug("please open "+currentFileName);
541 openFile(fileName ); 541 openFile(fileName );
542 } 542 }
543 } 543 }
544 } 544 }
545 delete browseForFiles; 545 delete browseForFiles;
546 editor->setEdited( true ); 546 editor->setEdited( true );
547} 547}
548 548
549#if 0 549#if 0
550void TextEdit::slotFind() 550void TextEdit::slotFind()
551{ 551{
552 FindDialog frmFind( "Text Editor", this ); 552 FindDialog frmFind( "Text Editor", this );
553 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 553 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
554 editor, SLOT(slotDoFind( const QString&,bool,bool))); 554 editor, SLOT(slotDoFind( const QString&,bool,bool)));
555 555
556 //case sensitive, backwards, [category] 556 //case sensitive, backwards, [category]
557 557
558 connect( editor, SIGNAL(notFound()), 558 connect( editor, SIGNAL(notFound()),
559 &frmFind, SLOT(slotNotFound()) ); 559 &frmFind, SLOT(slotNotFound()) );
560 connect( editor, SIGNAL(searchWrapped()), 560 connect( editor, SIGNAL(searchWrapped()),
561 &frmFind, SLOT(slotWrapAround()) ); 561 &frmFind, SLOT(slotWrapAround()) );
562 562
563 frmFind.exec(); 563 frmFind.exec();
564 564
565 565
566} 566}
567#endif 567#endif
568 568
569void TextEdit::fileRevert() 569void TextEdit::fileRevert()
570{ 570{
571 clear(); 571 clear();
572 fileOpen(); 572 fileOpen();
573} 573}
574 574
575void TextEdit::editCut() 575void TextEdit::editCut()
576{ 576{
577#ifndef QT_NO_CLIPBOARD 577#ifndef QT_NO_CLIPBOARD
578 editor->cut(); 578 editor->cut();
579#endif 579#endif
580} 580}
581 581
582void TextEdit::editCopy() 582void TextEdit::editCopy()
583{ 583{
584#ifndef QT_NO_CLIPBOARD 584#ifndef QT_NO_CLIPBOARD
585 editor->copy(); 585 editor->copy();
586#endif 586#endif
587} 587}
588 588
589void TextEdit::editPaste() 589void TextEdit::editPaste()
590{ 590{
591#ifndef QT_NO_CLIPBOARD 591#ifndef QT_NO_CLIPBOARD
592 editor->paste(); 592 editor->paste();
593#endif 593#endif
594} 594}
595 595
596void TextEdit::editFind() 596void TextEdit::editFind()
597{ 597{
598 searchBar->show(); 598 searchBar->show();
599 searchVisible = TRUE; 599 searchVisible = TRUE;
600 searchEdit->setFocus(); 600 searchEdit->setFocus();
601} 601}
602 602
603void TextEdit::findNext() 603void TextEdit::findNext()
604{ 604{
605 editor->find( searchEdit->text(), FALSE, FALSE ); 605 editor->find( searchEdit->text(), FALSE, FALSE );
606 606
607} 607}
608 608
609void TextEdit::findClose() 609void TextEdit::findClose()
610{ 610{
611 searchVisible = FALSE; 611 searchVisible = FALSE;
612 searchBar->hide(); 612 searchBar->hide();
613} 613}
614 614
615void TextEdit::search() 615void TextEdit::search()
616{ 616{
617 editor->find( searchEdit->text(), FALSE, FALSE ); 617 editor->find( searchEdit->text(), FALSE, FALSE );
618} 618}
619 619
620void TextEdit::newFile( const DocLnk &f ) 620void TextEdit::newFile( const DocLnk &f )
621{ 621{
622 DocLnk nf = f; 622 DocLnk nf = f;
623 nf.setType("text/plain"); 623 nf.setType("text/plain");
624 clear(); 624 clear();
625 editorStack->raiseWidget( editor ); 625 editorStack->raiseWidget( editor );
626 setWState (WState_Reserved1 ); 626 setWState (WState_Reserved1 );
627 editor->setFocus(); 627 editor->setFocus();
628 doc = new DocLnk(nf); 628 doc = new DocLnk(nf);
629 qDebug("newFile "+currentFileName); 629 qDebug("newFile "+currentFileName);
630 updateCaption(currentFileName); 630 updateCaption(currentFileName);
631} 631}
632 632
633void TextEdit::openFile( const QString &f ) 633void TextEdit::openFile( const QString &f )
634{ 634{
635 bFromDocView = TRUE; 635 bFromDocView = TRUE;
636 DocLnk nf; 636 DocLnk nf;
637 nf.setType("text/plain"); 637 nf.setType("text/plain");
638 nf.setFile(f); 638 nf.setFile(f);
639 currentFileName=f; 639 currentFileName=f;
640 QFileInfo fi( currentFileName); 640 QFileInfo fi( currentFileName);
641 nf.setName(fi.baseName()); 641 nf.setName(fi.baseName());
642 qDebug("openFile string"+currentFileName); 642 qDebug("openFile string"+currentFileName);
643 643
644 openFile(nf); 644 openFile(nf);
645 showEditTools(); 645 showEditTools();
646 // Show filename in caption 646 // Show filename in caption
647 QString name = f; 647 QString name = f;
648 int sep = name.findRev( '/' ); 648 int sep = name.findRev( '/' );
649 if ( sep > 0 ) 649 if ( sep > 0 )
650 name = name.mid( sep+1 ); 650 name = name.mid( sep+1 );
651 updateCaption( name ); 651 updateCaption( name );
652} 652}
653 653
654void TextEdit::openFile( const DocLnk &f ) 654void TextEdit::openFile( const DocLnk &f )
655{ 655{
656// clear(); 656// clear();
657 bFromDocView = TRUE; 657 bFromDocView = TRUE;
658 FileManager fm; 658 FileManager fm;
659 QString txt; 659 QString txt;
660 currentFileName=f.name(); 660 currentFileName=f.name();
661 qDebug("openFile doclnk " + currentFileName); 661 qDebug("openFile doclnk " + currentFileName);
662 if ( !fm.loadFile( f, txt ) ) { 662 if ( !fm.loadFile( f, txt ) ) {
663 // ####### could be a new file 663 // ####### could be a new file
664 qDebug( "Cannot open file" ); 664 qDebug( "Cannot open file" );
665 665
666 //return; 666 //return;
667 } 667 }
668 668
669 fileNew(); 669 fileNew();
670 if ( doc ) 670 if ( doc )
671 delete doc; 671 delete doc;
672 doc = new DocLnk(f); 672 doc = new DocLnk(f);
673 editor->setText(txt); 673 editor->setText(txt);
674 editor->setEdited( false); 674 editor->setEdited( false);
675 qDebug("openFile doclnk "+currentFileName); 675 qDebug("openFile doclnk "+currentFileName);
676 doc->setName(currentFileName); 676 doc->setName(currentFileName);
677 updateCaption(); 677 updateCaption();
678} 678}
679 679
680void TextEdit::showEditTools() 680void TextEdit::showEditTools()
681{ 681{
682// if ( !doc ) 682// if ( !doc )
683// close(); 683// close();
684// clear(); 684// clear();
685 fileSelector->hide(); 685 fileSelector->hide();
686 menu->show(); 686 menu->show();
687 editBar->show(); 687 editBar->show();
688 if ( searchVisible ) 688 if ( searchVisible )
689 searchBar->show(); 689 searchBar->show();
690// updateCaption(); 690// updateCaption();
691 editorStack->raiseWidget( editor ); 691 editorStack->raiseWidget( editor );
692 setWState (WState_Reserved1 ); 692 setWState (WState_Reserved1 );
693} 693}
694 694
695/*! 695/*!
696 unprompted save */ 696 unprompted save */
697bool TextEdit::save() 697bool TextEdit::save()
698{ 698{
699 QString file = doc->file(); 699 QString file = doc->file();
700 QString name= doc->name(); 700 QString name= doc->name();
701 701
702 QString rt = editor->text(); 702 QString rt = editor->text();
703 currentFileName= name ; 703 currentFileName= name ;
704 qDebug("saveFile "+currentFileName); 704 qDebug("saveFile "+currentFileName);
705 705
706 struct stat buf; 706 struct stat buf;
707 mode_t mode; 707 mode_t mode;
708 stat(file.latin1(), &buf); 708 stat(file.latin1(), &buf);
709 mode = buf.st_mode; 709 mode = buf.st_mode;
710 710
711 doc->setName( name); 711 doc->setName( name);
712 FileManager fm; 712 FileManager fm;
713 if ( !fm.saveFile( *doc, rt ) ) { 713 if ( !fm.saveFile( *doc, rt ) ) {
714 return false; 714 return false;
715 } 715 }
716 editor->setEdited( false ); 716 editor->setEdited( false );
717 717
718 chmod( file.latin1(), mode); 718 chmod( file.latin1(), mode);
719 return true; 719 return true;
720} 720}
721 721
722/*! 722/*!
723 prompted save */ 723 prompted save */
724bool TextEdit::saveAs() 724bool TextEdit::saveAs()
725{ 725{
726// qDebug("saveAsFile "+currentFileName); 726// qDebug("saveAsFile "+currentFileName);
727 727
728 // case of nothing to save... /// there's always something to save 728 // case of nothing to save... /// there's always something to save
729// if ( !doc )//|| !bFromDocView) 729// if ( !doc )//|| !bFromDocView)
730// { 730// {
731// qDebug("no doc"); 731// qDebug("no doc");
732// return true; 732// return true;
733// } 733// }
734 if ( !editor->edited() ) { 734 if ( !editor->edited() ) {
735 delete doc; 735 delete doc;
736 doc = 0; 736 doc = 0;
737 return true; 737 return true;
738 } 738 }
739 739
740 QString rt = editor->text(); 740 QString rt = editor->text();
741 qDebug(currentFileName); 741 qDebug(currentFileName);
742 742
743 if( currentFileName.isEmpty() || currentFileName == "Unnamed") { 743 if( currentFileName.isEmpty() || currentFileName == "Unnamed") {
744 qDebug("do silly TT filename thing"); 744 qDebug("do silly TT filename thing");
745 if ( doc->name().isEmpty() ) { 745 if ( doc->name().isEmpty() ) {
746 QString pt = rt.simplifyWhiteSpace(); 746 QString pt = rt.simplifyWhiteSpace();
747 int i = pt.find( ' ' ); 747 int i = pt.find( ' ' );
748 QString docname = pt; 748 QString docname = pt;
749 if ( i > 0 ) 749 if ( i > 0 )
750 docname = pt.left( i ); 750 docname = pt.left( i );
751 // remove "." at the beginning 751 // remove "." at the beginning
752 while( docname.startsWith( "." ) ) 752 while( docname.startsWith( "." ) )
753 docname = docname.mid( 1 ); 753 docname = docname.mid( 1 );
754 docname.replace( QRegExp("/"), "_" ); 754 docname.replace( QRegExp("/"), "_" );
755 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. 755 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long.
756 if ( docname.length() > 40 ) 756 if ( docname.length() > 40 )
757 docname = docname.left(40); 757 docname = docname.left(40);
758 if ( docname.isEmpty() ) 758 if ( docname.isEmpty() )
759 docname = "Unnamed"; 759 docname = "Unnamed";
760 doc->setName(docname); 760 doc->setName(docname);
761 currentFileName=docname; 761 currentFileName=docname;
762 } 762 }
763 } 763 }
764 764
765 765
766 fileSaveDlg=new fileSaver(this,"SaveFile",TRUE, 0, currentFileName); 766 fileSaveDlg=new fileSaver(this,"Save File",TRUE, 0, currentFileName);
767 qDebug("wanna save filename "+currentFileName); 767 qDebug("wanna save filename "+currentFileName);
768 fileSaveDlg->exec(); 768 fileSaveDlg->exec();
769 if( fileSaveDlg->result() == 1 ) { 769 if( fileSaveDlg->result() == 1 ) {
770 QString fileNm=fileSaveDlg->selectedFileName; 770 QString fileNm=fileSaveDlg->selectedFileName;
771 qDebug("saving filename "+fileNm); 771 qDebug("saving filename "+fileNm);
772 QFileInfo fi(fileNm); 772 QFileInfo fi(fileNm);
773 currentFileName=fi.fileName(); 773 currentFileName=fi.fileName();
774 if(doc) { 774 if(doc) {
775 qDebug("doclnk exists"); 775 qDebug("doclnk exists");
776// QString file = doc->file(); 776// QString file = doc->file();
777// doc->removeFiles(); 777// doc->removeFiles();
778 delete doc; 778 delete doc;
779 DocLnk nf; 779 DocLnk nf;
780 nf.setType("text/plain"); 780 nf.setType("text/plain");
781 nf.setFile( fileNm); 781 nf.setFile( fileNm);
782 doc = new DocLnk(nf); 782 doc = new DocLnk(nf);
783// editor->setText(rt); 783// editor->setText(rt);
784 qDebug("openFile doclnk "+currentFileName); 784 qDebug("openFile doclnk "+currentFileName);
785 doc->setName( currentFileName); 785 doc->setName( currentFileName);
786 updateCaption( currentFileName); 786 updateCaption( currentFileName);
787 787
788 FileManager fm; 788 FileManager fm;
789 if ( !fm.saveFile( *doc, rt ) ) { 789 if ( !fm.saveFile( *doc, rt ) ) {
790 return false; 790 return false;
791 } 791 }
792 if( fileSaveDlg->filePermCheck->isChecked() ) { 792 if( fileSaveDlg->filePermCheck->isChecked() ) {
793 filePermissions *filePerm; 793 filePermissions *filePerm;
794 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)fileNm); 794 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)fileNm);
795 filePerm->exec(); 795 filePerm->exec();
796 editor->setEdited( false ); 796 editor->setEdited( false );
797 if( filePerm) 797 if( filePerm)
798 delete filePerm; 798 delete filePerm;
799 } 799 }
800 } 800 }
801 } 801 }
802 802
803 if(fileSaveDlg) 803 if(fileSaveDlg)
804 delete fileSaveDlg; 804 delete fileSaveDlg;
805 return true; 805 return true;
806} 806}
807 807
808void TextEdit::clear() 808void TextEdit::clear()
809{ 809{
810 delete doc; 810 delete doc;
811 doc = 0; 811 doc = 0;
812 editor->clear(); 812 editor->clear();
813} 813}
814 814
815void TextEdit::updateCaption( const QString &name ) 815void TextEdit::updateCaption( const QString &name )
816{ 816{
817 if ( !doc ) 817 if ( !doc )
818 setCaption( tr("Text Editor") ); 818 setCaption( tr("Text Editor") );
819 else { 819 else {
820 QString s = name; 820 QString s = name;
821 if ( s.isNull() ) 821 if ( s.isNull() )
822 s = doc->name(); 822 s = doc->name();
823 if ( s.isEmpty() ) { 823 if ( s.isEmpty() ) {
824 s = tr( "Unnamed" ); 824 s = tr( "Unnamed" );
825 currentFileName=s; 825 currentFileName=s;
826 } 826 }
827 827
828 setCaption( s + " - " + tr("Text Editor") ); 828 setCaption( s + " - " + tr("Text Editor") );
829 } 829 }
830} 830}
831 831
832void TextEdit::setDocument(const QString& fileref) 832void TextEdit::setDocument(const QString& fileref)
833{ 833{
834 bFromDocView = TRUE; 834 bFromDocView = TRUE;
835 openFile(fileref); 835 openFile(fileref);
836// bFromDocView = TRUE; 836// bFromDocView = TRUE;
837// openFile(DocLnk(fileref)); 837// openFile(DocLnk(fileref));
838// showEditTools(); 838// showEditTools();
839} 839}
840 840
841void TextEdit::closeEvent( QCloseEvent *e ) 841void TextEdit::closeEvent( QCloseEvent *e )
842{ 842{
843 if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) { 843 if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) {
844 e->ignore(); 844 e->ignore();
845 repaint(); 845 repaint();
846// fileRevert(); 846// fileRevert();
847 847
848 } else { 848 } else {
849 bFromDocView = FALSE; 849 bFromDocView = FALSE;
850 e->accept(); 850 e->accept();
851 } 851 }
852} 852}
853 853
854void TextEdit::accept() 854void TextEdit::accept()
855{ 855{
856 save(); 856 save();
857 close(); 857 close();
858// fileOpen(); //godamn thats obnoxious! lemme out!!! 858// fileOpen(); //godamn thats obnoxious! lemme out!!!
859} 859}
860 860
861void TextEdit::changeFont() { 861void TextEdit::changeFont() {
862 FontDatabase fdb; 862 FontDatabase fdb;
863 QFont defaultFont=editor->font(); 863 QFont defaultFont=editor->font();
864 QFontInfo fontInfo(defaultFont); 864 QFontInfo fontInfo(defaultFont);
865 Config cfg("TextEdit"); 865 Config cfg("TextEdit");
866 cfg.setGroup("Font"); 866 cfg.setGroup("Font");
867 QString family = cfg.readEntry("Family", fontInfo.family()); 867 QString family = cfg.readEntry("Family", fontInfo.family());
868 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); 868 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
869 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); 869 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
870 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); 870 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
871 871
872 defaultFont = fdb.font(family,style,i_size,charSet); 872 defaultFont = fdb.font(family,style,i_size,charSet);
873 873
874 FontDialog *fontDlg; 874 FontDialog *fontDlg;
875 fontDlg=new FontDialog(this,"FontDialog",TRUE); 875 fontDlg=new FontDialog(this,"FontDialog",TRUE);
876 876
877 fontDlg->exec(); 877 fontDlg->exec();
878 878
879 QFont myFont=fontDlg->selectedFont; 879 QFont myFont=fontDlg->selectedFont;
880 editor->setFont( myFont); 880 editor->setFont( myFont);
881 delete fontDlg; 881 delete fontDlg;
882 882
883} 883}
884 884
885void TextEdit::editDelete() 885void TextEdit::editDelete()
886{ 886{
887 switch ( QMessageBox::warning(this,"Text Editor","Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!","Yes","No",0,0,1) ) { 887 switch ( QMessageBox::warning(this,"Text Editor","Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!","Yes","No",0,0,1) ) {
888 case 0: 888 case 0:
889 if(doc) { 889 if(doc) {
890 doc->removeFiles(); 890 doc->removeFiles();
891 clear(); 891 clear();
892 setCaption( tr("Text Editor") ); 892 setCaption( tr("Text Editor") );
893 } 893 }
894 break; 894 break;
895 case 1: 895 case 1:
896 // exit 896 // exit
897 break; 897 break;
898 }; 898 };
899} 899}