1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00

更新qqtdicttest7

This commit is contained in:
tianduanrui 2020-03-12 18:50:53 +08:00
parent 6e05113bbd
commit 5d73c27146
2 changed files with 135 additions and 12 deletions

View File

@ -35,23 +35,23 @@ MainWindow::MainWindow ( QWidget* parent ) :
QByteArray bytes0 = dict.toXML ( 4 );
p3line() << qPrintable ( QString ( bytes0 ) );
ui->textBrowser_2->append ( bytes0 );
ui->textBrowser->append ( bytes0 );
bytes0 = dict.toJson ( QJsonDocument::Indented ) ;
p3line() << qPrintable ( QString ( bytes0 ) );
ui->textBrowser_3->append ( bytes0 );
ui->textBrowser_2->append ( bytes0 );
bytes0 = dict.toYAML() ;
p3line() << qPrintable ( QString ( bytes0 ) );
ui->textBrowser_4->append ( bytes0 );
ui->textBrowser_3->append ( bytes0 );
bytes0 = dict["ui"]["widget"].toINI() ;
p3line() << qPrintable ( QString ( bytes0 ) );
ui->textBrowser_5->append ( bytes0 );
ui->textBrowser_4->append ( bytes0 );
bytes0 = dict["ui"]["layoutdefault"]["__attributes__"].toProperties() ;
p3line() << qPrintable ( QString ( bytes0 ) );
ui->textBrowser_6->append ( bytes0 );
ui->textBrowser_5->append ( bytes0 );
}
@ -63,5 +63,128 @@ MainWindow::~MainWindow()
void MainWindow::on_pushButton_clicked ( bool checked )
{
if ( ui->lineEdit->text().isEmpty() )
return;
QFile file ( ui->lineEdit->text() );
file.open ( QFile::ReadOnly );
QByteArray bytes = file.readAll();
file.close();;
QQtDictionary dict;
if ( ui->comboBox->currentText().contains ( ".xml" ) )
{
dict.fromXML ( bytes );
}
else if ( ui->comboBox->currentText().contains ( ".json" ) )
{
dict.fromJson ( bytes );
}
else if ( ui->comboBox->currentText().contains ( ".ini" ) )
{
dict.fromINI ( bytes );
}
else if ( ui->comboBox->currentText().contains ( ".yaml" ) )
{
dict.fromYAML ( bytes );
}
else if ( ui->comboBox->currentText().contains ( ".properties" ) )
{
dict.fromProperties ( bytes );
}
else
{
return;
}
if ( ui->checkBox->isChecked() )
{
ui->textBrowser->clear();
ui->textBrowser->append ( dict.toXML ( 4 ) );
if ( !ui->lineEdit_2->text().isEmpty() )
{
QFile file ( ui->lineEdit_2->text() + ".xml" );
file.open ( QFile::Truncate | QFile::WriteOnly );
file.write ( dict.toXML ( 4 ) );
file.close();;
}
}
if ( ui->checkBox_2->isChecked() )
{
ui->textBrowser_2->clear();
ui->textBrowser_2->append ( dict.toJson ( QJsonDocument::Indented ) );
if ( !ui->lineEdit_2->text().isEmpty() )
{
QFile file ( ui->lineEdit_2->text() + ".json" );
file.open ( QFile::Truncate | QFile::WriteOnly );
file.write ( dict.toJson ( QJsonDocument::Indented ) );
file.close();;
}
}
if ( ui->checkBox_3->isChecked() )
{
ui->textBrowser_3->clear();
ui->textBrowser_3->append ( dict.toYAML() );
if ( !ui->lineEdit_2->text().isEmpty() )
{
QFile file ( ui->lineEdit_2->text() + ".yaml" );
file.open ( QFile::Truncate | QFile::WriteOnly );
file.write ( dict.toYAML() );
file.close();;
}
}
if ( ui->checkBox_4->isChecked() )
{
ui->textBrowser_4->clear();
ui->textBrowser_4->append ( dict.toINI() );
if ( !ui->lineEdit_2->text().isEmpty() )
{
QFile file ( ui->lineEdit_2->text() + ".ini" );
file.open ( QFile::Truncate | QFile::WriteOnly );
file.write ( dict.toINI() );
file.close();;
}
}
if ( ui->checkBox_5->isChecked() )
{
ui->textBrowser_5->clear();
ui->textBrowser_5->append ( dict.toProperties() );
if ( !ui->lineEdit_2->text().isEmpty() )
{
QFile file ( ui->lineEdit_2->text() + ".properties" );
file.open ( QFile::Truncate | QFile::WriteOnly );
file.write ( dict.toProperties() );
file.close();;
}
}
}

View File

@ -41,7 +41,7 @@
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QTextBrowser" name="textBrowser_2"/>
<widget class="QTextBrowser" name="textBrowser"/>
</item>
</layout>
</widget>
@ -51,7 +51,7 @@
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QTextBrowser" name="textBrowser_3"/>
<widget class="QTextBrowser" name="textBrowser_2"/>
</item>
</layout>
</widget>
@ -61,7 +61,7 @@
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QTextBrowser" name="textBrowser_4"/>
<widget class="QTextBrowser" name="textBrowser_3"/>
</item>
</layout>
</widget>
@ -71,7 +71,7 @@
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QTextBrowser" name="textBrowser_5"/>
<widget class="QTextBrowser" name="textBrowser_4"/>
</item>
</layout>
</widget>
@ -81,7 +81,7 @@
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QTextBrowser" name="textBrowser_6"/>
<widget class="QTextBrowser" name="textBrowser_5"/>
</item>
</layout>
</widget>
@ -91,7 +91,7 @@
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTextBrowser" name="textBrowser">
<widget class="QTextBrowser" name="textBrowser_6">
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
@ -208,7 +208,7 @@ p, li { white-space: pre-wrap; }
</item>
<item>
<property name="text">
<string>.yaml</string>
<string>.yaml .yml</string>
</property>
</item>
<item>