Skip to content

Commit

Permalink
Merge pull request #95 from jacquetc/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
jacquetc authored Nov 15, 2020
2 parents 2acda9d + 145b740 commit 0018d43
Show file tree
Hide file tree
Showing 12 changed files with 149 additions and 57 deletions.
2 changes: 1 addition & 1 deletion src/app/src/qml/Items/SkrTabButtonForm.ui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ TabButton {
id: closeButton

visible: isCurrent | hoverHandler.hovered ? closable : false
text: "x"
text: qsTr("Close")
icon.source: "qrc:///icons/backup/window-close.svg"
focusPolicy: Qt.NoFocus
display: AbstractButton.IconOnly
Expand Down
11 changes: 9 additions & 2 deletions src/app/src/qml/Projects/ProjectTabForm.ui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,21 @@ TabButton {

Layout.fillHeight: true
}
SkrRoundButton {
SkrToolButton {
id: closeButton
visible: isCurrent | hoverHandler.hovered ? closable : false
text: "x"
text: qsTr("Close project")
icon.source: "qrc:///icons/backup/window-close.svg"
display: AbstractButton.IconOnly
focusPolicy: Qt.NoFocus
flat: true
implicitHeight: 30
implicitWidth: 30
padding: 0
topInset: 1
bottomInset: 1
leftInset: 1
rightInset: 1
}

HoverHandler {
Expand Down
24 changes: 20 additions & 4 deletions src/libskribisto-data/src/skrresult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

SKRResult::SKRResult() : m_status(SKRResult::OK)
{
this->addErrorCode("OK");
this->addErrorCode("OK");

}

Expand All @@ -35,7 +35,7 @@ SKRResult::SKRResult(const QObject *object) : m_status(SKRResult::OK)

SKRResult::SKRResult(const QString &className) : m_status(SKRResult::OK)
{
this->addErrorCode("OK_" + className.toUpper());
this->addErrorCode("OK_" + className.toUpper());

}

Expand Down Expand Up @@ -198,6 +198,22 @@ void SKRResult::addData(const QString& key, const QVariant& value)

QVariant SKRResult::getData(const QString& key, const QVariant& defaultValue) const
{
QHash<QString, QVariant> lastHash = m_dataHashList.last();
return lastHash.value(key, defaultValue);
QVariant final = -2;

QList<QHash<QString, QVariant> >::const_reverse_iterator i;
for (i = m_dataHashList.crbegin(); i != m_dataHashList.crend(); ++i){

QHash<QString, QVariant> hash = *i;
final = hash.value(key, -2);
if(final != -2){
break;
}
}

if(final == -2){
final = defaultValue;
}

return final;

}
80 changes: 32 additions & 48 deletions src/libskribisto-data/src/tasks/sql/plmimporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,57 +421,16 @@ SKRResult PLMImporter::importPlumeCreatorProject(const QUrl& plumeFileName, cons
IFOKDO(result, plmdata->projectHub()->setProjectName(projectId, projectName));


while (xml.readNextStartElement() && xml.name() == "book") {
IFOKDO(result, this->createPapersAndAssociations(projectId, 0, xml, tempDirPath));

while (xml.readNextStartElement()) {
if (xml.name() == "act") {
// qDebug() << "a name" << xml.name();
IFOKDO(result, this->createPapersAndAssociations(projectId, 1, xml, tempDirPath));

while (xml.readNextStartElement() && xml.name() == "chapter") {
// qDebug() << "c name" << xml.name();
IFOKDO(result, this->createPapersAndAssociations(projectId, 2, xml, tempDirPath));


while (xml.readNextStartElement() && xml.name() == "scene") {
// qDebug() << "s name" << xml.name();
IFOKDO(result, this->createPapersAndAssociations(projectId, 3, xml, tempDirPath));
xml.readElementText();

// for(const QXmlStreamAttribute
// &attribute : xml.attributes()){
// qDebug() << "attr" <<
// attribute.name() << ":" << attribute.value();
// }

// qDebug() << "decl" <<
// xml.namespaceDeclarations().first().namespaceUri();
}
}
}
else if (xml.name() == "chapter") {
// qDebug() << "c name" << xml.name();
IFOKDO(result, this->createPapersAndAssociations(projectId, 1, xml, tempDirPath));


while (xml.readNextStartElement() && xml.name() == "scene") {
// qDebug() << "s name" << xml.name();
IFOKDO(result, this->createPapersAndAssociations(projectId, 2, xml, tempDirPath));
xml.readElementText();

// qDebug() << "read" << xml.readElementText();

// for(const QXmlStreamAttribute &attribute :
// xml.attributes()){
// qDebug() << "attr" << attribute.name()
// << ":" << attribute.value();
// }
while (xml.readNextStartElement()){
if(xml.name() == "trash") {
xml.skipCurrentElement();
continue;
}
if(xml.name() == "book") {
IFOKDO(result, this->readXMLRecursivelyAndCreatePaper(projectId, 0, &xml, tempDirPath));

// qDebug() << "decl" <<
// xml.namespaceDeclarations().first().namespaceUri();
}
}
}
}
}
Expand Down Expand Up @@ -537,6 +496,31 @@ SKRResult PLMImporter::importPlumeCreatorProject(const QUrl& plumeFileName, cons
return result;
}

SKRResult PLMImporter::readXMLRecursivelyAndCreatePaper(int projectId,
int indent,
QXmlStreamReader *xml,
const QString & tempDirPath)
{
SKRResult result;

if(!xml->readNextStartElement()){
xml->readElementText();
return result;
}
else {
IFOKDO(result, this->createPapersAndAssociations(projectId, indent, *xml, tempDirPath));
IFOKDO(result, readXMLRecursivelyAndCreatePaper(projectId, indent + 1, xml, tempDirPath));
}

while (xml->readNextStartElement()) {

IFOKDO(result, this->createPapersAndAssociations(projectId, indent, *xml, tempDirPath));
IFOKDO(result, readXMLRecursivelyAndCreatePaper(projectId, indent + 1, xml, tempDirPath));

}
}


SKRResult PLMImporter::createPapersAndAssociations(int projectId,
int indent,
const QXmlStreamReader& xml,
Expand Down
1 change: 1 addition & 0 deletions src/libskribisto-data/src/tasks/sql/plmimporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public slots:
const QString & attributeName,
const QStringList & values);

SKRResult readXMLRecursivelyAndCreatePaper(int projectId, int indent, QXmlStreamReader *xml, const QString &tempDirPath);
private:

// used to track old plume id with new skribisto note id
Expand Down
4 changes: 2 additions & 2 deletions src/libskribisto-data/src/tasks/sql/plmproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ PLMProject::PLMProject(QObject *parent, int projectId, const QUrl& fileName, SKR
*result = SKRResult(SKRResult::Critical, this, "string_to_double_conversion_failed");
}

IFOK(result){
IFOK(*result){
double dbVersion = SKRSqlTools::getProjectDBVersion(result, m_sqlDb);

IFOK(result){
IFOK(*result){

if(dbTemplateVersion < dbVersion){
//means that Skribisto can't use this db
Expand Down
14 changes: 14 additions & 0 deletions src/translations/skribisto_de_DE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2821,6 +2821,13 @@ Bitte öffnen Sie eine Plume-Datei.</translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ProjectTabForm.ui</name>
<message>
<source>Close project</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
Expand Down Expand Up @@ -3657,6 +3664,13 @@ Bitte öffnen Sie eine Plume-Datei.</translation>
<translation type="obsolete">Maske</translation>
</message>
</context>
<context>
<name>SkrTabButtonForm.ui</name>
<message>
<source>Close</source>
<translation type="unfinished">Schließen</translation>
</message>
</context>
<context>
<name>SkrTheme</name>
<message>
Expand Down
14 changes: 14 additions & 0 deletions src/translations/skribisto_fr_FR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,13 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ProjectTabForm.ui</name>
<message>
<source>Close project</source>
<translation type="unfinished">Fermer le projet</translation>
</message>
</context>
<context>
<name>RestoreListView</name>
<message>
Expand Down Expand Up @@ -1317,6 +1324,13 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SkrTabButtonForm.ui</name>
<message>
<source>Close</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SkrTheme</name>
<message>
Expand Down
14 changes: 14 additions & 0 deletions src/translations/skribisto_it_IT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2494,6 +2494,13 @@ Please open a .plume file.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ProjectTabForm.ui</name>
<message>
<source>Close project</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
Expand Down Expand Up @@ -3245,6 +3252,13 @@ Please open a .plume file.</source>
<translation type="obsolete">Modulo</translation>
</message>
</context>
<context>
<name>SkrTabButtonForm.ui</name>
<message>
<source>Close</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SkrTheme</name>
<message>
Expand Down
14 changes: 14 additions & 0 deletions src/translations/skribisto_pt_BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2250,6 +2250,13 @@ not allowed delete a filled book.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ProjectTabForm.ui</name>
<message>
<source>Close project</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
Expand Down Expand Up @@ -2977,6 +2984,13 @@ not allowed delete a filled book.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SkrTabButtonForm.ui</name>
<message>
<source>Close</source>
<translation type="unfinished">Fechar</translation>
</message>
</context>
<context>
<name>SkrTheme</name>
<message>
Expand Down
14 changes: 14 additions & 0 deletions src/translations/skribisto_ru_RU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2482,6 +2482,13 @@ Have you checked the one(s) you want to look through ?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ProjectTabForm.ui</name>
<message>
<source>Close project</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
Expand Down Expand Up @@ -3358,6 +3365,13 @@ Have you checked the one(s) you want to look through ?</source>
<translation type="obsolete">...</translation>
</message>
</context>
<context>
<name>SkrTabButtonForm.ui</name>
<message>
<source>Close</source>
<translation type="unfinished">Закрыть</translation>
</message>
</context>
<context>
<name>SkrTheme</name>
<message>
Expand Down
14 changes: 14 additions & 0 deletions src/translations/skribisto_sp_SP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2479,6 +2479,13 @@ Have you checked the one(s) you want to look through ?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ProjectTabForm.ui</name>
<message>
<source>Close project</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
Expand Down Expand Up @@ -3355,6 +3362,13 @@ Have you checked the one(s) you want to look through ?</source>
<translation type="obsolete">...</translation>
</message>
</context>
<context>
<name>SkrTabButtonForm.ui</name>
<message>
<source>Close</source>
<translation type="unfinished">Cerrar</translation>
</message>
</context>
<context>
<name>SkrTheme</name>
<message>
Expand Down

0 comments on commit 0018d43

Please sign in to comment.