File: c2bTextEdit.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 (117 lines) | stat: -rw-r--r-- 2,529 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
/***************************************************************************
 *   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 C2BTEXTEDIT_H
#define C2BTEXTEDIT_H

#include <QPlainTextEdit>


class c2bSettings;


class c2bTextEdit : public QPlainTextEdit
{

    Q_OBJECT

public:
    explicit c2bTextEdit(QWidget* parentw = 0);
    ~c2bTextEdit();

    QAction* convertSelection2LaTeXAction;
    QAction* convertSelection2UnicodeAction;
    QAction* journalsToAbbreviatedAction;
    QAction* journalsToFullAction;
    QAction* pasteCurrentBibTeXAction;
    QAction* toggleWordWrappingAction;
    QAction* updateMetadataAction;
    void setBibTeXActions();
    void updatePlainText(const QString& text);

    inline const QString editorFilename() const
    {
        return _editor_filename;
    }

    void setEditorFilename(const QString& fn)
    {
        _editor_filename = fn;
    }


signals:
    void overwriteModeChanged();


public slots:
    void toggleWordWrapping();


protected slots:
    void convert2LaTeX();
    void convert2Unicode();


protected:
    void contextMenuEvent(QContextMenuEvent* qevent);
    void keyPressEvent(QKeyEvent* qevent);
    void resizeEvent(QResizeEvent* qevent);


private:
    QColor _line_number_area_color;
    QColor* _line_number_color_p;
    QString _editor_filename;
    QWidget* _line_number_area;
    c2bSettings* _settingsP;
    int lineNumberAreaWidth();
    void lineNumberAreaPaintEvent(QPaintEvent* qevent);


private slots:
    void loadSettings();
    void updateLineNumberAreaWidth();
    void updateLineNumberArea(const QRect& qrect, int dy);


    friend class LineNumberArea;

};


/***************************************************************************
 *  Line number area (From CodeEditor Qt's example)
 ***************************************************************************/
class LineNumberArea : public QWidget
{

public:
    explicit LineNumberArea(c2bTextEdit* editor) : QWidget(editor)
    {
        _editor = editor;
    }
    ~LineNumberArea() {}

    QSize sizeHint() const
    {
        return QSize(_editor->lineNumberAreaWidth(), 0);
    }


protected:
    void paintEvent(QPaintEvent* qevent)
    {
        _editor->lineNumberAreaPaintEvent(qevent);
    }


private:
    c2bTextEdit* _editor;

};

#endif