Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 40 additions & 32 deletions YUViewLib/src/ui/widgets/PlaylistTreeWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,22 +187,30 @@ playlistItem *PlaylistTreeWidget::getDropTarget(const QPoint &pos) const
void PlaylistTreeWidget::dragMoveEvent(QDragMoveEvent *event)
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
auto dropTarget = this->getDropTarget(event->position().toPoint());
const auto dropTarget = this->getDropTarget(event->position().toPoint());
#else
auto dropTarget = getDropTarget(event->pos());
const auto dropTarget = getDropTarget(event->pos());
#endif
if (dropTarget)

if (!dropTarget)
{
auto draggedItems = selectedItems();
auto draggedItem = dynamic_cast<playlistItem *>(draggedItems[0]);
event->ignore();
return;
}

// handle video items as target
if (!dropTarget->acceptDrops(draggedItem))
{
// no valid drop
event->ignore();
return;
}
const auto draggedItems = this->selectedItems();
if (draggedItems.empty())
{
event->ignore();
return;
}

const auto draggedItem = dynamic_cast<playlistItem *>(draggedItems[0]);

if (!dropTarget->acceptDrops(draggedItem))
{
event->ignore();
return;
}

QTreeWidget::dragMoveEvent(event);
Expand Down Expand Up @@ -275,7 +283,7 @@ void PlaylistTreeWidget::updateAllContainterItems()
{
for (int i = 0; i < topLevelItemCount(); i++)
{
QTreeWidgetItem * item = topLevelItem(i);
QTreeWidgetItem *item = topLevelItem(i);
playlistItemContainer *containerItem = dynamic_cast<playlistItemContainer *>(item);
if (containerItem != nullptr)
containerItem->updateChildItems();
Expand Down Expand Up @@ -802,7 +810,7 @@ QString PlaylistTreeWidget::getPlaylistString(QDir dirName)
// Create the XML document structure
QDomDocument document;
document.appendChild(document.createProcessingInstruction(
QStringLiteral("xml"), QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")));
QStringLiteral("xml"), QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")));
QDomElement plist = document.createElement(QStringLiteral("playlistItems"));
plist.setAttribute(QStringLiteral("version"), QStringLiteral("2.0"));
document.appendChild(plist);
Expand All @@ -811,7 +819,7 @@ QString PlaylistTreeWidget::getPlaylistString(QDir dirName)
for (int i = 0; i < topLevelItemCount(); ++i)
{
QTreeWidgetItem *item = topLevelItem(i);
playlistItem * plItem = dynamic_cast<playlistItem *>(item);
playlistItem *plItem = dynamic_cast<playlistItem *>(item);

plItem->savePlaylist(plist, dirName);
}
Expand Down Expand Up @@ -904,7 +912,7 @@ bool PlaylistTreeWidget::loadPlaylistFromByteArray(QByteArray data, QString file
QMessageBox::critical(this,
"Error loading playlist.",
errorMessage +
QString(" in line/column %1/%2").arg(errorLine).arg(errorColumn));
QString(" in line/column %1/%2").arg(errorLine).arg(errorColumn));
return false;
}

Expand All @@ -916,16 +924,16 @@ bool PlaylistTreeWidget::loadPlaylistFromByteArray(QByteArray data, QString file
{
// This is a playlist file in the old format. This is not supported anymore.
QMessageBox::critical(
this,
"Error loading playlist.",
"The given playlist file seems to be in the old XML format. The playlist format was "
"changed a while back and the old format is no longer supported.");
this,
"Error loading playlist.",
"The given playlist file seems to be in the old XML format. The playlist format was "
"changed a while back and the old format is no longer supported.");
return false;
}
if (root.tagName() != "playlistItems" || root.attribute("version") != "2.0")
{
QMessageBox::critical(
this, "Error loading playlist.", "The playlist file format could not be recognized.");
this, "Error loading playlist.", "The playlist file format could not be recognized.");
return false;
}

Expand Down Expand Up @@ -978,19 +986,19 @@ void PlaylistTreeWidget::checkAndUpdateItems()
if (!changedItems.empty())
{
auto ret =
QMessageBox::question(parentWidget(),
"Item changed",
"The source of one or more currently loaded items has changed. "
"Do you want to reload the item(s)?");
QMessageBox::question(parentWidget(),
"Item changed",
"The source of one or more currently loaded items has changed. "
"Do you want to reload the item(s)?");
if (ret != QMessageBox::Yes)
{
ret = QMessageBox::question(
parentWidget(),
"Item changed",
"It is really recommended to reload the changed items. YUView does not always buffer all "
"data from the items. We can not guarantee that the data you are shown is correct "
"anymore. For the shown values, there is no indication if they are old or new. Parsing "
"of statistics files may fail. So again: Do you want to reload the item(s)?");
parentWidget(),
"Item changed",
"It is really recommended to reload the changed items. YUView does not always buffer all "
"data from the items. We can not guarantee that the data you are shown is correct "
"anymore. For the shown values, there is no indication if they are old or new. Parsing "
"of statistics files may fail. So again: Do you want to reload the item(s)?");
if (ret != QMessageBox::Yes)
return; // Really no
}
Expand Down Expand Up @@ -1122,7 +1130,7 @@ QList<playlistItem *> PlaylistTreeWidget::getAllPlaylistItems(const bool topLeve
for (int i = 0; i < topLevelItemCount(); i++)
{
QTreeWidgetItem *item = topLevelItem(i);
playlistItem * plItem = dynamic_cast<playlistItem *>(item);
playlistItem *plItem = dynamic_cast<playlistItem *>(item);
if (plItem != nullptr)
{
returnList.append(plItem);
Expand Down
Loading