Fix bug: info not shown.

After adding status info to device list, listitem.text() is no longer
the device id. When constructing sql query to get info, the string must
be splitted with ','; the first element is used as device id.
Tweak list ordering.

Device list ordering:
- by device_state_id: online -> malfunctioning -> offline
- then by last connected timestamp: latested connected first