Author: tgoettlicher Date: Tue May 15 17:20:20 2007 New Revision: 5551 URL: http://svn.opensuse.org/viewcvs/zypp?rev=5551&view=rev Log: button logic rewritten for use of different backend plugins Modified: branches/work/updater-kde-refactoring/updater-kde/updater/MainWindow.cpp branches/work/updater-kde-refactoring/updater-kde/updater/MainWindow.h branches/work/updater-kde-refactoring/updater-kde/updater/UpdaterApplication.cpp branches/work/updater-kde-refactoring/updater-kde/updater/dummy/DummyUpdater.cpp Modified: branches/work/updater-kde-refactoring/updater-kde/updater/MainWindow.cpp URL: http://svn.opensuse.org/viewcvs/zypp/branches/work/updater-kde-refactoring/updater-kde/updater/MainWindow.cpp?rev=5551&r1=5550&r2=5551&view=diff ============================================================================== --- branches/work/updater-kde-refactoring/updater-kde/updater/MainWindow.cpp (original) +++ branches/work/updater-kde-refactoring/updater-kde/updater/MainWindow.cpp Tue May 15 17:20:20 2007 @@ -51,24 +51,11 @@ -void MainWindow::setUpdaterCapabilities(const UpdaterCapabilities &caps) -{ - kdDebug() << "CAPS" << _caps.canSelectIndividualUpdates << endl; - - _caps = caps; - - if (_caps.canSelectIndividualUpdates==false) - disableButtons(true); - else - disableButtons(false); -} - -MainWindow::MainWindow( const UpdaterCapabilities &caps, QWidget *parent) +MainWindow::MainWindow(QWidget *parent) : KMainWindow(parent) { - KIconLoader iconLoader(PROGRAM_NAME); applet = new TrayIcon(this); @@ -78,7 +65,6 @@ timer = new QTimer(this); slotConfigChanged(); connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdates())); - //timerInterval is read in by readConfig timer->start(timerInterval,false); initGUI(); @@ -86,7 +72,6 @@ _edit_sources_action = new KAction(i18n("Add/Remove Update Sources..."),0,0,this,SLOT(serverButtonClicked()), actionCollection(),"edit_sources"); _configure_applet_action = new KAction(i18n("Configure Applet..."),0,0,this,SLOT(configButtonClicked()), actionCollection(),"confgure_applet"); _check_updates_action = new KAction(i18n("Check Now"),0,0,this,SLOT(checkUpdates()), actionCollection(),"configure_applet"); - _install_updates_action = new KAction(i18n("Install"),0,0,this,SLOT(installButtonClicked()), actionCollection(),"configure_applet");; _edit_sources_action->plug(applet->contextMenu(), 1); @@ -101,7 +86,6 @@ popup = new OSUpdaterPopup(applet,this); hide(); - } /************************************************************* @@ -110,25 +94,12 @@ **************************************************************/ -// Read in the config, just the interval really as we cannot deal with the updater itself -void MainWindow::slotConfigChanged() -{ - int interval; - interval = UpdaterSettings::self()->interval() * 60 * 60 * 1000; // convert to ms - timerInterval = interval; - timer->changeInterval(timerInterval); - - emit(signalConfigChanged()); - -} - //Build GUI, setup system tray and hide GUI initially. void MainWindow::initGUI() { centralWidget = new QWidget( this ); setCentralWidget( centralWidget ); - KIconLoader *loader = KGlobal::iconLoader(); setIcon(loader->loadIcon(PROGRAM_NAME, KIcon::Small)); @@ -144,8 +115,6 @@ selectAllButton = new KPushButton(i18n("Select All"), centralWidget); clearSelectionButton = new KPushButton(i18n("Clear Selection"), centralWidget); -// updateList->setSelectionMode ( QListView::NoSelection ); - mainBox->addWidget(header, 0, 0); mainBox->addWidget(updateList, 0, 0); @@ -193,43 +162,52 @@ connect(updateList, SIGNAL(contextMenuRequested(QListViewItem*, const QPoint&, int)), this, SLOT(slotPackageRightClicked(QListViewItem*, const QPoint&, int))); + connect(updateList, SIGNAL(selectionChanged()), + this, SLOT(slotPackageSelectionChanged())); + + mainBox->setSpacing(10); mainBox->setMargin(10); resize(400,500); setIcon(UserIcon(TRAY_ICON_GREEN)); setCaption(i18n("Available Updates")); hide(); - return; } -/* - Button logic for mainWindow: - If disable is true, we disable select/install buttons. - If false, we make decisions based on whether we have - updates and if they are selected -*/ -void MainWindow::disableButtons(bool disable) { +void MainWindow::updateButtons() { - if (disable) { //If true, we just disable the buttons +// if there are updates selected for installation, enable this button +if ( (_caps.canSelectIndividualUpdates==true && updatesSelected > 0) ) // || +// (_caps.canSelectIndividualUpdates==false && > 0) ) + { + installButton->setDisabled(false); + } + else + { installButton->setDisabled(true); - if (selectAllButton != NULL) { //if not null, we need to disable these buttons too - selectAllButton->setDisabled(true); - clearSelectionButton->setDisabled(true); - } - } else if (selectAllButton != NULL) { //if this is true, we have to deal with the CheckListItems - if (updateList->childCount() > 0) { //if there are updates in the list, enable these - selectAllButton->setDisabled(false); - clearSelectionButton->setDisabled(false); - } - if (updatesSelected > 0) //if there are updates selected for installation, enable this button - installButton->setDisabled(false); - else - installButton->setDisabled(true); //else disable it - } else if (updateList->childCount() > 0) { //if we don't have to deal with selections, - installButton->setDisabled(false); //just enable the install button if there are updates } } +void MainWindow::setUpdaterCapabilities(const UpdaterCapabilities &caps) +{ + _caps = caps; + + if (_caps.canSelectIndividualUpdates==false) + { + selectAllButton->hide(); + clearSelectionButton->hide(); + updateList->setSelectionMode ( QListView::NoSelection ); + } + else + { + selectAllButton->show(); + clearSelectionButton->show(); + updateList->setSelectionMode ( QListView::Multi ); + } + updateButtons(); + +} + /********************************************************************* Slots recieving signals from the updater @@ -243,6 +221,7 @@ void MainWindow::slotAppletError(const QString &desc) { + kdDebug() << "Applet error, description: " << desc << endl; kdDebug() << "Applet error, description length: " << desc.length() << endl; applet->setUpdates(0); applet->setState(APPLET_PROBLEM, desc); @@ -257,8 +236,23 @@ popup->setUpdates(n); } +// Read in the config: set Intervall and inform UpdaterApplication to reload correct plugin +void MainWindow::slotConfigChanged() +{ + int interval; + interval = UpdaterSettings::self()->interval() * 60 * 60 * 1000; // convert to ms + timerInterval = interval; + timer->changeInterval(timerInterval); + + emit(signalConfigChanged()); + +} + + +// TODO void MainWindow::populateDone() { + kdDebug() << "populateDone()" << endl; //if selectAllButton is not NULL, then we have check boxes if (selectAllButton != NULL) { @@ -277,8 +271,13 @@ } } //applet->setUpdates(updateList->childCount()); + + updateButtons(); + } + +// TODO void MainWindow::disableSelectButtons() { //if selectAllButton is not NULL, we have not yet disabled it @@ -335,12 +334,10 @@ void MainWindow::slotLoadConfig() { - } void MainWindow::slotSaveConfig() { - } void MainWindow::installButtonClicked() { @@ -367,6 +364,7 @@ *************************************************************************/ void MainWindow::selectButtonClicked() { + QCheckListItem *item = (QCheckListItem*)updateList->firstChild(); while (item != NULL) { @@ -376,7 +374,8 @@ item = (QCheckListItem*)item->nextSibling(); } updatesSelected = updateList->childCount(); - disableButtons(false); + + updateButtons(); } void MainWindow::clearButtonClicked() { @@ -389,7 +388,7 @@ item = (QCheckListItem*)item->nextSibling(); } updatesSelected = 0; - disableButtons(false); + updateButtons(); } @@ -397,8 +396,8 @@ //Clear the list and fire the update signal to the backend updateList->clear(); packageDescription->setText(""); - disableButtons(true); updatesSelected = 0; + updateButtons(); emit(populateUpdateList(updateList)); } @@ -409,11 +408,31 @@ //We have to enable the select buttons here, if they exist // disableButtons(false); // } + + + updateButtons(); emit(updateSelected(packageSelected)); } -void MainWindow::slotPackageClicked(QListViewItem *pack) { -// disableButtons(false); +void MainWindow::slotPackageSelectionChanged() { + + updatesSelected = 0; + + QCheckListItem *item = (QCheckListItem*)updateList->firstChild(); + + while (item != NULL) { + if (item->isOn()) { + updatesSelected++; + } + item = (QCheckListItem*)item->nextSibling(); + } + + updateButtons(); +} + + +void MainWindow::slotPackageClicked(QListViewItem *pack) +{ } //Menu/Lock Menu Slot Modified: branches/work/updater-kde-refactoring/updater-kde/updater/MainWindow.h URL: http://svn.opensuse.org/viewcvs/zypp/branches/work/updater-kde-refactoring/updater-kde/updater/MainWindow.h?rev=5551&r1=5550&r2=5551&view=diff ============================================================================== --- branches/work/updater-kde-refactoring/updater-kde/updater/MainWindow.h (original) +++ branches/work/updater-kde-refactoring/updater-kde/updater/MainWindow.h Tue May 15 17:20:20 2007 @@ -79,7 +79,7 @@ Init function @param parent the parent window, always null in our case. */ - MainWindow( const UpdaterCapabilities &caps, QWidget *parent=0); + MainWindow(QWidget *parent=0); @@ -198,13 +198,14 @@ */ void showMainWindow(); - private slots: void slotExit(); void slotPackageSelected(QListViewItem *packageSelected); void slotPackageRightClicked(QListViewItem*, const QPoint&, int); void slotPackageClicked(QListViewItem *); + void slotPackageSelectionChanged(); + void configButtonClicked(); void serverButtonClicked(); @@ -229,8 +230,7 @@ //Decides which buttons to disable, if arg is true, //we disable all the buttons. - //If false the logic runs - void disableButtons(bool); + void updateButtons(); TrayIcon *applet; QListView *updateList; Modified: branches/work/updater-kde-refactoring/updater-kde/updater/UpdaterApplication.cpp URL: http://svn.opensuse.org/viewcvs/zypp/branches/work/updater-kde-refactoring/updater-kde/updater/UpdaterApplication.cpp?rev=5551&r1=5550&r2=5551&view=diff ============================================================================== --- branches/work/updater-kde-refactoring/updater-kde/updater/UpdaterApplication.cpp (original) +++ branches/work/updater-kde-refactoring/updater-kde/updater/UpdaterApplication.cpp Tue May 15 17:20:20 2007 @@ -38,7 +38,7 @@ { - _main = new MainWindow(UpdaterCapabilities()); + _main = new MainWindow(); setMainWidget(_main); connect(this, SIGNAL(pluginError(const QString &)), _main, SLOT(slotAppletError(const QString &))); @@ -47,7 +47,7 @@ connectToPlugin(); - _main->setUpdaterCapabilities(UpdaterCapabilities()); + _main->setUpdaterCapabilities(_updater->capabilities()); } void UpdaterApplication::connectToPlugin() @@ -129,6 +129,7 @@ { kdDebug() << "Config has changed. Reloading backend plugin..." << endl; connectToPlugin(); + _main->setUpdaterCapabilities(_updater->capabilities()); } Modified: branches/work/updater-kde-refactoring/updater-kde/updater/dummy/DummyUpdater.cpp URL: http://svn.opensuse.org/viewcvs/zypp/branches/work/updater-kde-refactoring/updater-kde/updater/dummy/DummyUpdater.cpp?rev=5551&r1=5550&r2=5551&view=diff ============================================================================== --- branches/work/updater-kde-refactoring/updater-kde/updater/dummy/DummyUpdater.cpp (original) +++ branches/work/updater-kde-refactoring/updater-kde/updater/dummy/DummyUpdater.cpp Tue May 15 17:20:20 2007 @@ -68,7 +68,6 @@ UpdaterCapabilities DummyUpdater::capabilities() { UpdaterCapabilities caps; -// caps.canSelectIndividualUpdates = false; caps.canSelectIndividualUpdates = true; return caps; } @@ -105,6 +104,9 @@ int patchcount=1; QCheckListItem *newItem; + QCheckListItem *newItem2; + QCheckListItem *newItem3; + newItem = new QCheckListItem(_list_view, "HALLO", QCheckListItem::CheckBox); newItem->setText(COLUMN_NAME, "Dummy-Program: Fixes nothing since this is an example"); @@ -112,6 +114,22 @@ newItem->setText(COLUMN_NEW_VERSION, "42" ); newItem->setText(COLUMN_CATALOG, "Dummy-Source" ); + newItem2 = new QCheckListItem(_list_view, "HALLO", QCheckListItem::CheckBox); + + newItem2->setText(COLUMN_NAME, "Dummy-Program: Fixes nothing too"); + newItem2->setText(COLUMN_TYPE, "Dummy-Patch"); + newItem2->setText(COLUMN_NEW_VERSION, "43" ); + newItem2->setText(COLUMN_CATALOG, "Dummy-Source" ); + + newItem3 = new QCheckListItem(_list_view, "HALLO", QCheckListItem::CheckBox); + + newItem3->setText(COLUMN_NAME, "Dummy-Program: Fixes absolutely nothing"); + newItem3->setText(COLUMN_TYPE, "Dummy-Patch"); + newItem3->setText(COLUMN_NEW_VERSION, "44" ); + newItem3->setText(COLUMN_CATALOG, "Dummy-Source" ); + + + if ( patchcount > 0 ) { emit(updateApplet(APPLET_UPDATES, patchcount)); -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org