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 QRegExp rx(QLatin1String("(\\d+)"));
90
91 int pos = 0;
92
93 while ((pos = rx.indexIn(files.at(0), pos)) != -1) {
94 fileNumberRxList << rx.cap(1);
95 pos += rx.matchedLength();
96 }
97
98 int firstFrameNumber = 0;
99 bool ok;
100
101 if (!fileNumberRxList.isEmpty()) {
102 fileNumberRxList.last().toInt(&ok);
103
104 }
105
106 if (firstFrameNumber == 0){
107 startfrom0 = false;
108 }
109
110 fileNumberRxList.clear();
111 const int offset = (startfrom0 ? 1 : 0);
112 int autoframe = 0;
113
115
116 Q_FOREACH(QString file, files) {
119
120 if ( (!usingPredefinedTimes && frame == firstFrame)
121 || (usingPredefinedTimes && frame == optionalKeyframeTimeList.first()) ) {
123 }
124
126 if (
m_d->updater->interrupted()) {
128 } else {
129 m_d->updater->setValue(filesProcessed + 1);
130
131
132
133 qApp->processEvents();
134 }
135 }
136
139 break;
140 }
141
142 if (cfg.trimFramesImport()) {
143 importDoc->image()->projection()->crop(
m_d->image->bounds());
144 }
145 importDoc->image()->projection()->purgeDefaultPixels();
146
148
149 if (!autoAddHoldframes) {
150 layerRasterChannelPair.second->importFrame(frame, importDoc->image()->projection(), NULL);
151 } else {
152 pos = 0;
153
154 while ((pos = rx.indexIn(file, pos)) != -1) {
155 fileNumberRxList << rx.cap(1);
156 pos += rx.matchedLength();
157 }
158
159 int filenum = fileNumberRxList.last().toInt(&ok);
160
161 if (isAscending == 0) {
162 autoframe = firstFrame + filenum - offset;
163 } else {
164 autoframe = firstFrame + (firstFrameNumber - filenum);
165 }
166
167 if (ok) {
168 layerRasterChannelPair.second->importFrame(autoframe , importDoc->image()->projection(), NULL);
169 } else {
170
171 layerRasterChannelPair.second->importFrame(autoframe + 1, importDoc->image()->projection(), NULL);
172 }
173 fileNumberRxList.clear();
174 }
175
176 if (usingPredefinedTimes && predefinedFrameQueue.count()) {
177 frame = predefinedFrameQueue.dequeue();
178 } else {
179 frame += step;
180 }
181
182 filesProcessed++;
183 }
184
185 if (layerRasterChannelPair.first && assignDocumentProfile) {
186
187 if (layerRasterChannelPair.first->colorSpace()->colorModelId() ==
m_d->image->colorSpace()->colorModelId()) {
188
189 const KoColorSpace *srcColorSpace = layerRasterChannelPair.first->colorSpace();
193 ,
m_d->image->colorSpace()->profile());
194
196 visitor->
visit(layerRasterChannelPair.first.data(), undo);
197 }
198 }
199
201
202 return status;
203}
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()