11 #include <QApplication>
12 #include <QHeaderView>
13 #include <QMessageBox>
14 #include <QSortFilterProxyModel>
21 const int ModuleSelectHistory::sMaxEntries = 10;
23 ModuleSelectHistory* ModuleSelectHistory::inst =
nullptr;
97 return mEntries.size();
135 QString runIconPath =
":/icons/filled-circle";
152 return mEntries.at(irow).id();
157 return mEntries.at(irow).color();
168 mSortMechanism = sortMechanism;
207 return checkRow(source_row, source_parent, 1, 3, 1);
223 if (mModules.
size() > 1)
225 for (
u32 modId : mModules)
237 if (mGates.
size() > 1)
239 for (
u32 modId : mGates)
243 retval +=
QString(
" '%1'[%2]").
arg(
g->get_name().c_str()).
arg(
g->get_id());
265 Module* firstAccepted =
nullptr;
267 bool terminate =
true;
291 else if (notAccepted)
326 if (exclude_ids !=
nullptr)
346 if (selected.
indexes().empty())
351 Q_UNUSED(deselected);
352 const ModuleSelectProxy* prox =
static_cast<const ModuleSelectProxy*
>(
model());
354 const ModuleSelectModel* modl =
static_cast<const ModuleSelectModel*
>(prox->sourceModel());
356 u32 selModId = modl->moduleId(sourceIndex.
row());
360 void ModuleSelectView::handleDoubleClick(
const QModelIndex& index)
362 const ModuleSelectProxy* prox =
static_cast<const ModuleSelectProxy*
>(
model());
364 const ModuleSelectModel* modl =
static_cast<const ModuleSelectModel*
>(prox->sourceModel());
365 QModelIndex sourceIndex = prox->mapToSource(index);
366 u32 selModId = modl->moduleId(sourceIndex.
row());
GraphTabWidget * getGraphTabWidget()
Get hal's graph tab widget.
std::string get_name() const
std::string get_type() const
The ModuleSelectEntry class comprises a single entry of the module selection table.
QVariant data(int icol) const
data returns data from requested column
ModuleSelectEntry(Module *m)
QString selectionToString() const
selectionToString function is used to generate selection as text for message box
bool isAccepted(u32 modId) const
The ModuleSelectHistory class singleton comprises a list of user selected modules.
static ModuleSelectHistory * instance()
The ModuleSelectModel class is the source model for module selection.
QColor moduleColor(int irow) const
void excludeModulesById(QSet< u32 > id_set)
void appendEntries(bool history)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
ModuleSelectModel(QObject *parent=nullptr)
ModuleSelectModel constructor.
u32 moduleId(int irow) const
int columnCount(const QModelIndex &parent=QModelIndex()) const override
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
void handleSelectionChanged(void *sender)
ModuleSelectPicker(ModuleSelectReceiver *receiver, QObject *parent=nullptr)
void modulesPicked(QSet< u32 > mods)
void triggerCursor(int icurs)
The ModuleSelectProxy class allows sorting and filtering of module tables.
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
void startSearch(QString text, int options) override
static bool lessThan(const QColor &a, const QColor &b)
ModuleSelectProxy(QObject *parent=nullptr)
void setSortMechanism(gui_utility::mSortMechanism sortMechanism)
virtual void handleModulesPicked(const QSet< u32 > &mods)=0
void moduleSelected(u32 modId, bool doubleClick)
ModuleSelectView(bool history, Searchbar *sbar, QSet< u32 > *exclude_ids, QWidget *parent=nullptr)
ModuleSelectView constructor.
Gate * get_gate_by_id(const u32 gate_id) const
const std::vector< Module * > & get_modules() const
Module * get_module_by_id(u32 module_id) const
QColor getModuleColor(const u32 id)
SearchOptions mSearchOptions
bool checkRow(int sourceRow, const QModelIndex &sourceParent, int startIndex, int endIndex, int offset=0) const
Should be called inside filterAcceptsRow function and returns true if the source_row,...
A QFrame with a QLineEdit that can be used to input a substring to search for.
void triggerNewSearch(const QString &text, int searchOptions)
int numberSelectedItems() const
void selectionChanged(void *sender)
QList< u32 > selectedModulesList() const
QList< u32 > selectedGatesList() const
QIcon getStyledSvgIcon(const QString &from_to_colors_enabled, const QString &svg_path, QString from_to_colors_disabled=QString())
int compare(mSortMechanism mechanism, QString a, QString b)
ContentManager * gContentManager
SelectionRelay * gSelectionRelay
NetlistRelay * gNetlistRelay
void doubleClicked(const QModelIndex &index)
QAbstractItemModel * model() const const
void setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior)
void setSelectionMode(QAbstractItemView::SelectionMode mode)
QItemSelectionModel * selectionModel() const const
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
QString name() const const
int saturation() const const
QModelIndexList indexes() const const
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
bool isEmpty() const const
void prepend(const T &value)
int removeAll(const T &value)
QMessageBox::StandardButton warning(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
bool isValid() const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
QObject * parent() const const
QObject * sender() const const
QSet::iterator insert(const T &value)
virtual void setSourceModel(QAbstractItemModel *sourceModel) override
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
QString fromStdString(const std::string &str)
bool isEmpty() const const
void sortByColumn(int column)
void resizeColumnsToContents()
virtual void setModel(QAbstractItemModel *model) override
void setSortingEnabled(bool enable)