summaryrefslogtreecommitdiffstats
path: root/kteatime/tealist.cpp
blob: 0f7aa264c899a9c530f5a65bc970fe6688f340de (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
/* -------------------------------------------------------------

   tealist.cpp

   (C) 2003 by Daniel Teske (teske@bigfoot.com)

 ------------------------------------------------------------- */

#include <klocale.h>
#include <qlistview.h>
#include "tealist.h"


QString int2time(int time)
{
	QString str;
	if (time / 60)
		str.append(i18n("%1 min").arg(time / 60));
	if (time % 60)
          if (str.isEmpty())
            str.append(i18n("%1 s").arg(time % 60));
          else
            str.append(i18n(" %1 s").arg(time % 60));
	return str;
}


TeaListItem::TeaListItem(QListView * parent)
    :QListViewItem(parent)
{

}

TeaListItem::TeaListItem(QListView * parent, QListViewItem *after)
    :QListViewItem(parent, after)
{

}

TeaListItem::~TeaListItem()
{
}

void TeaListItem::setTime(int t)
{
	QListViewItem::setText(1, int2time(t));
	tim = t;
}

void TeaListItem::setName(const QString &n)
{
	nam = n;
	QListViewItem::setText(0, n);
}

QString TeaListItem::name()
{
	return nam;
}

int TeaListItem::time()
{
	return tim;
}