21 files changed, 129 insertions, 129 deletions
diff --git a/noncore/unsupported/filebrowser/filebrowser.cpp b/noncore/unsupported/filebrowser/filebrowser.cpp index 8cf8a60..92a688a 100644 --- a/noncore/unsupported/filebrowser/filebrowser.cpp +++ b/noncore/unsupported/filebrowser/filebrowser.cpp | |||
@@ -167,196 +167,196 @@ bool FileItem::rename( const QString & name ) | |||
167 | return FALSE; | 167 | return FALSE; |
168 | 168 | ||
169 | if ( name.contains( QRegExp("[/\\$\"\'\\*\\?]") ) ) | 169 | if ( name.contains( QRegExp("[/\\$\"\'\\*\\?]") ) ) |
170 | return FALSE; | 170 | return FALSE; |
171 | 171 | ||
172 | oldpath = fileInfo.filePath(); | 172 | oldpath = fileInfo.filePath(); |
173 | newpath = fileInfo.dirPath() + "/" + name; | 173 | newpath = fileInfo.dirPath() + "/" + name; |
174 | 174 | ||
175 | if ( ::rename( (const char *) oldpath, (const char *) newpath ) != 0 ) | 175 | if ( ::rename( (const char *) oldpath, (const char *) newpath ) != 0 ) |
176 | return FALSE; | 176 | return FALSE; |
177 | else | 177 | else |
178 | return TRUE; | 178 | return TRUE; |
179 | } | 179 | } |
180 | 180 | ||
181 | QPixmap FileItem::drawThumbnail(const QFileInfo &file) { | 181 | QPixmap FileItem::drawThumbnail(const QFileInfo &file) { |
182 | 182 | ||
183 | /* | 183 | /* |
184 | * this thing is sloooooow, and it also doesn't load | 184 | * this thing is sloooooow, and it also doesn't load |
185 | * dynamicly (like a web browser). if anyone knows how to | 185 | * dynamicly (like a web browser). if anyone knows how to |
186 | * do that, please do! | 186 | * do that, please do! |
187 | */ | 187 | */ |
188 | QString cacheDir = "/tmp/filebrowserThumbnailCache"; | 188 | QString cacheDir = "/tmp/filebrowserThumbnailCache"; |
189 | QFileInfo cachedFile (cacheDir + file.filePath()); | 189 | QFileInfo cachedFile (cacheDir + file.filePath()); |
190 | 190 | ||
191 | if (cachedFile.exists() && cachedFile.lastModified() == file.lastModified()) { | 191 | if (cachedFile.exists() && cachedFile.lastModified() == file.lastModified()) { |
192 | 192 | ||
193 | QPixmap cachedImage (cachedFile.filePath()); | 193 | QPixmap cachedImage (cachedFile.filePath()); |
194 | return cachedImage; | 194 | return cachedImage; |
195 | } | 195 | } |
196 | else { | 196 | else { |
197 | 197 | ||
198 | QImage image (file.filePath()); | 198 | QImage image (file.filePath()); |
199 | 199 | ||
200 | // if inside of cache dir, don't render thumbnails! recursive error! | 200 | // if inside of cache dir, don't render thumbnails! recursive error! |
201 | if (image.isNull() || file.filePath().contains(QRegExp("^" + cacheDir))) { | 201 | if (image.isNull() || file.filePath().contains(QRegExp("^" + cacheDir))) { |
202 | DocLnk doc (file.filePath()); | 202 | DocLnk doc (file.filePath()); |
203 | return doc.pixmap(); | 203 | return doc.pixmap(); |
204 | } | 204 | } |
205 | Config cfg("Filebrowser"); | 205 | Config cfg("Filebrowser"); |
206 | cfg.setGroup("View"); | 206 | cfg.setGroup("View"); |
207 | int size; | 207 | int size; |
208 | size =cfg.readNumEntry("ThumbSize", 72); | 208 | size =cfg.readNumEntry("ThumbSize", 72); |
209 | QPixmap thumb (size, size); | 209 | QPixmap thumb (size, size); |
210 | 210 | ||
211 | double scale = (double)image.height() / (double)image.width(); | 211 | double scale = (double)image.height() / (double)image.width(); |
212 | int newHeight = int(size * scale); | 212 | int newHeight = int(size * scale); |
213 | thumb.convertFromImage (image.smoothScale(size, newHeight)); | 213 | thumb.convertFromImage (image.smoothScale(size, newHeight)); |
214 | 214 | ||
215 | if (!cachedFile.dir().exists()) { | 215 | if (!cachedFile.dir().exists()) { |
216 | QString cmd = "/bin/mkdir -p \"" + cachedFile.dirPath() +"\""; | 216 | QString cmd = "/bin/mkdir -p \"" + cachedFile.dirPath() +"\""; |
217 | system( (const char *) cmd ); | 217 | system( (const char *) cmd ); |
218 | } | 218 | } |
219 | 219 | ||
220 | if (thumb.save(cachedFile.filePath(), QPixmap::imageFormat(file.filePath()), 70)) { | 220 | if (thumb.save(cachedFile.filePath(), QPixmap::imageFormat(file.filePath()), 70)) { |
221 | // make thumbnail modify time the same as the image | 221 | // make thumbnail modify time the same as the image |
222 | QString cmd = "/bin/touch -r \"" + file.filePath() +"\" " + | 222 | QString cmd = "/bin/touch -r \"" + file.filePath() +"\" " + |
223 | "\"" + cachedFile.filePath() + "\""; | 223 | "\"" + cachedFile.filePath() + "\""; |
224 | system( (const char *) cmd ); | 224 | system( (const char *) cmd ); |
225 | 225 | ||
226 | } | 226 | } |
227 | 227 | ||
228 | return thumb; | 228 | return thumb; |
229 | } | 229 | } |
230 | } | 230 | } |
231 | 231 | ||
232 | // | 232 | // |
233 | // FileView | 233 | // FileView |
234 | // | 234 | // |
235 | FileView::FileView( const QString & dir, QWidget * parent, | 235 | FileView::FileView( const QString & dir, QWidget * parent, |
236 | const char * name, | 236 | const char * name, |
237 | bool hidden, bool symlinks, bool thumbnails ) | 237 | bool hidden, bool symlinks, bool thumbnails ) |
238 | : QListView( parent, name ), | 238 | : QListView( parent, name ), |
239 | menuTimer( this ), | 239 | menuTimer( this ), |
240 | le( NULL ), | 240 | le( NULL ), |
241 | itemToRename( NULL ), | 241 | itemToRename( NULL ), |
242 | showHidden( hidden ), | 242 | showHidden( hidden ), |
243 | showSymlinks( symlinks ), | 243 | showSymlinks( symlinks ), |
244 | showThumbnails( thumbnails ), | 244 | showThumbnails( thumbnails ), |
245 | menuKeepsOpen( FALSE ) | 245 | menuKeepsOpen( FALSE ) |
246 | { | 246 | { |
247 | addColumn( "Name" ); | 247 | addColumn( "Name" ); |
248 | addColumn( "Size" ); | 248 | addColumn( "Size" ); |
249 | addColumn( "Date" ); | 249 | addColumn( "Date" ); |
250 | addColumn( "Type" ); | 250 | addColumn( "Type" ); |
251 | 251 | ||
252 | setMultiSelection( TRUE ); | 252 | setMultiSelection( TRUE ); |
253 | //header()->hide(); | 253 | //header()->hide(); |
254 | 254 | ||
255 | setColumnWidthMode( 0, Manual ); | 255 | setColumnWidthMode( 0, Manual ); |
256 | setColumnWidthMode( 3, Manual ); | 256 | setColumnWidthMode( 3, Manual ); |
257 | 257 | ||
258 | // right align yize column | 258 | // right align yize column |
259 | setColumnAlignment( 1, AlignRight ); | 259 | setColumnAlignment( 1, AlignRight ); |
260 | 260 | ||
261 | generateDir( dir ); | 261 | generateDir( dir ); |
262 | 262 | ||
263 | connect( this, SIGNAL( clicked( QListViewItem * )), | 263 | connect( this, SIGNAL( clicked(QListViewItem*)), |
264 | SLOT( itemClicked( QListViewItem * )) ); | 264 | SLOT( itemClicked(QListViewItem*)) ); |
265 | connect( this, SIGNAL( doubleClicked( QListViewItem * )), | 265 | connect( this, SIGNAL( doubleClicked(QListViewItem*)), |
266 | SLOT( itemDblClicked( QListViewItem * )) ); | 266 | SLOT( itemDblClicked(QListViewItem*)) ); |
267 | connect( this, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); | 267 | connect( this, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); |
268 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); | 268 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); |
269 | } | 269 | } |
270 | 270 | ||
271 | void FileView::resizeEvent( QResizeEvent *e ) | 271 | void FileView::resizeEvent( QResizeEvent *e ) |
272 | { | 272 | { |
273 | setColumnWidth( 0, width() - 2 * lineWidth() - 20 - columnWidth( 1 ) - columnWidth( 2 ) ); | 273 | setColumnWidth( 0, width() - 2 * lineWidth() - 20 - columnWidth( 1 ) - columnWidth( 2 ) ); |
274 | 274 | ||
275 | // hide type column, we use it for "sort by type" only | 275 | // hide type column, we use it for "sort by type" only |
276 | //setColumnWidth( 3, 0 ); | 276 | //setColumnWidth( 3, 0 ); |
277 | QListView::resizeEvent( e ); | 277 | QListView::resizeEvent( e ); |
278 | } | 278 | } |
279 | 279 | ||
280 | void FileView::updateDir() | 280 | void FileView::updateDir() |
281 | { | 281 | { |
282 | generateDir( currentDir ); | 282 | generateDir( currentDir ); |
283 | } | 283 | } |
284 | 284 | ||
285 | void FileView::setDir( const QString & dir ) | 285 | void FileView::setDir( const QString & dir ) |
286 | { | 286 | { |
287 | if ( dir.startsWith( "/dev" ) ) { | 287 | if ( dir.startsWith( "/dev" ) ) { |
288 | QMessageBox::warning( this, tr( "File Manager" ), | 288 | QMessageBox::warning( this, tr( "File Manager" ), |
289 | tr( "Can't show /dev/ directory." ), tr( "&Ok" ) ); | 289 | tr( "Can't show /dev/ directory." ), tr( "&Ok" ) ); |
290 | return; | 290 | return; |
291 | } | 291 | } |
292 | dirHistory += currentDir; | 292 | dirHistory += currentDir; |
293 | generateDir( dir ); | 293 | generateDir( dir ); |
294 | } | 294 | } |
295 | 295 | ||
296 | void FileView::generateDir( const QString & dir ) | 296 | void FileView::generateDir( const QString & dir ) |
297 | { | 297 | { |
298 | if(menuKeepsOpen){ | 298 | if(menuKeepsOpen){ |
299 | cancelMenuTimer(); | 299 | cancelMenuTimer(); |
300 | } | 300 | } |
301 | QDir d( dir ); | 301 | QDir d( dir ); |
302 | 302 | ||
303 | if( d.exists() && !d.isReadable() ) return; | 303 | if( d.exists() && !d.isReadable() ) return; |
304 | 304 | ||
305 | currentDir = d.canonicalPath(); | 305 | currentDir = d.canonicalPath(); |
306 | 306 | ||
307 | if( !showHidden) | 307 | if( !showHidden) |
308 | d.setFilter( QDir::Dirs | QDir::Files ); | 308 | d.setFilter( QDir::Dirs | QDir::Files ); |
309 | else | 309 | else |
310 | d.setFilter( QDir::Dirs | QDir::Files |QDir::Hidden | QDir::All); | 310 | d.setFilter( QDir::Dirs | QDir::Files |QDir::Hidden | QDir::All); |
311 | 311 | ||
312 | d.setSorting( QDir::Name | QDir::DirsFirst | QDir::IgnoreCase | QDir::Reversed ); | 312 | d.setSorting( QDir::Name | QDir::DirsFirst | QDir::IgnoreCase | QDir::Reversed ); |
313 | 313 | ||
314 | const QFileInfoList * list = d.entryInfoList(); | 314 | const QFileInfoList * list = d.entryInfoList(); |
315 | QFileInfoListIterator it( *list ); | 315 | QFileInfoListIterator it( *list ); |
316 | QFileInfo *fi; | 316 | QFileInfo *fi; |
317 | 317 | ||
318 | QProgressBar *thumbProgress = 0; | 318 | QProgressBar *thumbProgress = 0; |
319 | if (showThumbnails) { | 319 | if (showThumbnails) { |
320 | 320 | ||
321 | thumbProgress = new QProgressBar(it.count(), this); | 321 | thumbProgress = new QProgressBar(it.count(), this); |
322 | thumbProgress->show(); | 322 | thumbProgress->show(); |
323 | } | 323 | } |
324 | 324 | ||
325 | clear(); | 325 | clear(); |
326 | 326 | ||
327 | int fileCount = 1; // used in the thumbnail progress meter | 327 | int fileCount = 1; // used in the thumbnail progress meter |
328 | while( (fi = it.current()) ){ | 328 | while( (fi = it.current()) ){ |
329 | if( (fi->fileName() == ".") || (fi->fileName() == "..") ){ | 329 | if( (fi->fileName() == ".") || (fi->fileName() == "..") ){ |
330 | ++it; | 330 | ++it; |
331 | continue; | 331 | continue; |
332 | } | 332 | } |
333 | if(!showSymlinks && fi->isSymLink()){ | 333 | if(!showSymlinks && fi->isSymLink()){ |
334 | ++it; | 334 | ++it; |
335 | continue; | 335 | continue; |
336 | } | 336 | } |
337 | // thumbnail progress | 337 | // thumbnail progress |
338 | if (showThumbnails) { | 338 | if (showThumbnails) { |
339 | 339 | ||
340 | thumbProgress->setProgress(fileCount); | 340 | thumbProgress->setProgress(fileCount); |
341 | } | 341 | } |
342 | (void) new FileItem( (QListView *) this, *fi ); | 342 | (void) new FileItem( (QListView *) this, *fi ); |
343 | 343 | ||
344 | ++it; | 344 | ++it; |
345 | ++fileCount; | 345 | ++fileCount; |
346 | } | 346 | } |
347 | 347 | ||
348 | if (showThumbnails) { | 348 | if (showThumbnails) { |
349 | thumbProgress->close(); | 349 | thumbProgress->close(); |
350 | } | 350 | } |
351 | emit dirChanged(); | 351 | emit dirChanged(); |
352 | 352 | ||
353 | } | 353 | } |
354 | 354 | ||
355 | void FileView::rename() | 355 | void FileView::rename() |
356 | { | 356 | { |
357 | itemToRename = (FileItem *) currentItem(); | 357 | itemToRename = (FileItem *) currentItem(); |
358 | const QPixmap * pm; | 358 | const QPixmap * pm; |
359 | int pmw; | 359 | int pmw; |
360 | 360 | ||
361 | if( itemToRename == NULL ) return; | 361 | if( itemToRename == NULL ) return; |
362 | 362 | ||
@@ -815,194 +815,194 @@ FileBrowser::FileBrowser( const QString & dir, QWidget * parent, | |||
815 | init( dir ); | 815 | init( dir ); |
816 | } | 816 | } |
817 | 817 | ||
818 | void FileBrowser::init(const QString & dir) | 818 | void FileBrowser::init(const QString & dir) |
819 | { | 819 | { |
820 | setCaption( tr("File Manager") ); | 820 | setCaption( tr("File Manager") ); |
821 | setIcon( Resource::loadPixmap( "filebrowser_icon" ) ); | 821 | setIcon( Resource::loadPixmap( "filebrowser_icon" ) ); |
822 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 822 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
823 | 823 | ||
824 | 824 | ||
825 | Config cfg("Filebrowser"); | 825 | Config cfg("Filebrowser"); |
826 | cfg.setGroup("View"); | 826 | cfg.setGroup("View"); |
827 | bool showHidden=(cfg.readEntry("Hidden","FALSE") == "TRUE"); | 827 | bool showHidden=(cfg.readEntry("Hidden","FALSE") == "TRUE"); |
828 | bool showSymlinks=(cfg.readEntry("Symlinks","FALSE") == "TRUE"); | 828 | bool showSymlinks=(cfg.readEntry("Symlinks","FALSE") == "TRUE"); |
829 | bool showThumbnails=(cfg.readEntry("Thumbnails","FALSE") == "TRUE"); | 829 | bool showThumbnails=(cfg.readEntry("Thumbnails","FALSE") == "TRUE"); |
830 | 830 | ||
831 | cfg.setGroup("Menu"); | 831 | cfg.setGroup("Menu"); |
832 | bool menuKeepsOpen=(cfg.readEntry("KeepOpen", "FALSE") == "TRUE"); | 832 | bool menuKeepsOpen=(cfg.readEntry("KeepOpen", "FALSE") == "TRUE"); |
833 | 833 | ||
834 | 834 | ||
835 | fileView = new FileView( dir, this, 0, showHidden, showSymlinks, showThumbnails ); | 835 | fileView = new FileView( dir, this, 0, showHidden, showSymlinks, showThumbnails ); |
836 | fileView->setAllColumnsShowFocus( TRUE ); | 836 | fileView->setAllColumnsShowFocus( TRUE ); |
837 | fileView->setMenuKeepsOpen(menuKeepsOpen); | 837 | fileView->setMenuKeepsOpen(menuKeepsOpen); |
838 | 838 | ||
839 | setCentralWidget( fileView ); | 839 | setCentralWidget( fileView ); |
840 | setToolBarsMovable( FALSE ); | 840 | setToolBarsMovable( FALSE ); |
841 | 841 | ||
842 | QToolBar* toolBar = new QToolBar( this ); | 842 | QToolBar* toolBar = new QToolBar( this ); |
843 | toolBar->setHorizontalStretchable( TRUE ); | 843 | toolBar->setHorizontalStretchable( TRUE ); |
844 | 844 | ||
845 | QMenuBar* menuBar = new QMenuBar( toolBar ); | 845 | QMenuBar* menuBar = new QMenuBar( toolBar ); |
846 | 846 | ||
847 | dirMenu = new QPopupMenu( this ); | 847 | dirMenu = new QPopupMenu( this ); |
848 | menuBar->insertItem( tr( "Dir" ), dirMenu ); | 848 | menuBar->insertItem( tr( "Dir" ), dirMenu ); |
849 | 849 | ||
850 | sortMenu = new QPopupMenu( this ); | 850 | sortMenu = new QPopupMenu( this ); |
851 | menuBar->insertItem( tr( "Sort" ), sortMenu ); | 851 | menuBar->insertItem( tr( "Sort" ), sortMenu ); |
852 | sortMenu->insertItem( tr( "by Name "), this, SLOT( sortName() ) ); | 852 | sortMenu->insertItem( tr( "by Name "), this, SLOT( sortName() ) ); |
853 | sortMenu->insertItem( tr( "by Size "), this, SLOT( sortSize() ) ); | 853 | sortMenu->insertItem( tr( "by Size "), this, SLOT( sortSize() ) ); |
854 | sortMenu->insertItem( tr( "by Date "), this, SLOT( sortDate() ) ); | 854 | sortMenu->insertItem( tr( "by Date "), this, SLOT( sortDate() ) ); |
855 | sortMenu->insertItem( tr( "by Type "), this, SLOT( sortType() ) ); | 855 | sortMenu->insertItem( tr( "by Type "), this, SLOT( sortType() ) ); |
856 | sortMenu->insertSeparator(); | 856 | sortMenu->insertSeparator(); |
857 | sortMenu->insertItem( tr( "Ascending" ), this, SLOT( updateSorting() ) ); | 857 | sortMenu->insertItem( tr( "Ascending" ), this, SLOT( updateSorting() ) ); |
858 | 858 | ||
859 | sortMenu->setItemChecked( sortMenu->idAt( 5 ), TRUE ); | 859 | sortMenu->setItemChecked( sortMenu->idAt( 5 ), TRUE ); |
860 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); | 860 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); |
861 | 861 | ||
862 | viewMenu = new QPopupMenu( this); | 862 | viewMenu = new QPopupMenu( this); |
863 | viewMenu->insertItem( tr( "Hidden"), this, SLOT( updateShowHidden() ) ); | 863 | viewMenu->insertItem( tr( "Hidden"), this, SLOT( updateShowHidden() ) ); |
864 | viewMenu->insertItem( tr( "Symlinks"), this, SLOT( updateShowSymlinks() ) ); | 864 | viewMenu->insertItem( tr( "Symlinks"), this, SLOT( updateShowSymlinks() ) ); |
865 | viewMenu->insertItem( tr( "Thumbnails"), this, SLOT( updateShowThumbnails() ) ); | 865 | viewMenu->insertItem( tr( "Thumbnails"), this, SLOT( updateShowThumbnails() ) ); |
866 | viewMenu->setItemChecked( viewMenu->idAt( 0 ), showHidden ); | 866 | viewMenu->setItemChecked( viewMenu->idAt( 0 ), showHidden ); |
867 | viewMenu->setItemChecked( viewMenu->idAt( 1 ), showSymlinks ); | 867 | viewMenu->setItemChecked( viewMenu->idAt( 1 ), showSymlinks ); |
868 | viewMenu->setItemChecked( viewMenu->idAt( 2 ), showThumbnails ); | 868 | viewMenu->setItemChecked( viewMenu->idAt( 2 ), showThumbnails ); |
869 | 869 | ||
870 | menuBar->insertItem( tr("View"), viewMenu ); | 870 | menuBar->insertItem( tr("View"), viewMenu ); |
871 | 871 | ||
872 | toolBar = new QToolBar( this ); | 872 | toolBar = new QToolBar( this ); |
873 | 873 | ||
874 | lastAction = new QAction( tr("Previous dir"), Resource::loadIconSet( "back" ), | 874 | lastAction = new QAction( tr("Previous dir"), Resource::loadIconSet( "back" ), |
875 | QString::null, 0, this, 0 ); | 875 | QString::null, 0, this, 0 ); |
876 | connect( lastAction, SIGNAL( activated() ), fileView, SLOT( lastDir() ) ); | 876 | connect( lastAction, SIGNAL( activated() ), fileView, SLOT( lastDir() ) ); |
877 | lastAction->addTo( toolBar ); | 877 | lastAction->addTo( toolBar ); |
878 | lastAction->setEnabled( FALSE ); | 878 | lastAction->setEnabled( FALSE ); |
879 | 879 | ||
880 | upAction = new QAction( tr("Parent dir"), Resource::loadIconSet( "up" ), | 880 | upAction = new QAction( tr("Parent dir"), Resource::loadIconSet( "up" ), |
881 | QString::null, 0, this, 0 ); | 881 | QString::null, 0, this, 0 ); |
882 | connect( upAction, SIGNAL( activated() ), fileView, SLOT( parentDir() ) ); | 882 | connect( upAction, SIGNAL( activated() ), fileView, SLOT( parentDir() ) ); |
883 | upAction->addTo( toolBar ); | 883 | upAction->addTo( toolBar ); |
884 | 884 | ||
885 | QAction *a = new QAction( tr("New folder"), Resource::loadPixmap( "newfolder" ), | 885 | QAction *a = new QAction( tr("New folder"), Resource::loadPixmap( "newfolder" ), |
886 | QString::null, 0, this, 0 ); | 886 | QString::null, 0, this, 0 ); |
887 | connect( a, SIGNAL( activated() ), fileView, SLOT( newFolder() ) ); | 887 | connect( a, SIGNAL( activated() ), fileView, SLOT( newFolder() ) ); |
888 | a->addTo( toolBar ); | 888 | a->addTo( toolBar ); |
889 | 889 | ||
890 | a = new QAction( tr("Cut"), Resource::loadPixmap( "cut" ), | 890 | a = new QAction( tr("Cut"), Resource::loadPixmap( "cut" ), |
891 | QString::null, 0, this, 0 ); | 891 | QString::null, 0, this, 0 ); |
892 | connect( a, SIGNAL( activated() ), fileView, SLOT( cut() ) ); | 892 | connect( a, SIGNAL( activated() ), fileView, SLOT( cut() ) ); |
893 | a->addTo( toolBar ); | 893 | a->addTo( toolBar ); |
894 | 894 | ||
895 | a = new QAction( tr("Copy"), Resource::loadPixmap( "copy" ), | 895 | a = new QAction( tr("Copy"), Resource::loadPixmap( "copy" ), |
896 | QString::null, 0, this, 0 ); | 896 | QString::null, 0, this, 0 ); |
897 | connect( a, SIGNAL( activated() ), fileView, SLOT( copy() ) ); | 897 | connect( a, SIGNAL( activated() ), fileView, SLOT( copy() ) ); |
898 | a->addTo( toolBar ); | 898 | a->addTo( toolBar ); |
899 | 899 | ||
900 | pasteAction = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), | 900 | pasteAction = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), |
901 | QString::null, 0, this, 0 ); | 901 | QString::null, 0, this, 0 ); |
902 | connect( pasteAction, SIGNAL( activated() ), fileView, SLOT( paste() ) ); | 902 | connect( pasteAction, SIGNAL( activated() ), fileView, SLOT( paste() ) ); |
903 | pasteAction->addTo( toolBar ); | 903 | pasteAction->addTo( toolBar ); |
904 | 904 | ||
905 | // dirLabel = new QLabel(this, "DirLabel"); | 905 | // dirLabel = new QLabel(this, "DirLabel"); |
906 | 906 | ||
907 | connect( fileView, SIGNAL( dirChanged() ), SLOT( updateDirMenu() ) ); | 907 | connect( fileView, SIGNAL( dirChanged() ), SLOT( updateDirMenu() ) ); |
908 | updateDirMenu(); | 908 | updateDirMenu(); |
909 | 909 | ||
910 | QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 910 | QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); |
911 | connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 911 | connect( pcmciaChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
912 | this, SLOT(pcmciaMessage( const QCString &, const QByteArray &)) ); | 912 | this, SLOT(pcmciaMessage(const QCString&,const QByteArray&)) ); |
913 | } | 913 | } |
914 | 914 | ||
915 | void FileBrowser::pcmciaMessage( const QCString &msg, const QByteArray &) | 915 | void FileBrowser::pcmciaMessage( const QCString &msg, const QByteArray &) |
916 | { | 916 | { |
917 | if ( msg == "mtabChanged()" ) { | 917 | if ( msg == "mtabChanged()" ) { |
918 | // ## Only really needed if current dir is on a card | 918 | // ## Only really needed if current dir is on a card |
919 | fileView->updateDir(); | 919 | fileView->updateDir(); |
920 | } | 920 | } |
921 | } | 921 | } |
922 | 922 | ||
923 | void FileBrowser::changeCaption(const QString & dir) { | 923 | void FileBrowser::changeCaption(const QString & dir) { |
924 | setCaption( dir); | 924 | setCaption( dir); |
925 | } | 925 | } |
926 | 926 | ||
927 | void FileBrowser::dirSelected( int id ) | 927 | void FileBrowser::dirSelected( int id ) |
928 | { | 928 | { |
929 | int i = 0, j; | 929 | int i = 0, j; |
930 | QString dir; | 930 | QString dir; |
931 | 931 | ||
932 | // Bulid target dir from menu | 932 | // Bulid target dir from menu |
933 | while( (j = dirMenu->idAt( i )) != id ){ | 933 | while( (j = dirMenu->idAt( i )) != id ){ |
934 | dir += dirMenu->text( j ).stripWhiteSpace(); | 934 | dir += dirMenu->text( j ).stripWhiteSpace(); |
935 | if( dirMenu->text( j ) != "/" ) dir += "/"; | 935 | if( dirMenu->text( j ) != "/" ) dir += "/"; |
936 | i++; | 936 | i++; |
937 | } | 937 | } |
938 | dir += dirMenu->text( dirMenu->idAt( i ) ).stripWhiteSpace(); | 938 | dir += dirMenu->text( dirMenu->idAt( i ) ).stripWhiteSpace(); |
939 | 939 | ||
940 | fileView->setDir( dir ); | 940 | fileView->setDir( dir ); |
941 | } | 941 | } |
942 | 942 | ||
943 | void FileBrowser::updateDirMenu() | 943 | void FileBrowser::updateDirMenu() |
944 | { | 944 | { |
945 | QString spc, cd = fileView->cd(); | 945 | QString spc, cd = fileView->cd(); |
946 | QStringList l = QStringList::split( "/", cd ); | 946 | QStringList l = QStringList::split( "/", cd ); |
947 | int i = 0; | 947 | int i = 0; |
948 | 948 | ||
949 | dirMenu->clear(); | 949 | dirMenu->clear(); |
950 | dirMenu->insertItem( tr( "/" ), this, SLOT( dirSelected(int) ) ); | 950 | dirMenu->insertItem( tr( "/" ), this, SLOT( dirSelected(int) ) ); |
951 | 951 | ||
952 | for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) { | 952 | for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) { |
953 | spc.fill( ' ', i++); | 953 | spc.fill( ' ', i++); |
954 | dirMenu->insertItem( spc + (*it), this, | 954 | dirMenu->insertItem( spc + (*it), this, |
955 | SLOT( dirSelected(int) ) ); | 955 | SLOT( dirSelected(int) ) ); |
956 | } | 956 | } |
957 | dirMenu->setItemChecked( dirMenu->idAt( l.count() ), TRUE ); | 957 | dirMenu->setItemChecked( dirMenu->idAt( l.count() ), TRUE ); |
958 | 958 | ||
959 | lastAction->setEnabled( fileView->history().count() != 0 ); | 959 | lastAction->setEnabled( fileView->history().count() != 0 ); |
960 | upAction->setEnabled( cd != "/" ); | 960 | upAction->setEnabled( cd != "/" ); |
961 | } | 961 | } |
962 | 962 | ||
963 | void FileBrowser::sortName() | 963 | void FileBrowser::sortName() |
964 | { | 964 | { |
965 | fileView->setSorting( 0, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); | 965 | fileView->setSorting( 0, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); |
966 | fileView->sort(); | 966 | fileView->sort(); |
967 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); | 967 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), TRUE ); |
968 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); | 968 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); |
969 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); | 969 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); |
970 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); | 970 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); |
971 | } | 971 | } |
972 | 972 | ||
973 | void FileBrowser::sortSize() | 973 | void FileBrowser::sortSize() |
974 | { | 974 | { |
975 | fileView->setSorting( 1, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); | 975 | fileView->setSorting( 1, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); |
976 | fileView->sort(); | 976 | fileView->sort(); |
977 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); | 977 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); |
978 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), TRUE ); | 978 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), TRUE ); |
979 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); | 979 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); |
980 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); | 980 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); |
981 | } | 981 | } |
982 | 982 | ||
983 | void FileBrowser::sortDate() | 983 | void FileBrowser::sortDate() |
984 | { | 984 | { |
985 | fileView->setSorting( 2, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); | 985 | fileView->setSorting( 2, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); |
986 | fileView->sort(); | 986 | fileView->sort(); |
987 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); | 987 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); |
988 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); | 988 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); |
989 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), TRUE ); | 989 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), TRUE ); |
990 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); | 990 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), FALSE ); |
991 | } | 991 | } |
992 | 992 | ||
993 | void FileBrowser::sortType() | 993 | void FileBrowser::sortType() |
994 | { | 994 | { |
995 | fileView->setSorting( 3, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); | 995 | fileView->setSorting( 3, sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); |
996 | fileView->sort(); | 996 | fileView->sort(); |
997 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); | 997 | sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); |
998 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); | 998 | sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); |
999 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); | 999 | sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); |
1000 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), TRUE ); | 1000 | sortMenu->setItemChecked( sortMenu->idAt( 3 ), TRUE ); |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | void FileBrowser::updateSorting() | 1003 | void FileBrowser::updateSorting() |
1004 | { | 1004 | { |
1005 | sortMenu->setItemChecked( sortMenu->idAt( 5 ), !sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); | 1005 | sortMenu->setItemChecked( sortMenu->idAt( 5 ), !sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); |
1006 | 1006 | ||
1007 | if ( sortMenu->isItemChecked( sortMenu->idAt( 0 ) ) ) | 1007 | if ( sortMenu->isItemChecked( sortMenu->idAt( 0 ) ) ) |
1008 | sortName(); | 1008 | sortName(); |
diff --git a/noncore/unsupported/gsmtool/gsmtool.cpp b/noncore/unsupported/gsmtool/gsmtool.cpp index 5940b0e..47920e5 100644 --- a/noncore/unsupported/gsmtool/gsmtool.cpp +++ b/noncore/unsupported/gsmtool/gsmtool.cpp | |||
@@ -1,139 +1,139 @@ | |||
1 | #include "gsmtool.h" | 1 | #include "gsmtool.h" |
2 | #include <qpushbutton.h> | 2 | #include <qpushbutton.h> |
3 | #include <qcombobox.h> | 3 | #include <qcombobox.h> |
4 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qtabwidget.h> | 6 | #include <qtabwidget.h> |
7 | #include <qlistview.h> | 7 | #include <qlistview.h> |
8 | #include <qtextbrowser.h> | 8 | #include <qtextbrowser.h> |
9 | #include <qmultilineedit.h> | 9 | #include <qmultilineedit.h> |
10 | 10 | ||
11 | #include <termios.h> | 11 | #include <termios.h> |
12 | 12 | ||
13 | #include <gsmlib/gsm_me_ta.h> | 13 | #include <gsmlib/gsm_me_ta.h> |
14 | #include <gsmlib/gsm_unix_serial.h> | 14 | #include <gsmlib/gsm_unix_serial.h> |
15 | #include <gsmlib/gsm_sms.h> | 15 | #include <gsmlib/gsm_sms.h> |
16 | #include <gsmlib/gsm_sorted_sms_store.h> | 16 | #include <gsmlib/gsm_sorted_sms_store.h> |
17 | 17 | ||
18 | using namespace gsmlib; | 18 | using namespace gsmlib; |
19 | 19 | ||
20 | 20 | ||
21 | /* | 21 | /* |
22 | * Constructs a GSMTool which is a child of 'parent', with the | 22 | * Constructs a GSMTool which is a child of 'parent', with the |
23 | * name 'name' and widget flags set to 'f' | 23 | * name 'name' and widget flags set to 'f' |
24 | */ | 24 | */ |
25 | GSMTool::GSMTool( QWidget* parent, const char* name, WFlags fl ) | 25 | GSMTool::GSMTool( QWidget* parent, const char* name, WFlags fl ) |
26 | : GSMToolBase( parent, name, fl ) | 26 | : GSMToolBase( parent, name, fl ) |
27 | { | 27 | { |
28 | devicelocked = 0; | 28 | devicelocked = 0; |
29 | me = NULL; | 29 | me = NULL; |
30 | sms_store = NULL; | 30 | sms_store = NULL; |
31 | setConnected(FALSE); | 31 | setConnected(FALSE); |
32 | /* FIXME: Persistent settings for device/baudrate */ | 32 | /* FIXME: Persistent settings for device/baudrate */ |
33 | connect(ConnectButton, SIGNAL(clicked()), this, SLOT(doConnectButton())); | 33 | connect(ConnectButton, SIGNAL(clicked()), this, SLOT(doConnectButton())); |
34 | connect(SMSDeleteButton, SIGNAL(clicked()), this, SLOT(doSMSDeleteButton())); | 34 | connect(SMSDeleteButton, SIGNAL(clicked()), this, SLOT(doSMSDeleteButton())); |
35 | connect(SMSSendButton, SIGNAL(clicked()), this, SLOT(doSMSSendButton())); | 35 | connect(SMSSendButton, SIGNAL(clicked()), this, SLOT(doSMSSendButton())); |
36 | connect(NewSMSClearButton, SIGNAL(clicked()), this, SLOT(doNewSMSClearButton())); | 36 | connect(NewSMSClearButton, SIGNAL(clicked()), this, SLOT(doNewSMSClearButton())); |
37 | connect(NewSMSSaveButton, SIGNAL(clicked()), this, SLOT(doNewSMSSaveButton())); | 37 | connect(NewSMSSaveButton, SIGNAL(clicked()), this, SLOT(doNewSMSSaveButton())); |
38 | connect(NewSMSSendButton, SIGNAL(clicked()), this, SLOT(doNewSMSSendButton())); | 38 | connect(NewSMSSendButton, SIGNAL(clicked()), this, SLOT(doNewSMSSendButton())); |
39 | connect(ScanButton, SIGNAL(clicked()), this, SLOT(doScanButton())); | 39 | connect(ScanButton, SIGNAL(clicked()), this, SLOT(doScanButton())); |
40 | connect(TabWidget2, SIGNAL(currentChanged(QWidget *)), this, SLOT(doTabChanged())); | 40 | connect(TabWidget2, SIGNAL(currentChanged(QWidget*)), this, SLOT(doTabChanged())); |
41 | connect(SMSStoreList, SIGNAL(activated(int)), this, SLOT(doSMSStoreChanged())); | 41 | connect(SMSStoreList, SIGNAL(activated(int)), this, SLOT(doSMSStoreChanged())); |
42 | connect(SMSViewType, SIGNAL(activated(int)), this, SLOT(doSMSTypeChanged())); | 42 | connect(SMSViewType, SIGNAL(activated(int)), this, SLOT(doSMSTypeChanged())); |
43 | connect(SMSList, SIGNAL(selectionChanged(QListViewItem *)), this, SLOT(doSelectedSMSChanged(QListViewItem *))); | 43 | connect(SMSList, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(doSelectedSMSChanged(QListViewItem*))); |
44 | timerid = -1; // Is this not possible normally? | 44 | timerid = -1; // Is this not possible normally? |
45 | } | 45 | } |
46 | 46 | ||
47 | /* | 47 | /* |
48 | * Destroys the object and frees any allocated resources | 48 | * Destroys the object and frees any allocated resources |
49 | */ | 49 | */ |
50 | GSMTool::~GSMTool() | 50 | GSMTool::~GSMTool() |
51 | { | 51 | { |
52 | // no need to delete child widgets, Qt does it all for us | 52 | // no need to delete child widgets, Qt does it all for us |
53 | if (devicelocked) | 53 | if (devicelocked) |
54 | unlockDevice(); | 54 | unlockDevice(); |
55 | } | 55 | } |
56 | const speed_t GSMTool::baudrates[12] = { | 56 | const speed_t GSMTool::baudrates[12] = { |
57 | B300, B600, B1200, B2400, B4800, B9600, B19200, | 57 | B300, B600, B1200, B2400, B4800, B9600, B19200, |
58 | B38400, B57600, B115200, B230400, B460800 | 58 | B38400, B57600, B115200, B230400, B460800 |
59 | }; | 59 | }; |
60 | 60 | ||
61 | int GSMTool::lockDevice( ) | 61 | int GSMTool::lockDevice( ) |
62 | { | 62 | { |
63 | devicelocked = 1; | 63 | devicelocked = 1; |
64 | /* FIXME */ | 64 | /* FIXME */ |
65 | return 0; | 65 | return 0; |
66 | } | 66 | } |
67 | 67 | ||
68 | void GSMTool::unlockDevice( ) | 68 | void GSMTool::unlockDevice( ) |
69 | { | 69 | { |
70 | devicelocked = 0; | 70 | devicelocked = 0; |
71 | } | 71 | } |
72 | 72 | ||
73 | void GSMTool::setConnected( bool conn ) | 73 | void GSMTool::setConnected( bool conn ) |
74 | { | 74 | { |
75 | TabWidget2->setTabEnabled(tab_2, conn); | 75 | TabWidget2->setTabEnabled(tab_2, conn); |
76 | TabWidget2->setTabEnabled(tab_3, conn); | 76 | TabWidget2->setTabEnabled(tab_3, conn); |
77 | //TabWidget2->setTabEnabled(tab_4, conn); | 77 | //TabWidget2->setTabEnabled(tab_4, conn); |
78 | NewSMSSendButton->setEnabled(conn); | 78 | NewSMSSendButton->setEnabled(conn); |
79 | MfrLabel->setEnabled(conn); | 79 | MfrLabel->setEnabled(conn); |
80 | MfrText->setEnabled(conn); | 80 | MfrText->setEnabled(conn); |
81 | ModelLabel->setEnabled(conn); | 81 | ModelLabel->setEnabled(conn); |
82 | ModelText->setEnabled(conn); | 82 | ModelText->setEnabled(conn); |
83 | RevisionLabel->setEnabled(conn); | 83 | RevisionLabel->setEnabled(conn); |
84 | RevisionText->setEnabled(conn); | 84 | RevisionText->setEnabled(conn); |
85 | SerialLabel->setEnabled(conn); | 85 | SerialLabel->setEnabled(conn); |
86 | SerialText->setEnabled(conn); | 86 | SerialText->setEnabled(conn); |
87 | 87 | ||
88 | } | 88 | } |
89 | void GSMTool::doTabChanged() | 89 | void GSMTool::doTabChanged() |
90 | { | 90 | { |
91 | int index = TabWidget2->currentPageIndex(); | 91 | int index = TabWidget2->currentPageIndex(); |
92 | qDebug("tab changed to %d", index); | 92 | qDebug("tab changed to %d", index); |
93 | 93 | ||
94 | if (index == 1) { | 94 | if (index == 1) { |
95 | timerid = startTimer(5000); | 95 | timerid = startTimer(5000); |
96 | timerEvent(NULL); | 96 | timerEvent(NULL); |
97 | } else if (timerid != -1) { | 97 | } else if (timerid != -1) { |
98 | killTimer(timerid); | 98 | killTimer(timerid); |
99 | timerid = -1; | 99 | timerid = -1; |
100 | } | 100 | } |
101 | } | 101 | } |
102 | 102 | ||
103 | void GSMTool::timerEvent( QTimerEvent * ) | 103 | void GSMTool::timerEvent( QTimerEvent * ) |
104 | { | 104 | { |
105 | OPInfo opi; | 105 | OPInfo opi; |
106 | 106 | ||
107 | opi = me->getCurrentOPInfo(); | 107 | opi = me->getCurrentOPInfo(); |
108 | 108 | ||
109 | if (opi._numericName == NOT_SET) { | 109 | if (opi._numericName == NOT_SET) { |
110 | NetStatText->setText("No network"); | 110 | NetStatText->setText("No network"); |
111 | NetworkLabel->setEnabled(FALSE); | 111 | NetworkLabel->setEnabled(FALSE); |
112 | NetworkText->setEnabled(FALSE); | 112 | NetworkText->setEnabled(FALSE); |
113 | NetworkText->setText(""); | 113 | NetworkText->setText(""); |
114 | SigStrText->setEnabled(FALSE); | 114 | SigStrText->setEnabled(FALSE); |
115 | SigStrText->setText(""); | 115 | SigStrText->setText(""); |
116 | dB->setEnabled(FALSE); | 116 | dB->setEnabled(FALSE); |
117 | SigStrLabel->setEnabled(FALSE); | 117 | SigStrLabel->setEnabled(FALSE); |
118 | } else { | 118 | } else { |
119 | // FIXME: Add 'roaming' info from AT+CFUN | 119 | // FIXME: Add 'roaming' info from AT+CFUN |
120 | qDebug("network"); | 120 | qDebug("network"); |
121 | NetStatText->setText("Registered"); | 121 | NetStatText->setText("Registered"); |
122 | NetworkLabel->setEnabled(TRUE); | 122 | NetworkLabel->setEnabled(TRUE); |
123 | NetworkText->setEnabled(TRUE); | 123 | NetworkText->setEnabled(TRUE); |
124 | NetworkText->setText(opi._longName.c_str()); | 124 | NetworkText->setText(opi._longName.c_str()); |
125 | SigStrText->setEnabled(TRUE); | 125 | SigStrText->setEnabled(TRUE); |
126 | 126 | ||
127 | qDebug("get sig str"); | 127 | qDebug("get sig str"); |
128 | int csq = me->getSignalStrength(); | 128 | int csq = me->getSignalStrength(); |
129 | if (csq == 0) { | 129 | if (csq == 0) { |
130 | SigStrText->setText("<= -113"); | 130 | SigStrText->setText("<= -113"); |
131 | dB->setEnabled(TRUE); | 131 | dB->setEnabled(TRUE); |
132 | SigStrLabel->setEnabled(TRUE); | 132 | SigStrLabel->setEnabled(TRUE); |
133 | } else if (csq == 99) { | 133 | } else if (csq == 99) { |
134 | SigStrText->setText("Unknown"); | 134 | SigStrText->setText("Unknown"); |
135 | dB->setEnabled(FALSE); | 135 | dB->setEnabled(FALSE); |
136 | SigStrLabel->setEnabled(FALSE); | 136 | SigStrLabel->setEnabled(FALSE); |
137 | } else { | 137 | } else { |
138 | char buf[6]; | 138 | char buf[6]; |
139 | sprintf(buf, "%d", -113 + (2*csq)); | 139 | sprintf(buf, "%d", -113 + (2*csq)); |
diff --git a/noncore/unsupported/mail2/bend/bend.cpp b/noncore/unsupported/mail2/bend/bend.cpp index e2ece2a..ab6eb45 100644 --- a/noncore/unsupported/mail2/bend/bend.cpp +++ b/noncore/unsupported/mail2/bend/bend.cpp | |||
@@ -1,124 +1,124 @@ | |||
1 | #include <qlayout.h> | 1 | #include <qlayout.h> |
2 | #include <qpixmap.h> | 2 | #include <qpixmap.h> |
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | #include <qsound.h> | 4 | #include <qsound.h> |
5 | #include <qtimer.h> | 5 | #include <qtimer.h> |
6 | #include <qdir.h> | 6 | #include <qdir.h> |
7 | 7 | ||
8 | #include <qpe/qcopenvelope_qws.h> | 8 | #include <qpe/qcopenvelope_qws.h> |
9 | #include <qpe/resource.h> | 9 | #include <qpe/resource.h> |
10 | #include <qpe/config.h> | 10 | #include <qpe/config.h> |
11 | 11 | ||
12 | #include <opie/odevice.h> | 12 | #include <opie/odevice.h> |
13 | 13 | ||
14 | #include "imapresponse.h" | 14 | #include "imapresponse.h" |
15 | #include "imaphandler.h" | 15 | #include "imaphandler.h" |
16 | #include "configfile.h" | 16 | #include "configfile.h" |
17 | #include "bend.h" | 17 | #include "bend.h" |
18 | 18 | ||
19 | using namespace Opie; | 19 | using namespace Opie; |
20 | 20 | ||
21 | BenD::BenD(QWidget *parent, const char *name, WFlags fl) | 21 | BenD::BenD(QWidget *parent, const char *name, WFlags fl) |
22 | : QButton(parent, name, fl) | 22 | : QButton(parent, name, fl) |
23 | { | 23 | { |
24 | _config = new Config("mail"); | 24 | _config = new Config("mail"); |
25 | _config->setGroup("Settings"); | 25 | _config->setGroup("Settings"); |
26 | 26 | ||
27 | QVBoxLayout *layout = new QVBoxLayout(this); | 27 | QVBoxLayout *layout = new QVBoxLayout(this); |
28 | layout->addItem(new QSpacerItem(0,0)); | 28 | layout->addItem(new QSpacerItem(0,0)); |
29 | 29 | ||
30 | QLabel *pixmap = new QLabel(this); | 30 | QLabel *pixmap = new QLabel(this); |
31 | pixmap->setPixmap(Resource::loadPixmap("mail/mailchecker")); | 31 | pixmap->setPixmap(Resource::loadPixmap("mail/mailchecker")); |
32 | layout->addWidget(pixmap); | 32 | layout->addWidget(pixmap); |
33 | 33 | ||
34 | layout->addItem(new QSpacerItem(0,0)); | 34 | layout->addItem(new QSpacerItem(0,0)); |
35 | 35 | ||
36 | hide(); | 36 | hide(); |
37 | 37 | ||
38 | connect(this, SIGNAL(clicked()), SLOT(slotClicked())); | 38 | connect(this, SIGNAL(clicked()), SLOT(slotClicked())); |
39 | 39 | ||
40 | if (!_config->readBoolEntry("Disabled", false)) { | 40 | if (!_config->readBoolEntry("Disabled", false)) { |
41 | _intervalMs = _config->readNumEntry("CheckEvery", 5) * 60000; | 41 | _intervalMs = _config->readNumEntry("CheckEvery", 5) * 60000; |
42 | _intervalTimer = new QTimer(); | 42 | _intervalTimer = new QTimer(); |
43 | _intervalTimer->start(_intervalMs); | 43 | _intervalTimer->start(_intervalMs); |
44 | connect(_intervalTimer, SIGNAL(timeout()), SLOT(slotCheck())); | 44 | connect(_intervalTimer, SIGNAL(timeout()), SLOT(slotCheck())); |
45 | 45 | ||
46 | QTimer::singleShot(0, this, SLOT(slotCheck())); | 46 | QTimer::singleShot(0, this, SLOT(slotCheck())); |
47 | } | 47 | } |
48 | } | 48 | } |
49 | 49 | ||
50 | void BenD::drawButton(QPainter *) { } | 50 | void BenD::drawButton(QPainter *) { } |
51 | void BenD::drawButtonText(QPainter *) { } | 51 | void BenD::drawButtonText(QPainter *) { } |
52 | 52 | ||
53 | void BenD::slotClicked() | 53 | void BenD::slotClicked() |
54 | { | 54 | { |
55 | QCopEnvelope e("QPE/System", "execute(QString)"); | 55 | QCopEnvelope e("QPE/System", "execute(QString)"); |
56 | e << QString("mail"); | 56 | e << QString("mail"); |
57 | 57 | ||
58 | ODevice *device = ODevice::inst(); | 58 | ODevice *device = ODevice::inst(); |
59 | if ( !device-> ledList ( ). isEmpty ( )) { | 59 | if ( !device-> ledList ( ). isEmpty ( )) { |
60 | OLed led = ( device-> ledList ( ). contains ( Led_Mail )) ? Led_Mail : device-> ledList ( ) [0]; | 60 | OLed led = ( device-> ledList ( ). contains ( Led_Mail )) ? Led_Mail : device-> ledList ( ) [0]; |
61 | 61 | ||
62 | device->setLedState(led, Led_Off); | 62 | device->setLedState(led, Led_Off); |
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | void BenD::slotCheck() | 66 | void BenD::slotCheck() |
67 | { | 67 | { |
68 | // Check wether the check interval has been changed. | 68 | // Check wether the check interval has been changed. |
69 | int newIntervalMs = _config->readNumEntry("CheckEvery", 5) * 60000; | 69 | int newIntervalMs = _config->readNumEntry("CheckEvery", 5) * 60000; |
70 | if (newIntervalMs != _intervalMs) { | 70 | if (newIntervalMs != _intervalMs) { |
71 | _intervalTimer->changeInterval(newIntervalMs); | 71 | _intervalTimer->changeInterval(newIntervalMs); |
72 | _intervalMs = newIntervalMs; | 72 | _intervalMs = newIntervalMs; |
73 | #ifndef QT_NO_DEBUG | 73 | #ifndef QT_NO_DEBUG |
74 | qWarning("BenD: Detected interval change"); | 74 | qWarning("BenD: Detected interval change"); |
75 | #endif | 75 | #endif |
76 | } | 76 | } |
77 | 77 | ||
78 | QValueList<Account> acList = ConfigFile::getAccounts(); | 78 | QValueList<Account> acList = ConfigFile::getAccounts(); |
79 | QValueList<Account>::Iterator ot; | 79 | QValueList<Account>::Iterator ot; |
80 | for (ot = acList.begin(); ot != acList.end(); ot++) { | 80 | for (ot = acList.begin(); ot != acList.end(); ot++) { |
81 | if (!((*ot).imapServer().isEmpty() || | 81 | if (!((*ot).imapServer().isEmpty() || |
82 | (*ot).imapPort().isEmpty() || | 82 | (*ot).imapPort().isEmpty() || |
83 | (*ot).user().isEmpty() || | 83 | (*ot).user().isEmpty() || |
84 | (*ot).pass().isEmpty())) { | 84 | (*ot).pass().isEmpty())) { |
85 | if (!((*ot).imapSsl() && | 85 | if (!((*ot).imapSsl() && |
86 | (*ot).imapSslPort().isEmpty())) { | 86 | (*ot).imapSslPort().isEmpty())) { |
87 | IMAPHandler *handler = new IMAPHandler(*ot); | 87 | IMAPHandler *handler = new IMAPHandler(*ot); |
88 | handler->iStatus("INBOX", "RECENT"); | 88 | handler->iStatus("INBOX", "RECENT"); |
89 | connect(handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPStatus(IMAPResponse &))); | 89 | connect(handler, SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPStatus(IMAPResponse&))); |
90 | } | 90 | } |
91 | } | 91 | } |
92 | } | 92 | } |
93 | } | 93 | } |
94 | 94 | ||
95 | void BenD::slotIMAPStatus(IMAPResponse &response) | 95 | void BenD::slotIMAPStatus(IMAPResponse &response) |
96 | { | 96 | { |
97 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPStatus(IMAPResponse &))); | 97 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPStatus(IMAPResponse&))); |
98 | 98 | ||
99 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 99 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
100 | if (response.STATUS()[0].recent().toInt() > 0) { | 100 | if (response.STATUS()[0].recent().toInt() > 0) { |
101 | ODevice *device = ODevice::inst(); | 101 | ODevice *device = ODevice::inst(); |
102 | if (isHidden()) show(); | 102 | if (isHidden()) show(); |
103 | if (_config->readBoolEntry("BlinkLed", true)) { | 103 | if (_config->readBoolEntry("BlinkLed", true)) { |
104 | if ( !device-> ledList ( ). isEmpty ( )) { | 104 | if ( !device-> ledList ( ). isEmpty ( )) { |
105 | OLed led = ( device-> ledList ( ). contains ( Led_Mail )) ? Led_Mail : device-> ledList ( ) [0]; | 105 | OLed led = ( device-> ledList ( ). contains ( Led_Mail )) ? Led_Mail : device-> ledList ( ) [0]; |
106 | 106 | ||
107 | device->setLedState(led, device-> ledStateList ( led ). contains ( Led_BlinkSlow ) ? Led_BlinkSlow : Led_On ); | 107 | device->setLedState(led, device-> ledStateList ( led ). contains ( Led_BlinkSlow ) ? Led_BlinkSlow : Led_On ); |
108 | } | 108 | } |
109 | } | 109 | } |
110 | if (_config->readBoolEntry("PlaySound", false)) | 110 | if (_config->readBoolEntry("PlaySound", false)) |
111 | device->alarmSound(); | 111 | device->alarmSound(); |
112 | } else { | 112 | } else { |
113 | ODevice *device = ODevice::inst(); | 113 | ODevice *device = ODevice::inst(); |
114 | if (!isHidden()) hide(); | 114 | if (!isHidden()) hide(); |
115 | if ( !device-> ledList ( ). isEmpty ( )) { | 115 | if ( !device-> ledList ( ). isEmpty ( )) { |
116 | OLed led = ( device-> ledList ( ). contains ( Led_Mail )) ? Led_Mail : device-> ledList ( ) [0]; | 116 | OLed led = ( device-> ledList ( ). contains ( Led_Mail )) ? Led_Mail : device-> ledList ( ) [0]; |
117 | 117 | ||
118 | device->setLedState(led, Led_Off); | 118 | device->setLedState(led, Led_Off); |
119 | } | 119 | } |
120 | } | 120 | } |
121 | response.imapHandler()->iLogout(); | 121 | response.imapHandler()->iLogout(); |
122 | } else qWarning("BenD: WARNING: Couldn't retrieve INBOX status."); | 122 | } else qWarning("BenD: WARNING: Couldn't retrieve INBOX status."); |
123 | } | 123 | } |
124 | 124 | ||
diff --git a/noncore/unsupported/mail2/composer.cpp b/noncore/unsupported/mail2/composer.cpp index cb80299..da1aee9 100644 --- a/noncore/unsupported/mail2/composer.cpp +++ b/noncore/unsupported/mail2/composer.cpp | |||
@@ -65,283 +65,283 @@ void Composer::hide() | |||
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | void Composer::exec() | 68 | void Composer::exec() |
69 | { | 69 | { |
70 | show(); | 70 | show(); |
71 | if (!_inLoop) { | 71 | if (!_inLoop) { |
72 | _inLoop = true; | 72 | _inLoop = true; |
73 | qApp->enter_loop(); | 73 | qApp->enter_loop(); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | void Composer::setSendMail(SendMail &sendMail) | 77 | void Composer::setSendMail(SendMail &sendMail) |
78 | { | 78 | { |
79 | to->setText(sendMail.to()); | 79 | to->setText(sendMail.to()); |
80 | cc->setText(sendMail.cc()); | 80 | cc->setText(sendMail.cc()); |
81 | bcc->setText(sendMail.bcc()); | 81 | bcc->setText(sendMail.bcc()); |
82 | subject->setText(sendMail.subject()); | 82 | subject->setText(sendMail.subject()); |
83 | message->setText(sendMail.message()); | 83 | message->setText(sendMail.message()); |
84 | _inReplyTo = sendMail.inReplyTo(); | 84 | _inReplyTo = sendMail.inReplyTo(); |
85 | 85 | ||
86 | QValueList<Attachment> attachments = sendMail.attachments(); | 86 | QValueList<Attachment> attachments = sendMail.attachments(); |
87 | QValueList<Attachment>::Iterator it; | 87 | QValueList<Attachment>::Iterator it; |
88 | for (it = attachments.begin(); it != attachments.end(); it++) { | 88 | for (it = attachments.begin(); it != attachments.end(); it++) { |
89 | (void) new AttachViewItem(attachView, *it); | 89 | (void) new AttachViewItem(attachView, *it); |
90 | if (attachView->isHidden()) attachView->show(); | 90 | if (attachView->isHidden()) attachView->show(); |
91 | } | 91 | } |
92 | } | 92 | } |
93 | 93 | ||
94 | void Composer::slotResizing() | 94 | void Composer::slotResizing() |
95 | { | 95 | { |
96 | from->setMaximumWidth(width() - fromBox->width()); | 96 | from->setMaximumWidth(width() - fromBox->width()); |
97 | from->resize(width() - fromBox->width(), y()); | 97 | from->resize(width() - fromBox->width(), y()); |
98 | if (_sendQueued) slotSendQueued(); | 98 | if (_sendQueued) slotSendQueued(); |
99 | } | 99 | } |
100 | 100 | ||
101 | void Composer::slotPopupHandler(int itemid) | 101 | void Composer::slotPopupHandler(int itemid) |
102 | { | 102 | { |
103 | if (attachView->currentItem() == NULL) { | 103 | if (attachView->currentItem() == NULL) { |
104 | QMessageBox::information(this, tr("Error"), tr("Please select an entry first."), tr("Ok")); | 104 | QMessageBox::information(this, tr("Error"), tr("Please select an entry first."), tr("Ok")); |
105 | return; | 105 | return; |
106 | } | 106 | } |
107 | 107 | ||
108 | if (itemid == POPUP_ATTACH_RENAME) { | 108 | if (itemid == POPUP_ATTACH_RENAME) { |
109 | QString tmp = Rename::rename(attachView->currentItem()->text(0), this); | 109 | QString tmp = Rename::rename(attachView->currentItem()->text(0), this); |
110 | if (tmp != QString(0)) attachView->currentItem()->setText(0, tmp); | 110 | if (tmp != QString(0)) attachView->currentItem()->setText(0, tmp); |
111 | } else if (itemid == POPUP_ATTACH_DESC) { | 111 | } else if (itemid == POPUP_ATTACH_DESC) { |
112 | QString tmp = Rename::getText(tr("Set Description"), tr("<div align=center>Description"), this); | 112 | QString tmp = Rename::getText(tr("Set Description"), tr("<div align=center>Description"), this); |
113 | if (tmp != QString(0)) attachView->currentItem()->setText(1, tmp); | 113 | if (tmp != QString(0)) attachView->currentItem()->setText(1, tmp); |
114 | } else if (itemid == POPUP_ATTACH_REMOVE) { | 114 | } else if (itemid == POPUP_ATTACH_REMOVE) { |
115 | attachView->takeItem(attachView->currentItem()); | 115 | attachView->takeItem(attachView->currentItem()); |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | void Composer::slotSendMail() | 119 | void Composer::slotSendMail() |
120 | { | 120 | { |
121 | if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) { | 121 | if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) { |
122 | QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok")); | 122 | QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok")); |
123 | return; | 123 | return; |
124 | } | 124 | } |
125 | 125 | ||
126 | SendMail smail; | 126 | SendMail smail; |
127 | smail.setFrom(from->currentText()); | 127 | smail.setFrom(from->currentText()); |
128 | smail.setReplyTo(replyto->text()); | 128 | smail.setReplyTo(replyto->text()); |
129 | smail.setTo(to->text()); | 129 | smail.setTo(to->text()); |
130 | smail.setCc(cc->text()); | 130 | smail.setCc(cc->text()); |
131 | smail.setBcc(bcc->text()); | 131 | smail.setBcc(bcc->text()); |
132 | smail.setSubject(subject->text()); | 132 | smail.setSubject(subject->text()); |
133 | smail.setMessage(message->text()); | 133 | smail.setMessage(message->text()); |
134 | smail.setNeedsMime(attachView->childCount() == 0 ? false : true); | 134 | smail.setNeedsMime(attachView->childCount() == 0 ? false : true); |
135 | smail.setAccount(accountsLoaded[from->currentItem()]); | 135 | smail.setAccount(accountsLoaded[from->currentItem()]); |
136 | 136 | ||
137 | if (priority->currentItem() == POPUP_PRIO_LOW) { | 137 | if (priority->currentItem() == POPUP_PRIO_LOW) { |
138 | smail.setPriority("Low");// No i18n on purpose | 138 | smail.setPriority("Low");// No i18n on purpose |
139 | } else if (priority->currentItem() == POPUP_PRIO_NORMAL) { | 139 | } else if (priority->currentItem() == POPUP_PRIO_NORMAL) { |
140 | smail.setPriority("Normal");// No i18n on purpose | 140 | smail.setPriority("Normal");// No i18n on purpose |
141 | } else if (priority->currentItem() == POPUP_PRIO_HIGH) { | 141 | } else if (priority->currentItem() == POPUP_PRIO_HIGH) { |
142 | smail.setPriority("High");// No i18n on purpose | 142 | smail.setPriority("High");// No i18n on purpose |
143 | } | 143 | } |
144 | 144 | ||
145 | QValueList<Attachment> attachments; | 145 | QValueList<Attachment> attachments; |
146 | QListViewItem *item; | 146 | QListViewItem *item; |
147 | for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) { | 147 | for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) { |
148 | attachments.append(((AttachViewItem *)item)->attachment()); | 148 | attachments.append(((AttachViewItem *)item)->attachment()); |
149 | } | 149 | } |
150 | 150 | ||
151 | smail.setAttachments(attachments); | 151 | smail.setAttachments(attachments); |
152 | 152 | ||
153 | QString header, message; | 153 | QString header, message; |
154 | MailFactory::genMail(header, message, smail, this); | 154 | MailFactory::genMail(header, message, smail, this); |
155 | if (header.isNull() || message.isNull()) return;// Aborted. | 155 | if (header.isNull() || message.isNull()) return;// Aborted. |
156 | 156 | ||
157 | status->setStopEnabled(true); | 157 | status->setStopEnabled(true); |
158 | 158 | ||
159 | SmtpHandler *handler = new SmtpHandler(header, message, accountsLoaded[from->currentItem()], to->text()); | 159 | SmtpHandler *handler = new SmtpHandler(header, message, accountsLoaded[from->currentItem()], to->text()); |
160 | connect(handler, SIGNAL(finished()), SLOT(slotSendFinished())); | 160 | connect(handler, SIGNAL(finished()), SLOT(slotSendFinished())); |
161 | connect(handler, SIGNAL(error(const QString &)), SLOT(slotSendError(const QString &))); | 161 | connect(handler, SIGNAL(error(const QString&)), SLOT(slotSendError(const QString&))); |
162 | connect(handler, SIGNAL(status(const QString &)), status, SLOT(setStatusText(const QString &))); | 162 | connect(handler, SIGNAL(status(const QString&)), status, SLOT(setStatusText(const QString&))); |
163 | } | 163 | } |
164 | 164 | ||
165 | void Composer::slotSendQueued() | 165 | void Composer::slotSendQueued() |
166 | { | 166 | { |
167 | int effSendCount = 0; | 167 | int effSendCount = 0; |
168 | qDebug("Sending queued messages"); | 168 | qDebug("Sending queued messages"); |
169 | Config cfg( "mailqueue", Config::User ); | 169 | Config cfg( "mailqueue", Config::User ); |
170 | cfg.setGroup( "Settings" ); | 170 | cfg.setGroup( "Settings" ); |
171 | _sendCount = 0; | 171 | _sendCount = 0; |
172 | _sendError = 0; | 172 | _sendError = 0; |
173 | _toSend = cfg.readNumEntry( "count", 0 ); | 173 | _toSend = cfg.readNumEntry( "count", 0 ); |
174 | 174 | ||
175 | if (_toSend == 0) close(); | 175 | if (_toSend == 0) close(); |
176 | 176 | ||
177 | qDebug("%i messages to send", _toSend); | 177 | qDebug("%i messages to send", _toSend); |
178 | QString str; | 178 | QString str; |
179 | for (int i=1;i<=_toSend;i++) | 179 | for (int i=1;i<=_toSend;i++) |
180 | { | 180 | { |
181 | qDebug("sending message %i",i); | 181 | qDebug("sending message %i",i); |
182 | cfg.setGroup( "Mail_" + QString::number(i) ); | 182 | cfg.setGroup( "Mail_" + QString::number(i) ); |
183 | SendMail smail; | 183 | SendMail smail; |
184 | str = cfg.readEntry("from"); | 184 | str = cfg.readEntry("from"); |
185 | qDebug("setFrom %s",str.latin1()); | 185 | qDebug("setFrom %s",str.latin1()); |
186 | smail.setFrom( str ); | 186 | smail.setFrom( str ); |
187 | str = cfg.readEntry("reply"); | 187 | str = cfg.readEntry("reply"); |
188 | qDebug("setReplyTo %s",str.latin1()); | 188 | qDebug("setReplyTo %s",str.latin1()); |
189 | smail.setReplyTo( str ); | 189 | smail.setReplyTo( str ); |
190 | QString toAdr = cfg.readEntry("to"); | 190 | QString toAdr = cfg.readEntry("to"); |
191 | qDebug("to %s",toAdr.latin1()); | 191 | qDebug("to %s",toAdr.latin1()); |
192 | smail.setTo( toAdr ); //to->text()); | 192 | smail.setTo( toAdr ); //to->text()); |
193 | str = cfg.readEntry("cc"); | 193 | str = cfg.readEntry("cc"); |
194 | qDebug("setCc %s",str.latin1()); | 194 | qDebug("setCc %s",str.latin1()); |
195 | smail.setCc( str ); //cc->text()); | 195 | smail.setCc( str ); //cc->text()); |
196 | smail.setBcc( cfg.readEntry("bcc") ); //bcc->text()); | 196 | smail.setBcc( cfg.readEntry("bcc") ); //bcc->text()); |
197 | str = cfg.readEntry("subject"); | 197 | str = cfg.readEntry("subject"); |
198 | qDebug("setSubject %s",str.latin1()); | 198 | qDebug("setSubject %s",str.latin1()); |
199 | smail.setSubject( str ); //subject->text()); | 199 | smail.setSubject( str ); //subject->text()); |
200 | str = cfg.readEntryCrypt("message"); | 200 | str = cfg.readEntryCrypt("message"); |
201 | qDebug("setMessage %s",str.latin1()); | 201 | qDebug("setMessage %s",str.latin1()); |
202 | smail.setMessage( str ); //message->text()); | 202 | smail.setMessage( str ); //message->text()); |
203 | smail.setNeedsMime( cfg.readBoolEntry("mime") ); //attachView->childCount() == 0 ? false : true); | 203 | smail.setNeedsMime( cfg.readBoolEntry("mime") ); //attachView->childCount() == 0 ? false : true); |
204 | 204 | ||
205 | qDebug("setting account [%i]",cfg.readNumEntry("account")); | 205 | qDebug("setting account [%i]",cfg.readNumEntry("account")); |
206 | Account accnt = accountsLoaded[ cfg.readNumEntry("account") ]; | 206 | Account accnt = accountsLoaded[ cfg.readNumEntry("account") ]; |
207 | smail.setAccount( accnt ); //accountsLoaded[from->currentItem()]); | 207 | smail.setAccount( accnt ); //accountsLoaded[from->currentItem()]); |
208 | 208 | ||
209 | 209 | ||
210 | int prio = cfg.readNumEntry( "priority" ); | 210 | int prio = cfg.readNumEntry( "priority" ); |
211 | qDebug("setting priority %i",prio); | 211 | qDebug("setting priority %i",prio); |
212 | if (prio == POPUP_PRIO_LOW) { | 212 | if (prio == POPUP_PRIO_LOW) { |
213 | smail.setPriority("Low");// No i18n on purpose | 213 | smail.setPriority("Low");// No i18n on purpose |
214 | } else if (prio == POPUP_PRIO_NORMAL) { | 214 | } else if (prio == POPUP_PRIO_NORMAL) { |
215 | smail.setPriority("Normal");// No i18n on purpose | 215 | smail.setPriority("Normal");// No i18n on purpose |
216 | } else if (prio == POPUP_PRIO_HIGH) { | 216 | } else if (prio == POPUP_PRIO_HIGH) { |
217 | smail.setPriority("High");// No i18n on purpose | 217 | smail.setPriority("High");// No i18n on purpose |
218 | } | 218 | } |
219 | 219 | ||
220 | QValueList<Attachment> attachments; | 220 | QValueList<Attachment> attachments; |
221 | Attachment a; | 221 | Attachment a; |
222 | QString an; | 222 | QString an; |
223 | 223 | ||
224 | int ac = cfg.readNumEntry( "attachments", 0 ); | 224 | int ac = cfg.readNumEntry( "attachments", 0 ); |
225 | qDebug("%i Attachments",ac); | 225 | qDebug("%i Attachments",ac); |
226 | for (int j = 0; i < ac; ac++) { | 226 | for (int j = 0; i < ac; ac++) { |
227 | an = "Attachment_" + QString::number( j ); | 227 | an = "Attachment_" + QString::number( j ); |
228 | qDebug(an.latin1()); | 228 | qDebug(an.latin1()); |
229 | a.setFileName(cfg.readEntry( an + "fileName" )); | 229 | a.setFileName(cfg.readEntry( an + "fileName" )); |
230 | a.setNewName(cfg.readEntry( an + "newName" )); | 230 | a.setNewName(cfg.readEntry( an + "newName" )); |
231 | a.setDescription(cfg.readEntry( an + "description" )); | 231 | a.setDescription(cfg.readEntry( an + "description" )); |
232 | a.setDocLnk( DocLnk( cfg.readEntry( an + "docLnk" )) ); | 232 | a.setDocLnk( DocLnk( cfg.readEntry( an + "docLnk" )) ); |
233 | attachments.append( a ); | 233 | attachments.append( a ); |
234 | } | 234 | } |
235 | 235 | ||
236 | smail.setAttachments(attachments); | 236 | smail.setAttachments(attachments); |
237 | 237 | ||
238 | qDebug("putting mail together"); | 238 | qDebug("putting mail together"); |
239 | 239 | ||
240 | QString header, message; | 240 | QString header, message; |
241 | MailFactory::genMail(header, message, smail, this); | 241 | MailFactory::genMail(header, message, smail, this); |
242 | if (header.isNull() || message.isNull()) continue;//return;// Aborted. | 242 | if (header.isNull() || message.isNull()) continue;//return;// Aborted. |
243 | 243 | ||
244 | // abort->setEnabled(true); | 244 | // abort->setEnabled(true); |
245 | 245 | ||
246 | qDebug("Sending to %s",toAdr.latin1()); | 246 | qDebug("Sending to %s",toAdr.latin1()); |
247 | SmtpHandler *handler = new SmtpHandler(header, message, accnt ,toAdr); | 247 | SmtpHandler *handler = new SmtpHandler(header, message, accnt ,toAdr); |
248 | effSendCount++; | 248 | effSendCount++; |
249 | connect(handler, SIGNAL(finished()), SLOT(slotSendQueuedFinished())); | 249 | connect(handler, SIGNAL(finished()), SLOT(slotSendQueuedFinished())); |
250 | connect(handler, SIGNAL(error(const QString &)), SLOT(slotSendQueuedError(const QString &))); | 250 | connect(handler, SIGNAL(error(const QString&)), SLOT(slotSendQueuedError(const QString&))); |
251 | connect(handler, SIGNAL(status(const QString &)), status, SLOT(setStatusText(const QString &))); | 251 | connect(handler, SIGNAL(status(const QString&)), status, SLOT(setStatusText(const QString&))); |
252 | 252 | ||
253 | } | 253 | } |
254 | if (effSendCount < _toSend) | 254 | if (effSendCount < _toSend) |
255 | { | 255 | { |
256 | _toSend = effSendCount; | 256 | _toSend = effSendCount; |
257 | QMessageBox::information(this, tr("Error"), tr("<p>There was a problem sending some of the queued mails.</p>"), tr("Ok")); | 257 | QMessageBox::information(this, tr("Error"), tr("<p>There was a problem sending some of the queued mails.</p>"), tr("Ok")); |
258 | } | 258 | } |
259 | } | 259 | } |
260 | 260 | ||
261 | void Composer::slotQueueMail() | 261 | void Composer::slotQueueMail() |
262 | { | 262 | { |
263 | if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) { | 263 | if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) { |
264 | QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok")); | 264 | QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok")); |
265 | return; | 265 | return; |
266 | } | 266 | } |
267 | 267 | ||
268 | Config cfg( "mailqueue", Config::User ); | 268 | Config cfg( "mailqueue", Config::User ); |
269 | 269 | ||
270 | cfg.setGroup( "Settings" ); | 270 | cfg.setGroup( "Settings" ); |
271 | int count = cfg.readNumEntry( "count", 0 ); | 271 | int count = cfg.readNumEntry( "count", 0 ); |
272 | count++; | 272 | count++; |
273 | cfg.writeEntry( "count", count ); | 273 | cfg.writeEntry( "count", count ); |
274 | qDebug("queueing mail %i",count); | 274 | qDebug("queueing mail %i",count); |
275 | 275 | ||
276 | cfg.setGroup( "Mail_" + QString::number( count )); | 276 | cfg.setGroup( "Mail_" + QString::number( count )); |
277 | cfg.writeEntry( "from", from->currentText() ); | 277 | cfg.writeEntry( "from", from->currentText() ); |
278 | cfg.writeEntry( "reply", replyto->text()); | 278 | cfg.writeEntry( "reply", replyto->text()); |
279 | cfg.writeEntry( "to", to->text()); | 279 | cfg.writeEntry( "to", to->text()); |
280 | cfg.writeEntry( "cc", cc->text()); | 280 | cfg.writeEntry( "cc", cc->text()); |
281 | cfg.writeEntry( "bcc", bcc->text()); | 281 | cfg.writeEntry( "bcc", bcc->text()); |
282 | cfg.writeEntry( "subject", subject->text()); | 282 | cfg.writeEntry( "subject", subject->text()); |
283 | cfg.writeEntryCrypt( "message", message->text()); | 283 | cfg.writeEntryCrypt( "message", message->text()); |
284 | cfg.writeEntry( "mime", attachView->childCount() == 0 ); | 284 | cfg.writeEntry( "mime", attachView->childCount() == 0 ); |
285 | cfg.writeEntry( "account", from->currentItem()); | 285 | cfg.writeEntry( "account", from->currentItem()); |
286 | cfg.writeEntry( "priority", priority->currentItem() ); | 286 | cfg.writeEntry( "priority", priority->currentItem() ); |
287 | cfg.writeEntry( "attachments", attachView->childCount() ); | 287 | cfg.writeEntry( "attachments", attachView->childCount() ); |
288 | 288 | ||
289 | Attachment a; | 289 | Attachment a; |
290 | QListViewItem *item; | 290 | QListViewItem *item; |
291 | QString an; | 291 | QString an; |
292 | int i = 0; | 292 | int i = 0; |
293 | for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) { | 293 | for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) { |
294 | a = ((AttachViewItem *)item)->attachment(); | 294 | a = ((AttachViewItem *)item)->attachment(); |
295 | an = "Attachment_" + QString::number( i++ ); | 295 | an = "Attachment_" + QString::number( i++ ); |
296 | cfg.writeEntry( an + "fileName", a.fileName() ); | 296 | cfg.writeEntry( an + "fileName", a.fileName() ); |
297 | cfg.writeEntry( an + "newName", a.newName() ); | 297 | cfg.writeEntry( an + "newName", a.newName() ); |
298 | cfg.writeEntry( an + "description", a.description() ); | 298 | cfg.writeEntry( an + "description", a.description() ); |
299 | cfg.writeEntry( an + "docLnk", a.docLnk().file() ); | 299 | cfg.writeEntry( an + "docLnk", a.docLnk().file() ); |
300 | } | 300 | } |
301 | 301 | ||
302 | QMessageBox::information(this, tr("Success"), tr("<p>The mail was queued successfully.</p><p>The queue contains ")+QString::number(count)+tr(" mails.</p>"), tr("Ok")); | 302 | QMessageBox::information(this, tr("Success"), tr("<p>The mail was queued successfully.</p><p>The queue contains ")+QString::number(count)+tr(" mails.</p>"), tr("Ok")); |
303 | 303 | ||
304 | } | 304 | } |
305 | 305 | ||
306 | void Composer::slotSendError(const QString &error) | 306 | void Composer::slotSendError(const QString &error) |
307 | { | 307 | { |
308 | status->setStatusText(tr("<font color=#ff0000>Error occoured during sending.</font>")); | 308 | status->setStatusText(tr("<font color=#ff0000>Error occoured during sending.</font>")); |
309 | QMessageBox::warning(this, tr("Error"), tr("<p>%1</p").arg(error), tr("Ok")); | 309 | QMessageBox::warning(this, tr("Error"), tr("<p>%1</p").arg(error), tr("Ok")); |
310 | } | 310 | } |
311 | 311 | ||
312 | void Composer::slotSendQueuedError(const QString &error) | 312 | void Composer::slotSendQueuedError(const QString &error) |
313 | { | 313 | { |
314 | _sendError++; | 314 | _sendError++; |
315 | qDebug("error send mail %i",_sendCount); | 315 | qDebug("error send mail %i",_sendCount); |
316 | status->setStatusText(tr("<font color=#ff0000>Error occoured during sending.</font>")); | 316 | status->setStatusText(tr("<font color=#ff0000>Error occoured during sending.</font>")); |
317 | QMessageBox::warning(this, tr("Error"), tr("<p>%1</p").arg(error), tr("Ok")); | 317 | QMessageBox::warning(this, tr("Error"), tr("<p>%1</p").arg(error), tr("Ok")); |
318 | } | 318 | } |
319 | 319 | ||
320 | void Composer::slotSendFinished() | 320 | void Composer::slotSendFinished() |
321 | { | 321 | { |
322 | QMessageBox::information(this, tr("Success"), tr("<p>The mail was sent successfully.</p>"), tr("Ok")); | 322 | QMessageBox::information(this, tr("Success"), tr("<p>The mail was sent successfully.</p>"), tr("Ok")); |
323 | 323 | ||
324 | status->setStatusText(QString(0)); | 324 | status->setStatusText(QString(0)); |
325 | status->setStopEnabled(false); | 325 | status->setStopEnabled(false); |
326 | } | 326 | } |
327 | 327 | ||
328 | void Composer::slotSendQueuedFinished() | 328 | void Composer::slotSendQueuedFinished() |
329 | { | 329 | { |
330 | 330 | ||
331 | _sendCount++; | 331 | _sendCount++; |
332 | qDebug("finished send mail %i of %i (error %i)",_sendCount,_toSend,_sendError); | 332 | qDebug("finished send mail %i of %i (error %i)",_sendCount,_toSend,_sendError); |
333 | if (_sendCount < _toSend) return; | 333 | if (_sendCount < _toSend) return; |
334 | if (_sendError == _toSend) close(); | 334 | if (_sendError == _toSend) close(); |
335 | QMessageBox::information(this, tr("Success"), tr("<p>The queued mails ")+QString::number(_toSend-_sendError)+tr(" of ")+QString::number(_toSend)+(" were sent successfully.</p>"), tr("Ok")); | 335 | QMessageBox::information(this, tr("Success"), tr("<p>The queued mails ")+QString::number(_toSend-_sendError)+tr(" of ")+QString::number(_toSend)+(" were sent successfully.</p>"), tr("Ok")); |
336 | Config cfg( "mailqueue", Config::User ); | 336 | Config cfg( "mailqueue", Config::User ); |
337 | cfg.setGroup( "Settings" ); | 337 | cfg.setGroup( "Settings" ); |
338 | cfg.writeEntry( "count", 0 ); | 338 | cfg.writeEntry( "count", 0 ); |
339 | for (int i=1;i<=_sendCount;i++) | 339 | for (int i=1;i<=_sendCount;i++) |
340 | { | 340 | { |
341 | cfg.setGroup( "Mail_" + QString::number(i) ); | 341 | cfg.setGroup( "Mail_" + QString::number(i) ); |
342 | qDebug("remove mail %i", i); | 342 | qDebug("remove mail %i", i); |
343 | cfg.clearGroup(); | 343 | cfg.clearGroup(); |
344 | cfg.removeEntry( "Mail_" + QString::number(i) ); | 344 | cfg.removeEntry( "Mail_" + QString::number(i) ); |
345 | } | 345 | } |
346 | close(); | 346 | close(); |
347 | } | 347 | } |
diff --git a/noncore/unsupported/mail2/folderwidget.cpp b/noncore/unsupported/mail2/folderwidget.cpp index d27968b..a0520b1 100644 --- a/noncore/unsupported/mail2/folderwidget.cpp +++ b/noncore/unsupported/mail2/folderwidget.cpp | |||
@@ -1,314 +1,314 @@ | |||
1 | #include <qmessagebox.h> | 1 | #include <qmessagebox.h> |
2 | #include <qtextstream.h> | 2 | #include <qtextstream.h> |
3 | #include <qpopupmenu.h> | 3 | #include <qpopupmenu.h> |
4 | #include <qheader.h> | 4 | #include <qheader.h> |
5 | #include <qfile.h> | 5 | #include <qfile.h> |
6 | #include <qdir.h> | 6 | #include <qdir.h> |
7 | 7 | ||
8 | #include <qpe/resource.h> | 8 | #include <qpe/resource.h> |
9 | 9 | ||
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | 11 | ||
12 | #include "folderwidget.h" | 12 | #include "folderwidget.h" |
13 | #include "imaphandler.h" | 13 | #include "imaphandler.h" |
14 | #include "imapbase.h" | 14 | #include "imapbase.h" |
15 | #include "rename.h" | 15 | #include "rename.h" |
16 | 16 | ||
17 | FolderWidgetItem::FolderWidgetItem(Folder &folder, QListView *parent) | 17 | FolderWidgetItem::FolderWidgetItem(Folder &folder, QListView *parent) |
18 | : QListViewItem(parent), _folder(folder) | 18 | : QListViewItem(parent), _folder(folder) |
19 | { | 19 | { |
20 | setPixmap(0, QPixmap(Resource::loadPixmap("mail/inbox"))); | 20 | setPixmap(0, QPixmap(Resource::loadPixmap("mail/inbox"))); |
21 | setText(0, _folder.topFolder().account().user() + " (" + _folder.topFolder().account().imapServer() + ")"); | 21 | setText(0, _folder.topFolder().account().user() + " (" + _folder.topFolder().account().imapServer() + ")"); |
22 | setOpen(true); | 22 | setOpen(true); |
23 | } | 23 | } |
24 | 24 | ||
25 | FolderWidgetItem::FolderWidgetItem(Folder &folder, FolderWidgetItem *parent) | 25 | FolderWidgetItem::FolderWidgetItem(Folder &folder, FolderWidgetItem *parent) |
26 | : QListViewItem(parent), _folder(folder) | 26 | : QListViewItem(parent), _folder(folder) |
27 | { | 27 | { |
28 | if (_folder.noCache()) { | 28 | if (_folder.noCache()) { |
29 | setText(0, QObject::tr("<Foldertree not known.>")); | 29 | setText(0, QObject::tr("<Foldertree not known.>")); |
30 | } else { | 30 | } else { |
31 | if (folder.fullName().upper() == "INBOX") { | 31 | if (folder.fullName().upper() == "INBOX") { |
32 | setPixmap(0, QPixmap(Resource::loadPixmap("mail/inbox"))); | 32 | setPixmap(0, QPixmap(Resource::loadPixmap("mail/inbox"))); |
33 | setText(0, QObject::tr("Inbox")); | 33 | setText(0, QObject::tr("Inbox")); |
34 | } else { | 34 | } else { |
35 | setPixmap(0, QPixmap(Resource::loadPixmap("mail/folder"))); | 35 | setPixmap(0, QPixmap(Resource::loadPixmap("mail/folder"))); |
36 | setText(0, folder.fullName()); | 36 | setText(0, folder.fullName()); |
37 | } | 37 | } |
38 | setOpen(true); | 38 | setOpen(true); |
39 | } | 39 | } |
40 | } | 40 | } |
41 | 41 | ||
42 | FolderWidget::FolderWidget(QWidget *parent, const char *name, WFlags fl) | 42 | FolderWidget::FolderWidget(QWidget *parent, const char *name, WFlags fl) |
43 | : ListViewPlus(parent, name, fl) | 43 | : ListViewPlus(parent, name, fl) |
44 | { | 44 | { |
45 | header()->hide(); | 45 | header()->hide(); |
46 | addColumn(""); | 46 | addColumn(""); |
47 | setSorting(-1); | 47 | setSorting(-1); |
48 | 48 | ||
49 | QPopupMenu *menu = new QPopupMenu(); | 49 | QPopupMenu *menu = new QPopupMenu(); |
50 | menu->insertItem(tr("Rename"), MENU_RENAME); | 50 | menu->insertItem(tr("Rename"), MENU_RENAME); |
51 | menu->insertItem(tr("Delete"), MENU_DELETE); | 51 | menu->insertItem(tr("Delete"), MENU_DELETE); |
52 | menu->insertItem(tr("Move"), MENU_MOVE); | 52 | menu->insertItem(tr("Move"), MENU_MOVE); |
53 | menu->insertItem(tr("Copy"), MENU_COPY); | 53 | menu->insertItem(tr("Copy"), MENU_COPY); |
54 | menu->insertSeparator(); | 54 | menu->insertSeparator(); |
55 | menu->insertItem(tr("Create folder"), MENU_CREATE); | 55 | menu->insertItem(tr("Create folder"), MENU_CREATE); |
56 | menu->insertSeparator(); | 56 | menu->insertSeparator(); |
57 | menu->insertItem(tr("Rescan folder list"), MENU_RESCAN); | 57 | menu->insertItem(tr("Rescan folder list"), MENU_RESCAN); |
58 | setPopup(menu); | 58 | setPopup(menu); |
59 | 59 | ||
60 | getAccounts(); | 60 | getAccounts(); |
61 | 61 | ||
62 | connect(menu, SIGNAL(activated(int)), SLOT(slotMenuActivated(int))); | 62 | connect(menu, SIGNAL(activated(int)), SLOT(slotMenuActivated(int))); |
63 | connect(this, SIGNAL(clicked(QListViewItem *)), SLOT(slotItemClicked(QListViewItem *))); | 63 | connect(this, SIGNAL(clicked(QListViewItem*)), SLOT(slotItemClicked(QListViewItem*))); |
64 | } | 64 | } |
65 | 65 | ||
66 | FolderWidget::~FolderWidget() | 66 | FolderWidget::~FolderWidget() |
67 | { | 67 | { |
68 | // TODO: Save folder tree. | 68 | // TODO: Save folder tree. |
69 | } | 69 | } |
70 | 70 | ||
71 | void FolderWidget::update() | 71 | void FolderWidget::update() |
72 | { | 72 | { |
73 | getAccounts(); | 73 | getAccounts(); |
74 | } | 74 | } |
75 | 75 | ||
76 | void FolderWidget::getAccounts() | 76 | void FolderWidget::getAccounts() |
77 | { | 77 | { |
78 | clear(); | 78 | clear(); |
79 | 79 | ||
80 | QValueList<Account> accounts = ConfigFile::getAccounts(); | 80 | QValueList<Account> accounts = ConfigFile::getAccounts(); |
81 | QValueList<Account>::Iterator it; | 81 | QValueList<Account>::Iterator it; |
82 | for (it = accounts.begin(); it != accounts.end(); it++) { | 82 | for (it = accounts.begin(); it != accounts.end(); it++) { |
83 | FolderWidgetItem *item = addAccount(*it); | 83 | FolderWidgetItem *item = addAccount(*it); |
84 | QFile f((QString) getenv("HOME") + "/Applications/mail/foldercache/foldercache-" + (*it).accountName()); | 84 | QFile f((QString) getenv("HOME") + "/Applications/mail/foldercache/foldercache-" + (*it).accountName()); |
85 | if (!f.open(IO_ReadOnly)) { | 85 | if (!f.open(IO_ReadOnly)) { |
86 | Folder folder; | 86 | Folder folder; |
87 | folder.setNoCache(true); | 87 | folder.setNoCache(true); |
88 | addFolder(folder, item); | 88 | addFolder(folder, item); |
89 | } else { | 89 | } else { |
90 | QTextStream t(&f); | 90 | QTextStream t(&f); |
91 | while (!t.atEnd()) { | 91 | while (!t.atEnd()) { |
92 | QString separator = t.readLine(); | 92 | QString separator = t.readLine(); |
93 | QString fullname = t.readLine(); | 93 | QString fullname = t.readLine(); |
94 | Folder folder; | 94 | Folder folder; |
95 | folder.setSeparator(separator); | 95 | folder.setSeparator(separator); |
96 | folder.setFullName(fullname); | 96 | folder.setFullName(fullname); |
97 | folder.setTopFolder(item->folder().topFolder()); | 97 | folder.setTopFolder(item->folder().topFolder()); |
98 | addFolder(folder, item); | 98 | addFolder(folder, item); |
99 | } | 99 | } |
100 | f.close(); | 100 | f.close(); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | FolderWidgetItem *FolderWidget::addAccount(Account &account) | 105 | FolderWidgetItem *FolderWidget::addAccount(Account &account) |
106 | { | 106 | { |
107 | TopFolder tf; | 107 | TopFolder tf; |
108 | tf.setAccount(account); | 108 | tf.setAccount(account); |
109 | 109 | ||
110 | // XXX This has to change!!! The folderwidget may not create an | 110 | // XXX This has to change!!! The folderwidget may not create an |
111 | // XXX IMAPHandler!!!! Do this in IMAPHandler! | 111 | // XXX IMAPHandler!!!! Do this in IMAPHandler! |
112 | tf.setIMAPHandler(new IMAPHandler(account)); | 112 | tf.setIMAPHandler(new IMAPHandler(account)); |
113 | 113 | ||
114 | Folder folder; | 114 | Folder folder; |
115 | folder.setTopFolder(tf); | 115 | folder.setTopFolder(tf); |
116 | 116 | ||
117 | connect(tf.handler(), SIGNAL(IMAPLookingUpHost()), SLOT(slotIMAPLookingUpHost())); | 117 | connect(tf.handler(), SIGNAL(IMAPLookingUpHost()), SLOT(slotIMAPLookingUpHost())); |
118 | connect(tf.handler(), SIGNAL(IMAPHostFound()), SLOT(slotIMAPHostFound())); | 118 | connect(tf.handler(), SIGNAL(IMAPHostFound()), SLOT(slotIMAPHostFound())); |
119 | connect(tf.handler(), SIGNAL(IMAPConnected()), SLOT(slotIMAPConnected())); | 119 | connect(tf.handler(), SIGNAL(IMAPConnected()), SLOT(slotIMAPConnected())); |
120 | connect(tf.handler(), SIGNAL(IMAPDisconnected()), SLOT(slotIMAPDisconnected())); | 120 | connect(tf.handler(), SIGNAL(IMAPDisconnected()), SLOT(slotIMAPDisconnected())); |
121 | connect(tf.handler(), SIGNAL(IMAPError(int)), SLOT(slotIMAPError(int))); | 121 | connect(tf.handler(), SIGNAL(IMAPError(int)), SLOT(slotIMAPError(int))); |
122 | 122 | ||
123 | return new FolderWidgetItem(folder, this); | 123 | return new FolderWidgetItem(folder, this); |
124 | } | 124 | } |
125 | 125 | ||
126 | FolderWidgetItem *FolderWidget::addFolder(Folder &folder, FolderWidgetItem *folderWidgetItem) | 126 | FolderWidgetItem *FolderWidget::addFolder(Folder &folder, FolderWidgetItem *folderWidgetItem) |
127 | { | 127 | { |
128 | return new FolderWidgetItem(folder, folderWidgetItem); | 128 | return new FolderWidgetItem(folder, folderWidgetItem); |
129 | } | 129 | } |
130 | 130 | ||
131 | void FolderWidget::slotMenuActivated(int itemid) | 131 | void FolderWidget::slotMenuActivated(int itemid) |
132 | { | 132 | { |
133 | if (currentItem() == NULL) { | 133 | if (currentItem() == NULL) { |
134 | QMessageBox::information(this, tr("Error"), tr("<p>Please select an item first.</p>"), tr("Ok")); | 134 | QMessageBox::information(this, tr("Error"), tr("<p>Please select an item first.</p>"), tr("Ok")); |
135 | return; | 135 | return; |
136 | } | 136 | } |
137 | 137 | ||
138 | if (itemid == MENU_RENAME) { | 138 | if (itemid == MENU_RENAME) { |
139 | if (((FolderWidgetItem *)currentItem())->folder().fullName().isEmpty()) return; | 139 | if (((FolderWidgetItem *)currentItem())->folder().fullName().isEmpty()) return; |
140 | 140 | ||
141 | Folder folder = ((FolderWidgetItem *)currentItem())->folder(); | 141 | Folder folder = ((FolderWidgetItem *)currentItem())->folder(); |
142 | QString newName = Rename::rename(folder.fullName(), this); | 142 | QString newName = Rename::rename(folder.fullName(), this); |
143 | if (newName.isNull()) return; | 143 | if (newName.isNull()) return; |
144 | 144 | ||
145 | folder.topFolder().handler()->iRename(folder.fullName(), newName); | 145 | folder.topFolder().handler()->iRename(folder.fullName(), newName); |
146 | connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPRename(IMAPResponse &))); | 146 | connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPRename(IMAPResponse&))); |
147 | } else if (itemid == MENU_DELETE) { | 147 | } else if (itemid == MENU_DELETE) { |
148 | if (((FolderWidgetItem *)currentItem())->folder().fullName().isEmpty()) return; | 148 | if (((FolderWidgetItem *)currentItem())->folder().fullName().isEmpty()) return; |
149 | 149 | ||
150 | Folder folder = ((FolderWidgetItem *)currentItem())->folder(); | 150 | Folder folder = ((FolderWidgetItem *)currentItem())->folder(); |
151 | 151 | ||
152 | int ret = QMessageBox::information(this, tr("Question"), tr("<p>Do you really want to delete <pre>%1</pre>?").arg(folder.fullName()), tr("Yes"), tr("No")); | 152 | int ret = QMessageBox::information(this, tr("Question"), tr("<p>Do you really want to delete <pre>%1</pre>?").arg(folder.fullName()), tr("Yes"), tr("No")); |
153 | if (ret == 1) return; | 153 | if (ret == 1) return; |
154 | 154 | ||
155 | _createFolder = folder; | 155 | _createFolder = folder; |
156 | 156 | ||
157 | folder.topFolder().handler()->iDelete(folder.fullName()); | 157 | folder.topFolder().handler()->iDelete(folder.fullName()); |
158 | connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPDelete(IMAPResponse &))); | 158 | connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPDelete(IMAPResponse&))); |
159 | } else if (itemid == MENU_MOVE) { | 159 | } else if (itemid == MENU_MOVE) { |
160 | 160 | ||
161 | } else if (itemid == MENU_COPY) { | 161 | } else if (itemid == MENU_COPY) { |
162 | 162 | ||
163 | } else if (itemid == MENU_CREATE) { | 163 | } else if (itemid == MENU_CREATE) { |
164 | Folder folder = (((FolderWidgetItem *)currentItem())->folder()); | 164 | Folder folder = (((FolderWidgetItem *)currentItem())->folder()); |
165 | _createFolder = folder; | 165 | _createFolder = folder; |
166 | 166 | ||
167 | QString folderName = Rename::getText(tr("Foldername"), tr("<p>Please enter the name of the new folder.</p>"), this); | 167 | QString folderName = Rename::getText(tr("Foldername"), tr("<p>Please enter the name of the new folder.</p>"), this); |
168 | if (folderName.isNull()) return; | 168 | if (folderName.isNull()) return; |
169 | 169 | ||
170 | folder.topFolder().handler()->iCreate(folder.fullName() + folder.separator() + folderName); | 170 | folder.topFolder().handler()->iCreate(folder.fullName() + folder.separator() + folderName); |
171 | connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPCreate(IMAPResponse &))); | 171 | connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPCreate(IMAPResponse&))); |
172 | } else if (itemid == MENU_RESCAN) { | 172 | } else if (itemid == MENU_RESCAN) { |
173 | Folder folder = (((FolderWidgetItem *)currentItem())->folder()); | 173 | Folder folder = (((FolderWidgetItem *)currentItem())->folder()); |
174 | _rescanAccount = folder.topFolder().account(); | 174 | _rescanAccount = folder.topFolder().account(); |
175 | 175 | ||
176 | folder.topFolder().handler()->iList("", "*"); | 176 | folder.topFolder().handler()->iList("", "*"); |
177 | connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPList(IMAPResponse &))); | 177 | connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPList(IMAPResponse&))); |
178 | } | 178 | } |
179 | } | 179 | } |
180 | 180 | ||
181 | void FolderWidget::slotItemClicked(QListViewItem *item) | 181 | void FolderWidget::slotItemClicked(QListViewItem *item) |
182 | { | 182 | { |
183 | if (item == NULL) return; | 183 | if (item == NULL) return; |
184 | Folder folder = ((FolderWidgetItem *)item)->folder(); | 184 | Folder folder = ((FolderWidgetItem *)item)->folder(); |
185 | if (folder.fullName().isEmpty()) return; | 185 | if (folder.fullName().isEmpty()) return; |
186 | 186 | ||
187 | emit folderSelected(folder); | 187 | emit folderSelected(folder); |
188 | } | 188 | } |
189 | 189 | ||
190 | void FolderWidget::slotIMAPLookingUpHost() | 190 | void FolderWidget::slotIMAPLookingUpHost() |
191 | { | 191 | { |
192 | emit status(tr("Looking up host...")); | 192 | emit status(tr("Looking up host...")); |
193 | emit connecting(); | 193 | emit connecting(); |
194 | } | 194 | } |
195 | 195 | ||
196 | void FolderWidget::slotIMAPHostFound() | 196 | void FolderWidget::slotIMAPHostFound() |
197 | { | 197 | { |
198 | emit status(tr("Host found.")); | 198 | emit status(tr("Host found.")); |
199 | } | 199 | } |
200 | 200 | ||
201 | void FolderWidget::slotIMAPConnected() | 201 | void FolderWidget::slotIMAPConnected() |
202 | { | 202 | { |
203 | emit status(tr("Connected to host.")); | 203 | emit status(tr("Connected to host.")); |
204 | emit connected(); | 204 | emit connected(); |
205 | } | 205 | } |
206 | 206 | ||
207 | void FolderWidget::slotIMAPError(int error) | 207 | void FolderWidget::slotIMAPError(int error) |
208 | { | 208 | { |
209 | if (error == IMAPBase::IMAPErrConnectionRefused) { | 209 | if (error == IMAPBase::IMAPErrConnectionRefused) { |
210 | QMessageBox::warning(this, tr("Error"), tr("<p>The IMAP connection was refused.</p>"), tr("Ok")); | 210 | QMessageBox::warning(this, tr("Error"), tr("<p>The IMAP connection was refused.</p>"), tr("Ok")); |
211 | } else if (error == IMAPBase::IMAPErrHostNotFound) { | 211 | } else if (error == IMAPBase::IMAPErrHostNotFound) { |
212 | QMessageBox::warning(this, tr("Error"), tr("<p>The host was not found.</p>"), tr("Ok")); | 212 | QMessageBox::warning(this, tr("Error"), tr("<p>The host was not found.</p>"), tr("Ok")); |
213 | } else if (error == IMAPBase::IMAPErrSocketRead) { | 213 | } else if (error == IMAPBase::IMAPErrSocketRead) { |
214 | QMessageBox::warning(this, tr("Error"), tr("<p>There was an error while reading from the socket.</p>"), tr("Ok")); | 214 | QMessageBox::warning(this, tr("Error"), tr("<p>There was an error while reading from the socket.</p>"), tr("Ok")); |
215 | } else if (error == IMAPBase::IMAPErrLoginFailed) { | 215 | } else if (error == IMAPBase::IMAPErrLoginFailed) { |
216 | QMessageBox::warning(this, tr("Error"), tr("<p>Login failed. Check your password/username.</p>"), tr("Ok")); | 216 | QMessageBox::warning(this, tr("Error"), tr("<p>Login failed. Check your password/username.</p>"), tr("Ok")); |
217 | } else { | 217 | } else { |
218 | QMessageBox::warning(this, tr("Error"), tr("<p>An unknown error was encountered.</p>"), tr("Ok")); | 218 | QMessageBox::warning(this, tr("Error"), tr("<p>An unknown error was encountered.</p>"), tr("Ok")); |
219 | } | 219 | } |
220 | } | 220 | } |
221 | 221 | ||
222 | void FolderWidget::slotIMAPDisconnected() | 222 | void FolderWidget::slotIMAPDisconnected() |
223 | { | 223 | { |
224 | emit status(tr("Disconnected.")); | 224 | emit status(tr("Disconnected.")); |
225 | emit disconnected(); | 225 | emit disconnected(); |
226 | } | 226 | } |
227 | 227 | ||
228 | void FolderWidget::slotIMAPLogin(IMAPResponse &response) | 228 | void FolderWidget::slotIMAPLogin(IMAPResponse &response) |
229 | { | 229 | { |
230 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPLogin(IMAPResponse &))); | 230 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPLogin(IMAPResponse&))); |
231 | 231 | ||
232 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 232 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
233 | emit status(tr("Login successful!")); | 233 | emit status(tr("Login successful!")); |
234 | } else { | 234 | } else { |
235 | QMessageBox::warning(this, tr("Error"), tr("<p>Login failed. Go away.</p>"), tr("Ok")); | 235 | QMessageBox::warning(this, tr("Error"), tr("<p>Login failed. Go away.</p>"), tr("Ok")); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | 238 | ||
239 | void FolderWidget::slotIMAPRename(IMAPResponse &response) | 239 | void FolderWidget::slotIMAPRename(IMAPResponse &response) |
240 | { | 240 | { |
241 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPRename(IMAPResponse &))); | 241 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPRename(IMAPResponse&))); |
242 | 242 | ||
243 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 243 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
244 | emit status(tr("Renaming successful!")); | 244 | emit status(tr("Renaming successful!")); |
245 | } else { | 245 | } else { |
246 | QMessageBox::warning(this, tr("Error"), tr("<p>Renaming failed. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); | 246 | QMessageBox::warning(this, tr("Error"), tr("<p>Renaming failed. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); |
247 | } | 247 | } |
248 | } | 248 | } |
249 | 249 | ||
250 | void FolderWidget::slotIMAPDelete(IMAPResponse &response) | 250 | void FolderWidget::slotIMAPDelete(IMAPResponse &response) |
251 | { | 251 | { |
252 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPDelete(IMAPResponse &))); | 252 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPDelete(IMAPResponse&))); |
253 | 253 | ||
254 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 254 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
255 | emit status(tr("Deletion successful!")); | 255 | emit status(tr("Deletion successful!")); |
256 | 256 | ||
257 | _rescanAccount = _createFolder.topFolder().account(); | 257 | _rescanAccount = _createFolder.topFolder().account(); |
258 | 258 | ||
259 | _createFolder.topFolder().handler()->iList(".", "*"); | 259 | _createFolder.topFolder().handler()->iList(".", "*"); |
260 | connect(_createFolder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPList(IMAPResponse &))); | 260 | connect(_createFolder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPList(IMAPResponse&))); |
261 | } else { | 261 | } else { |
262 | QMessageBox::warning(this, tr("Error"), tr("<p>Delete failed. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); | 262 | QMessageBox::warning(this, tr("Error"), tr("<p>Delete failed. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); |
263 | } | 263 | } |
264 | } | 264 | } |
265 | 265 | ||
266 | void FolderWidget::slotIMAPCreate(IMAPResponse &response) | 266 | void FolderWidget::slotIMAPCreate(IMAPResponse &response) |
267 | { | 267 | { |
268 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPCreate(IMAPResponse &))); | 268 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPCreate(IMAPResponse&))); |
269 | 269 | ||
270 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 270 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
271 | emit status(tr("Folder created. Rescanning...")); | 271 | emit status(tr("Folder created. Rescanning...")); |
272 | 272 | ||
273 | _rescanAccount = _createFolder.topFolder().account(); | 273 | _rescanAccount = _createFolder.topFolder().account(); |
274 | 274 | ||
275 | _createFolder.topFolder().handler()->iList(".", "*"); | 275 | _createFolder.topFolder().handler()->iList(".", "*"); |
276 | connect(_createFolder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPList(IMAPResponse &))); | 276 | connect(_createFolder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPList(IMAPResponse&))); |
277 | } else { | 277 | } else { |
278 | QMessageBox::warning(this, tr("Error"), tr("<p>The folder could not be created. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); | 278 | QMessageBox::warning(this, tr("Error"), tr("<p>The folder could not be created. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); |
279 | } | 279 | } |
280 | } | 280 | } |
281 | 281 | ||
282 | void FolderWidget::slotIMAPList(IMAPResponse &response) | 282 | void FolderWidget::slotIMAPList(IMAPResponse &response) |
283 | { | 283 | { |
284 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPList(IMAPResponse &))); | 284 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPList(IMAPResponse&))); |
285 | 285 | ||
286 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 286 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
287 | QDir d((QString) getenv("HOME") + "/Applications/mail/foldercache"); | 287 | QDir d((QString) getenv("HOME") + "/Applications/mail/foldercache"); |
288 | if (!d.exists()) { | 288 | if (!d.exists()) { |
289 | system("mkdir -p $HOME/Applications/mail/foldercache"); | 289 | system("mkdir -p $HOME/Applications/mail/foldercache"); |
290 | qWarning("Created $HOME/Applications/mail/foldercache."); | 290 | qWarning("Created $HOME/Applications/mail/foldercache."); |
291 | } | 291 | } |
292 | QFile f((QString) getenv("HOME") + "/Applications/mail/foldercache/foldercache-" + _rescanAccount.accountName()); | 292 | QFile f((QString) getenv("HOME") + "/Applications/mail/foldercache/foldercache-" + _rescanAccount.accountName()); |
293 | if (!f.open(IO_WriteOnly)) { | 293 | if (!f.open(IO_WriteOnly)) { |
294 | QMessageBox::critical(this, tr("Error"), tr("<p>Couldn't open folder cache file for writing!</p>"), tr("Ok")); | 294 | QMessageBox::critical(this, tr("Error"), tr("<p>Couldn't open folder cache file for writing!</p>"), tr("Ok")); |
295 | return; | 295 | return; |
296 | } | 296 | } |
297 | QTextStream t(&f); | 297 | QTextStream t(&f); |
298 | 298 | ||
299 | QValueList<IMAPResponseLIST>::Iterator it; | 299 | QValueList<IMAPResponseLIST>::Iterator it; |
300 | QValueList<IMAPResponseLIST> lists = response.LIST(); | 300 | QValueList<IMAPResponseLIST> lists = response.LIST(); |
301 | for (it = lists.begin(); it != lists.end(); it++) { | 301 | for (it = lists.begin(); it != lists.end(); it++) { |
302 | t << (*it).folderSeparator() << "\n"; | 302 | t << (*it).folderSeparator() << "\n"; |
303 | t << (*it).folder() << "\n"; | 303 | t << (*it).folder() << "\n"; |
304 | } | 304 | } |
305 | 305 | ||
306 | f.close(); | 306 | f.close(); |
307 | 307 | ||
308 | emit status(tr("Got folder list.")); | 308 | emit status(tr("Got folder list.")); |
309 | getAccounts(); | 309 | getAccounts(); |
310 | } else { | 310 | } else { |
311 | QMessageBox::warning(this, tr("Error"), tr("<p>Couldn't retrieve the folder list. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); | 311 | QMessageBox::warning(this, tr("Error"), tr("<p>Couldn't retrieve the folder list. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); |
312 | } | 312 | } |
313 | } | 313 | } |
314 | 314 | ||
diff --git a/noncore/unsupported/mail2/libmail/imaphandler.cpp b/noncore/unsupported/mail2/libmail/imaphandler.cpp index dc97b28..8da0acd 100644 --- a/noncore/unsupported/mail2/libmail/imaphandler.cpp +++ b/noncore/unsupported/mail2/libmail/imaphandler.cpp | |||
@@ -1,110 +1,110 @@ | |||
1 | #include "imapresponse.h" | 1 | #include "imapresponse.h" |
2 | #include "imaphandler.h" | 2 | #include "imaphandler.h" |
3 | #include "imapbase.h" | 3 | #include "imapbase.h" |
4 | 4 | ||
5 | IMAPHandler::IMAPHandler(const Account &account) | 5 | IMAPHandler::IMAPHandler(const Account &account) |
6 | : QObject(), _account(account) | 6 | : QObject(), _account(account) |
7 | { | 7 | { |
8 | _ready = false; | 8 | _ready = false; |
9 | _loggingin = false; | 9 | _loggingin = false; |
10 | _loggedin = false; | 10 | _loggedin = false; |
11 | _tag = 0; | 11 | _tag = 0; |
12 | _ibase = new IMAPBase(account); | 12 | _ibase = new IMAPBase(account); |
13 | 13 | ||
14 | connect(_ibase, SIGNAL(dataReceived(const QString &)), SLOT(slotDataReceived(const QString &))); | 14 | connect(_ibase, SIGNAL(dataReceived(const QString&)), SLOT(slotDataReceived(const QString&))); |
15 | connect(_ibase, SIGNAL(lookingUpHost()), SLOT(slotLookingUpHost())); | 15 | connect(_ibase, SIGNAL(lookingUpHost()), SLOT(slotLookingUpHost())); |
16 | connect(_ibase, SIGNAL(hostFound()), SLOT(slotHostFound())); | 16 | connect(_ibase, SIGNAL(hostFound()), SLOT(slotHostFound())); |
17 | connect(_ibase, SIGNAL(connected()), SLOT(slotConnected())); | 17 | connect(_ibase, SIGNAL(connected()), SLOT(slotConnected())); |
18 | connect(_ibase, SIGNAL(disconnected()), SLOT(slotDisconnected())); | 18 | connect(_ibase, SIGNAL(disconnected()), SLOT(slotDisconnected())); |
19 | connect(_ibase, SIGNAL(error(int)), SLOT(slotError(int))); | 19 | connect(_ibase, SIGNAL(error(int)), SLOT(slotError(int))); |
20 | } | 20 | } |
21 | 21 | ||
22 | void IMAPHandler::doLogin() | 22 | void IMAPHandler::doLogin() |
23 | { | 23 | { |
24 | if (_loggedin) return; | 24 | if (_loggedin) return; |
25 | if (_loggingin) return; | 25 | if (_loggingin) return; |
26 | 26 | ||
27 | _loggingin = true; | 27 | _loggingin = true; |
28 | iLogin(_account.user(), _account.pass()); | 28 | iLogin(_account.user(), _account.pass()); |
29 | } | 29 | } |
30 | 30 | ||
31 | QString IMAPHandler::iCapability() | 31 | QString IMAPHandler::iCapability() |
32 | { | 32 | { |
33 | _ibase->sendCommand(QString("%1 CAPABILITY\r\n") | 33 | _ibase->sendCommand(QString("%1 CAPABILITY\r\n") |
34 | .arg(tag())); | 34 | .arg(tag())); |
35 | return tag(false); | 35 | return tag(false); |
36 | } | 36 | } |
37 | 37 | ||
38 | QString IMAPHandler::iNoop() | 38 | QString IMAPHandler::iNoop() |
39 | { | 39 | { |
40 | _ibase->sendCommand(QString("%1 NOOP\r\n") | 40 | _ibase->sendCommand(QString("%1 NOOP\r\n") |
41 | .arg(tag())); | 41 | .arg(tag())); |
42 | return tag(false); | 42 | return tag(false); |
43 | } | 43 | } |
44 | 44 | ||
45 | QString IMAPHandler::iLogout() | 45 | QString IMAPHandler::iLogout() |
46 | { | 46 | { |
47 | _ibase->sendCommand(QString("%1 LOGOUT\r\n") | 47 | _ibase->sendCommand(QString("%1 LOGOUT\r\n") |
48 | .arg(tag())); | 48 | .arg(tag())); |
49 | return tag(false); | 49 | return tag(false); |
50 | } | 50 | } |
51 | 51 | ||
52 | QString IMAPHandler::iAuthenticate(const QString &mechanism) | 52 | QString IMAPHandler::iAuthenticate(const QString &mechanism) |
53 | { | 53 | { |
54 | _ibase->sendCommand(QString("%1 AUTHENTICATE \"%2\"\r\n") | 54 | _ibase->sendCommand(QString("%1 AUTHENTICATE \"%2\"\r\n") |
55 | .arg(tag()) | 55 | .arg(tag()) |
56 | .arg(escape(mechanism))); | 56 | .arg(escape(mechanism))); |
57 | return tag(false); | 57 | return tag(false); |
58 | } | 58 | } |
59 | 59 | ||
60 | QString IMAPHandler::iLogin(const QString &user, const QString &pass) | 60 | QString IMAPHandler::iLogin(const QString &user, const QString &pass) |
61 | { | 61 | { |
62 | _ibase->sendCommand(QString("%1 LOGIN \"%2\" \"%3\"\r\n") | 62 | _ibase->sendCommand(QString("%1 LOGIN \"%2\" \"%3\"\r\n") |
63 | .arg(tag()) | 63 | .arg(tag()) |
64 | .arg(escape(user)) | 64 | .arg(escape(user)) |
65 | .arg(escape(pass))); | 65 | .arg(escape(pass))); |
66 | return tag(false); | 66 | return tag(false); |
67 | } | 67 | } |
68 | 68 | ||
69 | QString IMAPHandler::iSelect(const QString &mailbox) | 69 | QString IMAPHandler::iSelect(const QString &mailbox) |
70 | { | 70 | { |
71 | doLogin(); | 71 | doLogin(); |
72 | 72 | ||
73 | _ibase->sendCommand(QString("%1 SELECT \"%2\"\r\n") | 73 | _ibase->sendCommand(QString("%1 SELECT \"%2\"\r\n") |
74 | .arg(tag()) | 74 | .arg(tag()) |
75 | .arg(escape(mailbox))); | 75 | .arg(escape(mailbox))); |
76 | return tag(false); | 76 | return tag(false); |
77 | } | 77 | } |
78 | 78 | ||
79 | QString IMAPHandler::iExamine(const QString &mailbox) | 79 | QString IMAPHandler::iExamine(const QString &mailbox) |
80 | { | 80 | { |
81 | doLogin(); | 81 | doLogin(); |
82 | 82 | ||
83 | _ibase->sendCommand(QString("%1 EXAMINE \"%2\"\r\n") | 83 | _ibase->sendCommand(QString("%1 EXAMINE \"%2\"\r\n") |
84 | .arg(tag()) | 84 | .arg(tag()) |
85 | .arg(escape(mailbox))); | 85 | .arg(escape(mailbox))); |
86 | return tag(false); | 86 | return tag(false); |
87 | } | 87 | } |
88 | 88 | ||
89 | QString IMAPHandler::iCreate(const QString &mailbox) | 89 | QString IMAPHandler::iCreate(const QString &mailbox) |
90 | { | 90 | { |
91 | doLogin(); | 91 | doLogin(); |
92 | 92 | ||
93 | _ibase->sendCommand(QString("%1 CREATE \"%2\"\r\n") | 93 | _ibase->sendCommand(QString("%1 CREATE \"%2\"\r\n") |
94 | .arg(tag()) | 94 | .arg(tag()) |
95 | .arg(escape(mailbox))); | 95 | .arg(escape(mailbox))); |
96 | return tag(false); | 96 | return tag(false); |
97 | } | 97 | } |
98 | 98 | ||
99 | QString IMAPHandler::iDelete(const QString &mailbox) | 99 | QString IMAPHandler::iDelete(const QString &mailbox) |
100 | { | 100 | { |
101 | doLogin(); | 101 | doLogin(); |
102 | 102 | ||
103 | _ibase->sendCommand(QString("%1 DELETE \"%2\"\r\n") | 103 | _ibase->sendCommand(QString("%1 DELETE \"%2\"\r\n") |
104 | .arg(tag()) | 104 | .arg(tag()) |
105 | .arg(escape(mailbox))); | 105 | .arg(escape(mailbox))); |
106 | return tag(false); | 106 | return tag(false); |
107 | } | 107 | } |
108 | 108 | ||
109 | QString IMAPHandler::iRename(const QString &mailbox, const QString &newMailbox) | 109 | QString IMAPHandler::iRename(const QString &mailbox, const QString &newMailbox) |
110 | { | 110 | { |
@@ -206,141 +206,141 @@ QString IMAPHandler::iExpunge() | |||
206 | { | 206 | { |
207 | doLogin(); | 207 | doLogin(); |
208 | 208 | ||
209 | _ibase->sendCommand(QString("%1 EXPUNGE\r\n") | 209 | _ibase->sendCommand(QString("%1 EXPUNGE\r\n") |
210 | .arg(tag())); | 210 | .arg(tag())); |
211 | return tag(false); | 211 | return tag(false); |
212 | } | 212 | } |
213 | 213 | ||
214 | QString IMAPHandler::iSearch(const QString &search, const QString &charset) | 214 | QString IMAPHandler::iSearch(const QString &search, const QString &charset) |
215 | { | 215 | { |
216 | doLogin(); | 216 | doLogin(); |
217 | 217 | ||
218 | _ibase->sendCommand(QString("%1 SEARCH %2 %3\r\n") | 218 | _ibase->sendCommand(QString("%1 SEARCH %2 %3\r\n") |
219 | .arg(tag()) | 219 | .arg(tag()) |
220 | .arg(charset.isEmpty() ? QString(0) : escape(charset)) | 220 | .arg(charset.isEmpty() ? QString(0) : escape(charset)) |
221 | .arg(search)); | 221 | .arg(search)); |
222 | return tag(false); | 222 | return tag(false); |
223 | } | 223 | } |
224 | 224 | ||
225 | QString IMAPHandler::iFetch(const QString &message, const QString &items) | 225 | QString IMAPHandler::iFetch(const QString &message, const QString &items) |
226 | { | 226 | { |
227 | doLogin(); | 227 | doLogin(); |
228 | 228 | ||
229 | _ibase->sendCommand(QString("%1 FETCH %2 (%3)\r\n") | 229 | _ibase->sendCommand(QString("%1 FETCH %2 (%3)\r\n") |
230 | .arg(tag()) | 230 | .arg(tag()) |
231 | .arg(message) | 231 | .arg(message) |
232 | .arg(items)); | 232 | .arg(items)); |
233 | return tag(false); | 233 | return tag(false); |
234 | } | 234 | } |
235 | 235 | ||
236 | QString IMAPHandler::iStore(const QString &message, const QString &items) | 236 | QString IMAPHandler::iStore(const QString &message, const QString &items) |
237 | { | 237 | { |
238 | doLogin(); | 238 | doLogin(); |
239 | 239 | ||
240 | _ibase->sendCommand(QString("%1 STORE %2 %3\r\n") | 240 | _ibase->sendCommand(QString("%1 STORE %2 %3\r\n") |
241 | .arg(tag()) | 241 | .arg(tag()) |
242 | .arg(message) | 242 | .arg(message) |
243 | .arg(items)); | 243 | .arg(items)); |
244 | return tag(false); | 244 | return tag(false); |
245 | } | 245 | } |
246 | 246 | ||
247 | QString IMAPHandler::iCopy(const QString &message, const QString &mailbox) | 247 | QString IMAPHandler::iCopy(const QString &message, const QString &mailbox) |
248 | { | 248 | { |
249 | doLogin(); | 249 | doLogin(); |
250 | 250 | ||
251 | _ibase->sendCommand(QString("%1 COPY %2 \"%3\"\r\n") | 251 | _ibase->sendCommand(QString("%1 COPY %2 \"%3\"\r\n") |
252 | .arg(tag()) | 252 | .arg(tag()) |
253 | .arg(message) | 253 | .arg(message) |
254 | .arg(escape(mailbox))); | 254 | .arg(escape(mailbox))); |
255 | return tag(false); | 255 | return tag(false); |
256 | } | 256 | } |
257 | 257 | ||
258 | QString IMAPHandler::iUid(const QString &command, const QString &arguments) | 258 | QString IMAPHandler::iUid(const QString &command, const QString &arguments) |
259 | { | 259 | { |
260 | doLogin(); | 260 | doLogin(); |
261 | 261 | ||
262 | _ibase->sendCommand(QString("%1 UID %2 %3\r\n") | 262 | _ibase->sendCommand(QString("%1 UID %2 %3\r\n") |
263 | .arg(tag()) | 263 | .arg(tag()) |
264 | .arg(command) | 264 | .arg(command) |
265 | .arg(arguments)); | 265 | .arg(arguments)); |
266 | return tag(false); | 266 | return tag(false); |
267 | } | 267 | } |
268 | 268 | ||
269 | QString IMAPHandler::iX(const QString &commandAtom, const QString &arguments) | 269 | QString IMAPHandler::iX(const QString &commandAtom, const QString &arguments) |
270 | { | 270 | { |
271 | doLogin(); | 271 | doLogin(); |
272 | 272 | ||
273 | _ibase->sendCommand(QString("%1 X%2 %3\r\n") | 273 | _ibase->sendCommand(QString("%1 X%2 %3\r\n") |
274 | .arg(tag()) | 274 | .arg(tag()) |
275 | .arg(commandAtom) | 275 | .arg(commandAtom) |
276 | .arg(arguments)); | 276 | .arg(arguments)); |
277 | return tag(false); | 277 | return tag(false); |
278 | } | 278 | } |
279 | 279 | ||
280 | QString IMAPHandler::escape(const QString &in) | 280 | QString IMAPHandler::escape(const QString &in) |
281 | { | 281 | { |
282 | QString in_ = in; | 282 | QString in_ = in; |
283 | return in_.replace(QRegExp("\""), "\\\""); | 283 | return in_.replace(QRegExp("\""), "\\\""); |
284 | } | 284 | } |
285 | 285 | ||
286 | QString IMAPHandler::tag(bool count) | 286 | QString IMAPHandler::tag(bool count) |
287 | { | 287 | { |
288 | return QString("a%1").arg(count ? _tag++ : _tag); | 288 | return QString("a%1").arg(count ? _tag++ : _tag); |
289 | } | 289 | } |
290 | 290 | ||
291 | void IMAPHandler::slotDataReceived(const QString &data) | 291 | void IMAPHandler::slotDataReceived(const QString &data) |
292 | { | 292 | { |
293 | if (!_ready) { | 293 | if (!_ready) { |
294 | // The first data is always the greeting string. | 294 | // The first data is always the greeting string. |
295 | // We can ignore it. | 295 | // We can ignore it. |
296 | _ready = true; | 296 | _ready = true; |
297 | return; | 297 | return; |
298 | } | 298 | } |
299 | 299 | ||
300 | 300 | ||
301 | IMAPResponseParser parser; | 301 | IMAPResponseParser parser; |
302 | //connect ( &parser, SIGNAL( needMoreData ( QString & )), _ibase, SLOT( tryRead ( QString & ))); | 302 | //connect ( &parser, SIGNAL( needMoreData(QString&)), _ibase, SLOT( tryRead(QString&))); |
303 | parser. parse ( data ); | 303 | parser. parse ( data ); |
304 | IMAPResponse response = parser.response(); | 304 | IMAPResponse response = parser.response(); |
305 | //disconnect ( &parser, SIGNAL( needMoreData ( QString & )), _ibase, SLOT( tryRead ( QString & ))); | 305 | //disconnect ( &parser, SIGNAL( needMoreData(QString&)), _ibase, SLOT( tryRead(QString&))); |
306 | response.setImapHandler(this); | 306 | response.setImapHandler(this); |
307 | 307 | ||
308 | if (!_loggingin) { qDebug("Emitting gotResponse!\n" ); emit gotResponse(response); } | 308 | if (!_loggingin) { qDebug("Emitting gotResponse!\n" ); emit gotResponse(response); } |
309 | else { | 309 | else { |
310 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 310 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
311 | _loggingin = false; | 311 | _loggingin = false; |
312 | _loggedin = true; | 312 | _loggedin = true; |
313 | qWarning("OK. Logged in. Leaving loggingin state."); | 313 | qWarning("OK. Logged in. Leaving loggingin state."); |
314 | } else { | 314 | } else { |
315 | _loggingin = false; | 315 | _loggingin = false; |
316 | emit IMAPError(IMAPBase::IMAPErrLoginFailed); | 316 | emit IMAPError(IMAPBase::IMAPErrLoginFailed); |
317 | } | 317 | } |
318 | } | 318 | } |
319 | } | 319 | } |
320 | 320 | ||
321 | void IMAPHandler::slotLookingUpHost() | 321 | void IMAPHandler::slotLookingUpHost() |
322 | { | 322 | { |
323 | emit IMAPLookingUpHost(); | 323 | emit IMAPLookingUpHost(); |
324 | } | 324 | } |
325 | 325 | ||
326 | void IMAPHandler::slotHostFound() | 326 | void IMAPHandler::slotHostFound() |
327 | { | 327 | { |
328 | emit IMAPHostFound(); | 328 | emit IMAPHostFound(); |
329 | } | 329 | } |
330 | 330 | ||
331 | void IMAPHandler::slotConnected() | 331 | void IMAPHandler::slotConnected() |
332 | { | 332 | { |
333 | emit IMAPConnected(); | 333 | emit IMAPConnected(); |
334 | } | 334 | } |
335 | 335 | ||
336 | void IMAPHandler::slotDisconnected() | 336 | void IMAPHandler::slotDisconnected() |
337 | { | 337 | { |
338 | _loggedin = false; | 338 | _loggedin = false; |
339 | emit IMAPDisconnected(); | 339 | emit IMAPDisconnected(); |
340 | } | 340 | } |
341 | 341 | ||
342 | void IMAPHandler::slotError(int err) | 342 | void IMAPHandler::slotError(int err) |
343 | { | 343 | { |
344 | emit IMAPError(err); | 344 | emit IMAPError(err); |
345 | } | 345 | } |
346 | 346 | ||
diff --git a/noncore/unsupported/mail2/listviewplus.cpp b/noncore/unsupported/mail2/listviewplus.cpp index ce5f35f..722b347 100644 --- a/noncore/unsupported/mail2/listviewplus.cpp +++ b/noncore/unsupported/mail2/listviewplus.cpp | |||
@@ -1,54 +1,54 @@ | |||
1 | #include <qpopupmenu.h> | 1 | #include <qpopupmenu.h> |
2 | #include <qtimer.h> | 2 | #include <qtimer.h> |
3 | 3 | ||
4 | #include "listviewplus.h" | 4 | #include "listviewplus.h" |
5 | 5 | ||
6 | ListViewPlus::ListViewPlus(QWidget *parent, const char *name, WFlags fl) | 6 | ListViewPlus::ListViewPlus(QWidget *parent, const char *name, WFlags fl) |
7 | : QListView(parent, name, fl) | 7 | : QListView(parent, name, fl) |
8 | { | 8 | { |
9 | 9 | ||
10 | } | 10 | } |
11 | 11 | ||
12 | void ListViewPlus::keyPressEvent(QKeyEvent *event) | 12 | void ListViewPlus::keyPressEvent(QKeyEvent *event) |
13 | { | 13 | { |
14 | switch(event->key()) { | 14 | switch(event->key()) { |
15 | case Qt::Key_Space: // FALLTHROUGH | 15 | case Qt::Key_Space: // FALLTHROUGH |
16 | case Qt::Key_Enter: | 16 | case Qt::Key_Enter: |
17 | if (currentItem() != 0) | 17 | if (currentItem() != 0) |
18 | emit clicked(currentItem()); | 18 | emit clicked(currentItem()); |
19 | break; | 19 | break; |
20 | default: break; | 20 | default: break; |
21 | } | 21 | } |
22 | 22 | ||
23 | QListView::keyPressEvent(event); | 23 | QListView::keyPressEvent(event); |
24 | } | 24 | } |
25 | 25 | ||
26 | void ListViewPlus::setPopup(QPopupMenu *popup, int delay) | 26 | void ListViewPlus::setPopup(QPopupMenu *popup, int delay) |
27 | { | 27 | { |
28 | _popup = popup; | 28 | _popup = popup; |
29 | _delay = delay; | 29 | _delay = delay; |
30 | 30 | ||
31 | connect(this, SIGNAL(pressed(QListViewItem *, const QPoint &, int)), SLOT(_initPopup(QListViewItem *, const QPoint &, int))); | 31 | connect(this, SIGNAL(pressed(QListViewItem*,const QPoint&,int)), SLOT(_initPopup(QListViewItem*,const QPoint&,int))); |
32 | connect(this, SIGNAL(clicked(QListViewItem *, const QPoint &, int)), SLOT(_cancelPopup(QListViewItem *, const QPoint &, int))); | 32 | connect(this, SIGNAL(clicked(QListViewItem*,const QPoint&,int)), SLOT(_cancelPopup(QListViewItem*,const QPoint&,int))); |
33 | } | 33 | } |
34 | 34 | ||
35 | void ListViewPlus::_initPopup(QListViewItem *, const QPoint &point, int) | 35 | void ListViewPlus::_initPopup(QListViewItem *, const QPoint &point, int) |
36 | { | 36 | { |
37 | _point = point; | 37 | _point = point; |
38 | 38 | ||
39 | _timer = new QTimer(); | 39 | _timer = new QTimer(); |
40 | _timer->start(_delay, true); | 40 | _timer->start(_delay, true); |
41 | 41 | ||
42 | connect(_timer, SIGNAL(timeout()), this, SLOT(_showPopup())); | 42 | connect(_timer, SIGNAL(timeout()), this, SLOT(_showPopup())); |
43 | } | 43 | } |
44 | 44 | ||
45 | void ListViewPlus::_cancelPopup(QListViewItem *, const QPoint &, int) | 45 | void ListViewPlus::_cancelPopup(QListViewItem *, const QPoint &, int) |
46 | { | 46 | { |
47 | delete _timer; | 47 | delete _timer; |
48 | } | 48 | } |
49 | 49 | ||
50 | void ListViewPlus::_showPopup() | 50 | void ListViewPlus::_showPopup() |
51 | { | 51 | { |
52 | _popup->popup(_point); | 52 | _popup->popup(_point); |
53 | } | 53 | } |
54 | 54 | ||
diff --git a/noncore/unsupported/mail2/mailtable.cpp b/noncore/unsupported/mail2/mailtable.cpp index fd179f0..56feab0 100644 --- a/noncore/unsupported/mail2/mailtable.cpp +++ b/noncore/unsupported/mail2/mailtable.cpp | |||
@@ -1,171 +1,171 @@ | |||
1 | #include <qmessagebox.h> | 1 | #include <qmessagebox.h> |
2 | #include <qpopupmenu.h> | 2 | #include <qpopupmenu.h> |
3 | #include <qheader.h> | 3 | #include <qheader.h> |
4 | #include <qtimer.h> | 4 | #include <qtimer.h> |
5 | 5 | ||
6 | #include "folderwidget.h" | 6 | #include "folderwidget.h" |
7 | #include "imaphandler.h" | 7 | #include "imaphandler.h" |
8 | #include "mailtable.h" | 8 | #include "mailtable.h" |
9 | 9 | ||
10 | MailTableItem::MailTableItem(QListView *parent, IMAPResponseFETCH fetch) | 10 | MailTableItem::MailTableItem(QListView *parent, IMAPResponseFETCH fetch) |
11 | : QListViewItem(parent), _fetch(fetch) | 11 | : QListViewItem(parent), _fetch(fetch) |
12 | { | 12 | { |
13 | _draft = false; | 13 | _draft = false; |
14 | _new = false; | 14 | _new = false; |
15 | _unseen = true; | 15 | _unseen = true; |
16 | 16 | ||
17 | QValueList<IMAPResponseEnums::IMAPResponseFlags>::Iterator it; | 17 | QValueList<IMAPResponseEnums::IMAPResponseFlags>::Iterator it; |
18 | QValueList<IMAPResponseEnums::IMAPResponseFlags> flags = fetch.flags(); | 18 | QValueList<IMAPResponseEnums::IMAPResponseFlags> flags = fetch.flags(); |
19 | for (it = flags.begin(); it != flags.end(); it++) { | 19 | for (it = flags.begin(); it != flags.end(); it++) { |
20 | if (*it == IMAPResponseEnums::Draft) _draft = true; | 20 | if (*it == IMAPResponseEnums::Draft) _draft = true; |
21 | else if (*it == IMAPResponseEnums::Recent) _new = true; | 21 | else if (*it == IMAPResponseEnums::Recent) _new = true; |
22 | else if (*it == IMAPResponseEnums::Seen) _unseen = false; | 22 | else if (*it == IMAPResponseEnums::Seen) _unseen = false; |
23 | } | 23 | } |
24 | 24 | ||
25 | setText(0, fetch.envelope().from()[0].name().isEmpty() ? QObject::tr("(no from)") : fetch.envelope().from()[0].name()); | 25 | setText(0, fetch.envelope().from()[0].name().isEmpty() ? QObject::tr("(no from)") : fetch.envelope().from()[0].name()); |
26 | setText(1, fetch.envelope().subject().isEmpty() ? QObject::tr("(no subject)") : fetch.envelope().subject()); | 26 | setText(1, fetch.envelope().subject().isEmpty() ? QObject::tr("(no subject)") : fetch.envelope().subject()); |
27 | setText(2, fetch.envelope().mailDate().isEmpty() ? QObject::tr("(no date)") : fetch.envelope().mailDate()); | 27 | setText(2, fetch.envelope().mailDate().isEmpty() ? QObject::tr("(no date)") : fetch.envelope().mailDate()); |
28 | } | 28 | } |
29 | 29 | ||
30 | void MailTableItem::paintCell(QPainter *painter, const QColorGroup &cg, int col, int width, int align) | 30 | void MailTableItem::paintCell(QPainter *painter, const QColorGroup &cg, int col, int width, int align) |
31 | { | 31 | { |
32 | QColor color = cg.color(QColorGroup::Text); | 32 | QColor color = cg.color(QColorGroup::Text); |
33 | QFont font = painter->font(); | 33 | QFont font = painter->font(); |
34 | if (_draft) { | 34 | if (_draft) { |
35 | color = QColor("#707070"); | 35 | color = QColor("#707070"); |
36 | } else if (_new) { | 36 | } else if (_new) { |
37 | color = QColor("#ff0000"); | 37 | color = QColor("#ff0000"); |
38 | font.setBold(true); | 38 | font.setBold(true); |
39 | } else if (_unseen) { | 39 | } else if (_unseen) { |
40 | font.setBold(true); | 40 | font.setBold(true); |
41 | } | 41 | } |
42 | 42 | ||
43 | painter->setFont(font); | 43 | painter->setFont(font); |
44 | QColorGroup cg_(cg); | 44 | QColorGroup cg_(cg); |
45 | cg_.setColor(QColorGroup::Text, color); | 45 | cg_.setColor(QColorGroup::Text, color); |
46 | 46 | ||
47 | QListViewItem::paintCell(painter, cg_, col, width, align); | 47 | QListViewItem::paintCell(painter, cg_, col, width, align); |
48 | } | 48 | } |
49 | 49 | ||
50 | MailTable::MailTable(QWidget *parent, const char *name, WFlags fl) | 50 | MailTable::MailTable(QWidget *parent, const char *name, WFlags fl) |
51 | : ListViewPlus(parent, name, fl), _parent(parent) | 51 | : ListViewPlus(parent, name, fl), _parent(parent) |
52 | { | 52 | { |
53 | _stopped = false; | 53 | _stopped = false; |
54 | 54 | ||
55 | setSorting(-1); | 55 | setSorting(-1); |
56 | 56 | ||
57 | setAllColumnsShowFocus(true); | 57 | setAllColumnsShowFocus(true); |
58 | addColumn(tr("From"), 100); | 58 | addColumn(tr("From"), 100); |
59 | addColumn(tr("Subject"), 100); | 59 | addColumn(tr("Subject"), 100); |
60 | addColumn(tr("Date"), 100); | 60 | addColumn(tr("Date"), 100); |
61 | 61 | ||
62 | QPopupMenu *menu = new QPopupMenu(this); | 62 | QPopupMenu *menu = new QPopupMenu(this); |
63 | menu->insertItem(tr("Copy"), MENU_COPY); | 63 | menu->insertItem(tr("Copy"), MENU_COPY); |
64 | 64 | ||
65 | QPopupMenu *markMenu = new QPopupMenu(this); | 65 | QPopupMenu *markMenu = new QPopupMenu(this); |
66 | markMenu->insertItem(tr("Seen"), MENU_MARK_READ); | 66 | markMenu->insertItem(tr("Seen"), MENU_MARK_READ); |
67 | markMenu->insertItem(tr("Unseen"), MENU_MARK_UNREAD); | 67 | markMenu->insertItem(tr("Unseen"), MENU_MARK_UNREAD); |
68 | markMenu->insertSeparator(); | 68 | markMenu->insertSeparator(); |
69 | markMenu->insertItem(tr("Marked"), MENU_MARK_MARKED); | 69 | markMenu->insertItem(tr("Marked"), MENU_MARK_MARKED); |
70 | markMenu->insertItem(tr("Unmarked"), MENU_MARK_UNMARKED); | 70 | markMenu->insertItem(tr("Unmarked"), MENU_MARK_UNMARKED); |
71 | 71 | ||
72 | menu->insertItem(tr("Mark as..."), markMenu, MENU_MARK); | 72 | menu->insertItem(tr("Mark as..."), markMenu, MENU_MARK); |
73 | menu->insertSeparator(); | 73 | menu->insertSeparator(); |
74 | menu->insertItem(tr("Delete Mail"), MENU_DELETE); | 74 | menu->insertItem(tr("Delete Mail"), MENU_DELETE); |
75 | setPopup(menu); | 75 | setPopup(menu); |
76 | 76 | ||
77 | connect(this, SIGNAL(clicked(QListViewItem *)), SLOT(itemClicked(QListViewItem *))); | 77 | connect(this, SIGNAL(clicked(QListViewItem*)), SLOT(itemClicked(QListViewItem*))); |
78 | } | 78 | } |
79 | 79 | ||
80 | void MailTable::setFolder(Folder folder) | 80 | void MailTable::setFolder(Folder folder) |
81 | { | 81 | { |
82 | folder.topFolder().handler()->iSelect(folder.fullName()); | 82 | folder.topFolder().handler()->iSelect(folder.fullName()); |
83 | _handler = folder.topFolder().handler(); | 83 | _handler = folder.topFolder().handler(); |
84 | connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPSelect(IMAPResponse &))); | 84 | connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPSelect(IMAPResponse&))); |
85 | } | 85 | } |
86 | 86 | ||
87 | void MailTable::setHeaders(QValueList<IMAPResponseFETCH> response) | 87 | void MailTable::setHeaders(QValueList<IMAPResponseFETCH> response) |
88 | { | 88 | { |
89 | clear(); | 89 | clear(); |
90 | QValueList<IMAPResponseFETCH>::Iterator it; | 90 | QValueList<IMAPResponseFETCH>::Iterator it; |
91 | for (it = response.begin(); it != response.end(); it++) { | 91 | for (it = response.begin(); it != response.end(); it++) { |
92 | (void) new MailTableItem(this, *it); | 92 | (void) new MailTableItem(this, *it); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | void MailTable::slotIMAPSelect(IMAPResponse &response) | 96 | void MailTable::slotIMAPSelect(IMAPResponse &response) |
97 | { | 97 | { |
98 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSelect(IMAPResponse &))); | 98 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPSelect(IMAPResponse&))); |
99 | 99 | ||
100 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 100 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
101 | clear(); | 101 | clear(); |
102 | QString mails = response.EXISTS()[0].mails(); | 102 | QString mails = response.EXISTS()[0].mails(); |
103 | if (mails.toInt() == 0) { | 103 | if (mails.toInt() == 0) { |
104 | emit status(tr("Mailbox contained no mails.")); | 104 | emit status(tr("Mailbox contained no mails.")); |
105 | return; | 105 | return; |
106 | } | 106 | } |
107 | int a = mails.toInt() / 5; | 107 | int a = mails.toInt() / 5; |
108 | int b = mails.toInt() % 5; | 108 | int b = mails.toInt() % 5; |
109 | 109 | ||
110 | _downloadSteps = a; | 110 | _downloadSteps = a; |
111 | if (b > 0) _downloadSteps++; | 111 | if (b > 0) _downloadSteps++; |
112 | _lastStep = b; | 112 | _lastStep = b; |
113 | _currentProgress = 0; | 113 | _currentProgress = 0; |
114 | 114 | ||
115 | emit totalSteps(_downloadSteps); | 115 | emit totalSteps(_downloadSteps); |
116 | emit progress(_currentProgress); | 116 | emit progress(_currentProgress); |
117 | emit stopEnabled(true); | 117 | emit stopEnabled(true); |
118 | 118 | ||
119 | response.imapHandler()->iFetch(QString("1:%1").arg((a == 0) ? b : 5), "ENVELOPE FLAGS UID"); | 119 | response.imapHandler()->iFetch(QString("1:%1").arg((a == 0) ? b : 5), "ENVELOPE FLAGS UID"); |
120 | emit status(tr("Getting mail headers...")); | 120 | emit status(tr("Getting mail headers...")); |
121 | connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPFetch(IMAPResponse &))); | 121 | connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPFetch(IMAPResponse&))); |
122 | } else { | 122 | } else { |
123 | QMessageBox::warning(this, tr("Error"), tr("<p>An error occoured during the selection of the mailbox. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); | 123 | QMessageBox::warning(this, tr("Error"), tr("<p>An error occoured during the selection of the mailbox. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); |
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | void MailTable::slotIMAPFetch(IMAPResponse &response) | 127 | void MailTable::slotIMAPFetch(IMAPResponse &response) |
128 | { | 128 | { |
129 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPFetch(IMAPResponse &))); | 129 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPFetch(IMAPResponse&))); |
130 | 130 | ||
131 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 131 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
132 | QValueList<IMAPResponseFETCH>::Iterator it; | 132 | QValueList<IMAPResponseFETCH>::Iterator it; |
133 | QValueList<IMAPResponseFETCH> fetch = response.FETCH(); | 133 | QValueList<IMAPResponseFETCH> fetch = response.FETCH(); |
134 | for (it = fetch.begin(); it != fetch.end(); it++) { | 134 | for (it = fetch.begin(); it != fetch.end(); it++) { |
135 | (void) new MailTableItem(this, *it); | 135 | (void) new MailTableItem(this, *it); |
136 | } | 136 | } |
137 | emit progress(++_currentProgress); | 137 | emit progress(++_currentProgress); |
138 | 138 | ||
139 | if (_currentProgress != _downloadSteps) { | 139 | if (_currentProgress != _downloadSteps) { |
140 | if (_stopped) { | 140 | if (_stopped) { |
141 | _currentProgress = 0; | 141 | _currentProgress = 0; |
142 | _downloadSteps = 0; | 142 | _downloadSteps = 0; |
143 | _lastStep = 0; | 143 | _lastStep = 0; |
144 | _stopped = false; | 144 | _stopped = false; |
145 | emit status(tr("Stopped")); | 145 | emit status(tr("Stopped")); |
146 | emit resetProgress(); | 146 | emit resetProgress(); |
147 | emit stopEnabled(false); | 147 | emit stopEnabled(false); |
148 | } else { | 148 | } else { |
149 | response.imapHandler()->iFetch(QString("%1:%2").arg(_currentProgress * 5 + 1).arg((_currentProgress + 1 == _downloadSteps) ? _currentProgress * 5 + _lastStep : _currentProgress * 5 + 5), "ENVELOPE FLAGS UID"); | 149 | response.imapHandler()->iFetch(QString("%1:%2").arg(_currentProgress * 5 + 1).arg((_currentProgress + 1 == _downloadSteps) ? _currentProgress * 5 + _lastStep : _currentProgress * 5 + 5), "ENVELOPE FLAGS UID"); |
150 | connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPFetch(IMAPResponse &))); | 150 | connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPFetch(IMAPResponse&))); |
151 | } | 151 | } |
152 | } else { | 152 | } else { |
153 | _currentProgress = 0; | 153 | _currentProgress = 0; |
154 | _downloadSteps = 0; | 154 | _downloadSteps = 0; |
155 | _lastStep = 0; | 155 | _lastStep = 0; |
156 | emit status(tr("Got all mail headers.")); | 156 | emit status(tr("Got all mail headers.")); |
157 | emit resetProgress(); | 157 | emit resetProgress(); |
158 | emit stopEnabled(false); | 158 | emit stopEnabled(false); |
159 | } | 159 | } |
160 | } else { | 160 | } else { |
161 | emit status(tr("<font color=#ff0000>Couldn't fetch mail.")); | 161 | emit status(tr("<font color=#ff0000>Couldn't fetch mail.")); |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | void MailTable::itemClicked(QListViewItem *item) | 165 | void MailTable::itemClicked(QListViewItem *item) |
166 | { | 166 | { |
167 | if (item == NULL) return; | 167 | if (item == NULL) return; |
168 | emit mailClicked(((MailTableItem *)item)->fetch(), _handler); | 168 | emit mailClicked(((MailTableItem *)item)->fetch(), _handler); |
169 | } | 169 | } |
170 | 170 | ||
171 | 171 | ||
diff --git a/noncore/unsupported/mail2/mainwindow.cpp b/noncore/unsupported/mail2/mainwindow.cpp index 0d09ec8..ce80391 100644 --- a/noncore/unsupported/mail2/mainwindow.cpp +++ b/noncore/unsupported/mail2/mainwindow.cpp | |||
@@ -1,118 +1,118 @@ | |||
1 | #include <qmessagebox.h> | 1 | #include <qmessagebox.h> |
2 | #include <qaction.h> | 2 | #include <qaction.h> |
3 | #include <qapplication.h> | 3 | #include <qapplication.h> |
4 | 4 | ||
5 | #include <qpe/qcopenvelope_qws.h> | 5 | #include <qpe/qcopenvelope_qws.h> |
6 | 6 | ||
7 | #include "mailstatusbar.h" | 7 | #include "mailstatusbar.h" |
8 | #include "folderwidget.h" | 8 | #include "folderwidget.h" |
9 | #include "mainwindow.h" | 9 | #include "mainwindow.h" |
10 | #include "configdiag.h" | 10 | #include "configdiag.h" |
11 | #include "configfile.h" | 11 | #include "configfile.h" |
12 | #include "searchdiag.h" | 12 | #include "searchdiag.h" |
13 | #include "mailtable.h" | 13 | #include "mailtable.h" |
14 | #include "composer.h" | 14 | #include "composer.h" |
15 | #include "viewmail.h" | 15 | #include "viewmail.h" |
16 | #include "mailfactory.h" | 16 | #include "mailfactory.h" |
17 | 17 | ||
18 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags fl) | 18 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags fl) |
19 | : MainWindowBase(parent, name, fl) | 19 | : MainWindowBase(parent, name, fl) |
20 | { | 20 | { |
21 | status->setStopEnabled(false); | 21 | status->setStopEnabled(false); |
22 | 22 | ||
23 | connect(folderView, SIGNAL(status(const QString &)), status, SLOT(setStatusText(const QString &))); | 23 | connect(folderView, SIGNAL(status(const QString&)), status, SLOT(setStatusText(const QString&))); |
24 | connect(folderView, SIGNAL(folderSelected(Folder)), mailView, SLOT(setFolder(Folder))); | 24 | connect(folderView, SIGNAL(folderSelected(Folder)), mailView, SLOT(setFolder(Folder))); |
25 | 25 | ||
26 | connect(mailView, SIGNAL(mailClicked(IMAPResponseFETCH, IMAPHandler *)), SLOT(mailClicked(IMAPResponseFETCH, IMAPHandler *))); | 26 | connect(mailView, SIGNAL(mailClicked(IMAPResponseFETCH,IMAPHandler*)), SLOT(mailClicked(IMAPResponseFETCH,IMAPHandler*))); |
27 | connect(mailView, SIGNAL(status(const QString &)), status, SLOT(setStatusText(const QString &))); | 27 | connect(mailView, SIGNAL(status(const QString&)), status, SLOT(setStatusText(const QString&))); |
28 | connect(mailView, SIGNAL(totalSteps(int)), status, SLOT(setProgressTotalSteps(int))); | 28 | connect(mailView, SIGNAL(totalSteps(int)), status, SLOT(setProgressTotalSteps(int))); |
29 | connect(mailView, SIGNAL(progress(int)), status, SLOT(setProgress(int))); | 29 | connect(mailView, SIGNAL(progress(int)), status, SLOT(setProgress(int))); |
30 | connect(mailView, SIGNAL(resetProgress()), status, SLOT(resetProgress())); | 30 | connect(mailView, SIGNAL(resetProgress()), status, SLOT(resetProgress())); |
31 | connect(mailView, SIGNAL(stopEnabled(bool)), status, SLOT(setStopEnabled(bool))); | 31 | connect(mailView, SIGNAL(stopEnabled(bool)), status, SLOT(setStopEnabled(bool))); |
32 | 32 | ||
33 | connect(status, SIGNAL(stop()), mailView, SLOT(stop())); | 33 | connect(status, SIGNAL(stop()), mailView, SLOT(stop())); |
34 | 34 | ||
35 | connect(compose, SIGNAL(activated()), SLOT(slotComposeNoParams())); | 35 | connect(compose, SIGNAL(activated()), SLOT(slotComposeNoParams())); |
36 | connect(sendQueue, SIGNAL(activated()), SLOT(slotSendQueued())); | 36 | connect(sendQueue, SIGNAL(activated()), SLOT(slotSendQueued())); |
37 | connect(findmails, SIGNAL(activated()), SLOT(slotSearch())); | 37 | connect(findmails, SIGNAL(activated()), SLOT(slotSearch())); |
38 | connect(configure, SIGNAL(activated()), SLOT(slotConfigure())); | 38 | connect(configure, SIGNAL(activated()), SLOT(slotConfigure())); |
39 | 39 | ||
40 | // Added by Stefan Eilers to allow starting by addressbook.. | 40 | // Added by Stefan Eilers to allow starting by addressbook.. |
41 | #if !defined(QT_NO_COP) | 41 | #if !defined(QT_NO_COP) |
42 | // QCopChannel *addressChannel = new QCopChannel("QPE/Application/mail" , this ); | 42 | // QCopChannel *addressChannel = new QCopChannel("QPE/Application/mail" , this ); |
43 | // connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), | 43 | // connect (addressChannel, SIGNAL( received(const QCString&,const QByteArray&)), |
44 | // this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); | 44 | // this, SLOT ( appMessage(const QCString&,const QByteArray&) ) ); |
45 | connect( qApp, SIGNAL( appMessage( const QCString&, const QByteArray& ) ), | 45 | connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), |
46 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); | 46 | this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); |
47 | #endif | 47 | #endif |
48 | } | 48 | } |
49 | 49 | ||
50 | // Added by Stefan Eilers to allow starting by addressbook.. | 50 | // Added by Stefan Eilers to allow starting by addressbook.. |
51 | void MainWindow::appMessage(const QCString &msg, const QByteArray &data) | 51 | void MainWindow::appMessage(const QCString &msg, const QByteArray &data) |
52 | { | 52 | { |
53 | if (msg == "writeMail(QString,QString)") { | 53 | if (msg == "writeMail(QString,QString)") { |
54 | QDataStream stream(data,IO_ReadOnly); | 54 | QDataStream stream(data,IO_ReadOnly); |
55 | QString name, email; | 55 | QString name, email; |
56 | stream >> name >> email; | 56 | stream >> name >> email; |
57 | 57 | ||
58 | qWarning("opie-mail:: Should send mail to %s with address %s", name.latin1(), email.latin1() ); | 58 | qWarning("opie-mail:: Should send mail to %s with address %s", name.latin1(), email.latin1() ); |
59 | 59 | ||
60 | slotCompose( name, email ); | 60 | slotCompose( name, email ); |
61 | 61 | ||
62 | }else{ | 62 | }else{ |
63 | QString str_message = msg; | 63 | QString str_message = msg; |
64 | qWarning("opie-mail:: Received unknown QCop-Message: %s", str_message.latin1() ); | 64 | qWarning("opie-mail:: Received unknown QCop-Message: %s", str_message.latin1() ); |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | void MainWindow::slotCompose( const QString& name, const QString& email ) | 68 | void MainWindow::slotCompose( const QString& name, const QString& email ) |
69 | { | 69 | { |
70 | Composer composer(this, 0, true); | 70 | Composer composer(this, 0, true); |
71 | 71 | ||
72 | // If there is a mailaddress given, create message.. | 72 | // If there is a mailaddress given, create message.. |
73 | if ( ! name.isEmpty() ){ | 73 | if ( ! name.isEmpty() ){ |
74 | qWarning("opie-mail:: Compose mail for %s with address %s", name.latin1(), email.latin1() ); | 74 | qWarning("opie-mail:: Compose mail for %s with address %s", name.latin1(), email.latin1() ); |
75 | SendMail compMail; | 75 | SendMail compMail; |
76 | compMail.setTo( "\"" + name + "\"" + " " + "<"+ email + ">"); | 76 | compMail.setTo( "\"" + name + "\"" + " " + "<"+ email + ">"); |
77 | composer.setSendMail( compMail ); | 77 | composer.setSendMail( compMail ); |
78 | } | 78 | } |
79 | composer.showMaximized(); | 79 | composer.showMaximized(); |
80 | composer.exec(); | 80 | composer.exec(); |
81 | } | 81 | } |
82 | 82 | ||
83 | void MainWindow::slotComposeNoParams() | 83 | void MainWindow::slotComposeNoParams() |
84 | { | 84 | { |
85 | slotCompose( 0l, 0l); | 85 | slotCompose( 0l, 0l); |
86 | } | 86 | } |
87 | 87 | ||
88 | void MainWindow::slotSendQueued() | 88 | void MainWindow::slotSendQueued() |
89 | { | 89 | { |
90 | Composer composer(this, 0, true, true); | 90 | Composer composer(this, 0, true, true); |
91 | // composer.sendQueue(); | 91 | // composer.sendQueue(); |
92 | composer.showMaximized(); | 92 | composer.showMaximized(); |
93 | composer.exec(); | 93 | composer.exec(); |
94 | //composer.close(); | 94 | //composer.close(); |
95 | } | 95 | } |
96 | 96 | ||
97 | void MainWindow::slotSearch() | 97 | void MainWindow::slotSearch() |
98 | { | 98 | { |
99 | SearchDiag searchDiag(this, 0, true); | 99 | SearchDiag searchDiag(this, 0, true); |
100 | searchDiag.showMaximized(); | 100 | searchDiag.showMaximized(); |
101 | searchDiag.exec(); | 101 | searchDiag.exec(); |
102 | } | 102 | } |
103 | 103 | ||
104 | void MainWindow::slotConfigure() | 104 | void MainWindow::slotConfigure() |
105 | { | 105 | { |
106 | ConfigDiag configDiag(this, 0, true); | 106 | ConfigDiag configDiag(this, 0, true); |
107 | configDiag.showMaximized(); | 107 | configDiag.showMaximized(); |
108 | configDiag.exec(); | 108 | configDiag.exec(); |
109 | 109 | ||
110 | connect(&configDiag, SIGNAL(changed()), folderView, SLOT(update())); | 110 | connect(&configDiag, SIGNAL(changed()), folderView, SLOT(update())); |
111 | } | 111 | } |
112 | 112 | ||
113 | void MainWindow::mailClicked(IMAPResponseFETCH mail, IMAPHandler *handler) | 113 | void MainWindow::mailClicked(IMAPResponseFETCH mail, IMAPHandler *handler) |
114 | { | 114 | { |
115 | ViewMail viewMail(mail, handler, this, 0, true); | 115 | ViewMail viewMail(mail, handler, this, 0, true); |
116 | viewMail.showMaximized(); | 116 | viewMail.showMaximized(); |
117 | viewMail.exec(); | 117 | viewMail.exec(); |
118 | } | 118 | } |
diff --git a/noncore/unsupported/mail2/searchdiag.cpp b/noncore/unsupported/mail2/searchdiag.cpp index 907f6ff..6fb4e4d 100644 --- a/noncore/unsupported/mail2/searchdiag.cpp +++ b/noncore/unsupported/mail2/searchdiag.cpp | |||
@@ -1,128 +1,128 @@ | |||
1 | #include <qmessagebox.h> | 1 | #include <qmessagebox.h> |
2 | #include <qpushbutton.h> | 2 | #include <qpushbutton.h> |
3 | #include <qcombobox.h> | 3 | #include <qcombobox.h> |
4 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
5 | 5 | ||
6 | #include <qpe/qpeapplication.h> | 6 | #include <qpe/qpeapplication.h> |
7 | 7 | ||
8 | #include "imaphandler.h" | 8 | #include "imaphandler.h" |
9 | #include "searchdiag.h" | 9 | #include "searchdiag.h" |
10 | #include "viewmail.h" | 10 | #include "viewmail.h" |
11 | 11 | ||
12 | #define INMENU_BODY0 | 12 | #define INMENU_BODY0 |
13 | #define INMENU_HEADERF1 | 13 | #define INMENU_HEADERF1 |
14 | #define INMENU_SUBJECT2 | 14 | #define INMENU_SUBJECT2 |
15 | #define INMENU_FROM3 | 15 | #define INMENU_FROM3 |
16 | #define INMENU_TO4 | 16 | #define INMENU_TO4 |
17 | 17 | ||
18 | SearchDiag::SearchDiag(QWidget *parent, const char *name, WFlags fl) | 18 | SearchDiag::SearchDiag(QWidget *parent, const char *name, WFlags fl) |
19 | : SearchDiagBase(parent, name, fl) | 19 | : SearchDiagBase(parent, name, fl) |
20 | { | 20 | { |
21 | _selected = false; | 21 | _selected = false; |
22 | 22 | ||
23 | in->insertItem(tr("Body"), INMENU_BODY); | 23 | in->insertItem(tr("Body"), INMENU_BODY); |
24 | in->insertItem(tr("Header Field"), INMENU_HEADERF); | 24 | in->insertItem(tr("Header Field"), INMENU_HEADERF); |
25 | in->insertItem(tr("Subject"), INMENU_SUBJECT); | 25 | in->insertItem(tr("Subject"), INMENU_SUBJECT); |
26 | in->insertItem(tr("From"), INMENU_FROM); | 26 | in->insertItem(tr("From"), INMENU_FROM); |
27 | in->insertItem(tr("To"), INMENU_TO); | 27 | in->insertItem(tr("To"), INMENU_TO); |
28 | 28 | ||
29 | connect(folderView, SIGNAL(folderSelected(Folder)), SLOT(folderSelected(Folder))); | 29 | connect(folderView, SIGNAL(folderSelected(Folder)), SLOT(folderSelected(Folder))); |
30 | connect(in, SIGNAL(activated(int)), SLOT(slotInItemActivated(int))); | 30 | connect(in, SIGNAL(activated(int)), SLOT(slotInItemActivated(int))); |
31 | connect(mailTable, SIGNAL(mailClicked(IMAPResponseFETCH, IMAPHandler *)), SLOT(slotMailClicked(IMAPResponseFETCH, IMAPHandler *))); | 31 | connect(mailTable, SIGNAL(mailClicked(IMAPResponseFETCH,IMAPHandler*)), SLOT(slotMailClicked(IMAPResponseFETCH,IMAPHandler*))); |
32 | } | 32 | } |
33 | 33 | ||
34 | void SearchDiag::accept() | 34 | void SearchDiag::accept() |
35 | { | 35 | { |
36 | if (searchFor->text().isEmpty()) { | 36 | if (searchFor->text().isEmpty()) { |
37 | QMessageBox::information(this, tr("Error"), tr("<p>Please enter what to search for.</p>"), tr("Ok")); | 37 | QMessageBox::information(this, tr("Error"), tr("<p>Please enter what to search for.</p>"), tr("Ok")); |
38 | return; | 38 | return; |
39 | } | 39 | } |
40 | 40 | ||
41 | if (!_selected) { | 41 | if (!_selected) { |
42 | QMessageBox::information(this, tr("Error"), tr("<p>Please select a folder.</p>"), tr("Ok")); | 42 | QMessageBox::information(this, tr("Error"), tr("<p>Please select a folder.</p>"), tr("Ok")); |
43 | return; | 43 | return; |
44 | } | 44 | } |
45 | 45 | ||
46 | if (in->currentItem() == INMENU_HEADERF && other->currentText().isEmpty()) { | 46 | if (in->currentItem() == INMENU_HEADERF && other->currentText().isEmpty()) { |
47 | QMessageBox::information(this, tr("Error"), tr("<p>Please enter a header field to search in.</p>"), tr("Ok")); | 47 | QMessageBox::information(this, tr("Error"), tr("<p>Please enter a header field to search in.</p>"), tr("Ok")); |
48 | return; | 48 | return; |
49 | } | 49 | } |
50 | 50 | ||
51 | _folder.topFolder().handler()->iSelect(_folder.fullName()); | 51 | _folder.topFolder().handler()->iSelect(_folder.fullName()); |
52 | connect(_folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPSelect(IMAPResponse &))); | 52 | connect(_folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPSelect(IMAPResponse&))); |
53 | } | 53 | } |
54 | 54 | ||
55 | void SearchDiag::folderSelected(Folder folder) | 55 | void SearchDiag::folderSelected(Folder folder) |
56 | { | 56 | { |
57 | _selected = true; | 57 | _selected = true; |
58 | _folder = folder; | 58 | _folder = folder; |
59 | } | 59 | } |
60 | 60 | ||
61 | void SearchDiag::slotIMAPSelect(IMAPResponse &response) | 61 | void SearchDiag::slotIMAPSelect(IMAPResponse &response) |
62 | { | 62 | { |
63 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSelect(IMAPResponse &))); | 63 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPSelect(IMAPResponse&))); |
64 | 64 | ||
65 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 65 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
66 | if (in->currentItem() == INMENU_BODY) { | 66 | if (in->currentItem() == INMENU_BODY) { |
67 | response.imapHandler()->iSearch("BODY \"" + searchFor->text() + "\""); | 67 | response.imapHandler()->iSearch("BODY \"" + searchFor->text() + "\""); |
68 | } else if (in->currentItem() == INMENU_HEADERF) { | 68 | } else if (in->currentItem() == INMENU_HEADERF) { |
69 | response.imapHandler()->iSearch("HEADER \""+ other->currentText() + "\" \"" + searchFor->text() + "\""); | 69 | response.imapHandler()->iSearch("HEADER \""+ other->currentText() + "\" \"" + searchFor->text() + "\""); |
70 | } else if (in->currentItem() == INMENU_SUBJECT) { | 70 | } else if (in->currentItem() == INMENU_SUBJECT) { |
71 | response.imapHandler()->iSearch("SUBJECT \"" + searchFor->text() + "\""); | 71 | response.imapHandler()->iSearch("SUBJECT \"" + searchFor->text() + "\""); |
72 | } else if (in->currentItem() == INMENU_FROM) { | 72 | } else if (in->currentItem() == INMENU_FROM) { |
73 | response.imapHandler()->iSearch("FROM \"" + searchFor->text() + "\""); | 73 | response.imapHandler()->iSearch("FROM \"" + searchFor->text() + "\""); |
74 | } else if (in->currentItem() == INMENU_TO) { | 74 | } else if (in->currentItem() == INMENU_TO) { |
75 | response.imapHandler()->iSearch("TO \"" + searchFor->text() + "\""); | 75 | response.imapHandler()->iSearch("TO \"" + searchFor->text() + "\""); |
76 | } else return; | 76 | } else return; |
77 | 77 | ||
78 | connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPSearch(IMAPResponse &))); | 78 | connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPSearch(IMAPResponse&))); |
79 | } else { | 79 | } else { |
80 | QMessageBox::warning(this, tr("Error"), tr("<p>Could not select the folder. Aborting. (Server said: %1)").arg(response.statusResponse().comment()), tr("Ok")); | 80 | QMessageBox::warning(this, tr("Error"), tr("<p>Could not select the folder. Aborting. (Server said: %1)").arg(response.statusResponse().comment()), tr("Ok")); |
81 | } | 81 | } |
82 | } | 82 | } |
83 | 83 | ||
84 | void SearchDiag::slotIMAPSearch(IMAPResponse &response) | 84 | void SearchDiag::slotIMAPSearch(IMAPResponse &response) |
85 | { | 85 | { |
86 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSearch(IMAPResponse &))); | 86 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPSearch(IMAPResponse&))); |
87 | 87 | ||
88 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 88 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
89 | IMAPResponseSEARCH results = response.SEARCH()[0]; | 89 | IMAPResponseSEARCH results = response.SEARCH()[0]; |
90 | if (results.mails().count() == 0) { | 90 | if (results.mails().count() == 0) { |
91 | QMessageBox::information(this, tr("Results"), tr("<p>No mails match your criteria.</p>"), tr("Ok")); | 91 | QMessageBox::information(this, tr("Results"), tr("<p>No mails match your criteria.</p>"), tr("Ok")); |
92 | return; | 92 | return; |
93 | } | 93 | } |
94 | 94 | ||
95 | response.imapHandler()->iFetch(results.mails().join(","), "ENVELOPE FLAGS UID"); | 95 | response.imapHandler()->iFetch(results.mails().join(","), "ENVELOPE FLAGS UID"); |
96 | connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPFetch(IMAPResponse &))); | 96 | connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPFetch(IMAPResponse&))); |
97 | } else { | 97 | } else { |
98 | QMessageBox::warning(this, tr("Error"), tr("<p>Search failed. (Server said: %1)").arg(response.statusResponse().comment()), tr("Ok")); | 98 | QMessageBox::warning(this, tr("Error"), tr("<p>Search failed. (Server said: %1)").arg(response.statusResponse().comment()), tr("Ok")); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | void SearchDiag::slotIMAPFetch(IMAPResponse &response) | 102 | void SearchDiag::slotIMAPFetch(IMAPResponse &response) |
103 | { | 103 | { |
104 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSearch(IMAPResponse &))); | 104 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPSearch(IMAPResponse&))); |
105 | 105 | ||
106 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 106 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
107 | mailTable->setHeaders(response.FETCH()); | 107 | mailTable->setHeaders(response.FETCH()); |
108 | } else { | 108 | } else { |
109 | QMessageBox::warning(this, tr("Error"), tr("<p>Couldn't fetch the mail headers. (Server said: %1)").arg(response.statusResponse().comment())); | 109 | QMessageBox::warning(this, tr("Error"), tr("<p>Couldn't fetch the mail headers. (Server said: %1)").arg(response.statusResponse().comment())); |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | void SearchDiag::slotMailClicked(IMAPResponseFETCH fetch, IMAPHandler *) | 113 | void SearchDiag::slotMailClicked(IMAPResponseFETCH fetch, IMAPHandler *) |
114 | { | 114 | { |
115 | ViewMail viewMail(fetch, _folder.topFolder().handler(), this, 0, true); | 115 | ViewMail viewMail(fetch, _folder.topFolder().handler(), this, 0, true); |
116 | viewMail.showMaximized(); | 116 | viewMail.showMaximized(); |
117 | viewMail.exec(); | 117 | viewMail.exec(); |
118 | } | 118 | } |
119 | 119 | ||
120 | void SearchDiag::slotInItemActivated(int index) | 120 | void SearchDiag::slotInItemActivated(int index) |
121 | { | 121 | { |
122 | if (index == INMENU_HEADERF) { | 122 | if (index == INMENU_HEADERF) { |
123 | other->setEnabled(true); | 123 | other->setEnabled(true); |
124 | } else { | 124 | } else { |
125 | other->setEnabled(false); | 125 | other->setEnabled(false); |
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
diff --git a/noncore/unsupported/mail2/viewmail.cpp b/noncore/unsupported/mail2/viewmail.cpp index da6924d..0cfb6e5 100644 --- a/noncore/unsupported/mail2/viewmail.cpp +++ b/noncore/unsupported/mail2/viewmail.cpp | |||
@@ -1,198 +1,198 @@ | |||
1 | #include <qtextbrowser.h> | 1 | #include <qtextbrowser.h> |
2 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qapplication.h> | 4 | #include <qapplication.h> |
5 | 5 | ||
6 | #include "mailfactory.h" | 6 | #include "mailfactory.h" |
7 | #include "composer.h" | 7 | #include "composer.h" |
8 | #include "viewmail.h" | 8 | #include "viewmail.h" |
9 | 9 | ||
10 | AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore) | 10 | AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore) |
11 | : QListViewItem(parent), _attachItemStore(attachItemStore) | 11 | : QListViewItem(parent), _attachItemStore(attachItemStore) |
12 | { | 12 | { |
13 | setText(0, _attachItemStore.mimeType()); | 13 | setText(0, _attachItemStore.mimeType()); |
14 | setText(1, _attachItemStore.fileName()); | 14 | setText(1, _attachItemStore.fileName()); |
15 | setText(2, _attachItemStore.description()); | 15 | setText(2, _attachItemStore.description()); |
16 | } | 16 | } |
17 | 17 | ||
18 | AttachItem::AttachItem(QListViewItem *parent, AttachItemStore &attachItemStore) | 18 | AttachItem::AttachItem(QListViewItem *parent, AttachItemStore &attachItemStore) |
19 | : QListViewItem(parent), _attachItemStore(attachItemStore) | 19 | : QListViewItem(parent), _attachItemStore(attachItemStore) |
20 | { | 20 | { |
21 | setText(0, _attachItemStore.mimeType()); | 21 | setText(0, _attachItemStore.mimeType()); |
22 | setText(1, _attachItemStore.fileName()); | 22 | setText(1, _attachItemStore.fileName()); |
23 | setText(2, _attachItemStore.description()); | 23 | setText(2, _attachItemStore.description()); |
24 | } | 24 | } |
25 | 25 | ||
26 | ViewMail::ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *parent, const char *name, WFlags fl) | 26 | ViewMail::ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *parent, const char *name, WFlags fl) |
27 | : ViewMailBase(parent, name, fl), _inLoop(false), _mail(mail), _handler(handler) | 27 | : ViewMailBase(parent, name, fl), _inLoop(false), _mail(mail), _handler(handler) |
28 | { | 28 | { |
29 | setCaption(caption().arg(mail.envelope().from()[0].name())); | 29 | setCaption(caption().arg(mail.envelope().from()[0].name())); |
30 | 30 | ||
31 | _gotBody = false; | 31 | _gotBody = false; |
32 | _mailHtml = tr( | 32 | _mailHtml = tr( |
33 | "<html><body>" | 33 | "<html><body>" |
34 | "<div align=center><b>%1</b></div>" | 34 | "<div align=center><b>%1</b></div>" |
35 | "<b>From:</b> %2<br>" | 35 | "<b>From:</b> %2<br>" |
36 | "<b>To:</b> %3<br>" | 36 | "<b>To:</b> %3<br>" |
37 | "%4" | 37 | "%4" |
38 | "%5" | 38 | "%5" |
39 | "<b>Date:</b> %6<hr>" | 39 | "<b>Date:</b> %6<hr>" |
40 | "<font face=fixed>%7</font>") | 40 | "<font face=fixed>%7</font>") |
41 | .arg(deHtml(mail.envelope().subject().isNull() ? tr("(no subject)") | 41 | .arg(deHtml(mail.envelope().subject().isNull() ? tr("(no subject)") |
42 | : deHtml(mail.envelope().subject()))) | 42 | : deHtml(mail.envelope().subject()))) |
43 | .arg(deHtml(mail.envelope().from().toString().isNull() ? tr("(no from)") | 43 | .arg(deHtml(mail.envelope().from().toString().isNull() ? tr("(no from)") |
44 | : mail.envelope().from().toString())) | 44 | : mail.envelope().from().toString())) |
45 | .arg(deHtml(mail.envelope().to().toString().isNull() ? tr("(no recipient)") | 45 | .arg(deHtml(mail.envelope().to().toString().isNull() ? tr("(no recipient)") |
46 | : mail.envelope().to().toString())) | 46 | : mail.envelope().to().toString())) |
47 | .arg(mail.envelope().cc().toString().isNull() ? QString(0) | 47 | .arg(mail.envelope().cc().toString().isNull() ? QString(0) |
48 | : tr("<b>Cc:</b> %1<br>").arg(deHtml(mail.envelope().cc().toString()))) | 48 | : tr("<b>Cc:</b> %1<br>").arg(deHtml(mail.envelope().cc().toString()))) |
49 | .arg(mail.envelope().bcc().toString().isNull() ? QString(0) | 49 | .arg(mail.envelope().bcc().toString().isNull() ? QString(0) |
50 | : tr("<b>Bcc:</b> %1<br>").arg(deHtml(mail.envelope().bcc().toString()))) | 50 | : tr("<b>Bcc:</b> %1<br>").arg(deHtml(mail.envelope().bcc().toString()))) |
51 | .arg(mail.envelope().mailDate().isNull() ? tr("(no date)") | 51 | .arg(mail.envelope().mailDate().isNull() ? tr("(no date)") |
52 | : mail.envelope().mailDate()) | 52 | : mail.envelope().mailDate()) |
53 | .arg("%1"); | 53 | .arg("%1"); |
54 | 54 | ||
55 | connect(reply, SIGNAL(activated()), SLOT(slotReply())); | 55 | connect(reply, SIGNAL(activated()), SLOT(slotReply())); |
56 | connect(forward, SIGNAL(activated()), SLOT(slotForward())); | 56 | connect(forward, SIGNAL(activated()), SLOT(slotForward())); |
57 | 57 | ||
58 | attachments->setEnabled(_gotBody); | 58 | attachments->setEnabled(_gotBody); |
59 | browser->setText(QString(_mailHtml).arg(tr("Getting mail body from server. Please wait..."))); | 59 | browser->setText(QString(_mailHtml).arg(tr("Getting mail body from server. Please wait..."))); |
60 | 60 | ||
61 | _handler->iUid("FETCH", QString("%1 (BODY[1])").arg(mail.uid())); | 61 | _handler->iUid("FETCH", QString("%1 (BODY[1])").arg(mail.uid())); |
62 | connect(_handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPUid(IMAPResponse &))); | 62 | connect(_handler, SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPUid(IMAPResponse&))); |
63 | } | 63 | } |
64 | 64 | ||
65 | ViewMail::~ViewMail() | 65 | ViewMail::~ViewMail() |
66 | { | 66 | { |
67 | hide(); | 67 | hide(); |
68 | } | 68 | } |
69 | 69 | ||
70 | void ViewMail::hide() | 70 | void ViewMail::hide() |
71 | { | 71 | { |
72 | QWidget::hide(); | 72 | QWidget::hide(); |
73 | 73 | ||
74 | if (_inLoop) { | 74 | if (_inLoop) { |
75 | _inLoop = false; | 75 | _inLoop = false; |
76 | qApp->exit_loop(); | 76 | qApp->exit_loop(); |
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | void ViewMail::exec() | 80 | void ViewMail::exec() |
81 | { | 81 | { |
82 | show(); | 82 | show(); |
83 | 83 | ||
84 | if (!_inLoop) { | 84 | if (!_inLoop) { |
85 | _inLoop = true; | 85 | _inLoop = true; |
86 | qApp->enter_loop(); | 86 | qApp->enter_loop(); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | QString ViewMail::deHtml(const QString &string) | 90 | QString ViewMail::deHtml(const QString &string) |
91 | { | 91 | { |
92 | QString string_ = string; | 92 | QString string_ = string; |
93 | string_.replace(QRegExp("&"), "&"); | 93 | string_.replace(QRegExp("&"), "&"); |
94 | string_.replace(QRegExp("<"), "<"); | 94 | string_.replace(QRegExp("<"), "<"); |
95 | string_.replace(QRegExp(">"), ">"); | 95 | string_.replace(QRegExp(">"), ">"); |
96 | string_.replace(QRegExp("\\n"), "<br>"); | 96 | string_.replace(QRegExp("\\n"), "<br>"); |
97 | return string_; | 97 | return string_; |
98 | } | 98 | } |
99 | 99 | ||
100 | void ViewMail::slotReply() | 100 | void ViewMail::slotReply() |
101 | { | 101 | { |
102 | if (!_gotBody) { | 102 | if (!_gotBody) { |
103 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); | 103 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); |
104 | return; | 104 | return; |
105 | } | 105 | } |
106 | 106 | ||
107 | QString rtext; | 107 | QString rtext; |
108 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 108 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
109 | .arg(_mail.envelope().from()[0].toString()) | 109 | .arg(_mail.envelope().from()[0].toString()) |
110 | .arg(_mail.envelope().mailDate()); | 110 | .arg(_mail.envelope().mailDate()); |
111 | 111 | ||
112 | QString text = _mail.bodyPart(1).data(); | 112 | QString text = _mail.bodyPart(1).data(); |
113 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 113 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
114 | QStringList::Iterator it; | 114 | QStringList::Iterator it; |
115 | for (it = lines.begin(); it != lines.end(); it++) { | 115 | for (it = lines.begin(); it != lines.end(); it++) { |
116 | rtext += "> " + *it + "\n"; | 116 | rtext += "> " + *it + "\n"; |
117 | } | 117 | } |
118 | rtext += "\n"; | 118 | rtext += "\n"; |
119 | 119 | ||
120 | QString prefix; | 120 | QString prefix; |
121 | if (_mail.envelope().subject().find(QRegExp("^Re: *$")) != -1) prefix = ""; | 121 | if (_mail.envelope().subject().find(QRegExp("^Re: *$")) != -1) prefix = ""; |
122 | else prefix = "Re: "; // no i18n on purpose | 122 | else prefix = "Re: "; // no i18n on purpose |
123 | 123 | ||
124 | SendMail sendMail; | 124 | SendMail sendMail; |
125 | sendMail.setTo(_mail.envelope().from()[0].toString()); | 125 | sendMail.setTo(_mail.envelope().from()[0].toString()); |
126 | sendMail.setSubject(prefix + _mail.envelope().subject()); | 126 | sendMail.setSubject(prefix + _mail.envelope().subject()); |
127 | sendMail.setInReplyTo(_mail.envelope().messageId()); | 127 | sendMail.setInReplyTo(_mail.envelope().messageId()); |
128 | sendMail.setMessage(rtext); | 128 | sendMail.setMessage(rtext); |
129 | 129 | ||
130 | Composer composer(this, 0, true); | 130 | Composer composer(this, 0, true); |
131 | composer.setSendMail(sendMail); | 131 | composer.setSendMail(sendMail); |
132 | composer.showMaximized(); | 132 | composer.showMaximized(); |
133 | composer.exec(); | 133 | composer.exec(); |
134 | } | 134 | } |
135 | 135 | ||
136 | void ViewMail::slotForward() | 136 | void ViewMail::slotForward() |
137 | { | 137 | { |
138 | if (!_gotBody) { | 138 | if (!_gotBody) { |
139 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); | 139 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); |
140 | return; | 140 | return; |
141 | } | 141 | } |
142 | 142 | ||
143 | QString ftext; | 143 | QString ftext; |
144 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 144 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
145 | .arg(_mail.envelope().from()[0].toString()); | 145 | .arg(_mail.envelope().from()[0].toString()); |
146 | if (!_mail.envelope().mailDate().isNull()) | 146 | if (!_mail.envelope().mailDate().isNull()) |
147 | ftext += QString("Date: %1\n") | 147 | ftext += QString("Date: %1\n") |
148 | .arg(_mail.envelope().mailDate()); | 148 | .arg(_mail.envelope().mailDate()); |
149 | if (!_mail.envelope().from()[0].toString().isNull()) | 149 | if (!_mail.envelope().from()[0].toString().isNull()) |
150 | ftext += QString("From: %1\n") | 150 | ftext += QString("From: %1\n") |
151 | .arg(_mail.envelope().from()[0].toString()); | 151 | .arg(_mail.envelope().from()[0].toString()); |
152 | if (!_mail.envelope().to().toString().isNull()) | 152 | if (!_mail.envelope().to().toString().isNull()) |
153 | ftext += QString("To: %1\n") | 153 | ftext += QString("To: %1\n") |
154 | .arg(_mail.envelope().to().toString()); | 154 | .arg(_mail.envelope().to().toString()); |
155 | if (!_mail.envelope().cc().toString().isNull()) | 155 | if (!_mail.envelope().cc().toString().isNull()) |
156 | ftext += QString("Cc: %1\n") | 156 | ftext += QString("Cc: %1\n") |
157 | .arg(_mail.envelope().cc().toString()); | 157 | .arg(_mail.envelope().cc().toString()); |
158 | if (!_mail.envelope().bcc().toString().isNull()) | 158 | if (!_mail.envelope().bcc().toString().isNull()) |
159 | ftext += QString("Bcc: %1\n") | 159 | ftext += QString("Bcc: %1\n") |
160 | .arg(_mail.envelope().bcc().toString()); | 160 | .arg(_mail.envelope().bcc().toString()); |
161 | if (!_mail.envelope().subject().isNull()) | 161 | if (!_mail.envelope().subject().isNull()) |
162 | ftext += QString("Subject: %1\n") | 162 | ftext += QString("Subject: %1\n") |
163 | .arg(_mail.envelope().subject()); | 163 | .arg(_mail.envelope().subject()); |
164 | 164 | ||
165 | ftext += QString("\n%1\n") | 165 | ftext += QString("\n%1\n") |
166 | .arg(_mail.bodyPart(1).data()); | 166 | .arg(_mail.bodyPart(1).data()); |
167 | 167 | ||
168 | ftext += QString("----- End forwarded message -----\n"); | 168 | ftext += QString("----- End forwarded message -----\n"); |
169 | 169 | ||
170 | SendMail sendMail; | 170 | SendMail sendMail; |
171 | sendMail.setSubject("Fwd: " + _mail.envelope().subject()); | 171 | sendMail.setSubject("Fwd: " + _mail.envelope().subject()); |
172 | sendMail.setMessage(ftext); | 172 | sendMail.setMessage(ftext); |
173 | 173 | ||
174 | Composer composer(this, 0, true); | 174 | Composer composer(this, 0, true); |
175 | composer.setSendMail(sendMail); | 175 | composer.setSendMail(sendMail); |
176 | composer.showMaximized(); | 176 | composer.showMaximized(); |
177 | composer.exec(); | 177 | composer.exec(); |
178 | } | 178 | } |
179 | 179 | ||
180 | void ViewMail::slotIMAPUid(IMAPResponse &response) | 180 | void ViewMail::slotIMAPUid(IMAPResponse &response) |
181 | { | 181 | { |
182 | disconnect(_handler, SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPUid(IMAPResponse &))); | 182 | disconnect(_handler, SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPUid(IMAPResponse&))); |
183 | 183 | ||
184 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 184 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
185 | QValueList<IMAPResponseBodyPart> bodyParts; | 185 | QValueList<IMAPResponseBodyPart> bodyParts; |
186 | bodyParts.append(response.FETCH()[0].bodyPart(0)); | 186 | bodyParts.append(response.FETCH()[0].bodyPart(0)); |
187 | _mail.setBodyParts(bodyParts); | 187 | _mail.setBodyParts(bodyParts); |
188 | 188 | ||
189 | browser->setText(QString(_mailHtml).arg(deHtml(response.FETCH()[0].bodyPart(0).data()))); | 189 | browser->setText(QString(_mailHtml).arg(deHtml(response.FETCH()[0].bodyPart(0).data()))); |
190 | 190 | ||
191 | // fillList(response.FETCH()[0].bodyStructure()); | 191 | // fillList(response.FETCH()[0].bodyStructure()); |
192 | 192 | ||
193 | _gotBody = true; | 193 | _gotBody = true; |
194 | } else { | 194 | } else { |
195 | QMessageBox::warning(this, tr("Error"), tr("<p>I was unable to retrieve the mail from the server. You can try again later or give up.</p>"), tr("Ok")); | 195 | QMessageBox::warning(this, tr("Error"), tr("<p>I was unable to retrieve the mail from the server. You can try again later or give up.</p>"), tr("Ok")); |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
diff --git a/noncore/unsupported/mailit/addatt.cpp b/noncore/unsupported/mailit/addatt.cpp index 19ac58f..420f84c 100644 --- a/noncore/unsupported/mailit/addatt.cpp +++ b/noncore/unsupported/mailit/addatt.cpp | |||
@@ -1,196 +1,196 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop 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 | #include <qlayout.h> | 20 | #include <qlayout.h> |
21 | #include <qhbox.h> | 21 | #include <qhbox.h> |
22 | #include <qdir.h> | 22 | #include <qdir.h> |
23 | #include <qstringlist.h> | 23 | #include <qstringlist.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | #include "addatt.h" | 25 | #include "addatt.h" |
26 | 26 | ||
27 | FileItem::FileItem(QListView *parent, DocLnk* dl) | 27 | FileItem::FileItem(QListView *parent, DocLnk* dl) |
28 | : QListViewItem(parent) | 28 | : QListViewItem(parent) |
29 | { | 29 | { |
30 | /*file = fileInfo; | 30 | /*file = fileInfo; |
31 | type = fileType;*/ | 31 | type = fileType;*/ |
32 | 32 | ||
33 | doclnk=dl; | 33 | doclnk=dl; |
34 | 34 | ||
35 | setText(0, doclnk->name()); | 35 | setText(0, doclnk->name()); |
36 | 36 | ||
37 | /*if (fileType == "Picture") { | 37 | /*if (fileType == "Picture") { |
38 | setPixmap(0, Resource::loadPixmap("pixmap")); | 38 | setPixmap(0, Resource::loadPixmap("pixmap")); |
39 | } else if (fileType == "Document") { | 39 | } else if (fileType == "Document") { |
40 | setPixmap(0, Resource::loadPixmap("txt")); | 40 | setPixmap(0, Resource::loadPixmap("txt")); |
41 | } else if (fileType == "Sound") { | 41 | } else if (fileType == "Sound") { |
42 | setPixmap(0, Resource::loadPixmap("play")); | 42 | setPixmap(0, Resource::loadPixmap("play")); |
43 | } else if (fileType == "Movie") { | 43 | } else if (fileType == "Movie") { |
44 | setPixmap(0, Resource::loadPixmap("MPEGPlayer")); | 44 | setPixmap(0, Resource::loadPixmap("MPEGPlayer")); |
45 | } else if (fileType == "File") { | 45 | } else if (fileType == "File") { |
46 | setPixmap(0, Resource::loadPixmap("exec")); | 46 | setPixmap(0, Resource::loadPixmap("exec")); |
47 | }*/ | 47 | }*/ |
48 | } | 48 | } |
49 | 49 | ||
50 | FileItem::~FileItem() | 50 | FileItem::~FileItem() |
51 | { | 51 | { |
52 | if (doclnk!=NULL) delete doclnk; | 52 | if (doclnk!=NULL) delete doclnk; |
53 | doclnk=NULL; | 53 | doclnk=NULL; |
54 | } | 54 | } |
55 | 55 | ||
56 | AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f) | 56 | AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f) |
57 | : QDialog(parent, name, f) | 57 | : QDialog(parent, name, f) |
58 | { | 58 | { |
59 | setCaption(tr("Adding attachments") ); | 59 | setCaption(tr("Adding attachments") ); |
60 | 60 | ||
61 | QGridLayout *top = new QGridLayout(this, 1,1 ); | 61 | QGridLayout *top = new QGridLayout(this, 1,1 ); |
62 | 62 | ||
63 | QHBox *buttons=new QHBox(this); | 63 | QHBox *buttons=new QHBox(this); |
64 | /*fileCategoryButton = new QPushButton(this);*/ | 64 | /*fileCategoryButton = new QPushButton(this);*/ |
65 | attachButton = new QPushButton(tr("attach..."), buttons); | 65 | attachButton = new QPushButton(tr("attach..."), buttons); |
66 | removeButton = new QPushButton(tr("Remove"), buttons); | 66 | removeButton = new QPushButton(tr("Remove"), buttons); |
67 | 67 | ||
68 | /*fileCategories = new QPopupMenu(fileCategoryButton); | 68 | /*fileCategories = new QPopupMenu(fileCategoryButton); |
69 | fileCategoryButton->setPopup(fileCategories); | 69 | fileCategoryButton->setPopup(fileCategories); |
70 | fileCategories->insertItem("Document"); | 70 | fileCategories->insertItem("Document"); |
71 | fileCategories->insertItem("Picture"); | 71 | fileCategories->insertItem("Picture"); |
72 | fileCategories->insertItem("Sound"); | 72 | fileCategories->insertItem("Sound"); |
73 | fileCategories->insertItem("Movie"); | 73 | fileCategories->insertItem("Movie"); |
74 | fileCategories->insertItem("File"); | 74 | fileCategories->insertItem("File"); |
75 | 75 | ||
76 | fileCategoryButton->setText("Document"); | 76 | fileCategoryButton->setText("Document"); |
77 | top->addWidget(fileCategoryButton, 0, 0);*/ | 77 | top->addWidget(fileCategoryButton, 0, 0);*/ |
78 | 78 | ||
79 | 79 | ||
80 | top->addWidget(buttons,1,0); | 80 | top->addWidget(buttons,1,0); |
81 | //buttons->addWidget(attachButton,0,0); | 81 | //buttons->addWidget(attachButton,0,0); |
82 | //buttons->addWidget(removeButton,0,1); | 82 | //buttons->addWidget(removeButton,0,1); |
83 | 83 | ||
84 | //connect(fileCategories, SIGNAL(activated(int)), this, | 84 | //connect(fileCategories, SIGNAL(activated(int)), this, |
85 | //SLOT(fileCategorySelected(int)) );*/ | 85 | //SLOT(fileCategorySelected(int)) );*/ |
86 | connect(attachButton, SIGNAL(clicked()), this, | 86 | connect(attachButton, SIGNAL(clicked()), this, |
87 | SLOT(addattachment()) ); | 87 | SLOT(addattachment()) ); |
88 | connect(removeButton, SIGNAL(clicked()), this, | 88 | connect(removeButton, SIGNAL(clicked()), this, |
89 | SLOT(removeattachment()) ); | 89 | SLOT(removeattachment()) ); |
90 | 90 | ||
91 | /*listView = new QListView(this, "AttView"); | 91 | /*listView = new QListView(this, "AttView"); |
92 | listView->addColumn("Documents");* | 92 | listView->addColumn("Documents");* |
93 | connect(listView, SIGNAL(doubleClicked(QListViewItem *)), this, | 93 | connect(listView, SIGNAL(doubleClicked(QListViewItem*)), this, |
94 | SLOT(addattachment()) );*/ | 94 | SLOT(addattachment()) );*/ |
95 | 95 | ||
96 | 96 | ||
97 | attView = new QListView(this, "Selected"); | 97 | attView = new QListView(this, "Selected"); |
98 | attView->addColumn(tr("Attached")); | 98 | attView->addColumn(tr("Attached")); |
99 | attView->addColumn(tr("File type")); | 99 | attView->addColumn(tr("File type")); |
100 | connect(attView, SIGNAL(doubleClicked(QListViewItem *)), this, | 100 | connect(attView, SIGNAL(doubleClicked(QListViewItem*)), this, |
101 | SLOT(removeattachment()) ); | 101 | SLOT(removeattachment()) ); |
102 | 102 | ||
103 | //top->addWidget(ofs, 0,0); | 103 | //top->addWidget(ofs, 0,0); |
104 | top->addWidget(attView, 0,0); | 104 | top->addWidget(attView, 0,0); |
105 | 105 | ||
106 | clear(); | 106 | clear(); |
107 | 107 | ||
108 | 108 | ||
109 | } | 109 | } |
110 | 110 | ||
111 | void AddAtt::clear() | 111 | void AddAtt::clear() |
112 | { | 112 | { |
113 | attView->clear(); | 113 | attView->clear(); |
114 | //getFiles(); | 114 | //getFiles(); |
115 | modified = FALSE; | 115 | modified = FALSE; |
116 | } | 116 | } |
117 | 117 | ||
118 | /*void AddAtt::fileCategorySelected(int id) | 118 | /*void AddAtt::fileCategorySelected(int id) |
119 | { | 119 | { |
120 | fileCategoryButton->setText(fileCategories->text(id)); | 120 | fileCategoryButton->setText(fileCategories->text(id)); |
121 | getFiles(); | 121 | getFiles(); |
122 | }*/ | 122 | }*/ |
123 | 123 | ||
124 | void AddAtt::addattachment() | 124 | void AddAtt::addattachment() |
125 | {// ### FIXME wrong use -zecke | 125 | {// ### FIXME wrong use -zecke |
126 | OFileDialog ofs("Attachments",this,0,0,"/root/Documents"); | 126 | OFileDialog ofs("Attachments",this,0,0,"/root/Documents"); |
127 | 127 | ||
128 | ofs.showMaximized(); | 128 | ofs.showMaximized(); |
129 | 129 | ||
130 | if (ofs.exec()==QDialog::Accepted) | 130 | if (ofs.exec()==QDialog::Accepted) |
131 | { | 131 | { |
132 | DocLnk* dl=new DocLnk(ofs.selectedDocument()); | 132 | DocLnk* dl=new DocLnk(ofs.selectedDocument()); |
133 | FileItem* fi=new FileItem(attView,dl); | 133 | FileItem* fi=new FileItem(attView,dl); |
134 | fi->setPixmap(0,dl->pixmap()); | 134 | fi->setPixmap(0,dl->pixmap()); |
135 | fi->setText(1,dl->type()); | 135 | fi->setText(1,dl->type()); |
136 | attView->insertItem(fi); | 136 | attView->insertItem(fi); |
137 | modified = TRUE; | 137 | modified = TRUE; |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | void AddAtt::removeattachment() | 141 | void AddAtt::removeattachment() |
142 | { | 142 | { |
143 | if (attView->selectedItem() != NULL) | 143 | if (attView->selectedItem() != NULL) |
144 | { | 144 | { |
145 | attView->takeItem(attView->selectedItem()); | 145 | attView->takeItem(attView->selectedItem()); |
146 | } | 146 | } |
147 | modified = TRUE; | 147 | modified = TRUE; |
148 | } | 148 | } |
149 | 149 | ||
150 | void AddAtt::reject() | 150 | void AddAtt::reject() |
151 | { | 151 | { |
152 | if (modified) { | 152 | if (modified) { |
153 | attView->clear(); | 153 | attView->clear(); |
154 | modified = FALSE; | 154 | modified = FALSE; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | void AddAtt::accept() | 158 | void AddAtt::accept() |
159 | { | 159 | { |
160 | modified = FALSE; | 160 | modified = FALSE; |
161 | hide(); | 161 | hide(); |
162 | } | 162 | } |
163 | 163 | ||
164 | void AddAtt::getFiles() | 164 | void AddAtt::getFiles() |
165 | { | 165 | { |
166 | QString path, selected; | 166 | QString path, selected; |
167 | 167 | ||
168 | /*listView->clear(); | 168 | /*listView->clear(); |
169 | 169 | ||
170 | selected = fileCategoryButton->text(); | 170 | selected = fileCategoryButton->text(); |
171 | if (selected == "Picture") { | 171 | if (selected == "Picture") { |
172 | path = "../pics/"; | 172 | path = "../pics/"; |
173 | } else if (selected == "Document") { | 173 | } else if (selected == "Document") { |
174 | path = "" ; //sub-dirs not decided | 174 | path = "" ; //sub-dirs not decided |
175 | } else if (selected == "Sound") { | 175 | } else if (selected == "Sound") { |
176 | path = "../sounds/"; //sub-dirs not decided | 176 | path = "../sounds/"; //sub-dirs not decided |
177 | } else if (selected == "Movie") { | 177 | } else if (selected == "Movie") { |
178 | path = ""; //sub-dirs not decided | 178 | path = ""; //sub-dirs not decided |
179 | } else if (selected == "File") { | 179 | } else if (selected == "File") { |
180 | path = ""; //sub-dirs not decided | 180 | path = ""; //sub-dirs not decided |
181 | } | 181 | } |
182 | 182 | ||
183 | dir = new QDir(path); | 183 | dir = new QDir(path); |
184 | dir->setFilter(QDir::Files); | 184 | dir->setFilter(QDir::Files); |
185 | const QFileInfoList *dirInfoList = dir->entryInfoList(); | 185 | const QFileInfoList *dirInfoList = dir->entryInfoList(); |
186 | 186 | ||
187 | QFileInfoListIterator it(*dirInfoList); // create list iterator | 187 | QFileInfoListIterator it(*dirInfoList); // create list iterator |
188 | 188 | ||
189 | while ( (fi=it.current()) ) { // for each file... | 189 | while ( (fi=it.current()) ) { // for each file... |
190 | item = new FileItem(lis+ütView, *fi, selected); | 190 | item = new FileItem(lis+ütView, *fi, selected); |
191 | ++it; // goto next list element | 191 | ++it; // goto next list element |
192 | }*/ | 192 | }*/ |
193 | } | 193 | } |
194 | 194 | ||
195 | QStringList AddAtt::returnattachedFiles() | 195 | QStringList AddAtt::returnattachedFiles() |
196 | { | 196 | { |
diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp index 8359acf..86c7987 100644 --- a/noncore/unsupported/mailit/emailclient.cpp +++ b/noncore/unsupported/mailit/emailclient.cpp | |||
@@ -1,319 +1,319 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop 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 | #include <qapplication.h> | 20 | #include <qapplication.h> |
21 | #include <qmessagebox.h> | 21 | #include <qmessagebox.h> |
22 | #include <qvbox.h> | 22 | #include <qvbox.h> |
23 | #include <qfile.h> | 23 | #include <qfile.h> |
24 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
25 | #include <qmenubar.h> | 25 | #include <qmenubar.h> |
26 | #include <qaction.h> | 26 | #include <qaction.h> |
27 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
28 | #include <qpe/resource.h> | 28 | #include <qpe/resource.h> |
29 | #include "emailclient.h" | 29 | #include "emailclient.h" |
30 | #include "writemail.h" | 30 | #include "writemail.h" |
31 | 31 | ||
32 | QCollection::Item AccountList::newItem(QCollection::Item d) | 32 | QCollection::Item AccountList::newItem(QCollection::Item d) |
33 | { | 33 | { |
34 | return dupl( (MailAccount *) d); | 34 | return dupl( (MailAccount *) d); |
35 | } | 35 | } |
36 | 36 | ||
37 | MailAccount* AccountList::dupl(MailAccount *in) | 37 | MailAccount* AccountList::dupl(MailAccount *in) |
38 | { | 38 | { |
39 | ac = new MailAccount(*in); | 39 | ac = new MailAccount(*in); |
40 | return ac; | 40 | return ac; |
41 | } | 41 | } |
42 | 42 | ||
43 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) | 43 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) |
44 | : QMainWindow( parent, name, fl ) | 44 | : QMainWindow( parent, name, fl ) |
45 | { | 45 | { |
46 | emailHandler = new EmailHandler(); | 46 | emailHandler = new EmailHandler(); |
47 | addressList = new AddressList(); | 47 | addressList = new AddressList(); |
48 | 48 | ||
49 | sending = FALSE; | 49 | sending = FALSE; |
50 | receiving = FALSE; | 50 | receiving = FALSE; |
51 | previewingMail = FALSE; | 51 | previewingMail = FALSE; |
52 | mailIdCount = 1; | 52 | mailIdCount = 1; |
53 | accountIdCount = 1; | 53 | accountIdCount = 1; |
54 | allAccounts = FALSE; | 54 | allAccounts = FALSE; |
55 | 55 | ||
56 | init(); | 56 | init(); |
57 | 57 | ||
58 | 58 | ||
59 | 59 | ||
60 | connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); | 60 | connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); |
61 | 61 | ||
62 | connect(emailHandler, SIGNAL(smtpError(int,const QString &)), this, | 62 | connect(emailHandler, SIGNAL(smtpError(int,const QString&)), this, |
63 | SLOT(smtpError(int,const QString &)) ); | 63 | SLOT(smtpError(int,const QString&)) ); |
64 | connect(emailHandler, SIGNAL(popError(int,const QString &)), this, | 64 | connect(emailHandler, SIGNAL(popError(int,const QString&)), this, |
65 | SLOT(popError(int,const QString &)) ); | 65 | SLOT(popError(int,const QString&)) ); |
66 | 66 | ||
67 | connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); | 67 | connect(inboxView, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(inboxItemSelected()) ); |
68 | connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); | 68 | connect(outboxView, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(outboxItemSelected()) ); |
69 | 69 | ||
70 | connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) ); | 70 | connect(inboxView, SIGNAL(pressed(QListViewItem*)), this, SLOT(inboxItemPressed()) ); |
71 | connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) ); | 71 | connect(inboxView, SIGNAL(clicked(QListViewItem*)), this, SLOT(inboxItemReleased()) ); |
72 | 72 | ||
73 | connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, | 73 | connect(emailHandler, SIGNAL(mailArrived(const Email&,bool)), this, |
74 | SLOT(mailArrived(const Email &, bool)) ); | 74 | SLOT(mailArrived(const Email&,bool)) ); |
75 | connect(emailHandler, SIGNAL(mailTransfered(int)), this, | 75 | connect(emailHandler, SIGNAL(mailTransfered(int)), this, |
76 | SLOT(allMailArrived(int)) ); | 76 | SLOT(allMailArrived(int)) ); |
77 | 77 | ||
78 | mailconf = new Config("mailit"); | 78 | mailconf = new Config("mailit"); |
79 | //In case Synchronize is not defined in settings.txt | 79 | //In case Synchronize is not defined in settings.txt |
80 | 80 | ||
81 | readSettings(); | 81 | readSettings(); |
82 | 82 | ||
83 | updateAccounts(); | 83 | updateAccounts(); |
84 | 84 | ||
85 | lineShift = "\n"; | 85 | lineShift = "\n"; |
86 | readMail(); | 86 | readMail(); |
87 | lineShift = "\r\n"; | 87 | lineShift = "\r\n"; |
88 | 88 | ||
89 | mailboxView->setCurrentTab(0); //ensure that inbox has focus | 89 | mailboxView->setCurrentTab(0); //ensure that inbox has focus |
90 | 90 | ||
91 | /*channel = new QCopChannel( "QPE/Application/mailit", this ); | 91 | /*channel = new QCopChannel( "QPE/Application/mailit", this ); |
92 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 92 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
93 | this, SLOT(receive(const QCString&, const QByteArray&)) );*/ | 93 | this, SLOT(receive(const QCString&,const QByteArray&)) );*/ |
94 | 94 | ||
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | EmailClient::~EmailClient() | 98 | EmailClient::~EmailClient() |
99 | { | 99 | { |
100 | //needs to be moved from destructor to closewindow event | 100 | //needs to be moved from destructor to closewindow event |
101 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); | 101 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); |
102 | //does not currently work. Defining outbox in the same | 102 | //does not currently work. Defining outbox in the same |
103 | //format as inbox is not a good solution as they have | 103 | //format as inbox is not a good solution as they have |
104 | //different properties | 104 | //different properties |
105 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); | 105 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); |
106 | saveSettings(); | 106 | saveSettings(); |
107 | 107 | ||
108 | mailconf->write(); | 108 | mailconf->write(); |
109 | delete mailconf; | 109 | delete mailconf; |
110 | 110 | ||
111 | } | 111 | } |
112 | 112 | ||
113 | void EmailClient::init() | 113 | void EmailClient::init() |
114 | { | 114 | { |
115 | initStatusBar(this); | 115 | initStatusBar(this); |
116 | 116 | ||
117 | setToolBarsMovable(FALSE); | 117 | setToolBarsMovable(FALSE); |
118 | 118 | ||
119 | bar = new QToolBar(this); | 119 | bar = new QToolBar(this); |
120 | QWhatsThis::add(bar,tr("Main operation toolbar")); | 120 | QWhatsThis::add(bar,tr("Main operation toolbar")); |
121 | bar->setHorizontalStretchable( TRUE ); | 121 | bar->setHorizontalStretchable( TRUE ); |
122 | 122 | ||
123 | mb = new QMenuBar( bar ); | 123 | mb = new QMenuBar( bar ); |
124 | 124 | ||
125 | QPopupMenu *mail = new QPopupMenu(mb); | 125 | QPopupMenu *mail = new QPopupMenu(mb); |
126 | mb->insertItem( tr( "&Mail" ), mail); | 126 | mb->insertItem( tr( "&Mail" ), mail); |
127 | 127 | ||
128 | QPopupMenu *configure = new QPopupMenu(mb); | 128 | QPopupMenu *configure = new QPopupMenu(mb); |
129 | mb->insertItem( tr( "Accounts" ), configure); | 129 | mb->insertItem( tr( "Accounts" ), configure); |
130 | 130 | ||
131 | selectAccountMenu = new QPopupMenu(mb); | 131 | selectAccountMenu = new QPopupMenu(mb); |
132 | editAccountMenu = new QPopupMenu(mb); | 132 | editAccountMenu = new QPopupMenu(mb); |
133 | deleteAccountMenu = new QPopupMenu(mb); | 133 | deleteAccountMenu = new QPopupMenu(mb); |
134 | 134 | ||
135 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); | 135 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); |
136 | configure->insertItem(tr("Edit account"), editAccountMenu); | 136 | configure->insertItem(tr("Edit account"), editAccountMenu); |
137 | configure->insertItem(tr("Delete account"), deleteAccountMenu); | 137 | configure->insertItem(tr("Delete account"), deleteAccountMenu); |
138 | 138 | ||
139 | bar = new QToolBar(this); | 139 | bar = new QToolBar(this); |
140 | 140 | ||
141 | getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar); | 141 | getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar); |
142 | QWhatsThis::add(getMailButton,tr("Click to download mail via all available accounts.\n Press and hold to select the desired account.")); | 142 | QWhatsThis::add(getMailButton,tr("Click to download mail via all available accounts.\n Press and hold to select the desired account.")); |
143 | 143 | ||
144 | getMailButton->setPopup(selectAccountMenu); | 144 | getMailButton->setPopup(selectAccountMenu); |
145 | 145 | ||
146 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); | 146 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); |
147 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); | 147 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); |
148 | sendMailButton->addTo(bar); | 148 | sendMailButton->addTo(bar); |
149 | sendMailButton->addTo(mail); | 149 | sendMailButton->addTo(mail); |
150 | sendMailButton->setWhatsThis("Send mail queued in the outbox"); | 150 | sendMailButton->setWhatsThis("Send mail queued in the outbox"); |
151 | 151 | ||
152 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); | 152 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); |
153 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); | 153 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); |
154 | composeButton->addTo(bar); | 154 | composeButton->addTo(bar); |
155 | composeButton->addTo(mail); | 155 | composeButton->addTo(mail); |
156 | composeButton->setWhatsThis("Compose a new mail"); | 156 | composeButton->setWhatsThis("Compose a new mail"); |
157 | 157 | ||
158 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); | 158 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); |
159 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); | 159 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); |
160 | cancelButton->addTo(mail); | 160 | cancelButton->addTo(mail); |
161 | cancelButton->addTo(bar); | 161 | cancelButton->addTo(bar); |
162 | cancelButton->setEnabled(FALSE); | 162 | cancelButton->setEnabled(FALSE); |
163 | cancelButton->setWhatsThis("Stop the currently active mail transfer"); | 163 | cancelButton->setWhatsThis("Stop the currently active mail transfer"); |
164 | 164 | ||
165 | 165 | ||
166 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); | 166 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); |
167 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); | 167 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); |
168 | deleteButton->addTo(bar); | 168 | deleteButton->addTo(bar); |
169 | deleteButton->setWhatsThis("Remove the currently selected eMail(s)"); | 169 | deleteButton->setWhatsThis("Remove the currently selected eMail(s)"); |
170 | 170 | ||
171 | mailboxView = new OTabWidget( this, "mailboxView" ); | 171 | mailboxView = new OTabWidget( this, "mailboxView" ); |
172 | 172 | ||
173 | QWidget* widget = new QWidget( mailboxView, "widget" ); | 173 | QWidget* widget = new QWidget( mailboxView, "widget" ); |
174 | grid_2 = new QGridLayout( widget ); | 174 | grid_2 = new QGridLayout( widget ); |
175 | // grid_2->setSpacing(6); | 175 | // grid_2->setSpacing(6); |
176 | // grid_2->setMargin( 11 ); | 176 | // grid_2->setMargin( 11 ); |
177 | 177 | ||
178 | inboxView = new QListView( widget, "inboxView" ); | 178 | inboxView = new QListView( widget, "inboxView" ); |
179 | inboxView->addColumn( tr( "From" ) ); | 179 | inboxView->addColumn( tr( "From" ) ); |
180 | inboxView->addColumn( tr( "Subject" ) ); | 180 | inboxView->addColumn( tr( "Subject" ) ); |
181 | inboxView->addColumn( tr( "Date" ) ); | 181 | inboxView->addColumn( tr( "Date" ) ); |
182 | inboxView->setMinimumSize( QSize( 0, 0 ) ); | 182 | inboxView->setMinimumSize( QSize( 0, 0 ) ); |
183 | inboxView->setAllColumnsShowFocus(TRUE); | 183 | inboxView->setAllColumnsShowFocus(TRUE); |
184 | QWhatsThis::add(inboxView,QWidget::tr("This is the inbox view.\n" | 184 | QWhatsThis::add(inboxView,QWidget::tr("This is the inbox view.\n" |
185 | "It keeps the fetched mail which can be \n" | 185 | "It keeps the fetched mail which can be \n" |
186 | "viewed by double clicking the entry.\n" | 186 | "viewed by double clicking the entry.\n" |
187 | "blue attachment icon shows whether this \n" | 187 | "blue attachment icon shows whether this \n" |
188 | "mailhas attachments.\n")); | 188 | "mailhas attachments.\n")); |
189 | 189 | ||
190 | grid_2->addWidget( inboxView, 2, 0 ); | 190 | grid_2->addWidget( inboxView, 2, 0 ); |
191 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); | 191 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); |
192 | 192 | ||
193 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); | 193 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); |
194 | grid_3 = new QGridLayout( widget_2 ); | 194 | grid_3 = new QGridLayout( widget_2 ); |
195 | // grid_3->setSpacing(6); | 195 | // grid_3->setSpacing(6); |
196 | // grid_3->setMargin( 11 ); | 196 | // grid_3->setMargin( 11 ); |
197 | 197 | ||
198 | outboxView = new QListView( widget_2, "outboxView" ); | 198 | outboxView = new QListView( widget_2, "outboxView" ); |
199 | outboxView->addColumn( tr( "To" ) ); | 199 | outboxView->addColumn( tr( "To" ) ); |
200 | outboxView->addColumn( tr( "Subject" ) ); | 200 | outboxView->addColumn( tr( "Subject" ) ); |
201 | outboxView->setAllColumnsShowFocus(TRUE); | 201 | outboxView->setAllColumnsShowFocus(TRUE); |
202 | 202 | ||
203 | QWhatsThis::add(outboxView,QWidget::tr("This is the outbox view.\n" | 203 | QWhatsThis::add(outboxView,QWidget::tr("This is the outbox view.\n" |
204 | "It keeps the queued mails to send which can be \n" | 204 | "It keeps the queued mails to send which can be \n" |
205 | "reviewed by double clicking the entry.")); | 205 | "reviewed by double clicking the entry.")); |
206 | grid_3->addWidget( outboxView, 0, 0 ); | 206 | grid_3->addWidget( outboxView, 0, 0 ); |
207 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); | 207 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); |
208 | 208 | ||
209 | setCentralWidget(mailboxView); | 209 | setCentralWidget(mailboxView); |
210 | 210 | ||
211 | } | 211 | } |
212 | 212 | ||
213 | void EmailClient::initStatusBar(QWidget* parent) | 213 | void EmailClient::initStatusBar(QWidget* parent) |
214 | { | 214 | { |
215 | statusBar = new QStatusBar(parent); | 215 | statusBar = new QStatusBar(parent); |
216 | statusBar->setSizeGripEnabled(FALSE); | 216 | statusBar->setSizeGripEnabled(FALSE); |
217 | 217 | ||
218 | status1Label = new QLabel( tr("Idle"), statusBar); | 218 | status1Label = new QLabel( tr("Idle"), statusBar); |
219 | status2Label = new QLabel("", statusBar); | 219 | status2Label = new QLabel("", statusBar); |
220 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), | 220 | connect(emailHandler, SIGNAL(updatePopStatus(const QString&)), |
221 | status2Label, SLOT(setText(const QString &)) ); | 221 | status2Label, SLOT(setText(const QString&)) ); |
222 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), | 222 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString&)), |
223 | status2Label, SLOT(setText(const QString &)) ); | 223 | status2Label, SLOT(setText(const QString&)) ); |
224 | 224 | ||
225 | progressBar = new QProgressBar(statusBar); | 225 | progressBar = new QProgressBar(statusBar); |
226 | 226 | ||
227 | connect(emailHandler, SIGNAL(mailboxSize(int)), | 227 | connect(emailHandler, SIGNAL(mailboxSize(int)), |
228 | this, SLOT(setTotalSize(int)) ); | 228 | this, SLOT(setTotalSize(int)) ); |
229 | connect(emailHandler, SIGNAL(currentMailSize(int)), | 229 | connect(emailHandler, SIGNAL(currentMailSize(int)), |
230 | this, SLOT(setMailSize(int)) ); | 230 | this, SLOT(setMailSize(int)) ); |
231 | connect(emailHandler, SIGNAL(downloadedSize(int)), | 231 | connect(emailHandler, SIGNAL(downloadedSize(int)), |
232 | this, SLOT(setDownloadedSize(int)) ); | 232 | this, SLOT(setDownloadedSize(int)) ); |
233 | 233 | ||
234 | statusBar->addWidget(status1Label); | 234 | statusBar->addWidget(status1Label); |
235 | statusBar->addWidget(progressBar); | 235 | statusBar->addWidget(progressBar); |
236 | statusBar->addWidget(status2Label); | 236 | statusBar->addWidget(status2Label); |
237 | 237 | ||
238 | } | 238 | } |
239 | 239 | ||
240 | void EmailClient::compose() | 240 | void EmailClient::compose() |
241 | { | 241 | { |
242 | emit composeRequested(); | 242 | emit composeRequested(); |
243 | } | 243 | } |
244 | 244 | ||
245 | void EmailClient::cancel() | 245 | void EmailClient::cancel() |
246 | { | 246 | { |
247 | emailHandler->cancel(); | 247 | emailHandler->cancel(); |
248 | } | 248 | } |
249 | 249 | ||
250 | AddressList* EmailClient::getAdrListRef() | 250 | AddressList* EmailClient::getAdrListRef() |
251 | { | 251 | { |
252 | return addressList; | 252 | return addressList; |
253 | } | 253 | } |
254 | 254 | ||
255 | //this needs to be rewritten to syncronize with outboxView | 255 | //this needs to be rewritten to syncronize with outboxView |
256 | void EmailClient::enqueMail(const Email &mail) | 256 | void EmailClient::enqueMail(const Email &mail) |
257 | { | 257 | { |
258 | if (accountList.count() == 0) { | 258 | if (accountList.count() == 0) { |
259 | QMessageBox::warning(qApp->activeWindow(), | 259 | QMessageBox::warning(qApp->activeWindow(), |
260 | tr("No account selected"), tr("You must create an account"), "OK\n"); | 260 | tr("No account selected"), tr("You must create an account"), "OK\n"); |
261 | return; | 261 | return; |
262 | } | 262 | } |
263 | 263 | ||
264 | if (accountList.count() > 0) { | 264 | if (accountList.count() > 0) { |
265 | currentAccount = accountList.first(); | 265 | currentAccount = accountList.first(); |
266 | qWarning("using account " + currentAccount->name); | 266 | qWarning("using account " + currentAccount->name); |
267 | } | 267 | } |
268 | 268 | ||
269 | Email addMail = mail; | 269 | Email addMail = mail; |
270 | addMail.from = currentAccount->name; | 270 | addMail.from = currentAccount->name; |
271 | addMail.fromMail = currentAccount->emailAddress; | 271 | addMail.fromMail = currentAccount->emailAddress; |
272 | addMail.rawMail.prepend("From: \"" + addMail.from + "\" <" + addMail.fromMail + ">\n"); | 272 | addMail.rawMail.prepend("From: \"" + addMail.from + "\" <" + addMail.fromMail + ">\n"); |
273 | item = new EmailListItem(outboxView, addMail, false); | 273 | item = new EmailListItem(outboxView, addMail, false); |
274 | 274 | ||
275 | mailboxView->setCurrentTab(1); | 275 | mailboxView->setCurrentTab(1); |
276 | 276 | ||
277 | } | 277 | } |
278 | 278 | ||
279 | void EmailClient::sendQuedMail() | 279 | void EmailClient::sendQuedMail() |
280 | { | 280 | { |
281 | int count = 0; | 281 | int count = 0; |
282 | 282 | ||
283 | if (accountList.count() == 0) { | 283 | if (accountList.count() == 0) { |
284 | QMessageBox::warning(qApp->activeWindow(), tr("No account selected"), tr("You must create an account"), "OK\n"); | 284 | QMessageBox::warning(qApp->activeWindow(), tr("No account selected"), tr("You must create an account"), "OK\n"); |
285 | return; | 285 | return; |
286 | } | 286 | } |
287 | //traverse listview, find messages to send | 287 | //traverse listview, find messages to send |
288 | if (! sending) { | 288 | if (! sending) { |
289 | item = (EmailListItem *) outboxView->firstChild(); | 289 | item = (EmailListItem *) outboxView->firstChild(); |
290 | if (item != NULL) { | 290 | if (item != NULL) { |
291 | while (item != NULL) { | 291 | while (item != NULL) { |
292 | quedMessages.append(item->getMail()); | 292 | quedMessages.append(item->getMail()); |
293 | item = (EmailListItem *) item->nextSibling(); | 293 | item = (EmailListItem *) item->nextSibling(); |
294 | count++; | 294 | count++; |
295 | } | 295 | } |
296 | setMailAccount(); | 296 | setMailAccount(); |
297 | emailHandler->sendMail(&quedMessages); | 297 | emailHandler->sendMail(&quedMessages); |
298 | sending = TRUE; | 298 | sending = TRUE; |
299 | sendMailButton->setEnabled(FALSE); | 299 | sendMailButton->setEnabled(FALSE); |
300 | cancelButton->setEnabled(TRUE); | 300 | cancelButton->setEnabled(TRUE); |
301 | } else { | 301 | } else { |
302 | qWarning("sendQuedMail(): no messages to send"); | 302 | qWarning("sendQuedMail(): no messages to send"); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | } | 305 | } |
306 | 306 | ||
307 | void EmailClient::setMailAccount() | 307 | void EmailClient::setMailAccount() |
308 | { | 308 | { |
309 | emailHandler->setAccount(*currentAccount); | 309 | emailHandler->setAccount(*currentAccount); |
310 | } | 310 | } |
311 | 311 | ||
312 | void EmailClient::mailSent() | 312 | void EmailClient::mailSent() |
313 | { | 313 | { |
314 | sending = FALSE; | 314 | sending = FALSE; |
315 | sendMailButton->setEnabled(TRUE); | 315 | sendMailButton->setEnabled(TRUE); |
316 | 316 | ||
317 | quedMessages.clear(); | 317 | quedMessages.clear(); |
318 | outboxView->clear(); //should be moved to an sentBox | 318 | outboxView->clear(); //should be moved to an sentBox |
319 | } | 319 | } |
diff --git a/noncore/unsupported/mailit/emailhandler.cpp b/noncore/unsupported/mailit/emailhandler.cpp index 06e978d..02b3e9a 100644 --- a/noncore/unsupported/mailit/emailhandler.cpp +++ b/noncore/unsupported/mailit/emailhandler.cpp | |||
@@ -1,154 +1,154 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop 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 | #include <qfileinfo.h> | 20 | #include <qfileinfo.h> |
21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
22 | #include <qapplication.h> | 22 | #include <qapplication.h> |
23 | #include <qmessagebox.h> | 23 | #include <qmessagebox.h> |
24 | #include <qcstring.h> | 24 | #include <qcstring.h> |
25 | #include "emailhandler.h" | 25 | #include "emailhandler.h" |
26 | #include <qpe/applnk.h> | 26 | #include <qpe/applnk.h> |
27 | #include <qpe/filemanager.h> | 27 | #include <qpe/filemanager.h> |
28 | 28 | ||
29 | QCollection::Item EnclosureList::newItem(QCollection::Item d) | 29 | QCollection::Item EnclosureList::newItem(QCollection::Item d) |
30 | { | 30 | { |
31 | return dupl( (Enclosure *) d); | 31 | return dupl( (Enclosure *) d); |
32 | } | 32 | } |
33 | 33 | ||
34 | Enclosure* EnclosureList::dupl(Enclosure *in) | 34 | Enclosure* EnclosureList::dupl(Enclosure *in) |
35 | { | 35 | { |
36 | ac = new Enclosure(*in); | 36 | ac = new Enclosure(*in); |
37 | return ac; | 37 | return ac; |
38 | } | 38 | } |
39 | 39 | ||
40 | EmailHandler::EmailHandler() | 40 | EmailHandler::EmailHandler() |
41 | { | 41 | { |
42 | qDebug("EMailHandler::EmailHandler"); | 42 | qDebug("EMailHandler::EmailHandler"); |
43 | 43 | ||
44 | smtpClient = new SmtpClient(); | 44 | smtpClient = new SmtpClient(); |
45 | popClient = new PopClient(); | 45 | popClient = new PopClient(); |
46 | 46 | ||
47 | connect(smtpClient, SIGNAL(errorOccurred(int, const QString &)), this, | 47 | connect(smtpClient, SIGNAL(errorOccurred(int,const QString&)), this, |
48 | SIGNAL(smtpError(int, const QString &)) ); | 48 | SIGNAL(smtpError(int,const QString&)) ); |
49 | connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); | 49 | connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); |
50 | connect(smtpClient, SIGNAL(updateStatus(const QString &)), this, | 50 | connect(smtpClient, SIGNAL(updateStatus(const QString&)), this, |
51 | SIGNAL(updateSmtpStatus(const QString &)) ); | 51 | SIGNAL(updateSmtpStatus(const QString&)) ); |
52 | 52 | ||
53 | connect(popClient, SIGNAL(errorOccurred(int, const QString &)), this, | 53 | connect(popClient, SIGNAL(errorOccurred(int,const QString&)), this, |
54 | SIGNAL(popError(int, const QString &)) ); | 54 | SIGNAL(popError(int,const QString&)) ); |
55 | connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)), | 55 | connect(popClient, SIGNAL(newMessage(const QString&,int,uint,bool)), |
56 | this, SLOT(messageArrived(const QString &, int, uint, bool)) ); | 56 | this, SLOT(messageArrived(const QString&,int,uint,bool)) ); |
57 | connect(popClient, SIGNAL(updateStatus(const QString &)), this, | 57 | connect(popClient, SIGNAL(updateStatus(const QString&)), this, |
58 | SIGNAL(updatePopStatus(const QString &)) ); | 58 | SIGNAL(updatePopStatus(const QString&)) ); |
59 | connect(popClient, SIGNAL(mailTransfered(int)), this, | 59 | connect(popClient, SIGNAL(mailTransfered(int)), this, |
60 | SIGNAL(mailTransfered(int)) ); | 60 | SIGNAL(mailTransfered(int)) ); |
61 | 61 | ||
62 | 62 | ||
63 | //relaying size information | 63 | //relaying size information |
64 | connect(popClient, SIGNAL(currentMailSize(int)), | 64 | connect(popClient, SIGNAL(currentMailSize(int)), |
65 | this, SIGNAL(currentMailSize(int)) ); | 65 | this, SIGNAL(currentMailSize(int)) ); |
66 | connect(popClient, SIGNAL(downloadedSize(int)), | 66 | connect(popClient, SIGNAL(downloadedSize(int)), |
67 | this, SIGNAL(downloadedSize(int)) ); | 67 | this, SIGNAL(downloadedSize(int)) ); |
68 | } | 68 | } |
69 | 69 | ||
70 | void EmailHandler::sendMail(QList<Email> *mailList) | 70 | void EmailHandler::sendMail(QList<Email> *mailList) |
71 | { | 71 | { |
72 | Email *currentMail; | 72 | Email *currentMail; |
73 | QString temp; | 73 | QString temp; |
74 | QString userName = QString::null; | 74 | QString userName = QString::null; |
75 | // not supported by ALL SMTP servers in the MAIL From field | 75 | // not supported by ALL SMTP servers in the MAIL From field |
76 | // userName = "\""+mailAccount.name+"\""; | 76 | // userName = "\""+mailAccount.name+"\""; |
77 | userName += "<" + mailAccount.emailAddress + ">"; | 77 | userName += "<" + mailAccount.emailAddress + ">"; |
78 | 78 | ||
79 | for (currentMail = mailList->first(); currentMail != 0; | 79 | for (currentMail = mailList->first(); currentMail != 0; |
80 | currentMail = mailList->next()) { | 80 | currentMail = mailList->next()) { |
81 | 81 | ||
82 | if (encodeMime(currentMail) == 0) { | 82 | if (encodeMime(currentMail) == 0) { |
83 | smtpClient->addMail(userName, currentMail->subject, | 83 | smtpClient->addMail(userName, currentMail->subject, |
84 | currentMail->recipients, currentMail->rawMail); | 84 | currentMail->recipients, currentMail->rawMail); |
85 | } else { //error | 85 | } else { //error |
86 | temp = tr("Could not locate all files in \nmail with subject: ") + | 86 | temp = tr("Could not locate all files in \nmail with subject: ") + |
87 | currentMail->subject; | 87 | currentMail->subject; |
88 | temp += tr("\nMail has NOT been sent"); | 88 | temp += tr("\nMail has NOT been sent"); |
89 | QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); | 89 | QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); |
90 | 90 | ||
91 | } | 91 | } |
92 | } | 92 | } |
93 | smtpClient->newConnection(mailAccount.smtpServer, 25); | 93 | smtpClient->newConnection(mailAccount.smtpServer, 25); |
94 | } | 94 | } |
95 | 95 | ||
96 | void EmailHandler::setAccount(MailAccount account) | 96 | void EmailHandler::setAccount(MailAccount account) |
97 | { | 97 | { |
98 | mailAccount = account; | 98 | mailAccount = account; |
99 | } | 99 | } |
100 | 100 | ||
101 | void EmailHandler::getMail() | 101 | void EmailHandler::getMail() |
102 | { | 102 | { |
103 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 103 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
104 | if (mailAccount.synchronize) { | 104 | if (mailAccount.synchronize) { |
105 | popClient->setSynchronize(mailAccount.lastServerMailCount); | 105 | popClient->setSynchronize(mailAccount.lastServerMailCount); |
106 | } else { | 106 | } else { |
107 | popClient->removeSynchronize(); | 107 | popClient->removeSynchronize(); |
108 | } | 108 | } |
109 | 109 | ||
110 | headers = FALSE; | 110 | headers = FALSE; |
111 | //popClient->headersOnly(headers, 0); | 111 | //popClient->headersOnly(headers, 0); |
112 | popClient->newConnection(mailAccount.popServer, 110); | 112 | popClient->newConnection(mailAccount.popServer, 110); |
113 | } | 113 | } |
114 | 114 | ||
115 | void EmailHandler::getMailHeaders() | 115 | void EmailHandler::getMailHeaders() |
116 | { | 116 | { |
117 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 117 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
118 | mailAccount.synchronize ? popClient->setSynchronize(mailAccount.lastServerMailCount): popClient->removeSynchronize(); | 118 | mailAccount.synchronize ? popClient->setSynchronize(mailAccount.lastServerMailCount): popClient->removeSynchronize(); |
119 | 119 | ||
120 | headers = TRUE; | 120 | headers = TRUE; |
121 | popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all | 121 | popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all |
122 | qDebug("Initiating connection"); | 122 | qDebug("Initiating connection"); |
123 | popClient->newConnection(mailAccount.popServer, 110); | 123 | popClient->newConnection(mailAccount.popServer, 110); |
124 | } | 124 | } |
125 | 125 | ||
126 | void EmailHandler::getMailByList(MailList *mailList) | 126 | void EmailHandler::getMailByList(MailList *mailList) |
127 | { | 127 | { |
128 | if (mailList->count() == 0) { //should not occur though | 128 | if (mailList->count() == 0) { //should not occur though |
129 | emit mailTransfered(0); | 129 | emit mailTransfered(0); |
130 | return; | 130 | return; |
131 | } | 131 | } |
132 | 132 | ||
133 | headers = FALSE; | 133 | headers = FALSE; |
134 | popClient->headersOnly(FALSE, 0); | 134 | popClient->headersOnly(FALSE, 0); |
135 | 135 | ||
136 | popClient->setAccount(mailAccount.popUserName,mailAccount.popPasswd); | 136 | popClient->setAccount(mailAccount.popUserName,mailAccount.popPasswd); |
137 | popClient->setSelectedMails(mailList); | 137 | popClient->setSelectedMails(mailList); |
138 | popClient->newConnection(mailAccount.popServer, 110); | 138 | popClient->newConnection(mailAccount.popServer, 110); |
139 | } | 139 | } |
140 | 140 | ||
141 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) | 141 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) |
142 | { | 142 | { |
143 | Email mail; | 143 | Email mail; |
144 | 144 | ||
145 | mail.rawMail = message; | 145 | mail.rawMail = message; |
146 | mail.serverId = id; | 146 | mail.serverId = id; |
147 | mail.size = size; | 147 | mail.size = size; |
148 | mail.downloaded = complete; | 148 | mail.downloaded = complete; |
149 | 149 | ||
150 | emit mailArrived(mail, FALSE); | 150 | emit mailArrived(mail, FALSE); |
151 | } | 151 | } |
152 | 152 | ||
153 | bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mail) | 153 | bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mail) |
154 | { | 154 | { |
diff --git a/noncore/unsupported/mailit/mailitwindow.cpp b/noncore/unsupported/mailit/mailitwindow.cpp index 6e298c7..fec4d78 100644 --- a/noncore/unsupported/mailit/mailitwindow.cpp +++ b/noncore/unsupported/mailit/mailitwindow.cpp | |||
@@ -1,161 +1,161 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop 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 | #include <qwhatsthis.h> | 20 | #include <qwhatsthis.h> |
21 | #include <qmessagebox.h> | 21 | #include <qmessagebox.h> |
22 | #include "mailitwindow.h" | 22 | #include "mailitwindow.h" |
23 | 23 | ||
24 | MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags /*fl*/) | 24 | MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags /*fl*/) |
25 | : QMainWindow(parent, name, WStyle_ContextHelp) | 25 | : QMainWindow(parent, name, WStyle_ContextHelp) |
26 | { | 26 | { |
27 | currentCaption = tr("Mailit"); | 27 | currentCaption = tr("Mailit"); |
28 | setCaption(tr(currentCaption)); | 28 | setCaption(tr(currentCaption)); |
29 | views = new QWidgetStack(this); | 29 | views = new QWidgetStack(this); |
30 | setCentralWidget(views); | 30 | setCentralWidget(views); |
31 | QWhatsThis::add(views,tr("Central view area")); | 31 | QWhatsThis::add(views,tr("Central view area")); |
32 | emailClient = new EmailClient(views, "client"); | 32 | emailClient = new EmailClient(views, "client"); |
33 | writeMail = new WriteMail(views, "writing"); | 33 | writeMail = new WriteMail(views, "writing"); |
34 | readMail = new ReadMail(views, "reading"); | 34 | readMail = new ReadMail(views, "reading"); |
35 | 35 | ||
36 | views->raiseWidget(emailClient); | 36 | views->raiseWidget(emailClient); |
37 | 37 | ||
38 | connect(emailClient, SIGNAL(composeRequested()), | 38 | connect(emailClient, SIGNAL(composeRequested()), |
39 | this, SLOT(compose()) ); | 39 | this, SLOT(compose()) ); |
40 | connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, | 40 | connect(emailClient, SIGNAL(viewEmail(QListView*,Email*)), this, |
41 | SLOT(viewMail(QListView *, Email *)) ); | 41 | SLOT(viewMail(QListView*,Email*)) ); |
42 | connect(emailClient, SIGNAL(mailUpdated(Email *)), this, | 42 | connect(emailClient, SIGNAL(mailUpdated(Email*)), this, |
43 | SLOT(updateMailView(Email *)) ); | 43 | SLOT(updateMailView(Email*)) ); |
44 | 44 | ||
45 | connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); | 45 | connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); |
46 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, | 46 | connect(writeMail, SIGNAL(sendMailRequested(const Email&)), this, |
47 | SLOT(showEmailClient()) ); | 47 | SLOT(showEmailClient()) ); |
48 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, | 48 | connect(writeMail, SIGNAL(sendMailRequested(const Email&)), emailClient, |
49 | SLOT(enqueMail(const Email &)) ); | 49 | SLOT(enqueMail(const Email&)) ); |
50 | 50 | ||
51 | connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); | 51 | connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); |
52 | connect(readMail, SIGNAL(replyRequested(Email &, bool&)), this, | 52 | connect(readMail, SIGNAL(replyRequested(Email&,bool&)), this, |
53 | SLOT(composeReply(Email &, bool&)) ); | 53 | SLOT(composeReply(Email&,bool&)) ); |
54 | connect(readMail, SIGNAL(forwardRequested(Email &)), this, | 54 | connect(readMail, SIGNAL(forwardRequested(Email&)), this, |
55 | SLOT(composeForward(Email &)) ); | 55 | SLOT(composeForward(Email&)) ); |
56 | 56 | ||
57 | connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, | 57 | connect(readMail, SIGNAL(removeItem(EmailListItem*,bool&)), emailClient, |
58 | SLOT(deleteMail(EmailListItem *, bool &)) ); | 58 | SLOT(deleteMail(EmailListItem*,bool&)) ); |
59 | connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, | 59 | connect(readMail, SIGNAL(viewingMail(Email*)), emailClient, |
60 | SLOT(moveMailFront(Email *)) ); | 60 | SLOT(moveMailFront(Email*)) ); |
61 | 61 | ||
62 | connect(emailClient, SIGNAL(newCaption(const QString &)), | 62 | connect(emailClient, SIGNAL(newCaption(const QString&)), |
63 | this, SLOT(updateCaption(const QString &)) ); | 63 | this, SLOT(updateCaption(const QString&)) ); |
64 | 64 | ||
65 | connect(readMail, SIGNAL(download(Email *)), emailClient, SLOT(download(Email*)) ); | 65 | connect(readMail, SIGNAL(download(Email*)), emailClient, SLOT(download(Email*)) ); |
66 | 66 | ||
67 | viewingMail = FALSE; | 67 | viewingMail = FALSE; |
68 | } | 68 | } |
69 | 69 | ||
70 | MailItWindow::~MailItWindow() | 70 | MailItWindow::~MailItWindow() |
71 | { | 71 | { |
72 | } | 72 | } |
73 | 73 | ||
74 | void MailItWindow::closeEvent(QCloseEvent *e) | 74 | void MailItWindow::closeEvent(QCloseEvent *e) |
75 | { | 75 | { |
76 | if (views->visibleWidget() == emailClient) { | 76 | if (views->visibleWidget() == emailClient) { |
77 | e->accept(); | 77 | e->accept(); |
78 | } else { | 78 | } else { |
79 | showEmailClient(); | 79 | showEmailClient(); |
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | void MailItWindow::compose() | 83 | void MailItWindow::compose() |
84 | { | 84 | { |
85 | viewingMail = FALSE; | 85 | viewingMail = FALSE; |
86 | emailClient->hide(); | 86 | emailClient->hide(); |
87 | readMail->hide(); | 87 | readMail->hide(); |
88 | views->raiseWidget(writeMail); | 88 | views->raiseWidget(writeMail); |
89 | writeMail->setAddressList(emailClient->getAdrListRef()); | 89 | writeMail->setAddressList(emailClient->getAdrListRef()); |
90 | writeMail->newMail(); | 90 | writeMail->newMail(); |
91 | setCaption( tr( "Write mail" ) ); | 91 | setCaption( tr( "Write mail" ) ); |
92 | } | 92 | } |
93 | 93 | ||
94 | void MailItWindow::composeReply(Email &mail, bool& replyAll) | 94 | void MailItWindow::composeReply(Email &mail, bool& replyAll) |
95 | { | 95 | { |
96 | compose(); | 96 | compose(); |
97 | writeMail->reply(mail,replyAll) ; | 97 | writeMail->reply(mail,replyAll) ; |
98 | } | 98 | } |
99 | 99 | ||
100 | void MailItWindow::composeForward(Email &mail) | 100 | void MailItWindow::composeForward(Email &mail) |
101 | { | 101 | { |
102 | compose(); | 102 | compose(); |
103 | writeMail->forward(mail) ; | 103 | writeMail->forward(mail) ; |
104 | } | 104 | } |
105 | 105 | ||
106 | 106 | ||
107 | void MailItWindow::showEmailClient() | 107 | void MailItWindow::showEmailClient() |
108 | { | 108 | { |
109 | viewingMail = FALSE; | 109 | viewingMail = FALSE; |
110 | writeMail->hide(); | 110 | writeMail->hide(); |
111 | readMail->hide(); | 111 | readMail->hide(); |
112 | views->raiseWidget(emailClient); | 112 | views->raiseWidget(emailClient); |
113 | setCaption( tr(currentCaption) ); | 113 | setCaption( tr(currentCaption) ); |
114 | } | 114 | } |
115 | 115 | ||
116 | void MailItWindow::viewMail(QListView *view, Email *mail) | 116 | void MailItWindow::viewMail(QListView *view, Email *mail) |
117 | { | 117 | { |
118 | viewingMail = TRUE; | 118 | viewingMail = TRUE; |
119 | emailClient->hide(); | 119 | emailClient->hide(); |
120 | 120 | ||
121 | int result=0; | 121 | int result=0; |
122 | 122 | ||
123 | if ((mail->received)&&(!mail->downloaded)) | 123 | if ((mail->received)&&(!mail->downloaded)) |
124 | { | 124 | { |
125 | QMessageBox mb( tr("Mail not downloaded"), | 125 | QMessageBox mb( tr("Mail not downloaded"), |
126 | tr("The mail you have clicked \n" | 126 | tr("The mail you have clicked \n" |
127 | "has not been downloaded yet.\n " | 127 | "has not been downloaded yet.\n " |
128 | "Would you like to do it now ?"), | 128 | "Would you like to do it now ?"), |
129 | QMessageBox::Information, | 129 | QMessageBox::Information, |
130 | QMessageBox::Yes | QMessageBox::Default, | 130 | QMessageBox::Yes | QMessageBox::Default, |
131 | QMessageBox::No | QMessageBox::Escape,0 ); | 131 | QMessageBox::No | QMessageBox::Escape,0 ); |
132 | 132 | ||
133 | result=mb.exec(); | 133 | result=mb.exec(); |
134 | 134 | ||
135 | if (result==QMessageBox::Yes) | 135 | if (result==QMessageBox::Yes) |
136 | { | 136 | { |
137 | emailClient->download(mail); | 137 | emailClient->download(mail); |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | readMail->update(view, mail); | 141 | readMail->update(view, mail); |
142 | views->raiseWidget(readMail); | 142 | views->raiseWidget(readMail); |
143 | setCaption( tr( "Read Mail" ) ); | 143 | setCaption( tr( "Read Mail" ) ); |
144 | } | 144 | } |
145 | 145 | ||
146 | void MailItWindow::updateMailView(Email *mail) | 146 | void MailItWindow::updateMailView(Email *mail) |
147 | { | 147 | { |
148 | if (viewingMail) { | 148 | if (viewingMail) { |
149 | readMail->mailUpdated(mail); | 149 | readMail->mailUpdated(mail); |
150 | } | 150 | } |
151 | } | 151 | } |
152 | 152 | ||
153 | void MailItWindow::updateCaption(const QString &newCaption) | 153 | void MailItWindow::updateCaption(const QString &newCaption) |
154 | { | 154 | { |
155 | currentCaption = newCaption; | 155 | currentCaption = newCaption; |
156 | setCaption(tr(currentCaption)); | 156 | setCaption(tr(currentCaption)); |
157 | } | 157 | } |
158 | 158 | ||
159 | void MailItWindow::setDocument(const QString &_address) | 159 | void MailItWindow::setDocument(const QString &_address) |
160 | { | 160 | { |
161 | // strip leading 'mailto:' | 161 | // strip leading 'mailto:' |
diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp index a09bc30..7f1c0b8 100644 --- a/noncore/unsupported/oipkg/mainwindow.cpp +++ b/noncore/unsupported/oipkg/mainwindow.cpp | |||
@@ -83,214 +83,214 @@ void MainWindow::makeMenu() | |||
83 | { | 83 | { |
84 | 84 | ||
85 | QToolBar *toolBar = new QToolBar( this ); | 85 | QToolBar *toolBar = new QToolBar( this ); |
86 | QMenuBar *menuBar = new QMenuBar( toolBar ); | 86 | QMenuBar *menuBar = new QMenuBar( toolBar ); |
87 | QPopupMenu *srvMenu = new QPopupMenu( menuBar ); | 87 | QPopupMenu *srvMenu = new QPopupMenu( menuBar ); |
88 | QPopupMenu *viewMenu = new QPopupMenu( menuBar ); | 88 | QPopupMenu *viewMenu = new QPopupMenu( menuBar ); |
89 | QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); | 89 | QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); |
90 | QPopupMenu *helpMenu = new QPopupMenu( menuBar ); | 90 | QPopupMenu *helpMenu = new QPopupMenu( menuBar ); |
91 | 91 | ||
92 | setToolBarsMovable( false ); | 92 | setToolBarsMovable( false ); |
93 | toolBar->setHorizontalStretchable( true ); | 93 | toolBar->setHorizontalStretchable( true ); |
94 | menuBar->insertItem( tr( "Package" ), srvMenu ); | 94 | menuBar->insertItem( tr( "Package" ), srvMenu ); |
95 | menuBar->insertItem( tr( "View" ), viewMenu ); | 95 | menuBar->insertItem( tr( "View" ), viewMenu ); |
96 | menuBar->insertItem( tr( "Settings" ), cfgMenu ); | 96 | menuBar->insertItem( tr( "Settings" ), cfgMenu ); |
97 | menuBar->insertItem( tr( "Help" ), helpMenu ); | 97 | menuBar->insertItem( tr( "Help" ), helpMenu ); |
98 | 98 | ||
99 | // QLabel *spacer; | 99 | // QLabel *spacer; |
100 | // spacer = new QLabel( "", toolBar ); | 100 | // spacer = new QLabel( "", toolBar ); |
101 | // spacer->setBackgroundColor( toolBar->backgroundColor() ); | 101 | // spacer->setBackgroundColor( toolBar->backgroundColor() ); |
102 | // toolBar->setStretchableWidget( spacer ); | 102 | // toolBar->setStretchableWidget( spacer ); |
103 | 103 | ||
104 | 104 | ||
105 | runAction = new QAction( tr( "Apply" ), | 105 | runAction = new QAction( tr( "Apply" ), |
106 | Resource::loadPixmap( "oipkg/install" ), | 106 | Resource::loadPixmap( "oipkg/install" ), |
107 | QString::null, 0, this, 0 ); | 107 | QString::null, 0, this, 0 ); |
108 | connect( runAction, SIGNAL( activated() ), | 108 | connect( runAction, SIGNAL( activated() ), |
109 | this, SLOT( runIpkg() ) ); | 109 | this, SLOT( runIpkg() ) ); |
110 | runAction->addTo( toolBar ); | 110 | runAction->addTo( toolBar ); |
111 | runAction->addTo( srvMenu ); | 111 | runAction->addTo( srvMenu ); |
112 | 112 | ||
113 | srvMenu->insertSeparator(); | 113 | srvMenu->insertSeparator(); |
114 | 114 | ||
115 | updateAction = new QAction( tr( "Update" ), | 115 | updateAction = new QAction( tr( "Update" ), |
116 | Resource::loadIconSet( "oipkg/update" ), | 116 | Resource::loadIconSet( "oipkg/update" ), |
117 | QString::null, 0, this, 0 ); | 117 | QString::null, 0, this, 0 ); |
118 | connect( updateAction, SIGNAL( activated() ), | 118 | connect( updateAction, SIGNAL( activated() ), |
119 | this , SLOT( updateList() ) ); | 119 | this , SLOT( updateList() ) ); |
120 | updateAction->addTo( toolBar ); | 120 | updateAction->addTo( toolBar ); |
121 | updateAction->addTo( srvMenu ); | 121 | updateAction->addTo( srvMenu ); |
122 | 122 | ||
123 | QAction *cfgact; | 123 | QAction *cfgact; |
124 | 124 | ||
125 | cfgact = new QAction( tr( "Setups" ), | 125 | cfgact = new QAction( tr( "Setups" ), |
126 | QString::null, 0, this, 0 ); | 126 | QString::null, 0, this, 0 ); |
127 | connect( cfgact, SIGNAL( activated() ), | 127 | connect( cfgact, SIGNAL( activated() ), |
128 | SLOT( showSettingsSetup() ) ); | 128 | SLOT( showSettingsSetup() ) ); |
129 | cfgact->addTo( cfgMenu ); | 129 | cfgact->addTo( cfgMenu ); |
130 | 130 | ||
131 | cfgact = new QAction( tr( "Servers" ), | 131 | cfgact = new QAction( tr( "Servers" ), |
132 | QString::null, 0, this, 0 ); | 132 | QString::null, 0, this, 0 ); |
133 | connect( cfgact, SIGNAL( activated() ), | 133 | connect( cfgact, SIGNAL( activated() ), |
134 | SLOT( showSettingsSrv() ) ); | 134 | SLOT( showSettingsSrv() ) ); |
135 | cfgact->addTo( cfgMenu ); | 135 | cfgact->addTo( cfgMenu ); |
136 | cfgact = new QAction( tr( "Destinations" ), | 136 | cfgact = new QAction( tr( "Destinations" ), |
137 | QString::null, 0, this, 0 ); | 137 | QString::null, 0, this, 0 ); |
138 | connect( cfgact, SIGNAL( activated() ), | 138 | connect( cfgact, SIGNAL( activated() ), |
139 | SLOT( showSettingsDst() ) ); | 139 | SLOT( showSettingsDst() ) ); |
140 | cfgact->addTo( cfgMenu ); | 140 | cfgact->addTo( cfgMenu ); |
141 | 141 | ||
142 | QAction *a; | 142 | QAction *a; |
143 | 143 | ||
144 | // SECTIONS | 144 | // SECTIONS |
145 | sectionBar = new QToolBar( this ); | 145 | sectionBar = new QToolBar( this ); |
146 | addToolBar( sectionBar, "Section", QMainWindow::Top, TRUE ); | 146 | addToolBar( sectionBar, "Section", QMainWindow::Top, TRUE ); |
147 | sectionBar->setHorizontalStretchable( true ); | 147 | sectionBar->setHorizontalStretchable( true ); |
148 | QLabel *label = new QLabel( sectionBar, "section" ); | 148 | QLabel *label = new QLabel( sectionBar, "section" ); |
149 | // label->setBackgroundMode( NoBackground ); | 149 | // label->setBackgroundMode( NoBackground ); |
150 | label->font().setPointSize( 8 ); | 150 | label->font().setPointSize( 8 ); |
151 | label->setText( tr( "Section:" ) ); | 151 | label->setText( tr( "Section:" ) ); |
152 | sectionBar->setStretchableWidget( label ); | 152 | sectionBar->setStretchableWidget( label ); |
153 | section = new QComboBox( false, sectionBar ); | 153 | section = new QComboBox( false, sectionBar ); |
154 | section->font().setPointSize( 8 ); | 154 | section->font().setPointSize( 8 ); |
155 | label = new QLabel( " / ", sectionBar ); | 155 | label = new QLabel( " / ", sectionBar ); |
156 | label->font().setPointSize( 8 ); | 156 | label->font().setPointSize( 8 ); |
157 | // label->setBackgroundMode( PaletteForeground ); | 157 | // label->setBackgroundMode( PaletteForeground ); |
158 | subsection = new QComboBox( false, sectionBar ); | 158 | subsection = new QComboBox( false, sectionBar ); |
159 | subsection->font().setPointSize( 8 ); | 159 | subsection->font().setPointSize( 8 ); |
160 | a = new QAction( tr( "Close Section" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 160 | a = new QAction( tr( "Close Section" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
161 | connect( a, SIGNAL( activated() ), this, SLOT( sectionClose() ) ); | 161 | connect( a, SIGNAL( activated() ), this, SLOT( sectionClose() ) ); |
162 | a->addTo( sectionBar ); | 162 | a->addTo( sectionBar ); |
163 | setSections(); | 163 | setSections(); |
164 | setSubSections(); | 164 | setSubSections(); |
165 | sectionAction = new QAction( tr( "Sections" ), QString::null, 0, this, 0 ); | 165 | sectionAction = new QAction( tr( "Sections" ), QString::null, 0, this, 0 ); |
166 | connect( sectionAction, SIGNAL( toggled(bool) ), this, SLOT( sectionShow(bool) ) ); | 166 | connect( sectionAction, SIGNAL( toggled(bool) ), this, SLOT( sectionShow(bool) ) ); |
167 | sectionAction->setToggleAction( true ); | 167 | sectionAction->setToggleAction( true ); |
168 | sectionAction->addTo( viewMenu ); | 168 | sectionAction->addTo( viewMenu ); |
169 | // sectionBar->setStretchableWidget( section ); | 169 | // sectionBar->setStretchableWidget( section ); |
170 | 170 | ||
171 | //FIND | 171 | //FIND |
172 | findBar = new QToolBar(this); | 172 | findBar = new QToolBar(this); |
173 | addToolBar( findBar, "Filter", QMainWindow::Top, TRUE ); | 173 | addToolBar( findBar, "Filter", QMainWindow::Top, TRUE ); |
174 | label = new QLabel( tr("Filter: "), findBar ); | 174 | label = new QLabel( tr("Filter: "), findBar ); |
175 | // label->setBackgroundMode( PaletteForeground ); | 175 | // label->setBackgroundMode( PaletteForeground ); |
176 | findBar->setHorizontalStretchable( TRUE ); | 176 | findBar->setHorizontalStretchable( TRUE ); |
177 | findEdit = new QLineEdit( findBar, "findEdit" ); | 177 | findEdit = new QLineEdit( findBar, "findEdit" ); |
178 | findBar->setStretchableWidget( findEdit ); | 178 | findBar->setStretchableWidget( findEdit ); |
179 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), | 179 | connect( findEdit, SIGNAL( textChanged(const QString&) ), |
180 | this, SLOT( displayList() ) ); | 180 | this, SLOT( displayList() ) ); |
181 | a = new QAction( tr( "Clear Find" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); | 181 | a = new QAction( tr( "Clear Find" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); |
182 | connect( a, SIGNAL( activated() ), findEdit, SLOT( clear() ) ); | 182 | connect( a, SIGNAL( activated() ), findEdit, SLOT( clear() ) ); |
183 | a->addTo( findBar ); | 183 | a->addTo( findBar ); |
184 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 184 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
185 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 185 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
186 | a->addTo( findBar ); | 186 | a->addTo( findBar ); |
187 | findAction = new QAction( tr( "Filter" ), QString::null, 0, this, 0 ); | 187 | findAction = new QAction( tr( "Filter" ), QString::null, 0, this, 0 ); |
188 | connect( findAction, SIGNAL( toggled(bool) ), this, SLOT( findShow(bool) ) ); | 188 | connect( findAction, SIGNAL( toggled(bool) ), this, SLOT( findShow(bool) ) ); |
189 | findAction->setToggleAction( true ); | 189 | findAction->setToggleAction( true ); |
190 | findAction->addTo( viewMenu ); | 190 | findAction->addTo( viewMenu ); |
191 | 191 | ||
192 | //SEARCH | 192 | //SEARCH |
193 | searchBar = new QToolBar(this); | 193 | searchBar = new QToolBar(this); |
194 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 194 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
195 | label = new QLabel( tr("Search: "), searchBar ); | 195 | label = new QLabel( tr("Search: "), searchBar ); |
196 | // label->setBackgroundMode( PaletteForeground ); | 196 | // label->setBackgroundMode( PaletteForeground ); |
197 | searchBar->setHorizontalStretchable( TRUE ); | 197 | searchBar->setHorizontalStretchable( TRUE ); |
198 | searchEdit = new QLineEdit( searchBar, "seachEdit" ); | 198 | searchEdit = new QLineEdit( searchBar, "seachEdit" ); |
199 | searchBar->setStretchableWidget( searchEdit ); | 199 | searchBar->setStretchableWidget( searchEdit ); |
200 | // connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 200 | // connect( searchEdit, SIGNAL( textChanged(const QString&) ), |
201 | // this, SLOT( displayList() ) ); | 201 | // this, SLOT( displayList() ) ); |
202 | a = new QAction( tr( "Clear Search" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); | 202 | a = new QAction( tr( "Clear Search" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); |
203 | connect( a, SIGNAL( activated() ), searchEdit, SLOT( clear() ) ); | 203 | connect( a, SIGNAL( activated() ), searchEdit, SLOT( clear() ) ); |
204 | a->addTo( searchBar ); | 204 | a->addTo( searchBar ); |
205 | searchCommit = new QAction( tr( "Do Search" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 205 | searchCommit = new QAction( tr( "Do Search" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
206 | connect( searchCommit, SIGNAL( activated() ), SLOT( remotePackageQuery() ) ); | 206 | connect( searchCommit, SIGNAL( activated() ), SLOT( remotePackageQuery() ) ); |
207 | searchCommit->addTo( searchBar ); | 207 | searchCommit->addTo( searchBar ); |
208 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 208 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
209 | connect( a, SIGNAL( activated() ), this, SLOT( searchClose() ) ); | 209 | connect( a, SIGNAL( activated() ), this, SLOT( searchClose() ) ); |
210 | a->addTo( searchBar ); | 210 | a->addTo( searchBar ); |
211 | searchAction = new QAction( tr( "Search" ), QString::null, 0, this, 0 ); | 211 | searchAction = new QAction( tr( "Search" ), QString::null, 0, this, 0 ); |
212 | connect( searchAction, SIGNAL( toggled(bool) ), this, SLOT( searchShow(bool) ) ); | 212 | connect( searchAction, SIGNAL( toggled(bool) ), this, SLOT( searchShow(bool) ) ); |
213 | searchAction->setToggleAction( true ); | 213 | searchAction->setToggleAction( true ); |
214 | searchAction->addTo( viewMenu ); | 214 | searchAction->addTo( viewMenu ); |
215 | 215 | ||
216 | //DEST | 216 | //DEST |
217 | destBar = new QToolBar(this); | 217 | destBar = new QToolBar(this); |
218 | addToolBar( destBar, "Destination", QMainWindow::Top, TRUE ); | 218 | addToolBar( destBar, "Destination", QMainWindow::Top, TRUE ); |
219 | label = new QLabel( tr("Destination: "), destBar ); | 219 | label = new QLabel( tr("Destination: "), destBar ); |
220 | // label->setBackgroundMode( PaletteForeground ); | 220 | // label->setBackgroundMode( PaletteForeground ); |
221 | destBar->setHorizontalStretchable( TRUE ); | 221 | destBar->setHorizontalStretchable( TRUE ); |
222 | destination = new QComboBox( false, destBar ); | 222 | destination = new QComboBox( false, destBar ); |
223 | destination->insertStringList( settings->getDestinationNames() ); | 223 | destination->insertStringList( settings->getDestinationNames() ); |
224 | setComboName(destination,settings->getDestinationName()); | 224 | setComboName(destination,settings->getDestinationName()); |
225 | connect( destination, SIGNAL(activated(int)), | 225 | connect( destination, SIGNAL(activated(int)), |
226 | settings, SLOT(activeDestinationChange(int)) ); | 226 | settings, SLOT(activeDestinationChange(int)) ); |
227 | // space->setBackgroundMode( PaletteForeground ); | 227 | // space->setBackgroundMode( PaletteForeground ); |
228 | CheckBoxLink = new QCheckBox( tr("Link"), destBar); | 228 | CheckBoxLink = new QCheckBox( tr("Link"), destBar); |
229 | // CheckBoxLink->setBackgroundMode( PaletteForeground ); | 229 | // CheckBoxLink->setBackgroundMode( PaletteForeground ); |
230 | CheckBoxLink->setChecked( settings->createLinks() ); | 230 | CheckBoxLink->setChecked( settings->createLinks() ); |
231 | connect( CheckBoxLink, SIGNAL(toggled(bool)), | 231 | connect( CheckBoxLink, SIGNAL(toggled(bool)), |
232 | settings, SLOT(linkEnabled(bool)) ); | 232 | settings, SLOT(linkEnabled(bool)) ); |
233 | destAction = new QAction( tr( "Destinations" ), QString::null, 0, this, 0 ); | 233 | destAction = new QAction( tr( "Destinations" ), QString::null, 0, this, 0 ); |
234 | connect( destAction, SIGNAL( toggled(bool) ), SLOT( destShow(bool) ) ); | 234 | connect( destAction, SIGNAL( toggled(bool) ), SLOT( destShow(bool) ) ); |
235 | a = new QAction( tr( "Close Destinations" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 235 | a = new QAction( tr( "Close Destinations" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
236 | connect( a, SIGNAL( activated() ), SLOT( destClose() ) ); | 236 | connect( a, SIGNAL( activated() ), SLOT( destClose() ) ); |
237 | a->addTo( destBar ); | 237 | a->addTo( destBar ); |
238 | destBar->setStretchableWidget( CheckBoxLink ); | 238 | destBar->setStretchableWidget( CheckBoxLink ); |
239 | destAction->setToggleAction( true ); | 239 | destAction->setToggleAction( true ); |
240 | destAction->addTo( viewMenu ); | 240 | destAction->addTo( viewMenu ); |
241 | 241 | ||
242 | // helpMenu | 242 | // helpMenu |
243 | helpMenu->insertSeparator(); | 243 | helpMenu->insertSeparator(); |
244 | a = new QAction( tr( "Package Actions" ), QString::null, 0, this, 0 ); | 244 | a = new QAction( tr( "Package Actions" ), QString::null, 0, this, 0 ); |
245 | a->addTo( helpMenu ); | 245 | a->addTo( helpMenu ); |
246 | helpMenu->insertSeparator(); | 246 | helpMenu->insertSeparator(); |
247 | a = new QAction( tr( "Install" ), | 247 | a = new QAction( tr( "Install" ), |
248 | Resource::loadPixmap( "oipkg/install" ), QString::null, 0, this, 0 ); | 248 | Resource::loadPixmap( "oipkg/install" ), QString::null, 0, this, 0 ); |
249 | a->addTo( helpMenu ); | 249 | a->addTo( helpMenu ); |
250 | a = new QAction( tr( "Remove" ), | 250 | a = new QAction( tr( "Remove" ), |
251 | Resource::loadPixmap( "oipkg/uninstall" ), QString::null, 0, this, 0 ); | 251 | Resource::loadPixmap( "oipkg/uninstall" ), QString::null, 0, this, 0 ); |
252 | a->addTo( helpMenu ); | 252 | a->addTo( helpMenu ); |
253 | helpMenu->insertSeparator(); | 253 | helpMenu->insertSeparator(); |
254 | a = new QAction( tr( "Package Status" ), QString::null, 0, this, 0 ); | 254 | a = new QAction( tr( "Package Status" ), QString::null, 0, this, 0 ); |
255 | a->addTo( helpMenu ); | 255 | a->addTo( helpMenu ); |
256 | helpMenu->insertSeparator(); | 256 | helpMenu->insertSeparator(); |
257 | a = new QAction( tr( "New version, installed" ), | 257 | a = new QAction( tr( "New version, installed" ), |
258 | Resource::loadPixmap( "oipkg/installed" ), QString::null, 0, this, 0 ); | 258 | Resource::loadPixmap( "oipkg/installed" ), QString::null, 0, this, 0 ); |
259 | a->addTo( helpMenu ); | 259 | a->addTo( helpMenu ); |
260 | a = new QAction( tr( "New version, not installed" ), | 260 | a = new QAction( tr( "New version, not installed" ), |
261 | Resource::loadPixmap( "oipkg/uninstalled" ), QString::null, 0, this, 0 ); | 261 | Resource::loadPixmap( "oipkg/uninstalled" ), QString::null, 0, this, 0 ); |
262 | a->addTo( helpMenu ); | 262 | a->addTo( helpMenu ); |
263 | a = new QAction( tr( "Old version, installed" ), | 263 | a = new QAction( tr( "Old version, installed" ), |
264 | Resource::loadPixmap( "oipkg/installedOld" ), QString::null, 0, this, 0 ); | 264 | Resource::loadPixmap( "oipkg/installedOld" ), QString::null, 0, this, 0 ); |
265 | a->addTo( helpMenu ); | 265 | a->addTo( helpMenu ); |
266 | a = new QAction( tr( "Old version, not installed" ), | 266 | a = new QAction( tr( "Old version, not installed" ), |
267 | Resource::loadPixmap( "oipkg/uninstalledOld" ), QString::null, 0, this, 0 ); | 267 | Resource::loadPixmap( "oipkg/uninstalledOld" ), QString::null, 0, this, 0 ); |
268 | a->addTo( helpMenu ); | 268 | a->addTo( helpMenu ); |
269 | a = new QAction( tr( "Old version, new version installed" ), | 269 | a = new QAction( tr( "Old version, new version installed" ), |
270 | Resource::loadPixmap( "oipkg/uninstalledOldinstalledNew" ), QString::null, 0, this, 0 ); | 270 | Resource::loadPixmap( "oipkg/uninstalledOldinstalledNew" ), QString::null, 0, this, 0 ); |
271 | a->addTo( helpMenu ); | 271 | a->addTo( helpMenu ); |
272 | a = new QAction( tr( "New version, old version installed" ), | 272 | a = new QAction( tr( "New version, old version installed" ), |
273 | Resource::loadPixmap( "oipkg/uninstalledInstalledOld" ), QString::null, 0, this, 0 ); | 273 | Resource::loadPixmap( "oipkg/uninstalledInstalledOld" ), QString::null, 0, this, 0 ); |
274 | a->addTo( helpMenu ); | 274 | a->addTo( helpMenu ); |
275 | //a = new QAction( tr( "" ), | 275 | //a = new QAction( tr( "" ), |
276 | // Resource::loadPixmap( "oipkg/" ), QString::null, 0, this, 0 ); | 276 | // Resource::loadPixmap( "oipkg/" ), QString::null, 0, this, 0 ); |
277 | // a->addTo( helpMenu ); | 277 | // a->addTo( helpMenu ); |
278 | 278 | ||
279 | // configure the menus | 279 | // configure the menus |
280 | Config cfg( "oipkg", Config::User ); | 280 | Config cfg( "oipkg", Config::User ); |
281 | cfg.setGroup( "gui" ); | 281 | cfg.setGroup( "gui" ); |
282 | 282 | ||
283 | findShow( cfg.readBoolEntry( "findBar", true ) ); | 283 | findShow( cfg.readBoolEntry( "findBar", true ) ); |
284 | searchShow( cfg.readBoolEntry( "searchBar", true ) ); | 284 | searchShow( cfg.readBoolEntry( "searchBar", true ) ); |
285 | sectionShow( cfg.readBoolEntry( "sectionBar", true ) ); | 285 | sectionShow( cfg.readBoolEntry( "sectionBar", true ) ); |
286 | destShow( cfg.readBoolEntry( "destBar", false ) ); | 286 | destShow( cfg.readBoolEntry( "destBar", false ) ); |
287 | setComboName(section,cfg.readEntry("default_section")); | 287 | setComboName(section,cfg.readEntry("default_section")); |
288 | sectionChanged(); | 288 | sectionChanged(); |
289 | } | 289 | } |
290 | 290 | ||
291 | MainWindow::~MainWindow() | 291 | MainWindow::~MainWindow() |
292 | { | 292 | { |
293 | Config cfg( "oipkg", Config::User ); | 293 | Config cfg( "oipkg", Config::User ); |
294 | cfg.setGroup( "gui" ); | 294 | cfg.setGroup( "gui" ); |
295 | cfg.writeEntry( "findBar", !findBar->isHidden() ); | 295 | cfg.writeEntry( "findBar", !findBar->isHidden() ); |
296 | cfg.writeEntry( "searchBar", !searchBar->isHidden() ); | 296 | cfg.writeEntry( "searchBar", !searchBar->isHidden() ); |
@@ -375,141 +375,141 @@ void MainWindow::setSections() | |||
375 | { | 375 | { |
376 | section->clear(); | 376 | section->clear(); |
377 | section->insertStringList( packageListServers.getSections() ); | 377 | section->insertStringList( packageListServers.getSections() ); |
378 | } | 378 | } |
379 | 379 | ||
380 | void MainWindow::setSubSections() | 380 | void MainWindow::setSubSections() |
381 | { | 381 | { |
382 | subsection->clear(); | 382 | subsection->clear(); |
383 | subsection->insertStringList( packageListServers.getSubSections() ); | 383 | subsection->insertStringList( packageListServers.getSubSections() ); |
384 | } | 384 | } |
385 | 385 | ||
386 | 386 | ||
387 | void MainWindow::showSettings(int i) | 387 | void MainWindow::showSettings(int i) |
388 | { | 388 | { |
389 | if ( settings->showDialog( i ) ) | 389 | if ( settings->showDialog( i ) ) |
390 | { | 390 | { |
391 | updateList(); | 391 | updateList(); |
392 | } | 392 | } |
393 | setComboName(destination,settings->getDestinationName()); | 393 | setComboName(destination,settings->getDestinationName()); |
394 | CheckBoxLink->setChecked( settings->createLinks() ); | 394 | CheckBoxLink->setChecked( settings->createLinks() ); |
395 | } | 395 | } |
396 | void MainWindow::showSettingsSetup() | 396 | void MainWindow::showSettingsSetup() |
397 | { | 397 | { |
398 | showSettings(0); | 398 | showSettings(0); |
399 | } | 399 | } |
400 | void MainWindow::showSettingsSrv() | 400 | void MainWindow::showSettingsSrv() |
401 | { | 401 | { |
402 | showSettings(1); | 402 | showSettings(1); |
403 | } | 403 | } |
404 | void MainWindow::showSettingsDst() | 404 | void MainWindow::showSettingsDst() |
405 | { | 405 | { |
406 | showSettings(2); | 406 | showSettings(2); |
407 | } | 407 | } |
408 | 408 | ||
409 | void MainWindow::sectionShow(bool b) | 409 | void MainWindow::sectionShow(bool b) |
410 | { | 410 | { |
411 | if (b) sectionBar->show(); | 411 | if (b) sectionBar->show(); |
412 | else sectionBar->hide(); | 412 | else sectionBar->hide(); |
413 | sectionAction->setOn( b ); | 413 | sectionAction->setOn( b ); |
414 | } | 414 | } |
415 | 415 | ||
416 | void MainWindow::sectionClose() | 416 | void MainWindow::sectionClose() |
417 | { | 417 | { |
418 | sectionAction->setOn( false ); | 418 | sectionAction->setOn( false ); |
419 | } | 419 | } |
420 | 420 | ||
421 | void MainWindow::findShow(bool b) | 421 | void MainWindow::findShow(bool b) |
422 | { | 422 | { |
423 | if (b) findBar->show(); | 423 | if (b) findBar->show(); |
424 | else findBar->hide(); | 424 | else findBar->hide(); |
425 | findAction->setOn( b ); | 425 | findAction->setOn( b ); |
426 | } | 426 | } |
427 | 427 | ||
428 | void MainWindow::findClose() | 428 | void MainWindow::findClose() |
429 | { | 429 | { |
430 | findAction->setOn( false ); | 430 | findAction->setOn( false ); |
431 | } | 431 | } |
432 | 432 | ||
433 | void MainWindow::searchShow(bool b) | 433 | void MainWindow::searchShow(bool b) |
434 | { | 434 | { |
435 | if (b) searchBar->show(); | 435 | if (b) searchBar->show(); |
436 | else searchBar->hide(); | 436 | else searchBar->hide(); |
437 | searchAction->setOn( b ); | 437 | searchAction->setOn( b ); |
438 | } | 438 | } |
439 | 439 | ||
440 | void MainWindow::searchClose() | 440 | void MainWindow::searchClose() |
441 | { | 441 | { |
442 | searchAction->setOn( false ); | 442 | searchAction->setOn( false ); |
443 | } | 443 | } |
444 | 444 | ||
445 | 445 | ||
446 | void MainWindow::destShow(bool b) | 446 | void MainWindow::destShow(bool b) |
447 | { | 447 | { |
448 | if (b) destBar->show(); | 448 | if (b) destBar->show(); |
449 | else destBar->hide(); | 449 | else destBar->hide(); |
450 | destAction->setOn( b ); | 450 | destAction->setOn( b ); |
451 | } | 451 | } |
452 | 452 | ||
453 | void MainWindow::destClose() | 453 | void MainWindow::destClose() |
454 | { | 454 | { |
455 | destAction->setOn( false ); | 455 | destAction->setOn( false ); |
456 | } | 456 | } |
457 | 457 | ||
458 | void MainWindow::setDocument(const QString &fileName) | 458 | void MainWindow::setDocument(const QString &fileName) |
459 | { | 459 | { |
460 | if ( !QFile::exists( fileName ) ) return; | 460 | if ( !QFile::exists( fileName ) ) return; |
461 | ipkg->installFile( fileName ); | 461 | ipkg->installFile( fileName ); |
462 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 462 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
463 | QString lf = QString::null; | 463 | QString lf = QString::null; |
464 | e << lf; | 464 | e << lf; |
465 | } | 465 | } |
466 | 466 | ||
467 | 467 | ||
468 | void MainWindow::makeChannel() | 468 | void MainWindow::makeChannel() |
469 | { | 469 | { |
470 | channel = new QCopChannel( "QPE/Application/oipkg", this ); | 470 | channel = new QCopChannel( "QPE/Application/oipkg", this ); |
471 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 471 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
472 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 472 | this, SLOT(receive(const QCString&,const QByteArray&)) ); |
473 | } | 473 | } |
474 | 474 | ||
475 | 475 | ||
476 | 476 | ||
477 | void MainWindow::receive(const QCString &msg, const QByteArray &arg) | 477 | void MainWindow::receive(const QCString &msg, const QByteArray &arg) |
478 | { | 478 | { |
479 | pvDebug(3, "QCop "+msg+" "+QCString(arg)); | 479 | pvDebug(3, "QCop "+msg+" "+QCString(arg)); |
480 | if ( msg == "installFile(QString)" ) | 480 | if ( msg == "installFile(QString)" ) |
481 | { | 481 | { |
482 | ipkg->installFile( QString(arg) ); | 482 | ipkg->installFile( QString(arg) ); |
483 | }else if( msg == "removeFile(QString)" ) | 483 | }else if( msg == "removeFile(QString)" ) |
484 | { | 484 | { |
485 | ipkg->removeFile( QString(arg) ); | 485 | ipkg->removeFile( QString(arg) ); |
486 | }else if( msg == "createLinks(QString)" ) | 486 | }else if( msg == "createLinks(QString)" ) |
487 | { | 487 | { |
488 | ipkg->createLinks( QString(arg) ); | 488 | ipkg->createLinks( QString(arg) ); |
489 | }else if( msg == "removeLinks(QString)" ) | 489 | }else if( msg == "removeLinks(QString)" ) |
490 | { | 490 | { |
491 | ipkg->removeLinks( QString(arg) ); | 491 | ipkg->removeLinks( QString(arg) ); |
492 | }else{ | 492 | }else{ |
493 | pvDebug(2,"Huh what do ya want") | 493 | pvDebug(2,"Huh what do ya want") |
494 | } | 494 | } |
495 | } | 495 | } |
496 | 496 | ||
497 | 497 | ||
498 | void MainWindow::createLinks() | 498 | void MainWindow::createLinks() |
499 | { | 499 | { |
500 | pvDebug(2,"creating links..."); | 500 | pvDebug(2,"creating links..."); |
501 | ipkg->createLinks( settings->destinationurl->text() ); | 501 | ipkg->createLinks( settings->destinationurl->text() ); |
502 | } | 502 | } |
503 | 503 | ||
504 | void MainWindow::removeLinks() | 504 | void MainWindow::removeLinks() |
505 | { | 505 | { |
506 | pvDebug(2,"removing links..."); | 506 | pvDebug(2,"removing links..."); |
507 | ipkg->removeLinks( settings->destinationurl->text() ); | 507 | ipkg->removeLinks( settings->destinationurl->text() ); |
508 | } | 508 | } |
509 | 509 | ||
510 | void MainWindow::remotePackageQuery() | 510 | void MainWindow::remotePackageQuery() |
511 | { | 511 | { |
512 | packageListSearch.query( searchEdit->text() ); | 512 | packageListSearch.query( searchEdit->text() ); |
513 | packageListSearch.update(); | 513 | packageListSearch.update(); |
514 | displayList(); | 514 | displayList(); |
515 | } | 515 | } |
diff --git a/noncore/unsupported/oipkg/packagelistitem.cpp b/noncore/unsupported/oipkg/packagelistitem.cpp index 1610a37..1b4812d 100644 --- a/noncore/unsupported/oipkg/packagelistitem.cpp +++ b/noncore/unsupported/oipkg/packagelistitem.cpp | |||
@@ -118,123 +118,123 @@ void PackageListItem::paintCell( QPainter *p, const QColorGroup & cg, | |||
118 | 118 | ||
119 | void PackageListItem::paintFocus( QPainter *p, const QColorGroup & cg, | 119 | void PackageListItem::paintFocus( QPainter *p, const QColorGroup & cg, |
120 | const QRect & r ) | 120 | const QRect & r ) |
121 | { | 121 | { |
122 | // Skip QCheckListItem | 122 | // Skip QCheckListItem |
123 | // (makes you wonder what we're getting from QCheckListItem) | 123 | // (makes you wonder what we're getting from QCheckListItem) |
124 | QListViewItem::paintFocus(p,cg,r); | 124 | QListViewItem::paintFocus(p,cg,r); |
125 | } | 125 | } |
126 | 126 | ||
127 | QPixmap PackageListItem::statePixmap() const | 127 | QPixmap PackageListItem::statePixmap() const |
128 | { | 128 | { |
129 | bool installed = package->installed(); | 129 | bool installed = package->installed(); |
130 | bool old = package->isOld(); | 130 | bool old = package->isOld(); |
131 | bool verinstalled = package->otherInstalled(); | 131 | bool verinstalled = package->otherInstalled(); |
132 | if ( !package->toProcess() ) { | 132 | if ( !package->toProcess() ) { |
133 | if ( !installed ) | 133 | if ( !installed ) |
134 | if (old) | 134 | if (old) |
135 | { | 135 | { |
136 | if (verinstalled) return *pm_uninstalled_old_installed_new; | 136 | if (verinstalled) return *pm_uninstalled_old_installed_new; |
137 | else return *pm_uninstalled_old; | 137 | else return *pm_uninstalled_old; |
138 | } | 138 | } |
139 | else | 139 | else |
140 | { | 140 | { |
141 | if (verinstalled) return *pm_uninstalled_installed_old; | 141 | if (verinstalled) return *pm_uninstalled_installed_old; |
142 | else return *pm_uninstalled; | 142 | else return *pm_uninstalled; |
143 | } | 143 | } |
144 | else | 144 | else |
145 | if (old) return *pm_installed_old; | 145 | if (old) return *pm_installed_old; |
146 | else return *pm_installed; | 146 | else return *pm_installed; |
147 | } else { //toProcess() == true | 147 | } else { //toProcess() == true |
148 | if ( !installed ) | 148 | if ( !installed ) |
149 | return *pm_install; | 149 | return *pm_install; |
150 | else | 150 | else |
151 | return *pm_uninstall; | 151 | return *pm_uninstall; |
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | QString PackageListItem::key( int column, bool ascending ) const | 155 | QString PackageListItem::key( int column, bool ascending ) const |
156 | { | 156 | { |
157 | if ( column == 2 ) { | 157 | if ( column == 2 ) { |
158 | QString t = text(2); | 158 | QString t = text(2); |
159 | double bytes=t.toDouble(); | 159 | double bytes=t.toDouble(); |
160 | if ( t.contains('M') ) bytes*=1024*1024; | 160 | if ( t.contains('M') ) bytes*=1024*1024; |
161 | else if ( t.contains('K') || t.contains('k') ) bytes*=1024; | 161 | else if ( t.contains('K') || t.contains('k') ) bytes*=1024; |
162 | if ( !ascending ) bytes=999999999-bytes; | 162 | if ( !ascending ) bytes=999999999-bytes; |
163 | return QString().sprintf("%09d",(int)bytes); | 163 | return QString().sprintf("%09d",(int)bytes); |
164 | } else { | 164 | } else { |
165 | return QListViewItem::key(column,ascending); | 165 | return QListViewItem::key(column,ascending); |
166 | } | 166 | } |
167 | } | 167 | } |
168 | 168 | ||
169 | void PackageListItem::setOn( bool b ) | 169 | void PackageListItem::setOn( bool b ) |
170 | { | 170 | { |
171 | QCheckListItem::setOn( b ); | 171 | QCheckListItem::setOn( b ); |
172 | package->toggleProcess(); | 172 | package->toggleProcess(); |
173 | package->setLink( settings->createLinks() ); | 173 | package->setLink( settings->createLinks() ); |
174 | displayDetails(); | 174 | displayDetails(); |
175 | } | 175 | } |
176 | 176 | ||
177 | void PackageListItem::displayDetails() | 177 | void PackageListItem::displayDetails() |
178 | { | 178 | { |
179 | QString sod; | 179 | QString sod; |
180 | sod += package->sizeUnits().isEmpty()?QString(""):QString(package->sizeUnits()); | 180 | sod += package->sizeUnits().isEmpty()?QString(""):QString(package->sizeUnits()); |
181 | //sod += QString(package->dest().isEmpty()?"":QObject::tr(" on ")+package->dest()); | 181 | //sod += QString(package->dest().isEmpty()?"":QObject::tr(" on ")+package->dest()); |
182 | sod += package->dest().isEmpty()?QString(""):QString(QObject::tr(" on ")+package->dest()); | 182 | sod += package->dest().isEmpty()?QString(""):QString(QObject::tr(" on ")+package->dest()); |
183 | sod = sod.isEmpty()?QString(""):QString(" ("+sod+")"); | 183 | sod = sod.isEmpty()?QString(""):QString(" ("+sod+")"); |
184 | setText(0, package->name()+sod ); | 184 | setText(0, package->name()+sod ); |
185 | nameItem->setText( 0, QObject::tr("Name: ")+package->name()); | 185 | nameItem->setText( 0, QObject::tr("Name: ")+package->name()); |
186 | linkItem->setText( 0, QObject::tr("Link: ")+(package->link()?QObject::tr("Yes"):QObject::tr("No"))); | 186 | linkItem->setText( 0, QObject::tr("Link: ")+(package->link()?QObject::tr("Yes"):QObject::tr("No"))); |
187 | destItem->setText( 0, QObject::tr("Destination: ")+package->dest() ); | 187 | destItem->setText( 0, QObject::tr("Destination: ")+package->dest() ); |
188 | statusItem->setText( 0, QObject::tr("Status: ")+package->status() ); | 188 | statusItem->setText( 0, QObject::tr("Status: ")+package->status() ); |
189 | repaint(); | 189 | repaint(); |
190 | } | 190 | } |
191 | 191 | ||
192 | QPopupMenu* PackageListItem::getPopupMenu() | 192 | QPopupMenu* PackageListItem::getPopupMenu() |
193 | { | 193 | { |
194 | popupMenu->clear(); | 194 | popupMenu->clear(); |
195 | destsMenu->clear(); | 195 | destsMenu->clear(); |
196 | 196 | ||
197 | QAction *popupAction; | 197 | QAction *popupAction; |
198 | qDebug("PackageListItem::showPopup "); | 198 | qDebug("PackageListItem::showPopup "); |
199 | 199 | ||
200 | if (!package->installed()){ | 200 | if (!package->installed()){ |
201 | popupMenu->insertItem( QObject::tr("Install to"), destsMenu ); | 201 | popupMenu->insertItem( QObject::tr("Install to"), destsMenu ); |
202 | QStringList dests = settings->getDestinationNames(); | 202 | QStringList dests = settings->getDestinationNames(); |
203 | QString ad = settings->getDestinationName(); | 203 | QString ad = settings->getDestinationName(); |
204 | for (uint i = 0; i < dests.count(); i++ ) | 204 | for (uint i = 0; i < dests.count(); i++ ) |
205 | { | 205 | { |
206 | popupAction = new QAction( dests[i], QString::null, 0, popupMenu, 0 ); | 206 | popupAction = new QAction( dests[i], QString::null, 0, popupMenu, 0 ); |
207 | popupAction->addTo( destsMenu ); | 207 | popupAction->addTo( destsMenu ); |
208 | if ( dests[i] == ad && getPackage()->toInstall() ) | 208 | if ( dests[i] == ad && getPackage()->toInstall() ) |
209 | { | 209 | { |
210 | popupAction->setToggleAction( true ); | 210 | popupAction->setToggleAction( true ); |
211 | popupAction->setOn(true); | 211 | popupAction->setOn(true); |
212 | } | 212 | } |
213 | } | 213 | } |
214 | connect( destsMenu, SIGNAL( activated( int ) ), | 214 | connect( destsMenu, SIGNAL( activated(int) ), |
215 | this, SLOT( menuAction( int ) ) ); | 215 | this, SLOT( menuAction(int) ) ); |
216 | popupMenu->popup( QCursor::pos() ); | 216 | popupMenu->popup( QCursor::pos() ); |
217 | }else{ | 217 | }else{ |
218 | popupMenu->insertItem( QObject::tr("Remove")); | 218 | popupMenu->insertItem( QObject::tr("Remove")); |
219 | connect( popupMenu, SIGNAL( activated( int ) ), | 219 | connect( popupMenu, SIGNAL( activated(int) ), |
220 | this, SLOT( menuAction( int ) ) ); | 220 | this, SLOT( menuAction(int) ) ); |
221 | popupMenu->popup( QCursor::pos() ); | 221 | popupMenu->popup( QCursor::pos() ); |
222 | } | 222 | } |
223 | return popupMenu; | 223 | return popupMenu; |
224 | } | 224 | } |
225 | 225 | ||
226 | void PackageListItem::menuAction( int i ) | 226 | void PackageListItem::menuAction( int i ) |
227 | { | 227 | { |
228 | if (!package->installed()){ | 228 | if (!package->installed()){ |
229 | package->setDest( destsMenu->text(i) ); | 229 | package->setDest( destsMenu->text(i) ); |
230 | package->setLink( settings->createLinks() ); | 230 | package->setLink( settings->createLinks() ); |
231 | } | 231 | } |
232 | package->setOn(); | 232 | package->setOn(); |
233 | displayDetails(); | 233 | displayDetails(); |
234 | } | 234 | } |
235 | 235 | ||
236 | //void PackageListItem::toggleProcess() | 236 | //void PackageListItem::toggleProcess() |
237 | //{ | 237 | //{ |
238 | // package->toggleProcess() ; | 238 | // package->toggleProcess() ; |
239 | // displayDetails(); | 239 | // displayDetails(); |
240 | //} | 240 | //} |
diff --git a/noncore/unsupported/oipkg/packagelistview.cpp b/noncore/unsupported/oipkg/packagelistview.cpp index 3c7435d..98ebf88 100644 --- a/noncore/unsupported/oipkg/packagelistview.cpp +++ b/noncore/unsupported/oipkg/packagelistview.cpp | |||
@@ -1,118 +1,118 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> | 9 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> |
10 | #include "packagelistview.h" | 10 | #include "packagelistview.h" |
11 | 11 | ||
12 | #include <qpopupmenu.h> | 12 | #include <qpopupmenu.h> |
13 | #include <qaction.h> | 13 | #include <qaction.h> |
14 | 14 | ||
15 | #include "listviewitemoipkg.h" | 15 | #include "listviewitemoipkg.h" |
16 | #include "packagelistitem.h" | 16 | #include "packagelistitem.h" |
17 | #include "pksettings.h" | 17 | #include "pksettings.h" |
18 | 18 | ||
19 | PackageListView::PackageListView(QWidget *p, const char* n, PackageManagerSettings *s) | 19 | PackageListView::PackageListView(QWidget *p, const char* n, PackageManagerSettings *s) |
20 | : QListView(p,n) | 20 | : QListView(p,n) |
21 | { | 21 | { |
22 | settings = s; | 22 | settings = s; |
23 | popupTimer = new QTimer( this ); | 23 | popupTimer = new QTimer( this ); |
24 | setSelectionMode(QListView::NoSelection); | 24 | setSelectionMode(QListView::NoSelection); |
25 | addColumn( tr("Package") ); | 25 | addColumn( tr("Package") ); |
26 | setRootIsDecorated( true ); | 26 | setRootIsDecorated( true ); |
27 | 27 | ||
28 | connect( popupTimer, SIGNAL(timeout()), | 28 | connect( popupTimer, SIGNAL(timeout()), |
29 | this, SLOT(showPopup()) ); | 29 | this, SLOT(showPopup()) ); |
30 | connect( this, SIGNAL( pressed( QListViewItem* ) ), | 30 | connect( this, SIGNAL( pressed(QListViewItem*) ), |
31 | this, SLOT( setCurrent( QListViewItem* ) ) ); | 31 | this, SLOT( setCurrent(QListViewItem*) ) ); |
32 | connect( this, SIGNAL( clicked( QListViewItem* ) ), | 32 | connect( this, SIGNAL( clicked(QListViewItem*) ), |
33 | this, SLOT( stopTimer( QListViewItem* ) ) ); | 33 | this, SLOT( stopTimer(QListViewItem*) ) ); |
34 | 34 | ||
35 | } | 35 | } |
36 | 36 | ||
37 | //PackageListView::~PackageListView() | 37 | //PackageListView::~PackageListView() |
38 | //{ | 38 | //{ |
39 | //} | 39 | //} |
40 | 40 | ||
41 | void PackageListView::setCurrent( QListViewItem* p ) | 41 | void PackageListView::setCurrent( QListViewItem* p ) |
42 | { | 42 | { |
43 | qDebug("PackageListView::setCurrent "); | 43 | qDebug("PackageListView::setCurrent "); |
44 | activeItem = (ListViewItemOipkg*)p; | 44 | activeItem = (ListViewItemOipkg*)p; |
45 | 45 | ||
46 | if ( activeItem != 0 ) popupTimer->start( 750, true ); | 46 | if ( activeItem != 0 ) popupTimer->start( 750, true ); |
47 | 47 | ||
48 | // if ( activeItem->getType() != ListViewItemOipkg::Package ){ | 48 | // if ( activeItem->getType() != ListViewItemOipkg::Package ){ |
49 | // qDebug("PackageListView::setCurrent !p "); | 49 | // qDebug("PackageListView::setCurrent !p "); |
50 | // activePackage = 0; | 50 | // activePackage = 0; |
51 | // activePackageListItem = 0; | 51 | // activePackageListItem = 0; |
52 | // qDebug("PackageListView::setCurrent returning "); | 52 | // qDebug("PackageListView::setCurrent returning "); |
53 | // return; | 53 | // return; |
54 | // }; | 54 | // }; |
55 | // activePackageListItem = (PackageListItem*)p; | 55 | // activePackageListItem = (PackageListItem*)p; |
56 | // activePackage = activePackageListItem->getPackage(); | 56 | // activePackage = activePackageListItem->getPackage(); |
57 | // if (activePackage == 0 ) | 57 | // if (activePackage == 0 ) |
58 | // { | 58 | // { |
59 | // qDebug("PackageListView::setCurrent if (!activePackage)"); | 59 | // qDebug("PackageListView::setCurrent if (!activePackage)"); |
60 | // return; | 60 | // return; |
61 | // } | 61 | // } |
62 | 62 | ||
63 | 63 | ||
64 | qDebug("PackageListView::setCurrent popupTimer->start"); | 64 | qDebug("PackageListView::setCurrent popupTimer->start"); |
65 | } | 65 | } |
66 | 66 | ||
67 | 67 | ||
68 | void PackageListView::showPopup() | 68 | void PackageListView::showPopup() |
69 | { | 69 | { |
70 | qDebug("PackageListView::showPopup"); | 70 | qDebug("PackageListView::showPopup"); |
71 | QPopupMenu *popup = activeItem->getPopupMenu(); | 71 | QPopupMenu *popup = activeItem->getPopupMenu(); |
72 | if (popup == 0) return; | 72 | if (popup == 0) return; |
73 | popup->popup( QCursor::pos() ); | 73 | popup->popup( QCursor::pos() ); |
74 | qDebug("PackageListView::showPopup"); | 74 | qDebug("PackageListView::showPopup"); |
75 | } | 75 | } |
76 | 76 | ||
77 | void PackageListView::stopTimer( QListViewItem* ) | 77 | void PackageListView::stopTimer( QListViewItem* ) |
78 | { | 78 | { |
79 | popupTimer->stop(); | 79 | popupTimer->stop(); |
80 | } | 80 | } |
81 | 81 | ||
82 | 82 | ||
83 | void PackageListView::display() | 83 | void PackageListView::display() |
84 | { | 84 | { |
85 | QDictIterator<PackageList> list( PackageLists ); | 85 | QDictIterator<PackageList> list( PackageLists ); |
86 | PackageList *packlist; | 86 | PackageList *packlist; |
87 | OipkgPackage *pack; | 87 | OipkgPackage *pack; |
88 | PackageListItem *item; | 88 | PackageListItem *item; |
89 | ListViewItemOipkg *rootItem; | 89 | ListViewItemOipkg *rootItem; |
90 | QListViewItem* it; | 90 | QListViewItem* it; |
91 | QListViewItem* itdel; | 91 | QListViewItem* itdel; |
92 | while ( list.current() ) { | 92 | while ( list.current() ) { |
93 | packlist = list.current(); | 93 | packlist = list.current(); |
94 | rootItem = rootItems.find( list.currentKey() ); | 94 | rootItem = rootItems.find( list.currentKey() ); |
95 | //rootItem->clear(); | 95 | //rootItem->clear(); |
96 | it=rootItem->firstChild(); | 96 | it=rootItem->firstChild(); |
97 | while ( it ) | 97 | while ( it ) |
98 | { | 98 | { |
99 | itdel = it; | 99 | itdel = it; |
100 | it = it->nextSibling(); | 100 | it = it->nextSibling(); |
101 | delete itdel; | 101 | delete itdel; |
102 | } | 102 | } |
103 | pack = packlist->first(); | 103 | pack = packlist->first(); |
104 | while( pack ) | 104 | while( pack ) |
105 | { | 105 | { |
106 | item = new PackageListItem( rootItem, pack, settings ); | 106 | item = new PackageListItem( rootItem, pack, settings ); |
107 | pack = packlist->next(); | 107 | pack = packlist->next(); |
108 | } | 108 | } |
109 | ++list; | 109 | ++list; |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | void PackageListView::addList( QString n, PackageList* pl) | 113 | void PackageListView::addList( QString n, PackageList* pl) |
114 | { | 114 | { |
115 | PackageLists.insert(n, pl); | 115 | PackageLists.insert(n, pl); |
116 | ListViewItemOipkg *item = new ListViewItemOipkg(this,n,ListViewItemOipkg::Feed); | 116 | ListViewItemOipkg *item = new ListViewItemOipkg(this,n,ListViewItemOipkg::Feed); |
117 | rootItems.insert(n, item); | 117 | rootItems.insert(n, item); |
118 | } | 118 | } |
diff --git a/noncore/unsupported/oipkg/pksettings.cpp b/noncore/unsupported/oipkg/pksettings.cpp index 063b018..aac011e 100644 --- a/noncore/unsupported/oipkg/pksettings.cpp +++ b/noncore/unsupported/oipkg/pksettings.cpp | |||
@@ -1,145 +1,145 @@ | |||
1 | #include "pksettings.h" | 1 | #include "pksettings.h" |
2 | 2 | ||
3 | #include <qpe/process.h> | 3 | #include <qpe/process.h> |
4 | #include <qpe/resource.h> | 4 | #include <qpe/resource.h> |
5 | #include <qpe/stringutil.h> | 5 | #include <qpe/stringutil.h> |
6 | #include <qpe/qpeapplication.h> | 6 | #include <qpe/qpeapplication.h> |
7 | #include <qpe/qcopenvelope_qws.h> | 7 | #include <qpe/qcopenvelope_qws.h> |
8 | #include <qpe/applnk.h> | 8 | #include <qpe/applnk.h> |
9 | #include <qpe/config.h> | 9 | #include <qpe/config.h> |
10 | 10 | ||
11 | #include <qprogressbar.h> | 11 | #include <qprogressbar.h> |
12 | #include <qcombobox.h> | 12 | #include <qcombobox.h> |
13 | #include <qdict.h> | 13 | #include <qdict.h> |
14 | #include <qfile.h> | 14 | #include <qfile.h> |
15 | #include <qlineedit.h> | 15 | #include <qlineedit.h> |
16 | #include <qpushbutton.h> | 16 | #include <qpushbutton.h> |
17 | #include <qlistview.h> | 17 | #include <qlistview.h> |
18 | #include <qlistbox.h> | 18 | #include <qlistbox.h> |
19 | #include <qcheckbox.h> | 19 | #include <qcheckbox.h> |
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | #include <qpainter.h> | 21 | #include <qpainter.h> |
22 | #include <qpixmap.h> | 22 | #include <qpixmap.h> |
23 | #include <qregexp.h> | 23 | #include <qregexp.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qtextstream.h> | 26 | #include <qtextstream.h> |
27 | #include <qtextview.h> | 27 | #include <qtextview.h> |
28 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
29 | #include <qtabwidget.h> | 29 | #include <qtabwidget.h> |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | #include <unistd.h> | 32 | #include <unistd.h> |
33 | #include "debug.h" | 33 | #include "debug.h" |
34 | //#include "utils.h" | 34 | //#include "utils.h" |
35 | 35 | ||
36 | PackageManagerSettings::PackageManagerSettings( QWidget* parent, const char* name, WFlags fl ) | 36 | PackageManagerSettings::PackageManagerSettings( QWidget* parent, const char* name, WFlags fl ) |
37 | : PackageManagerSettingsBase( parent, name, fl ) | 37 | : PackageManagerSettingsBase( parent, name, fl ) |
38 | { | 38 | { |
39 | connect( newserver, SIGNAL(clicked()), this, SLOT(newServer()) ); | 39 | connect( newserver, SIGNAL(clicked()), this, SLOT(newServer()) ); |
40 | connect( removeserver, SIGNAL(clicked()), this, SLOT(removeServer()) ); | 40 | connect( removeserver, SIGNAL(clicked()), this, SLOT(removeServer()) ); |
41 | connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); | 41 | connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); |
42 | connect( newdestination, SIGNAL(clicked()), this, SLOT(newDestination()) ); | 42 | connect( newdestination, SIGNAL(clicked()), this, SLOT(newDestination()) ); |
43 | connect( removedestination, SIGNAL(clicked()), this, SLOT(removeDestination()) ); | 43 | connect( removedestination, SIGNAL(clicked()), this, SLOT(removeDestination()) ); |
44 | connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); | 44 | connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); |
45 | // connect( CheckBoxLink, SIGNAL(toggled(bool)), | 45 | // connect( CheckBoxLink, SIGNAL(toggled(bool)), |
46 | // activeLinkDestination, SLOT(setEnabled(bool)) ); | 46 | // activeLinkDestination, SLOT(setEnabled(bool)) ); |
47 | 47 | ||
48 | // connect( settingName, SIGNAL(activated(int)), this, SLOT(installationSettingChange(int)) ); | 48 | // connect( settingName, SIGNAL(activated(int)), this, SLOT(installationSettingChange(int)) ); |
49 | // connect( settingName, SIGNAL(textChanged(const QString &)), this, SLOT(installationSettingSetName(const QString &)) ); | 49 | // connect( settingName, SIGNAL(textChanged(const QString&)), this, SLOT(installationSettingSetName(const QString&)) ); |
50 | // connect( newsetting, SIGNAL(clicked()), this, SLOT(newInstallationSetting()) ); | 50 | // connect( newsetting, SIGNAL(clicked()), this, SLOT(newInstallationSetting()) ); |
51 | // connect( renamesetting, SIGNAL(clicked()), this, SLOT(renameInstallationSetting()) ); | 51 | // connect( renamesetting, SIGNAL(clicked()), this, SLOT(renameInstallationSetting()) ); |
52 | // connect( removesetting, SIGNAL(clicked()), this, SLOT(removeInstallationSetting()) ); | 52 | // connect( removesetting, SIGNAL(clicked()), this, SLOT(removeInstallationSetting()) ); |
53 | servername->setEnabled(FALSE); | 53 | servername->setEnabled(FALSE); |
54 | serverurl->setEnabled(FALSE); | 54 | serverurl->setEnabled(FALSE); |
55 | serverurlDic.setAutoDelete(TRUE); | 55 | serverurlDic.setAutoDelete(TRUE); |
56 | destinationname->setEnabled(FALSE); | 56 | destinationname->setEnabled(FALSE); |
57 | destinationurl->setEnabled(FALSE); | 57 | destinationurl->setEnabled(FALSE); |
58 | destinationurlDic.setAutoDelete(TRUE); | 58 | destinationurlDic.setAutoDelete(TRUE); |
59 | readSettings(); | 59 | readSettings(); |
60 | activeLinkDestination->hide(); | 60 | activeLinkDestination->hide(); |
61 | serverChanged = false; | 61 | serverChanged = false; |
62 | 62 | ||
63 | // get rid of setups | 63 | // get rid of setups |
64 | // Settings->hide(); | 64 | // Settings->hide(); |
65 | // settingName->hide(); | 65 | // settingName->hide(); |
66 | // newsetting->hide(); | 66 | // newsetting->hide(); |
67 | // renamesetting->hide(); | 67 | // renamesetting->hide(); |
68 | // removesetting->hide(); | 68 | // removesetting->hide(); |
69 | } | 69 | } |
70 | 70 | ||
71 | PackageManagerSettings::~PackageManagerSettings() | 71 | PackageManagerSettings::~PackageManagerSettings() |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | 75 | ||
76 | void PackageManagerSettings::newServer() | 76 | void PackageManagerSettings::newServer() |
77 | { | 77 | { |
78 | int i = servers->count(); | 78 | int i = servers->count(); |
79 | if ( servername->isEnabled() || serverurl->text().isEmpty() ) { | 79 | if ( servername->isEnabled() || serverurl->text().isEmpty() ) { |
80 | serverurlDic.insert(i,new QString("http://")); | 80 | serverurlDic.insert(i,new QString("http://")); |
81 | servers->insertItem(tr("New")); | 81 | servers->insertItem(tr("New")); |
82 | activeServers->insertItem(tr("New")); | 82 | activeServers->insertItem(tr("New")); |
83 | } else { | 83 | } else { |
84 | // allows one-level undo | 84 | // allows one-level undo |
85 | serverurlDic.insert(i,new QString(serverurl->text())); | 85 | serverurlDic.insert(i,new QString(serverurl->text())); |
86 | servers->insertItem(servername->text()); | 86 | servers->insertItem(servername->text()); |
87 | activeServers->insertItem(servername->text()); | 87 | activeServers->insertItem(servername->text()); |
88 | } | 88 | } |
89 | changed = true; | 89 | changed = true; |
90 | servers->setSelected(i,TRUE); | 90 | servers->setSelected(i,TRUE); |
91 | editServer(i); | 91 | editServer(i); |
92 | changed = true; | 92 | changed = true; |
93 | } | 93 | } |
94 | 94 | ||
95 | void PackageManagerSettings::newDestination() | 95 | void PackageManagerSettings::newDestination() |
96 | { | 96 | { |
97 | int i = destinations->count(); | 97 | int i = destinations->count(); |
98 | if ( destinationname->isEnabled() || destinationurl->text().isEmpty() ) { | 98 | if ( destinationname->isEnabled() || destinationurl->text().isEmpty() ) { |
99 | destinationurlDic.insert(i,new QString("/")); | 99 | destinationurlDic.insert(i,new QString("/")); |
100 | destinations->insertItem(tr("New")); | 100 | destinations->insertItem(tr("New")); |
101 | activeDestination->insertItem(tr("New")); | 101 | activeDestination->insertItem(tr("New")); |
102 | activeLinkDestination->insertItem(tr("New")); | 102 | activeLinkDestination->insertItem(tr("New")); |
103 | } else { | 103 | } else { |
104 | // allows one-level undo | 104 | // allows one-level undo |
105 | destinationurlDic.insert(i,new QString(destinationurl->text())); | 105 | destinationurlDic.insert(i,new QString(destinationurl->text())); |
106 | destinations->insertItem(destinationname->text()); | 106 | destinations->insertItem(destinationname->text()); |
107 | activeDestination->insertItem(destinationname->text()); | 107 | activeDestination->insertItem(destinationname->text()); |
108 | activeLinkDestination->insertItem(destinationname->text()); | 108 | activeLinkDestination->insertItem(destinationname->text()); |
109 | } | 109 | } |
110 | destinations->setSelected(i,TRUE); | 110 | destinations->setSelected(i,TRUE); |
111 | editDestination(i); | 111 | editDestination(i); |
112 | changed = true; | 112 | changed = true; |
113 | } | 113 | } |
114 | 114 | ||
115 | 115 | ||
116 | void PackageManagerSettings::editServer(int i) | 116 | void PackageManagerSettings::editServer(int i) |
117 | { | 117 | { |
118 | if ( servername->isEnabled() ) { | 118 | if ( servername->isEnabled() ) { |
119 | disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); | 119 | disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); |
120 | disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); | 120 | disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); |
121 | } else { | 121 | } else { |
122 | servername->setEnabled(TRUE); | 122 | servername->setEnabled(TRUE); |
123 | serverurl->setEnabled(TRUE); | 123 | serverurl->setEnabled(TRUE); |
124 | } | 124 | } |
125 | 125 | ||
126 | servername->setText( servers->text(i) ); | 126 | servername->setText( servers->text(i) ); |
127 | serverurl->setText( *serverurlDic[i] ); | 127 | serverurl->setText( *serverurlDic[i] ); |
128 | 128 | ||
129 | editedserver = i; | 129 | editedserver = i; |
130 | serverChanged = true; | 130 | serverChanged = true; |
131 | connect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); | 131 | connect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); |
132 | connect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); | 132 | connect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); |
133 | changed = true; | 133 | changed = true; |
134 | } | 134 | } |
135 | 135 | ||
136 | 136 | ||
137 | void PackageManagerSettings::editDestination(int i) | 137 | void PackageManagerSettings::editDestination(int i) |
138 | { | 138 | { |
139 | if ( destinationname->isEnabled() ) { | 139 | if ( destinationname->isEnabled() ) { |
140 | disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); | 140 | disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); |
141 | disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); | 141 | disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); |
142 | } else { | 142 | } else { |
143 | destinationname->setEnabled(TRUE); | 143 | destinationname->setEnabled(TRUE); |
144 | destinationurl->setEnabled(TRUE); | 144 | destinationurl->setEnabled(TRUE); |
145 | //since it does not work anyway | 145 | //since it does not work anyway |
diff --git a/noncore/unsupported/qpdf/qbusybar.cpp b/noncore/unsupported/qpdf/qbusybar.cpp index ce7ab8e..e942f06 100644 --- a/noncore/unsupported/qpdf/qbusybar.cpp +++ b/noncore/unsupported/qpdf/qbusybar.cpp | |||
@@ -1,116 +1,116 @@ | |||
1 | #include <qapplication.h> | 1 | #include <qapplication.h> |
2 | #include <qtimer.h> | 2 | #include <qtimer.h> |
3 | #include <qpainter.h> | 3 | #include <qpainter.h> |
4 | 4 | ||
5 | #include "qbusybar.h" | 5 | #include "qbusybar.h" |
6 | 6 | ||
7 | 7 | ||
8 | 8 | ||
9 | QBusyBar::QBusyBar ( QWidget *parent, const char *name, int flags ) : QWidget ( parent, name, flags | WRepaintNoErase ) | 9 | QBusyBar::QBusyBar ( QWidget *parent, const char *name, int flags ) : QWidget ( parent, name, flags | WRepaintNoErase ) |
10 | { | 10 | { |
11 | m_busy = 0; | 11 | m_busy = 0; |
12 | 12 | ||
13 | m_div = 0; | 13 | m_div = 0; |
14 | m_pos = 0; | 14 | m_pos = 0; |
15 | m_fade = 0; | 15 | m_fade = 0; |
16 | m_fadecols = 0; | 16 | m_fadecols = 0; |
17 | m_speed = 500; | 17 | m_speed = 500; |
18 | 18 | ||
19 | m_timer = new QTimer ( this ); | 19 | m_timer = new QTimer ( this ); |
20 | connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( slotTimeout ( ))); | 20 | connect ( m_timer, SIGNAL( timeout()), this, SLOT( slotTimeout())); |
21 | 21 | ||
22 | setParameters ( 12, 8, 200 ); | 22 | setParameters ( 12, 8, 200 ); |
23 | } | 23 | } |
24 | 24 | ||
25 | void QBusyBar::setParameters ( int d, int s, int v ) | 25 | void QBusyBar::setParameters ( int d, int s, int v ) |
26 | { | 26 | { |
27 | bool running = m_timer-> isActive ( ); | 27 | bool running = m_timer-> isActive ( ); |
28 | 28 | ||
29 | if ( running ) | 29 | if ( running ) |
30 | m_timer-> stop ( ); | 30 | m_timer-> stop ( ); |
31 | 31 | ||
32 | m_div = d; | 32 | m_div = d; |
33 | m_speed = v; | 33 | m_speed = v; |
34 | 34 | ||
35 | delete [] m_fadecols; | 35 | delete [] m_fadecols; |
36 | m_fade = s; | 36 | m_fade = s; |
37 | m_fadecols = new QColor [m_fade]; | 37 | m_fadecols = new QColor [m_fade]; |
38 | 38 | ||
39 | int rt, gt, bt; | 39 | int rt, gt, bt; |
40 | int rf, gf, bf; | 40 | int rf, gf, bf; |
41 | 41 | ||
42 | colorGroup ( ). color ( QColorGroup::Highlight ). rgb ( &rf, &gf, &bf ); | 42 | colorGroup ( ). color ( QColorGroup::Highlight ). rgb ( &rf, &gf, &bf ); |
43 | colorGroup ( ). color ( QColorGroup::Background ). rgb ( &rt, >, &bt ); | 43 | colorGroup ( ). color ( QColorGroup::Background ). rgb ( &rt, >, &bt ); |
44 | 44 | ||
45 | for ( int i = 0; i < s; i++ ) | 45 | for ( int i = 0; i < s; i++ ) |
46 | m_fadecols [i]. setRgb ( rf + ( rt - rf ) * i / s, gf + ( gt - gf ) * i / s, bf + ( bt - bf ) * i / s ); | 46 | m_fadecols [i]. setRgb ( rf + ( rt - rf ) * i / s, gf + ( gt - gf ) * i / s, bf + ( bt - bf ) * i / s ); |
47 | 47 | ||
48 | if ( running ) { | 48 | if ( running ) { |
49 | m_pos = 0; | 49 | m_pos = 0; |
50 | m_timer-> start ( m_speed ); | 50 | m_timer-> start ( m_speed ); |
51 | } | 51 | } |
52 | } | 52 | } |
53 | 53 | ||
54 | QBusyBar::~QBusyBar ( ) | 54 | QBusyBar::~QBusyBar ( ) |
55 | { | 55 | { |
56 | delete [] m_fadecols; | 56 | delete [] m_fadecols; |
57 | } | 57 | } |
58 | 58 | ||
59 | bool QBusyBar::isBusy ( ) const | 59 | bool QBusyBar::isBusy ( ) const |
60 | { | 60 | { |
61 | return m_busy; | 61 | return m_busy; |
62 | } | 62 | } |
63 | 63 | ||
64 | void QBusyBar::beginBusy ( ) | 64 | void QBusyBar::beginBusy ( ) |
65 | { | 65 | { |
66 | setBusy ( true ); | 66 | setBusy ( true ); |
67 | } | 67 | } |
68 | 68 | ||
69 | void QBusyBar::endBusy ( ) | 69 | void QBusyBar::endBusy ( ) |
70 | { | 70 | { |
71 | setBusy ( false ); | 71 | setBusy ( false ); |
72 | } | 72 | } |
73 | 73 | ||
74 | void QBusyBar::setBusy ( bool b ) | 74 | void QBusyBar::setBusy ( bool b ) |
75 | { | 75 | { |
76 | int busy = m_busy + ( b ? 1 : -1 ); | 76 | int busy = m_busy + ( b ? 1 : -1 ); |
77 | 77 | ||
78 | if ( busy < 0 ) | 78 | if ( busy < 0 ) |
79 | busy = 0; | 79 | busy = 0; |
80 | 80 | ||
81 | if (( m_busy == 0 ) && ( busy > 0 )) { // Changed stateto on | 81 | if (( m_busy == 0 ) && ( busy > 0 )) { // Changed stateto on |
82 | m_pos = 0; | 82 | m_pos = 0; |
83 | m_timer-> start ( m_speed ); | 83 | m_timer-> start ( m_speed ); |
84 | update ( ); | 84 | update ( ); |
85 | } | 85 | } |
86 | else if (( m_busy > 0 ) && ( busy == 0 )) { // Changed state to off | 86 | else if (( m_busy > 0 ) && ( busy == 0 )) { // Changed state to off |
87 | m_timer-> stop ( ); | 87 | m_timer-> stop ( ); |
88 | update ( ); | 88 | update ( ); |
89 | } | 89 | } |
90 | 90 | ||
91 | m_busy = busy; | 91 | m_busy = busy; |
92 | } | 92 | } |
93 | 93 | ||
94 | void QBusyBar::slotTimeout ( ) | 94 | void QBusyBar::slotTimeout ( ) |
95 | { | 95 | { |
96 | m_pos++; | 96 | m_pos++; |
97 | m_pos %= ( 2 * ( m_fade + m_div )); | 97 | m_pos %= ( 2 * ( m_fade + m_div )); |
98 | 98 | ||
99 | update ( ); | 99 | update ( ); |
100 | } | 100 | } |
101 | 101 | ||
102 | void QBusyBar::paintEvent ( QPaintEvent *e ) | 102 | void QBusyBar::paintEvent ( QPaintEvent *e ) |
103 | { | 103 | { |
104 | QPainter p ( this ); | 104 | QPainter p ( this ); |
105 | 105 | ||
106 | QRect clip = e-> rect ( ); | 106 | QRect clip = e-> rect ( ); |
107 | 107 | ||
108 | int x = 0; | 108 | int x = 0; |
109 | int dx = width ( ) / m_div; | 109 | int dx = width ( ) / m_div; |
110 | int y = clip. top ( ); | 110 | int y = clip. top ( ); |
111 | int dy = clip. height ( ); | 111 | int dy = clip. height ( ); |
112 | 112 | ||
113 | if ( m_busy ) { | 113 | if ( m_busy ) { |
114 | int dir = ( m_pos < ( m_fade + m_div )) ? 1 : -1; | 114 | int dir = ( m_pos < ( m_fade + m_div )) ? 1 : -1; |
115 | int pos = ( dir > 0 ) ? m_pos : ( 2 * ( m_div + m_fade )) - m_pos - m_fade - 1; | 115 | int pos = ( dir > 0 ) ? m_pos : ( 2 * ( m_div + m_fade )) - m_pos - m_fade - 1; |
116 | 116 | ||
diff --git a/noncore/unsupported/qpdf/qpdf.cpp b/noncore/unsupported/qpdf/qpdf.cpp index 5cdcccf..75e86d0 100644 --- a/noncore/unsupported/qpdf/qpdf.cpp +++ b/noncore/unsupported/qpdf/qpdf.cpp | |||
@@ -1,242 +1,242 @@ | |||
1 | //======================================================================== | 1 | //======================================================================== |
2 | // | 2 | // |
3 | // qpdf.cc | 3 | // qpdf.cc |
4 | // | 4 | // |
5 | // Copyright 2001 Robert Griebl | 5 | // Copyright 2001 Robert Griebl |
6 | // | 6 | // |
7 | //======================================================================== | 7 | //======================================================================== |
8 | 8 | ||
9 | #include "aconf.h" | 9 | #include "aconf.h" |
10 | #include "GString.h" | 10 | #include "GString.h" |
11 | #include "PDFDoc.h" | 11 | #include "PDFDoc.h" |
12 | #include "TextOutputDev.h" | 12 | #include "TextOutputDev.h" |
13 | 13 | ||
14 | #include "QPEOutputDev.h" | 14 | #include "QPEOutputDev.h" |
15 | 15 | ||
16 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
17 | #include <qpe/resource.h> | 17 | #include <qpe/resource.h> |
18 | #include <qpe/applnk.h> | 18 | #include <qpe/applnk.h> |
19 | #include <qpe/qcopenvelope_qws.h> | 19 | #include <qpe/qcopenvelope_qws.h> |
20 | 20 | ||
21 | 21 | ||
22 | #include <qclipboard.h> | 22 | #include <qclipboard.h> |
23 | #include <qpe/qpetoolbar.h> | 23 | #include <qpe/qpetoolbar.h> |
24 | #include <qtoolbutton.h> | 24 | #include <qtoolbutton.h> |
25 | #include <qmenubar.h> | 25 | #include <qmenubar.h> |
26 | #include <qpopupmenu.h> | 26 | #include <qpopupmenu.h> |
27 | #include <qwidgetstack.h> | 27 | #include <qwidgetstack.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qfileinfo.h> | 29 | #include <qfileinfo.h> |
30 | #include <qstring.h> | 30 | #include <qstring.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qspinbox.h> | 32 | #include <qspinbox.h> |
33 | #include <qlayout.h> | 33 | #include <qlayout.h> |
34 | #include <qdialog.h> | 34 | #include <qdialog.h> |
35 | #include <qlabel.h> | 35 | #include <qlabel.h> |
36 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
37 | 37 | ||
38 | #include "qpdf.h" | 38 | #include "qpdf.h" |
39 | 39 | ||
40 | #ifdef QPDF_QPE_ONLY | 40 | #ifdef QPDF_QPE_ONLY |
41 | #include <qpe/fileselector.h> | 41 | #include <qpe/fileselector.h> |
42 | #else | 42 | #else |
43 | #include <opie/ofileselector.h> | 43 | #include <opie/ofileselector.h> |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | 46 | ||
47 | int main ( int argc, char **argv ) | 47 | int main ( int argc, char **argv ) |
48 | { | 48 | { |
49 | QPEApplication app ( argc, argv ); | 49 | QPEApplication app ( argc, argv ); |
50 | 50 | ||
51 | // read config file | 51 | // read config file |
52 | globalParams = new GlobalParams ( "" ); | 52 | globalParams = new GlobalParams ( "" ); |
53 | globalParams-> setErrQuiet ( true ); | 53 | globalParams-> setErrQuiet ( true ); |
54 | 54 | ||
55 | QPdfDlg *dlg = new QPdfDlg ( ); | 55 | QPdfDlg *dlg = new QPdfDlg ( ); |
56 | app. showMainDocumentWidget ( dlg ); | 56 | app. showMainDocumentWidget ( dlg ); |
57 | 57 | ||
58 | if (( app. argc ( ) == 3 ) && ( app. argv ( ) [1] == QCString ( "-f" ))) | 58 | if (( app. argc ( ) == 3 ) && ( app. argv ( ) [1] == QCString ( "-f" ))) |
59 | dlg-> openFile ( app. argv ( ) [2] ); | 59 | dlg-> openFile ( app. argv ( ) [2] ); |
60 | 60 | ||
61 | return app. exec ( ); | 61 | return app. exec ( ); |
62 | } | 62 | } |
63 | 63 | ||
64 | 64 | ||
65 | QPdfDlg::QPdfDlg ( ) : QMainWindow ( ) | 65 | QPdfDlg::QPdfDlg ( ) : QMainWindow ( ) |
66 | { | 66 | { |
67 | setCaption ( tr( "QPdf" )); | 67 | setCaption ( tr( "QPdf" )); |
68 | setIcon ( Resource::loadPixmap ( "qpdf_icon" )); | 68 | setIcon ( Resource::loadPixmap ( "qpdf_icon" )); |
69 | 69 | ||
70 | m_busy = false; | 70 | m_busy = false; |
71 | 71 | ||
72 | m_doc = 0; | 72 | m_doc = 0; |
73 | m_pages = 0; | 73 | m_pages = 0; |
74 | m_zoom = 72; | 74 | m_zoom = 72; |
75 | m_currentpage = 0; | 75 | m_currentpage = 0; |
76 | 76 | ||
77 | m_fullscreen = false; | 77 | m_fullscreen = false; |
78 | m_renderok = false; | 78 | m_renderok = false; |
79 | 79 | ||
80 | 80 | ||
81 | setToolBarsMovable ( false ); | 81 | setToolBarsMovable ( false ); |
82 | 82 | ||
83 | m_stack = new QWidgetStack ( this ); | 83 | m_stack = new QWidgetStack ( this ); |
84 | m_stack-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); | 84 | m_stack-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); |
85 | setCentralWidget ( m_stack ); | 85 | setCentralWidget ( m_stack ); |
86 | 86 | ||
87 | m_outdev = new QPEOutputDev ( m_stack ); | 87 | m_outdev = new QPEOutputDev ( m_stack ); |
88 | connect ( m_outdev, SIGNAL( selectionChanged ( const QRect & )), this, SLOT( copyToClipboard ( const QRect & ))); | 88 | connect ( m_outdev, SIGNAL( selectionChanged(const QRect&)), this, SLOT( copyToClipboard(const QRect&))); |
89 | 89 | ||
90 | #ifdef QPDF_QPE_ONLY | 90 | #ifdef QPDF_QPE_ONLY |
91 | m_filesel = new FileSelector ( "application/pdf", m_stack, "fs", false, true ); | 91 | m_filesel = new FileSelector ( "application/pdf", m_stack, "fs", false, true ); |
92 | #else | 92 | #else |
93 | m_filesel = new OFileSelector ( "application/pdf", m_stack, "fs", false, true ); | 93 | m_filesel = new OFileSelector ( "application/pdf", m_stack, "fs", false, true ); |
94 | #endif | 94 | #endif |
95 | 95 | ||
96 | connect ( m_filesel, SIGNAL( closeMe ( )), this, SLOT( closeFileSelector ( ))); | 96 | connect ( m_filesel, SIGNAL( closeMe()), this, SLOT( closeFileSelector())); |
97 | connect ( m_filesel, SIGNAL( fileSelected ( const DocLnk & )), this, SLOT( openFile ( const DocLnk & ))); | 97 | connect ( m_filesel, SIGNAL( fileSelected(const DocLnk&)), this, SLOT( openFile(const DocLnk&))); |
98 | 98 | ||
99 | m_tb_menu = new QToolBar ( this ); | 99 | m_tb_menu = new QToolBar ( this ); |
100 | m_tb_menu-> setHorizontalStretchable ( true ); | 100 | m_tb_menu-> setHorizontalStretchable ( true ); |
101 | 101 | ||
102 | QMenuBar *mb = new QMenuBar ( m_tb_menu ); | 102 | QMenuBar *mb = new QMenuBar ( m_tb_menu ); |
103 | 103 | ||
104 | m_pm_zoom = new QPopupMenu ( mb ); | 104 | m_pm_zoom = new QPopupMenu ( mb ); |
105 | m_pm_zoom-> setCheckable ( true ); | 105 | m_pm_zoom-> setCheckable ( true ); |
106 | 106 | ||
107 | mb-> insertItem ( tr( "Zoom" ), m_pm_zoom ); | 107 | mb-> insertItem ( tr( "Zoom" ), m_pm_zoom ); |
108 | 108 | ||
109 | m_pm_zoom-> insertItem ( tr( "Fit to width" ), 1 ); | 109 | m_pm_zoom-> insertItem ( tr( "Fit to width" ), 1 ); |
110 | m_pm_zoom-> insertItem ( tr( "Fit to page" ), 2 ); | 110 | m_pm_zoom-> insertItem ( tr( "Fit to page" ), 2 ); |
111 | m_pm_zoom-> insertSeparator ( ); | 111 | m_pm_zoom-> insertSeparator ( ); |
112 | m_pm_zoom-> insertItem ( tr( "50%" ), 50 ); | 112 | m_pm_zoom-> insertItem ( tr( "50%" ), 50 ); |
113 | m_pm_zoom-> insertItem ( tr( "75%" ), 75 ); | 113 | m_pm_zoom-> insertItem ( tr( "75%" ), 75 ); |
114 | m_pm_zoom-> insertItem ( tr( "100%" ), 100 ); | 114 | m_pm_zoom-> insertItem ( tr( "100%" ), 100 ); |
115 | m_pm_zoom-> insertItem ( tr( "125%" ), 125 ); | 115 | m_pm_zoom-> insertItem ( tr( "125%" ), 125 ); |
116 | m_pm_zoom-> insertItem ( tr( "150%" ), 150 ); | 116 | m_pm_zoom-> insertItem ( tr( "150%" ), 150 ); |
117 | m_pm_zoom-> insertItem ( tr( "200%" ), 200 ); | 117 | m_pm_zoom-> insertItem ( tr( "200%" ), 200 ); |
118 | 118 | ||
119 | connect ( m_pm_zoom, SIGNAL( activated ( int )), this, SLOT( setZoom ( int ))); | 119 | connect ( m_pm_zoom, SIGNAL( activated(int)), this, SLOT( setZoom(int))); |
120 | 120 | ||
121 | m_tb_tool = new QToolBar ( this ); | 121 | m_tb_tool = new QToolBar ( this ); |
122 | 122 | ||
123 | new QToolButton ( Resource::loadIconSet ( "fileopen" ), tr( "Open..." ), QString::null, this, SLOT( openFile ( )), m_tb_tool, "open" ); | 123 | new QToolButton ( Resource::loadIconSet ( "fileopen" ), tr( "Open..." ), QString::null, this, SLOT( openFile()), m_tb_tool, "open" ); |
124 | m_tb_tool-> addSeparator ( ); | 124 | m_tb_tool-> addSeparator ( ); |
125 | m_to_find = new QToolButton ( Resource::loadIconSet ( "find" ), tr( "Find..." ), QString::null, this, SLOT( toggleFindBar ( )), m_tb_tool, "find" ); | 125 | m_to_find = new QToolButton ( Resource::loadIconSet ( "find" ), tr( "Find..." ), QString::null, this, SLOT( toggleFindBar()), m_tb_tool, "find" ); |
126 | m_to_find-> setToggleButton ( true ); | 126 | m_to_find-> setToggleButton ( true ); |
127 | m_tb_tool-> addSeparator ( ); | 127 | m_tb_tool-> addSeparator ( ); |
128 | m_to_full = new QToolButton ( Resource::loadIconSet ( "fullscreen" ), tr( "Fullscreen" ), QString::null, this, SLOT( toggleFullscreen ( )), m_tb_tool, "fullscreen" ); | 128 | m_to_full = new QToolButton ( Resource::loadIconSet ( "fullscreen" ), tr( "Fullscreen" ), QString::null, this, SLOT( toggleFullscreen()), m_tb_tool, "fullscreen" ); |
129 | m_to_full-> setToggleButton ( true ); | 129 | m_to_full-> setToggleButton ( true ); |
130 | m_tb_tool-> addSeparator ( ); | 130 | m_tb_tool-> addSeparator ( ); |
131 | new QToolButton ( Resource::loadIconSet ( "fastback" ), tr( "First page" ), QString::null, this, SLOT( firstPage ( )), m_tb_tool, "first" ); | 131 | new QToolButton ( Resource::loadIconSet ( "fastback" ), tr( "First page" ), QString::null, this, SLOT( firstPage()), m_tb_tool, "first" ); |
132 | new QToolButton ( Resource::loadIconSet ( "back" ), tr( "Previous page" ), QString::null, this, SLOT( prevPage ( )), m_tb_tool, "prev" ); | 132 | new QToolButton ( Resource::loadIconSet ( "back" ), tr( "Previous page" ), QString::null, this, SLOT( prevPage()), m_tb_tool, "prev" ); |
133 | new QToolButton ( Resource::loadIconSet ( "down" ), tr( "Goto page..." ), QString::null, this, SLOT( gotoPageDialog ( )), m_tb_tool, "goto" ); | 133 | new QToolButton ( Resource::loadIconSet ( "down" ), tr( "Goto page..." ), QString::null, this, SLOT( gotoPageDialog()), m_tb_tool, "goto" ); |
134 | new QToolButton ( Resource::loadIconSet ( "forward" ), tr( "Next page" ), QString::null, this, SLOT( nextPage ( )), m_tb_tool, "next" ); | 134 | new QToolButton ( Resource::loadIconSet ( "forward" ), tr( "Next page" ), QString::null, this, SLOT( nextPage()), m_tb_tool, "next" ); |
135 | new QToolButton ( Resource::loadIconSet ( "fastforward" ), tr( "Last page" ), QString::null, this, SLOT( lastPage ( )), m_tb_tool, "last" ); | 135 | new QToolButton ( Resource::loadIconSet ( "fastforward" ), tr( "Last page" ), QString::null, this, SLOT( lastPage()), m_tb_tool, "last" ); |
136 | 136 | ||
137 | m_tb_find = new QToolBar ( this ); | 137 | m_tb_find = new QToolBar ( this ); |
138 | addToolBar ( m_tb_find, "Search", QMainWindow::Top, true ); | 138 | addToolBar ( m_tb_find, "Search", QMainWindow::Top, true ); |
139 | m_tb_find-> setHorizontalStretchable ( true ); | 139 | m_tb_find-> setHorizontalStretchable ( true ); |
140 | m_tb_find-> hide ( ); | 140 | m_tb_find-> hide ( ); |
141 | 141 | ||
142 | m_findedit = new QLineEdit ( m_tb_find, "findedit" ); | 142 | m_findedit = new QLineEdit ( m_tb_find, "findedit" ); |
143 | m_tb_find-> setStretchableWidget ( m_findedit ); | 143 | m_tb_find-> setStretchableWidget ( m_findedit ); |
144 | connect ( m_findedit, SIGNAL( textChanged ( const QString & )), this, SLOT( findText ( const QString & ))); | 144 | connect ( m_findedit, SIGNAL( textChanged(const QString&)), this, SLOT( findText(const QString&))); |
145 | 145 | ||
146 | new QToolButton ( Resource::loadIconSet ( "next" ), tr( "Next" ), QString::null, this, SLOT( findText ( )), m_tb_find, "findnext" ); | 146 | new QToolButton ( Resource::loadIconSet ( "next" ), tr( "Next" ), QString::null, this, SLOT( findText()), m_tb_find, "findnext" ); |
147 | 147 | ||
148 | openFile ( ); | 148 | openFile ( ); |
149 | } | 149 | } |
150 | 150 | ||
151 | QPdfDlg::~QPdfDlg ( ) | 151 | QPdfDlg::~QPdfDlg ( ) |
152 | { | 152 | { |
153 | delete m_doc; | 153 | delete m_doc; |
154 | } | 154 | } |
155 | 155 | ||
156 | // vv Fullscreen handling (for broken QT-lib) [David Hedbor, www.eongames.com] | 156 | // vv Fullscreen handling (for broken QT-lib) [David Hedbor, www.eongames.com] |
157 | 157 | ||
158 | void QPdfDlg::resizeEvent ( QResizeEvent * ) | 158 | void QPdfDlg::resizeEvent ( QResizeEvent * ) |
159 | { | 159 | { |
160 | if ( m_fullscreen && ( size ( ) != qApp-> desktop ( )-> size ( ))) | 160 | if ( m_fullscreen && ( size ( ) != qApp-> desktop ( )-> size ( ))) |
161 | setFullscreen ( true ); | 161 | setFullscreen ( true ); |
162 | } | 162 | } |
163 | 163 | ||
164 | void QPdfDlg::focusInEvent ( QFocusEvent * ) | 164 | void QPdfDlg::focusInEvent ( QFocusEvent * ) |
165 | { | 165 | { |
166 | if ( m_fullscreen ) | 166 | if ( m_fullscreen ) |
167 | setFullscreen ( true ); | 167 | setFullscreen ( true ); |
168 | } | 168 | } |
169 | 169 | ||
170 | void QPdfDlg::toggleFullscreen ( ) | 170 | void QPdfDlg::toggleFullscreen ( ) |
171 | { | 171 | { |
172 | if ( m_to_full-> isOn ( ) == m_fullscreen ) | 172 | if ( m_to_full-> isOn ( ) == m_fullscreen ) |
173 | m_to_full-> setOn ( !m_fullscreen ); | 173 | m_to_full-> setOn ( !m_fullscreen ); |
174 | 174 | ||
175 | m_fullscreen = !m_fullscreen; | 175 | m_fullscreen = !m_fullscreen; |
176 | setFullscreen ( m_fullscreen ); | 176 | setFullscreen ( m_fullscreen ); |
177 | } | 177 | } |
178 | 178 | ||
179 | void QPdfDlg::setFullscreen ( bool b ) | 179 | void QPdfDlg::setFullscreen ( bool b ) |
180 | { | 180 | { |
181 | static QSize normalsize; | 181 | static QSize normalsize; |
182 | 182 | ||
183 | if ( b ) { | 183 | if ( b ) { |
184 | if ( !normalsize. isValid ( )) | 184 | if ( !normalsize. isValid ( )) |
185 | normalsize = size ( ); | 185 | normalsize = size ( ); |
186 | 186 | ||
187 | setFixedSize ( qApp-> desktop ( )-> size ( )); | 187 | setFixedSize ( qApp-> desktop ( )-> size ( )); |
188 | showNormal ( ); | 188 | showNormal ( ); |
189 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, QPoint ( 0, 0 )); | 189 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, QPoint ( 0, 0 )); |
190 | showFullScreen ( ); | 190 | showFullScreen ( ); |
191 | } | 191 | } |
192 | else { | 192 | else { |
193 | showNormal ( ); | 193 | showNormal ( ); |
194 | reparent ( 0, 0, QPoint ( 0, 0 )); | 194 | reparent ( 0, 0, QPoint ( 0, 0 )); |
195 | resize ( normalsize ); | 195 | resize ( normalsize ); |
196 | showMaximized ( ); | 196 | showMaximized ( ); |
197 | normalsize = QSize ( ); | 197 | normalsize = QSize ( ); |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | // ^^ Fullscreen handling (for broken QT-lib) | 201 | // ^^ Fullscreen handling (for broken QT-lib) |
202 | 202 | ||
203 | void QPdfDlg::setBusy ( bool b ) | 203 | void QPdfDlg::setBusy ( bool b ) |
204 | { | 204 | { |
205 | if ( b != m_busy ) { | 205 | if ( b != m_busy ) { |
206 | m_busy = b; | 206 | m_busy = b; |
207 | 207 | ||
208 | m_outdev-> setBusy ( m_busy ); | 208 | m_outdev-> setBusy ( m_busy ); |
209 | setEnabled ( !m_busy ); | 209 | setEnabled ( !m_busy ); |
210 | } | 210 | } |
211 | } | 211 | } |
212 | 212 | ||
213 | bool QPdfDlg::busy ( ) const | 213 | bool QPdfDlg::busy ( ) const |
214 | { | 214 | { |
215 | return m_busy; | 215 | return m_busy; |
216 | } | 216 | } |
217 | 217 | ||
218 | 218 | ||
219 | void QPdfDlg::updateCaption ( ) | 219 | void QPdfDlg::updateCaption ( ) |
220 | { | 220 | { |
221 | QString cap = ""; | 221 | QString cap = ""; |
222 | 222 | ||
223 | if ( !m_currentdoc. isEmpty ( )) | 223 | if ( !m_currentdoc. isEmpty ( )) |
224 | cap = QString ( "%1 - " ). arg ( m_currentdoc ); | 224 | cap = QString ( "%1 - " ). arg ( m_currentdoc ); |
225 | cap += "QPdf"; | 225 | cap += "QPdf"; |
226 | 226 | ||
227 | setCaption ( cap ); | 227 | setCaption ( cap ); |
228 | } | 228 | } |
229 | 229 | ||
230 | 230 | ||
231 | void QPdfDlg::setZoom ( int id ) | 231 | void QPdfDlg::setZoom ( int id ) |
232 | { | 232 | { |
233 | int dpi = 0; | 233 | int dpi = 0; |
234 | 234 | ||
235 | switch ( id ) { | 235 | switch ( id ) { |
236 | case 1: | 236 | case 1: |
237 | if ( m_doc && m_doc-> isOk ( )) | 237 | if ( m_doc && m_doc-> isOk ( )) |
238 | dpi = m_outdev-> visibleWidth ( ) * 72 / m_doc-> getPageWidth ( m_currentpage ); | 238 | dpi = m_outdev-> visibleWidth ( ) * 72 / m_doc-> getPageWidth ( m_currentpage ); |
239 | break; | 239 | break; |
240 | 240 | ||
241 | case 2: | 241 | case 2: |
242 | if ( m_doc && m_doc-> isOk ( )) | 242 | if ( m_doc && m_doc-> isOk ( )) |
@@ -402,139 +402,139 @@ void QPdfDlg::copyToClipboard ( const QRect &r ) | |||
402 | qApp-> clipboard ( )-> setText ( m_outdev-> getText ( r )); | 402 | qApp-> clipboard ( )-> setText ( m_outdev-> getText ( r )); |
403 | } | 403 | } |
404 | 404 | ||
405 | void QPdfDlg::firstPage ( ) | 405 | void QPdfDlg::firstPage ( ) |
406 | { | 406 | { |
407 | gotoPage ( 1 ); | 407 | gotoPage ( 1 ); |
408 | } | 408 | } |
409 | 409 | ||
410 | void QPdfDlg::prevPage ( ) | 410 | void QPdfDlg::prevPage ( ) |
411 | { | 411 | { |
412 | gotoPage ( m_currentpage - 1 ); | 412 | gotoPage ( m_currentpage - 1 ); |
413 | } | 413 | } |
414 | 414 | ||
415 | void QPdfDlg::nextPage ( ) | 415 | void QPdfDlg::nextPage ( ) |
416 | { | 416 | { |
417 | gotoPage ( m_currentpage + 1 ); | 417 | gotoPage ( m_currentpage + 1 ); |
418 | } | 418 | } |
419 | 419 | ||
420 | void QPdfDlg::lastPage ( ) | 420 | void QPdfDlg::lastPage ( ) |
421 | { | 421 | { |
422 | gotoPage ( m_pages ); | 422 | gotoPage ( m_pages ); |
423 | } | 423 | } |
424 | 424 | ||
425 | void QPdfDlg::gotoPage ( int n ) | 425 | void QPdfDlg::gotoPage ( int n ) |
426 | { | 426 | { |
427 | if ( n < 1 ) | 427 | if ( n < 1 ) |
428 | n = 1; | 428 | n = 1; |
429 | if ( n > m_pages ) | 429 | if ( n > m_pages ) |
430 | n = m_pages; | 430 | n = m_pages; |
431 | 431 | ||
432 | if ( n != m_currentpage ) { | 432 | if ( n != m_currentpage ) { |
433 | m_currentpage = n; | 433 | m_currentpage = n; |
434 | 434 | ||
435 | renderPage ( ); | 435 | renderPage ( ); |
436 | } | 436 | } |
437 | } | 437 | } |
438 | 438 | ||
439 | void QPdfDlg::renderPage ( ) | 439 | void QPdfDlg::renderPage ( ) |
440 | { | 440 | { |
441 | if ( m_renderok && m_doc && m_doc-> isOk ( )) { | 441 | if ( m_renderok && m_doc && m_doc-> isOk ( )) { |
442 | m_renderok = false; | 442 | m_renderok = false; |
443 | 443 | ||
444 | setBusy ( true ); | 444 | setBusy ( true ); |
445 | m_doc-> displayPage ( m_outdev, m_currentpage, m_zoom, 0, true ); | 445 | m_doc-> displayPage ( m_outdev, m_currentpage, m_zoom, 0, true ); |
446 | setBusy ( false ); | 446 | setBusy ( false ); |
447 | 447 | ||
448 | m_outdev-> setPageCount ( m_currentpage, m_pages ); | 448 | m_outdev-> setPageCount ( m_currentpage, m_pages ); |
449 | 449 | ||
450 | m_renderok = true; | 450 | m_renderok = true; |
451 | } | 451 | } |
452 | } | 452 | } |
453 | 453 | ||
454 | void QPdfDlg::closeFileSelector ( ) | 454 | void QPdfDlg::closeFileSelector ( ) |
455 | { | 455 | { |
456 | m_tb_menu-> show ( ); | 456 | m_tb_menu-> show ( ); |
457 | m_tb_tool-> show ( ); | 457 | m_tb_tool-> show ( ); |
458 | m_stack-> raiseWidget ( m_outdev ); | 458 | m_stack-> raiseWidget ( m_outdev ); |
459 | } | 459 | } |
460 | 460 | ||
461 | void QPdfDlg::openFile ( ) | 461 | void QPdfDlg::openFile ( ) |
462 | { | 462 | { |
463 | m_tb_menu-> hide ( ); | 463 | m_tb_menu-> hide ( ); |
464 | m_tb_tool-> hide ( ); | 464 | m_tb_tool-> hide ( ); |
465 | m_tb_find-> hide ( ); | 465 | m_tb_find-> hide ( ); |
466 | m_stack-> raiseWidget ( m_filesel ); | 466 | m_stack-> raiseWidget ( m_filesel ); |
467 | } | 467 | } |
468 | 468 | ||
469 | void QPdfDlg::openFile ( const QString &f ) | 469 | void QPdfDlg::openFile ( const QString &f ) |
470 | { | 470 | { |
471 | DocLnk nf; | 471 | DocLnk nf; |
472 | nf. setType ( "application/pdf" ); | 472 | nf. setType ( "application/pdf" ); |
473 | nf. setFile ( f ); | 473 | nf. setFile ( f ); |
474 | QFileInfo fi ( f ); | 474 | QFileInfo fi ( f ); |
475 | nf. setName ( fi. baseName ( )); | 475 | nf. setName ( fi. baseName ( )); |
476 | openFile ( nf ); | 476 | openFile ( nf ); |
477 | } | 477 | } |
478 | 478 | ||
479 | void QPdfDlg::openFile ( const DocLnk &f ) | 479 | void QPdfDlg::openFile ( const DocLnk &f ) |
480 | { | 480 | { |
481 | QString fn = f. file ( ); | 481 | QString fn = f. file ( ); |
482 | QFileInfo fi ( fn ); | 482 | QFileInfo fi ( fn ); |
483 | 483 | ||
484 | if ( fi. exists ( )) { | 484 | if ( fi. exists ( )) { |
485 | delete m_doc; | 485 | delete m_doc; |
486 | 486 | ||
487 | m_doc = new PDFDoc ( new GString ( fn. local8Bit ( )), 0, 0 ); | 487 | m_doc = new PDFDoc ( new GString ( fn. local8Bit ( )), 0, 0 ); |
488 | 488 | ||
489 | if ( m_doc-> isOk ( )) { | 489 | if ( m_doc-> isOk ( )) { |
490 | m_currentdoc = f. name ( ); | 490 | m_currentdoc = f. name ( ); |
491 | int sep = m_currentdoc. findRev ( '/' ); | 491 | int sep = m_currentdoc. findRev ( '/' ); |
492 | if ( sep > 0 ) | 492 | if ( sep > 0 ) |
493 | m_currentdoc = m_currentdoc. mid ( sep + 1 ); | 493 | m_currentdoc = m_currentdoc. mid ( sep + 1 ); |
494 | 494 | ||
495 | m_pages = m_doc-> getNumPages ( ); | 495 | m_pages = m_doc-> getNumPages ( ); |
496 | m_currentpage = 0; | 496 | m_currentpage = 0; |
497 | 497 | ||
498 | QTimer::singleShot ( 0, this, SLOT( delayedInit ( ))); | 498 | QTimer::singleShot ( 0, this, SLOT( delayedInit())); |
499 | } | 499 | } |
500 | else { | 500 | else { |
501 | delete m_doc; | 501 | delete m_doc; |
502 | m_doc = 0; | 502 | m_doc = 0; |
503 | 503 | ||
504 | m_currentdoc = QString::null; | 504 | m_currentdoc = QString::null; |
505 | } | 505 | } |
506 | 506 | ||
507 | updateCaption ( ); | 507 | updateCaption ( ); |
508 | } | 508 | } |
509 | else | 509 | else |
510 | QMessageBox::warning ( this, tr( "Error" ), tr( "File does not exist!" )); | 510 | QMessageBox::warning ( this, tr( "Error" ), tr( "File does not exist!" )); |
511 | } | 511 | } |
512 | 512 | ||
513 | void QPdfDlg::setDocument ( const QString &f ) | 513 | void QPdfDlg::setDocument ( const QString &f ) |
514 | { | 514 | { |
515 | if ( f. find ( ".desktop", 0, true ) == -1 ) | 515 | if ( f. find ( ".desktop", 0, true ) == -1 ) |
516 | openFile ( f ); | 516 | openFile ( f ); |
517 | else | 517 | else |
518 | openFile ( DocLnk ( f )); | 518 | openFile ( DocLnk ( f )); |
519 | 519 | ||
520 | closeFileSelector ( ); | 520 | closeFileSelector ( ); |
521 | } | 521 | } |
522 | 522 | ||
523 | void QPdfDlg::delayedInit ( ) | 523 | void QPdfDlg::delayedInit ( ) |
524 | { | 524 | { |
525 | closeFileSelector ( ); | 525 | closeFileSelector ( ); |
526 | 526 | ||
527 | m_currentpage = 0; | 527 | m_currentpage = 0; |
528 | m_zoom = 0; | 528 | m_zoom = 0; |
529 | m_renderok = false; | 529 | m_renderok = false; |
530 | 530 | ||
531 | setZoom ( 100 ); | 531 | setZoom ( 100 ); |
532 | gotoPage ( 1 ); | 532 | gotoPage ( 1 ); |
533 | 533 | ||
534 | m_renderok = true; | 534 | m_renderok = true; |
535 | 535 | ||
536 | renderPage ( ); | 536 | renderPage ( ); |
537 | 537 | ||
538 | m_outdev-> setFocus ( ); | 538 | m_outdev-> setFocus ( ); |
539 | } | 539 | } |
540 | 540 | ||