QElectroTech  0.70
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>

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 to the 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 . 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 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 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.

Definition at line 35 of file dynamicelementtextmodel.h.

Member Enumeration Documentation

◆ ValueType

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

Definition at line 40 of file dynamicelementtextmodel.h.

Constructor & Destructor Documentation

◆ DynamicElementTextModel()

DynamicElementTextModel::DynamicElementTextModel ( Element element,
QObject *  parent = nullptr 
)

◆ ~DynamicElementTextModel()

DynamicElementTextModel::~DynamicElementTextModel ( )
override

Member Function Documentation

◆ addGroup()

void DynamicElementTextModel::addGroup ( ElementTextItemGroup group)
private

◆ addText()

void DynamicElementTextModel::addText ( DynamicElementTextItem deti)
private

DynamicElementTextModel::addText.

Parameters
deti

Definition at line 334 of file dynamicelementtextmodel.cpp.

References itemsForText().

Referenced by DynamicElementTextModel().

◆ addTextToGroup()

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

DynamicElementTextModel::textAddedToGroup Add the text to the group .

Parameters
deti
group

Definition at line 783 of file dynamicelementtextmodel.cpp.

References itemsForText(), and m_groups_list.

Referenced by DynamicElementTextModel().

◆ canDropMimeData()

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

Definition at line 913 of file dynamicelementtextmodel.cpp.

References indexIsInGroup(), and m_element.

◆ dataChanged

void DynamicElementTextModel::dataChanged ( )
signal

◆ 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.

Definition at line 968 of file dynamicelementtextmodel.cpp.

References groupFromIndex(), indexIsInGroup(), m_element, and QET::Icons::tr.

◆ enableGroupRotationAndPos()

void DynamicElementTextModel::enableGroupRotationAndPos ( ElementTextItemGroup group)
private

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

Parameters
group

Definition at line 1131 of file dynamicelementtextmodel.cpp.

References ElementTextItemGroup::holdToBottomPage, m_groups_list, rot_grp_row, x_grp_row, and y_grp_row.

Referenced by addGroup(), and updateDataFromGroup().

◆ 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 .

Parameters
deti
tf

Definition at line 1100 of file dynamicelementtextmodel.cpp.

References compo_txt_row, DynamicElementTextItem::CompositeText, DynamicElementTextItem::ElementInfo, info_txt_row, m_texts_list, DynamicElementTextItem::UserText, and usr_txt_row.

Referenced by itemDataChanged(), itemsForText(), and updateDataFromText().

◆ groupFromIndex()

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

DynamicElementTextModel::groupFromIndex.

Parameters
index
Returns
the group associated with . Return value can be nullptr can be a child of an index associated with a group and can be the column 0 or 1.

Definition at line 808 of file dynamicelementtextmodel.cpp.

References groupFromItem().

Referenced by dropMimeData(), and DynamicElementTextItemEditor::on_m_remove_selection_clicked().

◆ groupFromItem()

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

DynamicElementTextModel::groupFromItem.

Parameters
item
Returns
the group associated with . Return value can be nullptr can be a child of an item associated with a group and can be the column 0 or 1.

Definition at line 825 of file dynamicelementtextmodel.cpp.

References m_groups_list.

Referenced by groupFromIndex(), and itemDataChanged().

◆ indexFromGroup()

QModelIndex DynamicElementTextModel::indexFromGroup ( ElementTextItemGroup group) const

DynamicElementTextModel::indexFromGroup.

Parameters
group
Returns
The index associated to the group or a default QModelIndex if not match

Definition at line 851 of file dynamicelementtextmodel.cpp.

References m_groups_list.

Referenced by DynamicElementTextItemEditor::setCurrentGroup().

◆ indexFromText()

QModelIndex DynamicElementTextModel::indexFromText ( DynamicElementTextItem text) const

DynamicElementTextModel::indexFromText.

Parameters
text
Returns
the QModelIndex for , or a default QModelIndex if not match

Definition at line 431 of file dynamicelementtextmodel.cpp.

References m_texts_list.

Referenced by DynamicElementTextItemEditor::setCurrentText().

