23 #include <QResizeEvent>
27 #include <QVBoxLayout>
28 #include <QHeaderView>
36 #include <QApplication>
37 #include <QInputDialog>
59 mNewDirectoryAction->
setToolTip(
"New directory");
65 mOpenAction->
setText(
"Open view");
66 mNewViewAction->
setText(
"Create new view");
67 mNewDirectoryAction->
setText(
"Create new directory");
68 mRenameAction->
setText(
"Rename item");
69 mDuplicateAction->
setText(
"Duplicate view");
70 mDeleteAction->
setText(
"Delete item");
85 mContextTreeView->
setModel(mContextTreeProxyModel);
137 void ContextManagerWidget::handleHeaderSectionClicked(
int column)
142 void ContextManagerWidget::handleCreateContextClicked()
144 UserActionCompound* act =
new UserActionCompound;
145 act->setUseCreatedObject();
155 for (
int irow = first; irow <= last; irow++)
161 void ContextManagerWidget::handleCreateDirectoryClicked()
166 if (confirm && !newName.
isEmpty())
178 if (!defaultContext)
return;
193 if (!clickedContext)
return;
208 void ContextManagerWidget::handleRenameClicked()
215 if (!clicked_context)
return;
219 used_context_names.
append(context->name());
226 ipd.
setInfoText(
"Please select a new unique name for the view.");
240 ContextDirectory* clicked_directory = clicked_item->
directory();
242 if (!clicked_directory)
return;
246 ipd.setInfoText(
"Please select a new name for the directory.");
247 ipd.setInputText(clicked_directory->name());
251 ActionRenameObject* act =
new ActionRenameObject(ipd.textValue());
258 void ContextManagerWidget::handleDuplicateContextClicked()
262 if (!clicked_context)
return;
264 UserActionCompound* act =
new UserActionCompound;
265 act->setUseCreatedObject();
267 act->addAction(
new ActionAddItemsToObject(clicked_context->modules(),clicked_context->gates()));
271 void ContextManagerWidget::handleDeleteClicked()
274 if (!currentIndex.
isValid())
return;
278 if (currentItem->isContext()) {
279 GraphContext* clicked_context = currentItem->context();
281 if (!clicked_context)
return;
283 ActionDeleteObject* act =
new ActionDeleteObject;
287 else if (currentItem->isDirectory()) {
288 if (currentItem->getChildCount())
291 QMessageBox::information(
this,
"Directory not empty",
"You are about to delete a directory which is not empty.\nThis action cannot be undone",
296 ContextDirectory* clicked_directory = currentItem->directory();
298 if (!clicked_directory)
return;
300 ActionDeleteObject* act =
new ActionDeleteObject;
310 Q_UNUSED(deselected);
312 if(selected.
indexes().isEmpty())
313 setToolbarButtonsEnabled(
false);
315 setToolbarButtonsEnabled(
true);
318 void ContextManagerWidget::handleContextMenuRequest(
const QPoint& point)
323 ContextTreeItem* item =
static_cast<ContextTreeItem*
>(mContextTreeModel->
getItemFromIndex(sourceIndex));
330 context_menu.
addAction(mNewDirectoryAction);
335 if (!clicked_context && !clicked_directory) {
340 if (clicked_index.
isValid() && clicked_context)
343 context_menu.
addAction(mDuplicateAction);
348 if (clicked_index.
isValid() && clicked_directory)
375 if(proxy_model_index.
isValid())
386 if(proxy_model_index.
isValid())
397 return mContextTreeModel->
getContext(source_model_index);
406 if (currentItem != mContextTreeModel->
getRootItem())
435 void ContextManagerWidget::setToolbarButtonsEnabled(
bool enabled)
469 void ContextManagerWidget::toggleSearchbar()
488 return mDisabledIconStyle;
493 return mNewViewIconPath;
498 return mNewDirIconPath;
503 return mNewViewIconStyle;
508 return mRenameIconPath;
513 return mRenameIconStyle;
518 return mDuplicateIconPath;
523 return mDuplicateIconStyle;
528 return mDeleteIconPath;
533 return mDeleteIconStyle;
538 return mOpenIconPath;
543 return mOpenIconStyle;
548 return mSearchIconPath;
553 return mSearchIconStyle;
558 return mSearchActiveIconStyle;
563 mDisabledIconStyle =
style;
568 mNewViewIconPath = path;
573 mNewDirIconPath = path;
578 mNewViewIconStyle =
style;
583 mRenameIconPath = path;
588 mRenameIconStyle =
style;
593 mDuplicateIconPath = path;
598 mDuplicateIconStyle =
style;
603 mDeleteIconPath = path;
608 mDeleteIconStyle =
style;
613 mOpenIconPath = path;
618 mOpenIconStyle =
style;
623 mSearchIconPath = path;
628 mSearchIconStyle =
style;
633 mSearchActiveIconStyle =
style;
636 void ContextManagerWidget::handleFocusChanged(
QWidget* oldWidget,
QWidget* newWidget)
639 if(!newWidget)
return;
640 if(newWidget->
parent() ==
this)
Adds an item to a module or grouping.
(Future) Base class for all tree models related to the details widget.
QModelIndex getIndexFromItem(BaseTreeItem *item) const
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
BaseTreeItem * getRootItem() const
BaseTreeItem * getItemFromIndex(QModelIndex index) const
static SettingsItemKeybind * sSettingDeleteItem
Abstract class for Widgets within HAL's ContentArea.
QKeySequence mSearchKeysequence
QShortcut * mSearchShortcut
QVBoxLayout * mContentLayout
void setDuplicateIconStyle(const QString &style)
QString searchActiveIconStyle
void selectViewContext(GraphContext *context)
void setSearchIconStyle(const QString &style)
void setRenameIconPath(const QString &path)
void setOpenIconPath(const QString &path)
void handleItemClicked(const QModelIndex &proxyIndex)
void setDeleteIconPath(const QString &path)
void handleItemDoubleClicked(const QModelIndex &proxyIndex)
ContextManagerWidget(GraphTabWidget *tab_view, QWidget *parent=nullptr)
GraphContext * getCurrentContext()
void setDuplicateIconPath(const QString &path)
void setNewDirIconPath(const QString &path)
void setSearchActiveIconStyle(const QString &style)
ContextTreeItem * getCurrentItem()
QString duplicateIconStyle
void setRenameIconStyle(const QString &style)
void setDisabledIconStyle(const QString &path)
QString disabledIconStyle
void setNewViewIconStyle(const QString &style)
void setOpenIconStyle(const QString &style)
void setNewViewIconPath(const QString &path)
void handleOpenContextClicked()
void setSearchIconPath(const QString &path)
void setDeleteIconStyle(const QString &style)
virtual void setupToolbar(Toolbar *toolbar) override
QString duplicateIconPath
void selectDirectory(ContextTreeItem *item)
void handleRowsInserted(const QModelIndex &parent, int first, int last)
void enableSearchbar(bool enable)
A proxy model to filter the ContextTableModel by a given string.
void startSearch(QString text, int options) override
GraphContext * context() const
ContextDirectory * directory() const
void setCurrentDirectory(ContextTreeItem *currentItem)
void directoryCreatedSignal(ContextTreeItem *item)
QModelIndex getIndexFromContext(GraphContext *context) const
BaseTreeItem * getContext(u32 contextId) const
Checks if a given string is not empty.
Logical container for modules, gates, and nets.
void setExclusiveModuleId(u32 id, bool emitSignal=true)
ContextTreeModel * getContextTreeModel() const
QVector< GraphContext * > getContexts() const
std::string get_name() const
Module * get_top_module() const
virtual QList< QString > getColumnNames()
A QFrame with a QLineEdit that can be used to input a substring to search for.
void setColumnNames(QList< QString > list)
void triggerNewSearch(const QString &text, int searchOptions)
void keySequenceChanged(QKeySequence value)
Checks if a given string is unique compared to other given strings.
void addAction(UserAction *act)
void setUseCreatedObject()
virtual void setObject(const UserActionObject &obj)
The UserActionObject class represents a single object used in UserAction.
QIcon getStyledSvgIcon(const QString &from_to_colors_enabled, const QString &svg_path, QString from_to_colors_disabled=QString())
GraphContextManager * gGraphContextManager
void rowsInserted(const QModelIndex &parent, int first, int last)
void rowsRemoved(const QModelIndex &parent, int first, int last)
void clicked(const QModelIndex &index)
QModelIndex currentIndex() const const
void doubleClicked(const QModelIndex &index)
void setDragEnabled(bool enable)
void setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior)
void setSelectionMode(QAbstractItemView::SelectionMode mode)
QItemSelectionModel * selectionModel() const const
void setCurrentIndex(const QModelIndex &index)
void setDropIndicatorShown(bool enable)
void setIcon(const QIcon &icon)
void setText(const QString &text)
void triggered(bool checked)
void focusChanged(QWidget *old, QWidget *now)
QString getText(QWidget *parent, const QString &title, const QString &label, QLineEdit::EchoMode mode, const QString &text, bool *ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints)
QModelIndexList indexes() const const
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
void append(const T &value)
bool isValid() const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject * parent() const const
void setEnabled(bool enable)
void setKey(const QKeySequence &key)
virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const const override
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const const override
virtual int rowCount(const QModelIndex &parent) const const override
virtual void setSourceModel(QAbstractItemModel *sourceModel) override
void setSortRole(int role)
QString fromStdString(const std::string &str)
bool isEmpty() const const
void expand(const QModelIndex &index)
virtual QModelIndex indexAt(const QPoint &point) const const override
virtual void setModel(QAbstractItemModel *model) override
void setSortingEnabled(bool enable)