summaryrefslogtreecommitdiffstats
path: root/bibletime/frontend/searchdialog/csearchanalysis.cpp
blob: 14606227d3887f56fb08f7c71b50f20d9cc8c15a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
/*********
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2006 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/



#include "csearchanalysis.h"
#include "csearchdialog.h"

#include "backend/cswordkey.h"
#include "backend/cswordversekey.h"

#include "frontend/cbtconfig.h"

#include "util/cresmgr.h"
#include "util/ctoolclass.h"

//TQt includes
#include <tqhbox.h>
#include <tqvbox.h>
#include <tqptrlist.h>
#include <tqpainter.h>
#include <tqlayout.h>
#include <tqmap.h>
#include <tqlineedit.h>
#include <tqtextedit.h>
#include <tqlabel.h>
#include <tqsizepolicy.h>
#include <tqpushbutton.h>
#include <tqheader.h>
#include <tqregexp.h>
#include <tqmessagebox.h>

//KDE includes
#include <tdeapplication.h>
#include <tdefiledialog.h>
#include <tdelocale.h>
#include <kiconloader.h>

namespace Search {
	namespace Analysis {
	
const int SPACE_BETWEEN_PARTS = 5;
const int RIGHT_BORDER = 15;
const int LEFT_BORDER = 15;
const int LOWER_BORDER = 10;
const int UPPER_BORDER = 10;

const int ITEM_TEXT_SIZE = 8;
const int LABEL_TEXT_SIZE = 6;

//used for the shift between the bars
const int BAR_DELTAX = 4;
const int BAR_DELTAY = 2;
const int BAR_WIDTH  = 2 + (2*BAR_DELTAX);  //should be equal or bigger than the label font size
// Used for the text below the bars
const int BAR_LOWER_BORDER = 100;

const int LEGEND_INNER_BORDER = 5;
const int LEGEND_DELTAY = 4;
const int LEGEND_WIDTH = 85;

/****************************/

CSearchAnalysisDialog::CSearchAnalysisDialog( ListCSwordModuleInfo modules, TQWidget* parentDialog ) : KDialogBase(Plain, i18n("Search analysis"), Close, Close, parentDialog, 0, true) {
	initView();
	initConnections();
	m_analysis->reset();
	m_analysis->analyse(modules);
	showMaximized();
};

CSearchAnalysisDialog::~CSearchAnalysisDialog() {}
;

/** Initializes this dialog. */
void CSearchAnalysisDialog::initView() {
	TQVBoxLayout* layout = new TQVBoxLayout(plainPage(),0);

	TQPushButton* button = new TQPushButton(plainPage(), "button");
	button->setIconSet(SmallIconSet("document-save"));
	button->setText(i18n("Save search analysis as HTML"));
	button->setFixedSize(button->sizeHint());
	layout->addWidget(button);
	layout->addSpacing(10);

	m_analysis = new CSearchAnalysis(TQT_TQOBJECT(plainPage()));
	m_analysisView = new CSearchAnalysisView(m_analysis, plainPage());
	m_analysisView->show();
	layout->addWidget(m_analysisView);

	connect(button, TQT_SIGNAL(clicked()), m_analysis, TQT_SLOT(saveAsHTML()));
}

/** Initializes the widgets TQT_SIGNAL and TQT_SLOT connections,. */
void CSearchAnalysisDialog::initConnections() {}

/****************************/
/*  CSearchAnalysis         */
/****************************/

CSearchAnalysis::CSearchAnalysis(TQObject *parent, const char *name )
: TQCanvas(parent,name) {

	m_scaleFactor = 0.0;
	m_legend = 0;
	setBackgroundColor(TQt::white);
	m_canvasItemList.resize(67);
	m_canvasItemList.setAutoDelete(true);
	resize(1,1);
	connect(this, TQT_SIGNAL(resized()), TQT_SLOT(slotResized()));
}

CSearchAnalysis::~CSearchAnalysis() {}

TQDict<CSearchAnalysisItem>* CSearchAnalysis::getSearchAnalysisItemList() {
	// Returns pointer to the search analysis items
	return &m_canvasItemList;
}

