summaryrefslogtreecommitdiff
path: root/noncore/settings/aqpkg/installdlgimpl.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/aqpkg/installdlgimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp58
1 files changed, 47 insertions, 11 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp
index 2bb8b4d..76d0a80 100644
--- a/noncore/settings/aqpkg/installdlgimpl.cpp
+++ b/noncore/settings/aqpkg/installdlgimpl.cpp
@@ -1,89 +1,94 @@
/***************************************************************************
installdlgimpl.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 <stdio.h>
+
+#include <opie/ofiledialog.h>
#ifdef QWS
#include <qpe/config.h>
+#include <qpe/fileselector.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include <qpe/storage.h>
#endif
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qdialog.h>
+#include <qfileinfo.h>
#include <qgroupbox.h>
#include <qmultilineedit.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include "datamgr.h"
#include "destination.h"
#include "instoptionsimpl.h"
#include "installdlgimpl.h"
#include "ipkg.h"
#include "utils.h"
#include "global.h"
enum {
MAXLINES = 100,
};
InstallDlgImpl::InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title )
: QWidget( 0, 0, 0 )
{
setCaption( title );
init( TRUE );
pIpkg = 0;
upgradePackages = false;
dataMgr = dataManager;
QString defaultDest = "root";
#ifdef QWS
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
defaultDest = cfg.readEntry( "dest", "root" );
// Grab flags - Turn MAKE_LINKS on by default (if no flags found)
flags = cfg.readNumEntry( "installFlags", 0 );
+ infoLevel = cfg.readNumEntry( "infoLevel", 1 );
#else
flags = 0;
#endif
// Output text is read only
output->setReadOnly( true );
// QFont f( "helvetica" );
// f.setPointSize( 10 );
// output->setFont( f );
// setup destination data
int defIndex = 0;
int i;
QListIterator<Destination> dit( dataMgr->getDestinationList() );
for ( i = 0; dit.current(); ++dit, ++i )
{
destination->insertItem( dit.current()->getDestinationName() );
if ( dit.current()->getDestinationName() == defaultDest )
defIndex = i;
}
destination->setCurrentItem( defIndex );
@@ -169,59 +174,87 @@ void InstallDlgImpl :: init( bool displayextrainfo )
destination = 0x0;
txtAvailableSpace = 0x0;
}
QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this );
GroupBox2->layout()->setSpacing( 0 );
GroupBox2->layout()->setMargin( 4 );
QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() );
output = new QMultiLineEdit( GroupBox2 );
GroupBox2Layout->addWidget( output );
layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 );
btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this );
layout->addWidget( btnInstall, 3, 0 );
connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) );
btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this );
layout->addWidget( btnOptions, 3, 1 );
connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) );
}
void InstallDlgImpl :: optionsSelected()
{
- InstallOptionsDlgImpl opt( flags, this, "Option", true );
- opt.exec();
-
- // set options selected from dialog
- flags = opt.getFlags();
+ if ( btnOptions->text() == tr( "Options" ) )
+ {
+ InstallOptionsDlgImpl opt( flags, infoLevel, this, "Option", true );
+ if ( opt.exec() == QDialog::Accepted )
+ {
+ // set options selected from dialog
+ flags = opt.getFlags();
+ infoLevel = opt.getInfoLevel();
#ifdef QWS
- Config cfg( "aqpkg" );
- cfg.setGroup( "settings" );
- cfg.writeEntry( "installFlags", flags );
+ Config cfg( "aqpkg" );
+ cfg.setGroup( "settings" );
+ cfg.writeEntry( "installFlags", flags );
+ cfg.writeEntry( "infoLevel", infoLevel );
#endif
+ }
+ }
+ else // Save output
+ {
+ QMap<QString, QStringList> map;
+ map.insert( tr( "All" ), QStringList() );
+ QStringList text;
+ text << "text/*";
+ map.insert(tr( "Text" ), text );
+ text << "*";
+ map.insert( tr( "All" ), text );
+
+ QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map );
+ if( !filename.isEmpty() )
+ {
+ QString currentFileName = QFileInfo( filename ).fileName();
+ DocLnk doc;
+ doc.setType( "text/plain" );
+ doc.setFile( filename );
+ doc.setName( currentFileName );
+ FileManager fm;
+ fm.saveFile( doc, output->text() );
+ }
+ }
}
void InstallDlgImpl :: installSelected()
{
if ( btnInstall->text() == tr( "Abort" ) )
{
if ( pIpkg )
{
displayText( tr( "\n**** User Clicked ABORT ***" ) );
pIpkg->abort();
displayText( tr( "**** Process Aborted ****" ) );
}
btnInstall->setText( tr( "Close" ) );
btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
return;
}
else if ( btnInstall->text() == tr( "Close" ) )
{
emit reloadData( this );
return;
}
// Disable buttons
@@ -251,91 +284,94 @@ void InstallDlgImpl :: installSelected()
// Save settings
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
cfg.writeEntry( "dest", dest );
#endif
pIpkg = new Ipkg;
connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
// First run through the remove list, then the install list then the upgrade list
pIpkg->setOption( "remove" );
QListIterator<InstallData> it( removeList );
InstallData *idata;
for ( ; it.current(); ++it )
{
idata = it.current();
pIpkg->setDestination( idata->destination->getDestinationName() );
pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
pIpkg->setPackage( idata->packageName );
int tmpFlags = flags;
if ( idata->destination->linkToRoot() )
tmpFlags |= MAKE_LINKS;
- pIpkg->setFlags( tmpFlags );
+ pIpkg->setFlags( tmpFlags, infoLevel );
pIpkg->runIpkg();
}
pIpkg->setOption( "install" );
pIpkg->setDestination( dest );
pIpkg->setDestinationDir( destDir );
- pIpkg->setFlags( instFlags );
+ pIpkg->setFlags( instFlags, infoLevel );
QListIterator<InstallData> it2( installList );
for ( ; it2.current(); ++it2 )
{
pIpkg->setPackage( it2.current()->packageName );
pIpkg->runIpkg();
}
flags |= FORCE_REINSTALL;
QListIterator<InstallData> it3( updateList );
for ( ; it3.current() ; ++it3 )
{
idata = it3.current();
if ( idata->option == "R" )
pIpkg->setOption( "reinstall" );
else
pIpkg->setOption( "upgrade" );
pIpkg->setDestination( idata->destination->getDestinationName() );
pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
pIpkg->setPackage( idata->packageName );
int tmpFlags = flags;
if ( idata->destination->linkToRoot() && idata->recreateLinks )
tmpFlags |= MAKE_LINKS;
- pIpkg->setFlags( tmpFlags );
+ pIpkg->setFlags( tmpFlags, infoLevel );
pIpkg->runIpkg();
}
delete pIpkg;
pIpkg = 0;
}
btnOptions->setEnabled( true );
// btnInstall->setEnabled( true );
btnInstall->setText( tr( "Close" ) );
btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
+
+ btnOptions->setText( tr( "Save output" ) );
+ btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
if ( destination && destination->currentText() != 0 && destination->currentText() != "" )
displayAvailableSpace( destination->currentText() );
}
void InstallDlgImpl :: displayText(const QString &text )
{
QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text );
/* Set a max line count for the QMultiLineEdit, as users have reported
* performance issues when line count gets extreme.
*/
if(output->numLines() >= MAXLINES)
output->removeLine(0);
output->setText( newtext );
output->setCursorPosition( output->numLines(), 0 );
}
void InstallDlgImpl :: displayAvailableSpace( const QString &text )
{
Destination *d = dataMgr->getDestination( text );
QString destDir = d->getDestinationPath();