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();
270 ActionAddItemsToObject* actAddItems =
new ActionAddItemsToObject(clicked_context->modules(),clicked_context->gates());
272 QMap<Node, QPoint> contextNodeMap = clicked_context->getLayouter()->nodeToPositionMap();
273 for (
auto it = contextNodeMap.
begin(); it != contextNodeMap.
end(); it++)
274 plc.
insert(it.key(), it.value());
275 actAddItems->setPlacementHint(plc);
276 act->addAction(actAddItems);
281 void ContextManagerWidget::handleDeleteClicked()
284 if (!currentIndex.
isValid())
return;
288 if (currentItem->isContext()) {
289 GraphContext* clicked_context = currentItem->context();
291 if (!clicked_context)
return;
293 ActionDeleteObject* act =
new ActionDeleteObject;
297 else if (currentItem->isDirectory()) {
298 if (currentItem->getChildCount())
301 QMessageBox::information(
this,
"Directory not empty",
"You are about to delete a directory which is not empty.\nThis action cannot be undone",
306 ContextDirectory* clicked_directory = currentItem->directory();
308 if (!clicked_directory)
return;
310 ActionDeleteObject* act =
new ActionDeleteObject;
320 Q_UNUSED(deselected);
322 if(selected.
indexes().isEmpty())
323 setToolbarButtonsEnabled(
false);
325 setToolbarButtonsEnabled(
true);
328 void ContextManagerWidget::handleContextMenuRequest(
const QPoint& point)
333 ContextTreeItem* item =
static_cast<ContextTreeItem*
>(mContextTreeModel->
getItemFromIndex(sourceIndex));
340 context_menu.
addAction(mNewDirectoryAction);
345 if (!clicked_context && !clicked_directory) {
350 if (clicked_index.
isValid() && clicked_context)
353 context_menu.
addAction(mDuplicateAction);
358 if (clicked_index.
isValid() && clicked_directory)
385 if(proxy_model_index.
isValid())
396 if(proxy_model_index.
isValid())
407 return mContextTreeModel->
getContext(source_model_index);
416 if (currentItem != mContextTreeModel->
getRootItem())
445 void ContextManagerWidget::setToolbarButtonsEnabled(
bool enabled)
479 void ContextManagerWidget::toggleSearchbar()
498 return mDisabledIconStyle;
503 return mNewViewIconPath;
508 return mNewDirIconPath;
513 return mNewViewIconStyle;
518 return mRenameIconPath;
523 return mRenameIconStyle;
528 return mDuplicateIconPath;
533 return mDuplicateIconStyle;
538 return mDeleteIconPath;
543 return mDeleteIconStyle;
548 return mOpenIconPath;
553 return mOpenIconStyle;
558 return mSearchIconPath;
563 return mSearchIconStyle;
568 return mSearchActiveIconStyle;
573 mDisabledIconStyle =
style;
578 mNewViewIconPath = path;
583 mNewDirIconPath = path;
588 mNewViewIconStyle =
style;
593 mRenameIconPath = path;
598 mRenameIconStyle =
style;
603 mDuplicateIconPath = path;
608 mDuplicateIconStyle =
style;
613 mDeleteIconPath = path;
618 mDeleteIconStyle =
style;
623 mOpenIconPath = path;
628 mOpenIconStyle =
style;
633 mSearchIconPath = path;
638 mSearchIconStyle =
style;
643 mSearchActiveIconStyle =
style;
646 void ContextManagerWidget::handleFocusChanged(
QWidget* oldWidget,
QWidget* newWidget)
649 if(!newWidget)
return;
650 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)
QMap::iterator insert(const Key &key, 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)