-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 59 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 75 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 2 |
3 files changed, 77 insertions, 59 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp index f322513..fced326 100644 --- a/core/apps/textedit/fileBrowser.cpp +++ b/core/apps/textedit/fileBrowser.cpp | |||
@@ -1,625 +1,634 @@ | |||
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 | //#define QTOPIA_INTERNAL_MIMEEXT | 14 | #define QTOPIA_INTERNAL_MIMEEXT |
15 | #include "fileBrowser.h" | 15 | #include "fileBrowser.h" |
16 | //#include "inputDialog.h" | 16 | //#include "inputDialog.h" |
17 | 17 | ||
18 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
19 | #include <qpe/resource.h> | 19 | #include <qpe/resource.h> |
20 | #include <qpe/fileselector.h> | 20 | #include <qpe/fileselector.h> |
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/menubutton.h> | 22 | #include <qpe/menubutton.h> |
23 | #include <qpe/mimetype.h> | 23 | #include <qpe/mimetype.h> |
24 | 24 | ||
25 | #include <qdict.h> | 25 | #include <qdict.h> |
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | #include <qlistview.h> | 27 | #include <qlistview.h> |
28 | #include <qcombo.h> | 28 | #include <qcombo.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qlayout.h> | 32 | #include <qlayout.h> |
33 | #include <unistd.h> | 33 | #include <unistd.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qlineedit.h> | 35 | #include <qlineedit.h> |
36 | #include <qstringlist.h> | 36 | #include <qstringlist.h> |
37 | 37 | ||
38 | #include <unistd.h> | 38 | #include <unistd.h> |
39 | #include <stdlib.h> | 39 | #include <stdlib.h> |
40 | 40 | ||
41 | static int u_id = 1; | 41 | static int u_id = 1; |
42 | static int get_unique_id() | 42 | static int get_unique_id() |
43 | { | 43 | { |
44 | return u_id++; | 44 | return u_id++; |
45 | } | 45 | } |
46 | 46 | ||
47 | fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString mimeFilter ) | 47 | fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString mimeFilter ) |
48 | : QDialog( parent, name, modal, fl ) | 48 | : QDialog( parent, name, modal, fl ) |
49 | { | 49 | { |
50 | if ( !name ) | 50 | if ( !name ) |
51 | setName( "fileBrowser" ); | 51 | setName( "fileBrowser" ); |
52 | setCaption(tr( name ) ); | 52 | setCaption(tr( name ) ); |
53 | // mimeType = mimeFilter; | ||
54 | // MimeType mt( mimeType); | ||
55 | // if( mt.extension().isEmpty()) | ||
56 | // QStringList filterList; | ||
57 | // filterList=QStringList::split(";",mimeFilter,FALSE); | ||
58 | // for ( QStringList::Iterator it = filterList.begin(); it != filterList.end(); ++it ) { | ||
59 | // printf( "%s \n", (*it).latin1() ); | ||
60 | // } | ||
61 | 53 | ||
62 | filterStr = mimeFilter.right(mimeFilter.length() - mimeFilter.find("/",0,TRUE) - 1);// "*"; | 54 | // getMimeTypes(); |
55 | |||
56 | mimeType = mimeFilter; | ||
57 | MimeType mt( mimeType); | ||
58 | |||
59 | if( mt.extension().isEmpty()) { | ||
60 | |||
61 | QStringList filterList; | ||
62 | filterList=QStringList::split(";",mimeFilter,FALSE); | ||
63 | |||
64 | for ( QStringList::Iterator it = filterList.begin(); it != filterList.end(); ++it ) { | ||
65 | printf( "%s \n", (*it).latin1() ); | ||
66 | } | ||
67 | |||
68 | filterStr = mimeFilter.right(mimeFilter.length() - mimeFilter.find("/",0,TRUE) - 1);// "*"; | ||
63 | 69 | ||
64 | qDebug(filterStr); | 70 | qDebug(filterStr); |
65 | // else | 71 | } else { |
66 | // filterStr = "*."+ mt.extension(); | 72 | filterStr = "*."+ mt.extension(); |
67 | // qDebug("description "+mt.description()); | 73 | // qDebug("description "+mt.description()); |
68 | // qDebug( "id "+mt.id()); | 74 | // qDebug( "id "+mt.id()); |
69 | // qDebug("extension "+mt.extension()); | 75 | // qDebug("extension "+mt.extension()); |
70 | 76 | } | |
71 | // channel = new QCopChannel( "QPE/fileDialog", this ); | 77 | // channel = new QCopChannel( "QPE/fileDialog", this ); |
72 | // connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 78 | // connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
73 | // this, SLOT(receive(const QCString&, const QByteArray&)) ); | 79 | // this, SLOT(receive(const QCString&, const QByteArray&)) ); |
74 | 80 | ||
75 | QGridLayout *layout = new QGridLayout( this ); | 81 | QGridLayout *layout = new QGridLayout( this ); |
76 | layout->setSpacing( 4 ); | 82 | layout->setSpacing( 4 ); |
77 | layout->setMargin( 4 ); | 83 | layout->setMargin( 4 ); |
78 | 84 | ||
79 | dirPathCombo = new QComboBox( FALSE, this, "dirPathCombo" ); | 85 | dirPathCombo = new QComboBox( FALSE, this, "dirPathCombo" ); |
80 | dirPathCombo->setEditable(TRUE); | 86 | dirPathCombo->setEditable(TRUE); |
81 | 87 | ||
82 | connect( dirPathCombo, SIGNAL( activated( const QString & ) ), | 88 | connect( dirPathCombo, SIGNAL( activated( const QString & ) ), |
83 | this, SLOT( dirPathComboActivated( const QString & ) ) ); | 89 | this, SLOT( dirPathComboActivated( const QString & ) ) ); |
84 | 90 | ||
85 | connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ), | 91 | connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ), |
86 | this, SLOT( dirPathEditPressed( ) ) ); | 92 | this, SLOT( dirPathEditPressed( ) ) ); |
87 | 93 | ||
88 | dirPathStringList << "/"; | 94 | dirPathStringList << "/"; |
89 | // we can get the storage here | 95 | // we can get the storage here |
90 | 96 | ||
91 | layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 ); | 97 | layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 ); |
92 | 98 | ||
93 | cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); | 99 | cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); |
94 | cdUpButton ->setMinimumSize( QSize( 20, 20 ) ); | 100 | cdUpButton ->setMinimumSize( QSize( 20, 20 ) ); |
95 | cdUpButton ->setMaximumSize( QSize( 20, 20 ) ); | 101 | cdUpButton ->setMaximumSize( QSize( 20, 20 ) ); |
96 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); | 102 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); |
97 | cdUpButton ->setFlat(TRUE); | 103 | cdUpButton ->setFlat(TRUE); |
98 | layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 ); | 104 | layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 ); |
99 | 105 | ||
100 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); | 106 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); |
101 | docButton->setMinimumSize( QSize( 20, 20 ) ); | 107 | docButton->setMinimumSize( QSize( 20, 20 ) ); |
102 | docButton->setMaximumSize( QSize( 20, 20 ) ); | 108 | docButton->setMaximumSize( QSize( 20, 20 ) ); |
103 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 109 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
104 | docButton->setFlat(TRUE); | 110 | docButton->setFlat(TRUE); |
105 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); | 111 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); |
106 | 112 | ||
107 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); | 113 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); |
108 | homeButton->setMinimumSize( QSize( 20, 20 ) ); | 114 | homeButton->setMinimumSize( QSize( 20, 20 ) ); |
109 | homeButton->setMaximumSize( QSize( 20, 20 ) ); | 115 | homeButton->setMaximumSize( QSize( 20, 20 ) ); |
110 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 116 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
111 | homeButton->setFlat(TRUE); | 117 | homeButton->setFlat(TRUE); |
112 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 ); | 118 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 ); |
113 | 119 | ||
114 | FileStack = new QWidgetStack( this ); | 120 | FileStack = new QWidgetStack( this ); |
115 | 121 | ||
116 | ListView = new QListView( this, "ListView" ); | 122 | ListView = new QListView( this, "ListView" ); |
117 | // ListView->setMinimumSize( QSize( 100, 25 ) ); | 123 | // ListView->setMinimumSize( QSize( 100, 25 ) ); |
118 | ListView->addColumn( tr( "Name" ) ); | 124 | ListView->addColumn( tr( "Name" ) ); |
119 | ListView->setColumnWidth(0,120); | 125 | ListView->setColumnWidth(0,120); |
120 | ListView->setSorting( 2, FALSE); | 126 | ListView->setSorting( 2, FALSE); |
121 | ListView->addColumn( tr( "Size" ) ); | 127 | ListView->addColumn( tr( "Size" ) ); |
122 | ListView->setColumnWidth(1,-1); | 128 | ListView->setColumnWidth(1,-1); |
123 | ListView->addColumn( "Date",-1); | 129 | ListView->addColumn( "Date",-1); |
124 | 130 | ||
125 | ListView->setColumnWidthMode(0,QListView::Manual); | 131 | ListView->setColumnWidthMode(0,QListView::Manual); |
126 | ListView->setColumnAlignment(1,QListView::AlignRight); | 132 | ListView->setColumnAlignment(1,QListView::AlignRight); |
127 | ListView->setColumnAlignment(2,QListView::AlignRight); | 133 | ListView->setColumnAlignment(2,QListView::AlignRight); |
128 | ListView->setAllColumnsShowFocus( TRUE ); | 134 | ListView->setAllColumnsShowFocus( TRUE ); |
129 | 135 | ||
130 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); | 136 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); |
131 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 137 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
132 | this, SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 138 | this, SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
133 | 139 | ||
134 | connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 140 | connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
135 | 141 | ||
136 | FileStack->addWidget( ListView, get_unique_id() ); | 142 | FileStack->addWidget( ListView, get_unique_id() ); |
137 | mimeType="text/plain"; | 143 | mimeType="text/plain"; |
138 | fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy | 144 | fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy |
139 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); | 145 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); |
140 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 146 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
141 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), | 147 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), |
142 | this, SLOT( docOpen( const DocLnk & ) ) ); | 148 | this, SLOT( docOpen( const DocLnk & ) ) ); |
143 | layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 ); | 149 | layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 ); |
144 | 150 | ||
145 | SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" ); | 151 | SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" ); |
146 | SelectionCombo->insertItem( tr( "Documents" ) ); | 152 | SelectionCombo->insertItem( tr( "Documents" ) ); |
147 | SelectionCombo->insertItem( tr( "All files" ) ); | 153 | SelectionCombo->insertItem( tr( "All files" ) ); |
148 | SelectionCombo->insertItem( tr( "Hidden files" ) ); | 154 | SelectionCombo->insertItem( tr( "Hidden files" ) ); |
149 | // SelectionCombo->setMaximumWidth(120); | 155 | // SelectionCombo->setMaximumWidth(120); |
150 | layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 ); | 156 | layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 ); |
151 | 157 | ||
152 | connect( SelectionCombo, SIGNAL( activated( const QString & ) ), | 158 | connect( SelectionCombo, SIGNAL( activated( const QString & ) ), |
153 | this, SLOT( selectionChanged( const QString & ) ) ); | 159 | this, SLOT( selectionChanged( const QString & ) ) ); |
154 | 160 | ||
155 | typemb = new MenuButton(this); | 161 | typemb = new MenuButton(this); |
156 | typemb->setLabel(tr("Type: %1")); | 162 | typemb->setLabel(tr("Type: %1")); |
157 | typemb->setMinimumWidth(110); | 163 | typemb->setMinimumWidth(110); |
158 | typemb->setFixedHeight(22); | 164 | typemb->setFixedHeight(22); |
159 | layout->addMultiCellWidget( typemb, 2, 2, 4, 7 ); | 165 | layout->addMultiCellWidget( typemb, 2, 2, 4, 7 ); |
160 | updateMimeTypeMenu() ; | 166 | updateMimeTypeMenu() ; |
161 | 167 | ||
162 | currentDir.setPath(QDir::currentDirPath()); | 168 | currentDir.setPath(QDir::currentDirPath()); |
163 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); | 169 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); |
164 | currentDir.setNameFilter(filterStr); | 170 | currentDir.setNameFilter(filterStr); |
165 | 171 | ||
166 | populateList(); | 172 | populateList(); |
167 | move(0,15); | 173 | move(0,15); |
168 | } | 174 | } |
169 | 175 | ||
170 | fileBrowser::~fileBrowser() | 176 | fileBrowser::~fileBrowser() |
171 | { | 177 | { |
172 | } | 178 | } |
173 | 179 | ||
174 | void fileBrowser::setFileView( int selection ) | 180 | void fileBrowser::setFileView( int selection ) |
175 | { | 181 | { |
176 | SelectionCombo->setCurrentItem( selection ); | 182 | SelectionCombo->setCurrentItem( selection ); |
177 | selectionChanged( SelectionCombo->currentText() ); | 183 | selectionChanged( SelectionCombo->currentText() ); |
178 | } | 184 | } |
179 | 185 | ||
180 | void fileBrowser::populateList() | 186 | void fileBrowser::populateList() |
181 | { | 187 | { |
182 | ListView->clear(); | 188 | ListView->clear(); |
183 | QListViewItem * item; | 189 | QListViewItem * item; |
184 | bool isDir=FALSE; | 190 | bool isDir=FALSE; |
185 | //qDebug(currentDir.canonicalPath()); | 191 | //qDebug(currentDir.canonicalPath()); |
186 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 192 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
187 | currentDir.setMatchAllDirs(TRUE); | 193 | currentDir.setMatchAllDirs(TRUE); |
188 | 194 | ||
189 | // currentDir.setNameFilter("*.txt;*.etx"); | 195 | // currentDir.setNameFilter("*.txt;*.etx"); |
190 | QString fileL, fileS, fileDate; | 196 | QString fileL, fileS, fileDate; |
191 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 197 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
192 | QFileInfoListIterator it(*list); | 198 | QFileInfoListIterator it(*list); |
193 | QFileInfo *fi; | 199 | QFileInfo *fi; |
194 | while ( (fi=it.current()) ) { | 200 | while ( (fi=it.current()) ) { |
195 | if (fi->isSymLink() ){ | 201 | if (fi->isSymLink() ){ |
196 | QString symLink=fi->readLink(); | 202 | QString symLink=fi->readLink(); |
197 | // qDebug("Symlink detected "+symLink); | 203 | // qDebug("Symlink detected "+symLink); |
198 | QFileInfo sym( symLink); | 204 | QFileInfo sym( symLink); |
199 | fileS.sprintf( "%10li", sym.size() ); | 205 | fileS.sprintf( "%10li", sym.size() ); |
200 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 206 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
201 | fileDate = sym.lastModified().toString(); | 207 | fileDate = sym.lastModified().toString(); |
202 | } else { | 208 | } else { |
203 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 209 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
204 | fileS.sprintf( "%10li", fi->size() ); | 210 | fileS.sprintf( "%10li", fi->size() ); |
205 | fileL.sprintf( "%s",fi->fileName().data() ); | 211 | fileL.sprintf( "%s",fi->fileName().data() ); |
206 | fileDate= fi->lastModified().toString(); | 212 | fileDate= fi->lastModified().toString(); |
207 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 213 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
208 | fileL+="/"; | 214 | fileL+="/"; |
209 | isDir=TRUE; | 215 | isDir=TRUE; |
210 | // qDebug( fileL); | 216 | // qDebug( fileL); |
211 | } | 217 | } |
212 | } | 218 | } |
213 | if(fileL !="./" && fi->exists()) { | 219 | if(fileL !="./" && fi->exists()) { |
214 | item= new QListViewItem( ListView,fileL,fileS , fileDate); | 220 | item= new QListViewItem( ListView,fileL,fileS , fileDate); |
215 | QPixmap pm; | 221 | QPixmap pm; |
216 | 222 | ||
217 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 223 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
218 | if( !QDir( fi->filePath() ).isReadable()) | 224 | if( !QDir( fi->filePath() ).isReadable()) |
219 | pm = Resource::loadPixmap( "lockedfolder" ); | 225 | pm = Resource::loadPixmap( "lockedfolder" ); |
220 | else | 226 | else |
221 | pm= Resource::loadPixmap( "folder" ); | 227 | pm= Resource::loadPixmap( "folder" ); |
222 | item->setPixmap( 0,pm ); | 228 | item->setPixmap( 0,pm ); |
223 | } else { | 229 | } else { |
224 | if( !fi->isReadable() ) | 230 | if( !fi->isReadable() ) |
225 | pm = Resource::loadPixmap( "locked" ); | 231 | pm = Resource::loadPixmap( "locked" ); |
226 | else { | 232 | else { |
227 | MimeType mt(fi->filePath()); | 233 | MimeType mt(fi->filePath()); |
228 | pm=mt.pixmap();// sets the pixmap for the mimetype | 234 | pm=mt.pixmap();// sets the pixmap for the mimetype |
229 | if(pm.isNull()) | 235 | if(pm.isNull()) |
230 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 236 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
231 | item->setPixmap( 0,pm); | 237 | item->setPixmap( 0,pm); |
232 | } | 238 | } |
233 | } | 239 | } |
234 | if( fileL.find("->",0,TRUE) != -1) { | 240 | if( fileL.find("->",0,TRUE) != -1) { |
235 | // overlay link image | 241 | // overlay link image |
236 | pm= Resource::loadPixmap( "folder" ); | 242 | pm= Resource::loadPixmap( "folder" ); |
237 | QPixmap lnk = Resource::loadPixmap( "symlink" ); | 243 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
238 | QPainter painter( &pm ); | 244 | QPainter painter( &pm ); |
239 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 245 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
240 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 246 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
241 | item->setPixmap( 0, pm); | 247 | item->setPixmap( 0, pm); |
242 | } | 248 | } |
243 | } | 249 | } |
244 | isDir=FALSE; | 250 | isDir=FALSE; |
245 | ++it; | 251 | ++it; |
246 | // } | 252 | // } |
247 | } | 253 | } |
248 | ListView->setSorting( 3, FALSE); | 254 | ListView->setSorting( 3, FALSE); |
249 | QString currentPath = currentDir.canonicalPath(); | 255 | QString currentPath = currentDir.canonicalPath(); |
250 | 256 | ||
251 | fillCombo( (const QString &)currentPath); | 257 | fillCombo( (const QString &)currentPath); |
252 | // dirPathCombo->lineEdit()->setText(currentPath); | 258 | // dirPathCombo->lineEdit()->setText(currentPath); |
253 | 259 | ||
254 | // if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 260 | // if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
255 | // dirPathCombo->clear(); | 261 | // dirPathCombo->clear(); |
256 | // dirPathStringList.prepend(currentPath ); | 262 | // dirPathStringList.prepend(currentPath ); |
257 | // dirPathCombo->insertStringList( dirPathStringList,-1); | 263 | // dirPathCombo->insertStringList( dirPathStringList,-1); |
258 | // } | 264 | // } |
259 | } | 265 | } |
260 | 266 | ||
261 | void fileBrowser::upDir() | 267 | void fileBrowser::upDir() |
262 | { | 268 | { |
263 | QString current = currentDir.canonicalPath(); | 269 | QString current = currentDir.canonicalPath(); |
264 | QDir dir(current); | 270 | QDir dir(current); |
265 | dir.cdUp(); | 271 | dir.cdUp(); |
266 | current = dir.canonicalPath(); | 272 | current = dir.canonicalPath(); |
267 | chdir( current.latin1() ); | 273 | chdir( current.latin1() ); |
268 | currentDir.cd( current, TRUE); | 274 | currentDir.cd( current, TRUE); |
269 | populateList(); | 275 | populateList(); |
270 | update(); | 276 | update(); |
271 | } | 277 | } |
272 | 278 | ||
273 | // you may want to switch these 2 functions. I like single clicks | 279 | // you may want to switch these 2 functions. I like single clicks |
274 | void fileBrowser::listClicked(QListViewItem *selectedItem) | 280 | void fileBrowser::listClicked(QListViewItem *selectedItem) |
275 | { | 281 | { |
276 | if(selectedItem) { | 282 | if(selectedItem) { |
277 | QString strItem=selectedItem->text(0); | 283 | QString strItem=selectedItem->text(0); |
278 | QString strSize=selectedItem->text(1); | 284 | QString strSize=selectedItem->text(1); |
279 | // qDebug("strItem is "+strItem); | 285 | // qDebug("strItem is "+strItem); |
280 | strSize.stripWhiteSpace(); | 286 | strSize.stripWhiteSpace(); |
281 | // qDebug(strSize); | 287 | // qDebug(strSize); |
282 | 288 | ||
283 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 289 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
284 | // is symlink | 290 | // is symlink |
285 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); | 291 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); |
286 | // qDebug("strItem symlink is "+strItem2); | 292 | // qDebug("strItem symlink is "+strItem2); |
287 | if(QDir(strItem2).exists() ) { | 293 | if(QDir(strItem2).exists() ) { |
288 | currentDir.cd(strItem2, TRUE); | 294 | currentDir.cd(strItem2, TRUE); |
289 | populateList(); | 295 | populateList(); |
290 | } | 296 | } |
291 | } else { // not a symlink | 297 | } else { // not a symlink |
292 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 298 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
293 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 299 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
294 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 300 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
295 | currentDir.cd(strItem,FALSE); | 301 | currentDir.cd(strItem,FALSE); |
296 | // qDebug("Path is "+strItem); | 302 | // qDebug("Path is "+strItem); |
297 | populateList(); | 303 | populateList(); |
298 | } else { | 304 | } else { |
299 | currentDir.cdUp(); | 305 | currentDir.cdUp(); |
300 | populateList(); | 306 | populateList(); |
301 | } | 307 | } |
302 | if(QDir(strItem).exists()){ | 308 | if(QDir(strItem).exists()){ |
303 | currentDir.cd(strItem, TRUE); | 309 | currentDir.cd(strItem, TRUE); |
304 | populateList(); | 310 | populateList(); |
305 | } | 311 | } |
306 | } else { | 312 | } else { |
307 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 313 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
308 | if( QFile::exists(strItem ) ) { | 314 | if( QFile::exists(strItem ) ) { |
309 | //currentDir.canonicalPath() | 315 | //currentDir.canonicalPath() |
310 | qDebug("We found our files!!"+strItem); | 316 | qDebug("We found our files!!"+strItem); |
311 | OnOK(); | 317 | OnOK(); |
312 | } | 318 | } |
313 | } //end not symlink | 319 | } //end not symlink |
314 | chdir(strItem.latin1()); | 320 | chdir(strItem.latin1()); |
315 | } | 321 | } |
316 | } | 322 | } |
317 | } | 323 | } |
318 | 324 | ||
319 | void fileBrowser::OnOK() | 325 | void fileBrowser::OnOK() |
320 | { | 326 | { |
321 | QListViewItemIterator it1( ListView); | 327 | QListViewItemIterator it1( ListView); |
322 | for ( ; it1.current(); ++it1 ) { | 328 | for ( ; it1.current(); ++it1 ) { |
323 | if ( it1.current()->isSelected() ) { | 329 | if ( it1.current()->isSelected() ) { |
324 | selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); | 330 | selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); |
325 | qDebug("selected filename is "+selectedFileName); | 331 | qDebug("selected filename is "+selectedFileName); |
326 | fileList.append( selectedFileName ); | 332 | fileList.append( selectedFileName ); |
327 | } | 333 | } |
328 | } | 334 | } |
329 | accept(); | 335 | accept(); |
330 | } | 336 | } |
331 | 337 | ||
332 | void fileBrowser::homeButtonPushed() { | 338 | void fileBrowser::homeButtonPushed() { |
333 | QString current = QDir::homeDirPath(); | 339 | QString current = QDir::homeDirPath(); |
334 | chdir( current.latin1() ); | 340 | chdir( current.latin1() ); |
335 | currentDir.cd( current, TRUE); | 341 | currentDir.cd( current, TRUE); |
336 | populateList(); | 342 | populateList(); |
337 | update(); | 343 | update(); |
338 | } | 344 | } |
339 | 345 | ||
340 | void fileBrowser::docButtonPushed() { | 346 | void fileBrowser::docButtonPushed() { |
341 | QString current = QPEApplication::documentDir(); | 347 | QString current = QPEApplication::documentDir(); |
342 | chdir( current.latin1() ); | 348 | chdir( current.latin1() ); |
343 | currentDir.cd( current, TRUE); | 349 | currentDir.cd( current, TRUE); |
344 | populateList(); | 350 | populateList(); |
345 | update(); | 351 | update(); |
346 | 352 | ||
347 | } | 353 | } |
348 | 354 | ||
349 | void fileBrowser::selectionChanged( const QString &select ) | 355 | void fileBrowser::selectionChanged( const QString &select ) |
350 | { | 356 | { |
351 | if ( select == "Documents") { | 357 | if ( select == "Documents") { |
352 | FileStack->raiseWidget( fileSelector ); | 358 | FileStack->raiseWidget( fileSelector ); |
353 | dirPathCombo->hide(); | 359 | dirPathCombo->hide(); |
354 | cdUpButton->hide(); | 360 | cdUpButton->hide(); |
355 | docButton->hide(); | 361 | docButton->hide(); |
356 | homeButton->hide(); | 362 | homeButton->hide(); |
357 | } else { | 363 | } else { |
358 | if ( select == "All files" ) | 364 | if ( select == "All files" ) |
359 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All); | 365 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All); |
360 | else | 366 | else |
361 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 367 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
362 | 368 | ||
363 | populateList(); | 369 | populateList(); |
364 | update(); | 370 | update(); |
365 | dirPathCombo->show(); | 371 | dirPathCombo->show(); |
366 | cdUpButton->show(); | 372 | cdUpButton->show(); |
367 | docButton->show(); | 373 | docButton->show(); |
368 | homeButton->show(); | 374 | homeButton->show(); |
369 | FileStack->raiseWidget( ListView ); | 375 | FileStack->raiseWidget( ListView ); |
370 | } | 376 | } |
371 | } | 377 | } |
372 | 378 | ||
373 | void fileBrowser::docOpen( const DocLnk &doc ) | 379 | void fileBrowser::docOpen( const DocLnk &doc ) |
374 | { | 380 | { |
375 | fileList.append( doc.file().latin1() ); | 381 | fileList.append( doc.file().latin1() ); |
376 | accept(); | 382 | accept(); |
377 | } | 383 | } |
378 | 384 | ||
379 | void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 385 | void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
380 | { | 386 | { |
381 | switch (mouse) { | 387 | switch (mouse) { |
382 | case 1: | 388 | case 1: |
383 | break; | 389 | break; |
384 | case 2: | 390 | case 2: |
385 | showListMenu(item); | 391 | showListMenu(item); |
386 | break; | 392 | break; |
387 | }; | 393 | }; |
388 | } | 394 | } |
389 | 395 | ||
390 | void fileBrowser::showListMenu(QListViewItem *item) { | 396 | void fileBrowser::showListMenu(QListViewItem *item) { |
391 | 397 | ||
392 | QPopupMenu m;// = new QPopupMenu( Local_View ); | 398 | QPopupMenu m;// = new QPopupMenu( Local_View ); |
393 | if(item) { | 399 | if(item) { |
394 | if( item->text(0).find("/",0,TRUE)) | 400 | if( item->text(0).find("/",0,TRUE)) |
395 | m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); | 401 | m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); |
396 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); | 402 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); |
397 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); | 403 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); |
398 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 404 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
399 | m.insertSeparator(); | 405 | m.insertSeparator(); |
400 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 406 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
401 | } else { | 407 | } else { |
402 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); | 408 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); |
403 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); | 409 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); |
404 | 410 | ||
405 | } | 411 | } |
406 | m.exec( QCursor::pos() ); | 412 | m.exec( QCursor::pos() ); |
407 | } | 413 | } |
408 | 414 | ||
409 | void fileBrowser::doCd() { | 415 | void fileBrowser::doCd() { |
410 | listClicked( ListView->currentItem()); | 416 | listClicked( ListView->currentItem()); |
411 | } | 417 | } |
412 | 418 | ||
413 | void fileBrowser::makDir() { | 419 | void fileBrowser::makDir() { |
414 | InputDialog *fileDlg; | 420 | InputDialog *fileDlg; |
415 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); | 421 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); |
416 | fileDlg->exec(); | 422 | fileDlg->exec(); |
417 | if( fileDlg->result() == 1 ) { | 423 | if( fileDlg->result() == 1 ) { |
418 | QString filename = fileDlg->LineEdit1->text(); | 424 | QString filename = fileDlg->LineEdit1->text(); |
419 | qDebug("Make dir"); | 425 | qDebug("Make dir"); |
420 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 426 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
421 | } | 427 | } |
422 | populateList(); | 428 | populateList(); |
423 | } | 429 | } |
424 | 430 | ||
425 | void fileBrowser::localRename() { | 431 | void fileBrowser::localRename() { |
426 | QString curFile = ListView->currentItem()->text(0); | 432 | QString curFile = ListView->currentItem()->text(0); |
427 | InputDialog *fileDlg; | 433 | InputDialog *fileDlg; |
428 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); | 434 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); |
429 | fileDlg->setTextEdit((const QString &) curFile); | 435 | fileDlg->setTextEdit((const QString &) curFile); |
430 | fileDlg->exec(); | 436 | fileDlg->exec(); |
431 | if( fileDlg->result() == 1 ) { | 437 | if( fileDlg->result() == 1 ) { |
432 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 438 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
433 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 439 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
434 | if( rename(oldname.latin1(), newName.latin1())== -1) | 440 | if( rename(oldname.latin1(), newName.latin1())== -1) |
435 | QMessageBox::message("Note","Could not rename"); | 441 | QMessageBox::message("Note","Could not rename"); |
436 | } | 442 | } |
437 | populateList(); | 443 | populateList(); |
438 | } | 444 | } |
439 | 445 | ||
440 | void fileBrowser::localDelete() { | 446 | void fileBrowser::localDelete() { |
441 | QString f = ListView->currentItem()->text(0); | 447 | QString f = ListView->currentItem()->text(0); |
442 | if(QDir(f).exists() ) { | 448 | if(QDir(f).exists() ) { |
443 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ | 449 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ |
444 | " ?\nIt must be empty","Yes","No",0,0,1) ) { | 450 | " ?\nIt must be empty","Yes","No",0,0,1) ) { |
445 | case 0: { | 451 | case 0: { |
446 | f=currentDir.canonicalPath()+"/"+f; | 452 | f=currentDir.canonicalPath()+"/"+f; |
447 | QString cmd="rmdir "+f; | 453 | QString cmd="rmdir "+f; |
448 | system( cmd.latin1()); | 454 | system( cmd.latin1()); |
449 | populateList(); | 455 | populateList(); |
450 | } | 456 | } |
451 | break; | 457 | break; |
452 | case 1: | 458 | case 1: |
453 | // exit | 459 | // exit |
454 | break; | 460 | break; |
455 | }; | 461 | }; |
456 | } else { | 462 | } else { |
457 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f | 463 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f |
458 | +" ?","Yes","No",0,0,1) ) { | 464 | +" ?","Yes","No",0,0,1) ) { |
459 | case 0: { | 465 | case 0: { |
460 | f=currentDir.canonicalPath()+"/"+f; | 466 | f=currentDir.canonicalPath()+"/"+f; |
461 | QString cmd="rm "+f; | 467 | QString cmd="rm "+f; |
462 | system( cmd.latin1()); | 468 | system( cmd.latin1()); |
463 | populateList(); | 469 | populateList(); |
464 | } | 470 | } |
465 | break; | 471 | break; |
466 | case 1: | 472 | case 1: |
467 | // exit | 473 | // exit |
468 | break; | 474 | break; |
469 | }; | 475 | }; |
470 | } | 476 | } |
471 | } | 477 | } |
472 | 478 | ||
473 | void fileBrowser::updateMimeTypeMenu() { | 479 | void fileBrowser::updateMimeTypeMenu() { |
474 | 480 | ||
475 | disconnect( typemb, SIGNAL(selected(const QString&)), | 481 | disconnect( typemb, SIGNAL(selected(const QString&)), |
476 | this, SLOT(showType(const QString&)) ); | 482 | this, SLOT(showType(const QString&)) ); |
477 | 483 | ||
478 | QString prev; | 484 | QString prev; |
479 | 485 | ||
480 | // Type filter | 486 | // Type filter |
481 | QStringList types; | 487 | QStringList types; |
482 | types << tr("All"); | 488 | types << tr("All"); |
483 | types << "--"; | 489 | types << "--"; |
484 | types += getMimeTypes(); | 490 | types += getMimeTypes(); |
485 | prev = typemb->currentText(); | 491 | prev = typemb->currentText(); |
486 | typemb->clear(); | 492 | typemb->clear(); |
487 | typemb->insertItems(types); | 493 | typemb->insertItems(types); |
488 | // typemb->select(prev); | 494 | // typemb->select(prev); |
489 | 495 | ||
490 | connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&))); | 496 | connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&))); |
491 | } | 497 | } |
492 | 498 | ||
493 | void fileBrowser::showType(const QString &t) { | 499 | void fileBrowser::showType(const QString &t) { |
494 | 500 | ||
495 | qDebug(t); | 501 | // qDebug("Show type "+t); |
496 | if(t.find("All",0,TRUE) != -1) { | 502 | if(t.find("All",0,TRUE) != -1) { |
497 | filterStr = "*"; | 503 | filterStr = "*"; |
498 | } else { | 504 | } else { |
499 | QStringList list = mimetypes.grep( t,TRUE); | 505 | QStringList list = mimetypes.grep( t,TRUE); |
500 | QString ext; | 506 | QString ext; |
501 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 507 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
502 | mimeType =(*it); | 508 | mimeType =(*it); |
503 | MimeType mt( mimeType); | 509 | MimeType mt(mimeType); |
504 | // qDebug("mime "+mimeType); | 510 | |
505 | // qDebug("description "+mt.description()); | 511 | // qDebug("mime "+mimeType); |
506 | // qDebug( "id "+mt.id()); | 512 | // qDebug("description "+mt.description()); |
507 | // qDebug("extension "+mt.extension()); | 513 | // qDebug( "id "+mt.id()); |
508 | // if( mt.extension().isEmpty()) | 514 | // qDebug("extension "+mt.extension()); |
515 | |||
516 | if( mt.extension().isEmpty()) | ||
509 | filterStr = "*"; | 517 | filterStr = "*"; |
510 | // else | 518 | else |
511 | // filterStr = "*."+ mt.extension()+" "; | 519 | filterStr = "*."+ mt.extension()+" "; |
512 | // printf( "%s \n", (*it).latin1() ); | 520 | // printf( "%s \n", (*it).latin1() ); |
513 | } | 521 | } |
514 | } | 522 | } |
515 | currentDir.setNameFilter(filterStr); | 523 | currentDir.setNameFilter(filterStr); |
516 | 524 | ||
517 | populateList(); | 525 | populateList(); |
518 | update(); | 526 | update(); |
519 | // if(fileSelector) { | 527 | // if(fileSelector) { |
520 | // disconnect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); | 528 | // disconnect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); |
521 | // delete fileSelector; | 529 | // delete fileSelector; |
522 | // } | 530 | // } |
523 | // fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy | 531 | // fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy |
524 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); | 532 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); |
525 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 533 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
526 | // connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); | 534 | // connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); |
527 | // fileSelector->reread(); | 535 | // fileSelector->reread(); |
528 | // if ( t == tr("All") ) { | 536 | // if ( t == tr("All") ) { |
529 | // icons->setTypeFilter("",TRUE); | 537 | // icons->setTypeFilter("",TRUE); |
530 | // } else { | 538 | // } else { |
531 | // icons->setTypeFilter(t+"/*",TRUE); | 539 | // icons->setTypeFilter(t+"/*",TRUE); |
532 | // } | 540 | // } |
533 | 541 | ||
534 | } | 542 | } |
535 | 543 | ||
536 | QStringList fileBrowser::getMimeTypes() { | 544 | QStringList fileBrowser::getMimeTypes() { |
537 | 545 | ||
538 | QStringList r; | 546 | QStringList r; |
539 | AppLnkSet apps( QPEApplication::qpeDir() + "apps" ); | 547 | AppLnkSet apps( QPEApplication::qpeDir() + "apps" ); |
540 | QFile file( QPEApplication::qpeDir()+"etc/available.mime"); | 548 | QFile file( QPEApplication::qpeDir()+"etc/available.mime"); |
541 | file.open( IO_WriteOnly|IO_Truncate);//) | 549 | file.open( IO_WriteOnly|IO_Truncate);//) |
542 | for ( QListIterator<AppLnk> it( apps.children() ); it.current(); ++it ) { | 550 | for ( QListIterator<AppLnk> it( apps.children() ); it.current(); ++it ) { |
543 | AppLnk* l; | 551 | AppLnk* l; |
544 | l = it.current(); | 552 | l = it.current(); |
545 | QStringList maj = l->mimeTypes(); | 553 | QStringList maj = l->mimeTypes(); |
546 | QStringList::ConstIterator f; | 554 | QStringList::ConstIterator f; |
547 | for ( f = maj.begin(); f != maj.end(); f++ ) { | 555 | for ( f = maj.begin(); f != maj.end(); f++ ) { |
548 | QString temp = *f; | 556 | QString temp = *f; |
557 | qDebug("type "+temp); | ||
549 | mimetypes << temp; | 558 | mimetypes << temp; |
550 | int sl = temp.find('/'); | 559 | int sl = temp.find('/'); |
551 | if (sl >= 0) { | 560 | if (sl >= 0) { |
552 | QString k = temp.left(sl); | 561 | QString k = temp;//.left(sl); |
553 | if( r.grep(k,TRUE).isEmpty() ) { | 562 | if( r.grep(k,TRUE).isEmpty() ) { |
554 | r << k; | 563 | r << k; |
555 | k+="\n"; | 564 | k+="\n"; |
556 | file.writeBlock( k.latin1(), k.length()); | 565 | file.writeBlock( k.latin1(), k.length()); |
557 | } | 566 | } |
558 | } | 567 | } |
559 | } | 568 | } |
560 | } | 569 | } |
561 | r.sort(); | 570 | r.sort(); |
562 | file.close(); | 571 | file.close(); |
563 | return r; | 572 | return r; |
564 | } | 573 | } |
565 | 574 | ||
566 | void fileBrowser::receive( const QCString &msg, const QByteArray &data ) { | 575 | void fileBrowser::receive( const QCString &msg, const QByteArray &data ) { |
567 | // QDataStream stream( data, IO_ReadOnly ); | 576 | // QDataStream stream( data, IO_ReadOnly ); |
568 | // if (msg == "keyRegister(int key, QString channel, QString message)") | 577 | // if (msg == "keyRegister(int key, QString channel, QString message)") |
569 | // { | 578 | // { |
570 | // int k; | 579 | // int k; |
571 | // QString c, m; | 580 | // QString c, m; |
572 | // stream >> k; | 581 | // stream >> k; |
573 | // stream >> c; | 582 | // stream >> c; |
574 | // stream >> m; | 583 | // stream >> m; |
575 | } | 584 | } |
576 | 585 | ||
577 | void fileBrowser::dirPathComboActivated( const QString & current) { | 586 | void fileBrowser::dirPathComboActivated( const QString & current) { |
578 | chdir( current.latin1() ); | 587 | chdir( current.latin1() ); |
579 | currentDir.cd( current, TRUE); | 588 | currentDir.cd( current, TRUE); |
580 | populateList(); | 589 | populateList(); |
581 | update(); | 590 | update(); |
582 | } | 591 | } |
583 | 592 | ||
584 | void fileBrowser::dirPathEditPressed() { | 593 | void fileBrowser::dirPathEditPressed() { |
585 | QString current = dirPathCombo->lineEdit()->text(); | 594 | QString current = dirPathCombo->lineEdit()->text(); |
586 | chdir( current.latin1() ); | 595 | chdir( current.latin1() ); |
587 | currentDir.cd( current, TRUE); | 596 | currentDir.cd( current, TRUE); |
588 | populateList(); | 597 | populateList(); |
589 | update(); | 598 | update(); |
590 | } | 599 | } |
591 | 600 | ||
592 | void fileBrowser::fillCombo(const QString ¤tPath) { | 601 | void fileBrowser::fillCombo(const QString ¤tPath) { |
593 | 602 | ||
594 | dirPathCombo->lineEdit()->setText(currentPath); | 603 | dirPathCombo->lineEdit()->setText(currentPath); |
595 | 604 | ||
596 | if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 605 | if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
597 | dirPathCombo->clear(); | 606 | dirPathCombo->clear(); |
598 | dirPathStringList.prepend(currentPath ); | 607 | dirPathStringList.prepend(currentPath ); |
599 | dirPathCombo->insertStringList( dirPathStringList,-1); | 608 | dirPathCombo->insertStringList( dirPathStringList,-1); |
600 | } | 609 | } |
601 | } | 610 | } |
602 | 611 | ||
603 | 612 | ||
604 | InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | 613 | InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) |
605 | : QDialog( parent, name, modal, fl ) | 614 | : QDialog( parent, name, modal, fl ) |
606 | { | 615 | { |
607 | if ( !name ) | 616 | if ( !name ) |
608 | setName( "InputDialog" ); | 617 | setName( "InputDialog" ); |
609 | resize( 234, 50 ); | 618 | resize( 234, 50 ); |
610 | setMaximumSize( QSize( 240, 50 ) ); | 619 | setMaximumSize( QSize( 240, 50 ) ); |
611 | setCaption( tr(name ) ); | 620 | setCaption( tr(name ) ); |
612 | 621 | ||
613 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | 622 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); |
614 | LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); | 623 | LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); |
615 | } | 624 | } |
616 | 625 | ||
617 | InputDialog::~InputDialog() | 626 | InputDialog::~InputDialog() |
618 | { | 627 | { |
619 | inputText= LineEdit1->text(); | 628 | inputText= LineEdit1->text(); |
620 | 629 | ||
621 | } | 630 | } |
622 | 631 | ||
623 | void InputDialog::setTextEdit(const QString &string) { | 632 | void InputDialog::setTextEdit(const QString &string) { |
624 | LineEdit1->setText(string); | 633 | LineEdit1->setText(string); |
625 | } | 634 | } |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 18402d4..84888c1 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -120,801 +120,810 @@ static char * filesave_xpm[] = { | |||
120 | "r c #696969", | 120 | "r c #696969", |
121 | "s c #494949", | 121 | "s c #494949", |
122 | "t c #555555", | 122 | "t c #555555", |
123 | "u c #949494", | 123 | "u c #949494", |
124 | "v c #E6E6E6", | 124 | "v c #E6E6E6", |
125 | "w c #424242", | 125 | "w c #424242", |
126 | "x c #515151", | 126 | "x c #515151", |
127 | "y c #535353", | 127 | "y c #535353", |
128 | "z c #3E3E3E", | 128 | "z c #3E3E3E", |
129 | "A c #D4D4D4", | 129 | "A c #D4D4D4", |
130 | "B c #0C0C0C", | 130 | "B c #0C0C0C", |
131 | "C c #353535", | 131 | "C c #353535", |
132 | "D c #474747", | 132 | "D c #474747", |
133 | "E c #ECECEC", | 133 | "E c #ECECEC", |
134 | "F c #919191", | 134 | "F c #919191", |
135 | "G c #7D7D7D", | 135 | "G c #7D7D7D", |
136 | "H c #000000", | 136 | "H c #000000", |
137 | "I c #404040", | 137 | "I c #404040", |
138 | "J c #858585", | 138 | "J c #858585", |
139 | "K c #323232", | 139 | "K c #323232", |
140 | "L c #D0D0D0", | 140 | "L c #D0D0D0", |
141 | "M c #1C1C1C", | 141 | "M c #1C1C1C", |
142 | " ...+ ", | 142 | " ...+ ", |
143 | " @#$%&..+ ", | 143 | " @#$%&..+ ", |
144 | " .*=-;;>,..+ ", | 144 | " .*=-;;>,..+ ", |
145 | " ')!~;;;;;;{]..", | 145 | " ')!~;;;;;;{]..", |
146 | " ^/(-;;;;;;;_:<", | 146 | " ^/(-;;;;;;;_:<", |
147 | " [}|;;;;;;;{12$", | 147 | " [}|;;;;;;;{12$", |
148 | " #34-55;;;;678$+", | 148 | " #34-55;;;;678$+", |
149 | " 90ab=c;dd;e1fg ", | 149 | " 90ab=c;dd;e1fg ", |
150 | " [ahij((kbl0mn$ ", | 150 | " [ahij((kbl0mn$ ", |
151 | " op^q^^7r&]s/$+ ", | 151 | " op^q^^7r&]s/$+ ", |
152 | "@btu;vbwxy]zAB ", | 152 | "@btu;vbwxy]zAB ", |
153 | "CzDEvEv;;DssF$ ", | 153 | "CzDEvEv;;DssF$ ", |
154 | "G.H{E{E{IxsJ$+ ", | 154 | "G.H{E{E{IxsJ$+ ", |
155 | " +...vEKxzLM ", | 155 | " +...vEKxzLM ", |
156 | " +...z]n$ ", | 156 | " +...z]n$ ", |
157 | " +... "}; | 157 | " +... "}; |
158 | 158 | ||
159 | 159 | ||
160 | #if QT_VERSION < 300 | 160 | #if QT_VERSION < 300 |
161 | 161 | ||
162 | class QpeEditor : public QMultiLineEdit | 162 | class QpeEditor : public QMultiLineEdit |
163 | { | 163 | { |
164 | // Q_OBJECT | 164 | // Q_OBJECT |
165 | public: | 165 | public: |
166 | QpeEditor( QWidget *parent, const char * name = 0 ) | 166 | QpeEditor( QWidget *parent, const char * name = 0 ) |
167 | : QMultiLineEdit( parent, name ) | 167 | : QMultiLineEdit( parent, name ) |
168 | { | 168 | { |
169 | clearTableFlags(); | 169 | clearTableFlags(); |
170 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); | 170 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); |
171 | } | 171 | } |
172 | 172 | ||
173 | void find( const QString &txt, bool caseSensitive, | 173 | void find( const QString &txt, bool caseSensitive, |
174 | bool backwards ); | 174 | bool backwards ); |
175 | //public slots: | 175 | //public slots: |
176 | /* | 176 | /* |
177 | signals: | 177 | signals: |
178 | void notFound(); | 178 | void notFound(); |
179 | void searchWrapped(); | 179 | void searchWrapped(); |
180 | */ | 180 | */ |
181 | 181 | ||
182 | private: | 182 | private: |
183 | 183 | ||
184 | }; | 184 | }; |
185 | 185 | ||
186 | 186 | ||
187 | void QpeEditor::find ( const QString &txt, bool caseSensitive, | 187 | void QpeEditor::find ( const QString &txt, bool caseSensitive, |
188 | bool backwards ) | 188 | bool backwards ) |
189 | { | 189 | { |
190 | static bool wrap = FALSE; | 190 | static bool wrap = FALSE; |
191 | int line, col; | 191 | int line, col; |
192 | if ( wrap ) { | 192 | if ( wrap ) { |
193 | if ( !backwards ) | 193 | if ( !backwards ) |
194 | line = col = 0; | 194 | line = col = 0; |
195 | wrap = FALSE; | 195 | wrap = FALSE; |
196 | // emit searchWrapped(); | 196 | // emit searchWrapped(); |
197 | } else { | 197 | } else { |
198 | getCursorPosition( &line, &col ); | 198 | getCursorPosition( &line, &col ); |
199 | } | 199 | } |
200 | //ignore backwards for now.... | 200 | //ignore backwards for now.... |
201 | if ( !backwards ) { | 201 | if ( !backwards ) { |
202 | for ( ; ; ) { | 202 | for ( ; ; ) { |
203 | if ( line >= numLines() ) { | 203 | if ( line >= numLines() ) { |
204 | wrap = TRUE; | 204 | wrap = TRUE; |
205 | //emit notFound(); | 205 | //emit notFound(); |
206 | break; | 206 | break; |
207 | } | 207 | } |
208 | int findCol = getString( line )->find( txt, col, caseSensitive ); | 208 | int findCol = getString( line )->find( txt, col, caseSensitive ); |
209 | if ( findCol >= 0 ) { | 209 | if ( findCol >= 0 ) { |
210 | setCursorPosition( line, findCol, FALSE ); | 210 | setCursorPosition( line, findCol, FALSE ); |
211 | col = findCol + txt.length(); | 211 | col = findCol + txt.length(); |
212 | setCursorPosition( line, col, TRUE ); | 212 | setCursorPosition( line, col, TRUE ); |
213 | 213 | ||
214 | //found = TRUE; | 214 | //found = TRUE; |
215 | break; | 215 | break; |
216 | } | 216 | } |
217 | line++; | 217 | line++; |
218 | col = 0; | 218 | col = 0; |
219 | } | 219 | } |
220 | 220 | ||
221 | } | 221 | } |
222 | 222 | ||
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | #else | 226 | #else |
227 | 227 | ||
228 | #error "Must make a QpeEditor that inherits QTextEdit" | 228 | #error "Must make a QpeEditor that inherits QTextEdit" |
229 | 229 | ||
230 | #endif | 230 | #endif |
231 | 231 | ||
232 | 232 | ||
233 | static const int nfontsizes = 6; | 233 | static const int nfontsizes = 6; |
234 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; | 234 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; |
235 | 235 | ||
236 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | 236 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) |
237 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ) | 237 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ) |
238 | { | 238 | { |
239 | doc = 0; | 239 | doc = 0; |
240 | edited=FALSE; | 240 | edited=FALSE; |
241 | edited1=FALSE; | 241 | edited1=FALSE; |
242 | setToolBarsMovable( FALSE ); | 242 | setToolBarsMovable( FALSE ); |
243 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 243 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
244 | 244 | ||
245 | channel = new QCopChannel( "QPE/Application/textedit", this ); | 245 | channel = new QCopChannel( "QPE/Application/textedit", this ); |
246 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 246 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
247 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 247 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
248 | 248 | ||
249 | setIcon( Resource::loadPixmap( "TextEditor" ) ); | 249 | setIcon( Resource::loadPixmap( "TextEditor" ) ); |
250 | 250 | ||
251 | QPEToolBar *bar = new QPEToolBar( this ); | 251 | QPEToolBar *bar = new QPEToolBar( this ); |
252 | bar->setHorizontalStretchable( TRUE ); | 252 | bar->setHorizontalStretchable( TRUE ); |
253 | menu = bar; | 253 | menu = bar; |
254 | 254 | ||
255 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 255 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
256 | QPopupMenu *file = new QPopupMenu( this ); | 256 | QPopupMenu *file = new QPopupMenu( this ); |
257 | QPopupMenu *edit = new QPopupMenu( this ); | 257 | QPopupMenu *edit = new QPopupMenu( this ); |
258 | font = new QPopupMenu( this ); | 258 | font = new QPopupMenu( this ); |
259 | 259 | ||
260 | bar = new QPEToolBar( this ); | 260 | bar = new QPEToolBar( this ); |
261 | editBar = bar; | 261 | editBar = bar; |
262 | 262 | ||
263 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 263 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
264 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 264 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
265 | a->addTo( bar ); | 265 | a->addTo( bar ); |
266 | a->addTo( file ); | 266 | a->addTo( file ); |
267 | 267 | ||
268 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 268 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
269 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 269 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
270 | a->addTo( bar ); | 270 | a->addTo( bar ); |
271 | a->addTo( file ); | 271 | a->addTo( file ); |
272 | 272 | ||
273 | a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); | 273 | a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); |
274 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); | 274 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); |
275 | file->insertSeparator(); | 275 | file->insertSeparator(); |
276 | a->addTo( file ); | 276 | a->addTo( file ); |
277 | 277 | ||
278 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); | 278 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); |
279 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); | 279 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); |
280 | a->addTo( file ); | 280 | a->addTo( file ); |
281 | 281 | ||
282 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); | 282 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); |
283 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 283 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
284 | a->addTo( editBar ); | 284 | a->addTo( editBar ); |
285 | a->addTo( edit ); | 285 | a->addTo( edit ); |
286 | 286 | ||
287 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); | 287 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); |
288 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 288 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
289 | a->addTo( editBar ); | 289 | a->addTo( editBar ); |
290 | a->addTo( edit ); | 290 | a->addTo( edit ); |
291 | 291 | ||
292 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 292 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
293 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 293 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
294 | a->addTo( editBar ); | 294 | a->addTo( editBar ); |
295 | a->addTo( edit ); | 295 | a->addTo( edit ); |
296 | 296 | ||
297 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 297 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
298 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 298 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
299 | edit->insertSeparator(); | 299 | edit->insertSeparator(); |
300 | a->addTo( bar ); | 300 | a->addTo( bar ); |
301 | a->addTo( edit ); | 301 | a->addTo( edit ); |
302 | 302 | ||
303 | int defsize; | 303 | int defsize; |
304 | bool defb, defi, wrap; | 304 | bool defb, defi, wrap; |
305 | 305 | ||
306 | Config cfg("TextEdit"); | 306 | Config cfg("TextEdit"); |
307 | cfg.setGroup("View"); | 307 | cfg.setGroup("View"); |
308 | defsize = cfg.readNumEntry("FontSize",10); | 308 | defsize = cfg.readNumEntry("FontSize",10); |
309 | defb = cfg.readBoolEntry("Bold",FALSE); | 309 | defb = cfg.readBoolEntry("Bold",FALSE); |
310 | defi = cfg.readBoolEntry("Italic",FALSE); | 310 | defi = cfg.readBoolEntry("Italic",FALSE); |
311 | wrap = cfg.readBoolEntry("Wrap",TRUE); | 311 | wrap = cfg.readBoolEntry("Wrap",TRUE); |
312 | 312 | ||
313 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 313 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
314 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 314 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
315 | zin->addTo( font ); | 315 | zin->addTo( font ); |
316 | 316 | ||
317 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 317 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
318 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 318 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
319 | zout->addTo( font ); | 319 | zout->addTo( font ); |
320 | 320 | ||
321 | font->insertSeparator(); | 321 | font->insertSeparator(); |
322 | 322 | ||
323 | #if 0 | 323 | #if 0 |
324 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); | 324 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); |
325 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); | 325 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); |
326 | ba->setToggleAction(TRUE); | 326 | ba->setToggleAction(TRUE); |
327 | ba->addTo( font ); | 327 | ba->addTo( font ); |
328 | 328 | ||
329 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); | 329 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); |
330 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); | 330 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); |
331 | ia->setToggleAction(TRUE); | 331 | ia->setToggleAction(TRUE); |
332 | ia->addTo( font ); | 332 | ia->addTo( font ); |
333 | 333 | ||
334 | ba->setOn(defb); | 334 | ba->setOn(defb); |
335 | ia->setOn(defi); | 335 | ia->setOn(defi); |
336 | 336 | ||
337 | font->insertSeparator(); | 337 | font->insertSeparator(); |
338 | #endif | 338 | #endif |
339 | 339 | ||
340 | 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 ); |
341 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); | 341 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); |
342 | wa->setToggleAction(TRUE); | 342 | wa->setToggleAction(TRUE); |
343 | wa->addTo( font ); | 343 | wa->addTo( font ); |
344 | 344 | ||
345 | font->insertSeparator(); | 345 | font->insertSeparator(); |
346 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); | 346 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); |
347 | 347 | ||
348 | font->insertSeparator(); | 348 | font->insertSeparator(); |
349 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); | 349 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); |
350 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); | 350 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); |
351 | nStart->setToggleAction(TRUE); | 351 | nStart->setToggleAction(TRUE); |
352 | nStart->addTo( font ); | 352 | nStart->addTo( font ); |
353 | 353 | ||
354 | mb->insertItem( tr( "File" ), file ); | 354 | mb->insertItem( tr( "File" ), file ); |
355 | mb->insertItem( tr( "Edit" ), edit ); | 355 | mb->insertItem( tr( "Edit" ), edit ); |
356 | mb->insertItem( tr( "View" ), font ); | 356 | mb->insertItem( tr( "View" ), font ); |
357 | 357 | ||
358 | searchBar = new QPEToolBar(this); | 358 | searchBar = new QPEToolBar(this); |
359 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 359 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
360 | 360 | ||
361 | searchBar->setHorizontalStretchable( TRUE ); | 361 | searchBar->setHorizontalStretchable( TRUE ); |
362 | 362 | ||
363 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 363 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
364 | searchBar->setStretchableWidget( searchEdit ); | 364 | searchBar->setStretchableWidget( searchEdit ); |
365 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 365 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
366 | this, SLOT( search() ) ); | 366 | this, SLOT( search() ) ); |
367 | 367 | ||
368 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | 368 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); |
369 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 369 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
370 | a->addTo( searchBar ); | 370 | a->addTo( searchBar ); |
371 | a->addTo( edit ); | 371 | a->addTo( edit ); |
372 | 372 | ||
373 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 373 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
374 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 374 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
375 | a->addTo( searchBar ); | 375 | a->addTo( searchBar ); |
376 | 376 | ||
377 | edit->insertSeparator(); | 377 | edit->insertSeparator(); |
378 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 378 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
379 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 379 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
380 | a->addTo( edit ); | 380 | a->addTo( edit ); |
381 | 381 | ||
382 | searchBar->hide(); | 382 | searchBar->hide(); |
383 | 383 | ||
384 | editor = new QpeEditor( this ); | 384 | editor = new QpeEditor( this ); |
385 | setCentralWidget( editor ); | 385 | setCentralWidget( editor ); |
386 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 386 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
387 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); | 387 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); |
388 | 388 | ||
389 | // resize( 200, 300 ); | 389 | // resize( 200, 300 ); |
390 | 390 | ||
391 | // setFontSize(defsize,TRUE); | 391 | // setFontSize(defsize,TRUE); |
392 | FontDatabase fdb; | 392 | FontDatabase fdb; |
393 | QFont defaultFont=editor->font(); | 393 | QFont defaultFont=editor->font(); |
394 | QFontInfo fontInfo(defaultFont); | 394 | QFontInfo fontInfo(defaultFont); |
395 | 395 | ||
396 | cfg.setGroup("Font"); | 396 | cfg.setGroup("Font"); |
397 | QString family = cfg.readEntry("Family", fontInfo.family()); | 397 | QString family = cfg.readEntry("Family", fontInfo.family()); |
398 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 398 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
399 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 399 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
400 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 400 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
401 | 401 | ||
402 | defaultFont = fdb.font(family,style,i_size,charSet); | 402 | defaultFont = fdb.font(family,style,i_size,charSet); |
403 | editor->setFont( defaultFont); | 403 | editor->setFont( defaultFont); |
404 | 404 | ||
405 | wa->setOn(wrap); | 405 | wa->setOn(wrap); |
406 | updateCaption(); | 406 | updateCaption(); |
407 | 407 | ||
408 | cfg.setGroup("View"); | 408 | cfg.setGroup("View"); |
409 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { | 409 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { |
410 | nStart->setOn(TRUE); | 410 | nStart->setOn(TRUE); |
411 | fileNew(); | 411 | fileNew(); |
412 | } else { | 412 | } else { |
413 | fileOpen(); | 413 | fileOpen(); |
414 | } | 414 | } |
415 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 415 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
416 | } | 416 | } |
417 | 417 | ||
418 | void TextEdit::cleanUp() | 418 | void TextEdit::cleanUp() |
419 | { | 419 | { |
420 | // save(); | 420 | // save(); |
421 | Config cfg("TextEdit"); | 421 | Config cfg("TextEdit"); |
422 | cfg.setGroup("View"); | 422 | cfg.setGroup("View"); |
423 | QFont f = editor->font(); | 423 | QFont f = editor->font(); |
424 | cfg.writeEntry("FontSize",f.pointSize()); | 424 | cfg.writeEntry("FontSize",f.pointSize()); |
425 | cfg.writeEntry("Bold",f.bold()); | 425 | cfg.writeEntry("Bold",f.bold()); |
426 | cfg.writeEntry("Italic",f.italic()); | 426 | cfg.writeEntry("Italic",f.italic()); |
427 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); | 427 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); |
428 | cfg.writeEntry( "FileView", viewSelection ); | 428 | cfg.writeEntry( "FileView", viewSelection ); |
429 | 429 | ||
430 | } | 430 | } |
431 | 431 | ||
432 | TextEdit::~TextEdit() | 432 | TextEdit::~TextEdit() |
433 | { | 433 | { |
434 | } | 434 | } |
435 | 435 | ||
436 | void TextEdit::zoomIn() | 436 | void TextEdit::zoomIn() |
437 | { | 437 | { |
438 | setFontSize(editor->font().pointSize()+1,FALSE); | 438 | setFontSize(editor->font().pointSize()+1,FALSE); |
439 | } | 439 | } |
440 | 440 | ||
441 | void TextEdit::zoomOut() | 441 | void TextEdit::zoomOut() |
442 | { | 442 | { |
443 | setFontSize(editor->font().pointSize()-1,TRUE); | 443 | setFontSize(editor->font().pointSize()-1,TRUE); |
444 | } | 444 | } |
445 | 445 | ||
446 | 446 | ||
447 | void TextEdit::setFontSize(int sz, bool round_down_not_up) | 447 | void TextEdit::setFontSize(int sz, bool round_down_not_up) |
448 | { | 448 | { |
449 | int s=10; | 449 | int s=10; |
450 | for (int i=0; i<nfontsizes; i++) { | 450 | for (int i=0; i<nfontsizes; i++) { |
451 | if ( fontsize[i] == sz ) { | 451 | if ( fontsize[i] == sz ) { |
452 | s = sz; | 452 | s = sz; |
453 | break; | 453 | break; |
454 | } else if ( round_down_not_up ) { | 454 | } else if ( round_down_not_up ) { |
455 | if ( fontsize[i] < sz ) | 455 | if ( fontsize[i] < sz ) |
456 | s = fontsize[i]; | 456 | s = fontsize[i]; |
457 | } else { | 457 | } else { |
458 | if ( fontsize[i] > sz ) { | 458 | if ( fontsize[i] > sz ) { |
459 | s = fontsize[i]; | 459 | s = fontsize[i]; |
460 | break; | 460 | break; |
461 | } | 461 | } |
462 | } | 462 | } |
463 | } | 463 | } |
464 | 464 | ||
465 | QFont f = editor->font(); | 465 | QFont f = editor->font(); |
466 | f.setPointSize(s); | 466 | f.setPointSize(s); |
467 | editor->setFont(f); | 467 | editor->setFont(f); |
468 | 468 | ||
469 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 469 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
470 | zout->setEnabled(s != fontsize[0]); | 470 | zout->setEnabled(s != fontsize[0]); |
471 | } | 471 | } |
472 | 472 | ||
473 | void TextEdit::setBold(bool y) | 473 | void TextEdit::setBold(bool y) |
474 | { | 474 | { |
475 | QFont f = editor->font(); | 475 | QFont f = editor->font(); |
476 | f.setBold(y); | 476 | f.setBold(y); |
477 | editor->setFont(f); | 477 | editor->setFont(f); |
478 | } | 478 | } |
479 | 479 | ||
480 | void TextEdit::setItalic(bool y) | 480 | void TextEdit::setItalic(bool y) |
481 | { | 481 | { |
482 | QFont f = editor->font(); | 482 | QFont f = editor->font(); |
483 | f.setItalic(y); | 483 | f.setItalic(y); |
484 | editor->setFont(f); | 484 | editor->setFont(f); |
485 | } | 485 | } |
486 | 486 | ||
487 | void TextEdit::setWordWrap(bool y) | 487 | void TextEdit::setWordWrap(bool y) |
488 | { | 488 | { |
489 | bool state = editor->edited(); | 489 | bool state = editor->edited(); |
490 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 490 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
491 | editor->setEdited( state ); | 491 | editor->setEdited( state ); |
492 | } | 492 | } |
493 | 493 | ||
494 | void TextEdit::fileNew() | 494 | void TextEdit::fileNew() |
495 | { | 495 | { |
496 | // if( !bFromDocView ) { | 496 | // if( !bFromDocView ) { |
497 | // saveAs(); | 497 | // saveAs(); |
498 | // } | 498 | // } |
499 | newFile(DocLnk()); | 499 | newFile(DocLnk()); |
500 | } | 500 | } |
501 | 501 | ||
502 | void TextEdit::fileOpen() | 502 | void TextEdit::fileOpen() |
503 | { | 503 | { |
504 | QString str = OFileDialog::getOpenFileName(1,"/","", QStringList() , this ); | 504 | Config cfg("TextEdit"); |
505 | if(!str.isEmpty() ) | 505 | cfg.setGroup("View"); |
506 | openFile( str ); | 506 | bool b=FALSE; |
507 | // browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); // | 507 | if(cfg.readEntry("useOldFileDialog") == "TRUE") |
508 | // browseForFiles->setFileView( viewSelection ); | 508 | b=TRUE; |
509 | // browseForFiles->showMaximized(); | 509 | if(!b) { |
510 | // // if( result != -1 ) | 510 | QString str = OFileDialog::getOpenFileName( 1,"/","", "text/plain", this ); |
511 | 511 | if(!str.isEmpty() ) | |
512 | // if( browseForFiles->exec() != -1 ) { | 512 | openFile( str ); |
513 | // QString selFile = browseForFiles->selectedFileName; | 513 | } else { |
514 | // QStringList fileList = browseForFiles->fileList; | 514 | QString str; |
515 | // qDebug(selFile); | 515 | browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); // |
516 | // QStringList::ConstIterator f; | 516 | browseForFiles->setFileView( viewSelection ); |
517 | // QString fileTemp; | 517 | browseForFiles->showMaximized(); |
518 | // for ( f = fileList.begin(); f != fileList.end(); f++ ) { | 518 | // if( result != -1 ) |
519 | // fileTemp = *f; | 519 | |
520 | // fileTemp.right( fileTemp.length()-5); | 520 | if( browseForFiles->exec() != -1 ) { |
521 | // QString fileName = fileTemp; | 521 | QString selFile = browseForFiles->selectedFileName; |
522 | // if( fileName != "Unnamed" || fileName != "Empty Text" ) { | 522 | QStringList fileList = browseForFiles->fileList; |
523 | // currentFileName = fileName; | 523 | qDebug(selFile); |
524 | // qDebug("please open "+currentFileName); | 524 | QStringList::ConstIterator f; |
525 | // openFile(str ); | 525 | QString fileTemp; |
526 | // } | 526 | for ( f = fileList.begin(); f != fileList.end(); f++ ) { |
527 | // } | 527 | fileTemp = *f; |
528 | // viewSelection = browseForFiles->SelectionCombo->currentItem(); | 528 | fileTemp.right( fileTemp.length()-5); |
529 | // } | 529 | QString fileName = fileTemp; |
530 | // delete browseForFiles; | 530 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { |
531 | // editor->setEdited( FALSE); | 531 | currentFileName = fileName; |
532 | // edited1=FALSE; | 532 | qDebug("please open "+currentFileName); |
533 | // edited=FALSE; | 533 | openFile(str ); |
534 | // if(caption().left(1)=="*") | 534 | } |
535 | // setCaption(caption().right(caption().length()-1)); | 535 | } |
536 | // doSearchBar(); | 536 | viewSelection = browseForFiles->SelectionCombo->currentItem(); |
537 | } | ||
538 | delete browseForFiles; | ||
539 | editor->setEdited( FALSE); | ||
540 | edited1=FALSE; | ||
541 | edited=FALSE; | ||
542 | if(caption().left(1)=="*") | ||
543 | setCaption(caption().right(caption().length()-1)); | ||
544 | doSearchBar(); | ||
545 | } | ||
537 | } | 546 | } |
538 | 547 | ||
539 | void TextEdit::doSearchBar() | 548 | void TextEdit::doSearchBar() |
540 | { | 549 | { |
541 | Config cfg("TextEdit"); | 550 | Config cfg("TextEdit"); |
542 | cfg.setGroup("View"); | 551 | cfg.setGroup("View"); |
543 | if(cfg.readEntry("SearchBar","Closed") != "Opened") | 552 | if(cfg.readEntry("SearchBar","Closed") != "Opened") |
544 | searchBar->hide(); | 553 | searchBar->hide(); |
545 | } | 554 | } |
546 | 555 | ||
547 | #if 0 | 556 | #if 0 |
548 | void TextEdit::slotFind() | 557 | void TextEdit::slotFind() |
549 | { | 558 | { |
550 | FindDialog frmFind( tr("Text Editor"), this ); | 559 | FindDialog frmFind( tr("Text Editor"), this ); |
551 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 560 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
552 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 561 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
553 | 562 | ||
554 | //case sensitive, backwards, [category] | 563 | //case sensitive, backwards, [category] |
555 | 564 | ||
556 | connect( editor, SIGNAL(notFound()), | 565 | connect( editor, SIGNAL(notFound()), |
557 | &frmFind, SLOT(slotNotFound()) ); | 566 | &frmFind, SLOT(slotNotFound()) ); |
558 | connect( editor, SIGNAL(searchWrapped()), | 567 | connect( editor, SIGNAL(searchWrapped()), |
559 | &frmFind, SLOT(slotWrapAround()) ); | 568 | &frmFind, SLOT(slotWrapAround()) ); |
560 | 569 | ||
561 | frmFind.exec(); | 570 | frmFind.exec(); |
562 | 571 | ||
563 | 572 | ||
564 | } | 573 | } |
565 | #endif | 574 | #endif |
566 | 575 | ||
567 | void TextEdit::fileRevert() | 576 | void TextEdit::fileRevert() |
568 | { | 577 | { |
569 | clear(); | 578 | clear(); |
570 | fileOpen(); | 579 | fileOpen(); |
571 | } | 580 | } |
572 | 581 | ||
573 | void TextEdit::editCut() | 582 | void TextEdit::editCut() |
574 | { | 583 | { |
575 | #ifndef QT_NO_CLIPBOARD | 584 | #ifndef QT_NO_CLIPBOARD |
576 | editor->cut(); | 585 | editor->cut(); |
577 | #endif | 586 | #endif |
578 | } | 587 | } |
579 | 588 | ||
580 | void TextEdit::editCopy() | 589 | void TextEdit::editCopy() |
581 | { | 590 | { |
582 | #ifndef QT_NO_CLIPBOARD | 591 | #ifndef QT_NO_CLIPBOARD |
583 | editor->copy(); | 592 | editor->copy(); |
584 | #endif | 593 | #endif |
585 | } | 594 | } |
586 | 595 | ||
587 | void TextEdit::editPaste() | 596 | void TextEdit::editPaste() |
588 | { | 597 | { |
589 | #ifndef QT_NO_CLIPBOARD | 598 | #ifndef QT_NO_CLIPBOARD |
590 | editor->paste(); | 599 | editor->paste(); |
591 | #endif | 600 | #endif |
592 | } | 601 | } |
593 | 602 | ||
594 | void TextEdit::editFind() | 603 | void TextEdit::editFind() |
595 | { | 604 | { |
596 | searchBar->show(); | 605 | searchBar->show(); |
597 | searchVisible = TRUE; | 606 | searchVisible = TRUE; |
598 | searchEdit->setFocus(); | 607 | searchEdit->setFocus(); |
599 | Config cfg("TextEdit"); | 608 | Config cfg("TextEdit"); |
600 | cfg.setGroup("View"); | 609 | cfg.setGroup("View"); |
601 | cfg.writeEntry("SearchBar","Opened"); | 610 | cfg.writeEntry("SearchBar","Opened"); |
602 | 611 | ||
603 | } | 612 | } |
604 | 613 | ||
605 | void TextEdit::findNext() | 614 | void TextEdit::findNext() |
606 | { | 615 | { |
607 | editor->find( searchEdit->text(), FALSE, FALSE ); | 616 | editor->find( searchEdit->text(), FALSE, FALSE ); |
608 | 617 | ||
609 | } | 618 | } |
610 | 619 | ||
611 | void TextEdit::findClose() | 620 | void TextEdit::findClose() |
612 | { | 621 | { |
613 | searchVisible = FALSE; | 622 | searchVisible = FALSE; |
614 | searchBar->hide(); | 623 | searchBar->hide(); |
615 | Config cfg("TextEdit"); | 624 | Config cfg("TextEdit"); |
616 | cfg.setGroup("View"); | 625 | cfg.setGroup("View"); |
617 | cfg.writeEntry("SearchBar","Closed"); | 626 | cfg.writeEntry("SearchBar","Closed"); |
618 | cfg.write(); | 627 | cfg.write(); |
619 | } | 628 | } |
620 | 629 | ||
621 | void TextEdit::search() | 630 | void TextEdit::search() |
622 | { | 631 | { |
623 | editor->find( searchEdit->text(), FALSE, FALSE ); | 632 | editor->find( searchEdit->text(), FALSE, FALSE ); |
624 | } | 633 | } |
625 | 634 | ||
626 | void TextEdit::newFile( const DocLnk &f ) | 635 | void TextEdit::newFile( const DocLnk &f ) |
627 | { | 636 | { |
628 | DocLnk nf = f; | 637 | DocLnk nf = f; |
629 | nf.setType("text/plain"); | 638 | nf.setType("text/plain"); |
630 | clear(); | 639 | clear(); |
631 | setWState (WState_Reserved1 ); | 640 | setWState (WState_Reserved1 ); |
632 | editor->setFocus(); | 641 | editor->setFocus(); |
633 | doc = new DocLnk(nf); | 642 | doc = new DocLnk(nf); |
634 | currentFileName = "Unnamed"; | 643 | currentFileName = "Unnamed"; |
635 | qDebug("newFile "+currentFileName); | 644 | qDebug("newFile "+currentFileName); |
636 | updateCaption( currentFileName); | 645 | updateCaption( currentFileName); |
637 | // editor->setEdited( FALSE); | 646 | // editor->setEdited( FALSE); |
638 | } | 647 | } |
639 | 648 | ||
640 | void TextEdit::openFile( const QString &f ) | 649 | void TextEdit::openFile( const QString &f ) |
641 | { | 650 | { |
642 | qDebug("filename is "+ f); | 651 | qDebug("filename is "+ f); |
643 | QString filer; | 652 | QString filer; |
644 | // bFromDocView = TRUE; | 653 | // bFromDocView = TRUE; |
645 | if(f.find(".desktop",0,TRUE) != -1) { | 654 | if(f.find(".desktop",0,TRUE) != -1) { |
646 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 655 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
647 | tr("Text Editor has detected\n you selected a .desktop file.\nOpen .desktop file or linked file?"), | 656 | tr("Text Editor has detected\n you selected a .desktop file.\nOpen .desktop file or linked file?"), |
648 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) { | 657 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) { |
649 | case 0: | 658 | case 0: |
650 | filer = f; | 659 | filer = f; |
651 | break; | 660 | break; |
652 | case 1: | 661 | case 1: |
653 | DocLnk sf(f); | 662 | DocLnk sf(f); |
654 | filer = sf.file(); | 663 | filer = sf.file(); |
655 | break; | 664 | break; |
656 | } | 665 | } |
657 | } else | 666 | } else |
658 | filer = f; | 667 | filer = f; |
659 | 668 | ||
660 | DocLnk nf; | 669 | DocLnk nf; |
661 | nf.setType("text/plain"); | 670 | nf.setType("text/plain"); |
662 | nf.setFile(filer); | 671 | nf.setFile(filer); |
663 | currentFileName=filer; | 672 | currentFileName=filer; |
664 | QFileInfo fi( currentFileName); | 673 | QFileInfo fi( currentFileName); |
665 | nf.setName(fi.baseName()); | 674 | nf.setName(fi.baseName()); |
666 | qDebug("openFile string "+currentFileName); | 675 | qDebug("openFile string "+currentFileName); |
667 | 676 | ||
668 | openFile(nf); | 677 | openFile(nf); |
669 | showEditTools(); | 678 | showEditTools(); |
670 | // Show filename in caption | 679 | // Show filename in caption |
671 | QString name = filer; | 680 | QString name = filer; |
672 | int sep = name.findRev( '/' ); | 681 | int sep = name.findRev( '/' ); |
673 | if ( sep > 0 ) | 682 | if ( sep > 0 ) |
674 | name = name.mid( sep+1 ); | 683 | name = name.mid( sep+1 ); |
675 | updateCaption( name ); | 684 | updateCaption( name ); |
676 | } | 685 | } |
677 | 686 | ||
678 | void TextEdit::openFile( const DocLnk &f ) | 687 | void TextEdit::openFile( const DocLnk &f ) |
679 | { | 688 | { |
680 | // clear(); | 689 | // clear(); |
681 | // bFromDocView = TRUE; | 690 | // bFromDocView = TRUE; |
682 | FileManager fm; | 691 | FileManager fm; |
683 | QString txt; | 692 | QString txt; |
684 | currentFileName=f.file(); | 693 | currentFileName=f.file(); |
685 | qDebug("openFile doclnk " + currentFileName); | 694 | qDebug("openFile doclnk " + currentFileName); |
686 | if ( !fm.loadFile( f, txt ) ) { | 695 | if ( !fm.loadFile( f, txt ) ) { |
687 | // ####### could be a new file | 696 | // ####### could be a new file |
688 | qDebug( "Cannot open file" ); | 697 | qDebug( "Cannot open file" ); |
689 | } | 698 | } |
690 | // fileNew(); | 699 | // fileNew(); |
691 | if ( doc ) | 700 | if ( doc ) |
692 | delete doc; | 701 | delete doc; |
693 | doc = new DocLnk(f); | 702 | doc = new DocLnk(f); |
694 | editor->setText(txt); | 703 | editor->setText(txt); |
695 | editor->setEdited( FALSE); | 704 | editor->setEdited( FALSE); |
696 | edited1=FALSE; | 705 | edited1=FALSE; |
697 | edited=FALSE; | 706 | edited=FALSE; |
698 | 707 | ||
699 | doc->setName(currentFileName); | 708 | doc->setName(currentFileName); |
700 | updateCaption(); | 709 | updateCaption(); |
701 | } | 710 | } |
702 | 711 | ||
703 | void TextEdit::showEditTools() | 712 | void TextEdit::showEditTools() |
704 | { | 713 | { |
705 | // if ( !doc ) | 714 | // if ( !doc ) |
706 | // close(); | 715 | // close(); |
707 | // clear(); | 716 | // clear(); |
708 | menu->show(); | 717 | menu->show(); |
709 | editBar->show(); | 718 | editBar->show(); |
710 | if ( searchVisible ) | 719 | if ( searchVisible ) |
711 | searchBar->show(); | 720 | searchBar->show(); |
712 | // updateCaption(); | 721 | // updateCaption(); |
713 | setWState (WState_Reserved1 ); | 722 | setWState (WState_Reserved1 ); |
714 | } | 723 | } |
715 | 724 | ||
716 | /*! | 725 | /*! |
717 | unprompted save */ | 726 | unprompted save */ |
718 | bool TextEdit::save() | 727 | bool TextEdit::save() |
719 | { | 728 | { |
720 | QString file = doc->file(); | 729 | QString file = doc->file(); |
721 | qDebug("saver file "+file); | 730 | qDebug("saver file "+file); |
722 | QString name= doc->name(); | 731 | QString name= doc->name(); |
723 | qDebug("File named "+name); | 732 | qDebug("File named "+name); |
724 | QString rt = editor->text(); | 733 | QString rt = editor->text(); |
725 | if( !rt.isEmpty() ) { | 734 | if( !rt.isEmpty() ) { |
726 | if(name.isEmpty()) { | 735 | if(name.isEmpty()) { |
727 | saveAs(); | 736 | saveAs(); |
728 | } else { | 737 | } else { |
729 | currentFileName= name ; | 738 | currentFileName= name ; |
730 | qDebug("saveFile "+currentFileName); | 739 | qDebug("saveFile "+currentFileName); |
731 | 740 | ||
732 | struct stat buf; | 741 | struct stat buf; |
733 | mode_t mode; | 742 | mode_t mode; |
734 | stat(file.latin1(), &buf); | 743 | stat(file.latin1(), &buf); |
735 | mode = buf.st_mode; | 744 | mode = buf.st_mode; |
736 | 745 | ||
737 | doc->setName( name); | 746 | doc->setName( name); |
738 | FileManager fm; | 747 | FileManager fm; |
739 | if ( !fm.saveFile( *doc, rt ) ) { | 748 | if ( !fm.saveFile( *doc, rt ) ) { |
740 | return false; | 749 | return false; |
741 | } | 750 | } |
742 | editor->setEdited( FALSE); | 751 | editor->setEdited( FALSE); |
743 | edited1=FALSE; | 752 | edited1=FALSE; |
744 | edited=FALSE; | 753 | edited=FALSE; |
745 | if(caption().left(1)=="*") | 754 | if(caption().left(1)=="*") |
746 | setCaption(caption().right(caption().length()-1)); | 755 | setCaption(caption().right(caption().length()-1)); |
747 | 756 | ||
748 | 757 | ||
749 | chmod( file.latin1(), mode); | 758 | chmod( file.latin1(), mode); |
750 | } | 759 | } |
751 | return true; | 760 | return true; |
752 | } | 761 | } |
753 | return false; | 762 | return false; |
754 | } | 763 | } |
755 | 764 | ||
756 | /*! | 765 | /*! |
757 | prompted save */ | 766 | prompted save */ |
758 | bool TextEdit::saveAs() | 767 | bool TextEdit::saveAs() |
759 | { | 768 | { |
760 | // qDebug("saveAsFile "+currentFileName); | 769 | // qDebug("saveAsFile "+currentFileName); |
761 | // case of nothing to save... | 770 | // case of nothing to save... |
762 | if ( !doc )//|| !bFromDocView) | 771 | if ( !doc )//|| !bFromDocView) |
763 | { | 772 | { |
764 | qDebug("no doc"); | 773 | qDebug("no doc"); |
765 | return true; | 774 | return true; |
766 | } | 775 | } |
767 | if ( !editor->edited() ) { | 776 | if ( !editor->edited() ) { |
768 | delete doc; | 777 | delete doc; |
769 | doc = 0; | 778 | doc = 0; |
770 | return true; | 779 | return true; |
771 | } | 780 | } |
772 | 781 | ||
773 | QString rt = editor->text(); | 782 | QString rt = editor->text(); |
774 | qDebug(currentFileName); | 783 | qDebug(currentFileName); |
775 | 784 | ||
776 | if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) { | 785 | if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) { |
777 | qDebug("do silly TT filename thing"); | 786 | qDebug("do silly TT filename thing"); |
778 | if ( doc->name().isEmpty() ) { | 787 | if ( doc->name().isEmpty() ) { |
779 | QString pt = rt.simplifyWhiteSpace(); | 788 | QString pt = rt.simplifyWhiteSpace(); |
780 | int i = pt.find( ' ' ); | 789 | int i = pt.find( ' ' ); |
781 | QString docname = pt; | 790 | QString docname = pt; |
782 | if ( i > 0 ) | 791 | if ( i > 0 ) |
783 | docname = pt.left( i ); | 792 | docname = pt.left( i ); |
784 | // remove "." at the beginning | 793 | // remove "." at the beginning |
785 | while( docname.startsWith( "." ) ) | 794 | while( docname.startsWith( "." ) ) |
786 | docname = docname.mid( 1 ); | 795 | docname = docname.mid( 1 ); |
787 | docname.replace( QRegExp("/"), "_" ); | 796 | docname.replace( QRegExp("/"), "_" ); |
788 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. | 797 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. |
789 | if ( docname.length() > 40 ) | 798 | if ( docname.length() > 40 ) |
790 | docname = docname.left(40); | 799 | docname = docname.left(40); |
791 | if ( docname.isEmpty() ) | 800 | if ( docname.isEmpty() ) |
792 | docname = tr("Unnamed"); | 801 | docname = tr("Unnamed"); |
793 | doc->setName(docname); | 802 | doc->setName(docname); |
794 | currentFileName=docname; | 803 | currentFileName=docname; |
795 | } | 804 | } |
796 | } | 805 | } |
797 | 806 | ||
798 | 807 | ||
799 | fileSaveDlg=new fileSaver(this,tr("Save File As?"),TRUE, 0, currentFileName); | 808 | fileSaveDlg=new fileSaver(this,tr("Save File As?"),TRUE, 0, currentFileName); |
800 | qDebug("wanna save filename "+currentFileName); | 809 | qDebug("wanna save filename "+currentFileName); |
801 | fileSaveDlg->exec(); | 810 | fileSaveDlg->exec(); |
802 | if( fileSaveDlg->result() == 1 ) { | 811 | if( fileSaveDlg->result() == 1 ) { |
803 | QString fileNm=fileSaveDlg->selectedFileName; | 812 | QString fileNm=fileSaveDlg->selectedFileName; |
804 | qDebug("saving filename "+fileNm); | 813 | qDebug("saving filename "+fileNm); |
805 | QFileInfo fi(fileNm); | 814 | QFileInfo fi(fileNm); |
806 | currentFileName=fi.fileName(); | 815 | currentFileName=fi.fileName(); |
807 | if(doc) { | 816 | if(doc) { |
808 | // QString file = doc->file(); | 817 | // QString file = doc->file(); |
809 | // doc->removeFiles(); | 818 | // doc->removeFiles(); |
810 | delete doc; | 819 | delete doc; |
811 | DocLnk nf; | 820 | DocLnk nf; |
812 | nf.setType("text/plain"); | 821 | nf.setType("text/plain"); |
813 | nf.setFile( fileNm); | 822 | nf.setFile( fileNm); |
814 | doc = new DocLnk(nf); | 823 | doc = new DocLnk(nf); |
815 | // editor->setText(rt); | 824 | // editor->setText(rt); |
816 | // qDebug("openFile doclnk "+currentFileName); | 825 | // qDebug("openFile doclnk "+currentFileName); |
817 | doc->setName( currentFileName); | 826 | doc->setName( currentFileName); |
818 | updateCaption( currentFileName); | 827 | updateCaption( currentFileName); |
819 | 828 | ||
820 | FileManager fm; | 829 | FileManager fm; |
821 | if ( !fm.saveFile( *doc, rt ) ) { | 830 | if ( !fm.saveFile( *doc, rt ) ) { |
822 | return false; | 831 | return false; |
823 | } | 832 | } |
824 | if( fileSaveDlg->filePermCheck->isChecked() ) { | 833 | if( fileSaveDlg->filePermCheck->isChecked() ) { |
825 | filePermissions *filePerm; | 834 | filePermissions *filePerm; |
826 | filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm); | 835 | filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm); |
827 | filePerm->exec(); | 836 | filePerm->exec(); |
828 | 837 | ||
829 | if( filePerm) | 838 | if( filePerm) |
830 | delete filePerm; | 839 | delete filePerm; |
831 | } | 840 | } |
832 | } | 841 | } |
833 | } | 842 | } |
834 | editor->setEdited(TRUE); | 843 | editor->setEdited(TRUE); |
835 | edited1=FALSE; | 844 | edited1=FALSE; |
836 | edited=TRUE; | 845 | edited=TRUE; |
837 | if(caption().left(1)=="*") | 846 | if(caption().left(1)=="*") |
838 | setCaption(caption().right(caption().length()-1)); | 847 | setCaption(caption().right(caption().length()-1)); |
839 | 848 | ||
840 | if(fileSaveDlg) | 849 | if(fileSaveDlg) |
841 | delete fileSaveDlg; | 850 | delete fileSaveDlg; |
842 | return true; | 851 | return true; |
843 | } //end saveAs | 852 | } //end saveAs |
844 | 853 | ||
845 | void TextEdit::clear() | 854 | void TextEdit::clear() |
846 | { | 855 | { |
847 | delete doc; | 856 | delete doc; |
848 | doc = 0; | 857 | doc = 0; |
849 | editor->clear(); | 858 | editor->clear(); |
850 | } | 859 | } |
851 | 860 | ||
852 | void TextEdit::updateCaption( const QString &name ) | 861 | void TextEdit::updateCaption( const QString &name ) |
853 | { | 862 | { |
854 | if ( !doc ) | 863 | if ( !doc ) |
855 | setCaption( tr("Text Editor") ); | 864 | setCaption( tr("Text Editor") ); |
856 | else { | 865 | else { |
857 | QString s = name; | 866 | QString s = name; |
858 | if ( s.isNull() ) | 867 | if ( s.isNull() ) |
859 | s = doc->name(); | 868 | s = doc->name(); |
860 | if ( s.isEmpty() ) { | 869 | if ( s.isEmpty() ) { |
861 | s = tr( "Unnamed" ); | 870 | s = tr( "Unnamed" ); |
862 | currentFileName=s; | 871 | currentFileName=s; |
863 | } | 872 | } |
864 | if(s.left(1) == "/") | 873 | if(s.left(1) == "/") |
865 | s = s.right(s.length()-1); | 874 | s = s.right(s.length()-1); |
866 | setCaption( s + " - " + tr("Text Editor") ); | 875 | setCaption( s + " - " + tr("Text Editor") ); |
867 | } | 876 | } |
868 | } | 877 | } |
869 | 878 | ||
870 | void TextEdit::setDocument(const QString& fileref) | 879 | void TextEdit::setDocument(const QString& fileref) |
871 | { | 880 | { |
872 | bFromDocView = TRUE; | 881 | bFromDocView = TRUE; |
873 | openFile(fileref); | 882 | openFile(fileref); |
874 | editor->setEdited(TRUE); | 883 | editor->setEdited(TRUE); |
875 | edited1=FALSE; | 884 | edited1=FALSE; |
876 | edited=TRUE; | 885 | edited=TRUE; |
877 | doSearchBar(); | 886 | doSearchBar(); |
878 | } | 887 | } |
879 | 888 | ||
880 | void TextEdit::closeEvent( QCloseEvent *e ) | 889 | void TextEdit::closeEvent( QCloseEvent *e ) |
881 | { | 890 | { |
882 | bFromDocView = FALSE; | 891 | bFromDocView = FALSE; |
883 | e->accept(); | 892 | e->accept(); |
884 | } | 893 | } |
885 | 894 | ||
886 | void TextEdit::accept() | 895 | void TextEdit::accept() |
887 | { | 896 | { |
888 | //if(caption() !="Unnamed") | 897 | //if(caption() !="Unnamed") |
889 | if(edited1) | 898 | if(edited1) |
890 | saveAs(); | 899 | saveAs(); |
891 | exit(0); | 900 | exit(0); |
892 | 901 | ||
893 | } | 902 | } |
894 | 903 | ||
895 | void TextEdit::changeFont() { | 904 | void TextEdit::changeFont() { |
896 | FontDatabase fdb; | 905 | FontDatabase fdb; |
897 | QFont defaultFont=editor->font(); | 906 | QFont defaultFont=editor->font(); |
898 | QFontInfo fontInfo(defaultFont); | 907 | QFontInfo fontInfo(defaultFont); |
899 | Config cfg("TextEdit"); | 908 | Config cfg("TextEdit"); |
900 | cfg.setGroup("Font"); | 909 | cfg.setGroup("Font"); |
901 | QString family = cfg.readEntry("Family", fontInfo.family()); | 910 | QString family = cfg.readEntry("Family", fontInfo.family()); |
902 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 911 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
903 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 912 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
904 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 913 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
905 | 914 | ||
906 | defaultFont = fdb.font(family,style,i_size,charSet); | 915 | defaultFont = fdb.font(family,style,i_size,charSet); |
907 | 916 | ||
908 | FontDialog *fontDlg; | 917 | FontDialog *fontDlg; |
909 | fontDlg=new FontDialog(this,tr("FontDialog"),TRUE); | 918 | fontDlg=new FontDialog(this,tr("FontDialog"),TRUE); |
910 | 919 | ||
911 | fontDlg->exec(); | 920 | fontDlg->exec(); |
912 | 921 | ||
913 | QFont myFont=fontDlg->selectedFont; | 922 | QFont myFont=fontDlg->selectedFont; |
914 | editor->setFont( myFont); | 923 | editor->setFont( myFont); |
915 | delete fontDlg; | 924 | delete fontDlg; |
916 | 925 | ||
917 | } | 926 | } |
918 | 927 | ||
919 | void TextEdit::editDelete() | 928 | void TextEdit::editDelete() |
920 | { | 929 | { |
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h index 61fa2a0..edc6fe3 100644 --- a/core/apps/textedit/textedit.h +++ b/core/apps/textedit/textedit.h | |||
@@ -1,124 +1,124 @@ | |||
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" | 27 | #include "fileBrowser.h" |
28 | #include "fileSaver.h" | 28 | #include "fileSaver.h" |
29 | 29 | ||
30 | #include <qpe/filemanager.h> | 30 | #include <qpe/filemanager.h> |
31 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
32 | 32 | ||
33 | #include <opie/ofileselector.h> | 33 | #include <opie/ofileselector.h> |
34 | 34 | ||
35 | #include <qmainwindow.h> | 35 | #include <qmainwindow.h> |
36 | #include <qmultilineedit.h> | 36 | #include <qmultilineedit.h> |
37 | #include <qlist.h> | 37 | #include <qlist.h> |
38 | #include <qmap.h> | 38 | #include <qmap.h> |
39 | 39 | ||
40 | class QAction; | 40 | class QAction; |
41 | class QWidgetStack; | 41 | class QWidgetStack; |
42 | class QToolButton; | 42 | class QToolButton; |
43 | class QPopupMenu; | 43 | class QPopupMenu; |
44 | class QToolBar; | 44 | class QToolBar; |
45 | class QLineEdit; | 45 | class QLineEdit; |
46 | class QAction; | 46 | class QAction; |
47 | class FileSelector; | 47 | class FileSelector; |
48 | class QpeEditor; | 48 | class QpeEditor; |
49 | class QPopupMenu; | 49 | class QPopupMenu; |
50 | 50 | ||
51 | class TextEdit : public QMainWindow | 51 | class TextEdit : public QMainWindow |
52 | { | 52 | { |
53 | Q_OBJECT | 53 | Q_OBJECT |
54 | 54 | ||
55 | public: | 55 | public: |
56 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 56 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
57 | ~TextEdit(); | 57 | ~TextEdit(); |
58 | 58 | ||
59 | QPopupMenu *font; | 59 | QPopupMenu *font; |
60 | QAction *nStart; | 60 | QAction *nStart, *nFileDlgOpt; |
61 | bool edited, edited1; | 61 | bool edited, edited1; |
62 | void openFile( const QString & ); | 62 | void openFile( const QString & ); |
63 | QCopChannel * channel; | 63 | QCopChannel * channel; |
64 | public slots: | 64 | public slots: |
65 | void editorChanged(); | 65 | void editorChanged(); |
66 | void receive(const QCString&, const QByteArray&); | 66 | void receive(const QCString&, const QByteArray&); |
67 | protected: | 67 | protected: |
68 | void closeEvent( QCloseEvent *e ); | 68 | void closeEvent( QCloseEvent *e ); |
69 | void doSearchBar(); | 69 | void doSearchBar(); |
70 | private slots: | 70 | private slots: |
71 | void setDocument(const QString&); | 71 | void setDocument(const QString&); |
72 | void changeFont(); | 72 | void changeFont(); |
73 | void fileNew(); | 73 | void fileNew(); |
74 | void fileRevert(); | 74 | void fileRevert(); |
75 | void fileOpen(); | 75 | void fileOpen(); |
76 | void changeStartConfig(bool); | 76 | void changeStartConfig(bool); |
77 | bool save(); | 77 | bool save(); |
78 | bool saveAs(); | 78 | bool saveAs(); |
79 | void cleanUp(); | 79 | void cleanUp(); |
80 | 80 | ||
81 | 81 | ||
82 | void editCut(); | 82 | void editCut(); |
83 | void editCopy(); | 83 | void editCopy(); |
84 | void editPaste(); | 84 | void editPaste(); |
85 | void editFind(); | 85 | void editFind(); |
86 | void editDelete(); | 86 | void editDelete(); |
87 | 87 | ||
88 | void findNext(); | 88 | void findNext(); |
89 | void findClose(); | 89 | void findClose(); |
90 | 90 | ||
91 | void search(); | 91 | void search(); |
92 | void accept(); | 92 | void accept(); |
93 | 93 | ||
94 | void newFile( const DocLnk & ); | 94 | void newFile( const DocLnk & ); |
95 | void openFile( const DocLnk & ); | 95 | void openFile( const DocLnk & ); |
96 | void showEditTools(); | 96 | void showEditTools(); |
97 | 97 | ||
98 | void zoomIn(); | 98 | void zoomIn(); |
99 | void zoomOut(); | 99 | void zoomOut(); |
100 | void setBold(bool y); | 100 | void setBold(bool y); |
101 | void setItalic(bool y); | 101 | void setItalic(bool y); |
102 | void setWordWrap(bool y); | 102 | void setWordWrap(bool y); |
103 | 103 | ||
104 | private: | 104 | private: |
105 | void colorChanged( const QColor &c ); | 105 | void colorChanged( const QColor &c ); |
106 | void clear(); | 106 | void clear(); |
107 | void updateCaption( const QString &name=QString::null ); | 107 | void updateCaption( const QString &name=QString::null ); |
108 | void setFontSize(int sz, bool round_down_not_up); | 108 | void setFontSize(int sz, bool round_down_not_up); |
109 | 109 | ||
110 | private: | 110 | private: |
111 | fileSaver *fileSaveDlg; | 111 | fileSaver *fileSaveDlg; |
112 | fileBrowser *browseForFiles; | 112 | fileBrowser *browseForFiles; |
113 | QpeEditor* editor; | 113 | QpeEditor* editor; |
114 | QToolBar *menu, *editBar, *searchBar; | 114 | QToolBar *menu, *editBar, *searchBar; |
115 | QLineEdit *searchEdit; | 115 | QLineEdit *searchEdit; |
116 | DocLnk *doc; | 116 | DocLnk *doc; |
117 | bool searchVisible; | 117 | bool searchVisible; |
118 | bool bFromDocView; | 118 | bool bFromDocView; |
119 | int viewSelection; | 119 | int viewSelection; |
120 | QAction *zin, *zout; | 120 | QAction *zin, *zout; |
121 | QString currentFileName; | 121 | QString currentFileName; |
122 | }; | 122 | }; |
123 | 123 | ||
124 | #endif | 124 | #endif |