5 #include <QtWidgets/QMenu>
6 #include <QApplication>
14 mCurrentGateId(0), mShowPlainDescr(false), mShowPlainPyDescr(false), mChangeBooleanFunc(false)
16 this->
setModel(mBooleanFunctionTableModel);
31 return mBooleanFunctionTableModel;
35 mBooleanFunctionTableModel->
setEntries(entries);
44 mCurrentGateId =
g ?
g->get_id() : 0;
47 void BooleanFunctionTable::resizeEvent(
QResizeEvent *event)
53 void BooleanFunctionTable::handleContextMenuRequest(
const QPoint &pos)
69 QString toClipboardText = entry->getEntryValueString();
70 QString description = mShowPlainDescr ?
"Boolean function to clipboard" : entry->getEntryIdentifier() +
" function to clipboard";
80 if(mChangeBooleanFunc && mCurrentGate)
82 QString entryIdentifier = entry->getEntryIdentifier();
83 menu.
addAction(
"Change Boolean function", [
this, entryIdentifier](){
84 InputDialog ipd(
"Change Boolean function",
"New function",
"");
90 ActionAddBooleanFunction* act =
new ActionAddBooleanFunction(entryIdentifier, funcRes.get(), mCurrentGateId);
100 pythonCode = entry->getPythonCode();
101 QString pythonDesc = mShowPlainPyDescr ?
"Get boolean function" :
"Get " + entry->getEntryIdentifier() +
" function";
104 menu.
addAction(
QIcon(
":/icons/python"), pythonDesc, [pythonCode](){
113 void BooleanFunctionTable::adjustTableSizes()
122 for (
int i = 0; i < mBooleanFunctionTableModel->
rowCount(); i++)
static Result< BooleanFunction > from_string(const std::string &expression)
BooleanFunctionTable(QWidget *parent=nullptr)
BooleanFunctionTableModel * getModel()
void setEntries(QVector< QSharedPointer< BooleanFunctionTableEntry >> entries)
void setGateInformation(Gate *g)
A model that holds BooleanFunctions and clear-preset behaviors.
QSharedPointer< BooleanFunctionTableEntry > getEntryAtRow(int row) const
void setEntries(QVector< QSharedPointer< BooleanFunctionTableEntry >> entries)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
virtual bool event(QEvent *event) override
virtual void resizeEvent(QResizeEvent *event) override
void setSelectionMode(QAbstractItemView::SelectionMode mode)
void setText(const QString &text, QClipboard::Mode mode)
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)
bool isEmpty() const const
virtual QModelIndex indexAt(const QPoint &pos) const const override
void resizeColumnsToContents()
void resizeRowsToContents()
int rowHeight(int row) const const
virtual void setModel(QAbstractItemModel *model) override
void setShowGrid(bool show)
void setWordWrap(bool on)