summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp9
-rw-r--r--noncore/settings/aqpkg/mainwin.h1
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp31
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.h1
4 files changed, 40 insertions, 2 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index 206d11c..9f19dfa 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -1,86 +1,95 @@
/***************************************************************************
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 <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
QPopupMenu *help = new QPopupMenu( this );
help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_H );
help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A );
QPopupMenu *settings = new QPopupMenu( this );
settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S );
// Create the main menu
QMenuBar *menu = menuBar(); //new QMenuBar( this );
menu->insertItem( "&Settings", settings );
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 );
+ cout << "Selecting package " << package << 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 :: displayAbout()
{
QMessageBox::about( this, "About AQPkg", VERSION_TEXT );
}
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h
index 2a182fc..a9e290c 100644
--- a/noncore/settings/aqpkg/mainwin.h
+++ b/noncore/settings/aqpkg/mainwin.h
@@ -1,47 +1,48 @@
/***************************************************************************
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;
QWidgetStack *stack;
NetworkPackageManager *networkPkgWindow;
public slots:
+ void setDocument( const QString &doc );
void displayHelp();
void displayAbout();
void displaySettings();
};
#endif
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index 6874ded..a374266 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -15,142 +15,169 @@
* *
***************************************************************************/
#include <fstream>
#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 "global.h"
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
initGui();
setupConnections();
- progressDlg = 0;
- timerId = startTimer( 100 );
+ updateData();
+// progressDlg = 0;
+// timerId = startTimer( 100 );
}
NetworkPackageManager::~NetworkPackageManager()
{
}
void NetworkPackageManager :: timerEvent ( QTimerEvent * )
{
killTimer( timerId );
// showProgressDialog();
// Add server names to listbox
updateData();
// progressDlg->hide();
}
void NetworkPackageManager :: updateData()
{
serversList->clear();
packagesList->clear();
vector<Server>::iterator it;
int activeItem = -1;
int i;
for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i )
{
if ( !it->isServerActive() )
{
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 List", 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()
{
diff --git a/noncore/settings/aqpkg/networkpkgmgr.h b/noncore/settings/aqpkg/networkpkgmgr.h
index fba8155..3c437b4 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.h
+++ b/noncore/settings/aqpkg/networkpkgmgr.h
@@ -1,77 +1,78 @@
/***************************************************************************
networkpkgmgr.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 NETWORKPKGMGR_H
#define NETWORKPKGMGR_H
#include <qlayout.h>
#include <qpushbutton.h>
#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();
private:
DataManager *dataMgr;
QComboBox *serversList;
QListView *packagesList;
QPushButton *update;
QPushButton *upgrade;
QPushButton *download;
QPushButton *apply;
ProgressDlg *progressDlg;
QString currentlySelectedServer;
bool showJumpTo;
int timerId;
void timerEvent ( QTimerEvent * );
void initGui();
void setupConnections();
void showProgressDialog( char *initialText );
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 );
};
#endif