QElectroTech  0.8-dev
Public Types | Signals | Public Member Functions | Private Member Functions | Private Attributes | List of all members
DynamicElementTextModel Class Reference

The DynamicElementTextModel class A model to use with QtView. This model display and can edit the value of dynamic text of an element. Set the delegate DynamicTextItemDelegate as delegate of this model. More...

#include <dynamicelementtextmodel.h>

Inherits QStandardItemModel.

Collaboration diagram for DynamicElementTextModel:
Collaboration graph

Public Types

enum  ValueType {
  textFrom =1, userText, infoText, compositeText,
  txtAlignment, size, font, color,
  pos, frame, rotation, textWidth,
  grpAlignment, grpPos, grpRotation, grpVAdjust,
  grpName, grpHoldBottom, grpFrame
}
 

Signals

void dataChanged ()
 

Public Member Functions

 DynamicElementTextModel (Element *element, QObject *parent=nullptr)
 
 ~DynamicElementTextModel () override
 
bool indexIsInGroup (const QModelIndex &index) const
 DynamicElementTextModel::indexIsInGroup. More...
 
DynamicElementTextItemtextFromIndex (const QModelIndex &index) const
 DynamicElementTextModel::textFromIndex. More...
 
DynamicElementTextItemtextFromItem (QStandardItem *item) const
 DynamicElementTextModel::textFromItem. More...
 
QModelIndex indexFromText (DynamicElementTextItem *text) const
 DynamicElementTextModel::indexFromText. More...
 
QUndoCommand * undoForEditedText (DynamicElementTextItem *deti, QUndoCommand *parent_undo=nullptr) const
 DynamicElementTextModel::undoForEditedText. More...
 
QUndoCommand * undoForEditedGroup (ElementTextItemGroup *group, QUndoCommand *parent_undo=nullptr) const
 DynamicElementTextModel::undoForEditedGroup. More...
 
ElementTextItemGroupgroupFromIndex (const QModelIndex &index) const
 DynamicElementTextModel::groupFromIndex. More...
 
ElementTextItemGroupgroupFromItem (QStandardItem *item) const
 DynamicElementTextModel::groupFromItem. More...
 
QModelIndex indexFromGroup (ElementTextItemGroup *group) const
 DynamicElementTextModel::indexFromGroup. More...
 
bool indexIsText (const QModelIndex &index) const
 DynamicElementTextModel::indexIsText. More...
 
bool indexIsGroup (const QModelIndex &index) const
 DynamicElementTextModel::indexIsGroup. More...
 
bool canDropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override
 
bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
 DynamicElementTextModel::dropMimeData. More...
 
QMimeData * mimeData (const QModelIndexList &indexes) const override
 
QStringList mimeTypes () const override
 DynamicElementTextModel::mimeTypes. More...
 

Private Member Functions

QList< QStandardItem * > itemsForText (DynamicElementTextItem *deti)
 DynamicElementTextModel::itemsForText. More...
 
void addText (DynamicElementTextItem *deti)
 DynamicElementTextModel::addText. More...
 
void removeText (DynamicElementTextItem *deti)
 DynamicElementTextModel::removeText. More...
 
void addGroup (ElementTextItemGroup *group)
 DynamicElementTextModel::AddGroup Add a text item group to this model. More...
 
void removeGroup (ElementTextItemGroup *group)
 DynamicElementTextModel::removeGroup Remove the text item group from this model. More...
 
void addTextToGroup (DynamicElementTextItem *deti, ElementTextItemGroup *group)
 DynamicElementTextModel::textAddedToGroup Add the text text to the group group. More...
 
void removeTextFromGroup (DynamicElementTextItem *deti, ElementTextItemGroup *group)
 
void enableSourceText (DynamicElementTextItem *deti, DynamicElementTextItem::TextFrom tf)
 DynamicElementTextModel::enableSourceText Enable the good field, according to the current source of text, for the edited text deti. More...
 
void enableGroupRotationAndPos (ElementTextItemGroup *group)
 DynamicElementTextModel::enableGroupRotation Enable/disable the item "group rotation" according the option hold to bottom. More...
 
void itemDataChanged (QStandardItem *qsi)
 
void setConnection (DynamicElementTextItem *deti, bool set)
 DynamicElementTextModel::setConnection Set up the connection for deti to keep up to date the data of this model and the text. Is notably use with the use of QUndoCommand. More...
 
void setConnection (ElementTextItemGroup *group, bool set)
 DynamicElementTextModel::setConnection Set up the connection for group to keep up to date the data of this model and the group. Is notably use with the use of QUndoCommand. More...
 
void updateDataFromText (DynamicElementTextItem *deti, DynamicElementTextModel::ValueType type)
 
void updateDataFromGroup (ElementTextItemGroup *group, DynamicElementTextModel::ValueType type)
 

Private Attributes

QPointer< Elementm_element
 
QHash< DynamicElementTextItem *, QStandardItem * > m_texts_list
 
QHash< ElementTextItemGroup *, QStandardItem * > m_groups_list
 
