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 "../vmisc/vtapesettings.h"
#include "../mapplication.h" #include "../mapplication.h"
#include <QPushButton>
#include <QShowEvent> #include <QShowEvent>
#include <QTextCodec> #include <QTextCodec>
@ -53,6 +54,10 @@ DialogExportToCSV::DialogExportToCSV(QWidget *parent)
ui->comboBoxCodec->setCurrentIndex(ui->comboBoxCodec->findData(qApp->TapeSettings()->GetCSVCodec())); ui->comboBoxCodec->setCurrentIndex(ui->comboBoxCodec->findData(qApp->TapeSettings()->GetCSVCodec()));
SetSeparator(qApp->TapeSettings()->GetCSVSeparator()); 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 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) void DialogExportToCSV::SetSeparator(const QChar &separator)
{ {

View file

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

View file

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

View file

@ -93,7 +93,13 @@ void VTapeSettings::SetCSVWithHeader(bool withHeader)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VTapeSettings::GetCSVWithHeader() const 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 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; break;
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QChar VTapeSettings::GetDefCSVSeparator() const
{
return QChar(',');
}

View file

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