Skip to content

Commit

Permalink
Merge branch 'release/1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
npruehs committed Jan 14, 2018
2 parents 9eeb074 + df3e29c commit 7be9565
Show file tree
Hide file tree
Showing 36 changed files with 426 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<Mapping TomeType="Reference" ExportedType="string"/>
<Mapping TomeType="String" ExportedType="string"/>
</TypeMap>
<StringReplacementMap/>
<IgnoredRecords/>
<IgnoredFields/>
</Template>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<Mapping TomeType="Reference" ExportedType="String"/>
<Mapping TomeType="String" ExportedType="String"/>
</TypeMap>
<StringReplacementMap/>
<IgnoredRecords/>
<IgnoredFields/>
</Template>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<Mapping TomeType="Reference" ExportedType="string"/>
<Mapping TomeType="String" ExportedType="string"/>
</TypeMap>
<StringReplacementMap/>
<IgnoredRecords/>
<IgnoredFields/>
</Template>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<Mapping TomeType="Reference" ExportedType="string"/>
<Mapping TomeType="String" ExportedType="string"/>
</TypeMap>
<StringReplacementMap/>
<IgnoredRecords/>
<IgnoredFields/>
</Template>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<Name>Data (CSV)</Name>
<FileExtension>.csv</FileExtension>
<TypeMap/>
<StringReplacementMap/>
<IgnoredRecords/>
<IgnoredFields/>
</Template>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<Name>Data (HTML)</Name>
<FileExtension>.html</FileExtension>
<TypeMap/>
<StringReplacementMap/>
<IgnoredRecords/>
<IgnoredFields/>
</Template>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<Name>Data (INI)</Name>
<FileExtension>.ini</FileExtension>
<TypeMap/>
<StringReplacementMap/>
<IgnoredRecords/>
<IgnoredFields/>
</Template>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<Name>Data (JSON)</Name>
<FileExtension>.json</FileExtension>
<TypeMap/>
<StringReplacementMap/>
<IgnoredRecords/>
<IgnoredFields/>
</Template>
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<Mapping TomeType="ShortString" ExportedType="System.String"/>
<Mapping TomeType="String" ExportedType="System.String"/>
</TypeMap>
<StringReplacementMap/>
<IgnoredRecords/>
<IgnoredFields/>
</Template>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<Name>Data (StarCraft II XML)</Name>
<FileExtension>.xml</FileExtension>
<TypeMap/>
<StringReplacementMap/>
<IgnoredRecords/>
<IgnoredFields/>
</Template>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<Name>Data (YAML)</Name>
<FileExtension>.yaml</FileExtension>
<TypeMap/>
<StringReplacementMap/>
<IgnoredRecords/>
<IgnoredFields/>
</Template>
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
<Name>Units (CSV)</Name>
<SourceType>CSV</SourceType>
<IdColumn>ID</IdColumn>
<DisplayNameColumn></DisplayNameColumn>
<EditorIconFieldIdColumn></EditorIconFieldIdColumn>
<RootRecordId>Unit</RootRecordId>
<ColumnMap>
<Mapping ColumnName="Attack Damage" FieldId="AttackDamage"/>
</ColumnMap>
<StringReplacementMap/>
<IgnoredIds>
<Id>COMMENT</Id>
</IgnoredIds>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
<Name>Units (Google Sheets)</Name>
<SourceType>GoogleSheets</SourceType>
<IdColumn>ID</IdColumn>
<DisplayNameColumn></DisplayNameColumn>
<EditorIconFieldIdColumn></EditorIconFieldIdColumn>
<RootRecordId>Unit</RootRecordId>
<ColumnMap>
<Mapping ColumnName="Attack Damage" FieldId="AttackDamage"/>
<Mapping ColumnName="Attack Range" FieldId="AttackRange"/>
<Mapping ColumnName="Damage Type" FieldId="DamageType"/>
</ColumnMap>
<StringReplacementMap/>
<IgnoredIds>
<Id>COMMENT</Id>
</IgnoredIds>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
<Name>Units (XLSX)</Name>
<SourceType>XLSX</SourceType>
<IdColumn>ID</IdColumn>
<DisplayNameColumn></DisplayNameColumn>
<EditorIconFieldIdColumn></EditorIconFieldIdColumn>
<RootRecordId>Unit</RootRecordId>
<ColumnMap>
<Mapping ColumnName="Attack Damage" FieldId="AttackDamage"/>
</ColumnMap>
<StringReplacementMap/>
<IgnoredIds>
<Id>COMMENT</Id>
</IgnoredIds>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<Name>Localization (CSV)</Name>
<FileExtension>.csv</FileExtension>
<TypeMap/>
<StringReplacementMap/>
<IgnoredRecords/>
<IgnoredFields/>
</Template>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<Name>Localization (XLIFF 1.2)</Name>
<FileExtension>.xlf</FileExtension>
<TypeMap/>
<StringReplacementMap/>
<IgnoredRecords/>
<IgnoredFields/>
</Template>
4 changes: 2 additions & 2 deletions Project/Tome.pro
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ TEMPLATE = app