◆ indexIsGroup()

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

DynamicElementTextModel::indexIsGroup.

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

Definition at line 892 of file dynamicelementtextmodel.cpp.

References m_groups_list.

Referenced by DynamicElementTextItemEditor::on_m_tree_view_clicked().

◆ 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

Definition at line 99 of file dynamicelementtextmodel.cpp.

References m_groups_list.

Referenced by canDropMimeData(), and dropMimeData().

◆ indexIsText()

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

DynamicElementTextModel::indexIsText.

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

Definition at line 865 of file dynamicelementtextmodel.cpp.

References m_texts_list.

Referenced by DynamicElementTextItemEditor::on_m_tree_view_clicked().

◆ itemDataChanged()

void DynamicElementTextModel::itemDataChanged ( QStandardItem *  qsi)
private

◆ itemsForText()

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

◆ mimeData()

QMimeData * DynamicElementTextModel::mimeData ( const QModelIndexList &  indexes) const
override

Definition at line 1061 of file dynamicelementtextmodel.cpp.

References m_texts_list, and DynamicElementTextItem::uuid().

◆ 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

Definition at line 766 of file dynamicelementtextmodel.cpp.

References m_groups_list, and setConnection().

Referenced by DynamicElementTextModel().

◆ removeText()

void DynamicElementTextModel::removeText ( DynamicElementTextItem deti)
private

DynamicElementTextModel::removeText.

Parameters
deti

Definition at line 343 of file dynamicelementtextmodel.cpp.

References m_texts_list, and setConnection().

Referenced by DynamicElementTextModel().

◆ removeTextFromGroup()

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

Definition at line 789 of file dynamicelementtextmodel.cpp.

References m_texts_list.

Referenced by DynamicElementTextModel().

◆ setConnection() [1/2]

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

◆ setConnection() [2/2]

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

DynamicElementTextModel::setConnection Set up the connection for 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

Definition at line 1266 of file dynamicelementtextmodel.cpp.

References ElementTextItemGroup::alignmentChanged(), ElementTextItemGroup::frameChanged(), grpAlignment, grpFrame, grpHoldBottom, grpName, grpPos, grpRotation, grpVAdjust, ElementTextItemGroup::holdToBottomPageChanged(), m_hash_group_connect, ElementTextItemGroup::rotationChanged(), updateDataFromGroup(), ElementTextItemGroup::verticalAdjustmentChanged(), ElementTextItemGroup::xChanged(), and ElementTextItemGroup::yChanged().

◆ textFromIndex()

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

DynamicElementTextModel::textFromIndex.

Parameters
index
Returns
the text associated with . Returned value can be nullptr can be a child of an index associated with a text and can be the column 0 or 1.

Definition at line 360 of file dynamicelementtextmodel.cpp.

References textFromItem().

Referenced by DynamicTextItemDelegate::createEditor(), DynamicElementTextItemEditor::on_m_remove_selection_clicked(), and DynamicTextItemDelegate::setModelData().

◆ textFromItem()

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

DynamicElementTextModel::textFromItem.

Parameters
item
Returns
the text associated with . Return value can be nullptr can be a child of an item associated with a text and can be the column 0 or 1. Note can return nullptr

Definition at line 378 of file dynamicelementtextmodel.cpp.

References m_groups_list, and m_texts_list.

Referenced by itemDataChanged(), and textFromIndex().

◆ undoForEditedGroup()

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

◆ undoForEditedText()

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

◆ updateDataFromGroup()

void DynamicElementTextModel::updateDataFromGroup ( ElementTextItemGroup group,
DynamicElementTextModel::ValueType  type 
)
private

◆ updateDataFromText()

void DynamicElementTextModel::updateDataFromText ( DynamicElementTextItem deti,
DynamicElementTextModel::ValueType  type 
)
private

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

Definition at line 107 of file dynamicelementtextmodel.h.

Referenced by setConnection(), and ~DynamicElementTextModel().

◆ m_hash_text_connect

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

Definition at line 106 of file dynamicelementtextmodel.h.

Referenced by setConnection(), and ~DynamicElementTextModel().

◆ m_texts_list

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

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