You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
1.7 KiB
105 lines
1.7 KiB
#ifndef DOGDATABASE_H
|
|
#define DOGDATABASE_H
|
|
|
|
#include <QtSql>
|
|
<<<<<<< HEAD:src/Client2/fly_land/DogDatabase.h
|
|
#include <QWidget>
|
|
#include <QSqlQuery>
|
|
#include <QSqlDatabase>
|
|
=======
|
|
#include <QSqlDatabase>
|
|
#include <QWidget>
|
|
#include <QSqlQuery>
|
|
>>>>>>> master:src/Client/DogDatabase.h
|
|
#include <QString>
|
|
#include <QSqlRecord>
|
|
#include <QDebug>
|
|
#include "UAVDatabase.h"
|
|
|
|
using namespace std;
|
|
|
|
|
|
struct Dog
|
|
{
|
|
QString id;
|
|
int state;
|
|
QString ip;
|
|
int port;
|
|
double lon;
|
|
double lat;
|
|
};
|
|
|
|
|
|
class DogDatabase
|
|
{
|
|
// Q_OBJECT宏用于提供Qt信号槽和元对象系统服务
|
|
// 它必须限定为私有访问权限
|
|
//Q_OBJECT
|
|
|
|
public:
|
|
static DogDatabase *getInstance();
|
|
DogDatabase();
|
|
~DogDatabase();
|
|
|
|
Dog data;
|
|
|
|
//返回状态信息
|
|
int giveInfo(QString id);
|
|
//添加数据记录
|
|
bool add(const Dog &data);
|
|
//查询位置信息数据
|
|
Point ReturnUAVPosition( QString id);
|
|
|
|
|
|
|
|
private:
|
|
//打开
|
|
bool open(const QString &dbName,const QString &userName = QString(),const QString &passwd = QString());
|
|
//关闭
|
|
void close();
|
|
//开始添加字段
|
|
void beginAddFiled(const QString &tableName);
|
|
|
|
//添加字段
|
|
void addFiled(const QString &filedName);
|
|
|
|
//结束添加字段
|
|
void endAddFiled();
|
|
|
|
//开始添加行
|
|
void beginAddRow();
|
|
|
|
//添加字段值
|
|
void addValue(const QVariant &value);
|
|
|
|
//结束添加行
|
|
void endAddRow();
|
|
|
|
//执行
|
|
bool exec(const QString &sql);
|
|
|
|
|
|
private:
|
|
//数据库
|
|
QSqlDatabase m_sqlDb;
|
|
|
|
//表名
|
|
QString m_tableName;
|
|
|
|
//字段名
|
|
QStringList m_fieldName;
|
|
|
|
//头sql
|
|
QString m_headerSql;
|
|
|
|
//值sql
|
|
QString m_valueSql;
|
|
|
|
//已添加row数
|
|
int m_fieldAdd = 0;
|
|
|
|
};
|
|
|
|
|
|
#endif // DOGDATABASE_H
|