Changeset 4837
- Timestamp:
- 01/27/07 17:56:03 (21 months ago)
- Location:
- trunk/qt-gui/src
- Files:
-
- 4 modified
-
ewidgets.cpp (modified) (3 diffs)
-
ewidgets.h (modified) (2 diffs)
-
userinfodlg.cpp (modified) (3 diffs)
-
userinfodlg.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/qt-gui/src/ewidgets.cpp
r4792 r4837 51 51 #include "licq_history.h" 52 52 #include "licq_events.h" 53 #include "licq_user.h" 53 54 #include "mainwin.h" 54 55 #include "eventdesc.h" … … 651 652 } 652 653 654 // ----------------------------------------------------------------------------- 655 656 CTimeZoneField::CTimeZoneField(QWidget *parent) 657 : QSpinBox(-24, 24, 1, parent) 658 { 659 // The world is round so let timezones wrap 660 setWrapping(true); 661 662 // Plus and minus seems more fitting than up and down 663 setButtonSymbols(QSpinBox::PlusMinus); 664 665 // Force the input to be in format GMT+500, GMT-1030, etc... 666 setPrefix("GMT"); 667 setValidator(new QRegExpValidator(QRegExp("^[\\+\\-](1[012]|\\d)[03]0$|^Unknown$"), this)); 668 669 // Allow the value to be undefined as well. This will replace the lowest value (-24) 670 setSpecialValueText(tr("Unknown")); 671 } 672 673 void CTimeZoneField::setData(char data) 674 { 675 // The spinbox uses the lowest value to mark the undefined state but the constant is some other value so we need to change it 676 // For all defined values, the sign is inverted 677 setValue(data == TIMEZONE_UNKNOWN ? undefinedValue : static_cast<int>(-data)); 678 } 679 680 char CTimeZoneField::data() 681 { 682 int v = value(); 683 if (v == undefinedValue) 684 return TIMEZONE_UNKNOWN; 685 return static_cast<char>(-v); 686 } 687 688 QString CTimeZoneField::mapValueToText(int v) 689 { 690 // The internal value in the spinbox is 30min intervals so convert it to something more readable 691 return QString("%1%2%3").arg(v < 0 ? "-" : "+").arg(abs(v) / 2).arg(v % 2 ? "30" : "00"); 692 } 693 694 int CTimeZoneField::mapTextToValue(bool *ok) 695 { 696 // The user entered something so now we must try and convert it back to the internal int 697 QRegExp rx("^(\\+|-)(\\d+)(0|3)0$"); 698 if (rx.search(cleanText()) == -1) 699 { 700 *ok = false; 701 return 0; 702 } 703 int ret = rx.cap(2).toInt() * 2; 704 if (rx.cap(3) == "3") 705 ret++; 706 if (rx.cap(1) == "-") 707 ret = -ret; 708 *ok = true; 709 return ret; 710 } 653 711 654 712 // ----------------------------------------------------------------------------- … … 658 716 { 659 717 setTextFormat(RichText); 660 } ;718 } 661 719 662 720 // ----------------------------------------------------------------------------- -
trunk/qt-gui/src/ewidgets.h
r4792 r4837 34 34 #include <qlistview.h> 35 35 #include <qstringlist.h> 36 #include <qspinbox.h> 36 37 37 38 #include "mlview.h" … … 180 181 }; 181 182 183 /* ----------------------------------------------------------------------------- */ 184 185 /** 186 * Input field for timezones. 187 */ 188 class CTimeZoneField : public QSpinBox 189 { 190 public: 191 CTimeZoneField(QWidget *parent); 192 void setData(char data); 193 char data(); 194 protected: 195 QString mapValueToText(int v); 196 int mapTextToValue(bool* ok); 197 198 static const int undefinedValue = -24; 199 }; 182 200 183 201 /* ----------------------------------------------------------------------------- */ -
trunk/qt-gui/src/userinfodlg.cpp
r4791 r4837 308 308 lay->addWidget(nfoStatus, CR, 1); 309 309 lay->addWidget(new QLabel(tr("Timezone:"), p), CR, 3); 310 nfoTime = new CInfoField(p, true);311 lay->addWidget( nfoTime, CR, 4);310 tznZone = new CTimeZoneField(p); 311 lay->addWidget(tznZone, CR, 4); 312 312 313 313 lay->addWidget(new QLabel(tr("Name:"), p), ++CR, 0); … … 414 414 } 415 415 nfoIp->setData(ip); 416 if (u->GetTimezone() == TIMEZONE_UNKNOWN) 417 nfoTime->setText(tr("Unknown")); 418 else 419 { 420 nfoTime->setText(tr("GMT%1%1%1") 421 .arg(u->GetTimezone() > 0 ? "-" : "+") 422 .arg(abs(u->GetTimezone() / 2)).arg(u->GetTimezone() % 2 ? "30" : "00") ); 423 } 416 tznZone->setData(u->GetTimezone()); 424 417 nfoStatus->setData(u->StatusStr()); 425 418 if (m_bOwner) 426 419 { 420 // Owner timezone is not editable, it is taken from system timezone instead 421 tznZone->setEnabled(false); 422 427 423 const SCountry *c = GetCountryByCode(u->GetCountryCode()); 428 424 if (c == NULL) … … 491 487 u->SetCountryCode(GetCountryByIndex(i)->nCode); 492 488 } 489 u->SetTimezone(tznZone->data()); 493 490 494 491 u->SetEnableSave(true); -
trunk/qt-gui/src/userinfodlg.h
r4699 r4837 104 104 *nfoAlias, *nfoIp, *nfoUin, *nfoCity, *nfoState, 105 105 *nfoZipCode, *nfoAddress, *nfoCountry, *nfoFax, *nfoCellular, 106 *nfoPhone, *nfo Time, *nfoStatus;106 *nfoPhone, *nfoStatus; 107 107 QCheckBox *chkKeepAliasOnUpdate; 108 108 CEComboBox *cmbCountry; 109 109 QLabel *lblAuth, *lblICQHomepage; 110 CTimeZoneField *tznZone; 110 111 111 112 // More info
