git-svn-id: svn://db.shs.com.ru/libs@481 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
#include <QLineEdit>
|
||||
#include <QToolButton>
|
||||
#include <QBoxLayout>
|
||||
#include <piqt.h>
|
||||
#include <piiodevice.h>
|
||||
|
||||
|
||||
IODeviceEdit::IODeviceEdit(QWidget * parent): QWidget(parent) {
|
||||
@@ -73,4 +75,18 @@ public:
|
||||
|
||||
__IODeviceEditRegistrator__::__IODeviceEditRegistrator__() {
|
||||
QVariantEditorFactories::registerEditorFactory(qMetaTypeId<QAD::IODevice>(), new Factory());
|
||||
__QADTypesRegistrator__::instance()->toString_funcs.insert(qMetaTypeId<QAD::IODevice>(), &QAD_IODevice_toString);
|
||||
}
|
||||
|
||||
|
||||
void QAD_IODevice_toString(const QVariant & v, QString & r) {
|
||||
PIVariantTypes::IODevice sd = Q2PIVariant(v).toIODevice();
|
||||
// piCout << sd;
|
||||
PIIODevice * rd = PIIODevice::createFromVariant(sd);
|
||||
if (rd) {
|
||||
PIString ps = rd->constructFullPath();
|
||||
r = PI2QString(ps);
|
||||
} else {
|
||||
piCout << "error in " << sd;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,4 +48,5 @@ public:
|
||||
|
||||
static __IODeviceEditRegistrator__ __iodeviceeditregistrator__;
|
||||
|
||||
void QAD_IODevice_toString(const QVariant & v, QString & r);
|
||||
#endif // PIQT_IODEVICE_EDIT_H
|
||||
|
||||
@@ -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