#include "SaveHistogramWidget.qo.h"
#include <QFileSystemModel>
const QString SaveHistogramWidget::SAVE_ASCII ="ascii";
const QString SaveHistogramWidget::SAVE_PNG ="png";
SaveHistogramWidget::SaveHistogramWidget(QWidget *parent)
ui.suffixComboBox->addItem( SAVE_PNG );
ui.suffixComboBox->addItem( SAVE_ASCII );
QIntValidator* intValidator = new QIntValidator(1, std::numeric_limits<int>::max(), this );
ui.heightLineEdit->setValidator( intValidator );
ui.widthLineEdit->setValidator( intValidator );
QString defaultSize = QString::number(300);
ui.widthLineEdit->setText( defaultSize );
ui.heightLineEdit->setText( defaultSize );
fileModel = new QFileSystemModel( ui.directoryTreeWidget );
QString initialDir = QDir::currentPath();
ui.directoryTreeWidget->setModel( fileModel );
QString rootDir = QDir::rootPath();
fileModel->setRootPath(rootDir );
QModelIndex initialIndex = fileModel->index( initialDir );
ui.directoryTreeWidget->setCurrentIndex( initialIndex );
ui.directoryTreeWidget->setColumnHidden( 1, true );
ui.directoryTreeWidget->setColumnHidden( 2, true );
ui.directoryTreeWidget->setColumnHidden( 3, true );
ui.directoryLineEdit->setText( initialDir );
connect( ui.directoryTreeWidget, SIGNAL(clicked(const QModelIndex&)), this, SLOT(directoryChanged(const QModelIndex&)));
connect( ui.directoryLineEdit, SIGNAL(textEdited(const QString&)), this, SLOT(validateDirectory(const QString&)));
connect( ui.saveButton, SIGNAL(clicked()), this, SLOT(save()));
connect( ui.cancelButton, SIGNAL( clicked()), this, SLOT(saveCanceled()));
connect( ui.suffixComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(suffixChanged(const QString&)));
void SaveHistogramWidget::saveCanceled(){
void SaveHistogramWidget::save(){
QString saveFileName = ui.directoryLineEdit->text();
QString directorySeparator = QDir::separator();
if ( !saveFileName.endsWith( directorySeparator )){
saveFileName.append( directorySeparator );
QString fileName = ui.nameLineEdit->text();
if ( fileName.length() == 0 ){
QMessageBox::warning(this,"Missing File Name", "Please specify a name for the file.");
int dotIndex = fileName.indexOf( ".");