Cleaned up the add name on the dry prinicple
fixed bug in the position of the inserted name that happened with names identical except for capitalization.
This commit is contained in:
parent
55d0d69c8f
commit
c65f2fbf6e
@ -9,7 +9,7 @@ display_wallet::display_wallet(wxWindow* parent, wxFileName& walletfile) :
|
||||
m_read_from_misc(m_db),
|
||||
m_insert_name(m_db),
|
||||
m_find_position(m_db, R"|( SELECT COUNT(*) FROM UserZookoIDs
|
||||
WHERE LOWER("name")<LOWER(?1) AND "name"<?1;)|")
|
||||
WHERE LOWER("name")<LOWER(?1) OR (LOWER("name")=LOWER(?1) AND "name"<?1);)|")
|
||||
{
|
||||
wxLogMessage(wxT("Loading %s"), walletfile.GetFullPath());
|
||||
try {
|
||||
@ -59,6 +59,39 @@ void display_wallet::close_menu_event_handler(wxCommandEvent& event) {
|
||||
Close(true);
|
||||
}
|
||||
|
||||
|
||||
struct display_wallet::cleanup {
|
||||
cleanup() = delete;
|
||||
// copy constructor
|
||||
cleanup(const cleanup& a) = delete;
|
||||
// move constructor
|
||||
cleanup(cleanup&& p) = delete;
|
||||
// copy assignment
|
||||
cleanup& operator=(cleanup) = delete;
|
||||
// Move assignment
|
||||
cleanup& operator=(cleanup&&) = delete;
|
||||
display_wallet* m_win;
|
||||
wxSizer* sizer;
|
||||
wxSize dirty_area;
|
||||
cleanup(display_wallet* win) :
|
||||
m_win(win),
|
||||
sizer(win->GetSizer()),
|
||||
dirty_area(sizer->ComputeFittingClientSize(singletonFrame))
|
||||
{
|
||||
assert(sizer);
|
||||
}
|
||||
~cleanup() {
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
void display_wallet::add_name_event_handler(wxCommandEvent& event) {
|
||||
wxTextEntryDialog dialog(this,
|
||||
R"("A Zooko name has a human readable name,
|
||||
@ -76,13 +109,8 @@ and a public key defined by the name and the wallet master secret)",
|
||||
pubkey
|
||||
);
|
||||
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);
|
||||
cleanup cln(this);
|
||||
m_lSizer->Insert(position,
|
||||
new wxStaticText(
|
||||
this,
|
||||
@ -103,15 +131,6 @@ and a public key defined by the name and the wallet master secret)",
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@ -129,14 +148,7 @@ void display_wallet::OnClose(wxCloseEvent& event) {
|
||||
}
|
||||
|
||||
void display_wallet::refresh_from_database() {
|
||||
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);
|
||||
m_lsizer->Clear(true);
|
||||
m_rsizer->Clear(true);
|
||||
cleanup cln(this);
|
||||
try {
|
||||
m_read_names_and_keys.reset();
|
||||
while (m_read_names_and_keys.step() == Icompiled_sql::ROW) {
|
||||
@ -177,12 +189,4 @@ void display_wallet::refresh_from_database() {
|
||||
szError = sz_unknown_error;
|
||||
throw MyException(sz_unknown_error, __LINE__, __func__, SrcFilename);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ public:
|
||||
display_wallet(wxWindow*, wxFileName&);
|
||||
~display_wallet();
|
||||
private:
|
||||
struct cleanup;
|
||||
typedef MenuLink<display_wallet> MenuLink;
|
||||
ro::dbconnect m_db;
|
||||
sql_read_from_misc m_read_from_misc;
|
||||
|
Loading…
Reference in New Issue
Block a user