-rw-r--r-- | core/apps/textedit/Makefile.in | 8 | ||||
-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 160 | ||||
-rw-r--r-- | core/apps/textedit/fileBrowser.h | 67 | ||||
-rw-r--r-- | core/apps/textedit/fileSaver.cpp | 164 | ||||
-rw-r--r-- | core/apps/textedit/fileSaver.h | 71 | ||||
-rw-r--r-- | core/apps/textedit/fontDialog.cpp | 236 | ||||
-rw-r--r-- | core/apps/textedit/fontDialog.h | 63 | ||||
-rw-r--r-- | core/apps/textedit/inserttable.ui | 103 | ||||
-rw-r--r-- | core/apps/textedit/qtextedit.h | 282 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 481 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 7 | ||||
-rw-r--r-- | core/apps/textedit/textedit.pro | 14 |
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 | |||
@@ -80,46 +80,52 @@ listpromodules: | |||
80 | listallmodules: | 80 | listallmodules: |
81 | @echo | 81 | @echo |
82 | 82 | ||
83 | listaddonpromodules: | 83 | listaddonpromodules: |
84 | @echo | 84 | @echo |
85 | 85 | ||
86 | listaddonentmodules: | 86 | listaddonentmodules: |
87 | @echo | 87 | @echo |
88 | 88 | ||
89 | 89 | ||
90 | REQUIRES= | 90 | REQUIRES= |
91 | 91 | ||
92 | ####### Sub-libraries | 92 | ####### Sub-libraries |
93 | 93 | ||
94 | 94 | ||
95 | ###### Combined headers | 95 | ###### Combined headers |
96 | 96 | ||
97 | 97 | ||
98 | 98 | ||
99 | ####### Compile | 99 | ####### Compile |
100 | 100 | ||
101 | main.o: main.cpp \ | 101 | main.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 | ||
106 | textedit.o: textedit.cpp \ | 108 | textedit.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 | ||
118 | moc_textedit.o: moc_textedit.cpp \ | 124 | moc_textedit.o: moc_textedit.cpp \ |
119 | textedit.h \ | 125 | textedit.h \ |
120 | $(OPIEDIR)/include/qpe/filemanager.h | 126 | $(OPIEDIR)/include/qpe/filemanager.h |
121 | 127 | ||
122 | moc_textedit.cpp: textedit.h | 128 | moc_textedit.cpp: textedit.h |
123 | $(MOC) textedit.h -o moc_textedit.cpp | 129 | $(MOC) textedit.h -o moc_textedit.cpp |
124 | 130 | ||
125 | 131 | ||
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 | |||
23 | fileBrowser::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 | |||
55 | fileBrowser::~fileBrowser() | ||
56 | { | ||
57 | } | ||
58 | |||
59 | |||
60 | void 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 | |||
99 | void fileBrowser::upDir() | ||
100 | { | ||
101 | // qDebug(currentDir.canonicalPath()); | ||
102 | } | ||
103 | |||
104 | void fileBrowser::listDoubleClicked(QListViewItem *selectedItem) | ||
105 | { | ||
106 | } | ||
107 | |||
108 | // you may want to switch these 2 functions. I like single clicks | ||
109 | void 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 | |||
149 | void 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 | ** | ||
13 | copyright 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 | |||
26 | class QVBoxLayout; | ||
27 | class QHBoxLayout; | ||
28 | class QGridLayout; | ||
29 | class QListView; | ||
30 | class QListViewItem; | ||
31 | class QPushButton; | ||
32 | |||
33 | class fileBrowser : public QDialog | ||
34 | { | ||
35 | Q_OBJECT | ||
36 | |||
37 | public: | ||
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 | |||
51 | QListViewItem * item; | ||
52 | public slots: | ||
53 | |||
54 | private: | ||
55 | |||
56 | private slots: | ||
57 | void upDir(); | ||
58 | void listDoubleClicked(QListViewItem *); | ||
59 | void listClicked(QListViewItem *); | ||
60 | void OnOK(); | ||
61 | protected slots: | ||
62 | |||
63 | protected: | ||
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 | |||
25 | fileSaver::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 | |||
60 | fileSaver::~fileSaver() | ||
61 | { | ||
62 | } | ||
63 | |||
64 | |||
65 | void 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 | |||
104 | void fileSaver::upDir() | ||
105 | { | ||
106 | // qDebug(currentDir.canonicalPath()); | ||
107 | } | ||
108 | |||
109 | void fileSaver::listDoubleClicked(QListViewItem *selectedItem) | ||
110 | { | ||
111 | } | ||
112 | |||
113 | void 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 | |||
155 | void fileSaver::OnOK() | ||
156 | { | ||
157 | // reject(); | ||
158 | } | ||
159 | |||
160 | void 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 | ** | ||
5 | copyright 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 | |||
27 | class QVBoxLayout; | ||
28 | class QHBoxLayout; | ||
29 | class QGridLayout; | ||
30 | class QListView; | ||
31 | class QListViewItem; | ||
32 | class QPushButton; | ||
33 | class QLineEdit; | ||
34 | |||
35 | class fileSaver : public QDialog | ||
36 | { | ||
37 | Q_OBJECT | ||
38 | |||
39 | public: | ||
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 | |||
54 | QListViewItem * item; | ||
55 | public slots: | ||
56 | |||
57 | private: | ||
58 | |||
59 | private slots: | ||
60 | void accept(); | ||
61 | void upDir(); | ||
62 | void listDoubleClicked(QListViewItem *); | ||
63 | void listClicked(QListViewItem *); | ||
64 | void OnOK(); | ||
65 | protected slots: | ||
66 | |||
67 | protected: | ||
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 | ||
3 | copyright 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 | |||
34 | FontDialog::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 | |||
76 | FontDialog::~FontDialog() | ||
77 | { | ||
78 | } | ||
79 | |||
80 | void 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 | |||
110 | void FontDialog::styleListBoxSlot(const QString &text) | ||
111 | { | ||
112 | changeText(); | ||
113 | } | ||
114 | |||
115 | void FontDialog::sizeListBoxSlot(const QString & text) | ||
116 | { | ||
117 | changeText(); | ||
118 | } | ||
119 | |||
120 | void 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 | |||
177 | void FontDialog::clearListBoxes() { | ||
178 | familyListBox->clear(); | ||
179 | sizeListBox->clear(); | ||
180 | styleListBox->clear(); | ||
181 | } | ||
182 | |||
183 | void 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 | ||
3 | copyright 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 | |||
22 | class QVBoxLayout; | ||
23 | class QHBoxLayout; | ||
24 | class QGridLayout; | ||
25 | class QLabel; | ||
26 | class QListBox; | ||
27 | class QListBoxItem; | ||
28 | class QPushButton; | ||
29 | class QGroupBox; | ||
30 | class QMultiLineEdit; | ||
31 | |||
32 | class FontDialog : public QDialog// QWidget | ||
33 | { | ||
34 | Q_OBJECT | ||
35 | |||
36 | public: | ||
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(); | ||
54 | protected 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 | |||
28 | class QPainter; | ||
29 | class QTextDocument; | ||
30 | class QTextCursor; | ||
31 | class QKeyEvent; | ||
32 | class QResizeEvent; | ||
33 | class QMouseEvent; | ||
34 | class QTimer; | ||
35 | class QTextString; | ||
36 | class QVBox; | ||
37 | class QListBox; | ||
38 | class QTextCommand; | ||
39 | class QTextParag; | ||
40 | class QTextFormat; | ||
41 | class QFont; | ||
42 | class QColor; | ||
43 | |||
44 | class QTextEdit : public QScrollView | ||
45 | { | ||
46 | Q_OBJECT | ||
47 | |||
48 | public: | ||
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 ¶g, int &index ); | ||
64 | void selection( int ¶g_from, int &index_from, | ||
65 | int ¶g_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 | |||
116 | public 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 | |||
157 | signals: | ||
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 | |||
165 | protected: | ||
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 | |||
187 | private slots: | ||
188 | void formatMore(); | ||
189 | void doResize(); | ||
190 | void doAutoScroll(); | ||
191 | void doChangeInterval(); | ||
192 | void blinkCursor(); | ||
193 | void setModified(); | ||
194 | void startDrag(); | ||
195 | |||
196 | private: | ||
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 | |||
227 | private: | ||
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 | |||
245 | private: | ||
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 | |||
272 | inline QTextDocument *QTextEdit::document() const | ||
273 | { | ||
274 | return doc; | ||
275 | } | ||
276 | |||
277 | inline 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 | |||
@@ -1,410 +1,578 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 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. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
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> |
26 | #include <qpe/resource.h> | 32 | #include <qpe/resource.h> |
27 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
28 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
29 | #include <qpe/qpemenubar.h> | 35 | #include <qpe/qpemenubar.h> |
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> |
36 | #include <qlineedit.h> | 43 | #include <qlineedit.h> |
37 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
38 | #include <qobjectlist.h> | 45 | #include <qobjectlist.h> |
39 | #include <qpopupmenu.h> | 46 | #include <qpopupmenu.h> |
40 | #include <qspinbox.h> | 47 | #include <qspinbox.h> |
41 | #include <qtoolbutton.h> | 48 | #include <qtoolbutton.h> |
42 | #include <qwidgetstack.h> | 49 | #include <qwidgetstack.h> |
43 | 50 | ||
44 | #include <stdlib.h> //getenv | 51 | #include <stdlib.h> //getenv |
52 | /* XPM */ | ||
53 | static 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 |
48 | 152 | ||
49 | class QpeEditor : public QMultiLineEdit | 153 | class QpeEditor : public QMultiLineEdit |
50 | { | 154 | { |
51 | // Q_OBJECT | 155 | // Q_OBJECT |
52 | public: | 156 | public: |
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, |
58 | bool backwards ); | 166 | bool backwards ); |
59 | /* | 167 | /* |
60 | signals: | 168 | signals: |
61 | void notFound(); | 169 | void notFound(); |
62 | void searchWrapped(); | 170 | void searchWrapped(); |
63 | */ | 171 | */ |
64 | 172 | ||
65 | private: | 173 | private: |
66 | 174 | ||
67 | }; | 175 | }; |
68 | 176 | ||
69 | 177 | ||
70 | void QpeEditor::find ( const QString &txt, bool caseSensitive, | 178 | void 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 | ||
106 | } | 214 | } |
107 | 215 | ||
108 | 216 | ||
109 | #else | 217 | #else |
110 | 218 | ||
111 | #error "Must make a QpeEditor that inherits QTextEdit" | 219 | #error "Must make a QpeEditor that inherits QTextEdit" |
112 | 220 | ||
113 | #endif | 221 | #endif |
114 | 222 | ||
115 | 223 | ||
116 | 224 | ||
117 | 225 | ||
118 | static int u_id = 1; | 226 | static int u_id = 1; |
119 | static int get_unique_id() | 227 | static int get_unique_id() |
120 | { | 228 | { |
121 | return u_id++; | 229 | return u_id++; |
122 | } | 230 | } |
123 | 231 | ||
124 | static const int nfontsizes = 6; | 232 | static const int nfontsizes = 6; |
125 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; | 233 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; |
126 | 234 | ||
127 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | 235 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) |
128 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ) | 236 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ) |
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" ) ); |
137 | 243 | ||
138 | QPEToolBar *bar = new QPEToolBar( this ); | 244 | QPEToolBar *bar = new QPEToolBar( this ); |
139 | bar->setHorizontalStretchable( TRUE ); | 245 | bar->setHorizontalStretchable( TRUE ); |
140 | menu = bar; | 246 | menu = bar; |
141 | 247 | ||
142 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 248 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
143 | QPopupMenu *file = new QPopupMenu( this ); | 249 | QPopupMenu *file = new QPopupMenu( this ); |
144 | QPopupMenu *edit = new QPopupMenu( this ); | 250 | QPopupMenu *edit = new QPopupMenu( this ); |
145 | QPopupMenu *font = new QPopupMenu( this ); | 251 | QPopupMenu *font = new QPopupMenu( this ); |
146 | 252 | ||
147 | bar = new QPEToolBar( this ); | 253 | bar = new QPEToolBar( this ); |
148 | editBar = bar; | 254 | editBar = bar; |
149 | 255 | ||
150 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 256 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
151 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 257 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
152 | a->addTo( bar ); | 258 | a->addTo( bar ); |
153 | a->addTo( file ); | 259 | a->addTo( file ); |
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 ); |
163 | a->addTo( edit ); | 281 | a->addTo( edit ); |
164 | 282 | ||
165 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); | 283 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); |
166 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 284 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
167 | a->addTo( editBar ); | 285 | a->addTo( editBar ); |
168 | a->addTo( edit ); | 286 | a->addTo( edit ); |
169 | 287 | ||
170 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 288 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
171 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 289 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
172 | a->addTo( editBar ); | 290 | a->addTo( editBar ); |
173 | a->addTo( edit ); | 291 | a->addTo( edit ); |
174 | 292 | ||
175 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 293 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
176 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 294 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
177 | edit->insertSeparator(); | 295 | edit->insertSeparator(); |
178 | a->addTo( bar ); | 296 | a->addTo( bar ); |
179 | a->addTo( edit ); | 297 | a->addTo( edit ); |
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() ) ); |
194 | zin->addTo( font ); | 311 | zin->addTo( font ); |
195 | 312 | ||
196 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 313 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
197 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 314 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
198 | zout->addTo( font ); | 315 | zout->addTo( font ); |
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); |
206 | ba->addTo( font ); | 323 | ba->addTo( font ); |
207 | 324 | ||
208 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); | 325 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); |
209 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); | 326 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); |
210 | ia->setToggleAction(TRUE); | 327 | ia->setToggleAction(TRUE); |
211 | ia->addTo( font ); | 328 | ia->addTo( font ); |
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 | ||
219 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); | 336 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); |
220 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); | 337 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); |
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 ); |
227 | 347 | ||
228 | searchBar = new QPEToolBar(this); | 348 | searchBar = new QPEToolBar(this); |
229 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 349 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
230 | 350 | ||
231 | searchBar->setHorizontalStretchable( TRUE ); | 351 | searchBar->setHorizontalStretchable( TRUE ); |
232 | 352 | ||
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() ) ); |
240 | a->addTo( searchBar ); | 361 | a->addTo( searchBar ); |
241 | a->addTo( edit ); | 362 | a->addTo( edit ); |
242 | 363 | ||
243 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 364 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
244 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 365 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
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 | ||
271 | TextEdit::~TextEdit() | 415 | TextEdit::~TextEdit() |
272 | { | 416 | { |
273 | save(); | 417 | save(); |
274 | 418 | ||
275 | Config cfg("TextEdit"); | 419 | Config cfg("TextEdit"); |
276 | cfg.setGroup("View"); | 420 | cfg.setGroup("View"); |
277 | QFont f = editor->font(); | 421 | QFont f = editor->font(); |
278 | cfg.writeEntry("FontSize",f.pointSize()); | 422 | cfg.writeEntry("FontSize",f.pointSize()); |
279 | cfg.writeEntry("Bold",f.bold()); | 423 | cfg.writeEntry("Bold",f.bold()); |
280 | cfg.writeEntry("Italic",f.italic()); | 424 | cfg.writeEntry("Italic",f.italic()); |
281 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); | 425 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); |
282 | } | 426 | } |
283 | 427 | ||
284 | void TextEdit::zoomIn() | 428 | void TextEdit::zoomIn() |
285 | { | 429 | { |
286 | setFontSize(editor->font().pointSize()+1,FALSE); | 430 | setFontSize(editor->font().pointSize()+1,FALSE); |
287 | } | 431 | } |
288 | 432 | ||
289 | void TextEdit::zoomOut() | 433 | void TextEdit::zoomOut() |
290 | { | 434 | { |
291 | setFontSize(editor->font().pointSize()-1,TRUE); | 435 | setFontSize(editor->font().pointSize()-1,TRUE); |
292 | } | 436 | } |
293 | 437 | ||
294 | 438 | ||
295 | void TextEdit::setFontSize(int sz, bool round_down_not_up) | 439 | 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(); |
314 | f.setPointSize(s); | 458 | f.setPointSize(s); |
315 | editor->setFont(f); | 459 | editor->setFont(f); |
316 | 460 | ||
317 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 461 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
318 | zout->setEnabled(s != fontsize[0]); | 462 | zout->setEnabled(s != fontsize[0]); |
319 | } | 463 | } |
320 | 464 | ||
321 | void TextEdit::setBold(bool y) | 465 | void TextEdit::setBold(bool y) |
322 | { | 466 | { |
323 | QFont f = editor->font(); | 467 | QFont f = editor->font(); |
324 | f.setBold(y); | 468 | f.setBold(y); |
325 | editor->setFont(f); | 469 | editor->setFont(f); |
326 | } | 470 | } |
327 | 471 | ||
328 | void TextEdit::setItalic(bool y) | 472 | void TextEdit::setItalic(bool y) |
329 | { | 473 | { |
330 | QFont f = editor->font(); | 474 | QFont f = editor->font(); |
331 | f.setItalic(y); | 475 | f.setItalic(y); |
332 | editor->setFont(f); | 476 | editor->setFont(f); |
333 | } | 477 | } |
334 | 478 | ||
335 | void TextEdit::setWordWrap(bool y) | 479 | void 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 | ||
340 | void TextEdit::fileNew() | 486 | void TextEdit::fileNew() |
341 | { | 487 | { |
342 | save(); | 488 | save(); |
343 | newFile(DocLnk()); | 489 | newFile(DocLnk()); |
344 | } | 490 | } |
345 | 491 | ||
346 | void TextEdit::fileOpen() | 492 | void 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(); |
366 | clearWState (WState_Reserved1 ); | 512 | clearWState (WState_Reserved1 ); |
367 | editorStack->raiseWidget( fileSelector ); | 513 | editorStack->raiseWidget( fileSelector ); |
368 | fileSelector->reread(); | 514 | fileSelector->reread(); |
369 | updateCaption(); | 515 | updateCaption(); |
370 | } | 516 | } |
371 | 517 | ||
518 | void 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 |
374 | void TextEdit::slotFind() | 543 | void 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 | ||
390 | 558 | ||
391 | } | 559 | } |
392 | #endif | 560 | #endif |
393 | 561 | ||
394 | void TextEdit::fileRevert() | 562 | void TextEdit::fileRevert() |
395 | { | 563 | { |
396 | clear(); | 564 | clear(); |
397 | fileOpen(); | 565 | fileOpen(); |
398 | } | 566 | } |
399 | 567 | ||
400 | void TextEdit::editCut() | 568 | void TextEdit::editCut() |
401 | { | 569 | { |
402 | #ifndef QT_NO_CLIPBOARD | 570 | #ifndef QT_NO_CLIPBOARD |
403 | editor->cut(); | 571 | editor->cut(); |
404 | #endif | 572 | #endif |
405 | } | 573 | } |
406 | 574 | ||
407 | void TextEdit::editCopy() | 575 | void TextEdit::editCopy() |
408 | { | 576 | { |
409 | #ifndef QT_NO_CLIPBOARD | 577 | #ifndef QT_NO_CLIPBOARD |
410 | editor->copy(); | 578 | editor->copy(); |
@@ -445,150 +613,191 @@ void TextEdit::search() | |||
445 | void TextEdit::newFile( const DocLnk &f ) | 613 | void TextEdit::newFile( const DocLnk &f ) |
446 | { | 614 | { |
447 | DocLnk nf = f; | 615 | DocLnk nf = f; |
448 | nf.setType("text/plain"); | 616 | nf.setType("text/plain"); |
449 | clear(); | 617 | clear(); |
450 | editorStack->raiseWidget( editor ); | 618 | editorStack->raiseWidget( editor ); |
451 | setWState (WState_Reserved1 ); | 619 | setWState (WState_Reserved1 ); |
452 | editor->setFocus(); | 620 | editor->setFocus(); |
453 | doc = new DocLnk(nf); | 621 | doc = new DocLnk(nf); |
454 | updateCaption(); | 622 | updateCaption(); |
455 | } | 623 | } |
456 | 624 | ||
457 | void TextEdit::openFile( const QString &f ) | 625 | void TextEdit::openFile( const QString &f ) |
458 | { | 626 | { |
459 | bFromDocView = TRUE; | 627 | bFromDocView = TRUE; |
460 | DocLnk nf; | 628 | DocLnk nf; |
461 | nf.setType("text/plain"); | 629 | nf.setType("text/plain"); |
462 | nf.setFile(f); | 630 | nf.setFile(f); |
463 | openFile(nf); | 631 | openFile(nf); |
464 | showEditTools(); | 632 | showEditTools(); |
465 | // Show filename in caption | 633 | // Show filename in caption |
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 | ||
473 | void TextEdit::openFile( const DocLnk &f ) | 641 | void 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); |
489 | updateCaption(); | 659 | updateCaption(); |
490 | } | 660 | } |
491 | 661 | ||
492 | void TextEdit::showEditTools() | 662 | void 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 | ||
504 | bool TextEdit::save() | 677 | bool 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; |
548 | editor->setEdited( false ); | 727 | editor->setEdited( false ); |
549 | return true; | 728 | return true; |
550 | } | 729 | } |
551 | 730 | ||
552 | void TextEdit::clear() | 731 | void TextEdit::clear() |
553 | { | 732 | { |
554 | delete doc; | 733 | delete doc; |
555 | doc = 0; | 734 | doc = 0; |
556 | editor->clear(); | 735 | editor->clear(); |
557 | } | 736 | } |
558 | 737 | ||
559 | void TextEdit::updateCaption( const QString &name ) | 738 | void 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 | ||
573 | void TextEdit::setDocument(const QString& fileref) | 754 | 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 | ||
580 | void TextEdit::closeEvent( QCloseEvent *e ) | 761 | void 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 | ||
591 | void TextEdit::accept() | 774 | void TextEdit::accept() |
592 | { | 775 | { |
593 | fileOpen(); | 776 | close(); |
594 | } | 777 | // fileOpen(); //godamn thats obnoxious! lemme out!!! |
778 | } | ||
779 | |||
780 | void 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 | |||
@@ -1,102 +1,105 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 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. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
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 |
23 | 24 | ||
24 | #define QTEXTEDIT_OPEN_API | 25 | #define QTEXTEDIT_OPEN_API |
25 | 26 | ||
26 | #include <qpe/filemanager.h> | 27 | #include <qpe/filemanager.h> |
27 | 28 | ||
28 | #include <qmainwindow.h> | 29 | #include <qmainwindow.h> |
29 | #include <qmultilineedit.h> | 30 | #include <qmultilineedit.h> |
30 | #include <qlist.h> | 31 | #include <qlist.h> |
31 | #include <qmap.h> | 32 | #include <qmap.h> |
32 | 33 | ||
33 | class QWidgetStack; | 34 | class QWidgetStack; |
34 | class QToolButton; | 35 | class QToolButton; |
35 | class QPopupMenu; | 36 | class QPopupMenu; |
36 | class QToolBar; | 37 | class QToolBar; |
37 | class QLineEdit; | 38 | class QLineEdit; |
38 | class QAction; | 39 | class QAction; |
39 | class FileSelector; | 40 | class FileSelector; |
40 | class QpeEditor; | 41 | class QpeEditor; |
41 | 42 | ||
42 | class TextEdit : public QMainWindow | 43 | class TextEdit : public QMainWindow |
43 | { | 44 | { |
44 | Q_OBJECT | 45 | Q_OBJECT |
45 | 46 | ||
46 | public: | 47 | public: |
47 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 48 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
48 | ~TextEdit(); | 49 | ~TextEdit(); |
49 | 50 | ||
50 | void openFile( const QString & ); | 51 | void openFile( const QString & ); |
51 | 52 | ||
52 | protected: | 53 | protected: |
53 | void closeEvent( QCloseEvent *e ); | 54 | void closeEvent( QCloseEvent *e ); |
54 | 55 | ||
55 | private slots: | 56 | private 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(); |
64 | void editPaste(); | 67 | void editPaste(); |
65 | void editFind(); | 68 | void editFind(); |
66 | 69 | ||
67 | void findNext(); | 70 | void findNext(); |
68 | void findClose(); | 71 | void findClose(); |
69 | 72 | ||
70 | void search(); | 73 | void search(); |
71 | void accept(); | 74 | void accept(); |
72 | 75 | ||
73 | void newFile( const DocLnk & ); | 76 | void newFile( const DocLnk & ); |
74 | void openFile( const DocLnk & ); | 77 | void openFile( const DocLnk & ); |
75 | void showEditTools(); | 78 | void showEditTools(); |
76 | 79 | ||
77 | void zoomIn(); | 80 | void zoomIn(); |
78 | void zoomOut(); | 81 | void zoomOut(); |
79 | void setBold(bool y); | 82 | void setBold(bool y); |
80 | void setItalic(bool y); | 83 | void setItalic(bool y); |
81 | void setWordWrap(bool y); | 84 | void setWordWrap(bool y); |
82 | 85 | ||
83 | private: | 86 | private: |
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); |
89 | 91 | ||
90 | private: | 92 | private: |
91 | QWidgetStack *editorStack; | 93 | QWidgetStack *editorStack; |
92 | FileSelector *fileSelector; | 94 | FileSelector *fileSelector; |
93 | QpeEditor* editor; | 95 | QpeEditor* editor; |
94 | QToolBar *menu, *editBar, *searchBar; | 96 | QToolBar *menu, *editBar, *searchBar; |
95 | QLineEdit *searchEdit; | 97 | QLineEdit *searchEdit; |
96 | DocLnk *doc; | 98 | DocLnk *doc; |
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 | 1 | TEMPLATE = app |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | 3 | ||
4 | DESTDIR = $(OPIEDIR)/bin | 4 | DESTDIR = $(OPIEDIR)/bin |
5 | 5 | ||
6 | HEADERS= textedit.h | 6 | HEADERS = textedit.h fileBrowser.h fontDialog.h fileSaver.h |
7 | 7 | ||
8 | SOURCES= main.cpp textedit.cpp | 8 | SOURCES = main.cpp textedit.cpp fileBrowser.cpp fontDialog.cpp fileSaver.cpp |
9 | 9 | ||
10 | INCLUDEPATH += $(OPIEDIR)/include | 10 | INCLUDEPATH += $(OPIEDIR)/include |
11 | DEPENDPATH+= $(OPIEDIR)/include | 11 | DEPENDPATH += $(OPIEDIR)/include |
12 | LIBS += -lqpe | 12 | LIBS += -lqpe |
13 | 13 | ||
14 | TARGET = textedit | 14 | TARGET = textedit |
15 | 15 | ||
16 | TRANSLATIONS = ../i18n/de/textedit.ts | 16 | TRANSLATIONS = ../i18n/de/textedit.ts |