namespace ui
{ /////////////////////////////////////////////////////////////////
+ struct StatusHelper
+ {
+ StatusHelper( const Selectable::Impl & impl )
+ : _impl( impl )
+ , inst( impl.installedObj() )
+ , cand( impl.candidateObj() )
+ {}
+
+ bool hasInstalled() const
+ { return inst; }
+
+ bool hasCandidate() const
+ { return cand; }
+
+ bool hasInstalledOnly() const
+ { return inst && !cand; }
+
+ bool hasCandidateOnly() const
+ { return cand && !inst; }
+
+ bool hasBoth() const
+ { return inst && cand; }
+
+
+ bool userSetInstall() const
+ { return false; }
+
+ bool userSetDelete() const
+ { return false; }
+
+ bool userUnset() const
+ { return false; }
+
+ bool autoSetInstall() const
+ { return false; }
+
+ bool autoSetDelete() const
+ { return false; }
+
+ const Selectable::Impl & _impl;
+ PoolItem inst;
+ PoolItem cand;
+ };
+
/**
* \todo Still open questions in state calculation;
* neglecting TABOO/PROTECTED
return( installedObj() ? S_KeepInstalled : S_NoInst );
}
+
+ /**
+ * \todo Neglecting TABOO/PROTECTED
+ */
+ bool Selectable::Impl::set_status( const Status state_r )
+ {
+ StatusHelper self( *this );
+
+ switch ( state_r )
+ {
+ case S_Protected:
+ case S_Taboo:
+ return false;
+
+ case S_Del:
+ return self.userSetDelete();
+ break;
+
+ case S_Install:
+ return self.hasCandidateOnly() && self.userSetInstall();
+ break;
+
+ case S_Update:
+ return self.hasBoth() && self.userSetInstall();
+ break;
+
+ case S_AutoDel:
+ return self.autoSetDelete();
+ break;
+
+ case S_AutoInstall:
+ return self.hasCandidateOnly() && self.autoSetInstall();
+ break;
+
+ case S_AutoUpdate:
+ return self.hasBoth() && self.autoSetInstall();
+ break;
+
+ case S_KeepInstalled:
+ return self.hasInstalled() && self.userUnset();
+ break;
+
+ case S_NoInst:
+ return !self.hasInstalled() && self.userUnset();
+ break;
+ }
+
+ return false;
+ }
+
+
/////////////////////////////////////////////////////////////////
} // namespace ui
///////////////////////////////////////////////////////////////////
Status status() const;
/** */
- bool set_status( const Status state_r )
- { return false; }
+ bool set_status( const Status state_r );
/** Installed object. */
PoolItem installedObj() const
{ return _installedItem; }
/** Best among available objects.
- * \nore Transacted Objects prefered, Status calculation relies on it.
+ * \note Transacted Objects prefered, Status calculation relies on it.
+ * \note Need sort order based on (arch,edition), requires arch compat lists.
*/
PoolItem candidateObj() const
{ return( _availableItems.empty() ? PoolItem() : *_availableItems.begin() ); }