summaryrefslogtreecommitdiffstats
path: root/kvoctrain/kvoctrain/kvoctraintable.h
blob: 77fffa77d762f91839e1020582d574db767fa215 (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
/***************************************************************************

                      table for kvoctrain

    -----------------------------------------------------------------------

    begin                : Tue Jan 4 19:04:53 PST 2005

    copyright            :(C) 2005 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 KVOCTRAINTABLE_H
#define KVOCTRAINTABLE_H

#include <tqtable.h>
#include <tqtimer.h>

#include "kvt-core/kvoctraindoc.h"
#include "kvt-core/kvoctrainexpr.h"
#include "kvt-core/langset.h"
#include "kvoctraintableitem.h"

/**
@author Peter Hedlund
*/
class KVocTrainTable : public QTable
{
Q_OBJECT
public:
  public:
    KVocTrainTable( kvoctrainDoc *_doc, const LangSet *ls, TQWidget *parent = NULL, const char *name = NULL );

    friend class kvoctrainView;

    int currentItem() { return currentRow(); }
    void setCurrentItem(int row);
    int count() { return numRows(); }

    void setModified(bool _dirty = true) { m_doc->setModified(_dirty); }
    TQString getIdent(int i) const { return m_doc->getIdent(i); }
    TQString getOriginalIdent() const { return m_doc->getOriginalIdent(); }
    int findIdent(TQString id) const { return m_doc->findIdent(id); }
    void setCurrentRow(int row, int col);
    void updateContents(int row = -1, int col = -1);
    kvoctrainExpr *getRow(int row);
    void setDoc(kvoctrainDoc *rows);
    void setFont(const TQFont &);

  signals:
    void selected(int row);
    void rightButtonClicked(int header, int x, int y);
    void forwardKeyPressEvent(TQKeyEvent *);
    void forwardKeyReleaseEvent(TQKeyEvent *);
    void edited(int, int);

  public slots:
    void sortByColumn_alpha(int index);
    void sortByColumn_index(int index);
    void slotSelectionChanged();
    void slotCurrentChanged(int, int);

  protected slots:
    void menuTriggerTimeout();
    void headerReleaseEvent(int sec);
    void headerPressEvent(int sec);

  protected:
    int current;
    //TQWidget* beginEdit(int row, int col, bool replace);
    //void endEdit(int row, int col, bool accept, bool replace);
    void paintCell(TQPainter *p, int row, int col, const TQRect &cr, bool selected, const TQColorGroup &cg);
    void setItem(int row, int col, TQTableItem * item);
    TQTableItem* item (int row, int col) const;
    void keyPressEvent(TQKeyEvent *e);
    void keyReleaseEvent(TQKeyEvent *e);
    void contentsMousePressEvent(TQMouseEvent *e);
    void contentsMouseDoubleClickEvent(TQMouseEvent *e);
    void activateNextCell();

  private:
    kvoctrainDoc * m_doc;
    void sortByColumn(int, bool);
    const LangSet* langs;
    //const GradeCols *gradecols;
    KVocTrainTableItem *defaultItem;
    TQTimer *delayTimer;
    int triggerSect;
    TQPixmap m_pixInactive;
    TQPixmap m_pixInQuery;
};

#endif