summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.cpp211
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.h38
2 files changed, 141 insertions, 108 deletions
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.cpp b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
index d9a67f3..6805863 100644
--- a/noncore/settings/packagemanager/oipkgconfigdlg.cpp
+++ b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
@@ -30,12 +30,13 @@ _;:, .> :=|. This program is free software; you can
30*/ 30*/
31 31
32#include "oipkgconfigdlg.h" 32#include "oipkgconfigdlg.h"
33 33
34#include <opie2/ofiledialog.h> 34#include <opie2/ofiledialog.h>
35 35
36#include <qpe/qpeapplication.h>
36#include <qpe/resource.h> 37#include <qpe/resource.h>
37 38
38#include <qcheckbox.h> 39#include <qcheckbox.h>
39#include <qcombobox.h> 40#include <qcombobox.h>
40#include <qgroupbox.h> 41#include <qgroupbox.h>
41#include <qlabel.h> 42#include <qlabel.h>
@@ -45,13 +46,13 @@ _;:, .> :=|. This program is free software; you can
45#include <qscrollview.h> 46#include <qscrollview.h>
46#include <qwhatsthis.h> 47#include <qwhatsthis.h>
47 48
48OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent ) 49OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent )
49 : QDialog( parent, QString::null, true, WStyle_ContextHelp ) 50 : QDialog( parent, QString::null, true, WStyle_ContextHelp )
50 , m_ipkg( ipkg ) 51 , m_ipkg( ipkg )
51 , m_configs( 0x0 ) 52 , m_configs( 0l )
52 , m_installOptions( installOptions ) 53 , m_installOptions( installOptions )
53 , m_serverNew( false ) 54 , m_serverNew( false )
54 , m_serverCurrent( -1 ) 55 , m_serverCurrent( -1 )
55 , m_destNew( false ) 56 , m_destNew( false )
56 , m_destCurrent( -1 ) 57 , m_destCurrent( -1 )
57 , m_layout( this, 2, 4 ) 58 , m_layout( this, 2, 4 )
@@ -163,59 +164,36 @@ void OIpkgConfigDlg::initServerWidget()
163 QScrollView *sv = new QScrollView( m_serverWidget ); 164 QScrollView *sv = new QScrollView( m_serverWidget );
164 vb->addWidget( sv, 0, 0 ); 165 vb->addWidget( sv, 0, 0 );
165 sv->setResizePolicy( QScrollView::AutoOneFit ); 166 sv->setResizePolicy( QScrollView::AutoOneFit );
166 sv->setFrameStyle( QFrame::NoFrame ); 167 sv->setFrameStyle( QFrame::NoFrame );
167 QWidget *container = new QWidget( sv->viewport() ); 168 QWidget *container = new QWidget( sv->viewport() );
168 sv->addChild( container ); 169 sv->addChild( container );
169 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 ); 170 QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 );
170 171
171 m_serverList = new QListBox( container ); 172 m_serverList = new QListBox( container );
172 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." ) ); 173 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." ) );
173 m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); 174 m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
174 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerEdit(int)) ); 175 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerSelected(int)) );
175 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 ); 176 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 );
176 177
177 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); 178 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
178 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); 179 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) );
179 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) ); 180 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) );
180 layout->addWidget( btn, 1, 0 ); 181 layout->addWidget( btn, 1, 0 );
181 182
182 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); 183 m_serverEditBtn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), container );
183 QWhatsThis::add( btn, tr( "Tap here to delete the entry selected above." ) ); 184 m_serverEditBtn->setEnabled( false );
184 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) ); 185 QWhatsThis::add( m_serverEditBtn, tr( "Tap here to edit the entry selected above." ) );
185 layout->addWidget( btn, 1, 1 ); 186 connect( m_serverEditBtn, SIGNAL(clicked()), this, SLOT(slotServerEdit()) );
186 187 layout->addWidget( m_serverEditBtn, 1, 1 );
187 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); 188
188 grpbox->layout()->setSpacing( 2 ); 189 m_serverDeleteBtn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
189 grpbox->layout()->setMargin( 4 ); 190 m_serverDeleteBtn->setEnabled( false );
190 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); 191 QWhatsThis::add( m_serverDeleteBtn, tr( "Tap here to delete the entry selected above." ) );
191 192 connect( m_serverDeleteBtn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) );
192 QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); 193 layout->addWidget( m_serverDeleteBtn, 1, 2 );
193
194 QLabel *label = new QLabel( tr( "Name:" ), grpbox );
195 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
196 grplayout->addWidget( label, 0, 0 );
197 m_serverName = new QLineEdit( grpbox );
198 QWhatsThis::add( m_serverName, tr( "Enter the name of this entry here." ) );
199 grplayout->addWidget( m_serverName, 0, 1 );
200
201 label = new QLabel( tr( "Address:" ), grpbox );
202 QWhatsThis::add( label, tr( "Enter the URL address of this entry here." ) );
203 grplayout->addWidget( label, 1, 0 );
204 m_serverLocation = new QLineEdit( grpbox );
205 QWhatsThis::add( m_serverLocation, tr( "Enter the URL address of this entry here." ) );
206 grplayout->addWidget( m_serverLocation, 1, 1 );
207
208 m_serverActive = new QCheckBox( tr( "Active" ), grpbox );
209 QWhatsThis::add( m_serverActive, tr( "Tap here to indicate whether this entry is active or not." ) );
210 grplayout->addMultiCellWidget( m_serverActive, 2, 2, 0, 1 );
211
212 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
213 QWhatsThis::add( btn, tr( "Tap here to update the entry's information." ) );
214 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerUpdate()) );
215 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 );
216} 194}
217 195
218void OIpkgConfigDlg::initDestinationWidget() 196void OIpkgConfigDlg::initDestinationWidget()
219{ 197{
220 m_destWidget = new QWidget( this ); 198 m_destWidget = new QWidget( this );
221 199
@@ -446,109 +424,83 @@ void OIpkgConfigDlg::initData()
446} 424}
447 425
448OConfItem *OIpkgConfigDlg::findConfItem( OConfItem::Type type, const QString &name ) 426OConfItem *OIpkgConfigDlg::findConfItem( OConfItem::Type type, const QString &name )
449{ 427{
450 // Find selected server in list 428 // Find selected server in list
451 OConfItemListIterator configIt( *m_configs ); 429 OConfItemListIterator configIt( *m_configs );
452 OConfItem *config = 0x0; 430 OConfItem *config = 0l;
453 for ( ; configIt.current(); ++configIt ) 431 for ( ; configIt.current(); ++configIt )
454 { 432 {
455 config = configIt.current(); 433 config = configIt.current();
456 if ( config->type() == type && config->name() == name ) 434 if ( config->type() == type && config->name() == name )
457 break; 435 break;
458 } 436 }
459 437
460 if ( config && config->type() == type && config->name() == name ) 438 if ( config && config->type() == type && config->name() == name )
461 return config; 439 return config;
462 440
463 return 0x0; 441 return 0l;
464} 442}
465 443
466void OIpkgConfigDlg::slotServerEdit( int index ) 444void OIpkgConfigDlg::slotServerSelected( int index )
467{ 445{
468 m_serverNew = false;
469 m_serverCurrent = index; 446 m_serverCurrent = index;
470 447
471 // Find selected server in list 448 // Enable Edit and Delete buttons
472 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() ); 449 m_serverEditBtn->setEnabled( true );
473 450 m_serverDeleteBtn->setEnabled( true );
474 // Display server details
475 if ( server )
476 {
477 m_serverCurrName = server->name();
478 m_serverName->setText( server->name() );
479 m_serverLocation->setText( server->value() );
480 m_serverActive->setChecked( server->active() );
481 m_serverName->setFocus();
482 }
483} 451}
484 452
485void OIpkgConfigDlg::slotServerNew() 453void OIpkgConfigDlg::slotServerNew()
486{ 454{
487 m_serverNew = true; 455 OConfItem *server = new OConfItem( OConfItem::Source );
456
457 OIpkgServerDlg dlg( server, this );
458 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
459 {
460 // Add to configuration option list
461 m_configs->append( server );
462 m_configs->sort();
488 463
489 m_serverName->setText( QString::null ); 464 // Add to server list
490 m_serverLocation->setText( QString::null ); 465 m_serverList->insertItem( server->name() );
491 m_serverActive->setChecked( true ); 466 m_serverList->setCurrentItem( m_serverList->count() );
492 m_serverName->setFocus(); 467 }
468 else
469 delete server;
493} 470}
494 471
495void OIpkgConfigDlg::slotServerDelete() 472void OIpkgConfigDlg::slotServerEdit()
496{ 473{
497 // Find selected server in list 474 // Find selected server in list
498 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() ); 475 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() );
499 476
500 // Delete server 477 // Delete server
501 if ( server ) 478 if ( server )
502 { 479 {
503 m_configs->removeRef( server ); 480 QString origName = server->name();
504 m_serverList->removeItem( m_serverCurrent ); 481 OIpkgServerDlg dlg( server, this );
482 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
483 {
484 // Check to see if name has changed, if so update the server list
485 if ( server->name() != origName )
486 m_serverList->changeItem( server->name(), m_serverCurrent );
487 }
505 } 488 }
506} 489}
507 490
508void OIpkgConfigDlg::slotServerUpdate() 491void OIpkgConfigDlg::slotServerDelete()
509{ 492{
510 QString newName = m_serverName->text(); 493 // Find selected server in list
511 494 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() );
512 // Convert any spaces to underscores
513 newName.replace( QRegExp( " " ), "_" );
514
515 if ( !m_serverNew )
516 {
517 // Find selected server in list
518 OConfItem *server = findConfItem( OConfItem::Source, m_serverCurrName );
519
520 // Delete server
521 if ( server )
522 {
523 // Update url
524 server->setValue( m_serverLocation->text() );
525 server->setActive( m_serverActive->isChecked() );
526
527 // Check if server name has changed, if it has then we need to replace the key in the map
528 if ( m_serverCurrName != newName )
529 {
530 // Update server name
531 server->setName( newName );
532 495
533 // Update list box 496 // Delete server
534 m_serverList->changeItem( newName, m_serverCurrent ); 497 if ( server )
535 }
536 }
537 }
538 else
539 { 498 {
540 // Add new server to configuration list 499 m_configs->removeRef( server );
541 // TODO - support src/gz 500 m_serverList->removeItem( m_serverCurrent );
542 m_configs->append( new OConfItem( OConfItem::Source, newName, m_serverLocation->text(),
543 QString::null, m_serverActive->isChecked() ) );
544 m_configs->sort();
545
546 m_serverList->insertItem( newName );
547 m_serverList->setCurrentItem( m_serverList->count() );
548 m_serverNew = false;
549 } 501 }
550} 502}
551 503
552void OIpkgConfigDlg::slotDestEdit( int index ) 504void OIpkgConfigDlg::slotDestEdit( int index )
553{ 505{
554 m_destNew = false; 506 m_destNew = false;
@@ -638,6 +590,65 @@ void OIpkgConfigDlg::slotDestUpdate()
638 590
639 m_destList->insertItem( newName ); 591 m_destList->insertItem( newName );
640 m_destList->setCurrentItem( m_destList->count() ); 592 m_destList->setCurrentItem( m_destList->count() );
641 m_destNew = false; 593 m_destNew = false;
642 } 594 }
643} 595}
596
597OIpkgServerDlg::OIpkgServerDlg( OConfItem *server, QWidget *parent )
598 : QDialog( parent, QString::null, true, WStyle_ContextHelp )
599 , m_server( server )
600{
601 setCaption( tr( "Edit server" ) );
602
603 // Initialize UI
604 QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 );
605
606 m_active = new QCheckBox( tr( "Active" ), this );
607 QWhatsThis::add( m_active, tr( "Tap here to indicate whether this entry is active or not." ) );
608 layout->addWidget( m_active );
609
610 layout->addStretch();
611
612 QLabel *label = new QLabel( tr( "Name:" ), this );
613 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
614 layout->addWidget( label );
615 m_name = new QLineEdit( this );
616 QWhatsThis::add( m_name, tr( "Enter the name of this entry here." ) );
617 layout->addWidget( m_name );
618
619 layout->addStretch();
620
621 label = new QLabel( tr( "Address:" ), this );
622 QWhatsThis::add( label, tr( "Enter the URL address of this entry here." ) );
623 layout->addWidget( label );
624 m_location = new QLineEdit( this );
625 QWhatsThis::add( m_location, tr( "Enter the URL address of this entry here." ) );
626 layout->addWidget( m_location );
627
628 layout->addStretch();
629
630 m_compressed = new QCheckBox( tr( "Compressed server feed" ), this );
631 QWhatsThis::add( m_compressed, tr( "Tap here to indicate whether the server support compressed archives or not." ) );
632 layout->addWidget( m_compressed );
633
634 // Populate initial information
635 if ( m_server )
636 {
637 m_name->setText( m_server->name() );
638 m_location->setText( m_server->value() );
639 m_compressed->setChecked( m_server->features().contains( "Compressed" ) );
640 m_active->setChecked( m_server->active() );
641 }
642}
643
644void OIpkgServerDlg::accept()
645{
646 // Save information entered
647 m_server->setName( m_name->text() );
648 m_server->setValue( m_location->text() );
649 m_compressed->isChecked() ? m_server->setFeatures( "Compressed" )
650 : m_server->setFeatures( QString::null );
651 m_server->setActive( m_active->isChecked() );
652
653 QDialog::accept();
654}
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.h b/noncore/settings/packagemanager/oipkgconfigdlg.h
index a4e4f82..076a181 100644
--- a/noncore/settings/packagemanager/oipkgconfigdlg.h
+++ b/noncore/settings/packagemanager/oipkgconfigdlg.h
@@ -41,19 +41,20 @@ _;:, .> :=|. This program is free software; you can
41#include "oipkg.h" 41#include "oipkg.h"
42 42
43class QCheckBox; 43class QCheckBox;
44class QComboBox; 44class QComboBox;
45class QLineEdit; 45class QLineEdit;
46class QListBox; 46class QListBox;
47class QPushButton;
47 48
48class OIpkgConfigDlg : public QDialog 49class OIpkgConfigDlg : public QDialog
49{ 50{
50 Q_OBJECT 51 Q_OBJECT
51 52
52public: 53public:
53 OIpkgConfigDlg( OIpkg *ipkg = 0x0, bool installOptions = false, QWidget *parent = 0x0 ); 54 OIpkgConfigDlg( OIpkg *ipkg = 0l, bool installOptions = false, QWidget *parent = 0l );
54 55
55protected slots: 56protected slots:
56 void accept(); 57 void accept();
57 void reject(); 58 void reject();
58 59
59private: 60private:
@@ -78,16 +79,15 @@ private:
78 QWidget *m_serverWidget; // Widget containing server configuration controls 79 QWidget *m_serverWidget; // Widget containing server configuration controls
79 QWidget *m_destWidget; // Widget containing destination configuration controls 80 QWidget *m_destWidget; // Widget containing destination configuration controls
80 QWidget *m_proxyWidget; // Widget containing proxy configuration controls 81 QWidget *m_proxyWidget; // Widget containing proxy configuration controls
81 QWidget *m_optionsWidget; // Widget containing ipkg execution configuration controls 82 QWidget *m_optionsWidget; // Widget containing ipkg execution configuration controls
82 83
83 // Server configuration UI controls 84 // Server configuration UI controls
84 QListBox *m_serverList; // Server list selection 85 QListBox *m_serverList; // Server list selection
85 QLineEdit *m_serverName; // Server name edit box 86 QPushButton *m_serverEditBtn; // Server edit button
86 QLineEdit *m_serverLocation; // Server location URL edit box 87 QPushButton *m_serverDeleteBtn; // Server edit button
87 QCheckBox *m_serverActive; // Activate server check box
88 88
89 // Destination configuration UI controls 89 // Destination configuration UI controls
90 QListBox *m_destList; // Destination list selection 90 QListBox *m_destList; // Destination list selection
91 QLineEdit *m_destName; // Destination name edit box 91 QLineEdit *m_destName; // Destination name edit box
92 QLineEdit *m_destLocation; // Destination location URL edit box 92 QLineEdit *m_destLocation; // Destination location URL edit box
93 QCheckBox *m_destActive; // Activate destination check box 93 QCheckBox *m_destActive; // Activate destination check box
@@ -111,22 +111,44 @@ private:
111 void initDestinationWidget(); 111 void initDestinationWidget();
112 void initProxyWidget(); 112 void initProxyWidget();
113 void initOptionsWidget(); 113 void initOptionsWidget();
114 114
115 void initData(); 115 void initData();
116 116
117 OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, const QString &name = 0x0 ); 117 OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined,
118 const QString &name = QString::null );
118 119
119private slots: 120private slots:
120 void slotServerEdit( int index ); 121 void slotServerSelected( int index );
121 void slotServerNew(); 122 void slotServerNew();
123 void slotServerEdit();
122 void slotServerDelete(); 124 void slotServerDelete();
123 void slotServerUpdate(); 125// void slotServerUpdate();
124 126
125 void slotDestEdit( int index ); 127 void slotDestEdit( int index );
126 void slotDestNew(); 128 void slotDestNew();
127 void slotDestDelete(); 129 void slotDestDelete();
128 void slotDestSelectPath(); 130 void slotDestSelectPath();
129 void slotDestUpdate(); 131 void slotDestUpdate();
130}; 132};
131 133
134class OIpkgServerDlg : public QDialog
135{
136 Q_OBJECT
137
138public:
139 OIpkgServerDlg( OConfItem *server = 0l, QWidget *parent = 0l );
140
141protected slots:
142 void accept();
143
144private:
145 OConfItem *m_server;
146
147 // UI controls
148 QLineEdit *m_name; // Server name edit box
149 QLineEdit *m_location; // Server location URL edit box
150 QCheckBox *m_compressed; // Indicates whether the server is a 'src/gz' feed
151 QCheckBox *m_active; // Indicates whether the server is activated
152};
153
132#endif 154#endif