added legacyPairing property to NearbyItem
authorKevron Rees <kevron_m_rees@linux.intel.com>
Thu, 10 Feb 2011 23:38:34 +0000 (15:38 -0800)
committerKevron Rees <kevron_m_rees@linux.intel.com>
Thu, 10 Feb 2011 23:38:34 +0000 (15:38 -0800)
nearbydevicesmodel.cpp
nearbydevicesmodel.h

index 1112645..a8fa3f0 100644 (file)
@@ -41,24 +41,12 @@ int NearbyDevicesModel::rowCount(const QModelIndex &parent) const
 
 QVariant NearbyDevicesModel::data(const QModelIndex &index, int role) const
 {
-       /**if (role == NearbyDevicesModelRoles::name)
+
+       if(!index.isValid() || index.row() < 0)
        {
-               QString rowData;
-               if(index.row() < devices.size())
-               {
-                       rowData = deviceAliasMap[devices[index.row()]];
-               }
-               return QVariant(rowData);
+               qDebug()<<"invalid index"<<index.row();
+               return QVariant();
        }
-       else if (role == NearbyDevicesModelRoles::address)
-       {
-               QString rowData;
-               if(index.row() < devices.size())
-               {
-                       rowData = devices[index.row()];
-               }
-               return QVariant(rowData);
-       }*/
 
        QString roleName = roleNames()[role];
        QMetaObject object = NearbyItem::staticMetaObject;
@@ -67,6 +55,7 @@ QVariant NearbyDevicesModel::data(const QModelIndex &index, int role) const
        {
                if(object.property(i).name() == roleName)
                {
+
                        return object.property(i).read(devices[index.row()]);
                }
        }
@@ -141,8 +130,8 @@ void NearbyDevicesModel::deviceCreated(QString hwaddy, QVariantMap properties)
        {
                beginInsertRows(QModelIndex(), devices.size()+1, devices.size()+1);
 
-               NearbyItem* item = new NearbyItem(properties["Alias"].toString(),
-                              hwaddy,properties["Icon"].toString(),this);
+               NearbyItem* item = new NearbyItem(properties["Name"].toString(),
+                              hwaddy,properties["Icon"].toString(),properties["LegacyPairing"].toBool(),this);
 
                devices.append(item);
                emit nearbyDeviceFound(devices.indexOf(item));
@@ -157,8 +146,9 @@ void NearbyDevicesModel::deviceRemoved(QString hwaddy)
                if(device->address() == hwaddy)
                {
                        int i=devices.indexOf(device);
+                       //if(i == -1) continue;
                        beginRemoveRows(QModelIndex(),i,i);
-                       devices.removeAll(device);
+                       devices.removeAt(i);
                        emit nearbyDeviceRemoved(i);
                        endRemoveRows();
                }
index 3bc9ab6..1c3f87e 100644 (file)
@@ -26,23 +26,26 @@ class NearbyItem: public QObject
        Q_PROPERTY(QString name READ name)
        Q_PROPERTY(QString address READ address)
        Q_PROPERTY(QString icon READ icon)
+       Q_PROPERTY(bool legacyPairing READ legacyPairing)
 public:
-       NearbyItem(QString name="", QString address="", QString icon="", QObject* parent = 0)
+       NearbyItem(QString name="", QString address="", QString icon="", bool legacy=false, QObject* parent = 0)
        :QObject(parent)
        {
            m_name=name;
            m_addy=address;
            m_icon=icon;
+           m_legacy = legacy;
        }
 
        QString name() { return m_name; }
        QString address() { return m_addy; }
        QString icon() { return m_icon; }
-
+       bool legacyPairing() { return m_legacy; }
 private:
        QString m_name;
        QString m_addy;
        QString m_icon;
+       bool m_legacy;
 };
 
 class NearbyDevicesModel : public QAbstractListModel