# Expose application version in Windows property window and in application code.
# http://www.openguru.com/2009/11/qt-best-way-to-set-application-version.html
VERSION = 1.0
VERSION_NAME = Phoenix
VERSION = 1.1
VERSION_NAME = Griffin
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
DEFINES += APP_VERSION_NAME=\\\"$$VERSION_NAME\\\"

Expand Down
116 changes: 79 additions & 37 deletions Source/Tome/Core/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,55 +898,101 @@ void MainWindow::on_actionDuplicate_Record_triggered()
this->duplicateRecordWindow = new DuplicateRecordWindow(this);
}

const QVariant& recordId = this->recordTreeWidget->getSelectedRecordId();
const QVariantList recordIds = this->controller->getRecordsController().getRecordIds();

if (recordId.isNull())
{
return;
}
// Get selected record id.
const QVariantList& selectedRecordIds = this->recordTreeWidget->getSelectedRecordIds();
const QVariantList existingRecordIds = this->controller->getRecordsController().getRecordIds();

// Check record id type.
RecordIdType::RecordIdType recordIdType = this->controller->getProjectController().getProjectRecordIdType();

// Get new record id.
DuplicateRecordCommand* command;

if (recordIdType == RecordIdType::String)
if (selectedRecordIds.count() <= 0)
{
// Disallow all existing record ids.
this->duplicateRecordWindow->setRecordId(recordId.toString());
return;
}
else if (selectedRecordIds.count() == 1)
{
const QVariant& recordId = selectedRecordIds.first();

if (recordIdType == RecordIdType::String)
{
// Disallow all existing record ids.
this->duplicateRecordWindow->setRecordId(recordId.toString());

QStringList recordStringIds;
for (QVariant v : existingRecordIds)
{
recordStringIds << v.toString();
}

this->duplicateRecordWindow->setDisallowedRecordIds(recordStringIds);

// Show window.
int result = this->duplicateRecordWindow->exec();

QStringList recordStringIds;
for (QVariant v : recordIds)
if (result != QDialog::Accepted)
{
return;
}

const QString& newRecordId = this->duplicateRecordWindow->getRecordId();


command = new DuplicateRecordCommand(this->controller->getRecordsController(),
recordId,
newRecordId);
}
else
{
recordStringIds << v.toString();
command = new DuplicateRecordCommand(this->controller->getRecordsController(),
recordId,
QVariant());
}

this->duplicateRecordWindow->setDisallowedRecordIds(recordStringIds);
// Update model.
this->controller->getUndoController().doCommand(command);
}
else
{
const QString& question = tr("Are you sure you want to duplicate %1 records? Tome will automatically assign IDs for them.")
.arg(selectedRecordIds.count());

// Show window.
int result = this->duplicateRecordWindow->exec();
int answer = QMessageBox::question(
this,
tr("Duplicate Records"),
question,
QMessageBox::Yes,
QMessageBox::No);

if (result != QDialog::Accepted)
if (answer != QMessageBox::Yes)
{
return;
}

const QString& newRecordId = this->duplicateRecordWindow->getRecordId();
for (auto recordId : selectedRecordIds)
{
if (recordIdType == RecordIdType::String)
{
const QString& newRecordId = QString("%1New").arg(recordId.toString());


command = new DuplicateRecordCommand(this->controller->getRecordsController(),
recordId,
newRecordId);
}
else
{
command = new DuplicateRecordCommand(this->controller->getRecordsController(),
recordId,
QVariant());
}
command = new DuplicateRecordCommand(this->controller->getRecordsController(),
recordId,
newRecordId);
}
else
{
command = new DuplicateRecordCommand(this->controller->getRecordsController(),
recordId,
QVariant());
}

// Update model.
this->controller->getUndoController().doCommand(command);
// Update model.
this->controller->getUndoController().doCommand(command);
}
}
}

