Skip to content

Commit

Permalink
修正了处理不包含dcm的zip的bug
Browse files Browse the repository at this point in the history
修正了已关闭log窗口,后面重新提示的bug
  • Loading branch information
test authored and test committed May 30, 2020
1 parent 8e30ada commit 5ffc506
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 39 deletions.
96 changes: 58 additions & 38 deletions Anonymizer/Anonymizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ void Anonymizer::closeEvent(QCloseEvent *event)
event->ignore();
}
else if (button == QMessageBox::Yes) {
LogBrowserWindow.close();
if (LogBrowserWindow.is_open)
{
LogBrowserWindow.close();
}
event->accept();
}
}
Expand Down Expand Up @@ -259,21 +262,8 @@ void Anonymizer::anonymizeZip(QString folderChoose, QFileInfoList zipList)
{
QString createUnzipDir = folderChoose + "/unzip_temp/";
QDir dir;
if (!dir.exists(createUnzipDir))
{
bool res = dir.mkdir(createUnzipDir);
if (res)
{
std::cout << "create folder: " << createUnzipDir.toStdString() << std::endl;
LogBrowserWindow.printLog(mZlib.str2qstr("<font color = '#389fff'>create folder: </font>" + createUnzipDir.toStdString()));
}
}
else
{
dir.rmdir(createUnzipDir);
}


std::string createUnzipDir_str = mZlib.qstr2str(createUnzipDir);
const char *uncompressPath_char = createUnzipDir_str.c_str();
std::cout << uncompressPath_char << std::endl;
Expand All @@ -293,6 +283,20 @@ void Anonymizer::anonymizeZip(QString folderChoose, QFileInfoList zipList)
}
for (int i = 0; i != zipList.size(); i++)
{
if (!dir.exists(createUnzipDir))
{
bool res = dir.mkdir(createUnzipDir);
if (res)
{
std::cout << "create folder: " << createUnzipDir.toStdString() << std::endl;
LogBrowserWindow.printLog(mZlib.str2qstr("<font color = '#389fff'>create folder: </font>" + createUnzipDir.toStdString()));
}
}
else
{
dir.rmdir(createUnzipDir);
}

QApplication::processEvents();
ui.progressBar_2->setValue(100 * (i + 1) / zipList.size());
std::string zipPath_str = zipList.at(i).absoluteFilePath().toStdString();
Expand All @@ -310,39 +314,55 @@ void Anonymizer::anonymizeZip(QString folderChoose, QFileInfoList zipList)
LogBrowserWindow.printError(mZlib.str2qstr("<font color = 'red'><b> error to uncompress : </b></font>" + std::string(zipPath_str)));
}

QFileInfoList zipDcmList;

if (succd)
{
nameFiltersDcm << "*.dcm";
QFileInfoList zipDcmList = getFileList(uncompressPath_char, nameFiltersDcm);
DCMTK_anonymizeDcm(uncompressPath_char, zipDcmList);


zipDcmList = getFileList(uncompressPath_char, nameFiltersDcm);
if (zipDcmList.size() == 0)
{
ui.progressBar->setValue(100);
}
else
{
DCMTK_anonymizeDcm(uncompressPath_char, zipDcmList);

nameFiltersAllSuffix << "*.*";
QFileInfoList zipFileList = getFileList(uncompressPath_char, nameFiltersAllSuffix);

mZlib.Compress(zipFileList, compressPath_char, uncompressPath_char);




nameFiltersAllSuffix << "*.*";
QFileInfoList zipFileList = getFileList(uncompressPath_char, nameFiltersAllSuffix);

mZlib.Compress(zipFileList, compressPath_char, uncompressPath_char);
}
}

// d.setFilter(QDir::Files);
// int j, k = d.count() - 1;
// for (j = 0;j <= k;j++)
// {
// if (! d.remove(d[j]))
// {
// LogBrowserWindow.printLog(mZlib.str2qstr("<font color = 'red'><b> error to remove file: </b><font>") + d[j]);
// LogBrowserWindow.printError(mZlib.str2qstr("<font color = 'red'><b> error to remove file: </b><font>") + d[j]);
// }
// }
QDir d(uncompressPath_char);
d.setFilter(QDir::Files);
int j, k = d.count() - 1;
for (j = 0;j <= k;j++)
if (d.removeRecursively())
{
if (! d.remove(d[j]))
{
LogBrowserWindow.printLog(mZlib.str2qstr("<font color = 'red'><b> error to remove file: </b><font>") + d[j]);
LogBrowserWindow.printError(mZlib.str2qstr("<font color = 'red'><b> error to remove file: </b><font>") + d[j]);
}
std::cout << "removed temp files" << std::endl;
LogBrowserWindow.printLog(mZlib.str2qstr("<font color = '#389fff'>removed temp files</font>"));
}

std::cout << "removed temp files" << std::endl;
LogBrowserWindow.printLog(mZlib.str2qstr("<font color = '#389fff'>removed temp files</font>"));

removeFile(zipPath_str.c_str());
renameFile(compressPath_char, zipPath_str.c_str());

if (zipDcmList.size() != 0)
{
removeFile(zipPath_str.c_str());
renameFile(compressPath_char, zipPath_str.c_str());
}
}
dir.rmdir(uncompressPath_char);// this method only suitable for empty folder
//dir.rmdir(uncompressPath_char);// this method only suitable for empty folder
}

void Anonymizer::anonymizeNoSuffix(QString folderChoose)
Expand Down
2 changes: 2 additions & 0 deletions Anonymizer/LogBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ void LogBrowser::closeEvent(QCloseEvent *event)

if (button == QMessageBox::No) {
event->ignore();
is_open = true;
}
else if (button == QMessageBox::Yes) {
event->accept();
is_open = false;
}

}
Expand Down
3 changes: 2 additions & 1 deletion Anonymizer/LogBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ class LogBrowser : public QMainWindow
void printLog(QString logQStr);
void printError(QString errQStr);
Ui::LogBrowser ui;
bool is_open = true;

private:
void closeEvent(QCloseEvent *event);
void closeEvent(QCloseEvent *event);//函数重写。重写基类函数

};
3 changes: 3 additions & 0 deletions Anonymizer/LogBrowser.ui
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<property name="windowTitle">
<string>LogBrowser</string>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QTextBrowser" name="logTextBrowser">
<property name="geometry">
Expand Down
Binary file modified LICENSE
Binary file not shown.

0 comments on commit 5ffc506

Please sign in to comment.