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);
|
||||
int numberOfDevices = tdGetNumberOfDevices();
|
||||
errorNo = 0;
|
||||
if (numberOfDevices < 0) { //Error
|
||||
errorNo = numberOfDevices;
|
||||
}
|
||||
for( int i = 0; i < numberOfDevices; ++i ) {
|
||||
int id = tdGetDeviceId(i);
|
||||
Device *device = new Device(id, SUPPORTED_METHODS, this);
|
||||
|
@ -117,6 +121,18 @@ QVariant DeviceModel::headerData ( int section, Qt::Orientation orientation, int
|
|||
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 ) {
|
||||
if (index.row() >= devices.size()) {
|
||||
return 0;
|
||||
|
|
|
@ -21,7 +21,10 @@ public:
|
|||
|
||||
Device *device( const QModelIndex & );
|
||||
int deviceId( const QModelIndex & );
|
||||
|
||||
|
||||
bool haveError() const;
|
||||
QString errorString() const;
|
||||
|
||||
signals:
|
||||
void deviceChange(int deviceId, int, int);
|
||||
void showMessage( const QString &title, const QString &message, const QString &detailedMessage );
|
||||
|
@ -38,7 +41,7 @@ private:
|
|||
void triggerCellUpdate(int row, int column);
|
||||
// static void deviceEvent(int deviceId, int method, const char *data, int callbackId, void *context);
|
||||
static void WINAPI deviceChangeEvent(int deviceId, int, int, int, void *);
|
||||
|
||||
|
||||
// void connectDeviceSignals( Device *device ) const;
|
||||
// int deviceId( const QModelIndex &index ) const;
|
||||
// int deviceId( int index ) const;
|
||||
|
@ -46,6 +49,7 @@ private:
|
|||
// mutable QHash<int, int> indexToId;
|
||||
QList<Device *> devices;
|
||||
int deviceChangeCallbackId;
|
||||
int errorNo;
|
||||
};
|
||||
|
||||
#endif // DEVICEMODEL_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue