Ticket #3560: bug#3560-status-line-enhancement-004.patch
File bug#3560-status-line-enhancement-004.patch, 5.8 KB (added by , 9 years ago) |
---|
-
src/kits/tracker/CountView.cpp
From cd75968f9c9f0f1909de23978a81925961e6843b Mon Sep 17 00:00:00 2001 From: "Sidhant Sharma [:TigerKid001]" <tigerkid001@gmail.com> Date: Sat, 25 Oct 2014 11:24:51 +0530 Subject: [PATCH] Status line enhancement v1.3 --- src/kits/tracker/CountView.cpp | 105 ++++++++++++++++++++++++++++++++++------- src/kits/tracker/CountView.h | 5 ++ src/kits/tracker/PoseView.cpp | 2 +- 3 files changed, 93 insertions(+), 19 deletions(-) diff --git a/src/kits/tracker/CountView.cpp b/src/kits/tracker/CountView.cpp index a1d3c7c..301d840 100644
a b All rights reserved. 47 47 #include "Bitmaps.h" 48 48 #include "ContainerWindow.h" 49 49 #include "DirMenu.h" 50 #include "Entry.h" 51 #include "Model.h" 50 52 #include "PoseView.h" 53 #include "StringForSize.h" 51 54 #include "Utilities.h" 52 55 53 56 … … BCountView::BCountView(BRect bounds, BPoseView* view) 66 69 BView(bounds, "CountVw", B_FOLLOW_LEFT + B_FOLLOW_BOTTOM, 67 70 B_PULSE_NEEDED | B_WILL_DRAW), 68 71 fLastCount(-1), 72 fFileCount(0), 73 fDirCount(0), 74 fTotalFilesSize(0), 69 75 fPoseView(view), 76 fMoreFiles(false), 70 77 fShowingBarberPole(false), 71 78 fBorderHighlighted(false), 72 79 fBarberPoleMap(NULL), 73 80 fLastBarberPoleOffset(5), 74 81 fStartSpinningAfter(0), 82 fStatusString(""), 75 83 fTypeAheadString(""), 76 84 fFilterString("") 77 85 { … … BCountView::CheckCount() 198 206 // invalidate the count text area if necessary 199 207 if (fLastCount != fPoseView->CountItems()) { 200 208 fLastCount = fPoseView->CountItems(); 209 _UpdateCountsAndSizes(); 201 210 Invalidate(TextInvalRect()); 202 211 } 203 212 … … BCountView::CheckCount() 207 216 208 217 209 218 void 219 BCountView::_UpdateCountsAndSizes() 220 { 221 fFileCount = 0; 222 fDirCount = 0; 223 fTotalFilesSize = 0; 224 fLastCount = fPoseView->CountItems(); 225 fMoreFiles = false; 226 227 node_ref ref; 228 Model* model = fPoseView->TargetModel(); 229 if (model->IsDirectory()) 230 ref = *model->NodeRef(); 231 else { 232 // we can't check for files and folders if model is not a directory 233 return; 234 } 235 236 BDirectory dir(&ref); 237 BEntry entry; 238 while (dir.GetNextEntry(&entry) == B_OK) { 239 StatStruct statbuf; 240 status_t status = entry.GetStat(&statbuf); 241 if (status != B_OK) { 242 fMoreFiles = true; 243 continue; 244 } 245 246 if (S_ISDIR(statbuf.st_mode)) 247 fDirCount++; 248 else { 249 fFileCount++; 250 fTotalFilesSize += statbuf.st_size; 251 } 252 } 253 254 BString itemString; 255 BString fileString, folderString, sizeString; 256 if (IsTypingAhead()) 257 fStatusString << TypeAhead(); 258 else if (IsFiltering()) { 259 fStatusString << fLastCount << " " << Filter(); 260 } else { 261 if (fLastCount == 0) 262 fStatusString << B_TRANSLATE("no items"); 263 else { 264 fStatusString = ""; 265 static BMessageFormat itemFormat(B_TRANSLATE_COMMENT( 266 "{0, plural, one{# item} other{# items}}", 267 "Number of selected items: \"1 item\" or \"2 items\"")); 268 itemFormat.Format(itemString, fLastCount); 269 fStatusString += itemString; 270 271 fStatusString += " | "; 272 static BMessageFormat folderFormat(B_TRANSLATE_COMMENT( 273 "{0, plural, one{# folder} other{# folders}}", 274 "Number of selected folders: \"1 folder\" or \"2 folders\"")); 275 folderFormat.Format(folderString, fDirCount); 276 fStatusString += folderString; 277 278 fStatusString += " | "; 279 static BMessageFormat fileFormat(B_TRANSLATE_COMMENT( 280 "{0, plural, one{#%more% file} other{#%more% files}} (%size%)", 281 "Number of selected files: \"1 file\" or \"2 files\"")); 282 fileFormat.Format(fileString, fFileCount); 283 fileString.ReplaceFirst("%more%", (fMoreFiles?"+":"") ); 284 char sizeBuffer[128]; 285 sizeString = string_for_size((double)fTotalFilesSize, 286 sizeBuffer, sizeof(sizeBuffer)); 287 fileString.ReplaceFirst("%size%", sizeString); 288 fStatusString += fileString; 289 } 290 } 291 } 292 293 294 void 210 295 BCountView::Draw(BRect updateRect) 211 296 { 212 297 BRect bounds(Bounds()); … … BCountView::Draw(BRect updateRect) 223 308 ViewColor()); 224 309 } 225 310 226 BString itemString;227 if (IsTypingAhead())228 itemString << TypeAhead();229 else if (IsFiltering()) {230 itemString << fLastCount << " " << Filter();231 } else {232 if (fLastCount == 0)233 itemString << B_TRANSLATE("no items");234 else {235 static BMessageFormat format(B_TRANSLATE_COMMENT(236 "{0, plural, one{# item} other{# items}}",237 "Number of selected items: \"1 item\" or \"2 items\""));238 format.Format(itemString, fLastCount);239 }240 }241 242 311 BRect textRect(TextInvalRect()); 243 312 244 TruncateString(& itemString, IsTypingAhead() ? B_TRUNCATE_BEGINNING313 TruncateString(&fStatusString, IsTypingAhead() ? B_TRUNCATE_BEGINNING 245 314 : IsFiltering() ? B_TRUNCATE_MIDDLE : B_TRUNCATE_END, 246 315 textRect.Width()); 247 316 … … BCountView::Draw(BRect updateRect) 253 322 SetHighColor(0, 0, 0); 254 323 255 324 MovePenTo(textRect.LeftBottom()); 256 DrawString( itemString.String());325 DrawString(fStatusString.String()); 257 326 258 327 bounds.top++; 259 328 -
src/kits/tracker/CountView.h
diff --git a/src/kits/tracker/CountView.h b/src/kits/tracker/CountView.h index 52ad97e..7291e1c 100644
a b private: 78 78 BRect TextInvalRect() const; 79 79 BRect TextAndBarberPoleRect() const; 80 80 void TrySpinningBarberPole(); 81 void _UpdateCountsAndSizes(); 81 82 82 83 int32 fLastCount; 84 int32 fFileCount, fDirCount; 85 off_t fTotalFilesSize; 83 86 BPoseView* fPoseView; 87 bool fMoreFiles : 1; 84 88 bool fShowingBarberPole : 1; 85 89 bool fBorderHighlighted : 1; 86 90 BBitmap* fBarberPoleMap; 87 91 float fLastBarberPoleOffset; 88 92 bigtime_t fStartSpinningAfter; 93 BString fStatusString; 89 94 BString fTypeAheadString; 90 95 BString fFilterString; 91 96 }; -
src/kits/tracker/PoseView.cpp
diff --git a/src/kits/tracker/PoseView.cpp b/src/kits/tracker/PoseView.cpp index ae04731..a13b00c 100644
a b using std::max; 113 113 114 114 115 115 const float kDoubleClickTresh = 6; 116 const float kCountViewWidth = 76;116 const float kCountViewWidth = 250; 117 117 118 118 const uint32 kAddNewPoses = 'Tanp'; 119 119 const uint32 kAddPosesCompleted = 'Tapc';