42 #define YUILogComponent "qt-pkg" 45 #include <zypp/Repository.h> 49 #include <QHeaderView> 50 #include <QStylePainter> 51 #include <QStyleOptionButton> 52 #include <QMessageBox> 53 #include <QApplication> 56 #include "YQPkgVersionsView.h" 57 #include "YQPkgRepoList.h" 58 #include "YQIconPool.h" 59 #include "YQSignalBlocker.h" 66 : QScrollArea( parent )
71 _isMixedMultiVersion =
false;
72 _parentTab =
dynamic_cast<QTabWidget *
> (parent);
74 _buttons =
new QButtonGroup(
this);
78 connect( _parentTab, SIGNAL( currentChanged(
int ) ),
79 this, SLOT (
reload (
int ) ) );
93 if ( _parentTab && _parentTab->widget( newCurrent ) == this )
101 _selectable = selectable;
106 if ( _parentTab->currentWidget() == this )
119 _selectable = selectable;
125 qDeleteAll( _installed );
128 _content =
new QWidget(
this );
129 setWidget( _content );
135 _content =
new QWidget(
this );
136 _layout =
new QVBoxLayout( _content );
137 _content->setLayout( _layout );
139 QLabel * pkgNameLabel =
new QLabel(
this );
141 if ( ! selectable->theObj() )
144 _layout->addWidget( pkgNameLabel );
146 QFont font = pkgNameLabel->font();
147 font.setBold(
true );
149 QFontMetrics fm( font) ;
150 font.setPixelSize( (
int) ( fm.height() * 1.1 ) );
152 pkgNameLabel->setFont( font );
153 pkgNameLabel->setText( fromUTF8(selectable->theObj()->name().c_str()) );
157 QListIterator<QAbstractButton*> it( _buttons->buttons() );
159 while ( it.hasNext() )
166 qDeleteAll( _installed );
169 if ( selectable->multiversionInstall() )
175 zypp::ui::Selectable::picklist_iterator it = selectable->picklistBegin();
177 while ( it != selectable->picklistEnd() )
181 _installed.push_back( version );
182 _layout->addWidget( version );
188 version, SLOT ( update() ) );
201 zypp::ui::Selectable::installed_iterator it = selectable->installedBegin();
203 while ( it != selectable->installedEnd() )
205 QString text = _(
"%1-%2 from vendor %3 (installed)" )
206 .arg( fromUTF8( (*it)->edition().asString().c_str() ) )
207 .arg( fromUTF8( (*it)->arch().asString().c_str() ) )
208 .arg( fromUTF8( (*it)->vendor().c_str() ) ) ;
210 QWidget * installedVersion =
new QWidget(
this );
211 QHBoxLayout * instLayout =
new QHBoxLayout( installedVersion );
212 instLayout->setContentsMargins( 0, 0, 0, 0 );
214 QLabel * icon =
new QLabel( installedVersion );
215 icon->setPixmap( YQIconPool::pkgSatisfied() );
216 instLayout->addWidget( icon );
218 QLabel * textLabel =
new QLabel( text, installedVersion );
219 instLayout->addWidget( textLabel );
220 instLayout->addStretch();
222 _installed.push_back( installedVersion );
223 _layout->addWidget( installedVersion );
235 zypp::ui::Selectable::available_iterator it = selectable->availableBegin();
237 while ( it != selectable->availableEnd() )
239 QRadioButton *radioButton =
new YQPkgVersion(
this, selectable, *it );
240 connect( radioButton, SIGNAL( clicked(
bool ) ),
243 _buttons->addButton( radioButton );
244 _layout->addWidget( radioButton );
247 if ( selectable->hasCandidateObj() &&
248 selectable->candidateObj()->edition() == (*it)->edition() &&
249 selectable->candidateObj()->arch() == (*it)->arch() )
251 radioButton->setChecked(
true);
259 _layout->addStretch();
260 setWidget( _content );
268 QListIterator<QAbstractButton*> it( _buttons->buttons() );
270 while ( it.hasNext() )
274 if ( versionItem && versionItem->isChecked() )
276 ZyppObj newCandidate = versionItem->
zyppObj();
278 if ( _selectable && *newCandidate != _selectable->candidateObj() )
280 yuiMilestone() <<
"Candidate changed" << endl;
284 ZyppStatus status = _selectable->status();
286 if ( !_selectable->installedEmpty() &&
287 _selectable->installedObj()->arch() == newCandidate->arch() &&
288 _selectable->installedObj()->edition() == newCandidate->edition() )
292 status = S_KeepInstalled;
298 case S_KeepInstalled:
317 _selectable->setStatus( status );
322 _selectable->setCandidate( newCandidate );
334 return QSize( 0, 0 );
342 Q_CHECK_PTR( poolItem );
344 bool multiVersion = poolItem->multiversionInstall();
346 yuiMilestone() <<
"Selected: " 347 << ( multiVersion ?
"Multiversion " :
"Non-Multiversion " )
348 << newSelected->text()
353 yuiMilestone() <<
"Multiversion and non-multiversion conflict!" << endl;
358 _selectable->setPickStatus( poolItem, S_Install );
380 QString msg = _(
"You are trying to install multiversion-capable\n" 381 "and non-multiversion-capable versions of this\n" 382 "package at the same time." );
388 _(
"This version is multiversion-capable.\n" 390 "Press \"Continue\" to install this version\n" 391 "and unselect the non-multiversion-capable version,\n" 392 "\"Cancel\" to unselect this version and keep the other one." );
397 _(
"This version is not multiversion-capable.\n" 399 "Press \"Continue\" to install only this version\n" 400 "and unselect all other versions,\n" 401 "\"Cancel\" to unselect this version and keep the other ones." );
405 QString heading = _(
"Incompatible Package Versions" );
407 int buttonNo = QMessageBox::question( 0,
412 yuiMilestone() <<
"User hit " << (buttonNo == 0 ?
"[Continue]" :
"[Cancel]" ) << endl;
414 return buttonNo == 0;
425 zypp::ui::Selectable::available_iterator it = _selectable->availableBegin();
427 while ( it != _selectable->availableEnd() )
429 if ( it->multiversionInstall() == multiversion )
431 switch ( _selectable->pickStatus( *it ) )
435 yuiMilestone() <<
"Found " << ( multiversion ?
"multiversion" :
"non-multiversion" )
436 <<
" to install" << endl;
447 yuiMilestone() <<
"No " << ( multiversion ?
"multiversion" :
"non-multiversion" )
448 <<
" to install" << endl;
459 zypp::ui::Selectable::available_iterator it = _selectable->availableBegin();
461 while ( it != _selectable->availableEnd() )
463 if ( it->multiversionInstall() )
465 switch ( _selectable->pickStatus( *it ) )
469 _selectable->setPickStatus( *it, S_NoInst );
470 yuiMilestone() <<
"Unselecting " << *it << endl;
489 zypp::ui::Selectable::available_iterator it = selectable->availableBegin();
491 if ( it == selectable->availableEnd() )
494 bool multiversion = it->multiversionInstall();
496 while ( it != selectable->availableEnd() )
498 if ( it->multiversionInstall() != multiversion )
500 yuiMilestone() <<
"Mixed multiversion" << endl;
518 : QRadioButton( parent )
519 , _selectable( selectable )
520 , _zyppObj( zyppObj )
531 setText( _(
"%1-%2 from %3 with priority %4 and vendor %5" )
532 .arg( fromUTF8(
zyppObj->edition().asString().c_str() ) )
533 .arg( fromUTF8(
zyppObj->arch().asString().c_str() ) )
534 .arg( fromUTF8(
zyppObj->repository().info().name().c_str() ) )
535 .arg(
zyppObj->repository().info().priority() )
536 .arg( fromUTF8(
zyppObj->vendor().c_str() ) ) );
552 tip = _(
"This version is installed in your system." );
562 ZyppPoolItem zyppPoolItem )
563 : QCheckBox( parent )
565 , _selectable( selectable )
566 , _zyppPoolItem( zyppPoolItem )
568 setText (_(
"%1-%2 from %3 with priority %4 and vendor %5" )
569 .arg( fromUTF8(
zyppPoolItem->edition().asString().c_str() ) )
570 .arg( fromUTF8(
zyppPoolItem->arch().asString().c_str() ) )
571 .arg( fromUTF8(
zyppPoolItem->repository().info().name().c_str() ) )
575 connect(
this, SIGNAL( toggled(
bool) ),
576 this, SLOT ( slotIconClicked() ) );
586 void YQPkgMultiVersion::slotIconClicked()
589 YQSignalBlocker sigBlocker(
this );
599 ZyppStatus oldStatus = _selectable->pickStatus( _zyppPoolItem );
600 ZyppStatus newStatus = oldStatus;
607 newStatus = S_NoInst;
610 case S_KeepInstalled:
619 newStatus = S_KeepInstalled;
624 newStatus = S_Install;
628 bool handled =
false;
631 newStatus == S_Install &&
632 oldStatus != newStatus )
638 setStatus( newStatus );
640 yuiMilestone() <<
"oldStatus: " << oldStatus << endl;
641 ZyppStatus actualStatus = _selectable->pickStatus( _zyppPoolItem );
643 if ( actualStatus != newStatus )
644 yuiWarning() <<
"FAILED to set new status: " << newStatus
645 <<
" actual Status: " << actualStatus << endl;
647 yuiMilestone() <<
"newStatus:" << newStatus << endl;
649 if ( oldStatus != actualStatus )
657 void YQPkgMultiVersion::setStatus( ZyppStatus newStatus )
659 yuiMilestone() <<
"Setting pick status to " << newStatus << endl;
660 _selectable->setPickStatus( _zyppPoolItem, newStatus );
667 QStylePainter p(
this);
668 QStyleOptionButton opt;
669 initStyleOption(&opt);
670 p.drawControl(QStyle::CE_CheckBox, opt);
674 QRect elementRect = style()->subElementRect ( QStyle::SE_CheckBoxIndicator, &opt);
675 QPixmap icon = statusIcon( _selectable->pickStatus(_zyppPoolItem) );
677 QPoint start = elementRect.center() - icon.rect().center();
678 QRect rect = QRect(start.x(), start.y(), icon.width(), icon.height());
680 p.drawItemPixmap( rect, 0, icon );
684 QPixmap YQPkgMultiVersion::statusIcon( ZyppStatus status )
686 QPixmap icon = YQIconPool::pkgNoInst();
690 case S_Del: icon = YQIconPool::pkgDel();
break;
691 case S_Install: icon = YQIconPool::pkgInstall();
break;
692 case S_KeepInstalled: icon = YQIconPool::pkgKeepInstalled();
break;
693 case S_NoInst: icon = QPixmap();
break;
694 case S_Protected: icon = YQIconPool::pkgProtected();
break;
695 case S_Taboo: icon = YQIconPool::pkgTaboo();
break;
696 case S_Update: icon = YQIconPool::pkgUpdate();
break;
698 case S_AutoDel: icon = YQIconPool::pkgAutoDel();
break;
699 case S_AutoInstall: icon = YQIconPool::pkgAutoInstall();
break;
700 case S_AutoUpdate: icon = YQIconPool::pkgAutoUpdate();
break;
ZyppPoolItem zyppPoolItem() const
Returns the original ZYPP object.
ZyppObj zyppObj() const
Returns the original ZYPP object.
virtual QString toolTip(int column)
Returns a tool tip text for a specific column of this item.
bool isMixedMultiVersion() const
Return the cached value for the current selectable.
YQPkgMultiVersion(YQPkgVersionsView *parent, ZyppSel selectable, ZyppPoolItem zyppPoolItem)
Constructor.
YQPkgVersion(QWidget *parent, ZyppSel selectable, ZyppObj zyppObj)
Constructor.
void showDetailsIfVisible(ZyppSel selectable)
Show details for the specified package.
virtual ~YQPkgVersion()
Destructor.
virtual ~YQPkgMultiVersion()
Destructor.
YQPkgVersionsView(QWidget *parent)
Constructor.
Package version selector: Display a list of available versions from all the different installation so...
virtual QSize minimumSizeHint() const
Returns the minimum size required for this widget.
void paintEvent(QPaintEvent *)
Paints checkboxes with status icons instead of a checkmark.
void checkForChangedCandidate()
Check for changed candidates.
bool anyMultiVersionToInstall(bool multiversion) const
Check if any package version is marked for installation where its 'multiversion' flag is set to 'mult...
bool mixedMultiVersionPopup(bool multiversion) const
Ask user if he really wants to install incompatible package versions.
void unselectAllMultiVersion()
Unselect all multiversion package versions.
void candidateChanged(ZyppObj newCandidate)
Emitted when the user changes the candidate.
virtual ~YQPkgVersionsView()
Destructor.
bool handleMixedMultiVersion(YQPkgMultiVersion *newSelected)
Negotiate between multiversion and non-multiversion packages if there are both kinds in that selectab...
ZyppSel selectable() const
Returns the original ZYPP selectable.
void statusChanged()
Emitted when the status of this package version is changed.
void cycleStatus()
Cycle the package status to the next valid value.
static bool isMixedMultiVersion(ZyppSel selectable)
Return 'true' if 'selectable' has mixed multiversion flags, 'false' if all its pool items are of the ...
void statusChanged()
Emitted when the status of any package changed.
void reload(int newCurrent)
Show data for the current package.
void showDetails(ZyppSel selectable)
Show details for the specified package.