mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-27 19:45:43 +03:00
refact1
This commit is contained in:
203
InstructorsAndTrainees/settings/dialogversioncontrol.cpp
Normal file
203
InstructorsAndTrainees/settings/dialogversioncontrol.cpp
Normal file
@@ -0,0 +1,203 @@
|
||||
#include <QResizeEvent>
|
||||
|
||||
#include "dialogversioncontrol.h"
|
||||
#include "specialmessagebox.h"
|
||||
#include "ui_dialogversioncontrol.h"
|
||||
|
||||
|
||||
DialogVersionControl::DialogVersionControl(ConnectorToServer* connectorToServer, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DialogVersionControl),
|
||||
connectorToServer(connectorToServer),
|
||||
serverDataList(nullptr),
|
||||
selectedVersion(nullptr),
|
||||
versionContainer(nullptr),
|
||||
waitAnimationWidget(nullptr),
|
||||
authorName(""),
|
||||
flGetVersion(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setMinimumSize(500, 300);
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
setWindowTitle(tr("Version control"));
|
||||
|
||||
versionContainer = new VersionContainer;
|
||||
|
||||
waitAnimationWidget = new WaitAnimationWidget;
|
||||
QMovie *movie = new QMovie(":/resources/icons/762.gif");
|
||||
waitAnimationWidget->setParent(this);
|
||||
waitAnimationWidget->initialize(movie,this);
|
||||
}
|
||||
|
||||
DialogVersionControl::~DialogVersionControl()
|
||||
{
|
||||
waitAnimationWidget->hideWithStop();
|
||||
|
||||
delete versionContainer;
|
||||
|
||||
delete waitAnimationWidget;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DialogVersionControl::initialize(QString authorName)
|
||||
{
|
||||
this->authorName = authorName;
|
||||
|
||||
connect (connectorToServer, &ConnectorToServer::signal_SetVersion, this, &DialogVersionControl::slot_SetVersion);
|
||||
connect(connectorToServer, &ConnectorToServer::signal_AnimationActivated, this, &DialogVersionControl::slot_activateLoadAnimation);
|
||||
|
||||
connect(connectorToServer, &ConnectorToServer::signal_showServerList, this, &DialogVersionControl::slot_showServerList);
|
||||
|
||||
connect(this, &DialogVersionControl::sigSendSwitchVersion, connectorToServer, &ConnectorToServer::slot_SendSwitchVersion);
|
||||
connect(this, &DialogVersionControl::sigSendCopyVersion, connectorToServer, &ConnectorToServer::slot_SendCopyVersion);
|
||||
connect(this, &DialogVersionControl::sigSendDeleteVersion, connectorToServer, &ConnectorToServer::slot_SendDeleteVersion);
|
||||
|
||||
connect(this, &DialogVersionControl::signal_getVersion, connectorToServer, &ConnectorToServer::slot_getVersion);
|
||||
|
||||
emit signal_getVersion();
|
||||
}
|
||||
|
||||
void DialogVersionControl::fillView(QList<StreamingVersionData *> *serverData)
|
||||
{
|
||||
ui->verListView->clear();
|
||||
serverDataList = serverData;
|
||||
ui->verValue->setText(versionContainer->getServerVersionData()->getViewName());
|
||||
|
||||
for(StreamingVersionData *data : *serverData)
|
||||
{
|
||||
ui->verListView->addItem(data->getViewName());
|
||||
}
|
||||
|
||||
if(ui->verListView->count())
|
||||
{
|
||||
ui->verListView->setCurrentRow(0);
|
||||
ui->verListView->itemClicked(ui->verListView->item(0));
|
||||
}
|
||||
}
|
||||
|
||||
QString DialogVersionControl::changableText(bool flag)
|
||||
{
|
||||
if(flag) return tr("Yes");
|
||||
else return tr("No");
|
||||
}
|
||||
|
||||
void DialogVersionControl::on_verListView_itemClicked(QListWidgetItem *item)
|
||||
{
|
||||
for(StreamingVersionData *data : *serverDataList)
|
||||
{
|
||||
if(data->getViewName() == item->text())
|
||||
{
|
||||
QString info = tr("Version name: ") + data->getViewName() + "\n";
|
||||
info.append(tr("Created: ") + data->getCreateData().toString() + "\n");
|
||||
info.append(tr("Changeable: ") + changableText(data->getIsChangeable()) + "\n");
|
||||
info.append(tr("Author: ") + data->getAuthor());
|
||||
ui->infoValue->setText(info);
|
||||
selectedVersion = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DialogVersionControl::sendCopyEmit(QString newName)
|
||||
{
|
||||
QString result = selectedVersion->getViewName() + ";" + newName + ";" + authorName;
|
||||
|
||||
if (selectedVersion == nullptr)
|
||||
{
|
||||
QString text = tr("Version not selected");
|
||||
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec();
|
||||
return;
|
||||
}
|
||||
|
||||
versionContainer->setLocalVersionData(selectedVersion);
|
||||
emit sigSendCopyVersion(result);
|
||||
}
|
||||
|
||||
void DialogVersionControl::on_createDuplicateButton_clicked()
|
||||
{
|
||||
if (selectedVersion == nullptr)
|
||||
{
|
||||
QString text = tr("Version not selected");
|
||||
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec();
|
||||
return;
|
||||
}
|
||||
|
||||
DialogNewVersion *dlgNewVersion = new DialogNewVersion(this);
|
||||
dlgNewVersion->initialize(selectedVersion->getViewName());
|
||||
|
||||
switch(dlgNewVersion->exec())
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
QString newName = dlgNewVersion->getNewName();
|
||||
sendCopyEmit(newName);
|
||||
break;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
delete dlgNewVersion;
|
||||
}
|
||||
|
||||
void DialogVersionControl::on_deleteVersionButton_clicked()
|
||||
{
|
||||
if (selectedVersion == nullptr)
|
||||
{
|
||||
QString text = tr("Version not selected");
|
||||
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec();
|
||||
return;
|
||||
}
|
||||
|
||||
emit sigSendDeleteVersion(selectedVersion);
|
||||
}
|
||||
|
||||
void DialogVersionControl::on_switchServerVersionButton_clicked()
|
||||
{
|
||||
if (selectedVersion == nullptr)
|
||||
{
|
||||
QString text = tr("Version not selected");
|
||||
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec();
|
||||
return;
|
||||
}
|
||||
|
||||
versionContainer->setServerVersionData(selectedVersion);
|
||||
ui->verValue->setText(selectedVersion->getViewName());
|
||||
emit sigSendSwitchVersion(selectedVersion);
|
||||
}
|
||||
|
||||
void DialogVersionControl::slot_activateLoadAnimation(bool flag)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
waitAnimationWidget->showWithPlay();
|
||||
}
|
||||
else
|
||||
{
|
||||
waitAnimationWidget->hideWithStop();
|
||||
}
|
||||
}
|
||||
|
||||
void DialogVersionControl::slot_showServerList(QList<StreamingVersionData *> *serverList)
|
||||
{
|
||||
fillView(serverList);
|
||||
}
|
||||
|
||||
void DialogVersionControl::slot_SetVersion(StreamingVersionData *serverVersion)
|
||||
{
|
||||
versionContainer->setServerVersionData(serverVersion);
|
||||
|
||||
if(!flGetVersion)
|
||||
connectorToServer->sendShowVersionSelect();
|
||||
|
||||
flGetVersion = true;
|
||||
}
|
||||
|
||||
void DialogVersionControl::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QSize size = event->size();
|
||||
waitAnimationWidget->resize(size);
|
||||
}
|
||||
Reference in New Issue
Block a user