summaryrefslogtreecommitdiff
path: root/src/frontend/searchdialog/csearchresultview.h
blob: 1d37cbd6749a5d0064b472ab0b56d7333dfd7aa8 (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
/*********
*
* 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 CSEARCHRESULTSVIEW_H
#define CSEARCHRESULTSVIEW_H

#include <QTreeWidget>

// Sword includes
#include <listkey.h>


class CSwordModuleInfo;
class CReadDisplay;
class QAction;
class QMenu;

namespace Search {

class CSearchResultView  : public QTreeWidget {
        Q_OBJECT
    public:
        CSearchResultView(QWidget* parent);

        /**
          \returns the module which is currently used.
        */
        inline const CSwordModuleInfo *module() const {
            return m_module;
        }

    protected: // Protected methods
        /**
        * Initializes the view of this widget.
        */
        void initView();
        void initConnections();

        //from QTreeWidget
        virtual QMimeData * mimeData ( const QList<QTreeWidgetItem *> items ) const;
        virtual QStringList mimeTypes () const;

    public slots: // Public slots
        void saveItems();

        /**
          Setups the list with the given module.
        */
        void setupTree(const CSwordModuleInfo *m, const sword::ListKey &results);

        void setupStrongsTree(CSwordModuleInfo*, const QStringList&);
        void copyItemsWithText();
        void copyItems();
        void saveItemsWithText();
        /**
        * Reimplementation to show the popup menu.
        */
        virtual void contextMenuEvent(QContextMenuEvent* event);

    protected slots: // Protected slots
        void printItems();

        /**
        * Is connected to the signal which is emitted when a new item was chosen.
        */
        void executed(QTreeWidgetItem* current, QTreeWidgetItem*);

    private:
        struct {
            QMenu* saveMenu;
            struct {
                QAction* result;
                QAction* resultWithText;
            }
            save;

            QMenu* printMenu;
            struct {
                QAction* result;
            }
            print;

            QMenu* copyMenu;
            struct {
                QAction* result;
                QAction* resultWithText;
            }
            copy;
        }
        m_actions;

        QMenu* m_popup;
        const CSwordModuleInfo *m_module;

    signals: // Signals
        void keySelected(const QString&);
        void keyDeselected();
};

} //end of namespace Search

#endif