~ubuntu-branches/debian/sid/kxstitch/sid

« back to all changes in this revision

Viewing changes to kxstitch/flosslistboxitem.cpp

  • Committer: Bazaar Package Importer
  • Author(s): eric pareja
  • Date: 2005-02-19 12:37:22 UTC
  • Revision ID: james.westby@ubuntu.com-20050219123722-kt3ru1nqvllietee
Tags: upstream-0.6
ImportĀ upstreamĀ versionĀ 0.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2003 by Stephen Allewell                                *
 
3
 *   stephen@mirramar.fsnet.co.uk                                          *
 
4
 *                                                                         *
 
5
 *   This program is free software; you can redistribute it and/or modify  *
 
6
 *   it under the terms of the GNU General Public License as published by  *
 
7
 *   the Free Software Foundation; either version 2 of the License, or     *
 
8
 *   (at your option) any later version.                                   *
 
9
 ***************************************************************************/
 
10
 
 
11
#include <qpainter.h>
 
12
#include <qnamespace.h>
 
13
#include <klocale.h>
 
14
#include "flosslistboxitem.h"
 
15
 
 
16
FlossListBoxItem::FlossListBoxItem(QListBox* listBox,Floss* f)
 
17
  : QListBoxItem(listBox),
 
18
    floss(f),
 
19
    m_calibrated(false)
 
20
{
 
21
}
 
22
 
 
23
FlossListBoxItem::~FlossListBoxItem()
 
24
{
 
25
  // nothing to do
 
26
}
 
27
 
 
28
int FlossListBoxItem::height(const QListBox *) const
 
29
{
 
30
  return 20;
 
31
}
 
32
 
 
33
int FlossListBoxItem::width(const QListBox *) const
 
34
{
 
35
  return 100;
 
36
}
 
37
 
 
38
void FlossListBoxItem::paint(QPainter *p)
 
39
{
 
40
/** draws the list box item as a block of the color followed by the color code and description
 
41
  */
 
42
  QPen pen = p->pen();
 
43
 
 
44
  p->fillRect(0,0,50,18,QBrush(floss->color));
 
45
  if (!isSelectable())
 
46
    p->setPen(Qt::lightGray);
 
47
  QString s = QString("%1 %2 %3").arg(floss->name).arg(floss->description).arg(m_calibrated?i18n("(Calibrated)"):"");
 
48
  p->drawText(55,16,s);
 
49
  p->setPen(pen);
 
50
}
 
51
 
 
52
void FlossListBoxItem::setCalibrated(bool c)
 
53
{
 
54
  m_calibrated = c;
 
55
  listBox()->triggerUpdate(false);
 
56
}
 
57
 
 
58
bool FlossListBoxItem::isCalibrated()
 
59
{
 
60
  return m_calibrated;
 
61
}