summaryrefslogtreecommitdiffstats
path: root/quanta/components/tableeditor/tableeditor.h
blob: 3b9138119b1a25c09fd931160fd9ae2958e151c4 (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
125
126
127
128
129
130
131
132
/***************************************************************************
                           tableeditor.h  -  table editor dialog
    begin              : Thu 15 Apr 2004
    copyright          : (C) 2004 by Andras Mantia <[email protected]>
 ***************************************************************************/

/***************************************************************************
 *
 *   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; version 2 of the License.
 *
 ***************************************************************************/

#ifndef TABLEEDITOR_H
#define TABLEEDITOR_H

#include <kurl.h>
#include <tqvaluelist.h>

#include "tableeditors.h"
#include "document.h"

class TQSpinBox;
class TQTable;
class KPopupMenu;
class Tag;
struct DTDStruct;
class Node;

class TableNode 
{   
public:
  Node *node; 
  bool merged; 
  int mergedRow; 
  int mergedCol; 
  TableNode()    {node = 0;}
};



struct NestedTable { Node *node; int row; int col; int bLine; int bCol; int eLine; int eCol; TQString nestedData;};
class Parser;


class TableEditor : public TableEditorS
{
  Q_OBJECT

public:
  TableEditor( TQWidget* parent = 0, const char* name = 0 );
  ~TableEditor();

  virtual bool setTableArea( int bLine, int bCol, int eLine, int eCol, Parser * docParser );
  virtual void setBaseURL( const KURL & url );
  virtual TQString readModifiedTable();
  virtual void createNewTable( Document * write, const DTDStruct * dtd );
  // Set defaults for table: enable word wrap, fit content, allow swapping col/rows with D&D
  virtual void configureTable( TQTable * table );
  virtual void setCellText( TQTable * table, int row, int col, const TQString & text );
  // Configure TableItem from tag attributes
  virtual void configureCell( int row, int col, Node * node );

public slots:
  virtual void slotContextMenuRequested( int row, int col, const TQPoint & pos );
  virtual void slotEditCell();
  // Wrapper for setText to use TableItem instead of QTableItem
  virtual void slotEditCellText( int r, int );
  virtual void slotEditRow();
  virtual void slotEditCol();
  virtual void slotEditTable();
  virtual void slotEditTableBody();
  virtual void slotEditTableHeader();
  virtual void slotEditTableFooter();
  virtual void slotTabChanged( TQWidget * w );
  virtual void slotInsertRow();
  virtual void slotInsertCol();
  virtual void slotAddRemoveRow( int num );
  virtual void slotAddRemoveCol( int num );
  virtual void slotRemoveRow();
  virtual void slotRemoveCol();
  virtual void slotMergeCells();
  virtual void slotUnmergeCells();
  virtual void slotEditChildTable();
  virtual void slotHelpInvoked();

protected:
  TQValueList<Tag*> m_colTags;
  int m_unmergeCellsId;
  int m_mergeSeparatorId;
  int m_mergeCellsId;
  bool m_createNodes;
  TQValueList<TQValueList<TableNode> > *m_tableTags;
  TQValueList<TQValueList<TableNode> > *m_tableFooterTags;
  TQValueList<TQValueList<TableNode> > *m_tableHeaderTags;
  TQValueList<TableNode> *m_tableFooterRows;
  TQValueList<TableNode> *m_tableHeaderRows;
  TQValueList<TableNode> *m_tableRows;
  Document* m_write;
  Tag *m_table;
  Tag *m_tfoot;
  Tag *m_thead;
  int newVariable;
  Tag *m_tbody;
  int m_colEditId;
  int m_rowEditId;
  int m_cellEditId;
  int m_col;
  int m_row;
  KPopupMenu *m_popup;
  KURL m_baseURL;
  const DTDStruct *m_dtd;
  TQValueList<TQValueList<TableNode> > *m_tableDataTags;
  TQValueList<TableNode> *m_tableDataRows;
  TQTable *m_dataTable;
  TQSpinBox *m_rowSpin;
  TQSpinBox *m_colSpin;
  int m_bLine, m_bCol, m_eLine, m_eCol;
  TQValueList<NestedTable> m_nestedTables;
  int m_editChildId;

  virtual TQString indent( int n );
  virtual TQString cellValue( int row, int col );
  virtual TQString tableToString();
  virtual TQString tagContent( Node * node );
  virtual void deleteList( TQValueList<TableNode> * table );
  virtual void deleteMatrix( TQValueList<TQValueList<TableNode> > * matrix );

};

#endif