summaryrefslogtreecommitdiffstats
path: root/konversation/src/highlightviewitem.cpp
blob: 811a7d8e28cf5920317a9f88fb9c2405961bda8a (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
/***************************************************************************
    begin                : Sat Jun 15 2002
    copyright            : (C) 2002 by Matthias Gierlings
    email                : gismore@users.sourceforge.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.                                   *
 *                                                                         *
 ***************************************************************************/

#include "highlightviewitem.h"

#include <kurl.h>
#include <klistview.h>


HighlightViewItem::HighlightViewItem(KListView* tqparent, Highlight* passed_Highlight)
: TQCheckListItem(tqparent, TQString(), TQCheckListItem::CheckBox)
{
    setText(1,passed_Highlight->getPattern());
    itemColor = passed_Highlight->getColor();
    itemID = passed_Highlight->getID();
    setSoundURL(passed_Highlight->getSoundURL());
    setAutoText(passed_Highlight->getAutoText());
    setOn(passed_Highlight->getRegExp());
    m_changed=false;
}

HighlightViewItem::~HighlightViewItem()
{
}

void HighlightViewItem::paintCell(TQPainter* p, const TQColorGroup &cg, int column, int width, int tqalignment)
{
    // copy all colors from cg and only then change needed colors
    itemColorGroup=cg;
    itemColorGroup.setColor(TQColorGroup::Text, itemColor);
    TQCheckListItem::paintCell(p, itemColorGroup, column, width, tqalignment);
}

HighlightViewItem* HighlightViewItem::itemBelow()
{
    return (HighlightViewItem*) TQCheckListItem::itemBelow();
}

void HighlightViewItem::setPattern(const TQString& newPattern) { setText(1,newPattern); }
TQString HighlightViewItem::getPattern()                       { return text(1); }

void HighlightViewItem::setSoundURL(const KURL& url)
{
    soundURL = url;
    setText(2, soundURL.prettyURL());
}

void HighlightViewItem::setAutoText(const TQString& newAutoText)
{
    autoText = newAutoText;
    setText(3,newAutoText);
}

bool HighlightViewItem::getRegExp()
{
    return isOn();
}

TQString HighlightViewItem::getAutoText()
{
    return autoText;
}

// override default method to store the change
void HighlightViewItem::stateChange(bool /* newState */)
{
  // remember that the check box has been changed
  m_changed=true;
}

// returns true, if the checkbox has been changed
bool HighlightViewItem::hasChanged()
{
  return m_changed;
}

// tells us that the program has seen us changing
void HighlightViewItem::changeAcknowledged()
{
  m_changed=false;
}