修正图元更改后列表不正确的问题
parent
f175e50b7b
commit
578fd5da8e
|
@ -85,6 +85,7 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
||||||
this->projectName = source.value("project-name").toString();
|
this->projectName = source.value("project-name").toString();
|
||||||
qDebug() << this->backgroundColor;
|
qDebug() << this->backgroundColor;
|
||||||
qDebug() << this->projectName;
|
qDebug() << this->projectName;
|
||||||
|
elementInfoDisplayWidget->refresh();
|
||||||
QTimer::singleShot(300, this, [this, centralRefresh]() {
|
QTimer::singleShot(300, this, [this, centralRefresh]() {
|
||||||
handleBackgroundColorChange(this->backgroundColor);
|
handleBackgroundColorChange(this->backgroundColor);
|
||||||
handleProjectNameChange(this->projectName);
|
handleProjectNameChange(this->projectName);
|
||||||
|
|
|
@ -10,7 +10,7 @@ ElementPoolWidget::ElementPoolWidget(QWidget* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
elementManager = nullptr;
|
elementManager = nullptr;
|
||||||
iconWidth = 120, iconHeight = 90;
|
iconWidth = 120, iconHeight = 120;
|
||||||
pictureList = new QListWidget(this);
|
pictureList = new QListWidget(this);
|
||||||
pictureList->setContextMenuPolicy(Qt::CustomContextMenu);
|
pictureList->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
pictureList->setIconSize(QSize(iconWidth, iconHeight));
|
pictureList->setIconSize(QSize(iconWidth, iconHeight));
|
||||||
|
@ -41,7 +41,7 @@ void ElementPoolWidget::setElementList(std::vector<GraphicElement*> elements) {
|
||||||
for (int index = 0; index < elements.size(); index++) {
|
for (int index = 0; index < elements.size(); index++) {
|
||||||
QListWidgetItem* pItem = new QListWidgetItem(elements[index]->name);
|
QListWidgetItem* pItem = new QListWidgetItem(elements[index]->name);
|
||||||
QPainter* painter = new QPainter();
|
QPainter* painter = new QPainter();
|
||||||
QImage* image = new QImage(QSize(iconWidth - 12, iconHeight - 12), QImage::Format_ARGB32);
|
QImage* image = new QImage(QSize(iconWidth - 25, iconHeight - 25), QImage::Format_ARGB32);
|
||||||
image->fill(Qt::transparent);
|
image->fill(Qt::transparent);
|
||||||
pItem->setIcon(QIcon(QPixmap::fromImage(*image)));
|
pItem->setIcon(QIcon(QPixmap::fromImage(*image)));
|
||||||
pItem->setSizeHint(QSize(iconWidth, iconHeight));
|
pItem->setSizeHint(QSize(iconWidth, iconHeight));
|
||||||
|
@ -84,6 +84,9 @@ void ElementPoolWidget::refresh() {
|
||||||
refreshWait = false;
|
refreshWait = false;
|
||||||
if (elementManager != nullptr)
|
if (elementManager != nullptr)
|
||||||
{
|
{
|
||||||
|
elements = elementManager->elements;
|
||||||
|
for (int i = elements.size(); i < pictureList->count(); i++)
|
||||||
|
pictureList->takeItem(i);
|
||||||
for (int i = 0; i < elements.size(); i++)
|
for (int i = 0; i < elements.size(); i++)
|
||||||
{
|
{
|
||||||
QListWidgetItem* pItem = pictureList->item(i);
|
QListWidgetItem* pItem = pictureList->item(i);
|
||||||
|
@ -93,7 +96,7 @@ void ElementPoolWidget::refresh() {
|
||||||
pictureList->insertItem(i, pItem);
|
pictureList->insertItem(i, pItem);
|
||||||
}
|
}
|
||||||
QPainter* painter = new QPainter();
|
QPainter* painter = new QPainter();
|
||||||
QImage* image = new QImage(QSize(iconWidth - 12, iconHeight - 12), QImage::Format_ARGB32);
|
QImage* image = new QImage(QSize(iconWidth - 25, iconHeight - 25), QImage::Format_ARGB32);
|
||||||
image->fill(Qt::transparent);
|
image->fill(Qt::transparent);
|
||||||
painter->begin(image);
|
painter->begin(image);
|
||||||
elements[i]->paintPreview(painter);
|
elements[i]->paintPreview(painter);
|
||||||
|
@ -101,6 +104,7 @@ void ElementPoolWidget::refresh() {
|
||||||
pItem->setIcon(QIcon(QPixmap::fromImage(*image)));
|
pItem->setIcon(QIcon(QPixmap::fromImage(*image)));
|
||||||
pItem->setData(Qt::UserRole, QVariant::fromValue(image));
|
pItem->setData(Qt::UserRole, QVariant::fromValue(image));
|
||||||
pItem->setSizeHint(QSize(iconWidth, iconHeight));
|
pItem->setSizeHint(QSize(iconWidth, iconHeight));
|
||||||
|
pItem->setText(elements[i]->name);
|
||||||
pictureList->insertItem(i, pItem);
|
pictureList->insertItem(i, pItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,11 +158,12 @@ void ElementPoolWidget::popMenu(const QPoint& pos)
|
||||||
if (bOk && !sName.isEmpty())
|
if (bOk && !sName.isEmpty())
|
||||||
{
|
{
|
||||||
currentElement->name = sName;
|
currentElement->name = sName;
|
||||||
emit triggerCentralRefresh();
|
this->refresh();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menu->addAction(QString::fromLocal8Bit("ɾ³ý"), this, [this, currentElement]() {
|
menu->addAction(QString::fromLocal8Bit("ɾ³ý"), this, [this, currentElement, currentIndex]() {
|
||||||
this->elementManager->removeElement(currentElement);
|
this->elementManager->removeElement(currentElement);
|
||||||
|
this->refresh();
|
||||||
});
|
});
|
||||||
menu->actions().last()->setDisabled(currentElement->referencedCount > 0);
|
menu->actions().last()->setDisabled(currentElement->referencedCount > 0);
|
||||||
}
|
}
|
||||||
|
@ -175,6 +180,7 @@ void ElementPoolWidget::popMenu(const QPoint& pos)
|
||||||
QString fileName = fileInfo.fileName();
|
QString fileName = fileInfo.fileName();
|
||||||
qDebug() << fileName << " " << filePath;
|
qDebug() << fileName << " " << filePath;
|
||||||
this->elementManager->createSimpleElement(fileName, filePath);
|
this->elementManager->createSimpleElement(fileName, filePath);
|
||||||
|
this->refresh();
|
||||||
emit triggerCentralRefresh();
|
emit triggerCentralRefresh();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue