File indexing completed on 2024-12-22 04:17:28
0001 /*************************************************************************** 0002 * * 0003 * copyright : (C) 2007 The University of Toronto * 0004 * netterfield@astro.utoronto.ca * 0005 * * 0006 * This program is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published by * 0008 * the Free Software Foundation; either version 2 of the License, or * 0009 * (at your option) any later version. * 0010 * * 0011 ***************************************************************************/ 0012 0013 #include "datasourceconfiguredialog.h" 0014 0015 #include <QPushButton> 0016 #include <QVBoxLayout> 0017 #include <QDialogButtonBox> 0018 0019 namespace Kst { 0020 0021 DataSourceConfigureDialog::DataSourceConfigureDialog(DataDialog::EditMode mode, DataSourcePtr dataSource, QWidget *parent) 0022 : QDialog(parent), _dataSource(dataSource) { 0023 0024 setWindowTitle(QString("Configure %1").arg(_dataSource->fileType())); 0025 0026 QVBoxLayout *layout = new QVBoxLayout(this); 0027 0028 _dataSource->readLock(); 0029 _configWidget = _dataSource->configWidget(); 0030 connect(this, SIGNAL(ok()), _configWidget, SLOT(save())); 0031 connect(this, SIGNAL(cancel()), _configWidget, SLOT(cancel())); 0032 0033 if (mode == DataDialog::Edit) { 0034 // Why would we want a source to not be reuseable? 0035 // Note: this is the only place where reuse is ever disabled... 0036 //connect(this, SIGNAL(ok()), this, SLOT(disableReuse())); 0037 } 0038 0039 _dataSource->unlock(); 0040 0041 _configWidget->setDialogParent(this); 0042 layout->addWidget(_configWidget); 0043 0044 _buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); 0045 layout->addWidget(_buttonBox); 0046 0047 connect(_buttonBox, SIGNAL(clicked(QAbstractButton*)), 0048 this, SLOT(buttonClicked(QAbstractButton*))); 0049 0050 setLayout(layout); 0051 0052 setMaximumSize(QSize(1280, 1024)); 0053 resize(minimumSizeHint()); 0054 } 0055 0056 0057 DataSourceConfigureDialog::~DataSourceConfigureDialog() { 0058 } 0059 0060 0061 void DataSourceConfigureDialog::disableReuse() { 0062 _dataSource->disableReuse(); 0063 } 0064 0065 void DataSourceConfigureDialog::buttonClicked(QAbstractButton *button) { 0066 QDialogButtonBox::StandardButton std = _buttonBox->standardButton(button); 0067 switch(std) { 0068 case QDialogButtonBox::Ok: 0069 if (_configWidget->isOkAcceptabe()) { 0070 emit ok(); 0071 accept(); 0072 } 0073 break; 0074 case QDialogButtonBox::Cancel: 0075 emit cancel(); 0076 reject(); 0077 break; 0078 default: 0079 break; 0080 } 0081 } 0082 0083 } 0084 0085 // vim: ts=2 sw=2 et