1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
|
/***************************************************************************
moreinfo.cpp - description
-------------------
begin : Sun Mar 17 2002
copyright : (C) 2002 by Vladimir Shutoff
email : vovan@shutoff.ru
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "icons.h"
#include "moreinfo.h"
#include "icqclient.h"
#include "datepicker.h"
#include <qpushbutton.h>
#include <qdatetime.h>
#include <qspinbox.h>
#include <qcombobox.h>
#include <qlineedit.h>
using namespace SIM;
MoreInfo::MoreInfo(QWidget *parent, ICQUserData *data, unsigned contact, ICQClient *client)
: MoreInfoBase(parent)
{
m_data = data;
m_client = client;
m_contact = contact;
btnHomePage->setPixmap(Pict("home"));
connect(btnHomePage, SIGNAL(clicked()), this, SLOT(goUrl()));
spnAge->setSpecialValueText(" ");
spnAge->setRange(0, 100);
connect(cmbLang1, SIGNAL(activated(int)), this, SLOT(setLang(int)));
connect(cmbLang2, SIGNAL(activated(int)), this, SLOT(setLang(int)));
connect(cmbLang3, SIGNAL(activated(int)), this, SLOT(setLang(int)));
connect(edtDate, SIGNAL(changed()), this, SLOT(birthDayChanged()));
if (m_data){
disableWidget(spnAge);
edtHomePage->setReadOnly(true);
disableWidget(cmbGender);
disableWidget(edtDate);
disableWidget(cmbLang1);
disableWidget(cmbLang2);
disableWidget(cmbLang3);
}else{
connect(edtHomePage, SIGNAL(textChanged(const QString&)), this, SLOT(urlChanged(const QString&)));
}
fill();
}
void MoreInfo::apply()
{
}
bool MoreInfo::processEvent(Event *e)
{
if (e->type() == eEventContact){
EventContact *ec = static_cast<EventContact*>(e);
if(ec->action() != EventContact::eChanged)
return false;
Contact *contact = ec->contact();
if (contact->clientData.have(m_data))
fill();
} else
if ((e->type() == eEventClientChanged) && (m_data == 0)){
EventClientChanged *ecc = static_cast<EventClientChanged*>(e);
if (ecc->client() == m_client)
fill();
}
return false;
}
const ext_info genders[] =
{
{ I18N_NOOP("Female"), 1 },
{ I18N_NOOP("Male"), 2 },
{ "", 0 }
};
const ext_info *p_genders = genders;
const ext_info languages[] =
{
{I18N_NOOP("Arabic"), 1},
{I18N_NOOP("Bhojpuri"), 2},
{I18N_NOOP("Bulgarian"), 3},
{I18N_NOOP("Burmese"), 4},
{I18N_NOOP("Cantonese"), 5},
{I18N_NOOP("Catalan"), 6},
{I18N_NOOP("Chinese"), 7},
{I18N_NOOP("Croatian"), 8},
{I18N_NOOP("Czech"), 9},
{I18N_NOOP("Danish"), 10},
{I18N_NOOP("Dutch"), 11},
{I18N_NOOP("English"), 12},
{I18N_NOOP("Esperanto"), 13},
{I18N_NOOP("Estonian"), 14},
{I18N_NOOP("Farsi"), 15},
{I18N_NOOP("Finnish"), 16},
{I18N_NOOP("French"), 17},
{I18N_NOOP("Gaelic"), 18},
{I18N_NOOP("German"), 19},
{I18N_NOOP("Greek"), 20},
{I18N_NOOP("Hebrew"), 21},
{I18N_NOOP("Hindi"), 22},
{I18N_NOOP("Hungarian"), 23},
{I18N_NOOP("Icelandic"), 24},
{I18N_NOOP("Indonesian"), 25},
{I18N_NOOP("Italian"), 26},
{I18N_NOOP("Japanese"), 27},
{I18N_NOOP("Khmer"), 28},
{I18N_NOOP("Korean"), 29},
{I18N_NOOP("Lao"), 30},
{I18N_NOOP("Latvian"), 31},
{I18N_NOOP("Lithuanian"), 32},
{I18N_NOOP("Malay"), 33},
{I18N_NOOP("Norwegian"), 34},
{I18N_NOOP("Polish"), 35},
{I18N_NOOP("Portuguese"), 36},
{I18N_NOOP("Romanian"), 37},
{I18N_NOOP("Russian"), 38},
{I18N_NOOP("Serbian"), 39},
{I18N_NOOP("Slovak"), 40},
{I18N_NOOP("Slovenian"), 41},
{I18N_NOOP("Somali"), 42},
{I18N_NOOP("Spanish"), 43},
{I18N_NOOP("Swahili"), 44},
{I18N_NOOP("Swedish"), 45},
{I18N_NOOP("Tagalog"), 46},
{I18N_NOOP("Tatar"), 47},
{I18N_NOOP("Thai"), 48},
{I18N_NOOP("Turkish"), 49},
{I18N_NOOP("Ukrainian"), 50},
{I18N_NOOP("Urdu"), 51},
{I18N_NOOP("Vietnamese"), 52},
{I18N_NOOP("Yiddish"), 53},
{I18N_NOOP("Yoruba"), 54},
{I18N_NOOP("Afrikaans"), 55},
{I18N_NOOP("Persian"), 57},
{I18N_NOOP("Albanian"), 58},
{I18N_NOOP("Armenian"), 59},
{I18N_NOOP("Kyrgyz"), 123},
{I18N_NOOP("Maltese"), 125},
{"", 0}
};
const ext_info *p_languages = languages;
void MoreInfo::fill()
{
ICQUserData *data = m_data;
if (data == NULL)
data = &m_client->data.owner;
edtHomePage->setText(data->Homepage.str());
initCombo(cmbGender, data->Gender.toULong(), genders);
if (spnAge->text() == "0")
spnAge->setSpecialValueText(QString::null);
if (data->BirthYear.toULong()>0 && data->BirthMonth.toULong()>0 && data->BirthDay.toULong()>0) {
QDate date;
date.setYMD(data->BirthYear.toULong(), data->BirthMonth.toULong(), data->BirthDay.toULong());
edtDate->setDate(date);
birthDayChanged();
}
unsigned l = data->Language.toULong();
char l1 = (char)(l & 0xFF);
l = l >> 8;
char l2 = (char)(l & 0xFF);
l = l >> 8;
char l3 = (char)(l & 0xFF);
initCombo(cmbLang1, l1, languages);
initCombo(cmbLang2, l2, languages);
initCombo(cmbLang3, l3, languages);
setLang(0);
urlChanged(edtHomePage->text());
}
void MoreInfo::birthDayChanged()
{
int day = edtDate->getDate().day();
int month = edtDate->getDate().month();
int year = edtDate->getDate().year();
if (year){
QDate now = QDate::currentDate();
int age = now.year() - year;
if ((now.month() < month) || ((now.month() == month) && (now.day() < day))) age--;
if (age < 100){
spnAge->setValue(age);
}else{
spnAge->setValue(0);
}
}else{
spnAge->setValue(0);
}
}
void MoreInfo::goUrl()
{
QString url = edtHomePage->text();
if (url.isEmpty())
return;
if(!url.startsWith("http://"))
url = "http://" + url;
EventGoURL e(url);
e.process();
}
void MoreInfo::setLang(int)
{
unsigned l[3], sl[3];
l[0] = cmbLang1->currentItem();
l[1] = cmbLang2->currentItem();
l[2] = cmbLang3->currentItem();
unsigned j = 0;
for (unsigned i = 0; i < 3; i++)
if (l[i])
sl[j++] = l[i];
for (; j < 3; j++)
sl[j] = 0;
cmbLang1->setCurrentItem(sl[0]);
cmbLang2->setCurrentItem(sl[1]);
cmbLang3->setCurrentItem(sl[2]);
cmbLang2->setEnabled(sl[0] != 0);
cmbLang3->setEnabled(sl[1] != 0);
}
void MoreInfo::apply(Client *client, void *_data)
{
if (client != m_client)
return;
ICQUserData *data = m_client->toICQUserData((SIM::clientData*)_data); // FIXME unsafe type conversion
data->Homepage.str() = edtHomePage->text();
data->Gender.asULong() = getComboValue(cmbGender, genders);
data->BirthMonth.asULong() = edtDate->getDate().month();
data->BirthDay.asULong() = edtDate->getDate().day();
data->BirthYear.asULong() = edtDate->getDate().year();
unsigned l1 = getComboValue(cmbLang1, languages);
unsigned l2 = getComboValue(cmbLang2, languages);
unsigned l3 = getComboValue(cmbLang3, languages);
data->Language.asULong() = (l3 << 16) | (l2 << 8) | l1;
}
void MoreInfo::urlChanged(const QString &text)
{
btnHomePage->setEnabled(!text.isEmpty());
}
#ifndef NO_MOC_INCLUDES
#include "moreinfo.moc"
#endif
|