QHash< DynamicElementTextItem *, QList< QMetaObject::Connection > > m_hash_text_connect
 
QHash< ElementTextItemGroup *, QList< QMetaObject::Connection > > m_hash_group_connect
 
bool m_block_dataChanged = false
 

Detailed Description

The DynamicElementTextModel class A model to use with QtView. This model display and can edit the value of dynamic text of an element. Set the delegate DynamicTextItemDelegate as delegate of this model.

Member Enumeration Documentation

◆ ValueType

Enumerator
textFrom 
userText 
infoText 
compositeText 
txtAlignment 
size 
font 
color 
pos 
frame 
rotation 
textWidth 
grpAlignment 
grpPos 
grpRotation 
grpVAdjust 
grpName 
grpHoldBottom 
grpFrame 

Constructor & Destructor Documentation

◆ DynamicElementTextModel()

DynamicElementTextModel::DynamicElementTextModel ( Element element,
QObject *  parent = nullptr 
)
Here is the call graph for this function:

◆ ~DynamicElementTextModel()

DynamicElementTextModel::~DynamicElementTextModel ( )
override
Here is the call graph for this function:

Member Function Documentation

◆ addGroup()

void DynamicElementTextModel::addGroup ( ElementTextItemGroup group)
private

DynamicElementTextModel::AddGroup Add a text item group to this model.

Parameters
group
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addText()

void DynamicElementTextModel::addText ( DynamicElementTextItem deti)
private

DynamicElementTextModel::addText.

Parameters
deti
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addTextToGroup()

void DynamicElementTextModel::addTextToGroup ( DynamicElementTextItem deti,
ElementTextItemGroup group 
)
private

DynamicElementTextModel::textAddedToGroup Add the text text to the group group.

Parameters
deti
group
Here is the call graph for this function:
Here is the caller graph for this function:

◆ canDropMimeData()

bool DynamicElementTextModel::canDropMimeData ( const QMimeData *  data,
Qt::DropAction  action,
int  row,
int  column,
const QModelIndex &  parent 
) const
override
Here is the call graph for this function:

◆ dataChanged

void DynamicElementTextModel::dataChanged ( )
signal
Here is the caller graph for this function:

◆ dropMimeData()

bool DynamicElementTextModel::dropMimeData ( const QMimeData *  data,
Qt::DropAction  action,
int  row,
int  column,
const QModelIndex &  parent 
)
override

DynamicElementTextModel::dropMimeData.

Parameters
data
action
row
column
parent
Returns
In any case return false, for overwrite the default behavior of model.
Here is the call graph for this function:

◆ enableGroupRotationAndPos()

void DynamicElementTextModel::enableGroupRotationAndPos ( ElementTextItemGroup group)
private

DynamicElementTextModel::enableGroupRotation Enable/disable the item "group rotation" according the option hold to bottom.

Parameters
group
Here is the caller graph for this function:

◆ enableSourceText()

void DynamicElementTextModel::enableSourceText ( DynamicElementTextItem deti,
DynamicElementTextItem::TextFrom  tf 
)
private

DynamicElementTextModel::enableSourceText Enable the good field, according to the current source of text, for the edited text deti.

Parameters
deti
tf
Here is the caller graph for this function:

◆ groupFromIndex()

ElementTextItemGroup * DynamicElementTextModel::groupFromIndex ( const QModelIndex &  index) const

DynamicElementTextModel::groupFromIndex.

Parameters
index
Returns
the group associated with index. Return value can be nullptr Index can be a child of an index associated with a group and can be the column 0 or 1.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ groupFromItem()

ElementTextItemGroup * DynamicElementTextModel::groupFromItem ( QStandardItem *  item) const

DynamicElementTextModel::groupFromItem.

Parameters
item
Returns
the group associated with item. Return value can be nullptr item can be a child of an item associated with a group and can be the column 0 or 1.
Here is the caller graph for this function:

◆ indexFromGroup()

QModelIndex DynamicElementTextModel::indexFromGroup ( ElementTextItemGroup group) const

DynamicElementTextModel::indexFromGroup.

Parameters
group
Returns
The index associated to the group group or a default QModelIndex if not match
Here is the caller graph for this function:

◆ indexFromText()

QModelIndex DynamicElementTextModel::indexFromText ( DynamicElementTextItem text) const

DynamicElementTextModel::indexFromText.

Parameters
text
Returns
the QModelIndex for text, or a default QModelIndex if not match
Here is the caller graph for this function:

◆ indexIsGroup()

bool DynamicElementTextModel::indexIsGroup ( const QModelIndex &  index) const

DynamicElementTextModel::indexIsGroup.

Parameters
index
Returns
True if index represente a group, both for the column 0 and 1. Return false if index is a child of an index associated to a group.
Here is the caller graph for this function:

◆ indexIsInGroup()

bool DynamicElementTextModel::indexIsInGroup ( const QModelIndex &  index) const

DynamicElementTextModel::indexIsInGroup.

Parameters
index
Returns
True if the index represent a group or an item in a group
Here is the caller graph for this function:

◆ indexIsText()

bool DynamicElementTextModel::indexIsText ( const QModelIndex &  index) const

