Skip to content

Commit

Permalink
Support setting QFileInfo properties from the command line.
Browse files Browse the repository at this point in the history
  • Loading branch information
Toke Høiland-Jørgensen committed May 10, 2012
1 parent eae0854 commit b5e44c4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 15 additions & 2 deletions code/src/processing-gui.cpp
Expand Up @@ -10,6 +10,7 @@
#include <QtCore/QFileInfo> #include <QtCore/QFileInfo>
#include <QtCore/QTime> #include <QtCore/QTime>
#include <QtCore/QSettings> #include <QtCore/QSettings>
#include <QtCore/QMetaProperty>
#include <QDebug> #include <QDebug>


#include "processing-gui.h" #include "processing-gui.h"
Expand Down Expand Up @@ -140,8 +141,20 @@ void ProcessingGUI::set_args(QMap<QString, QVariant> arguments) {
if(!properties.empty()) { if(!properties.empty()) {
QMap<QString, QVariant>::iterator i; QMap<QString, QVariant>::iterator i;
for(i = properties.begin(); i != properties.end(); ++i) { for(i = properties.begin(); i != properties.end(); ++i) {
if(!current_processor->setProperty(i.key().toLocal8Bit(), i.value())) { int idx = current_processor->metaObject()->indexOfProperty(i.key().toLocal8Bit().data());
qWarning() << "Error setting property: " << i.key(); if(idx == -1) {
qWarning() << "Non-existing property:" << i.key();
} else {
QMetaProperty property = current_processor->metaObject()->property(idx);
if(QString(property.typeName()) == "QFileInfo") {
QFileInfo info(i.value().toString());
qDebug() << info.canonicalFilePath();
if(!current_processor->setProperty(i.key().toLocal8Bit(), QVariant::fromValue(info))) {
qWarning() << "Error setting QFileInfo property: " << i.key() << info.filePath();
}
} else if(!current_processor->setProperty(i.key().toLocal8Bit(), i.value())) {
qWarning() << "Error setting property: " << i.key() << i.value();
}
} }
} }
} }
Expand Down
2 changes: 2 additions & 0 deletions code/src/processing-gui.h
Expand Up @@ -2,6 +2,7 @@
#define PROCESSING_GUI_H #define PROCESSING_GUI_H


#include <QtGui/QApplication> #include <QtGui/QApplication>
#include <QtCore/QFileInfo>
#include <cv.h> #include <cv.h>
#include "ui_processing-gui.h" #include "ui_processing-gui.h"
#include "processor.h" #include "processor.h"
Expand Down Expand Up @@ -62,4 +63,5 @@ private slots:
void image_changed(); void image_changed();
}; };


Q_DECLARE_METATYPE(QFileInfo)
#endif #endif

0 comments on commit b5e44c4

Please sign in to comment.