Skip to content

Commit

Permalink
Added full name parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Bnn authored and Bnn committed Feb 26, 2020
1 parent 653f2e4 commit e1b522a
Show file tree
Hide file tree
Showing 20 changed files with 830 additions and 736 deletions.
1 change: 1 addition & 0 deletions app/doublecontact.pro
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ TRANSLATIONS += \
../translations/doublecontact_fr.ts \
../translations/doublecontact_nb_NO.ts \
../translations/doublecontact_nl.ts \
../translations/doublecontact_pl.ts \
../translations/doublecontact_pt.ts \
../translations/doublecontact_ru_RU.ts \
../translations/doublecontact_uk_UA.ts \
Expand Down
8 changes: 8 additions & 0 deletions app/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,3 +1140,11 @@ void MainWindow::on_actionJoin_names_triggered()
updateViewMode();
updateHeaders();
}

void MainWindow::on_actionParse_full_name_triggered()
{
if (!checkSelection()) return;
selectedModel->parseFullName(selection);
updateViewMode();
updateHeaders();
}
2 changes: 1 addition & 1 deletion app/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ private slots:
void on_action_About_triggered();
void on_action_About_Qt_triggered();
void on_actionCopy_text_triggered();

void on_actionJoin_names_triggered();
void on_actionParse_full_name_triggered();

private:
Ui::MainWindow *ui;
Expand Down
8 changes: 7 additions & 1 deletion app/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="verticalHeaderVisible">
<bool>true</bool>
<bool>false</bool>
</attribute>
</widget>
</item>
Expand Down Expand Up @@ -280,6 +280,7 @@
<addaction name="actionFormat_phone_numbers"/>
<addaction name="separator"/>
<addaction name="action_Generate_full_name"/>
<addaction name="actionParse_full_name"/>
<addaction name="actionDrop_full_name"/>
<addaction name="actionReverse_full_name"/>
</widget>
Expand Down Expand Up @@ -615,6 +616,11 @@
<string>Join names</string>
</property>
</action>
<action name="actionParse_full_name">
<property name="text">
<string>Parse full name</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
Expand Down
10 changes: 10 additions & 0 deletions core/contactlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,16 @@ QString ContactItem::makeGenericName() const
return res;
}

void ContactItem::parseFullName()
{
names = fullName.split(" ");
while (names.count()>MAX_NAMES)
names.removeLast();
for (int i=0; i<names.count(); i++)
if (names[i].right(1)==",")
names[i].remove(names[i].count()-1);
}

void ContactItem::reverseFullName()
{
int sPos = fullName.indexOf(" ");
Expand Down
1 change: 1 addition & 0 deletions core/contactlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ struct ContactItem {
void sortTypes(QList<T> &values); // Type sorting and lowercasing for correct compare
QString formatNames() const;
QString makeGenericName() const;
void parseFullName();
void reverseFullName();
void dropFinalEmptyNames(); // If empty parts not in-middle, remove it
void formatPhones(const QString& templ);
Expand Down
1 change: 1 addition & 0 deletions doc/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Bugfix release:

CURRENT
* Added names joining (primarily for SIM prepare)
* Added full name parsing (from FN to N)
* At main window, splitter between left and right panels added
* At contact edit dialog, unknown and unediting (other) tags can be removed or copied to clipboard via popup menu
* At contact edit dialog, "Save view" button added
Expand Down
1 change: 1 addition & 0 deletions doc/changelog.rus
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@

ТЕКУЩАЯ
* добавлено склеивание нескольких имен (преимущественно для подготовки для записи на SIM-карту)
* добавлен разбор полного имени (из FN в N)
* в главном окне добавлен разделитель между левой и правой панелью
* в окне редактирования контактов можно удалять нередактируемые и неизвестные теги, а также копировать их в буфер через контекстное меню
* в окне редактирования контактов добавлена операция "Запомнить вид" для сохранения количества и типоа имён, телефонов, почтовых ящиков, адресов и IM
Expand Down
10 changes: 10 additions & 0 deletions model/contactmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,16 @@ void ContactModel::generateFullNames(const QModelIndexList &indices)
_changed = true;
}

void ContactModel::parseFullName(const QModelIndexList& indices)
{
foreach(QModelIndex index, indices) {
beginEditRow(index);
items[index.row()].parseFullName();
endEditRow(index);
}
_changed = true;
}

void ContactModel::dropFullNames(const QModelIndexList &indices)
{
foreach(QModelIndex index, indices) {
Expand Down
1 change: 1 addition & 0 deletions model/contactmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class ContactModel : public QAbstractTableModel
void joinNames(const QModelIndexList& indices);
void dropSlashes(const QModelIndexList& indices);
void generateFullNames(const QModelIndexList& indices);
void parseFullName(const QModelIndexList& indices);
void dropFullNames(const QModelIndexList& indices);
void reverseFullNames(const QModelIndexList& indices);
void formatPhones(const QModelIndexList& indices, const QString& templ);
Expand Down
Loading

0 comments on commit e1b522a

Please sign in to comment.