Changeset 25415
- Timestamp:
- 05/10/08 07:24:27 (6 days ago)
- Files:
-
- haiku/trunk/src/preferences/time/DateTimeView.cpp (modified) (6 diffs)
- haiku/trunk/src/preferences/time/DateTimeView.h (modified) (3 diffs)
- haiku/trunk/src/preferences/time/Time.cpp (modified) (1 diff)
- haiku/trunk/src/preferences/time/TimeWindow.cpp (modified) (4 diffs)
- haiku/trunk/src/preferences/time/TimeWindow.h (modified) (2 diffs)
- haiku/trunk/src/preferences/time/ZoneView.cpp (modified) (13 diffs)
- haiku/trunk/src/preferences/time/ZoneView.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
haiku/trunk/src/preferences/time/DateTimeView.cpp
r25210 r25415 16 16 #include "TimeMessages.h" 17 17 #include "DateTime.h" 18 19 20 #include <Button.h> 18 #include "TimeWindow.h" 19 20 21 21 #include <CheckBox.h> 22 22 #include <Entry.h> … … 70 70 fInitialized = true; 71 71 72 fGmtTime->SetTarget(this);73 fLocalTime->SetTarget(this);74 72 fCalendarView->SetTarget(this); 75 fRevertButton->SetTarget(this);76 73 } 77 74 } … … 132 129 fUseGmtTime = fGmtTime->Value() == B_CONTROL_ON; 133 130 _UpdateGmtSettings(); 134 CheckCanRevert();135 131 break; 136 132 137 133 case kMsgRevert: 138 134 _Revert(); 139 fRevertButton->SetEnabled(false);140 135 break; 141 136 … … 147 142 148 143 149 void 144 bool 150 145 DateTimeView::CheckCanRevert() 151 146 { … … 158 153 time(&changedNow); 159 154 160 enable = enable || (changedNow != unchangedNow); 161 162 fRevertButton->SetEnabled(enable); 155 return enable || (changedNow != unchangedNow); 163 156 } 164 157 … … 266 259 267 260 fOldUseGmtTime = fUseGmtTime; 268 269 BRect rect = Bounds();270 271 rect.left = 10;272 rect.top = rect.bottom - 10;273 274 fRevertButton = new BButton(rect, "revert", "Revert",275 new BMessage(kMsgRevert), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW);276 277 fRevertButton->ResizeToPreferred();278 fRevertButton->SetEnabled(false);279 float buttonHeight = fRevertButton->Bounds().Height();280 fRevertButton->MoveBy(0, -buttonHeight);281 AddChild(fRevertButton);282 261 283 262 ResizeTo(fClock->Frame().right + 10.0, fGmtTime->Frame().bottom + 10.0); haiku/trunk/src/preferences/time/DateTimeView.h
r25210 r25415 21 21 class BRadioButton; 22 22 class TAnalogClock; 23 class BButton;24 23 25 24 … … 33 32 virtual void MessageReceived(BMessage *message); 34 33 35 void CheckCanRevert(); 34 bool CheckCanRevert(); 35 bool GetUseGmtTime(); 36 36 37 37 private: … … 52 52 TAnalogClock *fClock; 53 53 54 BButton *fRevertButton; 55 56 bool fUseGmtTime; 54 bool fUseGmtTime; 57 55 bool fOldUseGmtTime; 58 56 bool fInitialized; haiku/trunk/src/preferences/time/Time.cpp
r24403 r25415 47 47 BAlert *alert = new BAlert("about", 48 48 "Time & Date, writen by:\n\n\tAndrew Edward McCall\n\tMike Berg\n\t" 49 "Julun\n\ nCopyright 2004-2007, Haiku.", "OK");49 "Julun\n\tPhilippe Saint-Pierre\n\nCopyright 2004-2008, Haiku.", "OK"); 50 50 alert->Go(); 51 51 } haiku/trunk/src/preferences/time/TimeWindow.cpp
r25210 r25415 21 21 #include <Screen.h> 22 22 #include <TabView.h> 23 #include <Button.h> 23 24 24 25 … … 38 39 39 40 41 void 42 TTimeWindow::SetRevertStatus() 43 { 44 fRevertButton->SetEnabled(fDateTimeView->CheckCanRevert() 45 || fTimeZoneView->CheckCanRevert()); 46 } 47 48 40 49 void 41 50 TTimeWindow::MessageReceived(BMessage *message) … … 44 53 case H_USER_CHANGE: 45 54 fBaseView->ChangeTime(message); 46 fDateTimeView->CheckCanRevert();55 SetRevertStatus(); 47 56 break; 48 57 49 58 case B_ABOUT_REQUESTED: 50 59 be_app->PostMessage(B_ABOUT_REQUESTED); 60 break; 61 62 case kMsgRevert: 63 fDateTimeView->MessageReceived(message); 64 fTimeZoneView->MessageReceived(message); 65 fRevertButton->SetEnabled(false); 66 break; 67 68 case kRTCUpdate: 69 fDateTimeView->MessageReceived(message); 70 SetRevertStatus(); 51 71 break; 52 72 … … 102 122 fBaseView->AddChild(tabView); 103 123 tabView->ResizeBy(0.0, tabView->TabHeight()); 124 125 BRect rect = Bounds(); 126 127 rect.left = 10; 128 rect.top = rect.bottom - 10; 129 130 fRevertButton = new BButton(rect, "revert", "Revert", 131 new BMessage(kMsgRevert), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW); 132 133 fRevertButton->ResizeToPreferred(); 134 fRevertButton->SetEnabled(false); 135 float buttonHeight = fRevertButton->Bounds().Height(); 136 fRevertButton->MoveBy(0, -buttonHeight); 137 fBaseView->AddChild(fRevertButton); 138 fRevertButton->SetTarget(this); 139 104 140 fBaseView->ResizeTo(tabView->Bounds().Width() + 10.0, 105 tabView->Bounds().Height() + 10.0);141 tabView->Bounds().Height() + buttonHeight + 30.0); 106 142 107 143 ResizeTo(fBaseView->Bounds().Width(), fBaseView->Bounds().Height()); haiku/trunk/src/preferences/time/TimeWindow.h
r22633 r25415 28 28 virtual bool QuitRequested(); 29 29 virtual void MessageReceived(BMessage *message); 30 void SetRevertStatus(); 30 31 31 32 private: … … 37 38 DateTimeView *fDateTimeView; 38 39 TimeZoneView *fTimeZoneView; 40 BButton *fRevertButton; 39 41 }; 40 42 haiku/trunk/src/preferences/time/ZoneView.cpp
r22633 r25415 1 1 /* 2 * Copyright 2004-200 7, Haiku, Inc. All Rights Reserved.2 * Copyright 2004-2008, Haiku, Inc. All Rights Reserved. 3 3 * Distributed under the terms of the MIT License. 4 4 * … … 6 6 * Mike Berg <mike@berg-net.us> 7 7 * Julun <host.haiku@gmx.de> 8 * Philippe Saint-Pierre <stpere@gmail.com> 8 9 */ 9 10 … … 22 23 #include "TimeMessages.h" 23 24 #include "TZDisplay.h" 25 #include "TimeWindow.h" 24 26 25 27 … … 38 40 #include <String.h> 39 41 #include <View.h> 42 #include <Window.h> 40 43 41 44 … … 68 71 69 72 73 bool 74 TimeZoneView::CheckCanRevert() 75 { 76 return fCurrentZone != fOldZone; 77 } 78 79 80 void 81 TimeZoneView::_Revert() 82 { 83 BPath parent; 84 85 fCurrentZone = fOldZone; 86 int32 czone; 87 88 if (strcmp(fCurrentZone.Leaf(), "Greenwich") == 0) { 89 if (BMenuItem* item = fRegionPopUp->FindItem("Others")) 90 item->SetMarked(true); 91 czone = FillCityList("Others"); 92 } else { 93 fCurrentZone.GetParent(&parent); 94 if (BMenuItem* item = fRegionPopUp->FindItem(parent.Leaf())) 95 item->SetMarked(true); 96 czone = FillCityList(parent.Path()); 97 } 98 99 if (czone > -1) { 100 fCityList->Select(czone); 101 fCityList->ScrollToSelection(); 102 fCurrent->SetText(((TZoneItem *)fCityList->ItemAt(czone))->Text()); 103 SetPreview(); 104 } 105 SetTimeZone(); 106 } 107 108 70 109 TimeZoneView::~TimeZoneView() 71 110 { … … 88 127 // update displays 89 128 BPath parent; 90 fCurrentZone.GetParent(&parent); 91 int32 czone = FillCityList(parent.Path()); 92 if (czone > -1) { 93 fCityList->Select(czone); 94 fCurrent->SetText(((TZoneItem *)fCityList->ItemAt(czone))->Text()); 129 if (strcmp(fCurrentZone.Leaf(), "Greenwich") != 0) { 130 fCurrentZone.GetParent(&parent); 131 int32 czone = FillCityList(parent.Path()); 132 if (czone > -1) { 133 fCityList->Select(czone); 134 fCurrent->SetText(((TZoneItem *)fCityList->ItemAt(czone))->Text()); 135 } 136 } else { 137 int32 czone = FillCityList("Others"); 138 if (czone > -1) { 139 fCityList->Select(czone); 140 fCurrent->SetText(((TZoneItem *)fCityList->ItemAt(czone))->Text()); 141 } 95 142 } 96 143 } … … 121 168 122 169 case H_SET_TIME_ZONE: 170 { 123 171 SetTimeZone(); 172 BMessage msg(*message); 173 msg.what = kRTCUpdate; 174 Window()->PostMessage(&msg); 175 ((TTimeWindow*)Window())->SetRevertStatus(); 124 176 break; 125 177 } 178 179 case kMsgRevert: 180 _Revert(); 181 break; 182 126 183 case H_CITY_CHANGED: 127 184 SetPreview(); … … 243 300 // skip Etc directory 244 301 if (itemtext.Compare("Etc", 3) == 0) 245 continue;302 continue; 246 303 247 304 markit = itemtext.Compare(region.Leaf()) == 0; … … 264 321 } 265 322 } 323 BMessage *msg = new BMessage(H_REGION_CHANGED); 324 msg->AddString("region", "Others"); 325 326 item = new BMenuItem("Others", msg); 327 item->SetMarked(strcmp(fCurrentZone.Leaf(), "Greenwich") == 0); 328 fRegionPopUp->AddItem(item); 266 329 } 267 330 … … 278 341 } 279 342 280 // Enter time zones directory. Find subdir with name that matches string281 // stored in area. Enter subdirectory and count the items. For each item,282 // add a StringItem to fCityList Time zones directory283 284 BPath path;285 if (find_directory(B_BEOS_ETC_DIRECTORY, &path) != B_OK)286 return 0;287 288 path.Append("timezones");289 290 BPath Area(area);291 BDirectory zoneDir(path.Path());292 BDirectory cityDir;293 343 BStringItem *city; 294 BString city_name;295 BEntry entry;296 344 int32 index = -1; 297 298 //locate subdirectory: 299 if (zoneDir.Contains(Area.Leaf(), B_DIRECTORY_NODE)) { 300 cityDir.SetTo(&zoneDir, Area.Leaf()); 301 302 // There is a subdir with a name that matches 'area'. That's the one!! 303 // Iterate over the items in the subdir, fill listview with TZoneItems 304 while(cityDir.GetNextEntry(&entry) == B_NO_ERROR) { 305 if (!entry.IsDirectory()) { 306 BPath zone(&entry); 307 city_name = zone.Leaf(); 308 city_name.ReplaceAll("_IN", ", Indiana"); 309 city_name.ReplaceAll("__Calif", ", Calif"); 310 city_name.ReplaceAll("__", ", "); 311 city_name.ReplaceAll("_", " "); 312 city = new TZoneItem(city_name.String(), zone.Path()); 313 fCityList->AddItem(city); 314 if (strcmp(fCurrentZone.Leaf(), zone.Leaf()) == 0) 315 index = fCityList->IndexOf(city); 345 if (strcmp(area, "Others") != 0) { 346 347 // Enter time zones directory. Find subdir with name that matches string 348 // stored in area. Enter subdirectory and count the items. For each item, 349 // add a StringItem to fCityList Time zones directory 350 351 BPath path; 352 if (find_directory(B_BEOS_ETC_DIRECTORY, &path) != B_OK) 353 return 0; 354 355 path.Append("timezones"); 356 357 BPath Area(area); 358 BDirectory zoneDir(path.Path()); 359 BDirectory cityDir; 360 BString city_name; 361 BEntry entry; 362 363 364 //locate subdirectory: 365 if (zoneDir.Contains(Area.Leaf(), B_DIRECTORY_NODE)) { 366 cityDir.SetTo(&zoneDir, Area.Leaf()); 367 368 // There is a subdir with a name that matches 'area'. That's the one!! 369 // Iterate over the items in the subdir, fill listview with TZoneItems 370 while(cityDir.GetNextEntry(&entry) == B_NO_ERROR) { 371 if (!entry.IsDirectory()) { 372 BPath zone(&entry); 373 city_name = zone.Leaf(); 374 city_name.ReplaceAll("_IN", ", Indiana"); 375 city_name.ReplaceAll("__Calif", ", Calif"); 376 city_name.ReplaceAll("__", ", "); 377 city_name.ReplaceAll("_", " "); 378 city = new TZoneItem(city_name.String(), zone.Path()); 379 fCityList->AddItem(city); 380 if (strcmp(fCurrentZone.Leaf(), zone.Leaf()) == 0) 381 index = fCityList->IndexOf(city); 382 } 316 383 } 384 } 385 } else { 386 city = new TZoneItem("Greenwich", "/boot/beos/etc/timezones/Greenwich"); 387 fCityList->AddItem(city); 388 if (strcmp(fCurrentZone.Leaf(), "Greenwich") == 0) { 389 index = fCityList->IndexOf(city); 317 390 } 318 391 } … … 364 437 // do something like set to a default GMT??? 365 438 } 439 else if (!tzLink.Exists()) { // link doesn't exists 440 tzLink.SetTo("/boot/beos/etc/timezones/Greenwich"); 441 } 366 442 } else { 367 // set tzlink to a default443 // directory doesn't exist 368 444 tzLink.SetTo("/boot/beos/etc/timezones/EST"); 369 445 } … … 371 447 // we need something in the current zone 372 448 fCurrentZone.SetTo(&tzLink); 449 fOldZone.SetTo(&tzLink); 373 450 } 374 451 … … 450 527 // update environment 451 528 SetTimeZone(target.Path()); 452 529 453 530 // update display 454 531 time_t current = time(0); haiku/trunk/src/preferences/time/ZoneView.h
r22633 r25415 29 29 virtual void AttachedToWindow(); 30 30 virtual void MessageReceived(BMessage *message); 31 bool CheckCanRevert(); 31 32 32 33 private: … … 40 41 void ReadTimeZoneLink(); 41 42 void BuildRegionMenu(); 43 void _Revert(); 42 44 43 45 // returns index of current zone … … 54 56 int32 fMinute; 55 57 BPath fCurrentZone; 58 BPath fOldZone; 56 59 bool fInitialized; 57 60 };
