kitchensync
konnectorbar.cpp
00001 /* 00002 This file is part of KitchenSync. 00003 00004 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #include <kiconloader.h> 00023 00024 #include "konnectorbar.h" 00025 00026 using namespace KSync; 00027 00028 KonnectorState::KonnectorState( QWidget* parent ) 00029 : QLabel( parent ) { 00030 m_state = 1; // off; 00031 m_pix[0] = ::SmallIcon( QString::fromLatin1("connect_established") ); 00032 m_pix[1] = ::SmallIcon( QString::fromLatin1("connect_no") ); 00033 setPixmap( m_pix[1] ); 00034 } 00035 KonnectorState::~KonnectorState() { 00036 00037 } 00038 void KonnectorState::setState( bool b) { 00039 /* on */ 00040 if (b ) 00041 m_state = 0; 00042 else 00043 m_state = 1; 00044 00045 setPixmap( m_pix[m_state] ); 00046 } 00047 bool KonnectorState::state()const { 00048 return ( m_state != 0 ); 00049 } 00050 void KonnectorState::mousePressEvent( QMouseEvent* ) { 00051 emit clicked( state() ); 00052 } 00053 00054 KonnectorBar::KonnectorBar( QWidget* parent ) 00055 : QHBox( parent ) { 00056 m_lbl = new KonnectorLabel(this); 00057 m_state = new KonnectorState(this); 00058 connect(m_state, SIGNAL(clicked(bool) ), 00059 this, SIGNAL(toggled(bool) ) ); 00060 } 00061 KonnectorBar::~KonnectorBar() { 00062 } 00063 void KonnectorBar::setName( const QString& name ) { 00064 m_lbl->setText( name ); 00065 } 00066 QString KonnectorBar::name()const{ 00067 return m_lbl->text(); 00068 } 00069 void KonnectorBar::setState( bool b ) { 00070 m_state->setState( b ); 00071 } 00072 bool KonnectorBar::state()const { 00073 return isOn(); 00074 } 00075 bool KonnectorBar::isOn()const { 00076 return m_state->state(); 00077 } 00078 00079 #include "konnectorbar.moc"