DynamicElementTextModel::indexIsText.

Parameters
index
Returns
True if index represente a text, both for the column 0 and 1. Return false if index is a child of an index associated to a text.
Here is the caller graph for this function:

◆ itemDataChanged()

void DynamicElementTextModel::itemDataChanged ( QStandardItem *  qsi)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ itemsForText()

QList< QStandardItem * > DynamicElementTextModel::itemsForText ( DynamicElementTextItem deti)
private

DynamicElementTextModel::itemsForText.

Parameters
deti
Returns
The items for the text deti, if the text deti is already managed by this model the returned list is empty The returned items haven't got the same number of childs if the text is in a group or not.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mimeData()

QMimeData * DynamicElementTextModel::mimeData ( const QModelIndexList &  indexes) const
override
Here is the call graph for this function:

◆ mimeTypes()

QStringList DynamicElementTextModel::mimeTypes ( ) const
override

◆ removeGroup()

void DynamicElementTextModel::removeGroup ( ElementTextItemGroup group)
private

DynamicElementTextModel::removeGroup Remove the text item group from this model.

Parameters
group
Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeText()

void DynamicElementTextModel::removeText ( DynamicElementTextItem deti)
private

DynamicElementTextModel::removeText.

Parameters
deti
Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeTextFromGroup()

void DynamicElementTextModel::removeTextFromGroup ( DynamicElementTextItem deti,
ElementTextItemGroup group 
)
private
Here is the caller graph for this function:

◆ setConnection() [1/2]

void DynamicElementTextModel::setConnection ( DynamicElementTextItem deti,
bool  set 
)
private

DynamicElementTextModel::setConnection Set up the connection for deti to keep up to date the data of this model and the text. Is notably use with the use of QUndoCommand.

Parameters
deti- text to setup connection
set- true = set connection - false unset connection
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setConnection() [2/2]

void DynamicElementTextModel::setConnection ( ElementTextItemGroup group,
bool  set 
)
private

DynamicElementTextModel::setConnection Set up the connection for group to keep up to date the data of this model and the group. Is notably use with the use of QUndoCommand.

Parameters
groupgroup to setup the connection
settrue = set connection - false unset connection
Here is the call graph for this function:

◆ textFromIndex()

DynamicElementTextItem * DynamicElementTextModel::textFromIndex ( const QModelIndex &  index) const

DynamicElementTextModel::textFromIndex.

Parameters
index
Returns
the text associated with index. Returned value can be nullptr Index can be a child of an index associated with a text and can be the column 0 or 1.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ textFromItem()

DynamicElementTextItem * DynamicElementTextModel::textFromItem ( QStandardItem *  item) const

DynamicElementTextModel::textFromItem.

Parameters
item
Returns
the text associated with item. Return value can be nullptr item can be a child of an item associated with a text and can be the column 0 or 1. Note can return nullptr
Here is the caller graph for this function:

◆ undoForEditedGroup()

QUndoCommand * DynamicElementTextModel::undoForEditedGroup ( ElementTextItemGroup group,
QUndoCommand *  parent_undo = nullptr 
) const

DynamicElementTextModel::undoForEditedGroup.

Parameters
group
parent_undo
Returns
A QUndoCommand that describe all changes made for group. Each change made for group is append as a child of the returned QUndoCommand. In other word, if the returned QUndoCommand have no child, that mean there is no change.
Here is the caller graph for this function:

◆ undoForEditedText()

QUndoCommand * DynamicElementTextModel::undoForEditedText ( DynamicElementTextItem deti,
QUndoCommand *  parent_undo = nullptr 
) const

DynamicElementTextModel::undoForEditedText.

Parameters
deti
parent_undo
Returns
A QUndoCommand that describe all changes made for deti. Each change made for deti is append as a child of the returned QUndoCommand. In other word, if the returned QUndoCommand have no child, that mean there is no change.
Here is the caller graph for this function:

◆ updateDataFromGroup()

void DynamicElementTextModel::updateDataFromGroup ( ElementTextItemGroup group,
DynamicElementTextModel::ValueType  type 
)
private
Here is the caller graph for this function:

◆ updateDataFromText()

void DynamicElementTextModel::updateDataFromText ( DynamicElementTextItem deti,
DynamicElementTextModel::ValueType  type 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_block_dataChanged

bool DynamicElementTextModel::m_block_dataChanged = false
private

◆ m_element

QPointer<Element> DynamicElementTextModel::m_element
private

◆ m_groups_list

QHash<ElementTextItemGroup *, QStandardItem *> DynamicElementTextModel::m_groups_list
private

◆ m_hash_group_connect

QHash<ElementTextItemGroup *, QList<QMetaObject::Connection> > DynamicElementTextModel::m_hash_group_connect
private

◆ m_hash_text_connect

QHash<DynamicElementTextItem *, QList<QMetaObject::Connection> > DynamicElementTextModel::m_hash_text_connect
private

◆ m_texts_list

QHash<DynamicElementTextItem *, QStandardItem *> DynamicElementTextModel::m_texts_list
private

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