GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
GCW::Gui::TableView Class Reference

Custom Table View Class. More...

#include <TableView.h>

+ Inheritance diagram for GCW::Gui::TableView:

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
 
- Public Member Functions inherited from Wt::WTableView
 WTableView ()
 
virtual WWidgetitemWidget (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)
 
- Public Member Functions inherited from Wt::WAbstractItemView
std::shared_ptr< WAbstractItemModelmodel () const
 
void setRootIndex (const WModelIndex &rootIndex)
 
const WModelIndexrootIndex () const
 
void setItemDelegate (const std::shared_ptr< WAbstractItemDelegate > &delegate)
 
std::shared_ptr< WAbstractItemDelegateitemDelegate () const
 
void setItemDelegateForColumn (int column, const std::shared_ptr< WAbstractItemDelegate > &delegate)
 
std::shared_ptr< WAbstractItemDelegateitemDelegateForColumn (int column) const
 
std::shared_ptr< WAbstractItemDelegateitemDelegate (const WModelIndex &index) const
 
std::shared_ptr< WAbstractItemDelegateitemDelegate (int column) const
 
void setHeaderItemDelegate (const std::shared_ptr< WAbstractItemDelegate > &delegate)
 
std::shared_ptr< WAbstractItemDelegateheaderItemDelegate () 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
 
WItemSelectionModelselectionModel () 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< DropLocationenabledDropLocations () const
 
const WLengthrowHeight () const
 
WLength columnWidth (int column) const
 
bool isColumnHidden (int column) const
 
void hideColumn (int column)
 
void showColumn (int column)
 
const WLengthheaderHeight () const
 
void setEditTriggers (WFlags< EditTrigger > editTriggers)
 
WFlags< EditTriggereditTriggers () const
 
void setEditOptions (WFlags< EditOption > options)
 
WFlags< EditOptioneditOptions () 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 ()
 
SignalselectionChanged ()
 
SignalpageChanged ()
 
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 ()
 
- Public Member Functions inherited from Wt::WCompositeWidget
 WCompositeWidget ()
 
 WCompositeWidget (std::unique_ptr< WWidget > implementation)
 
virtual std::vector< WWidget * > children () const override
 
virtual std::unique_ptr< WWidgetremoveWidget (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< SideclearSides () 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 WCssDecorationStyledecorationStyle () 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 WWidgetfind (const std::string &name) override
 
virtual WWidgetfindById (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< WWidgetremoveWidget (WWidget *widget)
 
std::unique_ptr< Widget > removeWidget (Widget *widget)
 
void setFocus ()
 
virtual void setFocus (bool focus)=0
 
- Public Member Functions inherited from Wt::WWidget
virtual ~WWidget ()
 
WWidgetparent () const
 
std::unique_ptr< Widget > removeWidget (Widget *widget)
 
std::unique_ptr< WWidgetremoveFromParent ()
 
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
 
- Public Member Functions inherited from Wt::WObject
void addChild (std::unique_ptr< WObject > child)
 
Child * addChild (std::unique_ptr< Child > child)
 
std::unique_ptr< WObjectremoveChild (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)
 
- Public Member Functions inherited from Wt::Core::observable
 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
 
- Protected Member Functions inherited from Wt::WTableView
virtual void render (WFlags< RenderFlag > flags) override
 
virtual void adjustSize ()
 
virtual void enableAjax () override
 
- Protected Member Functions inherited from Wt::WAbstractItemView
 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< WWidgetcreateExtraHeaderWidget (int column)
 
WWidgetextraHeaderWidget (int column)
 
virtual std::unique_ptr< WWidgetcreatePageNavigationBar ()
 
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)
 
- Protected Member Functions inherited from Wt::WCompositeWidget
void setImplementation (std::unique_ptr< WWidget > widget)
 
Widget * setImplementation (std::unique_ptr< Widget > widget)
 
WsetNewImplementation (Args &&... args)
 
WWidgetimplementation ()
 
virtual int boxPadding (Orientation orientation) const override
 
virtual int boxBorder (Orientation orientation) const override
 
- Protected Member Functions inherited from Wt::WWidget
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::WLengthm_widths
 
int m_visible_rows = -1
 
int m_editingRow = -1
 

Additional Inherited Members

- Public Types inherited from Wt::WObject
typedef void(WObject::* Method) ()
 
- Static Public Member Functions inherited from Wt::WWidget
static WString tr (const char *key)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ TableView()

GCW::Gui::TableView::TableView ( )

Member Function Documentation

◆ handleClick()

auto GCW::Gui::TableView::handleClick ( const Wt::WModelIndex _index,
const Wt::WMouseEvent _event 
) -> void
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().

◆ handleMouseDown()

auto GCW::Gui::TableView::handleMouseDown ( const Wt::WModelIndex _index,
const Wt::WMouseEvent _event 
) -> void
protectedvirtual

◆ layoutSizeChanged()

auto GCW::Gui::TableView::layoutSizeChanged ( int  _width,
int  _height 
) -> void
overridevirtual

Upon a table resize, size the columns appropriately.

Parameters
intwidth Full table width
intheight Full table height

Reimplemented from Wt::WWidget.

Definition at line 257 of file TableView.cpp.

References Wt::WWidget::layoutSizeChanged().

◆ setColumnWidth()

auto GCW::Gui::TableView::setColumnWidth ( int  _column,
const Wt::WLength _width 
) -> void
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().

◆ setVisibleRows()

auto GCW::Gui::TableView::setVisibleRows ( int  _rows) -> void
inline

Set the number of visible rows before a scroll bar appears

Definition at line 69 of file TableView.h.

References m_visible_rows.

Member Data Documentation

◆ kDefaultDateTimeWidth

const int GCW::Gui::TableView::kDefaultDateTimeWidth = 120
static

Default fixed width a date/time column takes up (without wrapping)

Definition at line 41 of file TableView.h.

◆ kScrollBarWidth

const int GCW::Gui::TableView::kScrollBarWidth = 20
static

Width that a scroll bar adds to a table

Definition at line 38 of file TableView.h.

◆ kTableBodyRowHeight

const int GCW::Gui::TableView::kTableBodyRowHeight = 20
static

Default table row height

Definition at line 32 of file TableView.h.

Referenced by TableView().

◆ kTableCellPadding

const int GCW::Gui::TableView::kTableCellPadding = 7
static

Assumed table cell padding

Definition at line 35 of file TableView.h.

◆ kTableHeaderRowHeight

const int GCW::Gui::TableView::kTableHeaderRowHeight = 30
static

Default table header height

Definition at line 29 of file TableView.h.

Referenced by TableView().

◆ m_editingRow

int GCW::Gui::TableView::m_editingRow = -1
protected

Definition at line 93 of file TableView.h.

◆ m_lastIndexClick

Wt::WModelIndex GCW::Gui::TableView::m_lastIndexClick
protected

Definition at line 78 of file TableView.h.

◆ m_visible_rows

int GCW::Gui::TableView::m_visible_rows = -1
protected

Definition at line 88 of file TableView.h.

Referenced by setVisibleRows().

◆ m_widths

std::map< int, Wt::WLength > GCW::Gui::TableView::m_widths
protected

Definition at line 83 of file TableView.h.


The documentation for this class was generated from the following files: