Rivendellaudio/lib/rddatedialog.cpp
Fred Gleason 8ca15c773d 2019-10-01 Fred Gleason <fredg@paravelsystems.com>
* Refactored dialogs in the convenience library to use the
	'RDDialog' and 'RDWidget' base classes.
2019-10-01 15:10:29 -04:00

104 lines
2.5 KiB
C++

// rddatedialog.cpp
//
// A Dialog Box for using an RDDatePicker widget.
//
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License
// version 2 as published by the Free Software Foundation.
//
// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <qapplication.h>
#include <qwidget.h>
#include <qpushbutton.h>
#include <qrect.h>
#include <qpoint.h>
#include <qpainter.h>
#include <qstring.h>
#include <qmessagebox.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qsignalmapper.h>
#include <rdconf.h>
#include <rddatedialog.h>
//
// Global Classes
//
RDDateDialog::RDDateDialog(int low_year,int high_year,QWidget *parent)
: RDDialog(parent)
{
setWindowTitle(tr("Select Date"));
//
// Datepicker
//
date_picker=new RDDatePicker(low_year,high_year,this);
date_picker->setGeometry(10,10,
date_picker->sizeHint().width(),
date_picker->sizeHint().height());
//
// OK Button
//
QPushButton *button=new QPushButton(this,"ok_button");
button->setGeometry(sizeHint().width()-130,sizeHint().height()-40,50,30);
button->setFont(buttonFont());
button->setText(tr("&OK"));
connect(button,SIGNAL(clicked()),this,SLOT(okData()));
//
// Cancel Button
//
button=new QPushButton(this,"cancel_button");
button->setGeometry(sizeHint().width()-65,sizeHint().height()-40,55,30);
button->setFont(buttonFont());
button->setText(tr("&Cancel"));
connect(button,SIGNAL(clicked()),this,SLOT(cancelData()));
}
QSize RDDateDialog::sizeHint() const
{
return QSize(date_picker->sizeHint().width()+20,
date_picker->sizeHint().height()+60);
}
QSizePolicy RDDateDialog::sizePolicy() const
{
return QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
}
int RDDateDialog::exec(QDate *date)
{
date_date=date;
date_picker->setDate(*date_date);
return QDialog::exec();
}
void RDDateDialog::okData()
{
*date_date=date_picker->date();
done(0);
}
void RDDateDialog::cancelData()
{
done(-1);
}