OSDN Git Service

remove now redundant QImageIOHandler::SubType image handler option
authorIvailo Monev <xakepa10@gmail.com>
Sat, 21 May 2022 21:00:51 +0000 (21:00 +0000)
committerIvailo Monev <xakepa10@gmail.com>
Sat, 21 May 2022 21:00:51 +0000 (21:00 +0000)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/gui/image/qimageiohandler.cpp
src/gui/image/qimageiohandler.h
src/gui/image/qimagereader.cpp
src/gui/image/qimagewriter.cpp
src/gui/image/qppmhandler.cpp
src/gui/image/qppmhandler_p.h

index 81f5a39..0321f36 100644 (file)
     supports this option is expected to set the image quality level
     depending on the value of this option (an int) when writing.
 
-    \value SubType The subtype of the image. A handler that supports
-    this option can use the subtype value to help when reading and
-    writing images. For example, a PPM handler may have a subtype
-    value of "ppm" or "ppmraw".
-
     \value Animation Image formats that support animation return
     true for this value in supportsOption(); otherwise, false is returned.
 
index d80d99f..d83151e 100644 (file)
@@ -61,7 +61,6 @@ public:
         CompressionLevel,
         Gamma,
         Quality,
-        SubType,
         Animation,
         BackgroundColor
     };
index bb9024f..afe03d5 100644 (file)
@@ -144,7 +144,6 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
 #ifndef QT_NO_IMAGEFORMAT_PPM
     } else if (form == "pbm" || form == "pbmraw" || form == "ppm" || form == "ppmraw") {
         handler = new QPpmHandler();
-        handler->setOption(QImageIOHandler::SubType, form);
 #endif
     }
 
@@ -179,7 +178,6 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
         QByteArray subType;
         if (!handler && QPpmHandler::canRead(device, &subType)) {
             handler = new QPpmHandler();
-            handler->setOption(QImageIOHandler::SubType, subType);
         }
 #endif
     }
index 5a2e692..e9b5cd4 100644 (file)
@@ -107,7 +107,6 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device,
 #ifndef QT_NO_IMAGEFORMAT_PPM
     } else if (form == "pbm" || form == "pbmraw" || form == "ppm" || form == "ppmraw") {
         handler = new QPpmHandler();
-        handler->setOption(QImageIOHandler::SubType, form);
 #endif
     }
 
index 7c4051d..5ad7e17 100644 (file)
@@ -345,14 +345,12 @@ bool QPpmHandler::write(const QImage &image)
 
 bool QPpmHandler::supportsOption(QImageIOHandler::ImageOption option) const
 {
-    return (option == QImageIOHandler::SubType || option == QImageIOHandler::Size);
+    return (option == QImageIOHandler::Size);
 }
 
 QVariant QPpmHandler::option(QImageIOHandler::ImageOption option) const
 {
-    if (option == QImageIOHandler::SubType) {
-        return subType;
-    } else if (option == QImageIOHandler::Size) {
+    if (option == QImageIOHandler::Size) {
         if (state == Error)
             return QVariant();
         if (state == Ready && !const_cast<QPpmHandler*>(this)->readHeader())
@@ -362,12 +360,6 @@ QVariant QPpmHandler::option(QImageIOHandler::ImageOption option) const
     return QVariant();
 }
 
-void QPpmHandler::setOption(QImageIOHandler::ImageOption option, const QVariant &value)
-{
-    if (option == QImageIOHandler::SubType)
-        subType = value.toByteArray().toLower();
-}
-
 QByteArray QPpmHandler::name() const
 {
     return subType.isEmpty() ? QByteArray("ppm") : subType;
@@ -381,22 +373,24 @@ bool QPpmHandler::canRead(QIODevice *device, QByteArray *subType)
     }
 
     QSTACKARRAY(char, head, 2);
-    if (device->peek(head, sizeof(head)) != sizeof(head))
+    if (device->peek(head, sizeof(head)) != sizeof(head)) {
         return false;
+    }
 
-    if (head[0] != 'P')
+    if (head[0] != 'P') {
         return false;
+    }
 
     if (head[1] == '1' || head[1] == '4') {
-        if (subType)
-            *subType = "pbm";
+        Q_ASSERT(subType);
+        *subType = "pbm";
+        return true;
     } else if (head[1] == '3' || head[1] == '6') {
-        if (subType)
-            *subType = "ppm";
-    } else {
-        return false;
+        Q_ASSERT(subType);
+        *subType = "ppm";
+        return true;
     }
-    return true;
+    return false;
 }
 
 QT_END_NAMESPACE
index fcb4817..15e9571 100644 (file)
@@ -50,7 +50,6 @@ public:
     bool write(const QImage &image) final;
 
     QVariant option(QImageIOHandler::ImageOption option) const final;
-    void setOption(QImageIOHandler::ImageOption option, const QVariant &value) final;
     bool supportsOption(QImageIOHandler::ImageOption option) const final;
 
     QByteArray name() const final;