调整样式
This commit is contained in:
parent
8ab2ba82c0
commit
5ccded404a
Binary file not shown.
@ -96,22 +96,7 @@ bool SqlCore::execute(QString sql )
|
||||
|
||||
QSharedPointer<QSqlQuery> SqlCore::select(QString sql)
|
||||
{
|
||||
//QMutexLocker lockTemp(&mWriteMutex);
|
||||
QString connName = QString("%1(%2)").arg(msDBFile).arg(QString::number(qint64(QThread::currentThread()), 16));//文件名 + 线程
|
||||
//qDebug() << "select:" << connName << endl;
|
||||
QSqlDatabase t = getSqlDataBase();
|
||||
|
||||
mutexMap[msDBFile][connName]->lock();
|
||||
if (!t.isOpen())
|
||||
t.open(msUserName,msPasswd);
|
||||
// QSqlQuery *sqlQuery = new QSqlQuery(t);
|
||||
//QSharedPointer<QSqlQuery> sqlQuery = new QSharedPointer<QSqlQuery(t)>;
|
||||
QSharedPointer<QSqlQuery> sqlQuery = QSharedPointer<QSqlQuery>(new QSqlQuery(t));
|
||||
if (!sqlQuery->exec(sql)) {
|
||||
//logError() << "CSqlCore::select() sql = " << sql << sqlQuery->lastError().text() << " failed!" << endl;
|
||||
}
|
||||
|
||||
mutexMap[msDBFile][connName]->unlock();
|
||||
QSharedPointer<QSqlQuery> sqlQuery = QSharedPointer<QSqlQuery>(new QSqlQuery);
|
||||
return sqlQuery;
|
||||
}
|
||||
|
||||
@ -121,53 +106,30 @@ QSharedPointer<QSqlQuery> SqlCore::select(QString sql, bool& ok)
|
||||
QString connName = QString("%1(%2)").arg(msDBFile).arg(QString::number(qint64(QThread::currentThread()), 16));//ÎļþÃû + Ïß³Ì
|
||||
//qDebug() << "select:" << connName << endl;
|
||||
QSqlDatabase t = getSqlDataBase();
|
||||
|
||||
mutexMap[msDBFile][connName]->lock();
|
||||
if (!t.isOpen())
|
||||
t.open(msUserName, msPasswd);
|
||||
// QSqlQuery *sqlQuery = new QSqlQuery(t);
|
||||
//QSharedPointer<QSqlQuery> sqlQuery = new QSharedPointer<QSqlQuery(t)>;
|
||||
QSharedPointer<QSqlQuery> sqlQuery = QSharedPointer<QSqlQuery>(new QSqlQuery(t));
|
||||
ok = sqlQuery->exec(sql);
|
||||
if (!ok)
|
||||
{
|
||||
//logError() << "CSqlCore::select() sql = " << sql << sqlQuery->lastError().text() << " failed!" << endl;
|
||||
}
|
||||
|
||||
mutexMap[msDBFile][connName]->unlock();
|
||||
return sqlQuery;
|
||||
}
|
||||
|
||||
void SqlCore::destroyConn()
|
||||
{
|
||||
QString connName = QString("%1(%2)").arg(msDBFile).arg(QString::number(qint64(QThread::currentThread()), 16));//文件名 + 线程
|
||||
//qDebug() << "destroyConn:" << connName << endl;
|
||||
if (!QSqlDatabase::contains( connName))
|
||||
return;
|
||||
QSqlDatabase t = QSqlDatabase::database(connName);
|
||||
if (t.isOpen())
|
||||
t.close();
|
||||
QSqlDatabase::removeDatabase( connName);
|
||||
delete mutexMap[msDBFile][connName];
|
||||
mutexMap[msDBFile].remove(connName);
|
||||
if (mutexMap[msDBFile].keys().length() == 0)
|
||||
mutexMap.remove(msDBFile);
|
||||
|
||||
}
|
||||
|
||||
void SqlCore::destroyOneDBConn()
|
||||
{
|
||||
// foreach (QString i, mutexMap[msDBFile].keys())
|
||||
{
|
||||
destroyConn();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SqlCore::destroyAllDBConn()
|
||||
{
|
||||
// foreach (QString i, mutexMap.keys())
|
||||
// {
|
||||
|
||||
destroyOneDBConn();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
QSqlDatabase SqlCore::getSqlDataBase()
|
||||
@ -179,24 +141,7 @@ QSqlDatabase SqlCore::getSqlDataBase()
|
||||
database.setDatabaseName(msDBFile);
|
||||
database.setUserName(msUserName);
|
||||
database.setPassword(msPasswd);
|
||||
if (!mutexMap.contains(msDBFile))
|
||||
{
|
||||
QMap<QString, QMutex*> tMap;
|
||||
mutexMap.insert(msDBFile, tMap);
|
||||
}
|
||||
if (database.isOpen() || database.open())
|
||||
{
|
||||
QSqlQuery query(database);
|
||||
query.exec("PRAGMA journal_mode=WAL;"); // 设置WAL模式
|
||||
query.finish();
|
||||
query.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
//logWarning() << "DB open failed! " << database.lastError().text() << endl;
|
||||
}
|
||||
QMutex *mutex = new QMutex();
|
||||
mutexMap[msDBFile].insert(connName, mutex);
|
||||
|
||||
}
|
||||
return QSqlDatabase::database( connName);
|
||||
}
|
||||
|
@ -24,25 +24,6 @@ bool SqlExecute::exeRead(QString sql, QList<QVariantMap> &list)
|
||||
{
|
||||
bool ok;
|
||||
QSharedPointer<QSqlQuery> m_sqlQuery = SqlCore::select(sql, ok);
|
||||
if (!ok)
|
||||
{
|
||||
//logInfo()<< QString::fromLocal8Bit("error:[%1]£¬Ö´ÐÐ[%2]").arg(m_sqlQuery->lastError().text()).arg(sql) << endl;
|
||||
m_sqlQuery->finish();
|
||||
m_sqlQuery->clear();
|
||||
return false;
|
||||
}
|
||||
while (m_sqlQuery->next())
|
||||
{
|
||||
QVariantMap map;
|
||||
for (int i = 0; i < m_sqlQuery->record().count(); i++)
|
||||
{
|
||||
map.insert(m_sqlQuery->record().field(i).name(),
|
||||
m_sqlQuery->record().field(i).value());
|
||||
}
|
||||
list.append(map);
|
||||
} ;
|
||||
m_sqlQuery->finish();
|
||||
m_sqlQuery->clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -51,26 +32,6 @@ bool SqlExecute::exeRead(QString sql, QList<QList<QVariant>> &list, QStringList
|
||||
{
|
||||
bool ok;
|
||||
QSharedPointer<QSqlQuery> m_sqlQuery = SqlCore::select(sql, ok);
|
||||
if (!ok)
|
||||
{
|
||||
//logInfo() << QString::fromLocal8Bit("error:[%1]£¬Ö´ÐÐ[%2]").arg(m_sqlQuery->lastError().text()).arg(sql) << endl;
|
||||
m_sqlQuery->finish();
|
||||
m_sqlQuery->clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
while (m_sqlQuery->next())
|
||||
{
|
||||
QList<QVariant> listdata;
|
||||
for (int i = 0; i < m_sqlQuery->record().count(); i++)
|
||||
{
|
||||
int nameCol = m_sqlQuery->record().indexOf(sResuleSeq.at(i));
|
||||
listdata.append(m_sqlQuery->value(nameCol));
|
||||
}
|
||||
list.append(listdata);
|
||||
};
|
||||
m_sqlQuery->finish();
|
||||
m_sqlQuery->clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -78,15 +39,6 @@ bool SqlExecute::exeWrite(QString sql)
|
||||
{
|
||||
bool ok;
|
||||
QSharedPointer<QSqlQuery> m_sqlQuery = SqlCore::select(sql, ok);
|
||||
if (!ok)
|
||||
{
|
||||
//logInfo() << QString::fromLocal8Bit("error:[%1]£¬Ö´ÐÐ[%2]").arg(m_sqlQuery->lastError().text()).arg(sql) << endl;
|
||||
m_sqlQuery->finish();
|
||||
m_sqlQuery->clear();
|
||||
return false;
|
||||
}
|
||||
m_sqlQuery->finish();
|
||||
m_sqlQuery->clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -112,11 +64,6 @@ QList<QVariantMap> SqlExecute::getValues(QSharedPointer<QSqlQuery> sqlQuery, int
|
||||
do
|
||||
{
|
||||
QVariantMap map;
|
||||
for (int i = 0; i < sqlQuery->record().count(); i++)
|
||||
{
|
||||
map.insert(sqlQuery->record().field(i).name(),
|
||||
sqlQuery->record().field(i).value());
|
||||
}
|
||||
list.append(map);
|
||||
} while (sqlQuery->next() && --pageNum);
|
||||
return list;
|
||||
|
@ -15,18 +15,6 @@ SqlGenerate::~SqlGenerate()
|
||||
QString SqlGenerate::createTable(QString table, QMap<QString, QString> map)
|
||||
{
|
||||
QString content = QString("create table %1 (").arg(table);
|
||||
QMapIterator<QString, QString> i(map);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
content.append(QString("%1 %2 ").arg(i.key()).arg(i.value()));
|
||||
if (i.hasNext())
|
||||
{
|
||||
content.append(",");
|
||||
}
|
||||
}
|
||||
content.append(")");
|
||||
content += QString(";");
|
||||
return content;
|
||||
}
|
||||
|
||||
@ -35,18 +23,6 @@ QString SqlGenerate::insertData(QString table, QVariantMap map)
|
||||
//insert or replace into
|
||||
QString content = QString("insert or replace into %1 (").arg(table);
|
||||
QString values = QString("values(");
|
||||
QMapIterator<QString, QVariant> i(map);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
content.append(QString("%1").arg(i.key()));
|
||||
values.append("'" + i.value().toString().replace("'", "''") + "'"); //
|
||||
if (i.hasNext())
|
||||
{
|
||||
content.append(", ");
|
||||
values.append(",");
|
||||
}
|
||||
}
|
||||
content.append(") ");
|
||||
values.append(")");
|
||||
content.append(values);
|
||||
@ -59,76 +35,13 @@ QString SqlGenerate::selectWhere(QString table, QStringList Name, QString condit
|
||||
//QString content = QString("select from %1 ").arg(table);
|
||||
QString content = QString("select ");// .arg(table);
|
||||
QListIterator<QString> i(Name);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.hasNext())
|
||||
{
|
||||
content += QString(" %1 ,").arg(i.previous());
|
||||
}
|
||||
else
|
||||
{
|
||||
content += QString(" %1 ").arg(i.previous());
|
||||
}
|
||||
i.next();
|
||||
|
||||
}
|
||||
/*for(int i = 0; i < Name.size(); i++)
|
||||
{
|
||||
if (i + 1 == Name.size())
|
||||
{
|
||||
content += QString("%1 ").arg(Name.at(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
content += QString("%1,").arg(Name.at(i));
|
||||
}
|
||||
}*/
|
||||
content += QString("from %1").arg(table);
|
||||
if (!condition.isEmpty())
|
||||
{
|
||||
content += condition;// QString(" where %1").arg(condition);
|
||||
}
|
||||
content += QString(";");//
|
||||
|
||||
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
QString SqlGenerate::selectUnion(QStringList sTables, QStringList Name, QString condition /*= ""*/)
|
||||
{
|
||||
QString s_select_Data;
|
||||
for (int j = 0; j < sTables.size(); j++)
|
||||
{
|
||||
|
||||
QString content = QString("select ");// .arg(table);
|
||||
QListIterator<QString> i(Name);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.hasNext())
|
||||
{
|
||||
content += QString(" %1 ,").arg(i.previous());
|
||||
}
|
||||
else
|
||||
{
|
||||
content += QString(" %1 ").arg(i.previous());
|
||||
}
|
||||
i.next();
|
||||
|
||||
}
|
||||
content += QString("from %1").arg(sTables.at(j));
|
||||
|
||||
if (s_select_Data.isEmpty())
|
||||
{
|
||||
s_select_Data = content;
|
||||
}
|
||||
else
|
||||
{
|
||||
s_select_Data = s_select_Data + " union all " + content;
|
||||
}
|
||||
}
|
||||
if (!condition.isEmpty())
|
||||
{
|
||||
s_select_Data += condition;// QString(" where %1").arg(condition);
|
||||
@ -149,19 +62,6 @@ QString SqlGenerate::updateData(QString table, QVariantMap map, QString conditio
|
||||
{
|
||||
QString content = QString("update %1 set ").arg(table);
|
||||
QMapIterator<QString, QVariant>i(map);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.hasNext())
|
||||
{
|
||||
content += QString("%1 = '%2',").arg(i.key()).arg(i.value().toString().replace("'", "''"));
|
||||
}
|
||||
else
|
||||
{
|
||||
content += QString("%1= '%2' ").arg(i.key()).arg(i.value().toString().replace("'", "''"));
|
||||
}
|
||||
|
||||
}
|
||||
content += QString("where %1").arg(condition);
|
||||
content += QString(";");
|
||||
return content;
|
||||
|
@ -543,6 +543,13 @@ void LeadScheme::slotSave()
|
||||
m_vlayHH->addWidget(btn);
|
||||
btn->setCheckable(true);
|
||||
m_listBtnsSchemes.append(btn);
|
||||
btn->setObjectName("btnShem1");
|
||||
#if 1
|
||||
btn->setStyleSheet("QPushButton{ background: rgb(255, 255, 255); color: #666666;font-family: Source Han Sans; font-size: 30px;font-weight: normal; border-radius: 4px; border:0px ; } \
|
||||
QPushButton:hover{color: black;background: rgb(255, 255, 255);color: #666666;font-family: Source Han Sans; font-size: 30px;font-weight: normal; border-radius: 4px; }\
|
||||
QPushButton:pressed{color: black; background: rgb(255, 255, 255);color: #666666;font-family: Source Han Sans; font-size: 30px;font-weight: normal; border-radius: 4px;}\
|
||||
QPushButton:checked{ color: white;background: #0D9DDB;border-radius: 8px; }");
|
||||
#endif
|
||||
}
|
||||
m_vlayHH->addStretch();
|
||||
}
|
||||
@ -557,6 +564,10 @@ void LeadScheme::slotSave()
|
||||
{
|
||||
//logError()<<"delete:"<<m_listBtnsSchemes.at(i)->text()<<endl;
|
||||
sDeleName=m_listBtnsSchemes.at(i)->text();
|
||||
if(i<3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
listNames.append(m_listBtnsSchemes.at(i)->text());
|
||||
|
@ -26,7 +26,7 @@
|
||||
qApp->setStyleSheet(sqss);
|
||||
qss.close();
|
||||
}
|
||||
#include "cdateedit.h"
|
||||
|
||||
#include<QDateEdit>
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -44,19 +44,11 @@ void MedicalRecordWidget::init()
|
||||
#if 1
|
||||
m_dateBirthDay.setStyleSheet("QDateEdit{ border:1px solid #cccccc;background: #F5F7F9;border-radius: 12px;width: 400px;\
|
||||
font-family: Source Han Sans;font-size: 28px;font-weight: normal;color: #999999;\
|
||||
height: 60px;padding: 5px 20px;} QDateEdit::drop-down {\
|
||||
width: 80px; \
|
||||
border-left-width: 1px; \
|
||||
border-image:url(:/image/dateEdit.png);\
|
||||
}");
|
||||
height: 60px;padding: 5px 20px;}");
|
||||
#endif
|
||||
m_dateInspection.setStyleSheet("QDateEdit{ border:1px solid #cccccc;background: #F5F7F9;border-radius: 12px;width: 400px;\
|
||||
font-family: Source Han Sans;font-size: 28px;font-weight: normal;color: #999999;\
|
||||
height: 60px;padding: 5px 20px;} QDateEdit::drop-down {\
|
||||
width: 80px; \
|
||||
border-left-width: 1px; \
|
||||
border-image:url(:/image/dateEdit.png);\
|
||||
}");
|
||||
height: 60px;padding: 5px 20px;}");
|
||||
#if 0
|
||||
|
||||
#else
|
||||
|
Loading…
x
Reference in New Issue
Block a user