reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

browser_entry.hpp (2504B)


      1 /* ReaPack: Package manager for REAPER
      2  * Copyright (C) 2015-2025  Christian Fillion
      3  *
      4  * This program is free software: you can redistribute it and/or modify
      5  * it under the terms of the GNU Lesser General Public License as published by
      6  * the Free Software Foundation, either version 3 of the License, or
      7  * (at your option) any later version.
      8  *
      9  * This program is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12  * GNU Lesser General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU Lesser General Public License
     15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     16  */
     17 
     18 #ifndef REAPACK_BROWSER_ENTRY_HPP
     19 #define REAPACK_BROWSER_ENTRY_HPP
     20 
     21 #include "browser.hpp"
     22 #include "listview.hpp"
     23 #include "registry.hpp"
     24 
     25 #include <memory>
     26 #include <optional>
     27 
     28 class Index;
     29 class Menu;
     30 class Remote;
     31 
     32 typedef std::shared_ptr<const Index> IndexPtr;
     33 
     34 class Browser::Entry {
     35 public:
     36   enum Flag {
     37     UninstalledFlag = 1<<0,
     38     InstalledFlag   = 1<<1,
     39     OutOfDateFlag   = 1<<2,
     40     ObsoleteFlag    = 1<<3,
     41     ProtectedFlag   = 1<<4,
     42   };
     43 
     44   enum PossibleAction {
     45     CanInstallLatest = 1<<0,
     46     CanReinstall     = 1<<1,
     47     CanUninstall     = 1<<2,
     48     CanClearQueued   = 1<<3,
     49 
     50     CanToggleFlags   = 1<<10,
     51   };
     52 
     53   Entry(const Package *, const Registry::Entry &, const IndexPtr &);
     54   Entry(const Registry::Entry &, const IndexPtr &);
     55 
     56   std::optional<const Version *> target;
     57   std::optional<int> flags;
     58 
     59   std::string displayState() const;
     60   const std::string &indexName() const;
     61   const std::string &categoryName() const;
     62   const std::string &packageName() const;
     63   std::string displayName() const;
     64   Package::Type type() const;
     65   std::string displayType() const;
     66   std::string displayVersion() const;
     67   const VersionName *sortVersion() const;
     68   std::string displayAuthor() const;
     69   const Time *lastUpdate() const;
     70 
     71   void updateRow(ListView::Row *) const;
     72   void fillMenu(Menu &) const;
     73 
     74   int possibleActions(bool allowToggle) const;
     75   bool test(Flag f) const { return (m_flags & f) == f; }
     76   bool test(PossibleAction f, bool allowToggle = true) const {
     77     return (possibleActions(allowToggle) & f) == f; }
     78   bool operator==(const Entry &o) const;
     79 
     80 private:
     81   int m_flags;
     82 
     83 public:
     84   Registry::Entry regEntry;
     85   const Package *package;
     86   IndexPtr index;
     87   const Version *current;
     88   const Version *latest;
     89 };
     90 
     91 #endif