HaikuDepot: Clean up trailing whitespace.

This commit is contained in:
Michael Lotz
2015-04-08 11:15:29 +02:00
parent 5c7707fc34
commit 8708474567
26 changed files with 182 additions and 182 deletions
+1 -1
View File
@@ -99,7 +99,7 @@ public:
{ {
_Resize(0); _Resize(0);
} }
inline bool IsEmpty() const inline bool IsEmpty() const
{ {
return fCount == 0; return fCount == 0;
+22 -22
View File
@@ -660,13 +660,13 @@ Model::PopulatePackage(const PackageInfoRef& package, uint32 flags)
BMessage info; BMessage info;
BString packageName; BString packageName;
BString architecture; BString architecture;
{ {
BAutolock locker(&fLock); BAutolock locker(&fLock);
packageName = package->Name(); packageName = package->Name();
architecture = package->Architecture(); architecture = package->Architecture();
} }
status_t status = fWebAppInterface.RetrieveUserRatings(packageName, status_t status = fWebAppInterface.RetrieveUserRatings(packageName,
architecture, 0, 50, info); architecture, 0, 50, info);
if (status == B_OK) { if (status == B_OK) {
@@ -683,7 +683,7 @@ Model::PopulatePackage(const PackageInfoRef& package, uint32 flags)
while (true) { while (true) {
BString name; BString name;
name << index++; name << index++;
BMessage item; BMessage item;
if (items.FindMessage(name, &item) != B_OK) if (items.FindMessage(name, &item) != B_OK)
break; break;
@@ -831,7 +831,7 @@ Model::_UpdateIsFeaturedFilter()
{ {
if (fShowFeaturedPackages && SearchTerms().IsEmpty()) if (fShowFeaturedPackages && SearchTerms().IsEmpty())
fIsFeaturedFilter = PackageFilterRef(new IsFeaturedFilter(), true); fIsFeaturedFilter = PackageFilterRef(new IsFeaturedFilter(), true);
else else
fIsFeaturedFilter = PackageFilterRef(new AnyFilter(), true); fIsFeaturedFilter = PackageFilterRef(new AnyFilter(), true);
} }
@@ -860,7 +860,7 @@ Model::_PopulateAllPackagesThread(bool fromCacheOnly)
PackageInfoRef package; PackageInfoRef package;
{ {
BAutolock locker(&fLock); BAutolock locker(&fLock);
if (depotIndex >= fDepots.CountItems()) if (depotIndex >= fDepots.CountItems())
break; break;
const DepotInfo& depot = fDepots.ItemAt(depotIndex); const DepotInfo& depot = fDepots.ItemAt(depotIndex);
@@ -872,14 +872,14 @@ Model::_PopulateAllPackagesThread(bool fromCacheOnly)
depotIndex++; depotIndex++;
continue; continue;
} }
package = packages.ItemAt(packageIndex); package = packages.ItemAt(packageIndex);
packageIndex++; packageIndex++;
} }
if (package.Get() == NULL) if (package.Get() == NULL)
continue; continue;
//_PopulatePackageInfo(package, fromCacheOnly); //_PopulatePackageInfo(package, fromCacheOnly);
bulkPackageList.Add(package); bulkPackageList.Add(package);
if (bulkPackageList.CountItems() == 50) { if (bulkPackageList.CountItems() == 50) {
@@ -954,7 +954,7 @@ Model::_PopulatePackageInfos(PackageList& packages, bool fromCacheOnly,
{ {
if (fStopPopulatingAllPackages) if (fStopPopulatingAllPackages)
return; return;
// See if there are cached info files // See if there are cached info files
for (int i = packages.CountItems() - 1; i >= 0; i--) { for (int i = packages.CountItems() - 1; i >= 0; i--) {
if (fStopPopulatingAllPackages) if (fStopPopulatingAllPackages)
@@ -978,10 +978,10 @@ Model::_PopulatePackageInfos(PackageList& packages, bool fromCacheOnly,
} }
} }
} }
if (fromCacheOnly || packages.IsEmpty()) if (fromCacheOnly || packages.IsEmpty())
return; return;
// Retrieve info from web-app // Retrieve info from web-app
BMessage info; BMessage info;
@@ -1011,11 +1011,11 @@ Model::_PopulatePackageInfos(PackageList& packages, bool fromCacheOnly,
BMessage pkgInfo; BMessage pkgInfo;
if (pkgs.FindMessage(name, &pkgInfo) != B_OK) if (pkgs.FindMessage(name, &pkgInfo) != B_OK)
break; break;
BString pkgName; BString pkgName;
if (pkgInfo.FindString("name", &pkgName) != B_OK) if (pkgInfo.FindString("name", &pkgName) != B_OK)
continue; continue;
// Find the PackageInfoRef // Find the PackageInfoRef
bool found = false; bool found = false;
for (int i = 0; i < packages.CountItems(); i++) { for (int i = 0; i < packages.CountItems(); i++) {
@@ -1082,7 +1082,7 @@ Model::_PopulatePackageInfo(const PackageInfoRef& package, bool fromCacheOnly)
{ {
if (fromCacheOnly) if (fromCacheOnly)
return; return;
// Retrieve info from web-app // Retrieve info from web-app
BMessage info; BMessage info;
@@ -1104,7 +1104,7 @@ append_word_list(BString& words, const char* word)
if (words.Length() > 0) if (words.Length() > 0)
words << ", "; words << ", ";
words << word; words << word;
} }
void void
@@ -1173,7 +1173,7 @@ Model::_PopulatePackageInfo(const PackageInfoRef& package, const BMessage& data)
if (foundCategory) if (foundCategory)
append_word_list(foundInfo, "categories"); append_word_list(foundInfo, "categories");
} }
double derivedRating; double derivedRating;
if (data.FindDouble("derivedRating", &derivedRating) == B_OK) { if (data.FindDouble("derivedRating", &derivedRating) == B_OK) {
RatingSummary summary; RatingSummary summary;
@@ -1182,14 +1182,14 @@ Model::_PopulatePackageInfo(const PackageInfoRef& package, const BMessage& data)
append_word_list(foundInfo, "rating"); append_word_list(foundInfo, "rating");
} }
double prominenceOrdering; double prominenceOrdering;
if (data.FindDouble("prominenceOrdering", &prominenceOrdering) == B_OK) { if (data.FindDouble("prominenceOrdering", &prominenceOrdering) == B_OK) {
package->SetProminence(prominenceOrdering); package->SetProminence(prominenceOrdering);
append_word_list(foundInfo, "prominence"); append_word_list(foundInfo, "prominence");
} }
BMessage screenshots; BMessage screenshots;
if (data.FindMessage("pkgScreenshots", &screenshots) == B_OK) { if (data.FindMessage("pkgScreenshots", &screenshots) == B_OK) {
package->ClearScreenshotInfos(); package->ClearScreenshotInfos();
@@ -1198,7 +1198,7 @@ Model::_PopulatePackageInfo(const PackageInfoRef& package, const BMessage& data)
while (true) { while (true) {
BString name; BString name;
name << index++; name << index++;
BMessage screenshot; BMessage screenshot;
if (screenshots.FindMessage(name, &screenshot) != B_OK) if (screenshots.FindMessage(name, &screenshot) != B_OK)
break; break;
@@ -1219,7 +1219,7 @@ Model::_PopulatePackageInfo(const PackageInfoRef& package, const BMessage& data)
if (foundScreenshot) if (foundScreenshot)
append_word_list(foundInfo, "screenshots"); append_word_list(foundInfo, "screenshots");
} }
if (foundInfo.Length() > 0) { if (foundInfo.Length() > 0) {
printf("Populated package info for %s: %s\n", printf("Populated package info for %s: %s\n",
package->Name().String(), foundInfo.String()); package->Name().String(), foundInfo.String());
@@ -1346,11 +1346,11 @@ Model::_HasNativeIcon(const BMessage& message) const
while (true) { while (true) {
BString name; BString name;
name << index++; name << index++;
BMessage typeCodeInfo; BMessage typeCodeInfo;
if (pkgIcons.FindMessage(name, &typeCodeInfo) != B_OK) if (pkgIcons.FindMessage(name, &typeCodeInfo) != B_OK)
break; break;
BString mediaTypeCode; BString mediaTypeCode;
if (typeCodeInfo.FindString("mediaTypeCode", &mediaTypeCode) == B_OK if (typeCodeInfo.FindString("mediaTypeCode", &mediaTypeCode) == B_OK
&& mediaTypeCode == "application/x-vnd.haiku-icon") { && mediaTypeCode == "application/x-vnd.haiku-icon") {
+3 -3
View File
@@ -196,7 +196,7 @@ RatingSummary::operator==(const RatingSummary& other) const
if (ratingCountByStar[i] != other.ratingCountByStar[i]) if (ratingCountByStar[i] != other.ratingCountByStar[i])
return false; return false;
} }
return true; return true;
} }
@@ -818,7 +818,7 @@ PackageInfo::CalculateRatingSummary() const
{ {
if (fUserRatings.CountItems() == 0) if (fUserRatings.CountItems() == 0)
return fCachedRatingSummary; return fCachedRatingSummary;
RatingSummary summary; RatingSummary summary;
summary.ratingCount = fUserRatings.CountItems(); summary.ratingCount = fUserRatings.CountItems();
summary.averageRating = 0.0f; summary.averageRating = 0.0f;
@@ -1037,7 +1037,7 @@ void
DepotInfo::SyncPackages(const PackageList& otherPackages) DepotInfo::SyncPackages(const PackageList& otherPackages)
{ {
PackageList packages(fPackages); PackageList packages(fPackages);
for (int32 i = otherPackages.CountItems() - 1; i >= 0; i--) { for (int32 i = otherPackages.CountItems() - 1; i >= 0; i--) {
const PackageInfoRef& otherPackage = otherPackages.ItemAtFast(i); const PackageInfoRef& otherPackage = otherPackages.ItemAtFast(i);
bool found = false; bool found = false;
+1 -1
View File
@@ -306,7 +306,7 @@ public:
bool IsLocalFile() const; bool IsLocalFile() const;
const BString& FileName() const const BString& FileName() const
{ return fFileName; } { return fFileName; }
void ClearCategories(); void ClearCategories();
bool AddCategory(const CategoryRef& category); bool AddCategory(const CategoryRef& category);
const CategoryList& Categories() const const CategoryList& Categories() const
+20 -20
View File
@@ -187,24 +187,24 @@ public:
{ {
// printf("ConnectionOpened(%p)\n", caller); // printf("ConnectionOpened(%p)\n", caller);
} }
virtual void HostnameResolved(BUrlRequest* caller, const char* ip) virtual void HostnameResolved(BUrlRequest* caller, const char* ip)
{ {
// printf("HostnameResolved(%p): %s\n", caller, ip); // printf("HostnameResolved(%p): %s\n", caller, ip);
} }
virtual void ResponseStarted(BUrlRequest* caller) virtual void ResponseStarted(BUrlRequest* caller)
{ {
if (fDebug) if (fDebug)
printf("ResponseStarted(%p)\n", caller); printf("ResponseStarted(%p)\n", caller);
} }
virtual void HeadersReceived(BUrlRequest* caller) virtual void HeadersReceived(BUrlRequest* caller)
{ {
if (fDebug) if (fDebug)
printf("HeadersReceived(%p)\n", caller); printf("HeadersReceived(%p)\n", caller);
} }
virtual void DataReceived(BUrlRequest* caller, const char* data, virtual void DataReceived(BUrlRequest* caller, const char* data,
off_t position, ssize_t size) off_t position, ssize_t size)
{ {
@@ -216,27 +216,27 @@ public:
if (fDownloadIO != NULL) if (fDownloadIO != NULL)
fDownloadIO->Write(data, size); fDownloadIO->Write(data, size);
} }
virtual void DownloadProgress(BUrlRequest* caller, ssize_t bytesReceived, virtual void DownloadProgress(BUrlRequest* caller, ssize_t bytesReceived,
ssize_t bytesTotal) ssize_t bytesTotal)
{ {
// printf("DownloadProgress(%p): %ld/%ld\n", caller, bytesReceived, // printf("DownloadProgress(%p): %ld/%ld\n", caller, bytesReceived,
// bytesTotal); // bytesTotal);
} }
virtual void UploadProgress(BUrlRequest* caller, ssize_t bytesSent, virtual void UploadProgress(BUrlRequest* caller, ssize_t bytesSent,
ssize_t bytesTotal) ssize_t bytesTotal)
{ {
if (fDebug) if (fDebug)
printf("UploadProgress(%p): %ld/%ld\n", caller, bytesSent, bytesTotal); printf("UploadProgress(%p): %ld/%ld\n", caller, bytesSent, bytesTotal);
} }
virtual void RequestCompleted(BUrlRequest* caller, bool success) virtual void RequestCompleted(BUrlRequest* caller, bool success)
{ {
if (fDebug) if (fDebug)
printf("RequestCompleted(%p): %d\n", caller, success); printf("RequestCompleted(%p): %d\n", caller, success);
} }
virtual void DebugMessage(BUrlRequest* caller, virtual void DebugMessage(BUrlRequest* caller,
BUrlProtocolDebugMessage type, const char* text) BUrlProtocolDebugMessage type, const char* text)
{ {
@@ -295,11 +295,11 @@ WebAppInterface::operator=(const WebAppInterface& other)
{ {
if (this == &other) if (this == &other)
return *this; return *this;
fUsername = other.fUsername; fUsername = other.fUsername;
fPassword = other.fPassword; fPassword = other.fPassword;
fLanguage = other.fLanguage; fLanguage = other.fLanguage;
return *this; return *this;
} }
@@ -380,12 +380,12 @@ WebAppInterface::RetrievePackageIcon(const BString& packageName,
{ {
BString urlString = "https://depot.haiku-os.org/pkgicon/"; BString urlString = "https://depot.haiku-os.org/pkgicon/";
urlString << packageName << ".hvif"; urlString << packageName << ".hvif";
BUrl url(urlString); BUrl url(urlString);
ProtocolListener listener; ProtocolListener listener;
listener.SetDownloadIO(stream); listener.SetDownloadIO(stream);
BHttpRequest request(url, true, "HTTP", &listener); BHttpRequest request(url, true, "HTTP", &listener);
request.SetMethod(B_HTTP_GET); request.SetMethod(B_HTTP_GET);
@@ -396,7 +396,7 @@ WebAppInterface::RetrievePackageIcon(const BString& packageName,
request.Result()); request.Result());
int32 statusCode = result.StatusCode(); int32 statusCode = result.StatusCode();
if (statusCode == 200) if (statusCode == 200)
return B_OK; return B_OK;
@@ -523,15 +523,15 @@ WebAppInterface::RetrieveScreenshot(const BString& code,
BString urlString = "https://depot.haiku-os.org/pkgscreenshot/"; BString urlString = "https://depot.haiku-os.org/pkgscreenshot/";
urlString << code << ".png" urlString << code << ".png"
<< "?tw=" << width << "&th=" << height; << "?tw=" << width << "&th=" << height;
BUrl url(urlString); BUrl url(urlString);
ProtocolListener listener; ProtocolListener listener;
listener.SetDownloadIO(stream); listener.SetDownloadIO(stream);
BHttpHeaders headers; BHttpHeaders headers;
headers.AddHeader("User-Agent", "X-HDS-Client"); headers.AddHeader("User-Agent", "X-HDS-Client");
BHttpRequest request(url, true, "HTTP", &listener); BHttpRequest request(url, true, "HTTP", &listener);
request.SetMethod(B_HTTP_GET); request.SetMethod(B_HTTP_GET);
request.SetHeaders(headers); request.SetHeaders(headers);
@@ -543,7 +543,7 @@ WebAppInterface::RetrieveScreenshot(const BString& code,
request.Result()); request.Result());
int32 statusCode = result.StatusCode(); int32 statusCode = result.StatusCode();
if (statusCode == 200) if (statusCode == 200)
return B_OK; return B_OK;
@@ -588,7 +588,7 @@ WebAppInterface::CreateUser(const BString& nickName,
if (!email.IsEmpty()) if (!email.IsEmpty())
builder.AddValue("email", email); builder.AddValue("email", email);
builder.AddValue("captchaToken", captchaToken) builder.AddValue("captchaToken", captchaToken)
.AddValue("captchaResponse", captchaResponse) .AddValue("captchaResponse", captchaResponse)
.AddValue("naturalLanguageCode", languageCode) .AddValue("naturalLanguageCode", languageCode)
@@ -49,7 +49,7 @@ public:
{ return fFont; } { return fFont; }
CharacterStyleDataRef SetAscent(float ascent); CharacterStyleDataRef SetAscent(float ascent);
// Returns the ascent of the configured font, unless the ascent // Returns the ascent of the configured font, unless the ascent
// has been overridden by a fixed value with SetAscent(). // has been overridden by a fixed value with SetAscent().
float Ascent() const; float Ascent() const;
+4 -4
View File
@@ -286,12 +286,12 @@ Paragraph::SubParagraph(int32 start, int32 length) const
{ {
if (start < 0) if (start < 0)
start = 0; start = 0;
if (start == 0 && length == Length()) if (start == 0 && length == Length())
return *this; return *this;
Paragraph result(fStyle); Paragraph result(fStyle);
int32 count = fTextSpans.CountItems(); int32 count = fTextSpans.CountItems();
for (int32 i = 0; i < count; i++) { for (int32 i = 0; i < count; i++) {
const TextSpan& span = fTextSpans.ItemAtFast(i); const TextSpan& span = fTextSpans.ItemAtFast(i);
@@ -312,7 +312,7 @@ Paragraph::SubParagraph(int32 start, int32 length) const
result.Append(span); result.Append(span);
else else
result.Append(span.SubSpan(start, copyLength)); result.Append(span.SubSpan(start, copyLength));
length -= copyLength; length -= copyLength;
if (length == 0) if (length == 0)
break; break;
@@ -301,7 +301,7 @@ ParagraphLayout::LineIndexForOffset(int32 textOffset)
if (textOffset < 0) if (textOffset < 0)
textOffset = 0; textOffset = 0;
const GlyphInfo& glyph = fGlyphInfos.ItemAtFast(textOffset); const GlyphInfo& glyph = fGlyphInfos.ItemAtFast(textOffset);
return glyph.lineIndex; return glyph.lineIndex;
} }
@@ -396,7 +396,7 @@ ParagraphLayout::GetTextBounds(int32 textOffset, float& x1, float& y1,
if (textOffset < 0) if (textOffset < 0)
textOffset = 0; textOffset = 0;
const GlyphInfo& glyph = fGlyphInfos.ItemAtFast(textOffset); const GlyphInfo& glyph = fGlyphInfos.ItemAtFast(textOffset);
const LineInfo& line = fLineInfos.ItemAt(glyph.lineIndex); const LineInfo& line = fLineInfos.ItemAt(glyph.lineIndex);
+13 -13
View File
@@ -133,7 +133,7 @@ TextDocument::Insert(int32 textOffset, const BString& text,
chunkEnd++; chunkEnd++;
else else
chunkEnd = length; chunkEnd = length;
BString chunk; BString chunk;
text.CopyCharsInto(chunk, chunkStart, chunkEnd - chunkStart); text.CopyCharsInto(chunk, chunkStart, chunkEnd - chunkStart);
TextSpan span(chunk, characterStyle); TextSpan span(chunk, characterStyle);
@@ -171,7 +171,7 @@ TextDocument::Insert(int32 textOffset, const BString& text,
if (!fParagraphs.Replace(index, paragraph)) if (!fParagraphs.Replace(index, paragraph))
return B_NO_MEMORY; return B_NO_MEMORY;
} }
return B_OK; return B_OK;
} }
@@ -214,7 +214,7 @@ TextDocument::Remove(int32 textOffset, int32 length)
&& index + 1 < fParagraphs.CountItems()) { && index + 1 < fParagraphs.CountItems()) {
// Line break between paragraphs got removed. Shift the next // Line break between paragraphs got removed. Shift the next
// paragraph's text spans into the resulting one. // paragraph's text spans into the resulting one.
const TextSpanList& textSpans = ParagraphAt(index + 1).TextSpans(); const TextSpanList& textSpans = ParagraphAt(index + 1).TextSpans();
int32 spanCount = textSpans.CountItems(); int32 spanCount = textSpans.CountItems();
for (int32 i = 0; i < spanCount; i++) { for (int32 i = 0; i < spanCount; i++) {
@@ -225,7 +225,7 @@ TextDocument::Remove(int32 textOffset, int32 length)
} }
textOffset = 0; textOffset = 0;
while (length > 0 && index + 1 < fParagraphs.CountItems()) { while (length > 0 && index + 1 < fParagraphs.CountItems()) {
const Paragraph& paragraph = ParagraphAt(index + 1); const Paragraph& paragraph = ParagraphAt(index + 1);
paragraphLength = paragraph.Length(); paragraphLength = paragraph.Length();
@@ -251,7 +251,7 @@ TextDocument::Remove(int32 textOffset, int32 length)
const TextSpan& span = textSpans.ItemAtFast(i); const TextSpan& span = textSpans.ItemAtFast(i);
resultParagraph.Append(span); resultParagraph.Append(span);
} }
break; break;
} }
} }
@@ -288,7 +288,7 @@ TextDocument::Replace(int32 textOffset, int32 length, const BString& text,
status_t ret = Remove(textOffset, length); status_t ret = Remove(textOffset, length);
if (ret != B_OK) if (ret != B_OK)
return ret; return ret;
return Insert(textOffset, text, characterStyle, paragraphStyle); return Insert(textOffset, text, characterStyle, paragraphStyle);
} }
@@ -405,9 +405,9 @@ TextDocument::Text(int32 start, int32 length) const
{ {
if (start < 0) if (start < 0)
start = 0; start = 0;
BString text; BString text;
int32 count = fParagraphs.CountItems(); int32 count = fParagraphs.CountItems();
for (int32 i = 0; i < count; i++) { for (int32 i = 0; i < count; i++) {
const Paragraph& paragraph = fParagraphs.ItemAtFast(i); const Paragraph& paragraph = fParagraphs.ItemAtFast(i);
@@ -423,9 +423,9 @@ TextDocument::Text(int32 start, int32 length) const
// Remaining paragraph length after start // Remaining paragraph length after start
paragraphLength -= start; paragraphLength -= start;
int32 copyLength = std::min(paragraphLength, length); int32 copyLength = std::min(paragraphLength, length);
text << paragraph.Text(start, copyLength); text << paragraph.Text(start, copyLength);
length -= copyLength; length -= copyLength;
if (length == 0) if (length == 0)
break; break;
@@ -443,10 +443,10 @@ TextDocument::SubDocument(int32 start, int32 length) const
{ {
TextDocumentRef result(new(std::nothrow) TextDocument( TextDocumentRef result(new(std::nothrow) TextDocument(
fDefaultCharacterStyle, fEmptyLastParagraph.Style()), true); fDefaultCharacterStyle, fEmptyLastParagraph.Style()), true);
if (result.Get() == NULL) if (result.Get() == NULL)
return result; return result;
if (start < 0) if (start < 0)
start = 0; start = 0;
@@ -465,7 +465,7 @@ TextDocument::SubDocument(int32 start, int32 length) const
// Remaining paragraph length after start // Remaining paragraph length after start
paragraphLength -= start; paragraphLength -= start;
int32 copyLength = std::min(paragraphLength, length); int32 copyLength = std::min(paragraphLength, length);
result->Append(paragraph.SubParagraph(start, copyLength)); result->Append(paragraph.SubParagraph(start, copyLength));
length -= copyLength; length -= copyLength;
@@ -97,7 +97,7 @@ TextDocumentLayout::InvalidateParagraphs(int32 start, int32 count)
start); start);
info.layout->SetParagraph(paragraph); info.layout->SetParagraph(paragraph);
} }
start++; start++;
count--; count--;
} }
@@ -161,11 +161,11 @@ TextDocumentLayout::LineIndexForOffset(int32 textOffset)
for (int32 i = 0; i < index; i++) { for (int32 i = 0; i < index; i++) {
lineIndex += fParagraphLayouts.ItemAtFast(i).layout->CountLines(); lineIndex += fParagraphLayouts.ItemAtFast(i).layout->CountLines();
} }
const ParagraphLayoutInfo& info = fParagraphLayouts.ItemAtFast(index); const ParagraphLayoutInfo& info = fParagraphLayouts.ItemAtFast(index);
return lineIndex + info.layout->LineIndexForOffset(textOffset); return lineIndex + info.layout->LineIndexForOffset(textOffset);
} }
return 0; return 0;
} }
@@ -275,7 +275,7 @@ TextDocumentLayout::TextOffsetAt(float x, float y, bool& rightOfCenter)
textOffset += info.layout->TextOffsetAt(x, y - info.y, rightOfCenter); textOffset += info.layout->TextOffsetAt(x, y - info.y, rightOfCenter);
break; break;
} }
return textOffset; return textOffset;
} }
@@ -342,16 +342,16 @@ TextDocumentLayout::_ParagraphLayoutIndexForOffset(int32& textOffset)
int32 paragraphs = fParagraphLayouts.CountItems(); int32 paragraphs = fParagraphLayouts.CountItems();
for (int32 i = 0; i < paragraphs - 1; i++) { for (int32 i = 0; i < paragraphs - 1; i++) {
const ParagraphLayoutInfo& info = fParagraphLayouts.ItemAtFast(i); const ParagraphLayoutInfo& info = fParagraphLayouts.ItemAtFast(i);
int32 length = info.layout->CountGlyphs(); int32 length = info.layout->CountGlyphs();
if (textOffset >= length) { if (textOffset >= length) {
textOffset -= length; textOffset -= length;
continue; continue;
} }
return i; return i;
} }
if (paragraphs > 0) { if (paragraphs > 0) {
const ParagraphLayoutInfo& info = fParagraphLayouts.LastItem(); const ParagraphLayoutInfo& info = fParagraphLayouts.LastItem();
@@ -361,7 +361,7 @@ TextDocumentLayout::_ParagraphLayoutIndexForOffset(int32& textOffset)
if (textOffset <= length) if (textOffset <= length)
return paragraphs - 1; return paragraphs - 1;
} }
return -1; return -1;
} }
@@ -382,7 +382,7 @@ TextDocumentLayout::_ParagraphLayoutIndexForLineIndex(int32& lineIndex,
paragraphOffset += info.layout->CountGlyphs(); paragraphOffset += info.layout->CountGlyphs();
continue; continue;
} }
return i; return i;
} }
@@ -30,7 +30,7 @@ TextDocumentView::TextDocumentView(const char* name)
fMouseDown(false) fMouseDown(false)
{ {
fTextDocumentLayout.SetWidth(_TextLayoutWidth(Bounds().Width())); fTextDocumentLayout.SetWidth(_TextLayoutWidth(Bounds().Width()));
// Set default TextEditor // Set default TextEditor
SetTextEditor(TextEditorRef(new(std::nothrow) TextEditor(), true)); SetTextEditor(TextEditorRef(new(std::nothrow) TextEditor(), true));
@@ -142,10 +142,10 @@ TextDocumentView::MouseDown(BPoint where)
int32 modifiers = 0; int32 modifiers = 0;
if (Window() != NULL && Window()->CurrentMessage() != NULL) if (Window() != NULL && Window()->CurrentMessage() != NULL)
Window()->CurrentMessage()->FindInt32("modifiers", &modifiers); Window()->CurrentMessage()->FindInt32("modifiers", &modifiers);
fMouseDown = true; fMouseDown = true;
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
bool extendSelection = (modifiers & B_SHIFT_KEY) != 0; bool extendSelection = (modifiers & B_SHIFT_KEY) != 0;
SetCaret(where, extendSelection); SetCaret(where, extendSelection);
} }
@@ -184,7 +184,7 @@ TextDocumentView::KeyDown(const char* bytes, int32 numBytes)
event.length = numBytes; event.length = numBytes;
event.key = 0; event.key = 0;
event.modifiers = modifiers(); event.modifiers = modifiers();
if (Window() != NULL && Window()->CurrentMessage() != NULL) { if (Window() != NULL && Window()->CurrentMessage() != NULL) {
BMessage* message = Window()->CurrentMessage(); BMessage* message = Window()->CurrentMessage();
message->FindInt32("raw_char", &event.key); message->FindInt32("raw_char", &event.key);
@@ -391,10 +391,10 @@ TextDocumentView::Copy(BClipboard* clipboard)
// Nothing to copy, don't clear clipboard contents for now reason. // Nothing to copy, don't clear clipboard contents for now reason.
return; return;
} }
if (clipboard == NULL || !clipboard->Lock()) if (clipboard == NULL || !clipboard->Lock())
return; return;
clipboard->Clear(); clipboard->Clear();
BMessage* clip = clipboard->Data(); BMessage* clip = clipboard->Data();
@@ -402,13 +402,13 @@ TextDocumentView::Copy(BClipboard* clipboard)
int32 start; int32 start;
int32 end; int32 end;
GetSelection(start, end); GetSelection(start, end);
BString text = fTextDocument->Text(start, end - start); BString text = fTextDocument->Text(start, end - start);
clip->AddData("text/plain", B_MIME_TYPE, text.String(), clip->AddData("text/plain", B_MIME_TYPE, text.String(),
text.Length()); text.Length());
// TODO: Support for "application/x-vnd.Be-text_run_array" // TODO: Support for "application/x-vnd.Be-text_run_array"
clipboard->Commit(); clipboard->Commit();
} }
@@ -585,7 +585,7 @@ TextDocumentView::_GetSelectionShape(BShape& shape, int32 start, int32 end)
} else { } else {
// Selection over multiple lines // Selection over multiple lines
float width = ceilf(fTextDocumentLayout.Width()); float width = ceilf(fTextDocumentLayout.Width());
shape.MoveTo(BPoint(startX1, startY1)); shape.MoveTo(BPoint(startX1, startY1));
shape.LineTo(BPoint(width, startY1)); shape.LineTo(BPoint(width, startY1));
shape.LineTo(BPoint(width, endY1)); shape.LineTo(BPoint(width, endY1));
+6 -6
View File
@@ -239,11 +239,11 @@ TextEditor::KeyDown(KeyEvent event)
if (event.bytes != NULL && event.length > 0) { if (event.bytes != NULL && event.length > 0) {
// Handle null-termintating the string // Handle null-termintating the string
BString text(event.bytes, event.length); BString text(event.bytes, event.length);
// Remove selection, if any // Remove selection, if any
if (HasSelection()) if (HasSelection())
Remove(SelectionStart(), SelectionLength()); Remove(SelectionStart(), SelectionLength());
Insert(fSelection.Caret(), text); Insert(fSelection.Caret(), text);
} }
break; break;
@@ -262,9 +262,9 @@ TextEditor::Insert(int32 offset, const BString& string)
if (ret == B_OK) { if (ret == B_OK) {
// TODO: Via listener, and only affected paragraphs // TODO: Via listener, and only affected paragraphs
fLayout->Invalidate(); fLayout->Invalidate();
_SetCaretOffset(offset + string.CountChars(), true, false, true); _SetCaretOffset(offset + string.CountChars(), true, false, true);
fDocument->PrintToStream(); fDocument->PrintToStream();
} }
@@ -283,7 +283,7 @@ TextEditor::Remove(int32 offset, int32 length)
if (ret == B_OK) { if (ret == B_OK) {
// TODO: Via listener, and only affected paragraphs // TODO: Via listener, and only affected paragraphs
fLayout->Invalidate(); fLayout->Invalidate();
_SetCaretOffset(offset, true, false, true); _SetCaretOffset(offset, true, false, true);
fDocument->PrintToStream(); fDocument->PrintToStream();
@@ -437,7 +437,7 @@ TextEditor::_SetSelection(int32 caret, int32 anchor, bool updateAnchor,
{ {
if (fLayout.Get() == NULL) if (fLayout.Get() == NULL)
return; return;
if (caret == fSelection.Caret() && anchor == fSelection.Anchor()) if (caret == fSelection.Caret() && anchor == fSelection.Anchor())
return; return;
+5 -5
View File
@@ -69,10 +69,10 @@ App::ReadyToRun()
{ {
if (fWindowCount > 0) if (fWindowCount > 0)
return; return;
BMessage settings; BMessage settings;
_LoadSettings(settings); _LoadSettings(settings);
fMainWindow = new MainWindow(_GetNextWindowFrame(false), settings); fMainWindow = new MainWindow(_GetNextWindowFrame(false), settings);
_ShowWindow(fMainWindow); _ShowWindow(fMainWindow);
} }
@@ -152,7 +152,7 @@ App::_Open(const BEntry& entry)
fprintf(stderr, "Could not allocate PackageInfo\n"); fprintf(stderr, "Could not allocate PackageInfo\n");
return; return;
} }
package->SetLocalFilePath(path.Path()); package->SetLocalFilePath(path.Path());
BMessage settings; BMessage settings;
@@ -258,7 +258,7 @@ App::_CheckPackageDaemonRuns()
if (!_LaunchPackageDaemon()) if (!_LaunchPackageDaemon())
break; break;
} }
} }
@@ -270,7 +270,7 @@ App::_LaunchPackageDaemon()
BString errorMessage BString errorMessage
= B_TRANSLATE("Starting the package daemon failed:\n\n%Error%"); = B_TRANSLATE("Starting the package daemon failed:\n\n%Error%");
errorMessage.ReplaceAll("%Error%", strerror(ret)); errorMessage.ReplaceAll("%Error%", strerror(ret));
BAlert* alert = new BAlert("package_daemon_problem", BAlert* alert = new BAlert("package_daemon_problem",
errorMessage, errorMessage,
B_TRANSLATE("Quit HaikuDepot"), B_TRANSLATE("Quit HaikuDepot"),
@@ -46,7 +46,7 @@ public:
{ {
SetViewColor(255, 255, 255); SetViewColor(255, 255, 255);
SetEventMask(B_POINTER_EVENTS); SetEventMask(B_POINTER_EVENTS);
fIconView = new BitmapView("package icon view"); fIconView = new BitmapView("package icon view");
fInstalledIconView = new BitmapView("installed icon view"); fInstalledIconView = new BitmapView("installed icon view");
fTitleView = new BStringView("package title view", ""); fTitleView = new BStringView("package title view", "");
@@ -131,14 +131,14 @@ public:
break; break;
} }
} }
virtual void MouseDown(BPoint where) virtual void MouseDown(BPoint where)
{ {
BRect bounds = Bounds(); BRect bounds = Bounds();
BRect parentBounds = Parent()->Bounds(); BRect parentBounds = Parent()->Bounds();
ConvertFromParent(&parentBounds); ConvertFromParent(&parentBounds);
bounds = bounds & parentBounds; bounds = bounds & parentBounds;
if (bounds.Contains(where) && Window()->IsActive()) { if (bounds.Contains(where) && Window()->IsActive()) {
BMessage message(MSG_PACKAGE_SELECTED); BMessage message(MSG_PACKAGE_SELECTED);
message.AddString("name", PackageName()); message.AddString("name", PackageName());
@@ -227,13 +227,13 @@ public:
if (fSelected == selected) if (fSelected == selected)
return; return;
fSelected = selected; fSelected = selected;
rgb_color bgColor; rgb_color bgColor;
if (fSelected) if (fSelected)
bgColor = ui_color(B_LIST_SELECTED_BACKGROUND_COLOR); bgColor = ui_color(B_LIST_SELECTED_BACKGROUND_COLOR);
else else
bgColor = (rgb_color){ 255, 255, 255, 255 }; bgColor = (rgb_color){ 255, 255, 255, 255 };
List<BView*, true> views; List<BView*, true> views;
views.Add(this); views.Add(this);
@@ -245,10 +245,10 @@ public:
views.Add(fRatingView); views.Add(fRatingView);
views.Add(fAvgRating); views.Add(fAvgRating);
views.Add(fVoteInfo); views.Add(fVoteInfo);
for (int32 i = 0; i < views.CountItems(); i++) { for (int32 i = 0; i < views.CountItems(); i++) {
BView* view = views.ItemAtFast(i); BView* view = views.ItemAtFast(i);
view->SetViewColor(bgColor); view->SetViewColor(bgColor);
view->SetLowColor(bgColor); view->SetLowColor(bgColor);
view->Invalidate(); view->Invalidate();
@@ -376,7 +376,7 @@ FeaturedPackagesView::SelectPackage(const PackageInfoRef& package)
BString selectedName; BString selectedName;
if (package.Get() != NULL) if (package.Get() != NULL)
selectedName = package->Name(); selectedName = package->Name();
for (int32 i = 0; BLayoutItem* item = fPackageListLayout->ItemAt(i); i++) { for (int32 i = 0; BLayoutItem* item = fPackageListLayout->ItemAt(i); i++) {
PackageView* view = dynamic_cast<PackageView*>(item->View()); PackageView* view = dynamic_cast<PackageView*>(item->View());
if (view == NULL) if (view == NULL)
@@ -23,7 +23,7 @@ public:
void AddPackage(const PackageInfoRef& package); void AddPackage(const PackageInfoRef& package);
void RemovePackage(const PackageInfoRef& package); void RemovePackage(const PackageInfoRef& package);
void Clear(); void Clear();
void SelectPackage(const PackageInfoRef& package); void SelectPackage(const PackageInfoRef& package);
static void CleanupIcons(); static void CleanupIcons();
+3 -3
View File
@@ -138,7 +138,7 @@ FilterView::AdoptModel(const Model& model)
message->AddString("name", depot.Name()); message->AddString("name", depot.Name());
BMenuItem* item = new BMenuItem(depot.Name(), message); BMenuItem* item = new BMenuItem(depot.Name(), message);
repositoryMenu->AddItem(item); repositoryMenu->AddItem(item);
if (depot.Name() == model.Depot()) { if (depot.Name() == model.Depot()) {
item->SetMarked(true); item->SetMarked(true);
foundSelectedDepot = true; foundSelectedDepot = true;
@@ -146,7 +146,7 @@ FilterView::AdoptModel(const Model& model)
} }
if (!foundSelectedDepot) if (!foundSelectedDepot)
repositoryMenu->ItemAt(0)->SetMarked(true); repositoryMenu->ItemAt(0)->SetMarked(true);
// Adopt categories // Adopt categories
BMenu* showMenu = fShowField->Menu(); BMenu* showMenu = fShowField->Menu();
@@ -174,6 +174,6 @@ FilterView::AdoptModel(const Model& model)
} }
} }
if (!foundSelectedCategory) if (!foundSelectedCategory)
showMenu->ItemAt(0)->SetMarked(true); showMenu->ItemAt(0)->SetMarked(true);
} }
+9 -9
View File
@@ -101,7 +101,7 @@ public:
fMessenger(messenger) fMessenger(messenger)
{ {
} }
virtual void AuthorizationChanged() virtual void AuthorizationChanged()
{ {
if (fMessenger.IsValid()) if (fMessenger.IsValid())
@@ -315,7 +315,7 @@ MainWindow::MessageReceived(BMessage* message)
case B_PACKAGE_UPDATE: case B_PACKAGE_UPDATE:
// TODO: We should do a more selective update depending on the // TODO: We should do a more selective update depending on the
// "event", "location", and "change count" fields! // "event", "location", and "change count" fields!
_StartRefreshWorker(false); _StartRefreshWorker(false);
break; break;
@@ -514,9 +514,9 @@ MainWindow::StoreSettings(BMessage& settings) const
BMessage columnSettings; BMessage columnSettings;
fPackageListView->SaveState(&columnSettings); fPackageListView->SaveState(&columnSettings);
settings.AddMessage("column settings", &columnSettings); settings.AddMessage("column settings", &columnSettings);
settings.AddBool("show featured packages", settings.AddBool("show featured packages",
fModel.ShowFeaturedPackages()); fModel.ShowFeaturedPackages());
settings.AddBool("show available packages", settings.AddBool("show available packages",
@@ -660,7 +660,7 @@ MainWindow::_AdoptModel()
fPackageListView->Clear(); fPackageListView->Clear();
for (int32 i = 0; i < fVisiblePackages.CountItems(); i++) { for (int32 i = 0; i < fVisiblePackages.CountItems(); i++) {
BAutolock locker(fModel.Lock()); BAutolock locker(fModel.Lock());
const PackageInfoRef& package = fVisiblePackages.ItemAtFast(i); const PackageInfoRef& package = fVisiblePackages.ItemAtFast(i);
fPackageListView->AddPackage(package); fPackageListView->AddPackage(package);
@@ -697,7 +697,7 @@ MainWindow::_AdoptPackage(const PackageInfoRef& package)
{ {
BAutolock locker(fModel.Lock()); BAutolock locker(fModel.Lock());
fPackageInfoView->SetPackage(package); fPackageInfoView->SetPackage(package);
if (fFeaturedPackagesView != NULL) if (fFeaturedPackagesView != NULL)
fFeaturedPackagesView->SelectPackage(package); fFeaturedPackagesView->SelectPackage(package);
if (fPackageListView != NULL) if (fPackageListView != NULL)
@@ -890,7 +890,7 @@ MainWindow::_RefreshPackageList(bool force)
fModel.StopPopulatingAllPackages(); fModel.StopPopulatingAllPackages();
BAutolock lock(fModel.Lock()); BAutolock lock(fModel.Lock());
if (force) if (force)
fModel.Clear(); fModel.Clear();
@@ -1160,13 +1160,13 @@ MainWindow::_RatePackage()
if (alert == NULL) if (alert == NULL)
return; return;
int32 choice = alert->Go(); int32 choice = alert->Go();
if (choice == 1) if (choice == 1)
_OpenLoginWindow(BMessage(MSG_RATE_PACKAGE)); _OpenLoginWindow(BMessage(MSG_RATE_PACKAGE));
return; return;
} }
// TODO: Allow only one RatePackageWindow // TODO: Allow only one RatePackageWindow
// TODO: Mechanism for remembering the window frame // TODO: Mechanism for remembering the window frame
RatePackageWindow* window = new RatePackageWindow(this, RatePackageWindow* window = new RatePackageWindow(this,
@@ -33,7 +33,7 @@ MessagePackageListener::PackageChanged(const PackageInfoEvent& event)
{ {
if ((event.Changes() & fChangesMask) == 0) if ((event.Changes() & fChangesMask) == 0)
return; return;
BMessenger messenger(fTarget); BMessenger messenger(fTarget);
if (!messenger.IsValid()) if (!messenger.IsValid())
return; return;
@@ -87,7 +87,7 @@ public:
fPath.Append("/"); fPath.Append("/");
fPath.Append(entry->Name()); fPath.Append(entry->Name());
} }
inline const BString& EntryPath() const inline const BString& EntryPath() const
{ {
return fPath; return fPath;
@@ -213,11 +213,11 @@ public:
{ {
return B_OK; return B_OK;
} }
virtual void HandleErrorOccurred() virtual void HandleErrorOccurred()
{ {
} }
private: private:
BOutlineListView* fListView; BOutlineListView* fListView;
@@ -241,12 +241,12 @@ PackageContentsView::PackageContentsView(const char* name)
BView("package_contents_view", B_WILL_DRAW), BView("package_contents_view", B_WILL_DRAW),
fPackageLock("package contents populator lock") fPackageLock("package contents populator lock")
{ {
fContentListView = new BOutlineListView("content list view", fContentListView = new BOutlineListView("content list view",
B_SINGLE_SELECTION_LIST); B_SINGLE_SELECTION_LIST);
BScrollView* scrollView = new CustomScrollView("contents scroll view", BScrollView* scrollView = new CustomScrollView("contents scroll view",
fContentListView); fContentListView);
BLayoutBuilder::Group<>(this) BLayoutBuilder::Group<>(this)
.Add(scrollView, 1.0f) .Add(scrollView, 1.0f)
.SetInsets(0.0f, -1.0f, -1.0f, -1.0f) .SetInsets(0.0f, -1.0f, -1.0f, -1.0f)
@@ -299,7 +299,7 @@ PackageContentsView::SetPackage(const PackageInfoRef& package)
} }
void void
PackageContentsView::Clear() PackageContentsView::Clear()
{ {
{ {
+11 -11
View File
@@ -215,7 +215,7 @@ public:
const BMessage* dragMessage) const BMessage* dragMessage)
{ {
BButton::MouseMoved(point, transit, dragMessage); BButton::MouseMoved(point, transit, dragMessage);
if (fTransitMessage != NULL && transit == B_EXITED_VIEW) if (fTransitMessage != NULL && transit == B_EXITED_VIEW)
Invoke(fTransitMessage); Invoke(fTransitMessage);
} }
@@ -251,7 +251,7 @@ public:
const BMessage* dragMessage) const BMessage* dragMessage)
{ {
RatingView::MouseMoved(point, transit, dragMessage); RatingView::MouseMoved(point, transit, dragMessage);
if (fTransitMessage != NULL && transit == B_ENTERED_VIEW) if (fTransitMessage != NULL && transit == B_ENTERED_VIEW)
Invoke(fTransitMessage); Invoke(fTransitMessage);
} }
@@ -564,12 +564,12 @@ public:
{ {
if (fButtons.CountItems() > 0) if (fButtons.CountItems() > 0)
Clear(); Clear();
if (fStatusBar == NULL) { if (fStatusBar == NULL) {
fStatusLabel = new BStringView("progress label", fStatusLabel = new BStringView("progress label",
B_TRANSLATE("Downloading:")); B_TRANSLATE("Downloading:"));
fLayout->AddView(fStatusLabel); fLayout->AddView(fStatusLabel);
fStatusBar = new BStatusBar("progress"); fStatusBar = new BStatusBar("progress");
fStatusBar->SetMaxValue(100.0); fStatusBar->SetMaxValue(100.0);
fStatusBar->SetExplicitMinSize( fStatusBar->SetExplicitMinSize(
@@ -577,7 +577,7 @@ public:
fLayout->AddView(fStatusBar); fLayout->AddView(fStatusBar);
} }
fStatusBar->SetTo(package.DownloadProgress() * 100.0); fStatusBar->SetTo(package.DownloadProgress() * 100.0);
} }
@@ -769,7 +769,7 @@ public:
Window()->PostMessage(message, Window()); Window()->PostMessage(message, Window());
break; break;
} }
case MSG_EMAIL_PUBLISHER: case MSG_EMAIL_PUBLISHER:
{ {
// TODO: Implement. If memory serves, there is a // TODO: Implement. If memory serves, there is a
@@ -1068,7 +1068,7 @@ public:
.Add(scrollView, 1.0f) .Add(scrollView, 1.0f)
.SetInsets(B_USE_DEFAULT_SPACING, -1.0f, -1.0f, -1.0f) .SetInsets(B_USE_DEFAULT_SPACING, -1.0f, -1.0f, -1.0f)
; ;
_InitPreferredLanguages(); _InitPreferredLanguages();
} }
@@ -1144,7 +1144,7 @@ private:
return; return;
BMessage preferredLanguages; BMessage preferredLanguages;
if (localeRoster->GetPreferredLanguages(&preferredLanguages) != B_OK) if (localeRoster->GetPreferredLanguages(&preferredLanguages) != B_OK)
return; return;
BString language; BString language;
@@ -1280,7 +1280,7 @@ public:
AddTab(fUserRatingsView); AddTab(fUserRatingsView);
AddTab(fChangelogView); AddTab(fChangelogView);
AddTab(fContentsView); AddTab(fContentsView);
TabAt(0)->SetLabel(B_TRANSLATE("About")); TabAt(0)->SetLabel(B_TRANSLATE("About"));
TabAt(1)->SetLabel(B_TRANSLATE("Ratings")); TabAt(1)->SetLabel(B_TRANSLATE("Ratings"));
TabAt(2)->SetLabel(B_TRANSLATE("Changelog")); TabAt(2)->SetLabel(B_TRANSLATE("Changelog"));
@@ -1334,7 +1334,7 @@ PackageInfoView::PackageInfoView(BLocker* modelLock,
{ {
fCardLayout = new BCardLayout(); fCardLayout = new BCardLayout();
SetLayout(fCardLayout); SetLayout(fCardLayout);
BGroupView* noPackageCard = new BGroupView("no package card", B_VERTICAL); BGroupView* noPackageCard = new BGroupView("no package card", B_VERTICAL);
AddChild(noPackageCard); AddChild(noPackageCard);
@@ -1459,7 +1459,7 @@ PackageInfoView::SetPackage(const PackageInfoRef& packageRef)
// same package as before the refresh. // same package as before the refresh.
switchToDefaultTab = false; switchToDefaultTab = false;
} }
const PackageInfo& package = *packageRef.Get(); const PackageInfo& package = *packageRef.Get();
fTitleView->SetPackage(package); fTitleView->SetPackage(package);
+14 -14
View File
@@ -108,13 +108,13 @@ public:
{ {
if (dragMessage != NULL) if (dragMessage != NULL)
return; return;
if ((transit != B_INSIDE_VIEW && transit != B_ENTERED_VIEW) if ((transit != B_INSIDE_VIEW && transit != B_ENTERED_VIEW)
|| where.x > MinSize().width) { || where.x > MinSize().width) {
SetRating(fPermanentRating); SetRating(fPermanentRating);
return; return;
} }
float hoverRating = _RatingForMousePos(where); float hoverRating = _RatingForMousePos(where);
SetRating(hoverRating); SetRating(hoverRating);
} }
@@ -126,7 +126,7 @@ public:
message.AddFloat("rating", fPermanentRating); message.AddFloat("rating", fPermanentRating);
Window()->PostMessage(&message, Window()); Window()->PostMessage(&message, Window());
} }
void SetPermanentRating(float rating) void SetPermanentRating(float rating)
{ {
fPermanentRating = rating; fPermanentRating = rating;
@@ -187,7 +187,7 @@ RatePackageWindow::RatePackageWindow(BWindow* parent, BRect frame,
BStringView* ratingLabel = new BStringView("rating label", BStringView* ratingLabel = new BStringView("rating label",
B_TRANSLATE("Your rating:")); B_TRANSLATE("Your rating:"));
fSetRatingView = new SetRatingView(); fSetRatingView = new SetRatingView();
fTextView = new TextDocumentView(); fTextView = new TextDocumentView();
ScrollView* textScrollView = new ScrollView( ScrollView* textScrollView = new ScrollView(
@@ -218,10 +218,10 @@ RatePackageWindow::RatePackageWindow(BWindow* parent, BRect frame,
B_TRANSLATE("Very unstable"), "veryunstable")); B_TRANSLATE("Very unstable"), "veryunstable"));
fStabilityCodes.Add(StabilityRating( fStabilityCodes.Add(StabilityRating(
B_TRANSLATE("Does not start"), "nostart")); B_TRANSLATE("Does not start"), "nostart"));
add_stabilities_to_menu(fStabilityCodes, stabilityMenu); add_stabilities_to_menu(fStabilityCodes, stabilityMenu);
stabilityMenu->SetTargetForItems(this); stabilityMenu->SetTargetForItems(this);
fStability = fStabilityCodes.ItemAt(0).Name(); fStability = fStabilityCodes.ItemAt(0).Name();
stabilityMenu->ItemAt(0)->SetMarked(true); stabilityMenu->ItemAt(0)->SetMarked(true);
@@ -237,14 +237,14 @@ RatePackageWindow::RatePackageWindow(BWindow* parent, BRect frame,
fModel.SupportedLanguages().IndexOf(fCommentLanguage)); fModel.SupportedLanguages().IndexOf(fCommentLanguage));
if (defaultItem != NULL) if (defaultItem != NULL)
defaultItem->SetMarked(true); defaultItem->SetMarked(true);
fRatingActiveCheckBox = new BCheckBox("rating active", fRatingActiveCheckBox = new BCheckBox("rating active",
B_TRANSLATE("Other users can see this rating"), B_TRANSLATE("Other users can see this rating"),
new BMessage(MSG_RATING_ACTIVE_CHANGED)); new BMessage(MSG_RATING_ACTIVE_CHANGED));
// Hide the check mark by default, it will be made visible when // Hide the check mark by default, it will be made visible when
// the user already made a rating and it is loaded // the user already made a rating and it is loaded
fRatingActiveCheckBox->Hide(); fRatingActiveCheckBox->Hide();
// Construct buttons // Construct buttons
fCancelButton = new BButton("cancel", B_TRANSLATE("Cancel"), fCancelButton = new BButton("cancel", B_TRANSLATE("Cancel"),
new BMessage(B_QUIT_REQUESTED)); new BMessage(B_QUIT_REQUESTED));
@@ -297,7 +297,7 @@ RatePackageWindow::MessageReceived(BMessage* message)
case MSG_LANGUAGE_SELECTED: case MSG_LANGUAGE_SELECTED:
message->FindString("code", &fCommentLanguage); message->FindString("code", &fCommentLanguage);
break; break;
case MSG_RATING_ACTIVE_CHANGED: case MSG_RATING_ACTIVE_CHANGED:
{ {
int32 value; int32 value;
@@ -355,7 +355,7 @@ RatePackageWindow::_SetWorkerThread(thread_id thread)
{ {
if (!Lock()) if (!Lock())
return; return;
bool enabled = thread < 0; bool enabled = thread < 0;
// fTextEditor->SetEnabled(enabled); // fTextEditor->SetEnabled(enabled);
@@ -363,7 +363,7 @@ RatePackageWindow::_SetWorkerThread(thread_id thread)
fStabilityField->SetEnabled(enabled); fStabilityField->SetEnabled(enabled);
fCommentLanguageField->SetEnabled(enabled); fCommentLanguageField->SetEnabled(enabled);
fSendButton->SetEnabled(enabled); fSendButton->SetEnabled(enabled);
if (thread >= 0) { if (thread >= 0) {
fWorkerThread = thread; fWorkerThread = thread;
resume_thread(fWorkerThread); resume_thread(fWorkerThread);
@@ -418,7 +418,7 @@ RatePackageWindow::_QueryRatingThread()
BMessage result; BMessage result;
if (status == B_OK && info.FindMessage("result", &result) == B_OK if (status == B_OK && info.FindMessage("result", &result) == B_OK
&& Lock()) { && Lock()) {
result.FindString("code", &fRatingID); result.FindString("code", &fRatingID);
result.FindBool("active", &fRatingActive); result.FindBool("active", &fRatingActive);
BString comment; BString comment;
@@ -454,7 +454,7 @@ RatePackageWindow::_QueryRatingThread()
fRating = (float)rating; fRating = (float)rating;
fSetRatingView->SetPermanentRating(fRating); fSetRatingView->SetPermanentRating(fRating);
} }
fRatingActiveCheckBox->SetValue(fRatingActive); fRatingActiveCheckBox->SetValue(fRatingActive);
fRatingActiveCheckBox->Show(); fRatingActiveCheckBox->Show();
@@ -541,7 +541,7 @@ RatePackageWindow::_SendRatingThread()
error = B_TRANSLATE( error = B_TRANSLATE(
"It was not possible to contact the web service."); "It was not possible to contact the web service.");
} }
if (!error.IsEmpty()) { if (!error.IsEmpty()) {
BString failedTitle; BString failedTitle;
if (ratingID.Length() > 0) if (ratingID.Length() > 0)
+4 -4
View File
@@ -53,7 +53,7 @@ ScreenshotWindow::ScreenshotWindow(BWindow* parent, BRect frame)
ScreenshotWindow::~ScreenshotWindow() ScreenshotWindow::~ScreenshotWindow()
{ {
BAutolock locker(&fLock); BAutolock locker(&fLock);
if (fWorkerThread >= 0) if (fWorkerThread >= 0)
wait_for_thread(fWorkerThread, NULL); wait_for_thread(fWorkerThread, NULL);
} }
@@ -114,7 +114,7 @@ void
ScreenshotWindow::_DownloadScreenshot() ScreenshotWindow::_DownloadScreenshot()
{ {
BAutolock locker(&fLock); BAutolock locker(&fLock);
if (fWorkerThread >= 0) { if (fWorkerThread >= 0) {
fDownloadPending = true; fDownloadPending = true;
return; return;
@@ -132,13 +132,13 @@ ScreenshotWindow::_SetWorkerThread(thread_id thread)
{ {
if (!Lock()) if (!Lock())
return; return;
// bool enabled = thread < 0; // bool enabled = thread < 0;
// //
// fPreviewsButton->SetEnabled(enabled); // fPreviewsButton->SetEnabled(enabled);
// fNextButton->SetEnabled(enabled); // fNextButton->SetEnabled(enabled);
// fCloseButton->SetEnabled(enabled); // fCloseButton->SetEnabled(enabled);
if (thread >= 0) { if (thread >= 0) {
fWorkerThread = thread; fWorkerThread = thread;
resume_thread(fWorkerThread); resume_thread(fWorkerThread);
+19 -19
View File
@@ -102,7 +102,7 @@ UserLoginWindow::UserLoginWindow(BWindow* parent, BRect frame, Model& model)
fRepeatPasswordField = new BTextControl(B_TRANSLATE("Repeat pass phrase:"), fRepeatPasswordField = new BTextControl(B_TRANSLATE("Repeat pass phrase:"),
"", new BMessage(MSG_VALIDATE_FIELDS)); "", new BMessage(MSG_VALIDATE_FIELDS));
fRepeatPasswordField->TextView()->HideTyping(true); fRepeatPasswordField->TextView()->HideTyping(true);
// Construct languages popup // Construct languages popup
BPopUpMenu* languagesMenu = new BPopUpMenu(B_TRANSLATE("Language")); BPopUpMenu* languagesMenu = new BPopUpMenu(B_TRANSLATE("Language"));
fLanguageCodeField = new BMenuField("language", fLanguageCodeField = new BMenuField("language",
@@ -115,8 +115,8 @@ UserLoginWindow::UserLoginWindow(BWindow* parent, BRect frame, Model& model)
fModel.SupportedLanguages().IndexOf(fPreferredLanguage)); fModel.SupportedLanguages().IndexOf(fPreferredLanguage));
if (defaultItem != NULL) if (defaultItem != NULL)
defaultItem->SetMarked(true); defaultItem->SetMarked(true);
fEmailField = new BTextControl(B_TRANSLATE("Email address:"), "", NULL); fEmailField = new BTextControl(B_TRANSLATE("Email address:"), "", NULL);
fCaptchaView = new BitmapView("captcha view"); fCaptchaView = new BitmapView("captcha view");
fCaptchaResultField = new BTextControl("", "", NULL); fCaptchaResultField = new BTextControl("", "", NULL);
@@ -133,7 +133,7 @@ UserLoginWindow::UserLoginWindow(BWindow* parent, BRect frame, Model& model)
new BMessage(MSG_VALIDATE_FIELDS)); new BMessage(MSG_VALIDATE_FIELDS));
fCaptchaResultField->SetModificationMessage( fCaptchaResultField->SetModificationMessage(
new BMessage(MSG_VALIDATE_FIELDS)); new BMessage(MSG_VALIDATE_FIELDS));
fTabView = new TabView(BMessenger(this), fTabView = new TabView(BMessenger(this),
BMessage(MSG_TAB_SELECTED)); BMessage(MSG_TAB_SELECTED));
@@ -178,7 +178,7 @@ UserLoginWindow::UserLoginWindow(BWindow* parent, BRect frame, Model& model)
; ;
SetDefaultButton(fSendButton); SetDefaultButton(fSendButton);
_SetMode(LOGIN); _SetMode(LOGIN);
CenterIn(parent->Frame()); CenterIn(parent->Frame());
@@ -188,7 +188,7 @@ UserLoginWindow::UserLoginWindow(BWindow* parent, BRect frame, Model& model)
UserLoginWindow::~UserLoginWindow() UserLoginWindow::~UserLoginWindow()
{ {
BAutolock locker(&fLock); BAutolock locker(&fLock);
if (fWorkerThread >= 0) if (fWorkerThread >= 0)
wait_for_thread(fWorkerThread, NULL); wait_for_thread(fWorkerThread, NULL);
} }
@@ -331,13 +331,13 @@ UserLoginWindow::_ValidateCreateAccountFields(bool alertProblems)
// TODO: Use the same validation as the web-serivce // TODO: Use the same validation as the web-serivce
bool validUserName = nickName.Length() >= 3; bool validUserName = nickName.Length() >= 3;
fNewUsernameField->MarkAsInvalid(!validUserName); fNewUsernameField->MarkAsInvalid(!validUserName);
bool validPassword = password1.Length() >= 8 bool validPassword = password1.Length() >= 8
&& count_digits(password1) >= 2 && count_digits(password1) >= 2
&& count_upper_case_letters(password1) >= 2; && count_upper_case_letters(password1) >= 2;
fNewPasswordField->MarkAsInvalid(!validPassword); fNewPasswordField->MarkAsInvalid(!validPassword);
fRepeatPasswordField->MarkAsInvalid(password1 != password2); fRepeatPasswordField->MarkAsInvalid(password1 != password2);
bool validCaptcha = captcha.Length() > 0; bool validCaptcha = captcha.Length() > 0;
fCaptchaResultField->MarkAsInvalid(!validCaptcha); fCaptchaResultField->MarkAsInvalid(!validCaptcha);
@@ -399,7 +399,7 @@ UserLoginWindow::_ValidateCreateAccountFields(bool alertProblems)
return false; return false;
} }
} }
return valid; return valid;
} }
@@ -408,7 +408,7 @@ void
UserLoginWindow::_Login() UserLoginWindow::_Login()
{ {
BAutolock locker(&fLock); BAutolock locker(&fLock);
if (fWorkerThread >= 0) if (fWorkerThread >= 0)
return; return;
@@ -424,9 +424,9 @@ UserLoginWindow::_CreateAccount()
{ {
if (!_ValidateCreateAccountFields(true)) if (!_ValidateCreateAccountFields(true))
return; return;
BAutolock locker(&fLock); BAutolock locker(&fLock);
if (fWorkerThread >= 0) if (fWorkerThread >= 0)
return; return;
@@ -448,7 +448,7 @@ UserLoginWindow::_RequestCaptcha()
} }
BAutolock locker(&fLock); BAutolock locker(&fLock);
if (fWorkerThread >= 0) if (fWorkerThread >= 0)
return; return;
@@ -466,7 +466,7 @@ UserLoginWindow::_LoginSuccessful(const BString& message)
// (This method is executd from another thread.) // (This method is executd from another thread.)
BMessenger onSuccessTarget(fOnSuccessTarget); BMessenger onSuccessTarget(fOnSuccessTarget);
BMessage onSuccessMessage(fOnSuccessMessage); BMessage onSuccessMessage(fOnSuccessMessage);
BMessenger(this).SendMessage(B_QUIT_REQUESTED); BMessenger(this).SendMessage(B_QUIT_REQUESTED);
BAlert* alert = new(std::nothrow) BAlert( BAlert* alert = new(std::nothrow) BAlert(
@@ -489,7 +489,7 @@ UserLoginWindow::_SetWorkerThread(thread_id thread)
{ {
if (!Lock()) if (!Lock())
return; return;
bool enabled = thread < 0; bool enabled = thread < 0;
fUsernameField->SetEnabled(enabled); fUsernameField->SetEnabled(enabled);
@@ -501,7 +501,7 @@ UserLoginWindow::_SetWorkerThread(thread_id thread)
fLanguageCodeField->SetEnabled(enabled); fLanguageCodeField->SetEnabled(enabled);
fCaptchaResultField->SetEnabled(enabled); fCaptchaResultField->SetEnabled(enabled);
fSendButton->SetEnabled(enabled); fSendButton->SetEnabled(enabled);
if (thread >= 0) { if (thread >= 0) {
fWorkerThread = thread; fWorkerThread = thread;
resume_thread(fWorkerThread); resume_thread(fWorkerThread);
@@ -620,7 +620,7 @@ UserLoginWindow::_RequestCaptchaThread()
} }
delete[] buffer; delete[] buffer;
} }
} }
} else { } else {
fprintf(stderr, "Failed to obtain captcha: %s\n", strerror(status)); fprintf(stderr, "Failed to obtain captcha: %s\n", strerror(status));
} }
@@ -738,7 +738,7 @@ UserLoginWindow::_CollectValidationFailures(const BMessage& result,
BMessage failure; BMessage failure;
if (failures.FindMessage(name, &failure) != B_OK) if (failures.FindMessage(name, &failure) != B_OK)
break; break;
BString property; BString property;
BString message; BString message;
if (failure.FindString("property", &property) == B_OK if (failure.FindString("property", &property) == B_OK
@@ -764,7 +764,7 @@ UserLoginWindow::_CollectValidationFailures(const BMessage& result,
} }
} }
} }
if (!found) { if (!found) {
error << B_TRANSLATE("But none could be listed here, sorry."); error << B_TRANSLATE("But none could be listed here, sorry.");
} }
+1 -1
View File
@@ -65,7 +65,7 @@ LinkView::Draw(BRect updateRect)
float y = (bounds.top + bounds.bottom - ceilf(fontHeight.ascent) float y = (bounds.top + bounds.bottom - ceilf(fontHeight.ascent)
- ceilf(fontHeight.descent)) / 2.0 + ceilf(fontHeight.ascent); - ceilf(fontHeight.descent)) / 2.0 + ceilf(fontHeight.ascent);
float x = 0.0f; float x = 0.0f;
BString text(Text()); BString text(Text());
TruncateString(&text, B_TRUNCATE_END, bounds.Width()); TruncateString(&text, B_TRUNCATE_END, bounds.Width());
DrawString(text, BPoint(x, y)); DrawString(text, BPoint(x, y));
@@ -30,9 +30,9 @@ void
ScrollableGroupView::DoLayout() ScrollableGroupView::DoLayout()
{ {
BGroupView::DoLayout(); BGroupView::DoLayout();
BScrollBar* scrollBar = ScrollBar(B_VERTICAL); BScrollBar* scrollBar = ScrollBar(B_VERTICAL);
if (scrollBar == NULL) if (scrollBar == NULL)
return; return;
@@ -76,7 +76,7 @@ SharedBitmap::SharedBitmap(BPositionIO& data)
fBuffer = new(std::nothrow) uint8[fSize]; fBuffer = new(std::nothrow) uint8[fSize];
if (fBuffer != NULL) { if (fBuffer != NULL) {
data.Seek(0, SEEK_SET); data.Seek(0, SEEK_SET);
off_t bytesRead = 0; off_t bytesRead = 0;
size_t chunkSize = std::min((off_t)4096, fSize); size_t chunkSize = std::min((off_t)4096, fSize);
while (bytesRead < fSize) { while (bytesRead < fSize) {
@@ -86,7 +86,7 @@ SharedBitmap::SharedBitmap(BPositionIO& data)
else else
break; break;
} }
if (bytesRead != fSize) { if (bytesRead != fSize) {
delete[] fBuffer; delete[] fBuffer;
fBuffer = NULL; fBuffer = NULL;
@@ -177,7 +177,7 @@ BBitmap*
SharedBitmap::_CreateBitmapFromBuffer(int32 size) const SharedBitmap::_CreateBitmapFromBuffer(int32 size) const
{ {
BBitmap* bitmap = _LoadIconFromBuffer(fBuffer, fSize, size); BBitmap* bitmap = _LoadIconFromBuffer(fBuffer, fSize, size);
if (bitmap == NULL) if (bitmap == NULL)
bitmap = _LoadBitmapFromBuffer(fBuffer, fSize); bitmap = _LoadBitmapFromBuffer(fBuffer, fSize);
@@ -214,7 +214,7 @@ SharedBitmap::_LoadBitmapFromBuffer(const void* buffer, size_t size) const
// Try to read as an archived bitmap. // Try to read as an archived bitmap.
BBitmap* bitmap = _LoadArchivedBitmapFromStream(stream); BBitmap* bitmap = _LoadArchivedBitmapFromStream(stream);
if (bitmap == NULL) { if (bitmap == NULL) {
// Try to read as a translator bitmap // Try to read as a translator bitmap
stream.Seek(0, SEEK_SET); stream.Seek(0, SEEK_SET);