summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp6
-rw-r--r--noncore/settings/aqpkg/package.cpp12
-rw-r--r--noncore/settings/aqpkg/settings.ui2
3 files changed, 17 insertions, 3 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index e8e2982..d9e62b6 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -99,404 +99,406 @@ void NetworkPackageManager :: updateData()
{
cout << it->getServerName() << " is not active" << endl;
i--;
continue;
}
serversList->insertItem( it->getServerName() );
if ( it->getServerName() == currentlySelectedServer )
activeItem = i;
}
// set selected server to be active server
if ( activeItem != -1 )
serversList->setCurrentItem( activeItem );
serverSelected( 0 );
}
void NetworkPackageManager :: selectLocalPackage( const QString &pkg )
{
// First select local server
for ( int i = 0 ; i < serversList->count() ; ++i )
{
if ( serversList->text( i ) == LOCAL_IPKGS )
{
serversList->setCurrentItem( i );
break;
}
}
serverSelected( 0 );
// Now set the check box of the selected package
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 ;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->text().startsWith( pkg ) )
{
item->setOn( true );
break;
}
}
}
void NetworkPackageManager :: initGui()
{
QLabel *l = new QLabel( "Servers", this );
serversList = new QComboBox( this );
packagesList = new QListView( this );
update = new QPushButton( "Refresh Lists", this );
download = new QPushButton( "Download", this );
upgrade = new QPushButton( "Upgrade", this );
apply = new QPushButton( "Apply", this );
QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" );
QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" );
hbox1->addWidget( l );
hbox1->addWidget( serversList );
QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" );
QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" );
if ( showJumpTo )
{
char text[2];
text[1] = '\0';
for ( int i = 0 ; i < 26 ; ++i )
{
text[0] = 'A' + i;
LetterPushButton *b = new LetterPushButton( text, this );
connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
if ( i < 13 )
hbox3->addWidget( b );
else
hbox4->addWidget( b );
}
}
vbox->addWidget( packagesList );
packagesList->addColumn( "Packages" );
QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" );
hbox2->addWidget( update );
hbox2->addWidget( download );
hbox2->addWidget( upgrade );
hbox2->addWidget( apply );
}
void NetworkPackageManager :: setupConnections()
{
connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int )));
connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) );
connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) );
connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) );
connect( update, SIGNAL(released()), this, SLOT(updateServer()) );
}
void NetworkPackageManager :: showProgressDialog( char *initialText )
{
if ( !progressDlg )
progressDlg = new ProgressDlg( this, "Progress", false );
progressDlg->setText( initialText );
progressDlg->show();
}
void NetworkPackageManager :: serverSelected( int )
{
packagesList->clear();
// display packages
QString serverName = serversList->currentText();
currentlySelectedServer = serverName;
#ifdef QWS
// read download directory from config file
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
cfg.writeEntry( "selectedServer", currentlySelectedServer );
#endif
Server *s = dataMgr->getServer( serverName );
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 = "";
if ( it->getLocalPackage() )
{
if ( it->getLocalPackage()->getInstalledTo() )
destName = it->getLocalPackage()->getInstalledTo()->getDestinationName();
}
else
{
if ( it->getInstalledTo() )
destName = it->getInstalledTo()->getDestinationName();
}
if ( destName != "" )
new QCheckListItem( item, QString( "Installed To - " ) + destName );
}
if ( !it->isPackageStoredLocally() )
+ {
new QCheckListItem( item, QString( "Description - " ) + it->getDescription() );
+ new QCheckListItem( item, QString( "Size - " ) + it->getPackageSize() );
+ new QCheckListItem( item, QString( "Section - " ) + it->getSection() );
+ }
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
// 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,
QMessageBox::Yes,
QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
0, this );
warn.adjustSize();
if ( warn.exec() == QMessageBox::Yes )
{
// First, write out ipkg_conf file so that ipkg can use it
dataMgr->writeOutIpkgConf();
// Now run upgrade
Ipkg ipkg;
ipkg.setOption( "upgrade" );
InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true );
dlg.showDlg();
// Reload data
dataMgr->reloadServerData();
serverSelected(-1);
}
}
void NetworkPackageManager :: downloadPackage()
{
bool doUpdate = true;
if ( download->text() == "Download" )
{
// See if any packages are selected
bool found = false;
if ( serversList->currentText() != LOCAL_SERVER )
{
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 && !found;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
found = true;
}
}
// If user selected some packages then download the and store the locally
// otherwise, display dialog asking user what package to download from an http server
// and whether to install it
if ( found )
downloadSelectedPackages();
else
downloadRemotePackage();
}
else if ( download->text() == "Remove" )
{
doUpdate = false;
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 ;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
{
QString name = item->text();
int pos = name.find( "*" );
name.truncate( pos );
// if (there is a (installed), remove it
pos = name.find( "(installed)" );
if ( pos > 0 )
name.truncate( pos - 1 );
Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name );
QString msgtext;
msgtext.sprintf( "Are you sure you wish to delete\n%s?", (const char *)p->getPackageName() );
if ( QMessageBox::information( this, "Are you sure?",
msgtext, "No", "Yes" ) == 1 )
{
doUpdate = true;
QFile f( p->getFilename() );
f.remove();
}
}
}
}
if ( doUpdate )
{
dataMgr->reloadServerData();
serverSelected( -1 );
}
}
void NetworkPackageManager :: downloadSelectedPackages()
{
// First, write out ipkg_conf file so that ipkg can use it
dataMgr->writeOutIpkgConf();
// Display dialog to user asking where to download the files to
bool ok = FALSE;
QString dir = "";
#ifdef QWS
// read download directory from config file
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
#endif
QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
if ( ok && !text.isEmpty() )
dir = text; // user entered something and pressed ok
else
return; // user entered nothing or pressed cancel
#ifdef QWS
// Store download directory in config file
cfg.writeEntry( "downloadDir", dir );
#endif
// Get starting directory
char initDir[PATH_MAX];
getcwd( initDir, PATH_MAX );
// Download each package
Ipkg ipkg;
connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
ipkg.setOption( "download" );
ipkg.setRuntimeDirectory( dir );
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 ;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
{
QString name = item->text();
int pos = name.find( "*" );
name.truncate( pos );
// if (there is a (installed), remove it
diff --git a/noncore/settings/aqpkg/package.cpp b/noncore/settings/aqpkg/package.cpp
index 526de5e..db3e927 100644
--- a/noncore/settings/aqpkg/package.cpp
+++ b/noncore/settings/aqpkg/package.cpp
@@ -1,124 +1,136 @@
/***************************************************************************
package.cpp - 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. *
* *
***************************************************************************/
#include "package.h"
#include "global.h"
Package::Package( QString &name )
{
packageName = name;
+
+ version = "N/A";
+ description = "N/A";
+ packageSize = "N/A";
+ section = "N/A";
+
localPackage = 0;
installed = false;
packageStoredLocally = false;
installedToRoot = false;
installed = false;
installedTo = 0;
}
Package::Package( char *name )
{
packageName = name;
+
+ version = "N/A";
+ description = "N/A";
+ packageSize = "N/A";
+ section = "N/A";
+
localPackage = 0;
installed = false;
packageStoredLocally = false;
installedToRoot = false;
installed = false;
installedTo = 0;
}
Package::~Package()
{
}
QString Package :: toString()
{
QString ret = "Package - " + getPackageName() +
"\n version - " + getVersion();
if ( localPackage )
ret += "\n inst version - " + localPackage->getVersion();
return ret;
}
void Package :: setStatus( const QString &s )
{
status = s;
if ( status.find( "installed" ) != -1 )
installed = true;
}
void Package :: setLocalPackage( Package *p )
{
localPackage = p;
if ( localPackage )
if ( localPackage->getVersion() != getVersion() )
differentVersionAvailable = true;
else
differentVersionAvailable = false;
}
void Package :: setVersion( const QString &v )
{
version = v;
if ( localPackage )
if ( localPackage->getVersion() != getVersion() )
differentVersionAvailable = true;
else
differentVersionAvailable = false;
}
void Package :: setPackageName( const QString &name )
{
packageName = name;
}
void Package :: setDescription( const QString &d )
{
description = d;
}
void Package :: setFilename( const QString &f )
{
filename = f;
}
QString Package :: getInstalledVersion()
{
if ( localPackage )
return localPackage->getVersion();
else
return getVersion();
}
QString Package :: getInstalledPackageName()
{
if ( localPackage )
return localPackage->getPackageName();
else
return getPackageName();
}
bool Package :: isInstalled()
{
return installed || ( localPackage && localPackage->isInstalled() );
}
diff --git a/noncore/settings/aqpkg/settings.ui b/noncore/settings/aqpkg/settings.ui
index c2db861..44e8fd9 100644
--- a/noncore/settings/aqpkg/settings.ui
+++ b/noncore/settings/aqpkg/settings.ui
@@ -290,361 +290,361 @@
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>Destinations</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Destinations</string>
</property>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer2_2</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</hbox>
</widget>
<widget row="2" column="0" >
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout5</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>newdestination</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>true</bool>
</property>
<property stdset="1">
<name>text</name>
<string>New</string>
</property>
<property stdset="1">
<name>autoDefault</name>
<bool>false</bool>
</property>
</widget>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>removedestination</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>true</bool>
</property>
<property stdset="1">
<name>text</name>
<string>Remove</string>
</property>
<property stdset="1">
<name>autoDefault</name>
<bool>false</bool>
</property>
</widget>
</hbox>
</widget>
<spacer row="0" column="0" >
<property>
<name>name</name>
<cstring>Spacer3</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget row="1" column="0" >
<class>QListBox</class>
<property stdset="1">
<name>name</name>
<cstring>destinations</cstring>
</property>
<property stdset="1">
<name>selectionMode</name>
<enum>Single</enum>
</property>
</widget>
<widget row="3" column="0" >
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout13</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="1" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel1_3_2_2</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>URL:</string>
</property>
</widget>
<widget row="3" column="1" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>btnChangeDest</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Change</string>
</property>
</widget>
<widget row="0" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>destinationname</cstring>
</property>
</widget>
<widget row="0" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel1_3_2</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Name:</string>
</property>
</widget>
<widget row="2" column="1" >
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>linkToRoot</cstring>
</property>
<property stdset="1">
<name>text</name>
- <string>LinkToRoot</string>
+ <string>Link To Root</string>
</property>
<property stdset="1">
<name>checked</name>
<bool>true</bool>
</property>
</widget>
<widget row="1" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>destinationurl</cstring>
</property>
</widget>
</grid>
</widget>
</grid>
</widget>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tab</cstring>
</property>
<attribute>
<name>title</name>
<string>General</string>
</attribute>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel1</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>20</x>
<y>30</y>
<width>150</width>
<height>20</height>
</rect>
</property>
<property stdset="1">
<name>text</name>
<string>(Will take effect on restart)</string>
</property>
</widget>
<widget>
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>jumpTo</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>17</x>
<y>14</y>
<width>150</width>
<height>20</height>
</rect>
</property>
<property stdset="1">
<name>text</name>
<string>Show Jump To Letters</string>
</property>
</widget>
</widget>
</widget>
</grid>
</widget>
<connections>
<connection>
<sender>newserver</sender>
<signal>clicked()</signal>
<receiver>Settings</receiver>
<slot>newServer()</slot>
</connection>
<connection>
<sender>removeserver</sender>
<signal>clicked()</signal>
<receiver>Settings</receiver>
<slot>removeServer()</slot>
</connection>
<connection>
<sender>newdestination</sender>
<signal>clicked()</signal>
<receiver>Settings</receiver>
<slot>newDestination()</slot>
</connection>
<connection>
<sender>removedestination</sender>
<signal>clicked()</signal>
<receiver>Settings</receiver>
<slot>removeDestination()</slot>
</connection>
<connection>
<sender>servers</sender>
<signal>highlighted(int)</signal>
<receiver>Settings</receiver>
<slot>editServer(int)</slot>
</connection>
<connection>
<sender>destinations</sender>
<signal>highlighted(int)</signal>
<receiver>Settings</receiver>
<slot>editDestination(int)</slot>
</connection>
<connection>
<sender>btnChangeServer</sender>
<signal>clicked()</signal>
<receiver>Settings</receiver>
<slot>changeServerDetails()</slot>
</connection>
<connection>
<sender>btnChangeDest</sender>
<signal>clicked()</signal>
<receiver>Settings</receiver>
<slot>changeDestinationDetails()</slot>
</connection>
<connection>
<sender>jumpTo</sender>
<signal>toggled(bool)</signal>
<receiver>Settings</receiver>
<slot>toggleJumpTo(bool)</slot>
</connection>
<slot access="public">activeServerChanged()</slot>
<slot access="public">changeDestinationDetails()</slot>
<slot access="public">changeServerDetails()</slot>
<slot access="public">createLinksToDest()</slot>
<slot access="public">destNameChanged(const QString&amp;)</slot>
<slot access="public">destUrlChanged(const QString&amp;)</slot>
<slot access="public">editDestination(int)</slot>
<slot access="public">editServer(int)</slot>
<slot access="public">installationSettingChange(int)</slot>
<slot access="public">installationSettingSetName(const QString &amp;)</slot>
<slot access="public">linkEnabled(bool)</slot>
<slot access="public">newDestination()</slot>
<slot access="public">newInstallationSetting()</slot>
<slot access="public">newServer()</slot>
<slot access="public">removeDestination()</slot>
<slot access="public">removeInstallationSetting()</slot>
<slot access="public">removeLinksToDest()</slot>
<slot access="public">removeServer()</slot>
<slot access="public">renameInstallationSetting()</slot>
<slot access="public">serverNameChanged(const QString&amp;)</slot>
<slot access="public">serverUrlChanged(const QString&amp;)</slot>
<slot access="public">toggleJumpTo(bool)</slot>
</connections>
<tabstops>
<tabstop>servers</tabstop>
<tabstop>newserver</tabstop>
<tabstop>removeserver</tabstop>
<tabstop>servername</tabstop>
<tabstop>serverurl</tabstop>
<tabstop>active</tabstop>
<tabstop>btnChangeServer</tabstop>
<tabstop>TabWidget</tabstop>
<tabstop>destinations</tabstop>
<tabstop>newdestination</tabstop>
<tabstop>removedestination</tabstop>
<tabstop>destinationname</tabstop>
<tabstop>destinationurl</tabstop>
<tabstop>linkToRoot</tabstop>
<tabstop>btnChangeDest</tabstop>
<tabstop>jumpTo</tabstop>
</tabstops>
</UI>