00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "oipkgconfigdlg.h"
00032
00033 #include <opie2/ofiledialog.h>
00034 #include <opie2/oresource.h>
00035
00036 #include <qpe/qpeapplication.h>
00037
00038 #include <qcheckbox.h>
00039 #include <qcombobox.h>
00040 #include <qgroupbox.h>
00041 #include <qlabel.h>
00042 #include <qlineedit.h>
00043 #include <qlistbox.h>
00044 #include <qpushbutton.h>
00045 #include <qscrollview.h>
00046 #include <qwhatsthis.h>
00047
00048 OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent )
00049 : QDialog( parent, QString::null, true, WStyle_ContextHelp )
00050 , m_ipkg( ipkg )
00051 , m_configs( 0l )
00052 , m_installOptions( installOptions )
00053 , m_serverCurrent( -1 )
00054 , m_destCurrent( -1 )
00055 , m_layout( this, 2, 4 )
00056 , m_tabWidget( this )
00057 {
00058 setCaption( tr( "Configuration" ) );
00059
00060
00061 if ( !installOptions )
00062 {
00063 initServerWidget();
00064 initDestinationWidget();
00065 initProxyWidget();
00066 }
00067 initOptionsWidget();
00068
00069
00070 initData();
00071
00072
00073 m_layout.addWidget( &m_tabWidget );
00074 if ( !m_installOptions )
00075 {
00076 m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) );
00077 m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) );
00078 m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) );
00079 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) );
00080 m_tabWidget.setCurrentTab( tr( "Servers" ) );
00081 }
00082 else
00083 {
00084 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) );
00085 }
00086 }
00087
00088 void OIpkgConfigDlg::accept()
00089 {
00090
00091 if ( !m_installOptions )
00092 {
00093
00094 OConfItem *confItem = m_ipkg->findConfItem( OConfItem::Option, "http_proxy" );
00095 if ( confItem )
00096 {
00097 confItem->setValue( m_proxyHttpServer->text() );
00098 confItem->setActive( m_proxyHttpActive->isChecked() );
00099 }
00100 else
00101 m_configs->append( new OConfItem( OConfItem::Option, "http_proxy",
00102 m_proxyHttpServer->text(), QString::null,
00103 m_proxyHttpActive->isChecked() ) );
00104
00105 confItem = m_ipkg->findConfItem( OConfItem::Option, "ftp_proxy" );
00106 if ( confItem )
00107 {
00108 confItem->setValue( m_proxyFtpServer->text() );
00109 confItem->setActive( m_proxyFtpActive->isChecked() );
00110 }
00111 else
00112 m_configs->append( new OConfItem( OConfItem::Option, "ftp_proxy",
00113 m_proxyFtpServer->text(), QString::null,
00114 m_proxyFtpActive->isChecked() ) );
00115
00116 confItem = m_ipkg->findConfItem( OConfItem::Option, "proxy_username" );
00117 if ( confItem )
00118 confItem->setValue( m_proxyUsername->text() );
00119 else
00120 m_configs->append( new OConfItem( OConfItem::Option, "proxy_username",
00121 m_proxyUsername->text() ) );
00122
00123 confItem = m_ipkg->findConfItem( OConfItem::Option, "proxy_password" );
00124 if ( confItem )
00125 confItem->setValue( m_proxyPassword->text() );
00126 else
00127 m_configs->append( new OConfItem( OConfItem::Option, "proxy_password",
00128 m_proxyPassword->text() ) );
00129
00130 QString listsDir = m_optSourceLists->text();
00131 if ( listsDir == QString::null || listsDir == "" )
00132 listsDir = "/usr/lib/ipkg/lists";
00133 confItem = m_ipkg->findConfItem( OConfItem::Other, "lists_dir" );
00134 if ( confItem )
00135 confItem->setValue( listsDir );
00136 else
00137 m_configs->append( new OConfItem( OConfItem::Other, "lists_dir",
00138 listsDir, "name" ) );
00139
00140 m_ipkg->setConfigItems( m_configs );
00141 }
00142
00143
00144 int options = 0;
00145 if ( m_optForceDepends->isChecked() )
00146 options |= FORCE_DEPENDS;
00147 if ( m_optForceReinstall->isChecked() )
00148 options |= FORCE_REINSTALL;
00149 if ( m_optForceRemove->isChecked() )
00150 options |= FORCE_REMOVE;
00151 if ( m_optForceOverwrite->isChecked() )
00152 options |= FORCE_OVERWRITE;
00153 m_ipkg->setIpkgExecOptions( options );
00154 m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() );
00155
00156 QDialog::accept();
00157 }
00158
00159 void OIpkgConfigDlg::reject()
00160 {
00161 if ( m_configs )
00162 delete m_configs;
00163 }
00164
00165 void OIpkgConfigDlg::initServerWidget()
00166 {
00167 m_serverWidget = new QWidget( this );
00168
00169
00170 QVBoxLayout *vb = new QVBoxLayout( m_serverWidget );
00171 QScrollView *sv = new QScrollView( m_serverWidget );
00172 vb->addWidget( sv, 0, 0 );
00173 sv->setResizePolicy( QScrollView::AutoOneFit );
00174 sv->setFrameStyle( QFrame::NoFrame );
00175 QWidget *container = new QWidget( sv->viewport() );
00176 sv->addChild( container );
00177 QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 );
00178
00179 m_serverList = new QListBox( container );
00180 QWhatsThis::add( m_serverList, tr( "This is a list of all servers configured. Select one here to edit or delete, or add a new one below." ) );
00181 m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
00182 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerSelected(int)) );
00183 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 2 );
00184
00185 QPushButton *btn = new QPushButton( Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ),
00186 tr( "New" ), container );
00187 btn->setMinimumHeight( AppLnk::smallIconSize()+4 );
00188 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) );
00189 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) );
00190 layout->addWidget( btn, 1, 0 );
00191
00192 m_serverEditBtn = new QPushButton( Opie::Core::OResource::loadPixmap( "edit", Opie::Core::OResource::SmallIcon ),
00193 tr( "Edit" ), container );
00194 m_serverEditBtn->setMinimumHeight( AppLnk::smallIconSize()+4 );
00195 m_serverEditBtn->setEnabled( false );
00196 QWhatsThis::add( m_serverEditBtn, tr( "Tap here to edit the entry selected above." ) );
00197 connect( m_serverEditBtn, SIGNAL(clicked()), this, SLOT(slotServerEdit()) );
00198 layout->addWidget( m_serverEditBtn, 1, 1 );
00199
00200 m_serverDeleteBtn = new QPushButton( Opie::Core::OResource::loadPixmap( "trash", Opie::Core::OResource::SmallIcon ),
00201 tr( "Delete" ), container );
00202 m_serverDeleteBtn->setMinimumHeight( AppLnk::smallIconSize()+4 );
00203 m_serverDeleteBtn->setEnabled( false );
00204 QWhatsThis::add( m_serverDeleteBtn, tr( "Tap here to delete the entry selected above." ) );
00205 connect( m_serverDeleteBtn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) );
00206 layout->addWidget( m_serverDeleteBtn, 1, 2 );
00207 }
00208
00209 void OIpkgConfigDlg::initDestinationWidget()
00210 {
00211 m_destWidget = new QWidget( this );
00212
00213
00214 QVBoxLayout *vb = new QVBoxLayout( m_destWidget );
00215 QScrollView *sv = new QScrollView( m_destWidget );
00216 vb->addWidget( sv, 0, 0 );
00217 sv->setResizePolicy( QScrollView::AutoOneFit );
00218 sv->setFrameStyle( QFrame::NoFrame );
00219 QWidget *container = new QWidget( sv->viewport() );
00220 sv->addChild( container );
00221 QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 );
00222
00223 m_destList = new QListBox( container );
00224 QWhatsThis::add( m_destList, tr( "This is a list of all destinations configured for this device. Select one here to edit or delete, or add a new one below." ) );
00225 m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
00226 connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestSelected(int)) );
00227 layout->addMultiCellWidget( m_destList, 0, 0, 0, 2 );
00228
00229 QPushButton *btn = new QPushButton( Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ),
00230 tr( "New" ), container );
00231 btn->setMinimumHeight( AppLnk::smallIconSize()+4 );
00232 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) );
00233 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) );
00234 layout->addWidget( btn, 1, 0 );
00235
00236 m_destEditBtn = new QPushButton( Opie::Core::OResource::loadPixmap( "edit", Opie::Core::OResource::SmallIcon ),
00237 tr( "Edit" ), container );
00238 m_destEditBtn->setMinimumHeight( AppLnk::smallIconSize()+4 );
00239 m_destEditBtn->setEnabled( false );
00240 QWhatsThis::add( m_destEditBtn, tr( "Tap here to edit the entry selected above." ) );
00241 connect( m_destEditBtn, SIGNAL(clicked()), this, SLOT(slotDestEdit()) );
00242 layout->addWidget( m_destEditBtn, 1, 1 );
00243
00244 m_destDeleteBtn = new QPushButton( Opie::Core::OResource::loadPixmap( "trash", Opie::Core::OResource::SmallIcon ),
00245 tr( "Delete" ), container );
00246 m_destDeleteBtn->setMinimumHeight( AppLnk::smallIconSize()+4 );
00247 m_destDeleteBtn->setEnabled( false );
00248 QWhatsThis::add( m_destDeleteBtn, tr( "Tap here to delete the entry selected above." ) );
00249 connect( m_destDeleteBtn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) );
00250 layout->addWidget( m_destDeleteBtn, 1, 2 );
00251 }
00252
00253 void OIpkgConfigDlg::initProxyWidget()
00254 {
00255 m_proxyWidget = new QWidget( this );
00256
00257
00258 QVBoxLayout *vb = new QVBoxLayout( m_proxyWidget );
00259 QScrollView *sv = new QScrollView( m_proxyWidget );
00260 vb->addWidget( sv, 0, 0 );
00261 sv->setResizePolicy( QScrollView::AutoOneFit );
00262 sv->setFrameStyle( QFrame::NoFrame );
00263 QWidget *container = new QWidget( sv->viewport() );
00264 sv->addChild( container );
00265 QGridLayout *layout = new QGridLayout( container, 4, 2, 2, 4 );
00266
00267
00268 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container );
00269 grpbox->layout()->setSpacing( 2 );
00270 grpbox->layout()->setMargin( 4 );
00271 layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 );
00272 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() );
00273 m_proxyHttpServer = new QLineEdit( grpbox );
00274 QWhatsThis::add( m_proxyHttpServer, tr( "Enter the URL address of the HTTP proxy server here." ) );
00275 grplayout->addWidget( m_proxyHttpServer );
00276 m_proxyHttpActive = new QCheckBox( tr( "Enabled" ), grpbox );
00277 QWhatsThis::add( m_proxyHttpActive, tr( "Tap here to enable or disable the HTTP proxy server." ) );
00278 grplayout->addWidget( m_proxyHttpActive );
00279
00280
00281 grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container );
00282 grpbox->layout()->setSpacing( 2 );
00283 grpbox->layout()->setMargin( 4 );
00284 layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 );
00285 grplayout = new QVBoxLayout( grpbox->layout() );
00286 m_proxyFtpServer = new QLineEdit( grpbox );
00287 QWhatsThis::add( m_proxyFtpServer, tr( "Enter the URL address of the FTP proxy server here." ) );
00288 grplayout->addWidget( m_proxyFtpServer );
00289 m_proxyFtpActive = new QCheckBox( tr( "Enabled" ), grpbox );
00290 QWhatsThis::add( m_proxyFtpActive, tr( "Tap here to enable or disable the FTP proxy server." ) );
00291 grplayout->addWidget( m_proxyFtpActive );
00292
00293
00294 QLabel *label = new QLabel( tr( "Username:" ), container );
00295 QWhatsThis::add( label, tr( "Enter the username for the proxy servers here." ) );
00296 layout->addWidget( label, 2, 0 );
00297 m_proxyUsername = new QLineEdit( container );
00298 QWhatsThis::add( m_proxyUsername, tr( "Enter the username for the proxy servers here." ) );
00299 layout->addWidget( m_proxyUsername, 2, 1 );
00300
00301 label = new QLabel( tr( "Password:" ), container );
00302 QWhatsThis::add( label, tr( "Enter the password for the proxy servers here." ) );
00303 layout->addWidget( label, 3, 0 );
00304 m_proxyPassword = new QLineEdit( container );
00305 QWhatsThis::add( m_proxyPassword, tr( "Enter the password for the proxy servers here." ) );
00306 layout->addWidget( m_proxyPassword, 3, 1 );
00307 }
00308
00309 void OIpkgConfigDlg::initOptionsWidget()
00310 {
00311 m_optionsWidget = new QWidget( this );
00312
00313
00314 QVBoxLayout *vb = new QVBoxLayout( m_optionsWidget );
00315 QScrollView *sv = new QScrollView( m_optionsWidget );
00316 vb->addWidget( sv, 0, 0 );
00317 sv->setResizePolicy( QScrollView::AutoOneFit );
00318 sv->setFrameStyle( QFrame::NoFrame );
00319 QWidget *container = new QWidget( sv->viewport() );
00320 sv->addChild( container );
00321 QGridLayout *layout = new QGridLayout( container, 8, 2, 2, 4 );
00322
00323 m_optForceDepends = new QCheckBox( tr( "Force Depends" ), container );
00324 QWhatsThis::add( m_optForceDepends, tr( "Tap here to enable or disable the '-force-depends' option for Ipkg." ) );
00325 layout->addMultiCellWidget( m_optForceDepends, 0, 0, 0, 1 );
00326
00327 m_optForceReinstall = new QCheckBox( tr( "Force Reinstall" ), container );
00328 QWhatsThis::add( m_optForceReinstall, tr( "Tap here to enable or disable the '-force-reinstall' option for Ipkg." ) );
00329 layout->addMultiCellWidget( m_optForceReinstall, 1, 1, 0, 1 );
00330
00331 m_optForceRemove = new QCheckBox( tr( "Force Remove" ), container );
00332 QWhatsThis::add( m_optForceRemove, tr( "Tap here to enable or disable the '-force-removal-of-dependent-packages' option for Ipkg." ) );
00333 layout->addMultiCellWidget( m_optForceRemove, 2, 2, 0, 1 );
00334
00335 m_optForceOverwrite = new QCheckBox( tr( "Force Overwrite" ), container );
00336 QWhatsThis::add( m_optForceOverwrite, tr( "Tap here to enable or disable the '-force-overwrite' option for Ipkg." ) );
00337 layout->addMultiCellWidget( m_optForceOverwrite, 3, 3, 0, 1 );
00338
00339 QLabel *l = new QLabel( tr( "Information level:" ), container );
00340 QWhatsThis::add( l, tr( "Select information level for Ipkg." ) );
00341 layout->addMultiCellWidget( l, 4, 4, 0, 1 );
00342
00343 m_optVerboseIpkg = new QComboBox( container );
00344 QWhatsThis::add( m_optVerboseIpkg, tr( "Select information level for Ipkg." ) );
00345 m_optVerboseIpkg->insertItem( tr( "Errors only" ) );
00346 m_optVerboseIpkg->insertItem( tr( "Normal messages" ) );
00347 m_optVerboseIpkg->insertItem( tr( "Informative messages" ) );
00348 m_optVerboseIpkg->insertItem( tr( "Troubleshooting output" ) );
00349 layout->addMultiCellWidget( m_optVerboseIpkg, 5, 5, 0, 1 );
00350
00351 l = new QLabel( tr( "Package source lists directory:" ), container );
00352 QWhatsThis::add( l, tr( "Enter the directory where package source feed information is stored." ) );
00353 layout->addMultiCellWidget( l, 6, 6, 0, 1 );
00354
00355 m_optSourceLists = new QLineEdit( container );
00356 QWhatsThis::add( m_optSourceLists, tr( "Enter the directory where package source feed information is stored." ) );
00357 layout->addWidget( m_optSourceLists, 7, 0 );
00358
00359 QPushButton *btn = new QPushButton( Opie::Core::OResource::loadPixmap( "folder", Opie::Core::OResource::SmallIcon ),
00360 QString::null, container );
00361 btn->setMinimumHeight( AppLnk::smallIconSize()+4 );
00362 btn->setMaximumWidth( btn->height() );
00363 QWhatsThis::add( btn, tr( "Tap here to select the directory where package source feed information is stored." ) );
00364 connect( btn, SIGNAL(clicked()), this, SLOT(slotOptSelectSourceListsPath()) );
00365 layout->addWidget( btn, 7, 1 );
00366
00367 layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
00368 }
00369
00370 void OIpkgConfigDlg::initData()
00371 {
00372
00373 if ( m_ipkg && !m_installOptions )
00374 {
00375 m_configs = m_ipkg->configItems();
00376 if ( m_configs )
00377 {
00378 for ( OConfItemListIterator configIt( *m_configs ); configIt.current(); ++configIt )
00379 {
00380 OConfItem *config = configIt.current();
00381
00382
00383 if ( config )
00384 {
00385 switch ( config->type() )
00386 {
00387 case OConfItem::Source : m_serverList->insertItem( config->name() ); break;
00388 case OConfItem::Destination : m_destList->insertItem( config->name() ); break;
00389 case OConfItem::Option :
00390 {
00391 if ( config->name() == "http_proxy" )
00392 {
00393 m_proxyHttpServer->setText( config->value() );
00394 m_proxyHttpActive->setChecked( config->active() );
00395 }
00396 else if ( config->name() == "ftp_proxy" )
00397 {
00398 m_proxyFtpServer->setText( config->value() );
00399 m_proxyFtpActive->setChecked( config->active() );
00400 }
00401 else if ( config->name() == "proxy_username" )
00402 {
00403 m_proxyUsername->setText( config->value() );
00404 }
00405 else if ( config->name() == "proxy_password" )
00406 {
00407 m_proxyPassword->setText( config->value() );
00408 }
00409 }
00410 break;
00411 case OConfItem::Other :
00412 {
00413 if ( config->name() == "lists_dir" )
00414 m_optSourceLists->setText( config->value() );
00415 else
00416 m_optSourceLists->setText( "/usr/lib/ipkg/lists" );
00417 }
00418 break;
00419 default : break;
00420 };
00421 }
00422 }
00423 }
00424 }
00425
00426
00427 int options = m_ipkg->ipkgExecOptions();
00428 if ( options & FORCE_DEPENDS )
00429 m_optForceDepends->setChecked( true );
00430 if ( options & FORCE_REINSTALL )
00431 m_optForceReinstall->setChecked( true );
00432 if ( options & FORCE_REMOVE )
00433 m_optForceRemove->setChecked( true );
00434 if ( options & FORCE_OVERWRITE )
00435 m_optForceOverwrite->setChecked( true );
00436
00437 m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() );
00438 }
00439
00440 void OIpkgConfigDlg::slotServerSelected( int index )
00441 {
00442 m_serverCurrent = index;
00443
00444
00445 m_serverEditBtn->setEnabled( true );
00446 m_serverDeleteBtn->setEnabled( true );
00447 }
00448
00449 void OIpkgConfigDlg::slotServerNew()
00450 {
00451 OConfItem *server = new OConfItem( OConfItem::Source );
00452
00453 OIpkgServerDlg dlg( server, this );
00454 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
00455 {
00456
00457 m_configs->append( server );
00458 m_configs->sort();
00459
00460
00461 m_serverList->insertItem( server->name() );
00462 m_serverList->setCurrentItem( m_serverList->count() );
00463 }
00464 else
00465 delete server;
00466 }
00467
00468 void OIpkgConfigDlg::slotServerEdit()
00469 {
00470
00471 OConfItem *server = m_ipkg->findConfItem( OConfItem::Source, m_serverList->currentText() );
00472
00473
00474 if ( server )
00475 {
00476 QString origName = server->name();
00477 OIpkgServerDlg dlg( server, this );
00478 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
00479 {
00480
00481 if ( server->name() != origName )
00482 m_serverList->changeItem( server->name(), m_serverCurrent );
00483 }
00484 }
00485 }
00486
00487 void OIpkgConfigDlg::slotServerDelete()
00488 {
00489
00490 OConfItem *server = m_ipkg->findConfItem( OConfItem::Source, m_serverList->currentText() );
00491
00492
00493 if ( server )
00494 {
00495 m_configs->removeRef( server );
00496 m_serverList->removeItem( m_serverCurrent );
00497 }
00498 }
00499
00500 void OIpkgConfigDlg::slotDestSelected( int index )
00501 {
00502 m_destCurrent = index;
00503
00504
00505 m_destEditBtn->setEnabled( true );
00506 m_destDeleteBtn->setEnabled( true );
00507 }
00508
00509 void OIpkgConfigDlg::slotDestNew()
00510 {
00511 OConfItem *dest = new OConfItem( OConfItem::Destination );
00512
00513 OIpkgDestDlg dlg( dest, this );
00514 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
00515 {
00516
00517 m_configs->append( dest );
00518 m_configs->sort();
00519
00520
00521 m_destList->insertItem( dest->name() );
00522 m_destList->setCurrentItem( m_destList->count() );
00523 }
00524 else
00525 delete dest;
00526 }
00527
00528 void OIpkgConfigDlg::slotDestEdit()
00529 {
00530
00531 OConfItem *dest = m_ipkg->findConfItem( OConfItem::Destination, m_destList->currentText() );
00532
00533
00534 if ( dest )
00535 {
00536 QString origName = dest->name();
00537 OIpkgDestDlg dlg( dest, this );
00538 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
00539 {
00540
00541 if ( dest->name() != origName )
00542 m_destList->changeItem( dest->name(), m_destCurrent );
00543 }
00544 }
00545 }
00546
00547 void OIpkgConfigDlg::slotDestDelete()
00548 {
00549
00550 OConfItem *destination = m_ipkg->findConfItem( OConfItem::Destination, m_destList->currentText() );
00551
00552
00553 if ( destination )
00554 {
00555 m_configs->removeRef( destination );
00556 m_destList->removeItem( m_destCurrent );
00557 }
00558 }
00559
00560 void OIpkgConfigDlg::slotOptSelectSourceListsPath()
00561 {
00562 QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_optSourceLists->text() );
00563 if ( path.at( path.length() - 1 ) == '/' )
00564 path.truncate( path.length() - 1 );
00565 if ( !path.isNull() )
00566 m_optSourceLists->setText( path );
00567 }
00568
00569 OIpkgServerDlg::OIpkgServerDlg( OConfItem *server, QWidget *parent )
00570 : QDialog( parent, QString::null, true, WStyle_ContextHelp )
00571 , m_server( server )
00572 {
00573 setCaption( tr( "Edit Server" ) );
00574
00575
00576 QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 );
00577
00578 m_active = new QCheckBox( tr( "Active" ), this );
00579 QWhatsThis::add( m_active, tr( "Tap here to indicate whether this entry is active or not." ) );
00580 layout->addWidget( m_active );
00581
00582 layout->addStretch();
00583
00584 QLabel *label = new QLabel( tr( "Name:" ), this );
00585 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
00586 layout->addWidget( label );
00587 m_name = new QLineEdit( this );
00588 QWhatsThis::add( m_name, tr( "Enter the name of this entry here." ) );
00589 layout->addWidget( m_name );
00590
00591 layout->addStretch();
00592
00593 label = new QLabel( tr( "Address:" ), this );
00594 QWhatsThis::add( label, tr( "Enter the URL address of this entry here." ) );
00595 layout->addWidget( label );
00596 m_location = new QLineEdit( this );
00597 QWhatsThis::add( m_location, tr( "Enter the URL address of this entry here." ) );
00598 layout->addWidget( m_location );
00599
00600 layout->addStretch();
00601
00602 m_compressed = new QCheckBox( tr( "Compressed server feed" ), this );
00603 QWhatsThis::add( m_compressed, tr( "Tap here to indicate whether the server support compressed archives or not." ) );
00604 layout->addWidget( m_compressed );
00605
00606
00607 if ( m_server )
00608 {
00609 m_name->setText( m_server->name() );
00610 m_location->setText( m_server->value() );
00611 m_compressed->setChecked( m_server->features().contains( "Compressed" ) );
00612 m_active->setChecked( m_server->active() );
00613 }
00614 }
00615
00616 void OIpkgServerDlg::accept()
00617 {
00618
00619 QString name = m_name->text();
00620 name.replace( QRegExp( " " ), "_" );
00621 m_server->setName( name );
00622 m_server->setValue( m_location->text() );
00623 m_compressed->isChecked() ? m_server->setFeatures( "Compressed" )
00624 : m_server->setFeatures( QString::null );
00625 m_server->setActive( m_active->isChecked() );
00626
00627 QDialog::accept();
00628 }
00629
00630 OIpkgDestDlg::OIpkgDestDlg( OConfItem *dest, QWidget *parent )
00631 : QDialog( parent, QString::null, true, WStyle_ContextHelp )
00632 , m_dest( dest )
00633 {
00634 setCaption( tr( "Edit Destination" ) );
00635
00636
00637 QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 );
00638
00639 m_active = new QCheckBox( tr( "Active" ), this );
00640 QWhatsThis::add( m_active, tr( "Tap here to indicate whether this entry is active or not." ) );
00641 layout->addWidget( m_active );
00642
00643 layout->addStretch();
00644
00645 QLabel *label = new QLabel( tr( "Name:" ), this );
00646 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
00647 layout->addWidget( label );
00648 m_name = new QLineEdit( this );
00649 QWhatsThis::add( m_name, tr( "Enter the name of this entry here." ) );
00650 layout->addWidget( m_name );
00651
00652 layout->addStretch();
00653
00654 label = new QLabel( tr( "Location:" ), this );
00655 QWhatsThis::add( label, tr( "Enter the absolute directory path of this entry here." ) );
00656 layout->addWidget( label );
00657
00658 QHBoxLayout *layout2 = new QHBoxLayout( this, 2, 4 );
00659 layout->addLayout( layout2 );
00660
00661 m_location = new QLineEdit( this );
00662 QWhatsThis::add( m_location, tr( "Enter the absolute directory path of this entry here." ) );
00663 layout2->addWidget( m_location );
00664 QPushButton *btn = new QPushButton( Opie::Core::OResource::loadPixmap( "folder", Opie::Core::OResource::SmallIcon ),
00665 QString::null, this );
00666 btn->setMaximumWidth( btn->height() );
00667 QWhatsThis::add( btn, tr( "Tap here to select the desired location." ) );
00668 connect( btn, SIGNAL(clicked()), this, SLOT(slotSelectPath()) );
00669 layout2->addWidget( btn );
00670
00671
00672 if ( m_dest )
00673 {
00674 m_name->setText( m_dest->name() );
00675 m_location->setText( m_dest->value() );
00676 m_active->setChecked( m_dest->active() );
00677 }
00678 }
00679
00680 void OIpkgDestDlg::accept()
00681 {
00682
00683 QString name = m_name->text();
00684 name.replace( QRegExp( " " ), "_" );
00685 m_dest->setName( name );
00686 m_dest->setValue( m_location->text() );
00687 m_dest->setActive( m_active->isChecked() );
00688
00689 QDialog::accept();
00690 }
00691
00692 void OIpkgDestDlg::slotSelectPath()
00693 {
00694 QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_location->text() );
00695 if ( path.at( path.length() - 1 ) == '/' )
00696 path.truncate( path.length() - 1 );
00697 if ( !path.isNull() )
00698 m_location->setText( path );
00699 }
00700