summaryrefslogtreecommitdiffstats
path: root/klinkstatus/src/ui/tablelinkstatus.cpp
blob: d1609d3169da02c3675b92860fad3beb68f2c93b (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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
/***************************************************************************
 *   Copyright (C) 2004 by Paulo Moura Guedes                              *
 *   [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; 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.             *
 ***************************************************************************/

#include "tablelinkstatus.h"
#include "../utils/utils.h"
#include "../parser/url.h"
#include "../global.h"

#include <tqmemarray.h>
#include <tqtooltip.h>
#include <tqpixmap.h>
#include <tqclipboard.h>
#include <tqpainter.h>
#include <tqprocess.h>

#include <kapplication.h>
#include <kstandarddirs.h>
#include <krun.h>
#include <kiconloader.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <dcopclient.h>
#include <dcopref.h>


/*

********************* TableLinkstatus ***************************

*/

TableLinkstatus::TableLinkstatus(TQWidget * parent, const char * name,
                                 int column_index_status,
                                 int column_index_label,
                                 int column_index_URL)
        : TQTable(parent, name),
        ResultView(column_index_status, column_index_label, column_index_URL)
        //context_table_menu_(this, "context_table_menu")
{
    setShowGrid(false);
    setSorting(false);
    setSelectionMode(TQTable::NoSelection);
    setFocusStyle(TQTable::FollowStyle);
    setReadOnly(true);

    verticalHeader()->hide();
    setLeftMargin(0);

    cell_tip_ = new CellToolTip(this);

    sub_menu_ = new TQPopupMenu(this, "sub_menu_referrers");

    connect(this, TQT_SIGNAL( contextMenuRequested ( int, int, const TQPoint&  )),
            this, TQT_SLOT( slotPopupContextMenu( int, int, const TQPoint&)) );
}

TableLinkstatus::~TableLinkstatus()
{
    delete cell_tip_;
}

void TableLinkstatus::setColumns(TQStringList const& columns)
{
    ResultView::setColumns(columns);

    removeColunas();
    setNumCols(columns.size());

    TQHeader* horizontal_header = horizontalHeader();
    for(uint i = 0; i != columns.size(); ++i)
    {
        if(i == 0)
        {
            Q_ASSERT(columns[i] == i18n("Status") && col_status_ == 1);
            setColumnWidth(i, STATUS_COLUMN_WIDTH);
        }
        else if(i == 1)
        {
            Q_ASSERT(columns[i] == i18n("Label") && col_label_ == 2);
            setColumnWidth(i, width() / 3);
        }
        else if(i == 2)
            Q_ASSERT(columns[i] == i18n("URL") && col_url_ == 3);

        horizontal_header->setLabel(i, i18n(columns[i]));
    }

    setColumnStretchable(col_url_ - 1, true);
    horizontal_header->adjustHeaderSize();
}

void TableLinkstatus::insertResult(LinkStatus const* linkstatus)
{
    insereLinha(generateRowOfTableItems(linkstatus));
}

vector<TableItem*> TableLinkstatus::generateRowOfTableItems(LinkStatus const* linkstatus)
{
    vector<TableItem*> items;
    int column = 1;

    TableItem* item1 = new TableItemStatus(this, TQTableItem::Never,
                                           linkstatus, column++);
    TableItem* item2 = new TableItemNome(this, TQTableItem::Never,
                                         linkstatus, column++);
    TableItem* item3 = new TableItemURL(this, TQTableItem::Never,
                                        linkstatus, column++);
    items.push_back(item1);
    items.push_back(item2);
    items.push_back(item3);

    // If more columns are choosed in the settings, create and add the items here
    // ...

    return items;
}

void TableLinkstatus::insereLinha(vector<TableItem*> items)
{
    Q_ASSERT(items.size() == (uint)numCols());

    setNumRows(numRows() + 1);
    int row = numRows() - 1;

    for(vector<TableItem*>::size_type i = 0; i != items.size(); ++i)
    {
        Q_ASSERT(items[i]);

        int col = items[i]->columnIndex() - 1;
        setItem(row, col, items[i]);
    }

    if(items[col_url_ - 1]->sizeHint().width() > columnWidth(col_url_ - 1))
    {
        setColumnStretchable(col_url_ - 1, false);
        setColumnWidth(col_url_ - 1, items[col_url_ - 1]->sizeHint().width());
    }

    ensureCellVisible(row, 0);
}

void TableLinkstatus::clear()
{
    TQMemArray<int> linhas(numRows());
    for(uint i = 0; i != linhas.size(); ++i)
        linhas[i] = i + 1;

    removeRows(linhas);

    Q_ASSERT(numRows() == 0);
}

void TableLinkstatus::removeColunas()
{
    TQMemArray<int> columns(numCols());
    for(uint i = 0; i != columns.size(); ++i)
        columns[i] = i + 1;

    removeColumns(columns);

    Q_ASSERT(numCols() == 0);
}

void TableLinkstatus::show(ResultView::Status const& status)
{
    for(int i = 0; i != numRows(); ++i)
    {
        int row = i;
        TableItem* _item = myItem(row, col_status_);

        if(!ResultView::displayableWithStatus(_item->linkStatus(), status))
            hideRow(row);
        else
            showRow(row);
    }
}

void TableLinkstatus::showAll()
{
    for(int i = 0; i != numRows(); ++i)
        showRow(i);
}

/*
void TableLinkstatus::mostraPorStatusCode(int status_code)
{
    for(int i = 0; i != numRows(); ++i)
    {
        int row = i + 1;
        TQTableItem* _item = myItem(row, col_status_);

        if(status_code != _item->text().toInt())
            hideRow(row);
    }
}
*/
/**
   Use this procedure when you insert a row at the bottom of the table,
   and you only want the to scroll down if you were already at the bottom,
   before inserting the row.
   This allows you to see what's going on on other cells without having
   the table always scrolling down when every row is inserted.
*/
void TableLinkstatus::ensureCellVisible(int row, int col)
{
    // table viewport is at the bottom
    if(rowPos(row - 1) <= (contentsY() + visibleHeight()))
        TQTable::ensureCellVisible(row, col);
}

bool TableLinkstatus::textFitsInCell(int row, int col) const
{
    TQTableItem* itm(myItem(row, col));
    Q_ASSERT(itm);

    TQSize size_hint(itm->sizeHint());
    int visible_width = 0;

    if(col == numCols() - 1)
        visible_width = contentsX() + visibleWidth();
    else
        visible_width = columnPos(col) + columnWidth(col);

    if(columnPos(col) + size_hint.width() > visible_width)
        return false;
    else
        return true;
}

bool TableLinkstatus::isEmpty() const
{
    return numRows() == 0;
}

TableItem* TableLinkstatus::myItem(int row, int col) const
{
    TableItem* _item = dynamic_cast<TableItem*> (TQTable::item(row, col));
    Q_ASSERT(_item);
    return _item;
}

void TableLinkstatus::slotPopupContextMenu(int r, int w, const TQPoint& pos)
{
    TableItem* table_item = myItem(r, w);
    if(table_item)
    {
        TQValueVector<KURL> referrers = table_item->linkStatus()->referrers();
        loadContextTableMenu(referrers, table_item->linkStatus()->isRoot());
        context_table_menu_.popup(pos);
    }
}

void TableLinkstatus::loadContextTableMenu(TQValueVector<KURL> const& referrers, bool is_root)
{
    context_table_menu_.clear();
    sub_menu_->clear();

    if(!is_root)
    {
        sub_menu_->insertItem(i18n("All"), this, TQT_SLOT(slotEditReferrersWithQuanta()));
        sub_menu_->insertSeparator();

        for(uint i = 0; i != referrers.size(); ++i)
        {
            sub_menu_->insertItem(referrers[i].prettyURL());
        }
        connect(sub_menu_, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotEditReferrerWithQuanta(int)));

        context_table_menu_.insertItem(SmallIconSet("fileopen"), i18n("Edit Referrer with Quanta"),
                                       sub_menu_);
    }
    else
    {
        int id = context_table_menu_.insertItem(SmallIconSet("fileopen"), i18n("Edit Referrer with Quanta"));
        context_table_menu_.setItemEnabled(id, false);
    }

    context_table_menu_.insertItem(SmallIconSet("fileopen"), i18n("Open URL"),
                                   this, TQT_SLOT(slotViewUrlInBrowser()));

    context_table_menu_.insertItem(SmallIconSet("fileopen"), i18n("Open Referrer URL"),
                                   this, TQT_SLOT(slotViewParentUrlInBrowser()));

    context_table_menu_.insertSeparator();

    context_table_menu_.insertItem(SmallIconSet("editcopy"), i18n("Copy URL"),
                                   this, TQT_SLOT(slotCopyUrlToClipboard()));

    context_table_menu_.insertItem(SmallIconSet("editcopy"), i18n("Copy Referrer URL"),
                                   this, TQT_SLOT(slotCopyParentUrlToClipboard()));

    context_table_menu_.insertItem(SmallIconSet("editcopy"), i18n("Copy Cell Text"),
                                   this, TQT_SLOT(slotCopyCellTextToClipboard()));
}

