summaryrefslogtreecommitdiffstats
path: root/kwordquiz/src/kwordquizview.h
blob: 9c4a3f0dac8f2cb6e583a856fc73f90a347aedda (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/***************************************************************************
                          kwordquizview.h  -  description
                             -------------------
    begin                : Wed Jul 24 20:12:30 PDT 2002
    copyright            : (C) 2002 by Peter Hedlund
    email                : peter.hedlund@kdemail.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KWORDTQUIZVIEW_H
#define KWORDTQUIZVIEW_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

// include files for TQt
#include <tqtable.h>

#include <kprinter.h>

#include "wqlreader.h"
#include "wqundo.h"

#include <kprinter.h>
#include "wqundo.h"
//include <wqviewbase.h>

class KWordQuizDoc;
class DlgSpecChar;

/**
@author Peter Hedlund
*/

class KWTQTableItem :public TQTableItem
{
public:
  KWTQTableItem( TQTable* table, EditType et, const TQString & text );
  virtual int tqalignment() const;
};

class KWordQuizView : public TQTable
{
  Q_OBJECT
  TQ_OBJECT
  public:
    /** Constructor for the main view */
    KWordQuizView(TQWidget *tqparent = 0, const char *name=0);
    /** Destructor for the main view */
    ~KWordQuizView();

    /** returns a pointer to the document connected to the view instance. Mind that this method requires a KWordQuizApp instance as a tqparent
     * widget to get to the window document pointer by calling the KWordQuizApp::getDocument() method.
     *
     * @see KWordQuizApp#getDocument
     */
    KWordQuizDoc *getDocument() const;

    //Reimplemented from TQTable
    void paintCell ( TQPainter * p, int row, int col, const TQRect & cr, bool selected, const TQColorGroup & cg );
    void setFont( const TQFont &);
    void setText( int row, int col, const TQString &text );

    /** contains the implementation for printing functionality */
    void print(KPrinter *pPrinter);
    bool gridIsEmpty();
    void addUndo(const TQString & caption);
    void doEditUndo();
    void doEditCut();
    void doEditCopy();
    void doEditPaste();
    void doEditClear();
    void doEditInsert();
    void doEditDelete();
    void doEditMarkBlank();
    void doEditUnmarkBlank();
    void doVocabSort();
    void doVocabShuffle();
    void doVocabRC();
    void doVocabSpecChar();
    bool checkSyntax(bool all, bool blanks);
    void saveCurrentSelection(bool clear);
  protected:
    TQWidget * beginEdit(int row, int col, bool replace);
    void endEdit ( int row, int col, bool accept, bool replace );
    void activateNextCell();
    void keyPressEvent( TQKeyEvent* );
    bool eventFilter( TQObject*, TQEvent* );
  public slots:
    void adjustRow(int row);
    void slotSpecChar(const TQChar &);
    void slotCheckedAnswer(int );

  private slots:
    void slotDlgSpecCharClosed();

  signals:
    void undoChange(const TQString & text, bool enabled);

  private:
    int m_currentRow;
    int m_currentCol;
    TQString m_currentText;
    TQTableSelection m_currentSel;
    DlgSpecChar* dlgSpecChar;
    TQWidget * cellEditor;
    /** the list of the undo objects */
    static TQValueList<WTQUndo> *m_undoList;

    void doNewPage(TQPainter & painter, int res, int type);
    void doEndOfPage(TQPainter & painter, int vPos, int pageNum, int res, int type);
    bool checkForBlank(const TQString & s, bool blank);
};

#endif // KWORDTQUIZVIEW_H