summaryrefslogtreecommitdiffstats
path: root/klinkstatus/src/ui/tablelinkstatus.h
blob: a8aebf8d81d139c344e0cfb12c713fefca377862 (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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/***************************************************************************
 *   Copyright (C) 2004 by Paulo Moura Guedes                              *
 *   moura@kdewebdev.org                                                        *
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
 ***************************************************************************/

#ifndef TABLE_LINKSTATUS_H
#define TABLE_LINKSTATUS_H

#include <tqtable.h>
#include <tqstring.h>
#include <tqcolor.h>
#include <tqpopupmenu.h>
#include <tqvaluevector.h>
class TQStringList;

class KURL;

#include <vector>

#include "../engine/linkstatus.h"
#include "celltooltip.h"
#include "resultview.h"

using namespace std;


int const STATUS_COLUMN_WIDTH = 50;

class TableItem;

class TableLinkstatus: public TQTable, public ResultView
{
    Q_OBJECT
  TQ_OBJECT
public:

    TableLinkstatus(TQWidget * parent = 0, const char * name = 0,
                    int column_index_status = 1,
                    int column_index_label = 2,
                    int column_index_URL = 3);
    ~TableLinkstatus();

    virtual void setColumns(TQStringList const& columns);

    /* Insere uma nova entrada no fim da tabela */
    virtual void insertResult(LinktqStatus const* linkstatus);


    virtual void clear();
    void removeColunas();
    virtual void show(ResultView::tqStatus const& status);
    virtual void showAll();


    /* Specialization of TQTable::ensureCellVisible */
    virtual void ensureCellVisible(int row, int col);

    virtual bool textFitsInCell(int row, int col) const;
    virtual bool isEmpty() const;

    TableItem* myItem(int row, int col) const;

private slots:

    virtual void slotPopupContextMenu(int row, int col, const TQPoint& pos);
    virtual void slotCopyUrlToClipboard() const;
    virtual void slotCopyParentUrlToClipboard() const;
    virtual void slotCopyCellTextToClipboard() const;
    virtual void slotEditReferrersWithQuanta();
    virtual void slotEditReferrerWithQuanta(int id);
    virtual void slotEditReferrerWithQuanta(KURL const& url);
    virtual void slotViewUrlInBrowser();
    virtual void slotViewParentUrlInBrowser();
    virtual void loadContextTableMenu(TQValueVector<KURL> const& referrers, bool is_root = false);

private:

    vector<TableItem*> generateRowOfTableItems(LinktqStatus const* linkstatus);
    void insereLinha(vector<TableItem*> items);

private:
/*
    int col_status_;
    int col_label_;
    int col_url_;
    CellToolTip* cell_tip_;
    TQPopupMenu context_table_menu_;
    TQPopupMenu* sub_menu_;
*/
};


class TableItem: public TQTableItem, public ResultViewItem
{
public:

    TableItem(TQTable* table, EditType et,
              LinktqStatus const* linkstatus,
              int column_index, int tqalignment = TQt::AlignLeft);
    virtual ~TableItem();

    virtual void setColumnIndex(int i);
    virtual int columnIndex() const;

    void tqsetAlignment(int aFlags);
    virtual int tqalignment() const;

    virtual TQString toolTip() const = 0;
    //LinktqStatus const* const linktqStatus() const;

protected:

    //TQColor const& textStatusColor() const;
    virtual void paint( TQPainter *p, const TQColorGroup &cg,
                        const TQRect &cr, bool selected );
    virtual void setText() = 0;
    virtual void setPixmap() = 0;

private:

    //LinktqStatus* ls_;
    //int column_index_;
    int alignment_;
};


class TableItemURL: public TableItem
{
public:

    TableItemURL(TQTable* table, EditType et,
                 LinktqStatus const* linkstatus, int column_index = 3);
    //virtual ~TableItemURL(){};

    virtual TQString toolTip() const;

protected:

    virtual void setText();
    virtual void setPixmap();
    virtual void paint( TQPainter *p, const TQColorGroup &cg, const TQRect &cr, bool selected );
    TQColor const& textStatusColor() const;
};


class TableItemtqStatus: public TableItem
{
public:

    TableItemtqStatus(TQTable* table, EditType et,
                    LinktqStatus const* linkstatus, int column_index = 1);
    //virtual ~TableItemtqStatus(){};

    virtual TQString toolTip() const;

protected:

    virtual void setText();
    virtual void setPixmap();
    virtual void paint( TQPainter *p, const TQColorGroup &cg, const TQRect &cr, bool selected );
};


class TableItemNome: public TableItem
{
public:

    TableItemNome(TQTable* table, EditType et,
                  LinktqStatus const* linkstatus, int column_index = 2);
    //virtual ~TableItemNome(){};

    virtual TQString toolTip() const;

protected:

    virtual void setText();
    virtual void setPixmap();
    //virtual void paint( TQPainter *p, const TQColorGroup &cg, const TQRect &cr, bool selected );
};


inline void TableItem::paint( TQPainter *p, const TQColorGroup &cg,
                              const TQRect &cr, bool selected )
{
    TQTableItem::paint(p, cg, cr, selected);
}

#endif