void MainWindow::on_actionRevert_Record_triggered()
Expand Down Expand Up @@ -1327,16 +1373,14 @@ void MainWindow::revertFieldValue()
QVariant recordId = this->recordTreeWidget->getSelectedRecordId();

// Get field to revert.
QModelIndexList selectedIndexes = this->recordFieldTableWidget->selectionModel()->selectedRows(0);
auto selectedItems = this->recordFieldTableWidget->selectedItems();

if (selectedIndexes.empty())
if (selectedItems.empty())
{
return;
}

const RecordFieldValueMap fieldValues =
this->controller->getRecordsController().getRecordFieldValues(recordId);
const QString fieldId = fieldValues.keys()[selectedIndexes.first().row()];
const QString fieldId = selectedItems.first()->data(Qt::UserRole).toString();

// Get inherited field value.
QVariant valueToRevertTo = this->controller->getRecordsController().getInheritedFieldValue(recordId, fieldId);
Expand Down Expand Up @@ -1694,8 +1738,6 @@ void MainWindow::onRecordUpdated(const QVariant& oldId,
const QString& newDisplayName,
const QString& newEditorIconFieldId)
{
Q_UNUSED(oldDisplayName)

// Update view.
this->recordTreeWidget->updateRecord(oldId, oldDisplayName, oldEditorIconFieldId, newId, newDisplayName, newEditorIconFieldId);
this->refreshRecordTable();
Expand Down
8 changes: 8 additions & 0 deletions Source/Tome/Features/Export/Controller/exportcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,14 @@ void ExportController::exportRecords(const RecordExportTemplate& exportTemplate,
}
}

// Apply string replacement.
for (auto itStringReplacementMap = exportTemplate.stringReplacementMap.cbegin();
itStringReplacementMap != exportTemplate.stringReplacementMap.cend();
++itStringReplacementMap)
{
fieldValueText = fieldValueText.replace(itStringReplacementMap.key(), itStringReplacementMap.value());
}

// Store for later use.
fieldValueTexts[fieldId] = fieldValueText;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ const QString ExportTemplateSerializer::ElementIgnoredFields = "IgnoredFields";
const QString ExportTemplateSerializer::ElementIgnoredRecords = "IgnoredRecords";
const QString ExportTemplateSerializer::ElementMapping = "Mapping";
const QString ExportTemplateSerializer::ElementName = "Name";
const QString ExportTemplateSerializer::ElementReplaceWith = "ReplaceWith";
const QString ExportTemplateSerializer::ElementString = "String";
const QString ExportTemplateSerializer::ElementStringReplacementMap = "StringReplacementMap";
const QString ExportTemplateSerializer::ElementTemplate = "Template";
const QString ExportTemplateSerializer::ElementTypeMap = "TypeMap";

Expand Down Expand Up @@ -91,6 +94,21 @@ void ExportTemplateSerializer::serialize(QIODevice& device, const RecordExportTe
}
writer.writeEndElement();

// Write string replacement map.
writer.writeStartElement(ElementStringReplacementMap);
{
for (auto itStringReplacementMap = exportTemplate.stringReplacementMap.cbegin();
itStringReplacementMap != exportTemplate.stringReplacementMap.cend();
++itStringReplacementMap)
{
writer.writeStartElement(ElementMapping);
writer.writeTextElement(ElementString, itStringReplacementMap.key());
writer.writeTextElement(ElementReplaceWith, itStringReplacementMap.value());
writer.writeEndElement();
}
}
writer.writeEndElement();

// Write ignore lists.
writer.writeStartElement(ElementIgnoredRecords);
{
Expand Down Expand Up @@ -163,6 +181,26 @@ void ExportTemplateSerializer::deserialize(QIODevice& device, RecordExportTempla
}
reader.readEndElement();

// Read string replacement map.
if (reader.isAtElement(ElementStringReplacementMap))
{
reader.readStartElement(ElementStringReplacementMap);
{
while (reader.isAtElement(ElementMapping))
{
reader.readStartElement(ElementMapping);
{
QString stringReplacementKey = reader.readTextElement(ElementString);
QString stringReplacementValue = reader.readTextElement(ElementReplaceWith);

exportTemplate.stringReplacementMap.insert(stringReplacementKey, stringReplacementValue);
}
reader.readEndElement();
}
}
reader.readEndElement();
}

// Read ignore lists.
reader.readStartElement(ElementIgnoredRecords);
{
Expand Down
Loading

0 comments on commit 7be9565

Please sign in to comment.