forked from qt-creator/qt-creator
TaskTree: Reuse Repeat element in DataExchange example
Update the location of the target url so that it points to the TaskTree wiki image. Task-number: QTCREATORBUG-30081 Change-Id: Ic1c715c268b9e14711bc98415e747de8b75ed2dc Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -34,6 +34,7 @@ static int sizeForIndex(int index) { return (index + 1) * s_sizeInterval; }
|
|||||||
Group recipe(const Storage<ExternalData> &externalStorage)
|
Group recipe(const Storage<ExternalData> &externalStorage)
|
||||||
{
|
{
|
||||||
Storage<InternalData> internalStorage;
|
Storage<InternalData> internalStorage;
|
||||||
|
Repeat repeater(s_imageCount);
|
||||||
|
|
||||||
const auto onDownloadSetup = [externalStorage](NetworkQuery &query) {
|
const auto onDownloadSetup = [externalStorage](NetworkQuery &query) {
|
||||||
query.setNetworkAccessManager(externalStorage->inputNam);
|
query.setNetworkAccessManager(externalStorage->inputNam);
|
||||||
@@ -60,27 +61,24 @@ Group recipe(const Storage<ExternalData> &externalStorage)
|
|||||||
externalStorage->outputError = "Image Data Error.";
|
externalStorage->outputError = "Image Data Error.";
|
||||||
};
|
};
|
||||||
|
|
||||||
QList<GroupItem> parallelTasks;
|
const auto onScaleSetup = [internalStorage, repeater](ConcurrentCall<QImage> &data) {
|
||||||
parallelTasks.reserve(s_imageCount + 1); // +1 for parallelLimit
|
const int s = sizeForIndex(repeater.iteration());
|
||||||
parallelTasks.append(parallelLimit(QThread::idealThreadCount() - 1));
|
data.setConcurrentCallData(&scaleImage, internalStorage->imageSource, QSize(s, s));
|
||||||
|
};
|
||||||
for (int i = 0; i < s_imageCount; ++i) {
|
const auto onScaleDone = [externalStorage, repeater](const ConcurrentCall<QImage> &data) {
|
||||||
const int s = sizeForIndex(i);
|
externalStorage->outputImages.insert(repeater.iteration(), data.result());
|
||||||
const auto onScaleSetup = [internalStorage, s](ConcurrentCall<QImage> &data) {
|
};
|
||||||
data.setConcurrentCallData(&scaleImage, internalStorage->imageSource, QSize(s, s));
|
|
||||||
};
|
|
||||||
const auto onScaleDone = [externalStorage, s](const ConcurrentCall<QImage> &data) {
|
|
||||||
externalStorage->outputImages.insert(s, data.result());
|
|
||||||
};
|
|
||||||
parallelTasks.append(ConcurrentCallTask<QImage>(onScaleSetup, onScaleDone));
|
|
||||||
}
|
|
||||||
|
|
||||||
const QList<GroupItem> recipe {
|
const QList<GroupItem> recipe {
|
||||||
externalStorage,
|
externalStorage,
|
||||||
internalStorage,
|
internalStorage,
|
||||||
NetworkQueryTask(onDownloadSetup, onDownloadDone),
|
NetworkQueryTask(onDownloadSetup, onDownloadDone),
|
||||||
ConcurrentCallTask<QImage>(onReadSetup, onReadDone),
|
ConcurrentCallTask<QImage>(onReadSetup, onReadDone),
|
||||||
Group { parallelTasks }
|
Group {
|
||||||
|
repeater,
|
||||||
|
parallelLimit(QThread::idealThreadCount() - 1),
|
||||||
|
ConcurrentCallTask<QImage>(onScaleSetup, onScaleDone)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
return recipe;
|
return recipe;
|
||||||
}
|
}
|
||||||
|
@@ -16,9 +16,7 @@ Viewer::Viewer(QWidget *parent)
|
|||||||
setWindowTitle(tr("Data Exchange"));
|
setWindowTitle(tr("Data Exchange"));
|
||||||
|
|
||||||
QLabel *urlLabel = new QLabel(tr("Url:"));
|
QLabel *urlLabel = new QLabel(tr("Url:"));
|
||||||
m_lineEdit = new QLineEdit("https://media.licdn.com/dms/image/D4D22AQFj3ksh5rmnrg/"
|
m_lineEdit = new QLineEdit("https://qt-wiki-uploads.s3.amazonaws.com/images/f/fd/TaskTree.jpg");
|
||||||
"feedshare-shrink_800/0/1697023188446?e=1701302400&v=beta"
|
|
||||||
"&t=6dy5dmhzgONaLu139A6XmFSGqDohiezq1fH-q2mmu3w");
|
|
||||||
QPushButton *startButton = new QPushButton(tr("Start"));
|
QPushButton *startButton = new QPushButton(tr("Start"));
|
||||||
QPushButton *stopButton = new QPushButton(tr("Stop"));
|
QPushButton *stopButton = new QPushButton(tr("Stop"));
|
||||||
QPushButton *resetButton = new QPushButton(tr("Reset"));
|
QPushButton *resetButton = new QPushButton(tr("Reset"));
|
||||||
|
Reference in New Issue
Block a user