ManaPlus
Public Member Functions | Protected Member Functions | Private Attributes
TableModel Class Referenceabstract

#include <tablemodel.h>

Inheritance diagram for TableModel:
PlayerTableModel StaticTableModel

Public Member Functions

virtual ~TableModel ()
 
virtual int getRows () const =0
 
virtual int getColumns () const =0
 
virtual int getRowHeight () const =0
 
virtual int getColumnWidth (const int index) const =0
 
virtual WidgetgetElementAt (const int row, const int column) const =0
 
virtual void installListener (TableModelListener *const listener)
 
virtual void removeListener (TableModelListener *const listener)
 

Protected Member Functions

 TableModel ()
 
virtual void signalBeforeUpdate ()
 
virtual void signalAfterUpdate ()
 

Private Attributes

std::set< TableModelListener * > listeners
 

Detailed Description

A model for a regular table of widgets.

Definition at line 40 of file tablemodel.h.

Constructor & Destructor Documentation

◆ ~TableModel()

virtual TableModel::~TableModel ( )
inlinevirtual

Definition at line 45 of file tablemodel.h.

46  { }

◆ TableModel()

TableModel::TableModel ( )
inlineprotected

Definition at line 80 of file tablemodel.h.

80  :
81  listeners()
82  {
83  }
std::set< TableModelListener * > listeners
Definition: tablemodel.h:96

Member Function Documentation

◆ getColumns()

virtual int TableModel::getColumns ( ) const
pure virtual

◆ getColumnWidth()

virtual int TableModel::getColumnWidth ( const int  index) const
pure virtual

Determines the width of each individual column

Implemented in PlayerTableModel, and StaticTableModel.

Referenced by GuiTable::getColumnWidth().

◆ getElementAt()

virtual Widget* TableModel::getElementAt ( const int  row,
const int  column 
) const
pure virtual

Retrieves the widget stored at the specified location within the table.

Implemented in PlayerTableModel, and StaticTableModel.

Referenced by GuiTable::draw(), GuiTable::getWidgetAt(), GuiTable::installActionListeners(), GuiTable::safeDraw(), and GuiTable::setFocusHandler().

◆ getRowHeight()

virtual int TableModel::getRowHeight ( ) const
pure virtual

Determines the height for each row

Implemented in PlayerTableModel, and StaticTableModel.

Referenced by GuiTable::getRowHeight().

◆ getRows()

virtual int TableModel::getRows ( ) const
pure virtual

◆ installListener()

void TableModel::installListener ( TableModelListener *const  listener)
virtual

Definition at line 34 of file tablemodel.cpp.

35 {
36  if (listener != nullptr)
37  listeners.insert(listener);
38 }

References anonymous_namespace{itemlinkhandler.cpp}::listener, and listeners.

Referenced by GuiTable::setModel().

◆ removeListener()

void TableModel::removeListener ( TableModelListener *const  listener)
virtual

Definition at line 40 of file tablemodel.cpp.

41 {
42  if (listener != nullptr)
43  listeners.erase(listener);
44 }

References anonymous_namespace{itemlinkhandler.cpp}::listener, and listeners.

Referenced by GuiTable::setModel().

◆ signalAfterUpdate()

void TableModel::signalAfterUpdate ( )
protectedvirtual

Tells all listeners that the table has seen an update

Definition at line 55 of file tablemodel.cpp.

56 {
57  for (std::set<TableModelListener *>::const_iterator it = listeners.begin();
58  it != listeners.end(); ++it)
59  {
60  if (*it != nullptr)
61  (*it)->modelUpdated(true);
62  }
63 }

References listeners.

Referenced by PlayerTableModel::playerRelationsUpdated(), and StaticTableModel::set().

◆ signalBeforeUpdate()

void TableModel::signalBeforeUpdate ( )
protectedvirtual

Tells all listeners that the table is about to see an update

Definition at line 46 of file tablemodel.cpp.

47 {
48  for (std::set<TableModelListener *>::const_iterator it = listeners.begin();
49  it != listeners.end(); ++it)
50  {
51  (*it)->modelUpdated(false);
52  }
53 }

References listeners.

Referenced by PlayerTableModel::playerRelationsUpdated(), and StaticTableModel::set().

Field Documentation

◆ listeners

std::set<TableModelListener *> TableModel::listeners
private

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