author | llornkcor <llornkcor> | 2002-05-21 15:03:56 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-05-21 15:03:56 (UTC) |
commit | 0ba2d95e89f55b13f2247819b6672362a8b5a484 (patch) (unidiff) | |
tree | 3ee26bbcef62cca6192bd932658ed93708c23678 | |
parent | d65dc25caec62d4c554c99fbc151bf4d07c63b72 (diff) | |
download | opie-0ba2d95e89f55b13f2247819b6672362a8b5a484.zip opie-0ba2d95e89f55b13f2247819b6672362a8b5a484.tar.gz opie-0ba2d95e89f55b13f2247819b6672362a8b5a484.tar.bz2 |
maybe fixed bug
-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 24 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 4 |
2 files changed, 14 insertions, 14 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp index fced326..9ad0d69 100644 --- a/core/apps/textedit/fileBrowser.cpp +++ b/core/apps/textedit/fileBrowser.cpp | |||
@@ -1,268 +1,268 @@ | |||
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 | 53 | ||
54 | // getMimeTypes(); | 54 | // getMimeTypes(); |
55 | 55 | ||
56 | mimeType = mimeFilter; | 56 | // mimeType = mimeFilter; |
57 | MimeType mt( mimeType); | 57 | // MimeType mt( mimeType); |
58 | 58 | ||
59 | if( mt.extension().isEmpty()) { | 59 | // if( mt.extension().isEmpty()) { |
60 | 60 | ||
61 | QStringList filterList; | 61 | // QStringList filterList; |
62 | filterList=QStringList::split(";",mimeFilter,FALSE); | 62 | // filterList=QStringList::split(";",mimeFilter,FALSE); |
63 | 63 | ||
64 | for ( QStringList::Iterator it = filterList.begin(); it != filterList.end(); ++it ) { | 64 | // for ( QStringList::Iterator it = filterList.begin(); it != filterList.end(); ++it ) { |
65 | printf( "%s \n", (*it).latin1() ); | 65 | // printf( "%s \n", (*it).latin1() ); |
66 | } | 66 | // } |
67 | 67 | ||
68 | filterStr = mimeFilter.right(mimeFilter.length() - mimeFilter.find("/",0,TRUE) - 1);// "*"; | 68 | // filterStr = mimeFilter.right(mimeFilter.length() - mimeFilter.find("/",0,TRUE) - 1);// "*"; |
69 | 69 | ||
70 | qDebug(filterStr); | 70 | // qDebug(filterStr); |
71 | } else { | 71 | // } else { |
72 | filterStr = "*."+ mt.extension(); | 72 | filterStr = "*."+ mt.extension(); |
73 | // qDebug("description "+mt.description()); | 73 | // qDebug("description "+mt.description()); |
74 | // qDebug( "id "+mt.id()); | 74 | // qDebug( "id "+mt.id()); |
75 | // qDebug("extension "+mt.extension()); | 75 | // qDebug("extension "+mt.extension()); |
76 | } | 76 | // } |
77 | // channel = new QCopChannel( "QPE/fileDialog", this ); | 77 | // channel = new QCopChannel( "QPE/fileDialog", this ); |
78 | // connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 78 | // connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
79 | // this, SLOT(receive(const QCString&, const QByteArray&)) ); | 79 | // this, SLOT(receive(const QCString&, const QByteArray&)) ); |
80 | 80 | ||
81 | QGridLayout *layout = new QGridLayout( this ); | 81 | QGridLayout *layout = new QGridLayout( this ); |
82 | layout->setSpacing( 4 ); | 82 | layout->setSpacing( 4 ); |
83 | layout->setMargin( 4 ); | 83 | layout->setMargin( 4 ); |
84 | 84 | ||
85 | dirPathCombo = new QComboBox( FALSE, this, "dirPathCombo" ); | 85 | dirPathCombo = new QComboBox( FALSE, this, "dirPathCombo" ); |
86 | dirPathCombo->setEditable(TRUE); | 86 | dirPathCombo->setEditable(TRUE); |
87 | 87 | ||
88 | connect( dirPathCombo, SIGNAL( activated( const QString & ) ), | 88 | connect( dirPathCombo, SIGNAL( activated( const QString & ) ), |
89 | this, SLOT( dirPathComboActivated( const QString & ) ) ); | 89 | this, SLOT( dirPathComboActivated( const QString & ) ) ); |
90 | 90 | ||
91 | connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ), | 91 | connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ), |
92 | this, SLOT( dirPathEditPressed( ) ) ); | 92 | this, SLOT( dirPathEditPressed( ) ) ); |
93 | 93 | ||
94 | dirPathStringList << "/"; | 94 | dirPathStringList << "/"; |
95 | // we can get the storage here | 95 | // we can get the storage here |
96 | 96 | ||
97 | layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 ); | 97 | layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 ); |
98 | 98 | ||
99 | cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); | 99 | cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); |
100 | cdUpButton ->setMinimumSize( QSize( 20, 20 ) ); | 100 | cdUpButton ->setMinimumSize( QSize( 20, 20 ) ); |
101 | cdUpButton ->setMaximumSize( QSize( 20, 20 ) ); | 101 | cdUpButton ->setMaximumSize( QSize( 20, 20 ) ); |
102 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); | 102 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); |
103 | cdUpButton ->setFlat(TRUE); | 103 | cdUpButton ->setFlat(TRUE); |
104 | layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 ); | 104 | layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 ); |
105 | 105 | ||
106 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); | 106 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); |
107 | docButton->setMinimumSize( QSize( 20, 20 ) ); | 107 | docButton->setMinimumSize( QSize( 20, 20 ) ); |
108 | docButton->setMaximumSize( QSize( 20, 20 ) ); | 108 | docButton->setMaximumSize( QSize( 20, 20 ) ); |
109 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 109 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
110 | docButton->setFlat(TRUE); | 110 | docButton->setFlat(TRUE); |
111 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); | 111 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); |
112 | 112 | ||
113 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); | 113 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); |
114 | homeButton->setMinimumSize( QSize( 20, 20 ) ); | 114 | homeButton->setMinimumSize( QSize( 20, 20 ) ); |
115 | homeButton->setMaximumSize( QSize( 20, 20 ) ); | 115 | homeButton->setMaximumSize( QSize( 20, 20 ) ); |
116 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 116 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
117 | homeButton->setFlat(TRUE); | 117 | homeButton->setFlat(TRUE); |
118 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 ); | 118 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 ); |
119 | 119 | ||
120 | FileStack = new QWidgetStack( this ); | 120 | FileStack = new QWidgetStack( this ); |
121 | 121 | ||
122 | ListView = new QListView( this, "ListView" ); | 122 | ListView = new QListView( this, "ListView" ); |
123 | // ListView->setMinimumSize( QSize( 100, 25 ) ); | 123 | // ListView->setMinimumSize( QSize( 100, 25 ) ); |
124 | ListView->addColumn( tr( "Name" ) ); | 124 | ListView->addColumn( tr( "Name" ) ); |
125 | ListView->setColumnWidth(0,120); | 125 | ListView->setColumnWidth(0,120); |
126 | ListView->setSorting( 2, FALSE); | 126 | ListView->setSorting( 2, FALSE); |
127 | ListView->addColumn( tr( "Size" ) ); | 127 | ListView->addColumn( tr( "Size" ) ); |
128 | ListView->setColumnWidth(1,-1); | 128 | ListView->setColumnWidth(1,-1); |
129 | ListView->addColumn( "Date",-1); | 129 | ListView->addColumn( "Date",-1); |
130 | 130 | ||
131 | ListView->setColumnWidthMode(0,QListView::Manual); | 131 | ListView->setColumnWidthMode(0,QListView::Manual); |
132 | ListView->setColumnAlignment(1,QListView::AlignRight); | 132 | ListView->setColumnAlignment(1,QListView::AlignRight); |
133 | ListView->setColumnAlignment(2,QListView::AlignRight); | 133 | ListView->setColumnAlignment(2,QListView::AlignRight); |
134 | ListView->setAllColumnsShowFocus( TRUE ); | 134 | ListView->setAllColumnsShowFocus( TRUE ); |
135 | 135 | ||
136 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); | 136 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); |
137 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 137 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
138 | this, SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 138 | this, SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
139 | 139 | ||
140 | connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 140 | connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
141 | 141 | ||
142 | FileStack->addWidget( ListView, get_unique_id() ); | 142 | FileStack->addWidget( ListView, get_unique_id() ); |
143 | mimeType="text/plain"; | 143 | mimeType="text/plain"; |
144 | fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy | 144 | fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy |
145 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); | 145 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); |
146 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 146 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
147 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), | 147 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), |
148 | this, SLOT( docOpen( const DocLnk & ) ) ); | 148 | this, SLOT( docOpen( const DocLnk & ) ) ); |
149 | layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 ); | 149 | layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 ); |
150 | 150 | ||
151 | SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" ); | 151 | SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" ); |
152 | SelectionCombo->insertItem( tr( "Documents" ) ); | 152 | SelectionCombo->insertItem( tr( "Documents" ) ); |
153 | SelectionCombo->insertItem( tr( "All files" ) ); | 153 | SelectionCombo->insertItem( tr( "All files" ) ); |
154 | SelectionCombo->insertItem( tr( "Hidden files" ) ); | 154 | SelectionCombo->insertItem( tr( "Hidden files" ) ); |
155 | // SelectionCombo->setMaximumWidth(120); | 155 | // SelectionCombo->setMaximumWidth(120); |
156 | layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 ); | 156 | layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 ); |
157 | 157 | ||
158 | connect( SelectionCombo, SIGNAL( activated( const QString & ) ), | 158 | connect( SelectionCombo, SIGNAL( activated( const QString & ) ), |
159 | this, SLOT( selectionChanged( const QString & ) ) ); | 159 | this, SLOT( selectionChanged( const QString & ) ) ); |
160 | 160 | ||
161 | typemb = new MenuButton(this); | 161 | typemb = new MenuButton(this); |
162 | typemb->setLabel(tr("Type: %1")); | 162 | typemb->setLabel(tr("Type: %1")); |
163 | typemb->setMinimumWidth(110); | 163 | typemb->setMinimumWidth(110); |
164 | typemb->setFixedHeight(22); | 164 | typemb->setFixedHeight(22); |
165 | layout->addMultiCellWidget( typemb, 2, 2, 4, 7 ); | 165 | layout->addMultiCellWidget( typemb, 2, 2, 4, 7 ); |
166 | updateMimeTypeMenu() ; | 166 | updateMimeTypeMenu() ; |
167 | 167 | ||
168 | currentDir.setPath(QDir::currentDirPath()); | 168 | currentDir.setPath(QDir::currentDirPath()); |
169 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); | 169 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); |
170 | currentDir.setNameFilter(filterStr); | 170 | currentDir.setNameFilter(filterStr); |
171 | 171 | ||
172 | populateList(); | 172 | populateList(); |
173 | move(0,15); | 173 | move(0,15); |
174 | } | 174 | } |
175 | 175 | ||
176 | fileBrowser::~fileBrowser() | 176 | fileBrowser::~fileBrowser() |
177 | { | 177 | { |
178 | } | 178 | } |
179 | 179 | ||
180 | void fileBrowser::setFileView( int selection ) | 180 | void fileBrowser::setFileView( int selection ) |
181 | { | 181 | { |
182 | SelectionCombo->setCurrentItem( selection ); | 182 | SelectionCombo->setCurrentItem( selection ); |
183 | selectionChanged( SelectionCombo->currentText() ); | 183 | selectionChanged( SelectionCombo->currentText() ); |
184 | } | 184 | } |
185 | 185 | ||
186 | void fileBrowser::populateList() | 186 | void fileBrowser::populateList() |
187 | { | 187 | { |
188 | ListView->clear(); | 188 | ListView->clear(); |
189 | QListViewItem * item; | 189 | QListViewItem * item; |
190 | bool isDir=FALSE; | 190 | bool isDir=FALSE; |
191 | //qDebug(currentDir.canonicalPath()); | 191 | //qDebug(currentDir.canonicalPath()); |
192 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 192 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
193 | currentDir.setMatchAllDirs(TRUE); | 193 | currentDir.setMatchAllDirs(TRUE); |
194 | 194 | ||
195 | // currentDir.setNameFilter("*.txt;*.etx"); | 195 | // currentDir.setNameFilter("*.txt;*.etx"); |
196 | QString fileL, fileS, fileDate; | 196 | QString fileL, fileS, fileDate; |
197 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 197 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
198 | QFileInfoListIterator it(*list); | 198 | QFileInfoListIterator it(*list); |
199 | QFileInfo *fi; | 199 | QFileInfo *fi; |
200 | while ( (fi=it.current()) ) { | 200 | while ( (fi=it.current()) ) { |
201 | if (fi->isSymLink() ){ | 201 | if (fi->isSymLink() ){ |
202 | QString symLink=fi->readLink(); | 202 | QString symLink=fi->readLink(); |
203 | // qDebug("Symlink detected "+symLink); | 203 | // qDebug("Symlink detected "+symLink); |
204 | QFileInfo sym( symLink); | 204 | QFileInfo sym( symLink); |
205 | fileS.sprintf( "%10li", sym.size() ); | 205 | fileS.sprintf( "%10li", sym.size() ); |
206 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 206 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
207 | fileDate = sym.lastModified().toString(); | 207 | fileDate = sym.lastModified().toString(); |
208 | } else { | 208 | } else { |
209 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 209 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
210 | fileS.sprintf( "%10li", fi->size() ); | 210 | fileS.sprintf( "%10li", fi->size() ); |
211 | fileL.sprintf( "%s",fi->fileName().data() ); | 211 | fileL.sprintf( "%s",fi->fileName().data() ); |
212 | fileDate= fi->lastModified().toString(); | 212 | fileDate= fi->lastModified().toString(); |
213 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 213 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
214 | fileL+="/"; | 214 | fileL+="/"; |
215 | isDir=TRUE; | 215 | isDir=TRUE; |
216 | // qDebug( fileL); | 216 | // qDebug( fileL); |
217 | } | 217 | } |
218 | } | 218 | } |
219 | if(fileL !="./" && fi->exists()) { | 219 | if(fileL !="./" && fi->exists()) { |
220 | item= new QListViewItem( ListView,fileL,fileS , fileDate); | 220 | item= new QListViewItem( ListView,fileL,fileS , fileDate); |
221 | QPixmap pm; | 221 | QPixmap pm; |
222 | 222 | ||
223 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 223 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
224 | if( !QDir( fi->filePath() ).isReadable()) | 224 | if( !QDir( fi->filePath() ).isReadable()) |
225 | pm = Resource::loadPixmap( "lockedfolder" ); | 225 | pm = Resource::loadPixmap( "lockedfolder" ); |
226 | else | 226 | else |
227 | pm= Resource::loadPixmap( "folder" ); | 227 | pm= Resource::loadPixmap( "folder" ); |
228 | item->setPixmap( 0,pm ); | 228 | item->setPixmap( 0,pm ); |
229 | } else { | 229 | } else { |
230 | if( !fi->isReadable() ) | 230 | if( !fi->isReadable() ) |
231 | pm = Resource::loadPixmap( "locked" ); | 231 | pm = Resource::loadPixmap( "locked" ); |
232 | else { | 232 | else { |
233 | MimeType mt(fi->filePath()); | 233 | MimeType mt(fi->filePath()); |
234 | pm=mt.pixmap();// sets the pixmap for the mimetype | 234 | pm=mt.pixmap();// sets the pixmap for the mimetype |
235 | if(pm.isNull()) | 235 | if(pm.isNull()) |
236 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 236 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
237 | item->setPixmap( 0,pm); | 237 | item->setPixmap( 0,pm); |
238 | } | 238 | } |
239 | } | 239 | } |
240 | if( fileL.find("->",0,TRUE) != -1) { | 240 | if( fileL.find("->",0,TRUE) != -1) { |
241 | // overlay link image | 241 | // overlay link image |
242 | pm= Resource::loadPixmap( "folder" ); | 242 | pm= Resource::loadPixmap( "folder" ); |
243 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 243 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
244 | QPainter painter( &pm ); | 244 | QPainter painter( &pm ); |
245 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 245 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
246 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 246 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
247 | item->setPixmap( 0, pm); | 247 | item->setPixmap( 0, pm); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | isDir=FALSE; | 250 | isDir=FALSE; |
251 | ++it; | 251 | ++it; |
252 | // } | 252 | // } |
253 | } | 253 | } |
254 | ListView->setSorting( 3, FALSE); | 254 | ListView->setSorting( 3, FALSE); |
255 | QString currentPath = currentDir.canonicalPath(); | 255 | QString currentPath = currentDir.canonicalPath(); |
256 | 256 | ||
257 | fillCombo( (const QString &)currentPath); | 257 | fillCombo( (const QString &)currentPath); |
258 | // dirPathCombo->lineEdit()->setText(currentPath); | 258 | // dirPathCombo->lineEdit()->setText(currentPath); |
259 | 259 | ||
260 | // if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 260 | // if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
261 | // dirPathCombo->clear(); | 261 | // dirPathCombo->clear(); |
262 | // dirPathStringList.prepend(currentPath ); | 262 | // dirPathStringList.prepend(currentPath ); |
263 | // dirPathCombo->insertStringList( dirPathStringList,-1); | 263 | // dirPathCombo->insertStringList( dirPathStringList,-1); |
264 | // } | 264 | // } |
265 | } | 265 | } |
266 | 266 | ||
267 | void fileBrowser::upDir() | 267 | void fileBrowser::upDir() |
268 | { | 268 | { |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 19449cb..b8d62db 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -321,390 +321,390 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
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 | font->insertSeparator(); | 353 | font->insertSeparator(); |
354 | font->insertItem(tr("About"), this, SLOT( doAbout()) ); | 354 | font->insertItem(tr("About"), this, SLOT( doAbout()) ); |
355 | 355 | ||
356 | mb->insertItem( tr( "File" ), file ); | 356 | mb->insertItem( tr( "File" ), file ); |
357 | mb->insertItem( tr( "Edit" ), edit ); | 357 | mb->insertItem( tr( "Edit" ), edit ); |
358 | mb->insertItem( tr( "View" ), font ); | 358 | mb->insertItem( tr( "View" ), font ); |
359 | 359 | ||
360 | searchBar = new QPEToolBar(this); | 360 | searchBar = new QPEToolBar(this); |
361 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 361 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
362 | 362 | ||
363 | searchBar->setHorizontalStretchable( TRUE ); | 363 | searchBar->setHorizontalStretchable( TRUE ); |
364 | 364 | ||
365 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 365 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
366 | searchBar->setStretchableWidget( searchEdit ); | 366 | searchBar->setStretchableWidget( searchEdit ); |
367 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 367 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
368 | this, SLOT( search() ) ); | 368 | this, SLOT( search() ) ); |
369 | 369 | ||
370 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | 370 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); |
371 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 371 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
372 | a->addTo( searchBar ); | 372 | a->addTo( searchBar ); |
373 | a->addTo( edit ); | 373 | a->addTo( edit ); |
374 | 374 | ||
375 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 375 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
376 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 376 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
377 | a->addTo( searchBar ); | 377 | a->addTo( searchBar ); |
378 | 378 | ||
379 | edit->insertSeparator(); | 379 | edit->insertSeparator(); |
380 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 380 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
381 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 381 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
382 | a->addTo( edit ); | 382 | a->addTo( edit ); |
383 | 383 | ||
384 | searchBar->hide(); | 384 | searchBar->hide(); |
385 | 385 | ||
386 | editor = new QpeEditor( this ); | 386 | editor = new QpeEditor( this ); |
387 | setCentralWidget( editor ); | 387 | setCentralWidget( editor ); |
388 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 388 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
389 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); | 389 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); |
390 | 390 | ||
391 | // resize( 200, 300 ); | 391 | // resize( 200, 300 ); |
392 | 392 | ||
393 | // setFontSize(defsize,TRUE); | 393 | // setFontSize(defsize,TRUE); |
394 | FontDatabase fdb; | 394 | FontDatabase fdb; |
395 | QFont defaultFont=editor->font(); | 395 | QFont defaultFont=editor->font(); |
396 | QFontInfo fontInfo(defaultFont); | 396 | QFontInfo fontInfo(defaultFont); |
397 | 397 | ||
398 | cfg.setGroup("Font"); | 398 | cfg.setGroup("Font"); |
399 | QString family = cfg.readEntry("Family", fontInfo.family()); | 399 | QString family = cfg.readEntry("Family", fontInfo.family()); |
400 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 400 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
401 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 401 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
402 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 402 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
403 | 403 | ||
404 | defaultFont = fdb.font(family,style,i_size,charSet); | 404 | defaultFont = fdb.font(family,style,i_size,charSet); |
405 | editor->setFont( defaultFont); | 405 | editor->setFont( defaultFont); |
406 | 406 | ||
407 | wa->setOn(wrap); | 407 | wa->setOn(wrap); |
408 | updateCaption(); | 408 | updateCaption(); |
409 | 409 | ||
410 | cfg.setGroup("View"); | 410 | cfg.setGroup("View"); |
411 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { | 411 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { |
412 | nStart->setOn(TRUE); | 412 | nStart->setOn(TRUE); |
413 | fileNew(); | 413 | fileNew(); |
414 | } else { | 414 | } else { |
415 | fileOpen(); | 415 | fileOpen(); |
416 | } | 416 | } |
417 | 417 | ||
418 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 418 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
419 | } | 419 | } |
420 | 420 | ||
421 | void TextEdit::cleanUp() | 421 | void TextEdit::cleanUp() |
422 | { | 422 | { |
423 | // save(); | 423 | // save(); |
424 | Config cfg("TextEdit"); | 424 | Config cfg("TextEdit"); |
425 | cfg.setGroup("View"); | 425 | cfg.setGroup("View"); |
426 | QFont f = editor->font(); | 426 | QFont f = editor->font(); |
427 | cfg.writeEntry("FontSize",f.pointSize()); | 427 | cfg.writeEntry("FontSize",f.pointSize()); |
428 | cfg.writeEntry("Bold",f.bold()); | 428 | cfg.writeEntry("Bold",f.bold()); |
429 | cfg.writeEntry("Italic",f.italic()); | 429 | cfg.writeEntry("Italic",f.italic()); |
430 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); | 430 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); |
431 | cfg.writeEntry( "FileView", viewSelection ); | 431 | cfg.writeEntry( "FileView", viewSelection ); |
432 | 432 | ||
433 | } | 433 | } |
434 | 434 | ||
435 | TextEdit::~TextEdit() | 435 | TextEdit::~TextEdit() |
436 | { | 436 | { |
437 | } | 437 | } |
438 | 438 | ||
439 | void TextEdit::zoomIn() | 439 | void TextEdit::zoomIn() |
440 | { | 440 | { |
441 | setFontSize(editor->font().pointSize()+1,FALSE); | 441 | setFontSize(editor->font().pointSize()+1,FALSE); |
442 | } | 442 | } |
443 | 443 | ||
444 | void TextEdit::zoomOut() | 444 | void TextEdit::zoomOut() |
445 | { | 445 | { |
446 | setFontSize(editor->font().pointSize()-1,TRUE); | 446 | setFontSize(editor->font().pointSize()-1,TRUE); |
447 | } | 447 | } |
448 | 448 | ||
449 | 449 | ||
450 | void TextEdit::setFontSize(int sz, bool round_down_not_up) | 450 | void TextEdit::setFontSize(int sz, bool round_down_not_up) |
451 | { | 451 | { |
452 | int s=10; | 452 | int s=10; |
453 | for (int i=0; i<nfontsizes; i++) { | 453 | for (int i=0; i<nfontsizes; i++) { |
454 | if ( fontsize[i] == sz ) { | 454 | if ( fontsize[i] == sz ) { |
455 | s = sz; | 455 | s = sz; |
456 | break; | 456 | break; |
457 | } else if ( round_down_not_up ) { | 457 | } else if ( round_down_not_up ) { |
458 | if ( fontsize[i] < sz ) | 458 | if ( fontsize[i] < sz ) |
459 | s = fontsize[i]; | 459 | s = fontsize[i]; |
460 | } else { | 460 | } else { |
461 | if ( fontsize[i] > sz ) { | 461 | if ( fontsize[i] > sz ) { |
462 | s = fontsize[i]; | 462 | s = fontsize[i]; |
463 | break; | 463 | break; |
464 | } | 464 | } |
465 | } | 465 | } |
466 | } | 466 | } |
467 | 467 | ||
468 | QFont f = editor->font(); | 468 | QFont f = editor->font(); |
469 | f.setPointSize(s); | 469 | f.setPointSize(s); |
470 | editor->setFont(f); | 470 | editor->setFont(f); |
471 | 471 | ||
472 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 472 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
473 | zout->setEnabled(s != fontsize[0]); | 473 | zout->setEnabled(s != fontsize[0]); |
474 | } | 474 | } |
475 | 475 | ||
476 | void TextEdit::setBold(bool y) | 476 | void TextEdit::setBold(bool y) |
477 | { | 477 | { |
478 | QFont f = editor->font(); | 478 | QFont f = editor->font(); |
479 | f.setBold(y); | 479 | f.setBold(y); |
480 | editor->setFont(f); | 480 | editor->setFont(f); |
481 | } | 481 | } |
482 | 482 | ||
483 | void TextEdit::setItalic(bool y) | 483 | void TextEdit::setItalic(bool y) |
484 | { | 484 | { |
485 | QFont f = editor->font(); | 485 | QFont f = editor->font(); |
486 | f.setItalic(y); | 486 | f.setItalic(y); |
487 | editor->setFont(f); | 487 | editor->setFont(f); |
488 | } | 488 | } |
489 | 489 | ||
490 | void TextEdit::setWordWrap(bool y) | 490 | void TextEdit::setWordWrap(bool y) |
491 | { | 491 | { |
492 | bool state = editor->edited(); | 492 | bool state = editor->edited(); |
493 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 493 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
494 | editor->setEdited( state ); | 494 | editor->setEdited( state ); |
495 | } | 495 | } |
496 | 496 | ||
497 | void TextEdit::fileNew() | 497 | void TextEdit::fileNew() |
498 | { | 498 | { |
499 | // if( !bFromDocView ) { | 499 | // if( !bFromDocView ) { |
500 | // saveAs(); | 500 | // saveAs(); |
501 | // } | 501 | // } |
502 | newFile(DocLnk()); | 502 | newFile(DocLnk()); |
503 | } | 503 | } |
504 | 504 | ||
505 | void TextEdit::fileOpen() | 505 | void TextEdit::fileOpen() |
506 | { | 506 | { |
507 | Config cfg("TextEdit"); | 507 | Config cfg("TextEdit"); |
508 | cfg.setGroup("View"); | 508 | cfg.setGroup("View"); |
509 | bool b=FALSE; | 509 | bool b=FALSE; |
510 | if(cfg.readEntry("useOldFileDialog") == "TRUE") | 510 | if(cfg.readEntry("useOldFileDialog") == "TRUE") |
511 | b=TRUE; | 511 | b=TRUE; |
512 | if(!b) { | 512 | if(!b) { |
513 | QString str = OFileDialog::getOpenFileName( 1,"/","", "text/plain", this ); | 513 | QString str = OFileDialog::getOpenFileName( 1,"/","", "*", this ); |
514 | if(!str.isEmpty() ) | 514 | if(!str.isEmpty() ) |
515 | openFile( str ); | 515 | openFile( str ); |
516 | } else { | 516 | } else { |
517 | QString str; | 517 | QString str; |
518 | browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); // | 518 | browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "*"); // |
519 | browseForFiles->setFileView( viewSelection ); | 519 | browseForFiles->setFileView( viewSelection ); |
520 | browseForFiles->showMaximized(); | 520 | browseForFiles->showMaximized(); |
521 | // if( result != -1 ) | 521 | // if( result != -1 ) |
522 | 522 | ||
523 | if( browseForFiles->exec() != -1 ) { | 523 | if( browseForFiles->exec() != -1 ) { |
524 | QString selFile = browseForFiles->selectedFileName; | 524 | QString selFile = browseForFiles->selectedFileName; |
525 | QStringList fileList = browseForFiles->fileList; | 525 | QStringList fileList = browseForFiles->fileList; |
526 | qDebug(selFile); | 526 | qDebug(selFile); |
527 | QStringList::ConstIterator f; | 527 | QStringList::ConstIterator f; |
528 | QString fileTemp; | 528 | QString fileTemp; |
529 | for ( f = fileList.begin(); f != fileList.end(); f++ ) { | 529 | for ( f = fileList.begin(); f != fileList.end(); f++ ) { |
530 | fileTemp = *f; | 530 | fileTemp = *f; |
531 | fileTemp.right( fileTemp.length()-5); | 531 | fileTemp.right( fileTemp.length()-5); |
532 | QString fileName = fileTemp; | 532 | QString fileName = fileTemp; |
533 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { | 533 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { |
534 | currentFileName = fileName; | 534 | currentFileName = fileName; |
535 | qDebug("please open "+currentFileName); | 535 | qDebug("please open "+currentFileName); |
536 | openFile(currentFileName ); | 536 | openFile(currentFileName ); |
537 | } | 537 | } |
538 | } | 538 | } |
539 | viewSelection = browseForFiles->SelectionCombo->currentItem(); | 539 | viewSelection = browseForFiles->SelectionCombo->currentItem(); |
540 | } | 540 | } |
541 | delete browseForFiles; | 541 | delete browseForFiles; |
542 | editor->setEdited( FALSE); | 542 | editor->setEdited( FALSE); |
543 | edited1=FALSE; | 543 | edited1=FALSE; |
544 | edited=FALSE; | 544 | edited=FALSE; |
545 | if(caption().left(1)=="*") | 545 | if(caption().left(1)=="*") |
546 | setCaption(caption().right(caption().length()-1)); | 546 | setCaption(caption().right(caption().length()-1)); |
547 | doSearchBar(); | 547 | doSearchBar(); |
548 | } | 548 | } |
549 | } | 549 | } |
550 | 550 | ||
551 | void TextEdit::doSearchBar() | 551 | void TextEdit::doSearchBar() |
552 | { | 552 | { |
553 | Config cfg("TextEdit"); | 553 | Config cfg("TextEdit"); |
554 | cfg.setGroup("View"); | 554 | cfg.setGroup("View"); |
555 | if(cfg.readEntry("SearchBar","Closed") != "Opened") | 555 | if(cfg.readEntry("SearchBar","Closed") != "Opened") |
556 | searchBar->hide(); | 556 | searchBar->hide(); |
557 | } | 557 | } |
558 | 558 | ||
559 | #if 0 | 559 | #if 0 |
560 | void TextEdit::slotFind() | 560 | void TextEdit::slotFind() |
561 | { | 561 | { |
562 | FindDialog frmFind( tr("Text Editor"), this ); | 562 | FindDialog frmFind( tr("Text Editor"), this ); |
563 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 563 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
564 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 564 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
565 | 565 | ||
566 | //case sensitive, backwards, [category] | 566 | //case sensitive, backwards, [category] |
567 | 567 | ||
568 | connect( editor, SIGNAL(notFound()), | 568 | connect( editor, SIGNAL(notFound()), |
569 | &frmFind, SLOT(slotNotFound()) ); | 569 | &frmFind, SLOT(slotNotFound()) ); |
570 | connect( editor, SIGNAL(searchWrapped()), | 570 | connect( editor, SIGNAL(searchWrapped()), |
571 | &frmFind, SLOT(slotWrapAround()) ); | 571 | &frmFind, SLOT(slotWrapAround()) ); |
572 | 572 | ||
573 | frmFind.exec(); | 573 | frmFind.exec(); |
574 | 574 | ||
575 | 575 | ||
576 | } | 576 | } |
577 | #endif | 577 | #endif |
578 | 578 | ||
579 | void TextEdit::fileRevert() | 579 | void TextEdit::fileRevert() |
580 | { | 580 | { |
581 | clear(); | 581 | clear(); |
582 | fileOpen(); | 582 | fileOpen(); |
583 | } | 583 | } |
584 | 584 | ||
585 | void TextEdit::editCut() | 585 | void TextEdit::editCut() |
586 | { | 586 | { |
587 | #ifndef QT_NO_CLIPBOARD | 587 | #ifndef QT_NO_CLIPBOARD |
588 | editor->cut(); | 588 | editor->cut(); |
589 | #endif | 589 | #endif |
590 | } | 590 | } |
591 | 591 | ||
592 | void TextEdit::editCopy() | 592 | void TextEdit::editCopy() |
593 | { | 593 | { |
594 | #ifndef QT_NO_CLIPBOARD | 594 | #ifndef QT_NO_CLIPBOARD |
595 | editor->copy(); | 595 | editor->copy(); |
596 | #endif | 596 | #endif |
597 | } | 597 | } |
598 | 598 | ||
599 | void TextEdit::editPaste() | 599 | void TextEdit::editPaste() |
600 | { | 600 | { |
601 | #ifndef QT_NO_CLIPBOARD | 601 | #ifndef QT_NO_CLIPBOARD |
602 | editor->paste(); | 602 | editor->paste(); |
603 | #endif | 603 | #endif |
604 | } | 604 | } |
605 | 605 | ||
606 | void TextEdit::editFind() | 606 | void TextEdit::editFind() |
607 | { | 607 | { |
608 | searchBar->show(); | 608 | searchBar->show(); |
609 | searchVisible = TRUE; | 609 | searchVisible = TRUE; |
610 | searchEdit->setFocus(); | 610 | searchEdit->setFocus(); |
611 | Config cfg("TextEdit"); | 611 | Config cfg("TextEdit"); |
612 | cfg.setGroup("View"); | 612 | cfg.setGroup("View"); |
613 | cfg.writeEntry("SearchBar","Opened"); | 613 | cfg.writeEntry("SearchBar","Opened"); |
614 | 614 | ||
615 | } | 615 | } |
616 | 616 | ||
617 | void TextEdit::findNext() | 617 | void TextEdit::findNext() |
618 | { | 618 | { |
619 | editor->find( searchEdit->text(), FALSE, FALSE ); | 619 | editor->find( searchEdit->text(), FALSE, FALSE ); |
620 | 620 | ||
621 | } | 621 | } |
622 | 622 | ||
623 | void TextEdit::findClose() | 623 | void TextEdit::findClose() |
624 | { | 624 | { |
625 | searchVisible = FALSE; | 625 | searchVisible = FALSE; |
626 | searchBar->hide(); | 626 | searchBar->hide(); |
627 | Config cfg("TextEdit"); | 627 | Config cfg("TextEdit"); |
628 | cfg.setGroup("View"); | 628 | cfg.setGroup("View"); |
629 | cfg.writeEntry("SearchBar","Closed"); | 629 | cfg.writeEntry("SearchBar","Closed"); |
630 | cfg.write(); | 630 | cfg.write(); |
631 | } | 631 | } |
632 | 632 | ||
633 | void TextEdit::search() | 633 | void TextEdit::search() |
634 | { | 634 | { |
635 | editor->find( searchEdit->text(), FALSE, FALSE ); | 635 | editor->find( searchEdit->text(), FALSE, FALSE ); |
636 | } | 636 | } |
637 | 637 | ||
638 | void TextEdit::newFile( const DocLnk &f ) | 638 | void TextEdit::newFile( const DocLnk &f ) |
639 | { | 639 | { |
640 | DocLnk nf = f; | 640 | DocLnk nf = f; |
641 | nf.setType("text/plain"); | 641 | nf.setType("text/plain"); |
642 | clear(); | 642 | clear(); |
643 | setWState (WState_Reserved1 ); | 643 | setWState (WState_Reserved1 ); |
644 | editor->setFocus(); | 644 | editor->setFocus(); |
645 | doc = new DocLnk(nf); | 645 | doc = new DocLnk(nf); |
646 | currentFileName = "Unnamed"; | 646 | currentFileName = "Unnamed"; |
647 | qDebug("newFile "+currentFileName); | 647 | qDebug("newFile "+currentFileName); |
648 | updateCaption( currentFileName); | 648 | updateCaption( currentFileName); |
649 | // editor->setEdited( FALSE); | 649 | // editor->setEdited( FALSE); |
650 | } | 650 | } |
651 | 651 | ||
652 | void TextEdit::openFile( const QString &f ) | 652 | void TextEdit::openFile( const QString &f ) |
653 | { | 653 | { |
654 | qDebug("filename is "+ f); | 654 | qDebug("filename is "+ f); |
655 | QString filer; | 655 | QString filer; |
656 | // bFromDocView = TRUE; | 656 | // bFromDocView = TRUE; |
657 | if(f.find(".desktop",0,TRUE) != -1) { | 657 | if(f.find(".desktop",0,TRUE) != -1) { |
658 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 658 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
659 | tr("Text Editor has detected\n you selected a .desktop file.\nOpen .desktop file or linked file?"), | 659 | tr("Text Editor has detected\n you selected a .desktop file.\nOpen .desktop file or linked file?"), |
660 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) { | 660 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) { |
661 | case 0: | 661 | case 0: |
662 | filer = f; | 662 | filer = f; |
663 | break; | 663 | break; |
664 | case 1: | 664 | case 1: |
665 | DocLnk sf(f); | 665 | DocLnk sf(f); |
666 | filer = sf.file(); | 666 | filer = sf.file(); |
667 | break; | 667 | break; |
668 | } | 668 | } |
669 | } else { | 669 | } else { |
670 | filer = f; | 670 | filer = f; |
671 | fileIs = TRUE; | 671 | fileIs = TRUE; |
672 | } | 672 | } |
673 | 673 | ||
674 | DocLnk nf; | 674 | DocLnk nf; |
675 | nf.setType("text/plain"); | 675 | nf.setType("text/plain"); |
676 | nf.setFile(filer); | 676 | nf.setFile(filer); |
677 | currentFileName=filer; | 677 | currentFileName=filer; |
678 | QFileInfo fi( currentFileName); | 678 | QFileInfo fi( currentFileName); |
679 | nf.setName(fi.baseName()); | 679 | nf.setName(fi.baseName()); |
680 | qDebug("openFile string "+currentFileName); | 680 | qDebug("openFile string "+currentFileName); |
681 | 681 | ||
682 | openFile(nf); | 682 | openFile(nf); |
683 | showEditTools(); | 683 | showEditTools(); |
684 | // Show filename in caption | 684 | // Show filename in caption |
685 | QString name = filer; | 685 | QString name = filer; |
686 | int sep = name.findRev( '/' ); | 686 | int sep = name.findRev( '/' ); |
687 | if ( sep > 0 ) | 687 | if ( sep > 0 ) |
688 | name = name.mid( sep+1 ); | 688 | name = name.mid( sep+1 ); |
689 | updateCaption( name ); | 689 | updateCaption( name ); |
690 | } | 690 | } |
691 | 691 | ||
692 | void TextEdit::openFile( const DocLnk &f ) | 692 | void TextEdit::openFile( const DocLnk &f ) |
693 | { | 693 | { |
694 | // clear(); | 694 | // clear(); |
695 | // bFromDocView = TRUE; | 695 | // bFromDocView = TRUE; |
696 | FileManager fm; | 696 | FileManager fm; |
697 | QString txt; | 697 | QString txt; |
698 | currentFileName=f.file(); | 698 | currentFileName=f.file(); |
699 | qDebug("openFile doclnk " + currentFileName); | 699 | qDebug("openFile doclnk " + currentFileName); |
700 | if ( !fm.loadFile( f, txt ) ) { | 700 | if ( !fm.loadFile( f, txt ) ) { |
701 | // ####### could be a new file | 701 | // ####### could be a new file |
702 | qDebug( "Cannot open file" ); | 702 | qDebug( "Cannot open file" ); |
703 | } | 703 | } |
704 | // fileNew(); | 704 | // fileNew(); |
705 | if ( doc ) | 705 | if ( doc ) |
706 | delete doc; | 706 | delete doc; |
707 | doc = new DocLnk(f); | 707 | doc = new DocLnk(f); |
708 | editor->setText(txt); | 708 | editor->setText(txt); |
709 | editor->setEdited( FALSE); | 709 | editor->setEdited( FALSE); |
710 | edited1=FALSE; | 710 | edited1=FALSE; |