- Allow ui::Selectable queries via Selectable::Fate (TO_DELETE/UNMODIFIED/TO_INSTALL)
authorMichael Andres <ma@suse.de>
Mon, 13 Mar 2006 12:55:18 +0000 (12:55 +0000)
committerMichael Andres <ma@suse.de>
Mon, 13 Mar 2006 12:55:18 +0000 (12:55 +0000)
zypp/ui/Selectable.cc
zypp/ui/Selectable.h

index 734eff8..f21a693 100644 (file)
@@ -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<<
index 7b66702..82d9cb7 100644 (file)
@@ -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.