9 #include <QtWidgets/QMenu>
10 #include <QApplication>
15 #include <QColorDialog>
22 this->
setModel(mGroupingsOfItemModel);
40 return mGroupingsOfItemModel;
49 mCurrentObjectId = gate->
get_id();
50 mGroupingsOfItemModel->
setGate(gate);
61 mCurrentObjectId =
net->get_id();
80 void GroupingsOfItemWidget::resizeEvent(
QResizeEvent *event)
86 void GroupingsOfItemWidget::handleContextMenuRequest(
const QPoint &pos)
102 QString toClipboardText = e.name();
104 "Grouping name to clipboard",
113 "Grouping ID to clipboard",
123 menu.
addAction(
"Change grouping name", [
this, e](){changeNameTriggered(e);});
124 menu.
addAction(
"Change grouping color", [
this, e](){changeColorTriggered(e);});
129 if (mCurrentObjectType !=
ItemType::None && mCurrentObjectId > 0){
135 actionText =
"Remove gate from grouping";
136 rmGates.
insert(mCurrentObjectId);
140 actionText =
"Remove module from grouping";
141 rmMods.
insert(mCurrentObjectId);
145 actionText =
"Remove net from grouping";
146 rmNets.
insert(mCurrentObjectId);
151 [e,rmMods,rmGates,rmNets]()
153 ActionRemoveItemsFromObject* rmItemAction =
new ActionRemoveItemsFromObject(rmMods,rmGates,rmNets);
155 rmItemAction->setObjectLock(
true);
156 rmItemAction->exec();
168 QIcon(
":/icons/python"),
191 void GroupingsOfItemWidget::updateAppearance()
193 int n = mGroupingsOfItemModel->
rowCount();
203 void GroupingsOfItemWidget::adjustTableSizes()
210 for (
int i = 0; i < mGroupingsOfItemModel->
rowCount(); i++)
217 void GroupingsOfItemWidget::notifyNewTitle(
int elementCount)
219 if(elementCount < 1){
222 else if(elementCount == 1){
230 void GroupingsOfItemWidget::changeNameTriggered(GroupingTableEntry entry)
234 ipd.setWindowTitle(
"Rename Grouping");
235 ipd.setInfoText(
"Please select a new unique name for the grouping.");
236 QString oldName = entry.name();
237 grpModel->setAboutToRename(oldName);
238 ipd.setInputText(oldName);
239 ipd.addValidator(grpModel);
243 QString newName = ipd.textValue();
244 if (newName != oldName)
246 ActionRenameObject* act =
new ActionRenameObject(newName);
251 grpModel->setAboutToRename(
QString());
254 void GroupingsOfItemWidget::changeColorTriggered(GroupingTableEntry entry)
256 QColor color = entry.color();
260 ActionSetObjectColor* act =
new ActionSetObjectColor(color);
GroupingManagerWidget * getGroupingManagerWidget()
Displays a colored box for the GroupingManagerWidget.
A TableModel to store all Groupings that contain a specified Gate, Net or Module.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
void setModule(Module *module)
GroupingTableEntry getGroupingEntryAtRow(int row) const
static QString pyCodeGrouping(u32 groupingId)
const Module * module(const Gate *g, const NodeBoxes &boxes)
ContentManager * gContentManager
void layoutChanged(const QList< QPersistentModelIndex > &parents, QAbstractItemModel::LayoutChangeHint hint)
virtual bool event(QEvent *event) override
virtual void resizeEvent(QResizeEvent *event) override
void setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior)
void setSelectionMode(QAbstractItemView::SelectionMode mode)
void setItemDelegateForColumn(int column, QAbstractItemDelegate *delegate)
void setText(const QString &text, QClipboard::Mode mode)
bool isValid() const const
QColor getColor(const QColor &initial, QWidget *parent, const QString &title, QColorDialog::ColorDialogOptions options)
void setFrameStyle(int style)
bool isValid() const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject * sender() const const
QSet::iterator insert(const T &value)
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
QString number(int n, int base)
virtual QModelIndex indexAt(const QPoint &pos) const const override
void resizeColumnsToContents()
int rowHeight(int row) const const
virtual void setModel(QAbstractItemModel *model) override