void TableLinkstatus::slotCopyUrlToClipboard() const
{
    TableItem* _item = myItem(currentRow(), currentColumn());
    TQString content(_item->linkStatus()->absoluteUrl().prettyURL());
    TQClipboard* cb = kapp->clipboard();
    cb->setText(content);
}

void TableLinkstatus::slotCopyParentUrlToClipboard() const
{
    TableItem* _item = myItem(currentRow(), currentColumn());
    TQString content(_item->linkStatus()->parent()->absoluteUrl().prettyURL());
    TQClipboard* cb = kapp->clipboard();
    cb->setText(content);
}

void TableLinkstatus::slotCopyCellTextToClipboard() const
{
    TQString cell_text(text(currentRow(), currentColumn()));
    TQClipboard* cb = kapp->clipboard();
    cb->setText(cell_text);
}

void TableLinkstatus::slotEditReferrersWithQuanta()
{
    TableItem* _item = myItem(currentRow(), currentColumn());
    TQValueVector<KURL> referrers = _item->linkStatus()->referrers();

    if(Global::isQuantaAvailableViaDCOP())
    {
        for(uint i = 0; i != referrers.size(); ++i)
            slotEditReferrerWithQuanta(referrers[i]);
    }
    else
    {
        TQStringList list_urls;

        for(uint i = 0; i != referrers.size(); ++i)
            list_urls.append(referrers[i].url());

        Global::openQuanta(list_urls);
    }
}

