Skip to content

Commit c7dbb50

Browse files
authored
838 split column string into small medium large (#839)
* split column STRING into SMALL, MEDIUM and LARGE * fixed SRRING type, now STRING_MEDIUM
1 parent 13e61f8 commit c7dbb50

File tree

10 files changed

+55
-41
lines changed

10 files changed

+55
-41
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
2525
### Changed
2626

2727
- upgrade to lexilla 5.4.2
28+
- split column types STRING into STRING SMALL, MEDIUM and LARGE
2829
- The Open Group Base Specifications Issue 8, 2024 edition
2930
- listview standard column sizes are configurable
3031
- wex::quoted uses std::quoted and includes a delim character

include/wex/factory/listview.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Name: listview.h
33
// Purpose: Declaration of wex::factory::listview and related classes
44
// Author: Anton van Wezenbeek
5-
// Copyright: (c) 2021-2023 Anton van Wezenbeek
5+
// Copyright: (c) 2021-2025 Anton van Wezenbeek
66
////////////////////////////////////////////////////////////////////////////////
77

88
#pragma once
@@ -33,11 +33,13 @@ class column : public wxListItem
3333
/// get_column types.
3434
enum type_t
3535
{
36-
INVALID, ///< illegal col
37-
INT = 1, ///< integer
38-
DATE, ///< date
39-
FLOAT, ///< float
40-
STRING ///< string
36+
INVALID, ///< illegal col
37+
INT = 1, ///< integer
38+
DATE, ///< date
39+
FLOAT, ///< float
40+
STRING_SMALL, ///< string small size
41+
STRING_MEDIUM, ///< string medium size
42+
STRING_LARGE, ///< string large size
4143
};
4244

4345
/// Default constructor.

sample/frame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ frame::frame(app* app)
111111
m_grid->AppendCols(2);
112112

113113
m_listview->append_columns(
114-
{{"String", wex::column::STRING},
114+
{{"String", wex::column::STRING_MEDIUM},
115115
{"Number", wex::column::INT},
116116
{"Float", wex::column::FLOAT},
117117
{"Date", wex::column::DATE}});

src/data/listview.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Name: data/listview.cpp
33
// Purpose: Implementation of wex::data::listview
44
// Author: Anton van Wezenbeek
5-
// Copyright: (c) 2021-2024 Anton van Wezenbeek
5+
// Copyright: (c) 2021-2025 Anton van Wezenbeek
66
////////////////////////////////////////////////////////////////////////////////
77

88
#include <wex/data/listview.h>
@@ -23,14 +23,14 @@ wex::data::listview::listview(data::window& data)
2323

2424
void wex::data::listview::add_columns()
2525
{
26-
m_listview->append_columns({{_("File Name"), column::STRING}});
26+
m_listview->append_columns({{_("File Name"), column::STRING_MEDIUM}});
2727

2828
switch (m_type)
2929
{
3030
case FIND:
3131
m_listview->append_columns(
32-
{{_("Line"), column::STRING, 250},
33-
{_("Match"), column::STRING},
32+
{{_("Line"), column::STRING_MEDIUM},
33+
{_("Match"), column::STRING_SMALL},
3434
{_("Line No")}});
3535
break;
3636
default:
@@ -39,8 +39,8 @@ void wex::data::listview::add_columns()
3939

4040
m_listview->append_columns(
4141
{{_("Modified"), column::DATE},
42-
{_("In Folder"), column::STRING, 175},
43-
{_("Type"), column::STRING},
42+
{_("In Folder"), column::STRING_MEDIUM},
43+
{_("Type"), column::STRING_SMALL},
4444
{_("Size")}});
4545
}
4646

src/factory/listview.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,30 @@
22
// Name: listview.cpp
33
// Purpose: Implementation of wex core listview methods
44
// Author: Anton van Wezenbeek
5-
// Copyright: (c) 2021-2024 Anton van Wezenbeek
5+
// Copyright: (c) 2021-2025 Anton van Wezenbeek
66
////////////////////////////////////////////////////////////////////////////////
77

8+
#include <boost/algorithm/string.hpp>
9+
810
#include <wex/core/config.h>
911
#include <wex/core/core.h>
1012
#include <wex/factory/listview.h>
1113

14+
namespace wex
15+
{
16+
std::string skip_underscore(const std::string& text)
17+
{
18+
return boost::algorithm::replace_all_copy(text, "_", " ");
19+
}
20+
} // namespace wex
21+
1222
#define SETUP_COL(NAME, ALIGN, SIZE) \
1323
case column::NAME: \
1424
align = ALIGN; \
1525
\
1626
if (width == 0) \
1727
{ \
18-
width = config("col." #NAME).get(SIZE); \
28+
width = config(skip_underscore("col." #NAME)).get(SIZE); \
1929
} \
2030
break
2131

@@ -31,10 +41,12 @@ wex::column::column(const std::string& name, type_t type, int width)
3141

3242
switch (m_type)
3343
{
34-
SETUP_COL(DATE, wxLIST_FORMAT_LEFT, 150);
44+
SETUP_COL(DATE, wxLIST_FORMAT_LEFT, 80);
3545
SETUP_COL(FLOAT, wxLIST_FORMAT_RIGHT, 80);
3646
SETUP_COL(INT, wxLIST_FORMAT_RIGHT, 60);
37-
SETUP_COL(STRING, wxLIST_FORMAT_LEFT, 100);
47+
SETUP_COL(STRING_SMALL, wxLIST_FORMAT_LEFT, 60);
48+
SETUP_COL(STRING_MEDIUM, wxLIST_FORMAT_LEFT, 200);
49+
SETUP_COL(STRING_LARGE, wxLIST_FORMAT_LEFT, 400);
3850

3951
default:
4052
assert(0);

src/ui/listview.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ const std::vector<item> config_items()
108108
item::FONTPICKERCTRL,
109109
wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)}}},
110110
{_("Margin"),
111-
{{"col.DATE", 0, 150, 150},
111+
{{"col.DATE", 0, 150, 80},
112112
{"col.FLOAT", 0, 120, 80},
113113
{"col.INT", 0, 100, 60},
114-
{"col.STRING", 0, 500, 100}}},
114+
{"col.STRING SMALL", 0, 500, 60},
115+
{"col.STRING MEDIUM", 0, 500, 200},
116+
{"col.STRING LARGE", 0, 500, 400}}},
115117
{_("Colour"),
116118
{{_("list.Readonly colour"),
117119
item::COLOURPICKERWIDGET,
@@ -723,9 +725,6 @@ bool wex::listview::insert_item(
723725
(void)std::stoi(col);
724726
break;
725727

726-
case column::STRING:
727-
break;
728-
729728
default:
730729
break;
731730
}
@@ -979,7 +978,7 @@ bool wex::listview::load(const strings_t& l)
979978
tok.end(),
980979
[this, &i](const auto&)
981980
{
982-
append_columns({{std::to_string(i++ + 1), column::STRING, 50}});
981+
append_columns({{std::to_string(i++ + 1), column::STRING_MEDIUM, 100}});
983982
});
984983
}
985984

@@ -1300,7 +1299,9 @@ int wxCALLBACK compare_cb(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData)
13001299
return ascending ? wex::compare(std::stoi(str1), std::stoi(str2)) :
13011300
wex::compare(std::stoi(str2), std::stoi(str1));
13021301

1303-
case wex::column::STRING:
1302+
case wex::column::STRING_SMALL:
1303+
case wex::column::STRING_MEDIUM:
1304+
case wex::column::STRING_LARGE:
13041305
if (!wex::find_replace_data::get()->match_case())
13051306
{
13061307
return ascending ? wex::icompare(str1, str2) :
@@ -1344,9 +1345,6 @@ bool wex::listview::set_item(long index, int column, const std::string& text)
13441345
(void)std::stoi(text);
13451346
break;
13461347

1347-
case column::STRING:
1348-
break;
1349-
13501348
default:
13511349
break;
13521350
}

src/vcs/debug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class process_dir : public dir
3838
{
3939
if (init)
4040
{
41-
m_listview->append_columns({{"Name", column::STRING, 200}, {"Pid"}});
41+
m_listview->append_columns({{"Name", column::STRING_MEDIUM}, {"Pid"}});
4242
}
4343
else
4444
{

src/vcs/revisions-dialog.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,13 @@ int wex::vcs_entry::revisions_dialog(
166166

167167
if (is_new)
168168
{
169-
vb->append_columns({{"branches", wex::column::STRING, 500}});
170-
vt->append_columns({{"tags", wex::column::STRING, 500}});
169+
vb->append_columns({{"branches", wex::column::STRING_LARGE}});
170+
vt->append_columns({{"tags", wex::column::STRING_MEDIUM}});
171171
lv->append_columns(
172-
{{"date", wex::column::STRING, 75},
173-
{"comment", wex::column::STRING, 400},
174-
{"author", wex::column::STRING},
175-
{"hash", wex::column::STRING}});
172+
{{"date", wex::column::DATE},
173+
{"comment", wex::column::STRING_LARGE},
174+
{"author", wex::column::STRING_MEDIUM},
175+
{"hash", wex::column::STRING_SMALL}});
176176

177177
bind_rev(vb, repo_path, tl, "branches");
178178
bind_rev(vt, repo_path, tl, "tags");

test/del/test-listview-file.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Name: test-listview-file.cpp
33
// Purpose: Implementation for wex del unit testing
44
// Author: Anton van Wezenbeek
5-
// Copyright: (c) 2021-2022 Anton van Wezenbeek
5+
// Copyright: (c) 2021-2025 Anton van Wezenbeek
66
////////////////////////////////////////////////////////////////////////////////
77

88
#include <wex/del/listview-file.h>
@@ -38,7 +38,7 @@ TEST_CASE("wex::del::file")
3838
SUBCASE("columns")
3939
{
4040
lv->append_columns(
41-
{{"String", wex::column::STRING}, {"Number", wex::column::INT}});
41+
{{"String", wex::column::STRING_SMALL}, {"Number", wex::column::INT}});
4242

4343
// Remember that listview file already has columns.
4444
REQUIRE(lv->find_column("String") > 1);

test/ui/test-listview.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Name: test-listview.cpp
33
// Purpose: Implementation for wex unit testing
44
// Author: Anton van Wezenbeek
5-
// Copyright: (c) 2015-2024 Anton van Wezenbeek
5+
// Copyright: (c) 2015-2025 Anton van Wezenbeek
66
////////////////////////////////////////////////////////////////////////////////
77

88
#include <wex/core/log-none.h>
@@ -23,7 +23,7 @@ TEST_CASE("wex::listview")
2323
{"Int", wex::column::INT},
2424
{"Date", wex::column::DATE},
2525
{"Float", wex::column::FLOAT},
26-
{"String", wex::column::STRING}};
26+
{"String", wex::column::STRING_SMALL}};
2727

2828
SUBCASE("general")
2929
{
@@ -47,7 +47,7 @@ TEST_CASE("wex::listview")
4747
REQUIRE(lv->append_columns(
4848
{{"Date", wex::column::DATE},
4949
{"Float", wex::column::FLOAT},
50-
{"String", wex::column::STRING}}));
50+
{"String", wex::column::STRING_MEDIUM}}));
5151

5252
REQUIRE(lv->find_column("Int") == 0);
5353
REQUIRE(lv->find_column("Date") == 1);
@@ -105,7 +105,8 @@ TEST_CASE("wex::listview")
105105
SUBCASE("item_from_to_text")
106106
{
107107
REQUIRE(lv->append_columns(
108-
{{"Text", wex::column::STRING}, {"More", wex::column::STRING}}));
108+
{{"Text", wex::column::STRING_MEDIUM},
109+
{"More", wex::column::STRING_MEDIUM}}));
109110

110111
lv->field_separator('');
111112

@@ -153,7 +154,7 @@ TEST_CASE("wex::listview")
153154
REQUIRE(lv->data().image() == wex::data::listview::IMAGE_ART);
154155
REQUIRE(!lv->data().type_description().empty());
155156

156-
REQUIRE(lv->append_columns({{"String", wex::column::STRING}}));
157+
REQUIRE(lv->append_columns({{"String", wex::column::STRING_MEDIUM}}));
157158

158159
REQUIRE(lv->item_from_text("test.h\ntest.h"));
159160
REQUIRE(lv->set_item_image(0, wxART_WARNING));

0 commit comments

Comments
 (0)