Changeset View
Changeset View
Standalone View
Standalone View
kerfuffle/archiveentry.cpp
Show All 19 Lines | |||||
20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY | 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY | ||
21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
22 | * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF | 22 | * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF | ||
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
24 | */ | 24 | */ | ||
25 | 25 | | |||
26 | #include "archiveentry.h" | 26 | #include "archiveentry.h" | ||
27 | 27 | | |||
28 | #include <QMimeDatabase> | ||||
29 | | ||||
28 | namespace Kerfuffle { | 30 | namespace Kerfuffle { | ||
29 | Archive::Entry::Entry(QObject *parent, const QString &fullPath, const QString &rootNode) | 31 | Archive::Entry::Entry(QObject *parent, const QString &fullPath, const QString &rootNode) | ||
30 | : QObject(parent) | 32 | : QObject(parent) | ||
31 | , rootNode(rootNode) | 33 | , rootNode(rootNode) | ||
32 | , compressedSizeIsSet(true) | 34 | , compressedSizeIsSet(true) | ||
33 | , m_parent(qobject_cast<Entry*>(parent)) | 35 | , m_parent(qobject_cast<Entry*>(parent)) | ||
34 | , m_size(0) | 36 | , m_size(0) | ||
35 | , m_compressedSize(0) | 37 | , m_compressedSize(0) | ||
▲ Show 20 Lines • Show All 160 Lines • ▼ Show 20 Line(s) | 197 | for (auto entry : archiveEntries) { | |||
196 | if (entry->isDir()) { | 198 | if (entry->isDir()) { | ||
197 | dirs++; | 199 | dirs++; | ||
198 | } else { | 200 | } else { | ||
199 | files++; | 201 | files++; | ||
200 | } | 202 | } | ||
201 | } | 203 | } | ||
202 | } | 204 | } | ||
203 | 205 | | |||
206 | QIcon Archive::Entry::icon() const | ||||
207 | { | ||||
208 | if (m_icon.isNull()) { | ||||
209 | QMimeDatabase db; | ||||
210 | | ||||
211 | if (m_isDirectory) { | ||||
212 | static QIcon directoryIcon = QIcon::fromTheme(db.mimeTypeForName(QStringLiteral("inode/directory")).iconName()); | ||||
broulik: Potentially you could even cache this icon as it's not going to change | |||||
213 | m_icon = directoryIcon; | ||||
214 | } else { | ||||
215 | m_icon = QIcon::fromTheme(db.mimeTypeForFile(m_name, QMimeDatabase::MatchMode::MatchExtension).iconName()); | ||||
216 | } | ||||
217 | } | ||||
218 | | ||||
219 | return m_icon; | ||||
220 | } | ||||
221 | | ||||
204 | bool Archive::Entry::operator==(const Archive::Entry &right) const | 222 | bool Archive::Entry::operator==(const Archive::Entry &right) const | ||
205 | { | 223 | { | ||
206 | return m_fullPath == right.m_fullPath; | 224 | return m_fullPath == right.m_fullPath; | ||
207 | } | 225 | } | ||
208 | 226 | | |||
209 | QDebug operator<<(QDebug d, const Kerfuffle::Archive::Entry &entry) | 227 | QDebug operator<<(QDebug d, const Kerfuffle::Archive::Entry &entry) | ||
210 | { | 228 | { | ||
211 | d.nospace() << "Entry(" << entry.property("fullPath"); | 229 | d.nospace() << "Entry(" << entry.property("fullPath"); | ||
Show All 18 Lines |
Potentially you could even cache this icon as it's not going to change