summaryrefslogtreecommitdiff
path: root/SampleDownloader
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2021-03-27 10:24:15 +0100
committerChristoph Berg <myon@debian.org>2021-03-27 10:24:15 +0100
commit9655b6f589e8e5fa83d21827884d9488ebff63f4 (patch)
tree9ae726f568c60d008f44f472cdff4983cf75a995 /SampleDownloader
parent624f3a92bc09c65c75dda356f6a9af22feea0b5c (diff)
parent5c88480ddc5c5dab1f3444a8b8de9303fd6140da (diff)
Update upstream source from tag 'upstream/2.4.0_rc4+repack'
Update to upstream version '2.4.0~rc4+repack' with Debian dir 74c7d76ab37efed76838cc21b978156acf14f428
Diffstat (limited to 'SampleDownloader')
-rw-r--r--SampleDownloader/Directory.cpp13
-rw-r--r--SampleDownloader/DirectoryDelegate.cpp42
-rw-r--r--SampleDownloader/FileNode.cpp7
3 files changed, 42 insertions, 20 deletions
diff --git a/SampleDownloader/Directory.cpp b/SampleDownloader/Directory.cpp
index 19169e11..45ebe6b5 100644
--- a/SampleDownloader/Directory.cpp
+++ b/SampleDownloader/Directory.cpp
@@ -49,6 +49,8 @@ Directory::Directory (Configuration const * configuration
setColumnCount (2);
setHeaderLabels ({tr ("File"), tr ("Progress")});
+ headerItem ()->setTextAlignment (0, Qt::AlignHCenter);
+ headerItem ()->setTextAlignment (1, Qt::AlignHCenter);
header ()->setSectionResizeMode (QHeaderView::ResizeToContents);
setItemDelegate (&item_delegate_);
@@ -294,14 +296,15 @@ void Directory::update (QTreeWidgetItem * item)
int counted {0};
// get the count, progress and size of children
- int items {recurse_children (item, &counted, &bytes, &max)};
+ // int items {recurse_children (item, &counted, &bytes, &max)};
+ recurse_children (item, &counted, &bytes, &max);
// estimate size of items not yet downloaded as average of
// those actually present
- if (counted)
- {
- max += (items - counted) * max / counted;
- }
+ // if (counted)
+ // {
+ // max += (items - counted) * max / counted;
+ // }
// save as our progress
item->setData (1, Qt::UserRole, max);
diff --git a/SampleDownloader/DirectoryDelegate.cpp b/SampleDownloader/DirectoryDelegate.cpp
index f64e9870..f2589165 100644
--- a/SampleDownloader/DirectoryDelegate.cpp
+++ b/SampleDownloader/DirectoryDelegate.cpp
@@ -14,28 +14,42 @@ void DirectoryDelegate::paint (QPainter * painter, QStyleOptionViewItem const& o
{
if (1 == index.column ())
{
- QStyleOptionProgressBar progress_bar_option;
- progress_bar_option.rect = option.rect;
- progress_bar_option.state = QStyle::State_Enabled;
- progress_bar_option.direction = QApplication::layoutDirection ();
- progress_bar_option.fontMetrics = QApplication::fontMetrics ();
- progress_bar_option.minimum = 0;
- progress_bar_option.maximum = 100;
auto progress = index.data ().toLongLong ();
+ qint64 percent;
if (progress > 0)
{
- auto percent = int (progress * 100 / index.data (Qt::UserRole).toLongLong ());
- progress_bar_option.progress = percent;
- progress_bar_option.text = QString::number (percent) + '%';
- progress_bar_option.textVisible = true;
- progress_bar_option.textAlignment = Qt::AlignCenter;
+ percent = int (progress * 100 / index.data (Qt::UserRole).toLongLong ());
+ }
+#if !defined (Q_OS_DARWIN)
+ QStyleOptionProgressBar progress_option;
+ auto control_element = QStyle::CE_ProgressBar;
+ progress_option.minimum = 0;
+ progress_option.maximum = 100;
+ progress_option.textAlignment = Qt::AlignCenter;
+ if (progress > 0)
+ {
+ progress_option.progress = percent;
+ progress_option.textVisible = true;
}
else
{
// not started
- progress_bar_option.progress = -1;
+ progress_option.progress = -1;
}
- QApplication::style ()->drawControl (QStyle::CE_ProgressBar, &progress_bar_option, painter);
+#else
+ // workaround for broken QProgressBar item delegates on macOS
+ QStyleOptionViewItem progress_option;
+ auto control_element = QStyle::CE_ItemViewItem;
+ progress_option.displayAlignment = Qt::AlignHCenter;
+ progress_option.index = index;
+ progress_option.features = QStyleOptionViewItem::HasDisplay;
+#endif
+ progress_option.rect = option.rect;
+ progress_option.state = QStyle::State_Enabled;
+ progress_option.direction = QApplication::layoutDirection ();
+ progress_option.fontMetrics = QApplication::fontMetrics ();
+ progress_option.text = QString::number (progress > 0 ? percent : 0) + '%';
+ QApplication::style ()->drawControl (control_element, &progress_option, painter);
}
else
{
diff --git a/SampleDownloader/FileNode.cpp b/SampleDownloader/FileNode.cpp
index 66864287..e274dc5a 100644
--- a/SampleDownloader/FileNode.cpp
+++ b/SampleDownloader/FileNode.cpp
@@ -27,7 +27,12 @@ FileNode::FileNode (QTreeWidgetItem * parent
void FileNode::error (QString const& title, QString const& message)
{
- MessageBox::warning_message (treeWidget (), title, message);
+ if (MessageBox::Retry == MessageBox::warning_message (treeWidget (), title, message
+ , QString {}, MessageBox::Cancel | MessageBox::Retry
+ , MessageBox::Cancel))
+ {
+ sync (true);
+ }
}
bool FileNode::sync (bool local)