55{
56
57
58
59
60
61
62 Q_ASSERT(step > 0);
63
66
68 importDoc->setFileBatchMode(true);
69
70 const bool usingPredefinedTimes = !optionalKeyframeTimeList.isEmpty() && !autoAddHoldframes;
71 QQueue<int> predefinedFrameQueue;
72 predefinedFrameQueue.append(optionalKeyframeTimeList);
73
75 int frame = usingPredefinedTimes ? predefinedFrameQueue.dequeue() : firstFrame;
76 int filesProcessed = 0;
77
78 if (usingPredefinedTimes) {
79 KIS_ASSERT(files.count() == optionalKeyframeTimeList.count());
80 }
81
83 m_d->updater->setRange(0, files.size());
84 }
85
86 QPair<KisPaintLayerSP, KisRasterKeyframeChannel*> layerRasterChannelPair;
87
88 const QRegularExpression rx(QLatin1String("(\\d+)"));
90
91 QRegularExpressionMatchIterator i = rx.globalMatch(files.at(0));
92 while (i.hasNext()) {
93 QRegularExpressionMatch match = i.next();
94 fileNumberRxList << match.captured(1);
95 }
96
97 int firstFrameNumber = 0;
98 bool ok;
99
100 if (!fileNumberRxList.isEmpty()) {
101 fileNumberRxList.last().toInt(&ok);
102
103 }
104
105 if (firstFrameNumber == 0){
106 startfrom0 = false;
107 }
108
109 fileNumberRxList.clear();
110 const int offset = (startfrom0 ? 1 : 0);
111 int autoframe = 0;
112
114
115 Q_FOREACH(QString file, files) {
118
119 if ( (!usingPredefinedTimes && frame == firstFrame)
120 || (usingPredefinedTimes && frame == optionalKeyframeTimeList.first()) ) {
122 }
123
125 if (
m_d->updater->interrupted()) {
127 } else {
128 m_d->updater->setValue(filesProcessed + 1);
129
130
131
132 qApp->processEvents();
133 }
134 }
135
138 break;
139 }
140
141 if (cfg.trimFramesImport()) {
142 importDoc->image()->projection()->crop(
m_d->image->bounds());
143 }
144 importDoc->image()->projection()->purgeDefaultPixels();
145
147
148 if (!autoAddHoldframes) {
149 layerRasterChannelPair.second->importFrame(frame, importDoc->image()->projection(), NULL);
150 } else {
151 QRegularExpressionMatchIterator i = rx.globalMatch(file);
152 while (i.hasNext()) {
153 QRegularExpressionMatch match = i.next();
154 fileNumberRxList << match.captured(1);
155 }
156
157 int filenum = fileNumberRxList.last().toInt(&ok);
158
159 if (isAscending == 0) {
160 autoframe = firstFrame + filenum - offset;
161 } else {
162 autoframe = firstFrame + (firstFrameNumber - filenum);
163 }
164
165 if (ok) {
166 layerRasterChannelPair.second->importFrame(autoframe , importDoc->image()->projection(), NULL);
167 } else {
168
169 layerRasterChannelPair.second->importFrame(autoframe + 1, importDoc->image()->projection(), NULL);
170 }
171 fileNumberRxList.clear();
172 }
173
174 if (usingPredefinedTimes && predefinedFrameQueue.count()) {
175 frame = predefinedFrameQueue.dequeue();
176 } else {
177 frame += step;
178 }
179
180 filesProcessed++;
181 }
182
183 if (layerRasterChannelPair.first && assignDocumentProfile) {
184
185 if (layerRasterChannelPair.first->colorSpace()->colorModelId() ==
m_d->image->colorSpace()->colorModelId()) {
186
187 const KoColorSpace *srcColorSpace = layerRasterChannelPair.first->colorSpace();
191 ,
m_d->image->colorSpace()->profile());
192
194 visitor->
visit(layerRasterChannelPair.first.data(), undo);
195 }
196 }
197
199
200 return status;
201}
QPair< KisPaintLayerSP, class KisRasterKeyframeChannel * > initializePaintLayer(QScopedPointer< KisDocument > &doc, class KisUndoAdapter *undoAdapter)
void visit(KisTransformMask *mask, KisUndoAdapter *undoAdapter) override
static KisPart * instance()
virtual KoID colorModelId() const =0
virtual KoID colorDepthId() const =0
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
KisDocument * createDocument(QList< KisNodeSP > nodes, KisImageSP srcImage, const QRect &copiedBounds)
KUndo2MagicString kundo2_i18n(const char *text)
QAction * undo(const QObject *recvr, const char *slot, QObject *parent)
const KoColorSpace * colorSpace(const QString &colorModelId, const QString &colorDepthId, const KoColorProfile *profile)
static KoColorSpaceRegistry * instance()