LibrePCB Developers Documentation
EditableTableWidget Class Reference

A QTableView subclass which adds buttons to edit the underlying model. More...

#include <editabletablewidget.h>

Inherits QTableView.

+ Collaboration diagram for EditableTableWidget:

Signals

void readOnlyChanged (bool readOnly)
 
void canRemoveChanged (bool canRemove)
 
void currentRowChanged (int row)
 
void btnAddClicked (const QPersistentModelIndex &itemIndex)
 
void btnRemoveClicked (const QPersistentModelIndex &itemIndex)
 
void btnCopyClicked (const QPersistentModelIndex &itemIndex)
 
void btnEditClicked (const QPersistentModelIndex &itemIndex)
 
void btnMoveUpClicked (const QPersistentModelIndex &itemIndex)
 
void btnMoveDownClicked (const QPersistentModelIndex &itemIndex)
 
void btnBrowseClicked (const QPersistentModelIndex &itemIndex)
 

Public Member Functions

 EditableTableWidget (QWidget *parent=nullptr) noexcept
 
 EditableTableWidget (const EditableTableWidget &other)=delete
 
virtual ~EditableTableWidget () noexcept
 
virtual void setModel (QAbstractItemModel *model) noexcept override
 
void setReadOnly (bool readOnly) noexcept
 
void setAddButtonOnLastRow (bool btn) noexcept
 
void setShowCopyButton (bool show) noexcept
 
void setShowEditButton (bool show) noexcept
 
void setShowMoveButtons (bool show) noexcept
 
void setBrowseButtonColumn (int col) noexcept
 
void setMinimumRowCount (int count) noexcept
 
virtual void reset () override
 
EditableTableWidgetoperator= (const EditableTableWidget &rhs)=delete
 

Protected Member Functions

virtual bool edit (const QModelIndex &index, EditTrigger trigger, QEvent *event) override
 
virtual void currentChanged (const QModelIndex &current, const QModelIndex &previous) override
 
virtual void rowsInserted (const QModelIndex &parent, int start, int end) override
 

Private Types

typedef void(EditableTableWidget::* Signal) (const QPersistentModelIndex &)
 

Private Member Functions

void updateCanRemove () noexcept
 
void installButtons (int row) noexcept
 
QToolButton * createButton (const QString &objectName, const QIcon &icon, const QString &text, const QString &toolTip, int width, int height, Signal clickedSignal, const QPersistentModelIndex &itemIndex, bool doesModify, bool doesRemove) noexcept
 
void buttonClickedHandler (Signal clickedSignal, const QPersistentModelIndex &itemIndex) noexcept
 

Private Attributes

bool mAddButtonOnLastRow
 
bool mShowCopyButton
 
bool mShowEditButton
 
bool mShowMoveButtons
 
int mBrowseButtonColumn
 
int mMinimumRowCount
 
bool mCanRemove
 
bool mReadOnly
 
QScopedPointer< QAction > mActionAddRow
 
QScopedPointer< QAction > mActionRemoveRow
 
QMetaObject::Connection mRowsRemovedConnection
 

Detailed Description

A QTableView subclass which adds buttons to edit the underlying model.

Member Typedef Documentation

◆ Signal

typedef void(EditableTableWidget::* Signal) (const QPersistentModelIndex &)
private

Constructor & Destructor Documentation

◆ EditableTableWidget() [1/2]

EditableTableWidget ( QWidget *  parent = nullptr)
explicitnoexcept
+ Here is the call graph for this function:

◆ EditableTableWidget() [2/2]

EditableTableWidget ( const EditableTableWidget other)
delete

◆ ~EditableTableWidget()

~EditableTableWidget ( )
virtualnoexcept

Member Function Documentation

◆ setModel()

void setModel ( QAbstractItemModel *  model)
overridevirtualnoexcept

◆ setReadOnly()

void setReadOnly ( bool  readOnly)
noexcept

◆ setAddButtonOnLastRow()

void setAddButtonOnLastRow ( bool  btn)
inlinenoexcept

