File indexing completed on 2024-11-03 06:54:18
0001 // 0002 // C++ Implementation: cgaugebar 0003 // 0004 // Description: 0005 // 0006 /* 0007 Copyright 2004-2011 Tomas Mecir <kmuddy@kmuddy.com> 0008 0009 This program is free software; you can redistribute it and/or 0010 modify it under the terms of the GNU General Public License as 0011 published by the Free Software Foundation; either version 2 of 0012 the License, or (at your option) any later version. 0013 0014 This program is distributed in the hope that it will be useful, 0015 but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 GNU General Public License for more details. 0018 0019 You should have received a copy of the GNU General Public License 0020 along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 */ 0022 0023 #include "cgaugebar.h" 0024 0025 #include "cgauge.h" 0026 #include "cgaugebaritem.h" 0027 #include "cgaugelist.h" 0028 0029 #include <QHBoxLayout> 0030 0031 cGaugeBar::cGaugeBar (int sess, QWidget *parent) 0032 : QWidget(parent), cActionBase ("gaugebar", sess) 0033 { 0034 layout = new QHBoxLayout (this); 0035 layout->setSpacing (5); 0036 layout->setContentsMargins (2, 2, 2, 2); 0037 setFocusPolicy (Qt::NoFocus); 0038 count = 0; 0039 layout->addStretch (1); 0040 setAutoFillBackground (true); 0041 } 0042 0043 0044 cGaugeBar::~cGaugeBar () 0045 { 0046 } 0047 0048 void cGaugeBar::addGauge (cGauge *g) 0049 { 0050 layout->insertWidget (count, g->gaugeItem()); 0051 g->gaugeItem()->show(); 0052 count++; 0053 update (); 0054 } 0055 0056 void cGaugeBar::removeGauge (cGauge *g) 0057 { 0058 if (!g->gaugeItem()) return; 0059 layout->removeWidget (g->gaugeItem()); 0060 g->gaugeItem()->hide(); 0061 if (count) count--; 0062 update (); 0063 } 0064 0065 #include "moc_cgaugebar.cpp"