[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdegraphics/kfile-plugins
From:       Melchior Franz <mfranz () kde ! org>
Date:       2004-03-12 23:47:18
Message-ID: 20040312234718.9B80499B5 () office ! kde ! org
[Download RAW message or body]

CVS commit by mfranz: 

make image name editable


  M +1 -1      RETURNED_ITEMS   1.15
  M +58 -7     rgb/kfile_rgb.cpp   1.3
  M +5 -0      rgb/kfile_rgb.h   1.2


--- kdegraphics/kfile-plugins/RETURNED_ITEMS  #1.14:1.15
@@ -217,8 +217,8 @@
 type       key                        details
 ------------------------------------------------------------------------
+String     ImageName                  Image name (or comment)
 QSize      Dimensions                 Dimensions in pixels
 Int        BitDepth                   Bits per pixel
 String     ColorMode                  Color Mode (Monochrome, RGB, RGBA etc)
 String     Compression                Compression type
-String     ImageName                  Image name
 

--- kdegraphics/kfile-plugins/rgb/kfile_rgb.cpp  #1.2:1.3
@@ -22,7 +22,8 @@
 
 #include <qfile.h>
+#include <qvalidator.h>
 
-#include <kgenericfactory.h>
 #include <kdebug.h>
+#include <kgenericfactory.h>
 
 
@@ -38,8 +39,16 @@ KRgbPlugin::KRgbPlugin(QObject *parent, 
 
         KFileMimeTypeInfo::GroupInfo* group = 0;
-        group = addGroupInfo(info, "Technical", i18n("Technical Details"));
-
         KFileMimeTypeInfo::ItemInfo* item;
 
+
+        group = addGroupInfo(info, "Comment", i18n("Comment"));
+
+        item = addItemInfo(group, "ImageName", i18n("Name"), QVariant::String);
+        setAttributes(item, KFileMimeTypeInfo::Modifiable);
+        setHint(item, KFileMimeTypeInfo::Description);
+
+
+        group = addGroupInfo(info, "Technical", i18n("Technical Details"));
+
         item = addItemInfo(group, "Dimensions", i18n("Dimensions"), QVariant::Size);
         setHint(item, KFileMimeTypeInfo::Size);
@@ -51,5 +60,5 @@ KRgbPlugin::KRgbPlugin(QObject *parent, 
         item = addItemInfo(group, "ColorMode", i18n("Color mode"), QVariant::String);
         item = addItemInfo(group, "Compression", i18n("Compression"), QVariant::String);
-        item = addItemInfo(group, "ImageName", i18n("Name"), QVariant::String);
+
 }
 
@@ -96,5 +105,7 @@ bool KRgbPlugin::readInfo(KFileMetaInfo&
                 return false;
 
-        KFileMetaInfoGroup group = appendGroup(info, "Technical");
+        KFileMetaInfoGroup group;
+
+        group = appendGroup(info, "Technical");
 
         if (dimension == 1)
@@ -121,8 +132,48 @@ bool KRgbPlugin::readInfo(KFileMetaInfo&
                 appendItem(group, "Compression", i18n("Unknown"));
 
-        if (imagename[0])
+
+        group = appendGroup(info, "Comment");
                 appendItem(group, "ImageName", imagename);
+
+        file.close();
         return true;
 }
 
+
+bool KRgbPlugin::writeInfo(const KFileMetaInfo& info) const
+{
+        QFile file(info.path());
+
+        if (!file.open(IO_WriteOnly|IO_Raw)) {
+                kdDebug(7034) << "couldn't open " << QFile::encodeName(info.path()) << endl;
+                return false;
+        }
+
+        if (!file.at(24)) {
+                kdDebug(7034) << "couldn't set offset" << endl;
+                return false;
+        }
+
+        QDataStream dstream(&file);
+        QString s = info["Comment"]["ImageName"].value().toString();
+        s.truncate(79);
+
+        unsigned i;
+        for (i = 0; i < s.length(); i++)
+                dstream << Q_UINT8(s.latin1()[i]);
+        for (; i < 80; i++)
+                dstream << Q_UINT8(0);
+
+        file.close();
+        return true;
+}
+
+
+QValidator* KRgbPlugin::createValidator(const QString&, const QString &,
+                const QString &, QObject* parent, const char* name) const
+{
+        return new QRegExpValidator(QRegExp("[\x0020-\x007E]{79}"), parent, name);
+}
+
+
 #include "kfile_rgb.moc"

--- kdegraphics/kfile-plugins/rgb/kfile_rgb.h  #1.1:1.2
@@ -32,4 +32,9 @@ public:
         KRgbPlugin(QObject *parent, const char *name, const QStringList& args);
         virtual bool readInfo(KFileMetaInfo& info, uint what);
+        virtual bool writeInfo(const KFileMetaInfo& info) const;
+        virtual QValidator* createValidator(const QString& mimetype,
+                        const QString &group, const QString &key,
+                        QObject* parent, const char* name) const;
+
 };
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic