20 #include "driveritem.h"
23 #include <tqpainter.h>
24 #include <kiconloader.h>
27 DriverItem::DriverItem(TQListView *parent, DrBase *item)
28 : TQListViewItem(parent), m_item(item), m_conflict(false)
31 setPixmap(0,SmallIcon(
"document-print"));
35 DriverItem::DriverItem(TQListViewItem *parent, TQListViewItem *after, DrBase *item)
36 : TQListViewItem(parent, after), m_item(item), m_conflict(false)
39 if (item) setPixmap(0,SmallIcon((item->isOption() ?
"text-x-generic" :
"folder")));
43 void DriverItem::updateText()
47 TQString s(m_item->get(
"text"));
48 if (m_item->isOption())
49 s.append(TQString::fromLatin1(
": <%1>").arg(m_item->prettyText()));
50 if (m_item->type() == DrBase::List)
57 DrBase *ch =
static_cast<DrListOption*
>(m_item)->currentChoice();
58 if (ch && ch->type() == DrBase::ChoiceGroup)
61 static_cast<DrChoiceGroup*
>(ch)->createItem(
this);
72 void DriverItem::paintCell(TQPainter *p,
const TQColorGroup& cg,
int,
int width,
int)
75 p->fillRect(0, 0, width, height(), cg.base());
79 p->fillRect(0, 0, width, height(), (m_conflict ? red : cg.highlight()));
83 if (pixmap(0) && !pixmap(0)->isNull())
85 int h((height()-pixmap(0)->height())/2);
86 p->drawPixmap(w,h,*pixmap(0));
87 w += (pixmap(0)->width()+2);
91 if (!m_item || !m_item->isOption() || isSelected())
93 p->setPen((isSelected() ? cg.highlightedText() : (m_conflict ? red : cg.text())));
94 p->drawText(w,0,width-w,height(),TQt::AlignLeft|TQt::AlignVCenter,text(0));
99 TQString s(m_item->get(
"text") +
": <");
100 w1 = p->fontMetrics().width(s);
101 p->setPen(cg.text());
102 p->drawText(w,0,w1,height(),TQt::AlignLeft|TQt::AlignVCenter,s);
104 p->setPen((m_conflict ? red : darkGreen));
105 s = m_item->prettyText();
106 w1 = p->fontMetrics().width(s);
107 p->drawText(w,0,w1,height(),TQt::AlignLeft|TQt::AlignVCenter,s);
109 p->setPen(cg.text());
110 s = TQString::fromLatin1(
">");
111 w1 = p->fontMetrics().width(s);
112 p->drawText(w,0,w1,height(),TQt::AlignLeft|TQt::AlignVCenter,s);
116 bool DriverItem::updateConflict()
121 if (!m_item->isOption())
123 DriverItem *item = (DriverItem*)firstChild();
126 if (item->updateConflict())
128 item = (DriverItem*)item->nextSibling();
133 m_conflict = (m_item->conflict());
140 void DriverItem::updateTextRecursive()
142 if ( m_item->isOption() )
145 DriverItem *item =
static_cast<DriverItem*
>( firstChild() );
148 item->updateTextRecursive();
149 item =
static_cast<DriverItem*
>( item->nextSibling() );