/** Starts the analysis of the search result. This should be called only once because TQCanvas handles the updates automatically. */
void CSearchAnalysis::analyse(ListCSwordModuleInfo modules) {
	/**
	* 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
	*/
	setModules(modules);

	m_lastPosList.clear();
	const int numberOfModules = m_moduleList.count();
	if (!numberOfModules)
		return;
	m_legend = new CSearchAnalysisLegendItem(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);
	key.key("Genesis 1:1");

	CSearchAnalysisItem* analysisItem = m_canvasItemList[key.book()];
	bool ok = true;
	while (ok && analysisItem) {
		//   for (moduleIndex = 0,m_moduleList.first(); m_moduleList.current(); m_moduleList.next(),++moduleIndex) {
		moduleIndex = 0;
		ListCSwordModuleInfo::iterator end_it = m_moduleList.end();
		for (ListCSwordModuleInfo::iterator it(m_moduleList.begin()); it != end_it; ++it) {
			TDEApplication::kApplication()->processEvents( 10 ); //10 ms only
			if (!m_lastPosList.contains(*it)) {
				m_lastPosList.insert(*it,0);
			}

			analysisItem->setCountForModule(moduleIndex, (count = getCount(key.book(), *it)));
			m_maxCount = (count > m_maxCount) ? count : m_maxCount;

			++moduleIndex;
		}
		analysisItem->setX(xPos);
		analysisItem->setY(UPPER_BORDER);
		analysisItem->show();

		xPos += (int)analysisItem->width() + SPACE_BETWEEN_PARTS;
		ok = key.next(CSwordVerseKey::UseBook);
		analysisItem = m_canvasItemList[key.book()];
	}
	resize(xPos+BAR_WIDTH+(m_moduleList.count()-1)*BAR_DELTAX+RIGHT_BORDER, height() );
	slotResized();
}

/** Sets te module list used for the analysis. */
void CSearchAnalysis::setModules(ListCSwordModuleInfo modules) {
	m_moduleList.clear();
	//  for (modules.first(); modules.current(); modules.next()) {
	ListCSwordModuleInfo::iterator end_it = modules.end();
	for (ListCSwordModuleInfo::iterator it(modules.begin()); it != end_it; ++it) {
		if ( ((*it)->type() == CSwordModuleInfo::Bible) || ((*it)->type() == CSwordModuleInfo::Commentary) ) { //a Bible or an commentary
			m_moduleList.append(*it);
		}
	}

	m_canvasItemList.clear();
	CSearchAnalysisItem* analysisItem = 0;
	CSwordVerseKey key(0);
	key.key("Genesis 1:1");
	do {
		analysisItem = new CSearchAnalysisItem(this, m_moduleList.count(), key.book(), &m_scaleFactor, &m_moduleList);
		analysisItem->hide();
		m_canvasItemList.insert(key.book(), analysisItem);
	}
	while (key.next(CSwordVerseKey::UseBook));
	update();
}

/** Sets back the items and deletes things to cleanup */
void CSearchAnalysis::reset() {
	m_scaleFactor = 0.0;

	TQDictIterator<CSearchAnalysisItem> it( m_canvasItemList ); // iterator for items
	while ( it.current() ) {
		it.current()->hide();
		++it;
	}
	m_lastPosList.clear();

	if (m_legend) {
		m_legend->hide();
	}

	delete m_legend;
	m_legend = 0;

	update();
}

/** No descriptions */
void CSearchAnalysis::slotResized() {
	m_scaleFactor = (double)( (double)(height()-UPPER_BORDER-LOWER_BORDER-BAR_LOWER_BORDER-(m_moduleList.count()-1)*BAR_DELTAY)
							  /(double)m_maxCount);
	TQDictIterator<CSearchAnalysisItem> it( m_canvasItemList );
	while ( it.current() ) {
		it.current()->setSize(BAR_WIDTH + (m_moduleList.count()-1)*BAR_DELTAX, height()-UPPER_BORDER-LOWER_BORDER);
		it.current()->setY(UPPER_BORDER);
		++it;
	}
	update();
}

/** This function returns a color for each module */
TQColor CSearchAnalysis::getColor(int index) {
	switch (index) {
		case  0:
		return TQt::red;
		case  1:
		return TQt::darkGreen;
		case  2:
		return TQt::blue;
		case  3:
		return TQt::cyan;
		case  4:
		return TQt::magenta;
		case  5:
		return TQt::darkRed;
		case  6:
		return TQt::darkGray;
		case  7:
		return TQt::black;
		case  8:
		return TQt::darkCyan;
		case  9:
		return TQt::darkMagenta;
		default:
		return TQt::red;
	}
}

