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