commit d312f314fa3119a1d5518d89563c13763ed0abb1
parent e51f841744e68bf0f38d7bc1d6b009eb3b3e4ccf
Author: cfillion <cfillion@users.noreply.github.com>
Date: Tue, 2 Feb 2016 22:10:52 -0500
populate the Installed Files tab of the about dialog
Diffstat:
4 files changed, 50 insertions(+), 3 deletions(-)
diff --git a/src/about.cpp b/src/about.cpp
@@ -18,15 +18,18 @@
#include "about.hpp"
#include "encoding.hpp"
+#include "errors.hpp"
#include "index.hpp"
#include "listview.hpp"
#include "menu.hpp"
+#include "registry.hpp"
#include "remote.hpp"
#include "resource.hpp"
#include "richedit.hpp"
#include "tabbar.hpp"
#include <boost/algorithm/string/replace.hpp>
+#include <sstream>
using namespace std;
@@ -60,10 +63,12 @@ void About::onInit()
{AUTO_STR("Author"), 90},
});
+ m_installedFiles = getControl(IDC_LIST);
+
m_tabs = createControl<TabBar>(IDC_TABS, TabBar::Tabs{
{AUTO_STR("Description"), {m_about->handle()}},
{AUTO_STR("Packages"), {m_cats->handle(), m_packages->handle()}},
- {AUTO_STR("Installed Files"), {}},
+ {AUTO_STR("Installed Files"), {m_installedFiles}},
});
populate();
@@ -128,6 +133,8 @@ void About::populate()
m_cats->addRow({make_autostring(cat->name())});
updatePackages();
+
+ updateInstalledFiles();
}
void About::updatePackages()
@@ -165,6 +172,40 @@ void About::updatePackages()
m_currentCat = catIndex;
}
+void About::updateInstalledFiles()
+{
+ set<Path> allFiles;
+
+ try {
+ Registry reg(Path::prefixCache("registry.db"));
+ for(const Registry::Entry &entry : reg.getEntries(*m_remote)) {
+ const set<Path> &files = reg.getFiles(entry);
+ allFiles.insert(files.begin(), files.end());
+ }
+ }
+ catch(const reapack_error &e) {
+ const auto_string &desc = make_autostring(e.what());
+ auto_char msg[255] = {};
+ auto_snprintf(msg, sizeof(msg),
+ AUTO_STR("Cannot load the list of installed files: %s"), desc.c_str());
+ SetWindowText(m_installedFiles, msg);
+ return;
+ }
+
+ if(allFiles.empty()) {
+ SetWindowText(m_installedFiles, AUTO_STR(
+ "This repository does not own any file on your computer at this time."));
+ }
+ else {
+ stringstream stream;
+
+ for(const Path &path : allFiles)
+ stream << path.join() << "\r\n";
+
+ SetWindowText(m_installedFiles, make_autostring(stream.str()).c_str());
+ }
+}
+
void About::selectLink(const int ctrl, const std::vector<const Link *> &links)
{
const int count = (int)links.size();
diff --git a/src/about.hpp b/src/about.hpp
@@ -41,6 +41,7 @@ protected:
private:
void populate();
void updatePackages();
+ void updateInstalledFiles();
void selectLink(const int control, const std::vector<const Link *> &);
void openLink(const Link *);
@@ -52,6 +53,7 @@ private:
RichEdit *m_about;
ListView *m_cats;
ListView *m_packages;
+ HWND m_installedFiles;
std::vector<const Link *> m_websiteLinks;
std::vector<const Link *> m_donationLinks;
diff --git a/src/database.cpp b/src/database.cpp
@@ -92,8 +92,10 @@ int Database::errorCode() const
void Database::begin()
{
- // EXCLUSIVE -> don't wait until the first query to aquire a lock
- exec("BEGIN EXCLUSIVE TRANSACTION");
+ // IMMEDIATE -> don't wait until the first query to aquire a lock
+ // but still allow new read-only connections (unlike EXCLUSIVE)
+ // while preventing new transactions to be made as long as it's active
+ exec("BEGIN IMMEDIATE TRANSACTION");
}
void Database::commit()
diff --git a/src/resource.rc b/src/resource.rc
@@ -54,6 +54,8 @@ BEGIN
LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP, 10, 20, 96, 220
CONTROL "", IDC_PACKAGES, WC_LISTVIEW, LVS_REPORT | LVS_SINGLESEL |
LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP, 110, 20, 340, 220
+ EDITTEXT IDC_LIST, 10, 20, 440, 220,
+ WS_VSCROLL | ES_MULTILINE | ES_READONLY | NOT WS_TABSTOP
PUSHBUTTON "&Website", IDC_WEBSITE, 5, 250, 45, 14
PUSHBUTTON "&Donate...", IDC_DONATE, 54, 250, 45, 14
PUSHBUTTON "&Enable this repository!", IDC_ENABLE, 285, 250, 120, 14