/** Returns the count of the book in the module */
const unsigned int CSearchAnalysis::getCount( const TQString book, CSwordModuleInfo* module ) {
	sword::ListKey& result = module->searchResult();
	const int length = book.length();
	unsigned int i = m_lastPosList[module];
	unsigned int count = 0;
	const unsigned int resultCount = result.Count();
	while (i < resultCount) {
		if ( strncmp(book.utf8(), (const char*)*result.GetElement(i), length) )
			break;
		i++;
		++count;
	}
	m_lastPosList.contains(module) ? m_lastPosList.replace(module,i) : m_lastPosList.insert(module,i);

	return count;
}


//------------------------------------------------------------------
//------------------------------------------------------------------

CSearchAnalysisItem::CSearchAnalysisItem(TQCanvas *parent, const int moduleCount, const TQString &bookname, double *scaleFactor, ListCSwordModuleInfo* modules)
: TQCanvasRectangle(parent),
m_moduleList( modules ),
m_scaleFactor(scaleFactor),
m_bookName(bookname),
m_moduleCount(moduleCount),
m_bufferPixmap(0) {
	m_resultCountArray.resize(m_moduleCount);
	int index = 0;
	for (index = 0; index < m_moduleCount; ++index)
		m_resultCountArray[index] = 0;
}

CSearchAnalysisItem::~CSearchAnalysisItem() {
	delete m_bufferPixmap;
}

/** Sets the resultcount of this item for the given module */
void CSearchAnalysisItem::setCountForModule( const int moduleIndex, const int count) {
	m_resultCountArray[moduleIndex] = count;
}

/** Returns the resultcount of this item for the given module */
int CSearchAnalysisItem::getCountForModule( const int moduleIndex) {
	return m_resultCountArray[moduleIndex];
}

/** Reimplementation. Draws the content of this item. */
void CSearchAnalysisItem::draw(TQPainter& painter) {
	TQFont f = painter.font();
	f.setPointSize(ITEM_TEXT_SIZE);
	painter.setFont(f);

	setPen(TQPen(black,1));
	setBrush(TQt::red);
	/**
	* We have to paint so many bars as we have modules available (we use m_moduleCount)
	* We paint inside the area which is given by height and width of this rectangle item
	*/
	int index = 0;
	int drawn = 0;
	int Value = 0;

	//find out the biggest value
	for (index=0;index < m_moduleCount; index++) {
		if (m_resultCountArray[index] > Value) {
			Value = m_resultCountArray[index];
		}
	};

	while (drawn < m_moduleCount) {
		for (index = 0; index < m_moduleCount; index++) {
			if (m_resultCountArray[index] == Value) {
				TQPoint p1((int)x() + (m_moduleCount-drawn-1)*BAR_DELTAX,
						  (int)height() + (int)y() - BAR_LOWER_BORDER - (m_moduleCount-drawn)*BAR_DELTAY);
				TQPoint p2(p1.x() + BAR_WIDTH,
						  p1.y() - (int)( !m_resultCountArray[index] ? 0 : ((m_resultCountArray[index])*(*m_scaleFactor))) );
				TQRect r(p1, p2);
				painter.fillRect(r, TQBrush(CSearchAnalysis::getColor(index)) );
				painter.drawRect(r);
				drawn++;
			}
		}
		//finds the next smaller value
		int newValue = 0;
		for (index=0;index < m_moduleCount; index++)
			if (m_resultCountArray[index] < Value && m_resultCountArray[index] >= newValue)
				newValue = m_resultCountArray[index];
		Value = newValue;
	}
	if (!m_bufferPixmap) {
		m_bufferPixmap = new TQPixmap();
		m_bufferPixmap->resize(width(),BAR_LOWER_BORDER);
		m_bufferPixmap->fill();
		TQPainter p(m_bufferPixmap);
		f = p.font();
		f.setPointSize(ITEM_TEXT_SIZE);
		p.setFont(f);
		p.rotate(90);
		p.drawText(TQPoint(5,0), m_bookName);
	}
	painter.drawPixmap(TQPoint(int(x()),int(height()+y()-BAR_LOWER_BORDER)), *m_bufferPixmap);
}

/** Returns the width of this item. */
int CSearchAnalysisItem::width() {
	return m_moduleCount*(m_moduleCount>1 ? BAR_DELTAX : 0) + BAR_WIDTH;
}

