Save basic information in file.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-07-18 14:08:44 +03:00
parent a9edee47e5
commit 5ba6d62d94
9 changed files with 149 additions and 24 deletions

View File

@ -17,7 +17,11 @@
</size> </size>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>About Tape</string>
</property>
<property name="windowIcon">
<iconset resource="../share/resources/tapeicon.qrc">
<normaloff>:/tapeicon/64x64/logo.png</normaloff>:/tapeicon/64x64/logo.png</iconset>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>

View File

@ -76,13 +76,13 @@ Unit DialogNewMeasurements::MUnit() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int DialogNewMeasurements::BaseSize() const int DialogNewMeasurements::BaseSize() const
{ {
return ui->comboBoxBaseSize->currentData().toInt(); return ui->comboBoxBaseSize->currentText().toInt();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int DialogNewMeasurements::BaseHeight() const int DialogNewMeasurements::BaseHeight() const
{ {
return ui->comboBoxBaseHeight->currentData().toInt(); return ui->comboBoxBaseHeight->currentText().toInt();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -163,6 +163,57 @@ void TMainWindow::AboutApplication()
aboutDialog->show(); aboutDialog->show();
} }
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SaveGivenName()
{
m->SetGivenName(ui->lineEditGivenName->text());
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SaveFamilyName()
{
m->SetFamilyName(ui->lineEditFamilyName->text());
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SaveEmail()
{
m->SetEmail(ui->lineEditEmail->text());
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SaveSex(int index)
{
m->SetSex(static_cast<SexType>(ui->comboBoxSex->itemData(index).toInt()));
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SaveBirthDate(const QDate &date)
{
m->SetBirthDate(date);
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SaveNotes()
{
m->SetNotes(ui->plainTextEditNotes->toPlainText());
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::ReadOnly(bool ro)
{
ui->actionReadOnly->setChecked(ro);
if (ro)
{
ui->actionReadOnly->setIcon(QIcon("://tapeicon/24x24/padlock_locked.png"));
}
else
{
ui->actionReadOnly->setIcon(QIcon("://tapeicon/24x24/padlock_opened.png"));
}
m->SetReadOnly(ro);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SetupMenu() void TMainWindow::SetupMenu()
{ {
@ -179,17 +230,11 @@ void TMainWindow::SetupMenu()
connect(ui->actionSaveAs, &QAction::triggered, this, &TMainWindow::FileSaveAs); connect(ui->actionSaveAs, &QAction::triggered, this, &TMainWindow::FileSaveAs);
ui->actionSaveAs->setShortcuts(QKeySequence::SaveAs); ui->actionSaveAs->setShortcuts(QKeySequence::SaveAs);
QAction *separatorAct = new QAction(this); connect(ui->actionReadOnly, &QAction::triggered, this, &TMainWindow::ReadOnly);
separatorAct->setSeparator(true);
ui->menuFile->insertAction(ui->actionQuit, separatorAct);
connect(ui->actionQuit, &QAction::triggered, this, &TMainWindow::close); connect(ui->actionQuit, &QAction::triggered, this, &TMainWindow::close);
ui->actionQuit->setShortcuts(QKeySequence::Quit); ui->actionQuit->setShortcuts(QKeySequence::Quit);
// Edit
//ui->actionUndo->setShortcuts(QKeySequence::Undo);
//ui->actionRedo->setShortcuts(QKeySequence::Redo);
// Window // Window
connect(ui->menuWindow, &QMenu::aboutToShow, this, &TMainWindow::AboutToShowWindowMenu); connect(ui->menuWindow, &QMenu::aboutToShow, this, &TMainWindow::AboutToShowWindowMenu);
AboutToShowWindowMenu(); AboutToShowWindowMenu();
@ -211,13 +256,19 @@ void TMainWindow::InitWindow()
if (mType == MeasurementsType::Standard) if (mType == MeasurementsType::Standard)
{ {
ui->labelMType->setText(tr("Standard measurements")); ui->labelMType->setText(tr("Standard measurements"));
ui->labelBaseSizeValue->setText(QString().setNum(m->BaseSize()) + VDomDocument::UnitsToStr(m->MUnit(), true)); ui->labelBaseSizeValue->setText(QString().setNum(m->BaseSize()) + " " +
ui->labelBaseHeightValue->setText(QString().setNum(m->BaseHeight()) + VDomDocument::UnitsToStr(m->MUnit(), true));
VDomDocument::UnitsToStr(m->MUnit(), true)); ui->labelBaseHeightValue->setText(QString().setNum(m->BaseHeight()) + " " +
VDomDocument::UnitsToStr(m->MUnit(), true));
// Tab Measurements // Tab Measurements
delete ui->labelValue; delete ui->labelValue;
delete ui->horizontalLayoutValue; delete ui->horizontalLayoutValue;
delete ui->plainTextEditFormula;
delete ui->pushButtonGrowLength;
delete ui->toolButtonExprLength;
delete ui->labelEqual;
delete ui->labelResultCalculation;
// Tab Information // Tab Information
delete ui->labelGivenName; delete ui->labelGivenName;
@ -254,6 +305,26 @@ void TMainWindow::InitWindow()
delete ui->labelBaseSizeValue; delete ui->labelBaseSizeValue;
delete ui->labelBaseHeight; delete ui->labelBaseHeight;
delete ui->labelBaseHeightValue; delete ui->labelBaseHeightValue;
ui->lineEditGivenName->setText(m->GivenName());
ui->lineEditFamilyName->setText(m->FamilyName());
ui->comboBoxSex->addItem(tr("male"), QVariant(static_cast<int>(SexType::Male)));
ui->comboBoxSex->addItem(tr("female"), QVariant(static_cast<int>(SexType::Female)));
const qint32 index = ui->comboBoxSex->findData(static_cast<int>(m->Sex()));
ui->comboBoxSex->setCurrentIndex(index);
ui->dateEditBirthDate->setDate(m->BirthDate());
ui->lineEditEmail->setText(m->Email());
ui->plainTextEditNotes->setPlainText(m->Notes());
connect(ui->lineEditGivenName, &QLineEdit::editingFinished, this, &TMainWindow::SaveGivenName);
connect(ui->lineEditFamilyName, &QLineEdit::editingFinished, this, &TMainWindow::SaveFamilyName);
connect(ui->lineEditEmail, &QLineEdit::editingFinished, this, &TMainWindow::SaveEmail);
connect(ui->comboBoxSex, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&TMainWindow::SaveSex);
connect(ui->dateEditBirthDate, &QDateEdit::dateChanged, this, &TMainWindow::SaveBirthDate);
connect(ui->plainTextEditNotes, &QPlainTextEdit::textChanged, this, &TMainWindow::SaveNotes);
} }
ui->actionAddCustom->setEnabled(true); ui->actionAddCustom->setEnabled(true);

View File

@ -58,6 +58,13 @@ private slots:
void AboutToShowWindowMenu(); void AboutToShowWindowMenu();
void ShowWindow(); void ShowWindow();
void AboutApplication(); void AboutApplication();
void SaveGivenName();
void SaveFamilyName();
void SaveEmail();
void SaveSex(int index);
void SaveBirthDate(const QDate & date);
void SaveNotes();
void ReadOnly(bool ro);
private: private:
Q_DISABLE_COPY(TMainWindow) Q_DISABLE_COPY(TMainWindow)

View File

@ -606,13 +606,7 @@
<addaction name="actionAboutQt"/> <addaction name="actionAboutQt"/>
<addaction name="actionAboutTape"/> <addaction name="actionAboutTape"/>
</widget> </widget>
<widget class="QMenu" name="menuEdit">
<property name="title">
<string>Edit</string>
</property>
</widget>
<addaction name="menuFile"/> <addaction name="menuFile"/>
<addaction name="menuEdit"/>
<addaction name="menuWindow"/> <addaction name="menuWindow"/>
<addaction name="menuHelp"/> <addaction name="menuHelp"/>
</widget> </widget>

View File

@ -39,7 +39,7 @@
<enum>QTabWidget::North</enum> <enum>QTabWidget::North</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="tabStandard"> <widget class="QWidget" name="tabStandard">
<property name="sizePolicy"> <property name="sizePolicy">
@ -108,7 +108,7 @@
</size> </size>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="pagePersonalInformation"> <widget class="QWidget" name="pagePersonalInformation">
<property name="enabled"> <property name="enabled">
@ -118,8 +118,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>559</width> <width>939</width>
<height>82</height> <height>411</height>
</rect> </rect>
</property> </property>
<attribute name="icon"> <attribute name="icon">

View File

@ -377,7 +377,15 @@ QString VDomDocument::UniqueTagText(const QString &tagName, const QString &defVa
const QDomElement domElement = domNode.toElement(); const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false) if (domElement.isNull() == false)
{ {
return domElement.text(); const QString text = domElement.text();
if (text.isEmpty())
{
return defVal;
}
else
{
return text;
}
} }
} }
} }

View File

@ -43,6 +43,7 @@ const QString VMeasurements::TagGivenName = QStringLiteral("given-name");
const QString VMeasurements::TagBirthDate = QStringLiteral("birth-date"); const QString VMeasurements::TagBirthDate = QStringLiteral("birth-date");
const QString VMeasurements::TagSex = QStringLiteral("sex"); const QString VMeasurements::TagSex = QStringLiteral("sex");
const QString VMeasurements::TagEmail = QStringLiteral("email"); const QString VMeasurements::TagEmail = QStringLiteral("email");
const QString VMeasurements::TagReadOnly = QStringLiteral("read-only");
const QString VMeasurements::AttrBase = QStringLiteral("base"); const QString VMeasurements::AttrBase = QStringLiteral("base");
@ -198,6 +199,32 @@ void VMeasurements::SetEmail(const QString &text)
setTagText(TagEmail, text); setTagText(TagEmail, text);
} }
//---------------------------------------------------------------------------------------------------------------------
bool VMeasurements::ReadOnly() const
{
if (UniqueTagText(TagReadOnly, "false") == "true")
{
return true;
}
else
{
return false;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::SetReadOnly(bool ro)
{
if (ro)
{
setTagText(TagReadOnly, "true");
}
else
{
setTagText(TagReadOnly, "false");
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VMeasurements::GenderToStr(const SexType &sex) QString VMeasurements::GenderToStr(const SexType &sex)
{ {
@ -244,6 +271,11 @@ void VMeasurements::CreateEmptyStandardFile(Unit unit, int baseSize, int baseHei
version.appendChild(newNodeText); version.appendChild(newNodeText);
mElement.appendChild(version); mElement.appendChild(version);
QDomElement ro = createElement(TagReadOnly);
const QDomText roNodeText = createTextNode(false);
ro.appendChild(roNodeText);
mElement.appendChild(ro);
mElement.appendChild(createElement(TagNotes)); mElement.appendChild(createElement(TagNotes));
QDomElement mUnit = createElement(TagUnit); QDomElement mUnit = createElement(TagUnit);
@ -278,6 +310,11 @@ void VMeasurements::CreateEmptyIndividualFile(Unit unit)
version.appendChild(newNodeText); version.appendChild(newNodeText);
mElement.appendChild(version); mElement.appendChild(version);
QDomElement ro = createElement(TagReadOnly);
const QDomText roNodeText = createTextNode(false);
ro.appendChild(roNodeText);
mElement.appendChild(ro);
mElement.appendChild(createElement(TagNotes)); mElement.appendChild(createElement(TagNotes));
QDomElement mUnit = createElement(TagUnit); QDomElement mUnit = createElement(TagUnit);

View File

@ -66,6 +66,9 @@ public:
QString Email() const; QString Email() const;
void SetEmail(const QString &text); void SetEmail(const QString &text);
bool ReadOnly() const;
void SetReadOnly(bool ro);
static const QString TagVST; static const QString TagVST;
static const QString TagVIT; static const QString TagVIT;
static const QString TagBodyMeasurements; static const QString TagBodyMeasurements;
@ -79,6 +82,7 @@ public:
static const QString TagBirthDate; static const QString TagBirthDate;
static const QString TagSex; static const QString TagSex;
static const QString TagEmail; static const QString TagEmail;
static const QString TagReadOnly;
static const QString AttrBase; static const QString AttrBase;