Compare commits

...

2 Commits

Author SHA1 Message Date
yang.yongquan 6a4a724f00 更新单元测试 2023-03-07 16:54:19 +08:00
yang.yongquan 53025b93e4 完成了元素池的窗口 2023-03-07 16:53:03 +08:00
2 changed files with 24 additions and 5 deletions

View File

@ -3,26 +3,29 @@
ElementPoolWidget::ElementPoolWidget(QWidget* parent)
: QWidget(parent)
{
iconWidth = 30, iconHeight = 40;
iconWidth = 150, iconHeight = 100;
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);
setVisible(true);
connect(pictureList, SIGNAL(vitemClicked(QListWidgetItem*)), this, SLOT(pictureItemClicked(QListWidgetItem*)));
connect(pictureList, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(pictureItemClicked(QListWidgetItem*)));
}
void ElementPoolWidget::setElementList(std::vector<GraphicElement*> elements) {
pictureList->clear();
for (int index = 0; index < elements.size(); index++) {
QString strPath = QString("D:\\BigC\\Project\\ArchitectureColoredPainting\\svg\\test.svg");
QPixmap itemPixmap(strPath);
//
//QString strPath = QString("C:\\Users\\86177\\Pictures\\Screenshots\\test.png");
//QPixmap itemPixmap(strPath);
QPixmap itemPixmap = elements[index]->getPaintObject().getPixmap();
QListWidgetItem* pItem = new QListWidgetItem(
itemPixmap.scaled(QSize(iconWidth, iconHeight)),
itemPixmap.scaled(QSize(iconWidth-20, iconHeight-20)),
elements[index]->name);
pItem->setSizeHint(QSize(iconWidth, iconHeight));
pictureList->insertItem(index, pItem);
@ -34,5 +37,6 @@ ElementPoolWidget::~ElementPoolWidget() {
}
int ElementPoolWidget::pictureItemClicked(QListWidgetItem* item) {
//qDebug() << pictureList->currentRow();
return pictureList->currentRow();
}

View File

@ -97,11 +97,26 @@ namespace UnitTest
};
TEST_CLASS(ElementPoolTest)
{
private:
char* argv[1];
int argc;
public:
ElementPoolTest() :argv{ (char*)"" }, argc(1) {}
TEST_METHOD_INITIALIZE(initialize)
{
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
}
TEST_METHOD(ElementPool) {
QApplication a(argc, argv);
qInstallMessageHandler(messageHandler);
ElementPoolWidget wi;
//wi.setElementList({"1", "2", "3"});
wi.setFixedSize(QSize(600, 800));
wi.show();
a.exec();
}
};
}