summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.cpp244
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.h47
2 files changed, 157 insertions, 134 deletions
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.cpp b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
index 6805863..77ad220 100644
--- a/noncore/settings/packagemanager/oipkgconfigdlg.cpp
+++ b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
@@ -53,5 +53,3 @@ OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *paren
53 , m_installOptions( installOptions ) 53 , m_installOptions( installOptions )
54 , m_serverNew( false )
55 , m_serverCurrent( -1 ) 54 , m_serverCurrent( -1 )
56 , m_destNew( false )
57 , m_destCurrent( -1 ) 55 , m_destCurrent( -1 )
@@ -175,3 +173,3 @@ void OIpkgConfigDlg::initServerWidget()
175 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerSelected(int)) ); 173 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerSelected(int)) );
176 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 ); 174 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 2 );
177 175
@@ -207,3 +205,3 @@ void OIpkgConfigDlg::initDestinationWidget()
207 sv->addChild( container ); 205 sv->addChild( container );
208 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 ); 206 QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 );
209 207
@@ -212,4 +210,4 @@ void OIpkgConfigDlg::initDestinationWidget()
212 m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); 210 m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
213 connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestEdit(int)) ); 211 connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestSelected(int)) );
214 layout->addMultiCellWidget( m_destList, 0, 0, 0, 1 ); 212 layout->addMultiCellWidget( m_destList, 0, 0, 0, 2 );
215 213
@@ -220,41 +218,13 @@ void OIpkgConfigDlg::initDestinationWidget()
220 218
221 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); 219 m_destEditBtn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), container );
222 QWhatsThis::add( btn, tr( "Tap here to delete the entry selected above." ) ); 220 m_destEditBtn->setEnabled( false );
223 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) ); 221 QWhatsThis::add( m_destEditBtn, tr( "Tap here to edit the entry selected above." ) );
224 layout->addWidget( btn, 1, 1 ); 222 connect( m_destEditBtn, SIGNAL(clicked()), this, SLOT(slotDestEdit()) );
225 223 layout->addWidget( m_destEditBtn, 1, 1 );
226 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); 224
227 grpbox->layout()->setSpacing( 2 ); 225 m_destDeleteBtn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
228 grpbox->layout()->setMargin( 4 ); 226 m_destDeleteBtn->setEnabled( false );
229 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); 227 QWhatsThis::add( m_destDeleteBtn, tr( "Tap here to delete the entry selected above." ) );
230 228 connect( m_destDeleteBtn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) );
231 QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); 229 layout->addWidget( m_destDeleteBtn, 1, 2 );
232
233 QLabel *label = new QLabel( tr( "Name:" ), grpbox );
234 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
235 grplayout->addWidget( label, 0, 0 );
236 m_destName = new QLineEdit( grpbox );
237 QWhatsThis::add( m_destName, tr( "Enter the name of this entry here." ) );
238 grplayout->addMultiCellWidget( m_destName, 0, 0, 1, 2 );
239
240 label = new QLabel( tr( "Location:" ), grpbox );
241 QWhatsThis::add( label, tr( "Enter the absolute directory path of this entry here." ) );
242 grplayout->addWidget( label, 1, 0 );
243 m_destLocation = new QLineEdit( grpbox );
244 QWhatsThis::add( m_destLocation, tr( "Enter the absolute directory path of this entry here." ) );
245 grplayout->addWidget( m_destLocation, 1, 1 );
246 btn = new QPushButton( Resource::loadPixmap( "folder" ), QString::null, grpbox );
247 btn->setMaximumWidth( btn->height() );
248 QWhatsThis::add( btn, tr( "Tap here to select the desired location." ) );
249 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestSelectPath()) );
250 grplayout->addWidget( btn, 1, 2 );
251
252 m_destActive = new QCheckBox( tr( "Active" ), grpbox );
253 QWhatsThis::add( m_destActive, tr( "Tap here to indicate whether this entry is active or not." ) );
254 grplayout->addMultiCellWidget( m_destActive, 2, 2, 0, 2 );
255
256 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
257 QWhatsThis::add( btn, tr( "Tap here to update the entry's information." ) );
258 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestUpdate()) );
259 grplayout->addMultiCellWidget( btn, 3, 3, 0, 2 );
260} 230}
@@ -476,3 +446,3 @@ void OIpkgConfigDlg::slotServerEdit()
476 446
477 // Delete server 447 // Edit server
478 if ( server ) 448 if ( server )
@@ -503,29 +473,47 @@ void OIpkgConfigDlg::slotServerDelete()
503 473
504void OIpkgConfigDlg::slotDestEdit( int index ) 474void OIpkgConfigDlg::slotDestSelected( int index )
505{ 475{
506 m_destNew = false;
507 m_destCurrent = index; 476 m_destCurrent = index;
477
478 // Enable Edit and Delete buttons
479 m_destEditBtn->setEnabled( true );
480 m_destDeleteBtn->setEnabled( true );
481}
508 482
509 // Find selected destination in list 483void OIpkgConfigDlg::slotDestNew()
510 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() ); 484{
511 485 OConfItem *dest = new OConfItem( OConfItem::Destination );
512 // Display destination details 486
513 if ( destination ) 487 OIpkgDestDlg dlg( dest, this );
488 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
514 { 489 {
515 m_destCurrName = destination->name(); 490 // Add to configuration option list
516 m_destName->setText( destination->name() ); 491 m_configs->append( dest );
517 m_destLocation->setText( destination->value() ); 492 m_configs->sort();
518 m_destActive->setChecked( destination->active() ); 493
519 m_destName->setFocus(); 494 // Add to destination list
495 m_destList->insertItem( dest->name() );
496 m_destList->setCurrentItem( m_destList->count() );
520 } 497 }
498 else
499 delete dest;
521} 500}
522 501
523void OIpkgConfigDlg::slotDestNew() 502void OIpkgConfigDlg::slotDestEdit()
524{ 503{
525 m_destNew = true; 504 // Find selected destination in list
505 OConfItem *dest = findConfItem( OConfItem::Destination, m_destList->currentText() );
526 506
527 m_destName->setText( QString::null ); 507 // Edit destination
528 m_destLocation->setText( QString::null ); 508 if ( dest )
529 m_destActive->setChecked( true ); 509 {
530 m_destName->setFocus(); 510 QString origName = dest->name();
511 OIpkgDestDlg dlg( dest, this );
512 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
513 {
514 // Check to see if name has changed, if so update the dest list
515 if ( dest->name() != origName )
516 m_destList->changeItem( dest->name(), m_destCurrent );
517 }
518 }
531} 519}
@@ -545,53 +533,2 @@ void OIpkgConfigDlg::slotDestDelete()
545 533
546void OIpkgConfigDlg::slotDestSelectPath()
547{
548 QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_destLocation->text() );
549 if ( path.at( path.length() - 1 ) == '/' )
550 path.truncate( path.length() - 1 );
551 m_destLocation->setText( path );
552}
553
554void OIpkgConfigDlg::slotDestUpdate()
555{
556 QString newName = m_destName->text();
557
558 // Convert any spaces to underscores
559 newName.replace( QRegExp( " " ), "_" );
560
561 if ( !m_destNew )
562 {
563 // Find selected destination in list
564 OConfItem *destination = findConfItem( OConfItem::Destination, m_destCurrName );
565
566 // Display destination details
567 if ( destination )
568 {
569 // Update url
570 destination->setValue( m_destLocation->text() );
571 destination->setActive( m_destActive->isChecked() );
572
573 // Check if destination name has changed, if it has then we need to replace the key in the map
574 if ( m_destCurrName != newName )
575 {
576 // Update destination name
577 destination->setName( newName );
578
579 // Update list box
580 m_destList->changeItem( newName, m_destCurrent );
581 }
582 }
583 }
584 else
585 {
586 // Add new destination to configuration list
587 m_configs->append( new OConfItem( OConfItem::Destination, newName,
588 m_destLocation->text(), QString::null, m_destActive->isChecked() ) );
589 m_configs->sort();
590
591 m_destList->insertItem( newName );
592 m_destList->setCurrentItem( m_destList->count() );
593 m_destNew = false;
594 }
595}
596
597OIpkgServerDlg::OIpkgServerDlg( OConfItem *server, QWidget *parent ) 534OIpkgServerDlg::OIpkgServerDlg( OConfItem *server, QWidget *parent )
@@ -600,3 +537,3 @@ OIpkgServerDlg::OIpkgServerDlg( OConfItem *server, QWidget *parent )
600{ 537{
601 setCaption( tr( "Edit server" ) ); 538 setCaption( tr( "Edit Server" ) );
602 539
@@ -646,3 +583,5 @@ void OIpkgServerDlg::accept()
646 // Save information entered 583 // Save information entered
647 m_server->setName( m_name->text() ); 584 QString name = m_name->text();
585 name.replace( QRegExp( " " ), "_" );
586 m_server->setName( name );
648 m_server->setValue( m_location->text() ); 587 m_server->setValue( m_location->text() );
@@ -654 +593,72 @@ void OIpkgServerDlg::accept()
654} 593}
594
595OIpkgDestDlg::OIpkgDestDlg( OConfItem *dest, QWidget *parent )
596 : QDialog( parent, QString::null, true, WStyle_ContextHelp )
597 , m_dest( dest )
598{
599 setCaption( tr( "Edit Destination" ) );
600
601 // Initialize UI
602 QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 );
603
604 m_active = new QCheckBox( tr( "Active" ), this );
605 QWhatsThis::add( m_active, tr( "Tap here to indicate whether this entry is active or not." ) );
606 layout->addWidget( m_active );
607
608 layout->addStretch();
609
610 QLabel *label = new QLabel( tr( "Name:" ), this );
611 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
612 layout->addWidget( label );
613 m_name = new QLineEdit( this );
614 QWhatsThis::add( m_name, tr( "Enter the name of this entry here." ) );
615 layout->addWidget( m_name );
616
617 layout->addStretch();
618
619 label = new QLabel( tr( "Location:" ), this );
620 QWhatsThis::add( label, tr( "Enter the absolute directory path of this entry here." ) );
621 layout->addWidget( label );
622
623 QHBoxLayout *layout2 = new QHBoxLayout( this, 2, 4 );
624 layout->addLayout( layout2 );
625
626 m_location = new QLineEdit( this );
627 QWhatsThis::add( m_location, tr( "Enter the absolute directory path of this entry here." ) );
628 layout2->addWidget( m_location );
629 QPushButton *btn = new QPushButton( Resource::loadPixmap( "folder" ), QString::null, this );
630 btn->setMaximumWidth( btn->height() );
631 QWhatsThis::add( btn, tr( "Tap here to select the desired location." ) );
632 connect( btn, SIGNAL(clicked()), this, SLOT(slotSelectPath()) );
633 layout2->addWidget( btn );
634
635 // Populate initial information
636 if ( m_dest )
637 {
638 m_name->setText( m_dest->name() );
639 m_location->setText( m_dest->value() );
640 m_active->setChecked( m_dest->active() );
641 }
642}
643
644void OIpkgDestDlg::accept()
645{
646 // Save information entered
647 QString name = m_name->text();
648 name.replace( QRegExp( " " ), "_" );
649 m_dest->setName( name );
650 m_dest->setValue( m_location->text() );
651 m_dest->setActive( m_active->isChecked() );
652
653 QDialog::accept();
654}
655
656void OIpkgDestDlg::slotSelectPath()
657{
658 QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_location->text() );
659 if ( path.at( path.length() - 1 ) == '/' )
660 path.truncate( path.length() - 1 );
661 if ( !path.isNull() )
662 m_location->setText( path );
663}
664
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.h b/noncore/settings/packagemanager/oipkgconfigdlg.h
index 076a181..5b7e91d 100644
--- a/noncore/settings/packagemanager/oipkgconfigdlg.h
+++ b/noncore/settings/packagemanager/oipkgconfigdlg.h
@@ -65,11 +65,5 @@ private:
65 65
66 // Server cached information 66 // Server/Destination cached information
67 bool m_serverNew; // Indicates if server information is for a new server 67 int m_serverCurrent; // Index of currently selected server in m_serverList
68 int m_serverCurrent; // Index of currently selected server in m_serverList 68 int m_destCurrent; // Index of currently selected destination in m_destList
69 QString m_serverCurrName; // Name of currently selected server in m_serverList
70
71 // Destination cached information
72 bool m_destNew; // Indicates if destination information is for a new destination
73 int m_destCurrent; // Index of currently selected destination in m_destList
74 QString m_destCurrName; // Name of currently selected destination in m_destList
75 69
@@ -89,6 +83,5 @@ private:
89 // Destination configuration UI controls 83 // Destination configuration UI controls
90 QListBox *m_destList; // Destination list selection 84 QListBox *m_destList; // Destination list selection
91 QLineEdit *m_destName; // Destination name edit box 85 QPushButton *m_destEditBtn; // Destination edit button
92 QLineEdit *m_destLocation; // Destination location URL edit box 86 QPushButton *m_destDeleteBtn; // Destination edit button
93 QCheckBox *m_destActive; // Activate destination check box
94 87
@@ -124,9 +117,7 @@ private slots:
124 void slotServerDelete(); 117 void slotServerDelete();
125// void slotServerUpdate();
126 118
127 void slotDestEdit( int index ); 119 void slotDestSelected( int index );
128 void slotDestNew(); 120 void slotDestNew();
121 void slotDestEdit();
129 void slotDestDelete(); 122 void slotDestDelete();
130 void slotDestSelectPath();
131 void slotDestUpdate();
132}; 123};
@@ -153,2 +144,24 @@ private:
153 144
145class OIpkgDestDlg : public QDialog
146{
147 Q_OBJECT
148
149public:
150 OIpkgDestDlg( OConfItem *dest = 0l, QWidget *parent = 0l );
151
152protected slots:
153 void accept();
154
155private:
156 OConfItem *m_dest;
157
158 // UI controls
159 QLineEdit *m_name; // Destination name edit box
160 QLineEdit *m_location; // Destination location URL edit box
161 QCheckBox *m_active; // Indicates whether the destination is activated
162
163private slots:
164 void slotSelectPath();
165};
166
154#endif 167#endif