mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-26 22:28:41 -05:00
924e20efa8
Samples are downloaded from a web server, currently the SF download server. The samples are stored in the source controlled samples directory and the CMake script there builds a suitable directory tree for upload to the web server under samples/web containing the samples hierarchy and the generated JSON contents database file. The samples CMake script also defines an 'upload-samples' target that uses rsync to efficiently upload the samples and the accompanying contents JSON database file. Any directory structure under the samples directory may be created, to add a new sample file simply add the file to source control and amend the list of sample files (SAMPLE_FILES) in samples/CMakeLists.txt. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6308 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
45 lines
1.5 KiB
C++
45 lines
1.5 KiB
C++
#include "DirectoryDelegate.hpp"
|
|
|
|
#include <QApplication>
|
|
#include <QVariant>
|
|
#include <QString>
|
|
#include <QStyle>
|
|
#include <QModelIndex>
|
|
#include <QPainter>
|
|
#include <QStyleOptionViewItem>
|
|
#include <QStyleOptionProgressBar>
|
|
|
|
void DirectoryDelegate::paint (QPainter * painter, QStyleOptionViewItem const& option
|
|
, QModelIndex const& index) const
|
|
{
|
|
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 ();
|
|
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;
|
|
}
|
|
else
|
|
{
|
|
// not started
|
|
progress_bar_option.progress = -1;
|
|
}
|
|
QApplication::style ()->drawControl (QStyle::CE_ProgressBar, &progress_bar_option, painter);
|
|
}
|
|
else
|
|
{
|
|
QStyledItemDelegate::paint (painter, option, index);
|
|
}
|
|
}
|