QVariant SensorBrowserModel::data( const QModelIndex & index, int role) const { //virtual
    if(!index.isValid()) return QVariant();
    switch(role) {
        case Qt::DisplayRole: {
            if(index.column()==0) {
                uint id = index.internalId();
                if(mSensorInfoMap.contains(id)) {
                    Q_ASSERT(mSensorInfoMap.value(id));
                    SensorInfo *sensorInfo = mSensorInfoMap.value(id);
                    return QString(sensorInfo->description() + " (" + KSGRD::SensorMgr->translateSensorType(sensorInfo->type()) + ')' );
                }
                if(mTreeNodeNames.contains(id)) return mTreeNodeNames.value(id);
                if(mHostInfoMap.contains(id)) {
                    Q_ASSERT(mHostInfoMap.value(id));
                    return mHostInfoMap.value(id)->hostName();
                }
            }
            return QString();
        }
        case Qt::DecorationRole: {
            if(index.column() == 0) {
                HostInfo *host = getHostInfo(index.internalId());
                KSGRD::SensorAgent *agent;
                if(host != NULL && (agent = host->sensorAgent())) {
                    if(agent->daemonOnLine())
                        return KIcon("computer");
                    else
                        return KIcon("dialog-warning");
                } else
                    return QIcon();
            } else
                return QIcon();
            break;
        }
        case Qt::ToolTipRole: {
            if(index.column() == 0) {
                HostInfo *host = getHostInfo(index.internalId());
                KSGRD::SensorAgent *agent;
                if(host != NULL && (agent = host->sensorAgent())) {
                    if(agent->daemonOnLine())
                        return agent->hostName();
                    else
                        return agent->reasonForOffline();
                }
            }
            break;
        }

    } //switch
    return QVariant();
}
QMimeData * SensorBrowserModel::mimeData ( const QModelIndexList & indexes ) const { //virtual
    QMimeData *mimeData = new QMimeData();
    if(indexes.size() != 1) return mimeData;
    SensorInfo *sensor = getSensorInfo(indexes[0]);
    if(!sensor) return mimeData;
    // Create text drag object as
    // "<hostname> <sensorname> <sensortype> <sensordescription>".
    // Only the description may contain blanks.
    Q_ASSERT(sensor);
    Q_ASSERT(sensor->hostInfo());
    QString mDragText = sensor->hostInfo()->hostName() + ' ' +
        sensor->name() + ' ' +
        sensor->type()+ ' ' +
        sensor->description();


    mimeData->setData( "application/x-ksysguard", mDragText.toUtf8() );
    return mimeData;
}