Commit 710df664 authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Add the countries from the JS, and remove the JS

parent 1369e2e1
......@@ -40,7 +40,6 @@
<file>qml/components/DelegateMessageChatChangeTitle.qml</file>
<file>qml/components/DelegateMessageChatDeleteMember.qml</file>
<file>qml/components/DelegateMessageChatAddMembers.qml</file>
<file>qml/components/InternationalPhoneCodes.js</file>
<file>qml/components/DialogCountrySelector.qml</file>
<file>qml/components/DelegateFormattedText.qml</file>
<file>qml/components/DelegateAbstractMessageContent.qml</file>
......
......@@ -4,7 +4,6 @@ import Sailfish.Silica 1.0;
import Nemo.Notifications 1.0;
import harbour.Telegrame 1.0;
import QtGraphicalEffects 1.0;
import "../components/InternationalPhoneCodes.js" as InternationalPhoneCodes;
import "../components";
Dialog {
......@@ -19,20 +18,6 @@ Dialog {
property string flag : "";
property string name : "";
readonly property var countriesModel : {
var ret = ([]);
for (var i = 0; i < InternationalPhoneCodes.allCountries.length; ++i) {
var tmp = InternationalPhoneCodes.allCountries [i];
ret.push ({
"name" : tmp [0].replace (/\s+\(.+\)/, ""),
"iso2" : tmp [1],
"code" : tmp [2],
"flag" : "qrc:///RegionFlags/png/%1.png".arg (tmp [1].toUpperCase ()),
});
}
return ret;
}
DialogHeader {
id: headerDialCode;
title: qsTr ("Select country/region");
......@@ -62,18 +47,21 @@ Dialog {
ExtraAnchors.topDock: parent;
Repeater {
model: countriesModel; // use now TD_Global.countryCodes.list
model: TD_Global.countryCodes.list
delegate: ListItem {
visible: (modelData ["name"].toLowerCase ().indexOf (inputFilter.value) >= 0 || modelData ["code"].indexOf (inputFilter.value) >= 0);
highlighted: (dlgCountries.code === modelData ["code"]);
id: delegate;
visible: country.match (inputFilter.value);
highlighted: (dlgCountries.code === country.code);
implicitHeight: (layoutItem.height + layoutItem.anchors.margins * 2);
ExtraAnchors.horizontalFill: parent;
onClicked: {
dlgCountries.code = modelData ["code"];
dlgCountries.name = modelData ["name"];
dlgCountries.flag = modelData ["flag"];
dlgCountries.code = country.code
dlgCountries.name = country.name;
dlgCountries.flag = country.flag;
}
readonly property CountryCodesModelItem country : modelData;
RowContainer {
id: layoutItem;
spacing: Theme.paddingMedium;
......@@ -90,22 +78,22 @@ Dialog {
Image {
cache: true;
source: modelData ["flag"];
source: delegate.country.flag;
fillMode: Image.PreserveAspectFit;
sourceSize: Qt.size (width, height);
asynchronous: false;
asynchronous: true;
verticalAlignment: Image.AlignVCenter;
horizontalAlignment: Image.AlignHCenter;
anchors.fill: parent;
}
}
LabelFixed {
text: modelData ["name"];
text: delegate.country.name;
anchors.verticalCenter: parent.verticalCenter;
Container.horizontalStretch: 1;
}
LabelFixed {
text: ("+" + modelData ["code"]);
text: ("+" + delegate.country.code);
opacity: 0.65;
anchors.verticalCenter: parent.verticalCenter;
}
......
This diff is collapsed.
......@@ -4,7 +4,6 @@ import Sailfish.Silica 1.0;
import Nemo.Notifications 1.0;
import harbour.Telegrame 1.0;
import QtGraphicalEffects 1.0;
import "../components/InternationalPhoneCodes.js" as InternationalPhoneCodes;
import "../components";
Page {
......
This diff is collapsed.
......@@ -8,15 +8,17 @@
class CountryCodesModelItem : public QObject {
Q_OBJECT
QML_CONSTANT_CSTREF_PROPERTY (country, QString)
QML_CONSTANT_CSTREF_PROPERTY (abbr, QString)
QML_CONSTANT_CSTREF_PROPERTY (code, QString)
QML_CONSTANT_CSTREF_PROPERTY (name, QString)
QML_CONSTANT_CSTREF_PROPERTY (flag, QString)
QML_CONSTANT_CSTREF_PROPERTY (code, QString)
public:
explicit CountryCodesModelItem (const QString & country = { },
const QString & abbr = { },
const QString & code = { },
explicit CountryCodesModelItem (const QString & name = { },
const QString & flag = { },
const QString & code = { },
QObject * parent = nullptr);
Q_INVOKABLE bool match (const QString & filter) const;
};
class CountryCodes : public QObject {
......
......@@ -18,7 +18,7 @@ QtTdLibGlobal::QtTdLibGlobal (QObject * parent)
, m_currentMessageContent { Q_NULLPTR }
, m_sortedChatsList { new QSortFilterProxyModel { this } }
, m_sortedContactsList { new QSortFilterProxyModel { this } }
, m_countryCodest { new CountryCodes { this } }
, m_countryCodes { new CountryCodes { this } }
, m_sendTextOnEnterKey { false }
, SVG_ICON_FOR_MIMETYPE {
{ "image/png", "image" },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment