git-svn-id: svn://db.shs.com.ru/libs@481 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -10,6 +10,16 @@
|
||||
|
||||
bool __QADTypesRegistrator__::_inited = false;
|
||||
|
||||
|
||||
__QADTypesRegistrator__::__QADTypesRegistrator__(int) {
|
||||
instance()->_inited = true;
|
||||
}
|
||||
|
||||
__QADTypesRegistrator__ *__QADTypesRegistrator__::instance() {
|
||||
static __QADTypesRegistrator__ ret;
|
||||
return &ret;
|
||||
}
|
||||
|
||||
__QADTypesRegistrator__::__QADTypesRegistrator__() {
|
||||
if (_inited) return;
|
||||
_inited = true;
|
||||
@@ -38,7 +48,7 @@ __QADTypesRegistrator__::__QADTypesRegistrator__() {
|
||||
#endif
|
||||
}
|
||||
|
||||
__QADTypesRegistrator__ __registrator__;
|
||||
__QADTypesRegistrator__ __registrator__(1);
|
||||
|
||||
|
||||
int QAD::Enum::selectedValue() const {
|
||||
@@ -124,26 +134,36 @@ 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";
|
||||
if (__QADTypesRegistrator__::instance()->toString_funcs.contains(qMetaTypeId<QAD::IODevice>())) {
|
||||
QVariant v;
|
||||
v.setValue(*this);
|
||||
(*(__QADTypesRegistrator__::instance()->toString_funcs[qMetaTypeId<QAD::IODevice>()]))(v, s);
|
||||
return s;
|
||||
} else {
|
||||
// s += "IODevice(" + prefix + ", mode=";
|
||||
// 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) {
|
||||
// s += ", flags=";
|
||||
// if (options & 1)
|
||||
// s += "br";
|
||||
// if (options & 2)
|
||||
// if (options & 1)
|
||||
// s+= "|";
|
||||
// s += "bw";
|
||||
// }
|
||||
// PropertyStorage ps = props;
|
||||
// foreach (const PropertyStorage::Property & p, ps) {
|
||||
// QString vs = p.value.toString();
|
||||
// if (p.value.type() == QVariant::StringList)
|
||||
// vs = p.value.toStringList().join(";");
|
||||
// s += ", " + p.name + "=\"" + vs + "\"";
|
||||
// }
|
||||
// s += ")";
|
||||
return s;
|
||||
}
|
||||
PropertyStorage ps = props;
|
||||
foreach (const PropertyStorage::Property & p, ps) {
|
||||
QString vs = p.value.toString();
|
||||
if (p.value.type() == QVariant::StringList)
|
||||
vs = p.value.toStringList().join(";");
|
||||
s += ", " + p.name + "=\"" + vs + "\"";
|
||||
}
|
||||
s += ")";
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -89,6 +89,10 @@ inline QDebug operator <<(QDebug s, const QAD::IODevice & v) {s.nospace() << v.t
|
||||
|
||||
class __QADTypesRegistrator__ {
|
||||
public:
|
||||
__QADTypesRegistrator__(int);
|
||||
static __QADTypesRegistrator__ * instance();
|
||||
QMap<int, void(*)(const QVariant &, QString &)> toString_funcs;
|
||||
private:
|
||||
__QADTypesRegistrator__();
|
||||
static bool _inited;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user