void TableLinkstatus::slotEditReferrerWithQuanta(int id)
{
    int index = sub_menu_->indexOf(id);

    if(index == 0)
        return;
    Q_ASSERT(index != -1);
    Q_ASSERT(index != 1); // separator

    //kdDebug(23100) << "id: " << id << endl;
    //kdDebug(23100) << "index: " << index << endl;

    index -= 2; // The list of referrers starts on index = 2

    TableItem* _item = myItem(currentRow(), currentColumn());
    TQValueVector<KURL> referrers = _item->linkStatus()->referrers();
    Q_ASSERT(index >= 0 && (uint)index < referrers.size());

    slotEditReferrerWithQuanta(referrers[index]);
}

void TableLinkstatus::slotEditReferrerWithQuanta(KURL const& url)
{
    TQString filePath = url.url();

    if(Global::isQuantaAvailableViaDCOP())
    {
        DCOPRef quanta(Global::quantaDCOPAppId(),"WindowManagerIf");
        bool success = quanta.send("openFile", filePath, 0, 0);

        if(!success)
        {
            TQString message = i18n("<qt>File <b>%1</b> cannot be opened. Might be a DCOP problem.</qt>").arg(filePath);
            KMessageBox::error(parentWidget(), message);
        }
    }
    else
    {
        TQStringList args(url.url());
        Global::openQuanta(args);
    }
}

void TableLinkstatus::slotViewUrlInBrowser()
{
    TableItem* _item = myItem(currentRow(), currentColumn());
    KURL url = _item->linkStatus()->absoluteUrl();

    if(url.isValid())
    {
        (void) new KRun (url, 0, url.isLocalFile(), true);
    }
    else
        KMessageBox::sorry(this, i18n("Invalid URL."));
}

void TableLinkstatus::slotViewParentUrlInBrowser()
{
    TableItem* _item = myItem(currentRow(), currentColumn());

    if(_item->linkStatus()->isRoot())
    {
        KMessageBox::sorry(this, i18n("ROOT URL."));
    }
    else
    {
        LinkStatus const* ls_parent = _item->linkStatus()->parent();
        Q_ASSERT(ls_parent);

        KURL url = ls_parent->absoluteUrl();

        if(url.isValid())
            (void) new KRun (url, 0, url.isLocalFile(), true);
        else
            KMessageBox::sorry(this, i18n("Invalid URL."));
    }
}

