tools/qdbus/qdbusviewer/qdbusmodel.cpp
changeset 30 5dc02b23752f
parent 18 2f34d5167611
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
    73     QDBusItem *parent;
    73     QDBusItem *parent;
    74     QVector<QDBusItem *> children;
    74     QVector<QDBusItem *> children;
    75     bool isPrefetched;
    75     bool isPrefetched;
    76     QString name;
    76     QString name;
    77     QString caption;
    77     QString caption;
       
    78     QString typeSignature;
    78 };
    79 };
    79 
    80 
    80 QDomDocument QDBusModel::introspect(const QString &path)
    81 QDomDocument QDBusModel::introspect(const QString &path)
    81 {
    82 {
    82     QDomDocument doc;
    83     QDomDocument doc;
   116         QDBusItem *item = 0;
   117         QDBusItem *item = 0;
   117         if (child.tagName() == QLatin1String("method")) {
   118         if (child.tagName() == QLatin1String("method")) {
   118             item = new QDBusItem(QDBusModel::MethodItem,
   119             item = new QDBusItem(QDBusModel::MethodItem,
   119                     child.attribute(QLatin1String("name")), parent);
   120                     child.attribute(QLatin1String("name")), parent);
   120             item->caption = QLatin1String("Method: ") + item->name;
   121             item->caption = QLatin1String("Method: ") + item->name;
       
   122             //get "type" from <arg> where "direction" is "in"
       
   123             QDomElement n = child.firstChildElement();
       
   124             while (!n.isNull()) {
       
   125                 if (n.attribute(QLatin1String("direction")) == QLatin1String("in"))
       
   126                     item->typeSignature += n.attribute(QLatin1String("type"));
       
   127                 n = n.nextSiblingElement();
       
   128             }
   121         } else if (child.tagName() == QLatin1String("signal")) {
   129         } else if (child.tagName() == QLatin1String("signal")) {
   122             item = new QDBusItem(QDBusModel::SignalItem,
   130             item = new QDBusItem(QDBusModel::SignalItem,
   123                     child.attribute(QLatin1String("name")), parent);
   131                     child.attribute(QLatin1String("name")), parent);
   124             item->caption = QLatin1String("Signal: ") + item->name;
   132             item->caption = QLatin1String("Signal: ") + item->name;
   125         } else if (child.tagName() == QLatin1String("property")) {
   133         } else if (child.tagName() == QLatin1String("property")) {
   296 {
   304 {
   297     QDBusItem *item = static_cast<QDBusItem *>(index.internalPointer());
   305     QDBusItem *item = static_cast<QDBusItem *>(index.internalPointer());
   298     return item ? item->name : QString();
   306     return item ? item->name : QString();
   299 }
   307 }
   300 
   308 
       
   309 QString QDBusModel::dBusTypeSignature(const QModelIndex &index) const
       
   310 {
       
   311     QDBusItem *item = static_cast<QDBusItem *>(index.internalPointer());
       
   312     return item ? item->typeSignature : QString();
       
   313 }
       
   314 
   301 QModelIndex QDBusModel::findObject(const QDBusObjectPath &objectPath)
   315 QModelIndex QDBusModel::findObject(const QDBusObjectPath &objectPath)
   302 {
   316 {
   303     QStringList path = objectPath.path().split(QLatin1Char('/'), QString::SkipEmptyParts);
   317     QStringList path = objectPath.path().split(QLatin1Char('/'), QString::SkipEmptyParts);
   304 
   318 
   305     QDBusItem *item = root;
   319     QDBusItem *item = root;