mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
gwenview: remove archive support [ci reset]
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
5e1bf30c34
commit
4d3534da5d
16 changed files with 37 additions and 224 deletions
|
@ -51,7 +51,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
|
|||
#include <lib/gwenviewconfig.h>
|
||||
#include <lib/sorteddirmodel.h>
|
||||
#include <lib/sorting.h>
|
||||
#include <lib/archiveutils.h>
|
||||
#include <lib/thumbnailview/previewitemdelegate.h>
|
||||
#include <lib/thumbnailview/thumbnailview.h>
|
||||
#include <ui_browsemainpage.h>
|
||||
|
@ -201,7 +200,7 @@ struct BrowseMainPagePrivate : public Ui_BrowseMainPage
|
|||
for (int row = start; row <= end; ++row) {
|
||||
QModelIndex index = mDirModel->index(row, 0, parent);
|
||||
KFileItem item = mDirModel->itemForIndex(index);
|
||||
if (!ArchiveUtils::fileItemIsDirOrArchive(item)) {
|
||||
if (!item.isDir()) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
// Local
|
||||
#include "imagemetainfodialog.h"
|
||||
#include "sidebar.h"
|
||||
#include <lib/archiveutils.h>
|
||||
#include <lib/contextmanager.h>
|
||||
#include <lib/eventwatcher.h>
|
||||
#include <lib/gvdebug.h>
|
||||
|
@ -302,7 +301,7 @@ void InfoContextManagerItem::updateSideBarContent()
|
|||
}
|
||||
|
||||
KFileItem item = itemList.first();
|
||||
if (itemList.count() == 1 && !ArchiveUtils::fileItemIsDirOrArchive(item)) {
|
||||
if (itemList.count() == 1 && !item.isDir()) {
|
||||
fillOneFileGroup(item);
|
||||
} else {
|
||||
fillMultipleItemsGroup(itemList);
|
||||
|
|
|
@ -84,7 +84,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "thumbnailviewhelper.h"
|
||||
#include "browsemainpage.h"
|
||||
#include <lib/hud/hudbuttonbox.h>
|
||||
#include <lib/archiveutils.h>
|
||||
#include <lib/contextmanager.h>
|
||||
#include <lib/disabledactionshortcutmonitor.h>
|
||||
#include <lib/document/documentfactory.h>
|
||||
|
@ -543,7 +542,6 @@ struct MainWindow::Private
|
|||
{
|
||||
mDirModel->setKindFilter(
|
||||
MimeTypeUtils::KIND_DIR
|
||||
| MimeTypeUtils::KIND_ARCHIVE
|
||||
| MimeTypeUtils::KIND_RASTER_IMAGE
|
||||
| MimeTypeUtils::KIND_SVG_IMAGE);
|
||||
|
||||
|
@ -565,11 +563,11 @@ struct MainWindow::Private
|
|||
mThumbnailBarModel->setSourceModel(mDirModel);
|
||||
}
|
||||
|
||||
bool indexIsDirOrArchive(const QModelIndex& index) const
|
||||
bool indexIsDir(const QModelIndex& index) const
|
||||
{
|
||||
Q_ASSERT(index.isValid());
|
||||
KFileItem item = mDirModel->itemForIndex(index);
|
||||
return ArchiveUtils::fileItemIsDirOrArchive(item);
|
||||
return item.isDir();
|
||||
}
|
||||
|
||||
void goTo(const QModelIndex& index)
|
||||
|
@ -586,7 +584,7 @@ struct MainWindow::Private
|
|||
mPreloadDirectionIsForward = offset > 0;
|
||||
QModelIndex index = mContextManager->selectionModel()->currentIndex();
|
||||
index = mDirModel->index(index.row() + offset, 0);
|
||||
if (index.isValid() && !indexIsDirOrArchive(index)) {
|
||||
if (index.isValid() && !indexIsDir(index)) {
|
||||
goTo(index);
|
||||
}
|
||||
}
|
||||
|
@ -600,7 +598,7 @@ struct MainWindow::Private
|
|||
return;
|
||||
}
|
||||
|
||||
if (!indexIsDirOrArchive(index)) {
|
||||
if (!indexIsDir(index)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -893,16 +891,8 @@ void MainWindow::slotThumbnailViewIndexActivated(const QModelIndex& index)
|
|||
// Item is a dir, open it
|
||||
openDirUrl(item.url());
|
||||
} else {
|
||||
QString protocol = ArchiveUtils::protocolForMimeType(item.mimetype());
|
||||
if (!protocol.isEmpty()) {
|
||||
// Item is an archive, tweak url then open it
|
||||
KUrl url = item.url();
|
||||
url.setProtocol(protocol);
|
||||
openDirUrl(url);
|
||||
} else {
|
||||
// Item is a document, switch to view mode
|
||||
d->mViewAction->trigger();
|
||||
}
|
||||
// Item is a document, switch to view mode
|
||||
d->mViewAction->trigger();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -933,7 +923,7 @@ void MainWindow::openSelectedDocuments()
|
|||
|
||||
Q_FOREACH(const QModelIndex& index, list) {
|
||||
KFileItem item = d->mDirModel->itemForIndex(index);
|
||||
if (!item.isNull() && !ArchiveUtils::fileItemIsDirOrArchive(item)) {
|
||||
if (!item.isNull() && !item.isDir()) {
|
||||
KUrl url = item.url();
|
||||
if (!firstDocumentIndex.isValid()) {
|
||||
firstDocumentIndex = index;
|
||||
|
@ -1107,7 +1097,7 @@ void MainWindow::slotSelectionChanged()
|
|||
item = d->mDirModel->itemForIndex(index);
|
||||
}
|
||||
QUndoGroup* undoGroup = DocumentFactory::instance()->undoGroup();
|
||||
if (!item.isNull() && !ArchiveUtils::fileItemIsDirOrArchive(item)) {
|
||||
if (!item.isNull() && !item.isDir()) {
|
||||
KUrl url = item.url();
|
||||
Document::Ptr doc = DocumentFactory::instance()->load(url);
|
||||
undoGroup->addStack(doc->undoStack());
|
||||
|
@ -1197,12 +1187,12 @@ void MainWindow::updatePreviousNextActions()
|
|||
bool hasPrevious;
|
||||
bool hasNext;
|
||||
QModelIndex currentIndex = d->mContextManager->selectionModel()->currentIndex();
|
||||
if (currentIndex.isValid() && !d->indexIsDirOrArchive(currentIndex)) {
|
||||
if (currentIndex.isValid() && !d->indexIsDir(currentIndex)) {
|
||||
int row = currentIndex.row();
|
||||
QModelIndex prevIndex = d->mDirModel->index(row - 1, 0);
|
||||
QModelIndex nextIndex = d->mDirModel->index(row + 1, 0);
|
||||
hasPrevious = prevIndex.isValid() && !d->indexIsDirOrArchive(prevIndex);
|
||||
hasNext = nextIndex.isValid() && !d->indexIsDirOrArchive(nextIndex);
|
||||
hasPrevious = prevIndex.isValid() && !d->indexIsDir(prevIndex);
|
||||
hasNext = nextIndex.isValid() && !d->indexIsDir(nextIndex);
|
||||
} else {
|
||||
hasPrevious = false;
|
||||
hasNext = false;
|
||||
|
@ -1481,7 +1471,7 @@ void MainWindow::preloadNextUrl()
|
|||
}
|
||||
|
||||
KFileItem item = d->mDirModel->itemForIndex(index);
|
||||
if (!ArchiveUtils::fileItemIsDirOrArchive(item)) {
|
||||
if (!item.isDir()) {
|
||||
KUrl url = item.url();
|
||||
if (url.isLocalFile()) {
|
||||
QSize size = d->mViewStackedWidget->size();
|
||||
|
|
|
@ -69,7 +69,6 @@ void DocumentDirFinder::slotItemsAdded(const KUrl& dir, const KFileItemList& lis
|
|||
MimeTypeUtils::Kind kind = MimeTypeUtils::fileItemKind(item);
|
||||
switch (kind) {
|
||||
case MimeTypeUtils::KIND_DIR:
|
||||
case MimeTypeUtils::KIND_ARCHIVE:
|
||||
if (d->mFoundDirUrl.isValid()) {
|
||||
// This is the second dir we find, stop now
|
||||
finish(dir, MultipleDirsFound);
|
||||
|
|
|
@ -36,7 +36,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
|
|||
#include <KLocale>
|
||||
|
||||
// Local
|
||||
#include <lib/archiveutils.h>
|
||||
#include <lib/kindproxymodel.h>
|
||||
#include <lib/gwenviewconfig.h>
|
||||
#include <lib/recursivedirmodel.h>
|
||||
|
@ -321,7 +320,7 @@ void ThumbnailPage::importList(const QModelIndexList& list)
|
|||
d->mUrlList.clear();
|
||||
Q_FOREACH(const QModelIndex & index, list) {
|
||||
KFileItem item = itemForIndex(index);
|
||||
if (!ArchiveUtils::fileItemIsDirOrArchive(item)) {
|
||||
if (!item.isDir()) {
|
||||
d->mUrlList << item.url();
|
||||
}
|
||||
// FIXME: Handle dirs (do we want to import recursively?)
|
||||
|
|
|
@ -45,7 +45,6 @@ set(gwenviewlib_SRCS
|
|||
binder.cpp
|
||||
eventwatcher.cpp
|
||||
historymodel.cpp
|
||||
archiveutils.cpp
|
||||
datewidget.cpp
|
||||
exiv2imageloader.cpp
|
||||
flowlayout.cpp
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
// vim: set tabstop=4 shiftwidth=4 expandtab
|
||||
/*
|
||||
Gwenview - A simple image viewer for KDE
|
||||
Copyright 2000-2007 Aurélien Gâteau <agateau@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
// Self
|
||||
#include "archiveutils.h"
|
||||
|
||||
// KDE
|
||||
#include <KDebug>
|
||||
#include <KFileItem>
|
||||
#include <KMimeType>
|
||||
#include <KProtocolManager>
|
||||
|
||||
namespace Gwenview
|
||||
{
|
||||
|
||||
namespace ArchiveUtils
|
||||
{
|
||||
|
||||
bool fileItemIsArchive(const KFileItem& item)
|
||||
{
|
||||
KMimeType::Ptr mimeType = item.determineMimeType();
|
||||
if (!mimeType) {
|
||||
kWarning() << "determineMimeType() returned a null pointer";
|
||||
return false;
|
||||
}
|
||||
return !ArchiveUtils::protocolForMimeType(mimeType->name()).isEmpty();
|
||||
}
|
||||
|
||||
bool fileItemIsDirOrArchive(const KFileItem& item)
|
||||
{
|
||||
return item.isDir() || fileItemIsArchive(item);
|
||||
}
|
||||
|
||||
QString protocolForMimeType(const QString& mimeType)
|
||||
{
|
||||
static QHash<QString, QString> cache;
|
||||
QHash<QString, QString>::ConstIterator it = cache.constFind(mimeType);
|
||||
if (it != cache.constEnd()) {
|
||||
return it.value();
|
||||
}
|
||||
|
||||
if (mimeType == "image/svg+xml-compressed") {
|
||||
// We don't want .svgz to be considered as archives because QtSvg knows
|
||||
// how to decode gzip-ed svg files
|
||||
cache.insert(mimeType, QString());
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString protocol = KProtocolManager::protocolForArchiveMimetype(mimeType);
|
||||
if (protocol.isEmpty()) {
|
||||
// No protocol, try with mimeType parents. This is useful for .cbz for
|
||||
// example
|
||||
KMimeType::Ptr ptr = KMimeType::mimeType(mimeType);
|
||||
if (ptr) {
|
||||
Q_FOREACH(const QString & parentMimeType, ptr->allParentMimeTypes()) {
|
||||
protocol = KProtocolManager::protocolForArchiveMimetype(parentMimeType);
|
||||
if (!protocol.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cache.insert(mimeType, protocol);
|
||||
return protocol;
|
||||
}
|
||||
|
||||
} // namespace ArchiveUtils
|
||||
|
||||
} // namespace Gwenview
|
|
@ -1,61 +0,0 @@
|
|||
// vim: set tabstop=4 shiftwidth=4 expandtab
|
||||
/*
|
||||
Gwenview - A simple image viewer for KDE
|
||||
Copyright 2000-2004 Aurélien Gâteau <agateau@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
#ifndef ARCHIVEUTILS_H
|
||||
#define ARCHIVEUTILS_H
|
||||
|
||||
#include <lib/gwenviewlib_export.h>
|
||||
|
||||
// Qt
|
||||
#include <qstringlist.h>
|
||||
|
||||
class KFileItem;
|
||||
|
||||
namespace Gwenview
|
||||
{
|
||||
|
||||
/**
|
||||
* Helper functions to deal with archives
|
||||
*/
|
||||
namespace ArchiveUtils
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns true if @p item is an archive
|
||||
*/
|
||||
GWENVIEWLIB_EXPORT bool fileItemIsArchive(const KFileItem& item);
|
||||
|
||||
/**
|
||||
* Returns true if @p item is a dir or an archive
|
||||
*/
|
||||
GWENVIEWLIB_EXPORT bool fileItemIsDirOrArchive(const KFileItem& item);
|
||||
|
||||
/**
|
||||
* Returns the protocol for an archive mime type. Similar to
|
||||
* KProtocolManager::protocolForArchiveMimetype(), except it tries parent
|
||||
* mimetypes if it can't find anything (useful for .cbz and co)
|
||||
*/
|
||||
GWENVIEWLIB_EXPORT QString protocolForMimeType(const QString& mimeType);
|
||||
|
||||
} // namespace ArchiveUtils
|
||||
|
||||
} // namespace Gwenview
|
||||
#endif
|
||||
|
|
@ -21,9 +21,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
|
|||
// Self
|
||||
#include "moc_documentonlyproxymodel.cpp"
|
||||
|
||||
// Local
|
||||
#include <lib/archiveutils.h>
|
||||
|
||||
// KDE
|
||||
#include <KDirModel>
|
||||
|
||||
|
@ -52,7 +49,7 @@ bool DocumentOnlyProxyModel::filterAcceptsRow(int row, const QModelIndex &parent
|
|||
{
|
||||
const QModelIndex index = sourceModel()->index(row, 0, parent);
|
||||
const KFileItem fileItem = index.data(KDirModel::FileItemRole).value<KFileItem>();
|
||||
return !ArchiveUtils::fileItemIsDirOrArchive(fileItem);
|
||||
return !fileItem.isDir();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace Gwenview
|
|||
|
||||
struct DocumentOnlyProxyModelPrivate;
|
||||
/**
|
||||
* A proxy model which lists items which are neither dirs nor archives.
|
||||
* A proxy model which lists items which are not dirs.
|
||||
* Only works with models which expose a KDirModel::FileItemRole.
|
||||
*/
|
||||
class GWENVIEWLIB_EXPORT DocumentOnlyProxyModel : public QSortFilterProxyModel
|
||||
|
|
|
@ -38,7 +38,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include <KImageIO>
|
||||
|
||||
// Local
|
||||
#include <archiveutils.h>
|
||||
#include <gvdebug.h>
|
||||
|
||||
namespace Gwenview
|
||||
|
@ -161,9 +160,6 @@ Kind mimeTypeKind(const QString& mimeType)
|
|||
if (mimeType.startsWith(QLatin1String("inode/directory"))) {
|
||||
return KIND_DIR;
|
||||
}
|
||||
if (!ArchiveUtils::protocolForMimeType(mimeType).isEmpty()) {
|
||||
return KIND_ARCHIVE;
|
||||
}
|
||||
|
||||
return KIND_FILE;
|
||||
}
|
||||
|
|
|
@ -49,10 +49,9 @@ GWENVIEWLIB_EXPORT QString urlMimeTypeByContent(const KUrl&);
|
|||
enum Kind {
|
||||
KIND_UNKNOWN = 0,
|
||||
KIND_DIR = 1,
|
||||
KIND_ARCHIVE = 1 << 2,
|
||||
KIND_FILE = 1 << 3,
|
||||
KIND_RASTER_IMAGE = 1 << 4,
|
||||
KIND_SVG_IMAGE = 1 << 5
|
||||
KIND_FILE = 1 << 2,
|
||||
KIND_RASTER_IMAGE = 1 << 3,
|
||||
KIND_SVG_IMAGE = 1 << 4
|
||||
};
|
||||
Q_DECLARE_FLAGS(Kinds, Kind)
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include <KDirLister>
|
||||
|
||||
// Local
|
||||
#include <lib/archiveutils.h>
|
||||
#include <lib/timeutils.h>
|
||||
#include <KDirModel>
|
||||
|
||||
|
@ -182,7 +181,7 @@ bool SortedDirModel::filterAcceptsRow(int row, const QModelIndex& parent) const
|
|||
return false;
|
||||
}
|
||||
|
||||
if (kind != MimeTypeUtils::KIND_DIR && kind != MimeTypeUtils::KIND_ARCHIVE) {
|
||||
if (kind != MimeTypeUtils::KIND_DIR) {
|
||||
int dotPos = fileItem.name().lastIndexOf('.');
|
||||
if (dotPos >= 1) {
|
||||
QString extension = fileItem.name().mid(dotPos + 1).toLower();
|
||||
|
@ -221,11 +220,11 @@ bool SortedDirModel::lessThan(const QModelIndex& left, const QModelIndex& right)
|
|||
const KFileItem leftItem = itemForSourceIndex(left);
|
||||
const KFileItem rightItem = itemForSourceIndex(right);
|
||||
|
||||
const bool leftIsDirOrArchive = ArchiveUtils::fileItemIsDirOrArchive(leftItem);
|
||||
const bool rightIsDirOrArchive = ArchiveUtils::fileItemIsDirOrArchive(rightItem);
|
||||
const bool leftIsDir = leftItem.isDir();
|
||||
const bool rightIsDir = rightItem.isDir();
|
||||
|
||||
if (leftIsDirOrArchive != rightIsDirOrArchive) {
|
||||
return leftIsDirOrArchive;
|
||||
if (leftIsDir != rightIsDir) {
|
||||
return leftIsDir;
|
||||
}
|
||||
|
||||
if (sortRole() != KDirModel::ModifiedTime) {
|
||||
|
@ -247,7 +246,7 @@ bool SortedDirModel::hasDocuments() const
|
|||
for (int row = 0; row < count; ++row) {
|
||||
const QModelIndex idx = index(row, 0);
|
||||
const KFileItem item = itemForIndex(idx);
|
||||
if (!ArchiveUtils::fileItemIsDirOrArchive(item)) {
|
||||
if (!item.isDir()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
|
|||
#include <KUrl>
|
||||
|
||||
// Local
|
||||
#include "archiveutils.h"
|
||||
#include "contextbarbutton.h"
|
||||
#include "itemeditor.h"
|
||||
#include "paintutils.h"
|
||||
|
@ -349,9 +348,9 @@ struct PreviewItemDelegatePrivate
|
|||
|
||||
// FIXME: Duplicated from drawText
|
||||
const KFileItem fileItem = fileItemForIndex(index);
|
||||
const bool isDirOrArchive = ArchiveUtils::fileItemIsDirOrArchive(fileItem);
|
||||
const bool isDir = fileItem.isDir();
|
||||
if (mDetails & PreviewItemDelegate::DateDetail) {
|
||||
if (!ArchiveUtils::fileItemIsDirOrArchive(fileItem)) {
|
||||
if (!isDir) {
|
||||
const KDateTime dt = TimeUtils::dateTimeForFileItem(fileItem);
|
||||
const QString text = KGlobal::locale()->formatDateTime(dt);
|
||||
elided |= isTextElided(text);
|
||||
|
@ -359,7 +358,7 @@ struct PreviewItemDelegatePrivate
|
|||
}
|
||||
}
|
||||
|
||||
if (!isDirOrArchive && (mDetails & PreviewItemDelegate::ImageSizeDetail)) {
|
||||
if (!isDir && (mDetails & PreviewItemDelegate::ImageSizeDetail)) {
|
||||
QSize fullSize;
|
||||
QPixmap thumbnailPix = mView->thumbnailForIndex(index, &fullSize);
|
||||
if (fullSize.isValid()) {
|
||||
|
@ -369,7 +368,7 @@ struct PreviewItemDelegatePrivate
|
|||
}
|
||||
}
|
||||
|
||||
if (!isDirOrArchive && (mDetails & PreviewItemDelegate::FileSizeDetail)) {
|
||||
if (!isDir && (mDetails & PreviewItemDelegate::FileSizeDetail)) {
|
||||
const KIO::filesize_t size = fileItem.size();
|
||||
if (size > 0) {
|
||||
const QString text = KIO::convertSize(size);
|
||||
|
@ -485,7 +484,7 @@ struct PreviewItemDelegatePrivate
|
|||
void updateImageButtons()
|
||||
{
|
||||
const KFileItem item = fileItemForIndex(mIndexUnderCursor);
|
||||
const bool isImage = !ArchiveUtils::fileItemIsDirOrArchive(item);
|
||||
const bool isImage = !item.isDir();
|
||||
mFullScreenButton->setEnabled(isImage);
|
||||
mRotateLeftButton->setEnabled(isImage);
|
||||
mRotateRightButton->setEnabled(isImage);
|
||||
|
@ -618,7 +617,7 @@ void PreviewItemDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
|
|||
QPixmap thumbnailPix = d->mView->thumbnailForIndex(index, &fullSize);
|
||||
const KFileItem fileItem = fileItemForIndex(index);
|
||||
const bool opaque = !thumbnailPix.hasAlphaChannel();
|
||||
const bool isDirOrArchive = ArchiveUtils::fileItemIsDirOrArchive(fileItem);
|
||||
const bool isDir = fileItem.isDir();
|
||||
QRect rect = option.rect;
|
||||
const bool selected = option.state & QStyle::State_Selected;
|
||||
const bool underMouse = option.state & QStyle::State_MouseOver;
|
||||
|
@ -722,18 +721,18 @@ void PreviewItemDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
|
|||
rect.top() + 2 * ITEM_MARGIN + thumbnailHeight,
|
||||
rect.width() - 2 * ITEM_MARGIN,
|
||||
d->mView->fontMetrics().height());
|
||||
if (isDirOrArchive || (d->mDetails & PreviewItemDelegate::FileNameDetail)) {
|
||||
if (isDir || (d->mDetails & PreviewItemDelegate::FileNameDetail)) {
|
||||
d->drawText(painter, textRect, fgColor, index.data().toString());
|
||||
textRect.moveTop(textRect.bottom());
|
||||
}
|
||||
|
||||
if (!isDirOrArchive && (d->mDetails & PreviewItemDelegate::DateDetail)) {
|
||||
if (!isDir && (d->mDetails & PreviewItemDelegate::DateDetail)) {
|
||||
const KDateTime dt = TimeUtils::dateTimeForFileItem(fileItem);
|
||||
d->drawText(painter, textRect, fgColor, KGlobal::locale()->formatDateTime(dt));
|
||||
textRect.moveTop(textRect.bottom());
|
||||
}
|
||||
|
||||
if (!isDirOrArchive && (d->mDetails & PreviewItemDelegate::ImageSizeDetail)) {
|
||||
if (!isDir && (d->mDetails & PreviewItemDelegate::ImageSizeDetail)) {
|
||||
if (fullSize.isValid()) {
|
||||
const QString text = QString("%1x%2").arg(fullSize.width()).arg(fullSize.height());
|
||||
d->drawText(painter, textRect, fgColor, text);
|
||||
|
@ -741,7 +740,7 @@ void PreviewItemDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
|
|||
}
|
||||
}
|
||||
|
||||
if (!isDirOrArchive && (d->mDetails & PreviewItemDelegate::FileSizeDetail)) {
|
||||
if (!isDir && (d->mDetails & PreviewItemDelegate::FileSizeDetail)) {
|
||||
const KIO::filesize_t size = fileItem.size();
|
||||
if (size > 0) {
|
||||
const QString st = KIO::convertSize(size);
|
||||
|
|
|
@ -46,7 +46,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
// Local
|
||||
#include "abstractdocumentinfoprovider.h"
|
||||
#include "abstractthumbnailviewhelper.h"
|
||||
#include "archiveutils.h"
|
||||
#include "dragpixmapgenerator.h"
|
||||
#include "mimetypeutils.h"
|
||||
#include "urlutils.h"
|
||||
|
|
|
@ -35,7 +35,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
|
|||
#include <KUrl>
|
||||
|
||||
// Local
|
||||
#include <archiveutils.h>
|
||||
#include <mimetypeutils.h>
|
||||
|
||||
namespace Gwenview
|
||||
|
@ -98,19 +97,7 @@ KUrl fixUserEnteredUrl(const KUrl& in)
|
|||
QFileInfo info(in.toLocalFile());
|
||||
QString path = info.absoluteFilePath();
|
||||
|
||||
KUrl out = KUrl::fromPath(path);
|
||||
QString mimeType = MimeTypeUtils::urlMimeType(out);
|
||||
|
||||
const QString protocol = ArchiveUtils::protocolForMimeType(mimeType);
|
||||
|
||||
if (!protocol.isEmpty()) {
|
||||
KUrl tmp = out;
|
||||
tmp.setProtocol(protocol);
|
||||
if (KProtocolManager::supportsListing(tmp)) {
|
||||
out = tmp;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
return KUrl::fromPath(path);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Add table
Reference in a new issue