1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/as_numdial.cpp Fri Nov 28 11:21:08 2008 +0100 1.3 @@ -0,0 +1,134 @@ 1.4 +// 1.5 +// OSSP asgui - Accounting system graphical user interface 1.6 +// Copyright (c) 2002-2004 The OSSP Project (http://www.ossp.org/) 1.7 +// Copyright (c) 2002-2004 Ralf S. Engelschall <rse@engelschall.com> 1.8 +// Copyright (c) 2002-2004 Michael Schloh von Bennewitz <michael@schloh.com> 1.9 +// Copyright (c) 2002-2004 Cable & Wireless Telecommunications Services GmbH 1.10 +// 1.11 +// This file is part of OSSP asgui, an accounting system graphical user 1.12 +// interface which can be found at http://www.ossp.org/pkg/tool/asgui/. 1.13 +// 1.14 +// Permission to use, copy, modify, and distribute this software for 1.15 +// any purpose with or without fee is hereby granted, provided that 1.16 +// the above copyright notice and this permission notice appear in all 1.17 +// copies. 1.18 +// 1.19 +// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 1.20 +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 1.21 +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1.22 +// IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR 1.23 +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.24 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.25 +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 1.26 +// USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 1.27 +// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 1.28 +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 1.29 +// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1.30 +// SUCH DAMAGE. 1.31 +// 1.32 +// as_numdial.cpp: ISO C++ implementation 1.33 +// 1.34 + 1.35 +#include "as_numdial.h" 1.36 + 1.37 +#include <qvariant.h> 1.38 +#include <qframe.h> 1.39 +#include <qlabel.h> 1.40 +#include <qpushbutton.h> 1.41 +#include <qspinbox.h> 1.42 +#include <qlayout.h> 1.43 +#include <qtooltip.h> 1.44 +#include <qwhatsthis.h> 1.45 + 1.46 +#include "as_const.h" 1.47 + 1.48 + 1.49 +namespace AS { 1.50 + 1.51 +// 1.52 +// Constructs a Numdial as a child of 'pParent', with the 1.53 +// name 'kszName' and widget flags set to 'Flags'. 1.54 +// 1.55 +// The dialog will by default be modal, unless you set 'bModal' to 1.56 +// false to construct a modeless dialog. 1.57 +// 1.58 +Numdial::Numdial(QWidget *pParent, const char *kszName, bool bModal, WFlags Flags) 1.59 + : QDialog(pParent, kszName, bModal, Flags) 1.60 +{ 1.61 + // Boilerplate code to initialize the panel 1.62 + if (!kszName) 1.63 + this->setName("Numberdialog"); 1.64 + 1.65 + // Fix dialog size 1.66 + this->setSizeGripEnabled(false); 1.67 + this->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)0, 1.68 + (QSizePolicy::SizeType)0, 0, 0, this->sizePolicy().hasHeightForWidth())); 1.69 + 1.70 + m_pFrame = new QFrame(this, "Mainframe"); 1.71 + m_pFrame->setFrameShape(QFrame::StyledPanel); 1.72 + m_pFrame->setFrameShadow(QFrame::Raised); 1.73 + m_pFramelay = new QVBoxLayout(m_pFrame, 11, 6, "Framelay"); 1.74 + m_pInputlay = new QHBoxLayout(0, 0, 6, "Horizontallayout"); 1.75 + m_pFormlayout = new QVBoxLayout(this, 11, 6, "Formlayout"); 1.76 + 1.77 + m_pReportlabel = new QLabel(m_pFrame, "Reportlabel"); 1.78 + m_pReportlabel->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)4, (QSizePolicy::SizeType)5, 0, 0, m_pReportlabel->sizePolicy().hasHeightForWidth())); 1.79 + m_pInputlay->addWidget(m_pReportlabel); 1.80 + 1.81 + m_pSpinbox = new QSpinBox(m_pFrame, "Spinbox"); 1.82 + m_pSpinbox->setMinValue(1); // Must choose at least one week 1.83 + m_pSpinbox->setMaxValue(TITRAQ_BIGMAGIC); // Must choose less than magic 1.84 +// m_pSpinbox->setButtonSymbols(QSpinBox::PlusMinus); 1.85 +// m_pSpinbox->editor()->setAlignment(Qt::AlignRight); 1.86 + m_pInputlay->addWidget(m_pSpinbox); 1.87 + 1.88 + m_pWeeklabel = new QLabel(m_pFrame, "Weeklabel"); 1.89 + m_pWeeklabel->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)4, (QSizePolicy::SizeType)5, 0, 0, m_pWeeklabel->sizePolicy().hasHeightForWidth())); 1.90 + m_pInputlay->addWidget(m_pWeeklabel); 1.91 + m_pFramelay->addLayout(m_pInputlay); 1.92 + 1.93 + // Push button suite 1.94 + m_pButtlay = new QHBoxLayout(0, 0, 6, "Buttlay"); 1.95 + m_pOkaybutt = new QPushButton(m_pFrame, "Okaybutton"); 1.96 + m_pOkaybutt->setPaletteBackgroundColor(QColor(198, 196, 186)); 1.97 + m_pOkaybutt->setCursor(QCursor(13)); 1.98 + m_pOkaybutt->setDefault(true); 1.99 + m_pButtlay->addWidget(m_pOkaybutt); 1.100 + m_pCancelbutt = new QPushButton(m_pFrame, "Cancelbutton"); 1.101 + m_pCancelbutt->setPaletteBackgroundColor(QColor(198, 196, 186)); 1.102 + m_pCancelbutt->setCursor(QCursor(13)); 1.103 + m_pButtlay->addWidget(m_pCancelbutt); 1.104 + m_pFramelay->addLayout(m_pButtlay); 1.105 + 1.106 + // Add all the junk to our main frame 1.107 + m_pFormlayout->addWidget(m_pFrame); 1.108 + 1.109 + // Connect signals to slots, accept() and reject() are Qt implicit 1.110 + connect(m_pOkaybutt, SIGNAL(clicked(void)), SLOT(accept(void))); 1.111 + connect(m_pCancelbutt, SIGNAL(clicked(void)), SLOT(reject(void))); 1.112 + this->resize(QSize(272, 111).expandedTo(minimumSizeHint())); 1.113 + this->textChange(); 1.114 +} 1.115 + 1.116 +// 1.117 +// Sets the strings of the subwidgets using the current language 1.118 +// 1.119 +void Numdial::textChange() 1.120 +{ 1.121 + this->setCaption(trUtf8("Numberdialog", "For general input of numbers followed by an accept or cancel operation")); 1.122 + m_pReportlabel->setText(trUtf8("Report")); 1.123 + m_pWeeklabel->setText(trUtf8("weeks of data")); 1.124 + 1.125 + // Top level push buttons associated with accept slot 1.126 + m_pCancelbutt->setText(trUtf8("Cancel", "Comment for Cancelbutton")); 1.127 + QToolTip::add(m_pCancelbutt, trUtf8("Closes the report panel", "Comment for tooltip Cancelbutton")); 1.128 + QWhatsThis::add(m_pCancelbutt, trUtf8("The cancel button closes the report panel without further action", "Comment for whatsThis Cancelbutton")); 1.129 + m_pOkaybutt->setText(trUtf8("Okay", "Comment for Okaybutton")); 1.130 + QToolTip::add(m_pOkaybutt, trUtf8("Aknowleges your input", "Comment for tooltip Okaybutton")); 1.131 + QWhatsThis::add(m_pOkaybutt, trUtf8("The okay button aknowleges your input and prepares for action", "Comment for whatsThis Okaybutton")); 1.132 + 1.133 + // Text help for spinbox number input 1.134 + QToolTip::add(m_pSpinbox, trUtf8("Input a number", "Comment for tooltip Spinbox")); 1.135 + QWhatsThis::add(m_pSpinbox, trUtf8("Click on the arrows or type to input a number", "Comment for whatsThis Spinbox")); 1.136 +} 1.137 +} // namespace AS