|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "svndeletedialog.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Tnz6 includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tapp.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tsystem.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfilepath.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "filebrowser.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "fileselection.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzQt includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/tselectionhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/gutil.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzLib includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshsimplelevel.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Qt includes
|
|
Toshihiro Shimizu |
890ddd |
#include <qwidget></qwidget>
|
|
Toshihiro Shimizu |
890ddd |
#include <qlabel></qlabel>
|
|
Toshihiro Shimizu |
890ddd |
#include <qmovie></qmovie>
|
|
Toshihiro Shimizu |
890ddd |
#include <qcheckbox></qcheckbox>
|
|
Toshihiro Shimizu |
890ddd |
#include <qplaintextedit></qplaintextedit>
|
|
Toshihiro Shimizu |
890ddd |
#include <qpushbutton></qpushbutton>
|
|
Toshihiro Shimizu |
890ddd |
#include <qboxlayout></qboxlayout>
|
|
Toshihiro Shimizu |
890ddd |
#include <qformlayout></qformlayout>
|
|
Toshihiro Shimizu |
890ddd |
#include <qtreewidget></qtreewidget>
|
|
Toshihiro Shimizu |
890ddd |
#include <qheaderview></qheaderview>
|
|
Toshihiro Shimizu |
890ddd |
#include <qtextstream></qtextstream>
|
|
Toshihiro Shimizu |
890ddd |
#include <qdir></qdir>
|
|
Toshihiro Shimizu |
890ddd |
#include <qmainwindow></qmainwindow>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// SVNDeleteDialog
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
SVNDeleteDialog::SVNDeleteDialog(QWidget *parent, const QString &workingDir,
|
|
Shinya Kitaoka |
120a6e |
const QStringList &files, bool isFolder,
|
|
Shinya Kitaoka |
120a6e |
int sceneIconAdded)
|
|
Shinya Kitaoka |
120a6e |
: Dialog(TApp::instance()->getMainWindow(), true, false)
|
|
Shinya Kitaoka |
120a6e |
, m_deleteSceneContentsCheckBox(0)
|
|
Shinya Kitaoka |
120a6e |
, m_workingDir(workingDir)
|
|
Shinya Kitaoka |
120a6e |
, m_files(files)
|
|
Shinya Kitaoka |
120a6e |
, m_targetTempFile(0)
|
|
Shinya Kitaoka |
120a6e |
, m_isFolder(isFolder)
|
|
Shinya Kitaoka |
120a6e |
, m_sceneIconAdded(sceneIconAdded) {
|
|
Shinya Kitaoka |
120a6e |
setModal(false);
|
|
Shinya Kitaoka |
120a6e |
setAttribute(Qt::WA_DeleteOnClose, true);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
setWindowTitle(tr("Version Control: Delete"));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
setMinimumSize(300, 180);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QWidget *container = new QWidget;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QVBoxLayout *mainLayout = new QVBoxLayout;
|
|
Shinya Kitaoka |
120a6e |
mainLayout->setAlignment(Qt::AlignHCenter);
|
|
Shinya Kitaoka |
120a6e |
mainLayout->setMargin(0);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QHBoxLayout *hLayout = new QHBoxLayout;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_waitingLabel = new QLabel;
|
|
Shinya Kitaoka |
120a6e |
QMovie *waitingMove = new QMovie(":Resources/waiting.gif");
|
|
Shinya Kitaoka |
120a6e |
waitingMove->setParent(this);
|
|
Shinya Kitaoka |
120a6e |
m_waitingLabel->hide();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_waitingLabel->setMovie(waitingMove);
|
|
Shinya Kitaoka |
120a6e |
waitingMove->setCacheMode(QMovie::CacheAll);
|
|
Shinya Kitaoka |
120a6e |
waitingMove->start();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_textLabel = new QLabel;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_isFolder) {
|
|
Shinya Kitaoka |
120a6e |
QDir dir(m_workingDir + "/" + m_files.at(0));
|
|
Shinya Kitaoka |
120a6e |
int filesCount = dir.entryList(QDir::Files | QDir::Dirs).count();
|
|
Shinya Kitaoka |
120a6e |
if (filesCount > 0)
|
|
Shinya Kitaoka |
120a6e |
m_textLabel->setText(tr("Delete folder that contains %1 items.")
|
|
Shinya Kitaoka |
120a6e |
.arg(filesCount - m_sceneIconAdded));
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
m_textLabel->setText(tr("Delete empty folder."));
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
m_textLabel->setText(
|
|
Shinya Kitaoka |
120a6e |
tr("Delete %1 items.").arg(m_files.size() - m_sceneIconAdded));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
hLayout->addStretch();
|
|
Shinya Kitaoka |
120a6e |
hLayout->addWidget(m_waitingLabel);
|
|
Shinya Kitaoka |
120a6e |
hLayout->addWidget(m_textLabel);
|
|
Shinya Kitaoka |
120a6e |
hLayout->addStretch();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
mainLayout->addLayout(hLayout);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_treeWidget = new QTreeWidget;
|
|
Shinya Kitaoka |
120a6e |
m_treeWidget->setStyleSheet("QTreeWidget { border: 1px solid gray; }");
|
|
Shinya Kitaoka |
120a6e |
m_treeWidget->header()->hide();
|
|
Shinya Kitaoka |
120a6e |
m_treeWidget->hide();
|
|
Shinya Kitaoka |
120a6e |
mainLayout->addWidget(m_treeWidget);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QFormLayout *formLayout = new QFormLayout;
|
|
Shinya Kitaoka |
120a6e |
formLayout->setLabelAlignment(Qt::AlignRight);
|
|
Shinya Kitaoka |
120a6e |
formLayout->setFormAlignment(Qt::AlignHCenter | Qt::AlignTop);
|
|
Shinya Kitaoka |
120a6e |
formLayout->setSpacing(10);
|
|
Shinya Kitaoka |
120a6e |
formLayout->setMargin(0);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_commentTextEdit = new QPlainTextEdit;
|
|
Shinya Kitaoka |
120a6e |
m_commentTextEdit->setMaximumHeight(50);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_commentLabel = new QLabel(tr("Comment:"));
|
|
Shinya Kitaoka |
120a6e |
m_commentLabel->setFixedWidth(55);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_commentTextEdit->hide();
|
|
Shinya Kitaoka |
120a6e |
m_commentLabel->hide();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
formLayout->addRow(m_commentLabel, m_commentTextEdit);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!m_isFolder) {
|
|
Shinya Kitaoka |
120a6e |
m_deleteSceneContentsCheckBox = new QCheckBox(this);
|
|
Shinya Kitaoka |
120a6e |
connect(m_deleteSceneContentsCheckBox, SIGNAL(toggled(bool)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onDeleteSceneContentsToggled(bool)));
|
|
Shinya Kitaoka |
120a6e |
m_deleteSceneContentsCheckBox->setChecked(false);
|
|
Shinya Kitaoka |
120a6e |
m_deleteSceneContentsCheckBox->hide();
|
|
Shinya Kitaoka |
120a6e |
m_deleteSceneContentsCheckBox->setText(tr("Delete Scene Contents"));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
formLayout->addRow("", m_deleteSceneContentsCheckBox);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int fileSize = m_files.size();
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < fileSize; i++) {
|
|
Shinya Kitaoka |
120a6e |
if (m_files.at(i).endsWith(".tnz")) {
|
|
Shinya Kitaoka |
120a6e |
m_deleteSceneContentsCheckBox->show();
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_keepLocalCopyCheckBox = new QCheckBox(tr(" Keep Local Copy"));
|
|
Shinya Kitaoka |
120a6e |
m_keepLocalCopyCheckBox->setChecked(true);
|
|
Shinya Kitaoka |
120a6e |
m_keepLocalCopyCheckBox->hide();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
formLayout->addRow("", m_keepLocalCopyCheckBox);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
mainLayout->addLayout(formLayout);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
container->setLayout(mainLayout);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
beginHLayout();
|
|
Shinya Kitaoka |
120a6e |
addWidget(container, false);
|
|
Shinya Kitaoka |
120a6e |
endHLayout();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_deleteLocalButton = new QPushButton();
|
|
Shinya Kitaoka |
120a6e |
m_deleteLocalButton->setText(tr("Delete Local Copy "));
|
|
Shinya Kitaoka |
120a6e |
connect(m_deleteLocalButton, SIGNAL(clicked()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onDeleteLocalButtonClicked()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_deleteServerButton = new QPushButton();
|
|
Shinya Kitaoka |
120a6e |
m_deleteServerButton->setText(tr("Delete on Server "));
|
|
Shinya Kitaoka |
120a6e |
connect(m_deleteServerButton, SIGNAL(clicked()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onDeleteServerButtonClicked()));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_cancelButton = new QPushButton(tr("Cancel"));
|
|
Shinya Kitaoka |
120a6e |
connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
addButtonBarWidget(m_deleteLocalButton, m_deleteServerButton, m_cancelButton);
|
|
Shinya Kitaoka |
120a6e |
|
|
luz paz |
6454c4 |
// 0. Connect for svn errors (that may occur)
|
|
Shinya Kitaoka |
120a6e |
connect(&m_thread, SIGNAL(error(const QString &)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onError(const QString &)));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SVNDeleteDialog::showEvent(QShowEvent *e) {
|
|
manongjohn |
a8a7ab |
if (!m_isFolder) {
|
|
manongjohn |
a8a7ab |
initTreeWidget();
|
|
manongjohn |
a8a7ab |
|
|
manongjohn |
a8a7ab |
int height = 50;
|
|
manongjohn |
a8a7ab |
if (m_treeWidget->isVisible()) height += (m_files.size() * 50);
|
|
manongjohn |
a8a7ab |
|
|
otakuto |
158f9f |
setMinimumSize(300, std::min(height, 350));
|
|
manongjohn |
a8a7ab |
}
|
|
Shinya Kitaoka |
120a6e |
QDialog::showEvent(e);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SVNDeleteDialog::onError(const QString &errorString) {
|
|
Shinya Kitaoka |
120a6e |
if (m_targetTempFile) {
|
|
Shinya Kitaoka |
120a6e |
QFile::remove(m_targetTempFile->fileName());
|
|
Shinya Kitaoka |
120a6e |
delete m_targetTempFile;
|
|
Shinya Kitaoka |
120a6e |
m_targetTempFile = 0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_textLabel->setText(errorString);
|
|
Shinya Kitaoka |
120a6e |
switchToCloseButton();
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SVNDeleteDialog::switchToCloseButton() {
|
|
Shinya Kitaoka |
120a6e |
if (m_deleteSceneContentsCheckBox) m_deleteSceneContentsCheckBox->hide();
|
|
Shinya Kitaoka |
120a6e |
m_commentTextEdit->hide();
|
|
Shinya Kitaoka |
120a6e |
m_commentLabel->hide();
|
|
Shinya Kitaoka |
120a6e |
m_waitingLabel->hide();
|
|
Shinya Kitaoka |
120a6e |
m_treeWidget->hide();
|
|
Shinya Kitaoka |
120a6e |
m_keepLocalCopyCheckBox->hide();
|
|
Shinya Kitaoka |
120a6e |
m_deleteLocalButton->disconnect();
|
|
Shinya Kitaoka |
120a6e |
m_deleteLocalButton->setText("Close");
|
|
Shinya Kitaoka |
120a6e |
m_deleteLocalButton->show();
|
|
Shinya Kitaoka |
120a6e |
m_cancelButton->hide();
|
|
Shinya Kitaoka |
120a6e |
m_deleteServerButton->hide();
|
|
Shinya Kitaoka |
120a6e |
connect(m_deleteLocalButton, SIGNAL(clicked()), this, SLOT(close()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SVNDeleteDialog::onDeleteLocalButtonClicked() {
|
|
Shinya Kitaoka |
120a6e |
// Delete files locally
|
|
Shinya Kitaoka |
120a6e |
int fileCount = m_files.size();
|
|
Shinya Kitaoka |
120a6e |
m_waitingLabel->show();
|
|
Shinya Kitaoka |
120a6e |
m_textLabel->setText(
|
|
Shinya Kitaoka |
120a6e |
tr("Deleting %1 items...")
|
|
Shinya Kitaoka |
120a6e |
.arg(fileCount + m_sceneResources.size() - m_sceneIconAdded));
|
|
Shinya Kitaoka |
120a6e |
m_textLabel->show();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < fileCount; i++) {
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp((m_workingDir + "/" + m_files.at(i)).toStdWString());
|
|
Shinya Kitaoka |
120a6e |
TSystem::moveFileOrLevelToRecycleBin(fp);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int sceneResourcesCount = m_sceneResources.size();
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < sceneResourcesCount; i++) {
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp(m_sceneResources.at(i).toStdWString());
|
|
Shinya Kitaoka |
120a6e |
TSystem::moveFileOrLevelToRecycleBin(fp);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
updateFileBrowser();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
emit done(m_files);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_waitingLabel->hide();
|
|
Shinya Kitaoka |
120a6e |
m_textLabel->hide();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
close();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SVNDeleteDialog::updateFileBrowser() {
|
|
Shinya Kitaoka |
120a6e |
// Reset the selection
|
|
Shinya Kitaoka |
120a6e |
TSelection *selection =
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentSelection()->getSelection();
|
|
Shinya Kitaoka |
120a6e |
FileSelection *fileSelection = dynamic_cast<fileselection *="">(selection);</fileselection>
|
|
Shinya Kitaoka |
120a6e |
if (fileSelection) fileSelection->selectNone();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp((m_workingDir + "/" + m_files.at(0)).toStdWString());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Refresh FileBrowser
|
|
Shinya Kitaoka |
120a6e |
FileBrowser::refreshFolder(fp.getParentDir());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SVNDeleteDialog::onDeleteServerButtonClicked() {
|
|
Shinya Kitaoka |
120a6e |
m_deleteLocalButton->hide();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
disconnect(m_deleteServerButton, SIGNAL(clicked()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onDeleteServerButtonClicked()));
|
|
Shinya Kitaoka |
120a6e |
m_deleteServerButton->setText(tr("Delete"));
|
|
Shinya Kitaoka |
120a6e |
connect(m_deleteServerButton, SIGNAL(clicked()), this, SLOT(deleteFiles()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
manongjohn |
a8a7ab |
int height = 175;
|
|
manongjohn |
a8a7ab |
if (m_treeWidget->isVisible()) height += (m_files.size() * 50);
|
|
otakuto |
158f9f |
setMinimumSize(300, std::min(height, 350));
|
|
manongjohn |
a8a7ab |
|
|
Shinya Kitaoka |
120a6e |
m_textLabel->setText(
|
|
Shinya Kitaoka |
120a6e |
tr("You are deleting items also on repository. Are you sure ?"));
|
|
Shinya Kitaoka |
120a6e |
m_commentLabel->show();
|
|
Shinya Kitaoka |
120a6e |
m_commentTextEdit->show();
|
|
Shinya Kitaoka |
120a6e |
m_keepLocalCopyCheckBox->show();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SVNDeleteDialog::deleteFiles() {
|
|
Shinya Kitaoka |
120a6e |
m_waitingLabel->show();
|
|
Shinya Kitaoka |
120a6e |
m_textLabel->setText(
|
|
Shinya Kitaoka |
120a6e |
tr("Deleting %1 items...")
|
|
Shinya Kitaoka |
120a6e |
.arg(QString::number(m_files.size() + m_sceneResources.size() -
|
|
Shinya Kitaoka |
120a6e |
m_sceneIconAdded)));
|
|
Shinya Kitaoka |
120a6e |
m_commentLabel->hide();
|
|
Shinya Kitaoka |
120a6e |
m_commentTextEdit->hide();
|
|
Shinya Kitaoka |
120a6e |
m_treeWidget->hide();
|
|
Shinya Kitaoka |
120a6e |
m_keepLocalCopyCheckBox->hide();
|
|
Shinya Kitaoka |
120a6e |
if (m_deleteSceneContentsCheckBox) m_deleteSceneContentsCheckBox->hide();
|
|
Shinya Kitaoka |
120a6e |
m_deleteServerButton->hide();
|
|
Shinya Kitaoka |
120a6e |
m_cancelButton->hide();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QStringList args;
|
|
Shinya Kitaoka |
120a6e |
args << "delete";
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_keepLocalCopyCheckBox->isChecked()) args << "--keep-local";
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Use a temporary file to store all the files list
|
|
Shinya Kitaoka |
120a6e |
m_targetTempFile = new QFile(m_workingDir + "/" + "tempDeleteFile");
|
|
Shinya Kitaoka |
120a6e |
if (m_targetTempFile->open(QFile::WriteOnly | QFile::Truncate)) {
|
|
Shinya Kitaoka |
120a6e |
QTextStream out(m_targetTempFile);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int filesCount = m_files.count();
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < filesCount; i++) out << m_files.at(i) + "\n";
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int sceneResourcesCount = m_sceneResources.size();
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < sceneResourcesCount; i++)
|
|
Shinya Kitaoka |
120a6e |
out << m_sceneResources.at(i) + "\n";
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
m_targetTempFile->close();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
args << "--targets";
|
|
Shinya Kitaoka |
120a6e |
args << "tempDeleteFile";
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_thread.disconnect(SIGNAL(done(const QString &)));
|
|
Shinya Kitaoka |
120a6e |
connect(&m_thread, SIGNAL(done(const QString &)), SLOT(commitDeletedFiles()));
|
|
Shinya Kitaoka |
120a6e |
m_thread.executeCommand(m_workingDir, "svn", args, false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SVNDeleteDialog::commitDeletedFiles() {
|
|
Shinya Kitaoka |
120a6e |
updateFileBrowser();
|
|
Shinya Kitaoka |
120a6e |
QStringList args;
|
|
Shinya Kitaoka |
120a6e |
args << "commit";
|
|
Shinya Kitaoka |
120a6e |
args << "--targets";
|
|
Shinya Kitaoka |
120a6e |
args << "tempDeleteFile";
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!m_commentTextEdit->toPlainText().isEmpty())
|
|
Shinya Kitaoka |
120a6e |
args << QString("-m").append(m_commentTextEdit->toPlainText());
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
args << QString("-m").append(VersionControl::instance()->getUserName() +
|
|
Shinya Kitaoka |
120a6e |
" delete files.");
|
|
Shinya Kitaoka |
120a6e |
m_thread.disconnect(SIGNAL(done(const QString &)));
|
|
Shinya Kitaoka |
120a6e |
connect(&m_thread, SIGNAL(done(const QString &)), SLOT(onCommitDone()));
|
|
Shinya Kitaoka |
120a6e |
m_thread.executeCommand(m_workingDir, "svn", args);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SVNDeleteDialog::onCommitDone() {
|
|
Shinya Kitaoka |
120a6e |
if (m_targetTempFile) {
|
|
Shinya Kitaoka |
120a6e |
QFile::remove(m_targetTempFile->fileName());
|
|
Shinya Kitaoka |
120a6e |
delete m_targetTempFile;
|
|
Shinya Kitaoka |
120a6e |
m_targetTempFile = 0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
emit done(m_files);
|
|
Shinya Kitaoka |
120a6e |
close();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SVNDeleteDialog::initTreeWidget() {
|
|
Shinya Kitaoka |
120a6e |
int filesSize = m_files.size();
|
|
Shinya Kitaoka |
120a6e |
bool itemAdded = false;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < filesSize; i++) {
|
|
Shinya Kitaoka |
120a6e |
QString fileName = m_files.at(i);
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp =
|
|
Shinya Kitaoka |
120a6e |
TFilePath(m_workingDir.toStdWString()) + fileName.toStdWString();
|
|
Shinya Kitaoka |
120a6e |
TFilePathSet fpset;
|
|
Shinya Kitaoka |
120a6e |
TXshSimpleLevel::getFiles(fp, fpset);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QStringList linkedFiles;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TFilePathSet::iterator it;
|
|
Shinya Kitaoka |
120a6e |
for (it = fpset.begin(); it != fpset.end(); ++it) {
|
|
Shinya Kitaoka |
120a6e |
QString fn = toQString((*it).withoutParentDir());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_files.contains(fn)) linkedFiles.append(fn);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!linkedFiles.isEmpty()) {
|
|
Shinya Kitaoka |
120a6e |
itemAdded = true;
|
|
Shinya Kitaoka |
120a6e |
QTreeWidgetItem *twi = new QTreeWidgetItem(m_treeWidget);
|
|
Shinya Kitaoka |
120a6e |
twi->setText(0, fileName);
|
|
Shinya Kitaoka |
120a6e |
twi->setFirstColumnSpanned(false);
|
|
Shinya Kitaoka |
120a6e |
twi->setFlags(Qt::NoItemFlags);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < linkedFiles.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
QTreeWidgetItem *child = new QTreeWidgetItem(twi);
|
|
Shinya Kitaoka |
120a6e |
child->setText(0, linkedFiles.at(i));
|
|
Shinya Kitaoka |
120a6e |
child->setFlags(Qt::NoItemFlags);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
twi->setExpanded(true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (itemAdded) m_treeWidget->show();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SVNDeleteDialog::onDeleteSceneContentsToggled(bool checked) {
|
|
Shinya Kitaoka |
120a6e |
if (!checked)
|
|
Shinya Kitaoka |
120a6e |
m_sceneResources.clear();
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
VersionControl *vc = VersionControl::instance();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int fileSize = m_files.count();
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < fileSize; i++) {
|
|
Shinya Kitaoka |
120a6e |
QString fileName = m_files.at(i);
|
|
Shinya Kitaoka |
120a6e |
if (fileName.endsWith(".tnz")) {
|
|
Shinya Kitaoka |
120a6e |
if (m_files.contains(fileName))
|
|
Shinya Kitaoka |
120a6e |
m_sceneResources.append(vc->getSceneContents(m_workingDir, fileName));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
m_textLabel->setText(
|
|
Shinya Kitaoka |
120a6e |
tr("Delete %1 items.")
|
|
Shinya Kitaoka |
120a6e |
.arg(m_files.size() - m_sceneIconAdded + m_sceneResources.size()));
|
|
Toshihiro Shimizu |
890ddd |
}
|