summaryrefslogtreecommitdiffstats
path: root/korn/hvitem.cpp
blob: fa4190d3e8b2e24a3eb97f859d3460c3689e0c45 (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
/*
 * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
 *
 * 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 "hvitem.h"

#include "label.h"

#include <kactioncollection.h>
#include <kapplication.h>
#include <kdebug.h>
#include <kpassivepopup.h>
#include <kpopupmenu.h>
#include <kstdaction.h>

#include <tqcursor.h>
#include <tqtooltip.h>

HVItem::HVItem( TQWidget *tqparent, const char *name )
	: BoxContainerItem( 0, name ),
	_label( new Label( tqparent, "label" ) ),
	_popup( new KPopupMenu( _label, "popupmenu" ) ),
	_actions( new KActionCollection( _popup, "actions" ) )
{
	_popup->insertTitle( kapp->miniIcon(), kapp->caption() );
	this->fillKPopupMenu( _popup, _actions );
	_popup->insertSeparator();
	KStdAction::quit( TQT_TQOBJECT(kapp), TQT_SLOT( quit() ), _actions )->plug( _popup );
	
	connect( _label, TQT_SIGNAL( mouseButtonPressed( TQt::ButtonState ) ), this, TQT_SLOT( mouseButtonPressed( TQt::ButtonState ) ) );
}

HVItem::~HVItem()
{
	//Let everything be deleted by his parents.
}
	
void HVItem::showBox()
{
	_label->show();
}
	
void HVItem::setCount( const int count, const bool newMessages )
{
	drawLabel( _label, count, newMessages );
}

void HVItem::setTooltip( const TQString& string )
{
	TQToolTip::add( _label, string );
}

void HVItem::slotShowPassivePopup( TQPtrList< KornMailSubject >* list, int total, bool date, const TQString& name )
{
	showPassivePopup( _label, list, total, name, date );
}

void HVItem::slotShowPassivePopup( const TQString& errorMessage, const TQString& name )
{
	KPassivePopup::message( TQString( "korn-%1-%2" ).tqarg( TQString(objId()) ).tqarg( name ), errorMessage, _label, "Passive error message" );
}
	
void HVItem::doPopup()
{
	_popup->popup( TQCursor::pos() );
}

#include "hvitem.moc"