MCPcopy Create free account
hub / github.com/cxasm/notepad-- / changeFileExt

Method changeFileExt

src/renamewin.cpp:311–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

309}
310
311void ReNameWin::changeFileExt()
312{
313 QString dealDir = ui.lineEditDir->text();
314 QString destExt = ui.lineEditDestExt->text();
315 if (destExt.startsWith('.'))
316 {
317 destExt = destExt.mid(1, destExt.length() - 1);
318 }
319
320 if (dealDir.isEmpty() || destExt.isEmpty())
321 {
322 QMessageBox::warning(this, tr("Notice"), tr("Please Select Dir Or Dest Ext"));
323 return;
324 }
325
326 QString filterExt;
327 bool isNeedFilterExt = false;
328
329 if (0 != ui.comboBoxExt->currentIndex())
330 {
331 filterExt = ui.comboBoxExt->currentText();
332
333 if (filterExt.startsWith('.'))
334 {
335 filterExt = filterExt.mid(1, filterExt.length() - 1);
336 }
337 }
338 //检查是否需要过滤只处理ext类型
339 if (!filterExt.isEmpty())
340 {
341 isNeedFilterExt = true;
342 }
343
344 QList<QString> dirsList;
345 dirsList.append(dealDir);
346
347 int fileNums = 0;
348 int failNums = 0;
349 bool dealChildDir = ui.checkBoxDealChildDir->isChecked();
350
351 QString oldName;
352 QString newName;
353
354 auto getNewName = [](QString oldName, const QString& destExt)->QString{
355
356 QFileInfo fi(oldName);
357
358 //没有后缀名,则不修改
359 if (fi.suffix().isEmpty())
360 {
361 return QString();
362 }
363 int oldExtSize = fi.suffix().length();
364
365 return QString("%1%2").arg(oldName.mid(0, oldName.size()-oldExtSize)).arg(destExt);
366 };
367
368 ProgressWin* m_loadFileProcessWin = new ProgressWin(this);

Callers

nothing calls this directly

Calls 9

isEmptyMethod · 0.80
appendMethod · 0.80
suffixMethod · 0.80
infoMethod · 0.80
setTotalStepsMethod · 0.80
moveStepMethod · 0.80
textMethod · 0.45
lengthMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected