author | llornkcor <llornkcor> | 2002-03-24 22:30:34 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-24 22:30:34 (UTC) |
commit | 8cada0d43b00686567295e712f9c5c89e3977a7d (patch) (unidiff) | |
tree | c68219b8731b391b8512b9454a62dde62f5dddc4 | |
parent | 59e2a88589d8d3fce1a395d073516d99b4e46e78 (diff) | |
download | opie-8cada0d43b00686567295e712f9c5c89e3977a7d.zip opie-8cada0d43b00686567295e712f9c5c89e3977a7d.tar.gz opie-8cada0d43b00686567295e712f9c5c89e3977a7d.tar.bz2 |
added symplink icon
-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 18 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 2 |
2 files changed, 15 insertions, 5 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp index eea7144..41e800c 100644 --- a/core/apps/textedit/fileBrowser.cpp +++ b/core/apps/textedit/fileBrowser.cpp | |||
@@ -6,389 +6,399 @@ | |||
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ****************************************************************************/ | 13 | ****************************************************************************/ |
14 | #include "fileBrowser.h" | 14 | #include "fileBrowser.h" |
15 | #include "inputDialog.h" | 15 | #include "inputDialog.h" |
16 | 16 | ||
17 | #include <qpe/config.h> | 17 | #include <qpe/config.h> |
18 | #include <qpe/resource.h> | 18 | #include <qpe/resource.h> |
19 | #include <qpe/fileselector.h> | 19 | #include <qpe/fileselector.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/menubutton.h> | 21 | #include <qpe/menubutton.h> |
22 | 22 | ||
23 | #include <qdict.h> | 23 | #include <qdict.h> |
24 | #include <qwidgetstack.h> | 24 | #include <qwidgetstack.h> |
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | #include <qcombo.h> | 26 | #include <qcombo.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qfile.h> | 28 | #include <qfile.h> |
29 | #include <qmessagebox.h> | 29 | #include <qmessagebox.h> |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #include <qpopupmenu.h> | 32 | #include <qpopupmenu.h> |
33 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | 35 | ||
36 | #include <unistd.h> | 36 | #include <unistd.h> |
37 | #include <stdlib.h> | 37 | #include <stdlib.h> |
38 | 38 | ||
39 | static int u_id = 1; | 39 | static int u_id = 1; |
40 | static int get_unique_id() | 40 | static int get_unique_id() |
41 | { | 41 | { |
42 | return u_id++; | 42 | return u_id++; |
43 | } | 43 | } |
44 | 44 | ||
45 | fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter ) | 45 | fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter ) |
46 | : QDialog( parent, name, modal, fl ) | 46 | : QDialog( parent, name, modal, fl ) |
47 | { | 47 | { |
48 | if ( !name ) | 48 | if ( !name ) |
49 | setName( "fileBrowser" ); | 49 | setName( "fileBrowser" ); |
50 | setCaption(tr( name ) ); | 50 | setCaption(tr( name ) ); |
51 | filterStr=filter; | 51 | filterStr=filter; |
52 | 52 | ||
53 | // channel = new QCopChannel( "QPE/fileDialog", this ); | 53 | // channel = new QCopChannel( "QPE/fileDialog", this ); |
54 | // connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 54 | // connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
55 | // this, SLOT(receive(const QCString&, const QByteArray&)) ); | 55 | // this, SLOT(receive(const QCString&, const QByteArray&)) ); |
56 | 56 | ||
57 | QGridLayout *layout = new QGridLayout( this ); | 57 | QGridLayout *layout = new QGridLayout( this ); |
58 | layout->setSpacing( 4 ); | 58 | layout->setSpacing( 4 ); |
59 | layout->setMargin( 4 ); | 59 | layout->setMargin( 4 ); |
60 | 60 | ||
61 | dirPathCombo = new QComboBox( FALSE, this, "dorPathCombo" ); | 61 | dirPathCombo = new QComboBox( FALSE, this, "dorPathCombo" ); |
62 | dirPathCombo->setEditable(TRUE); | 62 | dirPathCombo->setEditable(TRUE); |
63 | 63 | ||
64 | connect( dirPathCombo, SIGNAL( activated( const QString & ) ), | 64 | connect( dirPathCombo, SIGNAL( activated( const QString & ) ), |
65 | this, SLOT( dirPathComboActivated( const QString & ) ) ); | 65 | this, SLOT( dirPathComboActivated( const QString & ) ) ); |
66 | 66 | ||
67 | connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ), | 67 | connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ), |
68 | this, SLOT( dirPathEditPressed( ) ) ); | 68 | this, SLOT( dirPathEditPressed( ) ) ); |
69 | 69 | ||
70 | dirPathStringList << "/"; | 70 | dirPathStringList << "/"; |
71 | // we can get the storage here | 71 | // we can get the storage here |
72 | 72 | ||
73 | layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 ); | 73 | layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 ); |
74 | 74 | ||
75 | cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); | 75 | cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); |
76 | cdUpButton ->setMinimumSize( QSize( 20, 20 ) ); | 76 | cdUpButton ->setMinimumSize( QSize( 20, 20 ) ); |
77 | cdUpButton ->setMaximumSize( QSize( 20, 20 ) ); | 77 | cdUpButton ->setMaximumSize( QSize( 20, 20 ) ); |
78 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); | 78 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); |
79 | cdUpButton ->setFlat(TRUE); | 79 | cdUpButton ->setFlat(TRUE); |
80 | layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 ); | 80 | layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 ); |
81 | 81 | ||
82 | 82 | ||
83 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); | 83 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); |
84 | docButton->setMinimumSize( QSize( 20, 20 ) ); | 84 | docButton->setMinimumSize( QSize( 20, 20 ) ); |
85 | docButton->setMaximumSize( QSize( 20, 20 ) ); | 85 | docButton->setMaximumSize( QSize( 20, 20 ) ); |
86 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 86 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
87 | docButton->setFlat(TRUE); | 87 | docButton->setFlat(TRUE); |
88 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); | 88 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); |
89 | 89 | ||
90 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); | 90 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); |
91 | homeButton->setMinimumSize( QSize( 20, 20 ) ); | 91 | homeButton->setMinimumSize( QSize( 20, 20 ) ); |
92 | homeButton->setMaximumSize( QSize( 20, 20 ) ); | 92 | homeButton->setMaximumSize( QSize( 20, 20 ) ); |
93 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 93 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
94 | homeButton->setFlat(TRUE); | 94 | homeButton->setFlat(TRUE); |
95 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 ); | 95 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 ); |
96 | 96 | ||
97 | FileStack = new QWidgetStack( this ); | 97 | FileStack = new QWidgetStack( this ); |
98 | 98 | ||
99 | 99 | ||
100 | ListView = new QListView( this, "ListView" ); | 100 | ListView = new QListView( this, "ListView" ); |
101 | // ListView->setMinimumSize( QSize( 100, 25 ) ); | 101 | // ListView->setMinimumSize( QSize( 100, 25 ) ); |
102 | ListView->addColumn( tr( "Name" ) ); | 102 | ListView->addColumn( tr( "Name" ) ); |
103 | ListView->setColumnWidth(0,120); | 103 | ListView->setColumnWidth(0,120); |
104 | ListView->setSorting( 2, FALSE); | 104 | ListView->setSorting( 2, FALSE); |
105 | ListView->addColumn( tr( "Size" ) ); | 105 | ListView->addColumn( tr( "Size" ) ); |
106 | ListView->setColumnWidth(1,-1); | 106 | ListView->setColumnWidth(1,-1); |
107 | ListView->addColumn( "Date",-1); | 107 | ListView->addColumn( "Date",-1); |
108 | 108 | ||
109 | ListView->setColumnWidthMode(0,QListView::Manual); | 109 | ListView->setColumnWidthMode(0,QListView::Manual); |
110 | ListView->setColumnAlignment(1,QListView::AlignRight); | 110 | ListView->setColumnAlignment(1,QListView::AlignRight); |
111 | ListView->setColumnAlignment(2,QListView::AlignRight); | 111 | ListView->setColumnAlignment(2,QListView::AlignRight); |
112 | ListView->setAllColumnsShowFocus( TRUE ); | 112 | ListView->setAllColumnsShowFocus( TRUE ); |
113 | 113 | ||
114 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); | 114 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); |
115 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 115 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
116 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 116 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
117 | 117 | ||
118 | connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 118 | connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
119 | 119 | ||
120 | FileStack->addWidget( ListView, get_unique_id() ); | 120 | FileStack->addWidget( ListView, get_unique_id() ); |
121 | mimeType="text/*"; | 121 | mimeType="text/*"; |
122 | fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy | 122 | fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy |
123 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); | 123 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); |
124 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 124 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
125 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); | 125 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); |
126 | layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 ); | 126 | layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 ); |
127 | 127 | ||
128 | SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" ); | 128 | SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" ); |
129 | SelectionCombo->insertItem( tr( "Documents" ) ); | 129 | SelectionCombo->insertItem( tr( "Documents" ) ); |
130 | SelectionCombo->insertItem( tr( "All files" ) ); | 130 | SelectionCombo->insertItem( tr( "All files" ) ); |
131 | SelectionCombo->insertItem( tr( "Hidden files" ) ); | 131 | SelectionCombo->insertItem( tr( "Hidden files" ) ); |
132 | // SelectionCombo->setMaximumWidth(120); | 132 | // SelectionCombo->setMaximumWidth(120); |
133 | layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 ); | 133 | layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 ); |
134 | 134 | ||
135 | connect( SelectionCombo, SIGNAL( activated( const QString & ) ), | 135 | connect( SelectionCombo, SIGNAL( activated( const QString & ) ), |
136 | this, SLOT( selectionChanged( const QString & ) ) ); | 136 | this, SLOT( selectionChanged( const QString & ) ) ); |
137 | 137 | ||
138 | typemb = new MenuButton(this); | 138 | typemb = new MenuButton(this); |
139 | typemb->setLabel(tr("Type: %1")); | 139 | typemb->setLabel(tr("Type: %1")); |
140 | typemb->setMinimumWidth(110); | 140 | typemb->setMinimumWidth(110); |
141 | typemb->setFixedHeight(22); | 141 | typemb->setFixedHeight(22); |
142 | layout->addMultiCellWidget( typemb, 2, 2, 4, 7 ); | 142 | layout->addMultiCellWidget( typemb, 2, 2, 4, 7 ); |
143 | updateMimeTypeMenu() ; | 143 | updateMimeTypeMenu() ; |
144 | 144 | ||
145 | currentDir.setPath(QDir::currentDirPath()); | 145 | currentDir.setPath(QDir::currentDirPath()); |
146 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); | 146 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); |
147 | 147 | ||
148 | populateList(); | 148 | populateList(); |
149 | move(0,15); | 149 | move(0,15); |
150 | } | 150 | } |
151 | 151 | ||
152 | fileBrowser::~fileBrowser() | 152 | fileBrowser::~fileBrowser() |
153 | { | 153 | { |
154 | } | 154 | } |
155 | 155 | ||
156 | void fileBrowser::setFileView( int selection ) | 156 | void fileBrowser::setFileView( int selection ) |
157 | { | 157 | { |
158 | SelectionCombo->setCurrentItem( selection ); | 158 | SelectionCombo->setCurrentItem( selection ); |
159 | selectionChanged( SelectionCombo->currentText() ); | 159 | selectionChanged( SelectionCombo->currentText() ); |
160 | } | 160 | } |
161 | 161 | ||
162 | void fileBrowser::populateList() | 162 | void fileBrowser::populateList() |
163 | { | 163 | { |
164 | ListView->clear(); | 164 | ListView->clear(); |
165 | bool isDir=FALSE; | 165 | bool isDir=FALSE; |
166 | //qDebug(currentDir.canonicalPath()); | 166 | //qDebug(currentDir.canonicalPath()); |
167 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 167 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
168 | currentDir.setMatchAllDirs(TRUE); | 168 | currentDir.setMatchAllDirs(TRUE); |
169 | 169 | ||
170 | currentDir.setNameFilter(filterStr); | 170 | currentDir.setNameFilter(filterStr); |
171 | // currentDir.setNameFilter("*.txt;*.etx"); | 171 | // currentDir.setNameFilter("*.txt;*.etx"); |
172 | QString fileL, fileS, fileDate; | 172 | QString fileL, fileS, fileDate; |
173 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 173 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
174 | QFileInfoListIterator it(*list); | 174 | QFileInfoListIterator it(*list); |
175 | QFileInfo *fi; | 175 | QFileInfo *fi; |
176 | while ( (fi=it.current()) ) { | 176 | while ( (fi=it.current()) ) { |
177 | 177 | ||
178 | if (fi->isSymLink() ){ | 178 | if (fi->isSymLink() ){ |
179 | QString symLink=fi->readLink(); | 179 | QString symLink=fi->readLink(); |
180 | // qDebug("Symlink detected "+symLink); | 180 | // qDebug("Symlink detected "+symLink); |
181 | QFileInfo sym( symLink); | 181 | QFileInfo sym( symLink); |
182 | fileS.sprintf( "%10li", sym.size() ); | 182 | fileS.sprintf( "%10li", sym.size() ); |
183 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 183 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
184 | fileDate = sym.lastModified().toString(); | 184 | fileDate = sym.lastModified().toString(); |
185 | } else { | 185 | } else { |
186 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 186 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
187 | fileS.sprintf( "%10li", fi->size() ); | 187 | fileS.sprintf( "%10li", fi->size() ); |
188 | fileL.sprintf( "%s",fi->fileName().data() ); | 188 | fileL.sprintf( "%s",fi->fileName().data() ); |
189 | fileDate= fi->lastModified().toString(); | 189 | fileDate= fi->lastModified().toString(); |
190 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 190 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
191 | fileL+="/"; | 191 | fileL+="/"; |
192 | isDir=TRUE; | 192 | isDir=TRUE; |
193 | // qDebug( fileL); | 193 | // qDebug( fileL); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | if(fileL !="./") { | 196 | if(fileL !="./") { |
197 | item= new QListViewItem( ListView,fileL,fileS , fileDate); | 197 | item= new QListViewItem( ListView,fileL,fileS , fileDate); |
198 | if(isDir || fileL.find("/",0,TRUE) != -1) | 198 | QPixmap pm; |
199 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); | 199 | pm= Resource::loadPixmap( "folder" ); |
200 | else | 200 | if(isDir || fileL.find("/",0,TRUE) != -1) |
201 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | 201 | item->setPixmap( 0,pm ); |
202 | else | ||
203 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | ||
204 | if( fileL.find("->",0,TRUE) != -1) { | ||
205 | // overlay link image | ||
206 | QPixmap lnk = Resource::loadPixmap( "symlink" ); | ||
207 | QPainter painter( &pm ); | ||
208 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | ||
209 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | ||
210 | item->setPixmap( 0, pm); | ||
202 | } | 211 | } |
212 | } | ||
203 | isDir=FALSE; | 213 | isDir=FALSE; |
204 | ++it; | 214 | ++it; |
205 | } | 215 | } |
206 | ListView->setSorting( 3, FALSE); | 216 | ListView->setSorting( 3, FALSE); |
207 | QString currentPath = currentDir.canonicalPath(); | 217 | QString currentPath = currentDir.canonicalPath(); |
208 | 218 | ||
209 | fillCombo( (const QString &)currentPath); | 219 | fillCombo( (const QString &)currentPath); |
210 | // dirPathCombo->lineEdit()->setText(currentPath); | 220 | // dirPathCombo->lineEdit()->setText(currentPath); |
211 | 221 | ||
212 | // if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 222 | // if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
213 | // dirPathCombo->clear(); | 223 | // dirPathCombo->clear(); |
214 | // dirPathStringList.prepend(currentPath ); | 224 | // dirPathStringList.prepend(currentPath ); |
215 | // dirPathCombo->insertStringList( dirPathStringList,-1); | 225 | // dirPathCombo->insertStringList( dirPathStringList,-1); |
216 | // } | 226 | // } |
217 | } | 227 | } |
218 | 228 | ||
219 | void fileBrowser::upDir() | 229 | void fileBrowser::upDir() |
220 | { | 230 | { |
221 | QString current = currentDir.canonicalPath(); | 231 | QString current = currentDir.canonicalPath(); |
222 | QDir dir(current); | 232 | QDir dir(current); |
223 | dir.cdUp(); | 233 | dir.cdUp(); |
224 | current = dir.canonicalPath(); | 234 | current = dir.canonicalPath(); |
225 | chdir( current.latin1() ); | 235 | chdir( current.latin1() ); |
226 | currentDir.cd( current, TRUE); | 236 | currentDir.cd( current, TRUE); |
227 | populateList(); | 237 | populateList(); |
228 | update(); | 238 | update(); |
229 | } | 239 | } |
230 | 240 | ||
231 | // you may want to switch these 2 functions. I like single clicks | 241 | // you may want to switch these 2 functions. I like single clicks |
232 | void fileBrowser::listClicked(QListViewItem *selectedItem) | 242 | void fileBrowser::listClicked(QListViewItem *selectedItem) |
233 | { | 243 | { |
234 | QString strItem=selectedItem->text(0); | 244 | QString strItem=selectedItem->text(0); |
235 | QString strSize=selectedItem->text(1); | 245 | QString strSize=selectedItem->text(1); |
236 | // qDebug("strItem is "+strItem); | 246 | // qDebug("strItem is "+strItem); |
237 | strSize.stripWhiteSpace(); | 247 | strSize.stripWhiteSpace(); |
238 | // qDebug(strSize); | 248 | // qDebug(strSize); |
239 | 249 | ||
240 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 250 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
241 | // is symlink | 251 | // is symlink |
242 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); | 252 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); |
243 | // qDebug("strItem symlink is "+strItem2); | 253 | // qDebug("strItem symlink is "+strItem2); |
244 | if(QDir(strItem2).exists() ) { | 254 | if(QDir(strItem2).exists() ) { |
245 | currentDir.cd(strItem2, TRUE); | 255 | currentDir.cd(strItem2, TRUE); |
246 | populateList(); | 256 | populateList(); |
247 | } | 257 | } |
248 | } else { // not a symlink | 258 | } else { // not a symlink |
249 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 259 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
250 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 260 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
251 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 261 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
252 | currentDir.cd(strItem,FALSE); | 262 | currentDir.cd(strItem,FALSE); |
253 | // qDebug("Path is "+strItem); | 263 | // qDebug("Path is "+strItem); |
254 | populateList(); | 264 | populateList(); |
255 | } else { | 265 | } else { |
256 | currentDir.cdUp(); | 266 | currentDir.cdUp(); |
257 | populateList(); | 267 | populateList(); |
258 | } | 268 | } |
259 | if(QDir(strItem).exists()){ | 269 | if(QDir(strItem).exists()){ |
260 | currentDir.cd(strItem, TRUE); | 270 | currentDir.cd(strItem, TRUE); |
261 | populateList(); | 271 | populateList(); |
262 | } | 272 | } |
263 | } else { | 273 | } else { |
264 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 274 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
265 | if( QFile::exists(strItem ) ) { | 275 | if( QFile::exists(strItem ) ) { |
266 | //currentDir.canonicalPath() | 276 | //currentDir.canonicalPath() |
267 | qDebug("We found our files!!"+strItem); | 277 | qDebug("We found our files!!"+strItem); |
268 | OnOK(); | 278 | OnOK(); |
269 | } | 279 | } |
270 | } //end not symlink | 280 | } //end not symlink |
271 | chdir(strItem.latin1()); | 281 | chdir(strItem.latin1()); |
272 | } | 282 | } |
273 | } | 283 | } |
274 | 284 | ||
275 | void fileBrowser::OnOK() | 285 | void fileBrowser::OnOK() |
276 | { | 286 | { |
277 | QListViewItemIterator it1( ListView); | 287 | QListViewItemIterator it1( ListView); |
278 | for ( ; it1.current(); ++it1 ) { | 288 | for ( ; it1.current(); ++it1 ) { |
279 | if ( it1.current()->isSelected() ) { | 289 | if ( it1.current()->isSelected() ) { |
280 | selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); | 290 | selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); |
281 | qDebug("selected filename is "+selectedFileName); | 291 | qDebug("selected filename is "+selectedFileName); |
282 | fileList.append( selectedFileName ); | 292 | fileList.append( selectedFileName ); |
283 | } | 293 | } |
284 | } | 294 | } |
285 | accept(); | 295 | accept(); |
286 | } | 296 | } |
287 | 297 | ||
288 | void fileBrowser::homeButtonPushed() { | 298 | void fileBrowser::homeButtonPushed() { |
289 | QString current = QDir::homeDirPath(); | 299 | QString current = QDir::homeDirPath(); |
290 | chdir( current.latin1() ); | 300 | chdir( current.latin1() ); |
291 | currentDir.cd( current, TRUE); | 301 | currentDir.cd( current, TRUE); |
292 | populateList(); | 302 | populateList(); |
293 | update(); | 303 | update(); |
294 | } | 304 | } |
295 | 305 | ||
296 | void fileBrowser::docButtonPushed() { | 306 | void fileBrowser::docButtonPushed() { |
297 | QString current = QPEApplication::documentDir(); | 307 | QString current = QPEApplication::documentDir(); |
298 | chdir( current.latin1() ); | 308 | chdir( current.latin1() ); |
299 | currentDir.cd( current, TRUE); | 309 | currentDir.cd( current, TRUE); |
300 | populateList(); | 310 | populateList(); |
301 | update(); | 311 | update(); |
302 | 312 | ||
303 | } | 313 | } |
304 | 314 | ||
305 | void fileBrowser::selectionChanged( const QString &select ) | 315 | void fileBrowser::selectionChanged( const QString &select ) |
306 | { | 316 | { |
307 | if ( select == "Documents") { | 317 | if ( select == "Documents") { |
308 | FileStack->raiseWidget( fileSelector ); | 318 | FileStack->raiseWidget( fileSelector ); |
309 | dirPathCombo->hide(); | 319 | dirPathCombo->hide(); |
310 | cdUpButton->hide(); | 320 | cdUpButton->hide(); |
311 | docButton->hide(); | 321 | docButton->hide(); |
312 | homeButton->hide(); | 322 | homeButton->hide(); |
313 | } else { | 323 | } else { |
314 | if ( select == "All files" ) | 324 | if ( select == "All files" ) |
315 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All); | 325 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All); |
316 | else | 326 | else |
317 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 327 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
318 | 328 | ||
319 | populateList(); | 329 | populateList(); |
320 | update(); | 330 | update(); |
321 | dirPathCombo->show(); | 331 | dirPathCombo->show(); |
322 | cdUpButton->show(); | 332 | cdUpButton->show(); |
323 | docButton->show(); | 333 | docButton->show(); |
324 | homeButton->show(); | 334 | homeButton->show(); |
325 | FileStack->raiseWidget( ListView ); | 335 | FileStack->raiseWidget( ListView ); |
326 | } | 336 | } |
327 | } | 337 | } |
328 | 338 | ||
329 | void fileBrowser::docOpen( const DocLnk &doc ) | 339 | void fileBrowser::docOpen( const DocLnk &doc ) |
330 | { | 340 | { |
331 | fileList.append( doc.file().latin1() ); | 341 | fileList.append( doc.file().latin1() ); |
332 | accept(); | 342 | accept(); |
333 | } | 343 | } |
334 | 344 | ||
335 | void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 345 | void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
336 | { | 346 | { |
337 | switch (mouse) { | 347 | switch (mouse) { |
338 | case 1: | 348 | case 1: |
339 | break; | 349 | break; |
340 | case 2: | 350 | case 2: |
341 | showListMenu(item); | 351 | showListMenu(item); |
342 | break; | 352 | break; |
343 | }; | 353 | }; |
344 | } | 354 | } |
345 | 355 | ||
346 | void fileBrowser::showListMenu(QListViewItem *item) { | 356 | void fileBrowser::showListMenu(QListViewItem *item) { |
347 | 357 | ||
348 | QPopupMenu m;// = new QPopupMenu( Local_View ); | 358 | QPopupMenu m;// = new QPopupMenu( Local_View ); |
349 | if( item->text(0).find("/",0,TRUE)) | 359 | if( item->text(0).find("/",0,TRUE)) |
350 | m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); | 360 | m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); |
351 | else | 361 | else |
352 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); | 362 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); |
353 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList()() )); | 363 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList()() )); |
354 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 364 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
355 | m.insertSeparator(); | 365 | m.insertSeparator(); |
356 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 366 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
357 | m.exec( QCursor::pos() ); | 367 | m.exec( QCursor::pos() ); |
358 | 368 | ||
359 | } | 369 | } |
360 | 370 | ||
361 | void fileBrowser::doCd() { | 371 | void fileBrowser::doCd() { |
362 | listClicked( ListView->currentItem()); | 372 | listClicked( ListView->currentItem()); |
363 | } | 373 | } |
364 | 374 | ||
365 | void fileBrowser::makDir() { | 375 | void fileBrowser::makDir() { |
366 | InputDialog *fileDlg; | 376 | InputDialog *fileDlg; |
367 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); | 377 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); |
368 | fileDlg->exec(); | 378 | fileDlg->exec(); |
369 | if( fileDlg->result() == 1 ) { | 379 | if( fileDlg->result() == 1 ) { |
370 | QString filename = fileDlg->LineEdit1->text(); | 380 | QString filename = fileDlg->LineEdit1->text(); |
371 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 381 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
372 | } | 382 | } |
373 | populateList(); | 383 | populateList(); |
374 | } | 384 | } |
375 | 385 | ||
376 | void fileBrowser::localRename() { | 386 | void fileBrowser::localRename() { |
377 | QString curFile = ListView->currentItem()->text(0); | 387 | QString curFile = ListView->currentItem()->text(0); |
378 | InputDialog *fileDlg; | 388 | InputDialog *fileDlg; |
379 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); | 389 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); |
380 | fileDlg->inputText = curFile; | 390 | fileDlg->inputText = curFile; |
381 | fileDlg->exec(); | 391 | fileDlg->exec(); |
382 | if( fileDlg->result() == 1 ) { | 392 | if( fileDlg->result() == 1 ) { |
383 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 393 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
384 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 394 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
385 | if( rename(oldname.latin1(), newName.latin1())== -1) | 395 | if( rename(oldname.latin1(), newName.latin1())== -1) |
386 | QMessageBox::message("Note","Could not rename"); | 396 | QMessageBox::message("Note","Could not rename"); |
387 | } | 397 | } |
388 | populateList(); | 398 | populateList(); |
389 | } | 399 | } |
390 | 400 | ||
391 | void fileBrowser::localDelete() { | 401 | void fileBrowser::localDelete() { |
392 | QString f = ListView->currentItem()->text(0); | 402 | QString f = ListView->currentItem()->text(0); |
393 | if(QDir(f).exists() ) { | 403 | if(QDir(f).exists() ) { |
394 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ | 404 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index da74893..ecebe12 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -189,385 +189,385 @@ void QpeEditor::find ( const QString &txt, bool caseSensitive, | |||
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("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, "*"); | 496 | browseForFiles=new fileBrowser(this,"Open File",TRUE,0, "*"); |
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( "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 | ||