From ef568c5ff7f3a5a26a82723848c00e4e1a0503ba Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Mon, 13 Mar 2006 12:55:18 +0000 Subject: [PATCH] - Allow ui::Selectable queries via Selectable::Fate (TO_DELETE/UNMODIFIED/TO_INSTALL) --- zypp/ui/Selectable.cc | 25 +++++++++++++++++++++++++ zypp/ui/Selectable.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/zypp/ui/Selectable.cc b/zypp/ui/Selectable.cc index 734eff8..f21a693 100644 --- a/zypp/ui/Selectable.cc +++ b/zypp/ui/Selectable.cc @@ -91,6 +91,31 @@ namespace zypp { _pimpl->setLicenceConfirmed( val_r ); } + Selectable::Fate Selectable::fate() const + { + switch ( status() ) { + case S_Update: + case S_Install: + case S_AutoUpdate: + case S_AutoInstall: + return TO_INSTALL; + break; + + case S_Del: + case S_AutoDel: + return TO_DELETE; + break; + + case S_Protected: + case S_Taboo: + case S_KeepInstalled: + case S_NoInst: + break; + } + return UNMODIFIED; + }; + + /****************************************************************** ** ** FUNCTION NAME : operator<< diff --git a/zypp/ui/Selectable.h b/zypp/ui/Selectable.h index 7b66702..82d9cb7 100644 --- a/zypp/ui/Selectable.h +++ b/zypp/ui/Selectable.h @@ -120,6 +120,35 @@ namespace zypp { return ! installedObj() && candidateObj(); } //@} + public: + /** \name Query objects fate in case of commit. + */ + //@{ + enum Fate { + TO_DELETE = -1, + UNMODIFIED = 0, + TO_INSTALL = 1 + }; + /** */ + Fate fate() const; + + /** True if either to delete or to install */ + bool unmodified() const + { return fate() == UNMODIFIED; } + + /** True if either to delete or to install */ + bool toModify() const + { return fate() != UNMODIFIED; } + + /** True if to delete */ + bool toDelete() const + { return fate() == TO_DELETE; } + + /** True if to install */ + bool toInstall() const + { return fate() == TO_INSTALL; } + //@} + public: /** \name Special inteface for Y2UI. * \note This interface acts on \ref ResStatus::USER level. -- 2.7.4