1#line 2 "src/Gui/TableView.cpp"
3#include <Wt/WMessageBox.h>
4#include <Wt/WStandardItem.h>
5#include <Wt/WStandardItemModel.h>
7#include "../Glb/gcwglobal.h"
8#include "../GnuCashew.h"
19static auto keyToCode(
Wt::Key _key )-> std::string
21 std::map< Wt::Key, std::string > keyMap =
116 "event.cancelBubble = true; event.returnValue = false; return false;"
128 std::cout << __FILE__ <<
":" << __LINE__ <<
" clicked row: " << _index.
row() <<
" col: " << _index.
column() << std::endl;
134 std::cout << __FILE__ <<
":" << __LINE__ <<
" doubleClicked row: " << _index.
row() <<
" col: " << _index.
column() << std::endl;
141 std::cout << __FILE__ <<
":" << __LINE__ <<
" mouseWentDown row: " << _index.
row() <<
" col: " << _index.
column() << std::endl;
147 std::cout << __FILE__ <<
":" << __LINE__ <<
" mouseWentUp row: " << _index.
row() <<
" col: " << _index.
column() << std::endl;
153 std::cout << __FILE__ <<
":" << __LINE__ <<
" touchStart row: " << _index.
row() <<
" col: " << _index.
column() << std::endl;
177 std::cout << __FILE__ <<
":" << __LINE__ <<
" selectionChanged: " << std::endl;
183 std::cout << __FILE__ <<
":" << __LINE__ <<
" pageChanged: " << std::endl;
189 std::cout << __FILE__ <<
":" << __LINE__ <<
" pageChanged: " << std::endl;
196 std::cout << __FILE__ <<
":" << __LINE__ <<
" headerClicked: " << std::endl;
203 std::cout << __FILE__ <<
":" << __LINE__ <<
" headerDoubleClicked: " << std::endl;
210 std::cout << __FILE__ <<
":" << __LINE__ <<
" headerMouseWentDown: " << std::endl;
217 std::cout << __FILE__ <<
":" << __LINE__ <<
" headerMouseWentUp: " << std::endl;
224 std::cout << __FILE__ <<
":" << __LINE__ <<
" scrolled"
225 <<
" x:" << _event.scrollX()
226 <<
" y:" << _event.scrollY()
227 <<
" w:" << _event.viewportWidth()
228 <<
" h:" << _event.viewportHeight()
237 std::cout << __FILE__ <<
":" << __LINE__ <<
" keyWentDown: " << _event.charCode() <<
" key:" << keyToCode( _event.key() ) << std::endl;
244 std::cout << __FILE__ <<
":" << __LINE__ <<
" keyPressed: " << _event.charCode() <<
" key:" << keyToCode( _event.key() ) << std::endl;
250 std::cout << __FILE__ <<
":" << __LINE__ <<
" keyWentUp charCode:" << _event.charCode() <<
" key:" << keyToCode( _event.key() ) << std::endl;
269 for(
auto col : m_widths )
270 if( col.second.unit() == Wt::LengthUnit::Percentage )
273 auto percent_sum = 0.0;
274 for(
auto col : m_widths )
276 if( col.second.unit() != Wt::LengthUnit::Percentage )
277 fixed += col.second.toPixels();
279 percent_sum += col.second.value();
285 const auto epsilon = 0.5;
286 if( 100.0 - percent_sum > epsilon )
288 <<
"Warning: Relative column widths do not take up 100% of the available width: "
289 << percent_sum <<
"%"
296 nfixed = model()->columnCount() - nrel;
299 bool show_scroll = m_visible_rows > 0 && model()-> rowCount() > m_visible_rows;
301 auto remainder = _width - ( fixed + ( kTableCellPadding * model()->columnCount() ) + ( show_scroll ? kScrollBarWidth : 0.0 ) );
303 for(
auto col : m_widths )
305 if( col.second.unit() == Wt::LengthUnit::Percentage )
312 col.second.value()/100.0*remainder,
313 Wt::LengthUnit::Pixel
333 m_widths.emplace( column, width );
365 std::cout << __FILE__ <<
":" << __LINE__
366 <<
" handleClick:<start>"
367 <<
" row:" << _index.row()
368 <<
" col:" << _index.column()
374 if( selectedIndexes().size() > 0 )
376 auto selectedIndex = *selectedIndexes().begin();
379 std::cout << __FILE__ <<
":" << __LINE__
380 <<
" selected:" << selectedIndexes().size()
381 <<
" row:" << selectedIndex.row()
382 <<
" col:" << selectedIndex.column()
397 if( selectedIndex.row () != _index.row ()
398 && selectedIndex.column () != _index.column ()
413 auto row = _index.row();
414 for(
int column = 0; column< m-> columnCount(); column++ )
416 std::cout << __FILE__ <<
":" << __LINE__
421 auto index = m-> index( row, column );
422 auto item = m-> itemFromIndex( index );
439 if( selectedIndexes().size() )
441 auto oldIndex = *selectedIndexes().begin();
443 std::cout << __FILE__ <<
":" << __LINE__ <<
" handleCLick()"
444 <<
" old:" << oldIndex.row()
445 <<
" new:" << _index.row()
448 if( _index.row() != oldIndex.row() )
451 closeEditors(
true );
464 std::cout << __FILE__ <<
":" << __LINE__ <<
" handleClick:<end>" << std::endl;
476 std::cout << __FILE__ <<
":" << __LINE__
477 <<
" handleDoubleClick:<start>"
478 <<
" row:" << _index.row()
479 <<
" col:" << _index.column()
487 std::cout << __FILE__ <<
":" << __LINE__ <<
" handleDoubleClick:<end>" << std::endl;
505 <<
" row:" << _index.row()
506 <<
" col:" << _index.column()
512 if( m_lastIndexClick.isValid() )
513 if( m_lastIndexClick. row () != _index. row ()
514 || m_lastIndexClick. column () != _index. column ()
523 auto balanceIndex = model()-> index( _index.row(), 7 );
525 std::cout << __FILE__ <<
":" << __LINE__ <<
" " <<balanceIndex.data(
Wt::ItemDataRole::User ).type().name() << std::endl;
528 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << balanceValue << std::endl;
541 m_lastIndexClick = _index;
552 std::cout << __FILE__ <<
":" << __LINE__
553 <<
" handleMouseUp:<start>"
554 <<
" row:" << _index.row()
555 <<
" col:" << _index.column()
563 std::cout << __FILE__ <<
":" << __LINE__ <<
" handleMouseUp:<end>" << std::endl;
static const int kTableBodyRowHeight
auto handleClick(const Wt::WModelIndex &_index, const Wt::WMouseEvent &_event) -> void
Handle Click Event.
auto handleMouseDown(const Wt::WModelIndex &_index, const Wt::WMouseEvent &_event) -> void
static const int kTableHeaderRowHeight
static const int kScrollBarWidth
auto layoutSizeChanged(int _width, int _height) -> void override
static const int kTableCellPadding
auto setColumnWidth(int _column, const Wt::WLength &_width) -> void override
static const int kDefaultDateTimeWidth
static constexpr const int User
virtual Wt::Signals::connection connect(WObject *target, WObject::Method method) override
virtual void handleMouseUp(const WModelIndex &index, const WMouseEvent &event)
Signal< WModelIndex, WMouseEvent > & mouseWentUp()
virtual void handleMouseDown(const WModelIndex &index, const WMouseEvent &event)
Signal & selectionChanged()
EventSignal< WKeyEvent > & keyPressed()
Signal< int, WMouseEvent > & headerClicked()
EventSignal< WKeyEvent > & keyWentDown()
EventSignal< WKeyEvent > & keyWentUp()
virtual void handleClick(const WModelIndex &index, const WMouseEvent &event)
Signal< WModelIndex, WMouseEvent > & mouseWentDown()
Signal< WModelIndex, WTouchEvent > & touchStart()
Signal< WModelIndex, WMouseEvent > & clicked()
Signal< int, WMouseEvent > & headerMouseWentUp()
Signal< WModelIndex, WMouseEvent > & doubleClicked()
Signal< int, WMouseEvent > & headerMouseWentDown()
virtual void handleDoubleClick(const WModelIndex &index, const WMouseEvent &event)
Signal< int, WLength > & columnResized()
Signal< int, WMouseEvent > & headerDoubleClicked()
virtual void setColumnWidth(int column, const WLength &width) override
virtual EventSignal< WScrollEvent > & scrolled() override
virtual void setHeaderHeight(const WLength &height) override
virtual void setRowHeight(const WLength &rowHeight) override