nextpnr/gui/designwidget.h

106 lines
3.5 KiB
C
Raw Normal View History

2018-06-22 16:21:20 +02:00
/*
* nextpnr -- Next Generation Place and Route
*
* Copyright (C) 2018 Miodrag Milanovic <miodrag@symbioticeda.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
2018-06-14 20:03:59 +02:00
#ifndef DESIGNWIDGET_H
#define DESIGNWIDGET_H
2018-07-28 15:44:00 +02:00
#include <QTreeView>
#include <QVariant>
2018-06-14 20:03:59 +02:00
#include "nextpnr.h"
2018-07-06 19:19:18 +02:00
#include "qtgroupboxpropertybrowser.h"
2018-06-14 20:03:59 +02:00
#include "qtpropertymanager.h"
#include "qttreepropertybrowser.h"
#include "qtvariantproperty.h"
2018-07-28 15:44:00 +02:00
#include "treemodel.h"
2018-06-14 20:03:59 +02:00
2018-06-22 13:10:27 +02:00
NEXTPNR_NAMESPACE_BEGIN
2018-06-14 20:03:59 +02:00
class DesignWidget : public QWidget
{
Q_OBJECT
public:
2018-06-26 15:47:22 +02:00
explicit DesignWidget(QWidget *parent = 0);
2018-06-14 20:03:59 +02:00
~DesignWidget();
private:
void clearProperties();
QtProperty *addTopLevelProperty(const QString &id);
QtProperty *addSubGroup(QtProperty *topItem, const QString &name);
void addProperty(QtProperty *topItem, int propertyType, const QString &name, QVariant value,
const ElementType &type = ElementType::NONE);
QString getElementTypeName(ElementType type);
ElementType getElementTypeByName(QString type);
2018-07-15 15:12:31 +02:00
int getElementIndex(ElementType type);
2018-07-15 16:20:35 +02:00
void updateButtons();
2018-07-28 15:44:00 +02:00
void addToHistory(QModelIndex item);
2018-07-15 17:50:58 +02:00
std::vector<DecalXY> getDecals(ElementType type, IdString value);
2018-07-31 16:49:47 +02:00
void updateHighlightGroup(QList<LazyTreeItem *> item, int group);
2018-06-15 11:10:11 +02:00
Q_SIGNALS:
void info(std::string text);
void selected(std::vector<DecalXY> decal, bool keep);
2018-07-15 17:50:58 +02:00
void highlight(std::vector<DecalXY> decal, int group);
void zoomSelected();
2018-06-15 11:10:11 +02:00
2018-06-14 20:03:59 +02:00
private Q_SLOTS:
void prepareMenuProperty(const QPoint &pos);
2018-07-15 17:50:58 +02:00
void prepareMenuTree(const QPoint &pos);
2018-07-28 15:44:00 +02:00
void onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
void onItemDoubleClicked(QTreeWidgetItem *item, int column);
void onDoubleClicked(const QModelIndex &index);
2018-06-26 15:47:22 +02:00
public Q_SLOTS:
void newContext(Context *ctx);
2018-07-05 20:06:12 +02:00
void updateTree();
void onClickedBel(BelId bel, bool keep);
void onClickedWire(WireId wire, bool keep);
2018-07-27 03:28:01 +02:00
void onClickedPip(PipId pip, bool keep);
2018-06-14 20:03:59 +02:00
private:
Context *ctx;
2018-06-14 20:03:59 +02:00
2018-07-28 15:44:00 +02:00
QTreeView *treeView;
QItemSelectionModel *selectionModel;
ContextTreeModel *treeModel;
2018-06-14 20:03:59 +02:00
QtVariantPropertyManager *variantManager;
2018-07-05 20:35:47 +02:00
QtVariantPropertyManager *readOnlyManager;
2018-07-05 21:51:17 +02:00
QtGroupPropertyManager *groupManager;
2018-06-14 20:03:59 +02:00
QtVariantEditorFactory *variantFactory;
QtTreePropertyBrowser *propertyEditor;
QMap<QtProperty *, QString> propertyToId;
2018-07-05 21:51:17 +02:00
QMap<QString, QtProperty *> idToProperty;
2018-07-15 15:12:31 +02:00
2018-07-28 15:44:00 +02:00
std::vector<QModelIndex> history;
2018-07-15 16:20:35 +02:00
int history_index;
bool history_ignore;
2018-07-15 15:12:31 +02:00
QAction *actionFirst;
QAction *actionPrev;
QAction *actionNext;
QAction *actionLast;
QAction *actionClear;
2018-07-15 17:50:58 +02:00
QColor highlightColors[8];
2018-07-31 16:49:47 +02:00
QMap<LazyTreeItem *, int> highlightSelected;
2018-06-14 20:03:59 +02:00
};
2018-06-22 13:10:27 +02:00
NEXTPNR_NAMESPACE_END
2018-06-14 20:03:59 +02:00
#endif // DESIGNWIDGET_H