68 importDoc->setFileBatchMode(
true);
70 const bool usingPredefinedTimes = !optionalKeyframeTimeList.isEmpty() && !autoAddHoldframes;
71 QQueue<int> predefinedFrameQueue;
72 predefinedFrameQueue.append(optionalKeyframeTimeList);
75 int frame = usingPredefinedTimes ? predefinedFrameQueue.dequeue() : firstFrame;
76 int filesProcessed = 0;
78 if (usingPredefinedTimes) {
79 KIS_ASSERT(files.count() == optionalKeyframeTimeList.count());
83 m_d->updater->setRange(0, files.size());
86 QPair<KisPaintLayerSP, KisRasterKeyframeChannel*> layerRasterChannelPair;
88 const QRegularExpression rx(QLatin1String(
"(\\d+)"));
91 QRegularExpressionMatchIterator i = rx.globalMatch(files.at(0));
93 QRegularExpressionMatch match = i.next();
94 fileNumberRxList << match.captured(1);
97 int firstFrameNumber = 0;
100 if (!fileNumberRxList.isEmpty()) {
101 fileNumberRxList.last().toInt(&ok);
105 if (firstFrameNumber == 0){
109 fileNumberRxList.clear();
110 const int offset = (startfrom0 ? 1 : 0);
115 Q_FOREACH(QString file, files) {
119 if ( (!usingPredefinedTimes && frame == firstFrame)
120 || (usingPredefinedTimes && frame == optionalKeyframeTimeList.first()) ) {
125 if (
m_d->updater->interrupted()) {
128 m_d->updater->setValue(filesProcessed + 1);
132 qApp->processEvents();
142 importDoc->image()->projection()->crop(
m_d->image->bounds());
144 importDoc->image()->projection()->purgeDefaultPixels();
148 if (!autoAddHoldframes) {
149 layerRasterChannelPair.second->importFrame(frame, importDoc->image()->projection(), NULL);
151 QRegularExpressionMatchIterator i = rx.globalMatch(file);
152 while (i.hasNext()) {
153 QRegularExpressionMatch match = i.next();
154 fileNumberRxList << match.captured(1);
157 int filenum = fileNumberRxList.last().toInt(&ok);
159 if (isAscending == 0) {
160 autoframe = firstFrame + filenum - offset;
162 autoframe = firstFrame + (firstFrameNumber - filenum);
166 layerRasterChannelPair.second->importFrame(autoframe , importDoc->image()->projection(), NULL);
169 layerRasterChannelPair.second->importFrame(autoframe + 1, importDoc->image()->projection(), NULL);
171 fileNumberRxList.clear();
174 if (usingPredefinedTimes && predefinedFrameQueue.count()) {
175 frame = predefinedFrameQueue.dequeue();
183 if (layerRasterChannelPair.first && assignDocumentProfile) {
185 if (layerRasterChannelPair.first->colorSpace()->colorModelId() ==
m_d->image->colorSpace()->colorModelId()) {
187 const KoColorSpace *srcColorSpace = layerRasterChannelPair.first->colorSpace();
191 ,
m_d->image->colorSpace()->profile());
194 visitor->
visit(layerRasterChannelPair.first.data(), undo);
KisImportExportErrorCode import(QStringList files, int firstFrame, int step, bool autoAddHoldframes=false, bool startfrom0=false, int isAscending=0, bool assignDocumentProfile=false, QList< int > optionalKeyframeTimeList={})