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" 67 : QScrollArea( parent )
72 _isMixedMultiVersion =
false;
73 _parentTab =
dynamic_cast<QTabWidget *
> (parent);
77 connect( _parentTab, SIGNAL( currentChanged(
int ) ),
78 this, SLOT (
reload (
int ) ) );
92 if ( _parentTab && _parentTab->widget( newCurrent ) == this )
105 if ( _parentTab->currentWidget() == this )
120 QWidget * content = widget();
123 content =
new QWidget(
this );
124 _buttonGroup =
new QButtonGroup( content );
125 _layout =
new QVBoxLayout( content );
126 content->setLayout( _layout );
130 setWidget( content );
134 QLabel * pkgNameLabel =
new QLabel(
this );
139 _layout->addWidget( pkgNameLabel );
141 QFont font = pkgNameLabel->font();
142 font.setBold(
true );
144 QFontMetrics fm( font) ;
145 font.setPixelSize( (
int) ( fm.height() * 1.1 ) );
147 pkgNameLabel->setFont( font );
148 pkgNameLabel->setText( fromUTF8(
selectable->theObj()->name().c_str()) );
156 zypp::ui::Selectable::picklist_iterator it =
selectable->picklistBegin();
162 _layout->addWidget( version );
168 version, SLOT ( update() ) );
181 zypp::ui::Selectable::installed_iterator it =
selectable->installedBegin();
191 text = _(
"%1-%2 [RETRACTED] from vendor %3 (installed)" )
192 .arg( fromUTF8( (*it)->edition().asString().c_str() ) )
193 .arg( fromUTF8( (*it)->arch().asString().c_str() ) )
194 .arg( fromUTF8( (*it)->vendor().c_str() ) ) ;
199 text = _(
"%1-%2 from vendor %3 (installed)" )
200 .arg( fromUTF8( (*it)->edition().asString().c_str() ) )
201 .arg( fromUTF8( (*it)->arch().asString().c_str() ) )
202 .arg( fromUTF8( (*it)->vendor().c_str() ) ) ;
205 QWidget * installedVersion =
new QWidget(
this );
206 QHBoxLayout * instLayout =
new QHBoxLayout( installedVersion );
207 instLayout->setContentsMargins( 0, 0, 0, 0 );
209 QLabel * icon =
new QLabel( installedVersion );
210 icon->setPixmap( YQIconPool::pkgSatisfied() );
211 instLayout->addWidget( icon );
213 QLabel * textLabel =
new QLabel( text, installedVersion );
214 instLayout->addWidget( textLabel );
215 instLayout->addStretch();
220 _layout->addWidget( installedVersion );
232 zypp::ui::Selectable::available_iterator it =
selectable->availableBegin();
238 connect( radioButton, SIGNAL( clicked(
bool ) ),
241 _buttonGroup->addButton( radioButton );
242 _layout->addWidget( radioButton );
244 if ( ! _buttonGroup->checkedButton() &&
246 selectable->candidateObj()->edition() == (*it)->edition() &&
247 selectable->candidateObj()->arch() == (*it)->arch() )
249 radioButton->setChecked(
true );
257 _layout->addStretch();
262 setWidget( content );
269 QPalette pal = widget->palette();
270 pal.setColor( QPalette::WindowText, Qt::red );
271 widget->setPalette( pal );
277 zypp::ui::Selectable::available_iterator it =
selectable->availableBegin();
281 if ( (*it)->isRetracted() )
283 if ( installed->edition() == (*it)->edition() &&
284 installed->arch() == (*it)->arch() &&
285 installed->vendor() == (*it)->vendor() )
301 QListIterator<QAbstractButton*> it( _buttonGroup->buttons() );
303 while ( it.hasNext() )
307 if ( versionItem && versionItem->isChecked() )
309 ZyppObj newCandidate = versionItem->
zyppObj();
311 if ( _selectable && *newCandidate != _selectable->candidateObj() )
313 yuiMilestone() <<
"Candidate changed" << endl;
317 ZyppStatus status = _selectable->status();
319 if ( !_selectable->installedEmpty() &&
320 _selectable->installedObj()->arch() == newCandidate->arch() &&
321 _selectable->installedObj()->edition() == newCandidate->edition() )
325 status = S_KeepInstalled;
331 case S_KeepInstalled:
350 _selectable->setStatus( status );
355 _selectable->setCandidate( newCandidate );
367 return QSize( 0, 0 );
375 Q_CHECK_PTR( poolItem );
377 bool multiVersion = poolItem->multiversionInstall();
379 yuiMilestone() <<
"Selected: " 380 << ( multiVersion ?
"Multiversion " :
"Non-Multiversion " )
381 << newSelected->text()
386 yuiMilestone() <<
"Multiversion and non-multiversion conflict!" << endl;
391 _selectable->setPickStatus( poolItem, S_Install );
413 QString msg = _(
"You are trying to install multiversion-capable\n" 414 "and non-multiversion-capable versions of this\n" 415 "package at the same time." );
421 _(
"This version is multiversion-capable.\n" 423 "Press \"Continue\" to install this version\n" 424 "and unselect the non-multiversion-capable version,\n" 425 "\"Cancel\" to unselect this version and keep the other one." );
430 _(
"This version is not multiversion-capable.\n" 432 "Press \"Continue\" to install only this version\n" 433 "and unselect all other versions,\n" 434 "\"Cancel\" to unselect this version and keep the other ones." );
438 QString heading = _(
"Incompatible Package Versions" );
440 int buttonNo = QMessageBox::question( 0,
445 yuiMilestone() <<
"User hit " << (buttonNo == 0 ?
"[Continue]" :
"[Cancel]" ) << endl;
447 return buttonNo == 0;
458 zypp::ui::Selectable::available_iterator it = _selectable->availableBegin();
460 while ( it != _selectable->availableEnd() )
462 if ( it->multiversionInstall() == multiversion )
464 switch ( _selectable->pickStatus( *it ) )
468 yuiMilestone() <<
"Found " << ( multiversion ?
"multiversion" :
"non-multiversion" )
469 <<
" to install" << endl;
480 yuiMilestone() <<
"No " << ( multiversion ?
"multiversion" :
"non-multiversion" )
481 <<
" to install" << endl;
492 zypp::ui::Selectable::available_iterator it = _selectable->availableBegin();
494 while ( it != _selectable->availableEnd() )
496 if ( it->multiversionInstall() )
498 switch ( _selectable->pickStatus( *it ) )
502 _selectable->setPickStatus( *it, S_NoInst );
503 yuiMilestone() <<
"Unselecting " << *it << endl;
522 zypp::ui::Selectable::available_iterator it =
selectable->availableBegin();
527 bool multiversion = it->multiversionInstall();
531 if ( it->multiversionInstall() != multiversion )
533 yuiMilestone() <<
"Mixed multiversion" << endl;
551 : QRadioButton( parent )
552 , _selectable( selectable )
553 , _zyppObj( zyppObj )
566 setText( _(
"%1-%2 [RETRACTED] from %3 with priority %4 and vendor %5" )
567 .arg( fromUTF8(
zyppObj->edition().asString().c_str() ) )
568 .arg( fromUTF8(
zyppObj->arch().asString().c_str() ) )
569 .arg( fromUTF8(
zyppObj->repository().info().name().c_str() ) )
570 .arg(
zyppObj->repository().info().priority() )
571 .arg( fromUTF8(
zyppObj->vendor().c_str() ) ) );
586 setText( _(
"%1-%2 from %3 with priority %4 and vendor %5" )
587 .arg( fromUTF8(
zyppObj->edition().asString().c_str() ) )
588 .arg( fromUTF8(
zyppObj->arch().asString().c_str() ) )
589 .arg( fromUTF8(
zyppObj->repository().info().name().c_str() ) )
590 .arg(
zyppObj->repository().info().priority() )
591 .arg( fromUTF8(
zyppObj->vendor().c_str() ) ) );
608 tip = _(
"This version is installed in your system." );
618 ZyppPoolItem zyppPoolItem )
619 : QCheckBox( parent )
621 , _selectable( selectable )
622 , _zyppPoolItem( zyppPoolItem )
624 setText (_(
"%1-%2 from %3 with priority %4 and vendor %5" )
625 .arg( fromUTF8(
zyppPoolItem->edition().asString().c_str() ) )
626 .arg( fromUTF8(
zyppPoolItem->arch().asString().c_str() ) )
627 .arg( fromUTF8(
zyppPoolItem->repository().info().name().c_str() ) )
631 connect(
this, SIGNAL( toggled(
bool) ),
632 this, SLOT ( slotIconClicked() ) );
642 void YQPkgMultiVersion::slotIconClicked()
645 YQSignalBlocker sigBlocker(
this );
654 ZyppStatus oldStatus = _selectable->pickStatus( _zyppPoolItem );
655 ZyppStatus newStatus = oldStatus;
662 newStatus = S_NoInst;
665 case S_KeepInstalled:
674 newStatus = S_KeepInstalled;
679 newStatus = S_Install;
683 bool handled =
false;
686 newStatus == S_Install &&
687 oldStatus != newStatus )
693 setStatus( newStatus );
695 yuiMilestone() <<
"oldStatus: " << oldStatus << endl;
696 ZyppStatus actualStatus = _selectable->pickStatus( _zyppPoolItem );
698 if ( actualStatus != newStatus )
699 yuiWarning() <<
"FAILED to set new status: " << newStatus
700 <<
" actual Status: " << actualStatus << endl;
702 yuiMilestone() <<
"newStatus:" << newStatus << endl;
704 if ( oldStatus != actualStatus )
712 void YQPkgMultiVersion::setStatus( ZyppStatus newStatus )
714 yuiMilestone() <<
"Setting pick status to " << newStatus << endl;
715 _selectable->setPickStatus( _zyppPoolItem, newStatus );
722 QStylePainter p(
this );
723 QStyleOptionButton opt;
724 initStyleOption( &opt );
725 p.drawControl( QStyle::CE_CheckBox, opt );
729 QRect elementRect = style()->subElementRect ( QStyle::SE_CheckBoxIndicator, &opt );
730 QPixmap icon = statusIcon( _selectable->pickStatus( _zyppPoolItem ) );
732 QPoint start = elementRect.center() - icon.rect().center();
733 QRect rect = QRect( start.x(), start.y(), icon.width(), icon.height() );
735 p.drawItemPixmap( rect, 0, icon );
739 QPixmap YQPkgMultiVersion::statusIcon( ZyppStatus status )
741 QPixmap icon = YQIconPool::pkgNoInst();
745 case S_Del: icon = YQIconPool::pkgDel();
break;
746 case S_Install: icon = YQIconPool::pkgInstall();
break;
747 case S_KeepInstalled: icon = YQIconPool::pkgKeepInstalled();
break;
748 case S_NoInst: icon = QPixmap();
break;
749 case S_Protected: icon = YQIconPool::pkgProtected();
break;
750 case S_Taboo: icon = YQIconPool::pkgTaboo();
break;
751 case S_Update: icon = YQIconPool::pkgUpdate();
break;
753 case S_AutoDel: icon = YQIconPool::pkgAutoDel();
break;
754 case S_AutoInstall: icon = YQIconPool::pkgAutoInstall();
break;
755 case S_AutoUpdate: icon = YQIconPool::pkgAutoUpdate();
break;
static void setRetractedColor(QWidget *widget)
Set the colors of a widget for a retracted zyppObj.
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.
ZyppSel selectable() const
Return the selectable of this details view.
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 installedIsRetracted(ZyppSel selectable, ZyppObj installed)
Return 'true' if 'installed' is retraced, i.e.
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.