Changeset 119 for smplayer/trunk/src/helper.cpp
- Timestamp:
- Dec 27, 2011, 5:44:12 PM (14 years ago)
- Location:
- smplayer/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
smplayer/trunk
-
Property svn:mergeinfo
set to
/smplayer/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
smplayer/trunk/src/helper.cpp
r112 r119 1 1 /* smplayer, GUI front-end for mplayer. 2 Copyright (C) 2006-201 0Ricardo Villalba <rvm@escomposlinux.org>2 Copyright (C) 2006-2011 Ricardo Villalba <rvm@escomposlinux.org> 3 3 4 4 This program is free software; you can redistribute it and/or modify … … 200 200 201 201 QStringList files_to_add; 202 QStringList matching_files; 202 203 203 204 QFileInfo fi(initial_file); … … 206 207 QString path = fi.absolutePath(); 207 208 208 QRegExp rx("^.*(\\d+)"); 209 210 if ( rx.indexIn(basename) > -1) { 211 int digits = rx.cap(1).length(); 212 int current_number = rx.cap(1).toInt(); 213 214 //qDebug("Helper::searchForConsecutiveFiles: filename ends with a number (%s)", rx.cap(1).toUtf8().constData()); 215 qDebug("Helper::searchForConsecutiveFiles: filename ends with a number (%d)", current_number); 216 qDebug("Helper::searchForConsecutiveFiles: trying to find consecutive files"); 217 218 QString template_name = path + "/" + basename.left(basename.length() - digits); 219 //qDebug("BaseGui::newMediaLoaded: name without digits: '%s'", template_name.toUtf8().constData()); 220 221 current_number++; 222 QString next_name = template_name + QString("%1").arg(current_number, digits, 10, QLatin1Char('0')) +"."+ extension; 223 qDebug("Helper::searchForConsecutiveFiles: looking for '%s'", next_name.toUtf8().constData()); 224 225 while (QFile::exists(next_name)) { 226 qDebug("Helper::searchForConsecutiveFiles: '%s' exists, added to the list", next_name.toUtf8().constData()); 227 files_to_add.append(next_name); 209 QDir dir(path); 210 dir.setFilter(QDir::Files); 211 dir.setSorting(QDir::Name); 212 213 QRegExp rx("(\\d+)"); 214 215 int digits; 216 int current_number; 217 int pos = 0; 218 QString next_name; 219 bool next_found = false; 220 qDebug("Helper::searchForConsecutiveFiles: trying to find consecutive files"); 221 while ( ( pos = rx.indexIn(basename, pos) ) != -1 ) { 222 qDebug("Helper::searchForConsecutiveFiles: captured: %s",rx.cap(1).toStdString().c_str()); 223 digits = rx.cap(1).length(); 224 current_number = rx.cap(1).toInt() + 1; 225 next_name = basename.left(pos) + QString("%1").arg(current_number, digits, 10, QLatin1Char('0')); 226 next_name.replace(QRegExp("([\\[\\]?*])"), "[\\1]"); 227 next_name += "*." + extension; 228 qDebug("Helper::searchForConsecutiveFiles: next name = %s",next_name.toStdString().c_str()); 229 matching_files = dir.entryList((QStringList)next_name); 230 231 if ( !matching_files.isEmpty() ) { 232 next_found = true; 233 break; 234 } 235 qDebug("Helper::searchForConsecutiveFiles: pos = %d",pos); 236 pos += digits; 237 } 238 239 if (next_found) { 240 qDebug("Helper::searchForConsecutiveFiles: adding consecutive files"); 241 while ( !matching_files.isEmpty() ) { 242 qDebug("Helper::searchForConsecutiveFiles: '%s' exists, added to the list", matching_files[0].toUtf8().constData()); 243 files_to_add << path + "/" + matching_files[0]; 228 244 current_number++; 229 next_name = template_name + QString("%1").arg(current_number, digits, 10, QLatin1Char('0')) +"."+ extension; 245 next_name = basename.left(pos) + QString("%1").arg(current_number, digits, 10, QLatin1Char('0')); 246 next_name.replace(QRegExp("([\\[\\]?*])"), "[\\1]"); 247 next_name += "*." + extension; 248 matching_files = dir.entryList((QStringList)next_name); 230 249 qDebug("Helper::searchForConsecutiveFiles: looking for '%s'", next_name.toUtf8().constData()); 231 250 }
Note:
See TracChangeset
for help on using the changeset viewer.