parent
7c6b0d9f58
commit
7fedd20319
|
@ -981,6 +981,7 @@ void TMainWindow::ImportDataFromCSV()
|
||||||
dialog.SetWithHeader(qApp->Settings()->GetCSVWithHeader());
|
dialog.SetWithHeader(qApp->Settings()->GetCSVWithHeader());
|
||||||
dialog.SetSelectedMib(qApp->Settings()->GetCSVCodec());
|
dialog.SetSelectedMib(qApp->Settings()->GetCSVCodec());
|
||||||
dialog.SetSeparator(qApp->Settings()->GetCSVSeparator());
|
dialog.SetSeparator(qApp->Settings()->GetCSVSeparator());
|
||||||
|
dialog.ShowFilePreview(fileName);
|
||||||
|
|
||||||
if (dialog.exec() == QDialog::Accepted)
|
if (dialog.exec() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
|
@ -3159,17 +3160,24 @@ void TMainWindow::ImportIndividualMeasurements(const QxtCsvModel &csv)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
const QString name = csv.text(i, 0).simplified();
|
||||||
|
if (name.isEmpty())
|
||||||
|
{
|
||||||
|
ShowError(tr("Error in row %1. Measurement name is empty.").arg(i));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
IndividualMeasurement measurement;
|
IndividualMeasurement measurement;
|
||||||
measurement.name = CheckMName(qApp->TrVars()->MFromUser(csv.text(i, 0).simplified()));
|
measurement.name = CheckMName(qApp->TrVars()->MFromUser(name));
|
||||||
measurement.value = VTranslateVars::TryFormulaFromUser(csv.text(i, 1), qApp->Settings()->GetOsSeparator());
|
measurement.value = VTranslateVars::TryFormulaFromUser(csv.text(i, 1), qApp->Settings()->GetOsSeparator());
|
||||||
|
|
||||||
const bool custom = csv.text(i, 0).simplified().startsWith(CustomMSign);
|
const bool custom = csv.text(i, 0).simplified().startsWith(CustomMSign);
|
||||||
if (columns >= 3 && not custom)
|
if (columns > 2 && custom)
|
||||||
{
|
{
|
||||||
measurement.fullName = csv.text(i, 2).simplified();
|
measurement.fullName = csv.text(i, 2).simplified();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (columns >= 4 && not custom)
|
if (columns > 3 && custom)
|
||||||
{
|
{
|
||||||
measurement.description = csv.text(i, 3).simplified();
|
measurement.description = csv.text(i, 3).simplified();
|
||||||
}
|
}
|
||||||
|
@ -3251,8 +3259,15 @@ void TMainWindow::ImportMultisizeMeasurements(const QxtCsvModel &csv)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
const QString name = csv.text(i, 0).simplified();
|
||||||
|
if (name.isEmpty())
|
||||||
|
{
|
||||||
|
ShowError(tr("Error in row %1. Measurement name is empty.").arg(i));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
MultisizeMeasurement measurement;
|
MultisizeMeasurement measurement;
|
||||||
measurement.name = CheckMName(qApp->TrVars()->MFromUser(csv.text(i, 0).simplified()));
|
measurement.name = CheckMName(qApp->TrVars()->MFromUser(name));
|
||||||
|
|
||||||
measurement.base = ConverToDouble(csv.text(i, 1),
|
measurement.base = ConverToDouble(csv.text(i, 1),
|
||||||
tr("Cannot convert base size value to double in column 2."));
|
tr("Cannot convert base size value to double in column 2."));
|
||||||
|
@ -3264,12 +3279,12 @@ void TMainWindow::ImportMultisizeMeasurements(const QxtCsvModel &csv)
|
||||||
tr("Cannot convert size increase value to double in column 4."));
|
tr("Cannot convert size increase value to double in column 4."));
|
||||||
|
|
||||||
const bool custom = csv.text(i, 0).simplified().startsWith(CustomMSign);
|
const bool custom = csv.text(i, 0).simplified().startsWith(CustomMSign);
|
||||||
if (columns >= 5 && not custom)
|
if (columns > 4 && custom)
|
||||||
{
|
{
|
||||||
measurement.fullName = csv.text(i, 4).simplified();
|
measurement.fullName = csv.text(i, 4).simplified();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (columns >= 6 && not custom)
|
if (columns > 5 && custom)
|
||||||
{
|
{
|
||||||
measurement.description = csv.text(i, 5).simplified();
|
measurement.description = csv.text(i, 5).simplified();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
#include "dialogexporttocsv.h"
|
#include "dialogexporttocsv.h"
|
||||||
#include "ui_dialogexporttocsv.h"
|
#include "ui_dialogexporttocsv.h"
|
||||||
|
|
||||||
#include "../vmisc/vcommonsettings.h"
|
#include "../vcommonsettings.h"
|
||||||
|
#include "../qxtcsvmodel.h"
|
||||||
#include "../vabstractapplication.h"
|
#include "../vabstractapplication.h"
|
||||||
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
@ -40,7 +41,8 @@
|
||||||
DialogExportToCSV::DialogExportToCSV(QWidget *parent)
|
DialogExportToCSV::DialogExportToCSV(QWidget *parent)
|
||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
ui(new Ui::DialogExportToCSV),
|
ui(new Ui::DialogExportToCSV),
|
||||||
isInitialized(false)
|
isInitialized(false),
|
||||||
|
m_fileName()
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -57,11 +59,27 @@ DialogExportToCSV::DialogExportToCSV(QWidget *parent)
|
||||||
SCASSERT(bDefaults != nullptr)
|
SCASSERT(bDefaults != nullptr)
|
||||||
connect(bDefaults, &QPushButton::clicked, this, [this]()
|
connect(bDefaults, &QPushButton::clicked, this, [this]()
|
||||||
{
|
{
|
||||||
|
ui->comboBoxCodec->blockSignals(true);
|
||||||
|
ui->checkBoxWithHeader->blockSignals(true);
|
||||||
|
ui->buttonGroup->blockSignals(true);
|
||||||
|
|
||||||
ui->checkBoxWithHeader->setChecked(qApp->Settings()->GetDefCSVWithHeader());
|
ui->checkBoxWithHeader->setChecked(qApp->Settings()->GetDefCSVWithHeader());
|
||||||
ui->comboBoxCodec->setCurrentIndex(ui->comboBoxCodec->findData(VCommonSettings::GetDefCSVCodec()));
|
ui->comboBoxCodec->setCurrentIndex(ui->comboBoxCodec->findData(VCommonSettings::GetDefCSVCodec()));
|
||||||
|
|
||||||
SetSeparator(VCommonSettings::GetDefCSVSeparator());
|
SetSeparator(VCommonSettings::GetDefCSVSeparator());
|
||||||
|
|
||||||
|
ui->comboBoxCodec->blockSignals(false);
|
||||||
|
ui->checkBoxWithHeader->blockSignals(false);
|
||||||
|
ui->buttonGroup->blockSignals(false);
|
||||||
|
|
||||||
|
ShowPreview();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ui->groupBoxPreview->setVisible(false);
|
||||||
|
|
||||||
|
connect(ui->comboBoxCodec, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](){ShowPreview();});
|
||||||
|
connect(ui->checkBoxWithHeader, &QCheckBox::stateChanged, this, [this](){ShowPreview();});
|
||||||
|
connect(ui->buttonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked), this, [this](){ShowPreview();});
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -158,12 +176,71 @@ void DialogExportToCSV::showEvent(QShowEvent *event)
|
||||||
}
|
}
|
||||||
// do your init stuff here
|
// do your init stuff here
|
||||||
|
|
||||||
|
resize(1, 1);
|
||||||
|
adjustSize();
|
||||||
|
if (not m_fileName.isEmpty())
|
||||||
|
{
|
||||||
|
ShowPreview();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
setMaximumSize(size());
|
setMaximumSize(size());
|
||||||
setMinimumSize(size());
|
setMinimumSize(size());
|
||||||
|
}
|
||||||
|
|
||||||
isInitialized = true;//first show windows are held
|
isInitialized = true;//first show windows are held
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogExportToCSV::ShowPreview()
|
||||||
|
{
|
||||||
|
if (m_fileName.isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->groupBoxPreview->setVisible(true);
|
||||||
|
|
||||||
|
QxtCsvModel csv(m_fileName, nullptr, IsWithHeader(), GetSeparator(), QTextCodec::codecForMib(GetSelectedMib()));
|
||||||
|
|
||||||
|
const int columns = csv.columnCount();
|
||||||
|
const int rows = csv.rowCount();
|
||||||
|
|
||||||
|
ui->tableWidget->clear();
|
||||||
|
ui->tableWidget->setColumnCount(columns);
|
||||||
|
ui->tableWidget->setRowCount(rows);
|
||||||
|
|
||||||
|
ui->tableWidget->horizontalHeader()->setVisible(IsWithHeader());
|
||||||
|
if (IsWithHeader())
|
||||||
|
{
|
||||||
|
for(int column=0; column<columns; ++column)
|
||||||
|
{
|
||||||
|
QTableWidgetItem *header = new QTableWidgetItem(csv.headerText(column));
|
||||||
|
ui->tableWidget->setHorizontalHeaderItem(column, header);
|
||||||
|
}
|
||||||
|
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int row=0; row < rows; ++row)
|
||||||
|
{
|
||||||
|
for(int column=0; column<columns; ++column)
|
||||||
|
{
|
||||||
|
QTableWidgetItem *item = new QTableWidgetItem(csv.text(row, column));
|
||||||
|
item->setToolTip(csv.text(row, column));
|
||||||
|
|
||||||
|
// set the item non-editable (view only), and non-selectable
|
||||||
|
Qt::ItemFlags flags = item->flags();
|
||||||
|
flags &= ~(Qt::ItemIsEditable); // reset/clear the flag
|
||||||
|
item->setFlags(flags);
|
||||||
|
|
||||||
|
ui->tableWidget->setItem(row, column, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->tableWidget->resizeColumnsToContents();
|
||||||
|
ui->tableWidget->resizeRowsToContents();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogExportToCSV::SetSeparator(const QChar &separator)
|
void DialogExportToCSV::SetSeparator(const QChar &separator)
|
||||||
{
|
{
|
||||||
|
@ -185,6 +262,12 @@ void DialogExportToCSV::SetSeparator(const QChar &separator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogExportToCSV::ShowFilePreview(const QString &fileName)
|
||||||
|
{
|
||||||
|
m_fileName = fileName;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogExportToCSV::MakeHelpCodecsList()
|
QString DialogExportToCSV::MakeHelpCodecsList()
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,6 +53,8 @@ public:
|
||||||
QChar GetSeparator() const;
|
QChar GetSeparator() const;
|
||||||
void SetSeparator(const QChar &separator);
|
void SetSeparator(const QChar &separator);
|
||||||
|
|
||||||
|
void ShowFilePreview(const QString &fileName);
|
||||||
|
|
||||||
static QString MakeHelpCodecsList();
|
static QString MakeHelpCodecsList();
|
||||||
static QString MakeHelpSeparatorList();
|
static QString MakeHelpSeparatorList();
|
||||||
|
|
||||||
|
@ -64,6 +66,9 @@ private:
|
||||||
Q_DISABLE_COPY(DialogExportToCSV)
|
Q_DISABLE_COPY(DialogExportToCSV)
|
||||||
Ui::DialogExportToCSV *ui;
|
Ui::DialogExportToCSV *ui;
|
||||||
bool isInitialized;
|
bool isInitialized;
|
||||||
|
QString m_fileName;
|
||||||
|
|
||||||
|
void ShowPreview();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIALOGEXPORTTOCSV_H
|
#endif // DIALOGEXPORTTOCSV_H
|
||||||
|
|
|
@ -9,25 +9,25 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>333</width>
|
<width>326</width>
|
||||||
<height>292</height>
|
<height>383</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Export options</string>
|
<string>Options</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowIcon">
|
<property name="windowIcon">
|
||||||
<iconset resource="../share/resources/tapeicon.qrc">
|
<iconset resource="../../../app/tape/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">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBoxExport">
|
<widget class="QGroupBox" name="groupBoxGlobal">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Export</string>
|
<string>Global</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
|
@ -53,7 +53,27 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="comboBoxCodec"/>
|
<widget class="QComboBox" name="comboBoxCodec">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
@ -62,12 +82,36 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBoxSeparator">
|
<widget class="QGroupBox" name="groupBoxSeparator">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Separator</string>
|
<string>Separator</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<property name="alignment">
|
||||||
<item>
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<property name="fieldGrowthPolicy">
|
||||||
|
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||||
|
</property>
|
||||||
|
<property name="labelAlignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="formAlignment">
|
||||||
|
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
<widget class="QRadioButton" name="radioButtonTab">
|
<widget class="QRadioButton" name="radioButtonTab">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Tab</string>
|
<string>Tab</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -76,8 +120,30 @@
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="2" column="0">
|
||||||
|
<widget class="QRadioButton" name="radioButtonSemicolon">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Semicolon</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">buttonGroup</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
<widget class="QRadioButton" name="radioButtonComma">
|
<widget class="QRadioButton" name="radioButtonComma">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Comma</string>
|
<string>Comma</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -89,23 +155,53 @@
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="2" column="1">
|
||||||
<widget class="QRadioButton" name="radioButtonSemicolon">
|
<widget class="QRadioButton" name="radioButtonSpace">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Semicolon</string>
|
<string>Space</string>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="buttonGroup">
|
<attribute name="buttonGroup">
|
||||||
<string notr="true">buttonGroup</string>
|
<string notr="true">buttonGroup</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QRadioButton" name="radioButtonSpace">
|
<widget class="QGroupBox" name="groupBoxPreview">
|
||||||
<property name="text">
|
<property name="title">
|
||||||
<string>Space</string>
|
<string>Preview</string>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="buttonGroup">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<string notr="true">buttonGroup</string>
|
<item>
|
||||||
|
<widget class="QTableWidget" name="tableWidget">
|
||||||
|
<property name="editTriggers">
|
||||||
|
<set>QAbstractItemView::NoEditTriggers</set>
|
||||||
|
</property>
|
||||||
|
<property name="tabKeyNavigation">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="showDropIndicator" stdset="0">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="dragDropOverwriteMode">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="alternatingRowColors">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="selectionMode">
|
||||||
|
<enum>QAbstractItemView::NoSelection</enum>
|
||||||
|
</property>
|
||||||
|
<attribute name="verticalHeaderVisible">
|
||||||
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -125,7 +221,7 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../share/resources/tapeicon.qrc"/>
|
<include location="../../../app/tape/share/resources/tapeicon.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user