Skip to content

Commit

Permalink
Merge pull request moneymanagerex#6959 from n-stein/fix(moneymanagere…
Browse files Browse the repository at this point in the history
…x#6847)

fix(moneymanagerex#6847): fixes for Windows drag & drop
  • Loading branch information
whalley authored Nov 21, 2024
2 parents 64b2477 + 731d9af commit 8fd9ff5
Show file tree
Hide file tree
Showing 10 changed files with 219 additions and 139 deletions.
20 changes: 11 additions & 9 deletions src/assetspanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,26 @@ mmAssetsListCtrl::mmAssetsListCtrl(mmAssetsPanel* cp, wxWindow *parent, wxWindow
mmThemeMetaColour(this, meta::COLOR_LISTPANEL);

m_columns.push_back(PANEL_COLUMN(" ", 25, wxLIST_FORMAT_LEFT, false));
m_real_columns.push_back(m_panel->COL_ICON);
m_columns.push_back(PANEL_COLUMN(_("ID"), wxLIST_AUTOSIZE, wxLIST_FORMAT_RIGHT, true));
m_real_columns.push_back(m_panel->COL_ID);
m_columns.push_back(PANEL_COLUMN(_("Name"), 150, wxLIST_FORMAT_LEFT, true));
m_real_columns.push_back(m_panel->COL_NAME);
m_columns.push_back(PANEL_COLUMN(_("Date"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_LEFT, true));
m_real_columns.push_back(m_panel->COL_DATE);
m_columns.push_back(PANEL_COLUMN(_("Type"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_LEFT, true));
m_real_columns.push_back(m_panel->COL_TYPE);
m_columns.push_back(PANEL_COLUMN(_("Initial Value"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_RIGHT, true));
m_real_columns.push_back(m_panel->COL_VALUE_INITIAL);
m_columns.push_back(PANEL_COLUMN(_("Current Value"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_RIGHT, true));
m_real_columns.push_back(m_panel->COL_VALUE_CURRENT);
m_columns.push_back(PANEL_COLUMN(_("Notes"), 450, wxLIST_FORMAT_LEFT, true));
m_real_columns.push_back(m_panel->COL_NOTES);

m_col_width = "ASSETS_COL%d_WIDTH";
m_col_idstr = "ASSETS";
for (const auto& entry : m_columns)
{
int count = GetColumnCount();
InsertColumn(count
, entry.HEADER
, entry.FORMAT
, Model_Setting::instance().GetIntSetting(wxString::Format(m_col_width, count), entry.WIDTH));
}

CreateColumns();

// load the global variables
m_default_sort_column = m_panel->col_sort();
Expand Down Expand Up @@ -139,7 +141,7 @@ void mmAssetsListCtrl::OnListLeftClick(wxMouseEvent& event)

wxString mmAssetsListCtrl::OnGetItemText(long item, long column) const
{
return m_panel->getItem(item, column);
return m_panel->getItem(item, m_real_columns[column]);
}

void mmAssetsListCtrl::OnListItemSelected(wxListEvent& event)
Expand Down
25 changes: 13 additions & 12 deletions src/assetspanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ class mmAssetsPanel : public mmPanelBase
ICON_DOWNARROW
};

enum EColumn
{
COL_ICON = 0,
COL_ID,
COL_NAME,
COL_DATE,
COL_TYPE,
COL_VALUE_INITIAL,
COL_VALUE_CURRENT,
COL_NOTES,
COL_MAX, // number of columns
};

mmAssetsPanel(mmGUIFrame* frame, wxWindow *parent, wxWindowID winid, const wxString& name="mmAssetsPanel");
mmGUIFrame* m_frame = nullptr;

Expand Down Expand Up @@ -147,18 +160,6 @@ class mmAssetsPanel : public mmPanelBase
IDC_PANEL_ASSET_STATIC_DETAILS = wxID_HIGHEST + 1220,
IDC_PANEL_ASSET_STATIC_DETAILS_MINI,
};
enum EColumn
{
COL_ICON = 0,
COL_ID,
COL_NAME,
COL_DATE,
COL_TYPE,
COL_VALUE_INITIAL,
COL_VALUE_CURRENT,
COL_NOTES,
COL_MAX, // number of columns
};
};

inline void mmAssetsPanel::RefreshList(){ m_listCtrlAssets->doRefreshItems(); }
29 changes: 20 additions & 9 deletions src/billsdepositspanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,35 +128,46 @@ billsDepositsListCtrl::billsDepositsListCtrl(mmBillsDepositsPanel* bdp, wxWindow
m_asc = Model_Setting::instance().GetBoolSetting("BD_ASC", true);

m_columns.push_back(PANEL_COLUMN(" ", 25, wxLIST_FORMAT_LEFT, false));
m_real_columns.push_back(m_bdp->COL_ICON);
m_columns.push_back(PANEL_COLUMN(_("ID"), wxLIST_AUTOSIZE, wxLIST_FORMAT_RIGHT, true));
m_real_columns.push_back(m_bdp->COL_ID);
m_columns.push_back(PANEL_COLUMN(_("Date Paid"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_LEFT, true));
m_real_columns.push_back(m_bdp->COL_PAYMENT_DATE);
m_columns.push_back(PANEL_COLUMN(_("Date Due"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_LEFT, true));
m_real_columns.push_back(m_bdp->COL_DUE_DATE);
m_columns.push_back(PANEL_COLUMN(_("Account"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_LEFT, true));
m_real_columns.push_back(m_bdp->COL_ACCOUNT);
m_columns.push_back(PANEL_COLUMN(_("Payee"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_LEFT, true));
m_real_columns.push_back(m_bdp->COL_PAYEE);
m_columns.push_back(PANEL_COLUMN(_("Status"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_LEFT, true));
m_real_columns.push_back(m_bdp->COL_STATUS);
m_columns.push_back(PANEL_COLUMN(_("Category"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_LEFT, true));
m_real_columns.push_back(m_bdp->COL_CATEGORY);
m_columns.push_back(PANEL_COLUMN(_("Tags"), 200, wxLIST_FORMAT_LEFT, true));
m_real_columns.push_back(m_bdp->COL_TAGS);
m_columns.push_back(PANEL_COLUMN(_("Type"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_LEFT, true));
m_real_columns.push_back(m_bdp->COL_TYPE);
m_columns.push_back(PANEL_COLUMN(_("Amount"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_RIGHT, true));
m_real_columns.push_back(m_bdp->COL_AMOUNT);
m_columns.push_back(PANEL_COLUMN(_("Frequency"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_LEFT, true));
m_real_columns.push_back(m_bdp->COL_FREQUENCY);
m_columns.push_back(PANEL_COLUMN(_("Repetitions"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_RIGHT, true));
m_real_columns.push_back(m_bdp->COL_REPEATS);
m_columns.push_back(PANEL_COLUMN(_("Autorepeat"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_LEFT, true));
m_real_columns.push_back(m_bdp->COL_AUTO);
m_columns.push_back(PANEL_COLUMN(_("Payment"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_LEFT, true));
m_real_columns.push_back(m_bdp->COL_DAYS);
m_columns.push_back(PANEL_COLUMN(_("Number"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_LEFT, true));
m_real_columns.push_back(m_bdp->COL_NUMBER);
m_columns.push_back(PANEL_COLUMN(_("Notes"), 150, wxLIST_FORMAT_LEFT, true));
m_real_columns.push_back(m_bdp->COL_NOTES);

m_col_width = "BD_COL%d_WIDTH";
m_col_idstr = "BD";
m_default_sort_column = m_bdp->col_sort();

for (const auto& entry : m_columns)
{
int count = GetColumnCount();
InsertColumn(count
, entry.HEADER
, entry.FORMAT
, Model_Setting::instance().GetIntSetting(wxString::Format(m_col_width, count), entry.WIDTH));
}
CreateColumns();

}

billsDepositsListCtrl::~billsDepositsListCtrl()
Expand Down Expand Up @@ -570,7 +581,7 @@ const wxString mmBillsDepositsPanel::GetRemainingDays(const Model_Billsdeposits:

wxString billsDepositsListCtrl::OnGetItemText(long item, long column) const
{
return m_bdp->getItem(item, column);
return m_bdp->getItem(item, m_real_columns[column]);
}

void billsDepositsListCtrl::OnListItemSelected(wxListEvent& event)
Expand Down
44 changes: 22 additions & 22 deletions src/billsdepositspanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,28 @@ class mmBillsDepositsPanel : public mmPanelBase
ICON_DOWNARROW
};

enum EColumn
{
COL_ICON = 0,
COL_ID,
COL_PAYMENT_DATE,
COL_DUE_DATE,
COL_ACCOUNT,
COL_PAYEE,
COL_STATUS,
COL_CATEGORY,
COL_TAGS,
COL_TYPE,
COL_AMOUNT,
COL_FREQUENCY,
COL_REPEATS,
COL_AUTO,
COL_DAYS,
COL_NUMBER,
COL_NOTES,
COL_MAX, // number of columns
};

mmBillsDepositsPanel(wxWindow *parent
, wxWindowID winid = wxID_ANY
, const wxPoint& pos = wxDefaultPosition
Expand Down Expand Up @@ -146,28 +168,6 @@ class mmBillsDepositsPanel : public mmPanelBase
wxStaticText* m_infoTextMini = nullptr;
wxDate m_today;

enum EColumn
{
COL_ICON = 0,
COL_ID,
COL_PAYMENT_DATE,
COL_DUE_DATE,
COL_ACCOUNT,
COL_PAYEE,
COL_STATUS,
COL_CATEGORY,
COL_TAGS,
COL_TYPE,
COL_AMOUNT,
COL_FREQUENCY,
COL_REPEATS,
COL_AUTO,
COL_DAYS,
COL_NUMBER,
COL_NOTES,
COL_MAX, // number of columns
};

bool transFilterActive_;
void OnFilterTransactions(wxCommandEvent& WXUNUSED(event));
wxButton* m_bitmapTransFilter = nullptr;
Expand Down
20 changes: 4 additions & 16 deletions src/mmchecking_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,13 @@ TransactionListCtrl::TransactionListCtrl(
wxAcceleratorTable tab(sizeof(entries) / sizeof(*entries), entries);
SetAcceleratorTable(tab);

resetColumns();

// V2 used as now maps to real column names and this resets everything to default
// to avoid strange column widths when this code version is first
m_col_width = m_cp->isAllAccounts_ ? "ALLTRANS_COLV2%d_WIDTH" : "CHECK2_COLV2%d_WIDTH";
m_col_idstr = m_cp->isAllAccounts_ ? "ALLTRANS" : "CHECK2";

resetColumns();

m_default_sort_column = COL_DEF_SORT;
m_today = Option::instance().UseTransDateTime() ? wxDateTime::Now().FormatISOCombined() : wxDateTime(23, 59, 59, 999).FormatISOCombined();

Expand Down Expand Up @@ -354,25 +354,13 @@ void TransactionListCtrl::resetColumns()
}
m_columns.push_back(PANEL_COLUMN(_("Last Updated"), wxLIST_AUTOSIZE, wxLIST_FORMAT_LEFT, true));
m_real_columns.push_back(COL_UPDATEDTIME);

CreateColumns();
}

TransactionListCtrl::~TransactionListCtrl()
{}

//----------------------------------------------------------------------------
void TransactionListCtrl::createColumns(mmListCtrl &lst)
{

for (const auto& entry : m_columns)
{
int count = lst.GetColumnCount();
lst.InsertColumn(count
, entry.HEADER
, entry.FORMAT
, Model_Setting::instance().GetIntSetting(wxString::Format(m_col_width, GetRealColumn(count)), entry.WIDTH));
}
}

void TransactionListCtrl::setExtraTransactionData(const bool single)
{
bool isForeign = false;
Expand Down
4 changes: 2 additions & 2 deletions src/mmchecking_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class TransactionListCtrl : public mmListCtrl

~TransactionListCtrl();

void createColumns(mmListCtrl &lst);
void createColumns();
Model_Checking::Full_Data_Set m_trans;
void markSelectedTransaction();
void DeleteTransactionsByStatus(const wxString& status);
Expand Down Expand Up @@ -74,7 +74,6 @@ class TransactionListCtrl : public mmListCtrl
};
EColumn toEColumn(const unsigned long col);

public:
EColumn g_sortcol = COL_DEF_SORT; // index of primary column to sort by
EColumn prev_g_sortcol = COL_DEF_SORT2; // index of secondary column to sort by
bool g_asc = true; // asc\desc sorting for primary sort column
Expand Down Expand Up @@ -238,6 +237,7 @@ inline std::vector<int> TransactionListCtrl::getSelectedForCopy() const { return
inline std::vector<int> TransactionListCtrl::getSelectedId() const { return m_selected_id; }

inline void TransactionListCtrl::setVisibleItemIndex(long v) { m_topItemIndex = v; }
inline void TransactionListCtrl::createColumns(){ mmListCtrl::CreateColumns(); }

#endif // MM_EX_CHECKING_LIST_H_

Expand Down
30 changes: 1 addition & 29 deletions src/mmcheckingpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,34 +400,6 @@ void mmCheckingPanel::CreateControls()
m_listCtrlAccount->setSortOrder(m_listCtrlAccount->g_asc);
m_listCtrlAccount->setSortColumn(m_listCtrlAccount->g_sortcol);

// Get sorted columns list and update the sorted columns with missing columns if needed.
wxArrayString columnList, sortedColumnList;
sortedColumnList = m_listCtrlAccount->GetColumnsOrder();
wxLogDebug("CreateControls: getColumnList() = %s", wxJoin(sortedColumnList, '|'));

// sort m_columns according to sortedColumnsList
std::vector<PANEL_COLUMN> sortedColumns = {};
std::vector<int> sortedRealColumns = {};
for (const auto& i : sortedColumnList)
{
for (unsigned int j = 0; j < m_listCtrlAccount->m_columns.size(); j++)
{
auto k = m_listCtrlAccount->m_columns[j];
auto l = m_listCtrlAccount->m_real_columns[j];
if (wxString::Format("%d", j) == i)
{
sortedColumns.push_back(k);
sortedRealColumns.push_back(l);
break;
}
}
}

m_listCtrlAccount->m_columns = sortedColumns;
m_listCtrlAccount->m_real_columns = sortedRealColumns;

m_listCtrlAccount->createColumns(*m_listCtrlAccount);

// load the global variables
m_sortSaveTitle = isAllAccounts_ ? "ALLTRANS" : (isTrash_ ? "DELETED" : "CHECK");

Expand Down Expand Up @@ -936,7 +908,7 @@ void mmCheckingPanel::ResetColumnView()
{
m_listCtrlAccount->DeleteAllColumns();
m_listCtrlAccount->resetColumns();
m_listCtrlAccount->createColumns(*m_listCtrlAccount);
m_listCtrlAccount->createColumns();
m_listCtrlAccount->refreshVisualList();
}

Expand Down
Loading

0 comments on commit 8fd9ff5

Please sign in to comment.