/*

********************* TableItem ***************************

*/

TableItem::TableItem(TQTable* table, EditType et,
                     LinkStatus const* linkstatus,
                     int column_index, int alignment)
        : TQTableItem(table, et, ""), ResultViewItem(linkstatus, column_index),
        /*ls_((LinkStatus*)linkstatus),
        column_index_(column_index),*/ alignment_(alignment)
{
    //Q_ASSERT(ls_);
    //Q_ASSERT(column_index_ > 0);
}

TableItem::~TableItem()
{}

void TableItem::setColumnIndex(int i)
{
    Q_ASSERT(i > 0 && i <= table()->numCols());

    //column_index_ = i;
    ResultViewItem::setColumnIndex(i);
}

int TableItem::columnIndex() const
{
    Q_ASSERT(column_index_ <= table()->numCols());

    return ResultViewItem::columnIndex();
}

void TableItem::setAlignment(int aFlags)
{
    alignment_ = aFlags;
}

int TableItem::alignment() const
{
    return alignment_;
}
/*
LinkStatus const* const TableItem::linkStatus() const
{
    Q_ASSERT(ls_);
    return ls_;
}

TQColor const& TableItem::textStatusColor() const
{
    if(linkStatus()->errorOccurred())
    {
        //kdDebug(23100) <<  "ERROR: " << linkStatus()->error() << ": " << linkStatus()->absoluteUrl().prettyURL() << endl;
        if(linkStatus()->error() == i18n( "Javascript not supported" ))
            return TQt::lightGray;
        else
            return TQt::red;
    }

    else if(linkStatus()->absoluteUrl().hasRef())
        return TQt::blue;

    else if(linkStatus()->absoluteUrl().protocol() != "http" &&
            linkStatus()->absoluteUrl().protocol() != "https")
        return TQt::darkGreen;

    else
    {
        TQString status_code(TQString::number(linkStatus()->httpHeader().statusCode()));

        if(status_code[0] == '0')
        {
            kdWarning(23100) <<  "status code == 0: " << endl;
            kdWarning(23100) <<  linkStatus()->toString() << endl;
            kdWarning(23100) <<  linkStatus()->httpHeader().toString() << endl;
        }
        //Q_ASSERT(status_code[0] != '0');

        if(status_code[0] == '5')
            return TQt::darkMagenta;

        else if(status_code[0] == '4')
            return TQt::red;

        else if(status_code[0] == '3')
            return TQt::blue;

        else if(status_code[0] == '2')
            return TQt::darkGreen;

        else
            return TQt::red;
    }
}
*/

/*

********************* TableItemURL ***************************

*/

TableItemURL::TableItemURL(TQTable* table, EditType et,
                           LinkStatus const* linkstatus, int column_index)
        : TableItem(table, et, linkstatus, column_index)
{
    setText();
}

void TableItemURL::setText()
{
    if(linkStatus()->node() && linkStatus()->malformed())
    {
        if(linkStatus()->node()->url().isEmpty())
            TQTableItem::setText( linkStatus()->node()->content().simplifyWhiteSpace() );
        else
            TQTableItem::setText( linkStatus()->node()->url() );
    }
    else
    {
        KURL url = linkStatus()->absoluteUrl();
        TQTableItem::setText(::convertToLocal(linkStatus()));
    }
}

void TableItemURL::setPixmap()
{}

TQString TableItemURL::toolTip() const
{
    return text(); // Pode parecer repeticao mas nao eh... Ver construtor
}

void TableItemURL::paint( TQPainter *p, const TQColorGroup &cg,
                          const TQRect &cr, bool selected )
{
    // Get a color to draw the text
    TQColorGroup m_cg(cg);
    TQColor color(textStatusColor());
    m_cg.setColor(TQColorGroup::Text, color);

    TQTableItem::paint(p, m_cg, cr, selected);
}

TQColor const& TableItemURL::textStatusColor() const
{
    // TODO clean this code

    TQString status_code(TQString::number(linkStatus()->httpHeader().statusCode()));

    if(linkStatus()->errorOccurred())
    {
        if(linkStatus()->error().contains(i18n( "Timeout" )))
            return darkMagenta;
        else if(linkStatus()->error().contains(i18n( "not supported" )))
            return lightGray;
        else
            return red;
    }
    else if(linkStatus()->absoluteUrl().protocol() != "http" &&
            linkStatus()->absoluteUrl().protocol() != "https")
        return black;

    else if(status_code[0] == '5')
        return darkMagenta;

    else if(status_code[0] == '4')
        return red;

    else
        return black;
}

