From c6c587934e213811dcdc6076c67d36507fe06529 Mon Sep 17 00:00:00 2001
From: "Sidhant Sharma [:TigerKid001]" <tigerkid001@gmail.com>
Date: Wed, 22 Oct 2014 18:32:22 +0000
Subject: [PATCH] Status line enhancement v1.0
---
src/kits/tracker/CountView.cpp | 68 ++++++++++++++++++++++++++++++++++++++----
src/kits/tracker/CountView.h | 3 ++
src/kits/tracker/PoseView.cpp | 2 +-
3 files changed, 67 insertions(+), 6 deletions(-)
diff --git a/src/kits/tracker/CountView.cpp b/src/kits/tracker/CountView.cpp
index a1d3c7c..976ec47 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), |
70 | 76 | fShowingBarberPole(false), |
71 | 77 | fBorderHighlighted(false), |
… |
… |
BCountView::CheckCount()
|
207 | 213 | |
208 | 214 | |
209 | 215 | void |
| 216 | BCountView::GetCountsAndSizes() |
| 217 | { |
| 218 | if(fLastCount != fPoseView->CountItems()) |
| 219 | fLastCount = fPoseView->CountItems(); |
| 220 | |
| 221 | node_ref ref; |
| 222 | Model* model = fPoseView->TargetModel(); |
| 223 | if(model->IsDirectory()) |
| 224 | ref = *model->NodeRef(); |
| 225 | |
| 226 | BDirectory dir(&ref); |
| 227 | dir.Rewind(); |
| 228 | BEntry entry; |
| 229 | while (dir.GetNextEntry(&entry) == B_OK) { |
| 230 | StatStruct statbuf; |
| 231 | status_t status = entry.GetStat(&statbuf); |
| 232 | if (status != B_OK) |
| 233 | return; |
| 234 | |
| 235 | if (S_ISDIR(statbuf.st_mode)) |
| 236 | fDirCount++; |
| 237 | else{ |
| 238 | fFileCount++; |
| 239 | off_t fileSize = 0; |
| 240 | BFile file(&entry,B_READ_ONLY); |
| 241 | file.GetSize(&fileSize); |
| 242 | fTotalFilesSize += fileSize; |
| 243 | } |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | void |
210 | 248 | BCountView::Draw(BRect updateRect) |
211 | 249 | { |
212 | 250 | BRect bounds(Bounds()); |
… |
… |
BCountView::Draw(BRect updateRect)
|
222 | 260 | be_control_look->DrawMenuBarBackground(this, bounds, updateRect, |
223 | 261 | ViewColor()); |
224 | 262 | } |
225 | | |
226 | 263 | BString itemString; |
| 264 | BString fileString, folderString, sizeString; |
227 | 265 | if (IsTypingAhead()) |
228 | 266 | itemString << TypeAhead(); |
229 | 267 | else if (IsFiltering()) { |
… |
… |
BCountView::Draw(BRect updateRect)
|
232 | 270 | if (fLastCount == 0) |
233 | 271 | itemString << B_TRANSLATE("no items"); |
234 | 272 | else { |
235 | | static BMessageFormat format(B_TRANSLATE_COMMENT( |
| 273 | static BMessageFormat itemFormat(B_TRANSLATE_COMMENT( |
236 | 274 | "{0, plural, one{# item} other{# items}}", |
237 | 275 | "Number of selected items: \"1 item\" or \"2 items\"")); |
238 | | format.Format(itemString, fLastCount); |
| 276 | itemFormat.Format(itemString, fLastCount); |
| 277 | |
| 278 | itemString += " | "; |
| 279 | static BMessageFormat folderFormat(B_TRANSLATE_COMMENT( |
| 280 | "{0, plural, one{# folder} other{# folders}}", |
| 281 | "Number of selected folders: \"1 folder\" or \"2 folders\"")); |
| 282 | folderFormat.Format(folderString, fDirCount); |
| 283 | itemString += folderString; |
| 284 | } |
| 285 | |
| 286 | itemString += " | "; |
| 287 | static BMessageFormat fileFormat(B_TRANSLATE_COMMENT( |
| 288 | "{0, plural, one{# file} other{# files}}", |
| 289 | "Number of selected folders: \"1 file\" or \"2 files\"")); |
| 290 | fileFormat.Format(fileString, fFileCount); |
| 291 | itemString += fileString; |
| 292 | char sizeBuffer[128]; |
| 293 | sizeString = string_for_size((double)fTotalFilesSize, |
| 294 | sizeBuffer, sizeof(sizeBuffer)); |
| 295 | itemString += "("; |
| 296 | itemString += sizeString; |
| 297 | itemString += ")"; |
239 | 298 | } |
240 | | } |
241 | | |
242 | 299 | BRect textRect(TextInvalRect()); |
243 | 300 | |
244 | 301 | TruncateString(&itemString, IsTypingAhead() ? B_TRUNCATE_BEGINNING |
… |
… |
BCountView::AttachedToWindow()
|
346 | 403 | SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); |
347 | 404 | SetLowColor(ViewColor()); |
348 | 405 | |
| 406 | GetCountsAndSizes(); |
349 | 407 | CheckCount(); |
350 | 408 | } |
351 | 409 | |
diff --git a/src/kits/tracker/CountView.h b/src/kits/tracker/CountView.h
index 52ad97e..2e47885 100644
a
|
b
|
public:
|
57 | 57 | virtual void WindowActivated(bool active); |
58 | 58 | |
59 | 59 | void CheckCount(); |
| 60 | void GetCountsAndSizes(); |
60 | 61 | void StartBarberPole(); |
61 | 62 | void EndBarberPole(); |
62 | 63 | |
… |
… |
private:
|
80 | 81 | void TrySpinningBarberPole(); |
81 | 82 | |
82 | 83 | int32 fLastCount; |
| 84 | int32 fFileCount, fDirCount; |
| 85 | off_t fTotalFilesSize; |
83 | 86 | BPoseView* fPoseView; |
84 | 87 | bool fShowingBarberPole : 1; |
85 | 88 | bool fBorderHighlighted : 1; |
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 = 240; |
117 | 117 | |
118 | 118 | const uint32 kAddNewPoses = 'Tanp'; |
119 | 119 | const uint32 kAddPosesCompleted = 'Tapc'; |