/** Returns the tooltip for this item. */
const TQString CSearchAnalysisItem::getToolTip() {
	TQString ret = TQString("<center><b>%1</b></center><hr/>").arg(m_bookName);
	ret += "<table cellspacing=\"0\" cellpadding=\"3\" width=\"100%\" height=\"100%\" align=\"center\">";

	//ToDo: Fix that loop
	int i = 0;
	ListCSwordModuleInfo::iterator end_it = m_moduleList->end();

	for (ListCSwordModuleInfo::iterator it(m_moduleList->begin()); it != end_it; ++it) {
		//  for (int i = 0; i < m_moduleCount; ++i) {
		CSwordModuleInfo* info = (*it);
		const TQColor c = CSearchAnalysis::getColor(i);

		ret.append(
			TQString("<tr bgcolor=\"white\"><td><b><font color=\"#%1\">%2</font></b></td><td>%3 (%4%)</td></tr>")
			.arg(TQString().sprintf("%02X%02X%02X",c.red(),c.green(),c.blue()))
			.arg(info ? info->name() : TQString())
			.arg( m_resultCountArray[i] )
			.arg( (info && m_resultCountArray[i])? ((double)m_resultCountArray[i] / (double)info->searchResult().Count())*(double)100 : 0.0, 0, 'g', 2)
		);
		++i;
	}

	ret += "</table>";

	return ret;
}

//------------------------------------------------------------------
//------------------------------------------------------------------

CSearchAnalysisView::CSearchAnalysisView(TQCanvas* canvas, TQWidget* parent)
: TQCanvasView(canvas, parent) {
	setFocusPolicy(TQ_WheelFocus);
	m_toolTip = new ToolTip(this);
	resize(sizeHint());
}

/** Returns the sizeHint for this view */
TQSize CSearchAnalysisView::sizeHint() {
	if ( parentWidget() )
		return parentWidget()->sizeHint();
	return TQCanvasView::sizeHint();
}

/** No descriptions */
void CSearchAnalysisView::resizeEvent( TQResizeEvent* e) {
	TQCanvasView::resizeEvent(e);
	canvas()->resize( canvas()->width(), viewport()->height() );
}

CSearchAnalysisView::ToolTip::ToolTip(TQWidget* parent) : TQToolTip(parent) {}

void CSearchAnalysisView::ToolTip::maybeTip(const TQPoint& p) {
	CSearchAnalysisView* view = dynamic_cast<CSearchAnalysisView*>(parentWidget());
	if (!view)
		return;
	TQPoint point(p);
	point = view->viewport()->mapFrom(view, point);
	CSearchAnalysisItem* i = view->itemAt( view->viewportToContents(point) );
	if (!i)
		return;

	//get type of item and display correct text
	TQString text = i->getToolTip();
	if (text.isEmpty())
		return;

	TQPoint p1 = view->viewport()->mapTo(view, view->contentsToViewport(i->rect().topLeft()));
	p1.setY(0);
	TQPoint p2 = view->viewport()->mapTo(view, view->contentsToViewport(i->rect().bottomRight()));
	p2.setY(view->height());
	TQRect r = TQRect( p1, p2 );
	if (r.contains(p))
		tip(r, text);
}


/** Returns the item at position p. If there no item at that point return 0. */
CSearchAnalysisItem* CSearchAnalysisView::itemAt( const TQPoint& p ) {
	TQCanvasItemList l = canvas()->collisions(p);
	if (!l.count())
		return 0;
	return dynamic_cast<CSearchAnalysisItem*>(l.first());
}

//------------------------------------------------------------------
//------------------------------------------------------------------

CSearchAnalysisLegendItem::CSearchAnalysisLegendItem(TQCanvas *parent, ListCSwordModuleInfo *list )
: TQCanvasRectangle(parent) {
	m_moduleList = list;
}

/** Reimplementation. Draws the content of this item. */
void CSearchAnalysisLegendItem::draw (TQPainter& painter) {
	painter.save();

	setPen( TQPen(black,2) );
	setBrush( TQt::white );
	//the outer rectangle
	TQPoint p1( (int)x(), (int)y() );
	TQPoint p2( (int)x()+width(), (int)y() + height() );
	TQRect r(p1, p2);
	r.normalize();
	painter.drawRect(r);

	TQFont f = painter.font();
	f.setPointSize(ITEM_TEXT_SIZE);
	painter.setFont(f);

	//   for (unsigned int index=0; index < m_moduleList->count(); index++){
	int moduleIndex = 0;
	ListCSwordModuleInfo::iterator end_it = m_moduleList->end();
	for (ListCSwordModuleInfo::iterator it(m_moduleList->begin()); it != end_it; ++it) {
		// the module color indicators
		TQPoint p1( (int)x() + LEGEND_INNER_BORDER, (int)y() + LEGEND_INNER_BORDER + moduleIndex*(LEGEND_DELTAY + ITEM_TEXT_SIZE) );
		TQPoint p2(p1.x() + ITEM_TEXT_SIZE, p1.y() + ITEM_TEXT_SIZE);
		TQRect r(p1,p2);
		painter.fillRect(r, TQBrush(CSearchAnalysis::getColor(moduleIndex)) );
		r.normalize();
		painter.drawRect(r);

		TQPoint p3( p2.x() + LEGEND_INNER_BORDER, p2.y() );
		painter.drawText(p3, (*it)->name() );

		++moduleIndex;
	}
	painter.restore();
}

