Skip to content

Commit

Permalink
Run display command for the item preview
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Holecek <hluk@email.cz>
  • Loading branch information
hluk committed Sep 4, 2020
1 parent d064b2a commit 124cbce
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/item/itemdelegate.cpp
Expand Up @@ -33,6 +33,7 @@

#include <QEvent>
#include <QPainter>
#include <QScrollArea>
#include <QVBoxLayout>

#include <algorithm>
Expand Down Expand Up @@ -163,6 +164,8 @@ QWidget *ItemDelegate::createPreview(const QVariantMap &data, QWidget *parent)

parent->setFocusProxy( itemWidget->widget() );

emit itemWidgetCreated(PersistentDisplayItem(this, data, itemWidget->widget()));

return itemWidget->widget();
}

Expand Down Expand Up @@ -192,6 +195,23 @@ ItemWidget *ItemDelegate::cache(const QModelIndex &index)

void ItemDelegate::updateCache(QObject *widget, const QVariantMap &data)
{
if ( widget->parent() != m_view->viewport() ) {
auto previewParent = qobject_cast<QWidget*>( widget->parent() );
Q_ASSERT(previewParent);
if (!previewParent)
return;

auto scrollArea = qobject_cast<QScrollArea*>( previewParent->parentWidget() );
Q_ASSERT(scrollArea);
if (!scrollArea)
return;

auto newPreview = createPreview(data, scrollArea);
scrollArea->setWidget(newPreview);
newPreview->show();
return;
}

const auto row = findWidgetRow(widget);
if (row == -1)
return;
Expand Down

0 comments on commit 124cbce

Please sign in to comment.