removed redundant std_uniques, and fixed

add name so it does not flash so horribly

Massively violating dry - I need to extract the repeated
code into a struct that does the cleanup when it is
destroyed
This commit is contained in:
Cheng 2023-11-12 03:56:47 +00:00
parent 53cd580da1
commit 55d0d69c8f
No known key found for this signature in database
GPG Key ID: 571C3A9C3B9E6FCA
3 changed files with 47 additions and 8 deletions

View File

@ -17,8 +17,7 @@ namespace ro {
//Owns a database connection and closes it when it is deconstructed //Owns a database connection and closes it when it is deconstructed
//Has move semantics //Has move semantics
class dbconnect : public std::unique_ptr<ISqlite3> { struct dbconnect : std::unique_ptr<ISqlite3> {
public:
dbconnect(const wxFileName&); //And here we wrap our Cish implementation in C++ish implementation dbconnect(const wxFileName&); //And here we wrap our Cish implementation in C++ish implementation
dbconnect() = delete; dbconnect() = delete;
~dbconnect() = default; //Our base class takes care of it ~dbconnect() = default; //Our base class takes care of it

View File

@ -7,7 +7,9 @@ display_wallet::display_wallet(wxWindow* parent, wxFileName& walletfile) :
m_db(walletfile), m_DisplayWalletEditMenu(1), m_db(walletfile), m_DisplayWalletEditMenu(1),
m_read_names_and_keys(m_db, R"|(SELECT * FROM "UserZookoIDs"; )|"), m_read_names_and_keys(m_db, R"|(SELECT * FROM "UserZookoIDs"; )|"),
m_read_from_misc(m_db), m_read_from_misc(m_db),
m_find_position(m_db, R"|( SELECT COUNT(*) FROM UserZookoIDs WHERE LOWER("name")<LOWER(?1) AND "name"<?1;)|") m_insert_name(m_db),
m_find_position(m_db, R"|( SELECT COUNT(*) FROM UserZookoIDs
WHERE LOWER("name")<LOWER(?1) AND "name"<?1;)|")
{ {
wxLogMessage(wxT("Loading %s"), walletfile.GetFullPath()); wxLogMessage(wxT("Loading %s"), walletfile.GetFullPath());
try { try {
@ -68,12 +70,50 @@ and a public key defined by the name and the wallet master secret)",
{ {
std::string zookoNickname(dialog.GetValue().ToUTF8()); std::string zookoNickname(dialog.GetValue().ToUTF8());
auto zookoNickname_psz = zookoNickname.c_str(); auto zookoNickname_psz = zookoNickname.c_str();
(*m_insert_name)( auto pubkey = m_MasterSecret(zookoNickname_psz).timesBase();
m_insert_name(
zookoNickname_psz, zookoNickname_psz,
m_MasterSecret(zookoNickname_psz).timesBase() pubkey
); );
refresh_from_database(); m_find_position.read_one(zookoNickname_psz);
auto sizer = this->GetSizer();
auto dirty_area = sizer->ComputeFittingClientSize(singletonFrame);
auto m_lsizer = sizer->GetItem((size_t)0)->GetSizer();
assert(m_lsizer);
auto m_rsizer = sizer->GetItem(1)->GetSizer();
assert(m_rsizer);
auto position = m_find_position.column<int64_t>(0);
m_lSizer->Insert(position,
new wxStaticText(
this,
wxID_ANY,
zookoNickname_psz,
wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT | wxEXPAND | wxFIXED_MINSIZE | wxST_ELLIPSIZE_END
),
10,
wxALL, // and make border all around
2);
m_rSizer->Insert(position,
new wxStaticText(
this,
wxID_ANY,
"#" + base58(pubkey).operator std::string(),
wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT | wxEXPAND | wxFIXED_MINSIZE | wxST_ELLIPSIZE_END
),
10,
wxALL, // and make border all around
2);
auto desired_size = sizer->ComputeFittingClientSize(singletonFrame);
dirty_area.IncTo(desired_size);
//singletonFrame->SetMinClientSize(desired_size);
auto clientSize = singletonFrame->GetClientSize();
desired_size.IncTo(clientSize);
if (desired_size.GetHeight() > clientSize.GetHeight()
|| desired_size.GetWidth() > clientSize.GetWidth()
)singletonFrame->SetClientSize(desired_size);
} }
} }

View File

@ -9,7 +9,7 @@ private:
ro::dbconnect m_db; ro::dbconnect m_db;
sql_read_from_misc m_read_from_misc; sql_read_from_misc m_read_from_misc;
ro::sql m_read_names_and_keys; ro::sql m_read_names_and_keys;
std::unique_ptr <sql_insert_name> m_insert_name; sql_insert_name m_insert_name;
ro::sql m_find_position; ro::sql m_find_position;
ristretto255::CMasterSecret m_MasterSecret; ristretto255::CMasterSecret m_MasterSecret;