summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp22
-rw-r--r--core/apps/textedit/fileBrowser.h2
-rw-r--r--core/apps/textedit/fileSaver.cpp29
-rw-r--r--core/apps/textedit/fileSaver.h2
-rw-r--r--core/apps/textedit/textedit.cpp3
5 files changed, 45 insertions, 13 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
index 2275388..3e3cc3a 100644
--- a/core/apps/textedit/fileBrowser.cpp
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -1,164 +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 17
17#include <qlistview.h> 18#include <qlistview.h>
18#include <qpushbutton.h> 19#include <qpushbutton.h>
19#include <qfile.h> 20#include <qfile.h>
20#include <qmessagebox.h> 21#include <qmessagebox.h>
21#include <unistd.h> 22#include <unistd.h>
22 23
23fileBrowser::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 )
24 : QDialog( parent, name, modal, fl ) 25 : QDialog( parent, name, modal, fl )
25{ 26{
26 if ( !name ) 27 if ( !name )
27 setName( "fileBrowser" ); 28 setName( "fileBrowser" );
28 resize( 236, 280 ); 29 resize( 240, 280 );
29 setCaption(tr( "Browse for file" ) ); 30 setCaption(tr( "Browse for file" ) );
30 filterStr=filter; 31 filterStr=filter;
32
31 dirLabel = new QLabel(this, "DirLabel"); 33 dirLabel = new QLabel(this, "DirLabel");
32 dirLabel->setText(currentDir.canonicalPath()); 34 dirLabel->setText(currentDir.canonicalPath());
33 dirLabel->setGeometry(10,4,230,30); 35 dirLabel->setGeometry(10,20,230,15);
36
37 QPushButton *homeButton;
38 homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton");
39 homeButton->setGeometry(200,4,25,25);
40 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
41
34 ListView = new QListView( this, "ListView" ); 42 ListView = new QListView( this, "ListView" );
35 ListView->addColumn( tr( "Name" ) ); 43 ListView->addColumn( tr( "Name" ) );
36 ListView->setColumnWidth(0,140); 44 ListView->setColumnWidth(0,140);
37 ListView->setSorting( 2, FALSE); 45 ListView->setSorting( 2, FALSE);
38 ListView->addColumn( tr( "Size" ) ); 46 ListView->addColumn( tr( "Size" ) );
39 ListView->setColumnWidth(1,59); 47 ListView->setColumnWidth(1,59);
40// ListView->addColumn( tr( "" ) ); 48// ListView->addColumn( tr( "" ) );
41 ListView->setColumnWidthMode(0,QListView::Manual); 49 ListView->setColumnWidthMode(0,QListView::Manual);
42 ListView->setColumnAlignment(1,QListView::AlignRight); 50 ListView->setColumnAlignment(1,QListView::AlignRight);
43// ListView->setMultiSelection(true); 51// ListView->setMultiSelection(true);
44// ListView->setSelectionMode(QListView::Extended); 52// ListView->setSelectionMode(QListView::Extended);
45 53
46 ListView->setAllColumnsShowFocus( TRUE ); 54 ListView->setAllColumnsShowFocus( TRUE );
47 ListView->setGeometry( QRect( 10, 35, 220, 240 ) ); 55 ListView->setGeometry( QRect( 10, 35, 220, 240 ) );
48 56
49 // signals and slots connections 57 // signals and slots connections
50 connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); 58 connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) );
51 connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); 59 connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
52 currentDir.setPath(QDir::currentDirPath()); 60 currentDir.setPath(QDir::currentDirPath());
53 populateList(); 61 populateList();
62 move(0,15);
54} 63}
55 64
56fileBrowser::~fileBrowser() 65fileBrowser::~fileBrowser()
57{ 66{
58} 67}
59 68
60 69
61void fileBrowser::populateList() 70void fileBrowser::populateList()
62{ 71{
63 ListView->clear(); 72 ListView->clear();
64//qDebug(currentDir.canonicalPath()); 73//qDebug(currentDir.canonicalPath());
65 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden ); 74 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden );
66 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 75 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
67 currentDir.setMatchAllDirs(TRUE); 76 currentDir.setMatchAllDirs(TRUE);
68 77
69 currentDir.setNameFilter(filterStr); 78 currentDir.setNameFilter(filterStr);
70// currentDir.setNameFilter("*.txt;*.etx"); 79// currentDir.setNameFilter("*.txt;*.etx");
71 QString fileL, fileS; 80 QString fileL, fileS;
72 const QFileInfoList *list = currentDir.entryInfoList(QDir::All /*, QDir::SortByMask*/); 81 const QFileInfoList *list = currentDir.entryInfoList(QDir::All /*, QDir::SortByMask*/);
73 QFileInfoListIterator it(*list); 82 QFileInfoListIterator it(*list);
74 QFileInfo *fi; 83 QFileInfo *fi;
75 while ( (fi=it.current()) ) { 84 while ( (fi=it.current()) ) {
76 85
77 if (fi->isSymLink() ){ 86 if (fi->isSymLink() ){
78 QString symLink=fi->readLink(); 87 QString symLink=fi->readLink();
79// qDebug("Symlink detected "+symLink); 88// qDebug("Symlink detected "+symLink);
80 QFileInfo sym( symLink); 89 QFileInfo sym( symLink);
81 fileS.sprintf( "%10li", sym.size() ); 90 fileS.sprintf( "%10li", sym.size() );
82 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 91 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
83 92
84 } else { 93 } else {
85// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 94// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
86 fileS.sprintf( "%10li", fi->size() ); 95 fileS.sprintf( "%10li", fi->size() );
87 fileL.sprintf( "%s",fi->fileName().data() ); 96 fileL.sprintf( "%s",fi->fileName().data() );
88 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 97 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
89 fileL+="/"; 98 fileL+="/";
90// qDebug(currentDir.canonicalPath()+fileL); 99// qDebug(currentDir.canonicalPath()+fileL);
91 } 100 }
92 } 101 }
93 item= new QListViewItem( ListView,fileL,fileS ); 102 item= new QListViewItem( ListView,fileL,fileS );
94 ++it; 103 ++it;
95 } 104 }
96 ListView->setSorting( 2, FALSE); 105 ListView->setSorting( 2, FALSE);
97 dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath()); 106 dirLabel->setText(currentDir.canonicalPath());
98} 107}
99 108
100void fileBrowser::upDir() 109void fileBrowser::upDir()
101{ 110{
102// qDebug(currentDir.canonicalPath()); 111// qDebug(currentDir.canonicalPath());
103} 112}
104 113
105void fileBrowser::listDoubleClicked(QListViewItem *selectedItem) 114void fileBrowser::listDoubleClicked(QListViewItem *selectedItem)
106{ 115{
107} 116}
108 117
109// 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
110void fileBrowser::listClicked(QListViewItem *selectedItem) 119void fileBrowser::listClicked(QListViewItem *selectedItem)
111{ 120{
112 QString strItem=selectedItem->text(0); 121 QString strItem=selectedItem->text(0);
113 QString strSize=selectedItem->text(1); 122 QString strSize=selectedItem->text(1);
114// qDebug("strItem is "+strItem); 123// qDebug("strItem is "+strItem);
115 strSize.stripWhiteSpace(); 124 strSize.stripWhiteSpace();
116// qDebug(strSize); 125// qDebug(strSize);
117 126
118 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
119 // is symlink 128 // is symlink
120 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); 129 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4);
121// qDebug("strItem symlink is "+strItem2); 130// qDebug("strItem symlink is "+strItem2);
122 if(QDir(strItem2).exists() ) { 131 if(QDir(strItem2).exists() ) {
123 currentDir.cd(strItem2, TRUE); 132 currentDir.cd(strItem2, TRUE);
124 populateList(); 133 populateList();
125 } 134 }
126 } else { // not a symlink 135 } else { // not a symlink
127 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 136 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
128 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 137 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
129 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 138 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
130 currentDir.cd(strItem,FALSE); 139 currentDir.cd(strItem,FALSE);
131// qDebug("Path is "+strItem); 140// qDebug("Path is "+strItem);
132 populateList(); 141 populateList();
133 } else { 142 } else {
134 currentDir.cdUp(); 143 currentDir.cdUp();
135 populateList(); 144 populateList();
136 } 145 }
137 if(QDir(strItem).exists()){ 146 if(QDir(strItem).exists()){
138 currentDir.cd(strItem, TRUE); 147 currentDir.cd(strItem, TRUE);
139 populateList(); 148 populateList();
140 } 149 }
141 } else { 150 } else {
142 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 151 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
143 if( QFile::exists(strItem ) ) { 152 if( QFile::exists(strItem ) ) {
144//currentDir.canonicalPath() 153//currentDir.canonicalPath()
145 qDebug("We found our files!!"+strItem); 154 qDebug("We found our files!!"+strItem);
146 OnOK(); 155 OnOK();
147 } 156 }
148 } //end not symlink 157 } //end not symlink
149 chdir(strItem.latin1()); 158 chdir(strItem.latin1());
150 } 159 }
151} 160}
152 161
153void fileBrowser::OnOK() 162void fileBrowser::OnOK()
154{ 163{
155 QListViewItemIterator it1( ListView); 164 QListViewItemIterator it1( ListView);
156 for ( ; it1.current(); ++it1 ) { 165 for ( ; it1.current(); ++it1 ) {
157 if ( it1.current()->isSelected() ) { 166 if ( it1.current()->isSelected() ) {
158 selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); 167 selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0));
159 qDebug("selected filename is "+selectedFileName); 168 qDebug("selected filename is "+selectedFileName);
160 fileList.append( selectedFileName ); 169 fileList.append( selectedFileName );
161 } 170 }
162 } 171 }
163 accept(); 172 accept();
164} 173}
174
175void fileBrowser::homeButtonPushed() {
176 chdir( QDir::homeDirPath().latin1() );
177 currentDir.cd( QDir::homeDirPath(), TRUE);
178 populateList();
179 update();
180}
diff --git a/core/apps/textedit/fileBrowser.h b/core/apps/textedit/fileBrowser.h
index 17ed862..c0e1d4a 100644
--- a/core/apps/textedit/fileBrowser.h
+++ b/core/apps/textedit/fileBrowser.h
@@ -1,67 +1,67 @@
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**
13copyright Sun 02-17-2002 22:28:23 L. J. Potter ljp@llornkcor.com 13copyright Sun 02-17-2002 22:28:23 L. J. Potter ljp@llornkcor.com
14****************************************************************************/ 14****************************************************************************/
15#ifndef FILEBROWSER_H 15#ifndef FILEBROWSER_H
16#define FILEBROWSER_H 16#define FILEBROWSER_H
17 17
18//#include <qvariant.h> 18//#include <qvariant.h>
19#include <qdialog.h> 19#include <qdialog.h>
20#include <qfile.h> 20#include <qfile.h>
21#include <qdir.h> 21#include <qdir.h>
22#include <qstringlist.h> 22#include <qstringlist.h>
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qstring.h> 24#include <qstring.h>
25 25
26class QVBoxLayout; 26class QVBoxLayout;
27class QHBoxLayout; 27class QHBoxLayout;
28class QGridLayout; 28class QGridLayout;
29class QListView; 29class QListView;
30class QListViewItem; 30class QListViewItem;
31class QPushButton; 31class QPushButton;
32 32
33class fileBrowser : public QDialog 33class fileBrowser : public QDialog
34{ 34{
35 Q_OBJECT 35 Q_OBJECT
36 36
37public: 37public:
38 void populateList(); 38 void populateList();
39 fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0); 39 fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0);
40 ~fileBrowser(); 40 ~fileBrowser();
41 41
42 QPushButton* buttonOk; 42 QPushButton* buttonOk;
43 QListView* ListView; 43 QListView* ListView;
44 QPushButton* buttonCancel; 44 QPushButton* buttonCancel;
45 QLabel *dirLabel; 45 QLabel *dirLabel;
46 QString selectedFileName, filterStr; 46 QString selectedFileName, filterStr;
47 QDir currentDir; 47 QDir currentDir;
48 QFile file; 48 QFile file;
49 QStringList fileList; 49 QStringList fileList;
50 50
51QListViewItem * item; 51QListViewItem * item;
52public slots: 52public slots:
53 53void homeButtonPushed();
54private: 54private:
55 55
56private slots: 56private slots:
57 void upDir(); 57 void upDir();
58 void listDoubleClicked(QListViewItem *); 58 void listDoubleClicked(QListViewItem *);
59 void listClicked(QListViewItem *); 59 void listClicked(QListViewItem *);
60 void OnOK(); 60 void OnOK();
61protected slots: 61protected slots:
62 62
63protected: 63protected:
64 64
65}; 65};
66 66
67#endif // FILEBROWSER_H 67#endif // FILEBROWSER_H
diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp
index 9e9e863..de594aa 100644
--- a/core/apps/textedit/fileSaver.cpp
+++ b/core/apps/textedit/fileSaver.cpp
@@ -1,188 +1,203 @@
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>
17
16#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
17#include <qlistview.h> 19#include <qlistview.h>
18#include <qpushbutton.h> 20#include <qpushbutton.h>
19#include <qfile.h> 21#include <qfile.h>
20#include <qmessagebox.h> 22#include <qmessagebox.h>
21#include <qlineedit.h> 23#include <qlineedit.h>
22#include <qcheckbox.h> 24#include <qcheckbox.h>
23 25
24#include <unistd.h> 26#include <unistd.h>
25 27
26fileSaver::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 )
27 : QDialog( parent, name, modal, fl ) 29 : QDialog( parent, name, modal, fl )
28{ 30{
29 if ( !name ) 31 if ( !name )
30 setName( "fileSaver" ); 32 setName( "fileSaver" );
31 resize( 236, 280 ); 33 resize( 240, 280 );
32 setCaption(tr( "Save file" ) ); 34 setCaption(tr( "Save file" ) );
33 QFileInfo fi(currentFileName); 35 QFileInfo fi(currentFileName);
34 QString tmpFileName=fi.fileName(); 36 QString tmpFileName=fi.fileName();
35// qDebug( tmpFileName); 37// qDebug( tmpFileName);
36
37 dirLabel = new QLabel(this, "DirLabel"); 38 dirLabel = new QLabel(this, "DirLabel");
38 dirLabel->setText(currentDir.canonicalPath()); 39 dirLabel->setText(currentDir.canonicalPath());
39 dirLabel->setGeometry(10,4,230,30); 40 dirLabel->setGeometry(10,20,230,15);
40 41
42 QPushButton *homeButton;
43 homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton");
44 homeButton->setGeometry(200,4,25,25);
45 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
46
41 ListView = new QListView( this, "ListView" ); 47 ListView = new QListView( this, "ListView" );
42 ListView->addColumn( tr( "Name" ) ); 48 ListView->addColumn( tr( "Name" ) );
43 ListView->setColumnWidth(0,140); 49 ListView->setColumnWidth(0,140);
44 ListView->setSorting( 2, FALSE); 50 ListView->setSorting( 2, FALSE);
45 ListView->addColumn( tr( "Size" ) ); 51 ListView->addColumn( tr( "Size" ) );
46 ListView->setColumnWidth(1,59); 52 ListView->setColumnWidth(1,59);
47 ListView->setColumnWidthMode(0,QListView::Manual); 53 ListView->setColumnWidthMode(0,QListView::Manual);
48 ListView->setColumnAlignment(1,QListView::AlignRight); 54 ListView->setColumnAlignment(1,QListView::AlignRight);
49// ListView->setMultiSelection(true); 55// ListView->setMultiSelection(true);
50// ListView->setSelectionMode(QListView::Extended); 56// ListView->setSelectionMode(QListView::Extended);
51 57
52 ListView->setAllColumnsShowFocus( TRUE ); 58 ListView->setAllColumnsShowFocus( TRUE );
53 ListView->setGeometry( QRect( 10, 35, 220, 160 ) ); 59 ListView->setGeometry( QRect( 10,35,220,125));
54 60
55 fileEdit= new QLineEdit(this); 61 fileEdit= new QLineEdit(this);
56 fileEdit->setGeometry( QRect( 10, 200, 200, 22)); 62 fileEdit->setGeometry( QRect( 10, 162, 205, 17));
57 63
58 fileEdit->setText( tmpFileName); 64 fileEdit->setText( tmpFileName);
59 65
60 filePermCheck = new QCheckBox( this, "SetFilePerms" ); 66 filePermCheck = new QCheckBox( this, "SetFilePerms" );
61 filePermCheck->setText("set file permissions"); 67 filePermCheck->setText("set file permissions");
62 filePermCheck->setGeometry(10, 220, 150,22); 68 filePermCheck->setGeometry(10, 178, 150,17);
63 // signals and slots connections 69 // signals and slots connections
64 connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); 70 connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) );
65 connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); 71 connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
66 72
67// tmpFileName=fi.FilePath(); 73// tmpFileName=fi.FilePath();
68// qDebug( tmpFileName); 74// qDebug( tmpFileName);
69 currentDir.setPath( QDir::currentDirPath() ); 75 currentDir.setPath( QDir::currentDirPath() );
70 populateList(); 76 populateList();
77 move(0,15);
78
71} 79}
72 80
73fileSaver::~fileSaver() 81fileSaver::~fileSaver()
74{ 82{
75} 83}
76 84
77 85
78void fileSaver::populateList() 86void fileSaver::populateList()
79{ 87{
80 ListView->clear(); 88 ListView->clear();
81 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden ); 89 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden );
82 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 90 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
83 currentDir.setMatchAllDirs(TRUE); 91 currentDir.setMatchAllDirs(TRUE);
84 92
85 currentDir.setNameFilter("*"); 93 currentDir.setNameFilter("*");
86 QString fileL, fileS; 94 QString fileL, fileS;
87 const QFileInfoList *list = currentDir.entryInfoList(QDir::All /*, QDir::SortByMask*/); 95 const QFileInfoList *list = currentDir.entryInfoList(QDir::All /*, QDir::SortByMask*/);
88 QFileInfoListIterator it(*list); 96 QFileInfoListIterator it(*list);
89 QFileInfo *fi; 97 QFileInfo *fi;
90 while ( (fi=it.current()) ) { 98 while ( (fi=it.current()) ) {
91 99
92 if (fi->isSymLink() ){ 100 if (fi->isSymLink() ){
93 QString symLink=fi->readLink(); 101 QString symLink=fi->readLink();
94// qDebug("Symlink detected "+symLink); 102// qDebug("Symlink detected "+symLink);
95 QFileInfo sym( symLink); 103 QFileInfo sym( symLink);
96 fileS.sprintf( "%10li", sym.size() ); 104 fileS.sprintf( "%10li", sym.size() );
97 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 105 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
98 106
99 } else { 107 } else {
100// // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 108// // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
101 fileS.sprintf( "%10li", fi->size() ); 109 fileS.sprintf( "%10li", fi->size() );
102 fileL.sprintf( "%s",fi->fileName().data() ); 110 fileL.sprintf( "%s",fi->fileName().data() );
103 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 111 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
104 fileL+="/"; 112 fileL+="/";
105// qDebug(currentDir.canonicalPath()+fileL); 113// qDebug(currentDir.canonicalPath()+fileL);
106 } 114 }
107 } 115 }
108 item= new QListViewItem( ListView,fileL,fileS ); 116 item= new QListViewItem( ListView,fileL,fileS );
109 ++it; 117 ++it;
110 } 118 }
111 ListView->setSorting( 2, FALSE); 119 ListView->setSorting( 2, FALSE);
112 dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath()); 120 dirLabel->setText(currentDir.canonicalPath());
113 121
114 122
115} 123}
116 124
117void fileSaver::upDir() 125void fileSaver::upDir()
118{ 126{
119// qDebug(currentDir.canonicalPath()); 127// qDebug(currentDir.canonicalPath());
120} 128}
121 129
122void fileSaver::listDoubleClicked(QListViewItem *selectedItem) 130void fileSaver::listDoubleClicked(QListViewItem *selectedItem)
123{ 131{
124} 132}
125 133
126void fileSaver::listClicked(QListViewItem *selectedItem) 134void fileSaver::listClicked(QListViewItem *selectedItem)
127{ 135{
128 QString strItem=selectedItem->text(0); 136 QString strItem=selectedItem->text(0);
129 QString strSize=selectedItem->text(1); 137 QString strSize=selectedItem->text(1);
130// qDebug("strItem is "+strItem); 138// qDebug("strItem is "+strItem);
131 strSize.stripWhiteSpace(); 139 strSize.stripWhiteSpace();
132// qDebug(strSize); 140// qDebug(strSize);
133 141
134 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 142 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
135 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); 143 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4);
136// qDebug("strItem symlink is "+strItem2); 144// qDebug("strItem symlink is "+strItem2);
137 if(QDir(strItem2).exists() ) { 145 if(QDir(strItem2).exists() ) {
138 currentDir.cd(strItem2, TRUE); 146 currentDir.cd(strItem2, TRUE);
139 populateList(); 147 populateList();
140 } 148 }
141 } else { // not a symlink 149 } else { // not a symlink
142 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 150 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
143 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 151 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
144 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 152 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
145 currentDir.cd(strItem,FALSE); 153 currentDir.cd(strItem,FALSE);
146// qDebug("Path is "+strItem); 154// qDebug("Path is "+strItem);
147 populateList(); 155 populateList();
148 } else { 156 } else {
149 currentDir.cdUp(); 157 currentDir.cdUp();
150 populateList(); 158 populateList();
151 } 159 }
152 if(QDir(strItem).exists()){ 160 if(QDir(strItem).exists()){
153 currentDir.cd(strItem, TRUE); 161 currentDir.cd(strItem, TRUE);
154 populateList(); 162 populateList();
155 } 163 }
156 } // else 164 } // else
157// if( QFile::exists(strItem ) ) { 165// if( QFile::exists(strItem ) ) {
158// qDebug("We found our files!!"); 166// qDebug("We found our files!!");
159 167
160// OnOK(); 168// OnOK();
161 } //end not symlink 169 } //end not symlink
162 chdir(strItem.latin1()); 170 chdir(strItem.latin1());
163 171
164 172
165} 173}
166 174
167 175
168void fileSaver::closeEvent( QCloseEvent *e ) 176void fileSaver::closeEvent( QCloseEvent *e )
169{ 177{
170 if(e->isAccepted()) { 178 if(e->isAccepted()) {
171 e->accept(); 179 e->accept();
172 } else { 180 } else {
173 qDebug("not accepted"); 181 qDebug("not accepted");
174 done(-1); 182 done(-1);
175 } 183 }
176} 184}
177 185
178void fileSaver::accept() { 186void fileSaver::accept() {
179 selectedFileName = fileEdit->text(); 187 selectedFileName = fileEdit->text();
180 QString path = currentDir.canonicalPath()+"/" + selectedFileName; 188 QString path = currentDir.canonicalPath()+"/" + selectedFileName;
181 if( path.find("//",0,TRUE) ==-1 ) { 189 if( path.find("//",0,TRUE) ==-1 ) {
182 selectedFileName = path; 190 selectedFileName = path;
183 } else { 191 } else {
184 selectedFileName = currentDir.canonicalPath()+selectedFileName; 192 selectedFileName = currentDir.canonicalPath()+selectedFileName;
185 } 193 }
186 qDebug("going to save "+selectedFileName); 194 qDebug("going to save "+selectedFileName);
187 done(1); 195 done(1);
188} 196}
197
198void fileSaver::homeButtonPushed() {
199 chdir( QDir::homeDirPath().latin1() );
200 currentDir.cd( QDir::homeDirPath(), TRUE);
201 populateList();
202 update();
203}
diff --git a/core/apps/textedit/fileSaver.h b/core/apps/textedit/fileSaver.h
index ce4493e..526085d 100644
--- a/core/apps/textedit/fileSaver.h
+++ b/core/apps/textedit/fileSaver.h
@@ -1,74 +1,74 @@
1/**************************************************************************** 1/****************************************************************************
2** 2**
3** Created: Fri Dec 14 08:16:02 2001 fileSaver.h 3** Created: Fri Dec 14 08:16:02 2001 fileSaver.h
4** 4**
5copyright Sun 02-17-2002 22:28:48 L. J. Potter ljp@llornkcor.com 5copyright Sun 02-17-2002 22:28:48 L. J. Potter ljp@llornkcor.com
6 6
7** This file may be distributed and/or modified under the terms of the 7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software 8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging of this file.
11** 11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14** 14**
15****************************************************************************/ 15****************************************************************************/
16#ifndef FILESAVER_H 16#ifndef FILESAVER_H
17#define FILESAVER_H 17#define FILESAVER_H
18 18
19//#include <qvariant.h> 19//#include <qvariant.h>
20#include <qdialog.h> 20#include <qdialog.h>
21#include <qfile.h> 21#include <qfile.h>
22#include <qdir.h> 22#include <qdir.h>
23#include <qstringlist.h> 23#include <qstringlist.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qstring.h> 25#include <qstring.h>
26 26
27class QVBoxLayout; 27class QVBoxLayout;
28class QHBoxLayout; 28class QHBoxLayout;
29class QGridLayout; 29class QGridLayout;
30class QListView; 30class QListView;
31class QListViewItem; 31class QListViewItem;
32class QPushButton; 32class QPushButton;
33class QLineEdit; 33class QLineEdit;
34class QCheckBox; 34class QCheckBox;
35 35
36class fileSaver : public QDialog 36class fileSaver : public QDialog
37{ 37{
38 Q_OBJECT 38 Q_OBJECT
39 39
40public: 40public:
41 void populateList(); 41 void populateList();
42 fileSaver( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0); 42 fileSaver( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0);
43 ~fileSaver(); 43 ~fileSaver();
44 QLineEdit *fileEdit; 44 QLineEdit *fileEdit;
45 45
46 QPushButton* buttonOk; 46 QPushButton* buttonOk;
47 QListView* ListView; 47 QListView* ListView;
48 QPushButton* buttonCancel; 48 QPushButton* buttonCancel;
49 QLabel *dirLabel; 49 QLabel *dirLabel;
50 QString selectedFileName, filterStr; 50 QString selectedFileName, filterStr;
51 QDir currentDir; 51 QDir currentDir;
52 QFile file; 52 QFile file;
53 QStringList fileList; 53 QStringList fileList;
54 QCheckBox *filePermCheck; 54 QCheckBox *filePermCheck;
55 55
56QListViewItem * item; 56QListViewItem * item;
57public slots: 57public slots:
58 58void homeButtonPushed();
59private: 59private:
60 60
61private slots: 61private slots:
62 void accept(); 62 void accept();
63 void upDir(); 63 void upDir();
64 void listDoubleClicked(QListViewItem *); 64 void listDoubleClicked(QListViewItem *);
65 void listClicked(QListViewItem *); 65 void listClicked(QListViewItem *);
66 void closeEvent( QCloseEvent * ); 66 void closeEvent( QCloseEvent * );
67 67
68protected slots: 68protected slots:
69 69
70protected: 70protected:
71 71
72}; 72};
73 73
74#endif // FILESAVER_H 74#endif // FILESAVER_H
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index bc975f3..72cc4d1 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -670,229 +670,230 @@ void TextEdit::openFile( const DocLnk &f )
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,"SaveFile",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 } 893 }
893 break; 894 break;
894 case 1: 895 case 1:
895 // exit 896 // exit
896 break; 897 break;
897 }; 898 };
898} 899}