From 1118dc819a8e376642c33e0f52b6c0bd04724ca6 Mon Sep 17 00:00:00 2001
From: "yang.yongquan" <3395816735@qq.com>
Date: Wed, 8 Mar 2023 12:40:05 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86ElementPool?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
...rchitectureColoredPainting.vcxproj.filters | 3 +++
.../src/Editor/ElementPoolWidget.cpp | 27 ++++++++++++++++---
.../src/Editor/ElementPoolWidget.h | 3 +++
3 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
index 1173571..a80ee13 100644
--- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
+++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
@@ -70,6 +70,9 @@
Form Files
+
+ Form Files
+
diff --git a/ArchitectureColoredPainting/src/Editor/ElementPoolWidget.cpp b/ArchitectureColoredPainting/src/Editor/ElementPoolWidget.cpp
index 74da077..6eec65d 100644
--- a/ArchitectureColoredPainting/src/Editor/ElementPoolWidget.cpp
+++ b/ArchitectureColoredPainting/src/Editor/ElementPoolWidget.cpp
@@ -3,14 +3,22 @@
ElementPoolWidget::ElementPoolWidget(QWidget* parent)
: QWidget(parent)
{
- iconWidth = 150, iconHeight = 100;
+ parentSize = QSize(270, 210);
+ elementManager = nullptr;
+ iconWidth = 80, iconHeight = 60;
pictureList = new QListWidget(this);
pictureList->setIconSize(QSize(iconWidth, iconHeight));
pictureList->setResizeMode(QListView::Adjust);
pictureList->setViewMode(QListView::IconMode);
pictureList->setMovement(QListView::Static);
- pictureList->setSpacing(10);
- pictureList->setFixedSize(600, 800);
+ pictureList->setSpacing(5);
+ pictureList->setStyleSheet("QListWidget::Item:hover{background-color:rgba(47,46,46,0);border-radius:5px; }"
+ "QListWidget::item:selected{background-color:rgba(47,46,46,0);color:rgb(61,61,61);border:1px solid #000;border-radius:2px; }"
+ "QScrollBar:vertical{width:6px}");
+
+ pictureList->setFocusPolicy(Qt::NoFocus);
+ pictureList->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
+ //pictureList->setFixedSize(600, 800);
setVisible(true);
@@ -37,13 +45,19 @@ void ElementPoolWidget::setElementList(std::vector elements) {
//p->show();
QListWidgetItem* pItem = new QListWidgetItem(
- itemPixmap.scaled(QSize(iconWidth-20, iconHeight-20)),
+ itemPixmap.scaled(QSize(iconWidth-15, iconHeight-15)),
elements[index]->name);
pItem->setSizeHint(QSize(iconWidth, iconHeight));
pictureList->insertItem(index, pItem);
}
}
+void ElementPoolWidget::setParentSize(QSize pSize) {
+ parentSize = pSize;
+ iconWidth = (parentSize.width() - 30) / 3;
+ iconHeight = (parentSize.width() - 30) / 4;
+}
+
ElementPoolWidget::~ElementPoolWidget() {
}
@@ -58,4 +72,9 @@ void ElementPoolWidget::setElementManager(ElementManager* element)
{
this->elementManager = element;
this->setElementList(this->elementManager->elements);
+}
+
+void ElementPoolWidget::refresh() {
+ this->setElementList(this->elementManager->elements);
+ // update();
}
\ No newline at end of file
diff --git a/ArchitectureColoredPainting/src/Editor/ElementPoolWidget.h b/ArchitectureColoredPainting/src/Editor/ElementPoolWidget.h
index a57e53f..abd09a2 100644
--- a/ArchitectureColoredPainting/src/Editor/ElementPoolWidget.h
+++ b/ArchitectureColoredPainting/src/Editor/ElementPoolWidget.h
@@ -12,12 +12,14 @@ private:
std::vector elements;
QListWidget* pictureList;
int iconWidth, iconHeight;
+ QSize parentSize;
ElementManager* elementManager;
public:
ElementPoolWidget(QWidget* parent = nullptr);
void setElementList(std::vector elementList);
void setElementManager(ElementManager* element);
+ void setParentSize(QSize pSize);
~ElementPoolWidget();
signals:
@@ -25,5 +27,6 @@ signals:
public slots:
int pictureItemClicked(QListWidgetItem* item);
+ void refresh();
};