MCPcopy Create free account
hub / github.com/KDE/okular / open

Method open

generators/comicbook/document.cpp:59–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59bool Document::open(const QString &fileName)
60{
61 close();
62
63 QMimeDatabase db;
64 const QMimeType mime = db.mimeTypeForFile(fileName, QMimeDatabase::MatchContent);
65
66 /**
67 * We have a zip archive
68 */
69 if (mime.inherits(QStringLiteral("application/x-cbz")) || mime.inherits(QStringLiteral("application/zip"))) {
70 mArchive = new KZip(fileName);
71
72 if (!processArchive()) {
73 return false;
74 }
75 /**
76 * We have a TAR archive
77 */
78 } else if (mime.inherits(QStringLiteral("application/x-cbt")) || mime.inherits(QStringLiteral("application/x-gzip")) || mime.inherits(QStringLiteral("application/x-tar")) || mime.inherits(QStringLiteral("application/x-bzip"))) {
79 mArchive = new KTar(fileName);
80
81 if (!processArchive()) {
82 return false;
83 }
84#if WITH_K7ZIP
85 /**
86 * We have a 7z archive
87 */
88 } else if (mime.inherits(QStringLiteral("application/x-cb7")) || mime.inherits(QStringLiteral("application/x-7z-compressed"))) {
89 mArchive = new K7Zip(fileName);
90
91 if (!processArchive()) {
92 return false;
93 }
94#endif
95 } else if (mime.inherits(QStringLiteral("application/x-cbr")) || mime.inherits(QStringLiteral("application/x-rar")) || mime.inherits(QStringLiteral("application/vnd.rar"))) {
96 if (!Unrar::isAvailable()) {
97 mLastErrorString = i18n("Cannot open document, neither unrar nor unarchiver were found.");
98 return false;
99 }
100
101 if (!Unrar::isSuitableVersionAvailable()) {
102 mLastErrorString = i18n("The version of unrar on your system is not suitable for opening comicbooks.");
103 return false;
104 }
105
106 /**
107 * We have a rar archive
108 */
109 mUnrar = new Unrar();
110
111 if (!mUnrar->open(fileName)) {
112 delete mUnrar;
113 mUnrar = nullptr;
114
115 return false;
116 }

Callers 1

processArchiveMethod · 0.45

Calls 1

listMethod · 0.45

Tested by

no test coverage detected