Export to CSV. Added button "Restore Defaults".

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-06-01 17:21:03 +03:00
parent 32d391c587
commit e0bf6f11d1
5 changed files with 46 additions and 6 deletions

View File

@ -32,6 +32,7 @@
#include "../vmisc/vtapesettings.h"
#include "../mapplication.h"
#include <QPushButton>
#include <QShowEvent>
#include <QTextCodec>
@ -53,6 +54,10 @@ DialogExportToCSV::DialogExportToCSV(QWidget *parent)
ui->comboBoxCodec->setCurrentIndex(ui->comboBoxCodec->findData(qApp->TapeSettings()->GetCSVCodec()));
SetSeparator(qApp->TapeSettings()->GetCSVSeparator());
QPushButton *bDefaults = ui->buttonBox->button(QDialogButtonBox::RestoreDefaults);
SCASSERT(bDefaults != nullptr);
connect(bDefaults, &QPushButton::clicked, this, &DialogExportToCSV::RestoreDefaults);
}
//---------------------------------------------------------------------------------------------------------------------
@ -132,6 +137,15 @@ void DialogExportToCSV::showEvent(QShowEvent *event)
isInitialized = true;//first show windows are held
}
//---------------------------------------------------------------------------------------------------------------------
void DialogExportToCSV::RestoreDefaults()
{
ui->checkBoxWithHeader->setChecked(qApp->TapeSettings()->GetDefCSVWithHeader());
ui->comboBoxCodec->setCurrentIndex(ui->comboBoxCodec->findData(qApp->TapeSettings()->GetDefCSVCodec()));
SetSeparator(qApp->TapeSettings()->GetDefCSVSeparator());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogExportToCSV::SetSeparator(const QChar &separator)
{

View File

@ -51,6 +51,9 @@ protected:
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
private slots:
void RestoreDefaults();
private:
Q_DISABLE_COPY(DialogExportToCSV)
Ui::DialogExportToCSV *ui;

View File

@ -9,7 +9,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>298</width>
<width>333</width>
<height>292</height>
</rect>
</property>
@ -17,7 +17,7 @@
<string>Export options</string>
</property>
<property name="windowIcon">
<iconset>
<iconset resource="../share/resources/tapeicon.qrc">
<normaloff>:/tapeicon/64x64/logo.png</normaloff>:/tapeicon/64x64/logo.png</iconset>
</property>
<property name="modal">
@ -118,13 +118,15 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../share/resources/tapeicon.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>

View File

@ -93,7 +93,13 @@ void VTapeSettings::SetCSVWithHeader(bool withHeader)
//---------------------------------------------------------------------------------------------------------------------
bool VTapeSettings::GetCSVWithHeader() const
{
return value(SettingCSVWithHeader, false).toBool();
return value(SettingCSVWithHeader, GetDefCSVWithHeader()).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
bool VTapeSettings::GetDefCSVWithHeader() const
{
return false;
}
//---------------------------------------------------------------------------------------------------------------------
@ -105,7 +111,13 @@ void VTapeSettings::SetCSVCodec(int mib)
//---------------------------------------------------------------------------------------------------------------------
int VTapeSettings::GetCSVCodec() const
{
return value(SettingCSVCodec, QTextCodec::codecForLocale()->mibEnum()).toInt();
return value(SettingCSVCodec, GetDefCSVCodec()).toInt();
}
//---------------------------------------------------------------------------------------------------------------------
int VTapeSettings::GetDefCSVCodec() const
{
return QTextCodec::codecForLocale()->mibEnum();
}
//---------------------------------------------------------------------------------------------------------------------
@ -150,3 +162,9 @@ QChar VTapeSettings::GetCSVSeparator() const
break;
}
}
//---------------------------------------------------------------------------------------------------------------------
QChar VTapeSettings::GetDefCSVSeparator() const
{
return QChar(',');
}

View File

@ -49,12 +49,15 @@ public:
void SetCSVWithHeader(bool withHeader);
bool GetCSVWithHeader() const;
bool GetDefCSVWithHeader() const;
void SetCSVCodec(int mib);
int GetCSVCodec() const;
int GetDefCSVCodec() const;
void SetCSVSeparator(const QChar &separator);
QChar GetCSVSeparator() const;
QChar GetDefCSVSeparator() const;
private:
Q_DISABLE_COPY(VTapeSettings)