-rw-r--r-- | noncore/unsupported/oipkg/mainwindow.cpp | 5 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelistitem.cpp | 1 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pksettings.cpp | 114 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pksettings.h | 10 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pksettingsbase.ui | 138 |
5 files changed, 64 insertions, 204 deletions
diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp index 11fc91b..04362d3 100644 --- a/noncore/unsupported/oipkg/mainwindow.cpp +++ b/noncore/unsupported/oipkg/mainwindow.cpp @@ -3,322 +3,321 @@ * 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. * * * ***************************************************************************/ // Copyright (C) 2000 Trolltech AS. // adadpted form qpe/qipkg // (c) 2002 Patrick S. Vogt <tille@handhelds.org> #include "mainwindow.h" #include <qpe/qpemenubar.h> #include <qpe/qpemessagebox.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/qpetoolbar.h> #include <qpe/qcopenvelope_qws.h> #include <qaction.h> #include <qmessagebox.h> #include <qpopupmenu.h> #include <qtoolbutton.h> #include <qstring.h> #include <qlabel.h> #include <qfile.h> #include <qlistview.h> #include <qtextview.h> #include <qcheckbox.h> #include <qlineedit.h> #include <qtabwidget.h> #include <qcombobox.h> #include <qmessagebox.h> #include <qpushbutton.h> #include <qlayout.h> #include "pksettingsbase.h" #include "utils.h" #include "packagelistitem.h" MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : QMainWindow( parent, name, f ) // packageListServers( QObject(parent), name ), // packageListSearch( parent, name ), // packageListDocLnk( parent, name ) { setCaption( tr("Package Manager") ); settings = new PackageManagerSettings(this,0,TRUE); listViewPackages = new PackageListView( this,"listViewPackages",settings ); setCentralWidget( listViewPackages ); listViewPackages->addList( tr("feeds"), &packageListServers ); listViewPackages->addList( tr("ipkgfind&killefiz"), &packageListSearch ); listViewPackages->addList( tr("documents"), &packageListDocLnk ); ipkg = new PmIpkg( settings, this ); packageListServers.setSettings( settings ); packageListSearch.setSettings( settings ); packageListDocLnk.setSettings( settings ); pvDebug(9,"packageListServers.update"); packageListServers.update(); pvDebug(9,"packageListDocLnk.update"); packageListDocLnk.update(); pvDebug(9,"makeMenu"); makeMenu(); makeChannel(); connect( section, SIGNAL(activated(int)), SLOT(sectionChanged()) ); connect( subsection, SIGNAL(activated(int)), SLOT(subSectionChanged()) ); connect( settings->removeLinksButton, SIGNAL( clicked()), SLOT(removeLinks()) ); connect( settings->createLinksButton, SIGNAL( clicked()), SLOT(createLinks()) ); pvDebug(9,"displayList"); displayList(); } void MainWindow::makeMenu() { QPEToolBar *toolBar = new QPEToolBar( this ); QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); QPopupMenu *srvMenu = new QPopupMenu( menuBar ); QPopupMenu *viewMenu = new QPopupMenu( menuBar ); QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); QPopupMenu *helpMenu = new QPopupMenu( menuBar ); setToolBarsMovable( false ); toolBar->setHorizontalStretchable( true ); menuBar->insertItem( tr( "Package" ), srvMenu ); menuBar->insertItem( tr( "View" ), viewMenu ); menuBar->insertItem( tr( "Settings" ), cfgMenu ); menuBar->insertItem( tr( "Help" ), helpMenu ); - QLabel *spacer; +// QLabel *spacer; // spacer = new QLabel( "", toolBar ); // spacer->setBackgroundColor( toolBar->backgroundColor() ); // toolBar->setStretchableWidget( spacer ); runAction = new QAction( tr( "Apply" ), Resource::loadPixmap( "oipkg/install" ), QString::null, 0, this, 0 ); connect( runAction, SIGNAL( activated() ), this, SLOT( runIpkg() ) ); runAction->addTo( toolBar ); runAction->addTo( srvMenu ); srvMenu->insertSeparator(); updateAction = new QAction( tr( "Update" ), Resource::loadIconSet( "oipkg/update" ), QString::null, 0, this, 0 ); connect( updateAction, SIGNAL( activated() ), this , SLOT( updateList() ) ); updateAction->addTo( toolBar ); updateAction->addTo( srvMenu ); QAction *cfgact; cfgact = new QAction( tr( "Setups" ), QString::null, 0, this, 0 ); connect( cfgact, SIGNAL( activated() ), SLOT( showSettingsSetup() ) ); cfgact->addTo( cfgMenu ); cfgact = new QAction( tr( "Servers" ), QString::null, 0, this, 0 ); connect( cfgact, SIGNAL( activated() ), SLOT( showSettingsSrv() ) ); cfgact->addTo( cfgMenu ); cfgact = new QAction( tr( "Destinations" ), QString::null, 0, this, 0 ); connect( cfgact, SIGNAL( activated() ), SLOT( showSettingsDst() ) ); cfgact->addTo( cfgMenu ); QAction *a; // SECTIONS sectionBar = new QPEToolBar( this ); addToolBar( sectionBar, "Section", QMainWindow::Top, TRUE ); sectionBar->setHorizontalStretchable( true ); QLabel *label = new QLabel( sectionBar, "section" ); // label->setBackgroundMode( NoBackground ); label->font().setPointSize( 8 ); label->setText( tr( "Section:" ) ); sectionBar->setStretchableWidget( label ); section = new QComboBox( false, sectionBar ); section->font().setPointSize( 8 ); label = new QLabel( " / ", sectionBar ); label->font().setPointSize( 8 ); // label->setBackgroundMode( PaletteForeground ); subsection = new QComboBox( false, sectionBar ); subsection->font().setPointSize( 8 ); a = new QAction( tr( "Close Section" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( sectionClose() ) ); a->addTo( sectionBar ); setSections(); setSubSections(); sectionAction = new QAction( tr( "Sections" ), QString::null, 0, this, 0 ); connect( sectionAction, SIGNAL( toggled(bool) ), this, SLOT( sectionShow(bool) ) ); sectionAction->setToggleAction( true ); sectionAction->addTo( viewMenu ); // sectionBar->setStretchableWidget( section ); //FIND findBar = new QPEToolBar(this); addToolBar( findBar, "Filter", QMainWindow::Top, TRUE ); label = new QLabel( tr("Filter: "), findBar ); // label->setBackgroundMode( PaletteForeground ); findBar->setHorizontalStretchable( TRUE ); findEdit = new QLineEdit( findBar, "findEdit" ); findBar->setStretchableWidget( findEdit ); connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( displayList() ) ); a = new QAction( tr( "Clear Find" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), findEdit, SLOT( clear() ) ); a->addTo( findBar ); a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); a->addTo( findBar ); findAction = new QAction( tr( "Filter" ), QString::null, 0, this, 0 ); connect( findAction, SIGNAL( toggled(bool) ), this, SLOT( findShow(bool) ) ); findAction->setToggleAction( true ); findAction->addTo( viewMenu ); //SEARCH searchBar = new QPEToolBar(this); addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); label = new QLabel( tr("Search: "), searchBar ); // label->setBackgroundMode( PaletteForeground ); searchBar->setHorizontalStretchable( TRUE ); searchEdit = new QLineEdit( searchBar, "seachEdit" ); searchBar->setStretchableWidget( searchEdit ); // connect( searchEdit, SIGNAL( textChanged( const QString & ) ), // this, SLOT( displayList() ) ); a = new QAction( tr( "Clear Search" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), searchEdit, SLOT( clear() ) ); a->addTo( searchBar ); searchCommit = new QAction( tr( "Do Search" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); connect( searchCommit, SIGNAL( activated() ), SLOT( remotePackageQuery() ) ); searchCommit->addTo( searchBar ); a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( searchClose() ) ); a->addTo( searchBar ); searchAction = new QAction( tr( "Search" ), QString::null, 0, this, 0 ); connect( searchAction, SIGNAL( toggled(bool) ), this, SLOT( searchShow(bool) ) ); searchAction->setToggleAction( true ); searchAction->addTo( viewMenu ); //DEST destBar = new QPEToolBar(this); addToolBar( destBar, "Destination", QMainWindow::Top, TRUE ); label = new QLabel( tr("Destination: "), destBar ); // label->setBackgroundMode( PaletteForeground ); destBar->setHorizontalStretchable( TRUE ); destination = new QComboBox( false, destBar ); destination->insertStringList( settings->getDestinationNames() ); setComboName(destination,settings->getDestinationName()); connect( destination, SIGNAL(activated(int)), settings, SLOT(activeDestinationChange(int)) ); -// spacer = new QLabel( " ", destBar ); -// spacer->setBackgroundMode( PaletteForeground ); +// space->setBackgroundMode( PaletteForeground ); CheckBoxLink = new QCheckBox( tr("Link"), destBar); // CheckBoxLink->setBackgroundMode( PaletteForeground ); CheckBoxLink->setChecked( settings->createLinks() ); connect( CheckBoxLink, SIGNAL(toggled(bool)), settings, SLOT(linkEnabled(bool)) ); destAction = new QAction( tr( "Destinations" ), QString::null, 0, this, 0 ); connect( destAction, SIGNAL( toggled(bool) ), SLOT( destShow(bool) ) ); a = new QAction( tr( "Close Destinations" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), SLOT( destClose() ) ); a->addTo( destBar ); destBar->setStretchableWidget( CheckBoxLink ); destAction->setToggleAction( true ); destAction->addTo( viewMenu ); // helpMenu helpMenu->insertSeparator(); a = new QAction( tr( "Package Actions" ), QString::null, 0, this, 0 ); a->addTo( helpMenu ); helpMenu->insertSeparator(); a = new QAction( tr( "Install" ), Resource::loadPixmap( "oipkg/install" ), QString::null, 0, this, 0 ); a->addTo( helpMenu ); a = new QAction( tr( "Remove" ), Resource::loadPixmap( "oipkg/uninstall" ), QString::null, 0, this, 0 ); a->addTo( helpMenu ); helpMenu->insertSeparator(); a = new QAction( tr( "Package Status" ), QString::null, 0, this, 0 ); a->addTo( helpMenu ); helpMenu->insertSeparator(); a = new QAction( tr( "New version, installed" ), Resource::loadPixmap( "oipkg/installed" ), QString::null, 0, this, 0 ); a->addTo( helpMenu ); a = new QAction( tr( "New version, not installed" ), Resource::loadPixmap( "oipkg/uninstalled" ), QString::null, 0, this, 0 ); a->addTo( helpMenu ); a = new QAction( tr( "Old version, installed" ), Resource::loadPixmap( "oipkg/installedOld" ), QString::null, 0, this, 0 ); a->addTo( helpMenu ); a = new QAction( tr( "Old version, not installed" ), Resource::loadPixmap( "oipkg/uninstalledOld" ), QString::null, 0, this, 0 ); a->addTo( helpMenu ); a = new QAction( tr( "Old version, new version installed" ), Resource::loadPixmap( "oipkg/uninstalledOldinstalledNew" ), QString::null, 0, this, 0 ); a->addTo( helpMenu ); a = new QAction( tr( "New version, old version installed" ), Resource::loadPixmap( "oipkg/uninstalledInstalledOld" ), QString::null, 0, this, 0 ); a->addTo( helpMenu ); // a = new QAction( tr( "" ), // Resource::loadPixmap( "oipkg/" ), QString::null, 0, this, 0 ); // a->addTo( helpMenu ); // configure the menus Config cfg( "oipkg", Config::User ); cfg.setGroup( "gui" ); findShow( cfg.readBoolEntry( "findBar", true ) ); searchShow( cfg.readBoolEntry( "searchBar", true ) ); sectionShow( cfg.readBoolEntry( "sectionBar", true ) ); destShow( cfg.readBoolEntry( "destBar", false ) ); setComboName(section,cfg.readEntry("default_section")); sectionChanged(); } MainWindow::~MainWindow() { Config cfg( "oipkg", Config::User ); cfg.setGroup( "gui" ); cfg.writeEntry( "findBar", !findBar->isHidden() ); cfg.writeEntry( "searchBar", !searchBar->isHidden() ); cfg.writeEntry( "sectionBar", !sectionBar->isHidden() ); cfg.writeEntry( "destBar", !destBar->isHidden() ); cfg.writeEntry( "default_section", section->currentText() ); } void MainWindow::runIpkg() { packageListServers.allPackages(); ipkg->loadList( &packageListSearch ); ipkg->loadList( &packageListDocLnk ); ipkg->loadList( &packageListServers ); ipkg->commit(); ipkg->clearLists(); // ##### If we looked in the list of files, we could send out accurate // ##### messages. But we don't bother yet, and just do an "all". QCopEnvelope e("QPE/System", "linkChanged(QString)"); QString lf = QString::null; e << lf; displayList(); } void MainWindow::updateList() { packageListServers.clear(); packageListSearch.clear(); diff --git a/noncore/unsupported/oipkg/packagelistitem.cpp b/noncore/unsupported/oipkg/packagelistitem.cpp index b5e86f5..03bf477 100644 --- a/noncore/unsupported/oipkg/packagelistitem.cpp +++ b/noncore/unsupported/oipkg/packagelistitem.cpp @@ -19,157 +19,156 @@ static QPixmap *pm_uninstalled_old=0; static QPixmap *pm_installed=0; static QPixmap *pm_installed_old=0; static QPixmap *pm_uninstall=0; static QPixmap *pm_install=0; static QPixmap *pm_uninstalled_old_installed_new=0; static QPixmap *pm_uninstalled_installed_old=0; PackageListItem::PackageListItem(QListView* lv, Package *pi, PackageManagerSettings *s) : QCheckListItem(lv,pi->name(),CheckBox) { init(pi,s); } PackageListItem::PackageListItem(QListViewItem *lvi, Package *pi, PackageManagerSettings *s) : QCheckListItem(lvi,pi->name(),CheckBox) { init(pi,s); } void PackageListItem::init( Package *pi, PackageManagerSettings *s) { package = pi; settings = s; setExpandable( true ); QCheckListItem *item; nameItem = new QCheckListItem( this, "" ); item = new QCheckListItem( this, QObject::tr("Description: ")+pi->desc() ); item = new QCheckListItem( this, QObject::tr("Size: ")+pi->size() ); destItem = new QCheckListItem( this, "" ); linkItem = new QCheckListItem( this, "" ); statusItem = new QCheckListItem( this, "" ); QCheckListItem *otherItem = new QCheckListItem( this, QObject::tr("other") ); item = new QCheckListItem( otherItem, QObject::tr("Install Name: ")+pi->installName() ); QDict<QString> *fields = pi->getFields(); QDictIterator<QString> it( *fields ); while ( it.current() ) { item = new QCheckListItem( otherItem, QString(it.currentKey()+": "+*it.current()) ); ++it; } displayDetails(); if (!pm_uninstalled) { pm_uninstalled = new QPixmap(Resource::loadPixmap("oipkg/uninstalled")); pm_uninstalled_old = new QPixmap(Resource::loadPixmap("oipkg/uninstalledOld")); pm_uninstalled_old_installed_new = new QPixmap(Resource::loadPixmap("oipkg/uninstalledOldinstalledNew")); pm_uninstalled_installed_old = new QPixmap(Resource::loadPixmap("oipkg/uninstalledInstalledOld")); pm_installed = new QPixmap(Resource::loadPixmap("oipkg/installed")); pm_installed_old = new QPixmap(Resource::loadPixmap("oipkg/installedOld")); pm_install = new QPixmap(Resource::loadPixmap("oipkg/install")); pm_uninstall = new QPixmap(Resource::loadPixmap("oipkg/uninstall")); } } void PackageListItem::paintCell( QPainter *p, const QColorGroup & cg, int column, int width, int alignment ) { if ( !p ) return; p->fillRect( 0, 0, width, height(), isSelected()? cg.highlight() : cg.base() ); if ( column != 0 ) { // The rest is text QListViewItem::paintCell( p, cg, column, width, alignment ); return; } QListView *lv = listView(); if ( !lv ) return; int marg = lv->itemMargin(); int r = marg; QPixmap pm = statePixmap(); p->drawPixmap(marg,(height()-pm.height())/2,pm); r += pm.width()+1; p->translate( r, 0 ); QListViewItem::paintCell( p, cg, column, width - r, alignment ); } void PackageListItem::paintFocus( QPainter *p, const QColorGroup & cg, const QRect & r ) { // Skip QCheckListItem // (makes you wonder what we're getting from QCheckListItem) QListViewItem::paintFocus(p,cg,r); } QPixmap PackageListItem::statePixmap() const { bool installed = package->installed(); bool old = package->isOld(); - bool versions = package->hasVersions(); bool verinstalled = package->otherInstalled(); if ( !package->toProcess() ) { if ( !installed ) if (old) { if (verinstalled) return *pm_uninstalled_old_installed_new; else return *pm_uninstalled_old; } else { if (verinstalled) return *pm_uninstalled_installed_old; else return *pm_uninstalled; } else if (old) return *pm_installed_old; else return *pm_installed; } else { //toProcess() == true if ( !installed ) return *pm_install; else return *pm_uninstall; } } QString PackageListItem::key( int column, bool ascending ) const { if ( column == 2 ) { QString t = text(2); double bytes=t.toDouble(); if ( t.contains('M') ) bytes*=1024*1024; else if ( t.contains('K') || t.contains('k') ) bytes*=1024; if ( !ascending ) bytes=999999999-bytes; return QString().sprintf("%09d",(int)bytes); } else { return QListViewItem::key(column,ascending); } } void PackageListItem::setOn( bool b ) { QCheckListItem::setOn( b ); package->toggleProcess(); package->setLink( settings->createLinks() ); displayDetails(); } void PackageListItem::displayDetails() { QString sod; sod += package->sizeUnits().isEmpty()?QString(""):QString(package->sizeUnits()); //sod += QString(package->dest().isEmpty()?"":QObject::tr(" on ")+package->dest()); sod += package->dest().isEmpty()?QString(""):QString(QObject::tr(" on ")+package->dest()); sod = sod.isEmpty()?QString(""):QString(" ("+sod+")"); setText(0, package->name()+sod ); nameItem->setText( 0, QObject::tr("Name: ")+package->name()); linkItem->setText( 0, QObject::tr("Link: ")+(package->link()?QObject::tr("Yes"):QObject::tr("No"))); destItem->setText( 0, QObject::tr("Destination: ")+package->dest() ); statusItem->setText( 0, QObject::tr("Status: ")+package->status() ); repaint(); } diff --git a/noncore/unsupported/oipkg/pksettings.cpp b/noncore/unsupported/oipkg/pksettings.cpp index 14c1944..acabaed 100644 --- a/noncore/unsupported/oipkg/pksettings.cpp +++ b/noncore/unsupported/oipkg/pksettings.cpp @@ -1,451 +1,451 @@ #include "pksettings.h" #include <qpe/process.h> #include <qpe/resource.h> #include <qpe/stringutil.h> #include <qpe/qpeapplication.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/applnk.h> #include <qpe/config.h> #include <qprogressbar.h> #include <qcombobox.h> #include <qdict.h> #include <qfile.h> #include <qlineedit.h> #include <qpushbutton.h> #include <qlistview.h> #include <qlistbox.h> #include <qcheckbox.h> #include <qmessagebox.h> #include <qpainter.h> #include <qpixmap.h> #include <qregexp.h> #include <qstring.h> #include <qobject.h> #include <qtextstream.h> #include <qtextview.h> #include <qtoolbutton.h> #include <qtabwidget.h> #include <stdlib.h> #include <unistd.h> #include "debug.h" //#include "utils.h" PackageManagerSettings::PackageManagerSettings( QWidget* parent, const char* name, WFlags fl ) : PackageManagerSettingsBase( parent, name, fl ) { connect( newserver, SIGNAL(clicked()), this, SLOT(newServer()) ); connect( removeserver, SIGNAL(clicked()), this, SLOT(removeServer()) ); connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); connect( newdestination, SIGNAL(clicked()), this, SLOT(newDestination()) ); connect( removedestination, SIGNAL(clicked()), this, SLOT(removeDestination()) ); connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); // connect( CheckBoxLink, SIGNAL(toggled(bool)), // activeLinkDestination, SLOT(setEnabled(bool)) ); - connect( settingName, SIGNAL(activated(int)), this, SLOT(installationSettingChange(int)) ); - connect( settingName, SIGNAL(textChanged(const QString &)), this, SLOT(installationSettingSetName(const QString &)) ); - connect( newsetting, SIGNAL(clicked()), this, SLOT(newInstallationSetting()) ); - connect( renamesetting, SIGNAL(clicked()), this, SLOT(renameInstallationSetting()) ); - connect( removesetting, SIGNAL(clicked()), this, SLOT(removeInstallationSetting()) ); +// connect( settingName, SIGNAL(activated(int)), this, SLOT(installationSettingChange(int)) ); +// connect( settingName, SIGNAL(textChanged(const QString &)), this, SLOT(installationSettingSetName(const QString &)) ); +// connect( newsetting, SIGNAL(clicked()), this, SLOT(newInstallationSetting()) ); +// connect( renamesetting, SIGNAL(clicked()), this, SLOT(renameInstallationSetting()) ); + // connect( removesetting, SIGNAL(clicked()), this, SLOT(removeInstallationSetting()) ); servername->setEnabled(FALSE); serverurl->setEnabled(FALSE); serverurlDic.setAutoDelete(TRUE); destinationname->setEnabled(FALSE); destinationurl->setEnabled(FALSE); destinationurlDic.setAutoDelete(TRUE); readSettings(); activeLinkDestination->hide(); serverChanged = false; // get rid of setups // Settings->hide(); - settingName->hide(); - newsetting->hide(); - renamesetting->hide(); - removesetting->hide(); +// settingName->hide(); +// newsetting->hide(); +// renamesetting->hide(); +// removesetting->hide(); } PackageManagerSettings::~PackageManagerSettings() { } void PackageManagerSettings::newServer() { int i = servers->count(); if ( servername->isEnabled() || serverurl->text().isEmpty() ) { serverurlDic.insert(i,new QString("http://")); servers->insertItem(tr("New")); activeServers->insertItem(tr("New")); } else { // allows one-level undo serverurlDic.insert(i,new QString(serverurl->text())); servers->insertItem(servername->text()); activeServers->insertItem(servername->text()); } changed = true; servers->setSelected(i,TRUE); editServer(i); changed = true; } void PackageManagerSettings::newDestination() { int i = destinations->count(); if ( destinationname->isEnabled() || destinationurl->text().isEmpty() ) { destinationurlDic.insert(i,new QString("/")); destinations->insertItem(tr("New")); activeDestination->insertItem(tr("New")); activeLinkDestination->insertItem(tr("New")); } else { // allows one-level undo destinationurlDic.insert(i,new QString(destinationurl->text())); destinations->insertItem(destinationname->text()); activeDestination->insertItem(destinationname->text()); activeLinkDestination->insertItem(destinationname->text()); } destinations->setSelected(i,TRUE); editDestination(i); changed = true; } void PackageManagerSettings::editServer(int i) { if ( servername->isEnabled() ) { disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); } else { servername->setEnabled(TRUE); serverurl->setEnabled(TRUE); } servername->setText( servers->text(i) ); serverurl->setText( *serverurlDic[i] ); editedserver = i; serverChanged = true; connect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); connect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); changed = true; } void PackageManagerSettings::editDestination(int i) { if ( destinationname->isEnabled() ) { disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); } else { destinationname->setEnabled(TRUE); destinationurl->setEnabled(TRUE); //since it does not work anyway // createLinksButton->setEnabled(TRUE); // removeLinksButton->setEnabled(TRUE); } destinationname->setText( destinations->text(i) ); destinationurl->setText( *destinationurlDic[i] ); editeddestination = i; connect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); connect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); changed = true; } void PackageManagerSettings::removeServer() { disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); servername->setText(servers->text(editedserver)); serverurl->setText(*serverurlDic[editedserver]); disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); servers->removeItem(editedserver); activeServers->removeItem(editedserver); connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); servername->setEnabled(FALSE); serverurl->setEnabled(FALSE); changed = true; } void PackageManagerSettings::removeDestination() { disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); destinationname->setText(""); destinationurl->setText(""); disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); destinations->removeItem(editeddestination); activeDestination->removeItem(editeddestination); activeLinkDestination->removeItem(editeddestination); editeddestination=0; connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); destinationname->setEnabled(FALSE); destinationurl->setEnabled(FALSE); changed = true; } void PackageManagerSettings::serverNameChanged(const QString& t) { disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); servers->changeItem( t, editedserver ); activeServers->changeItem( t, editedserver ); connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); changed = true; serverChanged = true; } void PackageManagerSettings::destNameChanged(const QString& t) { disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); destinations->changeItem( t, editeddestination ); activeDestination->changeItem( t, editeddestination ); activeLinkDestination->changeItem( t, editeddestination ); connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); changed = true; } void PackageManagerSettings::serverUrlChanged(const QString& t) { serverurlDic.replace(editedserver, new QString(t)); changed = true; serverChanged = true; } void PackageManagerSettings::destUrlChanged(const QString& t) { destinationurlDic.replace(editeddestination, new QString(t)); changed = true; } void PackageManagerSettings::writeIpkgConfig(const QString& conffile) { QFile conf(conffile); if ( ! conf.open(IO_WriteOnly) ) return; QTextStream s(&conf); s << "# Written by qpie Package Manager\n"; for (int i=0; i<(int)activeServers->count(); i++) { QString url = serverurlDic[i] ? *serverurlDic[i] : QString("???"); if ( !activeServers->isSelected(i) ) s << "#"; s << "src " << activeServers->text(i) << " " << url << "\n"; } for (int i=0; i<(int)destinations->count(); i++) { QString url = destinationurlDic[i] ? *destinationurlDic[i] : QString("???"); s << "dest " << destinations->text(i) << " " << url << "\n"; } conf.close(); } void PackageManagerSettings::readInstallationSettings() { Config cfg( "oipkg", Config::User ); cfg.setGroup( "Settings" ); installationSettingsCount = cfg.readNumEntry( "count", -1 ); currentSetting = cfg.readNumEntry( "current", 0 );// o should be -1 - for (int i = 0; i < installationSettingsCount; i++) - { - cfg.setGroup( "Setting_" + QString::number(i) ); - settingName->insertItem( cfg.readEntry( "name", "???" ), i ); - }; +// for (int i = 0; i < installationSettingsCount; i++) +// { +// cfg.setGroup( "Setting_" + QString::number(i) ); +// settingName->insertItem( cfg.readEntry( "name", "???" ), i ); +// }; readInstallationSetting( currentSetting ); } -/** - * remove from conf file - */ -void PackageManagerSettings::removeInstallationSetting() -{ - settingName->removeItem( settingName->currentItem() ); - Config cfg( "oipkg", Config::User ); - cfg.setGroup( "Setting_" + QString::number( installationSettingsCount ) ); - cfg.clearGroup(); - installationSettingsCount--; - changed = true; - settingName->setEditable( false ); -} - -/** - * write to confgile - */ -void PackageManagerSettings::newInstallationSetting() -{ - installationSettingsCount++; - settingName->insertItem( "New", installationSettingsCount ); - settingName->setCurrentItem( installationSettingsCount ); - settingName->setEditable( true ); - changed = true; -} - -void PackageManagerSettings::installationSettingChange(int cs) -{ - writeCurrentInstallationSetting(); - currentSetting = cs; - readInstallationSetting( cs ); - changed = true; -} +///** +// * remove from conf file +// */ +//void PackageManagerSettings::removeInstallationSetting() +//{ +// settingName->removeItem( settingName->currentItem() ); +// Config cfg( "oipkg", Config::User ); +// cfg.setGroup( "Setting_" + QString::number( installationSettingsCount ) ); +// cfg.clearGroup(); +// installationSettingsCount--; +// changed = true; +// settingName->setEditable( false ); +//} + +///** +// * write to confgile +// */ +//void PackageManagerSettings::newInstallationSetting() +//{ +// installationSettingsCount++; +// settingName->insertItem( "New", installationSettingsCount ); +// settingName->setCurrentItem( installationSettingsCount ); +// settingName->setEditable( true ); +// changed = true; +//} + +//void PackageManagerSettings::installationSettingChange(int cs) +//{ +// writeCurrentInstallationSetting(); +// currentSetting = cs; +// readInstallationSetting( cs ); +// changed = true; +//} void PackageManagerSettings::writeInstallationSettings() { { Config cfg( "oipkg", Config::User ); cfg.setGroup( "Settings" ); cfg.writeEntry( "count", installationSettingsCount ); cfg.writeEntry( "current", currentSetting ); } writeCurrentInstallationSetting(); } void PackageManagerSettings::readInstallationSetting(int setting) { if ( setting < 0 ) return; Config cfg( "oipkg", Config::User ); cfg.setGroup( "Setting_" + QString::number( setting ) ); CheckBoxLink->setChecked( cfg.readBoolEntry( "link", true ) ); QString dest = cfg.readEntry( "dest" ); QString linkdest = cfg.readEntry( "linkdest" ); pvDebug(3, "dest="+dest); pvDebug(3, "linkdest="+linkdest); for ( int i = 0; i < activeDestination->count(); i++) { if ( activeDestination->text( i ) == dest ) activeDestination->setCurrentItem( i ); if ( activeLinkDestination->text( i ) == linkdest ) activeLinkDestination->setCurrentItem( i ); } } void PackageManagerSettings::writeCurrentInstallationSetting() { Config cfg( "oipkg", Config::User ); cfg.setGroup( "Setting_" + QString::number(currentSetting) ); cfg.writeEntry( "link", CheckBoxLink->isChecked() ); cfg.writeEntry( "dest", getDestinationName() ); cfg.writeEntry( "linkdest" , getLinkDestinationName() ); QStringList sers = getActiveServers(); int srvc = 0; for ( QStringList::Iterator it = sers.begin(); it != sers.end(); ++it ) { cfg.writeEntry( "server_" + QString::number(srvc++), *it ); } cfg.writeEntry( "server_count", srvc ); } -void PackageManagerSettings::renameInstallationSetting() -{ - settingName->setEditable( true ); - changed = true; -} +//void PackageManagerSettings::renameInstallationSetting() +//{ +// settingName->setEditable( true ); +// changed = true; +//} -void PackageManagerSettings::installationSettingSetName(const QString &name) -{ - settingName->changeItem( name, settingName->currentItem() ); - changed = true; -} +//void PackageManagerSettings::installationSettingSetName(const QString &name) +//{ +// settingName->changeItem( name, settingName->currentItem() ); +// changed = true; +//} bool PackageManagerSettings::readIpkgConfig(const QString& conffile) { QFile conf(conffile); changed = false; if ( conf.open(IO_ReadOnly) ) { QTextStream s(&conf); servers->clear(); activeServers->clear(); destinations->clear(); activeDestination->clear(); activeLinkDestination->clear(); serverurlDic.clear(); destinationurlDic.clear(); ipkg_old=0; int currentserver=0; while ( !s.atEnd() ) { QString l = s.readLine(); QStringList token = QStringList::split(' ', l); if ( token[0] == "src" || token[0] == "#src" ) { currentserver=servers->count(); serverurlDic.insert(servers->count(),new QString(token[2])); int a = token[0] == "src" ? 1 : 0; int i = servers->count(); servers->insertItem(token[1]); activeServers->insertItem( token[1] ); activeServers->setSelected(i,a); } else if ( token[0] == "dest" ) { currentserver=destinations->count(); destinationurlDic.insert(destinations->count(),new QString(token[2])); destinations->insertItem(token[1]); activeDestination->insertItem( token[1] ); activeLinkDestination->insertItem( token[1] ); } else if ( token[0] == "option" ) { // ### somehow need to use the settings from netsetup // if ( token[1] == "http_proxy" ) // http->setText(token[2]); // else if ( token[1] == "ftp_proxy" ) // ftp->setText(token[2]); // else if ( token[1] == "proxy_username" ) // username->setText(token[2]); // else if ( token[1] == "proxy_password" ) // password->setText(token[2]); } else { // Old style? int eq = l.find('='); if ( eq >= 0 ) { QString v = l.mid(eq+1).stripWhiteSpace(); if ( v[0] == '"' || v[0] == '\'' ) { int cl=v.find(v[0],1); if ( cl >= 0 ) v = v.mid(1,cl-1); } if ( l.left(12) == "IPKG_SOURCE=" ) { ipkg_old=1; currentserver=servers->count(); serverurlDic.insert(servers->count(),new QString(v)); servers->insertItem(v); } else if ( l.left(13) == "#IPKG_SOURCE=" ) { serverurlDic.insert(servers->count(),new QString(v)); servers->insertItem(v); } else if ( l.left(10) == "IPKG_ROOT=" ) { // ### no UI // } else if ( l.left(20) == "IPKG_PROXY_USERNAME=" ) { // username->setText(v); // } else if ( l.left(20) == "IPKG_PROXY_PASSWORD=" ) { // password->setText(v); // } else if ( l.left(16) == "IPKG_PROXY_HTTP=" ) { // http->setText(v); // } else if ( l.left(16) == "IPKG_PROXY_FTP=" ) { // ftp->setText(v); } } } } if ( ipkg_old ) { servers->setSelectionMode(QListBox::Single); servers->setSelected(currentserver,TRUE); } return TRUE; } else { return FALSE; } } /** * read from config file(s) */ void PackageManagerSettings::readSettings() { readIpkgConfig("/etc/ipkg.conf"); readInstallationSettings(); } diff --git a/noncore/unsupported/oipkg/pksettings.h b/noncore/unsupported/oipkg/pksettings.h index d66c4e8..db991f6 100644 --- a/noncore/unsupported/oipkg/pksettings.h +++ b/noncore/unsupported/oipkg/pksettings.h @@ -1,74 +1,74 @@ #ifndef PACKAGEMANAGERSETTINGS_H #define PACKAGEMANAGERSETTINGS_H #include "pksettingsbase.h" //#include "pmipkg.h" #include <qintdict.h> #include <qobject.h> class PackageManagerSettings : public PackageManagerSettingsBase { Q_OBJECT public: PackageManagerSettings( QWidget* , const char* , WFlags ); ~PackageManagerSettings(); bool showDialog( int ) ; QString getDestinationUrl(); QString getDestinationName(); QString getLinkDestinationName(); bool createLinks(); QStringList getServers(); QStringList getActiveServers(); QStringList getDestinationUrls(); QStringList getDestinationNames(); QString getDestinationUrlByName(QString); public slots: void writeInstallationSettings(); void readInstallationSettings(); void writeCurrentInstallationSetting(); void readInstallationSetting(int); - void installationSettingSetName(const QString &); +// void installationSettingSetName(const QString &); void removeLinksToDest(); void createLinksToDest(); void newServer(); void editServer(int); void removeDestination(); void newDestination(); void editDestination(int); void linkEnabled(bool); void removeServer(); void serverNameChanged(const QString&); void serverUrlChanged(const QString&); void destNameChanged(const QString&); void destUrlChanged(const QString&); - void installationSettingChange(int); - void newInstallationSetting(); - void removeInstallationSetting(); - void renameInstallationSetting(); +// void installationSettingChange(int); +// void newInstallationSetting(); +// void removeInstallationSetting(); +// void renameInstallationSetting(); void activeServerChanged(); void activeDestinationChange(int); signals: // void doCreateLinks( QString dest ); // void doRemoveLinks( QString dest ); private: QIntDict<QString> serverurlDic; QIntDict<QString> destinationurlDic; int ipkg_old; int editedserver; int editeddestination; int currentSetting; int installationSettingsCount; bool changed; bool serverChanged; bool readIpkgConfig(const QString&); void writeIpkgConfig(const QString&); void writeSettings(); void readSettings(); }; #endif diff --git a/noncore/unsupported/oipkg/pksettingsbase.ui b/noncore/unsupported/oipkg/pksettingsbase.ui index e95ed83..5bc5b46 100644 --- a/noncore/unsupported/oipkg/pksettingsbase.ui +++ b/noncore/unsupported/oipkg/pksettingsbase.ui @@ -1,443 +1,305 @@ <!DOCTYPE UI><UI> <class>PackageManagerSettingsBase</class> <widget> <class>QDialog</class> <property stdset="1"> <name>name</name> <cstring>Form4</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> <width>333</width> <height>454</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Package Servers</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <grid> <property stdset="1"> <name>margin</name> <number>3</number> </property> <property stdset="1"> <name>spacing</name> <number>3</number> </property> <widget row="0" column="0" > <class>QTabWidget</class> <property stdset="1"> <name>name</name> <cstring>TabWidget</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Settings</string> </attribute> <grid> <property stdset="1"> <name>margin</name> <number>3</number> </property> <property stdset="1"> <name>spacing</name> <number>3</number> </property> - <widget row="0" column="0" > - <class>QLayoutWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>Layout3_2</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>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>Settings</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Installation Setups</string> - </property> - </widget> - <spacer> - <property> - <name>name</name> - <cstring>Spacer2_2_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="5" column="0" > <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> <cstring>Layout8</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>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1</cstring> </property> <property stdset="1"> <name>text</name> <string>Install destination:</string> </property> </widget> <widget> <class>QComboBox</class> <property stdset="1"> <name>name</name> <cstring>activeDestination</cstring> </property> </widget> </hbox> </widget> <widget row="6" column="0" > <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> <cstring>Layout9</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>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>CheckBoxLink</cstring> </property> <property stdset="1"> <name>text</name> <string>Link to root destination</string> </property> </widget> <widget> <class>QComboBox</class> <property stdset="1"> <name>name</name> <cstring>activeLinkDestination</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> </widget> </hbox> </widget> <widget row="3" column="0" > <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> <cstring>Layout13</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>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1_2</cstring> </property> <property stdset="1"> <name>text</name> <string>Used servers: (Highlighted feeds are active)</string> </property> </widget> <spacer> <property> <name>name</name> <cstring>Spacer4</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="4" column="0" > <class>QListBox</class> <property stdset="1"> <name>name</name> <cstring>activeServers</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>selectionMode</name> <enum>Multi</enum> </property> </widget> - <widget row="1" column="0" > - <class>QComboBox</class> - <property stdset="1"> - <name>name</name> - <cstring>settingName</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>true</bool> - </property> - <property stdset="1"> - <name>focusPolicy</name> - <enum>NoFocus</enum> - </property> - <property stdset="1"> - <name>editable</name> - <bool>false</bool> - </property> - </widget> - <widget row="2" column="0" > - <class>QLayoutWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>Layout11</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>newsetting</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>false</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>renamesetting</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>false</bool> - </property> - <property stdset="1"> - <name>text</name> - <string>Rename</string> - </property> - </widget> - <widget> - <class>QPushButton</class> - <property stdset="1"> - <name>name</name> - <cstring>removesetting</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>false</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> </grid> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Servers</string> </attribute> <grid> <property stdset="1"> <name>margin</name> <number>3</number> </property> <property stdset="1"> <name>spacing</name> <number>3</number> </property> <widget row="3" column="0" rowspan="1" colspan="2" > <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>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>servername</cstring> </property> </widget> <widget row="0" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1_3</cstring> </property> <property stdset="1"> <name>text</name> <string>Name:</string> </property> </widget> <widget row="1" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>serverurl</cstring> </property> </widget> <widget row="1" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel2_3</cstring> </property> <property stdset="1"> <name>text</name> <string>URL:</string> </property> </widget> </grid> </widget> <widget row="0" column="0" rowspan="1" colspan="2" > <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> <cstring>Layout2</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>QLabel</class> <property stdset="1"> <name>name</name> <cstring>Servers</cstring> </property> <property stdset="1"> |