/** No descriptions */
void CSearchAnalysis::saveAsHTML() {
	const TQString file = KFileDialog::getSaveFileName(TQString(),
						 TQString("*.html | %1").arg(i18n("HTML files")),
						 0,
						 i18n("Save Search Analysis"));
	if (file.isNull()) {
		return;
	}

	int moduleIndex = 0;
	int count = 0;
	TQString countStr = "";
	TQString m_searchAnalysisHTML = "";
	TQString tableTitle = "";
	TQString tableTotals = "";
	TQString VerseRange = "";
	const TQString txtCSS = TQString("<style type=\"text/css\">\ntd {border:1px solid black;}\nth {font-size: 130%; text-align:left; vertical-align:top;}\n</style>\n");
	const TQString metaEncoding = TQString("<META http-equiv=Content-Type content=\"text/html; charset=utf-8\">");
	CSwordVerseKey key(0);
	sword::ListKey searchResult;

	key.key("Genesis 1:1");

	CSearchAnalysisItem* analysisItem = m_canvasItemList.find( key.book() );

	TQString text = "<html>\n<head>\n<title>" + i18n("BibleTime Search Analysis") + "</title>\n" + txtCSS + metaEncoding + "</head>\n<body>\n";
	text += "<table>\n<tr><th>" + i18n("Search text :") + "</th><th>" + CSearchDialog::getSearchDialog()->searchText() + "</th></tr>\n";

	tableTitle = "<tr><th align=\"left\">" + i18n("Book") + "</th>";
	tableTotals = "<tr><td align=\"left\">" + i18n("Total hits") + "</td>";
	//   for (moduleIndex = 0,m_moduleList.first(); m_moduleList.current(); m_moduleList.next(),++moduleIndex) {
	moduleIndex = 0;
	ListCSwordModuleInfo::iterator end_it = m_moduleList.end();
	for (ListCSwordModuleInfo::iterator it(m_moduleList.begin()); it != end_it; ++it) {
		tableTitle += TQString("<th align=\"left\">") + (*it)->name() + TQString("</th>");
		searchResult = (*it)->searchResult();
		countStr.setNum(searchResult.Count());

		tableTotals += TQString("<td align=\"right\">") + countStr + TQString("</td>");
		++moduleIndex;
	}
	tableTitle += TQString("</tr>\n");
	tableTotals += TQString("</tr>\n");

	m_searchAnalysisHTML = "";
	bool ok = true;
	while (ok) {
		m_searchAnalysisHTML += TQString("<tr><td>") + key.book() + TQString("</td>");
		analysisItem = m_canvasItemList.find( key.book() );

		//    for (moduleIndex = 0, m_moduleList.first(); m_moduleList.current(); m_moduleList.next(), ++moduleIndex) {
		moduleIndex = 0;
		ListCSwordModuleInfo::iterator end_it = m_moduleList.end();
		for (ListCSwordModuleInfo::iterator it(m_moduleList.begin()); it != end_it; ++it) {
			count = analysisItem->getCountForModule(moduleIndex);
			countStr.setNum(count);
			m_searchAnalysisHTML += TQString("<td align=\"right\">") + countStr + TQString("</td>");

			++moduleIndex;
		}
		m_searchAnalysisHTML += TQString("</tr>\n");
		ok = key.next(CSwordVerseKey::UseBook);
	}

	text += TQString("<table>\n") + tableTitle + tableTotals + m_searchAnalysisHTML + TQString("</table>\n");
	text += TQString("<center>") + i18n("Created by") + TQString(" <a href=\"http://www.bibletime.info/\">BibleTime</a></center>");
	text += TQString("</body></html>");

	CToolClass::savePlainFile(file, text, false, TQTextStream::UnicodeUTF8);
}
 
	} //end of namespace Search::Analysis
} //end of namespace Search