From fdac326bcab7425ca021d4910e4668bd3ff95d31 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Thu, 3 Dec 2009 14:02:20 +0100 Subject: [PATCH] Compute proper Selectable::pickStatus --- zypp/ui/SelectableImpl.cc | 71 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/zypp/ui/SelectableImpl.cc b/zypp/ui/SelectableImpl.cc index 8a118ef..877d636 100644 --- a/zypp/ui/SelectableImpl.cc +++ b/zypp/ui/SelectableImpl.cc @@ -340,11 +340,80 @@ namespace zypp return pi_r.status().setTransact( yesno_r, causer_r ); } + /////////////////////////////////////////////////////////////////// + Status Selectable::Impl::pickStatus( const PoolItem & pi_r ) const { - return status(); + if ( pi_r.satSolvable().ident() == ident() ) + { + if ( pi_r.satSolvable().isSystem() ) + { + // have installed! + if ( pi_r.status().isLocked() ) + return S_Protected; + + // at least one identical available transacing? + for_( it, _availableItems.begin(), _availableItems.end() ) + { + if ( identical( *it, pi_r ) ) + { + if ( (*it).status().transacts() ) + return( (*it).status().isByUser() ? S_Update : S_AutoUpdate ); + } + } + + // no update, so maybe delete? + if ( pi_r.status().transacts() ) + return ( pi_r.status().isByUser() ? S_Del : S_AutoDel ); + + // keep + return S_KeepInstalled; + } + else + { + // have available! + if ( pi_r.status().isLocked() ) + return S_Taboo; + + // have identical installed? (maybe transacting): + PoolItem inst; + for_( it, _installedItems.begin(), _installedItems.end() ) + { + if ( identical( *it, pi_r ) ) + { + if ( (*it).status().transacts() ) + { + inst = *it; + break; + } + if ( !inst ) + inst = *it; + } + } + + // check for inst/update + if ( pi_r.status().transacts() ) + { + if ( inst ) + return( pi_r.status().isByUser() ? S_Update : S_AutoUpdate ); + else + return( pi_r.status().isByUser() ? S_Install : S_AutoInstall ); + } + + // no inst/update, so maybe delete? + if ( ! inst ) + return S_NoInst; + + if ( inst.status().transacts() ) + return( inst.status().isByUser() ? S_Del : S_AutoDel ); + + return S_KeepInstalled; + } + } + return Status(-1); // not my PoolItem } + /////////////////////////////////////////////////////////////////// ResStatus::TransactByValue Selectable::Impl::modifiedBy() const { -- 2.7.4