commit e2f0a87c9a69c3fdd82c08a69400e7763d547b82
parent 5e1b104cdbefa2d3027a0190aa5e3c90c51dd81a
Author: cfillion <cfillion@users.noreply.github.com>
Date: Tue, 24 Oct 2017 08:51:17 -0400
merge Browser::Entry::canPin with Browser::Entry::possibleActions
Diffstat:
4 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/browser.cpp b/src/browser.cpp
@@ -750,7 +750,7 @@ void Browser::updateAction(const int index)
return;
const auto &it = find(m_actions.begin(), m_actions.end(), entry);
- if(!entry->target && (!entry->pin || !entry->canPin())) {
+ if(!entry->target && (!entry->pin || !entry->test(Entry::CanTogglePin))) {
if(it != m_actions.end())
m_actions.erase(it);
}
diff --git a/src/browser.hpp b/src/browser.hpp
@@ -95,7 +95,7 @@ private:
void updateFilter();
void updateAbout();
void fillList();
- Entry *getEntry(int);
+ Entry *getEntry(int listIndex);
void updateDisplayLabel();
void displayButton();
void actionsButton();
diff --git a/src/browser_entry.cpp b/src/browser_entry.cpp
@@ -76,7 +76,7 @@ string Browser::Entry::displayState() const
if(target)
state += *target == nullptr ? 'R' : 'I';
- if(pin && canPin())
+ if(pin && test(CanTogglePin))
state += 'P';
return state;
@@ -212,7 +212,7 @@ void Browser::Entry::fillMenu(Menu &menu) const
}
const UINT pinIndex = menu.addAction("&Pin current version", ACTION_PIN);
- if(!canPin())
+ if(!test(CanTogglePin))
menu.disable(pinIndex);
if(pin.value_or(regEntry.pinned))
menu.check(pinIndex);
@@ -241,6 +241,8 @@ int Browser::Entry::possibleActions() const
flags |= CanReinstall;
if(test(InstalledFlag) && !test(ProtectedFlag) && (!target || *target != nullptr))
flags |= CanUninstall;
+ if(target ? *target != nullptr : test(InstalledFlag))
+ flags |= CanTogglePin;
if(target || pin)
flags |= CanClearQueued;
diff --git a/src/browser_entry.hpp b/src/browser_entry.hpp
@@ -41,11 +41,13 @@ public:
ProtectedFlag = 1<<4,
};
- enum PossibleActions {
+ enum PossibleAction {
CanInstallLatest = 1<<0,
CanReinstall = 1<<1,
CanUninstall = 1<<2,
CanClearQueued = 1<<3,
+
+ CanTogglePin = 1<<10,
};
Entry(const Package *, const Registry::Entry &, const IndexPtr &);
@@ -71,7 +73,7 @@ public:
int possibleActions() const;
bool test(Flag f) const { return (m_flags & f) == f; }
- bool canPin() const { return target ? *target != nullptr : test(InstalledFlag); }
+ bool test(PossibleAction f) const { return (possibleActions() & f) == f; }
bool operator==(const Entry &o) const;
private: