Added functions DeviceModel::haveError() and DeviceModel::errorString()
This commit is contained in:
parent
e4b90eff4f
commit
70194457a9
2 changed files with 22 additions and 2 deletions
|
@ -21,6 +21,10 @@ DeviceModel::DeviceModel(QObject *parent)
|
||||||
{
|
{
|
||||||
connect(this, SIGNAL(deviceChange(int,int,int)), this, SLOT(deviceChanged(int,int,int)), Qt::QueuedConnection);
|
connect(this, SIGNAL(deviceChange(int,int,int)), this, SLOT(deviceChanged(int,int,int)), Qt::QueuedConnection);
|
||||||
int numberOfDevices = tdGetNumberOfDevices();
|
int numberOfDevices = tdGetNumberOfDevices();
|
||||||
|
errorNo = 0;
|
||||||
|
if (numberOfDevices < 0) { //Error
|
||||||
|
errorNo = numberOfDevices;
|
||||||
|
}
|
||||||
for( int i = 0; i < numberOfDevices; ++i ) {
|
for( int i = 0; i < numberOfDevices; ++i ) {
|
||||||
int id = tdGetDeviceId(i);
|
int id = tdGetDeviceId(i);
|
||||||
Device *device = new Device(id, SUPPORTED_METHODS, this);
|
Device *device = new Device(id, SUPPORTED_METHODS, this);
|
||||||
|
@ -117,6 +121,18 @@ QVariant DeviceModel::headerData ( int section, Qt::Orientation orientation, int
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DeviceModel::haveError() const {
|
||||||
|
return errorNo != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DeviceModel::errorString() const {
|
||||||
|
char *error = tdGetErrorString(errorNo);
|
||||||
|
QString errorStr = QString::fromUtf8( error );
|
||||||
|
tdReleaseString(error);
|
||||||
|
return errorStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Device *DeviceModel::device( const QModelIndex &index ) {
|
Device *DeviceModel::device( const QModelIndex &index ) {
|
||||||
if (index.row() >= devices.size()) {
|
if (index.row() >= devices.size()) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -22,6 +22,9 @@ public:
|
||||||
Device *device( const QModelIndex & );
|
Device *device( const QModelIndex & );
|
||||||
int deviceId( const QModelIndex & );
|
int deviceId( const QModelIndex & );
|
||||||
|
|
||||||
|
bool haveError() const;
|
||||||
|
QString errorString() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deviceChange(int deviceId, int, int);
|
void deviceChange(int deviceId, int, int);
|
||||||
void showMessage( const QString &title, const QString &message, const QString &detailedMessage );
|
void showMessage( const QString &title, const QString &message, const QString &detailedMessage );
|
||||||
|
@ -46,6 +49,7 @@ private:
|
||||||
// mutable QHash<int, int> indexToId;
|
// mutable QHash<int, int> indexToId;
|
||||||
QList<Device *> devices;
|
QList<Device *> devices;
|
||||||
int deviceChangeCallbackId;
|
int deviceChangeCallbackId;
|
||||||
|
int errorNo;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DEVICEMODEL_H
|
#endif // DEVICEMODEL_H
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue