Skip to content

Commit 711ee0a

Browse files
committed
Fixed some bugs
1 parent 18768a1 commit 711ee0a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

examples/demo/mainwindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void MainWindow::setItemInfos(const QList<ContentItemInfo> & infos, int fixedSiz
8282

8383
if (fixedSize == -1)
8484
fixedSize = fixedInfoSize;
85-
if (fixedSize > 0)
85+
if (fixedSize > 0 && !infos.isEmpty())
8686
{
8787
qDebug() << "creating items ...";
8888
displayInfos.clear();

src/contentwidget.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,10 @@ void ContentWidget::mousePressEvent(QMouseEvent * event)
11051105
}
11061106
event->accept();
11071107
mouseState = 0;
1108+
1109+
if (itemInfos.isEmpty())
1110+
return;
1111+
11081112
bool onNavigator;
11091113
int row = rowAt(event->y(), &onNavigator);
11101114
if (onNavigator)
@@ -1148,7 +1152,7 @@ void ContentWidget::mouseMoveEvent(QMouseEvent * event)
11481152
return;
11491153
}
11501154
event->accept();
1151-
if (event->buttons() == Qt::LeftButton)
1155+
if (event->buttons() == Qt::LeftButton && !itemInfos.isEmpty())
11521156
{
11531157
if (dragEnabled)
11541158
{
@@ -1187,6 +1191,9 @@ void ContentWidget::mouseReleaseEvent(QMouseEvent * event)
11871191

11881192
event->accept();
11891193

1194+
if (itemInfos.isEmpty())
1195+
return;
1196+
11901197
bool onNavigator;
11911198
int row = rowAt(event->y(), &onNavigator);
11921199
if (onNavigator)
@@ -1210,6 +1217,10 @@ void ContentWidget::mouseDoubleClickEvent(QMouseEvent * event)
12101217
{
12111218
event->accept();
12121219
mouseState = -2;
1220+
1221+
if (itemInfos.isEmpty())
1222+
return;
1223+
12131224
bool onNavigator;
12141225
int row = rowAt(event->y(), &onNavigator);
12151226
if (onNavigator)

0 commit comments

Comments
 (0)