GridBase Class

GridBase implements the base features for Qtitan::Grid, Qtitan::TreeGrid and Qtitan::CardGrid classes. More...

Header: #include <GridBase>
Inherits: AbstractScrollArea
Inherited By:

CardGrid, Grid, and TreeGrid

Public Types

flags SaveOption
enum SaveOptionFlag { SaveNone, SaveAutoFormatting, SaveLayout, SaveFilter, SaveFilterHistory, …, SaveAll }

Public Functions

GridBase(QWidget *parent = Q_NULL)
virtual ~GridBase() override
GridHitInfo hitInfo(const QPoint &pos)
QList<GridHitInfo> hitInfoAll() const
bool loadLayoutFromDevice(QIODevice *device)
bool loadLayoutFromFile(const QString &fileName)
bool loadLayoutFromXML(IXmlStreamReader *xmlreader)
GridViewBase *rootView() const
bool saveLayoutToDevice(QIODevice *device, GridBase::SaveOption option = SaveAll)
bool saveLayoutToFile(const QString &fileName, GridBase::SaveOption option = SaveAll)
bool saveLayoutToXML(IXmlStreamWriter *xmlwriter, GridBase::SaveOption option = SaveAll)
View *view() const

Reimplemented Public Functions

virtual QSize sizeHint() const override

Static Public Members

bool loadTranslation(const QString &country = QString())

Protected Functions

void setRootView(GridViewBase *view)

Detailed Description

Member Type Documentation

enum GridBase::SaveOptionFlag
flags GridBase::SaveOption

The enumerator describes the various settings for saving the grid state in XML

ConstantValueDescription
GridBase::SaveNone0x000Do not save anything
GridBase::SaveAutoFormatting0x001Use the auto-formatting of the XML document while saving.
GridBase::SaveLayout0x002Save grid layout to the XML.
GridBase::SaveFilter0x004Save grid filter to the XML.
GridBase::SaveFilterHistory0x008Save grid filter history to the XML.
GridBase::SaveFindPanel0x010Save grid find panel settings to the XML.
GridBase::SaveSummary0x020Save grid summaries settings to the XML.
GridBase::SaveRows0x040Save grid rows expanded/collapsed states to the XML.
GridBase::SaveAllSaveAutoFormatting | SaveLayout | SaveFilter | SaveFilterHistory | SaveFindPanel | SaveSummary | SaveRowsSave all settings and enable XML auto-formatting

The SaveOption type is a typedef for QFlags<SaveOptionFlag>. It stores an OR combination of SaveOptionFlag values.

Member Function Documentation

GridBase::GridBase(QWidget *parent = Q_NULL)

Constructor of the class GridBase. The parameter parent is a widget which will be parent and owner for the grid.

[override virtual] GridBase::~GridBase()

Destuctor of the class Qtitan::GridBase.

GridHitInfo GridBase::hitInfo(const QPoint &pos)

Returns a hint info by given point. The method is used to determine the type of element which is located at the given point of the grid.

QList<GridHitInfo> GridBase::hitInfoAll() const

Returns a list of GridHitInfo for all grid's elements that are visible on the view.

bool GridBase::loadLayoutFromDevice(QIODevice *device)

Load from XML of the internals view from the given device.

See also loadLayoutFromFile() and loadLayoutFromXML().

bool GridBase::loadLayoutFromFile(const QString &fileName)

Load from XML of the internals view from the given fileName.

See also loadLayoutFromDevice() and loadLayoutFromXML().

bool GridBase::loadLayoutFromXML(IXmlStreamReader *xmlreader)

Load from XML of the internals view from the XML reader - xmlreader.

See also loadLayoutFromDevice() and loadLayoutFromFile().

[static] bool GridBase::loadTranslation(const QString &country = QString())

Installs translator to QApplication based on country variable. Format variable is de_de, ru_ru, fr_fr. If country is empty then loaded QTranslator based on current locale setting.

GridViewBase *GridBase::rootView() const

Returns a reference to a base class of the view. This reference must be converted into the desired type of view by youself.

Qtitan::Grid* grid = new Qtitan::Grid();
grid->setViewType(Qtitan::Grid::TableView);
GridTableView* view = qobject_cast<GridTableView *>(grid->rootView());

Note: Getter function for property rootView.

See also setRootView().

bool GridBase::saveLayoutToDevice(QIODevice *device, GridBase::SaveOption option = SaveAll)

Save to XML of the internals view to the given device and option. The layout includes column's or band's sizing, order of grouping, visual position of the elements and etc. Additionally, the filter state and filter history can be stored. To do this, it is necessary to pass the flags GridSaveOption::SaveFilter | GridSaveOption::SaveFilterHistory via option parameter.

See also saveLayoutToFile() and saveLayoutToXML().

bool GridBase::saveLayoutToFile(const QString &fileName, GridBase::SaveOption option = SaveAll)

Save to XML of the internals view to the file given by fileName and option. For the details see saveLayoutToDevice().

See also saveLayoutToDevice() and saveLayoutToXML().

bool GridBase::saveLayoutToXML(IXmlStreamWriter *xmlwriter, GridBase::SaveOption option = SaveAll)

Save to XML of the internals view to the XML writer - xmlwriter with the given option.

See also saveLayoutToDevice() and saveLayoutToFile().

[protected] void GridBase::setRootView(GridViewBase *view)

Sets the view instance to the grid. For internal purpose only.

See also rootView().

[override virtual] QSize GridBase::sizeHint() const

Reimplements: QAbstractScrollArea::sizeHint() const.

Returns an optimal size of the grid.

template <typename View> View *GridBase::view() const

Returns the instance of the view for the current grid. The function is a C++ template. It's allow you to get the view desired type.

Qtitan::Grid* grid = new Qtitan::Grid();
grid->setViewType(Qtitan::Grid::TableView);
GridTableView* view = grid->view<GridTableView>();

Alternatively, there is a method rootView() which returns a reference to a base class of the view. This reference must be converted into the desired type of view by youself. If the viewType is UndefinedView then this function return NULL.

See also setViewType() and viewType().