-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADDITIVE] Add field access policy mode reference editor, modified wr…
…ite value editor.
- Loading branch information
Showing
18 changed files
with
1,110 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
//----------------------------------------------------------------------------- | ||
// File: ModeReferenceDelegate.cpp | ||
//----------------------------------------------------------------------------- | ||
// Project: Kactus 2 | ||
// Author: | ||
// Date: 10.8.2023 | ||
// | ||
// Description: | ||
// Delegate that provides editors for editing mode references. | ||
//----------------------------------------------------------------------------- | ||
|
||
#include "ModeReferenceDelegate.h" | ||
|
||
#include <QLineEdit> | ||
|
||
//----------------------------------------------------------------------------- | ||
// Function: ModeReferenceDelegate::ModeReferenceDelegate() | ||
//----------------------------------------------------------------------------- | ||
ModeReferenceDelegate::ModeReferenceDelegate(QObject* parent): | ||
QStyledItemDelegate(parent) | ||
{ | ||
|
||
} | ||
|
||
//----------------------------------------------------------------------------- | ||
// Function: ModeReferenceDelegate::createEditor() | ||
//----------------------------------------------------------------------------- | ||
QWidget* ModeReferenceDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const | ||
{ | ||
auto lineEdit = new QLineEdit(parent); | ||
return lineEdit; | ||
} | ||
|
||
//----------------------------------------------------------------------------- | ||
// Function: ModeReferenceDelegate::setEditorData() | ||
//----------------------------------------------------------------------------- | ||
void ModeReferenceDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const | ||
{ | ||
if (auto lineEdit = qobject_cast<QLineEdit*>(editor); lineEdit) | ||
{ | ||
lineEdit->setText(index.data(Qt::DisplayRole).toString()); | ||
} | ||
} | ||
|
||
//----------------------------------------------------------------------------- | ||
// Function: ModeReferenceDelegate::setModelData() | ||
//----------------------------------------------------------------------------- | ||
void ModeReferenceDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const | ||
{ | ||
auto lineEdit = qobject_cast<QLineEdit*>(editor); | ||
|
||
if (!lineEdit) | ||
{ | ||
return; | ||
} | ||
|
||
model->setData(index, lineEdit->text(), Qt::EditRole); | ||
} | ||
|
||
//----------------------------------------------------------------------------- | ||
// Function: ModeReferenceDelegate::commitAndCloseEditor() | ||
//----------------------------------------------------------------------------- | ||
void ModeReferenceDelegate::commitAndCloseEditor() | ||
{ | ||
auto editor = qobject_cast<QWidget*>(sender()); | ||
|
||
if (editor) | ||
{ | ||
emit commitData(editor); | ||
emit closeEditor(editor); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
//----------------------------------------------------------------------------- | ||
// File: ModeReferenceDelegate.h | ||
//----------------------------------------------------------------------------- | ||
// Project: Kactus 2 | ||
// Author: | ||
// Date: 10.8.2023 | ||
// | ||
// Description: | ||
// Delegate that provides editors for editing mode references. | ||
//----------------------------------------------------------------------------- | ||
|
||
#ifndef MODEREFERENCEDELEGATE_H | ||
#define MODEREFERENCEDELEGATE_H | ||
|
||
#include <QStyledItemDelegate> | ||
|
||
class ModeReferenceDelegate : public QStyledItemDelegate | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
|
||
/*! | ||
* The constructor. | ||
* | ||
* @param [in] parent The parent object. | ||
*/ | ||
ModeReferenceDelegate(QObject* parent); | ||
|
||
/*! | ||
* Create a new editor for the given item | ||
* | ||
* @param [in] parent Owner for the editor. | ||
* @param [in] option Contains options for the editor. | ||
* @param [in] index Model index identifying the item. | ||
* | ||
* @return The editor to be used to edit the item. | ||
*/ | ||
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override; | ||
|
||
/*! | ||
* Set the data for the editor. | ||
* | ||
* @param [in] editor The editor where the data is to be set. | ||
* @param [in] index Model index identifying the item that's data is to be set. | ||
*/ | ||
virtual void setEditorData(QWidget* editor, const QModelIndex& index) const override; | ||
|
||
/*! | ||
* Save the data from the editor to the model. | ||
* | ||
* @param [in] editor The editor that contains the data to store. | ||
* @param [in] model Model that contains the data structure where data is to be saved to. | ||
* @param [in] index Model index identifying the item that's data is to be saved. | ||
*/ | ||
virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override; | ||
|
||
private slots: | ||
|
||
/*! | ||
* Commit the data from the sending editor and close the editor. | ||
*/ | ||
void commitAndCloseEditor(); | ||
}; | ||
|
||
|
||
#endif // MODEREFERENCEDELEGATE_H | ||
|
||
|
||
|
Oops, something went wrong.