reapack

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

commit f79b8e1f0fbe1b0c0019989f68069107e8880f7a
parent a927f0ca80f70a482095cc469698d2c64968c2d6
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Tue, 19 Apr 2016 23:14:25 -0400

add "Package Contents" view

Diffstat:
Msrc/about.cpp | 17++++++++++++++++-
Msrc/about.hpp | 1+
Msrc/browser.cpp | 15+++++++++++++++
Msrc/browser.hpp | 1+
Msrc/report.cpp | 28+++++++++++++++++++++++++++-
Msrc/report.hpp | 14++++++++++++++
6 files changed, 74 insertions(+), 2 deletions(-)

diff --git a/src/about.cpp b/src/about.cpp @@ -34,7 +34,7 @@ using namespace std; -enum { ACTION_HISTORY = 300 }; +enum { ACTION_HISTORY = 300, ACTION_CONTENTS }; About::About(IndexPtr index) : Dialog(IDD_ABOUT_DIALOG), m_index(index), @@ -90,6 +90,9 @@ void About::onCommand(const int id, int) case IDC_INSTALL: close(InstallResult); break; + case ACTION_CONTENTS: + packageContents(); + break; case ACTION_HISTORY: packageHistory(); break; @@ -112,6 +115,7 @@ void About::onContextMenu(HWND target, const int x, const int y) return; Menu menu; + menu.addAction(AUTO_STR("Package &Contents"), ACTION_CONTENTS); menu.addAction(AUTO_STR("Package &History"), ACTION_HISTORY); menu.show(x, y, handle()); } @@ -275,3 +279,14 @@ void About::packageHistory() const Package *pkg = m_packagesData->at(index); Dialog::Show<History>(instance(), handle(), pkg); } + +void About::packageContents() +{ + const int index = m_packages->currentIndex(); + + if(index < 0) + return; + + const Package *pkg = m_packagesData->at(index); + Dialog::Show<Contents>(instance(), handle(), pkg); +} diff --git a/src/about.hpp b/src/about.hpp @@ -50,6 +50,7 @@ private: void selectLink(int control, const std::vector<const Link *> &); void openLink(const Link *); void packageHistory(); + void packageContents(); IndexPtr m_index; int m_currentCat; diff --git a/src/browser.cpp b/src/browser.cpp @@ -42,6 +42,7 @@ enum Action { ACTION_REINSTALL_ALL, ACTION_UNINSTALL, ACTION_UNINSTALL_ALL, + ACTION_CONTENTS, ACTION_HISTORY, ACTION_ABOUT, ACTION_RESET_ALL, @@ -135,6 +136,9 @@ void Browser::onCommand(const int id, const int event) case ACTION_UNINSTALL_ALL: selectionDo(bind(&Browser::uninstall, this, arg::_1, false)); break; + case ACTION_CONTENTS: + contents(m_currentIndex); + break; case ACTION_HISTORY: history(m_currentIndex); break; @@ -267,6 +271,9 @@ void Browser::onContextMenu(HWND target, const int x, const int y) menu.addSeparator(); menu.setEnabled(!entry->test(ObsoleteFlag), + menu.addAction(AUTO_STR("Package &Contents"), ACTION_CONTENTS)); + + menu.setEnabled(!entry->test(ObsoleteFlag), menu.addAction(AUTO_STR("Package &History"), ACTION_HISTORY)); auto_char aboutLabel[255] = {}; @@ -642,6 +649,14 @@ void Browser::history(const int index) const Dialog::Show<History>(instance(), handle(), entry->package); } +void Browser::contents(const int index) const +{ + const Entry *entry = getEntry(index); + + if(entry) + Dialog::Show<Contents>(instance(), handle(), entry->package); +} + void Browser::about(const int index) const { if(const Entry *entry = getEntry(index)) diff --git a/src/browser.hpp b/src/browser.hpp @@ -116,6 +116,7 @@ private: void uninstall(int index, bool toggle = true); void resetAction(int index); void history(int index) const; + void contents(int index) const; void about(int index) const; std::vector<IndexPtr> m_indexes; diff --git a/src/report.cpp b/src/report.cpp @@ -65,7 +65,10 @@ void ReportDialog::printVersion(const Version *ver) stream() << " – " << date; stream() << NL; - +} + +void ReportDialog::printChangelog(const Version *ver) +{ const string &changelog = ver->changelog(); printIndented(changelog.empty() ? "No changelog" : changelog); } @@ -149,6 +152,7 @@ void Report::printUpdates() break; printVersion(ver); + printChangelog(ver); } } } @@ -192,5 +196,27 @@ void History::fillReport() stream() << NL; printVersion(ver); + printChangelog(ver); + } +} + +Contents::Contents(const Package *pkg) + : ReportDialog(), m_package(pkg) +{ +} + +void Contents::fillReport() +{ + SetWindowText(handle(), AUTO_STR("Package Contents")); + SetWindowText(getControl(IDC_LABEL), + make_autostring(m_package->name()).c_str()); + + for(const Version *ver : m_package->versions() | boost::adaptors::reversed) { + if(stream().tellp()) + stream() << NL; + + printVersion(ver); + for(const Path &file : ver->files()) + printIndented(file.join()); } } diff --git a/src/report.hpp b/src/report.hpp @@ -20,6 +20,8 @@ #include "dialog.hpp" +#include "registry.hpp" + #include <sstream> class Package; @@ -40,6 +42,7 @@ protected: void printHeader(const char *); void printVersion(const Version *); + void printChangelog(const Version *); void printIndented(const std::string &); private: @@ -73,4 +76,15 @@ private: const Package *m_package; }; +class Contents : public ReportDialog { +public: + Contents(const Package *); + +protected: + void fillReport() override; + +private: + const Package *m_package; +}; + #endif