Deffered SQL query when database is visible

This commit is contained in:
2026-03-21 20:32:28 +01:00
parent 95808b094d
commit 305c1d1f55
2 changed files with 20 additions and 0 deletions
+17
View File
@@ -157,8 +157,19 @@ void FITSFileModel::filesUnmarked(const QModelIndexList &indexes)
}
}
void FITSFileModel::load()
{
if(!m_loaded)
{
m_loaded = true;
prepareQuery();
}
}
void FITSFileModel::prepareQuery()
{
if(!m_loaded)return;
QString cols;
QString join;
QStringList where;
@@ -427,6 +438,7 @@ bool DataBaseView::exportCSV(const QString &path)
if(!csv.open(QIODevice::WriteOnly | QIODevice::Text))
return false;
m_model->load();
QSqlQuery sql(m_model->query().lastQuery());
int colCount = m_model->columnCount();
QStringList header;
@@ -455,3 +467,8 @@ bool DataBaseView::exportCSV(const QString &path)
}
return true;
}
void DataBaseView::visible(bool visible)
{
if(visible)m_model->load();
}