mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-24 02:42:52 +00:00
gwenview: merge URL kind enums for images
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
dfd25bc1f0
commit
7027e26278
10 changed files with 21 additions and 28 deletions
|
@ -526,8 +526,7 @@ struct MainWindow::Private
|
||||||
{
|
{
|
||||||
mDirModel->setKindFilter(
|
mDirModel->setKindFilter(
|
||||||
MimeTypeUtils::KIND_DIR
|
MimeTypeUtils::KIND_DIR
|
||||||
| MimeTypeUtils::KIND_RASTER_IMAGE
|
| MimeTypeUtils::KIND_IMAGE);
|
||||||
| MimeTypeUtils::KIND_SVG_IMAGE);
|
|
||||||
|
|
||||||
connect(mDirModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
|
connect(mDirModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
|
||||||
q, SLOT(slotDirModelNewItems()));
|
q, SLOT(slotDirModelNewItems()));
|
||||||
|
@ -1315,8 +1314,7 @@ void MainWindow::toggleSlideShow()
|
||||||
KFileItem item = d->mDirModel->itemForIndex(index);
|
KFileItem item = d->mDirModel->itemForIndex(index);
|
||||||
MimeTypeUtils::Kind kind = MimeTypeUtils::fileItemKind(item);
|
MimeTypeUtils::Kind kind = MimeTypeUtils::fileItemKind(item);
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case MimeTypeUtils::KIND_SVG_IMAGE:
|
case MimeTypeUtils::KIND_IMAGE:
|
||||||
case MimeTypeUtils::KIND_RASTER_IMAGE:
|
|
||||||
list << item.url();
|
list << item.url();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -79,8 +79,7 @@ void DocumentDirFinder::slotItemsAdded(const KUrl& dir, const KFileItemList& lis
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MimeTypeUtils::KIND_RASTER_IMAGE:
|
case MimeTypeUtils::KIND_IMAGE:
|
||||||
case MimeTypeUtils::KIND_SVG_IMAGE:
|
|
||||||
finish(dir, DocumentDirFound);
|
finish(dir, DocumentDirFound);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ struct ThumbnailPagePrivate : public Ui_ThumbnailPage
|
||||||
mRecursiveDirModel = new RecursiveDirModel(q);
|
mRecursiveDirModel = new RecursiveDirModel(q);
|
||||||
|
|
||||||
KindProxyModel* kindProxyModel = new KindProxyModel(q);
|
KindProxyModel* kindProxyModel = new KindProxyModel(q);
|
||||||
kindProxyModel->setKindFilter(MimeTypeUtils::KIND_RASTER_IMAGE | MimeTypeUtils::KIND_SVG_IMAGE);
|
kindProxyModel->setKindFilter(MimeTypeUtils::KIND_IMAGE);
|
||||||
kindProxyModel->setSourceModel(mRecursiveDirModel);
|
kindProxyModel->setSourceModel(mRecursiveDirModel);
|
||||||
|
|
||||||
QSortFilterProxyModel *sortModel = new QSortFilterProxyModel(q);
|
QSortFilterProxyModel *sortModel = new QSortFilterProxyModel(q);
|
||||||
|
|
|
@ -268,7 +268,7 @@ void Gwenview::ContextManager::slotRowsAboutToBeRemoved(const QModelIndex& /*par
|
||||||
|
|
||||||
bool ContextManager::currentUrlIsRasterImage() const
|
bool ContextManager::currentUrlIsRasterImage() const
|
||||||
{
|
{
|
||||||
return MimeTypeUtils::urlKind(currentUrl()) == MimeTypeUtils::KIND_RASTER_IMAGE;
|
return MimeTypeUtils::urlKind(currentUrl()) == MimeTypeUtils::KIND_IMAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
KUrl ContextManager::urlToSelect() const
|
KUrl ContextManager::urlToSelect() const
|
||||||
|
|
|
@ -111,8 +111,7 @@ struct LoadingDocumentImplPrivate
|
||||||
q->setDocumentKind(kind);
|
q->setDocumentKind(kind);
|
||||||
|
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case MimeTypeUtils::KIND_RASTER_IMAGE:
|
case MimeTypeUtils::KIND_IMAGE:
|
||||||
case MimeTypeUtils::KIND_SVG_IMAGE:
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -130,8 +129,7 @@ struct LoadingDocumentImplPrivate
|
||||||
Q_ASSERT(!mMetaInfoLoaded);
|
Q_ASSERT(!mMetaInfoLoaded);
|
||||||
|
|
||||||
switch (q->document()->kind()) {
|
switch (q->document()->kind()) {
|
||||||
case MimeTypeUtils::KIND_RASTER_IMAGE:
|
case MimeTypeUtils::KIND_IMAGE:
|
||||||
case MimeTypeUtils::KIND_SVG_IMAGE:
|
|
||||||
// The hint is used to:
|
// The hint is used to:
|
||||||
// - Speed up loadMetaInfo(): QImageReader will try to decode the
|
// - Speed up loadMetaInfo(): QImageReader will try to decode the
|
||||||
// image using plugins matching this format first.
|
// image using plugins matching this format first.
|
||||||
|
|
|
@ -351,8 +351,7 @@ void DocumentView::createAdapterForDocument()
|
||||||
}
|
}
|
||||||
AbstractDocumentViewAdapter* adapter = 0;
|
AbstractDocumentViewAdapter* adapter = 0;
|
||||||
switch (documentKind) {
|
switch (documentKind) {
|
||||||
case MimeTypeUtils::KIND_RASTER_IMAGE:
|
case MimeTypeUtils::KIND_IMAGE:
|
||||||
case MimeTypeUtils::KIND_SVG_IMAGE:
|
|
||||||
adapter = new RasterImageViewAdapter;
|
adapter = new RasterImageViewAdapter;
|
||||||
break;
|
break;
|
||||||
case MimeTypeUtils::KIND_UNKNOWN:
|
case MimeTypeUtils::KIND_UNKNOWN:
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
|
|
||||||
virtual MimeTypeUtils::Kind kind() const
|
virtual MimeTypeUtils::Kind kind() const
|
||||||
{
|
{
|
||||||
return MimeTypeUtils::KIND_RASTER_IMAGE;
|
return MimeTypeUtils::KIND_IMAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool canZoom() const
|
virtual bool canZoom() const
|
||||||
|
|
|
@ -149,10 +149,10 @@ QString urlMimeTypeByContent(const KUrl& url)
|
||||||
Kind mimeTypeKind(const QString& mimeType)
|
Kind mimeTypeKind(const QString& mimeType)
|
||||||
{
|
{
|
||||||
if (rasterImageMimeTypes().contains(mimeType)) {
|
if (rasterImageMimeTypes().contains(mimeType)) {
|
||||||
return KIND_RASTER_IMAGE;
|
return KIND_IMAGE;
|
||||||
}
|
}
|
||||||
if (svgImageMimeTypes().contains(mimeType)) {
|
if (svgImageMimeTypes().contains(mimeType)) {
|
||||||
return KIND_SVG_IMAGE;
|
return KIND_IMAGE;
|
||||||
}
|
}
|
||||||
if (mimeType.startsWith(QLatin1String("inode/directory"))) {
|
if (mimeType.startsWith(QLatin1String("inode/directory"))) {
|
||||||
return KIND_DIR;
|
return KIND_DIR;
|
||||||
|
|
|
@ -51,8 +51,7 @@ enum Kind {
|
||||||
KIND_UNKNOWN = 0,
|
KIND_UNKNOWN = 0,
|
||||||
KIND_DIR = 1,
|
KIND_DIR = 1,
|
||||||
KIND_FILE = 1 << 2,
|
KIND_FILE = 1 << 2,
|
||||||
KIND_RASTER_IMAGE = 1 << 3,
|
KIND_IMAGE = 1 << 3
|
||||||
KIND_SVG_IMAGE = 1 << 4
|
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(Kinds, Kind)
|
Q_DECLARE_FLAGS(Kinds, Kind)
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ void DocumentTest::testLoad()
|
||||||
QCOMPARE(doc->kind(), expectedKind);
|
QCOMPARE(doc->kind(), expectedKind);
|
||||||
QCOMPARE(doc->isAnimated(), expectedIsAnimated);
|
QCOMPARE(doc->isAnimated(), expectedIsAnimated);
|
||||||
QCOMPARE(spy.count(), doc->isAnimated() ? 1 : 0);
|
QCOMPARE(spy.count(), doc->isAnimated() ? 1 : 0);
|
||||||
if (doc->kind() == MimeTypeUtils::KIND_RASTER_IMAGE) {
|
if (doc->kind() == MimeTypeUtils::KIND_IMAGE) {
|
||||||
QImage image = doc->image();
|
QImage image = doc->image();
|
||||||
if (maxHeight > -1) {
|
if (maxHeight > -1) {
|
||||||
QRect poiRect(0, 0, image.width(), maxHeight);
|
QRect poiRect(0, 0, image.width(), maxHeight);
|
||||||
|
@ -124,7 +124,7 @@ void DocumentTest::testLoad()
|
||||||
static void testLoad_newRow(
|
static void testLoad_newRow(
|
||||||
const char* fileName,
|
const char* fileName,
|
||||||
const QByteArray& format,
|
const QByteArray& format,
|
||||||
MimeTypeUtils::Kind kind = MimeTypeUtils::KIND_RASTER_IMAGE,
|
MimeTypeUtils::Kind kind = MimeTypeUtils::KIND_IMAGE,
|
||||||
bool isAnimated = false,
|
bool isAnimated = false,
|
||||||
int maxHeight = -1
|
int maxHeight = -1
|
||||||
)
|
)
|
||||||
|
@ -149,7 +149,7 @@ void DocumentTest::testLoad_data()
|
||||||
|
|
||||||
testLoad_newRow("test.png", "png");
|
testLoad_newRow("test.png", "png");
|
||||||
testLoad_newRow("160216_no_size_before_decoding.eps", "eps");
|
testLoad_newRow("160216_no_size_before_decoding.eps", "eps");
|
||||||
testLoad_newRow("160382_corrupted.jpeg", "jpeg", MimeTypeUtils::KIND_RASTER_IMAGE, false, 55);
|
testLoad_newRow("160382_corrupted.jpeg", "jpeg", MimeTypeUtils::KIND_IMAGE, false, 55);
|
||||||
testLoad_newRow("1x10k.png", "png");
|
testLoad_newRow("1x10k.png", "png");
|
||||||
testLoad_newRow("1x10k.jpg", "jpeg");
|
testLoad_newRow("1x10k.jpg", "jpeg");
|
||||||
testLoad_newRow("test.xcf", "xcf");
|
testLoad_newRow("test.xcf", "xcf");
|
||||||
|
@ -159,18 +159,18 @@ void DocumentTest::testLoad_data()
|
||||||
testLoad_newRow("jpg-with-gif-extension.gif", "jpeg");
|
testLoad_newRow("jpg-with-gif-extension.gif", "jpeg");
|
||||||
|
|
||||||
// RAW preview
|
// RAW preview
|
||||||
testLoad_newRow("CANON-EOS350D-02.CR2", "cr2", MimeTypeUtils::KIND_RASTER_IMAGE, false);
|
testLoad_newRow("CANON-EOS350D-02.CR2", "cr2", MimeTypeUtils::KIND_IMAGE, false);
|
||||||
testLoad_newRow("dsc_0093.nef", "nef", MimeTypeUtils::KIND_RASTER_IMAGE, false);
|
testLoad_newRow("dsc_0093.nef", "nef", MimeTypeUtils::KIND_IMAGE, false);
|
||||||
|
|
||||||
// SVG
|
// SVG
|
||||||
testLoad_newRow("test.svg", "", MimeTypeUtils::KIND_SVG_IMAGE);
|
testLoad_newRow("test.svg", "svg", MimeTypeUtils::KIND_IMAGE);
|
||||||
// FIXME: Test svgz
|
// FIXME: Test svgz
|
||||||
|
|
||||||
// Animated
|
// Animated
|
||||||
testLoad_newRow("4frames.gif", "gif", MimeTypeUtils::KIND_RASTER_IMAGE, true);
|
testLoad_newRow("4frames.gif", "gif", MimeTypeUtils::KIND_IMAGE, true);
|
||||||
testLoad_newRow("1frame.gif", "gif", MimeTypeUtils::KIND_RASTER_IMAGE, false);
|
testLoad_newRow("1frame.gif", "gif", MimeTypeUtils::KIND_IMAGE, false);
|
||||||
testLoad_newRow("185523_1frame_with_graphic_control_extension.gif",
|
testLoad_newRow("185523_1frame_with_graphic_control_extension.gif",
|
||||||
"gif", MimeTypeUtils::KIND_RASTER_IMAGE, false);
|
"gif", MimeTypeUtils::KIND_IMAGE, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentTest::testLoadTwoPasses()
|
void DocumentTest::testLoadTwoPasses()
|
||||||
|
|
Loading…
Add table
Reference in a new issue