9 #include <QDialogButtonBox>
10 #include <QPushButton>
50 if (!item)
return false;
63 bool stateWasEmpty = mSelectedGates.empty();
64 setSelectedGatesRecursion();
65 if (stateWasEmpty != mSelectedGates.empty())
80 setModuleStateRecursion(child,stat);
93 int countCheckable = 0;
96 countCheckable += insertModuleRecursion(subm, child);
101 if (isSel) ++countCheckable;
108 return countCheckable;
111 QPair<bool,bool> SelectGateModel::setCheckedRecursion(
bool applySet, BaseTreeItem *parentItem,
const QSet<u32> &selectedGateIds)
113 bool hasChecked =
false;
114 bool hasUnchecked =
false;
115 for (BaseTreeItem* bti : parentItem->getChildren())
118 if (res.first) hasChecked =
true;
119 if (res.second) hasUnchecked =
true;
121 SelectGateItem* item =
dynamic_cast<SelectGateItem*
>(parentItem);
126 switch (item->getType()) {
128 lastState = item->state();
129 if (hasChecked && hasUnchecked)
135 if (!applySet && item->state() != lastState)
144 if (selectedGateIds.
contains(item->id()))
171 void SelectGateModel::setSelectedGatesRecursion(SelectGateItem* item)
174 mSelectedGates.clear();
176 BaseTreeItem* parentItem =
nullptr;
179 if (!item->isSelectable())
return;
180 switch (item->getType()) {
188 if (g) mSelectedGates.push_back(g);
200 for (BaseTreeItem* childItem : parentItem->getChildren())
201 setSelectedGatesRecursion(
static_cast<SelectGateItem*
>(childItem));
208 for (
const Gate* g : gates)
209 selectedGateIds.
insert(g->get_id());
211 setCheckedRecursion(
true,
mRootItem, selectedGateIds);
212 setSelectedGatesRecursion();
227 setWindowTitle(
"Select combinatorical gates for logic evaluator");
252 mCompile =
new QCheckBox(
"Compile selected logic",
this);
266 void LogicEvaluatorSelectGates::handleSelectionStateChanged(
bool empty)
(Future) Base class for all tree models related to the details widget.
virtual QList< BaseTreeItem * > getChildren() const
virtual void appendChild(BaseTreeItem *child)
QModelIndex getIndexFromItem(BaseTreeItem *item) const
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
BaseTreeItem * getItemFromIndex(QModelIndex index) const
static bool acceptGate(const Gate *g)
LogicEvaluatorSelectGates(const std::vector< Gate * > &gates, QWidget *parent=nullptr)
QColor selBackground() const
QColor selForeground() const
const std::vector< Gate * > & get_gates() const
std::vector< Module * > get_submodules(const std::function< bool(Module *)> &filter=nullptr, bool recursive=false) const
TreeItemType getType() const
Qt::ItemFlags flags(const QModelIndex &index) const override
QVariant data(const QModelIndex &index, int role) const override
Enables filtering in the ModuleModel.
void startSearch(QString text, int options) override
Module * get_top_module() const
Gate * get_gate_by_id(const u32 gate_id) const
A QFrame with a QLineEdit that can be used to input a substring to search for.
void triggerNewSearch(const QString &text, int searchOptions)
Qt::CheckState state() const
bool isSelectable() const
void setState(Qt::CheckState stat)
void setSelectable(bool isSel)
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
const std::vector< Gate * > & selectedGates() const
void selectionStateChanged(bool empty)
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
void setChecked(const std::vector< Gate * > &gates)
SelectGateModel(QObject *parent=nullptr)
Qt::ItemFlags flags(const QModelIndex &index) const override
QModelIndex createIndex(int row, int column, void *ptr) const const
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles)
void * internalPointer() const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
bool contains(const T &value) const const
QSet::iterator insert(const T &value)
virtual void setSourceModel(QAbstractItemModel *sourceModel) override
virtual void polish(QWidget *widget)
virtual void unpolish(QWidget *widget)
void setColumnWidth(int column, int width)
virtual void setModel(QAbstractItemModel *model) override
int toInt(bool *ok) const const