/*

********************* TableItemStatus ***************************

*/

TableItemStatus::TableItemStatus(TQTable* table, EditType et,
                                 LinkStatus const* linkstatus, int column_index)
        : TableItem(table, et, linkstatus, column_index)
{
    setAlignment(TQt::AlignHCenter /*| TQt :: AlignVCenter*/);
    setText();
    setPixmap();
}

void TableItemStatus::setText()
{
    if(linkStatus()->errorOccurred() ||
            linkStatus()->status() == "OK" ||
            linkStatus()->status() == "304")
    {
        TQTableItem::setText("");
    }
    else
    {
        /*
                if(linkStatus()->httpHeader().statusCode() == 0)
                {
                    kdDebug(23100) <<  "TableItemStatus::setText : statusCode() == 0" << endl;
                    kdDebug(23100) <<  linkStatus()->toString() << endl;
                    kdDebug(23100) <<  linkStatus()->docHtml() << endl;
                }
        */
        //Q_ASSERT(linkStatus()->httpHeader().statusCode() != 0); //<------------------------------------------------------------
        //TQTableItem::setText( TQString::number(linkStatus()->httpHeader().statusCode()) );
        TQTableItem::setText( linkStatus()->status() );
    }
}

void TableItemStatus::setPixmap()
{
    if(linkStatus()->errorOccurred())
    {

        if(linkStatus()->error().contains(i18n( "Timeout" )))
        {
            TQTableItem::setPixmap(SmallIcon("kalarm"));
        }
        else if(linkStatus()->error() == i18n( "Malformed" ))
        {
            TQTableItem::setPixmap(SmallIcon("bug"));
        }
        else
        {
            TQTableItem::setPixmap(SmallIcon("no"));
        }
    }
    else if(linkStatus()->status() == "304")
        TQTableItem::setPixmap(UserIcon("304"));

    else if(linkStatus()->status() == "OK")
        TQTableItem::setPixmap(SmallIcon("ok"));
}

TQString TableItemStatus::toolTip() const
{
    if(linkStatus()->errorOccurred() ||
            linkStatus()->absoluteUrl().hasRef() ||
            (linkStatus()->absoluteUrl().protocol() != "http" &&
             linkStatus()->absoluteUrl().protocol() != "https"))
    {
        return i18n("%1").arg(linkStatus()->status());
    }
    else
        return i18n("%1").arg(linkStatus()->httpHeader().reasonPhrase());
}

void TableItemStatus::paint( TQPainter *p, const TQColorGroup &cg,
                             const TQRect &cr, bool selected )
{
    p->fillRect( 0, 0, cr.width(), cr.height(),
                 selected ? cg.brush( TQColorGroup::Highlight )
                 : cg.brush( TQColorGroup::Base ) );

    int w = cr.width();
    int h = cr.height();

    int x = 0;
    if ( !pixmap().isNull() )
    {
        p->drawPixmap( ( w - pixmap().width() ) / 2,
                       ( h - pixmap().height() ) / 2,
                       pixmap() );
        x = pixmap().width() + 2;
    }

    // Get a color to draw the text
    TQColorGroup m_cg(cg);
    TQColor color(textStatusColor());
    m_cg.setColor(TQColorGroup::Text, color);

    //TQTableItem::paint(p, m_cg, cr, selected);

    if ( selected )
        p->setPen( m_cg.highlightedText() );
    else
        p->setPen( m_cg.text() );
    p->drawText( x + 2, 0, w - x - 4, h,
                 wordWrap() ? (alignment() | WordBreak) : alignment(), text() );
}

/*

********************* TableItemNome ***************************

*/

TableItemNome::TableItemNome(TQTable* table, EditType et,
                             LinkStatus const* linkstatus, int column_index)
        : TableItem(table, et, linkstatus, column_index)
{
    setText();
}

void TableItemNome::setText()
{
    TQString label(linkStatus()->label());
    if(!label.isNull())
        TQTableItem::setText(label.simplifyWhiteSpace());
}

void TableItemNome::setPixmap()
{}

TQString TableItemNome::toolTip() const
{
    return text(); // Pode parecer repeticao mas nao eh... Ver construtor
}

#include "tablelinkstatus.moc"