commit 82e9c805798b511c7dc640500d375eec8eeb5f4c
parent 2cb25492e14e5f5379ac4a9bf77220a9f36266c2
Author: cfillion <cfillion@users.noreply.github.com>
Date: Sat, 8 Oct 2016 19:38:31 -0400
about pkg: also try to select the current version when opened from about repo
Diffstat:
3 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/src/about.cpp b/src/about.cpp
@@ -405,7 +405,16 @@ void AboutIndexDelegate::findInBrowser()
void AboutIndexDelegate::aboutPackage()
{
const Package *pkg = currentPackage();
- m_dialog->setDelegate(make_shared<AboutPackageDelegate>(pkg, nullptr, m_reapack));
+
+ Version current;
+
+ try {
+ Registry reg(Path::prefixRoot(Path::REGISTRY));
+ current = reg.getEntry(pkg).version;
+ }
+ catch(const reapack_error &) {}
+
+ m_dialog->setDelegate(make_shared<AboutPackageDelegate>(pkg, current, m_reapack));
}
void AboutIndexDelegate::install()
@@ -443,7 +452,7 @@ void AboutIndexDelegate::install()
}
AboutPackageDelegate::AboutPackageDelegate(const Package *pkg,
- const Version *ver, ReaPack *reapack)
+ const Version &ver, ReaPack *reapack)
: m_package(pkg), m_current(ver), m_reapack(reapack),
m_index(pkg->category()->index()->shared_from_this())
{
@@ -470,7 +479,7 @@ void AboutPackageDelegate::init(About *dialog)
for(const Version *ver : m_package->versions()) {
const auto index = dialog->menu()->addRow({make_autostring(ver->name())});
- if(m_current && *ver == *m_current)
+ if(m_current == *ver)
dialog->menu()->select(index);
}
diff --git a/src/about.hpp b/src/about.hpp
@@ -24,17 +24,16 @@
#include <memory>
#include <vector>
+#include "version.hpp"
+
class AboutDelegate;
class Index;
class ListView;
class Menu;
class Metadata;
-class Package;
class ReaPack;
class RichEdit;
-class Source;
class TabBar;
-class Version;
struct Link;
typedef std::shared_ptr<const Index> IndexPtr;
@@ -120,7 +119,7 @@ private:
class AboutPackageDelegate : public AboutDelegate {
public:
- AboutPackageDelegate(const Package *, const Version *current, ReaPack *);
+ AboutPackageDelegate(const Package *, const Version ¤t, ReaPack *);
protected:
void init(About *) override;
@@ -135,7 +134,7 @@ private:
void copySourceUrl();
const Package *m_package;
- const Version *m_current;
+ Version m_current;
ReaPack *m_reapack;
IndexPtr m_index; // keeps the package loaded in memory
const std::vector<const Source *> *m_sources;
diff --git a/src/browser.cpp b/src/browser.cpp
@@ -849,7 +849,7 @@ void Browser::aboutPackage(const int index)
const Entry *entry = getEntry(index);
if(entry && entry->package)
- m_reapack->about()->setDelegate(make_shared<AboutPackageDelegate>(entry->package, entry->current, m_reapack));
+ m_reapack->about()->setDelegate(make_shared<AboutPackageDelegate>(entry->package, entry->regEntry.version, m_reapack));
}
void Browser::aboutRemote(const int index)