GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
|
Custom Table View Class. More...
#include <TableView.h>
Public Member Functions | |
TableView () | |
ctor | |
auto | layoutSizeChanged (int _width, int _height) -> void override |
auto | setColumnWidth (int _column, const Wt::WLength &_width) -> void override |
auto | setVisibleRows (int _rows) -> void |
![]() | |
WTableView () | |
virtual WWidget * | itemWidget (const WModelIndex &index) const override |
virtual void | setModel (const std::shared_ptr< WAbstractItemModel > &model) override |
virtual void | setAlternatingRowColors (bool enable) override |
virtual void | setRowHeight (const WLength &rowHeight) override |
virtual void | setHeaderHeight (const WLength &height) override |
virtual void | resize (const WLength &width, const WLength &height) override |
virtual void | setColumnHidden (int column, bool hidden) override |
virtual void | setRowHeaderCount (int count) override |
virtual int | pageCount () const override |
virtual int | pageSize () const override |
virtual int | currentPage () const override |
virtual void | setCurrentPage (int page) override |
virtual void | scrollTo (const WModelIndex &index, ScrollHint hint=ScrollHint::EnsureVisible) override |
void | scrollTo (int x, int y) |
void | setOverflow (Overflow overflow, WFlags< Orientation > orientation=(Orientation::Horizontal|Orientation::Vertical)) |
void | setPreloadMargin (const WLength &margin, WFlags< Side > side=AllSides) |
WLength | preloadMargin (Side side) const |
virtual void | setHidden (bool hidden, const WAnimation &animation=WAnimation()) override |
WModelIndex | modelIndexAt (WWidget *widget) const |
virtual EventSignal< WScrollEvent > & | scrolled () override |
virtual void | setHeaderHeight (const WLength &height) |
![]() | |
std::shared_ptr< WAbstractItemModel > | model () const |
void | setRootIndex (const WModelIndex &rootIndex) |
const WModelIndex & | rootIndex () const |
void | setItemDelegate (const std::shared_ptr< WAbstractItemDelegate > &delegate) |
std::shared_ptr< WAbstractItemDelegate > | itemDelegate () const |
void | setItemDelegateForColumn (int column, const std::shared_ptr< WAbstractItemDelegate > &delegate) |
std::shared_ptr< WAbstractItemDelegate > | itemDelegateForColumn (int column) const |
std::shared_ptr< WAbstractItemDelegate > | itemDelegate (const WModelIndex &index) const |
std::shared_ptr< WAbstractItemDelegate > | itemDelegate (int column) const |
void | setHeaderItemDelegate (const std::shared_ptr< WAbstractItemDelegate > &delegate) |
std::shared_ptr< WAbstractItemDelegate > | headerItemDelegate () const |
virtual void | setColumnAlignment (int column, AlignmentFlag alignment) |
virtual AlignmentFlag | columnAlignment (int column) const |
virtual void | setHeaderAlignment (int column, WFlags< AlignmentFlag > alignment) |
AlignmentFlag | horizontalHeaderAlignment (int column) const |
AlignmentFlag | verticalHeaderAlignment (int column) const |
void | setHeaderWordWrap (int column, bool enabled) |
virtual bool | alternatingRowColors () const |
void | sortByColumn (int column, SortOrder order) |
int | sortColumn () const |
SortOrder | sortOrder () const |
void | setSortingEnabled (bool enabled) |
void | setSortingEnabled (int column, bool enabled) |
bool | isSortingEnabled () const |
bool | isSortingEnabled (int column) const |
void | setColumnResizeEnabled (bool enabled) |
bool | isColumnResizeEnabled () const |
void | setSelectionBehavior (SelectionBehavior behavior) |
SelectionBehavior | selectionBehavior () const |
void | setSelectionMode (SelectionMode mode) |
SelectionMode | selectionMode () const |
WItemSelectionModel * | selectionModel () const |
void | setSelectedIndexes (const WModelIndexSet &indexes) |
void | clearSelection () |
void | select (const WModelIndex &index, SelectionFlag option=SelectionFlag::Select) |
bool | isSelected (const WModelIndex &index) const |
WModelIndexSet | selectedIndexes () const |
void | setDragEnabled (bool enable) |
void | setDropsEnabled (bool enable) |
void | setEnabledDropLocations (WFlags< DropLocation > droplocation) |
WFlags< DropLocation > | enabledDropLocations () const |
const WLength & | rowHeight () const |
WLength | columnWidth (int column) const |
bool | isColumnHidden (int column) const |
void | hideColumn (int column) |
void | showColumn (int column) |
const WLength & | headerHeight () const |
void | setEditTriggers (WFlags< EditTrigger > editTriggers) |
WFlags< EditTrigger > | editTriggers () const |
void | setEditOptions (WFlags< EditOption > options) |
WFlags< EditOption > | editOptions () const |
void | edit (const WModelIndex &index) |
void | closeEditor (const WModelIndex &index, bool saveData=true) |
void | closeEditors (bool saveData=true) |
ValidationState | validateEditor (const WModelIndex &index) |
ValidationState | validateEditors () |
bool | isEditing (const WModelIndex &index) const |
bool | isValid (const WModelIndex &index) const |
Signal< WModelIndex, WMouseEvent > & | clicked () |
Signal< WModelIndex, WMouseEvent > & | doubleClicked () |
Signal< WModelIndex, WMouseEvent > & | mouseWentDown () |
Signal< WModelIndex, WMouseEvent > & | mouseWentUp () |
Signal< WModelIndex, WTouchEvent > & | touchStart () |
Signal< std::vector< WModelIndex >, WTouchEvent > & | touchStarted () |
Signal< std::vector< WModelIndex >, WTouchEvent > & | touchMoved () |
Signal< std::vector< WModelIndex >, WTouchEvent > & | touchEnded () |
Signal & | selectionChanged () |
Signal & | pageChanged () |
Signal< int, WLength > & | columnResized () |
bool | sortEnabled () |
void | setHeaderClickSortEnabled (bool enabled) |
Signal< int, WMouseEvent > & | headerClicked () |
Signal< int, WMouseEvent > & | headerDoubleClicked () |
Signal< int, WMouseEvent > & | headerMouseWentDown () |
Signal< int, WMouseEvent > & | headerMouseWentUp () |
int | rowHeaderCount () const |
EventSignal< WKeyEvent > & | keyWentDown () |
EventSignal< WKeyEvent > & | keyPressed () |
EventSignal< WKeyEvent > & | keyWentUp () |
![]() | |
WCompositeWidget () | |
WCompositeWidget (std::unique_ptr< WWidget > implementation) | |
virtual std::vector< WWidget * > | children () const override |
virtual std::unique_ptr< WWidget > | removeWidget (WWidget *widget) override |
virtual void | setObjectName (const std::string &name) override |
virtual std::string | objectName () const override |
virtual const std::string | id () const override |
virtual void | setPositionScheme (PositionScheme scheme) override |
virtual PositionScheme | positionScheme () const override |
virtual void | setOffsets (const WLength &offset, WFlags< Side > sides=AllSides) override |
virtual WLength | offset (Side s) const override |
virtual WLength | width () const override |
virtual WLength | height () const override |
virtual void | setMinimumSize (const WLength &width, const WLength &height) override |
virtual WLength | minimumWidth () const override |
virtual WLength | minimumHeight () const override |
virtual void | setMaximumSize (const WLength &width, const WLength &height) override |
virtual WLength | maximumWidth () const override |
virtual WLength | maximumHeight () const override |
virtual void | setLineHeight (const WLength &height) override |
virtual WLength | lineHeight () const override |
virtual void | setFloatSide (Side s) override |
virtual Side | floatSide () const override |
virtual void | setClearSides (WFlags< Side > sides) override |
virtual WFlags< Side > | clearSides () const override |
virtual void | setMargin (const WLength &margin, WFlags< Side > sides=AllSides) override |
virtual WLength | margin (Side side) const override |
virtual void | setHiddenKeepsGeometry (bool enabled) override |
virtual bool | hiddenKeepsGeometry () const override |
virtual bool | isHidden () const override |
virtual bool | isVisible () const override |
virtual void | setDisabled (bool disabled) override |
virtual bool | isDisabled () const override |
virtual bool | isEnabled () const override |
virtual void | setPopup (bool popup) override |
virtual bool | isPopup () const override |
virtual void | setInline (bool isInline) override |
virtual bool | isInline () const override |
virtual void | setDecorationStyle (const WCssDecorationStyle &style) override |
virtual WCssDecorationStyle & | decorationStyle () override |
virtual void | setStyleClass (const WString &styleClass) override |
virtual WString | styleClass () const override |
virtual void | addStyleClass (const WString &styleClass, bool force=false) override |
virtual void | removeStyleClass (const WString &styleClass, bool force=false) override |
virtual bool | hasStyleClass (const WString &styleClass) const override |
virtual void | setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength::Auto) override |
virtual AlignmentFlag | verticalAlignment () const override |
virtual WLength | verticalAlignmentLength () const override |
virtual void | setToolTip (const WString &text, TextFormat textFormat=TextFormat::Plain) override |
virtual WString | toolTip () const override |
virtual void | setDeferredToolTip (bool enable, TextFormat textFormat=TextFormat::Plain) override |
virtual void | refresh () override |
virtual void | setAttributeValue (const std::string &name, const WString &value) override |
virtual WString | attributeValue (const std::string &name) const override |
virtual void | setJavaScriptMember (const std::string &name, const std::string &value) override |
virtual std::string | javaScriptMember (const std::string &name) const override |
virtual void | callJavaScriptMember (const std::string &name, const std::string &args) override |
virtual void | load () override |
virtual bool | loaded () const override |
virtual void | setCanReceiveFocus (bool enabled) override |
virtual bool | canReceiveFocus () const override |
virtual void | setFocus (bool focus) override |
virtual bool | setFirstFocus () override |
virtual bool | hasFocus () const override |
virtual void | setTabIndex (int index) override |
virtual int | tabIndex () const override |
virtual void | setId (const std::string &id) override |
virtual WWidget * | find (const std::string &name) override |
virtual WWidget * | findById (const std::string &name) override |
virtual void | setSelectable (bool selectable) override |
virtual void | doJavaScript (const std::string &js) override |
virtual void | propagateSetEnabled (bool enabled) override |
virtual bool | scrollVisibilityEnabled () const final override |
virtual void | setScrollVisibilityEnabled (bool enabled) final override |
virtual int | scrollVisibilityMargin () const final override |
virtual void | setScrollVisibilityMargin (int margin) final override |
virtual Signal< bool > & | scrollVisibilityChanged () final override |
virtual bool | isScrollVisible () const final override |
virtual void | setThemeStyleEnabled (bool enabled) final override |
virtual bool | isThemeStyleEnabled () const final override |
virtual std::unique_ptr< WWidget > | removeWidget (WWidget *widget) |
std::unique_ptr< Widget > | removeWidget (Widget *widget) |
void | setFocus () |
virtual void | setFocus (bool focus)=0 |
![]() | |
virtual | ~WWidget () |
WWidget * | parent () const |
std::unique_ptr< Widget > | removeWidget (Widget *widget) |
std::unique_ptr< WWidget > | removeFromParent () |
void | setWidth (const WLength &width) |
void | setHeight (const WLength &height) |
virtual void | positionAt (const WWidget *widget, Orientation orientation=Orientation::Vertical) |
virtual void | toggleStyleClass (const WString &styleClass, bool add, bool force=false) |
std::string | jsRef () const |
void | setFocus () |
virtual void | acceptDrops (const std::string &mimeType, const WString &hoverStyleClass=WString()) |
virtual void | stopAcceptDrops (const std::string &mimeType) |
virtual void | htmlText (std::ostream &out) |
bool | isRendered () const |
void | hide () |
void | animateHide (const WAnimation &animation) |
void | show () |
void | animateShow (const WAnimation &animation) |
void | enable () |
void | disable () |
bool | layoutSizeAware () const |
![]() | |
void | addChild (std::unique_ptr< WObject > child) |
Child * | addChild (std::unique_ptr< Child > child) |
std::unique_ptr< WObject > | removeChild (WObject *child) |
std::unique_ptr< Child > | removeChild (Child *child) |
void | resetLearnedSlots () |
void | resetLearnedSlot (void(T::*method)()) |
WStatelessSlot * | implementStateless (void(T::*method)()) |
WStatelessSlot * | implementStateless (void(T::*method)(), void(T::*undoMethod)()) |
void | isNotStateless () |
WStatelessSlot * | implementJavaScript (void(T::*method)(), const std::string &jsCode) |
![]() | |
observable () noexcept | |
virtual | ~observable () |
auto | bindSafe (void(C::*method)(Args...)) noexcept |
auto | bindSafe (void(C::*method)(Args...) const) const noexcept |
auto | bindSafe (const Function &function) noexcept |
Static Public Attributes | |
static const int | kTableHeaderRowHeight = 30 |
static const int | kTableBodyRowHeight = 20 |
static const int | kTableCellPadding = 7 |
static const int | kScrollBarWidth = 20 |
static const int | kDefaultDateTimeWidth = 120 |
Protected Member Functions | |
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 |
![]() | |
virtual void | render (WFlags< RenderFlag > flags) override |
virtual void | adjustSize () |
virtual void | enableAjax () override |
![]() | |
WAbstractItemView () | |
virtual void | dropEvent (const WDropEvent &event, const WModelIndex &target) |
virtual void | dropEvent (const WDropEvent &event, const WModelIndex &index, Wt::Side side) |
virtual std::unique_ptr< WWidget > | createExtraHeaderWidget (int column) |
WWidget * | extraHeaderWidget (int column) |
virtual std::unique_ptr< WWidget > | createPageNavigationBar () |
virtual void | handleDoubleClick (const WModelIndex &index, const WMouseEvent &event) |
virtual void | handleMouseUp (const WModelIndex &index, const WMouseEvent &event) |
virtual void | handleTouchSelect (const std::vector< WModelIndex > &indices, const WTouchEvent &event) |
virtual void | handleTouchStart (const std::vector< WModelIndex > &indices, const WTouchEvent &event) |
virtual void | handleTouchMove (const std::vector< WModelIndex > &indices, const WTouchEvent &event) |
virtual void | handleTouchEnd (const std::vector< WModelIndex > &indices, const WTouchEvent &event) |
virtual void | dropEvent (WDropEvent dropEvent) |
![]() | |
void | setImplementation (std::unique_ptr< WWidget > widget) |
Widget * | setImplementation (std::unique_ptr< Widget > widget) |
W * | setNewImplementation (Args &&... args) |
WWidget * | implementation () |
virtual int | boxPadding (Orientation orientation) const override |
virtual int | boxBorder (Orientation orientation) const override |
![]() | |
void | setLayoutSizeAware (bool sizeAware) |
WWidget () | |
void | scheduleRender (WFlags< RepaintFlag > flags=None) |
virtual WStatelessSlot * | getStateless (Method method) override |
Protected Attributes | |
Wt::WModelIndex | m_lastIndexClick |
std::map< int, Wt::WLength > | m_widths |
int | m_visible_rows = -1 |
int | m_editingRow = -1 |
Additional Inherited Members | |
![]() | |
typedef void(WObject::* | Method) () |
![]() | |
static WString | tr (const char *key) |
Custom Table View Class.
Implementing our own table view class derived from the Wt one. This implementation is designed to be layout aware. Key features include auto-resizing columns.
Code Credit: https://redmine.webtoolkit.eu/boards/1/topics/11110?r=18058#message-18058 Matt Russell (mruss.nosp@m.ell@.nosp@m.nepte.nosp@m.c.co.nosp@m.m)
Definition at line 23 of file TableView.h.
GCW::Gui::TableView::TableView | ( | ) |
ctor
Definition at line 99 of file TableView.cpp.
References Wt::WCompositeWidget::addStyleClass(), Wt::WAbstractItemView::clicked(), Wt::WModelIndex::column(), Wt::WAbstractItemView::columnResized(), Wt::Signal< class... A >::connect(), Wt::WAbstractItemView::doubleClicked(), Wt::WAbstractItemView::headerClicked(), Wt::WAbstractItemView::headerDoubleClicked(), Wt::WAbstractItemView::headerMouseWentDown(), Wt::WAbstractItemView::headerMouseWentUp(), Wt::WAbstractItemView::keyPressed(), Wt::WAbstractItemView::keyWentDown(), Wt::WAbstractItemView::keyWentUp(), kTableBodyRowHeight, kTableHeaderRowHeight, Wt::WAbstractItemView::mouseWentDown(), Wt::WAbstractItemView::mouseWentUp(), Wt::WAbstractItemView::pageChanged(), Wt::WModelIndex::row(), Wt::WTableView::scrolled(), Wt::WAbstractItemView::selectionChanged(), Wt::WCompositeWidget::setAttributeValue(), Wt::WTableView::setHeaderHeight(), Wt::WWidget::setLayoutSizeAware(), Wt::WTableView::setRowHeight(), and Wt::WAbstractItemView::touchStart().
|
protectedvirtual |
Handle Click Event.
This handler responds to 'click' events in the view.
The intent here is to provide some 'handling' when the user is mouse-ing around the table view. He should be able to click around to get editors to open, and select rows and whatnot.
The 'purpose' for the handler is due to the fact that the view responds differently if the view is editable or not. For instance, if an index is read-only, clicking on it causes the view to 'select' the entire row. But, if the index is 'Editable' then you are placed in to the editor but the view 'selection' is still visible, even if it's on another row. Further, the editor widget that opened, did not signal to the rest of the row that it should be 'selected'.
Reimplemented from Wt::WAbstractItemView.
Definition at line 361 of file TableView.cpp.
References Wt::Editable, and Wt::WAbstractItemView::handleClick().
|
protectedvirtual |
Reimplemented from Wt::WAbstractItemView.
Definition at line 495 of file TableView.cpp.
References BREAKFOOTER, BREAKHEADER, Wt::WAbstractItemView::handleMouseDown(), and Wt::ItemDataRole::User.
|
overridevirtual |
Upon a table resize, size the columns appropriately.
int | width Full table width |
int | height Full table height |
Reimplemented from Wt::WWidget.
Definition at line 257 of file TableView.cpp.
References Wt::WWidget::layoutSizeChanged().
|
overridevirtual |
Overload setColumnWidth so we can save what the user specifies into our map. This implementation can take both absolute and relative (percentage) widths. Percentages are interpretted as the percentage of non-allocated width remaining. i.e. if a table is 100px, and one column has an absolute width of 20px, then the two following relative columns should both use 50%, which would yeild 40px each (minus padding.)
Reimplemented from Wt::WTableView.
Definition at line 329 of file TableView.cpp.
References Wt::WTableView::setColumnWidth().
|
inline |
Set the number of visible rows before a scroll bar appears
Definition at line 69 of file TableView.h.
References m_visible_rows.
|
static |
Default fixed width a date/time column takes up (without wrapping)
Definition at line 41 of file TableView.h.
|
static |
Width that a scroll bar adds to a table
Definition at line 38 of file TableView.h.
|
static |
|
static |
Assumed table cell padding
Definition at line 35 of file TableView.h.
|
static |
|
protected |
Definition at line 93 of file TableView.h.
|
protected |
Definition at line 78 of file TableView.h.
|
protected |
Definition at line 88 of file TableView.h.
Referenced by setVisibleRows().
|
protected |
Definition at line 83 of file TableView.h.