git-svn-id: svn://db.shs.com.ru/libs@475 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -34,7 +34,7 @@ __QADTypesRegistrator__::__QADTypesRegistrator__() {
|
||||
QMetaType::registerConverter<QAD::Enum, QString>(&QAD::Enum::selectedName);
|
||||
QMetaType::registerConverter<QAD::File, QString>(&QAD::File::toString);
|
||||
QMetaType::registerConverter<QAD::Dir, QString>(&QAD::Dir::toString);
|
||||
/// TDOD : //QMetaType::registerConverter<QAD::Dir, QString>(&QAD::IODevice::constructFullPath);
|
||||
QMetaType::registerConverter<QAD::IODevice, QString>(&QAD::IODevice::toString);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -122,6 +122,30 @@ QAD::Enum & QAD::Enum::operator <<(const QStringList & v) {
|
||||
|
||||
|
||||
|
||||
QString QAD::IODevice::toString() const {
|
||||
QString s;
|
||||
s += "IODevice(" + prefix + ", ";
|
||||
int rwc = 0;
|
||||
if (mode & QIODevice::ReadOnly) {s += "r"; ++rwc;}
|
||||
if (mode & QIODevice::WriteOnly) {s += "w"; ++rwc;}
|
||||
if (rwc == 1) s += "o";
|
||||
if (options != 0) {
|
||||
if (options & 1)
|
||||
s += " br";
|
||||
if (options & 2)
|
||||
s += " bw";
|
||||
}
|
||||
PropertyStorage ps = props;
|
||||
foreach (const PropertyStorage::Property & p, ps) {
|
||||
s += ", " + p.name + "=\"" + p.value.toString() + "\"";
|
||||
}
|
||||
s += ")";
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QVariant::Type typeFromLetter(const QString & l) {
|
||||
if (l.isEmpty()) return QVariant::String;
|
||||
QString ft = l.left(1);
|
||||
|
||||
@@ -48,11 +48,14 @@ namespace QAD {
|
||||
};
|
||||
|
||||
struct IODevice {
|
||||
IODevice(const QString & devece_prefix = QString(), const PropertyStorage & device_properties = PropertyStorage(), int open_mode = QIODevice::ReadWrite, int device_options = 0)
|
||||
: prefix(devece_prefix), mode(open_mode), opts(device_options), props(device_properties) {}
|
||||
IODevice(const QString & device_prefix = QString(), const PropertyStorage & device_properties = PropertyStorage(),
|
||||
int open_mode = QIODevice::ReadWrite, int device_options = 0)
|
||||
: prefix(device_prefix), mode(open_mode), options(device_options), props(device_properties) {}
|
||||
QString toString() const;
|
||||
bool isValid() const {return !prefix.isEmpty();}
|
||||
QString prefix;
|
||||
int mode;
|
||||
int opts;
|
||||
int options;
|
||||
PropertyStorage props;
|
||||
};
|
||||
|
||||
@@ -79,29 +82,10 @@ inline QDataStream & operator >>(QDataStream & s, QAD::Dir & v) {s >> v.dir >> v
|
||||
inline QDebug operator <<(QDebug s, const QAD::Dir & v) {s.nospace() << v.dir; return s.space();}
|
||||
|
||||
Q_DECLARE_METATYPE(QAD::IODevice)
|
||||
inline QDataStream & operator <<(QDataStream & s, const QAD::IODevice & v) {s << v.prefix << v.mode << v.opts << v.props; return s;}
|
||||
inline QDataStream & operator >>(QDataStream & s, QAD::IODevice & v) {s >> v.prefix >> v.mode >> v.opts >> v.props; return s;}
|
||||
inline QDebug operator <<(QDebug d, const QAD::IODevice & v) {
|
||||
QString s;
|
||||
s += "IODevice(" + v.prefix + ", ";
|
||||
int rwc = 0;
|
||||
if (v.mode & QIODevice::ReadOnly) {s += "r"; ++rwc;}
|
||||
if (v.mode & QIODevice::WriteOnly) {s += "w"; ++rwc;}
|
||||
if (rwc == 1) s += "o";
|
||||
if (v.opts != 0) {
|
||||
if (v.opts & 1)
|
||||
s += " br";
|
||||
if (v.opts & 2)
|
||||
s += " bw";
|
||||
}
|
||||
PropertyStorage ps = v.props;
|
||||
foreach (const PropertyStorage::Property & p, ps) {
|
||||
s += ", " + p.name + "=\"" + p.value.toString() + "\"";
|
||||
}
|
||||
s += ")";
|
||||
d.noquote() << s;
|
||||
return d;
|
||||
}
|
||||
inline QDataStream & operator <<(QDataStream & s, const QAD::IODevice & v) {s << v.prefix << v.mode << v.options << v.props; return s;}
|
||||
inline QDataStream & operator >>(QDataStream & s, QAD::IODevice & v) {s >> v.prefix >> v.mode >> v.options >> v.props; return s;}
|
||||
inline QDebug operator <<(QDebug s, const QAD::IODevice & v) {s.nospace() << v.toString(); return s.space();}
|
||||
|
||||
|
||||
class __QADTypesRegistrator__ {
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user