0 Star 0 Fork 3

fujingyuan/AutoVehTypeMon

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
dealexcelfile.cpp 2.75 KB
一键复制 编辑 原始数据 按行查看 历史
惊险一血 提交于 2014-10-28 10:39 . 首次提交
#include "dealexcelfile.h"
#include <QSqlError>
#include <QFileInfo>
#include <QMessageBox>
DealExcelFile::DealExcelFile(QObject *parent) :
QObject(parent)
{
xlsOpenFlag = false;
dbOpenFlag = false;
hasExistFile = false;
IsXlsFile = false;
IsDbFile = false;
m_bOpenSuccess = false;
sqlite = new multideal();//一个数据库操作接口
excelFile = new ExcelEngine;
//model = new QSqlTableModel(this);不能放在这里 否则TableView为空
//tableview = new QTableView(this);
//tableview->hide();
}
DealExcelFile::~DealExcelFile()
{
excelFile->Close();
}
DealExcelFile* getDealExecl()
{
static DealExcelFile execl;
return &execl;
}
bool DealExcelFile::OpenExcelFile()
{
if(!m_bOpenSuccess)
{
return false;
}
if(!excelFile->Open())
{
return false;
}
return true;
}
void DealExcelFile::Close()
{
excelFile->Close();
}
void DealExcelFile::Init()
{
QFile file("./RoadInfo.xls");
if(!file.exists())
{
m_bOpenSuccess = false;
QMessageBox::warning(0,"提示",tr("<font size='2' face='宋体'>路段表不存在</font>"),"确定");
return;
}
if(!file.open(QIODevice::ReadOnly))
{
m_bOpenSuccess = false;
return;
}
QFileInfo tmp(file);
excelFile->SetExcelFile(tmp.absoluteFilePath());
m_bOpenSuccess = true;
//excelFile->Init();
}
void DealExcelFile::createTable(int row, int col)
{
//excelTable = new QTableWidget(row,col,this);
excelTable = new QTableWidget(row,col);
excelTable->setGeometry(0,20,400,280);
excelFile->ReadDataToTable(excelTable);
excelTable->show();
xlsOpenFlag = true;
}
bool DealExcelFile::createTree(int row, int col,QTreeWidget* tree)
{
if(!OpenExcelFile())
{
return false;
}
excelTree = tree;
excelTree->setHeaderLabel("路段信息");
excelFile->ReadDataToTree(excelTree);
excelTree->show();
//excelTree->expandAll();
excelTree->collapseAll();
return true;
}
void DealExcelFile::SetPointStatue(const QString ip, const int statue)
{
QMutexLocker lock(&m_mutex);
//将设备状态存在map中,用于树初始化时设置树状态
excelFile->SetIPAndStatue(ip,statue);
excelFile->SetPointStatue(ip,statue);
}
//void DealExcelFile::SetIPAndStatue(const QString ip, const int statue)
//{
// QMutexLocker lock(&m_mutex);
// excelFile->SetIPAndStatue(ip,statue);
//}
bool DealExcelFile::GetIPByItem(QTreeWidgetItem *item, QString &ip)
{
QMutexLocker lock(&m_mutex);
return excelFile->GetItemLaneIP(item,ip);
}
bool DealExcelFile::GetNameByIP(const QString ip, QString &name,QString &firstName)
{
QMutexLocker lock(&m_mutex);
return excelFile->GetItemLaneName(ip,name,firstName);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fujingyuan/AutoVehTypeMon.git
git@gitee.com:fujingyuan/AutoVehTypeMon.git
fujingyuan
AutoVehTypeMon
AutoVehTypeMon
master

搜索帮助