[bt-devel] Saving Search Analysis To Disk
Luke Mauldin
bt-devel@crosswire.org
Tue, 26 Jun 2001 12:02:01 -0500
I am now trying to modify bibletime to allow a user to save the search
analysis to the disk. However I have encountered some code that I do not
really understand. It is from csearchdialoganalysis.cpp and I will list it
below.
void CSearchDialogAnalysis::analyse(){
qDebug("void CSearchDialogAnalysis::analyse()");
/**
* Steps of analysing our search result;
* -Create the items for all available books ("Genesis" - "Revelation")
* -Iterate through all modules we analyse
* -Go through all books of this module
* -Find out how many times we found the book
* -Set the count to the items which belongs to the book
*/
m_lastPosList.clear();
const int numberOfModules = m_moduleList.count();
if (!numberOfModules)
return;
m_legend = new CSearchDialogAnalysisLegendItem(this, &m_moduleList);
m_legend->setX(LEFT_BORDER);
m_legend->setY(UPPER_BORDER);
m_legend->setSize(LEGEND_WIDTH,
LEGEND_INNER_BORDER*2 + ITEM_TEXT_SIZE*numberOfModules +
LEGEND_DELTAY*(numberOfModules-1));
m_legend->show();
int xPos = LEFT_BORDER + m_legend->width() + SPACE_BETWEEN_PARTS;
int moduleIndex = 0;
m_maxCount = 0;
int count = 0;
CSwordVerseKey key(0/*m_moduleList.first()*/);
key.key("Genesis 1:1");
CSearchDialogAnalysisItem* analysisItem = m_canvasItemList[key.book()];
bool ok = true;
while (ok && analysisItem) {
for (moduleIndex = 0,m_moduleList.first(); m_moduleList.current();
m_moduleList.next(),++moduleIndex) {
KApplication::kApplication()->processEvents(10);
if (!m_lastPosList.contains(m_moduleList.current()))
m_lastPosList.insert(m_moduleList.current(),0);
analysisItem->setCountForModule(moduleIndex, (count =
getCount(key.book(),m_moduleList.current())));
m_maxCount = (count > m_maxCount) ? count : m_maxCount;
}
analysisItem->setX(xPos);
analysisItem->setY(UPPER_BORDER);
analysisItem->show();
xPos += (int)analysisItem->width() + SPACE_BETWEEN_PARTS;
ok = key.NextBook();
analysisItem = m_canvasItemList[key.book()];
}
resize(xPos+BAR_WIDTH+(m_moduleList.count()-1)*BAR_DELTAX+RIGHT_BORDER,
height() );
slotResized();
}
I know that count is the number of times the search criteria appears in the
module. However, I do not know what represents the "book" that is being
searched through. I had planned on adding code to the end of the main loop
that would take the "book" name that is being searched through, write it to a
file, insert a tab in the file, and then write the number of occurrences in
that book. For example,
John 8
Acts 9
etc...
I thought about using regular fstream to do it, but since we are using a KDE
application I think it would be better to use kfile to write the information
to the file. Unfortunately I have never dealt with any of this before so it
is doing to be a learning experience also. Any hints, tips, suggestions,
etc... would be greatly appreciated.
Luke