summaryrefslogtreecommitdiff
path: root/src/frontend/searchdialog/analysis/csearchanalysisscene.h
blob: f8bb966026ca31cf74626f4a199914e4b6b28c11 (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
/*********
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/

#ifndef SEARCHCSEARCHANALYSISSCENE_H
#define SEARCHCSEARCHANALYSISSCENE_H

#include <QGraphicsScene>

#include <QColor>
#include <QHash>
#include <QMap>
#include "backend/cswordmodulesearch.h"
#include "frontend/searchdialog/analysis/csearchanalysisitem.h"

// Sword includes
#include <listkey.h>


class CSwordModuleInfo;

namespace Search {

class CSearchAnalysisLegendItem;

/**
    @author The BibleTime team <info@bibletime.info>
*/
class CSearchAnalysisScene : public QGraphicsScene {
        Q_OBJECT
    public:
        CSearchAnalysisScene(QObject* parent);

        /**
        * Starts the analysis of the search result.
        * This should be called only once because
        * QCanvas handles the updates automatically.
        */
        void analyse(const CSwordModuleSearch::Results &results);

        /**
        * This function returns a color for each module
        * @return The color at position index in the list
        */
        static QColor getColor(int index);

        void reset();
        /**
         * resize the height of the scene
         */
        void resizeHeight(int height);

    public slots:
        void saveAsHTML();

    protected slots: // Protected slots
        /**
        * No descriptions
        */
        void slotResized();

    protected:
        void setResults(const CSwordModuleSearch::Results &results);

    private:
        /**
        * Returns the count of the book in the module
        */
        unsigned int getCount(const QString &book, const CSwordModuleInfo *module);

        CSwordModuleSearch::Results m_results;
        QHash<QString, CSearchAnalysisItem*> m_itemList;
        QMap<const CSwordModuleInfo*, unsigned int> m_lastPosList;
        int m_maxCount;
        double m_scaleFactor;
        CSearchAnalysisLegendItem* m_legend;
};

}

#endif