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