2 #include <QScriptEngine>
6 #include <QAtomicInteger>
19 m_Type(saver, this,
"type",
"object",
"Data object type"),
21 m_Creator(saver, this,
"creator",
"Unknown",
"QXRD Version Number"),
22 m_Version(saver, this,
"version",
"Unknown",
"QXRD Version Number"),
23 m_QtVersion(saver, this,
"qtVersion", QT_VERSION_STR,
"QT Version Number"),
24 m_Description(saver, this,
"description",
"",
"Object Description"),
25 m_FileName(saver, this,
"fileName",
"",
"File Name of Image"),
26 m_ObjectSaved(saver, this,
"objectSaved",0,
"Object is Saved?")
32 if (name.contains(
"/")) {
33 printMessage(tr(
"object %1 name contains \"/\"").arg(name));
65 if (qobject_cast<const QcepDataGroup*>(
this)) {
78 QFileInfo f(filePath);
82 dir.mkpath(dir.absolutePath());
92 QString base = f.baseName();
93 QString suff = f.completeSuffix();
103 for (
int i=1; ; i++) {
104 QString newname = dir.filePath(base+QString().sprintf(
"-%0*d.",width,i)+suff);
105 QFileInfo f(newname);
134 return engine->newQObject(data.data());
139 QObject *qobj = obj.toQObject();
150 printf(
"QcepDataObject::fromScriptValue returns NULL\n");
191 return parent->rootItem();
195 return qSharedPointerDynamicCast<QcepDataGroup>(obj);
213 for (
int i=0; i<parentGroup->
childCount(); i++) {
214 if (parentGroup->
item(i).data() ==
this) {
228 }
else if (col == 1) {
237 return QMetaType::typeName(
id);
242 return "Text (*.txt)";
QcepDataObjectPtr item(QString nm)
virtual void saveData(QString &name, QString filter, Overwrite canOverwrite=NoOverwrite)
static void fromScriptValue(const QScriptValue &obj, QcepDataObjectPtr &data)
QcepSettingsSaverWPtr m_Saver
static QScriptValue toScriptValue(QScriptEngine *engine, const QcepDataObjectPtr &data)
QSharedPointer< QcepDataGroup > QcepDataGroupPtr
QString uniqueFileName(QString name)
virtual int columnCount() const
void mkPath(QString filePath)
QcepDataObject(QcepSettingsSaverWPtr saver, QString name, int byteSize, QcepObject *parent)
virtual QcepDataGroupPtr parentItem() const
virtual ~QcepDataObject()
static int deletedObjects()
virtual int childCount() const
virtual QString fileFormatFilterString()
QString metaTypeName(int id) const
static int allocatedObjects()
virtual void setDefaultObjectData(QcepDataObject *obj)=0
virtual int rowCount() const
virtual void setParentItem(QcepDataGroupWPtr parent)
QcepDataGroupWPtr m_Parent
virtual void printMessage(QString msg, QDateTime dt=QDateTime::currentDateTime()) const
virtual int indexInParent() const
QcepDataGroupPtr rootItem()
QSharedPointer< QcepDataObject > QcepDataObjectPtr
virtual QString description() const
QcepApplication * g_Application
static QAtomicInt s_ObjectDeleteCount(0)
virtual QcepDataObjectPtr item(int n)
static QcepDataObjectPtr newDataObject(QcepSettingsSaverWPtr saver, QString name, QcepObject *parent)
static QAtomicInt s_ObjectAllocateCount(0)
virtual QVariant columnData(int col) const
QWeakPointer< QcepSettingsSaver > QcepSettingsSaverWPtr
QWeakPointer< QcepDataGroup > QcepDataGroupWPtr
QcepSettingsSaverWPtr saver()