add name type for English name.
This commit is contained in:
parent
231f63295f
commit
b2602b5ef7
@ -37,7 +37,7 @@ BirthdayCreater::~BirthdayCreater()
|
||||
{
|
||||
}
|
||||
|
||||
QList<NameInfo_t> BirthdayCreater::getNameByFileContent(const QByteArray& conetent)
|
||||
QList<NameInfo_t> BirthdayCreater::getNameByFileContent(Name_Type_e type, const QByteArray& conetent)
|
||||
{
|
||||
QList<NameInfo_t> nameList;
|
||||
|
||||
@ -74,11 +74,11 @@ QList<NameInfo_t> BirthdayCreater::getNameByFileContent(const QByteArray& conete
|
||||
return nameList;
|
||||
}
|
||||
|
||||
void BirthdayCreater::generaImageFromCSV(const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color)
|
||||
void BirthdayCreater::generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color)
|
||||
{
|
||||
int export_times = 0;
|
||||
|
||||
QList<NameInfo_t> nameList = getNameByFileContent(filecontent);
|
||||
QList<NameInfo_t> nameList = getNameByFileContent(type, filecontent);
|
||||
if (nameList.isEmpty()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString("Name is empty ! ").append(filename));
|
||||
|
||||
@ -8,9 +8,10 @@ public:
|
||||
~BirthdayCreater();
|
||||
|
||||
protected:
|
||||
QList<NameInfo_t> getNameByFileContent(const QByteArray& conetent);
|
||||
QList<NameInfo_t> getNameByFileContent(Name_Type_e type, const QByteArray& conetent);
|
||||
public:
|
||||
virtual void generaImageFromCSV(const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color);
|
||||
virtual void generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color);
|
||||
|
||||
|
||||
private:
|
||||
QMap<QString, QString> label_bg_map;
|
||||
|
||||
@ -54,11 +54,11 @@ FiveToSingle::~FiveToSingle()
|
||||
{
|
||||
}
|
||||
|
||||
void FiveToSingle::generaImageFromCSV(const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color)
|
||||
void FiveToSingle::generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color)
|
||||
{
|
||||
int export_times = 0;
|
||||
|
||||
QList<NameInfo_t> nameList = getNameByFileContent(filecontent);
|
||||
QList<NameInfo_t> nameList = getNameByFileContent(type, filecontent);
|
||||
if (nameList.isEmpty()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString("Name is empty ! ").append(filename));
|
||||
|
||||
@ -7,7 +7,7 @@ public:
|
||||
~FiveToSingle();
|
||||
|
||||
public:
|
||||
virtual void generaImageFromCSV(const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color);
|
||||
virtual void generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ void INameCreater::saveToImage(const QString& filename, QGraphicsScene* scene)
|
||||
|
||||
}
|
||||
|
||||
QList<NameInfo_t> INameCreater::getNameByFile(const QString& filename)
|
||||
QList<NameInfo_t> INameCreater::getNameByFile(Name_Type_e type, const QString& filename)
|
||||
{
|
||||
QList<NameInfo_t> nameList;
|
||||
|
||||
@ -110,7 +110,7 @@ QList<NameInfo_t> INameCreater::getNameByFile(const QString& filename)
|
||||
return nameList;
|
||||
}
|
||||
|
||||
QList<NameInfo_t> INameCreater::getNameByFileContent(const QByteArray& conetent)
|
||||
QList<NameInfo_t> INameCreater::getNameByFileContent(Name_Type_e type, const QByteArray& conetent)
|
||||
{
|
||||
QList<NameInfo_t> nameList;
|
||||
QTextCodec* tc = QTextCodec::codecForName("Big5");
|
||||
@ -150,6 +150,20 @@ QList<NameInfo_t> INameCreater::getNameByFileContent(const QByteArray& conetent)
|
||||
return nameList;
|
||||
}
|
||||
|
||||
void INameCreater::generaImageFromCSV(const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color)
|
||||
void INameCreater::generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color)
|
||||
{
|
||||
}
|
||||
|
||||
int INameCreater::getFontSizebyStr(const QFont& font, int max_font_size,int max_label_width, const QString& str)
|
||||
{
|
||||
QFont _font(font);
|
||||
int font_size = max_font_size;
|
||||
while (font_size > 10) {
|
||||
_font.setPixelSize(max_font_size);
|
||||
QFontMetrics fm(_font);
|
||||
if (fm.horizontalAdvance(str) <= max_label_width) break;
|
||||
font_size--;
|
||||
}
|
||||
|
||||
return font_size;
|
||||
}
|
||||
|
||||
@ -15,19 +15,26 @@ struct NameInfo_t {
|
||||
int bg_type;
|
||||
};
|
||||
|
||||
|
||||
enum Name_Type_e {
|
||||
Name_zh = 0,
|
||||
Name_eng,
|
||||
Name_zh_eng
|
||||
};
|
||||
|
||||
class INameCreater : public QObject {
|
||||
public:
|
||||
INameCreater();
|
||||
~INameCreater();
|
||||
|
||||
|
||||
protected:
|
||||
void saveToImage(const QString& filename, QGraphicsScene* scene);
|
||||
QList<NameInfo_t> getNameByFile(const QString& filename);
|
||||
QList<NameInfo_t> getNameByFileContent(const QByteArray& conetent);
|
||||
QList<NameInfo_t> getNameByFile(Name_Type_e type, const QString& filename);
|
||||
QList<NameInfo_t> getNameByFileContent(Name_Type_e type, const QByteArray& conetent);
|
||||
|
||||
virtual void generaImageFromCSV(const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color);
|
||||
virtual void generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color);
|
||||
|
||||
private:
|
||||
int getFontSizebyStr(const QFont& font, int max_font_size, int max_label_width, const QString& str);
|
||||
|
||||
};
|
||||
@ -98,11 +98,11 @@ void NameCreater::OnClickedReadBtn() {
|
||||
}
|
||||
else {
|
||||
// Use fileName and fileContent
|
||||
if(sender == ui.fivesingle_btn) FiveToSingle().generaImageFromCSV(fileName, fileContent, this->font, this->font_color);
|
||||
if(sender == ui.fivesingle_btn) FiveToSingle().generaImageFromCSV(Name_Type_e::Name_zh,fileName, fileContent, this->font, this->font_color);
|
||||
//if(sender == ui.fiveold_btn) OldFiveCreater().generaImageFromCSV(fileName, fileContent, this->font, this->font_color);
|
||||
if(sender == ui.birthday_btn) BirthdayCreater().generaImageFromCSV(fileName, fileContent, this->font, this->font_color);
|
||||
if(sender == ui.fivenew_btn) NewFiveCreater().generaImageFromCSV(fileName, fileContent, this->font, this->font_color);
|
||||
if(sender == ui.towel_btn) TowelCreater().generaImageFromCSV(fileName, fileContent, this->font_towel, this->font_color);
|
||||
if(sender == ui.birthday_btn) BirthdayCreater().generaImageFromCSV(Name_Type_e::Name_zh, fileName, fileContent, this->font, this->font_color);
|
||||
if(sender == ui.fivenew_btn) NewFiveCreater().generaImageFromCSV(Name_Type_e::Name_zh, fileName, fileContent, this->font, this->font_color);
|
||||
if(sender == ui.towel_btn) TowelCreater().generaImageFromCSV(Name_Type_e::Name_zh, fileName, fileContent, this->font_towel, this->font_color);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>946</width>
|
||||
<height>589</height>
|
||||
<height>817</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
@ -60,7 +60,7 @@
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>851</width>
|
||||
<height>441</height>
|
||||
<height>521</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
@ -77,6 +77,69 @@ border-color: rgb(255, 255, 255);
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="fivesingle_btn">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>76</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open File</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QPushButton" name="birthday_btn">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>76</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open File</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="towel_btn">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>76</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open File</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="tital_label_6">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Yu Gothic UI</family>
|
||||
<pointsize>20</pointsize>
|
||||
<weight>50</weight>
|
||||
<italic>false</italic>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">
|
||||
color: rgb(255, 255, 255);
|
||||
</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>生日禮產生器(中/英)</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="fivenew_btn">
|
||||
<property name="minimumSize">
|
||||
@ -90,6 +153,29 @@ border-color: rgb(255, 255, 255);
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="tital_label_3">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Yu Gothic UI</family>
|
||||
<pointsize>20</pointsize>
|
||||
<weight>50</weight>
|
||||
<italic>false</italic>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 255, 255);
|
||||
</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>五入組產生器</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="tital_label_4">
|
||||
<property name="font">
|
||||
@ -114,29 +200,6 @@ color: rgb(255, 255, 255);
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="tital_label_3">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Yu Gothic UI</family>
|
||||
<pointsize>20</pointsize>
|
||||
<weight>50</weight>
|
||||
<italic>false</italic>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 255, 255);
|
||||
</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>五入組產生器</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="tital_label">
|
||||
<property name="font">
|
||||
@ -160,19 +223,6 @@ color: rgb(255, 255, 255);
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="fivesingle_btn">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>76</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open File</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="tital_label_5">
|
||||
<property name="font">
|
||||
@ -196,21 +246,8 @@ color: rgb(255, 255, 255);
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QPushButton" name="birthday_btn">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>76</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open File</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="towel_btn">
|
||||
<item row="6" column="0">
|
||||
<widget class="QPushButton" name="birthday_zh_eng_btn">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
|
||||
@ -30,7 +30,7 @@ NewFiveCreater::~NewFiveCreater()
|
||||
{
|
||||
}
|
||||
|
||||
QList<NameInfo_t> NewFiveCreater::getNameByFileContent(const QByteArray& conetent)
|
||||
QList<NameInfo_t> NewFiveCreater::getNameByFileContent(Name_Type_e type, const QByteArray& conetent)
|
||||
{
|
||||
QList<NameInfo_t> nameList;
|
||||
|
||||
@ -68,12 +68,12 @@ QList<NameInfo_t> NewFiveCreater::getNameByFileContent(const QByteArray& coneten
|
||||
|
||||
}
|
||||
|
||||
void NewFiveCreater::generaImageFromCSV(const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color)
|
||||
void NewFiveCreater::generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color)
|
||||
{
|
||||
|
||||
int export_times = 0;
|
||||
|
||||
QList<NameInfo_t> nameList = getNameByFileContent(filecontent);
|
||||
QList<NameInfo_t> nameList = getNameByFileContent(type, filecontent);
|
||||
if (nameList.isEmpty()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString("Name is empty ! ").append(filename));
|
||||
|
||||
@ -8,9 +8,9 @@ public:
|
||||
~NewFiveCreater();
|
||||
|
||||
protected:
|
||||
QList<NameInfo_t> getNameByFileContent(const QByteArray& conetent);
|
||||
QList<NameInfo_t> getNameByFileContent(Name_Type_e type, const QByteArray& conetent);
|
||||
public:
|
||||
virtual void generaImageFromCSV(const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color);
|
||||
virtual void generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ OldFiveCreater::~OldFiveCreater()
|
||||
{
|
||||
}
|
||||
|
||||
QList<NameInfo_t> OldFiveCreater::getNameByFileContent(const QByteArray& conetent)
|
||||
QList<NameInfo_t> OldFiveCreater::getNameByFileContent(Name_Type_e type, const QByteArray& conetent)
|
||||
{
|
||||
QList<NameInfo_t> nameList;
|
||||
|
||||
@ -76,11 +76,11 @@ QList<NameInfo_t> OldFiveCreater::getNameByFileContent(const QByteArray& coneten
|
||||
return nameList;
|
||||
}
|
||||
|
||||
void OldFiveCreater::generaImageFromCSV(const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color)
|
||||
void OldFiveCreater::generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color)
|
||||
{
|
||||
int export_times = 0;
|
||||
|
||||
QList<NameInfo_t> nameList = getNameByFileContent(filecontent);
|
||||
QList<NameInfo_t> nameList = getNameByFileContent(type, filecontent);
|
||||
if (nameList.isEmpty()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString("Name is empty ! ").append(filename));
|
||||
|
||||
@ -8,8 +8,8 @@ public:
|
||||
~OldFiveCreater();
|
||||
|
||||
protected:
|
||||
QList<NameInfo_t> getNameByFileContent(const QByteArray& conetent);
|
||||
QList<NameInfo_t> getNameByFileContent(Name_Type_e type, const QByteArray& conetent);
|
||||
public:
|
||||
virtual void generaImageFromCSV(const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color);
|
||||
virtual void generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color);
|
||||
};
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ TowelCreater::~TowelCreater()
|
||||
{
|
||||
}
|
||||
|
||||
QList<NameInfo_t> TowelCreater::getNameByFileContent(const QByteArray& conetent)
|
||||
QList<NameInfo_t> TowelCreater::getNameByFileContent(Name_Type_e type, const QByteArray& conetent)
|
||||
{
|
||||
|
||||
QList<NameInfo_t> nameList;
|
||||
@ -75,11 +75,11 @@ QList<NameInfo_t> TowelCreater::getNameByFileContent(const QByteArray& conetent)
|
||||
|
||||
}
|
||||
|
||||
void TowelCreater::generaImageFromCSV(const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color)
|
||||
void TowelCreater::generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color)
|
||||
{
|
||||
int export_times = 0;
|
||||
|
||||
QList<NameInfo_t> nameList = getNameByFileContent(filecontent);
|
||||
QList<NameInfo_t> nameList = getNameByFileContent(type, filecontent);
|
||||
if (nameList.isEmpty()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString("Name is empty ! ").append(filename));
|
||||
|
||||
@ -7,8 +7,8 @@ public:
|
||||
~TowelCreater();
|
||||
|
||||
protected:
|
||||
QList<NameInfo_t> getNameByFileContent(const QByteArray& conetent);
|
||||
QList<NameInfo_t> getNameByFileContent(Name_Type_e type, const QByteArray& conetent);
|
||||
public:
|
||||
virtual void generaImageFromCSV(const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color);
|
||||
virtual void generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color);
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user