1#line 2 "src/Gui/TableView.cpp"
5#ifdef TABLEVIEW_HACK_V4_12_16
9#include <Wt/WMessageBox.h>
10#include <Wt/WStandardItem.h>
11#include <Wt/WStandardItemModel.h>
13#include "../Glb/gcwglobal.h"
14#include "../GnuCashew.h"
25static auto keyToCode(
Wt::Key _key )-> std::string
27 std::map< Wt::Key, std::string > keyMap =
122 "event.cancelBubble = true; event.returnValue = false; return false;"
134 std::cout << __FILE__ <<
":" << __LINE__ <<
" clicked row: " << _index.
row() <<
" col: " << _index.
column() << std::endl;
140 std::cout << __FILE__ <<
":" << __LINE__ <<
" doubleClicked row: " << _index.
row() <<
" col: " << _index.
column() << std::endl;
147 std::cout << __FILE__ <<
":" << __LINE__ <<
" mouseWentDown row: " << _index.
row() <<
" col: " << _index.
column() << std::endl;
153 std::cout << __FILE__ <<
":" << __LINE__ <<
" mouseWentUp row: " << _index.
row() <<
" col: " << _index.
column() << std::endl;
159 std::cout << __FILE__ <<
":" << __LINE__ <<
" touchStart row: " << _index.
row() <<
" col: " << _index.
column() << std::endl;
183 std::cout << __FILE__ <<
":" << __LINE__ <<
" selectionChanged: " << std::endl;
189 std::cout << __FILE__ <<
":" << __LINE__ <<
" pageChanged: " << std::endl;
195 std::cout << __FILE__ <<
":" << __LINE__ <<
" pageChanged: " << std::endl;
202 std::cout << __FILE__ <<
":" << __LINE__ <<
" headerClicked: " << std::endl;
209 std::cout << __FILE__ <<
":" << __LINE__ <<
" headerDoubleClicked: " << std::endl;
216 std::cout << __FILE__ <<
":" << __LINE__ <<
" headerMouseWentDown: " << std::endl;
223 std::cout << __FILE__ <<
":" << __LINE__ <<
" headerMouseWentUp: " << std::endl;
230 std::cout << __FILE__ <<
":" << __LINE__ <<
" scrolled"
231 <<
" x:" << _event.scrollX()
232 <<
" y:" << _event.scrollY()
233 <<
" w:" << _event.viewportWidth()
234 <<
" h:" << _event.viewportHeight()
243 std::cout << __FILE__ <<
":" << __LINE__ <<
" keyWentDown: " << _event.charCode() <<
" key:" << keyToCode( _event.key() ) << std::endl;
250 std::cout << __FILE__ <<
":" << __LINE__ <<
" keyPressed: " << _event.charCode() <<
" key:" << keyToCode( _event.key() ) << std::endl;
256 std::cout << __FILE__ <<
":" << __LINE__ <<
" keyWentUp charCode:" << _event.charCode() <<
" key:" << keyToCode( _event.key() ) << std::endl;
266#ifdef TABLEVIEW_HACK_V4_12_16
279 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << __FUNCTION__ <<
"(" <<
" w:" << _width <<
", h:" << _height <<
" ) " <<
" " << m_lastTime <<
" " << _elapsedTime << std::endl;
280 unsigned long long _currentTime = time(NULL);
281 unsigned long long _elapsedTime = _currentTime - m_lastTime;
282 if( _elapsedTime < 1 )
296 for(
auto col : m_widths )
297 if( col.second.unit() == Wt::LengthUnit::Percentage )
300 auto percent_sum = 0.0;
301 for(
auto col : m_widths )
303 if( col.second.unit() != Wt::LengthUnit::Percentage )
304 fixed += col.second.toPixels();
306 percent_sum += col.second.value();
312 const auto epsilon = 0.5;
313 if( 100.0 - percent_sum > epsilon )
315 <<
"Warning: Relative column widths do not take up 100% of the available width: "
316 << percent_sum <<
"%"
323 nfixed = model()->columnCount() - nrel;
326 bool show_scroll = m_visible_rows > 0 && model()-> rowCount() > m_visible_rows;
328 auto remainder = _width - ( fixed + ( kTableCellPadding * model()->columnCount() ) + ( show_scroll ? kScrollBarWidth : 0.0 ) );
330 for(
auto col : m_widths )
332 if( col.second.unit() == Wt::LengthUnit::Percentage )
339 col.second.value()/100.0*remainder,
340 Wt::LengthUnit::Pixel
353#ifdef TABLEVIEW_HACK_V4_12_16
354 m_lastTime = time(NULL);
364 m_widths.emplace( column, width );
396 std::cout << __FILE__ <<
":" << __LINE__
397 <<
" handleClick:<start>"
398 <<
" row:" << _index.row()
399 <<
" col:" << _index.column()
405 if( selectedIndexes().size() > 0 )
407 auto selectedIndex = *selectedIndexes().begin();
410 std::cout << __FILE__ <<
":" << __LINE__
411 <<
" selected:" << selectedIndexes().size()
412 <<
" row:" << selectedIndex.row()
413 <<
" col:" << selectedIndex.column()
428 if( selectedIndex.row () != _index.row ()
429 && selectedIndex.column () != _index.column ()
444 auto row = _index.row();
445 for(
int column = 0; column< m-> columnCount(); column++ )
447 std::cout << __FILE__ <<
":" << __LINE__
452 auto index = m-> index( row, column );
453 auto item = m-> itemFromIndex( index );
470 if( selectedIndexes().size() )
472 auto oldIndex = *selectedIndexes().begin();
474 std::cout << __FILE__ <<
":" << __LINE__ <<
" handleCLick()"
475 <<
" old:" << oldIndex.row()
476 <<
" new:" << _index.row()
479 if( _index.row() != oldIndex.row() )
482 closeEditors(
true );
495 std::cout << __FILE__ <<
":" << __LINE__ <<
" handleClick:<end>" << std::endl;
507 std::cout << __FILE__ <<
":" << __LINE__
508 <<
" handleDoubleClick:<start>"
509 <<
" row:" << _index.row()
510 <<
" col:" << _index.column()
518 std::cout << __FILE__ <<
":" << __LINE__ <<
" handleDoubleClick:<end>" << std::endl;
536 <<
" row:" << _index.row()
537 <<
" col:" << _index.column()
543 if( m_lastIndexClick.isValid() )
544 if( m_lastIndexClick. row () != _index. row ()
545 || m_lastIndexClick. column () != _index. column ()
554 auto balanceIndex = model()-> index( _index.row(), 7 );
556 std::cout << __FILE__ <<
":" << __LINE__ <<
" " <<balanceIndex.data(
Wt::ItemDataRole::User ).type().name() << std::endl;
559 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << balanceValue << std::endl;
572 m_lastIndexClick = _index;
583 std::cout << __FILE__ <<
":" << __LINE__
584 <<
" handleMouseUp:<start>"
585 <<
" row:" << _index.row()
586 <<
" col:" << _index.column()
594 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