File: c2b.h

package info (click to toggle)
cb2bib 1.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,368 kB
  • sloc: cpp: 24,179; sh: 481; makefile: 16
file content (131 lines) | stat: -rw-r--r-- 2,965 bytes parent folder | download
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
/***************************************************************************
 *   Copyright (C) 2004-2015 by Pere Constans
 *   constans@molspaces.com
 *   cb2Bib version 1.9.2. Licensed under the GNU GPL version 3.
 *   See the LICENSE file that comes with this distribution.
 ***************************************************************************/
#ifndef C2B_H
#define C2B_H

#include "c2bBibParser.h"
#include "c2bNetworkQueryInfo.h"

#include <metadataParser.h>
#include <network.h>

#include <QObject>


class c2bClipboard;

class QProgressDialog;
class QWidget;


class c2b : public QObject
{

    Q_OBJECT

public:
    c2b(QWidget* main, QObject* parento = 0);
    ~c2b();

    // Actions
    inline static const QString documentMetadata(const QString& fn)
    {
        return metaParser()->metadata(fn);
    }

    inline static const QString encodeLink(const QString& ln)
    {
        return netqinf()->encodeLink(ln);
    }

    inline static void showMessage(const QString& message)
    {
        instance()->emitMessage(message);
    }

    inline static void doSearchInFiles(const QString& string, const QString& fn)
    {
        instance()->emitSearchInFiles(string, fn);
    }

    // Pointers
    inline static c2b* instance()
    {
        Q_ASSERT_X(_c2b_single_instance, "c2b", "cb2Bib resources were not instantiated");
        return _c2b_single_instance;
    }

    inline static QWidget* mainWidget()
    {
        return instance()->_c2b_main;
    }

    inline static c2bClipboard* clipboard()
    {
        return instance()->_c2b_clipboard;
    }

    inline static network* net()
    {
        return instance()->_c2b_network;
    }

    inline static c2bNetworkQueryInfo* netqinf()
    {
        return instance()->_c2b_netqinf;
    }

    inline static c2bBibParser* bibParser()
    {
        return instance()->_c2b_bibparser;
    }

    inline static metadataParser* metaParser()
    {
        return instance()->_c2b_metadataparser;
    }


public slots:
    static void configure(int index = -1);
    void exitRequested();


signals:
    void searchInFiles(const QString& string, const QString& fn);
    void statusMessage(const QString& message);


private:
    QProgressDialog* _download_progress;
    QWidget* _c2b_main;
    c2bBibParser* _c2b_bibparser;
    c2bClipboard* _c2b_clipboard;
    c2bNetworkQueryInfo* _c2b_netqinf;
    metadataParser* _c2b_metadataparser;
    network* _c2b_network;
    static c2b* _c2b_single_instance;

    inline void emitMessage(const QString& message)
    {
        emit statusMessage(message);
    }

    inline void emitSearchInFiles(const QString& string, const QString& fn)
    {
        emit searchInFiles(string, fn);
    }


private slots:
    void proxyAuthenticationRequired(const QNetworkProxy& proxy, QAuthenticator* auth);
    void showMessage(const QString& title, const QString& ms);
    void updateDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);

};

#endif