◆ setShowCopyButton()

void setShowCopyButton ( bool  show)
inlinenoexcept

◆ setShowEditButton()

void setShowEditButton ( bool  show)
inlinenoexcept

◆ setShowMoveButtons()

void setShowMoveButtons ( bool  show)
inlinenoexcept

◆ setBrowseButtonColumn()

void setBrowseButtonColumn ( int  col)
inlinenoexcept

◆ setMinimumRowCount()

void setMinimumRowCount ( int  count)
noexcept

◆ reset()

void reset ( )
overridevirtual

◆ operator=()

EditableTableWidget & operator= ( const EditableTableWidget rhs)
delete

◆ edit()

bool edit ( const QModelIndex &  index,
EditTrigger  trigger,
QEvent *  event 
)
overrideprotectedvirtual

◆ currentChanged()

void currentChanged ( const QModelIndex &  current,
const QModelIndex &  previous 
)
overrideprotectedvirtual

◆ rowsInserted()

void rowsInserted ( const QModelIndex &  parent,
int  start,
int  end 
)
overrideprotectedvirtual

◆ readOnlyChanged

void readOnlyChanged ( bool  readOnly)
signal

◆ canRemoveChanged

void canRemoveChanged ( bool  canRemove)
signal

◆ currentRowChanged

void currentRowChanged ( int  row)
signal
+ Here is the caller graph for this function:

◆ btnAddClicked

void btnAddClicked ( const QPersistentModelIndex &  itemIndex)
signal
+ Here is the caller graph for this function:

◆ btnRemoveClicked

void btnRemoveClicked ( const QPersistentModelIndex &  itemIndex)
signal
+ Here is the caller graph for this function:

◆ btnCopyClicked

void btnCopyClicked ( const QPersistentModelIndex &  itemIndex)
signal
+ Here is the caller graph for this function:

◆ btnEditClicked

void btnEditClicked ( const QPersistentModelIndex &  itemIndex)
signal
+ Here is the caller graph for this function:

◆ btnMoveUpClicked

void btnMoveUpClicked ( const QPersistentModelIndex &  itemIndex)
signal
+ Here is the caller graph for this function:

◆ btnMoveDownClicked

void btnMoveDownClicked ( const QPersistentModelIndex &  itemIndex)
signal
+ Here is the caller graph for this function:

◆ btnBrowseClicked

void btnBrowseClicked ( const QPersistentModelIndex &  itemIndex)
signal
+ Here is the caller graph for this function:

◆ updateCanRemove()

void updateCanRemove ( )
privatenoexcept

◆ installButtons()

void installButtons ( int  row)
privatenoexcept

◆ createButton()

QToolButton * createButton ( const QString &  objectName,
const QIcon &  icon,
const QString &  text,
const QString &  toolTip,
int  width,
int  height,
Signal  clickedSignal,
const QPersistentModelIndex &  itemIndex,
bool  doesModify,
bool  doesRemove 
)
privatenoexcept

◆ buttonClickedHandler()

void buttonClickedHandler ( Signal  clickedSignal,
const QPersistentModelIndex &  itemIndex 
)
privatenoexcept

Member Data Documentation

◆ mAddButtonOnLastRow

bool mAddButtonOnLastRow
private

◆ mShowCopyButton

bool mShowCopyButton
private

◆ mShowEditButton

bool mShowEditButton
private

◆ mShowMoveButtons

bool mShowMoveButtons
private

◆ mBrowseButtonColumn

int mBrowseButtonColumn
private

◆ mMinimumRowCount

int mMinimumRowCount
private

◆ mCanRemove

bool mCanRemove
private

◆ mReadOnly

bool mReadOnly
private

◆ mActionAddRow

QScopedPointer<QAction> mActionAddRow
private

◆ mActionRemoveRow

QScopedPointer<QAction> mActionRemoveRow
private

◆ mRowsRemovedConnection

QMetaObject::Connection mRowsRemovedConnection
private

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