From 55d0d69c8f7151b4279683269fcdea076a9c1b9e Mon Sep 17 00:00:00 2001 From: Cheng Date: Sun, 12 Nov 2023 03:56:47 +0000 Subject: [PATCH] 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 --- src/db_accessors.h | 5 ++--- src/display_wallet.cpp | 48 ++++++++++++++++++++++++++++++++++++++---- src/display_wallet.h | 2 +- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/src/db_accessors.h b/src/db_accessors.h index 6a1f4a1..9759d42 100644 --- a/src/db_accessors.h +++ b/src/db_accessors.h @@ -17,8 +17,7 @@ namespace ro { //Owns a database connection and closes it when it is deconstructed //Has move semantics - class dbconnect : public std::unique_ptr { - public: + struct dbconnect : std::unique_ptr { dbconnect(const wxFileName&); //And here we wrap our Cish implementation in C++ish implementation dbconnect() = delete; ~dbconnect() = default; //Our base class takes care of it @@ -200,7 +199,7 @@ class sql_insert_name { ro::sql csql_into_names; public: sql_insert_name(ISqlite3* p) : - csql_into_names(p, R"|(INSERT OR FAIL INTO "UserZookoIDs" VALUES(?1, ?2);)|"){} + csql_into_names(p, R"|(INSERT OR FAIL INTO "UserZookoIDs" VALUES(?1, ?2);)|"){} sql_insert_name(const std::unique_ptr& p) : sql_insert_name(p.get()) {} void operator()(const char* psz, const ristretto255::point& pt) { csql_into_names.do_one(psz,pt); diff --git a/src/display_wallet.cpp b/src/display_wallet.cpp index f11dbaa..5f0ac60 100644 --- a/src/display_wallet.cpp +++ b/src/display_wallet.cpp @@ -7,7 +7,9 @@ display_wallet::display_wallet(wxWindow* parent, wxFileName& walletfile) : m_db(walletfile), m_DisplayWalletEditMenu(1), m_read_names_and_keys(m_db, R"|(SELECT * FROM "UserZookoIDs"; )|"), m_read_from_misc(m_db), - m_find_position(m_db, R"|( SELECT COUNT(*) FROM UserZookoIDs WHERE LOWER("name")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(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); } + } diff --git a/src/display_wallet.h b/src/display_wallet.h index 3461ee4..5328328 100644 --- a/src/display_wallet.h +++ b/src/display_wallet.h @@ -9,7 +9,7 @@ private: ro::dbconnect m_db; sql_read_from_misc m_read_from_misc; ro::sql m_read_names_and_keys; - std::unique_ptr m_insert_name; + sql_insert_name m_insert_name; ro::sql m_find_position; ristretto255::CMasterSecret m_MasterSecret;