-rw-r--r-- | noncore/settings/aqpkg/aqpkg.pro | 9 | ||||
-rw-r--r-- | noncore/settings/aqpkg/categoryfilter.ui | 118 | ||||
-rw-r--r-- | noncore/settings/aqpkg/categoryfilterimpl.cpp | 71 | ||||
-rw-r--r-- | noncore/settings/aqpkg/categoryfilterimpl.h | 40 | ||||
-rw-r--r-- | noncore/settings/aqpkg/datamgr.cpp | 12 | ||||
-rw-r--r-- | noncore/settings/aqpkg/datamgr.h | 5 | ||||
-rw-r--r-- | noncore/settings/aqpkg/global.h | 160 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 395 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.h | 131 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 63 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.h | 4 | ||||
-rw-r--r-- | noncore/settings/aqpkg/package.h | 8 | ||||
-rw-r--r-- | noncore/settings/aqpkg/server.cpp | 21 | ||||
-rw-r--r-- | noncore/settings/aqpkg/server.h | 1 |
14 files changed, 696 insertions, 342 deletions
diff --git a/noncore/settings/aqpkg/aqpkg.pro b/noncore/settings/aqpkg/aqpkg.pro index 301f4f2..6cc5a23 100644 --- a/noncore/settings/aqpkg/aqpkg.pro +++ b/noncore/settings/aqpkg/aqpkg.pro @@ -1,44 +1,47 @@ TEMPLATE = app CONFIG = qt warn_on debug HEADERS = global.h \ mainwin.h \ datamgr.h \ settingsimpl.h \ ipkg.h \ networkpkgmgr.h \ package.h \ progressdlg.h \ installdlgimpl.h \ instoptionsimpl.h \ destination.h \ utils.h \ server.h \ helpwindow.h \ letterpushbutton.h \ - inputdlg.h + inputdlg.h \ + categoryfilterimpl.h SOURCES = mainwin.cpp \ datamgr.cpp \ mem.cpp \ settingsimpl.cpp \ ipkg.cpp \ networkpkgmgr.cpp \ main.cpp \ package.cpp \ progressdlg.cpp \ installdlgimpl.cpp \ instoptionsimpl.cpp \ destination.cpp \ utils.cpp \ server.cpp \ helpwindow.cpp \ letterpushbutton.cpp \ inputdlg.cpp \ - version.cpp + version.cpp \ + categoryfilterimpl.cpp INTERFACES = settings.ui \ install.ui \ - instoptions.ui + instoptions.ui \ + categoryfilter.ui TARGET = aqpkg INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lstdc++ DESTDIR = $(OPIEDIR)/bin diff --git a/noncore/settings/aqpkg/categoryfilter.ui b/noncore/settings/aqpkg/categoryfilter.ui new file mode 100644 index 0000000..3416243 --- a/dev/null +++ b/noncore/settings/aqpkg/categoryfilter.ui @@ -0,0 +1,118 @@ +<!DOCTYPE UI><UI> +<class>CategoryFilterDlg</class> +<widget> + <class>QDialog</class> + <property stdset="1"> + <name>name</name> + <cstring>CategoryFilterDlg</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>215</width> + <height>295</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>Category Filter</string> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget row="1" column="0" > + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout4</cstring> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget row="0" column="1" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>btnOK</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>&OK</string> + </property> + </widget> + <widget row="0" column="0" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>btnCancel</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>&Cancel</string> + </property> + </widget> + </grid> + </widget> + <widget row="0" column="0" > + <class>QGroupBox</class> + <property stdset="1"> + <name>name</name> + <cstring>GroupBox1</cstring> + </property> + <property stdset="1"> + <name>title</name> + <string>Select groups to show</string> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget row="0" column="0" > + <class>QListBox</class> + <property stdset="1"> + <name>name</name> + <cstring>lstCategories</cstring> + </property> + <property stdset="1"> + <name>selectionMode</name> + <enum>Multi</enum> + </property> + </widget> + </grid> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>btnCancel</sender> + <signal>clicked()</signal> + <receiver>CategoryFilterDlg</receiver> + <slot>reject()</slot> + </connection> + <connection> + <sender>btnOK</sender> + <signal>clicked()</signal> + <receiver>CategoryFilterDlg</receiver> + <slot>accept()</slot> + </connection> +</connections> +</UI> diff --git a/noncore/settings/aqpkg/categoryfilterimpl.cpp b/noncore/settings/aqpkg/categoryfilterimpl.cpp new file mode 100644 index 0000000..0746da6 --- a/dev/null +++ b/noncore/settings/aqpkg/categoryfilterimpl.cpp @@ -0,0 +1,71 @@ +/*************************************************************************** + categoryfilterimpl.cpp - description + ------------------- + begin : Sun Nov 17 2002 + copyright : (C) 2002 by Andy Qua + email : andy.qua@blueyonder.co.uk + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#include <iostream> +using namespace std; + +#include <qlistbox.h> +#include <qstring.h> + +#include "categoryfilterimpl.h" + +CategoryFilterImpl :: CategoryFilterImpl(const QString &categories, const QString &selectedCategories, QWidget *parent, const char *name ) + : CategoryFilterDlg(parent,name, true) +{ + // Split up categories and add them to the listbox + int start = 1; + + QString item; + int end; + do + { + end = categories.find( "#", start ); + item = categories.mid( start, end - start ); + if ( item != "" ) + { + lstCategories->insertItem( item ); + + if ( selectedCategories.find( "#" + item + "#" ) != -1 ) + lstCategories->setSelected( lstCategories->count()-1, true ); + } + + start = end + 1; + } while ( start < (int)categories.length() ); + + lstCategories->sort( true ); + + showMaximized(); +} + +CategoryFilterImpl :: ~CategoryFilterImpl() +{ +} + +QString CategoryFilterImpl :: getSelectedFilter() +{ + // Grab cetegories from listbox + QString ret = "#"; + + for ( int i = 0 ; i < (int)lstCategories->count() ; ++i ) + { + if ( lstCategories->isSelected( i ) ) + ret += lstCategories->text( i ) + "#"; + } + + if ( ret == "#" ) + ret = ""; + return ret; +} diff --git a/noncore/settings/aqpkg/categoryfilterimpl.h b/noncore/settings/aqpkg/categoryfilterimpl.h new file mode 100644 index 0000000..b6b4fd5 --- a/dev/null +++ b/noncore/settings/aqpkg/categoryfilterimpl.h @@ -0,0 +1,40 @@ +/*************************************************************************** + categoryfilterimpl.h - description + ------------------- + begin : Sun Nov 17 2002 + copyright : (C) 2002 by Andy Qua + email : andy.qua@blueyonder.co.uk + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef CATEGORYFILTERIMPL_H +#define CATEGORYFILTERIMPL_H + +#include <qwidget.h> +#include <qstring.h> + +#include "categoryfilter.h" + +/** + *@author Andy Qua + */ + +class CategoryFilterImpl : public CategoryFilterDlg +{ + Q_OBJECT +public: + CategoryFilterImpl(const QString &categories, const QString &selectedCategories, QWidget *parent=0, const char *name=0); + ~CategoryFilterImpl(); + + QString getSelectedFilter(); +}; + +#endif diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp index f342aff..1420242 100644 --- a/noncore/settings/aqpkg/datamgr.cpp +++ b/noncore/settings/aqpkg/datamgr.cpp @@ -7,51 +7,53 @@ ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include <fstream> #include <iostream> using namespace std; #ifdef QWS #include <qpe/config.h> #endif #include <stdio.h> #include "datamgr.h" #include "global.h" +QString DataManager::availableCategories = ""; DataManager::DataManager() { - activeServer = ""; + activeServer = ""; + availableCategories = "#"; } DataManager::~DataManager() { } Server *DataManager :: getServer( const char *name ) { Server *s = 0; vector<Server>::iterator it = serverList.begin(); while ( it != serverList.end() && s == 0 ) { if ( it->getServerName() == name ) s = &(*it); ++it; } return s; } Destination *DataManager :: getDestination( const char *name ) { Destination *d = 0; @@ -186,24 +188,32 @@ void DataManager :: writeOutIpkgConf() if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS ) { QString url = it->getServerUrl();; if ( !it->isServerActive() ) out << "#"; out << "src " << alias << " " << url << endl; } it++; } out << endl; // Write out destinations vector<Destination>::iterator it2 = destList.begin(); while ( it2 != destList.end() ) { out << "dest " << it2->getDestinationName() << " " << it2->getDestinationPath() << endl; it2++; } out.close(); } + + +void DataManager :: setAvailableCategories( QString section ) +{ + section = section.lower(); + if ( availableCategories.find( "#" + section + "#" ) == -1 ) + availableCategories += section + "#"; +} diff --git a/noncore/settings/aqpkg/datamgr.h b/noncore/settings/aqpkg/datamgr.h index 8c6fb0d..3a64d92 100644 --- a/noncore/settings/aqpkg/datamgr.h +++ b/noncore/settings/aqpkg/datamgr.h @@ -1,64 +1,69 @@ /*************************************************************************** datamgr.h - description ------------------- begin : Thu Aug 29 2002 copyright : (C) 2002 by Andy Qua email : andy.qua@blueyonder.co.uk ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef DATAMGR_H #define DATAMGR_H #include <map> using namespace std; +#include <qstring.h> + #include "server.h" #include "destination.h" #define LOCAL_SERVER "Installed Pkgs" #define LOCAL_IPKGS "local IPKG" /** *@author Andy Qua */ class DataManager { public: DataManager(); ~DataManager(); void setActiveServer( const QString &act ) { activeServer = act; } QString &getActiveServer( ) { return activeServer; } Server *getLocalServer() { return getServer( LOCAL_SERVER ); } vector<Server> &getServerList() { return serverList; } Server *getServer( const char *name ); vector<Destination> &getDestinationList() { return destList; } Destination *getDestination( const char *name ); void loadServers(); void reloadServerData( ); void writeOutIpkgConf(); + static QString getAvailableCategories() { return availableCategories; } + static void setAvailableCategories( QString section ); private: + static QString availableCategories; QString activeServer; vector<Server> serverList; vector<Destination> destList; }; #endif diff --git a/noncore/settings/aqpkg/global.h b/noncore/settings/aqpkg/global.h index e65e2a0..609e1e8 100644 --- a/noncore/settings/aqpkg/global.h +++ b/noncore/settings/aqpkg/global.h @@ -1,80 +1,80 @@ -/***************************************************************************
- global.h - description
- -------------------
- begin : Mon Aug 26 2002
- copyright : (C) 2002 by Andy Qua
- email : andy.qua@blueyonder.co.uk
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#ifndef __GLOBAL_H
-#define __GLOBAL_H
-
-#define VERSION_TEXT "AQPkg Version 1.0"
-
-// Uncomment the below line to run on a Linux box rather than a Zaurus
-// box this allows you to change where root is, and where to load config files from
-// #define X86
-
-// Sets up location of ipkg.conf and root directory
-#ifdef QWS
-
-#ifndef X86
-
-// Running QT/Embedded on an arm processor
-#define IPKG_CONF "/etc/ipkg.conf"
-#define ROOT "/"
-#define IPKG_DIR "/usr/lib/ipkg/"
-
-#else
-
-// Running QT/Embedded on a X86 linux box
-#define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf"
-#define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root"
-#define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data/"
-
-#endif
-
-#else
-
-// Running QT on a X86 linux box
-#define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf"
-#define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root"
-#define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data/"
-
-#endif
-
-
-// Uncomment the below line to turn on memory checking
-//#define _DEBUG 1
-
-#ifndef __MEMFILE_C
-#ifdef _DEBUG
-void * operator new(unsigned int size,const char *file, int line);
-void operator delete(void *p);
-#endif
-
-#ifdef _DEBUG
-#define DEBUG_NEW new(__FILE__, __LINE__)
-//#define DEBUG_NEW new
-#else
-#define DEBUG_NEW new
-#endif
-
-#define new DEBUG_NEW
-#endif
-
-
-void AddTrack(long addr, long asize, const char *fname, long lnum);
-void RemoveTrack(long addr);
-void DumpUnfreed();
-
-#endif
+/*************************************************************************** + global.h - description + ------------------- + begin : Mon Aug 26 2002 + copyright : (C) 2002 by Andy Qua + email : andy.qua@blueyonder.co.uk + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef __GLOBAL_H +#define __GLOBAL_H + +#define VERSION_TEXT "AQPkg Version 1.1" + +// Uncomment the below line to run on a Linux box rather than a Zaurus +// box this allows you to change where root is, and where to load config files from +// #define X86 + +// Sets up location of ipkg.conf and root directory +#ifdef QWS + +#ifndef X86 + +// Running QT/Embedded on an arm processor +#define IPKG_CONF "/etc/ipkg.conf" +#define ROOT "/" +#define IPKG_DIR "/usr/lib/ipkg/" + +#else + +// Running QT/Embedded on a X86 linux box +#define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf" +#define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root" +#define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data/" + +#endif + +#else + +// Running QT on a X86 linux box +#define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf" +#define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root" +#define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data/" + +#endif + + +// Uncomment the below line to turn on memory checking +//#define _DEBUG 1 + +#ifndef __MEMFILE_C +#ifdef _DEBUG +void * operator new(unsigned int size,const char *file, int line); +void operator delete(void *p); +#endif + +#ifdef _DEBUG +#define DEBUG_NEW new(__FILE__, __LINE__) +//#define DEBUG_NEW new +#else +#define DEBUG_NEW new +#endif + +#define new DEBUG_NEW +#endif + + +void AddTrack(long addr, long asize, const char *fname, long lnum); +void RemoveTrack(long addr); +void DumpUnfreed(); + +#endif diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 5ccd3c3..0141359 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp @@ -1,186 +1,209 @@ -/***************************************************************************
- mainwin.cpp - description
- -------------------
- begin : Mon Aug 26 13:32:30 BST 2002
- copyright : (C) 2002 by Andy Qua
- email : andy.qua@blueyonder.co.uk
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#include <iostream>
-
-#include <qmenubar.h>
-#include <qpopupmenu.h>
-#include <qmessagebox.h>
-
-#include "mainwin.h"
-#include "datamgr.h"
-#include "networkpkgmgr.h"
-#include "settingsimpl.h"
-#include "helpwindow.h"
-#include "utils.h"
-#include "global.h"
-
-MainWindow :: MainWindow( QWidget *p, char *name )
- : QMainWindow( p, name )
-{
-#ifdef QWS
- showMaximized();
-#endif
-
- setCaption( "AQPkg - Package Manager" );
-
- // Create our menu
- help = new QPopupMenu( this );
- help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_G );
- help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A );
-
- settings = new QPopupMenu( this );
- settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S );
-
- edit = new QPopupMenu( this );
- edit->insertItem( "&Find", this, SLOT(searchForPackage()), Qt::CTRL+Qt::Key_I );
- edit->insertItem( "Find &Next", this, SLOT(repeatSearchForPackage()), Qt::CTRL+Qt::Key_N );
-
- filter = new QPopupMenu( this );
- mnuShowUninstalledPkgsId = filter->insertItem( "Show &Uninstalled Packages", this, SLOT(filterUninstalledPackages()), Qt::CTRL+Qt::Key_U );
- mnuShowInstalledPkgsId = filter->insertItem( "Show In&stalled Packages", this, SLOT(filterInstalledPackages()), Qt::CTRL+Qt::Key_S );
- mnuShowUpgradedPkgsId = filter->insertItem( "Show U&pdated Packages", this, SLOT(filterUpgradedPackages()), Qt::CTRL+Qt::Key_P );
-
- // Create the main menu
- menu = menuBar(); //new QMenuBar( this );
- menu->insertItem( "&Settings", settings );
- menu->insertItem( "&Edit", edit );
- menu->insertItem( "&Filter", filter );
- menu->insertItem( "&Help", help );
-
- mgr = new DataManager();
- mgr->loadServers();
-
- stack = new QWidgetStack( this );
-
- networkPkgWindow = new NetworkPackageManager( mgr, stack );
- stack->addWidget( networkPkgWindow, 1 );
-
- setCentralWidget( stack );
- stack->raiseWidget( networkPkgWindow );
-}
-
-MainWindow :: ~MainWindow()
-{
- delete networkPkgWindow;
-}
-
-void MainWindow :: setDocument( const QString &doc )
-{
- // Remove path from package
- QString package = Utils::getPackageNameFromIpkFilename( doc );
- std::cout << "Selecting package " << package << std::endl;
- networkPkgWindow->selectLocalPackage( package );
-}
-
-void MainWindow :: displaySettings()
-{
- SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
- if ( dlg->showDlg( 0 ) )
- networkPkgWindow->updateData();
- delete dlg;
-}
-
-void MainWindow :: displayHelp()
-{
- HelpWindow *dlg = new HelpWindow( this );
- dlg->exec();
- delete dlg;
-}
-
-void MainWindow :: searchForPackage()
-{
- networkPkgWindow->searchForPackage( false );
-}
-
-void MainWindow :: repeatSearchForPackage()
-{
- networkPkgWindow->searchForPackage( true );
-}
-
-void MainWindow :: displayAbout()
-{
- QMessageBox::about( this, "About AQPkg", VERSION_TEXT );
-}
-
-
-void MainWindow :: filterUninstalledPackages()
-{
- bool val;
- if ( filter->isItemChecked( mnuShowUninstalledPkgsId ) )
- {
- val = false;
- filter->setItemChecked( mnuShowUninstalledPkgsId, false );
- }
- else
- {
- val = true;
- filter->setItemChecked( mnuShowUninstalledPkgsId, true );
- }
-
- filter->setItemChecked( mnuShowInstalledPkgsId, false );
- networkPkgWindow->showOnlyInstalledPackages( false );
- filter->setItemChecked( mnuShowUpgradedPkgsId, false );
- networkPkgWindow->showUpgradedPackages( false );
-
- networkPkgWindow->showOnlyUninstalledPackages( val );
-
-}
-
-void MainWindow :: filterInstalledPackages()
-{
- bool val;
- if ( filter->isItemChecked( mnuShowInstalledPkgsId ) )
- {
- val = false;
- filter->setItemChecked( mnuShowInstalledPkgsId, false );
- }
- else
- {
- val = true;
- filter->setItemChecked( mnuShowInstalledPkgsId, true );
- }
-
- filter->setItemChecked( mnuShowUninstalledPkgsId, false );
- networkPkgWindow->showOnlyUninstalledPackages( false );
- filter->setItemChecked( mnuShowUpgradedPkgsId, false );
- networkPkgWindow->showUpgradedPackages( false );
-
- networkPkgWindow->showOnlyInstalledPackages( val );
-}
-
-void MainWindow :: filterUpgradedPackages()
-{
- bool val;
- if ( filter->isItemChecked( mnuShowUpgradedPkgsId ) )
- {
- val = false;
- filter->setItemChecked( mnuShowUpgradedPkgsId, false );
- }
- else
- {
- val = true;
- filter->setItemChecked( mnuShowUpgradedPkgsId, true );
- }
-
- filter->setItemChecked( mnuShowUninstalledPkgsId, false );
- networkPkgWindow->showOnlyUninstalledPackages( false );
- filter->setItemChecked( mnuShowInstalledPkgsId, false );
- networkPkgWindow->showOnlyInstalledPackages( false );
-
- networkPkgWindow->showUpgradedPackages( val );
-}
+/*************************************************************************** + mainwin.cpp - description + ------------------- + begin : Mon Aug 26 13:32:30 BST 2002 + copyright : (C) 2002 by Andy Qua + email : andy.qua@blueyonder.co.uk + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include <iostream> + +#include <qmenubar.h> +#include <qpopupmenu.h> +#include <qmessagebox.h> + +#include "mainwin.h" +#include "datamgr.h" +#include "networkpkgmgr.h" +#include "settingsimpl.h" +#include "helpwindow.h" +#include "utils.h" +#include "global.h" + +MainWindow :: MainWindow( QWidget *p, char *name ) + : QMainWindow( p, name ) +{ +#ifdef QWS + showMaximized(); +#endif + + setCaption( "AQPkg - Package Manager" ); + + // Create our menu + help = new QPopupMenu( this ); + help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_G ); + help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A ); + + settings = new QPopupMenu( this ); + settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S ); + + edit = new QPopupMenu( this ); + edit->insertItem( "&Find", this, SLOT(searchForPackage()), Qt::CTRL+Qt::Key_I ); + edit->insertItem( "Find &Next", this, SLOT(repeatSearchForPackage()), Qt::CTRL+Qt::Key_N ); + + filter = new QPopupMenu( this ); + mnuShowUninstalledPkgsId = filter->insertItem( "Show &Uninstalled Packages", this, SLOT(filterUninstalledPackages()), Qt::CTRL+Qt::Key_U ); + mnuShowInstalledPkgsId = filter->insertItem( "Show In&stalled Packages", this, SLOT(filterInstalledPackages()), Qt::CTRL+Qt::Key_S ); + mnuShowUpgradedPkgsId = filter->insertItem( "Show U&pdated Packages", this, SLOT(filterUpgradedPackages()), Qt::CTRL+Qt::Key_P ); + filter->insertSeparator(); + mnuFilterByCategory = filter->insertItem( "Filter By &Category", this, SLOT(filterCategory()), Qt::CTRL+Qt::Key_C ); + mnuSetFilterCategory = filter->insertItem( "Set Filter C&ategory", this, SLOT(setFilterCategory()), Qt::CTRL+Qt::Key_A ); + + // Create the main menu + menu = menuBar(); //new QMenuBar( this ); + menu->insertItem( "&Settings", settings ); + menu->insertItem( "&Edit", edit ); + menu->insertItem( "&Filter", filter ); + menu->insertItem( "&Help", help ); + + mgr = new DataManager(); + mgr->loadServers(); + + stack = new QWidgetStack( this ); + + networkPkgWindow = new NetworkPackageManager( mgr, stack ); + stack->addWidget( networkPkgWindow, 1 ); + + setCentralWidget( stack ); + stack->raiseWidget( networkPkgWindow ); +} + +MainWindow :: ~MainWindow() +{ + delete networkPkgWindow; +} + +void MainWindow :: setDocument( const QString &doc ) +{ + // Remove path from package + QString package = Utils::getPackageNameFromIpkFilename( doc ); + std::cout << "Selecting package " << package << std::endl; + networkPkgWindow->selectLocalPackage( package ); +} + +void MainWindow :: displaySettings() +{ + SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); + if ( dlg->showDlg( 0 ) ) + networkPkgWindow->updateData(); + delete dlg; +} + +void MainWindow :: displayHelp() +{ + HelpWindow *dlg = new HelpWindow( this ); + dlg->exec(); + delete dlg; +} + +void MainWindow :: searchForPackage() +{ + networkPkgWindow->searchForPackage( false ); +} + +void MainWindow :: repeatSearchForPackage() +{ + networkPkgWindow->searchForPackage( true ); +} + +void MainWindow :: displayAbout() +{ + QMessageBox::about( this, "About AQPkg", VERSION_TEXT ); +} + + +void MainWindow :: filterUninstalledPackages() +{ + bool val; + if ( filter->isItemChecked( mnuShowUninstalledPkgsId ) ) + { + val = false; + filter->setItemChecked( mnuShowUninstalledPkgsId, false ); + } + else + { + val = true; + filter->setItemChecked( mnuShowUninstalledPkgsId, true ); + } + + filter->setItemChecked( mnuShowInstalledPkgsId, false ); + networkPkgWindow->showOnlyInstalledPackages( false ); + filter->setItemChecked( mnuShowUpgradedPkgsId, false ); + networkPkgWindow->showUpgradedPackages( false ); + + networkPkgWindow->showOnlyUninstalledPackages( val ); + +} + +void MainWindow :: filterInstalledPackages() +{ + bool val; + if ( filter->isItemChecked( mnuShowInstalledPkgsId ) ) + { + val = false; + filter->setItemChecked( mnuShowInstalledPkgsId, false ); + } + else + { + val = true; + filter->setItemChecked( mnuShowInstalledPkgsId, true ); + } + + filter->setItemChecked( mnuShowUninstalledPkgsId, false ); + networkPkgWindow->showOnlyUninstalledPackages( false ); + filter->setItemChecked( mnuShowUpgradedPkgsId, false ); + networkPkgWindow->showUpgradedPackages( false ); + + networkPkgWindow->showOnlyInstalledPackages( val ); +} + +void MainWindow :: filterUpgradedPackages() +{ + bool val; + if ( filter->isItemChecked( mnuShowUpgradedPkgsId ) ) + { + val = false; + filter->setItemChecked( mnuShowUpgradedPkgsId, false ); + } + else + { + val = true; + filter->setItemChecked( mnuShowUpgradedPkgsId, true ); + } + + filter->setItemChecked( mnuShowUninstalledPkgsId, false ); + networkPkgWindow->showOnlyUninstalledPackages( false ); + filter->setItemChecked( mnuShowInstalledPkgsId, false ); + networkPkgWindow->showOnlyInstalledPackages( false ); + + networkPkgWindow->showUpgradedPackages( val ); +} + +void MainWindow :: setFilterCategory() +{ + if ( networkPkgWindow->setFilterCategory( ) ) + filter->setItemChecked( mnuFilterByCategory, true ); +} + +void MainWindow :: filterCategory() +{ + if ( filter->isItemChecked( mnuFilterByCategory ) ) + { + networkPkgWindow->filterByCategory( false ); + filter->setItemChecked( mnuFilterByCategory, false ); + } + else + { + if ( networkPkgWindow->filterByCategory( true ) ) + filter->setItemChecked( mnuFilterByCategory, true ); + } +}
\ No newline at end of file diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h index 7b6e0ba..92aba4d 100644 --- a/noncore/settings/aqpkg/mainwin.h +++ b/noncore/settings/aqpkg/mainwin.h @@ -1,63 +1,68 @@ -/***************************************************************************
- mainwin.h - description
- -------------------
- begin : Mon Aug 26 13:32:30 BST 2002
- copyright : (C) 2002 by Andy Qua
- email : andy.qua@blueyonder.co.uk
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#ifndef MAINWIN_H
-#define MAINWIN_H
-
-#include <qmainwindow.h>
-#include <qwidgetstack.h>
-
-
-class NetworkPackageManager;
-class DataManager;
-
-class MainWindow :public QMainWindow
-{
- Q_OBJECT
-public:
-
- MainWindow( QWidget *p = 0, char *name = 0 );
- ~MainWindow();
-
-private:
- DataManager *mgr;
-
- QMenuBar *menu;
- QPopupMenu *help;
- QPopupMenu *settings;
- QPopupMenu *edit;
- QPopupMenu *filter;
- QWidgetStack *stack;
-
- NetworkPackageManager *networkPkgWindow;
-
- int mnuShowUninstalledPkgsId;
- int mnuShowInstalledPkgsId;
- int mnuShowUpgradedPkgsId;
-
-public slots:
- void setDocument( const QString &doc );
- void displayHelp();
- void searchForPackage();
- void repeatSearchForPackage();
- void displayAbout();
- void displaySettings();
- void filterUninstalledPackages();
- void filterInstalledPackages();
- void filterUpgradedPackages();
-};
-#endif
+/*************************************************************************** + mainwin.h - description + ------------------- + begin : Mon Aug 26 13:32:30 BST 2002 + copyright : (C) 2002 by Andy Qua + email : andy.qua@blueyonder.co.uk + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef MAINWIN_H +#define MAINWIN_H + +#include <qmainwindow.h> +#include <qwidgetstack.h> + + +class NetworkPackageManager; +class DataManager; + +class MainWindow :public QMainWindow +{ + Q_OBJECT +public: + + MainWindow( QWidget *p = 0, char *name = 0 ); + ~MainWindow(); + +private: + DataManager *mgr; + + QMenuBar *menu; + QPopupMenu *help; + QPopupMenu *settings; + QPopupMenu *edit; + QPopupMenu *filter; + QWidgetStack *stack; + + NetworkPackageManager *networkPkgWindow; + + int mnuShowUninstalledPkgsId; + int mnuShowInstalledPkgsId; + int mnuShowUpgradedPkgsId; + int mnuFilterByCategory; + int mnuSetFilterCategory; + +public slots: + void setDocument( const QString &doc ); + void displayHelp(); + void searchForPackage(); + void repeatSearchForPackage(); + void displayAbout(); + void displaySettings(); + void filterUninstalledPackages(); + void filterInstalledPackages(); + void filterUpgradedPackages(); + void filterCategory(); + void setFilterCategory(); + +}; +#endif diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index 188f90d..0814121 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp @@ -19,71 +19,72 @@ #include <iostream> using namespace std; #include <unistd.h> #include <stdlib.h> #include <linux/limits.h> #ifdef QWS #include <qpe/qpeapplication.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/config.h> #else #include <qapplication.h> #endif #include <qlabel.h> #include <qfile.h> #include <qmessagebox.h> #include "datamgr.h" #include "networkpkgmgr.h" #include "installdlgimpl.h" #include "ipkg.h" #include "inputdlg.h" #include "letterpushbutton.h" +#include "categoryfilterimpl.h" #include "global.h" extern int compareVersions( const char *v1, const char *v2 ); NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) : QWidget(parent, name) { dataMgr = dataManager; #ifdef QWS // read download directory from config file Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); #endif showUninstalledPkgs = false; showInstalledPkgs = false; showUpgradedPkgs = false; - + categoryFilterEnabled = false; initGui(); setupConnections(); updateData(); } NetworkPackageManager::~NetworkPackageManager() { } void NetworkPackageManager :: timerEvent ( QTimerEvent * ) { killTimer( timerId ); // Add server names to listbox updateData(); } void NetworkPackageManager :: updateData() { serversList->clear(); packagesList->clear(); @@ -218,48 +219,55 @@ void NetworkPackageManager :: serverSelected( int ) vector<Package> &list = s->getPackageList(); vector<Package>::iterator it; for ( it = list.begin() ; it != list.end() ; ++it ) { QString text = ""; // Apply show only uninstalled packages filter if ( showUninstalledPkgs && it->isInstalled() ) continue; // Apply show only installed packages filter if ( showInstalledPkgs && !it->isInstalled() ) continue; // Apply show only new installed packages filter if ( showUpgradedPkgs ) { if ( !it->isInstalled() || compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) continue; } + // Apply the section filter + if ( categoryFilterEnabled && categoryFilter != "" ) + { + if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 ) + continue; + } + // If the local server, only display installed packages if ( serverName == LOCAL_SERVER && !it->isInstalled() ) continue; text += it->getPackageName(); if ( it->isInstalled() ) { text += " (installed)"; // If a different version of package is available, postfix it with an * if ( it->getVersion() != it->getInstalledVersion() ) { if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) text += "*"; } } QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); if ( it->isInstalled() ) { QString destName = ""; @@ -274,82 +282,81 @@ void NetworkPackageManager :: serverSelected( int ) destName = it->getInstalledTo()->getDestinationName(); } if ( destName != "" ) new QCheckListItem( item, QString( "Installed To - " ) + destName ); } if ( !it->isPackageStoredLocally() ) new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); else new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); if ( serverName == LOCAL_SERVER ) { new QCheckListItem( item, QString( "V. Installed - " ) + it->getVersion() ); } else { new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); if ( it->getLocalPackage() ) { if ( it->isInstalled() ) new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); } } + + new QCheckListItem( item, QString( "Size - " ) + it->getPackageSize() ); + new QCheckListItem( item, QString( "Section - " ) + it->getSection() ); packagesList->insertItem( item ); } // If the local server or the local ipkgs server disable the download button if ( serverName == LOCAL_SERVER ) { upgrade->setEnabled( false ); download->setText( "Download" ); download->setEnabled( true ); } else if ( serverName == LOCAL_IPKGS ) { upgrade->setEnabled( false ); download->setEnabled( true ); download->setText( "Remove" ); } else { upgrade->setEnabled( true ); download->setEnabled( true ); download->setText( "Download" ); } } void NetworkPackageManager :: updateServer() { QString serverName = serversList->currentText(); // Update the current server // Display dialog -// ProgressDlg *progDlg = new ProgressDlg( this ); -// QString status = "Updating package lists..."; -// progDlg->show(); -// progDlg->setText( status ); // Disable buttons to stop silly people clicking lots on them :) // First, write out ipkg_conf file so that ipkg can use it dataMgr->writeOutIpkgConf(); Ipkg ipkg; ipkg.setOption( "update" ); InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true ); dlg.showDlg(); // Reload data dataMgr->reloadServerData(); serverSelected(-1); // delete progDlg; } void NetworkPackageManager :: upgradePackages() { // We're gonna do an upgrade of all packages // First warn user that this isn't recommended QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; QMessageBox warn("Warning", text, QMessageBox::Warning, @@ -665,49 +672,49 @@ InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) caption = "Do you wish to remove or reinstall\n%s?"; text = "Remove or ReInstall"; secondButton = "ReInstall"; secondOption = "R"; } else if ( val == 1 ) { // Version available is newer - option to remove or upgrade caption = "Do you wish to remove or upgrade\n%s?"; text = "Remove or Upgrade"; secondButton = "Upgrade"; secondOption = "U"; } // Sticky option not implemented yet, but will eventually allow // the user to say something like 'remove all' if ( stickyOption == "" ) { QString msgtext; msgtext.sprintf( caption, (const char *)name ); switch( QMessageBox::information( this, text, msgtext, "Remove", secondButton ) ) { case 0: // Try again or Enter - // option 0 = Remove + // option 0 = Remove item.option = "D"; break; case 1: // Quit or Escape item.option = secondOption; break; } } else { // item.option = stickyOption; } } // Check if we are reinstalling the same version if ( item.option != "R" ) item.recreateLinks = true; else item.recreateLinks = false; // User hit cancel (on dlg - assume remove) return item; } } @@ -722,49 +729,49 @@ void NetworkPackageManager :: letterPushed( QString t ) { QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); if ( packagesList->firstChild() == 0 ) return; QCheckListItem *item; if ( start == 0 ) { item = (QCheckListItem *)packagesList->firstChild(); start = top; } else item = (QCheckListItem *)start->nextSibling(); if ( item == 0 ) item = (QCheckListItem *)packagesList->firstChild(); do { if ( item->text().lower().startsWith( t.lower() ) ) { packagesList->setSelected( item, true ); packagesList->ensureItemVisible( item ); break; - } + } item = (QCheckListItem *)item->nextSibling(); if ( !item ) item = (QCheckListItem *)packagesList->firstChild(); } while ( item != start); } void NetworkPackageManager :: searchForPackage( bool findNext ) { bool ok = false; if ( !findNext || lastSearchText.isEmpty() ) lastSearchText = InputDialog::getText( "Search for package", "Enter package to search for", lastSearchText, &ok, this ).lower(); else ok = true; if ( ok && !lastSearchText.isEmpty() ) { cout << "searching for " << lastSearchText << endl; // look through package list for text startng at current position vector<InstallData> workingPackages; QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); if ( start != 0 ) start = (QCheckListItem *)start->nextSibling(); @@ -783,24 +790,66 @@ void NetworkPackageManager :: searchForPackage( bool findNext ) packagesList->setCurrentItem( item ); break; } } } } void NetworkPackageManager :: showOnlyUninstalledPackages( bool val ) { showUninstalledPkgs = val; serverSelected( -1 ); } void NetworkPackageManager :: showOnlyInstalledPackages( bool val ) { showInstalledPkgs = val; serverSelected( -1 ); } void NetworkPackageManager :: showUpgradedPackages( bool val ) { showUpgradedPkgs = val; serverSelected( -1 ); } + +bool NetworkPackageManager :: filterByCategory( bool val ) +{ + if ( val ) + { + if ( categoryFilter == "" ) + { + if ( !setFilterCategory() ) + return false; + } + + categoryFilterEnabled = true; + serverSelected( -1 ); + return true; + } + else + { + // Turn off filter + categoryFilterEnabled = false; + serverSelected( -1 ); + return false; + } +} + +bool NetworkPackageManager :: setFilterCategory( ) +{ + // Get categories; + CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); + if ( dlg.exec() == QDialog::Accepted ) + { + categoryFilter = dlg.getSelectedFilter(); + + if ( categoryFilter == "" ) + return false; + + categoryFilterEnabled = true; + serverSelected( -1 ); + return true; + } + + return false; +} diff --git a/noncore/settings/aqpkg/networkpkgmgr.h b/noncore/settings/aqpkg/networkpkgmgr.h index 937c9b4..46919d7 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.h +++ b/noncore/settings/aqpkg/networkpkgmgr.h @@ -23,63 +23,67 @@ #include <qwidget.h> #include <qcombobox.h> #include <qlistview.h> #include "datamgr.h" #include "progressdlg.h" class InstallData; /** NetworkPackageManager is the base class of the project */ class NetworkPackageManager : public QWidget { Q_OBJECT public: /** construtor */ NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0); /** destructor */ ~NetworkPackageManager(); void selectLocalPackage( const QString &pkg ); void updateData(); void searchForPackage( bool findNext ); void showOnlyUninstalledPackages( bool val ); void showOnlyInstalledPackages( bool val ); void showUpgradedPackages( bool val ); + bool filterByCategory( bool val ); + bool setFilterCategory(); private: DataManager *dataMgr; QComboBox *serversList; QListView *packagesList; QPushButton *update; QPushButton *upgrade; QPushButton *download; QPushButton *apply; ProgressDlg *progressDlg; QString currentlySelectedServer; QString lastSearchText; + QString categoryFilter; + bool categoryFilterEnabled; bool showJumpTo; bool showUninstalledPkgs; bool showInstalledPkgs; bool showUpgradedPkgs; int timerId; void timerEvent ( QTimerEvent * ); void initGui(); void setupConnections(); void showProgressDialog( char *initialText ); void downloadSelectedPackages(); void downloadRemotePackage(); InstallData dealWithItem( QCheckListItem *item ); QString stickyOption; public slots: void serverSelected( int index ); void applyChanges(); void upgradePackages(); void downloadPackage(); void updateServer(); void displayText( const QString &t ); void letterPushed( QString t ); diff --git a/noncore/settings/aqpkg/package.h b/noncore/settings/aqpkg/package.h index 56ef874..7545818 100644 --- a/noncore/settings/aqpkg/package.h +++ b/noncore/settings/aqpkg/package.h @@ -23,61 +23,67 @@ /** *@author Andy Qua */ #include <qstring.h> #include "destination.h" class Package { public: Package( QString &name ); Package( char *name ); ~Package(); void setLocalPackage( Package *p ); void setPackageName( QString &name ); void setVersion( QString &v ); void setStatus( QString &s ); void setDescription( QString &d ); void setFilename( QString &f ); void setPackageStoredLocally( bool local ) { packageStoredLocally = local; } void setInstalledToRoot( bool root ) { installedToRoot = root; } void setInstalledTo( Destination *d ) { installedTo = d; } void setDependancies( QString &deps ) { dependancies = deps; } + void setPackageSize( QString size ) { packageSize = size; } + void setSection( QString sect) { section = sect; } Package *getLocalPackage() { return localPackage; } QString getPackageName() { return packageName; } QString getVersion() { return version; } QString getStatus() { return status; } QString getDescription() { return description; } - QString getFilename() { return filename; } + QString getFilename() { return filename; } QString getDependancies() { return dependancies; } + QString getPackageSize() { return packageSize; } + QString getSection() { return section; } bool isInstalled(); bool isPackageStoredLocally() { return packageStoredLocally; } bool isInstalledToRoot() { return installedToRoot; } QString getInstalledVersion(); QString getInstalledPackageName(); Destination *getInstalledTo() { return installedTo; } QString toString(); private: Package *localPackage; QString packageName; QString version; QString status; QString description; QString filename; bool packageStoredLocally; bool installedToRoot; bool installed; bool differentVersionAvailable; QString dependancies; + QString packageSize; + QString section; Destination *installedTo; }; #endif diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp index 539ebf0..7c3257b 100644 --- a/noncore/settings/aqpkg/server.cpp +++ b/noncore/settings/aqpkg/server.cpp @@ -7,48 +7,49 @@ description : This class holds details about a server : e.g. all the packages that contained on the server : the installation status ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <iostream> #include <fstream> using namespace std; #include "server.h" +#include "datamgr.h" #ifdef QWS #include <qpe/global.h> #include <qpe/applnk.h> #include <qlist.h> #endif #include "utils.h" #include "global.h" Server :: Server( const char *name, const char *url ) { serverName = name; serverUrl = url; packageFile = IPKG_DIR; packageFile += "lists/" + serverName; } Server :: ~Server() { cleanUp(); } @@ -189,49 +190,61 @@ void Server :: readPackageFile( Server *local, bool clearAll, bool installingToR { if (currPackage->getStatus().find( "deinstall" ) != -1 ) currPackage->setInstalledTo( dest ); } } else if ( key == "Version" ) { if ( currPackage ) currPackage->setVersion( value ); } else if ( key == "Status" ) { if ( currPackage ) currPackage->setStatus( value ); } else if ( key == "Description" ) { if ( currPackage ) currPackage->setDescription( value ); } else if ( key == "Filename" ) { if ( currPackage ) currPackage->setFilename( value ); - } + } + else if ( key == "Size" ) + { + if ( currPackage ) + currPackage->setPackageSize( value ); + } + else if ( key == "Section" ) + { + if ( currPackage ) + currPackage->setSection( value ); + + DataManager::setAvailableCategories( value ); + } else if ( key == "" ) { newPackage = true; } } while ( !in.eof() ); in.close(); // build local packages buildLocalPackages( local ); } void Server :: buildLocalPackages( Server *local ) { for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) { QString name = packageList[i].getPackageName(); // If the package name is an ipk name, then convert the filename to a package name if ( name.find( ".ipk" ) != -1 ) name = Utils::getPackageNameFromIpkFilename( packageList[i].getFilename() ); if ( local ) packageList[i].setLocalPackage( local->getPackage( name ) ); @@ -249,31 +262,37 @@ Package *Server :: getPackage( QString &name ) Package *Server :: getPackage( const char *name ) { Package *ret = 0; for ( unsigned int i = 0 ; i < packageList.size() && ret == 0; ++i ) { if ( packageList[i].getPackageName() == name ) ret = &packageList[i]; } return ret; } QString Server :: toString() { QString ret = "Server\n name - " + serverName + "\n url - " + serverUrl + "\n"; for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) ret += "\n " + packageList[i].toString(); return ret; +} /* +void addAvailableSection( QString section ) +{ + if ( DataManager::availableCategories.find( value ) == -1 ) +// DataManager::availableCategories += "#" + value; } +*/ vector<Package> &Server::getPackageList() { return packageList; } diff --git a/noncore/settings/aqpkg/server.h b/noncore/settings/aqpkg/server.h index e9f434c..f585b8f 100644 --- a/noncore/settings/aqpkg/server.h +++ b/noncore/settings/aqpkg/server.h @@ -38,28 +38,29 @@ public: void readStatusFile( vector<Destination> &v ); void readLocalIpks( Server *local ); void readPackageFile( Server *local = 0, bool clearAll = true, bool installedToRoot= false, Destination *dest = 0 ); void buildLocalPackages( Server *local ); Package *getPackage( const char *name ); Package *getPackage( QString &name ); QString toString(); vector<Package> &getPackageList(); bool isServerActive() { return active; } void setServerName( const QString &name ) { serverName = name; } void setServerUrl( const QString &url ) { serverUrl = url; } void setActive( bool val ) { active = val; } QString &getServerName() { return serverName; } QString &getServerUrl() { return serverUrl; } protected: private: QString serverName; QString serverUrl; QString packageFile; bool active; + vector<Package> packageList; }; #endif |