| 1604 | } |
| 1605 | |
| 1606 | void MainWindowViewer::getSiblingComics(QString path, QString currentComic) |
| 1607 | { |
| 1608 | QDir d(path); |
| 1609 | d.setFilter(QDir::Files | QDir::NoDotAndDotDot); |
| 1610 | #ifndef use_unarr |
| 1611 | d.setNameFilters(QStringList() << "*.cbr" |
| 1612 | << "*.cbz" |
| 1613 | << "*.rar" |
| 1614 | << "*.zip" |
| 1615 | << "*.tar" |
| 1616 | << "*.pdf" |
| 1617 | << "*.7z" |
| 1618 | << "*.cb7" |
| 1619 | << "*.arj" |
| 1620 | << "*.cbt"); |
| 1621 | #else |
| 1622 | d.setNameFilters(QStringList() << "*.cbr" |
| 1623 | << "*.cbz" |
| 1624 | << "*.rar" |
| 1625 | << "*.zip" |
| 1626 | << "*.tar" |
| 1627 | << "*.pdf" |
| 1628 | #if (UNARR_API_VERSION >= 110) |
| 1629 | << "*.7z" |
| 1630 | << "*.cb7" |
| 1631 | #endif |
| 1632 | << "*.cbt"); |
| 1633 | #endif |
| 1634 | d.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware); |
| 1635 | QStringList list = d.entryList(); |
| 1636 | std::sort(list.begin(), list.end(), naturalSortLessThanCI); |
| 1637 | int index = list.indexOf(currentComic); |
| 1638 | if (index == -1) // comic not found |
| 1639 | { |
| 1640 | /*QFile f(QCoreApplication::applicationDirPath()+"/errorLog.txt"); |
| 1641 | if(!f.open(QIODevice::WriteOnly)) |
| 1642 | { |
| 1643 | QMessageBox::critical(NULL,tr("Saving error log file...."),tr("There was a problem saving YACReader error log file. Please, check if you have enough permissions in the YACReader root folder.")); |
| 1644 | } |
| 1645 | else |
| 1646 | { |
| 1647 | QTextStream txtS(&f); |
| 1648 | txtS << "METHOD : MainWindowViewer::getSiblingComics" << '\n'; |
| 1649 | txtS << "ERROR : current comic not found in its own path" << '\n'; |
| 1650 | txtS << path << '\n'; |
| 1651 | txtS << currentComic << '\n'; |
| 1652 | txtS << "Comic list count : " + list.count() << '\n'; |
| 1653 | for (const QString &s : std::as_const(list)) { |
| 1654 | txtS << s << '\n'; |
| 1655 | } |
| 1656 | f.close(); |
| 1657 | }*/ |
| 1658 | } |
| 1659 | |
| 1660 | previousComicPath = nextComicPath = ""; |
| 1661 | if (index > 0) { |
| 1662 | previousComicPath = path + "/" + list.at(index - 1); |
| 1663 | } |