summaryrefslogtreecommitdiff
path: root/noncore/settings/aqpkg/mainwin.cpp
Unidiff
Diffstat (limited to 'noncore/settings/aqpkg/mainwin.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp176
1 files changed, 90 insertions, 86 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index dbe694e..6f5c712 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -1,15 +1,15 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 3
4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5             .=l. Dan Williams <drw@handhelds.org> 5             .=l. Dan Williams <drw@handhelds.org>
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This file is free software; you can 7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that 14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
@@ -18,65 +18,68 @@
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details. 19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .: 20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU 21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file; 22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the 23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc., 24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330, 25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30#include <linux/limits.h> 30#include "categoryfilterimpl.h"
31#include <unistd.h> 31#include "datamgr.h"
32#include "global.h"
33#include "inputdlg.h"
34#include "ipkg.h"
35#include "installdlgimpl.h"
36#include "letterpushbutton.h"
37#include "mainwin.h"
38#include "packagewin.h"
39#include "settingsimpl.h"
40#include "utils.h"
32 41
42/* OPIE */
33#include <qpe/qcopenvelope_qws.h> 43#include <qpe/qcopenvelope_qws.h>
34#include <qmenubar.h>
35#include <qpe/qpeapplication.h> 44#include <qpe/qpeapplication.h>
36#include <qtoolbar.h>
37#include <qpe/config.h> 45#include <qpe/config.h>
38#include <qpe/resource.h> 46#include <qpe/resource.h>
39 47
48/* QT */
49#include <qmenubar.h>
50#include <qtoolbar.h>
40#include <qaction.h> 51#include <qaction.h>
41#include <qcombobox.h> 52#include <qcombobox.h>
42#include <qfile.h> 53#include <qfile.h>
43#include <qlabel.h> 54#include <qlabel.h>
44#include <qlayout.h> 55#include <qlayout.h>
45#include <qlineedit.h> 56#include <qlineedit.h>
46#include <qlistview.h> 57#include <qlistview.h>
47#include <qmenubar.h> 58#include <qmenubar.h>
48#include <qmessagebox.h> 59#include <qmessagebox.h>
49#include <qpopupmenu.h> 60#include <qpopupmenu.h>
50#include <qprogressbar.h> 61#include <qprogressbar.h>
51#include <qtimer.h> 62#include <qtimer.h>
52#include <qwhatsthis.h> 63#include <qwhatsthis.h>
53#include <qwidgetstack.h> 64#include <qwidgetstack.h>
54 65
55#include "categoryfilterimpl.h" 66/* STD */
56#include "datamgr.h" 67#include <linux/limits.h>
57#include "global.h" 68#include <unistd.h>
58#include "inputdlg.h"
59#include "ipkg.h"
60#include "installdlgimpl.h"
61#include "letterpushbutton.h"
62#include "mainwin.h"
63#include "packagewin.h"
64#include "settingsimpl.h"
65#include "utils.h"
66 69
67extern int compareVersions( const char *v1, const char *v2 ); 70extern int compareVersions( const char *v1, const char *v2 );
68 71
69MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl ) 72MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl )
70 :QMainWindow( parent, name, fl || WStyle_ContextHelp ) 73 :QMainWindow( parent, name, fl || WStyle_ContextHelp )
71{ 74{
72 // Disable suspend mode 75 // Disable suspend mode
73 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; 76 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend;
74 77
75 LOCAL_SERVER = QObject::tr( "Installed packages" ); 78 LOCAL_SERVER = QObject::tr( "Installed packages" );
76 LOCAL_IPKGS = QObject::tr( "Local packages" ); 79 LOCAL_IPKGS = QObject::tr( "Local packages" );
77 80
78 setCaption( tr( "AQPkg - Package Manager" ) ); 81 setCaption( tr( "AQPkg - Package Manager" ) );
79 82
80 // Create UI widgets 83 // Create UI widgets
81 initMainWidget(); 84 initMainWidget();
82 initProgressWidget(); 85 initProgressWidget();
@@ -230,25 +233,25 @@ MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl )
230 stack = new QWidgetStack( this ); 233 stack = new QWidgetStack( this );
231 stack->addWidget( progressWindow, 2 ); 234 stack->addWidget( progressWindow, 2 );
232 stack->addWidget( networkPkgWindow, 1 ); 235 stack->addWidget( networkPkgWindow, 1 );
233 setCentralWidget( stack ); 236 setCentralWidget( stack );
234 stack->raiseWidget( progressWindow ); 237 stack->raiseWidget( progressWindow );
235 238
236 // Delayed call to finish initialization 239 // Delayed call to finish initialization
237 QTimer::singleShot( 100, this, SLOT( init() ) ); 240 QTimer::singleShot( 100, this, SLOT( init() ) );
238} 241}
239 242
240MainWindow :: ~MainWindow() 243MainWindow :: ~MainWindow()
241{ 244{
242 delete mgr; 245 delete mgr;
243 246
244 // Reenable suspend mode 247 // Reenable suspend mode
245 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 248 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
246} 249}
247 250
248void MainWindow :: initMainWidget() 251void MainWindow :: initMainWidget()
249{ 252{
250 networkPkgWindow = new QWidget( this ); 253 networkPkgWindow = new QWidget( this );
251 254
252 QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); 255 QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow );
253 256
254 serversList = new QComboBox( networkPkgWindow ); 257 serversList = new QComboBox( networkPkgWindow );
@@ -287,25 +290,25 @@ void MainWindow :: initProgressWidget()
287 290
288 m_progress = new QProgressBar( progressWindow ); 291 m_progress = new QProgressBar( progressWindow );
289 layout->addWidget( m_progress ); 292 layout->addWidget( m_progress );
290} 293}
291 294
292void MainWindow :: init() 295void MainWindow :: init()
293{ 296{
294#ifdef QWS 297#ifdef QWS
295 // read download directory from config file 298 // read download directory from config file
296 Config cfg( "aqpkg" ); 299 Config cfg( "aqpkg" );
297 cfg.setGroup( "settings" ); 300 cfg.setGroup( "settings" );
298 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); 301 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
299// showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); 302 // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
300 303
301#endif 304#endif
302 305
303 stack->raiseWidget( progressWindow ); 306 stack->raiseWidget( progressWindow );
304 307
305 mgr = new DataManager(); 308 mgr = new DataManager();
306 connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); 309 connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) );
307 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), 310 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ),
308 this, SLOT( setProgressMessage( const QString & ) ) ); 311 this, SLOT( setProgressMessage( const QString & ) ) );
309 connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); 312 connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) );
310 mgr->loadServers(); 313 mgr->loadServers();
311 314
@@ -328,42 +331,42 @@ void MainWindow :: setDocument( const QString &doc )
328 for ( int i = 0 ; i < serversList->count() ; ++i ) 331 for ( int i = 0 ; i < serversList->count() ; ++i )
329 { 332 {
330 if ( serversList->text( i ) == LOCAL_IPKGS ) 333 if ( serversList->text( i ) == LOCAL_IPKGS )
331 { 334 {
332 serversList->setCurrentItem( i ); 335 serversList->setCurrentItem( i );
333 break; 336 break;
334 } 337 }
335 } 338 }
336 serverSelected( 0 ); 339 serverSelected( 0 );
337 340
338 // Now set the check box of the selected package 341 // Now set the check box of the selected package
339 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 342 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
340 item != 0 ; 343 item != 0 ;
341 item = (QCheckListItem *)item->nextSibling() ) 344 item = (QCheckListItem *)item->nextSibling() )
342 { 345 {
343 if ( item->text().startsWith( package ) ) 346 if ( item->text().startsWith( package ) )
344 { 347 {
345 item->setOn( true ); 348 item->setOn( true );
346 break; 349 break;
347 } 350 }
348 } 351 }
349} 352}
350 353
351void MainWindow :: displaySettings() 354void MainWindow :: displaySettings()
352{ 355{
353 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); 356 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
354 if ( dlg->showDlg() ) 357 if ( dlg->showDlg() )
355 { 358 {
356 stack->raiseWidget( progressWindow ); 359 stack->raiseWidget( progressWindow );
357 updateData(); 360 updateData();
358 stack->raiseWidget( networkPkgWindow ); 361 stack->raiseWidget( networkPkgWindow );
359 } 362 }
360 delete dlg; 363 delete dlg;
361} 364}
362 365
363void MainWindow :: closeEvent( QCloseEvent *e ) 366void MainWindow :: closeEvent( QCloseEvent *e )
364{ 367{
365 // If install dialog is visible, return to main view, otherwise close app 368 // If install dialog is visible, return to main view, otherwise close app
366 QWidget *widget = stack->visibleWidget(); 369 QWidget *widget = stack->visibleWidget();
367 370
368 if ( widget != networkPkgWindow && widget != progressWindow ) 371 if ( widget != networkPkgWindow && widget != progressWindow )
369 { 372 {
@@ -573,30 +576,30 @@ void MainWindow :: updateData()
573 m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); 576 m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) );
574 m_progress->setProgress( i ); 577 m_progress->setProgress( i );
575 qApp->processEvents(); 578 qApp->processEvents();
576 579
577 if ( !server->isServerActive() ) 580 if ( !server->isServerActive() )
578 { 581 {
579 i--; 582 i--;
580 continue; 583 continue;
581 } 584 }
582 585
583 serversList->insertItem( serverName ); 586 serversList->insertItem( serverName );
584 if ( serverName == currentlySelectedServer ) 587 if ( serverName == currentlySelectedServer )
585 activeItem = i; 588 activeItem = i;
586 } 589 }
587 590
588 // set selected server to be active server 591 // set selected server to be active server
589 if ( activeItem != -1 ) 592 if ( activeItem != -1 )
590 serversList->setCurrentItem( activeItem ); 593 serversList->setCurrentItem( activeItem );
591 serverSelected( 0, FALSE ); 594 serverSelected( 0, FALSE );
592} 595}
593 596
594void MainWindow :: serverSelected( int index ) 597void MainWindow :: serverSelected( int index )
595{ 598{
596 serverSelected( index, TRUE ); 599 serverSelected( index, TRUE );
597} 600}
598 601
599void MainWindow :: serverSelected( int, bool raiseProgress ) 602void MainWindow :: serverSelected( int, bool raiseProgress )
600{ 603{
601 QPixmap nullIcon( installedIcon.size() ); 604 QPixmap nullIcon( installedIcon.size() );
602 nullIcon.fill( colorGroup().base() ); 605 nullIcon.fill( colorGroup().base() );
@@ -616,28 +619,28 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
616 { 619 {
617 if ( raiseProgress ) 620 if ( raiseProgress )
618 { 621 {
619 stack->raiseWidget( progressWindow ); 622 stack->raiseWidget( progressWindow );
620 } 623 }
621 m_progress->setTotalSteps( list.count() ); 624 m_progress->setTotalSteps( list.count() );
622 m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); 625 m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) );
623 } 626 }
624 627
625 packagesList->clear(); 628 packagesList->clear();
626 629
627#ifdef QWS 630#ifdef QWS
628 // read download directory from config file 631 // read download directory from config file
629 Config cfg( "aqpkg" ); 632 Config cfg( "aqpkg" );
630 cfg.setGroup( "settings" ); 633 cfg.setGroup( "settings" );
631 cfg.writeEntry( "selectedServer", currentlySelectedServer ); 634 cfg.writeEntry( "selectedServer", currentlySelectedServer );
632#endif 635#endif
633 636
634 int i = 0; 637 int i = 0;
635 Package *package; 638 Package *package;
636 for ( ; it.current(); ++it ) 639 for ( ; it.current(); ++it )
637 { 640 {
638 // Update progress after every 100th package (arbitrary value, seems to give good balance) 641 // Update progress after every 100th package (arbitrary value, seems to give good balance)
639 i++; 642 i++;
640 if ( ( i % 100 ) == 0 ) 643 if ( ( i % 100 ) == 0 )
641 { 644 {
642 if ( doProgress ) 645 if ( doProgress )
643 { 646 {
@@ -669,25 +672,25 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
669 if ( categoryFilterEnabled && categoryFilter != "" ) 672 if ( categoryFilterEnabled && categoryFilter != "" )
670 { 673 {
671 if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) 674 if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 )
672 continue; 675 continue;
673 } 676 }
674 677
675 // If the local server, only display installed packages 678 // If the local server, only display installed packages
676 if ( serverName == LOCAL_SERVER && !package->isInstalled() ) 679 if ( serverName == LOCAL_SERVER && !package->isInstalled() )
677 continue; 680 continue;
678 681
679 682
680 QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), 683 QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(),
681 QCheckListItem::CheckBox ); 684 QCheckListItem::CheckBox );
682 685
683 if ( package->isInstalled() ) 686 if ( package->isInstalled() )
684 { 687 {
685 // If a different version of package is available, show update available icon 688 // If a different version of package is available, show update available icon
686 // Otherwise, show installed icon 689 // Otherwise, show installed icon
687 if ( package->getNewVersionAvailable()) 690 if ( package->getNewVersionAvailable())
688 { 691 {
689 692
690 item->setPixmap( 0, updatedIcon ); 693 item->setPixmap( 0, updatedIcon );
691 } 694 }
692 else 695 else
693 { 696 {
@@ -729,25 +732,25 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
729 732
730void MainWindow :: searchForPackage( const QString &text ) 733void MainWindow :: searchForPackage( const QString &text )
731{ 734{
732 if ( !text.isEmpty() ) 735 if ( !text.isEmpty() )
733 { 736 {
734 // look through package list for text startng at current position 737 // look through package list for text startng at current position
735 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 738 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
736 739
737 if ( start == 0 ) 740 if ( start == 0 )
738 start = (QCheckListItem *)packagesList->firstChild(); 741 start = (QCheckListItem *)packagesList->firstChild();
739 742
740 for ( QCheckListItem *item = start; item != 0 ; 743 for ( QCheckListItem *item = start; item != 0 ;
741 item = (QCheckListItem *)item->nextSibling() ) 744 item = (QCheckListItem *)item->nextSibling() )
742 { 745 {
743 if ( item->text().lower().find( text ) != -1 ) 746 if ( item->text().lower().find( text ) != -1 )
744 { 747 {
745 packagesList->ensureItemVisible( item ); 748 packagesList->ensureItemVisible( item );
746 packagesList->setCurrentItem( item ); 749 packagesList->setCurrentItem( item );
747 break; 750 break;
748 } 751 }
749 } 752 }
750 } 753 }
751} 754}
752 755
753void MainWindow :: updateServer() 756void MainWindow :: updateServer()
@@ -757,114 +760,114 @@ void MainWindow :: updateServer()
757 // Update the current server 760 // Update the current server
758 // Display dialog 761 // Display dialog
759 762
760 // Disable buttons to stop silly people clicking lots on them :) 763 // Disable buttons to stop silly people clicking lots on them :)
761 764
762 // First, write out ipkg_conf file so that ipkg can use it 765 // First, write out ipkg_conf file so that ipkg can use it
763 mgr->writeOutIpkgConf(); 766 mgr->writeOutIpkgConf();
764 767
765 Ipkg *ipkg = new Ipkg; 768 Ipkg *ipkg = new Ipkg;
766 ipkg->setOption( "update" ); 769 ipkg->setOption( "update" );
767 770
768 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), 771 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ),
769 tr( "Update lists" ) ); 772 tr( "Update lists" ) );
770 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 773 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
771 reloadDocuments = FALSE; 774 reloadDocuments = FALSE;
772 stack->addWidget( dlg, 3 ); 775 stack->addWidget( dlg, 3 );
773 stack->raiseWidget( dlg ); 776 stack->raiseWidget( dlg );
774 777
775// delete progDlg; 778 // delete progDlg;
776} 779}
777 780
778void MainWindow :: upgradePackages() 781void MainWindow :: upgradePackages()
779{ 782{
780 // We're gonna do an upgrade of all packages 783 // We're gonna do an upgrade of all packages
781 // First warn user that this isn't recommended 784 // First warn user that this isn't recommended
782 // TODO - ODevice???? 785 // TODO - ODevice????
783 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); 786 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" );
784 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, 787 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning,
785 QMessageBox::Yes, 788 QMessageBox::Yes,
786 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 789 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
787 0, this ); 790 0, this );
788 warn.adjustSize(); 791 warn.adjustSize();
789 792
790 if ( warn.exec() == QMessageBox::Yes ) 793 if ( warn.exec() == QMessageBox::Yes )
791 { 794 {
792 // First, write out ipkg_conf file so that ipkg can use it 795 // First, write out ipkg_conf file so that ipkg can use it
793 mgr->writeOutIpkgConf(); 796 mgr->writeOutIpkgConf();
794 797
795 // Now run upgrade 798 // Now run upgrade
796 Ipkg *ipkg = new Ipkg; 799 Ipkg *ipkg = new Ipkg;
797 ipkg->setOption( "upgrade" ); 800 ipkg->setOption( "upgrade" );
798 801
799 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), 802 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ),
800 tr ( "Upgrade" ) ); 803 tr ( "Upgrade" ) );
801 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 804 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
802 reloadDocuments = TRUE; 805 reloadDocuments = TRUE;
803 stack->addWidget( dlg, 3 ); 806 stack->addWidget( dlg, 3 );
804 stack->raiseWidget( dlg ); 807 stack->raiseWidget( dlg );
805 } 808 }
806} 809}
807 810
808void MainWindow :: downloadPackage() 811void MainWindow :: downloadPackage()
809{ 812{
810 bool doUpdate = true; 813 bool doUpdate = true;
811 if ( downloadEnabled ) 814 if ( downloadEnabled )
812 { 815 {
813 // See if any packages are selected 816 // See if any packages are selected
814 bool found = false; 817 bool found = false;
815 if ( serversList->currentText() != LOCAL_SERVER ) 818 if ( serversList->currentText() != LOCAL_SERVER )
816 { 819 {
817 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 820 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
818 item != 0 && !found; 821 item != 0 && !found;
819 item = (QCheckListItem *)item->nextSibling() ) 822 item = (QCheckListItem *)item->nextSibling() )
820 { 823 {
821 if ( item->isOn() ) 824 if ( item->isOn() )
822 found = true; 825 found = true;
823 } 826 }
824 } 827 }
825 828
826 // If user selected some packages then download the and store the locally 829 // If user selected some packages then download the and store the locally
827 // otherwise, display dialog asking user what package to download from an http server 830 // otherwise, display dialog asking user what package to download from an http server
828 // and whether to install it 831 // and whether to install it
829 if ( found ) 832 if ( found )
830 downloadSelectedPackages(); 833 downloadSelectedPackages();
831 else 834 else
832 downloadRemotePackage(); 835 downloadRemotePackage();
833 836
834 } 837 }
835 else 838 else
836 { 839 {
837 doUpdate = false; 840 doUpdate = false;
838 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 841 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
839 item != 0 ; 842 item != 0 ;
840 item = (QCheckListItem *)item->nextSibling() ) 843 item = (QCheckListItem *)item->nextSibling() )
841 { 844 {
842 if ( item->isOn() ) 845 if ( item->isOn() )
843 { 846 {
844 QString name = item->text(); 847 QString name = item->text();
845 int pos = name.find( "*" ); 848 int pos = name.find( "*" );
846 name.truncate( pos ); 849 name.truncate( pos );
847 850
848 // if (there is a (installed), remove it 851 // if (there is a (installed), remove it
849 pos = name.find( "(installed)" ); 852 pos = name.find( "(installed)" );
850 if ( pos > 0 ) 853 if ( pos > 0 )
851 name.truncate( pos - 1 ); 854 name.truncate( pos - 1 );
852 855
853 Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); 856 Package *p = mgr->getServer( serversList->currentText() )->getPackage( name );
854 857
855 QString msgtext; 858 QString msgtext;
856 msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); 859 msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() );
857 if ( QMessageBox::information( this, tr( "Are you sure?" ), 860 if ( QMessageBox::information( this, tr( "Are you sure?" ),
858 msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) 861 msgtext, tr( "No" ), tr( "Yes" ) ) == 1 )
859 { 862 {
860 doUpdate = true; 863 doUpdate = true;
861 QFile f( p->getFilename() ); 864 QFile f( p->getFilename() );
862 f.remove(); 865 f.remove();
863 } 866 }
864 } 867 }
865 } 868 }
866 } 869 }
867 870
868 if ( doUpdate ) 871 if ( doUpdate )
869 { 872 {
870 reloadData( 0x0 ); 873 reloadData( 0x0 );
@@ -899,103 +902,103 @@ void MainWindow :: downloadSelectedPackages()
899 902
900 // Get starting directory 903 // Get starting directory
901 char initDir[PATH_MAX]; 904 char initDir[PATH_MAX];
902 getcwd( initDir, PATH_MAX ); 905 getcwd( initDir, PATH_MAX );
903 906
904 // Download each package 907 // Download each package
905 Ipkg ipkg; 908 Ipkg ipkg;
906 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 909 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
907 910
908 ipkg.setOption( "download" ); 911 ipkg.setOption( "download" );
909 ipkg.setRuntimeDirectory( dir ); 912 ipkg.setRuntimeDirectory( dir );
910 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 913 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
911 item != 0 ; 914 item != 0 ;
912 item = (QCheckListItem *)item->nextSibling() ) 915 item = (QCheckListItem *)item->nextSibling() )
913 { 916 {
914 if ( item->isOn() ) 917 if ( item->isOn() )
915 { 918 {
916 ipkg.setPackage( item->text() ); 919 ipkg.setPackage( item->text() );
917 ipkg.runIpkg( ); 920 ipkg.runIpkg( );
918 } 921 }
919 } 922 }
920} 923}
921 924
922void MainWindow :: downloadRemotePackage() 925void MainWindow :: downloadRemotePackage()
923{ 926{
924 // Display dialog 927 // Display dialog
925 bool ok; 928 bool ok;
926 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); 929 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this );
927 if ( !ok || package.isEmpty() ) 930 if ( !ok || package.isEmpty() )
928 return; 931 return;
929// DownloadRemoteDlgImpl dlg( this, "Install", true ); 932 // DownloadRemoteDlgImpl dlg( this, "Install", true );
930// if ( dlg.exec() == QDialog::Rejected ) 933 // if ( dlg.exec() == QDialog::Rejected )
931// return; 934 // return;
932 935
933 // grab details from dialog 936 // grab details from dialog
934// QString package = dlg.getPackageLocation(); 937 // QString package = dlg.getPackageLocation();
935 938
936 InstallData *item = new InstallData(); 939 InstallData *item = new InstallData();
937 item->option = "I"; 940 item->option = "I";
938 item->packageName = package; 941 item->packageName = package;
939 QList<InstallData> workingPackages; 942 QList<InstallData> workingPackages;
940 workingPackages.setAutoDelete( TRUE ); 943 workingPackages.setAutoDelete( TRUE );
941 workingPackages.append( item ); 944 workingPackages.append( item );
942 945
943 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); 946 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) );
944 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 947 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
945 reloadDocuments = TRUE; 948 reloadDocuments = TRUE;
946 stack->addWidget( dlg, 3 ); 949 stack->addWidget( dlg, 3 );
947 stack->raiseWidget( dlg ); 950 stack->raiseWidget( dlg );
948} 951}
949 952
950 953
951void MainWindow :: applyChanges() 954void MainWindow :: applyChanges()
952{ 955{
953 stickyOption = ""; 956 stickyOption = "";
954 957
955 // First, write out ipkg_conf file so that ipkg can use it 958 // First, write out ipkg_conf file so that ipkg can use it
956 mgr->writeOutIpkgConf(); 959 mgr->writeOutIpkgConf();
957 960
958 // Now for each selected item 961 // Now for each selected item
959 // deal with it 962 // deal with it
960 963
961 QList<InstallData> workingPackages; 964 QList<InstallData> workingPackages;
962 workingPackages.setAutoDelete( TRUE ); 965 workingPackages.setAutoDelete( TRUE );
963 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 966 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
964 item != 0 ; 967 item != 0 ;
965 item = (QCheckListItem *)item->nextSibling() ) 968 item = (QCheckListItem *)item->nextSibling() )
966 { 969 {
967 if ( item->isOn() ) 970 if ( item->isOn() )
968 { 971 {
969 InstallData *instdata = dealWithItem( item ); 972 InstallData *instdata = dealWithItem( item );
970 if ( instdata ) 973 if ( instdata )
971 workingPackages.append( instdata ); 974 workingPackages.append( instdata );
972 else 975 else
973 return; 976 return;
974 } 977 }
975 } 978 }
976 979
977 if ( workingPackages.count() == 0 ) 980 if ( workingPackages.count() == 0 )
978 { 981 {
979 // Nothing to do 982 // Nothing to do
980 QMessageBox::information( this, tr( "Nothing to do" ), 983 QMessageBox::information( this, tr( "Nothing to do" ),
981 tr( "No packages selected" ), tr( "OK" ) ); 984 tr( "No packages selected" ), tr( "OK" ) );
982 985
983 return; 986 return;
984 } 987 }
985 988
986 // do the stuff 989 // do the stuff
987 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); 990 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) );
988 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 991 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
989 reloadDocuments = TRUE; 992 reloadDocuments = TRUE;
990 stack->addWidget( dlg, 3 ); 993 stack->addWidget( dlg, 3 );
991 stack->raiseWidget( dlg ); 994 stack->raiseWidget( dlg );
992} 995}
993 996
994// decide what to do - either remove, upgrade or install 997// decide what to do - either remove, upgrade or install
995// Current rules: 998// Current rules:
996// If not installed - install 999// If not installed - install
997// If installed and different version available - upgrade 1000// If installed and different version available - upgrade
998// If installed and version up to date - remove 1001// If installed and version up to date - remove
999InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) 1002InstallData *MainWindow :: dealWithItem( QCheckListItem *item )
1000{ 1003{
1001 QString name = item->text(); 1004 QString name = item->text();
@@ -1015,25 +1018,25 @@ InstallData *MainWindow :: dealWithItem( QCheckListItem *item )
1015 InstallData *newitem = new InstallData(); 1018 InstallData *newitem = new InstallData();
1016 newitem->option = "I"; 1019 newitem->option = "I";
1017 newitem->packageName = name; 1020 newitem->packageName = name;
1018 return newitem; 1021 return newitem;
1019 } 1022 }
1020 else 1023 else
1021 { 1024 {
1022 InstallData *newitem = new InstallData(); 1025 InstallData *newitem = new InstallData();
1023 newitem->option = "D"; 1026 newitem->option = "D";
1024 // If local file, remove using package name, not filename 1027 // If local file, remove using package name, not filename
1025 if ( p->isPackageStoredLocally() ) 1028 if ( p->isPackageStoredLocally() )
1026 name = item->text(); 1029 name = item->text();
1027 1030
1028 if ( !p->isPackageStoredLocally() ) 1031 if ( !p->isPackageStoredLocally() )
1029 newitem->packageName = p->getInstalledPackageName(); 1032 newitem->packageName = p->getInstalledPackageName();
1030 else 1033 else
1031 newitem->packageName = name; 1034 newitem->packageName = name;
1032 1035
1033 if ( p->getInstalledTo() ) 1036 if ( p->getInstalledTo() )
1034 { 1037 {
1035 newitem->destination = p->getInstalledTo(); 1038 newitem->destination = p->getInstalledTo();
1036 } 1039 }
1037 else 1040 else
1038 { 1041 {
1039 newitem->destination = p->getLocalPackage()->getInstalledTo(); 1042 newitem->destination = p->getLocalPackage()->getInstalledTo();
@@ -1081,80 +1084,80 @@ InstallData *MainWindow :: dealWithItem( QCheckListItem *item )
1081 secondOption = "U"; // Internal action code, do not translate 1084 secondOption = "U"; // Internal action code, do not translate
1082 } 1085 }
1083 1086
1084 // Sticky option not implemented yet, but will eventually allow 1087 // Sticky option not implemented yet, but will eventually allow
1085 // the user to say something like 'remove all' 1088 // the user to say something like 'remove all'
1086 if ( stickyOption == "" ) 1089 if ( stickyOption == "" )
1087 { 1090 {
1088 QString msgtext; 1091 QString msgtext;
1089 msgtext = caption.arg( ( const char * )name ); 1092 msgtext = caption.arg( ( const char * )name );
1090 QuestionDlg dlg( text, msgtext, secondButton ); 1093 QuestionDlg dlg( text, msgtext, secondButton );
1091 switch( dlg.exec() ) 1094 switch( dlg.exec() )
1092 { 1095 {
1093 case 0: // Cancel 1096 case 0: // Cancel
1094 delete newitem; 1097 delete newitem;
1095 return 0x0; 1098 return 0x0;
1096 break; 1099 break;
1097 case 1: // Remove 1100 case 1: // Remove
1098 newitem->option = "D"; 1101 newitem->option = "D";
1099 // If local file, remove using package name, not filename 1102 // If local file, remove using package name, not filename
1100 if ( p->isPackageStoredLocally() ) 1103 if ( p->isPackageStoredLocally() )
1101 name = item->text(); 1104 name = item->text();
1102 break; 1105 break;
1103 case 2: // Reinstall or Upgrade 1106 case 2: // Reinstall or Upgrade
1104 newitem->option = secondOption; 1107 newitem->option = secondOption;
1105 break; 1108 break;
1106 } 1109 }
1107 } 1110 }
1108 else 1111 else
1109 { 1112 {
1110// newitem->option = stickyOption; 1113 // newitem->option = stickyOption;
1111 } 1114 }
1112 } 1115 }
1113 1116
1114 1117
1115 // Check if we are reinstalling the same version 1118 // Check if we are reinstalling the same version
1116 if ( newitem->option != "R" ) 1119 if ( newitem->option != "R" )
1117 newitem->recreateLinks = true; 1120 newitem->recreateLinks = true;
1118 else 1121 else
1119 newitem->recreateLinks = false; 1122 newitem->recreateLinks = false;
1120 1123
1121 // User hit cancel (on dlg - assume remove) 1124 // User hit cancel (on dlg - assume remove)
1122 return newitem; 1125 return newitem;
1123 } 1126 }
1124} 1127}
1125 1128
1126void MainWindow :: reloadData( InstallDlgImpl *dlg ) 1129void MainWindow :: reloadData( InstallDlgImpl *dlg )
1127{ 1130{
1128 stack->raiseWidget( progressWindow ); 1131 stack->raiseWidget( progressWindow );
1129 1132
1130 if ( dlg ) 1133 if ( dlg )
1131 { 1134 {
1132 dlg->close(); 1135 dlg->close();
1133 delete dlg; 1136 delete dlg;
1134 } 1137 }
1135 1138
1136 mgr->reloadServerData(); 1139 mgr->reloadServerData();
1137 serverSelected( -1, FALSE ); 1140 serverSelected( -1, FALSE );
1138 1141
1139#ifdef QWS 1142#ifdef QWS
1140 if ( reloadDocuments ) 1143 if ( reloadDocuments )
1141 { 1144 {
1142 m_status->setText( tr( "Updating Launcher..." ) ); 1145 m_status->setText( tr( "Updating Launcher..." ) );
1143 1146
1144 // Finally let the main system update itself 1147 // Finally let the main system update itself
1145 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 1148 QCopEnvelope e("QPE/System", "linkChanged(QString)");
1146 QString lf = QString::null; 1149 QString lf = QString::null;
1147 e << lf; 1150 e << lf;
1148 } 1151 }
1149#endif 1152#endif
1150 1153
1151 stack->raiseWidget( networkPkgWindow ); 1154 stack->raiseWidget( networkPkgWindow );
1152} 1155}
1153 1156
1154void MainWindow :: letterPushed( QString t ) 1157void MainWindow :: letterPushed( QString t )
1155{ 1158{
1156 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); 1159 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
1157 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 1160 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
1158 if ( packagesList->firstChild() == 0 ) 1161 if ( packagesList->firstChild() == 0 )
1159 return; 1162 return;
1160 1163
@@ -1172,36 +1175,37 @@ void MainWindow :: letterPushed( QString t )
1172 do 1175 do
1173 { 1176 {
1174 if ( item->text().lower().startsWith( t.lower() ) ) 1177 if ( item->text().lower().startsWith( t.lower() ) )
1175 { 1178 {
1176 packagesList->setSelected( item, true ); 1179 packagesList->setSelected( item, true );
1177 packagesList->ensureItemVisible( item ); 1180 packagesList->ensureItemVisible( item );
1178 break; 1181 break;
1179 } 1182 }
1180 1183
1181 item = (QCheckListItem *)item->nextSibling(); 1184 item = (QCheckListItem *)item->nextSibling();
1182 if ( !item ) 1185 if ( !item )
1183 item = (QCheckListItem *)packagesList->firstChild(); 1186 item = (QCheckListItem *)packagesList->firstChild();
1184 } while ( item != start); 1187 }
1188 while ( item != start);
1185} 1189}
1186 1190
1187void MainWindow :: slotDisplayPackage( QListViewItem *item ) 1191void MainWindow :: slotDisplayPackage( QListViewItem *item )
1188{ 1192{
1189 QString itemstr( ((QCheckListItem*)item)->text() ); 1193 QString itemstr( ((QCheckListItem*)item)->text() );
1190 PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); 1194 PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) );
1191 p->showMaximized(); 1195 QPEApplication::showWidget( p );
1192} 1196}
1193 1197
1194QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) 1198QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn )
1195 : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) 1199 : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog )
1196{ 1200{
1197 setCaption( caption ); 1201 setCaption( caption );
1198 resize( 175, 100 ); 1202 resize( 175, 100 );
1199 1203
1200 QGridLayout *layout = new QGridLayout( this ); 1204 QGridLayout *layout = new QGridLayout( this );
1201 1205
1202 QLabel *l = new QLabel( text, this ); 1206 QLabel *l = new QLabel( text, this );
1203 l->setAlignment( AlignCenter | WordBreak ); 1207 l->setAlignment( AlignCenter | WordBreak );
1204 layout->addMultiCellWidget( l, 0, 0, 0, 1 ); 1208 layout->addMultiCellWidget( l, 0, 0, 0, 1 );
1205 1209
1206 btn1 = new QPushButton( tr( "Remove" ), this ); 1210 btn1 = new QPushButton( tr( "Remove" ), this );
1207 connect( btn1, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); 1211 connect( btn1, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) );