summaryrefslogtreecommitdiff
path: root/core
authorllornkcor <llornkcor>2002-02-18 14:08:55 (UTC)
committer llornkcor <llornkcor>2002-02-18 14:08:55 (UTC)
commit9741205aa0b0892b870d2b7df7c5dd7e25b0bb18 (patch) (unidiff)
tree7f2f3d44ff3215984bd8b487b206d3d958a498da /core
parent0640b30f13beb9d6480d8042ec5397a68e6247fc (diff)
downloadopie-9741205aa0b0892b870d2b7df7c5dd7e25b0bb18.zip
opie-9741205aa0b0892b870d2b7df7c5dd7e25b0bb18.tar.gz
opie-9741205aa0b0892b870d2b7df7c5dd7e25b0bb18.tar.bz2
added fontDialog, fileBrowserDialog, and fileSave dialog, so we can edit anyfile, save anywhere,
using a user selected name. Changed what is seen when it opens. It now opens with the texteditor opened to a new file, instead of the file selector, unless one is specified from commandline, or setDocument message. FileSelector is still available, but from a menu item.
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/Makefile.in8
-rw-r--r--core/apps/textedit/fileBrowser.cpp160
-rw-r--r--core/apps/textedit/fileBrowser.h67
-rw-r--r--core/apps/textedit/fileSaver.cpp164
-rw-r--r--core/apps/textedit/fileSaver.h71
-rw-r--r--core/apps/textedit/fontDialog.cpp236
-rw-r--r--core/apps/textedit/fontDialog.h63
-rw-r--r--core/apps/textedit/inserttable.ui103
-rw-r--r--core/apps/textedit/qtextedit.h282
-rw-r--r--core/apps/textedit/textedit.cpp481
-rw-r--r--core/apps/textedit/textedit.h7
-rw-r--r--core/apps/textedit/textedit.pro14
12 files changed, 1125 insertions, 531 deletions
diff --git a/core/apps/textedit/Makefile.in b/core/apps/textedit/Makefile.in
index 997f2a4..bef671c 100644
--- a/core/apps/textedit/Makefile.in
+++ b/core/apps/textedit/Makefile.in
@@ -101,17 +101,23 @@ REQUIRES=
101main.o: main.cpp \ 101main.o: main.cpp \
102 textedit.h \ 102 textedit.h \
103 $(OPIEDIR)/include/qpe/filemanager.h \ 103 $(OPIEDIR)/include/qpe/filemanager.h \
104 $(OPIEDIR)/include/qpe/qpeapplication.h 104 $(OPIEDIR)/include/qpe/qpeapplication.h \
105 $(OPIEDIR)/include/qpedecoration_qws.h \
106 $(OPIEDIR)/include/timestring.h
105 107
106textedit.o: textedit.cpp \ 108textedit.o: textedit.cpp \
107 textedit.h \ 109 textedit.h \
108 $(OPIEDIR)/include/qpe/filemanager.h \ 110 $(OPIEDIR)/include/qpe/filemanager.h \
109 $(OPIEDIR)/include/qpe/global.h \ 111 $(OPIEDIR)/include/qpe/global.h \
110 $(OPIEDIR)/include/qpe/fileselector.h \ 112 $(OPIEDIR)/include/qpe/fileselector.h \
113 $(OPIEDIR)/include/filemanager.h \
114 $(OPIEDIR)/include/applnk.h \
111 $(OPIEDIR)/include/qpe/applnk.h \ 115 $(OPIEDIR)/include/qpe/applnk.h \
112 $(OPIEDIR)/include/qpe/resource.h \ 116 $(OPIEDIR)/include/qpe/resource.h \
113 $(OPIEDIR)/include/qpe/config.h \ 117 $(OPIEDIR)/include/qpe/config.h \
114 $(OPIEDIR)/include/qpe/qpeapplication.h \ 118 $(OPIEDIR)/include/qpe/qpeapplication.h \
119 $(OPIEDIR)/include/qpedecoration_qws.h \
120 $(OPIEDIR)/include/timestring.h \
115 $(OPIEDIR)/include/qpe/qpemenubar.h \ 121 $(OPIEDIR)/include/qpe/qpemenubar.h \
116 $(OPIEDIR)/include/qpe/qpetoolbar.h 122 $(OPIEDIR)/include/qpe/qpetoolbar.h
117 123
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
new file mode 100644
index 0000000..82ccf2c
--- a/dev/null
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -0,0 +1,160 @@
1/****************************************************************************
2** copyright 2001 ljp ljp@llornkcor.com
3** Created: Fri Dec 14 08:16:46 2001
4**
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
7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file.
9**
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.
12**
13****************************************************************************/
14#include "fileBrowser.h"
15#include <qpe/config.h>
16
17#include <qlistview.h>
18#include <qpushbutton.h>
19#include <qfile.h>
20#include <qmessagebox.h>
21#include <unistd.h>
22
23fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter )
24 : QDialog( parent, name, modal, fl )
25{
26 if ( !name )
27 setName( "fileBrowser" );
28 resize( 236, 280 );
29 setCaption(tr( "Browse for file" ) );
30 filterStr=filter;
31 dirLabel = new QLabel(this, "DirLabel");
32 dirLabel->setText(currentDir.canonicalPath());
33 dirLabel->setGeometry(10,4,230,30);
34 ListView = new QListView( this, "ListView" );
35 ListView->addColumn( tr( "Name" ) );
36 ListView->setColumnWidth(0,140);
37 ListView->setSorting( 2, FALSE);
38 ListView->addColumn( tr( "Size" ) );
39 ListView->setColumnWidth(1,59);
40// ListView->addColumn( tr( "" ) );
41// ListView->setColumnWidth(1,59);
42// ListView->setMultiSelection(true);
43// ListView->setSelectionMode(QListView::Extended);
44
45 ListView->setAllColumnsShowFocus( TRUE );
46 ListView->setGeometry( QRect( 10, 35, 220, 240 ) );
47
48 // signals and slots connections
49 connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) );
50 connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
51 currentDir.setPath(QDir::currentDirPath());
52 populateList();
53}
54
55fileBrowser::~fileBrowser()
56{
57}
58
59
60void fileBrowser::populateList()
61{
62 ListView->clear();
63//qDebug(currentDir.canonicalPath());
64 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden );
65 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
66 currentDir.setMatchAllDirs(TRUE);
67
68 currentDir.setNameFilter(filterStr);
69// currentDir.setNameFilter("*.txt;*.etx");
70 QString fileL, fileS;
71 const QFileInfoList *list = currentDir.entryInfoList(QDir::All /*, QDir::SortByMask*/);
72 QFileInfoListIterator it(*list);
73 QFileInfo *fi;
74 while ( (fi=it.current()) ) {
75
76 if (fi->isSymLink() ){
77 QString symLink=fi->readLink();
78// qDebug("Symlink detected "+symLink);
79 QFileInfo sym( symLink);
80 fileS.sprintf( "%10li", sym.size() );
81 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
82
83 } else {
84// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
85 fileS.sprintf( "%10li", fi->size() );
86 fileL.sprintf( "%s",fi->fileName().data() );
87 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
88 fileL+="/";
89// qDebug(currentDir.canonicalPath()+fileL);
90 }
91 }
92 item= new QListViewItem( ListView,fileL,fileS );
93 ++it;
94 }
95 ListView->setSorting( 2, FALSE);
96 dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath());
97}
98
99void fileBrowser::upDir()
100{
101// qDebug(currentDir.canonicalPath());
102}
103
104void fileBrowser::listDoubleClicked(QListViewItem *selectedItem)
105{
106}
107
108// you may want to switch these 2 functions. I like single clicks
109void fileBrowser::listClicked(QListViewItem *selectedItem)
110{
111 QString strItem=selectedItem->text(0);
112 QString strSize=selectedItem->text(1);
113// qDebug("strItem is "+strItem);
114 strSize.stripWhiteSpace();
115// qDebug(strSize);
116
117 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
118 // is symlink
119 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4);
120// qDebug("strItem symlink is "+strItem2);
121 if(QDir(strItem2).exists() ) {
122 currentDir.cd(strItem2, TRUE);
123 populateList();
124 }
125 } else { // not a symlink
126 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
127 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
128 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
129 currentDir.cd(strItem,FALSE);
130// qDebug("Path is "+strItem);
131 populateList();
132 } else {
133 currentDir.cdUp();
134 populateList();
135 }
136 if(QDir(strItem).exists()){
137 currentDir.cd(strItem, TRUE);
138 populateList();
139 }
140 } else
141 if( QFile::exists(strItem ) ) {
142// qDebug("We found our files!!");
143 OnOK();
144 } //end not symlink
145 chdir(strItem.latin1());
146 }
147}
148
149void fileBrowser::OnOK()
150{
151 QListViewItemIterator it1( ListView);
152 for ( ; it1.current(); ++it1 ) {
153 if ( it1.current()->isSelected() ) {
154 selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0));
155// qDebug("selected filename is "+selectedFileName);
156 fileList.append( selectedFileName );
157 }
158 }
159 accept();
160}
diff --git a/core/apps/textedit/fileBrowser.h b/core/apps/textedit/fileBrowser.h
new file mode 100644
index 0000000..17ed862
--- a/dev/null
+++ b/core/apps/textedit/fileBrowser.h
@@ -0,0 +1,67 @@
1/****************************************************************************
2**
3** Created: Fri Dec 14 08:16:02 2001
4**
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
7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file.
9**
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.
12**
13copyright Sun 02-17-2002 22:28:23 L. J. Potter ljp@llornkcor.com
14****************************************************************************/
15#ifndef FILEBROWSER_H
16#define FILEBROWSER_H
17
18//#include <qvariant.h>
19#include <qdialog.h>
20#include <qfile.h>
21#include <qdir.h>
22#include <qstringlist.h>
23#include <qlabel.h>
24#include <qstring.h>
25
26class QVBoxLayout;
27class QHBoxLayout;
28class QGridLayout;
29class QListView;
30class QListViewItem;
31class QPushButton;
32
33class fileBrowser : public QDialog
34{
35 Q_OBJECT
36
37public:
38 void populateList();
39 fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0);
40 ~fileBrowser();
41
42 QPushButton* buttonOk;
43 QListView* ListView;
44 QPushButton* buttonCancel;
45 QLabel *dirLabel;
46 QString selectedFileName, filterStr;
47 QDir currentDir;
48 QFile file;
49 QStringList fileList;
50
51QListViewItem * item;
52public slots:
53
54private:
55
56private slots:
57 void upDir();
58 void listDoubleClicked(QListViewItem *);
59 void listClicked(QListViewItem *);
60 void OnOK();
61protected slots:
62
63protected:
64
65};
66
67#endif // FILEBROWSER_H
diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp
new file mode 100644
index 0000000..d01daee
--- a/dev/null
+++ b/core/apps/textedit/fileSaver.cpp
@@ -0,0 +1,164 @@
1/****************************************************************************
2** copyright 2001 ljp ljp@llornkcor.com
3** Created: Fri Dec 14 08:16:46 2001 fileSaver.cpp
4**
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
7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file.
9**
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.
12**
13****************************************************************************/
14#include "fileSaver.h"
15#include <qpe/config.h>
16#include <qpe/qpeapplication.h>
17
18#include <qlistview.h>
19#include <qpushbutton.h>
20#include <qfile.h>
21#include <qmessagebox.h>
22#include <unistd.h>
23#include <qlineedit.h>
24
25fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName )
26 : QDialog( parent, name, modal, fl )
27{
28 if ( !name )
29 setName( "fileSaver" );
30 resize( 236, 280 );
31 setCaption(tr( "Save file" ) );
32// filterStr=currentFileName;
33
34 dirLabel = new QLabel(this, "DirLabel");
35 dirLabel->setText(currentDir.canonicalPath());
36 dirLabel->setGeometry(10,4,230,30);
37
38 ListView = new QListView( this, "ListView" );
39 ListView->addColumn( tr( "Name" ) );
40 ListView->setColumnWidth(0,140);
41 ListView->setSorting( 2, FALSE);
42 ListView->addColumn( tr( "Size" ) );
43 ListView->setColumnWidth(1,59);
44// ListView->setMultiSelection(true);
45// ListView->setSelectionMode(QListView::Extended);
46
47 ListView->setAllColumnsShowFocus( TRUE );
48 ListView->setGeometry( QRect( 10, 35, 220, 160 ) );
49
50 fileEdit= new QLineEdit(this);
51 fileEdit->setGeometry( QRect( 10, 230, 200, 25));
52 fileEdit->setText(currentFileName);
53 // signals and slots connections
54 connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) );
55 connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
56 currentDir.setPath(QDir::currentDirPath() );
57 populateList();
58}
59
60fileSaver::~fileSaver()
61{
62}
63
64
65void fileSaver::populateList()
66{
67 ListView->clear();
68 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden );
69 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
70 currentDir.setMatchAllDirs(TRUE);
71
72 currentDir.setNameFilter("*");
73 QString fileL, fileS;
74 const QFileInfoList *list = currentDir.entryInfoList(QDir::All /*, QDir::SortByMask*/);
75 QFileInfoListIterator it(*list);
76 QFileInfo *fi;
77 while ( (fi=it.current()) ) {
78
79 if (fi->isSymLink() ){
80 QString symLink=fi->readLink();
81// qDebug("Symlink detected "+symLink);
82 QFileInfo sym( symLink);
83 fileS.sprintf( "%10li", sym.size() );
84 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
85
86 } else {
87// // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
88 fileS.sprintf( "%10li", fi->size() );
89 fileL.sprintf( "%s",fi->fileName().data() );
90 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
91 fileL+="/";
92// qDebug(currentDir.canonicalPath()+fileL);
93 }
94 }
95 item= new QListViewItem( ListView,fileL,fileS );
96 ++it;
97 }
98 ListView->setSorting( 2, FALSE);
99 dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath());
100
101
102}
103
104void fileSaver::upDir()
105{
106// qDebug(currentDir.canonicalPath());
107}
108
109void fileSaver::listDoubleClicked(QListViewItem *selectedItem)
110{
111}
112
113void fileSaver::listClicked(QListViewItem *selectedItem)
114{
115 QString strItem=selectedItem->text(0);
116 QString strSize=selectedItem->text(1);
117// qDebug("strItem is "+strItem);
118 strSize.stripWhiteSpace();
119// qDebug(strSize);
120
121 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
122 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4);
123// qDebug("strItem symlink is "+strItem2);
124 if(QDir(strItem2).exists() ) {
125 currentDir.cd(strItem2, TRUE);
126 populateList();
127 }
128 } else { // not a symlink
129 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
130 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
131 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
132 currentDir.cd(strItem,FALSE);
133// qDebug("Path is "+strItem);
134 populateList();
135 } else {
136 currentDir.cdUp();
137 populateList();
138 }
139 if(QDir(strItem).exists()){
140 currentDir.cd(strItem, TRUE);
141 populateList();
142 }
143 } // else
144// if( QFile::exists(strItem ) ) {
145// qDebug("We found our files!!");
146
147// OnOK();
148 } //end not symlink
149 chdir(strItem.latin1());
150
151
152}
153
154
155void fileSaver::OnOK()
156{
157// reject();
158}
159
160void fileSaver::accept() {
161 selectedFileName = fileEdit->text();
162 selectedFileName = currentDir.canonicalPath()+ selectedFileName;
163 reject();
164}
diff --git a/core/apps/textedit/fileSaver.h b/core/apps/textedit/fileSaver.h
new file mode 100644
index 0000000..f496270
--- a/dev/null
+++ b/core/apps/textedit/fileSaver.h
@@ -0,0 +1,71 @@
1/****************************************************************************
2**
3** Created: Fri Dec 14 08:16:02 2001 fileSaver.h
4**
5copyright Sun 02-17-2002 22:28:48 L. J. Potter ljp@llornkcor.com
6
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
9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file.
11**
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.
14**
15****************************************************************************/
16#ifndef FILESAVER_H
17#define FILESAVER_H
18
19//#include <qvariant.h>
20#include <qdialog.h>
21#include <qfile.h>
22#include <qdir.h>
23#include <qstringlist.h>
24#include <qlabel.h>
25#include <qstring.h>
26
27class QVBoxLayout;
28class QHBoxLayout;
29class QGridLayout;
30class QListView;
31class QListViewItem;
32class QPushButton;
33class QLineEdit;
34
35class fileSaver : public QDialog
36{
37 Q_OBJECT
38
39public:
40 void populateList();
41 fileSaver( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0);
42 ~fileSaver();
43 QLineEdit *fileEdit;
44
45 QPushButton* buttonOk;
46 QListView* ListView;
47 QPushButton* buttonCancel;
48 QLabel *dirLabel;
49 QString selectedFileName, filterStr;
50 QDir currentDir;
51 QFile file;
52 QStringList fileList;
53
54QListViewItem * item;
55public slots:
56
57private:
58
59private slots:
60 void accept();
61 void upDir();
62 void listDoubleClicked(QListViewItem *);
63 void listClicked(QListViewItem *);
64 void OnOK();
65protected slots:
66
67protected:
68
69};
70
71#endif // FILESAVER_H
diff --git a/core/apps/textedit/fontDialog.cpp b/core/apps/textedit/fontDialog.cpp
new file mode 100644
index 0000000..e7bd924
--- a/dev/null
+++ b/core/apps/textedit/fontDialog.cpp
@@ -0,0 +1,236 @@
1/****************************************************************************
2** Created: Sun Jan 27 11:03:24 2002 fileDialog.cpp
3copyright 2002 by L.J. Potter ljp@llornkcor.com
4
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
7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file.
9**
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.
12**
13****************************************************************************/
14#include "fontDialog.h"
15
16#include <qpe/fontdatabase.h>
17#include <qpe/config.h>
18
19#include <qstringlist.h>
20#include <qfontinfo.h>
21#include <qvaluelist.h>
22#include <qpe/qpeapplication.h>
23
24#include <qgroupbox.h>
25#include <qlabel.h>
26#include <qlistbox.h>
27#include <qmultilineedit.h>
28#include <qpushbutton.h>
29#include <qlayout.h>
30#include <qvariant.h>
31#include <qtooltip.h>
32#include <qwhatsthis.h>
33
34FontDialog::FontDialog( QWidget * parent, const char* name , bool modal, WFlags fl )
35 :QDialog /*QWidget*/( parent, name , modal, fl )
36{
37 if ( !name )
38 setName( "FontDialog" );
39 setCaption( tr( "Font Dialog" ) );
40 FontTextLabel4 = new QLabel( this, "TextLabel4" );
41 FontTextLabel4->setGeometry( QRect( 145, 100, 30, 19 /*192, 0, 43, 19*/ ) );
42 FontTextLabel4->setText( tr( "Size" ) );
43
44 FamilyGroup = new QGroupBox( this, "FamilyGroup" );
45 FamilyGroup->setGeometry( QRect( 5, 5, 115, 135 /*0, 6, 185, 131 */) );
46 FamilyGroup->setTitle( tr( "Font" ) );
47
48 familyListBox = new QListBox( FamilyGroup, "familyListBox" );
49 familyListBox->setGeometry( QRect( 5, 20, 100, 105 /* 6, 18, 170, 105 */) );
50
51 GroupBox2 = new QGroupBox( this, "GroupBox2" );
52 GroupBox2->setGeometry( QRect( 120, 5, 100, 90/* 0, 138, 170, 90*/ ) );
53 GroupBox2->setTitle( tr( "Font Style" ) );
54
55 styleListBox = new QListBox( GroupBox2, "styleListBox" );
56 styleListBox->setGeometry( QRect( 5, 20, 90, 60 /*10, 20, 150, 61*/ ) );
57
58 sizeListBox = new QListBox( this, "sizeListBox" );
59 sizeListBox->setGeometry( QRect( 180, 100, 40, 60 /* 192, 24, 40, 108 */) );
60
61 MultiLineEdit1 = new QMultiLineEdit( this, "MultiLineEdit1" );
62 MultiLineEdit1->setGeometry( QRect( 5, 165, 215, 45 /* 6, 234, 222, 55*/ ) );
63 MultiLineEdit1->setText( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" ) );
64 MultiLineEdit1->setWordWrap(QMultiLineEdit::WidgetWidth);
65
66 connect( familyListBox,SIGNAL( highlighted( const QString &)),SLOT( familyListBoxSlot(const QString &) ));
67 connect( styleListBox,SIGNAL( highlighted( const QString &)),SLOT( styleListBoxSlot(const QString &) ));
68 connect( sizeListBox,SIGNAL( highlighted( const QString &)),SLOT( sizeListBoxSlot(const QString &) ));
69
70 populateLists();
71// MultiLineEdit1
72// connect();
73
74}
75
76FontDialog::~FontDialog()
77{
78}
79
80void FontDialog::familyListBoxSlot(const QString & text)
81{
82 int styleInt=styleListBox->currentItem();
83 int sizeInt=sizeListBox->currentItem();
84
85 styleListBox->clear();
86 sizeListBox->clear();
87 family= text;
88// qDebug(family);
89 QStringList styles = fdb.styles( family ); // string list of styles of our current font family
90 styleListBox->insertStringList( styles);
91 QString dstyle;// = "\t" + style + " (";
92 QValueList<int> smoothies = fdb.smoothSizes( family, styleListBox->text(0) );
93 for ( QValueList<int>::Iterator points = smoothies.begin(); points != smoothies.end(); ++points ) {
94 dstyle = QString::number( *points );
95 sizeListBox ->insertItem( dstyle.left( dstyle.length() - 1 ));
96 }
97 if(styleInt == -1 || styleInt > styleListBox->count() )
98 styleListBox->setCurrentItem(0);
99 else
100 styleListBox->setCurrentItem(styleInt);
101
102 if(sizeInt == -1 || sizeInt > sizeListBox->count())
103 sizeListBox->setCurrentItem(0);
104 else
105 sizeListBox->setCurrentItem(sizeInt);
106
107 changeText();
108}
109
110void FontDialog::styleListBoxSlot(const QString &text)
111{
112 changeText();
113}
114
115void FontDialog::sizeListBoxSlot(const QString & text)
116{
117 changeText();
118}
119
120void FontDialog::populateLists()
121{
122// QFont defaultFont=MultiLineEdit1->font();
123// QFont defaultFont=Lview->font();
124// QFontInfo fontInfo(defaultFont);
125 Config config("TextEdit");
126 config.setGroup("Font");
127 QString familyStr = config.readEntry("Family", "fixed");
128 QString styleStr = config.readEntry("Style", "Regular");
129 QString sizeStr = config.readEntry("Size", "10");
130 QString charSetStr = config.readEntry("CharSet", "iso10646-1" );
131 bool ok;
132 int i_size=sizeStr.toInt(&ok,10);
133 selectedFont = fdb.font(familyStr,styleStr,i_size,charSetStr);
134// defaultFont.setItalic(TRUE);
135 families = fdb.families();
136 for ( QStringList::Iterator f = families.begin(); f != families.end();++f ) {
137 QString family = *f;
138// if(family == defaultFont.family())
139// qDebug(family);
140 familyListBox->insertItem( family);
141
142 if( familyListBox->text(0) == family) {
143 QStringList styles = fdb.styles( family ); // string list of styles of our current font family
144 styleListBox->insertStringList( styles);
145 for ( QStringList::Iterator s = styles.begin(); s != styles.end();++s ) { // for each font style
146 style = *s;
147 QString dstyle;// = "\t" + style + " (";
148 if(styleListBox->text(0) == style) {
149 QValueList<int> smoothies = fdb.smoothSizes( family, style );
150 for ( QValueList<int>::Iterator points = smoothies.begin(); points != smoothies.end(); ++points ) {
151 dstyle = QString::number( *points ) + " ";
152
153 sizeListBox ->insertItem( dstyle.left( dstyle.length() - 1 ));
154 }
155 dstyle = dstyle.left( dstyle.length() - 1 ) + ")";
156 }
157 } // styles
158 }
159 }
160 for(int i=0;i < familyListBox->count();i++) {
161 if( familyListBox->text(i) == familyStr)
162 familyListBox->setSelected( i, TRUE);
163 }
164
165 for(int i=0;i < styleListBox->count();i++) {
166 if( styleListBox->text(i) == styleStr)
167 styleListBox->setSelected( i, TRUE);
168 }
169
170 for(int i=0;i < sizeListBox->count();i++) {
171 if( sizeListBox->text(i) == sizeStr)
172 sizeListBox->setSelected( i, TRUE);
173 }
174 changeText();
175}
176
177void FontDialog::clearListBoxes() {
178 familyListBox->clear();
179 sizeListBox->clear();
180 styleListBox->clear();
181}
182
183void FontDialog::changeText()
184{
185 if( familyListBox->currentItem() == -1)
186 family= familyListBox->text(0);
187 else {
188 family = familyListBox->currentText();
189 }
190// qDebug("Font family is "+family);
191 if( styleListBox->currentItem() == -1)
192 style=styleListBox->text(0);
193 else {
194 style = styleListBox->currentText();
195 }
196// qDebug("font style is "+style);
197 if( sizeListBox->currentItem() == -1 )
198 size= sizeListBox->text(0);
199 else {
200 size = sizeListBox->currentText();
201 }
202
203// qDebug("Font size is "+size);
204 bool ok;
205 int i_size= size.toInt(&ok,10);
206 QStringList charSetList= fdb.charSets(family);
207// QStringList styles = fdb.styles( family ); // string list of styles of our current font family
208 QString charSet;
209 for ( QStringList::Iterator s = charSetList.begin(); s != charSetList.end();++s ) { // for each font style
210 charSet = *s;
211// qDebug(charSet);
212 }
213 selectedFont = fdb.font(family,style,i_size,charSet);
214 QFontInfo fontInfo( selectedFont);
215// if(fontInfo.italic() ) qDebug("italic");
216 selectedFont.setWeight(fontInfo.weight() );
217// qDebug("Style are "+style+" %d ",fontInfo.weight());
218 Config cfg("TextEdit");
219 cfg.setGroup("Font");
220 cfg.writeEntry("Family",family);
221 cfg.writeEntry("Style",style);
222 cfg.writeEntry("Size",size);
223 cfg.writeEntry("CharSet",charSet);
224
225 if(style.find("Italic",0,TRUE) != -1) {
226 selectedFont = fdb.font(family,"Regular",i_size,charSet);
227 selectedFont.setItalic(TRUE); //ya right
228 cfg.writeEntry("Italic","TRUE");
229// qDebug("Style is "+styleListBox->currentText());
230 } else
231 cfg.writeEntry("Italic","FALSE");
232 changedFonts=TRUE;
233 MultiLineEdit1->setFont( selectedFont);
234 MultiLineEdit1->update();
235}
236
diff --git a/core/apps/textedit/fontDialog.h b/core/apps/textedit/fontDialog.h
new file mode 100644
index 0000000..ef930df
--- a/dev/null
+++ b/core/apps/textedit/fontDialog.h
@@ -0,0 +1,63 @@
1/****************************************************************************
2** Created: Sun Jan 27 11:02:59 2002 fileDialog.h
3copyright 2002 by L.J. Potter ljp@llornkcor.com
4
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
7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file.
9**
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.
12**
13****************************************************************************/
14#ifndef FONTDIALOG_H
15#define FONTDIALOG_H
16
17#include <qvariant.h>
18#include <qdialog.h>
19#include <qpe/fontdatabase.h>
20#include <qfont.h>
21
22class QVBoxLayout;
23class QHBoxLayout;
24class QGridLayout;
25class QLabel;
26class QListBox;
27class QListBoxItem;
28class QPushButton;
29class QGroupBox;
30class QMultiLineEdit;
31
32class FontDialog : public QDialog// QWidget
33{
34 Q_OBJECT
35
36public:
37 FontDialog( QWidget * parent = 0, const char* name = 0 , bool modal=FALSE, WFlags fl = 0 );
38 ~FontDialog();
39
40 QLabel *FontTextLabel4;
41 QGroupBox *FamilyGroup, *GroupBox2;
42 QListBox *familyListBox, *styleListBox, *sizeListBox;
43 QMultiLineEdit *MultiLineEdit1;
44 QPushButton *PushButtonOk,*PushButtonCancel;
45 QStringList families;
46
47 FontDatabase fdb;
48 QString family, style, size;
49 QFont selectedFont;
50 bool changedFonts;
51 void populateLists();
52 void clearListBoxes();
53 void changeText();
54protected slots:
55
56 void familyListBoxSlot(const QString &);
57 void styleListBoxSlot(const QString &);
58 void sizeListBoxSlot(const QString &);
59
60
61};
62
63#endif // FONTDIALOG_H
diff --git a/core/apps/textedit/inserttable.ui b/core/apps/textedit/inserttable.ui
deleted file mode 100644
index 09fe3c3..0000000
--- a/core/apps/textedit/inserttable.ui
+++ b/dev/null
@@ -1,103 +0,0 @@
1<!DOCTYPE UI><UI>
2<class>InsertTable</class><comment>*********************************************************************
3** Copyright (C) 2000 Trolltech AS. All rights reserved.
4**
5** This file is part of Qtopia Environment.
6**
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
9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file.
11**
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.
14**
15** See http://www.trolltech.com/gpl/ for GPL licensing information.
16**
17** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you.
19**
20*********************************************************************</comment>
21<widget>
22 <class>QDialog</class>
23 <property stdset="1">
24 <name>name</name>
25 <cstring>InsertTable</cstring>
26 </property>
27 <property stdset="1">
28 <name>geometry</name>
29 <rect>
30 <x>0</x>
31 <y>0</y>
32 <width>165</width>
33 <height>79</height>
34 </rect>
35 </property>
36 <property stdset="1">
37 <name>caption</name>
38 <string>Insert Table</string>
39 </property>
40 <grid>
41 <property stdset="1">
42 <name>margin</name>
43 <number>11</number>
44 </property>
45 <property stdset="1">
46 <name>spacing</name>
47 <number>6</number>
48 </property>
49 <widget row="0" column="0" >
50 <class>QLabel</class>
51 <property stdset="1">
52 <name>name</name>
53 <cstring>TextLabel1</cstring>
54 </property>
55 <property stdset="1">
56 <name>text</name>
57 <string>Rows:</string>
58 </property>
59 </widget>
60 <widget row="0" column="1" >
61 <class>QSpinBox</class>
62 <property stdset="1">
63 <name>name</name>
64 <cstring>spinRows</cstring>
65 </property>
66 <property stdset="1">
67 <name>minValue</name>
68 <number>1</number>
69 </property>
70 <property stdset="1">
71 <name>value</name>
72 <number>1</number>
73 </property>
74 </widget>
75 <widget row="1" column="1" >
76 <class>QSpinBox</class>
77 <property stdset="1">
78 <name>name</name>
79 <cstring>spinColumns</cstring>
80 </property>
81 <property stdset="1">
82 <name>minValue</name>
83 <number>1</number>
84 </property>
85 <property stdset="1">
86 <name>value</name>
87 <number>1</number>
88 </property>
89 </widget>
90 <widget row="1" column="0" >
91 <class>QLabel</class>
92 <property stdset="1">
93 <name>name</name>
94 <cstring>TextLabel1_2</cstring>
95 </property>
96 <property stdset="1">
97 <name>text</name>
98 <string>Columns:</string>
99 </property>
100 </widget>
101 </grid>
102</widget>
103</UI>
diff --git a/core/apps/textedit/qtextedit.h b/core/apps/textedit/qtextedit.h
deleted file mode 100644
index b29a728..0000000
--- a/core/apps/textedit/qtextedit.h
+++ b/dev/null
@@ -1,282 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#ifndef QTEXTEDIT_H
22#define QTEXTEDIT_H
23
24#include <qscrollview.h>
25#include <qstylesheet.h>
26#include <qpainter.h>
27
28class QPainter;
29class QTextDocument;
30class QTextCursor;
31class QKeyEvent;
32class QResizeEvent;
33class QMouseEvent;
34class QTimer;
35class QTextString;
36class QVBox;
37class QListBox;
38class QTextCommand;
39class QTextParag;
40class QTextFormat;
41class QFont;
42class QColor;
43
44class QTextEdit : public QScrollView
45{
46 Q_OBJECT
47
48public:
49 QTextEdit( QWidget *parent, const QString &fn, bool tabify = FALSE );
50 QTextEdit( QWidget *parent = 0, const char *name = 0 );
51 virtual ~QTextEdit();
52
53#if defined(QTEXTEDIT_OPEN_API)
54 QTextDocument *document() const;
55 QTextCursor *textCursor() const;
56#endif
57
58 QString text() const;
59 QString text( int parag, bool formatted = FALSE ) const;
60 Qt::TextFormat textFormat() const;
61 QString fileName() const;
62
63 void cursorPosition( int &parag, int &index );
64 void selection( int &parag_from, int &index_from,
65 int &parag_to, int &index_to );
66 virtual bool find( const QString &expr, bool cs, bool wo, bool forward = TRUE,
67 int *parag = 0, int *index = 0 );
68 void insert( const QString &text, bool indent = FALSE, bool checkNewLine = FALSE );
69
70 int paragraphs() const;
71 int lines() const;
72 int linesOfParagraph( int parag ) const;
73 int lineOfChar( int parag, int chr );
74
75 bool isModified() const;
76
77 bool italic() const;
78 bool bold() const;
79 bool underline() const;
80 QString family() const;
81 int pointSize() const;
82 QColor color() const;
83 QFont font() const;
84 int alignment() const;
85 int maxLines() const;
86
87 const QStyleSheet* styleSheet() const;
88 void setStyleSheet( const QStyleSheet* styleSheet );
89
90 void setPaper( const QBrush& pap);
91 QBrush paper() const;
92
93 void setLinkColor( const QColor& );
94 QColor linkColor() const;
95
96 void setLinkUnderline( bool );
97 bool linkUnderline() const;
98
99 void setMimeSourceFactory( const QMimeSourceFactory* factory );
100 const QMimeSourceFactory* mimeSourceFactory() const;
101
102 int heightForWidth( int w ) const;
103
104 void append( const QString& text );
105
106 bool hasSelectedText() const;
107 QString selectedText() const;
108
109 QString context() const;
110
111 QString documentTitle() const;
112
113 void scrollToAnchor( const QString& name );
114 QString anchorAt(const QPoint& pos);
115
116public slots:
117 virtual void undo();
118 virtual void redo();
119
120 virtual void cut();
121 virtual void copy();
122 virtual void paste();
123
124 virtual void indent();
125
126 virtual void setItalic( bool b );
127 virtual void setBold( bool b );
128 virtual void setUnderline( bool b );
129 virtual void setFamily( const QString &f );
130 virtual void setPointSize( int s );
131 virtual void setColor( const QColor &c );
132 virtual void setFont( const QFont &f );
133
134 virtual void setAlignment( int );
135
136 virtual void setParagType( QStyleSheetItem::DisplayMode, int listStyle );
137
138 virtual void setTextFormat( Qt::TextFormat f );
139 virtual void setText( const QString &txt, const QString &context = QString::null ) { setText( txt, context, FALSE ); }
140 virtual void setText( const QString &txt, const QString &context, bool tabify );
141
142 virtual void load( const QString &fn ) { load( fn, FALSE ); }
143 virtual void load( const QString &fn, bool tabify );
144 virtual void save( bool untabify = FALSE ) { save( QString::null, untabify ); }
145 virtual void save( const QString &fn, bool untabify = FALSE );
146
147 virtual void setCursorPosition( int parag, int index );
148 virtual void setSelection( int parag_from, int index_from,
149 int parag_to, int index_to );
150
151 virtual void setModified( bool m );
152 virtual void selectAll( bool select );
153
154 virtual void setMaxLines( int l );
155 virtual void resetFormat();
156
157signals:
158 void currentFontChanged( const QFont &f );
159 void currentColorChanged( const QColor &c );
160 void currentAlignmentChanged( int );
161 void textChanged();
162 void highlighted( const QString& );
163 void linkClicked( const QString& );
164
165protected:
166 void setFormat( QTextFormat *f, int flags );
167 void drawContents( QPainter *p, int cx, int cy, int cw, int ch );
168 void keyPressEvent( QKeyEvent *e );
169 void resizeEvent( QResizeEvent *e );
170 void contentsMousePressEvent( QMouseEvent *e );
171 void contentsMouseMoveEvent( QMouseEvent *e );
172 void contentsMouseReleaseEvent( QMouseEvent *e );
173 void contentsMouseDoubleClickEvent( QMouseEvent *e );
174#ifndef QT_NO_DRAGANDDROP
175 void contentsDragEnterEvent( QDragEnterEvent *e );
176 void contentsDragMoveEvent( QDragMoveEvent *e );
177 void contentsDragLeaveEvent( QDragLeaveEvent *e );
178 void contentsDropEvent( QDropEvent *e );
179#endif
180 bool eventFilter( QObject *o, QEvent *e );
181 bool focusNextPrevChild( bool next );
182#if !defined(QTEXTEDIT_OPEN_API)
183 QTextDocument *document() const;
184 QTextCursor *textCursor() const;
185#endif
186
187private slots:
188 void formatMore();
189 void doResize();
190 void doAutoScroll();
191 void doChangeInterval();
192 void blinkCursor();
193 void setModified();
194 void startDrag();
195
196private:
197 enum MoveDirection {
198 MoveLeft,
199 MoveRight,
200 MoveUp,
201 MoveDown,
202 MoveHome,
203 MoveEnd,
204 MovePgUp,
205 MovePgDown
206 };
207 enum KeyboardAction {
208 ActionBackspace,
209 ActionDelete,
210 ActionReturn
211 };
212
213 struct UndoRedoInfo {
214 enum Type { Invalid, Insert, Delete, Backspace, Return, RemoveSelected };
215 UndoRedoInfo( QTextDocument *d ) : type( Invalid ), doc( d )
216 { text = QString::null; id = -1; index = -1; }
217 void clear();
218 inline bool valid() const { return !text.isEmpty() && id >= 0&& index >= 0; }
219
220 QString text;
221 int id;
222 int index;
223 Type type;
224 QTextDocument *doc;
225 };
226
227private:
228 virtual bool isReadOnly() const { return FALSE; }
229 virtual bool linksEnabled() const { return TRUE; }
230 void init();
231 void ensureCursorVisible();
232 void drawCursor( bool visible );
233 void placeCursor( const QPoint &pos, QTextCursor *c = 0 );
234 void moveCursor( int direction, bool shift, bool control );
235 void moveCursor( int direction, bool control );
236 void removeSelectedText();
237 void doKeyboardAction( int action );
238 bool doCompletion();
239 void checkUndoRedoInfo( UndoRedoInfo::Type t );
240 void repaintChanged();
241 void updateCurrentFormat();
242 void handleReadOnlyKeyEvent( QKeyEvent *e );
243 void makeParagVisible( QTextParag *p );
244
245private:
246 QTextDocument *doc;
247 QTextCursor *cursor;
248 bool drawAll;
249 bool mousePressed;
250 QTimer *formatTimer, *scrollTimer, *changeIntervalTimer, *blinkTimer, *dragStartTimer, *resizeTimer;
251 QTextParag *lastFormatted;
252 int interval;
253 QVBox *completionPopup;
254 QListBox *completionListBox;
255 int completionOffset;
256 UndoRedoInfo undoRedoInfo;
257 QTextFormat *currentFormat;
258 QPainter painter;
259 int currentAlignment;
260 bool inDoubleClick;
261 QPoint oldMousePos, mousePos;
262 QPixmap *buf_pixmap;
263 bool cursorVisible, blinkCursorVisible;
264 bool readOnly, modified, mightStartDrag;
265 QPoint dragStartPos;
266 int mLines;
267 bool firstResize;
268 QString onLink;
269
270};
271
272inline QTextDocument *QTextEdit::document() const
273{
274 return doc;
275}
276
277inline QTextCursor *QTextEdit::textCursor() const
278{
279 return cursor;
280}
281
282#endif
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 867625e..14bc496 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -17,9 +17,15 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// changes added by L. J. Potter Sun 02-17-2002 21:31:31
20 21
21#include "textedit.h" 22#include "textedit.h"
23#include "fileBrowser.h"
24#include "fileSaver.h"
22 25
26#include "fontDialog.h"
27
28#include <qpe/fontdatabase.h>
23#include <qpe/global.h> 29#include <qpe/global.h>
24#include <qpe/fileselector.h> 30#include <qpe/fileselector.h>
25#include <qpe/applnk.h> 31#include <qpe/applnk.h>
@@ -30,6 +36,7 @@
30#include <qpe/qpetoolbar.h> 36#include <qpe/qpetoolbar.h>
31//#include <qpe/finddialog.h> 37//#include <qpe/finddialog.h>
32 38
39#include <qstringlist.h>
33#include <qaction.h> 40#include <qaction.h>
34#include <qcolordialog.h> 41#include <qcolordialog.h>
35#include <qfileinfo.h> 42#include <qfileinfo.h>
@@ -42,6 +49,103 @@
42#include <qwidgetstack.h> 49#include <qwidgetstack.h>
43 50
44#include <stdlib.h> //getenv 51#include <stdlib.h> //getenv
52/* XPM */
53static char * filesave_xpm[] = {
54"16 16 78 1",
55" c None",
56". c #343434",
57"+ c #A0A0A0",
58"@ c #565656",
59"# c #9E9E9E",
60"$ c #525252",
61"% c #929292",
62"& c #676767",
63"* c #848484",
64"= c #666666",
65"- c #D8D8D8",
66"; c #FFFFFF",
67"> c #DBDBDB",
68", c #636363",
69"' c #989898",
70") c #2D2D2D",
71"! c #909090",
72"~ c #AEAEAE",
73"{ c #EAEAEA",
74"] c #575757",
75"^ c #585858",
76"/ c #8A8A8A",
77"( c #828282",
78"_ c #6F6F6F",
79": c #C9C9C9",
80"< c #050505",
81"[ c #292929",
82"} c #777777",
83"| c #616161",
84"1 c #3A3A3A",
85"2 c #BEBEBE",
86"3 c #2C2C2C",
87"4 c #7C7C7C",
88"5 c #F6F6F6",
89"6 c #FCFCFC",
90"7 c #6B6B6B",
91"8 c #959595",
92"9 c #4F4F4F",
93"0 c #808080",
94"a c #767676",
95"b c #818181",
96"c c #B8B8B8",
97"d c #FBFBFB",
98"e c #F9F9F9",
99"f c #CCCCCC",
100"g c #030303",
101"h c #737373",
102"i c #7A7A7A",
103"j c #7E7E7E",
104"k c #6A6A6A",
105"l c #FAFAFA",
106"m c #505050",
107"n c #9D9D9D",
108"o c #333333",
109"p c #7B7B7B",
110"q c #787878",
111"r c #696969",
112"s c #494949",
113"t c #555555",
114"u c #949494",
115"v c #E6E6E6",
116"w c #424242",
117"x c #515151",
118"y c #535353",
119"z c #3E3E3E",
120"A c #D4D4D4",
121"B c #0C0C0C",
122"C c #353535",
123"D c #474747",
124"E c #ECECEC",
125"F c #919191",
126"G c #7D7D7D",
127"H c #000000",
128"I c #404040",
129"J c #858585",
130"K c #323232",
131"L c #D0D0D0",
132"M c #1C1C1C",
133" ...+ ",
134" @#$%&..+ ",
135" .*=-;;>,..+ ",
136" ')!~;;;;;;{]..",
137" ^/(-;;;;;;;_:<",
138" [}|;;;;;;;{12$",
139" #34-55;;;;678$+",
140" 90ab=c;dd;e1fg ",
141" [ahij((kbl0mn$ ",
142" op^q^^7r&]s/$+ ",
143"@btu;vbwxy]zAB ",
144"CzDEvEv;;DssF$ ",
145"G.H{E{E{IxsJ$+ ",
146" +...vEKxzLM ",
147" +...z]n$ ",
148" +... "};
45 149
46 150
47#if QT_VERSION < 300 151#if QT_VERSION < 300
@@ -51,7 +155,11 @@ class QpeEditor : public QMultiLineEdit
51 // Q_OBJECT 155 // Q_OBJECT
52public: 156public:
53 QpeEditor( QWidget *parent, const char * name = 0 ) 157 QpeEditor( QWidget *parent, const char * name = 0 )
54 : QMultiLineEdit( parent, name ) {} 158 : QMultiLineEdit( parent, name )
159 {
160 clearTableFlags();
161 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar );
162 }
55 163
56 //public slots: 164 //public slots:
57 void find( const QString &txt, bool caseSensitive, 165 void find( const QString &txt, bool caseSensitive,
@@ -63,43 +171,43 @@ signals:
63 */ 171 */
64 172
65private: 173private:
66 174
67}; 175};
68 176
69 177
70void QpeEditor::find ( const QString &txt, bool caseSensitive, 178void QpeEditor::find ( const QString &txt, bool caseSensitive,
71 bool backwards ) 179 bool backwards )
72{ 180{
73 static bool wrap = FALSE; 181 static bool wrap = FALSE;
74 int line, col; 182 int line, col;
75 if ( wrap ) { 183 if ( wrap ) {
76 if ( !backwards ) 184 if ( !backwards )
77 line = col = 0; 185 line = col = 0;
78 wrap = FALSE; 186 wrap = FALSE;
79 //emit searchWrapped(); 187 // emit searchWrapped();
80 } else { 188 } else {
81 getCursorPosition( &line, &col ); 189 getCursorPosition( &line, &col );
82 } 190 }
83 //ignore backwards for now.... 191 //ignore backwards for now....
84 if ( !backwards ) { 192 if ( !backwards ) {
85 for ( ; ; ) { 193 for ( ; ; ) {
86 if ( line >= numLines() ) { 194 if ( line >= numLines() ) {
87 wrap = TRUE; 195 wrap = TRUE;
88 //emit notFound(); 196 //emit notFound();
89 break; 197 break;
90 } 198 }
91 int findCol = getString( line )->find( txt, col, caseSensitive ); 199 int findCol = getString( line )->find( txt, col, caseSensitive );
92 if ( findCol >= 0 ) { 200 if ( findCol >= 0 ) {
93 setCursorPosition( line, findCol, FALSE ); 201 setCursorPosition( line, findCol, FALSE );
94 col = findCol + txt.length(); 202 col = findCol + txt.length();
95 setCursorPosition( line, col, TRUE ); 203 setCursorPosition( line, col, TRUE );
96 204
97 //found = TRUE; 205 //found = TRUE;
98 break; 206 break;
99 } 207 }
100 line++; 208 line++;
101 col = 0; 209 col = 0;
102 } 210 }
103 211
104 } 212 }
105 213
@@ -129,8 +237,6 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
129{ 237{
130 doc = 0; 238 doc = 0;
131 239
132 QString lang = getenv( "LANG" );
133
134 setToolBarsMovable( FALSE ); 240 setToolBarsMovable( FALSE );
135 241
136 setIcon( Resource::loadPixmap( "TextEditor" ) ); 242 setIcon( Resource::loadPixmap( "TextEditor" ) );
@@ -154,9 +260,21 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
154 260
155 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 261 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
156 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 262 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
263// a->addTo( bar );
264 a->addTo( file );
265
266 a = new QAction( tr( "Browse" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
267 connect( a, SIGNAL( activated() ), this, SLOT( newFileOpen() ) );
157 a->addTo( bar ); 268 a->addTo( bar );
158 a->addTo( file ); 269 a->addTo( file );
159 270
271//
272 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
273 connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
274// a->addTo( bar );
275 file->insertSeparator();
276 a->addTo( file );
277
160 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); 278 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 );
161 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 279 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
162 a->addTo( editBar ); 280 a->addTo( editBar );
@@ -180,14 +298,13 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
180 298
181 int defsize; 299 int defsize;
182 bool defb, defi, wrap; 300 bool defb, defi, wrap;
183 { 301
184 Config cfg("TextEdit"); 302 Config cfg("TextEdit");
185 cfg.setGroup("View"); 303 cfg.setGroup("View");
186 defsize = cfg.readNumEntry("FontSize",10); 304 defsize = cfg.readNumEntry("FontSize",10);
187 defb = cfg.readBoolEntry("Bold",FALSE); 305 defb = cfg.readBoolEntry("Bold",FALSE);
188 defi = cfg.readBoolEntry("Italic",FALSE); 306 defi = cfg.readBoolEntry("Italic",FALSE);
189 wrap = cfg.readBoolEntry("Wrap",TRUE); 307 wrap = cfg.readBoolEntry("Wrap",TRUE);
190 }
191 308
192 zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); 309 zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 );
193 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); 310 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) );
@@ -199,7 +316,7 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
199 316
200 font->insertSeparator(); 317 font->insertSeparator();
201 318
202#if 0 319#if 0
203 QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); 320 QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 );
204 connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); 321 connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) );
205 ba->setToggleAction(TRUE); 322 ba->setToggleAction(TRUE);
@@ -212,7 +329,7 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
212 329
213 ba->setOn(defb); 330 ba->setOn(defb);
214 ia->setOn(defi); 331 ia->setOn(defi);
215 332
216 font->insertSeparator(); 333 font->insertSeparator();
217#endif 334#endif
218 335
@@ -221,6 +338,9 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
221 wa->setToggleAction(TRUE); 338 wa->setToggleAction(TRUE);
222 wa->addTo( font ); 339 wa->addTo( font );
223 340
341 font->insertSeparator();
342 font->insertItem("Font", this, SLOT(changeFont()) );
343
224 mb->insertItem( tr( "File" ), file ); 344 mb->insertItem( tr( "File" ), file );
225 mb->insertItem( tr( "Edit" ), edit ); 345 mb->insertItem( tr( "Edit" ), edit );
226 mb->insertItem( tr( "View" ), font ); 346 mb->insertItem( tr( "View" ), font );
@@ -233,7 +353,8 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
233 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 353 searchEdit = new QLineEdit( searchBar, "searchEdit" );
234 searchBar->setStretchableWidget( searchEdit ); 354 searchBar->setStretchableWidget( searchEdit );
235 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 355 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
236 this, SLOT( search() ) ); 356 this, SLOT( search() ) );
357
237 358
238 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); 359 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 );
239 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 360 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
@@ -245,27 +366,50 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
245 a->addTo( searchBar ); 366 a->addTo( searchBar );
246 367
247 searchBar->hide(); 368 searchBar->hide();
248 369
249 editorStack = new QWidgetStack( this ); 370 editorStack = new QWidgetStack( this );
250 setCentralWidget( editorStack ); 371 setCentralWidget( editorStack );
251 372
252 searchVisible = FALSE; 373 searchVisible = FALSE;
253 374
254 fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , 375 fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //buggy
255 TRUE, FALSE );
256 fileSelector->setCategoriesVisible(TRUE);
257 connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); 376 connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) );
258 connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 377 connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
259 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) ); 378 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) );
260 fileOpen(); 379// fileOpen();
261 380
262 editor = new QpeEditor( editorStack ); 381 editor = new QpeEditor( editorStack );
382 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
263 editorStack->addWidget( editor, get_unique_id() ); 383 editorStack->addWidget( editor, get_unique_id() );
264 384
265 resize( 200, 300 ); 385 resize( 200, 300 );
266 386
267 setFontSize(defsize,TRUE); 387// setFontSize(defsize,TRUE);
388 FontDatabase fdb;
389 QFont defaultFont=editor->font();
390 QFontInfo fontInfo(defaultFont);
391
392 cfg.setGroup("Font");
393 QString family = cfg.readEntry("Family", fontInfo.family());
394 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
395 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
396 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
397
398 defaultFont = fdb.font(family,style,i_size,charSet);
399 editor->setFont( defaultFont);
400
268 wa->setOn(wrap); 401 wa->setOn(wrap);
402 updateCaption();
403 if( qApp->argc() > 1 ) {
404 for (int i=1;i< qApp->argc();i++) {
405 QString tmp;
406 currentFileName = tmp.sprintf("%s",qApp->argv()[i]);
407 qDebug(currentFileName);
408 setDocument( currentFileName );
409 }
410 }
411 else
412 fileNew();
269} 413}
270 414
271TextEdit::~TextEdit() 415TextEdit::~TextEdit()
@@ -296,18 +440,18 @@ void TextEdit::setFontSize(int sz, bool round_down_not_up)
296{ 440{
297 int s=10; 441 int s=10;
298 for (int i=0; i<nfontsizes; i++) { 442 for (int i=0; i<nfontsizes; i++) {
299 if ( fontsize[i] == sz ) { 443 if ( fontsize[i] == sz ) {
300 s = sz; 444 s = sz;
301 break; 445 break;
302 } else if ( round_down_not_up ) { 446 } else if ( round_down_not_up ) {
303 if ( fontsize[i] < sz ) 447 if ( fontsize[i] < sz )
304 s = fontsize[i]; 448 s = fontsize[i];
305 } else { 449 } else {
306 if ( fontsize[i] > sz ) { 450 if ( fontsize[i] > sz ) {
307 s = fontsize[i]; 451 s = fontsize[i];
308 break; 452 break;
309 } 453 }
310 } 454 }
311 } 455 }
312 456
313 QFont f = editor->font(); 457 QFont f = editor->font();
@@ -334,7 +478,9 @@ void TextEdit::setItalic(bool y)
334 478
335void TextEdit::setWordWrap(bool y) 479void TextEdit::setWordWrap(bool y)
336{ 480{
481 bool state = editor->edited();
337 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); 482 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
483 editor->setEdited( state );
338} 484}
339 485
340void TextEdit::fileNew() 486void TextEdit::fileNew()
@@ -345,21 +491,21 @@ void TextEdit::fileNew()
345 491
346void TextEdit::fileOpen() 492void TextEdit::fileOpen()
347{ 493{
348 if ( !save() ) { 494// if ( !save() ) {
349 if ( QMessageBox::critical( this, tr( "Out of space" ), 495// if ( QMessageBox::critical( this, tr( "Out of space" ),
350 tr( "Text Editor was unable to\n" 496// tr( "Text Editor was unable to\n"
351 "save your changes.\n" 497// "save your changes.\n"
352 "Free some space and try again.\n" 498// "Free some space and try again.\n"
353 "\nContinue anyway?" ), 499// "\nContinue anyway?" ),
354 QMessageBox::Yes|QMessageBox::Escape, 500// QMessageBox::Yes|QMessageBox::Escape,
355 QMessageBox::No|QMessageBox::Default ) 501// QMessageBox::No|QMessageBox::Default )
356 != QMessageBox::Yes ) 502// != QMessageBox::Yes )
357 return; 503// return;
358 else { 504// else {
359 delete doc; 505// delete doc;
360 doc = 0; 506// doc = 0;
361 } 507// }
362 } 508// }
363 menu->hide(); 509 menu->hide();
364 editBar->hide(); 510 editBar->hide();
365 searchBar->hide(); 511 searchBar->hide();
@@ -369,21 +515,43 @@ void TextEdit::fileOpen()
369 updateCaption(); 515 updateCaption();
370} 516}
371 517
518void TextEdit::newFileOpen()
519{
520 fileBrowser *browseForFiles;
521 browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*");
522 browseForFiles->exec();
523 QString selFile= browseForFiles->selectedFileName;
524 QStringList fileList=browseForFiles->fileList;
525 qDebug(selFile);
526 QStringList::ConstIterator f;
527 QString fileTemp;
528 for ( f = fileList.begin(); f != fileList.end(); f++ ) {
529 fileTemp = *f;
530 fileTemp.right( fileTemp.length()-5);
531 QString fileName = fileTemp;
532 if( fileName != "Unnamed" || fileName != "Empty Text" ) {
533 currentFileName = fileName;
534 qDebug("please open "+currentFileName);
535 openFile(fileName );
536 }
537 }
538 delete browseForFiles;
539
540}
372 541
373#if 0 542#if 0
374void TextEdit::slotFind() 543void TextEdit::slotFind()
375{ 544{
376 FindDialog frmFind( "Text Editor", this ); 545 FindDialog frmFind( "Text Editor", this );
377 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 546 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
378 editor, SLOT(slotDoFind( const QString&,bool,bool))); 547 editor, SLOT(slotDoFind( const QString&,bool,bool)));
379
380 //case sensitive, backwards, [category]
381 548
549 //case sensitive, backwards, [category]
382 550
383 connect( editor, SIGNAL(notFound()), 551 connect( editor, SIGNAL(notFound()),
384 &frmFind, SLOT(slotNotFound()) ); 552 &frmFind, SLOT(slotNotFound()) );
385 connect( editor, SIGNAL(searchWrapped()), 553 connect( editor, SIGNAL(searchWrapped()),
386 &frmFind, SLOT(slotWrapAround()) ); 554 &frmFind, SLOT(slotWrapAround()) );
387 555
388 frmFind.exec(); 556 frmFind.exec();
389 557
@@ -466,23 +634,25 @@ void TextEdit::openFile( const QString &f )
466 QString name = f; 634 QString name = f;
467 int sep = name.findRev( '/' ); 635 int sep = name.findRev( '/' );
468 if ( sep > 0 ) 636 if ( sep > 0 )
469 name = name.mid( sep+1 ); 637 name = name.mid( sep+1 );
470 updateCaption( name ); 638 updateCaption( name );
471} 639}
472 640
473void TextEdit::openFile( const DocLnk &f ) 641void TextEdit::openFile( const DocLnk &f )
474{ 642{
475 clear(); 643// clear();
476 FileManager fm; 644 FileManager fm;
477 QString txt; 645 QString txt;
478 if ( !fm.loadFile( f, txt ) ) { 646 if ( !fm.loadFile( f, txt ) ) {
479 // ####### could be a new file 647 // ####### could be a new file
480 //qDebug( "Cannot open file" ); 648 qDebug( "Cannot open file" );
481 //return; 649
650 //return;
482 } 651 }
652
483 fileNew(); 653 fileNew();
484 if ( doc ) 654 if ( doc )
485 delete doc; 655 delete doc;
486 doc = new DocLnk(f); 656 doc = new DocLnk(f);
487 editor->setText(txt); 657 editor->setText(txt);
488 editor->setEdited(FALSE); 658 editor->setEdited(FALSE);
@@ -491,57 +661,66 @@ void TextEdit::openFile( const DocLnk &f )
491 661
492void TextEdit::showEditTools() 662void TextEdit::showEditTools()
493{ 663{
494 if ( !doc ) 664// if ( !doc )
495 close(); 665// close();
666// clear();
496 fileSelector->hide(); 667 fileSelector->hide();
497 menu->show(); 668 menu->show();
498 editBar->show(); 669 editBar->show();
499 if ( searchVisible ) 670 if ( searchVisible )
500 searchBar->show(); 671 searchBar->show();
501 updateCaption(); 672 updateCaption();
673 editorStack->raiseWidget( editor );
674 setWState (WState_Reserved1 );
502} 675}
503 676
504bool TextEdit::save() 677bool TextEdit::save()
505{ 678{
506 // case of nothing to save... 679 // case of nothing to save...
507 if ( !doc ) 680 if ( !doc || !bFromDocView)
508 return true; 681 return true;
509 if ( !editor->edited() ) { 682 if ( !editor->edited() ) {
510 delete doc; 683 delete doc;
511 doc = 0; 684 doc = 0;
512 return true; 685 return true;
513 } 686 }
514 687
515 QString rt = editor->text(); 688 QString rt = editor->text();
516 689
517 if ( doc->name().isEmpty() ) { 690 if(currentFileName.isEmpty() || currentFileName == "Unnamed") {
518 QString pt = rt.simplifyWhiteSpace(); 691
519 int i = pt.find( ' ' ); 692 if ( doc->name().isEmpty() ) {
520 QString docname = pt; 693 QString pt = rt.simplifyWhiteSpace();
521 if ( i > 0 ) 694 int i = pt.find( ' ' );
522 docname = pt.left( i ); 695 QString docname = pt;
523 // remove "." at the beginning 696 if ( i > 0 )
524 while( docname.startsWith( "." ) ) 697 docname = pt.left( i );
525 docname = docname.mid( 1 ); 698 // remove "." at the beginning
526 docname.replace( QRegExp("/"), "_" ); 699 while( docname.startsWith( "." ) )
527 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. 700 docname = docname.mid( 1 );
528 if ( docname.length() > 40 ) 701 docname.replace( QRegExp("/"), "_" );
529 docname = docname.left(40); 702 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long.
530 if ( docname.isEmpty() ) 703 if ( docname.length() > 40 )
531 docname = "Empty Text"; 704 docname = docname.left(40);
532 doc->setName(docname); 705 if ( docname.isEmpty() )
533 706 docname = "Empty Text";
534 // append .txt to the file name 707 doc->setName(docname);
535 if ( doc->file().find(".txt") == -1 ) { 708 currentFileName=docname;
536 QString file = doc->file() + ".txt"; 709 }
537 doc->setFile( file );
538 }
539 } 710 }
540 711
541 712 fileSaver *fileSaveDlg;
713 fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName);
714 fileSaveDlg->exec();
715 QString fileNm=fileSaveDlg->selectedFileName;
716 qDebug("save filename "+fileNm);
717 doc->setName(fileNm);
718 updateCaption();
719 delete fileSaveDlg;
720
542 FileManager fm; 721 FileManager fm;
543 if ( !fm.saveFile( *doc, rt ) ) { 722 if ( !fm.saveFile( *doc, rt ) ) {
544 return false; 723 return false;
545 } 724 }
546 delete doc; 725 delete doc;
547 doc = 0; 726 doc = 0;
@@ -559,14 +738,16 @@ void TextEdit::clear()
559void TextEdit::updateCaption( const QString &name ) 738void TextEdit::updateCaption( const QString &name )
560{ 739{
561 if ( !doc ) 740 if ( !doc )
562 setCaption( tr("Text Editor") ); 741 setCaption( tr("Text Editor") );
563 else { 742 else {
564 QString s = name; 743 QString s = name;
565 if ( s.isNull() ) 744 if ( s.isNull() )
566 s = doc->name(); 745 s = doc->name();
567 if ( s.isEmpty() ) 746 if ( s.isEmpty() ) {
568 s = tr( "Unnamed" ); 747 s = tr( "Unnamed" );
569 setCaption( s + " - " + tr("Text Editor") ); 748 currentFileName=s;
749 }
750 setCaption( s + " - " + tr("Text Editor") );
570 } 751 }
571} 752}
572 753
@@ -574,21 +755,49 @@ void TextEdit::setDocument(const QString& fileref)
574{ 755{
575 bFromDocView = TRUE; 756 bFromDocView = TRUE;
576 openFile(DocLnk(fileref)); 757 openFile(DocLnk(fileref));
577 showEditTools(); 758// showEditTools();
578} 759}
579 760
580void TextEdit::closeEvent( QCloseEvent *e ) 761void TextEdit::closeEvent( QCloseEvent *e )
581{ 762{
582 if ( editorStack->visibleWidget() == editor && !bFromDocView ) { 763 if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) {
583 e->ignore(); 764 e->ignore();
584 fileRevert(); 765 repaint();
766// fileRevert();
767
585 } else { 768 } else {
586 bFromDocView = FALSE; 769 bFromDocView = FALSE;
587 e->accept(); 770 e->accept();
588 } 771 }
589} 772}
590 773
591void TextEdit::accept() 774void TextEdit::accept()
592{ 775{
593 fileOpen(); 776 close();
594 } 777// fileOpen(); //godamn thats obnoxious! lemme out!!!
778}
779
780void TextEdit::changeFont() {
781 FontDatabase fdb;
782 QFont defaultFont=editor->font();
783 QFontInfo fontInfo(defaultFont);
784 Config cfg("TextEdit");
785 cfg.setGroup("Font");
786 QString family = cfg.readEntry("Family", fontInfo.family());
787 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
788 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
789 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
790
791 defaultFont = fdb.font(family,style,i_size,charSet);
792
793 FontDialog *fontDlg;
794 fontDlg=new FontDialog(this,"FontDialog",TRUE);
795
796 fontDlg->exec();
797
798 QFont myFont=fontDlg->selectedFont;
799 editor->setFont( myFont);
800 delete fontDlg;
801
802}
803
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index f7d1052..4e469cc 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -17,6 +17,7 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// additions made by L.J. Potter Sun 02-17-2002 22:27:46
20 21
21#ifndef TEXTEDIT_H 22#ifndef TEXTEDIT_H
22#define TEXTEDIT_H 23#define TEXTEDIT_H
@@ -54,10 +55,12 @@ protected:
54 55
55private slots: 56private slots:
56 void setDocument(const QString&); 57 void setDocument(const QString&);
57 58 void changeFont();
58 void fileNew(); 59 void fileNew();
59 void fileRevert(); 60 void fileRevert();
60 void fileOpen(); 61 void fileOpen();
62 void newFileOpen();
63 bool save();
61 64
62 void editCut(); 65 void editCut();
63 void editCopy(); 66 void editCopy();
@@ -82,7 +85,6 @@ private slots:
82 85
83private: 86private:
84 void colorChanged( const QColor &c ); 87 void colorChanged( const QColor &c );
85 bool save();
86 void clear(); 88 void clear();
87 void updateCaption( const QString &name=QString::null ); 89 void updateCaption( const QString &name=QString::null );
88 void setFontSize(int sz, bool round_down_not_up); 90 void setFontSize(int sz, bool round_down_not_up);
@@ -97,6 +99,7 @@ private:
97 bool searchVisible; 99 bool searchVisible;
98 bool bFromDocView; 100 bool bFromDocView;
99 QAction *zin, *zout; 101 QAction *zin, *zout;
102 QString currentFileName;
100}; 103};
101 104
102#endif 105#endif
diff --git a/core/apps/textedit/textedit.pro b/core/apps/textedit/textedit.pro
index 23b8d8d..9b1a841 100644
--- a/core/apps/textedit/textedit.pro
+++ b/core/apps/textedit/textedit.pro
@@ -1,16 +1,16 @@
1 TEMPLATE= app 1TEMPLATE = app
2 CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3 3
4 DESTDIR = $(OPIEDIR)/bin 4DESTDIR = $(OPIEDIR)/bin
5 5
6 HEADERS= textedit.h 6HEADERS = textedit.h fileBrowser.h fontDialog.h fileSaver.h
7 7
8 SOURCES= main.cpp textedit.cpp 8SOURCES = main.cpp textedit.cpp fileBrowser.cpp fontDialog.cpp fileSaver.cpp
9 9
10INCLUDEPATH += $(OPIEDIR)/include 10INCLUDEPATH += $(OPIEDIR)/include
11 DEPENDPATH+= $(OPIEDIR)/include 11DEPENDPATH += $(OPIEDIR)/include
12LIBS += -lqpe 12LIBS += -lqpe
13 13
14 TARGET = textedit 14TARGET = textedit
15 15
16TRANSLATIONS = ../i18n/de/textedit.ts 16TRANSLATIONS = ../i18n/de/textedit.ts