Update GUI and Recon connection.
This commit is contained in:
87
src/forms/recon/ReconStateDelegate.cpp
Normal file
87
src/forms/recon/ReconStateDelegate.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
#include "ReconStateDelegate.h"
|
||||
#include "device/DeviceManager.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QProgressBar>
|
||||
#include <QApplication>
|
||||
|
||||
ReconStateDelegate::ReconStateDelegate(QObject* aParent)
|
||||
: QStyledItemDelegate(aParent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ReconStateDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QVariant data = index.data(Qt::DisplayRole);
|
||||
|
||||
if (data.isValid())
|
||||
{
|
||||
int state = data.toInt();
|
||||
QString displayText;
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
displayText = tr("Wait to transfer");
|
||||
break;
|
||||
case 100:
|
||||
{
|
||||
displayText = tr("Transfering");
|
||||
int progress = DeviceManager::Default()->getTransferProgress();
|
||||
QRect textRect = option.rect;
|
||||
textRect.setRight(option.rect.right() - 300);
|
||||
painter->drawText(textRect, Qt::AlignCenter, displayText);
|
||||
|
||||
QRect progressBarRect = option.rect;
|
||||
progressBarRect.setLeft(textRect.right() + 20);
|
||||
progressBarRect.setRight(option.rect.right() - 5);
|
||||
progressBarRect.setTop(option.rect.top() + 5);
|
||||
progressBarRect.setBottom(option.rect.bottom() - 5);
|
||||
|
||||
QStyleOptionProgressBarV2 progressBarOption;
|
||||
progressBarOption.rect = progressBarRect;
|
||||
progressBarOption.minimum = 0;
|
||||
progressBarOption.maximum = 100;
|
||||
progressBarOption.progress = progress;
|
||||
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, painter);
|
||||
|
||||
return;
|
||||
}
|
||||
case 104:
|
||||
displayText = tr("Transfer failed");
|
||||
break;
|
||||
case 200:
|
||||
displayText = tr("Transfer completed");
|
||||
break;
|
||||
case 204:
|
||||
displayText = tr("Recon create failed");
|
||||
break;
|
||||
case 300:
|
||||
displayText = tr("Recon create succeed");
|
||||
break;
|
||||
case 400:
|
||||
displayText = tr("Wait to recon");
|
||||
break;
|
||||
case 500:
|
||||
displayText = tr("Recon ing");
|
||||
break;
|
||||
case 504:
|
||||
displayText = tr("Recon failed");
|
||||
break;
|
||||
case 600:
|
||||
displayText = tr("Recon succeed");
|
||||
break;
|
||||
case 604:
|
||||
displayText = tr("PACS failed");
|
||||
break;
|
||||
case 999:
|
||||
displayText = tr("PACS succeed");
|
||||
break;
|
||||
default:
|
||||
displayText = tr("Unknow");
|
||||
break;
|
||||
}
|
||||
|
||||
painter->drawText(option.rect, Qt::AlignCenter, displayText);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user