Add indexing of XISF
This commit is contained in:
+35
-27
@@ -110,7 +110,7 @@ bool Database::checkError(QSqlQuery &query)
|
||||
}
|
||||
}
|
||||
|
||||
static QStringList nameFilters = {"*.fit", "*.fits"};
|
||||
static QStringList nameFilters = {"*.fit", "*.fits", "*.xisf"};
|
||||
|
||||
static int countFiles(const QDir &dir, int count = 0)
|
||||
{
|
||||
@@ -176,33 +176,41 @@ bool Database::indexDir2(const QDir &dir, QProgressDialog *progress)
|
||||
}
|
||||
}
|
||||
|
||||
readFITSHeader(filePath, info);
|
||||
m_insertFile.bindValue(0, filePath);
|
||||
m_insertFile.bindValue(1, mtime);
|
||||
if(!m_insertFile.exec())
|
||||
{
|
||||
qDebug() << m_insertFile.lastError();
|
||||
return false;
|
||||
}
|
||||
qlonglong last_id = m_insertFile.lastInsertId().toLongLong();
|
||||
QVariantList file_id, keys, values, comments;
|
||||
for(auto &record : info.fitsHeader)
|
||||
{
|
||||
file_id << last_id;
|
||||
keys << QString(record.key);
|
||||
values << record.value.toString();
|
||||
comments << QString(record.comment);
|
||||
}
|
||||
m_insertFitsHeader.bindValue(0, file_id);
|
||||
m_insertFitsHeader.bindValue(1, keys);
|
||||
m_insertFitsHeader.bindValue(2, values);
|
||||
m_insertFitsHeader.bindValue(3, comments);
|
||||
if(!m_insertFitsHeader.execBatch())
|
||||
{
|
||||
qDebug() << m_insertFitsHeader.lastError();
|
||||
return false;
|
||||
}
|
||||
bool ok;
|
||||
if(filePath.endsWith(".xisf", Qt::CaseInsensitive))
|
||||
ok = readXISFHeader(filePath, info);
|
||||
else
|
||||
ok = readFITSHeader(filePath, info);
|
||||
|
||||
qlonglong last_id = -1;
|
||||
if(ok)
|
||||
{
|
||||
m_insertFile.bindValue(0, filePath);
|
||||
m_insertFile.bindValue(1, mtime);
|
||||
if(!m_insertFile.exec())
|
||||
{
|
||||
qDebug() << m_insertFile.lastError();
|
||||
return false;
|
||||
}
|
||||
last_id = m_insertFile.lastInsertId().toLongLong();
|
||||
QVariantList file_id, keys, values, comments;
|
||||
for(auto &record : info.fitsHeader)
|
||||
{
|
||||
file_id << last_id;
|
||||
keys << QString(record.key);
|
||||
values << record.value.toString();
|
||||
comments << QString(record.comment);
|
||||
}
|
||||
m_insertFitsHeader.bindValue(0, file_id);
|
||||
m_insertFitsHeader.bindValue(1, keys);
|
||||
m_insertFitsHeader.bindValue(2, values);
|
||||
m_insertFitsHeader.bindValue(3, comments);
|
||||
if(!m_insertFitsHeader.execBatch())
|
||||
{
|
||||
qDebug() << m_insertFitsHeader.lastError();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
qDebug() << filePath << last_id;
|
||||
info.fitsHeader.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user