Fix in FListViewIterator
This commit is contained in:
parent
b05513a8f8
commit
b810b51e65
|
@ -1,4 +1,5 @@
|
||||||
2020-02-04 Markus Gans <guru.mail@muenster.de>
|
2020-02-04 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* Fix in FListViewIterator
|
||||||
* Add screenshorts to the first steps document
|
* Add screenshorts to the first steps document
|
||||||
|
|
||||||
2020-02-02 Markus Gans <guru.mail@muenster.de>
|
2020-02-02 Markus Gans <guru.mail@muenster.de>
|
||||||
|
|
|
@ -560,8 +560,13 @@ void FListViewIterator::nextElement (iterator& iter)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
++iter;
|
|
||||||
position++;
|
position++;
|
||||||
|
bool forward{};
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
forward = false; // Reset forward
|
||||||
|
++iter;
|
||||||
|
|
||||||
if ( ! iter_path.empty() )
|
if ( ! iter_path.empty() )
|
||||||
{
|
{
|
||||||
|
@ -571,10 +576,12 @@ void FListViewIterator::nextElement (iterator& iter)
|
||||||
{
|
{
|
||||||
iter = parent_iter;
|
iter = parent_iter;
|
||||||
iter_path.pop();
|
iter_path.pop();
|
||||||
++iter;
|
forward = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
while ( forward );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -1142,7 +1149,7 @@ void FListView::onMouseUp (FMouseEvent* ev)
|
||||||
else
|
else
|
||||||
item->expand();
|
item->expand();
|
||||||
|
|
||||||
adjustSize();
|
adjustScrollbars (getCount());
|
||||||
|
|
||||||
if ( isShown() )
|
if ( isShown() )
|
||||||
draw();
|
draw();
|
||||||
|
@ -1225,11 +1232,12 @@ void FListView::onMouseDoubleClick (FMouseEvent* ev)
|
||||||
|
|
||||||
const int mouse_x = ev->getX();
|
const int mouse_x = ev->getX();
|
||||||
const int mouse_y = ev->getY();
|
const int mouse_y = ev->getY();
|
||||||
|
const std::size_t element_count = getCount();
|
||||||
|
|
||||||
if ( mouse_x > 1 && mouse_x < int(getWidth())
|
if ( mouse_x > 1 && mouse_x < int(getWidth())
|
||||||
&& mouse_y > 1 && mouse_y < int(getHeight()) )
|
&& mouse_y > 1 && mouse_y < int(getHeight()) )
|
||||||
{
|
{
|
||||||
if ( first_visible_line.getPosition() + mouse_y - 1 > int(getCount()) )
|
if ( first_visible_line.getPosition() + mouse_y - 1 > int(element_count) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( itemlist.empty() )
|
if ( itemlist.empty() )
|
||||||
|
@ -1244,7 +1252,7 @@ void FListView::onMouseDoubleClick (FMouseEvent* ev)
|
||||||
else
|
else
|
||||||
item->expand();
|
item->expand();
|
||||||
|
|
||||||
adjustSize();
|
adjustScrollbars (element_count);
|
||||||
|
|
||||||
if ( isShown() )
|
if ( isShown() )
|
||||||
draw();
|
draw();
|
||||||
|
@ -1356,7 +1364,7 @@ void FListView::onFocusOut (FFocusEvent*)
|
||||||
|
|
||||||
// protected methods of FListView
|
// protected methods of FListView
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FListView::adjustViewport (int element_count)
|
void FListView::adjustViewport (const int element_count)
|
||||||
{
|
{
|
||||||
const int height = int(getClientHeight());
|
const int height = int(getClientHeight());
|
||||||
|
|
||||||
|
@ -1396,15 +1404,10 @@ void FListView::adjustViewport (int element_count)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FListView::adjustSize()
|
void FListView::adjustScrollbars (const std::size_t element_count)
|
||||||
{
|
{
|
||||||
FWidget::adjustSize();
|
|
||||||
const std::size_t element_count = getCount();
|
|
||||||
const std::size_t width = getClientWidth();
|
const std::size_t width = getClientWidth();
|
||||||
const std::size_t height = getClientHeight();
|
const std::size_t height = getClientHeight();
|
||||||
|
|
||||||
adjustViewport (int(element_count));
|
|
||||||
|
|
||||||
const int vmax = ( element_count > height )
|
const int vmax = ( element_count > height )
|
||||||
? int(element_count - height)
|
? int(element_count - height)
|
||||||
: 0;
|
: 0;
|
||||||
|
@ -1437,6 +1440,15 @@ void FListView::adjustSize()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FListView::adjustSize()
|
||||||
|
{
|
||||||
|
FWidget::adjustSize();
|
||||||
|
const std::size_t element_count = getCount();
|
||||||
|
adjustViewport (int(element_count));
|
||||||
|
adjustScrollbars (element_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// private methods of FListView
|
// private methods of FListView
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -1512,8 +1524,8 @@ void FListView::sort (Compare cmp)
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
std::size_t FListView::getAlignOffset ( const fc::text_alignment align
|
std::size_t FListView::getAlignOffset ( const fc::text_alignment align
|
||||||
, std::size_t column_width
|
, const std::size_t column_width
|
||||||
, std::size_t width )
|
, const std::size_t width )
|
||||||
{
|
{
|
||||||
switch ( align )
|
switch ( align )
|
||||||
{
|
{
|
||||||
|
@ -1536,6 +1548,22 @@ std::size_t FListView::getAlignOffset ( const fc::text_alignment align
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
FObject::iterator FListView::getListEnd (FListViewItem* item)
|
||||||
|
{
|
||||||
|
auto parent = item->getParent();
|
||||||
|
|
||||||
|
if ( ! parent )
|
||||||
|
return null_iter;
|
||||||
|
|
||||||
|
if ( this == parent )
|
||||||
|
return itemlist.end();
|
||||||
|
else if ( parent->isInstanceOf("FListViewItem") )
|
||||||
|
return static_cast<FListViewItem*>(parent)->end();
|
||||||
|
else
|
||||||
|
return null_iter;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FListView::draw()
|
void FListView::draw()
|
||||||
{
|
{
|
||||||
|
@ -1643,14 +1671,17 @@ void FListView::drawList()
|
||||||
|
|
||||||
uInt y{0};
|
uInt y{0};
|
||||||
const uInt page_height = uInt(getHeight()) - 2;
|
const uInt page_height = uInt(getHeight()) - 2;
|
||||||
|
const auto& itemlist_end = itemlist.end();
|
||||||
|
auto path_end = itemlist_end;
|
||||||
auto iter = first_visible_line;
|
auto iter = first_visible_line;
|
||||||
|
|
||||||
while ( iter != itemlist.end() && y < page_height )
|
while ( iter != path_end && iter != itemlist_end && y < page_height )
|
||||||
{
|
{
|
||||||
const bool is_current_line( iter == current_iter );
|
const bool is_current_line( iter == current_iter );
|
||||||
const auto& item = static_cast<FListViewItem*>(*iter);
|
const auto& item = static_cast<FListViewItem*>(*iter);
|
||||||
const int tree_offset = ( tree_view ) ? int(item->getDepth() << 1) + 1 : 0;
|
const int tree_offset = ( tree_view ) ? int(item->getDepth() << 1) + 1 : 0;
|
||||||
const int checkbox_offset = ( item->isCheckable() ) ? 1 : 0;
|
const int checkbox_offset = ( item->isCheckable() ) ? 1 : 0;
|
||||||
|
path_end = getListEnd(item);
|
||||||
print() << FPoint(2, 2 + int(y));
|
print() << FPoint(2, 2 + int(y));
|
||||||
|
|
||||||
// Draw one FListViewItem
|
// Draw one FListViewItem
|
||||||
|
@ -1757,10 +1788,17 @@ void FListView::drawListLine ( const FListViewItem* item
|
||||||
std::size_t char_width{0};
|
std::size_t char_width{0};
|
||||||
|
|
||||||
for (std::size_t i{0}; i < len; i++)
|
for (std::size_t i{0}; i < len; i++)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
char_width += getColumnWidth(line[i]);
|
char_width += getColumnWidth(line[i]);
|
||||||
print() << line[i];
|
print() << line[i];
|
||||||
}
|
}
|
||||||
|
catch (const std::out_of_range&)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (std::size_t i = char_width; i < width; i++)
|
for (std::size_t i = char_width; i < width; i++)
|
||||||
print (' ');
|
print (' ');
|
||||||
|
@ -2185,11 +2223,12 @@ void FListView::recalculateHorizontalBar (std::size_t len)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FListView::recalculateVerticalBar (std::size_t element_count)
|
void FListView::recalculateVerticalBar (std::size_t element_count)
|
||||||
{
|
{
|
||||||
const int vmax = ( element_count + 2 > getHeight() )
|
const std::size_t height = getClientHeight();
|
||||||
? int(element_count - getHeight() + 2)
|
const int vmax = ( element_count > height )
|
||||||
|
? int(element_count - height)
|
||||||
: 0;
|
: 0;
|
||||||
vbar->setMaximum (vmax);
|
vbar->setMaximum (vmax);
|
||||||
vbar->setPageSize (int(element_count), int(getHeight()) - 2);
|
vbar->setPageSize (int(element_count), int(height));
|
||||||
vbar->calculateSliderValues();
|
vbar->calculateSliderValues();
|
||||||
|
|
||||||
if ( isShown() )
|
if ( isShown() )
|
||||||
|
@ -2445,9 +2484,8 @@ inline void FListView::collapseAndScrollLeft()
|
||||||
{
|
{
|
||||||
// Collapse element
|
// Collapse element
|
||||||
item->collapse();
|
item->collapse();
|
||||||
adjustSize();
|
adjustScrollbars (getCount());
|
||||||
const std::size_t element_count = getCount();
|
vbar->calculateSliderValues();
|
||||||
recalculateVerticalBar (element_count);
|
|
||||||
// Force vertical scrollbar redraw
|
// Force vertical scrollbar redraw
|
||||||
first_line_position_before = -1;
|
first_line_position_before = -1;
|
||||||
}
|
}
|
||||||
|
@ -2498,7 +2536,7 @@ inline void FListView::expandAndScrollRight()
|
||||||
{
|
{
|
||||||
// Expand element
|
// Expand element
|
||||||
item->expand();
|
item->expand();
|
||||||
adjustSize();
|
adjustScrollbars (getCount());
|
||||||
// Force vertical scrollbar redraw
|
// Force vertical scrollbar redraw
|
||||||
first_line_position_before = -1;
|
first_line_position_before = -1;
|
||||||
}
|
}
|
||||||
|
@ -2549,7 +2587,7 @@ inline bool FListView::expandSubtree()
|
||||||
if ( tree_view && item->isExpandable() && ! item->isExpand() )
|
if ( tree_view && item->isExpandable() && ! item->isExpand() )
|
||||||
{
|
{
|
||||||
item->expand();
|
item->expand();
|
||||||
adjustSize();
|
adjustScrollbars (getCount());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2567,7 +2605,7 @@ inline bool FListView::collapseSubtree()
|
||||||
if ( tree_view && item->isExpandable() && item->isExpand() )
|
if ( tree_view && item->isExpandable() && item->isExpand() )
|
||||||
{
|
{
|
||||||
item->collapse();
|
item->collapse();
|
||||||
adjustSize();
|
adjustScrollbars (getCount());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -353,7 +353,8 @@ class FListView : public FWidget
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Methods
|
// Methods
|
||||||
void adjustViewport (int);
|
void adjustViewport (const int);
|
||||||
|
void adjustScrollbars (const std::size_t);
|
||||||
void adjustSize() override;
|
void adjustSize() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -383,8 +384,9 @@ class FListView : public FWidget
|
||||||
template <typename Compare>
|
template <typename Compare>
|
||||||
void sort (Compare);
|
void sort (Compare);
|
||||||
std::size_t getAlignOffset ( const fc::text_alignment
|
std::size_t getAlignOffset ( const fc::text_alignment
|
||||||
, std::size_t
|
, const std::size_t
|
||||||
, std::size_t );
|
, const std::size_t );
|
||||||
|
iterator getListEnd (FListViewItem*);
|
||||||
void draw() override;
|
void draw() override;
|
||||||
void drawBorder() override;
|
void drawBorder() override;
|
||||||
void drawScrollbars();
|
void drawScrollbars();
|
||||||
|
|
Loading…
Reference in New Issue