641 lines
18 KiB
C++
641 lines
18 KiB
C++
#include "creatprintbmp.h"
|
||
|
||
CreatPrintBmp::CreatPrintBmp(QObject *parent) : QObject(parent)
|
||
{
|
||
m_savePath.clear();
|
||
m_workState = WORK_PAUSE;
|
||
m_fileBegIdx = -1;
|
||
m_fileEndIdx = -1;
|
||
m_deleteFileIdx = -1;
|
||
m_listFileIdx = -1;//当前生成数据的文件索引
|
||
m_curBmpBlockIdx = -1;//当前生成数据的位图块数索引
|
||
m_mcPrintInfo = NULL;
|
||
m_conpressDir = 1;
|
||
m_printFileDir.clear();
|
||
m_moveFileIdx = -1;//上下移动打印文件索引
|
||
m_moveDir = 0;//-1,上移 1,下移
|
||
m_rotateAngle = 0;
|
||
m_autoDirFilesList.clear();
|
||
}
|
||
|
||
CreatPrintBmp::~CreatPrintBmp()
|
||
{
|
||
if(m_mcPrintInfo != NULL)
|
||
{
|
||
m_mcPrintInfo->clear();
|
||
delete m_mcPrintInfo;
|
||
}
|
||
}
|
||
|
||
int CreatPrintBmp::creatFileListMarker(int idx)
|
||
{
|
||
if(m_workState == WORK_PAUSE)
|
||
{
|
||
return -1;
|
||
}
|
||
|
||
if(m_mcPrintInfo->m_loadFileFinishFlag < 0)
|
||
{
|
||
if(idx >= m_autoDirFilesList.size())
|
||
{
|
||
return -1;
|
||
}
|
||
|
||
QFileInfo fileInfo(m_autoDirFilesList[idx]);
|
||
QString filePath = fileInfo.filePath();
|
||
|
||
int creatDataFlag = 0;//是否已经生成Marker数据的标志
|
||
if(idx < m_mcPrintInfo->m_filesList.size())
|
||
{
|
||
if(m_mcPrintInfo->m_filesList[idx].m_creatDataFlag != 0)
|
||
{
|
||
creatDataFlag = 1;
|
||
}
|
||
}
|
||
|
||
//已经生成数据的跳过
|
||
if(creatDataFlag == 0)
|
||
{
|
||
McFilesInfo curFilesInfo;//当前文件信息
|
||
creatMarkerDat(curFilesInfo,m_printFileDir,filePath,m_listFileIdx,m_rotateAngle);
|
||
long long fileTotalLength = (curFilesInfo.m_fileRect.right() - curFilesInfo.m_fileRect.left())/MMPIXELY;
|
||
m_mcPrintInfo->m_fileNums += 1;
|
||
m_mcPrintInfo->m_fileTotalLength += fileTotalLength;
|
||
m_mcPrintInfo->m_filesList.append(curFilesInfo);
|
||
}
|
||
}
|
||
|
||
if(m_mcPrintInfo->m_loadFileFinishFlag < 0)
|
||
{
|
||
//全部文件Marker数据加载完成
|
||
if(m_mcPrintInfo->m_filesList.size() == m_autoDirFilesList.size())
|
||
{
|
||
m_mcPrintInfo->m_loadFileFinishFlag = 1;
|
||
}
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
int CreatPrintBmp::creatFileListDatAndSend(int idx)
|
||
{
|
||
if(idx >= m_mcPrintInfo->m_filesList.size())
|
||
{
|
||
return -1;
|
||
}
|
||
|
||
McFilesInfo curFilesInfo;
|
||
|
||
if(m_workState == WORK_PAUSE)
|
||
{
|
||
return -1;
|
||
}
|
||
|
||
curFilesInfo = m_mcPrintInfo->m_filesList[idx];
|
||
QString filePath = m_printFileDir + QString::number(m_listFileIdx+1);
|
||
QDir fileDir(filePath);//对应每台机器的每个文件打印目录
|
||
if(!fileDir.exists())
|
||
{
|
||
fileDir.mkdir(filePath);
|
||
}
|
||
filePath = filePath + fileDir.separator();
|
||
|
||
if(curFilesInfo.m_creatDataFlag < 0)
|
||
{
|
||
creatMarkerDat(curFilesInfo,m_printFileDir,m_mcPrintInfo->m_filesList[idx].m_filePath,m_listFileIdx,m_rotateAngle);
|
||
m_mcPrintInfo->m_filesList[idx] = curFilesInfo;
|
||
}
|
||
|
||
QPicture pic;
|
||
|
||
int oft = 0;//起始打印位置的偏移
|
||
pic = m_mcPrintInfo->m_filesList[idx].m_sendPic;
|
||
oft = (int)(m_mcPrintInfo->m_filesList[idx].m_startPoint*MMPIXELY);
|
||
//将picture保存为多个宽度为PIXMAPWIDTH像素的bmp
|
||
m_mcPrintInfo->m_totalNums = (pic.width() - oft) / PIXMAPWIDTH;
|
||
int lwidth = (pic.width() - oft) % (PIXMAPWIDTH);
|
||
if(lwidth != 0)
|
||
{
|
||
m_mcPrintInfo->m_totalNums += 1;
|
||
}
|
||
|
||
m_mcPrintInfo->m_filesList[idx].m_totalBlocks = (pic.width() - oft)/ PIXMAPWIDTH;
|
||
lwidth = (pic.width() - oft) % PIXMAPWIDTH;
|
||
if(lwidth != 0)
|
||
{
|
||
m_mcPrintInfo->m_filesList[idx].m_totalBlocks += 1;
|
||
}
|
||
|
||
m_mcPrintInfo->m_filesList[idx].m_totalBlocks *= m_mcPrintInfo->m_filesList[idx].m_printNum;
|
||
|
||
m_mcPrintInfo->m_filesList[idx].m_printState = Printting;
|
||
|
||
//发送文件列表数据
|
||
emit siSendFileListDatToMc(idx);
|
||
return 0;
|
||
}
|
||
|
||
int CreatPrintBmp::creatBmpBlockDatAndSend(int fileidx, int idx)
|
||
{
|
||
if(m_workState == WORK_PAUSE)
|
||
{
|
||
return -1;
|
||
}
|
||
|
||
QPen pen;
|
||
pen.setWidth(1);
|
||
pen.setColor(QColor(Qt::black));
|
||
|
||
if(m_mcPrintInfo->m_filesList[fileidx].m_printNum <= 0)
|
||
{
|
||
m_mcPrintInfo->m_filesList[fileidx].m_printNum = 1;
|
||
}
|
||
int oneNumCount = m_mcPrintInfo->m_filesList[fileidx].m_totalBlocks / m_mcPrintInfo->m_filesList[fileidx].m_printNum;
|
||
|
||
int nextNum = idx / oneNumCount;
|
||
idx = idx - nextNum * oneNumCount;
|
||
|
||
QPicture pic = m_mcPrintInfo->m_filesList[fileidx].m_sendPic;
|
||
int oft = (int)(m_mcPrintInfo->m_filesList[fileidx].m_startPoint*MMPIXELY);
|
||
|
||
//将picture保存为多个宽度为PIXMAPWIDTH像素的bmp
|
||
int num = (pic.width() - oft) / PIXMAPWIDTH;
|
||
int lwidth = (pic.width() - oft) % PIXMAPWIDTH;
|
||
int height = pic.height();
|
||
int offset = 0 - idx * PIXMAPWIDTH - oft;//将picture画在bmp上每次的偏移量,bmp的最大尺寸为u16
|
||
|
||
if(lwidth != 0)
|
||
{
|
||
num += 1;
|
||
}
|
||
|
||
QBitmap *pixmap = new QBitmap(PIXMAPWIDTH,height);
|
||
QPainter *pixPainter = new QPainter();
|
||
pixPainter->begin(pixmap);
|
||
pixPainter->setPen(pen);
|
||
|
||
QString filePath = m_printFileDir + QString::number(m_listFileIdx+1);
|
||
QDir fileDir(filePath);//对应每台机器的每个文件打印目录
|
||
if(!fileDir.exists())
|
||
{
|
||
fileDir.mkdir(filePath);
|
||
}
|
||
filePath = filePath + fileDir.separator();
|
||
|
||
pixmap->fill(Qt::white);//用白色填充
|
||
pixPainter->drawPicture(offset,0,pic);
|
||
|
||
int cidx = idx + nextNum*oneNumCount;
|
||
QString path = filePath+QString::number(cidx+1)+".bmp";
|
||
bool bls = pixmap->save(path);
|
||
while(bls == false)
|
||
{
|
||
bls = pixmap->save(path);
|
||
qDebug()<<"pixmap save failed";
|
||
}
|
||
|
||
//压缩位图
|
||
BWBmp bwBmp;
|
||
int rslt;
|
||
|
||
rslt = bwBmp.LoadBiBmp(path);
|
||
if (rslt != 0)
|
||
{
|
||
qDebug() << "open file error" << path;
|
||
return -1;
|
||
}
|
||
rslt = bwBmp.Compress(cidx,m_conpressDir);
|
||
if (rslt != 0)
|
||
{
|
||
qDebug() << "Compress error";
|
||
return -1;
|
||
}
|
||
|
||
rslt = bwBmp.SavePrBmp(path+".prbmp");
|
||
if (rslt != 0)
|
||
{
|
||
qDebug() << "save prbmp error";
|
||
return -1;
|
||
}
|
||
QByteArray dat = bwBmp.getPrBmpDat();
|
||
emit siSendDatToMc(dat);
|
||
m_mcPrintInfo->m_filesList[fileidx].m_curPrintBlock = cidx + 1;
|
||
m_mcPrintInfo->m_filesList[fileidx].m_printedBlockNum = cidx;
|
||
m_mcPrintInfo->m_filesList[fileidx].m_leaveBlockNum = m_mcPrintInfo->m_filesList[fileidx].m_totalBlocks - m_mcPrintInfo->m_filesList[fileidx].m_printedBlockNum;
|
||
|
||
//计算机器打印进度
|
||
int fileNum = m_fileEndIdx - m_fileBegIdx;
|
||
int val = 1;
|
||
if(fileNum == 1)//每次只发送一个文件
|
||
{
|
||
val = 0;
|
||
}
|
||
double filePro = (1.0 / (double)fileNum)*m_listFileIdx*val;//发送到第m_listFileIdx个文件的进度
|
||
double blockPro = (double)m_mcPrintInfo->m_filesList[fileidx].m_printedBlockNum / (double)m_mcPrintInfo->m_filesList[fileidx].m_totalBlocks;//发送到第idx个块的进度
|
||
double fBlockPro = (1.0 / (double)fileNum) * blockPro;//发送到第idx个块的进度
|
||
double totalPro = filePro + fBlockPro;//发送到第m_listFileIdx个文件的第idx个块的进度
|
||
m_mcPrintInfo->m_mcSendProgress = totalPro*100.0;
|
||
|
||
//单个文件打印完成
|
||
if(m_mcPrintInfo->m_filesList[fileidx].m_printedBlockNum == m_mcPrintInfo->m_filesList[fileidx].m_totalBlocks)
|
||
{
|
||
m_mcPrintInfo->m_filesList[m_fileBegIdx].m_printState = Complete;
|
||
}
|
||
|
||
emit siRefreshPrintProgress(m_mcPrintInfo->m_mcNum,m_fileBegIdx);
|
||
|
||
m_mcPrintInfo->m_sendedlNums++;
|
||
|
||
pixPainter->end();
|
||
|
||
bool bla = pixPainter->isActive();
|
||
while(bla == true)
|
||
{
|
||
bla = pixPainter->isActive();
|
||
qDebug()<<"pixPainter isActive";
|
||
}
|
||
|
||
delete pixmap;
|
||
delete pixPainter;
|
||
return 0;
|
||
}
|
||
|
||
void CreatPrintBmp::slotCreatBmp()
|
||
{
|
||
#if(1)
|
||
m_curBmpBlockIdx = -1;//当前生成数据的位图块数索引
|
||
int val = creatFileListMarker(m_fileBegIdx);
|
||
if(val < 0)
|
||
{
|
||
return;
|
||
}
|
||
|
||
val = creatFileListDatAndSend(m_fileBegIdx);
|
||
if(val < 0)
|
||
{
|
||
return;
|
||
}
|
||
#else
|
||
QPen pen;
|
||
pen.setWidth(1);
|
||
pen.setColor(QColor(Qt::black));
|
||
|
||
//将picture保存为多个宽度为PIXMAPWIDTH像素的bmp
|
||
int num = m_picture.width() / PIXMAPWIDTH;
|
||
int lwidth = m_picture.width() % PIXMAPWIDTH;
|
||
int height = m_picture.height();
|
||
int offset = 0;
|
||
|
||
if(lwidth != 0)
|
||
{
|
||
num += 1;
|
||
}
|
||
|
||
QBitmap *pixmap = new QBitmap(PIXMAPWIDTH,height);
|
||
QPainter *pixPainter = new QPainter();
|
||
pixPainter->begin(pixmap);
|
||
pixPainter->setPen(pen);
|
||
|
||
for(int i = 0 ; i < num; i++)
|
||
{
|
||
pixmap->fill(Qt::white);//用白色填充
|
||
pixPainter->drawPicture(offset,0,m_picture);
|
||
offset -= PIXMAPWIDTH;
|
||
|
||
QString path = m_savePath+QString::number(i+1)+".bmp";
|
||
bool bls = pixmap->save(path);
|
||
while(bls == false)
|
||
{
|
||
bls = pixmap->save(path);
|
||
qDebug()<<"pixmap save failed";
|
||
}
|
||
|
||
//压缩位图
|
||
BWBmp bwBmp;
|
||
int rslt;
|
||
|
||
rslt = bwBmp.LoadBiBmp(path);
|
||
if (rslt != 0)
|
||
{
|
||
qDebug() << "open file error" << path;
|
||
break;
|
||
}
|
||
rslt = bwBmp.Compress();
|
||
if (rslt != 0)
|
||
{
|
||
qDebug() << "Compress error";
|
||
break;
|
||
}
|
||
|
||
rslt = bwBmp.SavePrBmp(path+".prbmp");
|
||
if (rslt != 0)
|
||
{
|
||
qDebug() << "save prbmp error";
|
||
break;
|
||
}
|
||
QByteArray dat = bwBmp.getPrBmpDat();
|
||
siCreatOneBmpFinished((unsigned char*)dat.data(),dat.size());
|
||
}
|
||
|
||
pixPainter->end();
|
||
|
||
bool bla = pixPainter->isActive();
|
||
while(bla == true)
|
||
{
|
||
bla = pixPainter->isActive();
|
||
qDebug()<<"pixPainter isActive";
|
||
}
|
||
|
||
delete pixmap;
|
||
delete pixPainter;
|
||
#endif
|
||
}
|
||
|
||
void CreatPrintBmp::slotCreatNextBmpBlockDat()
|
||
{
|
||
if(m_mcPrintInfo->m_filesList.size() <= m_fileBegIdx)
|
||
{
|
||
return;
|
||
}
|
||
|
||
m_mcPrintInfo->m_mcWorkState = Busying;
|
||
|
||
m_curBmpBlockIdx++;//一个文件可分为若干个位图块,位图块索引++
|
||
if(m_curBmpBlockIdx < 0)
|
||
{
|
||
m_curBmpBlockIdx = 0;
|
||
}
|
||
|
||
if(m_curBmpBlockIdx >= m_mcPrintInfo->m_filesList[m_fileBegIdx].m_totalBlocks)
|
||
{
|
||
m_listFileIdx++;//文件索引++
|
||
int flag = 0;
|
||
if(m_listFileIdx >= m_fileEndIdx)
|
||
{
|
||
m_mcPrintInfo->m_mcWorkState = NotBusy;//机器完成打印
|
||
m_mcPrintInfo->m_filesList[m_fileBegIdx].m_printedBlockNum = m_mcPrintInfo->m_filesList[m_fileBegIdx].m_totalBlocks;
|
||
m_mcPrintInfo->m_mcSendProgress = 100.0;
|
||
flag = 1;
|
||
}
|
||
emit siOneFilePrintFinished(m_mcPrintInfo->m_mcNum,m_fileBegIdx,flag);
|
||
//如果为自动绘图目录中的文件,删除自动绘图目录文件夹中已打印完成的文件
|
||
QString filePath = m_mcPrintInfo->m_filesList[m_fileBegIdx].m_filePath;
|
||
QDir apppath(qApp->applicationDirPath());
|
||
QString iniName = "MachineNo" + QString::number(m_mcPrintInfo->m_mcNum) + ".ini";
|
||
QString iniPath = apppath.path() + apppath.separator() + iniName;
|
||
QSettings setting(iniPath, QSettings::IniFormat); //QSettings能记录一些程序中的信息,下次再打开时可以读取出来
|
||
QFileInfo info(filePath);
|
||
QString autoFilePath = setting.value("AutoPrintDir/fileDir").toString() + apppath.separator() + info.fileName();
|
||
QFile file(autoFilePath);
|
||
if(file.exists())
|
||
{
|
||
//文件存在
|
||
QFile::remove(autoFilePath);
|
||
if(m_fileBegIdx < m_autoDirFilesList.size())
|
||
{
|
||
m_autoDirFilesList.removeAt(m_fileBegIdx);//删除自动绘图目录文件列表中的文件
|
||
}
|
||
}
|
||
|
||
//m_mcPrintInfo->m_filesList.removeAt(m_fileBegIdx);//删除机器文件列表中已打印完成的文件
|
||
|
||
#if(0)
|
||
//删除此文件的位图存储文件夹
|
||
QString bmpPath = m_printFileDir + QString::number(m_listFileIdx+1);
|
||
QDir bmpDir(bmpPath);//对应每台机器的每个文件打印目录
|
||
if(bmpDir.exists())
|
||
{
|
||
bmpDir.removeRecursively();
|
||
}
|
||
#endif
|
||
|
||
if(m_listFileIdx >= m_fileEndIdx)
|
||
{
|
||
return;
|
||
}
|
||
|
||
// if(flag == 1)
|
||
// {
|
||
// return;
|
||
// }
|
||
// creatFileListMarker(m_fileBegIdx);
|
||
// creatFileListDatAndSend(m_fileBegIdx);
|
||
// m_curBmpBlockIdx = -1;
|
||
return;
|
||
}
|
||
|
||
creatBmpBlockDatAndSend(m_fileBegIdx,m_curBmpBlockIdx);
|
||
m_conpressDir *= -1;
|
||
}
|
||
|
||
void CreatPrintBmp::setPicture(QPicture pic)
|
||
{
|
||
m_picture = pic;
|
||
}
|
||
|
||
void CreatPrintBmp::setPicture(QBitmap bitmap)
|
||
{
|
||
//将图片画在picture上
|
||
QPicture pic;
|
||
QPen pen;
|
||
pen.setWidth(1);//设置笔号
|
||
pen.setColor(QColor(Qt::black));
|
||
|
||
QPainter painter;
|
||
painter.begin(&pic);
|
||
painter.setPen(pen);
|
||
painter.drawPixmap(0,0,bitmap);
|
||
painter.end();
|
||
m_picture = pic;
|
||
}
|
||
|
||
void CreatPrintBmp::setSavePath(QString path)
|
||
{
|
||
m_savePath.clear();
|
||
m_savePath = path;
|
||
}
|
||
|
||
QString CreatPrintBmp::getSavePath()
|
||
{
|
||
return m_savePath;
|
||
}
|
||
|
||
void CreatPrintBmp::setMcPrintInfo(int fileIdx, McPrintInfo *printInfo)
|
||
{
|
||
m_mcPrintInfo = printInfo;
|
||
|
||
if(fileIdx < 0)
|
||
{
|
||
m_fileBegIdx = 0;
|
||
}
|
||
else
|
||
{
|
||
m_fileBegIdx = fileIdx;
|
||
}
|
||
|
||
//是否自动打印
|
||
int autoPrint = 0;
|
||
|
||
if(autoPrint == 1)
|
||
{
|
||
m_fileEndIdx = m_mcPrintInfo->m_filesList.size();
|
||
}
|
||
else
|
||
{
|
||
m_fileEndIdx = m_fileBegIdx + 1;
|
||
}
|
||
|
||
m_listFileIdx = m_fileBegIdx;
|
||
|
||
QDir apppath(qApp->applicationDirPath());
|
||
QString printPath = apppath.path() + apppath.separator() + PRINTDIR;
|
||
QString mcFile = printPath + apppath.separator() + PRINTMCDIR + QString::number(m_mcPrintInfo->m_mcNum);
|
||
m_printFileDir = mcFile + apppath.separator() + PRINTFILEDIR;
|
||
m_workState = WORK_START;
|
||
|
||
m_autoDirFilesList.clear();
|
||
if(m_mcPrintInfo->m_loadFileFinishFlag < 0)
|
||
{
|
||
QString iniName = "MachineNo" + QString::number(m_mcPrintInfo->m_mcNum) + ".ini";
|
||
QString iniPath = apppath.path() + apppath.separator() + iniName;
|
||
QSettings setting(iniPath, QSettings::IniFormat); //QSettings能记录一些程序中的信息,下次再打开时可以读取出来
|
||
QString dirPath = setting.value("AutoPrintDir/fileDir").toString();
|
||
QDir dir(dirPath);
|
||
if(dir.exists())
|
||
{
|
||
QStringList filter;
|
||
filter << QString("*.plt") << QString("*.PLT")
|
||
<< QString("*.png") << QString("*.PNG")
|
||
<< QString("*.bmp") << QString("*.BMP")
|
||
<< QString("*.jpg") << QString("*.JPG");
|
||
m_autoDirFilesList = dir.entryInfoList(filter, QDir::Files | QDir::NoSymLinks);
|
||
}
|
||
}
|
||
|
||
QDir printDir(printPath);//总的打印目录
|
||
if(!printDir.exists())
|
||
{
|
||
printDir.mkdir(printPath);
|
||
}
|
||
QDir mcDir(mcFile);//对应每台机器打印目录
|
||
if(!mcDir.exists())
|
||
{
|
||
mcDir.mkdir(mcFile);
|
||
}
|
||
m_curBmpBlockIdx = -1;//当前生成数据的位图块数索引
|
||
}
|
||
|
||
void CreatPrintBmp::stopCreatPrintDat()
|
||
{
|
||
m_workState = WORK_PAUSE;
|
||
}
|
||
|
||
void CreatPrintBmp::setDeleteFile(McPrintInfo *printInfo, int fileIdx)
|
||
{
|
||
if(m_mcPrintInfo == NULL)
|
||
{
|
||
m_mcPrintInfo = printInfo;
|
||
}
|
||
|
||
if(fileIdx == m_fileBegIdx)
|
||
{
|
||
return;
|
||
}
|
||
m_deleteFileIdx = fileIdx;
|
||
|
||
if(m_deleteFileIdx != m_fileBegIdx && m_deleteFileIdx != -1)
|
||
{
|
||
int length = (m_mcPrintInfo->m_filesList[m_deleteFileIdx].m_fileRect.right() - m_mcPrintInfo->m_filesList[m_deleteFileIdx].m_fileRect.left())/MMPIXELY;
|
||
m_mcPrintInfo->m_fileTotalLength -= length;
|
||
|
||
QString mcFile = m_printFileDir + QString::number(m_deleteFileIdx+1);
|
||
QDir fileDir(mcFile);
|
||
if(fileDir.exists())
|
||
{
|
||
//删除位图文件夹
|
||
fileDir.removeRecursively();
|
||
}
|
||
|
||
//如果为自动绘图目录中的文件,删除自动绘图目录文件夹中已打印完成的文件
|
||
QString filePath = m_mcPrintInfo->m_filesList[m_deleteFileIdx].m_filePath;
|
||
QDir apppath(qApp->applicationDirPath());
|
||
QString iniName = "MachineNo" + QString::number(m_mcPrintInfo->m_mcNum) + ".ini";
|
||
QString iniPath = apppath.path() + apppath.separator() + iniName;
|
||
QSettings setting(iniPath, QSettings::IniFormat); //QSettings能记录一些程序中的信息,下次再打开时可以读取出来
|
||
QString dirPath = setting.value("AutoPrintDir/fileDir").toString();
|
||
QDir dir(dirPath);
|
||
if(dir.exists(filePath))
|
||
{
|
||
//文件存在
|
||
QFile::remove(filePath);
|
||
if(m_deleteFileIdx < m_autoDirFilesList.size())
|
||
{
|
||
m_autoDirFilesList.removeAt(m_deleteFileIdx);//删除自动绘图目录文件列表中的文件
|
||
}
|
||
}
|
||
|
||
m_mcPrintInfo->m_filesList[m_deleteFileIdx].clear();
|
||
m_mcPrintInfo->m_filesList.removeAt(m_deleteFileIdx);
|
||
|
||
m_mcPrintInfo->m_fileNums = m_mcPrintInfo->m_filesList.size();
|
||
m_deleteFileIdx = -1;
|
||
}
|
||
}
|
||
|
||
void CreatPrintBmp::setMoveFile(McPrintInfo *printInfo, int fileIdx, int dir)
|
||
{
|
||
if(m_mcPrintInfo == NULL)
|
||
{
|
||
m_mcPrintInfo = printInfo;
|
||
}
|
||
|
||
if(fileIdx == m_fileBegIdx)
|
||
{
|
||
return;
|
||
}
|
||
m_moveFileIdx = fileIdx;//上下移动打印文件索引
|
||
m_moveDir = dir;//-1,上移 1,下移
|
||
|
||
//非正在打印的文件,正在发送文件时的上下移操作
|
||
if(m_moveFileIdx != m_fileBegIdx && m_moveFileIdx != -1 && m_moveDir != 0)
|
||
{
|
||
//交换列表
|
||
McFilesInfo info = m_mcPrintInfo->m_filesList[fileIdx];
|
||
QFileInfo fileInfo;
|
||
if(fileIdx < m_autoDirFilesList.size())
|
||
{
|
||
fileInfo = m_autoDirFilesList[fileIdx];
|
||
}
|
||
McFilesInfo cInfo;
|
||
QFileInfo cFileInfo;
|
||
if(dir == -1)
|
||
{
|
||
cInfo = m_mcPrintInfo->m_filesList[fileIdx-1];
|
||
m_mcPrintInfo->m_filesList[fileIdx-1] = info;
|
||
|
||
cFileInfo = m_autoDirFilesList[fileIdx-1];
|
||
m_autoDirFilesList[fileIdx-1] = fileInfo;
|
||
}
|
||
else
|
||
{
|
||
cInfo = m_mcPrintInfo->m_filesList[fileIdx+1];
|
||
m_mcPrintInfo->m_filesList[fileIdx+1] = info;
|
||
|
||
if(fileIdx+1 < m_autoDirFilesList.size())
|
||
{
|
||
cFileInfo = m_autoDirFilesList[fileIdx+1];
|
||
m_autoDirFilesList[fileIdx+1] = fileInfo;
|
||
}
|
||
}
|
||
|
||
m_mcPrintInfo->m_filesList[fileIdx] = cInfo;
|
||
if(fileIdx < m_autoDirFilesList.size())
|
||
{
|
||
m_autoDirFilesList[fileIdx] = cFileInfo;
|
||
}
|
||
|
||
m_moveFileIdx = -1;//上下移动打印文件索引
|
||
m_moveDir = 0;//-1,上移 1,下移
|
||
}
|
||
}
|