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

#ifndef BTSOURCEAREA_H
#define BTSOURCEAREA_H

#include <QWidget>

#include <boost/scoped_ptr.hpp>
#include <QApplication>
#include <QMap>
#include "backend/btmoduletreeitem.h"

// Sword includes:
#include <installmgr.h>


class QTreeWidget;
class QTreeWidgetItem;
class QLabel;
class QPushButton;

/**
* Area for one install source.
*
* - Tree widget for modules
* - Buttons for handling the source(s): refresh, edit, remove, add
*
* Each source has
* QTreeWidget, populated with the module tree if the source
* module list is in a local cache. Refreshing the source refreshes
* the cache and rebuilds the module tree. Sources are not refreshed
* automatically, only by the user action, one source at a time.
*/
class BtSourceArea : public QWidget {
        Q_OBJECT

        friend class BtSourceWidget;
    public:

        struct InstalledFilter : BTModuleTreeItem::Filter {
            InstalledFilter(QString sourceName);
            bool filter(CSwordModuleInfo*);
            sword::InstallSource m_source;
            boost::scoped_ptr<CSwordBackend> m_swordBackend;
        };

        BtSourceArea(const QString& sourceName);
        ~BtSourceArea();

        void initView();
        void prepareRemove();
        /** Reimplemented from QWidget. */
        virtual QSize sizeHint() const;
        void initTreeFirstTime();
        QTreeWidget* treeWidget();

        QMap<QString, bool>* selectedModules();

    public slots:
        void slotSwordSetupChanged();
        /** Create a module tree for a tree widget */
        void createModuleTree();

    signals:
        void signalSelectionChanged(QString sourceName, int selectedCount);
        void signalCreateTree();

    private slots:
        void slotCreateTree();
        void slotSelectionChanged(QTreeWidgetItem* item, int column);
        void slotItemDoubleClicked(QTreeWidgetItem* item, int column);
    private:
        void addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem);

        QString m_sourceName;
        bool m_treeAlreadyInitialized;
        QMap<QString, bool> m_checkedModules;
        CSwordBackend* m_remoteBackend; // needed for the module list
        QList<CSwordModuleInfo*> m_moduleList;

        QTreeWidget* m_view;
        QLabel* m_refreshTimeLabel;
        QPushButton* m_refreshButton;
        QPushButton* m_editButton;
        QPushButton* m_deleteButton;
        QPushButton* m_addButton;
};

#endif