MCPcopy Create free account
hub / github.com/IENT/YUView / fillImageFileList

Method fillImageFileList

YUViewLib/src/playlistitem/playlistItemImageFileSequence.cpp:94–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94void playlistItemImageFileSequence::fillImageFileList(QStringList & imageFiles,
95 const QString &filePath)
96{
97 // See if the filename ends with a number
98 QFileInfo fi(filePath);
99 QString fileName = fi.fileName();
100 QString base = fi.baseName();
101
102 int lastN = 0;
103 for (auto i = base.size() - 1; i >= 0; i--)
104 {
105 // Get the char and see if it is a number
106 if (base[i].isDigit())
107 lastN++;
108 else
109 break;
110 }
111
112 if (lastN == 0)
113 {
114 // No number at the end of the file name
115 imageFiles.append(filePath);
116 return;
117 }
118
119 // The base name without the indexing number at the end
120 QString absBaseName = base.left(base.size() - lastN);
121
122 // List all files in the directory and get all that have the same pattern.
123 QDir currentDir(fi.path());
124 const QFileInfoList fileList = currentDir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot);
125 QMap<int, QString> unsortedFiles;
126 for (auto &file : fileList)
127 {
128 if (file.baseName().startsWith(absBaseName) && file.suffix() == fi.suffix())
129 {
130 // Check if the remaining part is all digits
131 QString remainder = file.baseName().right(file.baseName().length() - absBaseName.length());
132 bool isNumber;
133 int num = remainder.toInt(&isNumber);
134 if (isNumber)
135 unsortedFiles.insert(num, file.absoluteFilePath());
136 }
137 }
138
139 int count = unsortedFiles.count();
140 int i = 0;
141 while (count > 0 && i < INT_MAX)
142 {
143 if (unsortedFiles.contains(i))
144 {
145 imageFiles.append(unsortedFiles[i]);
146 count--;
147 }
148 i++;
149 }
150}
151

Callers

nothing calls this directly

Calls 3

appendMethod · 0.80
containsMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected