git-svn-id: svn://db.shs.com.ru/libs@157 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -16,11 +16,15 @@ file(GLOB MOCS "./*.h")
|
||||
file(GLOB CPPS "./*.cpp")
|
||||
file(GLOB UIS "./*.ui")
|
||||
file(GLOB RES "./*.qrc")
|
||||
file(GLOB MAINCPPS "./*_main.cpp")
|
||||
list(REMOVE_ITEM CPPS ${MAINCPPS})
|
||||
qt4_wrap_ui(CUIS ${UIS})
|
||||
qt4_wrap_cpp(CMOCS ${MOCS} OPTIONS -nw)
|
||||
qt4_add_resources(CRES ${RES})
|
||||
add_library(${PROJECT_NAME} SHARED ${CPPS} ${CUIS} ${CMOCS} ${CRES} ${MOCS})
|
||||
target_link_libraries(${PROJECT_NAME} ${LIBS})
|
||||
add_executable(blockeditor WIN32 "blockeditor_main.cpp" ${CRES})
|
||||
target_link_libraries(blockeditor ${LIBS} ${PROJECT_NAME})
|
||||
if (LIB)
|
||||
if (WIN32)
|
||||
set(CMAKE_INSTALL_PREFIX ${MINGW_DIR})
|
||||
|
||||
340
qad_blockview/blockeditor.cpp
Normal file
340
qad_blockview/blockeditor.cpp
Normal file
@@ -0,0 +1,340 @@
|
||||
#include "blockeditor.h"
|
||||
#include "ui_blockeditor.h"
|
||||
#include "drawtools.h"
|
||||
#include "blockview.h"
|
||||
#include <QToolBar>
|
||||
#include <QComboBox>
|
||||
#include <QFileDialog>
|
||||
#include <QFile>
|
||||
#include <QTimer>
|
||||
|
||||
|
||||
BlockEditor::BlockEditor(QWidget *parent) : QWidget(parent), ui(new Ui::BlockEditor) {
|
||||
init = false;
|
||||
ui->setupUi(this);
|
||||
connect(ui->blockView->scene(), SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
|
||||
block.setFlags(0);
|
||||
ui->blockView->addItem(&block);
|
||||
ui->blockView->viewport()->installEventFilter(this);
|
||||
DrawTools * drawtools = new DrawTools(ui->blockView);
|
||||
drawtools->setAlignCompact(true);
|
||||
connect(drawtools, SIGNAL(itemCreated(QGraphicsItem*)), this, SLOT(addItem(QGraphicsItem*)));
|
||||
drawtools->textEditCombo()->addItems(QStringList() << "%name" << "%value" << "%id");
|
||||
ui->layoutProperties->addWidget(drawtools->propertyWidget());
|
||||
ui->actionRemove_items->setEnabled(false);
|
||||
ui->button_color->setColor(Qt::lightGray);
|
||||
ui->treePins->setItemDelegateForColumn(1, new PinBusDelegate());
|
||||
connect(ui->treePins, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(updateBlock()));
|
||||
ui->treePins->viewport()->installEventFilter(this);
|
||||
|
||||
QToolBar * bar;
|
||||
bar = new QToolBar(ui->widgetBar);
|
||||
bar->setOrientation(Qt::Vertical);
|
||||
bar->addActions(drawtools->actionsForAdd());
|
||||
ui->widgetBar->setMinimumSize(bar->sizeHint());
|
||||
|
||||
bar = new QToolBar(ui->widgetBarZ);
|
||||
bar->setOrientation(Qt::Vertical);
|
||||
bar->addActions(drawtools->actionsForZ());
|
||||
bar->addSeparator();
|
||||
bar->addActions(QList<QAction*>() << ui->actionRemove_items);
|
||||
ui->widgetBarZ->setMinimumSize(bar->sizeHint());
|
||||
init = true;
|
||||
on_buttonClear_clicked();
|
||||
}
|
||||
|
||||
|
||||
BlockEditor::~BlockEditor() {
|
||||
init = false;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void BlockEditor::loadModel(const QByteArray &model) {
|
||||
BlockItem b;
|
||||
b.loadModel(model);
|
||||
ui->spin_w->setValue(b.width());
|
||||
ui->spin_h->setValue(b.height());
|
||||
ui->spin_margin->setValue(b.pinsMargin());
|
||||
ui->button_color->setColor(b.color());
|
||||
block.loadModel(model);
|
||||
treePinsClear();
|
||||
ui->treePins->blockSignals(true);
|
||||
QVector<BlockItemPin * > pins = block.pins();
|
||||
foreach (BlockItemPin * p, pins) {
|
||||
QTreeWidgetItem * ti = new QTreeWidgetItem(QStringList() << p->text() << QString::number(p->busType()));
|
||||
ti->setData(0, Qt::UserRole, qulonglong(p));
|
||||
ti->setData(0, Qt::UserRole + 1, (int)p->alignment());
|
||||
ti->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled);
|
||||
pin_tli[p->alignment()]->addChild(ti);
|
||||
}
|
||||
foreach (QGraphicsItem * i, block.decors()) {
|
||||
i->setData(1002, false);
|
||||
i->setData(1100, true);
|
||||
}
|
||||
ui->treePins->blockSignals(false);
|
||||
}
|
||||
|
||||
|
||||
QByteArray BlockEditor::saveModel() {
|
||||
return block.saveModel();
|
||||
}
|
||||
|
||||
|
||||
void BlockEditor::selectionChanged() {
|
||||
if (!init) return;
|
||||
ui->actionRemove_items->setEnabled(!ui->blockView->scene()->selectedItems().isEmpty());
|
||||
}
|
||||
|
||||
|
||||
void BlockEditor::addItem(QGraphicsItem *item) {
|
||||
block.addDecor(item);
|
||||
item->setData(1002, false);
|
||||
item->setData(1100, true);
|
||||
}
|
||||
|
||||
|
||||
void BlockEditor::updateBlock() {
|
||||
block.setSize(ui->spin_w->value(), ui->spin_h->value());
|
||||
block.setColor(ui->button_color->color());
|
||||
block.setPinsMargin(ui->spin_margin->value());
|
||||
}
|
||||
|
||||
|
||||
void BlockEditor::treePinsClear() {
|
||||
ui->treePins->blockSignals(true);
|
||||
ui->treePins->clear();
|
||||
QFont bf(font()); bf.setBold(true);
|
||||
QList<int> al = QList<int>() << Qt::AlignLeft << Qt::AlignRight << Qt::AlignTop << Qt::AlignBottom;
|
||||
QStringList an = QStringList() << "Left" << "Right" << "Top" << "Bottom";
|
||||
pin_tli.clear();
|
||||
for (int i = 0; i < al.size(); ++i) {
|
||||
QTreeWidgetItem * ti = new QTreeWidgetItem();
|
||||
ti->setFlags(Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
|
||||
ti->setData(0, Qt::UserRole, al[i]);
|
||||
ti->setText(0, an[i]);
|
||||
ti->setFont(0, bf);
|
||||
ui->treePins->addTopLevelItem(ti);
|
||||
ti->setFirstColumnSpanned(true);
|
||||
ti->setExpanded(true);
|
||||
pin_tli[al[i]] = ti;
|
||||
}
|
||||
ui->treePins->blockSignals(false);
|
||||
}
|
||||
|
||||
|
||||
bool BlockEditor::eventFilter(QObject *o, QEvent *e) {
|
||||
if (!init) QWidget::eventFilter(o, e);
|
||||
if (o == ui->treePins->viewport()) {
|
||||
if (e->type() == QEvent::Drop) {
|
||||
QTimer::singleShot(0, this, SLOT(arrangePins()));
|
||||
}
|
||||
}
|
||||
if (o == ui->blockView->viewport()) {
|
||||
if (e->type() == QEvent::Resize) {
|
||||
ui->blockView->centerOn(&block);
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(o, e);
|
||||
}
|
||||
|
||||
|
||||
void BlockEditor::on_actionRemove_items_triggered() {
|
||||
QList<QGraphicsItem*> si = ui->blockView->scene()->selectedItems();
|
||||
foreach (QGraphicsItem * i, si)
|
||||
block.removeDecor(i);
|
||||
}
|
||||
|
||||
|
||||
void BlockEditor::on_buttonSave_clicked() {
|
||||
QString c = QFileDialog::getSaveFileName(this, "Save block model to file", cur_file, "*.blockmodel");
|
||||
if (!c.isEmpty()) {
|
||||
QFile f(c);
|
||||
if (f.open(QIODevice::WriteOnly)) {
|
||||
cur_file = c;
|
||||
f.write(saveModel());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BlockEditor::on_buttonLoad_clicked() {
|
||||
QString c = QFileDialog::getOpenFileName(this, "Save block model to file", cur_file, "*.blockmodel");
|
||||
if (!c.isEmpty()) {
|
||||
QFile f(c);
|
||||
if (f.open(QIODevice::ReadOnly)) {
|
||||
cur_file = c;
|
||||
loadModel(f.readAll());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BlockEditor::on_buttonClear_clicked() {
|
||||
BlockItem b;
|
||||
ui->spin_w->setValue(b.width());
|
||||
ui->spin_h->setValue(b.height());
|
||||
ui->spin_margin->setValue(b.pinsMargin());
|
||||
ui->button_color->setColor(b.color());
|
||||
block.loadModel(QByteArray());
|
||||
treePinsClear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BlockEditor::on_buttonPinAdd_clicked() {
|
||||
ui->treePins->blockSignals(true);
|
||||
QTreeWidgetItem * ti = new QTreeWidgetItem(QStringList() << "" << "0");
|
||||
ti->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled);
|
||||
ti->setData(0, Qt::UserRole, qulonglong(block.addPin(Qt::AlignLeft, ti->text(1).toInt(), ti->text(0))));
|
||||
ti->setData(0, Qt::UserRole + 1, (int)Qt::AlignLeft);
|
||||
pin_tli[Qt::AlignLeft]->addChild(ti);
|
||||
ui->treePins->setCurrentItem(ti);
|
||||
ui->treePins->blockSignals(false);
|
||||
updateBlock();
|
||||
}
|
||||
|
||||
|
||||
void BlockEditor::on_buttonPinDup_clicked() {
|
||||
QTreeWidgetItem * ci = ui->treePins->currentItem();
|
||||
if (ci == 0) return;
|
||||
ui->treePins->blockSignals(true);
|
||||
QTreeWidgetItem * ti = ci->clone();
|
||||
ti->setText(0, ti->text(0));
|
||||
ti->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled);
|
||||
Qt::Alignment al = (Qt::Alignment)ci->data(0, Qt::UserRole + 1).toInt();
|
||||
ti->setData(0, Qt::UserRole, qulonglong(block.addPin(al, ci->text(1).toInt(), ci->text(0))));
|
||||
ti->setData(0, Qt::UserRole + 1, (int)al);
|
||||
pin_tli[al]->addChild(ti);
|
||||
ui->treePins->setCurrentItem(ti);
|
||||
ui->treePins->blockSignals(false);
|
||||
}
|
||||
|
||||
|
||||
void BlockEditor::on_buttonPinDelete_clicked() {
|
||||
ui->treePins->blockSignals(true);
|
||||
QList<QTreeWidgetItem*> si = ui->treePins->selectedItems();
|
||||
foreach (QTreeWidgetItem * i, si) {
|
||||
if (!i->parent()) continue;
|
||||
block.removePin((BlockItemPin*)(i->data(0, Qt::UserRole).toLongLong()));
|
||||
delete i;
|
||||
}
|
||||
ui->treePins->blockSignals(false);
|
||||
}
|
||||
|
||||
|
||||
void BlockEditor::on_buttonPinClear_clicked() {
|
||||
treePinsClear();
|
||||
block.clearPins();
|
||||
}
|
||||
|
||||
|
||||
void BlockEditor::on_treePins_itemChanged(QTreeWidgetItem * item, int column) {
|
||||
if (!item) return;
|
||||
BlockItemPin * pin = (BlockItemPin*)item->data(0, Qt::UserRole).toULongLong();
|
||||
if (!pin) return;
|
||||
switch (column) {
|
||||
case 0:
|
||||
ui->treePins->blockSignals(true);
|
||||
item->setText(0, item->text(0));
|
||||
pin->setText(item->text(0));
|
||||
ui->treePins->blockSignals(false);
|
||||
break;
|
||||
case 1: pin->setBusType(item->text(1).toInt()); break;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BlockEditor::arrangePins() {
|
||||
QVector<BlockItemPin * > pins = block.pins();
|
||||
QList<QTreeWidgetItem*> tli = pin_tli.values();
|
||||
foreach (QTreeWidgetItem * ti, tli) {
|
||||
for (int i = 0; i < ti->childCount(); ++i) {
|
||||
foreach (BlockItemPin * p, pins)
|
||||
if (p == (BlockItemPin*)(ti->child(i)->data(0, Qt::UserRole).toULongLong())) {
|
||||
p->setAlignment((Qt::Alignment)ti->data(0, Qt::UserRole).toInt());
|
||||
BlockItemPin * np = block.addPin(p, false);
|
||||
ti->child(i)->setData(0, Qt::UserRole, qulonglong(np));
|
||||
ti->child(i)->setData(0, Qt::UserRole + 1, ti->data(0, Qt::UserRole).toInt());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// for (int i = 0; i < ui->treePins->topLevelItemCount(); ++i) {
|
||||
// QTreeWidgetItem * ti = ui->treePins->topLevelItem(i);
|
||||
// if (tli.contains(ti)) continue;
|
||||
// ti = ui->treePins->takeTopLevelItem(i);
|
||||
// pin_tli[ti->data(0, Qt::UserRole + 1).toInt()]->addChild(ti);
|
||||
// foreach (BlockItemPin * p, pins)
|
||||
// if (p->text() == ti->text(0)) {
|
||||
// p->setAlignment((Qt::Alignment)ti->data(0, Qt::UserRole + 1).toInt());
|
||||
// block.addPin(p, false);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
block.arrangePins();
|
||||
}
|
||||
|
||||
|
||||
/// ***********************************************************
|
||||
/// ***********************************************************
|
||||
/// ***********************************************************
|
||||
/// ***********************************************************
|
||||
|
||||
|
||||
QWidget * PinAlignDelegate::createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const {
|
||||
QComboBox * combo = new QComboBox(parent);
|
||||
int cv = index.data().toInt();
|
||||
combo->addItem("Left", int(Qt::AlignLeft)); if (cv == Qt::AlignLeft) combo->setCurrentIndex(0);
|
||||
combo->addItem("Right", int(Qt::AlignRight)); if (cv == Qt::AlignRight) combo->setCurrentIndex(1);
|
||||
combo->addItem("Top", int(Qt::AlignTop)); if (cv == Qt::AlignTop) combo->setCurrentIndex(2);
|
||||
combo->addItem("Bottom", int(Qt::AlignBottom)); if (cv == Qt::AlignBottom) combo->setCurrentIndex(3);
|
||||
combo->setGeometry(option.rect);
|
||||
return combo;
|
||||
}
|
||||
|
||||
|
||||
QString PinAlignDelegate::displayText(const QVariant & value, const QLocale & locale) const {
|
||||
int cv = value.toInt();
|
||||
switch (cv) {
|
||||
case Qt::AlignLeft: return "Left"; break;
|
||||
case Qt::AlignRight: return "Right"; break;
|
||||
case Qt::AlignTop: return "Top"; break;
|
||||
case Qt::AlignBottom: return "Bottom"; break;
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
|
||||
void PinAlignDelegate::setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const {
|
||||
model->setData(index, ((QComboBox*)editor)->itemData(((QComboBox*)editor)->currentIndex()).toInt());
|
||||
}
|
||||
|
||||
|
||||
/// ***********************************************************
|
||||
/// ***********************************************************
|
||||
/// ***********************************************************
|
||||
/// ***********************************************************
|
||||
|
||||
|
||||
QWidget * PinBusDelegate::createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const {
|
||||
QSpinBox * spin = new QSpinBox(parent);
|
||||
spin->setMinimum(-2147483648);
|
||||
spin->setMaximum(2147483647);
|
||||
spin->setValue(index.data().toInt());
|
||||
return spin;
|
||||
}
|
||||
|
||||
|
||||
QString PinBusDelegate::displayText(const QVariant & value, const QLocale & locale) const {
|
||||
int cv = value.toInt();
|
||||
return QString::number(cv);
|
||||
}
|
||||
|
||||
|
||||
void PinBusDelegate::setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const {
|
||||
model->setData(index, ((QSpinBox*)editor)->value());
|
||||
}
|
||||
|
||||
80
qad_blockview/blockeditor.h
Normal file
80
qad_blockview/blockeditor.h
Normal file
@@ -0,0 +1,80 @@
|
||||
#ifndef BLOCKEDITOR_H
|
||||
#define BLOCKEDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTreeWidgetItem>
|
||||
#include <QStyledItemDelegate>
|
||||
#include "blockitem.h"
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class BlockEditor;
|
||||
}
|
||||
|
||||
|
||||
class BlockEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BlockEditor(QWidget *parent = 0);
|
||||
~BlockEditor();
|
||||
|
||||
|
||||
public slots:
|
||||
void loadModel(const QByteArray & model);
|
||||
QByteArray saveModel();
|
||||
|
||||
private slots:
|
||||
void selectionChanged();
|
||||
void addItem(QGraphicsItem * item);
|
||||
void updateBlock();
|
||||
void treePinsClear();
|
||||
void arrangePins();
|
||||
void on_actionRemove_items_triggered();
|
||||
void on_buttonSave_clicked();
|
||||
void on_buttonLoad_clicked();
|
||||
void on_buttonClear_clicked();
|
||||
void on_buttonPinAdd_clicked();
|
||||
void on_buttonPinDup_clicked();
|
||||
void on_buttonPinDelete_clicked();
|
||||
void on_buttonPinClear_clicked();
|
||||
void on_treePins_itemChanged(QTreeWidgetItem *item, int column);
|
||||
|
||||
private:
|
||||
bool eventFilter(QObject * o, QEvent * e);
|
||||
|
||||
Ui::BlockEditor *ui;
|
||||
QMap<int, QTreeWidgetItem*> pin_tli;
|
||||
BlockItem block;
|
||||
QString cur_file;
|
||||
bool init;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class PinAlignDelegate: public QStyledItemDelegate {
|
||||
Q_OBJECT
|
||||
public:
|
||||
PinAlignDelegate(QObject * parent = 0): QStyledItemDelegate(parent) {}
|
||||
QWidget * createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
||||
QString displayText(const QVariant & value, const QLocale & locale) const;
|
||||
void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const;
|
||||
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const {return QSize(60, 26);}
|
||||
};
|
||||
|
||||
|
||||
class PinBusDelegate: public QStyledItemDelegate {
|
||||
Q_OBJECT
|
||||
public:
|
||||
PinBusDelegate(QObject * parent = 0): QStyledItemDelegate(parent) {}
|
||||
QWidget * createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
||||
QString displayText(const QVariant & value, const QLocale & locale) const;
|
||||
void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const;
|
||||
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const {return QSize(60, 26);}
|
||||
private:
|
||||
typedef QPair<int, QString> ISPair;
|
||||
QVector<ISPair> buses;
|
||||
};
|
||||
|
||||
#endif // BLOCKEDITOR_H
|
||||
458
qad_blockview/blockeditor.ui
Normal file
458
qad_blockview/blockeditor.ui
Normal file
@@ -0,0 +1,458 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BlockEditor</class>
|
||||
<widget class="QWidget" name="BlockEditor">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>901</width>
|
||||
<height>861</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Block parameters</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="margin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Width:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="spin_w">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Heigth:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spin_h">
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>60</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Pins margin:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="spin_margin">
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="ColorButton" name="button_color"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Pins</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="margin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="treePins">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::InternalMove</enum>
|
||||
</property>
|
||||
<property name="defaultDropAction">
|
||||
<enum>Qt::MoveAction</enum>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="itemsExpandable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="headerDefaultSectionSize">
|
||||
<number>200</number>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Bus</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonPinAdd">
|
||||
<property name="toolTip">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_blockview.qrc">
|
||||
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonPinDup">
|
||||
<property name="toolTip">
|
||||
<string>Clone</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_blockview.qrc">
|
||||
<normaloff>:/icons/edit-copy.png</normaloff>:/icons/edit-copy.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonPinDelete">
|
||||
<property name="toolTip">
|
||||
<string>Remove selected</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_blockview.qrc">
|
||||
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonPinClear">
|
||||
<property name="toolTip">
|
||||
<string>Remove all</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_blockview.qrc">
|
||||
<normaloff>:/icons/edit-clear.png</normaloff>:/icons/edit-clear.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>1</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="frameProperties">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="layoutProperties">
|
||||
<property name="margin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widgetBar" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widgetBarZ" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="BlockView" name="blockView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonSave">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_blockview.qrc">
|
||||
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonLoad">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Load</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_blockview.qrc">
|
||||
<normaloff>:/icons/document-open.png</normaloff>:/icons/document-open.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonClear">
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_blockview.qrc">
|
||||
<normaloff>:/icons/edit-clear.png</normaloff>:/icons/edit-clear.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
<action name="actionRemove_items">
|
||||
<property name="icon">
|
||||
<iconset resource="qad_blockview.qrc">
|
||||
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove items</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlockView</class>
|
||||
<extends>QGraphicsView</extends>
|
||||
<header>blockview.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ColorButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>colorbutton.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="qad_blockview.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>spin_w</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>BlockEditor</receiver>
|
||||
<slot>updateBlock()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>170</x>
|
||||
<y>21</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>254</x>
|
||||
<y>1</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>spin_h</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>BlockEditor</receiver>
|
||||
<slot>updateBlock()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>250</x>
|
||||
<y>49</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>373</x>
|
||||
<y>5</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>spin_margin</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>BlockEditor</receiver>
|
||||
<slot>updateBlock()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>350</x>
|
||||
<y>90</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>492</x>
|
||||
<y>8</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>button_color</sender>
|
||||
<signal>colorChanged(QColor)</signal>
|
||||
<receiver>BlockEditor</receiver>
|
||||
<slot>updateBlock()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>561</x>
|
||||
<y>115</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>613</x>
|
||||
<y>6</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>updateBlock()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
10
qad_blockview/blockeditor_main.cpp
Normal file
10
qad_blockview/blockeditor_main.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <QApplication>
|
||||
#include "blockeditor.h"
|
||||
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
QApplication a(argc, argv);
|
||||
BlockEditor w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
@@ -260,6 +260,8 @@ void BlockItem::loadModel(const QByteArray & data) {
|
||||
//qDebug() << "load from" << data.size() << "bytes";
|
||||
clearPins();
|
||||
clearDecors();
|
||||
col = Qt::lightGray;
|
||||
_resize(QSizeF(100., 60.));
|
||||
if (data.isEmpty()) return;
|
||||
/*QDataStream s(data);
|
||||
{QPointF _v; s >> _v;}
|
||||
@@ -407,7 +409,8 @@ void BlockItem::mouseMoveEvent(QGraphicsSceneMouseEvent * event) {
|
||||
|
||||
void BlockItem::arrangePins() {
|
||||
//double w = g_main.rect().width(), h = g_main.rect().height();
|
||||
QVector<BlockItemPin * > pl = pins();
|
||||
QSet<BlockItemPin * > pl;
|
||||
pl = pl.fromList(pins().toList());
|
||||
pins_.clear();
|
||||
foreach (BlockItemPin * p, pl)
|
||||
pins_[p->alignment()] << p;
|
||||
|
||||
Reference in New Issue
Block a user