summaryrefslogtreecommitdiff
path: root/user.cxx
diff options
context:
space:
mode:
authorErik Prabowo Kamal <erik@darapsa.co.id>2019-08-30 15:41:40 +0800
committerErik Prabowo Kamal <erik@darapsa.co.id>2019-08-30 15:41:40 +0800
commit5607c8dbc6ba69f17b12579f7aad8cb028e33ce4 (patch)
tree5e2556edd6a2d5018f4a2e246d80472d39025941 /user.cxx
parent55a2bf601f0c1633f7955fd7ac52c98a8917af64 (diff)
Made the user class members more straightforward
using rtclient's rt_user members.
Diffstat (limited to 'user.cxx')
-rw-r--r--user.cxx127
1 files changed, 52 insertions, 75 deletions
diff --git a/user.cxx b/user.cxx
index 0983874..76b44e1 100644
--- a/user.cxx
+++ b/user.cxx
@@ -1,179 +1,156 @@
+#include <cstring>
#include "rtuser.h"
#include "user.hxx"
-void User::update(rt_user* user)
-{
- if (m_isLoggedIn) {
- setName(QString{user->name});
- setEmailAddress(QString{user->emailaddress});
- setOrganization(QString{user->organization});
- setRealName(QString{user->realname});
- setNickName(QString{user->nickname});
- setLang(QString{user->lang});
- setHomePhone(QString{user->homephone});
- setWorkPhone(QString{user->workphone});
- setMobilePhone(QString{user->mobilephone});
- setPagerPhone(QString{user->pagerphone});
- setAddress1(QString{user->address1});
- setAddress2(QString{user->address2});
- setCity(QString{user->city});
- setState(QString{user->state});
- setZip(QString{user->zip});
- setCountry(QString{user->country});
- setTimeZone(QString{user->timezone});
- } else {
- setName("");
- setEmailAddress("");
- setOrganization("");
- setRealName("");
- setNickName("");
- setLang("");
- setHomePhone("");
- setWorkPhone("");
- setMobilePhone("");
- setPagerPhone("");
- setAddress1("");
- setAddress2("");
- setCity("");
- setState("");
- setZip("");
- setCountry("");
- setTimeZone("");
- }
-}
-
void User::setName(QString const& name)
{
- if (m_name != name) {
- m_name = name;
+ auto c_name = name.toUtf8().constData();
+ if (strcmp(m_user.name, c_name)) {
+ strcpy(m_user.name, c_name);
emit nameChanged();
}
}
void User::setEmailAddress(QString const& emailAddress)
{
- if (m_emailAddress != emailAddress) {
- m_emailAddress = emailAddress;
+ auto c_emailAddress = emailAddress.toUtf8().constData();
+ if (strcmp(m_user.emailaddress, c_emailAddress)) {
+ strcpy(m_user.emailaddress, c_emailAddress);
emit emailAddressChanged();
}
}
void User::setOrganization(QString const& organization)
{
- if (m_organization != organization) {
- m_organization = organization;
+ auto c_organization = organization.toUtf8().constData();
+ if (strcmp(m_user.organization, c_organization)) {
+ strcpy(m_user.organization, c_organization);
emit organizationChanged();
}
}
void User::setRealName(QString const& realName)
{
- if (m_realName != realName) {
- m_realName = realName;
+ auto c_realName = realName.toUtf8().constData();
+ if (strcmp(m_user.realname, c_realName)) {
+ strcpy(m_user.realname, c_realName);
emit realNameChanged();
}
}
void User::setNickName(QString const& nickName)
{
- if (m_nickName != nickName) {
- m_nickName = nickName;
+ auto c_nickName = nickName.toUtf8().constData();
+ if (strcmp(m_user.nickname, c_nickName)) {
+ strcpy(m_user.nickname, c_nickName);
emit nickNameChanged();
}
}
void User::setLang(QString const& lang)
{
- if (m_lang != lang) {
- m_lang = lang;
+ auto c_lang = lang.toUtf8().constData();
+ if (strcmp(m_user.lang, c_lang)) {
+ strcpy(m_user.lang, c_lang);
emit langChanged();
}
}
void User::setHomePhone(QString const& homePhone)
{
- if (m_homePhone != homePhone) {
- m_homePhone = homePhone;
+ auto c_homePhone = homePhone.toUtf8().constData();
+ if (strcmp(m_user.homephone, c_homePhone)) {
+ strcpy(m_user.homephone, c_homePhone);
emit homePhoneChanged();
}
}
void User::setWorkPhone(QString const& workPhone)
{
- if (m_workPhone != workPhone) {
- m_workPhone = workPhone;
+ auto c_workPhone = workPhone.toUtf8().constData();
+ if (strcmp(m_user.workphone, c_workPhone)) {
+ strcpy(m_user.workphone, c_workPhone);
emit workPhoneChanged();
}
}
void User::setMobilePhone(QString const& mobilePhone)
{
- if (m_mobilePhone != mobilePhone) {
- m_mobilePhone = mobilePhone;
+ auto c_mobilePhone = mobilePhone.toUtf8().constData();
+ if (strcmp(m_user.mobilephone, c_mobilePhone)) {
+ strcpy(m_user.mobilephone, c_mobilePhone);
emit mobilePhoneChanged();
}
}
void User::setPagerPhone(QString const& pagerPhone)
{
- if (m_pagerPhone != pagerPhone) {
- m_pagerPhone = pagerPhone;
+ auto c_pagerPhone = pagerPhone.toUtf8().constData();
+ if (strcmp(m_user.pagerphone, c_pagerPhone)) {
+ strcpy(m_user.pagerphone, c_pagerPhone);
emit pagerPhoneChanged();
}
}
void User::setAddress1(QString const& address1)
{
- if (m_address1 != address1) {
- m_address1 = address1;
+ auto c_address1 = address1.toUtf8().constData();
+ if (strcmp(m_user.address1, c_address1)) {
+ strcpy(m_user.address1, c_address1);
emit address1Changed();
}
}
void User::setAddress2(QString const& address2)
{
- if (m_address2 != address2) {
- m_address2 = address2;
+ auto c_address2 = address2.toUtf8().constData();
+ if (strcmp(m_user.address2, c_address2)) {
+ strcpy(m_user.address2, c_address2);
emit address2Changed();
}
}
void User::setCity(QString const& city)
{
- if (m_city != city) {
- m_city = city;
+ auto c_city = city.toUtf8().constData();
+ if (strcmp(m_user.city, c_city)) {
+ strcpy(m_user.city, c_city);
emit cityChanged();
}
}
void User::setState(QString const& state)
{
- if (m_state != state) {
- m_state = state;
+ auto c_state = state.toUtf8().constData();
+ if (strcmp(m_user.state, c_state)) {
+ strcpy(m_user.state, c_state);
emit stateChanged();
}
}
void User::setZip(QString const& zip)
{
- if (m_zip != zip) {
- m_zip = zip;
+ auto c_zip = zip.toUtf8().constData();
+ if (strcmp(m_user.zip, c_zip)) {
+ strcpy(m_user.zip, c_zip);
emit zipChanged();
}
}
void User::setCountry(QString const& country)
{
- if (m_country != country) {
- m_country = country;
+ auto c_country = country.toUtf8().constData();
+ if (strcmp(m_user.country, c_country)) {
+ strcpy(m_user.country, c_country);
emit countryChanged();
}
}
void User::setTimeZone(QString const& timeZone)
{
- if (m_timeZone != timeZone) {
- m_timeZone = timeZone;
+ auto c_timeZone = timeZone.toUtf8().constData();
+ if (strcmp(m_user.timezone, c_timeZone)) {
+ strcpy(m_user.timezone, c_timeZone);
emit timeZoneChanged();
}
}