[Kst] kdeextragear-2/kst/kst/datasources/planck
George Staikos
staikos at kde.org
Fri Oct 24 08:01:35 CEST 2003
CVS commit by staikos:
add planck file detection. The new method is that in order to access planck
data, the user must provide the xml filename. The vectors are then considered
to be a group and an object.
A pparser.cpp 1.1 [GPL (v2+)]
A pparser.h 1.1 [GPL (v2+)]
M +1 -1 Makefile.am 1.2
M +37 -8 planck.cpp 1.2
M +14 -10 planck.h 1.2
--- kdeextragear-2/kst/kst/datasources/planck/Makefile.am #1.1:1.2
@@ -4,5 +4,5 @@
kstdata_planck_la_LDFLAGS=$(all_libraries) -module -avoid-version
-kstdata_planck_la_SOURCES=planck.cpp planckdata.cpp plancktoi.cpp
+kstdata_planck_la_SOURCES=planck.cpp planckdata.cpp plancktoi.cpp pparser.cpp
METASOURCES=AUTO
--- kdeextragear-2/kst/kst/datasources/planck/planck.cpp #1.1:1.2
@@ -17,8 +17,11 @@
#include "planck.h"
+#include <qdir.h>
+#include <qfile.h>
-PlanckSource::PlanckSource(const QString& filename, const QString& type)
-: KstDataSource(filename, type) {
+PlanckSource::PlanckSource(const QString& filename, Planck::Database& db)
+: KstDataSource(filename, "PLANCK I/O"), _db(db) {
+ _valid = true;
}
@@ -61,5 +64,5 @@ int PlanckSource::frameCount() const {
QString PlanckSource::fileType() const {
- return QString::null;
+ return "PLANCK I/O";
}
@@ -70,19 +73,45 @@ void PlanckSource::save(QTextStream &ts)
+static bool parseXML(const QString& filename, Planck::Database& db) {
+ if (!QFile::exists(filename)) {
+ return false;
+ }
+
+ QFile f(filename);
+ if (!f.open(IO_ReadOnly)) {
+ return false;
+ }
+
+ if (0 != Planck::Parser::parse(&f, db)) {
+ return false;
+ }
+
+ if (!QDir(db.path()).exists()) {
+ return false;
+ }
+ return true;
+}
+
extern "C" {
KstDataSource *create_planck(const QString& filename, const QString& type) {
- return new PlanckSource(filename, type);
+ Planck::Database db;
+ if (!parseXML(filename, db)) {
+ return 0L;
+ }
+ return new PlanckSource(filename, db);
}
QStringList provides_planck() {
QStringList rc;
- // create the stringlist
+ rc += "PLANCK I/O";
return rc;
}
bool understands_planck(const QString& filename) {
- // determine if it is an X file
- Q_UNUSED(filename)
+ Planck::Database db;
+ if (!parseXML(filename, db)) {
return false;
+ }
+ return true;
}
--- kdeextragear-2/kst/kst/datasources/planck/planck.h #1.1:1.2
@@ -20,9 +20,10 @@
#include <kstdatasource.h>
+#include "pparser.h"
class PlanckSource : public KstDataSource {
-public:
- PlanckSource(const QString& filename, const QString& type);
+ public:
+ PlanckSource(const QString& filename, Planck::Database& db);
virtual ~PlanckSource();
@@ -41,4 +42,7 @@ public:
virtual void save(QTextStream &ts);
+
+ private:
+ Planck::Database _db;
};
More information about the Kst
mailing list