mirror of https://github.com/OpenMW/openmw.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.9 KiB
C++
73 lines
1.9 KiB
C++
#include "operations.hpp"
|
|
|
|
#include <algorithm>
|
|
|
|
#include <QDockWidget>
|
|
#include <QVBoxLayout>
|
|
#include <QWidget>
|
|
|
|
#include "operation.hpp"
|
|
|
|
namespace
|
|
{
|
|
constexpr int operationLineHeight = 36;
|
|
}
|
|
|
|
CSVDoc::Operations::Operations()
|
|
{
|
|
setFeatures(QDockWidget::NoDockWidgetFeatures);
|
|
|
|
QWidget* widgetContainer = new QWidget(this);
|
|
mLayout = new QVBoxLayout;
|
|
mLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
widgetContainer->setContentsMargins(0, 0, 0, 0);
|
|
widgetContainer->setLayout(mLayout);
|
|
setWidget(widgetContainer);
|
|
setVisible(false);
|
|
setFixedHeight(operationLineHeight);
|
|
setTitleBarWidget(new QWidget(this));
|
|
}
|
|
|
|
void CSVDoc::Operations::setProgress(int current, int max, int type, int threads)
|
|
{
|
|
for (std::vector<Operation*>::iterator iter(mOperations.begin()); iter != mOperations.end(); ++iter)
|
|
if ((*iter)->getType() == type)
|
|
{
|
|
(*iter)->setProgress(current, max, threads);
|
|
return;
|
|
}
|
|
|
|
Operation* operation = new Operation(type, this);
|
|
connect(operation, qOverload<int>(&Operation::abortOperation), this, &Operations::abortOperation);
|
|
|
|
mLayout->addLayout(operation->getLayout());
|
|
mOperations.push_back(operation);
|
|
operation->setProgress(current, max, threads);
|
|
|
|
int newCount = static_cast<int>(mOperations.size());
|
|
setFixedHeight(operationLineHeight * newCount);
|
|
|
|
setVisible(true);
|
|
}
|
|
|
|
void CSVDoc::Operations::quitOperation(int type)
|
|
{
|
|
for (std::vector<Operation*>::iterator iter(mOperations.begin()); iter != mOperations.end(); ++iter)
|
|
if ((*iter)->getType() == type)
|
|
{
|
|
mLayout->removeItem((*iter)->getLayout());
|
|
|
|
(*iter)->deleteLater();
|
|
mOperations.erase(iter);
|
|
|
|
int newCount = static_cast<int>(mOperations.size());
|
|
if (newCount > 0)
|
|
setFixedHeight(operationLineHeight * newCount);
|
|
else
|
|
setVisible(false);
|
|
|
|
break;
|
|
}
|
|
}
|