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.cpp55
1 files changed, 28 insertions, 27 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index f0e8e48..0102292 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -1,40 +1,52 @@
1/*************************************************************************** 1/*
2 mainwin.cpp - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Mon Aug 26 13:32:30 BST 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8 8.> <`_,   >  .   <= redistribute it and/or modify it under
9/*************************************************************************** 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10 * * 10.="- .-=="i,     .._ License as published by the Free Software
11 * This program is free software; you can redistribute it and/or modify * 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 * it under the terms of the GNU General Public License as published by * 12     ._= =}       : or (at your option) any later version.
13 * the Free Software Foundation; either version 2 of the License, or * 13    .%`+i>       _;_.
14 * (at your option) any later version. * 14    .i_,=:_.      -<s. This file is distributed in the hope that
15 * * 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 ***************************************************************************/ 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
17 29
18#include <linux/limits.h> 30#include <linux/limits.h>
19#include <unistd.h> 31#include <unistd.h>
20 32
21#include <qpe/qcopenvelope_qws.h> 33#include <qpe/qcopenvelope_qws.h>
22#include <qmenubar.h> 34#include <qmenubar.h>
23#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
24#include <qtoolbar.h> 36#include <qtoolbar.h>
25#include <qpe/config.h> 37#include <qpe/config.h>
26#include <qpe/resource.h> 38#include <qpe/resource.h>
27 39
28#include <qaction.h> 40#include <qaction.h>
29#include <qcombobox.h> 41#include <qcombobox.h>
30#include <qfile.h> 42#include <qfile.h>
31#include <qlabel.h> 43#include <qlabel.h>
32#include <qlayout.h> 44#include <qlayout.h>
33#include <qlineedit.h> 45#include <qlineedit.h>
34#include <qlistview.h> 46#include <qlistview.h>
35#include <qmenubar.h> 47#include <qmenubar.h>
36#include <qmessagebox.h> 48#include <qmessagebox.h>
37#include <qpopupmenu.h> 49#include <qpopupmenu.h>
38#include <qprogressbar.h> 50#include <qprogressbar.h>
39#include <qtimer.h> 51#include <qtimer.h>
40#include <qwhatsthis.h> 52#include <qwhatsthis.h>
@@ -281,49 +293,48 @@ void MainWindow :: init()
281 293
282 stack->raiseWidget( progressWindow ); 294 stack->raiseWidget( progressWindow );
283 295
284 mgr = new DataManager(); 296 mgr = new DataManager();
285 connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); 297 connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) );
286 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), 298 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ),
287 this, SLOT( setProgressMessage( const QString & ) ) ); 299 this, SLOT( setProgressMessage( const QString & ) ) );
288 connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); 300 connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) );
289 mgr->loadServers(); 301 mgr->loadServers();
290 302
291 showUninstalledPkgs = false; 303 showUninstalledPkgs = false;
292 showInstalledPkgs = false; 304 showInstalledPkgs = false;
293 showUpgradedPkgs = false; 305 showUpgradedPkgs = false;
294 categoryFilterEnabled = false; 306 categoryFilterEnabled = false;
295 307
296 updateData(); 308 updateData();
297 309
298 stack->raiseWidget( networkPkgWindow ); 310 stack->raiseWidget( networkPkgWindow );
299} 311}
300 312
301void MainWindow :: setDocument( const QString &doc ) 313void MainWindow :: setDocument( const QString &doc )
302{ 314{
303 // Remove path from package 315 // Remove path from package
304 QString package = Utils::getPackageNameFromIpkFilename( doc ); 316 QString package = Utils::getPackageNameFromIpkFilename( doc );
305// std::cout << "Selecting package " << package << std::endl;
306 317
307 // First select local server 318 // First select local server
308 for ( int i = 0 ; i < serversList->count() ; ++i ) 319 for ( int i = 0 ; i < serversList->count() ; ++i )
309 { 320 {
310 if ( serversList->text( i ) == LOCAL_IPKGS ) 321 if ( serversList->text( i ) == LOCAL_IPKGS )
311 { 322 {
312 serversList->setCurrentItem( i ); 323 serversList->setCurrentItem( i );
313 break; 324 break;
314 } 325 }
315 } 326 }
316 serverSelected( 0 ); 327 serverSelected( 0 );
317 328
318 // Now set the check box of the selected package 329 // Now set the check box of the selected package
319 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 330 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
320 item != 0 ; 331 item != 0 ;
321 item = (QCheckListItem *)item->nextSibling() ) 332 item = (QCheckListItem *)item->nextSibling() )
322 { 333 {
323 if ( item->text().startsWith( package ) ) 334 if ( item->text().startsWith( package ) )
324 { 335 {
325 item->setOn( true ); 336 item->setOn( true );
326 break; 337 break;
327 } 338 }
328 } 339 }
329} 340}
@@ -533,52 +544,50 @@ void MainWindow :: updateProgress( int progress )
533} 544}
534 545
535void MainWindow :: updateData() 546void MainWindow :: updateData()
536{ 547{
537 m_progress->setTotalSteps( mgr->getServerList().count() ); 548 m_progress->setTotalSteps( mgr->getServerList().count() );
538 549
539 serversList->clear(); 550 serversList->clear();
540 packagesList->clear(); 551 packagesList->clear();
541 552
542 int activeItem = -1; 553 int activeItem = -1;
543 int i = 0; 554 int i = 0;
544 QString serverName; 555 QString serverName;
545 556
546 QListIterator<Server> it( mgr->getServerList() ); 557 QListIterator<Server> it( mgr->getServerList() );
547 Server *server; 558 Server *server;
548 559
549 for ( ; it.current(); ++it, ++i ) 560 for ( ; it.current(); ++it, ++i )
550 { 561 {
551 server = it.current(); 562 server = it.current();
552 serverName = server->getServerName(); 563 serverName = server->getServerName();
553 m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); 564 m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) );
554 m_progress->setProgress( i ); 565 m_progress->setProgress( i );
555 qApp->processEvents(); 566 qApp->processEvents();
556 567
557// cout << "Adding " << it->getServerName() << " to combobox" << endl;
558 if ( !server->isServerActive() ) 568 if ( !server->isServerActive() )
559 { 569 {
560// cout << serverName << " is not active" << endl;
561 i--; 570 i--;
562 continue; 571 continue;
563 } 572 }
564 573
565 serversList->insertItem( serverName ); 574 serversList->insertItem( serverName );
566 if ( serverName == currentlySelectedServer ) 575 if ( serverName == currentlySelectedServer )
567 activeItem = i; 576 activeItem = i;
568 } 577 }
569 578
570 // set selected server to be active server 579 // set selected server to be active server
571 if ( activeItem != -1 ) 580 if ( activeItem != -1 )
572 serversList->setCurrentItem( activeItem ); 581 serversList->setCurrentItem( activeItem );
573 serverSelected( 0, FALSE ); 582 serverSelected( 0, FALSE );
574} 583}
575 584
576void MainWindow :: serverSelected( int index ) 585void MainWindow :: serverSelected( int index )
577{ 586{
578 serverSelected( index, TRUE ); 587 serverSelected( index, TRUE );
579} 588}
580 589
581void MainWindow :: serverSelected( int, bool raiseProgress ) 590void MainWindow :: serverSelected( int, bool raiseProgress )
582{ 591{
583 QPixmap nullIcon( installedIcon.size() ); 592 QPixmap nullIcon( installedIcon.size() );
584 nullIcon.fill( colorGroup().base() ); 593 nullIcon.fill( colorGroup().base() );
@@ -692,65 +701,59 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
692 } 701 }
693 else if ( serverName == LOCAL_IPKGS ) 702 else if ( serverName == LOCAL_IPKGS )
694 { 703 {
695 downloadEnabled = FALSE; 704 downloadEnabled = FALSE;
696 actionUpgrade->setEnabled( FALSE ); 705 actionUpgrade->setEnabled( FALSE );
697 } 706 }
698 else 707 else
699 { 708 {
700 downloadEnabled = TRUE; 709 downloadEnabled = TRUE;
701 actionUpgrade->setEnabled( TRUE ); 710 actionUpgrade->setEnabled( TRUE );
702 } 711 }
703 enableDownload( downloadEnabled ); 712 enableDownload( downloadEnabled );
704 713
705 // Display this widget once everything is done 714 // Display this widget once everything is done
706 if ( doProgress && raiseProgress ) 715 if ( doProgress && raiseProgress )
707 { 716 {
708 stack->raiseWidget( networkPkgWindow ); 717 stack->raiseWidget( networkPkgWindow );
709 } 718 }
710} 719}
711 720
712void MainWindow :: searchForPackage( const QString &text ) 721void MainWindow :: searchForPackage( const QString &text )
713{ 722{
714 if ( !text.isEmpty() ) 723 if ( !text.isEmpty() )
715 { 724 {
716// cout << "searching for " << text << endl;
717 // look through package list for text startng at current position 725 // look through package list for text startng at current position
718// vector<InstallData> workingPackages;
719 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 726 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
720// if ( start != 0 )
721// start = (QCheckListItem *)start->nextSibling();
722 727
723 if ( start == 0 ) 728 if ( start == 0 )
724 start = (QCheckListItem *)packagesList->firstChild(); 729 start = (QCheckListItem *)packagesList->firstChild();
725 730
726 for ( QCheckListItem *item = start; item != 0 ; 731 for ( QCheckListItem *item = start; item != 0 ;
727 item = (QCheckListItem *)item->nextSibling() ) 732 item = (QCheckListItem *)item->nextSibling() )
728 { 733 {
729// cout << "checking " << item->text().lower() << endl;
730 if ( item->text().lower().find( text ) != -1 ) 734 if ( item->text().lower().find( text ) != -1 )
731 { 735 {
732// cout << "matched " << item->text() << endl;
733 packagesList->ensureItemVisible( item ); 736 packagesList->ensureItemVisible( item );
734 packagesList->setCurrentItem( item ); 737 packagesList->setCurrentItem( item );
735 break; 738 break;
736 } 739 }
737 } 740 }
738 } 741 }
739} 742}
740 743
741void MainWindow :: updateServer() 744void MainWindow :: updateServer()
742{ 745{
743 QString serverName = serversList->currentText(); 746 QString serverName = serversList->currentText();
744 747
745 // Update the current server 748 // Update the current server
746 // Display dialog 749 // Display dialog
747 750
748 // Disable buttons to stop silly people clicking lots on them :) 751 // Disable buttons to stop silly people clicking lots on them :)
749 752
750 // First, write out ipkg_conf file so that ipkg can use it 753 // First, write out ipkg_conf file so that ipkg can use it
751 mgr->writeOutIpkgConf(); 754 mgr->writeOutIpkgConf();
752 755
753 Ipkg *ipkg = new Ipkg; 756 Ipkg *ipkg = new Ipkg;
754 ipkg->setOption( "update" ); 757 ipkg->setOption( "update" );
755 758
756 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), 759 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ),
@@ -992,50 +995,48 @@ InstallData *MainWindow :: dealWithItem( QCheckListItem *item )
992 if ( p->isPackageStoredLocally() ) 995 if ( p->isPackageStoredLocally() )
993 name = p->getFilename(); 996 name = p->getFilename();
994 997
995 QString option; 998 QString option;
996 QString dest = "root"; 999 QString dest = "root";
997 if ( !p->isInstalled() ) 1000 if ( !p->isInstalled() )
998 { 1001 {
999 InstallData *newitem = new InstallData(); 1002 InstallData *newitem = new InstallData();
1000 newitem->option = "I"; 1003 newitem->option = "I";
1001 newitem->packageName = name; 1004 newitem->packageName = name;
1002 return newitem; 1005 return newitem;
1003 } 1006 }
1004 else 1007 else
1005 { 1008 {
1006 InstallData *newitem = new InstallData(); 1009 InstallData *newitem = new InstallData();
1007 newitem->option = "D"; 1010 newitem->option = "D";
1008 if ( !p->isPackageStoredLocally() ) 1011 if ( !p->isPackageStoredLocally() )
1009 newitem->packageName = p->getInstalledPackageName(); 1012 newitem->packageName = p->getInstalledPackageName();
1010 else 1013 else
1011 newitem->packageName = name; 1014 newitem->packageName = name;
1012 1015
1013 if ( p->getInstalledTo() ) 1016 if ( p->getInstalledTo() )
1014 { 1017 {
1015 newitem->destination = p->getInstalledTo(); 1018 newitem->destination = p->getInstalledTo();
1016// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
1017// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
1018 } 1019 }
1019 else 1020 else
1020 { 1021 {
1021 newitem->destination = p->getLocalPackage()->getInstalledTo(); 1022 newitem->destination = p->getLocalPackage()->getInstalledTo();
1022 } 1023 }
1023 1024
1024 // Now see if version is newer or not 1025 // Now see if version is newer or not
1025 int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); 1026 int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
1026 1027
1027 // If the version requested is older and user selected a local ipk file, then reinstall the file 1028 // If the version requested is older and user selected a local ipk file, then reinstall the file
1028 if ( p->isPackageStoredLocally() && val == -1 ) 1029 if ( p->isPackageStoredLocally() && val == -1 )
1029 val = 0; 1030 val = 0;
1030 1031
1031 if ( val == -2 ) 1032 if ( val == -2 )
1032 { 1033 {
1033 // Error - should handle 1034 // Error - should handle
1034 } 1035 }
1035 else if ( val == -1 ) 1036 else if ( val == -1 )
1036 { 1037 {
1037 // Version available is older - remove only 1038 // Version available is older - remove only
1038 newitem->option = "D"; 1039 newitem->option = "D";
1039 } 1040 }
1040 else 1041 else
1041 { 1042 {