diff --git a/src/kits/tracker/AttributeStream.cpp b/src/kits/tracker/AttributeStream.cpp index 8c429e10ec..47a8ce0896 100644 --- a/src/kits/tracker/AttributeStream.cpp +++ b/src/kits/tracker/AttributeStream.cpp @@ -32,11 +32,13 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include "AttributeStream.h" #include #include + // ToDo: // lazy Rewind from Drive, only if data is available // BMessage node @@ -49,14 +51,15 @@ AttributeInfo::AttributeInfo(const AttributeInfo &cloneThis) { } -AttributeInfo::AttributeInfo(const char *name, attr_info info) + +AttributeInfo::AttributeInfo(const char* name, attr_info info) : fName(name), fInfo(info) { } -AttributeInfo::AttributeInfo(const char *name, uint32 type, off_t size) +AttributeInfo::AttributeInfo(const char* name, uint32 type, off_t size) : fName(name) { fInfo.size = size; @@ -64,7 +67,7 @@ AttributeInfo::AttributeInfo(const char *name, uint32 type, off_t size) } -const char * +const char* AttributeInfo::Name() const { return fName.String(); @@ -91,14 +94,14 @@ AttributeInfo::SetTo(const AttributeInfo &attr) } void -AttributeInfo::SetTo(const char *name, attr_info info) +AttributeInfo::SetTo(const char* name, attr_info info) { fName = name; fInfo = info; } void -AttributeInfo::SetTo(const char *name, uint32 type, off_t size) +AttributeInfo::SetTo(const char* name, uint32 type, off_t size) { fName = name; fInfo.type = type; @@ -118,7 +121,7 @@ AttributeStreamNode::~AttributeStreamNode() Detach(); } -AttributeStreamNode & +AttributeStreamNode& AttributeStreamNode::operator<<(AttributeStreamNode &source) { fReadFrom = &source; @@ -143,7 +146,7 @@ AttributeStreamFileNode::MakeEmpty() } off_t -AttributeStreamNode::Contains(const char *name, uint32 type) +AttributeStreamNode::Contains(const char* name, uint32 type) { if (!fReadFrom) return 0; @@ -153,8 +156,8 @@ AttributeStreamNode::Contains(const char *name, uint32 type) off_t -AttributeStreamNode::Read(const char *name, const char *foreignName, uint32 type, - off_t size, void *buffer, void (*swapFunc)(void *)) +AttributeStreamNode::Read(const char* name, const char* foreignName, uint32 type, + off_t size, void* buffer, void (*swapFunc)(void*)) { if (!fReadFrom) return 0; @@ -162,9 +165,10 @@ AttributeStreamNode::Read(const char *name, const char *foreignName, uint32 type return fReadFrom->Read(name, foreignName, type, size, buffer, swapFunc); } + off_t -AttributeStreamNode::Write(const char *name, const char *foreignName, uint32 type, - off_t size, const void *buffer) +AttributeStreamNode::Write(const char* name, const char* foreignName, uint32 type, + off_t size, const void* buffer) { if (!fWriteTo) return 0; @@ -172,6 +176,7 @@ AttributeStreamNode::Write(const char *name, const char *foreignName, uint32 typ return fWriteTo->Write(name, foreignName, type, size, buffer); } + bool AttributeStreamNode::Drive() { @@ -183,7 +188,8 @@ AttributeStreamNode::Drive() return true; } -const AttributeInfo * + +const AttributeInfo* AttributeStreamNode::Next() { if (fReadFrom) @@ -192,7 +198,8 @@ AttributeStreamNode::Next() return NULL; } -const char * + +const char* AttributeStreamNode::Get() { ASSERT(fReadFrom); @@ -202,13 +209,15 @@ AttributeStreamNode::Get() return fReadFrom->Get(); } + bool -AttributeStreamNode::Fill(char *buffer) const +AttributeStreamNode::Fill(char* buffer) const { ASSERT(fReadFrom); return fReadFrom->Fill(buffer); } + bool AttributeStreamNode::Start() { @@ -219,11 +228,12 @@ AttributeStreamNode::Start() return fWriteTo->Start(); } + void AttributeStreamNode::Detach() { - AttributeStreamNode *tmpFrom = fReadFrom; - AttributeStreamNode *tmpTo = fWriteTo; + AttributeStreamNode* tmpFrom = fReadFrom; + AttributeStreamNode* tmpTo = fWriteTo; fReadFrom = NULL; fWriteTo = NULL; @@ -240,12 +250,13 @@ AttributeStreamFileNode::AttributeStreamFileNode() } -AttributeStreamFileNode::AttributeStreamFileNode(BNode *node) +AttributeStreamFileNode::AttributeStreamFileNode(BNode* node) : fNode(node) { ASSERT(fNode); } + void AttributeStreamFileNode::Rewind() { @@ -253,15 +264,16 @@ AttributeStreamFileNode::Rewind() fNode->RewindAttrs(); } + void -AttributeStreamFileNode::SetTo(BNode *node) +AttributeStreamFileNode::SetTo(BNode* node) { fNode = node; } off_t -AttributeStreamFileNode::Contains(const char *name, uint32 type) +AttributeStreamFileNode::Contains(const char* name, uint32 type) { ASSERT(fNode); attr_info info; @@ -274,9 +286,10 @@ AttributeStreamFileNode::Contains(const char *name, uint32 type) return info.size; } + off_t -AttributeStreamFileNode::Read(const char *name, const char *foreignName, uint32 type, - off_t size, void *buffer, void (*swapFunc)(void *)) +AttributeStreamFileNode::Read(const char* name, const char* foreignName, uint32 type, + off_t size, void* buffer, void (*swapFunc)(void*)) { if (name && fNode->ReadAttr(name, type, 0, buffer, (size_t)size) == size) return size; @@ -291,12 +304,13 @@ AttributeStreamFileNode::Read(const char *name, const char *foreignName, uint32 return 0; } + off_t -AttributeStreamFileNode::Write(const char *name, const char *foreignName, uint32 type, - off_t size, const void *buffer) +AttributeStreamFileNode::Write(const char* name, const char* foreignName, uint32 type, + off_t size, const void* buffer) { ASSERT(fNode); - ASSERT(dynamic_cast(fNode)); + ASSERT(dynamic_cast(fNode)); off_t result = fNode->WriteAttr(name, type, 0, buffer, (size_t)size); if (result == size && foreignName) // the write operation worked fine, remove the foreign attribute @@ -306,6 +320,7 @@ AttributeStreamFileNode::Write(const char *name, const char *foreignName, uint32 return result; } + bool AttributeStreamFileNode::Drive() { @@ -313,9 +328,9 @@ AttributeStreamFileNode::Drive() if (!_inherited::Drive()) return false; - const AttributeInfo *attr; + const AttributeInfo* attr; while ((attr = fReadFrom->Next()) != 0) { - const char *data = fReadFrom->Get(); + const char* data = fReadFrom->Get(); off_t result = fNode->WriteAttr(attr->Name(), attr->Type(), 0, data, (size_t)attr->Size()); if (result < attr->Size()) @@ -324,7 +339,8 @@ AttributeStreamFileNode::Drive() return true; } -const char * + +const char* AttributeStreamFileNode::Get() { ASSERT(fNode); @@ -332,15 +348,17 @@ AttributeStreamFileNode::Get() return NULL; } + bool -AttributeStreamFileNode::Fill(char *buffer) const +AttributeStreamFileNode::Fill(char* buffer) const { ASSERT(fNode); return fNode->ReadAttr(fCurrentAttr.Name(), fCurrentAttr.Type(), 0, buffer, (size_t)fCurrentAttr.Size()) == (ssize_t)fCurrentAttr.Size(); } -const AttributeInfo * + +const AttributeInfo* AttributeStreamFileNode::Next() { ASSERT(fNode); @@ -364,12 +382,14 @@ AttributeStreamMemoryNode::AttributeStreamMemoryNode() { } + void AttributeStreamMemoryNode::MakeEmpty() { fAttributes.MakeEmpty(); } + void AttributeStreamMemoryNode::Rewind() { @@ -377,8 +397,9 @@ AttributeStreamMemoryNode::Rewind() fCurrentIndex = -1; } + int32 -AttributeStreamMemoryNode::Find(const char *name, uint32 type) const +AttributeStreamMemoryNode::Find(const char* name, uint32 type) const { int32 count = fAttributes.CountItems(); for (int32 index = 0; index < count; index++) @@ -389,8 +410,9 @@ AttributeStreamMemoryNode::Find(const char *name, uint32 type) const return -1; } + off_t -AttributeStreamMemoryNode::Contains(const char *name, uint32 type) +AttributeStreamMemoryNode::Contains(const char* name, uint32 type) { int32 index = Find(name, type); if (index < 0) @@ -400,13 +422,13 @@ AttributeStreamMemoryNode::Contains(const char *name, uint32 type) off_t -AttributeStreamMemoryNode::Read(const char *name, const char *DEBUG_ONLY(foreignName), - uint32 type, off_t bufferSize, void *buffer, void (*DEBUG_ONLY(swapFunc))(void *)) +AttributeStreamMemoryNode::Read(const char* name, const char* DEBUG_ONLY(foreignName), + uint32 type, off_t bufferSize, void* buffer, void (*DEBUG_ONLY(swapFunc))(void*)) { ASSERT(!foreignName); ASSERT(!swapFunc); - AttrNode *attrNode = NULL; + AttrNode* attrNode = NULL; int32 index = Find(name, type); if (index < 0) { @@ -429,18 +451,20 @@ AttributeStreamMemoryNode::Read(const char *name, const char *DEBUG_ONLY(foreign return attrNode->fAttr.Size(); } + off_t -AttributeStreamMemoryNode::Write(const char *name, const char *, uint32 type, - off_t size, const void *buffer) +AttributeStreamMemoryNode::Write(const char* name, const char*, uint32 type, + off_t size, const void* buffer) { - char *newBuffer = new char[size]; + char* newBuffer = new char[size]; memcpy(newBuffer, buffer, (size_t)size); - AttrNode *attrNode = new AttrNode(name, type, size, newBuffer); + AttrNode* attrNode = new AttrNode(name, type, size, newBuffer); fAttributes.AddItem(attrNode); return size; } + bool AttributeStreamMemoryNode::Drive() { @@ -453,35 +477,37 @@ AttributeStreamMemoryNode::Drive() return true; } -AttributeStreamMemoryNode::AttrNode * -AttributeStreamMemoryNode::BufferingGet(const char *name, uint32 type, off_t size) + +AttributeStreamMemoryNode::AttrNode* +AttributeStreamMemoryNode::BufferingGet(const char* name, uint32 type, off_t size) { - char *newBuffer = new char[size]; + char* newBuffer = new char[size]; if (!fReadFrom->Fill(newBuffer)) { delete[] newBuffer; return NULL; } - AttrNode *attrNode = new AttrNode(name, type, size, newBuffer); + AttrNode* attrNode = new AttrNode(name, type, size, newBuffer); fAttributes.AddItem(attrNode); return fAttributes.LastItem(); } -AttributeStreamMemoryNode::AttrNode * +AttributeStreamMemoryNode::AttrNode* AttributeStreamMemoryNode::BufferingGet() { if (!fReadFrom) return NULL; - const AttributeInfo *attr = fReadFrom->Next(); + const AttributeInfo* attr = fReadFrom->Next(); if (!attr) return NULL; return BufferingGet(attr->Name(), attr->Type(), attr->Size()); } -const AttributeInfo * + +const AttributeInfo* AttributeStreamMemoryNode::Next() { if (fReadFrom) @@ -495,15 +521,17 @@ AttributeStreamMemoryNode::Next() return &fAttributes.ItemAt(++fCurrentIndex)->fAttr; } -const char * + +const char* AttributeStreamMemoryNode::Get() { ASSERT(fCurrentIndex < fAttributes.CountItems()); return fAttributes.ItemAt(fCurrentIndex)->fData; } + bool -AttributeStreamMemoryNode::Fill(char *buffer) const +AttributeStreamMemoryNode::Fill(char* buffer) const { ASSERT(fCurrentIndex < fAttributes.CountItems()); memcpy(buffer, fAttributes.ItemAt(fCurrentIndex)->fData, @@ -513,16 +541,17 @@ AttributeStreamMemoryNode::Fill(char *buffer) const } -AttributeStreamTemplateNode::AttributeStreamTemplateNode(const AttributeTemplate * - attrTemplates, int32 count) +AttributeStreamTemplateNode::AttributeStreamTemplateNode( + const AttributeTemplate* attrTemplates, int32 count) : fAttributes(attrTemplates), fCurrentIndex(-1), fCount(count) { } + off_t -AttributeStreamTemplateNode::Contains(const char *name, uint32 type) +AttributeStreamTemplateNode::Contains(const char* name, uint32 type) { int32 index = Find(name, type); if (index < 0) @@ -531,13 +560,15 @@ AttributeStreamTemplateNode::Contains(const char *name, uint32 type) return fAttributes[index].fSize; } + void AttributeStreamTemplateNode::Rewind() { fCurrentIndex = -1; } -const AttributeInfo * + +const AttributeInfo* AttributeStreamTemplateNode::Next() { if (fCurrentIndex + 1 >= fCount) @@ -546,53 +577,62 @@ AttributeStreamTemplateNode::Next() ++fCurrentIndex; fCurrentAttr.SetTo(fAttributes[fCurrentIndex].fAttributeName, - fAttributes[fCurrentIndex].fAttributeType, fAttributes[fCurrentIndex].fSize); + fAttributes[fCurrentIndex].fAttributeType, + fAttributes[fCurrentIndex].fSize); return &fCurrentAttr; } -const char * + +const char* AttributeStreamTemplateNode::Get() { ASSERT(fCurrentIndex < fCount); return fAttributes[fCurrentIndex].fBits; } + bool -AttributeStreamTemplateNode::Fill(char *buffer) const +AttributeStreamTemplateNode::Fill(char* buffer) const { ASSERT(fCurrentIndex < fCount); - memcpy(buffer, fAttributes[fCurrentIndex].fBits, (size_t)fAttributes[fCurrentIndex].fSize); + memcpy(buffer, fAttributes[fCurrentIndex].fBits, + (size_t)fAttributes[fCurrentIndex].fSize); return true; } + int32 -AttributeStreamTemplateNode::Find(const char *name, uint32 type) const +AttributeStreamTemplateNode::Find(const char* name, uint32 type) const { - for (int32 index = 0; index < fCount; index++) + for (int32 index = 0; index < fCount; index++) { if (fAttributes[index].fAttributeType == type && - strcmp(name, fAttributes[index].fAttributeName) == 0) + strcmp(name, fAttributes[index].fAttributeName) == 0) { return index; + } + } return -1; } + bool -AttributeStreamFilterNode::Reject(const char *, uint32 , off_t ) +AttributeStreamFilterNode::Reject(const char*, uint32, off_t) { // simple pass everything filter return false; } -const AttributeInfo * + +const AttributeInfo* AttributeStreamFilterNode::Next() { if (!fReadFrom) return NULL; for (;;) { - const AttributeInfo *attr = fReadFrom->Next(); + const AttributeInfo* attr = fReadFrom->Next(); if (!attr) break; @@ -602,8 +642,9 @@ AttributeStreamFilterNode::Next() return NULL; } + off_t -AttributeStreamFilterNode::Contains(const char *name, uint32 type) +AttributeStreamFilterNode::Contains(const char* name, uint32 type) { if (!fReadFrom) return 0; @@ -616,9 +657,10 @@ AttributeStreamFilterNode::Contains(const char *name, uint32 type) return 0; } + off_t -AttributeStreamFilterNode::Read(const char *name, const char *foreignName, uint32 type, - off_t size, void *buffer, void (*swapFunc)(void *)) +AttributeStreamFilterNode::Read(const char* name, const char* foreignName, uint32 type, + off_t size, void* buffer, void (*swapFunc)(void*)) { if (!fReadFrom) return 0; @@ -629,9 +671,10 @@ AttributeStreamFilterNode::Read(const char *name, const char *foreignName, uint3 return 0; } + off_t -AttributeStreamFilterNode::Write(const char *name, const char *foreignName, uint32 type, - off_t size, const void *buffer) +AttributeStreamFilterNode::Write(const char* name, const char* foreignName, uint32 type, + off_t size, const void* buffer) { if (!fWriteTo) return 0; @@ -643,30 +686,34 @@ AttributeStreamFilterNode::Write(const char *name, const char *foreignName, uint } -NamesToAcceptAttrFilter::NamesToAcceptAttrFilter(const char **nameList) +NamesToAcceptAttrFilter::NamesToAcceptAttrFilter(const char** nameList) : fNameList(nameList) { } + bool -NamesToAcceptAttrFilter::Reject(const char *name, uint32 , off_t ) +NamesToAcceptAttrFilter::Reject(const char* name, uint32 , off_t ) { for (int32 index = 0; ;index++) { if (!fNameList[index]) break; if (strcmp(name, fNameList[index]) == 0) { -// PRINT(("filter passing through %s\n", name)); + //PRINT(("filter passing through %s\n", name)); return false; } } -// PRINT(("filter rejecting %s\n", name)); + + //PRINT(("filter rejecting %s\n", name)); return true; } -SelectiveAttributeTransformer::SelectiveAttributeTransformer(const char *attributeName, - bool (*transformFunc)(const char * , uint32 , off_t, void *, void *), void *params) +SelectiveAttributeTransformer::SelectiveAttributeTransformer( + const char* attributeName, + bool (*transformFunc)(const char* , uint32 , off_t, void*, void*), + void* params) : fAttributeNameToTransform(attributeName), fTransformFunc(transformFunc), fTransformParams(params), @@ -677,54 +724,62 @@ SelectiveAttributeTransformer::SelectiveAttributeTransformer(const char *attribu SelectiveAttributeTransformer::~SelectiveAttributeTransformer() { - for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0; index--) + for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0; + index--) { delete [] fTransformedBuffers.ItemAt(index); + } } + void SelectiveAttributeTransformer::Rewind() { - for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0; index--) + for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0; + index--) { delete [] fTransformedBuffers.ItemAt(index); + } fTransformedBuffers.MakeEmpty(); } off_t -SelectiveAttributeTransformer::Read(const char *name, const char *foreignName, - uint32 type, off_t size, void *buffer, void (*swapFunc)(void *)) +SelectiveAttributeTransformer::Read(const char* name, const char* foreignName, + uint32 type, off_t size, void* buffer, void (*swapFunc)(void*)) { if (!fReadFrom) return 0; - off_t result = fReadFrom->Read(name, foreignName, type, size, buffer, swapFunc); + off_t result = fReadFrom->Read(name, foreignName, type, size, buffer, + swapFunc); - if (WillTransform(name, type, size, (const char *)buffer)) - ApplyTransformer(name, type, size, (char *)buffer); + if (WillTransform(name, type, size, (const char*)buffer)) + ApplyTransformer(name, type, size, (char*)buffer); return result; } + bool -SelectiveAttributeTransformer::WillTransform(const char *name, uint32 , off_t , - const char *) const +SelectiveAttributeTransformer::WillTransform(const char* name, uint32, off_t, + const char*) const { return strcmp(name, fAttributeNameToTransform) == 0; } + bool -SelectiveAttributeTransformer::ApplyTransformer(const char *name, uint32 type, off_t size, - char *data) +SelectiveAttributeTransformer::ApplyTransformer(const char* name, uint32 type, + off_t size, char* data) { return (fTransformFunc)(name, type, size, data, fTransformParams); } -char * -SelectiveAttributeTransformer::CopyAndApplyTransformer(const char *name, uint32 type, - off_t size, const char *data) +char* +SelectiveAttributeTransformer::CopyAndApplyTransformer(const char* name, + uint32 type, off_t size, const char* data) { - char *result = NULL; + char* result = NULL; if (data) { result = new char[size]; memcpy(result, data, (size_t)size); @@ -734,13 +789,15 @@ SelectiveAttributeTransformer::CopyAndApplyTransformer(const char *name, uint32 delete [] result; return NULL; } + return result; } -const AttributeInfo * + +const AttributeInfo* SelectiveAttributeTransformer::Next() { - const AttributeInfo *result = fReadFrom->Next(); + const AttributeInfo* result = fReadFrom->Next(); if (!result) return NULL; @@ -748,19 +805,22 @@ SelectiveAttributeTransformer::Next() return result; } -const char * + +const char* SelectiveAttributeTransformer::Get() { if (!fReadFrom) return NULL; - const char *result = fReadFrom->Get(); + const char* result = fReadFrom->Get(); - if (!WillTransform(fCurrentAttr.Name(), fCurrentAttr.Type(), fCurrentAttr.Size(), result)) + if (!WillTransform(fCurrentAttr.Name(), fCurrentAttr.Type(), + fCurrentAttr.Size(), result)) { return result; + } - char *transformedData = CopyAndApplyTransformer(fCurrentAttr.Name(), fCurrentAttr.Type(), - fCurrentAttr.Size(), result); + char* transformedData = CopyAndApplyTransformer(fCurrentAttr.Name(), + fCurrentAttr.Type(), fCurrentAttr.Size(), result); // enlist for proper disposal when our job is done if (transformedData) { diff --git a/src/kits/tracker/AttributeStream.h b/src/kits/tracker/AttributeStream.h index 1c31a851c4..0102ba8972 100644 --- a/src/kits/tracker/AttributeStream.h +++ b/src/kits/tracker/AttributeStream.h @@ -46,11 +46,10 @@ All rights reserved. // // In addition to the whacky (but usefull) << syntax, calls like Read, Write are also // available - - #ifndef __ATTRIBUTE_STREAM__ #define __ATTRIBUTE_STREAM__ + #include #include #include @@ -60,14 +59,15 @@ All rights reserved. #include "ObjectList.h" + namespace BPrivate { struct AttributeTemplate { // used for read-only attribute source - const char *fAttributeName; + const char* fAttributeName; uint32 fAttributeType; off_t fSize; - const char *fBits; + const char* fBits; }; @@ -77,26 +77,27 @@ public: AttributeInfo() {} AttributeInfo(const AttributeInfo &); - AttributeInfo(const char *, attr_info); - AttributeInfo(const char *, uint32, off_t); + AttributeInfo(const char*, attr_info); + AttributeInfo(const char*, uint32, off_t); void SetTo(const AttributeInfo &); - void SetTo(const char *, attr_info); - void SetTo(const char *, uint32, off_t); - const char *Name() const; + void SetTo(const char*, attr_info); + void SetTo(const char*, uint32, off_t); + const char* Name() const; uint32 Type() const; off_t Size() const; private: BString fName; attr_info fInfo; -}; - +}; + + class AttributeStreamNode { public: AttributeStreamNode(); virtual ~AttributeStreamNode(); - + AttributeStreamNode &operator<<(AttributeStreamNode &source); // workhorse call // to the outside makes this node a part of the stream, passing on @@ -104,35 +105,34 @@ public: // // under the hood sets up streaming into the next node; hooking // up source and destination, forces the stream head to start streaming - + virtual void Rewind(); // get ready to start all over again virtual void MakeEmpty() {} // remove any attributes the node may have - - virtual off_t Contains(const char *, uint32); + + virtual off_t Contains(const char*, uint32); // returns size of attribute if found - virtual off_t Read(const char *name, const char *foreignName, uint32 type, off_t size, - void *buffer, void (*swapFunc)(void *) = 0); + virtual off_t Read(const char* name, const char* foreignName, uint32 type, off_t size, + void* buffer, void (*swapFunc)(void*) = 0); // read from this node - virtual off_t Write(const char *name, const char *foreignName, uint32 type, off_t size, - const void *buffer); + virtual off_t Write(const char* name, const char* foreignName, uint32 type, off_t size, + const void* buffer); // write to this node - // work calls virtual bool Drive(); // node at the head of the stream makes the entire stream // feed it - virtual const AttributeInfo *Next(); + virtual const AttributeInfo* Next(); // give me the next attribute in the stream - virtual const char *Get(); + virtual const char* Get(); // give me the data of the attribute in the stream that was just returned // by Next // assumes there is a buffering node somewhere on the way to // the source, from which the resulting buffer is borrowed - virtual bool Fill(char *buffer) const; + virtual bool Fill(char* buffer) const; // fill the buffer with data of the attribute in the stream that was just returned // by next // is big enough to hold the entire attribute data @@ -148,47 +148,49 @@ private: void Detach(); protected: - AttributeStreamNode *fReadFrom; - AttributeStreamNode *fWriteTo; + AttributeStreamNode* fReadFrom; + AttributeStreamNode* fWriteTo; }; + class AttributeStreamFileNode : public AttributeStreamNode { // handles reading and writing attributes to and from the // stream public: AttributeStreamFileNode(); - AttributeStreamFileNode(BNode *); - + AttributeStreamFileNode(BNode*); + virtual void MakeEmpty(); virtual void Rewind(); - virtual off_t Contains(const char *name, uint32 type); - virtual off_t Read(const char *name, const char *foreignName, uint32 type, off_t size, - void *buffer, void (*swapFunc)(void *) = 0); - virtual off_t Write(const char *name, const char *foreignName, uint32 type, off_t size, - const void *buffer); + virtual off_t Contains(const char* name, uint32 type); + virtual off_t Read(const char* name, const char* foreignName, uint32 type, + off_t size, void* buffer, void (*swapFunc)(void*) = 0); + virtual off_t Write(const char* name, const char* foreignName, uint32 type, + off_t size, const void* buffer); - void SetTo(BNode *); + void SetTo(BNode*); - BNode *Node() + BNode* Node() { return fNode; } - + protected: virtual bool CanFeed() const { return true; } virtual bool Drive(); // give me all the attributes, I'll write them into myself - virtual const AttributeInfo *Next(); + virtual const AttributeInfo* Next(); // return the info for the next attribute I can read for you - virtual const char *Get(); - virtual bool Fill(char *buffer) const; + virtual const char* Get(); + virtual bool Fill(char* buffer) const; private: AttributeInfo fCurrentAttr; - BNode *fNode; + BNode* fNode; typedef AttributeStreamNode _inherited; }; + class AttributeStreamMemoryNode : public AttributeStreamNode { // in memory attribute buffer; can be both target of writing and source // of reading at the same time @@ -196,24 +198,23 @@ public: AttributeStreamMemoryNode(); virtual void MakeEmpty(); - virtual off_t Contains(const char *name, uint32 type); - virtual off_t Read(const char *name, const char *foreignName, uint32 type, off_t size, - void *buffer, void (*swapFunc)(void *) = 0); - virtual off_t Write(const char *name, const char *foreignName, uint32 type, off_t size, - const void *buffer); - -protected: + virtual off_t Contains(const char* name, uint32 type); + virtual off_t Read(const char* name, const char* foreignName, uint32 type, off_t size, + void* buffer, void (*swapFunc)(void*) = 0); + virtual off_t Write(const char* name, const char* foreignName, uint32 type, off_t size, + const void* buffer); +protected: virtual bool CanFeed() const { return true; } virtual void Rewind(); virtual bool Drive(); - virtual const AttributeInfo *Next(); - virtual const char *Get(); - virtual bool Fill(char *buffer) const; + virtual const AttributeInfo* Next(); + virtual const char* Get(); + virtual bool Fill(char* buffer) const; class AttrNode { public: - AttrNode(const char *name, uint32 type, off_t size, char *data) + AttrNode(const char* name, uint32 type, off_t size, char* data) : fAttr(name, type, size), fData(data) { @@ -225,129 +226,132 @@ protected: } AttributeInfo fAttr; - char *fData; + char* fData; }; - + // utility calls - virtual AttrNode *BufferingGet(); - virtual AttrNode *BufferingGet(const char *name, uint32 type, off_t size); - int32 Find(const char *name, uint32 type) const; + virtual AttrNode* BufferingGet(); + virtual AttrNode* BufferingGet(const char* name, uint32 type, off_t size); + int32 Find(const char* name, uint32 type) const; private: - BObjectList fAttributes; int32 fCurrentIndex; typedef AttributeStreamNode _inherited; }; + class AttributeStreamTemplateNode : public AttributeStreamNode { // in read-only memory attribute source // can only be used as a source for Next and Get public: - AttributeStreamTemplateNode(const AttributeTemplate *, int32 count); + AttributeStreamTemplateNode(const AttributeTemplate*, int32 count); + + virtual off_t Contains(const char* name, uint32 type); - virtual off_t Contains(const char *name, uint32 type); - protected: - virtual bool CanFeed() const { return true; } virtual void Rewind(); - virtual const AttributeInfo *Next(); - virtual const char *Get(); - virtual bool Fill(char *buffer) const; + virtual const AttributeInfo* Next(); + virtual const char* Get(); + virtual bool Fill(char* buffer) const; - int32 Find(const char *name, uint32 type) const; + int32 Find(const char* name, uint32 type) const; private: AttributeInfo fCurrentAttr; - const AttributeTemplate *fAttributes; + const AttributeTemplate* fAttributes; int32 fCurrentIndex; int32 fCount; typedef AttributeStreamNode _inherited; }; + class AttributeStreamFilterNode : public AttributeStreamNode { // filter node may not pass thru specified attributes public: AttributeStreamFilterNode() {} - virtual off_t Contains(const char *name, uint32 type); - virtual off_t Read(const char *name, const char *foreignName, uint32 type, off_t size, - void *buffer, void (*swapFunc)(void *) = 0); - virtual off_t Write(const char *name, const char *foreignName, uint32 type, off_t size, - const void *buffer); + virtual off_t Contains(const char* name, uint32 type); + virtual off_t Read(const char* name, const char* foreignName, uint32 type, off_t size, + void* buffer, void (*swapFunc)(void*) = 0); + virtual off_t Write(const char* name, const char* foreignName, uint32 type, off_t size, + const void* buffer); protected: - virtual bool Reject(const char *name, uint32 type, off_t size); + virtual bool Reject(const char* name, uint32 type, off_t size); // override to implement filtering - virtual const AttributeInfo *Next(); - + virtual const AttributeInfo* Next(); + private: typedef AttributeStreamNode _inherited; }; + class NamesToAcceptAttrFilter : public AttributeStreamFilterNode { // filter node that only passes thru attributes that match // a list of names public: - NamesToAcceptAttrFilter(const char **); + NamesToAcceptAttrFilter(const char**); protected: - virtual bool Reject(const char *name, uint32 type, off_t size); + virtual bool Reject(const char* name, uint32 type, off_t size); private: - const char **fNameList; + const char** fNameList; }; + class SelectiveAttributeTransformer : public AttributeStreamNode { // node applies a transformation on specified attributes public: - SelectiveAttributeTransformer(const char *attributeName, bool (*)(const char *, - uint32 , off_t , void *, void *), void *params); + SelectiveAttributeTransformer(const char* attributeName, bool (*)(const char*, + uint32 , off_t , void*, void*), void* params); virtual ~SelectiveAttributeTransformer(); - virtual off_t Read(const char *name, const char *foreignName, uint32 type, off_t size, - void *buffer, void (*swapFunc)(void *) = 0); + virtual off_t Read(const char* name, const char* foreignName, uint32 type, off_t size, + void* buffer, void (*swapFunc)(void*) = 0); virtual void Rewind(); protected: - virtual bool WillTransform(const char *name, uint32 type, off_t size, const char *data) const; + virtual bool WillTransform(const char* name, uint32 type, off_t size, const char* data) const; // override to implement filtering; should only return true if transformation will // occur - virtual char *CopyAndApplyTransformer(const char *name, uint32 type, off_t size, const char *data); + virtual char* CopyAndApplyTransformer(const char* name, uint32 type, off_t size, const char* data); // makes a copy of data - virtual bool ApplyTransformer(const char *name, uint32 type, off_t size, char *data); + virtual bool ApplyTransformer(const char* name, uint32 type, off_t size, char* data); // transforms in place - virtual const AttributeInfo *Next(); - virtual const char *Get(); - + virtual const AttributeInfo* Next(); + virtual const char* Get(); + private: AttributeInfo fCurrentAttr; - const char *fAttributeNameToTransform; - bool (*fTransformFunc)(const char *, uint32 , off_t , void *, void *); - void *fTransformParams; + const char* fAttributeNameToTransform; + bool (*fTransformFunc)(const char*, uint32 , off_t , void*, void*); + void* fTransformParams; BObjectList fTransformedBuffers; typedef AttributeStreamNode _inherited; }; + template class AttributeStreamConstValue : public AttributeStreamNode { public: - AttributeStreamConstValue(const char *name, uint32 attributeType, Type value); -protected: + AttributeStreamConstValue(const char* name, uint32 attributeType, Type value); +protected: virtual bool CanFeed() const { return true; } virtual void Rewind() { fRewound = true; } - virtual const AttributeInfo *Next(); - virtual const char *Get(); - virtual bool Fill(char *buffer) const; + virtual const AttributeInfo* Next(); + virtual const char* Get(); + virtual bool Fill(char* buffer) const; - int32 Find(const char *name, uint32 type) const; + int32 Find(const char* name, uint32 type) const; private: AttributeInfo fAttr; @@ -357,8 +361,9 @@ private: typedef AttributeStreamNode _inherited; }; + template -AttributeStreamConstValue::AttributeStreamConstValue(const char *name, +AttributeStreamConstValue::AttributeStreamConstValue(const char* name, uint32 attributeType, Type value) : fAttr(name, attributeType, sizeof(Type)), fValue(value), @@ -366,35 +371,39 @@ AttributeStreamConstValue::AttributeStreamConstValue(const char *name, { } + template -const AttributeInfo * +const AttributeInfo* AttributeStreamConstValue::Next() { if (!fRewound) return NULL; - + fRewound = false; return &fAttr; } -template -const char * -AttributeStreamConstValue::Get() -{ - return (const char *)&fValue; -} template -bool -AttributeStreamConstValue::Fill(char *buffer) const +const char* +AttributeStreamConstValue::Get() +{ + return (const char*)&fValue; +} + + +template +bool +AttributeStreamConstValue::Fill(char* buffer) const { memcpy(buffer, &fValue, sizeof(Type)); return true; } + template -int32 -AttributeStreamConstValue::Find(const char *name, uint32 type) const +int32 +AttributeStreamConstValue::Find(const char* name, uint32 type) const { if (strcmp(fAttr.Name(), name) == 0 && type == fAttr.Type()) return 0; @@ -402,42 +411,47 @@ AttributeStreamConstValue::Find(const char *name, uint32 type) const return -1; } + class AttributeStreamBoolValue : public AttributeStreamConstValue { public: - AttributeStreamBoolValue(const char *name, bool value) + AttributeStreamBoolValue(const char* name, bool value) : AttributeStreamConstValue(name, B_BOOL_TYPE, value) {} }; + class AttributeStreamInt32Value : public AttributeStreamConstValue { public: - AttributeStreamInt32Value(const char *name, int32 value) + AttributeStreamInt32Value(const char* name, int32 value) : AttributeStreamConstValue(name, B_INT32_TYPE, value) {} }; + class AttributeStreamInt64Value : public AttributeStreamConstValue { public: - AttributeStreamInt64Value(const char *name, int64 value) + AttributeStreamInt64Value(const char* name, int64 value) : AttributeStreamConstValue(name, B_INT64_TYPE, value) {} }; + class AttributeStreamRectValue : public AttributeStreamConstValue { public: - AttributeStreamRectValue(const char *name, BRect value) + AttributeStreamRectValue(const char* name, BRect value) : AttributeStreamConstValue(name, B_RECT_TYPE, value) {} }; + class AttributeStreamFloatValue : public AttributeStreamConstValue { public: - AttributeStreamFloatValue(const char *name, float value) + AttributeStreamFloatValue(const char* name, float value) : AttributeStreamConstValue(name, B_FLOAT_TYPE, value) {} }; -} +} // namespace BPrivate using namespace BPrivate; diff --git a/src/kits/tracker/Attributes.h b/src/kits/tracker/Attributes.h index 2a513a38e6..b79f2ebc0b 100644 --- a/src/kits/tracker/Attributes.h +++ b/src/kits/tracker/Attributes.h @@ -31,157 +31,157 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef _ATTRIBUTES_H #define _ATTRIBUTES_H + namespace BPrivate { // viewable attributes -#define kAttrStatName "_stat/name" -#define kAttrRealName "_stat/realname" -#define kAttrStatSize "_stat/size" -#define kAttrStatModified "_stat/modified" -#define kAttrStatCreated "_stat/created" -#define kAttrStatMode "_stat/mode" -#define kAttrStatOwner "_stat/owner" -#define kAttrStatGroup "_stat/group" -#define kAttrPath "_trk/path" -#define kAttrOriginalPath "_trk/original_path" -#define kAttrAppVersion "_trk/app_version" -#define kAttrSystemVersion "_trk/system_version" -#define kAttrOpenWithRelation "_trk/open_with_relation" +#define kAttrStatName "_stat/name" +#define kAttrRealName "_stat/realname" +#define kAttrStatSize "_stat/size" +#define kAttrStatModified "_stat/modified" +#define kAttrStatCreated "_stat/created" +#define kAttrStatMode "_stat/mode" +#define kAttrStatOwner "_stat/owner" +#define kAttrStatGroup "_stat/group" +#define kAttrPath "_trk/path" +#define kAttrOriginalPath "_trk/original_path" +#define kAttrAppVersion "_trk/app_version" +#define kAttrSystemVersion "_trk/system_version" +#define kAttrOpenWithRelation "_trk/open_with_relation" // private attributes -#define kAttrWindowFrame "_trk/windframe" -#define kAttrWindowWorkspace "_trk/windwkspc" -#define kAttrWindowDecor "_trk/winddecor" +#define kAttrWindowFrame "_trk/windframe" +#define kAttrWindowWorkspace "_trk/windwkspc" +#define kAttrWindowDecor "_trk/winddecor" -#define kAttrQueryString "_trk/qrystr" -#define kAttrQueryVolume "_trk/qryvol1" +#define kAttrQueryString "_trk/qrystr" +#define kAttrQueryVolume "_trk/qryvol1" -#define kAttrMIMEType "BEOS:TYPE" -#define kAttrAppSignature "BEOS:APP_SIG" -#define kAttrPreferredApp "BEOS:PREF_APP" -#define kAttrLargeIcon "BEOS:L:STD_ICON" -#define kAttrMiniIcon "BEOS:M:STD_ICON" -#define kAttrIcon "BEOS:ICON" +#define kAttrMIMEType "BEOS:TYPE" +#define kAttrAppSignature "BEOS:APP_SIG" +#define kAttrPreferredApp "BEOS:PREF_APP" +#define kAttrLargeIcon "BEOS:L:STD_ICON" +#define kAttrMiniIcon "BEOS:M:STD_ICON" +#define kAttrIcon "BEOS:ICON" -#define kAttrDisksFrame "_trk/d_windframe" -#define kAttrDisksWorkspace "_trk/d_windwkspc" +#define kAttrDisksFrame "_trk/d_windframe" +#define kAttrDisksWorkspace "_trk/d_windwkspc" -#define kAttrOpenWindows "_trk/_windows_to_open_" +#define kAttrOpenWindows "_trk/_windows_to_open_" -#define kAttrClippingFile "_trk/_clipping_file_" +#define kAttrClippingFile "_trk/_clipping_file_" -#define kAttrQueryInitialMode "_trk/qryinitmode" -#define kAttrQueryInitialString "_trk/qryinitstr" -#define kAttrQueryInitialNumAttrs "_trk/qryinitnumattrs" -#define kAttrQueryInitialAttrs "_trk/qryinitattrs" -#define kAttrQueryInitialMime "_trk/qryinitmime" -#define kAttrQueryLastChange "_trk/qrylastchange" +#define kAttrQueryInitialMode "_trk/qryinitmode" +#define kAttrQueryInitialString "_trk/qryinitstr" +#define kAttrQueryInitialNumAttrs "_trk/qryinitnumattrs" +#define kAttrQueryInitialAttrs "_trk/qryinitattrs" +#define kAttrQueryInitialMime "_trk/qryinitmime" +#define kAttrQueryLastChange "_trk/qrylastchange" -#define kAttrQueryMoreOptions_le "_trk/qrymoreoptions_le" -#define kAttrQueryMoreOptions_be "_trk/qrymoreoptions" +#define kAttrQueryMoreOptions_le "_trk/qrymoreoptions_le" +#define kAttrQueryMoreOptions_be "_trk/qrymoreoptions" -#define kAttrQueryTemplate "_trk/queryTemplate" -#define kAttrQueryTemplateName "_trk/queryTemplateName" -#define kAttrDynamicDateQuery "_trk/queryDynamicDate" +#define kAttrQueryTemplate "_trk/queryTemplate" +#define kAttrQueryTemplateName "_trk/queryTemplateName" +#define kAttrDynamicDateQuery "_trk/queryDynamicDate" // attributes that need endian swapping (stored as raw) -#define kAttrPoseInfo_be "_trk/pinfo" -#define kAttrPoseInfo_le "_trk/pinfo_le" -#define kAttrDisksPoseInfo_be "_trk/d_pinfo" -#define kAttrDisksPoseInfo_le "_trk/d_pinfo_le" -#define kAttrTrashPoseInfo_be "_trk/t_pinfo" -#define kAttrTrashPoseInfo_le "_trk/t_pinfo_le" -#define kAttrColumns_be "_trk/columns" -#define kAttrColumns_le "_trk/columns_le" -#define kAttrViewState_be "_trk/viewstate" -#define kAttrViewState_le "_trk/viewstate_le" -#define kAttrDisksViewState_be "_trk/d_viewstate" -#define kAttrDisksViewState_le "_trk/d_viewstate_le" -#define kAttrDesktopViewState_be "_trk/desk_viewstate" -#define kAttrDesktopViewState_le "_trk/desk_viewstate_le" -#define kAttrDisksColumns_be "_trk/d_columns" -#define kAttrDisksColumns_le "_trk/d_columns_le" +#define kAttrPoseInfo_be "_trk/pinfo" +#define kAttrPoseInfo_le "_trk/pinfo_le" +#define kAttrDisksPoseInfo_be "_trk/d_pinfo" +#define kAttrDisksPoseInfo_le "_trk/d_pinfo_le" +#define kAttrTrashPoseInfo_be "_trk/t_pinfo" +#define kAttrTrashPoseInfo_le "_trk/t_pinfo_le" +#define kAttrColumns_be "_trk/columns" +#define kAttrColumns_le "_trk/columns_le" +#define kAttrViewState_be "_trk/viewstate" +#define kAttrViewState_le "_trk/viewstate_le" +#define kAttrDisksViewState_be "_trk/d_viewstate" +#define kAttrDisksViewState_le "_trk/d_viewstate_le" +#define kAttrDesktopViewState_be "_trk/desk_viewstate" +#define kAttrDesktopViewState_le "_trk/desk_viewstate_le" +#define kAttrDisksColumns_be "_trk/d_columns" +#define kAttrDisksColumns_le "_trk/d_columns_le" -#define kAttrExtendedPoseInfo_be "_trk/xtpinfo" -#define kAttrExtendedPoseInfo_le "_trk/xtpinfo_le" -#define kAttrExtendedDisksPoseInfo_be "_trk/xt_d_pinfo" -#define kAttrExtendedDisksPoseInfo_le "_trk/xt_d_pinfo_le" +#define kAttrExtendedPoseInfo_be "_trk/xtpinfo" +#define kAttrExtendedPoseInfo_le "_trk/xtpinfo_le" +#define kAttrExtendedDisksPoseInfo_be "_trk/xt_d_pinfo" +#define kAttrExtendedDisksPoseInfo_le "_trk/xt_d_pinfo_le" #if B_HOST_IS_LENDIAN -#define kEndianSuffix "_le" -#define kForeignEndianSuffix "" +#define kEndianSuffix "_le" +#define kForeignEndianSuffix "" -#define kAttrDisksPoseInfo kAttrDisksPoseInfo_le -#define kAttrDisksPoseInfoForeign kAttrDisksPoseInfo_be +#define kAttrDisksPoseInfo kAttrDisksPoseInfo_le +#define kAttrDisksPoseInfoForeign kAttrDisksPoseInfo_be -#define kAttrTrashPoseInfo kAttrTrashPoseInfo_le -#define kAttrTrashPoseInfoForeign kAttrTrashPoseInfo_be +#define kAttrTrashPoseInfo kAttrTrashPoseInfo_le +#define kAttrTrashPoseInfoForeign kAttrTrashPoseInfo_be -#define kAttrPoseInfo kAttrPoseInfo_le -#define kAttrPoseInfoForeign kAttrPoseInfo_be +#define kAttrPoseInfo kAttrPoseInfo_le +#define kAttrPoseInfoForeign kAttrPoseInfo_be -#define kAttrColumns kAttrColumns_le -#define kAttrColumnsForeign kAttrColumns_be +#define kAttrColumns kAttrColumns_le +#define kAttrColumnsForeign kAttrColumns_be -#define kAttrViewState kAttrViewState_le -#define kAttrViewStateForeign kAttrViewState_be +#define kAttrViewState kAttrViewState_le +#define kAttrViewStateForeign kAttrViewState_be -#define kAttrDisksViewState kAttrDisksViewState_le -#define kAttrDisksViewStateForeign kAttrDisksViewState_be +#define kAttrDisksViewState kAttrDisksViewState_le +#define kAttrDisksViewStateForeign kAttrDisksViewState_be -#define kAttrDisksColumns kAttrDisksColumns_le -#define kAttrDisksColumnsForeign kAttrDisksColumns_be +#define kAttrDisksColumns kAttrDisksColumns_le +#define kAttrDisksColumnsForeign kAttrDisksColumns_be -#define kAttrDesktopViewState kAttrDesktopViewState_le -#define kAttrDesktopViewStateForeign kAttrDesktopViewState_be +#define kAttrDesktopViewState kAttrDesktopViewState_le +#define kAttrDesktopViewStateForeign kAttrDesktopViewState_be -#define kAttrQueryMoreOptions kAttrQueryMoreOptions_le -#define kAttrQueryMoreOptionsForeign kAttrQueryMoreOptions_be -#define kAttrExtendedPoseInfo kAttrExtendedPoseInfo_le -#define kAttrExtendedPoseInfoForegin kAttrExtendedPoseInfo_be -#define kAttrExtendedDisksPoseInfo kAttrExtendedDisksPoseInfo_le -#define kAttrExtendedDisksPoseInfoForegin kAttrExtendedDisksPoseInfo_be +#define kAttrQueryMoreOptions kAttrQueryMoreOptions_le +#define kAttrQueryMoreOptionsForeign kAttrQueryMoreOptions_be +#define kAttrExtendedPoseInfo kAttrExtendedPoseInfo_le +#define kAttrExtendedPoseInfoForegin kAttrExtendedPoseInfo_be +#define kAttrExtendedDisksPoseInfo kAttrExtendedDisksPoseInfo_le +#define kAttrExtendedDisksPoseInfoForegin kAttrExtendedDisksPoseInfo_be #else -#define kEndianSuffix "" -#define kForeignEndianSuffix "_le" +#define kEndianSuffix "" +#define kForeignEndianSuffix "_le" -#define kAttrDisksPoseInfo kAttrDisksPoseInfo_be -#define kAttrDisksPoseInfoForeign kAttrDisksPoseInfo_le +#define kAttrDisksPoseInfo kAttrDisksPoseInfo_be +#define kAttrDisksPoseInfoForeign kAttrDisksPoseInfo_le -#define kAttrTrashPoseInfo kAttrTrashPoseInfo_be -#define kAttrTrashPoseInfoForeign kAttrTrashPoseInfo_le +#define kAttrTrashPoseInfo kAttrTrashPoseInfo_be +#define kAttrTrashPoseInfoForeign kAttrTrashPoseInfo_le -#define kAttrPoseInfo kAttrPoseInfo_be -#define kAttrPoseInfoForeign kAttrPoseInfo_le +#define kAttrPoseInfo kAttrPoseInfo_be +#define kAttrPoseInfoForeign kAttrPoseInfo_le -#define kAttrColumns kAttrColumns_be -#define kAttrColumnsForeign kAttrColumns_le +#define kAttrColumns kAttrColumns_be +#define kAttrColumnsForeign kAttrColumns_le -#define kAttrViewState kAttrViewState_be -#define kAttrViewStateForeign kAttrViewState_le +#define kAttrViewState kAttrViewState_be +#define kAttrViewStateForeign kAttrViewState_le -#define kAttrDisksViewState kAttrDisksViewState_be -#define kAttrDisksViewStateForeign kAttrDisksViewState_le +#define kAttrDisksViewState kAttrDisksViewState_be +#define kAttrDisksViewStateForeign kAttrDisksViewState_le -#define kAttrDisksColumns kAttrDisksColumns_be -#define kAttrDisksColumnsForeign kAttrDisksColumns_le +#define kAttrDisksColumns kAttrDisksColumns_be +#define kAttrDisksColumnsForeign kAttrDisksColumns_le -#define kAttrDesktopViewState kAttrViewState_be -#define kAttrDesktopViewStateForeign kAttrViewState_le +#define kAttrDesktopViewState kAttrViewState_be +#define kAttrDesktopViewStateForeign kAttrViewState_le -#define kAttrQueryMoreOptions kAttrQueryMoreOptions_be -#define kAttrQueryMoreOptionsForeign kAttrQueryMoreOptions_le -#define kAttrExtendedPoseInfo kAttrExtendedPoseInfo_be -#define kAttrExtendedPoseInfoForegin kAttrExtendedPoseInfo_le -#define kAttrExtendedDisksPoseInfo kAttrExtendedDisksPoseInfo_be -#define kAttrExtendedDisksPoseInfoForegin kAttrExtendedDisksPoseInfo_le +#define kAttrQueryMoreOptions kAttrQueryMoreOptions_be +#define kAttrQueryMoreOptionsForeign kAttrQueryMoreOptions_le +#define kAttrExtendedPoseInfo kAttrExtendedPoseInfo_be +#define kAttrExtendedPoseInfoForegin kAttrExtendedPoseInfo_le +#define kAttrExtendedDisksPoseInfo kAttrExtendedDisksPoseInfo_be +#define kAttrExtendedDisksPoseInfoForegin kAttrExtendedDisksPoseInfo_le #endif diff --git a/src/kits/tracker/AutoMounterSettings.cpp b/src/kits/tracker/AutoMounterSettings.cpp index 795870fa44..33730b3bcd 100644 --- a/src/kits/tracker/AutoMounterSettings.cpp +++ b/src/kits/tracker/AutoMounterSettings.cpp @@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include "AutoMounterSettings.h" #include diff --git a/src/kits/tracker/AutoMounterSettings.h b/src/kits/tracker/AutoMounterSettings.h index 88fa68de11..75cfbb90cb 100644 --- a/src/kits/tracker/AutoMounterSettings.h +++ b/src/kits/tracker/AutoMounterSettings.h @@ -31,7 +31,6 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef AUTOMOUNTER_SETTINGS_H #define AUTOMOUNTER_SETTINGS_H @@ -43,13 +42,13 @@ namespace BPrivate { class AutomountSettingsDialog : public BWindow { public: - AutomountSettingsDialog(BMessage *settings, const BMessenger &target); + AutomountSettingsDialog(BMessage* settings, const BMessenger &target); virtual ~AutomountSettingsDialog(); static void RunAutomountSettings(const BMessenger &target); private: - static AutomountSettingsDialog *sOneCopyOnly; + static AutomountSettingsDialog* sOneCopyOnly; }; } // namespace BPrivate diff --git a/src/kits/tracker/Background.h b/src/kits/tracker/Background.h index cf8afccddb..b850313ff4 100644 --- a/src/kits/tracker/Background.h +++ b/src/kits/tracker/Background.h @@ -68,4 +68,4 @@ enum { const int32 B_RESTORE_BACKGROUND_IMAGE = 'Tbgr'; // force a Tracker window to // use a new background image -#endif /* _TRACKER_BACKGROUND_H */ +#endif // _TRACKER_BACKGROUND_H diff --git a/src/kits/tracker/BackgroundImage.cpp b/src/kits/tracker/BackgroundImage.cpp index 565ee90dc3..f12d110bb0 100644 --- a/src/kits/tracker/BackgroundImage.cpp +++ b/src/kits/tracker/BackgroundImage.cpp @@ -33,7 +33,7 @@ All rights reserved. */ // Classes used for setting up and managing background images -// + #include #include @@ -50,26 +50,28 @@ All rights reserved. #include "Commands.h" #include "PoseView.h" + namespace BPrivate { -const char *kBackgroundImageInfo = B_BACKGROUND_INFO; -const char *kBackgroundImageInfoOffset = B_BACKGROUND_ORIGIN; -const char *kBackgroundImageInfoTextOutline = B_BACKGROUND_TEXT_OUTLINE; -const char *kBackgroundImageInfoMode = B_BACKGROUND_MODE; -const char *kBackgroundImageInfoWorkspaces = B_BACKGROUND_WORKSPACES; -const char *kBackgroundImageInfoPath = B_BACKGROUND_IMAGE; +const char* kBackgroundImageInfo = B_BACKGROUND_INFO; +const char* kBackgroundImageInfoOffset = B_BACKGROUND_ORIGIN; +const char* kBackgroundImageInfoTextOutline = B_BACKGROUND_TEXT_OUTLINE; +const char* kBackgroundImageInfoMode = B_BACKGROUND_MODE; +const char* kBackgroundImageInfoWorkspaces = B_BACKGROUND_WORKSPACES; +const char* kBackgroundImageInfoPath = B_BACKGROUND_IMAGE; -} +} // namespace BPrivate -BackgroundImage * -BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop) + +BackgroundImage* +BackgroundImage::GetBackgroundImage(const BNode* node, bool isDesktop) { attr_info info; if (node->GetAttrInfo(kBackgroundImageInfo, &info) != B_OK) return NULL; BMessage container; - char *buffer = new char [info.size]; + char* buffer = new char [info.size]; status_t error = node->ReadAttr(kBackgroundImageInfo, info.type, 0, buffer, (size_t)info.size); if (error == info.size) @@ -80,14 +82,14 @@ BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop) if (error != B_OK) return NULL; - BackgroundImage *result = NULL; + BackgroundImage* result = NULL; for (int32 index = 0; ; index++) { - const char *path; + const char* path; uint32 workspaces = B_ALL_WORKSPACES; Mode mode = kTiled; bool textWidgetLabelOutline = false; BPoint offset; - BBitmap *bitmap = NULL; + BBitmap* bitmap = NULL; if (container.FindString(kBackgroundImageInfoPath, index, &path) == B_OK) { bitmap = BTranslationUtils::GetBitmap(path); @@ -102,12 +104,12 @@ BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop) be_control_look->SetBackgroundInfo(container); } - container.FindInt32(kBackgroundImageInfoWorkspaces, index, (int32 *)&workspaces); - container.FindInt32(kBackgroundImageInfoMode, index, (int32 *)&mode); + container.FindInt32(kBackgroundImageInfoWorkspaces, index, (int32*)&workspaces); + container.FindInt32(kBackgroundImageInfoMode, index, (int32*)&mode); container.FindBool(kBackgroundImageInfoTextOutline, index, &textWidgetLabelOutline); container.FindPoint(kBackgroundImageInfoOffset, index, &offset); - BackgroundImage::BackgroundImageInfo *imageInfo = new + BackgroundImage::BackgroundImageInfo* imageInfo = new BackgroundImage::BackgroundImageInfo(workspaces, bitmap, mode, offset, textWidgetLabelOutline); @@ -121,7 +123,7 @@ BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop) BackgroundImage::BackgroundImageInfo::BackgroundImageInfo(uint32 workspaces, - BBitmap *bitmap, Mode mode, BPoint offset, bool textWidgetOutline) + BBitmap* bitmap, Mode mode, BPoint offset, bool textWidgetOutline) : fWorkspace(workspaces), fBitmap(bitmap), fMode(mode), @@ -137,7 +139,7 @@ BackgroundImage::BackgroundImageInfo::~BackgroundImageInfo() } -BackgroundImage::BackgroundImage(const BNode *node, bool desktop) +BackgroundImage::BackgroundImage(const BNode* node, bool desktop) : fIsDesktop(desktop), fDefinedByNode(*node), fView(NULL), @@ -153,20 +155,20 @@ BackgroundImage::~BackgroundImage() void -BackgroundImage::Add(BackgroundImageInfo *info) +BackgroundImage::Add(BackgroundImageInfo* info) { fBitmapForWorkspaceList.AddItem(info); } void -BackgroundImage::Show(BView *view, int32 workspace) +BackgroundImage::Show(BView* view, int32 workspace) { fView = view; - BackgroundImageInfo *info = ImageInfoForWorkspace(workspace); + BackgroundImageInfo* info = ImageInfoForWorkspace(workspace); if (info) { - BPoseView *poseView = dynamic_cast(fView); + BPoseView* poseView = dynamic_cast(fView); if (poseView) poseView->SetWidgetTextOutline(info->fTextWidgetOutline); Show(info, fView); @@ -174,9 +176,9 @@ BackgroundImage::Show(BView *view, int32 workspace) } void -BackgroundImage::Show(BackgroundImageInfo *info, BView *view) +BackgroundImage::Show(BackgroundImageInfo* info, BView* view) { - BPoseView *poseView = dynamic_cast(view); + BPoseView* poseView = dynamic_cast(view); if (poseView) poseView->SetWidgetTextOutline(info->fTextWidgetOutline); @@ -271,7 +273,7 @@ BackgroundImage::Remove() if (fShowingBitmap) { fView->ClearViewBitmap(); fView->Invalidate(); - BPoseView *poseView = dynamic_cast(fView); + BPoseView* poseView = dynamic_cast(fView); // make sure text widgets draw the default way, erasing their background if (poseView) poseView->SetWidgetTextOutline(true); @@ -279,7 +281,7 @@ BackgroundImage::Remove() fShowingBitmap = NULL; } -BackgroundImage::BackgroundImageInfo * +BackgroundImage::BackgroundImageInfo* BackgroundImage::ImageInfoForWorkspace(int32 workspace) const { uint32 workspaceMask = 1; @@ -292,9 +294,9 @@ BackgroundImage::ImageInfoForWorkspace(int32 workspace) const // do a simple lookup for the most likely candidate bitmap - // pick the imageInfo that is only defined for this workspace over one // that supports multiple workspaces - BackgroundImageInfo *result = NULL; + BackgroundImageInfo* result = NULL; for (int32 index = 0; index < count; index++) { - BackgroundImageInfo *info = fBitmapForWorkspaceList.ItemAt(index); + BackgroundImageInfo* info = fBitmapForWorkspaceList.ItemAt(index); if (info->fWorkspace == workspaceMask) return info; if (info->fWorkspace & workspaceMask) @@ -305,7 +307,7 @@ BackgroundImage::ImageInfoForWorkspace(int32 workspace) const } void -BackgroundImage::WorkspaceActivated(BView *view, int32 workspace, bool state) +BackgroundImage::WorkspaceActivated(BView* view, int32 workspace, bool state) { if (!fIsDesktop) // we only care for desktop bitmaps @@ -315,13 +317,13 @@ BackgroundImage::WorkspaceActivated(BView *view, int32 workspace, bool state) // we only care comming into a new workspace, not leaving one return; - BackgroundImageInfo *info = ImageInfoForWorkspace(workspace); + BackgroundImageInfo* info = ImageInfoForWorkspace(workspace); if (info != fShowingBitmap) { if (info) Show(info, view); else { - if (BPoseView *poseView = dynamic_cast(view)) + if (BPoseView* poseView = dynamic_cast(view)) poseView->SetWidgetTextOutline(true); view->ClearViewBitmap(); view->Invalidate(); @@ -350,16 +352,16 @@ BackgroundImage::ScreenChanged(BRect, color_space) } } -BackgroundImage * -BackgroundImage::Refresh(BackgroundImage *oldBackgroundImage, - const BNode *fromNode, bool desktop, BPoseView *poseView) +BackgroundImage* +BackgroundImage::Refresh(BackgroundImage* oldBackgroundImage, + const BNode* fromNode, bool desktop, BPoseView* poseView) { if (oldBackgroundImage) { oldBackgroundImage->Remove(); delete oldBackgroundImage; } - BackgroundImage *result = GetBackgroundImage(fromNode, desktop); + BackgroundImage* result = GetBackgroundImage(fromNode, desktop); if (result && poseView->ViewMode() != kListMode) result->Show(poseView, current_workspace()); diff --git a/src/kits/tracker/BackgroundImage.h b/src/kits/tracker/BackgroundImage.h index cba8f75405..d5857caa23 100644 --- a/src/kits/tracker/BackgroundImage.h +++ b/src/kits/tracker/BackgroundImage.h @@ -31,16 +31,17 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - -// Classes used for setting up and managing background images -// - #ifndef __BACKGROUND_IMAGE__ #define __BACKGROUND_IMAGE__ + +// Classes used for setting up and managing background images + + #include #include "ObjectList.h" + class BNode; class BView; class BBitmap; @@ -50,12 +51,12 @@ namespace BPrivate { class BackgroundImage; class BPoseView; -extern const char *kBackgroundImageInfo; -extern const char *kBackgroundImageInfoOffset; -extern const char *kBackgroundImageInfoTextOutline; -extern const char *kBackgroundImageInfoMode; -extern const char *kBackgroundImageInfoWorkspaces; -extern const char *kBackgroundImageInfoPath; +extern const char* kBackgroundImageInfo; +extern const char* kBackgroundImageInfoOffset; +extern const char* kBackgroundImageInfoTextOutline; +extern const char* kBackgroundImageInfoMode; +extern const char* kBackgroundImageInfoWorkspaces; +extern const char* kBackgroundImageInfoPath; const uint32 kRestoreBackgroundImage = 'Tbgr'; @@ -76,44 +77,44 @@ public: class BackgroundImageInfo { // element of the per-workspace list public: - BackgroundImageInfo(uint32 workspace, BBitmap *bitmap, Mode mode, BPoint offset, + BackgroundImageInfo(uint32 workspace, BBitmap* bitmap, Mode mode, BPoint offset, bool textWidgetOutline); ~BackgroundImageInfo(); uint32 fWorkspace; - BBitmap *fBitmap; + BBitmap* fBitmap; Mode fMode; BPoint fOffset; bool fTextWidgetOutline; }; - static BackgroundImage *GetBackgroundImage(const BNode *node, + static BackgroundImage* GetBackgroundImage(const BNode* node, bool isDesktop); // create a BackgroundImage object by reading it from a node virtual ~BackgroundImage(); - void Show(BView *view, int32 workspace); + void Show(BView* view, int32 workspace); // display the right background for a given workspace void Remove(); // remove the background from it's current view - void WorkspaceActivated(BView *view, int32 workspace, bool state); + void WorkspaceActivated(BView* view, int32 workspace, bool state); // respond to a workspace change void ScreenChanged(BRect rect, color_space space); // respond to a screen size change - static BackgroundImage *Refresh(BackgroundImage *oldBackgroundImage, - const BNode *fromNode, bool desktop, BPoseView *poseView); + static BackgroundImage* Refresh(BackgroundImage* oldBackgroundImage, + const BNode* fromNode, bool desktop, BPoseView* poseView); // respond to a background image setting change private: - BackgroundImageInfo *ImageInfoForWorkspace(int32) const; - void Show(BackgroundImageInfo *, BView *view); + BackgroundImageInfo* ImageInfoForWorkspace(int32) const; + void Show(BackgroundImageInfo*, BView* view); - BackgroundImage(const BNode *, bool); + BackgroundImage(const BNode*, bool); // no public constructor, GetBackgroundImage factory function is // used instead - void Add(BackgroundImageInfo *); + void Add(BackgroundImageInfo*); float BRectRatio(BRect rect); float BRectHorizontalOverlap(BRect hostRect, BRect resizedRect); @@ -121,13 +122,12 @@ private: bool fIsDesktop; BNode fDefinedByNode; - BView *fView; - BackgroundImageInfo *fShowingBitmap; + BView* fView; + BackgroundImageInfo* fShowingBitmap; BObjectList fBitmapForWorkspaceList; }; - } // namespace BPrivate using namespace BPrivate; diff --git a/src/kits/tracker/Bitmaps.cpp b/src/kits/tracker/Bitmaps.cpp index ed22d54217..2f4f68cbf5 100644 --- a/src/kits/tracker/Bitmaps.cpp +++ b/src/kits/tracker/Bitmaps.cpp @@ -48,7 +48,7 @@ All rights reserved. #endif -BImageResources::BImageResources(void *memAddr) +BImageResources::BImageResources(void* memAddr) { image_id image = find_image(memAddr); image_info info; @@ -71,7 +71,7 @@ BImageResources::~BImageResources() } -const BResources * +const BResources* BImageResources::ViewResources() const { if (fLock.Lock() != B_OK) @@ -81,7 +81,7 @@ BImageResources::ViewResources() const } -BResources * +BResources* BImageResources::ViewResources() { if (fLock.Lock() != B_OK) @@ -92,7 +92,7 @@ BImageResources::ViewResources() status_t -BImageResources::FinishResources(BResources *res) const +BImageResources::FinishResources(BResources* res) const { ASSERT(res == &fResources); if (res != &fResources) @@ -103,8 +103,8 @@ BImageResources::FinishResources(BResources *res) const } -const void * -BImageResources::LoadResource(type_code type, int32 id, size_t *out_size) const +const void* +BImageResources::LoadResource(type_code type, int32 id, size_t* out_size) const { // Serialize execution. // Looks like BResources is not really thread safe. We should @@ -116,12 +116,12 @@ BImageResources::LoadResource(type_code type, int32 id, size_t *out_size) const // Return the resource. Because we never change the BResources // object, the returned data will not change until TTracker is // destroyed. - return const_cast(&fResources)->LoadResource(type, id, out_size); + return const_cast(&fResources)->LoadResource(type, id, out_size); } -const void * -BImageResources::LoadResource(type_code type, const char *name, size_t *out_size) const +const void* +BImageResources::LoadResource(type_code type, const char* name, size_t* out_size) const { // Serialize execution. BAutolock lock(fLock); @@ -131,15 +131,15 @@ BImageResources::LoadResource(type_code type, const char *name, size_t *out_size // Return the resource. Because we never change the BResources // object, the returned data will not change until TTracker is // destroyed. - return const_cast(&fResources)->LoadResource(type, name, out_size); + return const_cast(&fResources)->LoadResource(type, name, out_size); } status_t -BImageResources::GetIconResource(int32 id, icon_size size, BBitmap *dest) const +BImageResources::GetIconResource(int32 id, icon_size size, BBitmap* dest) const { size_t length = 0; - const void *data; + const void* data; #ifdef __HAIKU__ // try to load vector icon @@ -194,27 +194,30 @@ BImageResources::GetIconResource(int32 id, const uint8** iconData, image_id -BImageResources::find_image(void *memAddr) const +BImageResources::find_image(void* memAddr) const { image_info info; int32 cookie = 0; while (get_next_image_info(0, &cookie, &info) == B_OK) - if ((info.text <= memAddr && (((uint8 *)info.text)+info.text_size) > memAddr) - ||(info.data <= memAddr && (((uint8 *)info.data)+info.data_size) > memAddr)) + if ((info.text <= memAddr + && (((uint8*)info.text)+info.text_size) > memAddr) + || (info.data <= memAddr + && (((uint8*)info.data)+info.data_size) > memAddr)) { // Found the image. return info.id; + } return -1; } status_t -BImageResources::GetBitmapResource(type_code type, int32 id, BBitmap **out) const +BImageResources::GetBitmapResource(type_code type, int32 id, BBitmap** out) const { *out = NULL; size_t len = 0; - const void *data = LoadResource(type, id, &len); + const void* data = LoadResource(type, id, &len); if (data == NULL) { TRESPASS(); @@ -245,7 +248,7 @@ BImageResources::GetBitmapResource(type_code type, int32 id, BBitmap **out) cons static BLocker resLock; -static BImageResources *resources = NULL; +static BImageResources* resources = NULL; // This class is used as a static instance to delete the resources // global object when the image is getting unloaded. @@ -265,7 +268,7 @@ namespace BPrivate { static _TTrackerCleanupResources CleanupResources; -BImageResources *GetTrackerResources() +BImageResources* GetTrackerResources() { if (!resources) { BAutolock lock(&resLock); diff --git a/src/kits/tracker/Bitmaps.h b/src/kits/tracker/Bitmaps.h index 3f3ced9219..c04331fd67 100644 --- a/src/kits/tracker/Bitmaps.h +++ b/src/kits/tracker/Bitmaps.h @@ -31,7 +31,6 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef __BITS__ #define __BITS__ @@ -43,31 +42,32 @@ All rights reserved. #include "TrackerIcons.h" + class BBitmap; namespace BPrivate { class BImageResources { - // convenience class for accessing + // convenience class for accessing public: - BImageResources(void *memAddr); + BImageResources(void* memAddr); ~BImageResources(); - - BResources *ViewResources(); - const BResources *ViewResources() const; - - status_t FinishResources(BResources *) const; - - const void *LoadResource(type_code type, int32 id, - size_t *outSize) const; - const void *LoadResource(type_code type, const char *name, - size_t *outSize) const; + + BResources* ViewResources(); + const BResources* ViewResources() const; + + status_t FinishResources(BResources*) const; + + const void* LoadResource(type_code type, int32 id, + size_t* outSize) const; + const void* LoadResource(type_code type, const char* name, + size_t* outSize) const; // load a resource from the Tracker executable, just like the // corresponding functions in BResources. These methods are // thread-safe. - - status_t GetIconResource(int32 id, icon_size size, BBitmap *dest) const; + + status_t GetIconResource(int32 id, icon_size size, BBitmap* dest) const; // this is a wrapper around LoadResource(), for retrieving // B_LARGE_ICON and B_MINI_ICON ('ICON' and 'MICN' respectively) // resources. this does sanity checking on the found data, @@ -78,7 +78,7 @@ public: // this is a wrapper around LoadResource(), for retrieving // the vector icon data - status_t GetBitmapResource(type_code type, int32 id, BBitmap **out) const; + status_t GetBitmapResource(type_code type, int32 id, BBitmap** out) const; // this is a wrapper around LoadResource(), for retrieving // arbitrary bitmaps. the resource with the given type and // id is looked up, and a BBitmap created from it and returned @@ -86,13 +86,12 @@ public: // that is an archived bitmap object. private: - image_id find_image(void *memAddr) const; + image_id find_image(void* memAddr) const; mutable BLocker fLock; BResources fResources; }; - extern #ifdef _IMPEXP_TRACKER @@ -100,6 +99,7 @@ _IMPEXP_TRACKER #endif BImageResources* GetTrackerResources(); + } // namespace BPrivate using namespace BPrivate; diff --git a/src/kits/tracker/Commands.h b/src/kits/tracker/Commands.h index c2e19d3646..208cbb68ff 100644 --- a/src/kits/tracker/Commands.h +++ b/src/kits/tracker/Commands.h @@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef _COMMANDS_H #define _COMMANDS_H + #include "PublicCommands.h" #include diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp index fc9649e375..34d9b28550 100644 --- a/src/kits/tracker/ContainerWindow.cpp +++ b/src/kits/tracker/ContainerWindow.cpp @@ -110,12 +110,12 @@ namespace BPrivate { class DraggableContainerIcon : public BView { public: - DraggableContainerIcon(BRect rect, const char *name, uint32 resizeMask); + DraggableContainerIcon(BRect rect, const char* name, uint32 resizeMask); virtual void AttachedToWindow(); virtual void MouseDown(BPoint where); virtual void MouseUp(BPoint where); - virtual void MouseMoved(BPoint point, uint32 /*transit*/, const BMessage *message); + virtual void MouseMoved(BPoint point, uint32 /*transit*/, const BMessage* message); virtual void FrameMoved(BPoint newLocation); virtual void Draw(BRect updateRect); @@ -128,8 +128,8 @@ class DraggableContainerIcon : public BView { } // namespace BPrivate struct AddOneAddonParams { - BObjectList *primaryList; - BObjectList *secondaryList; + BObjectList* primaryList; + BObjectList* secondaryList; }; struct StaggerOneParams { @@ -147,9 +147,9 @@ BRect BContainerWindow::sNewWindRect(85, 50, 548, 280); namespace BPrivate { filter_result -ActivateWindowFilter(BMessage *, BHandler **target, BMessageFilter *) +ActivateWindowFilter(BMessage*, BHandler** target, BMessageFilter*) { - BView *view = dynamic_cast(*target); + BView* view = dynamic_cast(*target); // activate the window if no PoseView or DraggableContainerIcon had been pressed // (those will activate the window themselves, if necessary) @@ -164,7 +164,7 @@ ActivateWindowFilter(BMessage *, BHandler **target, BMessageFilter *) static void -StripShortcut(const Model *model, char *result, uint32 &shortcut) +StripShortcut(const Model* model, char* result, uint32 &shortcut) { // model name (possibly localized) for the menu item label strlcpy(result, model->Name(), B_FILE_NAME_LENGTH); @@ -189,14 +189,14 @@ StripShortcut(const Model *model, char *result, uint32 &shortcut) } -static const Model * -MatchOne(const Model *model, void *castToName) +static const Model* +MatchOne(const Model* model, void* castToName) { char buffer[B_FILE_NAME_LENGTH]; uint32 dummy; StripShortcut(model, buffer, dummy); - if (strcmp(buffer, (const char *)castToName) == 0) { + if (strcmp(buffer, (const char*)castToName) == 0) { // found match, bail out return model; } @@ -206,7 +206,7 @@ MatchOne(const Model *model, void *castToName) int -CompareLabels(const BMenuItem *item1, const BMenuItem *item2) +CompareLabels(const BMenuItem* item1, const BMenuItem* item2) { return strcasecmp(item1->Label(), item2->Label()); } @@ -215,14 +215,14 @@ CompareLabels(const BMenuItem *item1, const BMenuItem *item2) static bool -AddOneAddon(const Model *model, const char *name, uint32 shortcut, bool primary, void *context) +AddOneAddon(const Model* model, const char* name, uint32 shortcut, bool primary, void* context) { - AddOneAddonParams *params = (AddOneAddonParams *)context; + AddOneAddonParams* params = (AddOneAddonParams*)context; - BMessage *message = new BMessage(kLoadAddOn); + BMessage* message = new BMessage(kLoadAddOn); message->AddRef("refs", model->EntryRef()); - ModelMenuItem *item = new ModelMenuItem(model, name, message, + ModelMenuItem* item = new ModelMenuItem(model, name, message, (char)shortcut, B_OPTION_KEY); if (primary) @@ -235,7 +235,7 @@ AddOneAddon(const Model *model, const char *name, uint32 shortcut, bool primary, static int32 -AddOnThread(BMessage *refsMessage, entry_ref addonRef, entry_ref dirRef) +AddOnThread(BMessage* refsMessage, entry_ref addonRef, entry_ref dirRef) { std::auto_ptr refsMessagePtr(refsMessage); @@ -248,15 +248,15 @@ AddOnThread(BMessage *refsMessage, entry_ref addonRef, entry_ref dirRef) if (result == B_OK) { image_id addonImage = load_add_on(path.Path()); if (addonImage >= 0) { - void (*processRefs)(entry_ref, BMessage *, void *); - result = get_image_symbol(addonImage, "process_refs", 2, (void **)&processRefs); + void (*processRefs)(entry_ref, BMessage*, void*); + result = get_image_symbol(addonImage, "process_refs", 2, (void**)&processRefs); #ifndef __INTEL__ if (result < 0) { PRINT(("trying old legacy ppc signature\n")); // try old-style addon signature result = get_image_symbol(addonImage, - "process_refs__F9entry_refP8BMessagePv", 2, (void **)&processRefs); + "process_refs__F9entry_refP8BMessagePv", 2, (void**)&processRefs); } #endif @@ -289,7 +289,7 @@ AddOnThread(BMessage *refsMessage, entry_ref addonRef, entry_ref dirRef) static bool -NodeHasSavedState(const BNode *node) +NodeHasSavedState(const BNode* node) { attr_info info; return node->GetAttrInfo(kAttrWindowFrame, &info) == B_OK; @@ -297,11 +297,11 @@ NodeHasSavedState(const BNode *node) static bool -OffsetFrameOne(const char *DEBUG_ONLY(name), uint32, off_t, void *castToRect, - void *castToParams) +OffsetFrameOne(const char* DEBUG_ONLY(name), uint32, off_t, void* castToRect, + void* castToParams) { ASSERT(strcmp(name, kAttrWindowFrame) == 0); - StaggerOneParams *params = (StaggerOneParams *)castToParams; + StaggerOneParams* params = (StaggerOneParams*)castToParams; if (!params->rectFromParent) return false; @@ -309,20 +309,20 @@ OffsetFrameOne(const char *DEBUG_ONLY(name), uint32, off_t, void *castToRect, if (!castToRect) return false; - ((BRect *)castToRect)->OffsetBy(kWindowStaggerBy, kWindowStaggerBy); + ((BRect*)castToRect)->OffsetBy(kWindowStaggerBy, kWindowStaggerBy); return true; } static void -AddMimeTypeString(BObjectList &list, Model *model) +AddMimeTypeString(BObjectList &list, Model* model) { - BString *mimeType = new BString(model->MimeType()); - + BString* mimeType = new BString(model->MimeType()); + if (mimeType->Length()) { // only add the type if it's not already there for (int32 i = list.CountItems(); i-- > 0;) { - BString *string = list.ItemAt(i); + BString* string = list.ItemAt(i); if (string != NULL && !string->ICompare(*mimeType)) { delete mimeType; return; @@ -336,7 +336,7 @@ AddMimeTypeString(BObjectList &list, Model *model) // #pragma mark - -DraggableContainerIcon::DraggableContainerIcon(BRect rect, const char *name, +DraggableContainerIcon::DraggableContainerIcon(BRect rect, const char* name, uint32 resizeMask) : BView(rect, name, resizeMask, B_WILL_DRAW | B_FRAME_EVENTS), fDragButton(0), @@ -358,7 +358,7 @@ void DraggableContainerIcon::MouseDown(BPoint point) { // we only like container windows - BContainerWindow *window = dynamic_cast(Window()); + BContainerWindow* window = dynamic_cast(Window()); if (window == NULL) return; @@ -367,7 +367,7 @@ DraggableContainerIcon::MouseDown(BPoint point) return; uint32 buttons; - window->CurrentMessage()->FindInt32("buttons", (int32 *)&buttons); + window->CurrentMessage()->FindInt32("buttons", (int32*)&buttons); if (IconCache::sIconCache->IconHitTest(point, window->TargetModel(), kNormalIcon, B_MINI_ICON)) { @@ -396,16 +396,16 @@ DraggableContainerIcon::MouseUp(BPoint /*point*/) void DraggableContainerIcon::MouseMoved(BPoint point, uint32 /*transit*/, - const BMessage */*message*/) + const BMessage* /*message*/) { if (fDragButton == 0 || fDragStarted || (abs((int32)(point.x - fClickPoint.x)) <= kDragSlop && abs((int32)(point.y - fClickPoint.y)) <= kDragSlop)) return; - BContainerWindow *window = static_cast(Window()); + BContainerWindow* window = static_cast(Window()); // we can only get here in a BContainerWindow - Model *model = window->TargetModel(); + Model* model = window->TargetModel(); // Find the required height BFont font; @@ -417,10 +417,10 @@ DraggableContainerIcon::MouseMoved(BPoint point, uint32 /*transit*/, + Bounds().Height() + 8; BRect rect(0, 0, max_c(Bounds().Width(), font.StringWidth(model->Name()) + 4), height); - BBitmap *dragBitmap = new BBitmap(rect, B_RGBA32, true); + BBitmap* dragBitmap = new BBitmap(rect, B_RGBA32, true); dragBitmap->Lock(); - BView *view = new BView(dragBitmap->Bounds(), "", B_FOLLOW_NONE, 0); + BView* view = new BView(dragBitmap->Bounds(), "", B_FOLLOW_NONE, 0); dragBitmap->AddChild(view); view->SetOrigin(0, 0); BRect clipRect(view->Bounds()); @@ -480,7 +480,7 @@ DraggableContainerIcon::MouseMoved(BPoint point, uint32 /*transit*/, void DraggableContainerIcon::FrameMoved(BPoint /*newLocation*/) { - BMenuBar* bar = dynamic_cast(Parent()); + BMenuBar* bar = dynamic_cast(Parent()); if (bar == NULL) return; @@ -493,11 +493,10 @@ DraggableContainerIcon::FrameMoved(BPoint /*newLocation*/) bar->GetPreferredSize(&width, &height); bar->SetResizingMode(resizingMode); -/* - BMenuItem* item = bar->ItemAt(bar->CountItems() - 1); - if (item == NULL) - return; -*/ + //BMenuItem* item = bar->ItemAt(bar->CountItems() - 1); + //if (item == NULL) + // return; + // BeOS shifts the coordinates for hidden views, so we cannot // use them to decide if we should be visible or not... @@ -513,7 +512,7 @@ DraggableContainerIcon::FrameMoved(BPoint /*newLocation*/) void DraggableContainerIcon::Draw(BRect updateRect) { - BContainerWindow *window = dynamic_cast(Window()); + BContainerWindow* window = dynamic_cast(Window()); if (window == NULL) return; @@ -540,7 +539,7 @@ DraggableContainerIcon::Draw(BRect updateRect) // #pragma mark - -BContainerWindow::BContainerWindow(LockingList *list, +BContainerWindow::BContainerWindow(LockingList* list, uint32 containerWindowFlags, window_look look, window_feel feel, uint32 flags, uint32 workspace) : BWindow(InitialWindowRect(feel), "TrackerWindow", look, feel, flags, @@ -590,7 +589,7 @@ BContainerWindow::BContainerWindow(LockingList *list, Run(); // Watch out for settings changes: - if (TTracker *app = dynamic_cast(be_app)) { + if (TTracker* app = dynamic_cast(be_app)) { app->Lock(); app->StartWatching(this, kWindowsShowFullPathChanged); app->StartWatching(this, kSingleWindowBrowseChanged); @@ -611,7 +610,7 @@ BContainerWindow::~BContainerWindow() ASSERT(IsLocked()); // stop the watchers - if (TTracker *app = dynamic_cast(be_app)) { + if (TTracker* app = dynamic_cast(be_app)) { app->Lock(); app->StopWatching(this, kWindowsShowFullPathChanged); app->StopWatching(this, kSingleWindowBrowseChanged); @@ -676,7 +675,7 @@ BContainerWindow::Quit() { // get rid of context menus if (fNavigationItem) { - BMenu *menu = fNavigationItem->Menu(); + BMenu* menu = fNavigationItem->Menu(); if (menu) menu->RemoveItem(fNavigationItem); delete fNavigationItem; @@ -741,15 +740,15 @@ BContainerWindow::Quit() } -BPoseView * -BContainerWindow::NewPoseView(Model *model, BRect rect, uint32 viewMode) +BPoseView* +BContainerWindow::NewPoseView(Model* model, BRect rect, uint32 viewMode) { return new BPoseView(model, rect, viewMode); } void -BContainerWindow::UpdateIfTrash(Model *model) +BContainerWindow::UpdateIfTrash(Model* model) { BEntry entry(model->EntryRef()); @@ -762,7 +761,7 @@ BContainerWindow::UpdateIfTrash(Model *model) void -BContainerWindow::CreatePoseView(Model *model) +BContainerWindow::CreatePoseView(Model* model) { UpdateIfTrash(model); BRect rect(Bounds()); @@ -843,10 +842,10 @@ BContainerWindow::RepopulateMenus() } if (fNavigationItem) { - BMenu *menu = fNavigationItem->Menu(); + BMenu* menu = fNavigationItem->Menu(); if (menu) { menu->RemoveItem(fNavigationItem); - BMenuItem *item = menu->RemoveItem((int32)0); + BMenuItem* item = menu->RemoveItem((int32)0); ASSERT(item != fNavigationItem); delete item; } @@ -894,7 +893,7 @@ BContainerWindow::RepopulateMenus() void -BContainerWindow::Init(const BMessage *message) +BContainerWindow::Init(const BMessage* message) { float y_delta; BEntry entry; @@ -948,7 +947,7 @@ BContainerWindow::Init(const BMessage *message) if (iconSize < 16) iconSize = 16; float iconPosY = 1 + (fMenuBar->Bounds().Height() - 2 - iconSize) / 2; - BView *icon = new DraggableContainerIcon(BRect(Bounds().Width() - 4 - iconSize + 1, + BView* icon = new DraggableContainerIcon(BRect(Bounds().Width() - 4 - iconSize + 1, iconPosY, Bounds().Width() - 4, iconPosY + iconSize - 1), "ThisContainer", B_FOLLOW_RIGHT); fMenuBar->AddChild(icon); @@ -993,7 +992,7 @@ BContainerWindow::Init(const BMessage *message) MarkAttributeMenu(fAttrMenu); CheckScreenIntersect(); - if (fBackgroundImage && !dynamic_cast(this) + if (fBackgroundImage && !dynamic_cast(this) && PoseView()->ViewMode() != kListMode) fBackgroundImage->Show(PoseView(), current_workspace()); @@ -1043,7 +1042,7 @@ BContainerWindow::RestoreStateCommon() WindowStateNodeOpener opener(this, false); - bool isDesktop = dynamic_cast(this); + bool isDesktop = dynamic_cast(this); if (!TargetModel()->IsRoot() && opener.Node()) // don't pick up background image for root disks // to do this, would have to have a unique attribute for the @@ -1086,7 +1085,7 @@ BContainerWindow::UpdateBackgroundImage() if (BootedInSafeMode()) return; - bool isDesktop = dynamic_cast(this) != NULL; + bool isDesktop = dynamic_cast(this) != NULL; WindowStateNodeOpener opener(this, false); if (!TargetModel()->IsRoot() && opener.Node()) @@ -1106,7 +1105,7 @@ BContainerWindow::UpdateBackgroundImage() void BContainerWindow::FrameResized(float, float) { - if (PoseView() && dynamic_cast(this) == NULL) { + if (PoseView() && dynamic_cast(this) == NULL) { BRect extent = PoseView()->Extent(); float offsetX = extent.left - PoseView()->Bounds().left; float offsetY = extent.top - PoseView()->Bounds().top; @@ -1153,7 +1152,7 @@ BContainerWindow::WorkspacesChanged(uint32, uint32) void BContainerWindow::ViewModeChanged(uint32 oldMode, uint32 newMode) { - BView *view = FindView("MenuBar"); + BView* view = FindView("MenuBar"); if (view != NULL) { // make sure the draggable icon hides if it doesn't have space left anymore view = view->FindView("ThisContainer"); @@ -1224,7 +1223,7 @@ BContainerWindow::StateNeedsSaving() const status_t -BContainerWindow::GetLayoutState(BNode *node, BMessage *message) +BContainerWindow::GetLayoutState(BNode* node, BMessage* message) { // ToDo: // get rid of this, use AttrStream instead @@ -1248,7 +1247,7 @@ BContainerWindow::GetLayoutState(BNode *node, BMessage *message) && strcmp(attrName, kAttrViewStateForeign) != 0) continue; - char *buffer = new char[info.size]; + char* buffer = new char[info.size]; if (node->ReadAttr(attrName, info.type, 0, buffer, (size_t)info.size) == info.size) message->AddData(attrName, info.type, buffer, (ssize_t)info.size); delete [] buffer; @@ -1258,7 +1257,7 @@ BContainerWindow::GetLayoutState(BNode *node, BMessage *message) status_t -BContainerWindow::SetLayoutState(BNode *node, const BMessage *message) +BContainerWindow::SetLayoutState(BNode* node, const BMessage* message) { status_t result = node->InitCheck(); if (result != B_OK) @@ -1266,9 +1265,9 @@ BContainerWindow::SetLayoutState(BNode *node, const BMessage *message) for (int32 globalIndex = 0; ;) { #if B_BEOS_VERSION_DANO - const char *name; + const char* name; #else - char *name; + char* name; #endif type_code type; int32 count; @@ -1278,7 +1277,7 @@ BContainerWindow::SetLayoutState(BNode *node, const BMessage *message) break; for (int32 index = 0; index < count; index++) { - const void *buffer; + const void* buffer; int32 size; result = message->FindData(name, type, index, &buffer, &size); if (result != B_OK) { @@ -1318,7 +1317,7 @@ BContainerWindow::ShouldAddCountView() const } -Model * +Model* BContainerWindow::TargetModel() const { return fPoseView->TargetModel(); @@ -1386,7 +1385,7 @@ BContainerWindow::ResizeToFit() void -BContainerWindow::MessageReceived(BMessage *message) +BContainerWindow::MessageReceived(BMessage* message) { switch (message->what) { case B_CUT: @@ -1396,7 +1395,7 @@ BContainerWindow::MessageReceived(BMessage *message) case kCopyMoreSelectionToClipboard: case kPasteLinksFromClipboard: { - BView *view = CurrentFocus(); + BView* view = CurrentFocus(); if (view->LockLooper()) { view->MessageReceived(message); view->UnlockLooper(); @@ -1545,7 +1544,7 @@ BContainerWindow::MessageReceived(BMessage *message) SetSingleWindowBrowseShortcuts(settings.SingleWindowBrowse()); // Update draggable folder icon - BView *view = FindView("MenuBar"); + BView* view = FindView("MenuBar"); if (view != NULL) { view = view->FindView("ThisContainer"); if (view != NULL) { @@ -1634,7 +1633,7 @@ BContainerWindow::MessageReceived(BMessage *message) { bool dontMoveToTrash = settings.DontMoveFilesToTrash(); - BMenuItem *item = fFileContextMenu->FindItem(kMoveToTrash); + BMenuItem* item = fFileContextMenu->FindItem(kMoveToTrash); if (item) { item->SetLabel(dontMoveToTrash ? B_TRANSLATE("Delete") @@ -1668,7 +1667,7 @@ BContainerWindow::MessageReceived(BMessage *message) FSUndo(); break; - //case B_REDO: /* only defined in Dano/Zeta/OpenBeOS */ + //case B_REDO: // only defined in Dano/Zeta/OpenBeOS case kRedo: FSRedo(); break; @@ -1680,9 +1679,9 @@ BContainerWindow::MessageReceived(BMessage *message) void -BContainerWindow::SetCutItem(BMenu *menu) +BContainerWindow::SetCutItem(BMenu* menu) { - BMenuItem *item; + BMenuItem* item; if ((item = menu->FindItem(B_CUT)) == NULL && (item = menu->FindItem(kCutMoreSelectionToClipboard)) == NULL) return; @@ -1703,9 +1702,9 @@ BContainerWindow::SetCutItem(BMenu *menu) void -BContainerWindow::SetCopyItem(BMenu *menu) +BContainerWindow::SetCopyItem(BMenu* menu) { - BMenuItem *item; + BMenuItem* item; if ((item = menu->FindItem(B_COPY)) == NULL && (item = menu->FindItem(kCopyMoreSelectionToClipboard)) == NULL) return; @@ -1726,9 +1725,9 @@ BContainerWindow::SetCopyItem(BMenu *menu) void -BContainerWindow::SetPasteItem(BMenu *menu) +BContainerWindow::SetPasteItem(BMenu* menu) { - BMenuItem *item; + BMenuItem* item; if ((item = menu->FindItem(B_PASTE)) == NULL && (item = menu->FindItem(kPasteLinksFromClipboard)) == NULL) return; @@ -1748,9 +1747,9 @@ BContainerWindow::SetPasteItem(BMenu *menu) void -BContainerWindow::SetArrangeMenu(BMenu *menu) +BContainerWindow::SetArrangeMenu(BMenu* menu) { - BMenuItem *item; + BMenuItem* item; if ((item = menu->FindItem(kCleanup)) == NULL && (item = menu->FindItem(kCleanupAll)) == NULL) return; @@ -1776,9 +1775,9 @@ BContainerWindow::SetArrangeMenu(BMenu *menu) void -BContainerWindow::SetCloseItem(BMenu *menu) +BContainerWindow::SetCloseItem(BMenu* menu) { - BMenuItem *item; + BMenuItem* item; if ((item = menu->FindItem(B_QUIT_REQUESTED)) == NULL && (item = menu->FindItem(kCloseAllWindows)) == NULL) return; @@ -1798,14 +1797,14 @@ BContainerWindow::SetCloseItem(BMenu *menu) bool -BContainerWindow::IsShowing(const node_ref *node) const +BContainerWindow::IsShowing(const node_ref* node) const { return PoseView()->Represents(node); } bool -BContainerWindow::IsShowing(const entry_ref *entry) const +BContainerWindow::IsShowing(const entry_ref* entry) const { return PoseView()->Represents(entry); } @@ -1828,7 +1827,7 @@ BContainerWindow::AddMenus() void -BContainerWindow::AddFileMenu(BMenu *menu) +BContainerWindow::AddFileMenu(BMenu* menu) { if (!PoseView()->IsFilePanel()) { menu->AddItem(new BMenuItem(B_TRANSLATE("Find" B_UTF8_ELLIPSIS), @@ -1885,7 +1884,7 @@ BContainerWindow::AddFileMenu(BMenu *menu) // BContainerWindow::SetupMoveCopyMenus() } - BMenuItem *cutItem = NULL, *copyItem = NULL, *pasteItem = NULL; + BMenuItem* cutItem = NULL,* copyItem = NULL,* pasteItem = NULL; if (!IsPrintersDir()) { menu->AddSeparatorItem(); @@ -1916,9 +1915,9 @@ BContainerWindow::AddFileMenu(BMenu *menu) void -BContainerWindow::AddWindowMenu(BMenu *menu) +BContainerWindow::AddWindowMenu(BMenu* menu) { - BMenuItem *item; + BMenuItem* item; BMenu* iconSizeMenu = new BMenu(B_TRANSLATE("Icon view")); @@ -2100,14 +2099,14 @@ BContainerWindow::MenusEnded() void -BContainerWindow::SetupNavigationMenu(const entry_ref *ref, BMenu *parent) +BContainerWindow::SetupNavigationMenu(const entry_ref* ref, BMenu* parent) { // start by removing nav item (and separator) from old menu if (fNavigationItem) { - BMenu *menu = fNavigationItem->Menu(); + BMenu* menu = fNavigationItem->Menu(); if (menu) { menu->RemoveItem(fNavigationItem); - BMenuItem *item = menu->RemoveItem((int32)0); + BMenuItem* item = menu->RemoveItem((int32)0); ASSERT(item != fNavigationItem); delete item; } @@ -2148,7 +2147,7 @@ BContainerWindow::SetupNavigationMenu(const entry_ref *ref, BMenu *parent) // setup a navigation menu item which will dynamically load items // as menu items are traversed - BNavMenu *navMenu = dynamic_cast(fNavigationItem->Submenu()); + BNavMenu* navMenu = dynamic_cast(fNavigationItem->Submenu()); navMenu->SetNavDir(ref); fNavigationItem->SetLabel(model.Name()); fNavigationItem->SetEntry(&entry); @@ -2156,7 +2155,7 @@ BContainerWindow::SetupNavigationMenu(const entry_ref *ref, BMenu *parent) parent->AddItem(fNavigationItem, 0); parent->AddItem(new BSeparatorItem(), 1); - BMessage *message = new BMessage(B_REFS_RECEIVED); + BMessage* message = new BMessage(B_REFS_RECEIVED); message->AddRef("refs", ref); fNavigationItem->SetMessage(message); fNavigationItem->SetTarget(be_app); @@ -2167,7 +2166,7 @@ BContainerWindow::SetupNavigationMenu(const entry_ref *ref, BMenu *parent) void -BContainerWindow::SetUpEditQueryItem(BMenu *menu) +BContainerWindow::SetUpEditQueryItem(BMenu* menu) { ASSERT(menu); // File menu @@ -2180,7 +2179,7 @@ BContainerWindow::SetUpEditQueryItem(BMenu *menu) // if any queries selected, add an edit query menu item for (int32 index = 0; index < selectCount; index++) { - BPose *pose = PoseView()->SelectionList()->ItemAt(index); + BPose* pose = PoseView()->SelectionList()->ItemAt(index); Model model(pose->TargetModel()->EntryRef(), true); if (model.InitCheck() != B_OK) continue; @@ -2215,11 +2214,11 @@ BContainerWindow::SetUpEditQueryItem(BMenu *menu) void -BContainerWindow::SetupOpenWithMenu(BMenu *parent) +BContainerWindow::SetupOpenWithMenu(BMenu* parent) { // start by removing nav item (and separator) from old menu if (fOpenWithItem) { - BMenu *menu = fOpenWithItem->Menu(); + BMenu* menu = fOpenWithItem->Menu(); if (menu) menu->RemoveItem(fOpenWithItem); @@ -2240,7 +2239,7 @@ BContainerWindow::SetupOpenWithMenu(BMenu *parent) // and do not add if true // add after "Open" - BMenuItem *item = parent->FindItem(kOpenSelection); + BMenuItem* item = parent->FindItem(kOpenSelection); int32 count = PoseView()->SelectionList()->CountItems(); if (!count) @@ -2249,7 +2248,7 @@ BContainerWindow::SetupOpenWithMenu(BMenu *parent) // build a list of all refs to open BMessage message(B_REFS_RECEIVED); for (int32 index = 0; index < count; index++) { - BPose *pose = PoseView()->SelectionList()->ItemAt(index); + BPose* pose = PoseView()->SelectionList()->ItemAt(index); message.AddRef("refs", pose->TargetModel()->EntryRef()); } @@ -2268,8 +2267,8 @@ BContainerWindow::SetupOpenWithMenu(BMenu *parent) void -BContainerWindow::PopulateMoveCopyNavMenu(BNavMenu *navMenu, uint32 what, - const entry_ref *ref, bool addLocalOnly) +BContainerWindow::PopulateMoveCopyNavMenu(BNavMenu* navMenu, uint32 what, + const entry_ref* ref, bool addLocalOnly) { BVolume volume; BVolumeRoster volumeRoster; @@ -2298,7 +2297,7 @@ BContainerWindow::PopulateMoveCopyNavMenu(BNavMenu *navMenu, uint32 what, menu->SetNavDir(model.EntryRef()); menu->SetShowParent(true); - BMenuItem *item = new SpecialModelMenuItem(&model,menu); + BMenuItem* item = new SpecialModelMenuItem(&model,menu); item->SetMessage(new BMessage((uint32)what)); navMenu->AddItem(item); @@ -2313,7 +2312,7 @@ BContainerWindow::PopulateMoveCopyNavMenu(BNavMenu *navMenu, uint32 what, BMenu* menu = new RecentsMenu(B_TRANSLATE("Recent folders"), kRecentFolders, what, this); - BMenuItem *item = new SpecialModelMenuItem(&model,menu); + BMenuItem* item = new SpecialModelMenuItem(&model,menu); item->SetMessage(new BMessage((uint32)what)); navMenu->AddItem(item); @@ -2370,20 +2369,22 @@ BContainerWindow::PopulateMoveCopyNavMenu(BNavMenu *navMenu, uint32 what, void -BContainerWindow::SetupMoveCopyMenus(const entry_ref *item_ref, BMenu *parent) +BContainerWindow::SetupMoveCopyMenus(const entry_ref* item_ref, BMenu* parent) { - if (IsTrash() || InTrash() || IsPrintersDir() || !fMoveToItem || !fCopyToItem || !fCreateLinkItem) + if (IsTrash() || InTrash() || IsPrintersDir() || !fMoveToItem + || !fCopyToItem || !fCreateLinkItem) { return; + } // Grab the modifiers state since we use it twice uint32 modifierKeys = modifiers(); // re-parent items to this menu since they're shared - int32 index; - BMenuItem *trash = parent->FindItem(kMoveToTrash); - if (trash) - index = parent->IndexOf(trash) + 2; - else + int32 index; + BMenuItem* trash = parent->FindItem(kMoveToTrash); + if (trash) + index = parent->IndexOf(trash) + 2; + else index = 0; if (fMoveToItem->Menu() != parent) { @@ -2432,23 +2433,23 @@ BContainerWindow::SetupMoveCopyMenus(const entry_ref *item_ref, BMenu *parent) return; // configure "Move to" menu item - PopulateMoveCopyNavMenu(dynamic_cast(fMoveToItem->Submenu()), + PopulateMoveCopyNavMenu(dynamic_cast(fMoveToItem->Submenu()), kMoveSelectionTo, item_ref, true); // configure "Copy to" menu item // add all mounted volumes (except the one this item lives on) - PopulateMoveCopyNavMenu(dynamic_cast(fCopyToItem->Submenu()), + PopulateMoveCopyNavMenu(dynamic_cast(fCopyToItem->Submenu()), kCopySelectionTo, item_ref, false); // Set "Create Link" menu item message and // add all mounted volumes (except the one this item lives on) if (modifierKeys & B_SHIFT_KEY) { fCreateLinkItem->SetMessage(new BMessage(kCreateRelativeLink)); - PopulateMoveCopyNavMenu(dynamic_cast(fCreateLinkItem->Submenu()), + PopulateMoveCopyNavMenu(dynamic_cast(fCreateLinkItem->Submenu()), kCreateRelativeLink, item_ref, false); } else { fCreateLinkItem->SetMessage(new BMessage(kCreateLink)); - PopulateMoveCopyNavMenu(dynamic_cast(fCreateLinkItem->Submenu()), + PopulateMoveCopyNavMenu(dynamic_cast(fCreateLinkItem->Submenu()), kCreateLink, item_ref, false); } @@ -2457,7 +2458,7 @@ BContainerWindow::SetupMoveCopyMenus(const entry_ref *item_ref, BMenu *parent) fCreateLinkItem->SetEnabled(true); // Set the "Identify" item label - BMenuItem *identifyItem = parent->FindItem(kIdentifyEntry); + BMenuItem* identifyItem = parent->FindItem(kIdentifyEntry); if (identifyItem != NULL) { if (modifierKeys & B_SHIFT_KEY) identifyItem->SetLabel(B_TRANSLATE("Force identify")); @@ -2477,7 +2478,7 @@ BContainerWindow::ShowDropContextMenu(BPoint loc) // Change the "Create Link" item - allow user to // create relative links with the Shift key down. - BMenuItem *item = fDropContextMenu->FindItem(kCreateLink); + BMenuItem* item = fDropContextMenu->FindItem(kCreateLink); if (item == NULL) item = fDropContextMenu->FindItem(kCreateRelativeLink); if (item && (modifiers() & B_SHIFT_KEY)) { @@ -2497,7 +2498,7 @@ BContainerWindow::ShowDropContextMenu(BPoint loc) void -BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref *ref, BView *) +BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref* ref, BView*) { ASSERT(IsLocked()); BPoint global(loc); @@ -2518,7 +2519,7 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref *ref, BView *) // selected item was trash, show the trash context menu instead EnableNamedMenuItem(fTrashContextMenu, kEmptyTrash, - static_cast(be_app)->TrashFull()); + static_cast(be_app)->TrashFull()); SetupNavigationMenu(ref, fTrashContextMenu); fTrashContextMenu->Go(global, true, true, true); @@ -2562,7 +2563,7 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref *ref, BView *) fDragContextMenu->SetNavDir(&resolvedRef); fDragContextMenu->SetTypesList(fCachedTypesList); fDragContextMenu->SetTarget(BMessenger(this)); - BPoseView *poseView = PoseView(); + BPoseView* poseView = PoseView(); if (poseView) { BMessenger target(poseView); fDragContextMenu->InitTrackingHook( @@ -2639,7 +2640,7 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref *ref, BView *) void -BContainerWindow::AddFileContextMenus(BMenu *menu) +BContainerWindow::AddFileContextMenus(BMenu* menu) { menu->AddItem(new BMenuItem(B_TRANSLATE("Open"), new BMessage(kOpenSelection), 'O')); @@ -2669,7 +2670,7 @@ BContainerWindow::AddFileContextMenus(BMenu *menu) #ifdef CUT_COPY_PASTE_IN_CONTEXT_MENU menu->AddSeparatorItem(); - BMenuItem *cutItem, *copyItem; + BMenuItem* cutItem,* copyItem; menu->AddItem(cutItem = new BMenuItem(B_TRANSLATE("Cut"), new BMessage(B_CUT), 'X')); menu->AddItem(copyItem = new BMenuItem(B_TRANSLATE("Copy"), @@ -2693,7 +2694,7 @@ BContainerWindow::AddFileContextMenus(BMenu *menu) void -BContainerWindow::AddVolumeContextMenus(BMenu *menu) +BContainerWindow::AddVolumeContextMenus(BMenu* menu) { menu->AddItem(new BMenuItem(B_TRANSLATE("Open"), new BMessage(kOpenSelection), 'O')); @@ -2705,7 +2706,7 @@ BContainerWindow::AddVolumeContextMenus(BMenu *menu) menu->AddSeparatorItem(); menu->AddItem(new MountMenu(B_TRANSLATE("Mount"))); - BMenuItem *item = new BMenuItem(B_TRANSLATE("Unmount"), + BMenuItem* item = new BMenuItem(B_TRANSLATE("Unmount"), new BMessage(kUnmountVolume), 'U'); item->SetEnabled(false); menu->AddItem(item); @@ -2718,7 +2719,7 @@ BContainerWindow::AddVolumeContextMenus(BMenu *menu) void -BContainerWindow::AddWindowContextMenus(BMenu *menu) +BContainerWindow::AddWindowContextMenus(BMenu* menu) { // create context sensitive menu for empty area of window // since we check view mode before display, this should be a radio @@ -2745,7 +2746,7 @@ BContainerWindow::AddWindowContextMenus(BMenu *menu) menu->AddSeparatorItem(); #if 0 - BMenuItem *pasteItem = new BMenuItem("Paste", new BMessage(B_PASTE), 'V'); + BMenuItem* pasteItem = new BMenuItem("Paste", new BMessage(B_PASTE), 'V'); menu->AddItem(pasteItem); menu->AddSeparatorItem(); #endif @@ -2770,7 +2771,7 @@ BContainerWindow::AddWindowContextMenus(BMenu *menu) #if DEBUG menu->AddSeparatorItem(); - BMenuItem *testing = new BMenuItem("Test icon cache", new BMessage(kTestIconCache)); + BMenuItem* testing = new BMenuItem("Test icon cache", new BMessage(kTestIconCache)); menu->AddItem(testing); #endif @@ -2783,7 +2784,7 @@ BContainerWindow::AddWindowContextMenus(BMenu *menu) void -BContainerWindow::AddDropContextMenus(BMenu *menu) +BContainerWindow::AddDropContextMenus(BMenu* menu) { menu->AddItem(new BMenuItem(B_TRANSLATE("Create link here"), new BMessage(kCreateLink))); @@ -2798,7 +2799,7 @@ BContainerWindow::AddDropContextMenus(BMenu *menu) void -BContainerWindow::AddTrashContextMenus(BMenu *menu) +BContainerWindow::AddTrashContextMenus(BMenu* menu) { // setup special trash context menu menu->AddItem(new BMenuItem(B_TRANSLATE("Empty Trash"), @@ -2812,8 +2813,8 @@ BContainerWindow::AddTrashContextMenus(BMenu *menu) void -BContainerWindow::EachAddon(bool (*eachAddon)(const Model *, const char *, - uint32 shortcut, bool primary, void *context), void *passThru, +BContainerWindow::EachAddon(bool (*eachAddon)(const Model*, const char*, + uint32 shortcut, bool primary, void* context), void* passThru, BObjectList &mimeTypes) { BObjectList uniqueList(10, true); @@ -2831,9 +2832,9 @@ BContainerWindow::EachAddon(bool (*eachAddon)(const Model *, const char *, bool -BContainerWindow::EachAddon(BPath &path, bool (*eachAddon)(const Model *, - const char *, uint32 shortcut, bool primary, void *), - BObjectList *uniqueList, void *params, +BContainerWindow::EachAddon(BPath &path, bool (*eachAddon)(const Model*, + const char*, uint32 shortcut, bool primary, void*), + BObjectList* uniqueList, void* params, BObjectList &mimeTypes) { path.Append("Tracker"); @@ -2846,7 +2847,7 @@ BContainerWindow::EachAddon(BPath &path, bool (*eachAddon)(const Model *, dir.Rewind(); while (dir.GetNextEntry(&entry) == B_OK) { - Model *model = new Model(&entry); + Model* model = new Model(&entry); if (model->InitCheck() == B_OK && model->IsSymLink()) { // resolve symlinks @@ -2884,7 +2885,7 @@ BContainerWindow::EachAddon(BPath &path, bool (*eachAddon)(const Model *, // check all supported types if it has some set if (!secondary) { for (int32 i = mimeTypes.CountItems(); !primary && i-- > 0;) { - BString *type = mimeTypes.ItemAt(i); + BString* type = mimeTypes.ItemAt(i); if (info.IsSupportedType(type->String())) { BMimeType mimeType(type->String()); if (info.Supports(&mimeType)) @@ -2932,7 +2933,7 @@ BContainerWindow::BuildMimeTypeList(BObjectList &mimeTypes) } else { _UpdateSelectionMIMEInfo(); for (int32 index = 0; index < count; index++) { - BPose *pose = PoseView()->SelectionList()->ItemAt(index); + BPose* pose = PoseView()->SelectionList()->ItemAt(index); AddMimeTypeString(mimeTypes, pose->TargetModel()); // If it's a symlink, resolves it and add the Target's MimeType if (pose->TargetModel()->IsSymLink()) { @@ -2949,7 +2950,7 @@ BContainerWindow::BuildMimeTypeList(BObjectList &mimeTypes) void -BContainerWindow::BuildAddOnMenu(BMenu *menu) +BContainerWindow::BuildAddOnMenu(BMenu* menu) { BMenuItem* item = menu->FindItem(B_TRANSLATE("Add-ons")); if (menu->IndexOf(item) == 0) { @@ -3007,7 +3008,7 @@ BContainerWindow::BuildAddOnMenu(BMenu *menu) void -BContainerWindow::UpdateMenu(BMenu *menu, UpdateMenuContext context) +BContainerWindow::UpdateMenu(BMenu* menu, UpdateMenuContext context) { const int32 selectCount = PoseView()->SelectionList()->CountItems(); const int32 count = PoseView()->CountItems(); @@ -3022,7 +3023,7 @@ BContainerWindow::UpdateMenu(BMenu *menu, UpdateMenuContext context) EnableNamedMenuItem(menu, kDuplicateSelection, selectCount > 0); } - Model *selectedModel = NULL; + Model* selectedModel = NULL; if (selectCount == 1) selectedModel = PoseView()->SelectionList()->FirstItem()->TargetModel(); @@ -3078,7 +3079,7 @@ BContainerWindow::UpdateMenu(BMenu *menu, UpdateMenuContext context) BEntry entry(TargetModel()->EntryRef()); BDirectory parent; entry_ref ref; - BEntry root("/"); + BEntry root("/"); bool parentIsRoot = (entry.GetParent(&parent) == B_OK && parent.GetEntry(&entry) == B_OK @@ -3097,7 +3098,7 @@ BContainerWindow::UpdateMenu(BMenu *menu, UpdateMenuContext context) BMenuItem* item = menu->FindItem(B_TRANSLATE("New")); if (item) { - TemplatesMenu *templateMenu = dynamic_cast( + TemplatesMenu* templateMenu = dynamic_cast( item->Submenu()); if (templateMenu) templateMenu->UpdateMenuState(); @@ -3109,7 +3110,7 @@ BContainerWindow::UpdateMenu(BMenu *menu, UpdateMenuContext context) void -BContainerWindow::LoadAddOn(BMessage *message) +BContainerWindow::LoadAddOn(BMessage* message) { UpdateIfNeeded(); @@ -3128,12 +3129,12 @@ BContainerWindow::LoadAddOn(BMessage *message) } // add selected refs to message - BMessage *refs = new BMessage(B_REFS_RECEIVED); + BMessage* refs = new BMessage(B_REFS_RECEIVED); - BObjectList *list = PoseView()->SelectionList(); + BObjectList* list = PoseView()->SelectionList(); int32 index = 0; - BPose *pose; + BPose* pose; while ((pose = list->ItemAt(index++)) != NULL) refs->AddRef("refs", pose->TargetModel()->EntryRef()); @@ -3167,8 +3168,8 @@ BContainerWindow::_UpdateSelectionMIMEInfo() } -BMenuItem * -BContainerWindow::NewAttributeMenuItem(const char *label, const char *name, +BMenuItem* +BContainerWindow::NewAttributeMenuItem(const char* label, const char* name, int32 type, float width, int32 align, bool editable, bool statField) { return NewAttributeMenuItem(label, name, type, NULL, width, align, @@ -3176,12 +3177,12 @@ BContainerWindow::NewAttributeMenuItem(const char *label, const char *name, } -BMenuItem * -BContainerWindow::NewAttributeMenuItem(const char *label, const char *name, +BMenuItem* +BContainerWindow::NewAttributeMenuItem(const char* label, const char* name, int32 type, const char* displayAs, float width, int32 align, bool editable, bool statField) { - BMessage *message = new BMessage(kAttributeItem); + BMessage* message = new BMessage(kAttributeItem); message->AddString("attr_name", name); message->AddInt32("attr_type", type); message->AddInt32("attr_hash", (int32)AttrHashString(name, (uint32)type)); @@ -3192,7 +3193,7 @@ BContainerWindow::NewAttributeMenuItem(const char *label, const char *name, message->AddBool("attr_editable", editable); message->AddBool("attr_statfield", statField); - BMenuItem *menuItem = new BMenuItem(label, message); + BMenuItem* menuItem = new BMenuItem(label, message); menuItem->SetTarget(PoseView()); return menuItem; @@ -3200,11 +3201,11 @@ BContainerWindow::NewAttributeMenuItem(const char *label, const char *name, void -BContainerWindow::NewAttributeMenu(BMenu *menu) +BContainerWindow::NewAttributeMenu(BMenu* menu) { ASSERT(PoseView()); - BMenuItem *item; + BMenuItem* item; menu->AddItem(item = new BMenuItem(B_TRANSLATE("Copy layout"), new BMessage(kCopyAttributes))); item->SetTarget(PoseView()); @@ -3278,14 +3279,14 @@ BContainerWindow::MarkAttributeMenu() void -BContainerWindow::MarkAttributeMenu(BMenu *menu) +BContainerWindow::MarkAttributeMenu(BMenu* menu) { if (!menu) return; int32 count = menu->CountItems(); for (int32 index = 0; index < count; index++) { - BMenuItem *item = menu->ItemAt(index); + BMenuItem* item = menu->ItemAt(index); int32 attrHash; if (item->Message()) { if (item->Message()->FindInt32("attr_hash", &attrHash) == B_OK) @@ -3294,7 +3295,7 @@ BContainerWindow::MarkAttributeMenu(BMenu *menu) item->SetMarked(false); } - BMenu *submenu = item->Submenu(); + BMenu* submenu = item->Submenu(); if (submenu) { int32 count2 = submenu->CountItems(); for (int32 subindex = 0; subindex < count2; subindex++) { @@ -3327,7 +3328,7 @@ BContainerWindow::MarkArrangeByMenu(BMenu* menu) if (item->Message()->FindInt32("attr_hash", (int32*)&attrHash) == B_OK) item->SetMarked(PoseView()->PrimarySort() == attrHash); else if (item->Command() == kArrangeReverseOrder) - item->SetMarked(PoseView()->ReverseSort()); + item->SetMarked(PoseView()->ReverseSort()); } } } @@ -3340,9 +3341,8 @@ BContainerWindow::AddMimeTypesToMenu() } -/*! Adds a menu for a specific MIME type if it doesn't exist already. - Returns the menu, if it existed or not. -*/ +// Adds a menu for a specific MIME type if it doesn't exist already. +// Returns the menu, if it existed or not. BMenu* BContainerWindow::AddMimeMenu(const BMimeType& mimeType, bool isSuperType, BMenu* menu, int32 start) @@ -3438,7 +3438,7 @@ BContainerWindow::AddMimeMenu(const BMimeType& mimeType, bool isSuperType, void -BContainerWindow::AddMimeTypesToMenu(BMenu *menu) +BContainerWindow::AddMimeTypesToMenu(BMenu* menu) { if (!menu) return; @@ -3452,7 +3452,7 @@ BContainerWindow::AddMimeTypesToMenu(BMenu *menu) // Add a separator item if there is none yet if (start > 0 - && dynamic_cast(menu->ItemAt(start - 1)) == NULL) + && dynamic_cast(menu->ItemAt(start - 1)) == NULL) menu->AddSeparatorItem(); // Add MIME type in case we're a default query type window @@ -3522,8 +3522,8 @@ BContainerWindow::AddMimeTypesToMenu(BMenu *menu) } // remove separator if it's the only item in menu - BMenuItem *item = menu->ItemAt(menu->CountItems() - 1); - if (dynamic_cast(item) != NULL) { + BMenuItem* item = menu->ItemAt(menu->CountItems() - 1); + if (dynamic_cast(item) != NULL) { menu->RemoveItem(item); delete item; } @@ -3532,9 +3532,9 @@ BContainerWindow::AddMimeTypesToMenu(BMenu *menu) } -BHandler * -BContainerWindow::ResolveSpecifier(BMessage *message, int32 index, - BMessage *specifier, int32 form, const char *property) +BHandler* +BContainerWindow::ResolveSpecifier(BMessage* message, int32 index, + BMessage* specifier, int32 form, const char* property) { if (strcmp(property, "Poses") == 0) { // PRINT(("BContainerWindow::ResolveSpecifier %s\n", property)); @@ -3547,7 +3547,7 @@ BContainerWindow::ResolveSpecifier(BMessage *message, int32 index, } -PiggybackTaskLoop * +PiggybackTaskLoop* BContainerWindow::DelayedTaskLoop() { if (!fTaskLoop) @@ -3577,7 +3577,7 @@ BContainerWindow::NeedsDefaultStateSetup() bool -BContainerWindow::DefaultStateSourceNode(const char *name, BNode *result, +BContainerWindow::DefaultStateSourceNode(const char* name, BNode* result, bool createNew, bool createFolder) { // PRINT(("looking for default state in tracker settings dir\n")); @@ -3596,7 +3596,7 @@ BContainerWindow::DefaultStateSourceNode(const char *name, BNode *result, BPath tmpPath(settingsPath); for (;;) { // deal with several levels of folders - const char *nextSlash = strchr(name, '/'); + const char* nextSlash = strchr(name, '/'); if (!nextSlash) break; @@ -3678,7 +3678,7 @@ BContainerWindow::SetUpDefaultState() // copy over the attributes // set up a filter of the attributes we want copied - const char *allowAttrs[] = { + const char* allowAttrs[] = { kAttrWindowFrame, kAttrWindowWorkspace, kAttrViewState, @@ -3708,14 +3708,14 @@ BContainerWindow::SetUpDefaultState() void -BContainerWindow::RestoreWindowState(AttributeStreamNode *node) +BContainerWindow::RestoreWindowState(AttributeStreamNode* node) { - if (!node || dynamic_cast(this)) + if (!node || dynamic_cast(this)) // don't restore any window state if we are a desktop window return; - const char *rectAttributeName; - const char *workspaceAttributeName; + const char* rectAttributeName; + const char* workspaceAttributeName; if (TargetModel()->IsRoot()) { rectAttributeName = kAttrDisksFrame; workspaceAttributeName = kAttrDisksWorkspace; @@ -3760,12 +3760,12 @@ BContainerWindow::RestoreWindowState(AttributeStreamNode *node) void BContainerWindow::RestoreWindowState(const BMessage &message) { - if (dynamic_cast(this)) + if (dynamic_cast(this)) // don't restore any window state if we are a desktop window return; - const char *rectAttributeName; - const char *workspaceAttributeName; + const char* rectAttributeName; + const char* workspaceAttributeName; if (TargetModel()->IsRoot()) { rectAttributeName = kAttrDisksFrame; workspaceAttributeName = kAttrDisksWorkspace; @@ -3783,7 +3783,7 @@ BContainerWindow::RestoreWindowState(const BMessage &message) uint32 workspace; if ((fContainerWindowFlags & kRestoreWorkspace) - && message.FindInt32(workspaceAttributeName, (int32 *)&workspace) == B_OK) + && message.FindInt32(workspaceAttributeName, (int32*)&workspace) == B_OK) SetWorkspaces(workspace); if (fContainerWindowFlags & kIsHidden) @@ -3801,11 +3801,11 @@ BContainerWindow::RestoreWindowState(const BMessage &message) void -BContainerWindow::SaveWindowState(AttributeStreamNode *node) +BContainerWindow::SaveWindowState(AttributeStreamNode* node) { ASSERT(node); - const char *rectAttributeName; - const char *workspaceAttributeName; + const char* rectAttributeName; + const char* workspaceAttributeName; if (TargetModel() && TargetModel()->IsRoot()) { rectAttributeName = kAttrDisksFrame; workspaceAttributeName = kAttrDisksWorkspace; @@ -3838,8 +3838,8 @@ BContainerWindow::SaveWindowState(AttributeStreamNode *node) void BContainerWindow::SaveWindowState(BMessage &message) const { - const char *rectAttributeName; - const char *workspaceAttributeName; + const char* rectAttributeName; + const char* workspaceAttributeName; if (TargetModel() && TargetModel()->IsRoot()) { rectAttributeName = kAttrDisksFrame; @@ -4085,7 +4085,7 @@ BContainerWindow::PopulateArrangeByMenu(BMenu* menu) message->what = kArrangeBy; BMenuItem* newItem = new BMenuItem(item->Label(), message); newItem->SetTarget(PoseView()); - menu->AddItem(newItem); + menu->AddItem(newItem); } } @@ -4108,7 +4108,7 @@ BContainerWindow::PopulateArrangeByMenu(BMenu* menu) // #pragma mark - -WindowStateNodeOpener::WindowStateNodeOpener(BContainerWindow *window, bool forWriting) +WindowStateNodeOpener::WindowStateNodeOpener(BContainerWindow* window, bool forWriting) : fModelOpener(NULL), fNode(NULL), fStreamNode(NULL) @@ -4135,7 +4135,7 @@ WindowStateNodeOpener::~WindowStateNodeOpener() void -WindowStateNodeOpener::SetTo(const BDirectory *node) +WindowStateNodeOpener::SetTo(const BDirectory* node) { delete fModelOpener; delete fNode; @@ -4148,7 +4148,7 @@ WindowStateNodeOpener::SetTo(const BDirectory *node) void -WindowStateNodeOpener::SetTo(const BEntry *entry, bool forWriting) +WindowStateNodeOpener::SetTo(const BEntry* entry, bool forWriting) { delete fModelOpener; delete fNode; @@ -4161,7 +4161,7 @@ WindowStateNodeOpener::SetTo(const BEntry *entry, bool forWriting) void -WindowStateNodeOpener::SetTo(Model *model, bool forWriting) +WindowStateNodeOpener::SetTo(Model* model, bool forWriting) { delete fModelOpener; delete fNode; @@ -4170,19 +4170,21 @@ WindowStateNodeOpener::SetTo(Model *model, bool forWriting) fNode = NULL; fStreamNode = NULL; fModelOpener = new ModelNodeLazyOpener(model, forWriting, false); - if (fModelOpener->IsOpen(forWriting)) - fStreamNode = new AttributeStreamFileNode(fModelOpener->TargetModel()->Node()); + if (fModelOpener->IsOpen(forWriting)) { + fStreamNode = new AttributeStreamFileNode( + fModelOpener->TargetModel()->Node()); + } } -AttributeStreamNode * +AttributeStreamNode* WindowStateNodeOpener::StreamNode() const { return fStreamNode; } -BNode * +BNode* WindowStateNodeOpener::Node() const { if (!fStreamNode) @@ -4252,7 +4254,7 @@ BackgroundView::WindowActivated(bool) void BackgroundView::Draw(BRect updateRect) { - BContainerWindow *window = dynamic_cast(Window()); + BContainerWindow* window = dynamic_cast(Window()); if (!window) return; @@ -4308,7 +4310,7 @@ BackgroundView::Draw(BRect updateRect) void BackgroundView::Pulse() { - BContainerWindow *window = dynamic_cast(Window()); + BContainerWindow* window = dynamic_cast(Window()); if (window) window->PulseTaskLoop(); } diff --git a/src/kits/tracker/ContainerWindow.h b/src/kits/tracker/ContainerWindow.h index e312ab213e..3fe8fc52ed 100644 --- a/src/kits/tracker/ContainerWindow.h +++ b/src/kits/tracker/ContainerWindow.h @@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - -#ifndef _CONTAINER_WINDOW_H +#ifndef _CONTAINER_WINDOW_H #define _CONTAINER_WINDOW_H + #include #include "LockingList.h" @@ -58,7 +58,7 @@ class SelectionWindow; #define kDefaultFolderTemplate "DefaultFolderTemplate" -extern const char *kAddOnsMenuName; +extern const char* kAddOnsMenuName; const window_feel kPrivateDesktopWindowFeel = window_feel(1024); const window_look kPrivateDesktopWindowLook = window_look(4); @@ -74,7 +74,7 @@ enum { class BContainerWindow : public BWindow { public: - BContainerWindow(LockingList *windowList, + BContainerWindow(LockingList* windowList, uint32 containerWindowFlags, window_look look = B_DOCUMENT_WINDOW_LOOK, window_feel feel = B_NORMAL_WINDOW_FEEL, @@ -83,7 +83,7 @@ class BContainerWindow : public BWindow { virtual ~BContainerWindow(); - virtual void Init(const BMessage *message = NULL); + virtual void Init(const BMessage* message = NULL); static BRect InitialWindowRect(window_feel); @@ -91,15 +91,15 @@ class BContainerWindow : public BWindow { virtual void Quit(); virtual bool QuitRequested(); - virtual void UpdateIfTrash(Model *); + virtual void UpdateIfTrash(Model*); - virtual void CreatePoseView(Model *); + virtual void CreatePoseView(Model*); - virtual void ShowContextMenu(BPoint, const entry_ref *, BView *); + virtual void ShowContextMenu(BPoint, const entry_ref*, BView*); virtual uint32 ShowDropContextMenu(BPoint); virtual void MenusBeginning(); virtual void MenusEnded(); - virtual void MessageReceived(BMessage *); + virtual void MessageReceived(BMessage*); virtual void FrameResized(float, float); virtual void FrameMoved(BPoint); virtual void Zoom(BPoint, float, float); @@ -116,14 +116,14 @@ class BContainerWindow : public BWindow { bool InTrash() const; bool IsPrintersDir() const; - virtual bool IsShowing(const node_ref *) const; - virtual bool IsShowing(const entry_ref *) const; + virtual bool IsShowing(const node_ref*) const; + virtual bool IsShowing(const entry_ref*) const; void ResizeToFit(); - Model *TargetModel() const; - BPoseView *PoseView() const; - BNavigator *Navigator() const; + Model* TargetModel() const; + BPoseView* PoseView() const; + BNavigator* Navigator() const; virtual void SelectionChanged(); virtual void ViewModeChanged(uint32 oldMode, uint32 newMode); @@ -141,44 +141,44 @@ class BContainerWindow : public BWindow { void UpdateBackgroundImage(); - static status_t GetLayoutState(BNode *, BMessage *); - static status_t SetLayoutState(BNode *, const BMessage *); + static status_t GetLayoutState(BNode*, BMessage*); + static status_t SetLayoutState(BNode*, const BMessage*); // calls for inheriting window size, attribute layout, etc. // deprecated - virtual void AddMimeTypesToMenu(BMenu *); + virtual void AddMimeTypesToMenu(BMenu*); void AddMimeTypesToMenu(); - virtual void MarkAttributeMenu(BMenu *); + virtual void MarkAttributeMenu(BMenu*); void MarkAttributeMenu(); - void MarkArrangeByMenu(BMenu *); - BMenuItem *NewAttributeMenuItem(const char *label, const char *name, + void MarkArrangeByMenu(BMenu*); + BMenuItem* NewAttributeMenuItem(const char* label, const char* name, int32 type, float width, int32 align, bool editable, bool statField); - BMenuItem *NewAttributeMenuItem(const char *label, const char *name, + BMenuItem* NewAttributeMenuItem(const char* label, const char* name, int32 type, const char* displayAs, float width, int32 align, bool editable, bool statField); - virtual void NewAttributeMenu(BMenu *); + virtual void NewAttributeMenu(BMenu*); void HideAttributeMenu(); void ShowAttributeMenu(); - PiggybackTaskLoop *DelayedTaskLoop(); + PiggybackTaskLoop* DelayedTaskLoop(); // use for RunLater queueing void PulseTaskLoop(); // called by some view that has pulse, either BackgroundView or BPoseView - static bool DefaultStateSourceNode(const char *name, BNode *result, + static bool DefaultStateSourceNode(const char* name, BNode* result, bool createNew = false, bool createFolder = true); // add-on iteration - void EachAddon(bool(*)(const Model *, const char *, uint32 shortcut, - bool primary, void *), void *, BObjectList &); + void EachAddon(bool (*)(const Model*, const char*, uint32 shortcut, + bool primary, void*), void*, BObjectList &); - BPopUpMenu *ContextMenu(); + BPopUpMenu* ContextMenu(); // drag&drop support - status_t DragStart(const BMessage *); + status_t DragStart(const BMessage*); void DragStop(); bool Dragging() const; - BMessage *DragMessage() const; + BMessage* DragMessage() const; void ShowSelectionWindow(); @@ -189,14 +189,14 @@ class BContainerWindow : public BWindow { bool IsPathWatchingEnabled(void) const; protected: - virtual BPoseView *NewPoseView(Model *, BRect, uint32); + virtual BPoseView* NewPoseView(Model*, BRect, uint32); // instantiate a different flavor of BPoseView for different // ContainerWindows - virtual void RestoreWindowState(AttributeStreamNode *); + virtual void RestoreWindowState(AttributeStreamNode*); virtual void RestoreWindowState(const BMessage &); - virtual void SaveWindowState(AttributeStreamNode *); - virtual void SaveWindowState(BMessage &) const; + virtual void SaveWindowState(AttributeStreamNode*); + virtual void SaveWindowState(BMessage&) const; virtual bool NeedsDefaultStateSetup(); virtual void SetUpDefaultState(); @@ -206,34 +206,34 @@ class BContainerWindow : public BWindow { virtual void AddMenus(); virtual void AddShortcuts(); // add equivalents of the menu shortcuts to the menuless desktop window - virtual void AddFileMenu(BMenu *menu); - virtual void AddWindowMenu(BMenu *menu); + virtual void AddFileMenu(BMenu* menu); + virtual void AddWindowMenu(BMenu* menu); virtual void AddContextMenus(); - virtual void AddFileContextMenus(BMenu *); - virtual void AddWindowContextMenus(BMenu *); - virtual void AddVolumeContextMenus(BMenu *); - virtual void AddDropContextMenus(BMenu *); - virtual void AddTrashContextMenus(BMenu *); + virtual void AddFileContextMenus(BMenu*); + virtual void AddWindowContextMenus(BMenu*); + virtual void AddVolumeContextMenus(BMenu*); + virtual void AddDropContextMenus(BMenu*); + virtual void AddTrashContextMenus(BMenu*); virtual void RepopulateMenus(); - void PopulateArrangeByMenu(BMenu* ); + void PopulateArrangeByMenu(BMenu*); - virtual void SetCutItem(BMenu *); - virtual void SetCopyItem(BMenu *); - virtual void SetPasteItem(BMenu *); - virtual void SetArrangeMenu(BMenu *); - virtual void SetCloseItem(BMenu *); - virtual void SetupNavigationMenu(const entry_ref *, BMenu *); - virtual void SetupMoveCopyMenus(const entry_ref *, BMenu *); - virtual void PopulateMoveCopyNavMenu(BNavMenu *, uint32, const entry_ref *, bool); + virtual void SetCutItem(BMenu*); + virtual void SetCopyItem(BMenu*); + virtual void SetPasteItem(BMenu*); + virtual void SetArrangeMenu(BMenu*); + virtual void SetCloseItem(BMenu*); + virtual void SetupNavigationMenu(const entry_ref*, BMenu*); + virtual void SetupMoveCopyMenus(const entry_ref*, BMenu*); + virtual void PopulateMoveCopyNavMenu(BNavMenu*, uint32, const entry_ref*, bool); - virtual void SetupOpenWithMenu(BMenu *); - virtual void SetUpEditQueryItem(BMenu *); - virtual void SetUpDiskMenu(BMenu *); + virtual void SetupOpenWithMenu(BMenu*); + virtual void SetUpEditQueryItem(BMenu*); + virtual void SetUpDiskMenu(BMenu*); - virtual void BuildAddOnMenu(BMenu *); + virtual void BuildAddOnMenu(BMenu*); void BuildMimeTypeList(BObjectList& mimeTypes); enum UpdateMenuContext { @@ -242,48 +242,48 @@ class BContainerWindow : public BWindow { kWindowPopUpContext }; - virtual void UpdateMenu(BMenu *menu, UpdateMenuContext context); + virtual void UpdateMenu(BMenu* menu, UpdateMenuContext context); BMenu* AddMimeMenu(const BMimeType& mimeType, bool isSuperType, BMenu* menu, int32 start); - BHandler *ResolveSpecifier(BMessage *, int32, BMessage *, int32, - const char *); + BHandler* ResolveSpecifier(BMessage*, int32, BMessage*, int32, + const char*); - bool EachAddon(BPath &path, bool(*)(const Model *, const char *, uint32, bool, void *), - BObjectList *, void *, BObjectList &); - void LoadAddOn(BMessage *); + bool EachAddon(BPath &path, bool(*)(const Model*, const char*, uint32, bool, void*), + BObjectList*, void*, BObjectList &); + void LoadAddOn(BMessage*); - BPopUpMenu *fFileContextMenu; - BPopUpMenu *fWindowContextMenu; - BPopUpMenu *fDropContextMenu; - BPopUpMenu *fVolumeContextMenu; - BPopUpMenu *fTrashContextMenu; - BSlowContextMenu *fDragContextMenu; - BMenuItem *fMoveToItem; - BMenuItem *fCopyToItem; - BMenuItem *fCreateLinkItem; - BMenuItem *fOpenWithItem; - ModelMenuItem *fNavigationItem; - BMenuBar *fMenuBar; - BNavigator *fNavigator; - BPoseView *fPoseView; - LockingList *fWindowList; - BMenu *fAttrMenu; - BMenu *fWindowMenu; - BMenu *fFileMenu; - BMenu *fArrangeByMenu; + BPopUpMenu* fFileContextMenu; + BPopUpMenu* fWindowContextMenu; + BPopUpMenu* fDropContextMenu; + BPopUpMenu* fVolumeContextMenu; + BPopUpMenu* fTrashContextMenu; + BSlowContextMenu* fDragContextMenu; + BMenuItem* fMoveToItem; + BMenuItem* fCopyToItem; + BMenuItem* fCreateLinkItem; + BMenuItem* fOpenWithItem; + ModelMenuItem* fNavigationItem; + BMenuBar* fMenuBar; + BNavigator* fNavigator; + BPoseView* fPoseView; + LockingList* fWindowList; + BMenu* fAttrMenu; + BMenu* fWindowMenu; + BMenu* fFileMenu; + BMenu* fArrangeByMenu; - SelectionWindow *fSelectionWindow; + SelectionWindow* fSelectionWindow; - PiggybackTaskLoop *fTaskLoop; + PiggybackTaskLoop* fTaskLoop; bool fIsTrash; bool fInTrash; bool fIsPrinters; uint32 fContainerWindowFlags; - BackgroundImage *fBackgroundImage; + BackgroundImage* fBackgroundImage; private: BRect fSavedZoomRect; @@ -291,9 +291,9 @@ class BContainerWindow : public BWindow { static BRect sNewWindRect; - BPopUpMenu *fContextMenu; - BMessage *fDragMessage; - BObjectList *fCachedTypesList; + BPopUpMenu* fContextMenu; + BMessage* fDragMessage; + BObjectList* fCachedTypesList; bool fWaitingForRefs; bool fStateNeedsSaving; @@ -316,20 +316,20 @@ class WindowStateNodeOpener { // setter calls used when no attributes can be read from a node and defaults // are to be substituted public: - WindowStateNodeOpener(BContainerWindow *window, bool forWriting); + WindowStateNodeOpener(BContainerWindow* window, bool forWriting); virtual ~WindowStateNodeOpener(); - void SetTo(const BDirectory *); - void SetTo(const BEntry *entry, bool forWriting); - void SetTo(Model *, bool forWriting); + void SetTo(const BDirectory*); + void SetTo(const BEntry* entry, bool forWriting); + void SetTo(Model*, bool forWriting); - AttributeStreamNode *StreamNode() const; - BNode *Node() const; + AttributeStreamNode* StreamNode() const; + BNode* Node() const; private: - ModelNodeLazyOpener *fModelOpener; - BNode *fNode; - AttributeStreamNode *fStreamNode; + ModelNodeLazyOpener* fModelOpener; + BNode* fNode; + AttributeStreamNode* fStreamNode; }; class BackgroundView : public BView { @@ -350,17 +350,17 @@ class BackgroundView : public BView { typedef BView _inherited; }; -int CompareLabels(const BMenuItem *, const BMenuItem *); +int CompareLabels(const BMenuItem*, const BMenuItem*); // inlines --------- -inline BNavigator * +inline BNavigator* BContainerWindow::Navigator() const { return fNavigator; } -inline BPoseView * +inline BPoseView* BContainerWindow::PoseView() const { return fPoseView; @@ -385,12 +385,12 @@ BContainerWindow::IsPrintersDir() const } inline void -BContainerWindow::SetUpDiskMenu(BMenu *) +BContainerWindow::SetUpDiskMenu(BMenu*) { // nothing at this level } -inline BPopUpMenu * +inline BPopUpMenu* BContainerWindow::ContextMenu() { return fContextMenu; @@ -402,7 +402,7 @@ BContainerWindow::Dragging() const return fDragMessage && fCachedTypesList; } -inline BMessage * +inline BMessage* BContainerWindow::DragMessage() const { return fDragMessage; @@ -428,8 +428,8 @@ BContainerWindow::IsPathWatchingEnabled() const return fIsWatchingPath; } -filter_result ActivateWindowFilter(BMessage *message, BHandler **target, - BMessageFilter *messageFilter); +filter_result ActivateWindowFilter(BMessage* message, BHandler**target, + BMessageFilter* messageFilter); } // namespace BPrivate diff --git a/src/kits/tracker/CountView.cpp b/src/kits/tracker/CountView.cpp index c633d5c30a..d9044d0f3e 100644 --- a/src/kits/tracker/CountView.cpp +++ b/src/kits/tracker/CountView.cpp @@ -300,7 +300,7 @@ BCountView::Draw(BRect updateRect) void BCountView::MouseDown(BPoint) { - BContainerWindow *window = dynamic_cast(Window()); + BContainerWindow* window = dynamic_cast(Window()); window->Activate(); window->UpdateIfNeeded(); @@ -308,7 +308,7 @@ BCountView::MouseDown(BPoint) return; if (!window->TargetModel()->IsRoot()) { - BDirMenu *menu = new BDirMenu(NULL, be_app, B_REFS_RECEIVED); + BDirMenu* menu = new BDirMenu(NULL, be_app, B_REFS_RECEIVED); BEntry entry; if (entry.SetTo(window->TargetModel()->EntryRef()) == B_OK) menu->Populate(&entry, Window(), false, false, true, false, true); @@ -340,14 +340,14 @@ BCountView::AttachedToWindow() void -BCountView::SetTypeAhead(const char *string) +BCountView::SetTypeAhead(const char* string) { fTypeAheadString = string; Invalidate(); } -const char * +const char* BCountView::TypeAhead() const { return fTypeAheadString.String(); @@ -362,7 +362,7 @@ BCountView::IsTypingAhead() const void -BCountView::AddFilterCharacter(const char *character) +BCountView::AddFilterCharacter(const char* character) { fFilterString.AppendChars(character, 1); Invalidate(); @@ -385,7 +385,7 @@ BCountView::CancelFilter() } -const char * +const char* BCountView::Filter() const { return fFilterString.String(); diff --git a/src/kits/tracker/CountView.h b/src/kits/tracker/CountView.h index f876c486d5..451fdcd42f 100644 --- a/src/kits/tracker/CountView.h +++ b/src/kits/tracker/CountView.h @@ -31,13 +31,14 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef __COUNT_VIEW__ #define __COUNT_VIEW__ + #include #include + namespace BPrivate { class BPoseView; @@ -46,7 +47,7 @@ class BCountView : public BView { // displays the item count and a barber pole while the view is updating public: - BCountView(BRect, BPoseView *); + BCountView(BRect, BPoseView*); ~BCountView(); virtual void Draw(BRect); @@ -59,14 +60,14 @@ public: void StartBarberPole(); void EndBarberPole(); - void SetTypeAhead(const char *); - const char *TypeAhead() const; + void SetTypeAhead(const char*); + const char* TypeAhead() const; bool IsTypingAhead() const; - void AddFilterCharacter(const char *character); + void AddFilterCharacter(const char* character); void RemoveFilterCharacter(); void CancelFilter(); - const char *Filter() const; + const char* Filter() const; bool IsFiltering() const; void SetBorderHighlighted(bool highlighted); @@ -79,10 +80,10 @@ private: void TrySpinningBarberPole(); int32 fLastCount; - BPoseView *fPoseView; + BPoseView* fPoseView; bool fShowingBarberPole : 1; bool fBorderHighlighted : 1; - BBitmap *fBarberPoleMap; + BBitmap* fBarberPoleMap; float fLastBarberPoleOffset; bigtime_t fStartSpinningAfter; BString fTypeAheadString; diff --git a/src/kits/tracker/Cursors.h b/src/kits/tracker/Cursors.h index c6dbd148a6..9e7076781b 100644 --- a/src/kits/tracker/Cursors.h +++ b/src/kits/tracker/Cursors.h @@ -8,6 +8,7 @@ #ifndef CURSORS_H #define CURSORS_H + // Exported with Wonderbrush from haiku/data/artwork/cursors/Overlays_Tracker // TODO: Don't use these, there are new cursors, which you can use by ID. // (Except for the kMoveCursor, which has different meaning here.) diff --git a/src/kits/tracker/DeskWindow.cpp b/src/kits/tracker/DeskWindow.cpp index bddc16471c..6680aff9c6 100644 --- a/src/kits/tracker/DeskWindow.cpp +++ b/src/kits/tracker/DeskWindow.cpp @@ -60,12 +60,12 @@ All rights reserved. #include "TemplatesMenu.h" -const char *kShelfPath = "tracker_shelf"; +const char* kShelfPath = "tracker_shelf"; // replicant support static void -WatchAddOnDir(directory_which dirName, BDeskWindow *window) +WatchAddOnDir(directory_which dirName, BDeskWindow* window) { BPath path; if (find_directory(dirName, &path) == B_OK) { @@ -79,19 +79,19 @@ WatchAddOnDir(directory_which dirName, BDeskWindow *window) struct AddOneShortcutParams { - BDeskWindow *window; - std::set *currentAddonShortcuts; + BDeskWindow* window; + std::set* currentAddonShortcuts; }; static bool -AddOneShortcut(const Model *model, const char *, uint32 shortcut, bool /*primary*/, void *context) +AddOneShortcut(const Model* model, const char*, uint32 shortcut, bool /*primary*/, void* context) { if (!shortcut) // no shortcut, bail return false; - AddOneShortcutParams *params = (AddOneShortcutParams *)context; - BMessage *runAddon = new BMessage(kLoadAddOn); + AddOneShortcutParams* params = (AddOneShortcutParams*)context; + BMessage* runAddon = new BMessage(kLoadAddOn); runAddon->AddRef("refs", model->EntryRef()); params->window->AddShortcut(shortcut, B_OPTION_KEY | B_COMMAND_KEY, @@ -108,7 +108,7 @@ AddOneShortcut(const Model *model, const char *, uint32 shortcut, bool /*primary #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "DeskWindow" -BDeskWindow::BDeskWindow(LockingList *windowList) +BDeskWindow::BDeskWindow(LockingList* windowList) : BContainerWindow(windowList, 0, kPrivateDesktopWindowLook, kPrivateDesktopWindowFeel, B_NOT_MOVABLE | B_WILL_ACCEPT_FIRST_CLICK @@ -149,7 +149,7 @@ BDeskWindow::~BDeskWindow() void -BDeskWindow::Init(const BMessage *) +BDeskWindow::Init(const BMessage*) { // // Set the size of the screen before calling the container window's @@ -220,7 +220,7 @@ BDeskWindow::Quit() // this duplicates BContainerWindow::Quit because // fNavigationItem can be part of fTrashContextMenu // and would get deleted with it - BMenu *menu = fNavigationItem->Menu(); + BMenu* menu = fNavigationItem->Menu(); if (menu) menu->RemoveItem(fNavigationItem); delete fNavigationItem; @@ -235,15 +235,15 @@ BDeskWindow::Quit() } -BPoseView * -BDeskWindow::NewPoseView(Model *model, BRect rect, uint32 viewMode) +BPoseView* +BDeskWindow::NewPoseView(Model* model, BRect rect, uint32 viewMode) { return new DesktopPoseView(model, rect, viewMode); } void -BDeskWindow::CreatePoseView(Model *model) +BDeskWindow::CreatePoseView(Model* model) { fPoseView = NewPoseView(model, Bounds(), kIconMode); fPoseView->SetIconMapping(false); @@ -272,7 +272,7 @@ BDeskWindow::CreatePoseView(Model *model) void -BDeskWindow::AddWindowContextMenus(BMenu *menu) +BDeskWindow::AddWindowContextMenus(BMenu* menu) { TemplatesMenu* tempateMenu = new TemplatesMenu(PoseView(), B_TRANSLATE("New")); @@ -444,14 +444,14 @@ BDeskWindow::ShouldAddContainerView() const void -BDeskWindow::MessageReceived(BMessage *message) +BDeskWindow::MessageReceived(BMessage* message) { if (message->WasDropped()) { - const rgb_color *color; + const rgb_color* color; int32 size; // handle "roColour"-style color drops if (message->FindData("RGBColor", 'RGBC', - (const void **)&color, &size) == B_OK) { + (const void**)&color, &size) == B_OK) { BScreen(this).SetDesktopColor(*color); fPoseView->SetViewColor(*color); fPoseView->SetLowColor(*color); diff --git a/src/kits/tracker/DeskWindow.h b/src/kits/tracker/DeskWindow.h index e490b0a051..472b31d0c9 100644 --- a/src/kits/tracker/DeskWindow.h +++ b/src/kits/tracker/DeskWindow.h @@ -31,38 +31,39 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef _DESK_WINDOW_H #define _DESK_WINDOW_H + #include #include #include "ContainerWindow.h" #include "DesktopPoseView.h" + class BPopUpMenu; namespace BPrivate { class BDeskWindow : public BContainerWindow { public: - BDeskWindow(LockingList *windowList); + BDeskWindow(LockingList* windowList); virtual ~BDeskWindow(); - virtual void Init(const BMessage *message = NULL); + virtual void Init(const BMessage* message = NULL); virtual void Show(); virtual void Quit(); virtual void ScreenChanged(BRect, color_space); - virtual void CreatePoseView(Model *); + virtual void CreatePoseView(Model*); virtual bool ShouldAddMenus() const; virtual bool ShouldAddScrollBars() const; virtual bool ShouldAddContainerView() const; - DesktopPoseView *PoseView() const; + DesktopPoseView* PoseView() const; void UpdateDesktopBackgroundImages(); // Desktop window has special background image handling @@ -70,17 +71,17 @@ public: void SaveDesktopPoseLocations(); protected: - virtual void AddWindowContextMenus(BMenu *); - virtual BPoseView *NewPoseView(Model *, BRect, uint32); + virtual void AddWindowContextMenus(BMenu*); + virtual BPoseView* NewPoseView(Model*, BRect, uint32); virtual void WorkspaceActivated(int32, bool); virtual void MenusBeginning(); - virtual void MessageReceived(BMessage *); + virtual void MessageReceived(BMessage*); private: - BShelf *fDeskShelf; + BShelf* fDeskShelf; // shelf for replicant support - BPopUpMenu *fTrashContextMenu; + BPopUpMenu* fTrashContextMenu; BRect fOldFrame; @@ -95,10 +96,11 @@ private: typedef BContainerWindow _inherited; }; -inline DesktopPoseView * + +inline DesktopPoseView* BDeskWindow::PoseView() const { - return dynamic_cast(_inherited::PoseView()); + return dynamic_cast(_inherited::PoseView()); } } // namespace BPrivate diff --git a/src/kits/tracker/DesktopPoseView.cpp b/src/kits/tracker/DesktopPoseView.cpp index c2bb9423ac..ad9bedf2eb 100644 --- a/src/kits/tracker/DesktopPoseView.cpp +++ b/src/kits/tracker/DesktopPoseView.cpp @@ -55,7 +55,7 @@ All rights reserved. // #pragma mark - -DesktopPoseView::DesktopPoseView(Model *model, BRect frame, uint32 viewMode, +DesktopPoseView::DesktopPoseView(Model* model, BRect frame, uint32 viewMode, uint32 resizeMask) : BPoseView(model, frame, viewMode, resizeMask) @@ -64,9 +64,9 @@ DesktopPoseView::DesktopPoseView(Model *model, BRect frame, uint32 viewMode, } -EntryListBase * -DesktopPoseView::InitDesktopDirentIterator(BPoseView *nodeMonitoringTarget, - const entry_ref *ref) +EntryListBase* +DesktopPoseView::InitDesktopDirentIterator(BPoseView* nodeMonitoringTarget, + const entry_ref* ref) { // the desktop dirent iterator knows how to iterate over all the volumes, // integrated onto the desktop @@ -75,16 +75,16 @@ DesktopPoseView::InitDesktopDirentIterator(BPoseView *nodeMonitoringTarget, if (sourceModel.InitCheck() != B_OK) return NULL; - CachedEntryIteratorList *result = new CachedEntryIteratorList(); + CachedEntryIteratorList* result = new CachedEntryIteratorList(); ASSERT(!sourceModel.IsQuery()); ASSERT(sourceModel.Node()); - BDirectory *sourceDirectory = dynamic_cast(sourceModel.Node()); + BDirectory* sourceDirectory = dynamic_cast(sourceModel.Node()); ASSERT(sourceDirectory); // build an iterator list, start with boot - EntryListBase *perDesktopIterator = new CachedDirectoryEntryList( + EntryListBase* perDesktopIterator = new CachedDirectoryEntryList( *sourceDirectory); result->AddItem(perDesktopIterator); @@ -106,15 +106,15 @@ DesktopPoseView::InitDesktopDirentIterator(BPoseView *nodeMonitoringTarget, } -EntryListBase * -DesktopPoseView::InitDirentIterator(const entry_ref *ref) +EntryListBase* +DesktopPoseView::InitDirentIterator(const entry_ref* ref) { return InitDesktopDirentIterator(this, ref); } bool -DesktopPoseView::FSNotification(const BMessage *message) +DesktopPoseView::FSNotification(const BMessage* message) { switch (message->FindInt32("opcode")) { case B_DEVICE_MOUNTED: @@ -144,7 +144,7 @@ DesktopPoseView::FSNotification(const BMessage *message) bool -DesktopPoseView::AddPosesThreadValid(const entry_ref *) const +DesktopPoseView::AddPosesThreadValid(const entry_ref*) const { return true; } @@ -159,7 +159,7 @@ DesktopPoseView::AddPosesCompleted() bool -DesktopPoseView::Represents(const node_ref *ref) const +DesktopPoseView::Represents(const node_ref* ref) const { // When the Tracker is set up to integrate non-boot beos volumes, // it represents the home/Desktop folders of all beos volumes @@ -169,7 +169,7 @@ DesktopPoseView::Represents(const node_ref *ref) const bool -DesktopPoseView::Represents(const entry_ref *ref) const +DesktopPoseView::Represents(const entry_ref* ref) const { BEntry entry(ref); node_ref nref; @@ -183,7 +183,7 @@ DesktopPoseView::ShowVolumes(bool visible, bool showShared) { if (LockLooper()) { SavePoseLocations(); - if (!visible) + if (!visible) RemoveRootPoses(); else AddRootPoses(true, showShared); @@ -215,9 +215,9 @@ DesktopPoseView::StopSettingsWatch() void -DesktopPoseView::AdaptToVolumeChange(BMessage *message) +DesktopPoseView::AdaptToVolumeChange(BMessage* message) { - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); if (!tracker) return; @@ -241,7 +241,7 @@ DesktopPoseView::AdaptToVolumeChange(BMessage *message) entryMessage.AddInt32("opcode", B_ENTRY_REMOVED); entry_ref ref; if (entry.GetRef(&ref) == B_OK) { - BContainerWindow *disksWindow = tracker->FindContainerWindow(&ref); + BContainerWindow* disksWindow = tracker->FindContainerWindow(&ref); if (disksWindow) { disksWindow->Lock(); disksWindow->Close(); @@ -252,7 +252,7 @@ DesktopPoseView::AdaptToVolumeChange(BMessage *message) entryMessage.AddInt64("node", model.NodeRef()->node); entryMessage.AddInt64("directory", model.EntryRef()->directory); entryMessage.AddString("name", model.EntryRef()->name); - BContainerWindow *deskWindow = dynamic_cast(Window()); + BContainerWindow* deskWindow = dynamic_cast(Window()); if (deskWindow) deskWindow->PostMessage(&entryMessage, deskWindow->PoseView()); } @@ -262,7 +262,7 @@ DesktopPoseView::AdaptToVolumeChange(BMessage *message) void -DesktopPoseView::AdaptToDesktopIntegrationChange(BMessage *message) +DesktopPoseView::AdaptToDesktopIntegrationChange(BMessage* message) { bool mountVolumesOnDesktop = true; bool mountSharedVolumesOntoDesktop = true; diff --git a/src/kits/tracker/DesktopPoseView.h b/src/kits/tracker/DesktopPoseView.h index 3b611129af..8d7ffad52e 100644 --- a/src/kits/tracker/DesktopPoseView.h +++ b/src/kits/tracker/DesktopPoseView.h @@ -34,49 +34,51 @@ All rights reserved. // DesktopPoseView adds support for displaying integrated desktops // from multiple volumes to BPoseView - #ifndef _DESKTOP_POSE_VIEW_H #define _DESKTOP_POSE_VIEW_H + #include "EntryIterator.h" #include "PoseView.h" + namespace BPrivate { class DesktopPoseView : public BPoseView { // overrides BPoseView to add desktop-view specific code public: - DesktopPoseView(Model *, BRect, uint32 viewMode, uint32 resizeMask = B_FOLLOW_ALL); + DesktopPoseView(Model*, BRect, uint32 viewMode, + uint32 resizeMask = B_FOLLOW_ALL); - static EntryListBase *InitDesktopDirentIterator(BPoseView *, const entry_ref *); + static EntryListBase* InitDesktopDirentIterator(BPoseView*, + const entry_ref*); void ShowVolumes(bool visible, bool showShared); - + void StartSettingsWatch(); void StopSettingsWatch(); - - virtual bool AddPosesThreadValid(const entry_ref *) const; + + virtual bool AddPosesThreadValid(const entry_ref*) const; virtual void AddPosesCompleted(); - + protected: - virtual EntryListBase *InitDirentIterator(const entry_ref *); - virtual bool FSNotification(const BMessage *); + virtual EntryListBase* InitDirentIterator(const entry_ref*); + virtual bool FSNotification(const BMessage*); virtual bool IsDesktopView() const; - virtual bool Represents(const node_ref *) const; - virtual bool Represents(const entry_ref *) const; + virtual bool Represents(const node_ref*) const; + virtual bool Represents(const entry_ref*) const; - void AdaptToVolumeChange(BMessage *); - void AdaptToDesktopIntegrationChange(BMessage *); + void AdaptToVolumeChange(BMessage*); + void AdaptToDesktopIntegrationChange(BMessage*); private: typedef BPoseView _inherited; - }; -inline bool +inline bool DesktopPoseView::IsDesktopView() const { return true; diff --git a/src/kits/tracker/DialogPane.cpp b/src/kits/tracker/DialogPane.cpp index 18dd586aae..06b60369a2 100644 --- a/src/kits/tracker/DialogPane.cpp +++ b/src/kits/tracker/DialogPane.cpp @@ -48,21 +48,21 @@ const rgb_color kHighlightColor = {100, 100, 0, 255}; static void -AddSelf(BView *self, BView *to) +AddSelf(BView* self, BView* to) { to->AddChild(self); } void -ViewList::RemoveAll(BView *) +ViewList::RemoveAll(BView*) { EachListItemIgnoreResult(this, &BView::RemoveSelf); } void -ViewList::AddAll(BView *toParent) +ViewList::AddAll(BView* toParent) { EachListItem(this, &AddSelf, toParent); } @@ -72,7 +72,7 @@ ViewList::AddAll(BView *toParent) DialogPane::DialogPane(BRect mode1Frame, BRect mode2Frame, int32 initialMode, - const char *name, uint32 followFlags, uint32 flags) + const char* name, uint32 followFlags, uint32 flags) : BView(FrameForMode(initialMode, mode1Frame, mode2Frame, mode2Frame), name, followFlags, flags), fMode(initialMode), @@ -85,7 +85,7 @@ DialogPane::DialogPane(BRect mode1Frame, BRect mode2Frame, int32 initialMode, DialogPane::DialogPane(BRect mode1Frame, BRect mode2Frame, BRect mode3Frame, - int32 initialMode, const char *name, uint32 followFlags, uint32 flags) + int32 initialMode, const char* name, uint32 followFlags, uint32 flags) : BView(FrameForMode(initialMode, mode1Frame, mode2Frame, mode3Frame), name, followFlags, flags), fMode(initialMode), @@ -134,7 +134,7 @@ DialogPane::SetMode(int32 mode, bool initialSetup) if (delta != 0) { MoveBy(0, delta); if (fLatch && (fLatch->ResizingMode() & B_FOLLOW_BOTTOM)) - fLatch->MoveBy(0, delta); + fLatch->MoveBy(0, delta); } switch (fMode) { @@ -145,7 +145,7 @@ DialogPane::SetMode(int32 mode, bool initialSetup) if (oldMode > 0) fMode2Items.RemoveAll(this); - BView *separator = FindView("separatorLine"); + BView* separator = FindView("separatorLine"); if (separator) { BRect frame(separator->Frame()); frame.InsetBy(-1, -1); @@ -160,34 +160,34 @@ DialogPane::SetMode(int32 mode, bool initialSetup) } case 1: { - if (oldMode > 1) + if (oldMode > 1) fMode3Items.RemoveAll(this); - else + else fMode2Items.AddAll(this); - BView *separator = FindView("separatorLine"); + BView* separator = FindView("separatorLine"); if (separator) { BRect frame(separator->Frame()); frame.InsetBy(-1, -1); RemoveChild(separator); Invalidate(); } - break; + break; } case 2: { fMode3Items.AddAll(this); - if (oldMode < 1) + if (oldMode < 1) fMode2Items.AddAll(this); - BView *separator = FindView("separatorLine"); + BView* separator = FindView("separatorLine"); if (separator) { BRect frame(separator->Frame()); frame.InsetBy(-1, -1); RemoveChild(separator); Invalidate(); } - break; + break; } } } @@ -196,7 +196,7 @@ DialogPane::SetMode(int32 mode, bool initialSetup) void DialogPane::AttachedToWindow() { - BView *parent = Parent(); + BView* parent = Parent(); if (parent) { SetViewColor(parent->ViewColor()); SetLowColor(parent->LowColor()); @@ -220,7 +220,7 @@ DialogPane::ResizeParentWindow(int32 from, int32 to) void -DialogPane::AddItem(BView *view, int32 toMode) +DialogPane::AddItem(BView* view, int32 toMode) { if (toMode == 1) fMode2Items.AddItem(view); @@ -283,16 +283,16 @@ DialogPane::FrameForMode(int32 mode, BRect mode1Frame, BRect mode2Frame, void -DialogPane::SetSwitch(BControl *control) +DialogPane::SetSwitch(BControl* control) { - fLatch = control; + fLatch = control; control->SetMessage(new BMessage(kValueChanged)); control->SetTarget(this); } void -DialogPane::MessageReceived(BMessage *message) +DialogPane::MessageReceived(BMessage* message) { if (message->what == kValueChanged) { int32 value; @@ -306,7 +306,7 @@ DialogPane::MessageReceived(BMessage *message) // #pragma mark - PaneSwitch -PaneSwitch::PaneSwitch(BRect frame, const char *name, bool leftAligned, +PaneSwitch::PaneSwitch(BRect frame, const char* name, bool leftAligned, uint32 resizeMask, uint32 flags) : BControl(frame, name, "", 0, resizeMask, flags), @@ -318,7 +318,7 @@ PaneSwitch::PaneSwitch(BRect frame, const char *name, bool leftAligned, } -PaneSwitch::PaneSwitch(const char *name, bool leftAligned, uint32 flags) +PaneSwitch::PaneSwitch(const char* name, bool leftAligned, uint32 flags) : BControl(name, "", 0, flags), fLeftAligned(leftAligned), @@ -507,32 +507,32 @@ PaneSwitch::DrawInState(PaneSwitch::State state) BeginLineArray(6); if (fLeftAligned) { - AddLine(BPoint(rect.left + 3, rect.top + 1), + AddLine(BPoint(rect.left + 3, rect.top + 1), BPoint(rect.left + 3, rect.bottom - 1), outlineColor); - AddLine(BPoint(rect.left + 3, rect.top + 1), + AddLine(BPoint(rect.left + 3, rect.top + 1), BPoint(rect.left + 7, rect.top + 5), outlineColor); - AddLine(BPoint(rect.left + 7, rect.top + 5), + AddLine(BPoint(rect.left + 7, rect.top + 5), BPoint(rect.left + 3, rect.bottom - 1), outlineColor); - AddLine(BPoint(rect.left + 4, rect.top + 3), + AddLine(BPoint(rect.left + 4, rect.top + 3), BPoint(rect.left + 4, rect.bottom - 3), middleColor); - AddLine(BPoint(rect.left + 5, rect.top + 4), + AddLine(BPoint(rect.left + 5, rect.top + 4), BPoint(rect.left + 5, rect.bottom - 4), middleColor); - AddLine(BPoint(rect.left + 5, rect.top + 5), + AddLine(BPoint(rect.left + 5, rect.top + 5), BPoint(rect.left + 6, rect.top + 5), middleColor); } else { - AddLine(BPoint(rect.right - 3, rect.top + 1), + AddLine(BPoint(rect.right - 3, rect.top + 1), BPoint(rect.right - 3, rect.bottom - 1), outlineColor); - AddLine(BPoint(rect.right - 3, rect.top + 1), + AddLine(BPoint(rect.right - 3, rect.top + 1), BPoint(rect.right - 7, rect.top + 5), outlineColor); - AddLine(BPoint(rect.right - 7, rect.top + 5), + AddLine(BPoint(rect.right - 7, rect.top + 5), BPoint(rect.right - 3, rect.bottom - 1), outlineColor); - AddLine(BPoint(rect.right - 4, rect.top + 3), + AddLine(BPoint(rect.right - 4, rect.top + 3), BPoint(rect.right - 4, rect.bottom - 3), middleColor); - AddLine(BPoint(rect.right - 5, rect.top + 4), + AddLine(BPoint(rect.right - 5, rect.top + 4), BPoint(rect.right - 5, rect.bottom - 4), middleColor); - AddLine(BPoint(rect.right - 5, rect.top + 5), + AddLine(BPoint(rect.right - 5, rect.top + 5), BPoint(rect.right - 6, rect.top + 5), middleColor); } EndLineArray(); @@ -541,36 +541,36 @@ PaneSwitch::DrawInState(PaneSwitch::State state) case kPressed: BeginLineArray(7); if (fLeftAligned) { - AddLine(BPoint(rect.left + 1, rect.top + 7), + AddLine(BPoint(rect.left + 1, rect.top + 7), BPoint(rect.left + 7, rect.top + 7), outlineColor); - AddLine(BPoint(rect.left + 7, rect.top + 1), + AddLine(BPoint(rect.left + 7, rect.top + 1), BPoint(rect.left + 7, rect.top + 7), outlineColor); - AddLine(BPoint(rect.left + 1, rect.top + 7), + AddLine(BPoint(rect.left + 1, rect.top + 7), BPoint(rect.left + 7, rect.top + 1), outlineColor); - AddLine(BPoint(rect.left + 3, rect.top + 6), + AddLine(BPoint(rect.left + 3, rect.top + 6), BPoint(rect.left + 6, rect.top + 6), middleColor); - AddLine(BPoint(rect.left + 4, rect.top + 5), + AddLine(BPoint(rect.left + 4, rect.top + 5), BPoint(rect.left + 6, rect.top + 5), middleColor); - AddLine(BPoint(rect.left + 5, rect.top + 4), + AddLine(BPoint(rect.left + 5, rect.top + 4), BPoint(rect.left + 6, rect.top + 4), middleColor); - AddLine(BPoint(rect.left + 6, rect.top + 3), + AddLine(BPoint(rect.left + 6, rect.top + 3), BPoint(rect.left + 6, rect.top + 4), middleColor); } else { - AddLine(BPoint(rect.right - 1, rect.top + 7), + AddLine(BPoint(rect.right - 1, rect.top + 7), BPoint(rect.right - 7, rect.top + 7), outlineColor); - AddLine(BPoint(rect.right - 7, rect.top + 1), + AddLine(BPoint(rect.right - 7, rect.top + 1), BPoint(rect.right - 7, rect.top + 7), outlineColor); - AddLine(BPoint(rect.right - 1, rect.top + 7), + AddLine(BPoint(rect.right - 1, rect.top + 7), BPoint(rect.right - 7, rect.top + 1), outlineColor); - AddLine(BPoint(rect.right - 3, rect.top + 6), + AddLine(BPoint(rect.right - 3, rect.top + 6), BPoint(rect.right - 6, rect.top + 6), middleColor); - AddLine(BPoint(rect.right - 4, rect.top + 5), + AddLine(BPoint(rect.right - 4, rect.top + 5), BPoint(rect.right - 6, rect.top + 5), middleColor); - AddLine(BPoint(rect.right - 5, rect.top + 4), + AddLine(BPoint(rect.right - 5, rect.top + 4), BPoint(rect.right - 6, rect.top + 4), middleColor); - AddLine(BPoint(rect.right - 6, rect.top + 3), + AddLine(BPoint(rect.right - 6, rect.top + 3), BPoint(rect.right - 6, rect.top + 4), middleColor); } EndLineArray(); @@ -578,21 +578,20 @@ PaneSwitch::DrawInState(PaneSwitch::State state) case kExpanded: BeginLineArray(6); - AddLine(BPoint(rect.left + 1, rect.top + 3), + AddLine(BPoint(rect.left + 1, rect.top + 3), BPoint(rect.right - 1, rect.top + 3), outlineColor); - AddLine(BPoint(rect.left + 1, rect.top + 3), + AddLine(BPoint(rect.left + 1, rect.top + 3), BPoint(rect.left + 5, rect.top + 7), outlineColor); - AddLine(BPoint(rect.left + 5, rect.top + 7), + AddLine(BPoint(rect.left + 5, rect.top + 7), BPoint(rect.right - 1, rect.top + 3), outlineColor); - AddLine(BPoint(rect.left + 3, rect.top + 4), + AddLine(BPoint(rect.left + 3, rect.top + 4), BPoint(rect.right - 3, rect.top + 4), middleColor); - AddLine(BPoint(rect.left + 4, rect.top + 5), + AddLine(BPoint(rect.left + 4, rect.top + 5), BPoint(rect.right - 4, rect.top + 5), middleColor); - AddLine(BPoint(rect.left + 5, rect.top + 5), + AddLine(BPoint(rect.left + 5, rect.top + 5), BPoint(rect.left + 5, rect.top + 6), middleColor); EndLineArray(); break; } } - diff --git a/src/kits/tracker/DialogPane.h b/src/kits/tracker/DialogPane.h index 21ca1c7e3d..c9d12a0b8a 100644 --- a/src/kits/tracker/DialogPane.h +++ b/src/kits/tracker/DialogPane.h @@ -31,14 +31,15 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef _DIALOG_PANE_ #define _DIALOG_PANE_ + #include #include "ObjectList.h" + namespace BPrivate { class ViewList : public BObjectList { @@ -51,6 +52,7 @@ public: void AddAll(BView* toParent); }; + class DialogPane : public BView { // dialog with collapsible panes public: @@ -101,7 +103,7 @@ private: }; -inline int32 +inline int32 DialogPane::Mode() const { return fMode; @@ -113,7 +115,7 @@ public: PaneSwitch(BRect frame, const char* name, bool leftAligned = true, uint32 resizeMask - = B_FOLLOW_LEFT | B_FOLLOW_TOP, + = B_FOLLOW_LEFT | B_FOLLOW_TOP, uint32 flags = B_WILL_DRAW | B_NAVIGABLE); PaneSwitch(const char* name, diff --git a/src/kits/tracker/DirMenu.cpp b/src/kits/tracker/DirMenu.cpp index 1d3a4d99da..38ae18b346 100644 --- a/src/kits/tracker/DirMenu.cpp +++ b/src/kits/tracker/DirMenu.cpp @@ -58,8 +58,8 @@ All rights reserved. #define B_TRANSLATION_CONTEXT "DirMenu" -BDirMenu::BDirMenu(BMenuBar *bar, BMessenger target, uint32 command, - const char *entryName) +BDirMenu::BDirMenu(BMenuBar* bar, BMessenger target, uint32 command, + const char* entryName) : BPopUpMenu("directories"), fTarget(target), @@ -80,7 +80,7 @@ BDirMenu::~BDirMenu() void -BDirMenu::Populate(const BEntry *startEntry, BWindow *originatingWindow, +BDirMenu::Populate(const BEntry* startEntry, BWindow* originatingWindow, bool includeStartEntry, bool select, bool reverse, bool addShortcuts, bool navMenuEntries) { @@ -91,7 +91,7 @@ BDirMenu::Populate(const BEntry *startEntry, BWindow *originatingWindow, Model model(startEntry); ThrowOnInitCheckError(&model); - ModelMenuItem *menu = new ModelMenuItem(&model, this, true, true); + ModelMenuItem* menu = new ModelMenuItem(&model, this, true, true); if (fMenuBar) fMenuBar->AddItem(menu); @@ -139,7 +139,8 @@ BDirMenu::Populate(const BEntry *startEntry, BWindow *originatingWindow, // if we're at the root directory skip "mnt" and go straight to "/" BDirectory dir(&entry); - if (!showDesktop && dir.InitCheck() == B_OK && dir.IsRootDirectory()) { + if (!showDesktop && dir.InitCheck() == B_OK + && dir.IsRootDirectory()) { hitRoot = true; parent.SetTo("/"); } @@ -176,7 +177,8 @@ BDirMenu::Populate(const BEntry *startEntry, BWindow *originatingWindow, if (!select) return; - ModelMenuItem *item = dynamic_cast(ItemAt(CountItems() - 1)); + ModelMenuItem* item + = dynamic_cast(ItemAt(CountItems() - 1)); if (item) { item->SetMarked(true); if (menu) { @@ -196,24 +198,24 @@ BDirMenu::Populate(const BEntry *startEntry, BWindow *originatingWindow, void -BDirMenu::AddItemToDirMenu(const BEntry *entry, BWindow *originatingWindow, +BDirMenu::AddItemToDirMenu(const BEntry* entry, BWindow* originatingWindow, bool atEnd, bool addShortcuts, bool navMenuEntries) { Model model(entry); if (model.InitCheck() != B_OK) return; - BMessage *message = new BMessage(fCommand); + BMessage* message = new BMessage(fCommand); message->AddRef(fEntryName.String(), model.EntryRef()); // add reference to the container windows model so that we can // close the window if - BContainerWindow *window = originatingWindow ? - dynamic_cast(originatingWindow) : 0; + BContainerWindow* window = originatingWindow ? + dynamic_cast(originatingWindow) : 0; if (window) message->AddData("nodeRefsToClose", B_RAW_TYPE, window->TargetModel()->NodeRef(), sizeof (node_ref)); - ModelMenuItem *item; + ModelMenuItem* item; if (navMenuEntries) { BNavMenu* subMenu = new BNavMenu(model.Name(), B_REFS_RECEIVED, fTarget, window); @@ -242,7 +244,7 @@ BDirMenu::AddItemToDirMenu(const BEntry *entry, BWindow *originatingWindow, item->SetTarget(fTarget); if (fMenuBar) { - ModelMenuItem *menu = dynamic_cast(fMenuBar->ItemAt(0)); + ModelMenuItem* menu = dynamic_cast(fMenuBar->ItemAt(0)); if (menu) { ThrowOnError(menu->SetEntry(entry)); item->SetMarked(true); @@ -259,7 +261,7 @@ BDirMenu::AddDisksIconToMenu(bool atEnd) if (model.InitCheck() != B_OK) return; - BMessage *message = new BMessage(fCommand); + BMessage* message = new BMessage(fCommand); message->AddRef(fEntryName.String(), model.EntryRef()); ModelMenuItem* item = new ModelMenuItem(&model, B_TRANSLATE("Disks"), @@ -269,4 +271,3 @@ BDirMenu::AddDisksIconToMenu(bool atEnd) else AddItem(item, 0); } - diff --git a/src/kits/tracker/DirMenu.h b/src/kits/tracker/DirMenu.h index 7cef53b352..597cd4e509 100644 --- a/src/kits/tracker/DirMenu.h +++ b/src/kits/tracker/DirMenu.h @@ -31,41 +31,43 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef DIR_MENU_H #define DIR_MENU_H + #include #include + class MenuBar; namespace BPrivate { class BDirMenu : public BPopUpMenu { public: - BDirMenu(BMenuBar *, BMessenger target, uint32 command, - const char *entryName = 0); + BDirMenu(BMenuBar*, BMessenger target, uint32 command, + const char* entryName = 0); virtual ~BDirMenu(); - void Populate(const BEntry *startDir, BWindow *originatingWindow, + void Populate(const BEntry* startDir, BWindow* originatingWindow, bool includeStartDir = false, bool select = false, bool reverse = false, bool addShortcuts = false, bool navMenuEntries = false); - void AddItemToDirMenu(const BEntry *, BWindow *originatingWindow, + void AddItemToDirMenu(const BEntry*, BWindow* originatingWindow, bool atEnd, bool addShortcuts, bool navMenuEntries = false); void AddDisksIconToMenu(bool reverse = false); - void SetMenuBar(BMenuBar *); + void SetMenuBar(BMenuBar*); private: BMessenger fTarget; - BMenuBar *fMenuBar; + BMenuBar* fMenuBar; uint32 fCommand; BString fEntryName; }; + inline void -BDirMenu::SetMenuBar(BMenuBar *bar) +BDirMenu::SetMenuBar(BMenuBar* bar) { fMenuBar = bar; } diff --git a/src/kits/tracker/EntryIterator.cpp b/src/kits/tracker/EntryIterator.cpp index 88063ce9af..ee328ec458 100644 --- a/src/kits/tracker/EntryIterator.cpp +++ b/src/kits/tracker/EntryIterator.cpp @@ -44,7 +44,7 @@ All rights reserved. #include "ObjectList.h" -TWalkerWrapper::TWalkerWrapper(BTrackerPrivate::TWalker *walker) +TWalkerWrapper::TWalkerWrapper(BTrackerPrivate::TWalker* walker) : fWalker(walker), fStatus(B_OK) @@ -66,7 +66,7 @@ TWalkerWrapper::InitCheck() const status_t -TWalkerWrapper::GetNextEntry(BEntry *entry, bool traverse) +TWalkerWrapper::GetNextEntry(BEntry* entry, bool traverse) { fStatus = fWalker->GetNextEntry(entry, traverse); return fStatus; @@ -74,7 +74,7 @@ TWalkerWrapper::GetNextEntry(BEntry *entry, bool traverse) status_t -TWalkerWrapper::GetNextRef(entry_ref *ref) +TWalkerWrapper::GetNextRef(entry_ref* ref) { fStatus = fWalker->GetNextRef(ref); return fStatus; @@ -82,7 +82,7 @@ TWalkerWrapper::GetNextRef(entry_ref *ref) int32 -TWalkerWrapper::GetNextDirents(struct dirent *buffer, size_t length, +TWalkerWrapper::GetNextDirents(struct dirent* buffer, size_t length, int32 count) { int32 result = fWalker->GetNextDirents(buffer, length, count); @@ -121,17 +121,17 @@ EntryListBase::InitCheck() const } -dirent * -EntryListBase::Next(dirent *ent) +dirent* +EntryListBase::Next(dirent* ent) { - return (dirent *)((char *)ent + ent->d_reclen); + return (dirent*)((char*)ent + ent->d_reclen); } // #pragma mark - -CachedEntryIterator::CachedEntryIterator(BEntryList *iterator, int32 numEntries, +CachedEntryIterator::CachedEntryIterator(BEntryList* iterator, int32 numEntries, bool sortInodes) : fIterator(iterator), @@ -158,7 +158,7 @@ CachedEntryIterator::~CachedEntryIterator() status_t -CachedEntryIterator::GetNextEntry(BEntry *result, bool traverse) +CachedEntryIterator::GetNextEntry(BEntry* result, bool traverse) { ASSERT(!fDirentBuffer); ASSERT(!fEntryRefBuffer); @@ -191,7 +191,7 @@ CachedEntryIterator::GetNextEntry(BEntry *result, bool traverse) status_t -CachedEntryIterator::GetNextRef(entry_ref *ref) +CachedEntryIterator::GetNextRef(entry_ref* ref) { ASSERT(!fDirentBuffer); ASSERT(!fEntryBuffer); @@ -223,7 +223,7 @@ CachedEntryIterator::GetNextRef(entry_ref *ref) /*static*/ int -CachedEntryIterator::_CompareInodes(const dirent *ent1, const dirent *ent2) +CachedEntryIterator::_CompareInodes(const dirent* ent1, const dirent* ent2) { if (ent1->d_ino < ent2->d_ino) return -1; @@ -235,12 +235,12 @@ CachedEntryIterator::_CompareInodes(const dirent *ent1, const dirent *ent2) int32 -CachedEntryIterator::GetNextDirents(struct dirent *ent, size_t size, +CachedEntryIterator::GetNextDirents(struct dirent* ent, size_t size, int32 count) { ASSERT(!fEntryRefBuffer); if (!fDirentBuffer) { - fDirentBuffer = (dirent *)malloc(kDirentBufferSize); + fDirentBuffer = (dirent*)malloc(kDirentBufferSize); ASSERT(fIndex == 0 && fNumEntries == 0); ASSERT(size > sizeof(dirent) + B_FILE_NAME_LENGTH); } @@ -272,7 +272,7 @@ CachedEntryIterator::GetNextDirents(struct dirent *ent, size_t size, } fCurrentDirent - = (dirent *)((char *)fCurrentDirent + currentDirentSize); + = (dirent*)((char*)fCurrentDirent + currentDirentSize); } fCurrentDirent = fDirentBuffer; if (fSortInodes) { @@ -307,7 +307,7 @@ CachedEntryIterator::GetNextDirents(struct dirent *ent, size_t size, memcpy(ent, fCurrentDirent, currentDirentSize); if (!fSortInodes) - fCurrentDirent = (dirent *)((char *)fCurrentDirent + currentDirentSize); + fCurrentDirent = (dirent*)((char*)fCurrentDirent + currentDirentSize); return 1; } @@ -336,7 +336,7 @@ CachedEntryIterator::CountEntries() void -CachedEntryIterator::SetTo(BEntryList *iterator) +CachedEntryIterator::SetTo(BEntryList* iterator) { fIndex = 0; fNumEntries = 0; @@ -374,7 +374,7 @@ DirectoryEntryList::DirectoryEntryList(const BDirectory &dir) status_t -DirectoryEntryList::GetNextEntry(BEntry *entry, bool traverse) +DirectoryEntryList::GetNextEntry(BEntry* entry, bool traverse) { fStatus = fDir.GetNextEntry(entry, traverse); return fStatus; @@ -382,7 +382,7 @@ DirectoryEntryList::GetNextEntry(BEntry *entry, bool traverse) status_t -DirectoryEntryList::GetNextRef(entry_ref *ref) +DirectoryEntryList::GetNextRef(entry_ref* ref) { fStatus = fDir.GetNextRef(ref); return fStatus; @@ -390,7 +390,7 @@ DirectoryEntryList::GetNextRef(entry_ref *ref) int32 -DirectoryEntryList::GetNextDirents(struct dirent *buffer, size_t length, +DirectoryEntryList::GetNextDirents(struct dirent* buffer, size_t length, int32 count) { fStatus = fDir.GetNextDirents(buffer, length, count); @@ -429,8 +429,8 @@ EntryIteratorList::~EntryIteratorList() int32 count = fList.CountItems(); for (;count; count--) { // workaround for BEntryList not having a proper destructor - BEntryList *entry = fList.RemoveItemAt(count - 1); - EntryListBase *fixedEntry = dynamic_cast(entry); + BEntryList* entry = fList.RemoveItemAt(count - 1); + EntryListBase* fixedEntry = dynamic_cast(entry); if (fixedEntry) delete fixedEntry; @@ -441,14 +441,14 @@ EntryIteratorList::~EntryIteratorList() void -EntryIteratorList::AddItem(BEntryList *walker) +EntryIteratorList::AddItem(BEntryList* walker) { fList.AddItem(walker); } status_t -EntryIteratorList::GetNextEntry(BEntry *entry, bool traverse) +EntryIteratorList::GetNextEntry(BEntry* entry, bool traverse) { while (true) { if (fCurrentIndex >= fList.CountItems()) { @@ -467,7 +467,7 @@ EntryIteratorList::GetNextEntry(BEntry *entry, bool traverse) status_t -EntryIteratorList::GetNextRef(entry_ref *ref) +EntryIteratorList::GetNextRef(entry_ref* ref) { while (true) { if (fCurrentIndex >= fList.CountItems()) { @@ -486,7 +486,7 @@ EntryIteratorList::GetNextRef(entry_ref *ref) int32 -EntryIteratorList::GetNextDirents(struct dirent *buffer, size_t length, +EntryIteratorList::GetNextDirents(struct dirent* buffer, size_t length, int32 count) { int32 result = 0; @@ -546,8 +546,7 @@ CachedEntryIteratorList::CachedEntryIteratorList(bool sortInodes) void -CachedEntryIteratorList::AddItem(BEntryList *walker) +CachedEntryIteratorList::AddItem(BEntryList* walker) { fIteratorList.AddItem(walker); } - diff --git a/src/kits/tracker/EntryIterator.h b/src/kits/tracker/EntryIterator.h index d38f88170d..843480bb56 100644 --- a/src/kits/tracker/EntryIterator.h +++ b/src/kits/tracker/EntryIterator.h @@ -31,20 +31,22 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ +#ifndef __ENTRY_ITERATOR__ +#define __ENTRY_ITERATOR__ + // A lot of the code in here wouldn't be needed if the destructor // for BEntryList was virtual -// ToDo: -// get rid of all BEntryList API's in here, replace them with EntryListBase ones +// TODO: get rid of all BEntryList API's in here, replace them with +// EntryListBase ones -#ifndef __ENTRY_ITERATOR__ -#define __ENTRY_ITERATOR__ #include #include "ObjectList.h" #include "NodeWalker.h" + namespace BPrivate { class EntryListBase : public BEntryList { @@ -55,41 +57,44 @@ public: virtual status_t InitCheck() const; - virtual status_t GetNextEntry(BEntry *entry, bool traverse = false) = 0; - virtual status_t GetNextRef(entry_ref *ref) = 0; - virtual int32 GetNextDirents(struct dirent *buffer, size_t length, + virtual status_t GetNextEntry(BEntry* entry, bool traverse = false) = 0; + virtual status_t GetNextRef(entry_ref* ref) = 0; + virtual int32 GetNextDirents(struct dirent* buffer, size_t length, int32 count = INT_MAX) = 0; virtual status_t Rewind() = 0; virtual int32 CountEntries() = 0; - static dirent *Next(dirent *); + static dirent* Next(dirent*); protected: status_t fStatus; }; + class TWalkerWrapper : public EntryListBase { // this is to be able to use TWalker polymorfically as BEntryListBase public: - TWalkerWrapper(BTrackerPrivate::TWalker *walker); + TWalkerWrapper(BTrackerPrivate::TWalker* walker); virtual ~TWalkerWrapper(); virtual status_t InitCheck() const; - virtual status_t GetNextEntry(BEntry *entry, bool traverse = false); - virtual status_t GetNextRef(entry_ref *ref); - virtual int32 GetNextDirents(struct dirent *buffer, size_t length, + virtual status_t GetNextEntry(BEntry* entry, bool traverse = false); + virtual status_t GetNextRef(entry_ref* ref); + virtual int32 GetNextDirents(struct dirent* buffer, size_t length, int32 count = INT_MAX); virtual status_t Rewind(); virtual int32 CountEntries(); protected: - BTrackerPrivate::TWalker *fWalker; + BTrackerPrivate::TWalker* fWalker; status_t fStatus; }; + const int32 kDirentBufferSize = 10 * 1024; + class CachedEntryIterator : public EntryListBase { public: // takes any iterator and runs it through a cache of a specified size @@ -100,46 +105,47 @@ public: // better performance over just using the order in which they show up using // the default BEntryList iterator subclass - CachedEntryIterator(BEntryList *iterator, int32 numEntries, + CachedEntryIterator(BEntryList* iterator, int32 numEntries, bool sortInodes = false); // CachedEntryIterator does not get to own the virtual ~CachedEntryIterator(); - virtual status_t GetNextEntry(BEntry *entry, bool traverse = false); - virtual status_t GetNextRef(entry_ref *ref); - virtual int32 GetNextDirents(struct dirent *buffer, size_t length, + virtual status_t GetNextEntry(BEntry* entry, bool traverse = false); + virtual status_t GetNextRef(entry_ref* ref); + virtual int32 GetNextDirents(struct dirent* buffer, size_t length, int32 count = INT_MAX); virtual status_t Rewind(); virtual int32 CountEntries(); - virtual void SetTo(BEntryList *iterator); + virtual void SetTo(BEntryList* iterator); // CachedEntryIterator does not get to own the private: - static int _CompareInodes(const dirent *ent1, const dirent *ent2); + static int _CompareInodes(const dirent* ent1, const dirent* ent2); - BEntryList *fIterator; - entry_ref *fEntryRefBuffer; + BEntryList* fIterator; + entry_ref* fEntryRefBuffer; int32 fCacheSize; int32 fNumEntries; int32 fIndex; - dirent *fDirentBuffer; - dirent *fCurrentDirent; + dirent* fDirentBuffer; + dirent* fCurrentDirent; bool fSortInodes; - BObjectList *fSortedList; + BObjectList* fSortedList; - BEntry *fEntryBuffer; + BEntry* fEntryBuffer; }; + class DirectoryEntryList : public EntryListBase { public: DirectoryEntryList(const BDirectory &); - virtual status_t GetNextEntry(BEntry *entry, bool traverse = false); - virtual status_t GetNextRef(entry_ref *ref); - virtual int32 GetNextDirents(struct dirent *buffer, size_t length, + virtual status_t GetNextEntry(BEntry* entry, bool traverse = false); + virtual status_t GetNextRef(entry_ref* ref); + virtual int32 GetNextDirents(struct dirent* buffer, size_t length, int32 count = INT_MAX); virtual status_t Rewind(); @@ -149,6 +155,7 @@ private: BDirectory fDir; }; + class CachedDirectoryEntryList : public CachedEntryIterator { // this class is to work around not being able to delete // BEntryList polymorfically - need to have a special @@ -161,6 +168,7 @@ private: BDirectory fDir; }; + class EntryIteratorList : public EntryListBase { // This wraps up several BEntryList style iterators and // iterates them all, going from one to the other as it finishes @@ -169,12 +177,12 @@ public: EntryIteratorList(); virtual ~EntryIteratorList(); - void AddItem(BEntryList *); + void AddItem(BEntryList*); // list gets to own walkers - virtual status_t GetNextEntry(BEntry *entry, bool traverse = false); - virtual status_t GetNextRef(entry_ref *ref); - virtual int32 GetNextDirents(struct dirent *buffer, size_t length, + virtual status_t GetNextEntry(BEntry* entry, bool traverse = false); + virtual status_t GetNextRef(entry_ref* ref); + virtual int32 GetNextDirents(struct dirent* buffer, size_t length, int32 count = INT_MAX); virtual status_t Rewind(); @@ -185,10 +193,11 @@ protected: int32 fCurrentIndex; }; + class CachedEntryIteratorList : public CachedEntryIterator { public: CachedEntryIteratorList(bool sortInodes = true); - void AddItem(BEntryList *list); + void AddItem(BEntryList* list); protected: EntryIteratorList fIteratorList; diff --git a/src/kits/tracker/FBCPadding.cpp b/src/kits/tracker/FBCPadding.cpp index fcc2a3c45a..9b1ac457cb 100644 --- a/src/kits/tracker/FBCPadding.cpp +++ b/src/kits/tracker/FBCPadding.cpp @@ -32,11 +32,13 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include #include "FilePanelPriv.h" #include "RecentItems.h" + // FBC fluff, stick it here to not pollute real .cpp files void BRecentItemsList::_r1() {} @@ -100,10 +102,10 @@ __10BFilePanel15file_panel_modeP10BMessengerP9entry_refUlbP8BMessageP10BRefFilte #elif __MWERKS__ __ct__10BFilePanelF15file_panel_modeP10BMessengerP9entry_refUlbP8BMessageP10BRefFilterbb #endif -(void *self, - file_panel_mode mode, BMessenger *target, - entry_ref *ref, uint32 nodeFlavors, bool multipleSelection, - BMessage *message, BRefFilter *filter, bool modal, +(void* self, + file_panel_mode mode, BMessenger* target, + entry_ref* ref, uint32 nodeFlavors, bool multipleSelection, + BMessage* message, BRefFilter* filter, bool modal, bool hideWhenDone) { return new (self) BFilePanel(mode, target, ref, nodeFlavors, @@ -117,7 +119,7 @@ SetPanelDirectory__10BFilePanelP10BDirectory #elif __MWERKS__ SetPanelDirectory__10BFilePanelFP10BDirectory #endif -(BFilePanel *self, BDirectory *d) +(BFilePanel* self, BDirectory* d) { self->SetPanelDirectory(d); } @@ -128,7 +130,7 @@ SetPanelDirectory__10BFilePanelP6BEntry #elif __MWERKS__ SetPanelDirectory__10BFilePanelFP6BEntry #endif -(BFilePanel *self, BEntry *e) +(BFilePanel* self, BEntry* e) { self->SetPanelDirectory(e); } @@ -139,7 +141,7 @@ SetPanelDirectory__10BFilePanelP9entry_ref #elif __MWERKS__ SetPanelDirectory__10BFilePanelFP9entry_ref #endif -(BFilePanel *self, entry_ref *r) +(BFilePanel* self, entry_ref* r) { self->SetPanelDirectory(r); } diff --git a/src/kits/tracker/FSClipboard.cpp b/src/kits/tracker/FSClipboard.cpp index 4921922fdc..f20f7b188a 100644 --- a/src/kits/tracker/FSClipboard.cpp +++ b/src/kits/tracker/FSClipboard.cpp @@ -44,11 +44,11 @@ All rights reserved. // prototypes -static void MakeNodeFromName(node_ref *node, char *name); -static inline void MakeRefName(char *refName, const node_ref *node); -static inline void MakeModeName(char *modeName, const node_ref *node); -static inline void MakeModeNameFromRefName(char *modeName, char *refName); -static inline bool CompareModeAndRefName(const char *modeName, const char *refName); +static void MakeNodeFromName(node_ref* node, char* name); +static inline void MakeRefName(char* refName, const node_ref* node); +static inline void MakeModeName(char* modeName, const node_ref* node); +static inline void MakeModeNameFromRefName(char* modeName, char* refName); +static inline bool CompareModeAndRefName(const char* modeName, const char* refName); /* static bool @@ -59,39 +59,39 @@ FSClipboardCheckIntegrity() */ static void -MakeNodeFromName(node_ref *node, char *name) +MakeNodeFromName(node_ref* node, char* name) { - char *nodeString = strchr(name, '_'); + char* nodeString = strchr(name, '_'); if (nodeString != NULL) { - node->node = strtoll(nodeString + 1, (char **)NULL, 10); + node->node = strtoll(nodeString + 1, (char**)NULL, 10); node->device = atoi(name + 1); } } static inline void -MakeRefName(char *refName, const node_ref *node) +MakeRefName(char* refName, const node_ref* node) { sprintf(refName, "r%ld_%Ld", node->device, node->node); } static inline void -MakeModeName(char *modeName, const node_ref *node) +MakeModeName(char* modeName, const node_ref* node) { sprintf(modeName, "m%ld_%Ld", node->device, node->node); } static inline void -MakeModeName(char *name) +MakeModeName(char* name) { name[0] = 'm'; } static inline void -MakeModeNameFromRefName(char *modeName, char *refName) +MakeModeNameFromRefName(char* modeName, char* refName) { strcpy(modeName, refName); modeName[0] = 'm'; @@ -99,7 +99,7 @@ MakeModeNameFromRefName(char *modeName, char *refName) static inline bool -CompareModeAndRefName(const char *modeName, const char *refName) +CompareModeAndRefName(const char* modeName, const char* refName) { return !strcmp(refName + 1, modeName + 1); } @@ -117,16 +117,16 @@ FSClipboardHasRefs() bool result = false; if (be_clipboard->Lock()) { - BMessage *clip = be_clipboard->Data(); + BMessage* clip = be_clipboard->Data(); if (clip != NULL) { #ifdef B_BEOS_VERSION_DANO const #endif - char *refName; + char* refName; #ifdef B_BEOS_VERSION_DANO const #endif - char *modeName; + char* modeName; uint32 type; int32 count; if (clip->GetInfo(B_REF_TYPE, 0, &refName, &type, &count) == B_OK @@ -142,8 +142,8 @@ FSClipboardHasRefs() void FSClipboardStartWatch(BMessenger target) { - if (dynamic_cast(be_app) != NULL) - ((TTracker *)be_app)->ClipboardRefsWatcher()->AddToNotifyList(target); + if (dynamic_cast(be_app) != NULL) + ((TTracker*)be_app)->ClipboardRefsWatcher()->AddToNotifyList(target); else { // this code is used by external apps using objects using FSClipboard functions // i.e: applications using FilePanel @@ -160,8 +160,8 @@ FSClipboardStartWatch(BMessenger target) void FSClipboardStopWatch(BMessenger target) { - if (dynamic_cast(be_app) != NULL) - ((TTracker *)be_app)->ClipboardRefsWatcher()->AddToNotifyList(target); + if (dynamic_cast(be_app) != NULL) + ((TTracker*)be_app)->ClipboardRefsWatcher()->AddToNotifyList(target); else { // this code is used by external apps using objects using FSClipboard functions // i.e: applications using FilePanel @@ -195,7 +195,7 @@ FSClipboardClear() */ uint32 -FSClipboardAddPoses(const node_ref *directory, PoseList *list, uint32 moveMode, +FSClipboardAddPoses(const node_ref* directory, PoseList* list, uint32 moveMode, bool clearClipboard) { uint32 refsAdded = 0; @@ -216,13 +216,13 @@ FSClipboardAddPoses(const node_ref *directory, PoseList *list, uint32 moveMode, if (clearClipboard) be_clipboard->Clear(); - BMessage *clip = be_clipboard->Data(); + BMessage* clip = be_clipboard->Data(); if (clip != NULL) { for (int32 index = 0; index < listCount; index++) { char refName[64], modeName[64]; - BPose *pose = (BPose *)list->ItemAt(index); - Model *model = pose->TargetModel(); - const node_ref *node = model->NodeRef(); + BPose* pose = (BPose*)list->ItemAt(index); + Model* model = pose->TargetModel(); + const node_ref* node = model->NodeRef(); BEntry entry; model->GetEntry(&entry); @@ -294,7 +294,7 @@ FSClipboardAddPoses(const node_ref *directory, PoseList *list, uint32 moveMode, } } be_clipboard->Commit(); - } + } be_clipboard->Unlock(); BMessenger(kTrackerSignature).SendMessage(&updateMessage); @@ -305,7 +305,7 @@ FSClipboardAddPoses(const node_ref *directory, PoseList *list, uint32 moveMode, uint32 -FSClipboardRemovePoses(const node_ref *directory, PoseList *list) +FSClipboardRemovePoses(const node_ref* directory, PoseList* list) { if (!be_clipboard->Lock()) return 0; @@ -321,13 +321,13 @@ FSClipboardRemovePoses(const node_ref *directory, PoseList *list) uint32 refsRemoved = 0; - BMessage *clip = be_clipboard->Data(); + BMessage* clip = be_clipboard->Data(); if (clip != NULL) { int32 listCount = list->CountItems(); for (int32 index = 0; index < listCount; index++) { char refName[64], modeName[64]; - BPose *pose = (BPose *)list->ItemAt(index); + BPose* pose = (BPose*)list->ItemAt(index); clipNode.node = *pose->TargetModel()->NodeRef(); MakeRefName(refName, &clipNode.node); @@ -355,35 +355,35 @@ FSClipboardRemovePoses(const node_ref *directory, PoseList *list) */ bool -FSClipboardPaste(Model *model, uint32 linksMode) +FSClipboardPaste(Model* model, uint32 linksMode) { if (!FSClipboardHasRefs()) return false; BMessenger tracker(kTrackerSignature); - node_ref *destNodeRef = (node_ref *)model->NodeRef(); + node_ref* destNodeRef = (node_ref*)model->NodeRef(); // these will be passed to the asynchronous copy/move process - BObjectList *moveList = new BObjectList(0, true); - BObjectList *copyList = new BObjectList(0, true); + BObjectList* moveList = new BObjectList(0, true); + BObjectList* copyList = new BObjectList(0, true); if ((be_clipboard->Lock())) { - BMessage *clip = be_clipboard->Data(); + BMessage* clip = be_clipboard->Data(); if (clip != NULL) { char modeName[64]; uint32 moveMode = 0; - BMessage *updateMessage = NULL; + BMessage* updateMessage = NULL; node_ref updateNodeRef; updateNodeRef.device = -1; - char *refName; + char* refName; type_code type; int32 count; for (int32 index = 0; clip->GetInfo(B_REF_TYPE, index, #ifdef B_BEOS_VERSION_DANO - (const char **) + (const char**) #endif &refName, &type, &count) == B_OK; index++) { entry_ref ref; @@ -404,12 +404,12 @@ FSClipboardPaste(Model *model, uint32 linksMode) updateMessage = new BMessage(kFSClipboardChanges); updateMessage->AddInt32("device", updateNodeRef.device); - updateMessage->AddInt64("directory", updateNodeRef.node); + updateMessage->AddInt64("directory", updateNodeRef.node); } // we need this data later on MakeModeNameFromRefName(modeName, refName); - if (!linksMode && clip->FindInt32(modeName, (int32 *)&moveMode) != B_OK) + if (!linksMode && clip->FindInt32(modeName, (int32*)&moveMode) != B_OK) continue; BEntry entry(&ref); @@ -474,7 +474,7 @@ FSClipboardPaste(Model *model, uint32 linksMode) B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetShortcut(0, B_ESCAPE); alert->Go(); - okToMove = false; + okToMove = false; } BEntry entry; @@ -513,12 +513,10 @@ FSClipboardPaste(Model *model, uint32 linksMode) } -/** Seek node in clipboard, if found return it's moveMode - * else return 0 - */ - +// Seek node in clipboard, if found return it's moveMode +// else return 0 uint32 -FSClipboardFindNodeMode(Model *model, bool autoLock, bool updateRefIfNeeded) +FSClipboardFindNodeMode(Model* model, bool autoLock, bool updateRefIfNeeded) { int32 moveMode = 0; if (autoLock) { @@ -528,13 +526,13 @@ FSClipboardFindNodeMode(Model *model, bool autoLock, bool updateRefIfNeeded) bool remove = false; bool change = false; - BMessage *clip = be_clipboard->Data(); + BMessage* clip = be_clipboard->Data(); if (clip != NULL) { - const node_ref *node = model->NodeRef(); + const node_ref* node = model->NodeRef(); char modeName[64]; MakeModeName(modeName, node); if ((clip->FindInt32(modeName, &moveMode) == B_OK)) { - const entry_ref *ref = model->EntryRef(); + const entry_ref* ref = model->EntryRef(); entry_ref clipref; char refName[64]; MakeRefName(refName, node); @@ -573,15 +571,15 @@ FSClipboardFindNodeMode(Model *model, bool autoLock, bool updateRefIfNeeded) void -FSClipboardRemove(Model *model) +FSClipboardRemove(Model* model) { BMessenger messenger(kTrackerSignature); if (messenger.IsValid()) { - BMessage *report = new BMessage(kFSClipboardChanges); + BMessage* report = new BMessage(kFSClipboardChanges); TClipboardNodeRef tcnode; tcnode.node = *model->NodeRef(); tcnode.moveMode = kDelete; - const entry_ref *ref = model->EntryRef(); + const entry_ref* ref = model->EntryRef(); report->AddInt32("device", ref->device); report->AddInt64("directory", ref->directory); report->AddBool("clearClipboard", false); @@ -618,7 +616,7 @@ BClipboardRefsWatcher::AddToNotifyList(BMessenger target) if (Lock()) { // add the messenger if it's not already in the list // ToDo: why do we have to care about that? - BMessenger *messenger; + BMessenger* messenger; bool found = false; for (int32 index = 0;(messenger = fNotifyList.ItemAt(index)) != NULL; index++) { @@ -639,7 +637,7 @@ void BClipboardRefsWatcher::RemoveFromNotifyList(BMessenger target) { if (Lock()) { - BMessenger *messenger; + BMessenger* messenger; for (int32 index = 0;(messenger = fNotifyList.ItemAt(index)) != NULL; index++) { if (*messenger == target) { @@ -653,7 +651,7 @@ BClipboardRefsWatcher::RemoveFromNotifyList(BMessenger target) void -BClipboardRefsWatcher::AddNode(const node_ref *node) +BClipboardRefsWatcher::AddNode(const node_ref* node) { TTracker::WatchNode(node, B_WATCH_NAME, this); fRefsInClipboard = true; @@ -661,7 +659,7 @@ BClipboardRefsWatcher::AddNode(const node_ref *node) void -BClipboardRefsWatcher::RemoveNode(node_ref *node, bool removeFromClipboard) +BClipboardRefsWatcher::RemoveNode(node_ref* node, bool removeFromClipboard) { watch_node(node, B_STOP_WATCHING, this); @@ -669,7 +667,7 @@ BClipboardRefsWatcher::RemoveNode(node_ref *node, bool removeFromClipboard) return; if (be_clipboard->Lock()) { - BMessage *clip = be_clipboard->Data(); + BMessage* clip = be_clipboard->Data(); if (clip != NULL) { char name[64]; MakeRefName(name, node); @@ -690,18 +688,18 @@ BClipboardRefsWatcher::RemoveNodesByDevice(dev_t device) if (!be_clipboard->Lock()) return; - BMessage *clip = be_clipboard->Data(); + BMessage* clip = be_clipboard->Data(); if (clip != NULL) { char deviceName[6]; sprintf(deviceName, "r%ld_", device); int32 index = 0; - char *refName; + char* refName; type_code type; int32 count; while (clip->GetInfo(B_REF_TYPE, index, #ifdef B_BEOS_VERSION_DANO - (const char **) + (const char**) #endif &refName, &type, &count) == B_OK) { if (!strncmp(deviceName, refName, strlen(deviceName))) { @@ -722,12 +720,12 @@ BClipboardRefsWatcher::RemoveNodesByDevice(dev_t device) void -BClipboardRefsWatcher::UpdateNode(node_ref *node, entry_ref *ref) +BClipboardRefsWatcher::UpdateNode(node_ref* node, entry_ref* ref) { if (!be_clipboard->Lock()) return; - BMessage *clip = be_clipboard->Data(); + BMessage* clip = be_clipboard->Data(); if (clip != NULL) { char name[64]; MakeRefName(name, node); @@ -761,27 +759,27 @@ BClipboardRefsWatcher::Clear() } } -/* -void -BClipboardRefsWatcher::UpdatePoseViews(bool clearClipboard, const node_ref *node) -{ - BMessage message(kFSClipboardChanges); - message.AddInt32("device", node->device); - message.AddInt64("directory", node->node); - message.AddBool("clearClipboard", clearClipboard); - if (Lock()) { - int32 items = fNotifyList.CountItems(); - for (int32 i = 0;i < items;i++) { - fNotifyList.ItemAt(i)->SendMessage(&message); - } - Unlock(); - } -} -*/ +//void +//BClipboardRefsWatcher::UpdatePoseViews(bool clearClipboard, const node_ref* node) +//{ +// BMessage message(kFSClipboardChanges); +// message.AddInt32("device", node->device); +// message.AddInt64("directory", node->node); +// message.AddBool("clearClipboard", clearClipboard); +// +// if (Lock()) { +// int32 items = fNotifyList.CountItems(); +// for (int32 i = 0;i < items;i++) { +// fNotifyList.ItemAt(i)->SendMessage(&message); +// } +// Unlock(); +// } +//} + void -BClipboardRefsWatcher::UpdatePoseViews(BMessage *reportMessage) +BClipboardRefsWatcher::UpdatePoseViews(BMessage* reportMessage) { if (Lock()) { // check if it was cleared, if so clear watching @@ -796,7 +794,7 @@ BClipboardRefsWatcher::UpdatePoseViews(BMessage *reportMessage) // move or copy: start watching node_ref // remove: stop watching node_ref int32 index = 0; - TClipboardNodeRef *tcnode = NULL; + TClipboardNodeRef* tcnode = NULL; ssize_t size; while (reportMessage->FindData("tcnode", T_CLIPBOARD_NODE, index, (const void**)&tcnode, &size) == B_OK) { if (tcnode->moveMode == kDelete) { @@ -820,7 +818,7 @@ BClipboardRefsWatcher::UpdatePoseViews(BMessage *reportMessage) void -BClipboardRefsWatcher::MessageReceived(BMessage *message) +BClipboardRefsWatcher::MessageReceived(BMessage* message) { if (message->what == B_CLIPBOARD_CHANGED && fRefsInClipboard) { if (!(fRefsInClipboard = FSClipboardHasRefs())) @@ -831,13 +829,13 @@ BClipboardRefsWatcher::MessageReceived(BMessage *message) return; } - switch (message->FindInt32("opcode")) { + switch (message->FindInt32("opcode")) { case B_ENTRY_MOVED: { ino_t toDir; ino_t fromDir; node_ref node; - const char *name = NULL; + const char* name = NULL; message->FindInt64("from directory", &fromDir); message->FindInt64("to directory", &toDir); message->FindInt64("node", &node.node); @@ -846,7 +844,7 @@ BClipboardRefsWatcher::MessageReceived(BMessage *message) entry_ref ref(node.device, toDir, name); UpdateNode(&node, &ref); break; - } + } case B_DEVICE_UNMOUNTED: { diff --git a/src/kits/tracker/FSClipboard.h b/src/kits/tracker/FSClipboard.h index bdc4b85e7a..acb40126c1 100644 --- a/src/kits/tracker/FSClipboard.h +++ b/src/kits/tracker/FSClipboard.h @@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef FS_CLIPBOARD_H #define FS_CLIPBOARD_H + #include #include "Model.h" #include "ObjectList.h" @@ -50,6 +50,7 @@ typedef struct { } TClipboardNodeRef; const int32 T_CLIPBOARD_NODE = 'TCNR'; + class BClipboardRefsWatcher : public BLooper { public: BClipboardRefsWatcher(); @@ -57,16 +58,16 @@ class BClipboardRefsWatcher : public BLooper { void AddToNotifyList(BMessenger target); void RemoveFromNotifyList(BMessenger target); - void AddNode(const node_ref *node); - void RemoveNode(node_ref *node, bool removeFromClipboard = false); + void AddNode(const node_ref* node); + void RemoveNode(node_ref* node, bool removeFromClipboard = false); void RemoveNodesByDevice(dev_t device); - void UpdateNode(node_ref *node, entry_ref *ref); + void UpdateNode(node_ref* node, entry_ref* ref); void Clear(); -// void UpdatePoseViews(bool clearClipboard, const node_ref *node); - void UpdatePoseViews(BMessage *reportMessage); +// void UpdatePoseViews(bool clearClipboard, const node_ref* node); + void UpdatePoseViews(BMessage* reportMessage); protected: - virtual void MessageReceived(BMessage *); + virtual void MessageReceived(BMessage*); private: bool fRefsInClipboard; @@ -86,10 +87,10 @@ void FSClipboardStartWatch(BMessenger target); void FSClipboardStopWatch(BMessenger target); void FSClipboardClear(); -uint32 FSClipboardAddPoses(const node_ref *directory, PoseList *list, uint32 moveMode, bool clearClipboard); -uint32 FSClipboardRemovePoses(const node_ref *directory, PoseList *list); -bool FSClipboardPaste(Model *model, uint32 linksMode = 0); -void FSClipboardRemove(Model *model); -uint32 FSClipboardFindNodeMode(Model *model, bool autoLock, bool updateRefIfNeeded); +uint32 FSClipboardAddPoses(const node_ref* directory, PoseList* list, uint32 moveMode, bool clearClipboard); +uint32 FSClipboardRemovePoses(const node_ref* directory, PoseList* list); +bool FSClipboardPaste(Model* model, uint32 linksMode = 0); +void FSClipboardRemove(Model* model); +uint32 FSClipboardFindNodeMode(Model* model, bool autoLock, bool updateRefIfNeeded); -#endif /* FS_CLIPBOARD_H */ +#endif // FS_CLIPBOARD_H diff --git a/src/kits/tracker/FSUndoRedo.cpp b/src/kits/tracker/FSUndoRedo.cpp index a3fe28e9e8..cf6f895803 100644 --- a/src/kits/tracker/FSUndoRedo.cpp +++ b/src/kits/tracker/FSUndoRedo.cpp @@ -20,8 +20,8 @@ class UndoItem { virtual status_t Undo() = 0; virtual status_t Redo() = 0; - virtual void UpdateEntry(BEntry */*entry*/, const char */*name*/) {} - // updates the name of the target from the source entry "entry" + virtual void UpdateEntry(BEntry* /*entry*/, const char* /*name*/) {} + // updates the name of the target from the source entry "entry" }; static BObjectList sUndoList, sRedoList; @@ -29,13 +29,13 @@ static BLocker sLock("undo"); class UndoItemCopy : public UndoItem { public: - UndoItemCopy(BObjectList *sourceList, BDirectory &target, - BList *pointList, uint32 moveMode); + UndoItemCopy(BObjectList* sourceList, BDirectory &target, + BList* pointList, uint32 moveMode); virtual ~UndoItemCopy(); virtual status_t Undo(); virtual status_t Redo(); - virtual void UpdateEntry(BEntry *entry, const char *name); + virtual void UpdateEntry(BEntry* entry, const char* name); private: BObjectList fSourceList; @@ -44,12 +44,13 @@ class UndoItemCopy : public UndoItem { uint32 fMoveMode; }; + class UndoItemMove : public UndoItem { public: /** source - list of file(s) that were moved. Assumes ownership. * origfolder - location it was moved from */ - UndoItemMove(BObjectList *sourceList, BDirectory &target, BList *pointList); + UndoItemMove(BObjectList* sourceList, BDirectory &target, BList* pointList); virtual ~UndoItemMove(); virtual status_t Undo(); @@ -60,6 +61,7 @@ class UndoItemMove : public UndoItem { entry_ref fSourceRef, fTargetRef; }; + class UndoItemFolder : public UndoItem { public: UndoItemFolder(const entry_ref &ref); @@ -77,22 +79,24 @@ class UndoItemFolder : public UndoItem { entry_ref fRef; }; + class UndoItemRename : public UndoItem { public: UndoItemRename(const entry_ref &origRef, const entry_ref &ref); - UndoItemRename(const BEntry &entry, const char *newName); + UndoItemRename(const BEntry &entry, const char* newName); virtual ~UndoItemRename(); virtual status_t Undo(); virtual status_t Redo(); private: - entry_ref fRef, fOrigRef; + entry_ref fRef, fOrigRef; }; + class UndoItemRenameVolume : public UndoItem { public: - UndoItemRenameVolume(BVolume &volume, const char *newName); + UndoItemRenameVolume(BVolume &volume, const char* newName); virtual ~UndoItemRenameVolume(); virtual status_t Undo(); @@ -115,18 +119,18 @@ ChangeListSource(BObjectList &list, BEntry &entry) return B_ERROR; for (int32 index = 0; index < list.CountItems(); index++) { - entry_ref *ref = list.ItemAt(index); + entry_ref* ref = list.ItemAt(index); ref->device = source.device; ref->directory = source.node; } - return B_OK; + return B_OK; } static void -AddUndoItem(UndoItem *item) +AddUndoItem(UndoItem* item) { BAutolock locker(sLock); @@ -149,15 +153,15 @@ Undo::~Undo() } -void -Undo::UpdateEntry(BEntry *entry, const char *destName) +void +Undo::UpdateEntry(BEntry* entry, const char* destName) { if (fUndo != NULL) fUndo->UpdateEntry(entry, destName); } -void +void Undo::Remove() { delete fUndo; @@ -165,8 +169,8 @@ Undo::Remove() } -MoveCopyUndo::MoveCopyUndo(BObjectList *sourceList, BDirectory &dest, - BList *pointList, uint32 moveMode) +MoveCopyUndo::MoveCopyUndo(BObjectList* sourceList, BDirectory &dest, + BList* pointList, uint32 moveMode) { if (moveMode == kMoveSelectionTo) fUndo = new UndoItemMove(sourceList, dest, pointList); @@ -181,13 +185,13 @@ NewFolderUndo::NewFolderUndo(const entry_ref &ref) } -RenameUndo::RenameUndo(BEntry &entry, const char *newName) +RenameUndo::RenameUndo(BEntry &entry, const char* newName) { fUndo = new UndoItemRename(entry, newName); } -RenameVolumeUndo::RenameVolumeUndo(BVolume &volume, const char *newName) +RenameVolumeUndo::RenameVolumeUndo(BVolume &volume, const char* newName) { fUndo = new UndoItemRenameVolume(volume, newName); } @@ -196,8 +200,8 @@ RenameVolumeUndo::RenameVolumeUndo(BVolume &volume, const char *newName) // #pragma mark - -UndoItemCopy::UndoItemCopy(BObjectList *sourceList, BDirectory &target, - BList */*pointList*/, uint32 moveMode) +UndoItemCopy::UndoItemCopy(BObjectList* sourceList, BDirectory &target, + BList* /*pointList*/, uint32 moveMode) : fSourceList(*sourceList), fTargetList(*sourceList), @@ -239,15 +243,15 @@ UndoItemCopy::Redo() } -void -UndoItemCopy::UpdateEntry(BEntry *entry, const char *name) +void +UndoItemCopy::UpdateEntry(BEntry* entry, const char* name) { entry_ref changedRef; if (entry->GetRef(&changedRef) != B_OK) return; for (int32 index = 0; index < fSourceList.CountItems(); index++) { - entry_ref *ref = fSourceList.ItemAt(index); + entry_ref* ref = fSourceList.ItemAt(index); if (changedRef != *ref) continue; @@ -260,8 +264,8 @@ UndoItemCopy::UpdateEntry(BEntry *entry, const char *name) // #pragma mark - -UndoItemMove::UndoItemMove(BObjectList *sourceList, BDirectory &target, - BList */*pointList*/) +UndoItemMove::UndoItemMove(BObjectList* sourceList, BDirectory &target, + BList* /*pointList*/) : fSourceList(*sourceList) { @@ -284,7 +288,7 @@ UndoItemMove::~UndoItemMove() status_t UndoItemMove::Undo() { - BObjectList *list = new BObjectList(fSourceList); + BObjectList* list = new BObjectList(fSourceList); BEntry entry(&fTargetRef); ChangeListSource(*list, entry); @@ -347,7 +351,7 @@ UndoItemRename::UndoItemRename(const entry_ref &origRef, const entry_ref &ref) } -UndoItemRename::UndoItemRename(const BEntry &entry, const char *newName) +UndoItemRename::UndoItemRename(const BEntry &entry, const char* newName) { entry.GetRef(&fOrigRef); @@ -380,12 +384,12 @@ UndoItemRename::Redo() // #pragma mark - -UndoItemRenameVolume::UndoItemRenameVolume(BVolume &volume, const char *newName) +UndoItemRenameVolume::UndoItemRenameVolume(BVolume &volume, const char* newName) : fVolume(volume), fNewName(newName) { - char *buffer = fOldName.LockBuffer(B_FILE_NAME_LENGTH); + char* buffer = fOldName.LockBuffer(B_FILE_NAME_LENGTH); if (buffer != NULL) { fVolume.GetName(buffer); fOldName.UnlockBuffer(); @@ -420,7 +424,7 @@ FSUndo() { BAutolock locker(sLock); - UndoItem *undoItem = sUndoList.FirstItem(); + UndoItem* undoItem = sUndoList.FirstItem(); if (undoItem == NULL) return; @@ -441,7 +445,7 @@ FSRedo() { BAutolock locker(sLock); - UndoItem *undoItem = sRedoList.FirstItem(); + UndoItem* undoItem = sRedoList.FirstItem(); if (undoItem == NULL) return; diff --git a/src/kits/tracker/FSUndoRedo.h b/src/kits/tracker/FSUndoRedo.h index 80c539402e..5c91203ebe 100644 --- a/src/kits/tracker/FSUndoRedo.h +++ b/src/kits/tracker/FSUndoRedo.h @@ -1,9 +1,11 @@ #ifndef _FS_UNDO_REDO_H #define _FS_UNDO_REDO_H + #include "ObjectList.h" #include + namespace BPrivate { class UndoItem; @@ -11,55 +13,63 @@ class UndoItem; class Undo { public: ~Undo(); - void UpdateEntry(BEntry *entry, const char *destName); + void UpdateEntry(BEntry* entry, const char* destName); void Remove(); protected: - UndoItem *fUndo; + UndoItem* fUndo; }; + class MoveCopyUndo : public Undo { public: - MoveCopyUndo(BObjectList *sourceList, BDirectory &dest, - BList *pointList, uint32 moveMode); + MoveCopyUndo(BObjectList* sourceList, BDirectory &dest, + BList* pointList, uint32 moveMode); }; + class NewFolderUndo : public Undo { public: NewFolderUndo(const entry_ref &ref); }; + class RenameUndo : public Undo { public: - RenameUndo(BEntry &entry, const char *newName); + RenameUndo(BEntry &entry, const char* newName); }; + class RenameVolumeUndo : public Undo { public: - RenameVolumeUndo(BVolume &volume, const char *newName); + RenameVolumeUndo(BVolume &volume, const char* newName); }; + static inline bool FSIsUndoMoveMode(uint32 moveMode) { return (moveMode & '\xff\0\0\0') == 'U\0\0\0'; } + static inline uint32 FSUndoMoveMode(uint32 moveMode) { return (moveMode & ~'\xff\0\0\0') | 'U\0\0\0'; } + static inline uint32 FSMoveMode(uint32 moveMode) { return (moveMode & ~'\xff\0\0\0') | 'T\0\0\0'; } + extern void FSUndo(); extern void FSRedo(); } // namespace BPrivate -#endif /* _FS_UNDO_REDO_H */ +#endif // _FS_UNDO_REDO_H diff --git a/src/kits/tracker/FSUtils.cpp b/src/kits/tracker/FSUtils.cpp index fb4e9d2fd0..a5170c3748 100644 --- a/src/kits/tracker/FSUtils.cpp +++ b/src/kits/tracker/FSUtils.cpp @@ -34,15 +34,16 @@ respective holders. All rights reserved. // Tracker file system calls. -// Note - APIs/code in FSUtils.h and FSUtils.cpp is slated for a major cleanup -// -- in other words, you will find a lot of ugly cruft in here +// APIs/code in FSUtils.h and FSUtils.cpp is slated for a major cleanup -- in +// other words, you will find a lot of ugly cruft in here // ToDo: // Move most of preflight error checks to the Model level and only keep those -// that have to do with size, reading/writing and name collisions. +// that have to do with size, reading/writing and name collisions. // Get rid of all the BList based APIs, use BObjectLists. // Clean up the error handling, push most of the user interaction out of the -// low level FS calls. +// low level FS calls. + #include #include @@ -105,36 +106,36 @@ namespace BPrivate { #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "FSUtils" -static status_t FSDeleteFolder(BEntry *, CopyLoopControl *, bool updateStatus, +static status_t FSDeleteFolder(BEntry*, CopyLoopControl*, bool updateStatus, bool deleteTopDir = true, bool upateFileNameInStatus = false); -static status_t MoveEntryToTrash(BEntry *, BPoint *, Undo &undo); -static void LowLevelCopy(BEntry *, StatStruct *, BDirectory *, char *destName, - CopyLoopControl *, BPoint *); -status_t DuplicateTask(BObjectList *srcList); -static status_t MoveTask(BObjectList *, BEntry *, BList *, uint32); -static status_t _DeleteTask(BObjectList *, bool); -static status_t _RestoreTask(BObjectList *); +static status_t MoveEntryToTrash(BEntry*, BPoint*, Undo &undo); +static void LowLevelCopy(BEntry*, StatStruct*, BDirectory*, char* destName, + CopyLoopControl*, BPoint*); +status_t DuplicateTask(BObjectList* srcList); +static status_t MoveTask(BObjectList*, BEntry*, BList*, uint32); +static status_t _DeleteTask(BObjectList*, bool); +static status_t _RestoreTask(BObjectList*); status_t CalcItemsAndSize(CopyLoopControl* loopControl, - BObjectList *refList, ssize_t blockSize, int32 *totalCount, - off_t *totalSize); -status_t MoveItem(BEntry *entry, BDirectory *destDir, BPoint *loc, - uint32 moveMode, const char *newName, Undo &undo, + BObjectList* refList, ssize_t blockSize, int32* totalCount, + off_t* totalSize); +status_t MoveItem(BEntry* entry, BDirectory* destDir, BPoint* loc, + uint32 moveMode, const char* newName, Undo &undo, CopyLoopControl* loopControl); -ConflictCheckResult PreFlightNameCheck(BObjectList *srcList, - const BDirectory *destDir, int32 *collisionCount, uint32 moveMode); -status_t CheckName(uint32 moveMode, const BEntry *srcEntry, - const BDirectory *destDir, bool multipleCollisions, ConflictCheckResult &); -void CopyAttributes(CopyLoopControl *control, BNode *srcNode, BNode* destNode, void *buffer, +ConflictCheckResult PreFlightNameCheck(BObjectList* srcList, + const BDirectory* destDir, int32* collisionCount, uint32 moveMode); +status_t CheckName(uint32 moveMode, const BEntry* srcEntry, + const BDirectory* destDir, bool multipleCollisions, ConflictCheckResult &); +void CopyAttributes(CopyLoopControl* control, BNode* srcNode, BNode* destNode, void* buffer, size_t bufsize); -void CopyPoseLocation(BNode *src, BNode *dest); -bool DirectoryMatchesOrContains(const BEntry *, directory_which); -bool DirectoryMatchesOrContains(const BEntry *, const char *additionalPath, +void CopyPoseLocation(BNode* src, BNode* dest); +bool DirectoryMatchesOrContains(const BEntry*, directory_which); +bool DirectoryMatchesOrContains(const BEntry*, const char* additionalPath, directory_which); -bool DirectoryMatches(const BEntry *, directory_which); -bool DirectoryMatches(const BEntry *, const char *additionalPath, +bool DirectoryMatches(const BEntry*, directory_which); +bool DirectoryMatches(const BEntry*, const char* additionalPath, directory_which); -status_t empty_trash(void *); +status_t empty_trash(void*); static const char* kDeleteConfirmationStr = @@ -182,12 +183,12 @@ static const char* kReplaceManyStr = static const char* kFindAlternativeStr = B_TRANSLATE_MARK("Would you like to find some other suitable application?"); -static const char *kFindApplicationStr = +static const char* kFindApplicationStr = B_TRANSLATE_MARK("Would you like to find a suitable application " "to open the file?"); // Skip these attributes when copying in Tracker -const char *kSkipAttributes[] = { +const char* kSkipAttributes[] = { kAttrPoseInfo, NULL }; @@ -337,7 +338,7 @@ TrackerCopyLoopControl::Init(int32 totalItems, off_t totalSize, bool -TrackerCopyLoopControl::FileError(const char *message, const char *name, +TrackerCopyLoopControl::FileError(const char* message, const char* name, status_t error, bool allowContinue) { BString buffer(message); @@ -360,7 +361,7 @@ TrackerCopyLoopControl::FileError(const char *message, const char *name, void -TrackerCopyLoopControl::UpdateStatus(const char *name, const entry_ref&, +TrackerCopyLoopControl::UpdateStatus(const char* name, const entry_ref&, int32 count, bool optional) { if (gStatusWindow != NULL) @@ -387,9 +388,9 @@ TrackerCopyLoopControl::CheckUserCanceled() bool -TrackerCopyLoopControl::SkipAttribute(const char *attributeName) +TrackerCopyLoopControl::SkipAttribute(const char* attributeName) { - for (const char **skipAttribute = kSkipAttributes; *skipAttribute; + for (const char** skipAttribute = kSkipAttributes; *skipAttribute; skipAttribute++) { if (strcmp(*skipAttribute, attributeName) == 0) return true; @@ -409,8 +410,8 @@ TrackerCopyLoopControl::SetSourceList(EntryList* list) // #pragma mark - -static BNode * -GetWritableNode(BEntry *entry, StatStruct *statBuf = 0) +static BNode* +GetWritableNode(BEntry* entry, StatStruct* statBuf = 0) { // utility call that works around the problem with BNodes not being // universally writeable @@ -433,7 +434,7 @@ GetWritableNode(BEntry *entry, StatStruct *statBuf = 0) bool -CheckDevicesEqual(const entry_ref *srcRef, const Model *targetModel) +CheckDevicesEqual(const entry_ref* srcRef, const Model* targetModel) { BDirectory destDir (targetModel->EntryRef()); struct stat deststat; @@ -444,7 +445,7 @@ CheckDevicesEqual(const entry_ref *srcRef, const Model *targetModel) status_t -FSSetPoseLocation(ino_t destDirInode, BNode *destNode, BPoint point) +FSSetPoseLocation(ino_t destDirInode, BNode* destNode, BPoint point) { PoseInfo poseInfo; poseInfo.fInvisible = false; @@ -462,7 +463,7 @@ FSSetPoseLocation(ino_t destDirInode, BNode *destNode, BPoint point) status_t -FSSetPoseLocation(BEntry *entry, BPoint point) +FSSetPoseLocation(BEntry* entry, BPoint point) { BNode node(entry); status_t result = node.InitCheck(); @@ -484,7 +485,7 @@ FSSetPoseLocation(BEntry *entry, BPoint point) bool -FSGetPoseLocation(const BNode *node, BPoint *point) +FSGetPoseLocation(const BNode* node, BPoint* point) { PoseInfo poseInfo; if (ReadAttr(node, kAttrPoseInfo, kAttrPoseInfoForeign, @@ -503,7 +504,7 @@ FSGetPoseLocation(const BNode *node, BPoint *point) static void SetUpPoseLocation(ino_t sourceParentIno, ino_t destParentIno, - const BNode *sourceNode, BNode *destNode, BPoint *loc) + const BNode* sourceNode, BNode* destNode, BPoint* loc) { BPoint point; if (!loc @@ -515,7 +516,7 @@ SetUpPoseLocation(ino_t sourceParentIno, ino_t destParentIno, loc = &point; // copy the originals location - if (loc && loc != (BPoint *)-1) { + if (loc && loc != (BPoint*)-1) { // loc of -1 is used when copying/moving into a window in list mode // where copying positions would not work // ToSo: @@ -526,8 +527,8 @@ SetUpPoseLocation(ino_t sourceParentIno, ino_t destParentIno, void -FSMoveToFolder(BObjectList *srcList, BEntry *destEntry, - uint32 moveMode, BList *pointList) +FSMoveToFolder(BObjectList* srcList, BEntry* destEntry, + uint32 moveMode, BList* pointList) { if (srcList->IsEmpty()) { delete srcList; @@ -542,16 +543,16 @@ FSMoveToFolder(BObjectList *srcList, BEntry *destEntry, void -FSDelete(entry_ref *ref, bool async, bool confirm) +FSDelete(entry_ref* ref, bool async, bool confirm) { - BObjectList *list = new BObjectList(1, true); + BObjectList* list = new BObjectList(1, true); list->AddItem(ref); FSDeleteRefList(list, async, confirm); } void -FSDeleteRefList(BObjectList *list, bool async, bool confirm) +FSDeleteRefList(BObjectList* list, bool async, bool confirm) { if (async) { LaunchInNewThread("DeleteTask", B_NORMAL_PRIORITY, _DeleteTask, list, @@ -562,7 +563,7 @@ FSDeleteRefList(BObjectList *list, bool async, bool confirm) void -FSRestoreRefList(BObjectList *list, bool async) +FSRestoreRefList(BObjectList* list, bool async) { if (async) { LaunchInNewThread("RestoreTask", B_NORMAL_PRIORITY, _RestoreTask, @@ -573,7 +574,7 @@ FSRestoreRefList(BObjectList *list, bool async) void -FSMoveToTrash(BObjectList *srcList, BList *pointList, bool async) +FSMoveToTrash(BObjectList* srcList, BList* pointList, bool async) { if (srcList->IsEmpty()) { delete srcList; @@ -583,14 +584,14 @@ FSMoveToTrash(BObjectList *srcList, BList *pointList, bool async) if (async) LaunchInNewThread("MoveTask", B_NORMAL_PRIORITY, MoveTask, srcList, - (BEntry *)0, pointList, kMoveSelectionTo); + (BEntry*)0, pointList, kMoveSelectionTo); else MoveTask(srcList, 0, pointList, kMoveSelectionTo); } static bool -IsDisksWindowIcon(BEntry *entry) +IsDisksWindowIcon(BEntry* entry) { BPath path; if (entry->InitCheck() != B_OK || entry->GetPath(&path) != B_OK) @@ -607,9 +608,9 @@ enum { bool -ConfirmChangeIfWellKnownDirectory(const BEntry *entry, - const char *ifYouDoAction, const char *toDoAction, - const char *toConfirmAction, bool dontAsk, int32 *confirmedAlready) +ConfirmChangeIfWellKnownDirectory(const BEntry* entry, + const char* ifYouDoAction, const char* toDoAction, + const char* toConfirmAction, bool dontAsk, int32* confirmedAlready) { // Don't let the user casually move/change important files/folders // @@ -701,7 +702,7 @@ ConfirmChangeIfWellKnownDirectory(const BEntry *entry, BString buttonLabel(toConfirmAction); - OverrideAlert *alert = new OverrideAlert("", warning.String(), + OverrideAlert* alert = new OverrideAlert("", warning.String(), buttonLabel.String(), (requireOverride ? B_SHIFT_KEY : 0), B_TRANSLATE("Cancel"), 0, NULL, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetShortcut(1, B_ESCAPE); @@ -724,9 +725,9 @@ ConfirmChangeIfWellKnownDirectory(const BEntry *entry, static status_t InitCopy(CopyLoopControl* loopControl, uint32 moveMode, - BObjectList *srcList, BVolume *dstVol, BDirectory *destDir, - entry_ref *destRef, bool preflightNameCheck, bool needSizeCalculation, - int32 *collisionCount, ConflictCheckResult *preflightResult) + BObjectList* srcList, BVolume* dstVol, BDirectory* destDir, + entry_ref* destRef, bool preflightNameCheck, bool needSizeCalculation, + int32* collisionCount, ConflictCheckResult* preflightResult) { if (dstVol->IsReadOnly()) { BAlert* alert = new BAlert("", @@ -742,7 +743,7 @@ InitCopy(CopyLoopControl* loopControl, uint32 moveMode, for (int32 index = 0; index < numItems; index++) { // we could check for this while iterating through items in each of // the copy loops, except it takes forever to call CalcItemsAndSize - BEntry entry((entry_ref *)srcList->ItemAt(index)); + BEntry entry((entry_ref*)srcList->ItemAt(index)); if (IsDisksWindowIcon(&entry)) { BString errorStr; if (moveMode == kCreateLink) { @@ -806,7 +807,7 @@ InitCopy(CopyLoopControl* loopControl, uint32 moveMode, } // check for free space before starting copy - if ((totalSize + (4 * kKBSize)) >= dstVol->FreeBytes()) { + if ((totalSize + (4* kKBSize)) >= dstVol->FreeBytes()) { BAlert* alert = new BAlert("", B_TRANSLATE_NOCOLLECT(kNoFreeSpace), B_TRANSLATE("Cancel"), @@ -837,7 +838,7 @@ InitCopy(CopyLoopControl* loopControl, uint32 moveMode, // ToDo: // get rid of this cruft bool -delete_ref(void *ref) +delete_ref(void* ref) { delete (entry_ref*)ref; return false; @@ -845,7 +846,7 @@ delete_ref(void *ref) bool -delete_point(void *point) +delete_point(void* point) { delete (BPoint*)point; return false; @@ -853,7 +854,7 @@ delete_point(void *point) static status_t -MoveTask(BObjectList *srcList, BEntry *destEntry, BList *pointList, +MoveTask(BObjectList* srcList, BEntry* destEntry, BList* pointList, uint32 moveMode) { ASSERT(!srcList->IsEmpty()); @@ -870,7 +871,7 @@ MoveTask(BObjectList *srcList, BEntry *destEntry, BList *pointList, bool destIsTrash = false; BDirectory destDir; - BDirectory *destDirToCheck = NULL; + BDirectory* destDirToCheck = NULL; bool needPreflightNameCheck = false; bool sourceIsReadOnly = volume.IsReadOnly(); volume.Unset(); @@ -945,7 +946,7 @@ MoveTask(BObjectList *srcList, BEntry *destEntry, BList *pointList, if (result == B_OK) { for (int32 i = 0; i < srcList->CountItems(); i++) { - BPoint *loc = (BPoint *)-1; + BPoint* loc = (BPoint*)-1; // a loc of -1 forces autoplacement, rather than copying the // position of the original node // TODO: @@ -955,7 +956,7 @@ MoveTask(BObjectList *srcList, BEntry *destEntry, BList *pointList, // location or other stuff. It should not be a job of the // copy-engine. - entry_ref *srcRef = srcList->ItemAt(i); + entry_ref* srcRef = srcList->ItemAt(i); if (moveMode == kDuplicateSelection) { BEntry entry(srcRef); @@ -992,7 +993,7 @@ MoveTask(BObjectList *srcList, BEntry *destEntry, BList *pointList, // are we moving item to trash? if (destIsTrash) { if (pointList) - loc = (BPoint *)pointList->ItemAt(i); + loc = (BPoint*)pointList->ItemAt(i); result = MoveEntryToTrash(&sourceEntry, loc, undo); if (result != B_OK) { @@ -1024,9 +1025,9 @@ MoveTask(BObjectList *srcList, BEntry *destEntry, BList *pointList, // get location to place this item if (pointList && moveMode != kCopySelectionTo) { - loc = (BPoint *)pointList->ItemAt(i); + loc = (BPoint*)pointList->ItemAt(i); - BNode *src_node = GetWritableNode(&sourceEntry); + BNode* src_node = GetWritableNode(&sourceEntry); if (src_node && src_node->InitCheck() == B_OK) { PoseInfo poseInfo; poseInfo.fInvisible = false; @@ -1063,22 +1064,22 @@ MoveTask(BObjectList *srcList, BEntry *destEntry, BList *pointList, class FailWithAlert { public: - static void FailOnError(status_t error, const char *string, - const char *name = NULL) + static void FailOnError(status_t error, const char* string, + const char* name = NULL) { if (error != B_OK) throw FailWithAlert(error, string, name); } - FailWithAlert(status_t error, const char *string, const char *name) + FailWithAlert(status_t error, const char* string, const char* name) : fString(string), fName(name), fError(error) { } - const char *fString; - const char *fName; + const char* fString; + const char* fName; status_t fError; }; @@ -1099,8 +1100,8 @@ class MoveError { void -CopyFile(BEntry *srcFile, StatStruct *srcStat, BDirectory *destDir, - CopyLoopControl *loopControl, BPoint *loc, bool makeOriginalName, +CopyFile(BEntry* srcFile, StatStruct* srcStat, BDirectory* destDir, + CopyLoopControl* loopControl, BPoint* loc, bool makeOriginalName, Undo &undo) { if (loopControl->SkipEntry(srcFile, true)) @@ -1173,7 +1174,7 @@ CopyFile(BEntry *srcFile, StatStruct *srcStat, BDirectory *destDir, #ifdef _SILENTLY_CORRECT_FILE_NAMES static bool -CreateFileSystemCompatibleName(const BDirectory *destDir, char *destName) +CreateFileSystemCompatibleName(const BDirectory* destDir, char* destName) { // Is it a FAT32 file system? (this is the only one we currently now about) @@ -1195,7 +1196,7 @@ CreateFileSystemCompatibleName(const BDirectory *destDir, char *destName) wasInvalid = true; } - char *invalid = destName; + char* invalid = destName; while ((invalid = strpbrk(invalid, "?<>\\:\"|*")) != NULL) { invalid[0] = '_'; wasInvalid = true; @@ -1210,8 +1211,8 @@ CreateFileSystemCompatibleName(const BDirectory *destDir, char *destName) static void -LowLevelCopy(BEntry *srcEntry, StatStruct *srcStat, BDirectory *destDir, - char *destName, CopyLoopControl *loopControl, BPoint *loc) +LowLevelCopy(BEntry* srcEntry, StatStruct* srcStat, BDirectory* destDir, + char* destName, CopyLoopControl* loopControl, BPoint* loc) { entry_ref ref; ThrowOnError(srcEntry->GetRef(&ref)); @@ -1248,8 +1249,8 @@ LowLevelCopy(BEntry *srcEntry, StatStruct *srcStat, BDirectory *destDir, BFile srcFile(srcEntry, O_RDONLY); ThrowOnInitCheckError(&srcFile); - const size_t kMinBufferSize = 1024 * 128; - const size_t kMaxBufferSize = 1024 * 1024; + const size_t kMinBufferSize = 1024* 128; + const size_t kMaxBufferSize = 1024* 1024; size_t bufsize = kMinBufferSize; if (bufsize < srcStat->st_size) { @@ -1259,7 +1260,7 @@ LowLevelCopy(BEntry *srcEntry, StatStruct *srcStat, BDirectory *destDir, size_t freesize = static_cast( (sinfo.max_pages - sinfo.used_pages) * B_PAGE_SIZE); bufsize = freesize / 4; // take 1/4 of RAM max - bufsize -= bufsize % (16 * 1024); // Round to 16 KB boundaries + bufsize -= bufsize % (16* 1024); // Round to 16 KB boundaries if (bufsize < kMinBufferSize) // at least kMinBufferSize bufsize = kMinBufferSize; else if (bufsize > kMaxBufferSize) // no more than kMaxBufferSize @@ -1283,7 +1284,7 @@ LowLevelCopy(BEntry *srcEntry, StatStruct *srcStat, BDirectory *destDir, SetUpPoseLocation(ref.directory, destNodeRef.node, &srcFile, &destFile, loc); - char *buffer = new char[bufsize]; + char* buffer = new char[bufsize]; try { // copy data portion of file while (true) { @@ -1303,7 +1304,7 @@ LowLevelCopy(BEntry *srcEntry, StatStruct *srcStat, BDirectory *destDir, if (bytes > 0) { ssize_t updateBytes = 0; - if (bytes > 32 * 1024) { + if (bytes > 32* 1024) { // when copying large chunks, update after read and after // write to get better update granularity updateBytes = bytes / 2; @@ -1354,8 +1355,8 @@ LowLevelCopy(BEntry *srcEntry, StatStruct *srcStat, BDirectory *destDir, void -CopyAttributes(CopyLoopControl *control, BNode *srcNode, BNode *destNode, - void *buffer, size_t bufsize) +CopyAttributes(CopyLoopControl* control, BNode* srcNode, BNode* destNode, + void* buffer, size_t bufsize) { // ToDo: // Add error checking @@ -1411,8 +1412,8 @@ CopyAttributes(CopyLoopControl *control, BNode *srcNode, BNode *destNode, static void -CopyFolder(BEntry *srcEntry, BDirectory *destDir, CopyLoopControl *loopControl, - BPoint *loc, bool makeOriginalName, Undo &undo, bool removeSource = false) +CopyFolder(BEntry* srcEntry, BDirectory* destDir, CopyLoopControl* loopControl, + BPoint* loc, bool makeOriginalName, Undo &undo, bool removeSource = false) { BDirectory newDir; BEntry entry; @@ -1491,7 +1492,7 @@ CopyFolder(BEntry *srcEntry, BDirectory *destDir, CopyLoopControl *loopControl, } } - char *buffer; + char* buffer; if (createDirectory && err == B_OK && (buffer = (char*)malloc(32768)) != 0) { CopyAttributes(loopControl, &srcDir, &newDir, buffer, 32768); @@ -1543,7 +1544,7 @@ CopyFolder(BEntry *srcEntry, BDirectory *destDir, CopyLoopControl *loopControl, status_t -RecursiveMove(BEntry *entry, BDirectory *destDir, +RecursiveMove(BEntry* entry, BDirectory* destDir, CopyLoopControl* loopControl) { char name[B_FILE_NAME_LENGTH]; @@ -1582,8 +1583,8 @@ RecursiveMove(BEntry *entry, BDirectory *destDir, } status_t -MoveItem(BEntry *entry, BDirectory *destDir, BPoint *loc, uint32 moveMode, - const char *newName, Undo &undo, CopyLoopControl* loopControl) +MoveItem(BEntry* entry, BDirectory* destDir, BPoint* loc, uint32 moveMode, + const char* newName, Undo &undo, CopyLoopControl* loopControl) { entry_ref ref; try { @@ -1606,7 +1607,7 @@ MoveItem(BEntry *entry, BDirectory *destDir, BPoint *loc, uint32 moveMode, BPath path; entry->GetPath(&path); - if (loc && loc != (BPoint *)-1) { + if (loc && loc != (BPoint*)-1) { poseInfo.fInvisible = false; poseInfo.fInitedDirectory = destNode.node; poseInfo.fLocation = *loc; @@ -1636,10 +1637,10 @@ MoveItem(BEntry *entry, BDirectory *destDir, BPoint *loc, uint32 moveMode, // find index while paths are the same - const char *src = srcString.String(); - const char *dest = destString.String(); - const char *lastFolderSrc = src; - const char *lastFolderDest = dest; + const char* src = srcString.String(); + const char* dest = destString.String(); + const char* lastFolderSrc = src; + const char* lastFolderDest = dest; while (*src && *dest && *src == *dest) { ++src; @@ -1690,7 +1691,7 @@ MoveItem(BEntry *entry, BDirectory *destDir, BPoint *loc, uint32 moveMode, B_TRANSLATE("Error creating link to \"%name\"."), ref.name); - if (loc && loc != (BPoint *)-1) { + if (loc && loc != (BPoint*)-1) { link.WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &poseInfo, sizeof(PoseInfo)); } @@ -1748,17 +1749,17 @@ MoveItem(BEntry *entry, BDirectory *destDir, BPoint *loc, uint32 moveMode, void -FSDuplicate(BObjectList *srcList, BList *pointList) +FSDuplicate(BObjectList* srcList, BList* pointList) { LaunchInNewThread("DupTask", B_NORMAL_PRIORITY, MoveTask, srcList, - (BEntry *)NULL, pointList, kDuplicateSelection); + (BEntry*)NULL, pointList, kDuplicateSelection); } #if 0 status_t -FSCopyFolder(BEntry *srcEntry, BDirectory *destDir, - CopyLoopControl *loopControl, BPoint *loc, bool makeOriginalName) +FSCopyFolder(BEntry* srcEntry, BDirectory* destDir, + CopyLoopControl* loopControl, BPoint* loc, bool makeOriginalName) { try CopyFolder(srcEntry, destDir, loopControl, loc, makeOriginalName); @@ -1771,9 +1772,9 @@ FSCopyFolder(BEntry *srcEntry, BDirectory *destDir, status_t -FSCopyAttributesAndStats(BNode *srcNode, BNode *destNode) +FSCopyAttributesAndStats(BNode* srcNode, BNode* destNode) { - char *buffer = new char[1024]; + char* buffer = new char[1024]; // copy the attributes srcNode->RewindAttrs(); @@ -1823,8 +1824,8 @@ FSCopyAttributesAndStats(BNode *srcNode, BNode *destNode) #if 0 status_t -FSCopyFile(BEntry* srcFile, StatStruct *srcStat, BDirectory* destDir, - CopyLoopControl *loopControl, BPoint *loc, bool makeOriginalName) +FSCopyFile(BEntry* srcFile, StatStruct* srcStat, BDirectory* destDir, + CopyLoopControl* loopControl, BPoint* loc, bool makeOriginalName) { try { CopyFile(srcFile, srcStat, destDir, loopControl, loc, @@ -1839,7 +1840,7 @@ FSCopyFile(BEntry* srcFile, StatStruct *srcStat, BDirectory* destDir, static status_t -MoveEntryToTrash(BEntry *entry, BPoint *loc, Undo &undo) +MoveEntryToTrash(BEntry* entry, BPoint* loc, Undo &undo) { BDirectory trash_dir; entry_ref ref; @@ -1929,8 +1930,8 @@ MoveEntryToTrash(BEntry *entry, BPoint *loc, Undo &undo) undo.UpdateEntry(entry, name); } - BNode *src_node = 0; - if (loc && loc != (BPoint *)-1 + BNode* src_node = 0; + if (loc && loc != (BPoint*)-1 && (src_node = GetWritableNode(entry, &statbuf)) != 0) { trash_dir.GetStat(&statbuf); PoseInfo poseInfo; @@ -1959,8 +1960,8 @@ MoveEntryToTrash(BEntry *entry, BPoint *loc, Undo &undo) ConflictCheckResult -PreFlightNameCheck(BObjectList *srcList, const BDirectory *destDir, - int32 *collisionCount, uint32 moveMode) +PreFlightNameCheck(BObjectList* srcList, const BDirectory* destDir, + int32* collisionCount, uint32 moveMode) { // count the number of name collisions in dest folder @@ -1968,7 +1969,7 @@ PreFlightNameCheck(BObjectList *srcList, const BDirectory *destDir, int32 count = srcList->CountItems(); for (int32 i = 0; i < count; i++) { - entry_ref *srcRef = srcList->ItemAt(i); + entry_ref* srcRef = srcList->ItemAt(i); BEntry entry(srcRef); BDirectory parent; entry.GetParent(&parent); @@ -2010,7 +2011,7 @@ PreFlightNameCheck(BObjectList *srcList, const BDirectory *destDir, void -FileStatToString(StatStruct *stat, char *buffer, int32 length) +FileStatToString(StatStruct* stat, char* buffer, int32 length) { tm timeData; localtime_r(&stat->st_mtime, &timeData); @@ -2023,8 +2024,8 @@ FileStatToString(StatStruct *stat, char *buffer, int32 length) status_t -CheckName(uint32 moveMode, const BEntry *sourceEntry, - const BDirectory *destDir, bool multipleCollisions, +CheckName(uint32 moveMode, const BEntry* sourceEntry, + const BDirectory* destDir, bool multipleCollisions, ConflictCheckResult &replaceAll) { if (moveMode == kDuplicateSelection) @@ -2145,7 +2146,7 @@ CheckName(uint32 moveMode, const BEntry *sourceEntry, } // special case single collision (don't need Replace All shortcut) - BAlert *alert; + BAlert* alert; if (multipleCollisions || sourceIsDirectory) { alert = new BAlert("", replaceMsg.String(), B_TRANSLATE("Skip"), B_TRANSLATE("Replace all")); @@ -2188,7 +2189,7 @@ CheckName(uint32 moveMode, const BEntry *sourceEntry, status_t -FSDeleteFolder(BEntry *dir_entry, CopyLoopControl *loopControl, +FSDeleteFolder(BEntry* dir_entry, CopyLoopControl* loopControl, bool update_status, bool delete_top_dir, bool upateFileNameInStatus) { entry_ref ref; @@ -2245,20 +2246,20 @@ FSDeleteFolder(BEntry *dir_entry, CopyLoopControl *loopControl, void -FSMakeOriginalName(BString &string, const BDirectory *destDir, - const char *suffix) +FSMakeOriginalName(BString &string, const BDirectory* destDir, + const char* suffix) { if (!destDir->Contains(string.String())) return; FSMakeOriginalName(string.LockBuffer(B_FILE_NAME_LENGTH), - const_cast(destDir), suffix ? suffix : " copy"); + const_cast(destDir), suffix ? suffix : " copy"); string.UnlockBuffer(); } void -FSMakeOriginalName(char *name, BDirectory *destDir, const char *suffix) +FSMakeOriginalName(char* name, BDirectory* destDir, const char* suffix) { char root[B_FILE_NAME_LENGTH]; char copybase[B_FILE_NAME_LENGTH]; @@ -2278,7 +2279,7 @@ FSMakeOriginalName(char *name, BDirectory *destDir, const char *suffix) bool copycopy = false; // are we copying a copy? int32 len = (int32)strlen(name); - char *p = name + len - 1; // get pointer to end os name + char* p = name + len - 1; // get pointer to end os name // eat up optional numbers (if were copying " copy 34") while ((p > name) && isdigit(*p)) @@ -2307,12 +2308,10 @@ FSMakeOriginalName(char *name, BDirectory *destDir, const char *suffix) } if (!copycopy) { - /* - The name can't be longer than B_FILE_NAME_LENGTH. - The algoritm adds " copy XX" to the name. That's 8 characters. - B_FILE_NAME_LENGTH already accounts for NULL termination so we - don't need to save an extra char at the end. - */ + // The name can't be longer than B_FILE_NAME_LENGTH. + // The algoritm adds " copy XX" to the name. That's 8 characters. + // B_FILE_NAME_LENGTH already accounts for NULL termination so we + // don't need to save an extra char at the end. if (strlen(name) > B_FILE_NAME_LENGTH - 8) { // name is too long - truncate it! name[B_FILE_NAME_LENGTH - 8] = '\0'; @@ -2331,13 +2330,11 @@ FSMakeOriginalName(char *name, BDirectory *destDir, const char *suffix) sprintf(temp_name, "%s %ld", copybase, ++fnum); if (strlen(temp_name) > (B_FILE_NAME_LENGTH - 1)) { - /* - The name has grown too long. Maybe we just went from - " copy 9" to " copy 10" and that extra - character was too much. The solution is to further - truncate the 'root' name and continue. - ??? should we reset fnum or not ??? - */ + // The name has grown too long. Maybe we just went from + // " copy 9" to " copy 10" and that extra + // character was too much. The solution is to further + // truncate the 'root' name and continue. + // ??? should we reset fnum or not ??? root[strlen(root) - 1] = '\0'; sprintf(temp_name, "%s%s %ld", root, suffix, fnum); } @@ -2367,7 +2364,7 @@ FSRecursiveCalcSize(BInfoWindow* window, CopyLoopControl* loopControl, if (status != B_OK) return status; - (*_runningSize) += statbuf.st_blocks * 512; + (*_runningSize) += statbuf.st_blocks* 512; if (S_ISDIR(statbuf.st_mode)) { BDirectory subdir(&entry); @@ -2384,8 +2381,8 @@ FSRecursiveCalcSize(BInfoWindow* window, CopyLoopControl* loopControl, status_t -CalcItemsAndSize(CopyLoopControl* loopControl, BObjectList *refList, - ssize_t blockSize, int32 *totalCount, off_t *totalSize) +CalcItemsAndSize(CopyLoopControl* loopControl, BObjectList* refList, + ssize_t blockSize, int32* totalCount, off_t* totalSize) { int32 fileCount = 0; int32 dirCount = 0; @@ -2414,7 +2411,7 @@ CalcItemsAndSize(CopyLoopControl* loopControl, BObjectList *refList, int32 num_items = refList->CountItems(); for (int32 i = 0; i < num_items; i++) { - entry_ref *ref = refList->ItemAt(i); + entry_ref* ref = refList->ItemAt(i); BEntry entry(ref); StatStruct statbuf; entry.GetStat(&statbuf); @@ -2442,7 +2439,7 @@ CalcItemsAndSize(CopyLoopControl* loopControl, BObjectList *refList, status_t -FSGetTrashDir(BDirectory *trashDir, dev_t dev) +FSGetTrashDir(BDirectory* trashDir, dev_t dev) { BVolume volume(dev); status_t result = volume.InitCheck(); @@ -2504,7 +2501,7 @@ FSGetTrashDir(BDirectory *trashDir, dev_t dev) // obsolete version of FSGetDeskDir retained for bin compat with // BeIDE and a few other apps that apparently use it status_t -FSGetDeskDir(BDirectory *deskDir, dev_t) +FSGetDeskDir(BDirectory* deskDir, dev_t) { // since we no longer keep a desktop directory on any volume other // than /boot, redirect to FSGetDeskDir ignoring the volume argument @@ -2514,7 +2511,7 @@ FSGetDeskDir(BDirectory *deskDir, dev_t) status_t -FSGetDeskDir(BDirectory *deskDir) +FSGetDeskDir(BDirectory* deskDir) { BPath path; status_t result = find_directory(B_DESKTOP_DIRECTORY, &path, true); @@ -2548,7 +2545,7 @@ FSGetDeskDir(BDirectory *deskDir) status_t -FSGetBootDeskDir(BDirectory *deskDir) +FSGetBootDeskDir(BDirectory* deskDir) { BVolume bootVol; BVolumeRoster().GetBootVolume(&bootVol); @@ -2564,7 +2561,7 @@ FSGetBootDeskDir(BDirectory *deskDir) static bool -FSIsDirFlavor(const BEntry *entry, directory_which directoryType) +FSIsDirFlavor(const BEntry* entry, directory_which directoryType) { StatStruct dir_stat; StatStruct entry_stat; @@ -2588,21 +2585,21 @@ FSIsDirFlavor(const BEntry *entry, directory_which directoryType) bool -FSIsPrintersDir(const BEntry *entry) +FSIsPrintersDir(const BEntry* entry) { return FSIsDirFlavor(entry, B_USER_PRINTERS_DIRECTORY); } bool -FSIsTrashDir(const BEntry *entry) +FSIsTrashDir(const BEntry* entry) { return FSIsDirFlavor(entry, B_TRASH_DIRECTORY); } bool -FSIsDeskDir(const BEntry *entry) +FSIsDeskDir(const BEntry* entry) { BPath path; status_t result = find_directory(B_DESKTOP_DIRECTORY, &path, true); @@ -2615,14 +2612,14 @@ FSIsDeskDir(const BEntry *entry) bool -FSIsHomeDir(const BEntry *entry) +FSIsHomeDir(const BEntry* entry) { return FSIsDirFlavor(entry, B_USER_DIRECTORY); } bool -FSIsRootDir(const BEntry *entry) +FSIsRootDir(const BEntry* entry) { BPath path(entry); return path == "/"; @@ -2630,7 +2627,7 @@ FSIsRootDir(const BEntry *entry) bool -DirectoryMatchesOrContains(const BEntry *entry, directory_which which) +DirectoryMatchesOrContains(const BEntry* entry, directory_which which) { BPath path; if (find_directory(which, &path, false, NULL) != B_OK) @@ -2650,7 +2647,7 @@ DirectoryMatchesOrContains(const BEntry *entry, directory_which which) bool -DirectoryMatchesOrContains(const BEntry *entry, const char *additionalPath, +DirectoryMatchesOrContains(const BEntry* entry, const char* additionalPath, directory_which which) { BPath path; @@ -2672,7 +2669,7 @@ DirectoryMatchesOrContains(const BEntry *entry, const char *additionalPath, bool -DirectoryMatches(const BEntry *entry, directory_which which) +DirectoryMatches(const BEntry* entry, directory_which which) { BPath path; if (find_directory(which, &path, false, NULL) != B_OK) @@ -2687,7 +2684,7 @@ DirectoryMatches(const BEntry *entry, directory_which which) bool -DirectoryMatches(const BEntry *entry, const char *additionalPath, +DirectoryMatches(const BEntry* entry, const char* additionalPath, directory_which which) { BPath path; @@ -2704,7 +2701,7 @@ DirectoryMatches(const BEntry *entry, const char *additionalPath, extern status_t -FSFindTrackerSettingsDir(BPath *path, bool autoCreate) +FSFindTrackerSettingsDir(BPath* path, bool autoCreate) { status_t result = find_directory (B_USER_SETTINGS_DIRECTORY, path, autoCreate); @@ -2718,7 +2715,7 @@ FSFindTrackerSettingsDir(BPath *path, bool autoCreate) bool -FSInTrashDir(const entry_ref *ref) +FSInTrashDir(const entry_ref* ref) { BEntry entry(ref); if (entry.InitCheck() != B_OK) @@ -2743,7 +2740,7 @@ FSEmptyTrash() status_t -empty_trash(void *) +empty_trash(void*) { // empty trash on all mounted volumes status_t err = B_OK; @@ -2801,7 +2798,7 @@ empty_trash(void *) } if (err != B_OK && err != kTrashCanceled && err != kUserCanceled) { - (new BAlert("", B_TRANSLATE("Error emptying Trash!"), + (new BAlert("", B_TRANSLATE("Error emptying Trash!"), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go(); } @@ -2811,7 +2808,7 @@ empty_trash(void *) status_t -_DeleteTask(BObjectList *list, bool confirm) +_DeleteTask(BObjectList* list, bool confirm) { if (confirm) { bool dontMoveToTrash = TrackerSettings().DontMoveFilesToTrash(); @@ -2915,7 +2912,7 @@ FSRecursiveCreateFolder(BPath path) } status_t -_RestoreTask(BObjectList *list) +_RestoreTask(BObjectList* list) { TrackerCopyLoopControl loopControl(kRestoreFromTrashState); @@ -2996,7 +2993,7 @@ FSCreateTrashDirs() status_t -FSCreateNewFolder(const entry_ref *ref) +FSCreateNewFolder(const entry_ref* ref) { node_ref node; node.device = ref->device; @@ -3024,8 +3021,8 @@ FSCreateNewFolder(const entry_ref *ref) status_t -FSCreateNewFolderIn(const node_ref *dirNode, entry_ref *newRef, - node_ref *newNode) +FSCreateNewFolderIn(const node_ref* dirNode, entry_ref* newRef, + node_ref* newNode) { BDirectory dir(dirNode); status_t result = dir.InitCheck(); @@ -3074,9 +3071,9 @@ FSCreateNewFolderIn(const node_ref *dirNode, entry_ref *newRef, ReadAttrResult -ReadAttr(const BNode *node, const char *hostAttrName, - const char *foreignAttrName, type_code type, off_t offset, void *buffer, - size_t length, void (*swapFunc)(void *), bool isForeign) +ReadAttr(const BNode* node, const char* hostAttrName, + const char* foreignAttrName, type_code type, off_t offset, void* buffer, + size_t length, void (*swapFunc)(void*), bool isForeign) { if (!isForeign && node->ReadAttr(hostAttrName, type, offset, buffer, length) == (ssize_t)length) { @@ -3102,8 +3099,8 @@ ReadAttr(const BNode *node, const char *hostAttrName, ReadAttrResult -GetAttrInfo(const BNode *node, const char *hostAttrName, - const char *foreignAttrName, type_code *type, size_t *size) +GetAttrInfo(const BNode* node, const char* hostAttrName, + const char* foreignAttrName, type_code* type, size_t* size) { attr_info info; @@ -3130,10 +3127,10 @@ GetAttrInfo(const BNode *node, const char *hostAttrName, // launching code static status_t -TrackerOpenWith(const BMessage *refs) +TrackerOpenWith(const BMessage* refs) { BMessage clone(*refs); - ASSERT(dynamic_cast(be_app)); + ASSERT(dynamic_cast(be_app)); ASSERT(clone.what); clone.AddInt32("launchUsingSelector", 0); // runs the Open With window @@ -3144,22 +3141,22 @@ TrackerOpenWith(const BMessage *refs) static void -AsynchLaunchBinder(void (*func)(const entry_ref *, const BMessage *, bool on), - const entry_ref *appRef, const BMessage *refs, bool openWithOK) +AsynchLaunchBinder(void (*func)(const entry_ref*, const BMessage*, bool on), + const entry_ref* appRef, const BMessage* refs, bool openWithOK) { - BMessage *task = new BMessage; - task->AddPointer("function", (void *)func); + BMessage* task = new BMessage; + task->AddPointer("function", (void*)func); task->AddMessage("refs", refs); task->AddBool("openWithOK", openWithOK); if (appRef != NULL) task->AddRef("appRef", appRef); - extern BLooper *gLaunchLooper; + extern BLooper* gLaunchLooper; gLaunchLooper->PostMessage(task); } static bool -SniffIfGeneric(const entry_ref *ref) +SniffIfGeneric(const entry_ref* ref) { BNode node(ref); char type[B_MIME_TYPE_LENGTH]; @@ -3181,7 +3178,7 @@ SniffIfGeneric(const entry_ref *ref) } static void -SniffIfGeneric(const BMessage *refs) +SniffIfGeneric(const BMessage* refs) { entry_ref ref; for (int32 index = 0; ; index++) { @@ -3192,7 +3189,7 @@ SniffIfGeneric(const BMessage *refs) } static void -_TrackerLaunchAppWithDocuments(const entry_ref *appRef, const BMessage *refs, +_TrackerLaunchAppWithDocuments(const entry_ref* appRef, const BMessage* refs, bool openWithOK) { team_id team; @@ -3218,12 +3215,12 @@ _TrackerLaunchAppWithDocuments(const entry_ref *appRef, const BMessage *refs, if (error == B_OK) { // close possible parent window, if specified - const node_ref *nodeToClose = 0; + const node_ref* nodeToClose = 0; int32 numBytes; refs->FindData("nodeRefsToClose", B_RAW_TYPE, - (const void **)&nodeToClose, &numBytes); + (const void**)&nodeToClose, &numBytes); if (nodeToClose) - dynamic_cast(be_app)->CloseParent(*nodeToClose); + dynamic_cast(be_app)->CloseParent(*nodeToClose); } else { alertString.SetTo(B_TRANSLATE("Could not open \"%name\" (%error). ")); alertString.ReplaceFirst("%name", appRef->name); @@ -3247,16 +3244,16 @@ _TrackerLaunchAppWithDocuments(const entry_ref *appRef, const BMessage *refs, extern "C" char** environ; -extern "C" status_t _kern_load_image(const char * const *flatArgs, +extern "C" status_t _kern_load_image(const char* const* flatArgs, size_t flatArgsSize, int32 argCount, int32 envCount, int32 priority, uint32 flags, port_id errorPort, uint32 errorToken); -extern "C" status_t __flatten_process_args(const char * const *args, - int32 argCount, const char * const *env, int32 envCount, char ***_flatArgs, - size_t *_flatSize); +extern "C" status_t __flatten_process_args(const char* const* args, + int32 argCount, const char* const* env, int32 envCount, char***_flatArgs, + size_t* _flatSize); static status_t -LoaderErrorDetails(const entry_ref *app, BString &details) +LoaderErrorDetails(const entry_ref* app, BString &details) { BPath path; BEntry appEntry(app, true); @@ -3265,7 +3262,7 @@ LoaderErrorDetails(const entry_ref *app, BString &details) if (result != B_OK) return result; - char *argv[2] = { const_cast(path.Path()), 0}; + char* argv[2] = { const_cast(path.Path()), 0}; port_id errorPort = create_port(1, "Tracker loader error"); @@ -3276,7 +3273,7 @@ LoaderErrorDetails(const entry_ref *app, BString &details) char** flatArgs = NULL; size_t flatArgsSize; - result = __flatten_process_args((const char **)argv, 1, + result = __flatten_process_args((const char**)argv, 1, environ, envCount, &flatArgs, &flatArgsSize); if (result != B_OK) return result; @@ -3301,7 +3298,7 @@ LoaderErrorDetails(const entry_ref *app, BString &details) return bufferSize; } - uint8 *buffer = (uint8 *)malloc(bufferSize); + uint8* buffer = (uint8*)malloc(bufferSize); if (buffer == NULL) { delete_port(errorPort); return B_NO_MEMORY; @@ -3317,7 +3314,7 @@ LoaderErrorDetails(const entry_ref *app, BString &details) } BMessage message; - result = message.Unflatten((const char *)buffer); + result = message.Unflatten((const char*)buffer); free(buffer); if (result != B_OK) @@ -3328,7 +3325,7 @@ LoaderErrorDetails(const entry_ref *app, BString &details) if (result != B_OK) return result; - const char *detailName = NULL; + const char* detailName = NULL; switch (errorCode) { case B_MISSING_LIBRARY: detailName = "missing library"; @@ -3342,7 +3339,7 @@ LoaderErrorDetails(const entry_ref *app, BString &details) if (detailName == NULL) return B_ERROR; - const char *detail; + const char* detail; for (int32 i = 0; message.FindString(detailName, i, &detail) == B_OK; i++) { if (i > 0) @@ -3355,7 +3352,7 @@ LoaderErrorDetails(const entry_ref *app, BString &details) static void -_TrackerLaunchDocuments(const entry_ref */*doNotUse*/, const BMessage *refs, +_TrackerLaunchDocuments(const entry_ref* /*doNotUse*/, const BMessage* refs, bool openWithOK) { BMessage copyOfRefs(*refs); @@ -3367,9 +3364,9 @@ _TrackerLaunchDocuments(const entry_ref */*doNotUse*/, const BMessage *refs, status_t error = B_ERROR; entry_ref app; - BMessage *refsToPass = NULL; + BMessage* refsToPass = NULL; BString alertString; - const char *alternative = 0; + const char* alternative = 0; for (int32 mimesetIt = 0; ; mimesetIt++) { alertString = ""; @@ -3546,7 +3543,7 @@ _TrackerLaunchDocuments(const entry_ref */*doNotUse*/, const BMessage *refs, // should fix that, making them void status_t -TrackerLaunch(const entry_ref *appRef, const BMessage *refs, bool async, +TrackerLaunch(const entry_ref* appRef, const BMessage* refs, bool async, bool openWithOK) { if (!async) @@ -3560,7 +3557,7 @@ TrackerLaunch(const entry_ref *appRef, const BMessage *refs, bool async, } status_t -TrackerLaunch(const entry_ref *appRef, bool async) +TrackerLaunch(const entry_ref* appRef, bool async) { if (!async) _TrackerLaunchAppWithDocuments(appRef, 0, false); @@ -3571,7 +3568,7 @@ TrackerLaunch(const entry_ref *appRef, bool async) } status_t -TrackerLaunch(const BMessage *refs, bool async, bool openWithOK) +TrackerLaunch(const BMessage* refs, bool async, bool openWithOK) { if (!async) _TrackerLaunchDocuments(0, refs, openWithOK); @@ -3582,11 +3579,11 @@ TrackerLaunch(const BMessage *refs, bool async, bool openWithOK) } status_t -LaunchBrokenLink(const char *signature, const BMessage *refs) +LaunchBrokenLink(const char* signature, const BMessage* refs) { // This call is to support a hacky workaround for double-clicking // broken refs for cifs - be_roster->Launch(signature, const_cast(refs)); + be_roster->Launch(signature, const_cast(refs)); return B_OK; } @@ -3596,7 +3593,7 @@ LaunchBrokenLink(const char *signature, const BMessage *refs) _IMPEXP_TRACKER #endif status_t -FSLaunchItem(const entry_ref *application, const BMessage *refsReceived, +FSLaunchItem(const entry_ref* application, const BMessage* refsReceived, bool async, bool openWithOK) { return TrackerLaunch(application, refsReceived, async, openWithOK); @@ -3607,12 +3604,12 @@ FSLaunchItem(const entry_ref *application, const BMessage *refsReceived, _IMPEXP_TRACKER #endif status_t -FSOpenWith(BMessage *listOfRefs) +FSOpenWith(BMessage* listOfRefs) { status_t result = B_ERROR; listOfRefs->what = B_REFS_RECEIVED; - if (dynamic_cast(be_app)) + if (dynamic_cast(be_app)) result = TrackerOpenWith(listOfRefs); else ASSERT(!"not yet implemented"); @@ -3623,14 +3620,14 @@ FSOpenWith(BMessage *listOfRefs) // legacy calls, need for compatibility void -FSOpenWithDocuments(const entry_ref *executable, BMessage *documents) +FSOpenWithDocuments(const entry_ref* executable, BMessage* documents) { TrackerLaunch(executable, documents, true); delete documents; } status_t -FSLaunchUsing(const entry_ref *ref, BMessage *listOfRefs) +FSLaunchUsing(const entry_ref* ref, BMessage* listOfRefs) { BMessage temp(B_REFS_RECEIVED); if (!listOfRefs) { @@ -3643,7 +3640,7 @@ FSLaunchUsing(const entry_ref *ref, BMessage *listOfRefs) } status_t -FSLaunchItem(const entry_ref *ref, BMessage* message, int32, bool async) +FSLaunchItem(const entry_ref* ref, BMessage* message, int32, bool async) { if (message) message->what = B_REFS_RECEIVED; @@ -3655,14 +3652,14 @@ FSLaunchItem(const entry_ref *ref, BMessage* message, int32, bool async) void -FSLaunchItem(const entry_ref *ref, BMessage *message, int32 workspace) +FSLaunchItem(const entry_ref* ref, BMessage* message, int32 workspace) { FSLaunchItem(ref, message, workspace, true); } // Get the original path of an entry in the trash status_t -FSGetOriginalPath(BEntry *entry, BPath *result) +FSGetOriginalPath(BEntry* entry, BPath* result) { status_t err; entry_ref ref; @@ -3728,17 +3725,17 @@ FSGetOriginalPath(BEntry *entry, BPath *result) } directory_which -WellKnowEntryList::Match(const node_ref *node) +WellKnowEntryList::Match(const node_ref* node) { - const WellKnownEntry *result = MatchEntry(node); + const WellKnownEntry* result = MatchEntry(node); if (result) return result->which; return (directory_which)-1; } -const WellKnowEntryList::WellKnownEntry * -WellKnowEntryList::MatchEntry(const node_ref *node) +const WellKnowEntryList::WellKnownEntry* +WellKnowEntryList::MatchEntry(const node_ref* node) { if (!self) self = new WellKnowEntryList(); @@ -3746,8 +3743,8 @@ WellKnowEntryList::MatchEntry(const node_ref *node) return self->MatchEntryCommon(node); } -const WellKnowEntryList::WellKnownEntry * -WellKnowEntryList::MatchEntryCommon(const node_ref *node) +const WellKnowEntryList::WellKnownEntry* +WellKnowEntryList::MatchEntryCommon(const node_ref* node) { uint32 count = entries.size(); for (uint32 index = 0; index < count; index++) @@ -3767,7 +3764,7 @@ WellKnowEntryList::Quit() void -WellKnowEntryList::AddOne(directory_which which, const char *name) +WellKnowEntryList::AddOne(directory_which which, const char* name) { BPath path; if (find_directory(which, &path, true) != B_OK) @@ -3784,7 +3781,7 @@ WellKnowEntryList::AddOne(directory_which which, const char *name) void WellKnowEntryList::AddOne(directory_which which, directory_which base, - const char *extra, const char *name) + const char* extra, const char* name) { BPath path; if (find_directory(base, &path, true) != B_OK) @@ -3801,8 +3798,8 @@ WellKnowEntryList::AddOne(directory_which which, directory_which base, void -WellKnowEntryList::AddOne(directory_which which, const char *path, - const char *name) +WellKnowEntryList::AddOne(directory_which which, const char* path, + const char* name) { BEntry entry(path, true); node_ref node; @@ -3859,6 +3856,6 @@ WellKnowEntryList::WellKnowEntryList() "downloads", "downloads"); } -WellKnowEntryList *WellKnowEntryList::self = NULL; +WellKnowEntryList* WellKnowEntryList::self = NULL; } // namespace BPrivate diff --git a/src/kits/tracker/FSUtils.h b/src/kits/tracker/FSUtils.h index d033e0be2b..da95902cb4 100644 --- a/src/kits/tracker/FSUtils.h +++ b/src/kits/tracker/FSUtils.h @@ -31,9 +31,9 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ +#ifndef FS_UTILS_H +#define FS_UTILS_H -#ifndef FS_UTILS_H -#define FS_UTILS_H #include #include @@ -45,6 +45,7 @@ All rights reserved. #include "Model.h" #include "ObjectList.h" + // Note - APIs/code in FSUtils.h and FSUtils.cpp is slated for a major cleanup // -- in other words, you will find a lot of ugly cruft in here @@ -97,7 +98,7 @@ public: bool srcIsDir, bool dstIsDir); //! Override to prevent copying of a given file or directory - virtual bool SkipEntry(const BEntry *, bool file); + virtual bool SkipEntry(const BEntry*, bool file); //! During a file copy, this is called every time a chunk of data // is copied. Users may override to keep a running checksum. @@ -128,17 +129,17 @@ public: const entry_ref* destDir = NULL, bool showCount = true); - virtual bool FileError(const char *message, - const char *name, status_t error, + virtual bool FileError(const char* message, + const char* name, status_t error, bool allowContinue); - virtual void UpdateStatus(const char *name, + virtual void UpdateStatus(const char* name, const entry_ref& ref, int32 count, bool optional = false); virtual bool CheckUserCanceled(); - virtual bool SkipAttribute(const char *attributeName); + virtual bool SkipAttribute(const char* attributeName); // One can specify an entry_ref list with the source entries. This will @@ -162,54 +163,54 @@ private: #ifndef _IMPEXP_TRACKER #define _IMPEXP_TRACKER #endif -_IMPEXP_TRACKER status_t FSCopyAttributesAndStats(BNode *, BNode *); +_IMPEXP_TRACKER status_t FSCopyAttributesAndStats(BNode*, BNode*); -_IMPEXP_TRACKER void FSDuplicate(BObjectList *srcList, BList *pointList); -_IMPEXP_TRACKER void FSMoveToFolder(BObjectList *srcList, BEntry *, uint32 moveMode, - BList *pointList = NULL); -_IMPEXP_TRACKER void FSMakeOriginalName(char *name, BDirectory *destDir, const char *suffix); -_IMPEXP_TRACKER bool FSIsTrashDir(const BEntry *); -_IMPEXP_TRACKER bool FSIsPrintersDir(const BEntry *); -_IMPEXP_TRACKER bool FSIsDeskDir(const BEntry *); -_IMPEXP_TRACKER bool FSIsHomeDir(const BEntry *); -_IMPEXP_TRACKER bool FSIsRootDir(const BEntry *); -_IMPEXP_TRACKER void FSMoveToTrash(BObjectList *srcList, BList *pointList = NULL, +_IMPEXP_TRACKER void FSDuplicate(BObjectList* srcList, BList* pointList); +_IMPEXP_TRACKER void FSMoveToFolder(BObjectList* srcList, BEntry*, uint32 moveMode, + BList* pointList = NULL); +_IMPEXP_TRACKER void FSMakeOriginalName(char* name, BDirectory* destDir, const char* suffix); +_IMPEXP_TRACKER bool FSIsTrashDir(const BEntry*); +_IMPEXP_TRACKER bool FSIsPrintersDir(const BEntry*); +_IMPEXP_TRACKER bool FSIsDeskDir(const BEntry*); +_IMPEXP_TRACKER bool FSIsHomeDir(const BEntry*); +_IMPEXP_TRACKER bool FSIsRootDir(const BEntry*); +_IMPEXP_TRACKER void FSMoveToTrash(BObjectList* srcList, BList* pointList = NULL, bool async = true); // Deprecated -void FSDeleteRefList(BObjectList *, bool, bool confirm = true); -void FSDelete(entry_ref *, bool, bool confirm = true); -void FSRestoreRefList(BObjectList *list, bool async); +void FSDeleteRefList(BObjectList*, bool, bool confirm = true); +void FSDelete(entry_ref*, bool, bool confirm = true); +void FSRestoreRefList(BObjectList* list, bool async); -_IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref *application, const BMessage *refsReceived, +_IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref* application, const BMessage* refsReceived, bool async, bool openWithOK); // Preferred way of launching; only pass an actual application in , not // a document; to open documents with the preferred app, pase 0 in and // stuff all the document refs into // Consider having silent mode that does not show alerts, just returns error code -_IMPEXP_TRACKER status_t FSOpenWith(BMessage *listOfRefs); +_IMPEXP_TRACKER status_t FSOpenWith(BMessage* listOfRefs); // runs the Open With window; pas a list of refs _IMPEXP_TRACKER void FSEmptyTrash(); -_IMPEXP_TRACKER status_t FSCreateNewFolderIn(const node_ref *destDir, entry_ref *newRef, - node_ref *new_node); +_IMPEXP_TRACKER status_t FSCreateNewFolderIn(const node_ref* destDir, entry_ref* newRef, + node_ref* new_node); _IMPEXP_TRACKER void FSCreateTrashDirs(); -_IMPEXP_TRACKER status_t FSGetTrashDir(BDirectory *trashDir, dev_t volume); -_IMPEXP_TRACKER status_t FSGetDeskDir(BDirectory *deskDir); -_IMPEXP_TRACKER status_t FSRecursiveCalcSize(BInfoWindow *, - CopyLoopControl* loopControl, BDirectory *, off_t *runningSize, - int32 *fileCount, int32 *dirCount); +_IMPEXP_TRACKER status_t FSGetTrashDir(BDirectory* trashDir, dev_t volume); +_IMPEXP_TRACKER status_t FSGetDeskDir(BDirectory* deskDir); +_IMPEXP_TRACKER status_t FSRecursiveCalcSize(BInfoWindow*, + CopyLoopControl* loopControl, BDirectory*, off_t* runningSize, + int32* fileCount, int32* dirCount); -bool FSInTrashDir(const entry_ref *); +bool FSInTrashDir(const entry_ref*); // doesn't need to be exported -bool FSGetPoseLocation(const BNode *node, BPoint *point); -status_t FSSetPoseLocation(BEntry *entry, BPoint point); -status_t FSSetPoseLocation(ino_t destDirInode, BNode *destNode, BPoint point); -status_t FSGetBootDeskDir(BDirectory *deskDir); +bool FSGetPoseLocation(const BNode* node, BPoint* point); +status_t FSSetPoseLocation(BEntry* entry, BPoint point); +status_t FSSetPoseLocation(ino_t destDirInode, BNode* destNode, BPoint point); +status_t FSGetBootDeskDir(BDirectory* deskDir); -status_t FSGetOriginalPath(BEntry *entry, BPath *path); +status_t FSGetOriginalPath(BEntry* entry, BPath* path); enum ReadAttrResult { kReadAttrFailed, @@ -217,48 +218,48 @@ enum ReadAttrResult { kReadAttrForeignOK }; -ReadAttrResult ReadAttr(const BNode *, const char *hostAttrName, const char *foreignAttrName, - type_code , off_t , void *, size_t , void (*swapFunc)(void *) = 0, +ReadAttrResult ReadAttr(const BNode*, const char* hostAttrName, const char* foreignAttrName, + type_code , off_t , void*, size_t , void (*swapFunc)(void*) = 0, bool isForeign = false); // Endian swapping ReadAttr call; endianness is determined by trying first the // native attribute name, then the foreign one; an endian swapping function can // be passed, if null data won't be swapped; if set the foreign endianness // will be read directly without first trying the native one -ReadAttrResult GetAttrInfo(const BNode *, const char *hostAttrName, const char *foreignAttrName, - type_code * = NULL, size_t * = NULL); +ReadAttrResult GetAttrInfo(const BNode*, const char* hostAttrName, const char* foreignAttrName, + type_code* = NULL, size_t* = NULL); -status_t FSCreateNewFolder(const entry_ref *); -status_t FSRecursiveCreateFolder(const char *path); -void FSMakeOriginalName(BString &name, const BDirectory *destDir, const char *suffix = 0); +status_t FSCreateNewFolder(const entry_ref*); +status_t FSRecursiveCreateFolder(const char* path); +void FSMakeOriginalName(BString &name, const BDirectory* destDir, const char* suffix = 0); -status_t TrackerLaunch(const entry_ref *app, bool async); -status_t TrackerLaunch(const BMessage *refs, bool async, bool okToRunOpenWith = true); -status_t TrackerLaunch(const entry_ref *app, const BMessage *refs, bool async, +status_t TrackerLaunch(const entry_ref* app, bool async); +status_t TrackerLaunch(const BMessage* refs, bool async, bool okToRunOpenWith = true); +status_t TrackerLaunch(const entry_ref* app, const BMessage* refs, bool async, bool okToRunOpenWith = true); -status_t LaunchBrokenLink(const char *, const BMessage *); +status_t LaunchBrokenLink(const char*, const BMessage*); -status_t FSFindTrackerSettingsDir(BPath *, bool autoCreate = true); +status_t FSFindTrackerSettingsDir(BPath*, bool autoCreate = true); -bool FSIsDeskDir(const BEntry *); +bool FSIsDeskDir(const BEntry*); // two separate ifYouDoAction and toDoAction versions are needed for localization // purposes. The first one is used in "If you do action ..." sentence, // the second one in the "To do action" sentence. -bool ConfirmChangeIfWellKnownDirectory(const BEntry *entry, - const char *ifYouDoAction, const char *toDoAction, - const char *toConfirmAction, bool dontAsk = false, - int32 *confirmedAlready = NULL); +bool ConfirmChangeIfWellKnownDirectory(const BEntry* entry, + const char* ifYouDoAction, const char* toDoAction, + const char* toConfirmAction, bool dontAsk = false, + int32* confirmedAlready = NULL); -bool CheckDevicesEqual(const entry_ref *entry, const Model *targetModel); +bool CheckDevicesEqual(const entry_ref* entry, const Model* targetModel); // Deprecated calls use newer calls above instead -_IMPEXP_TRACKER void FSLaunchItem(const entry_ref *, BMessage * = NULL, int32 workspace = -1); -_IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref *, BMessage *, +_IMPEXP_TRACKER void FSLaunchItem(const entry_ref*, BMessage* = NULL, int32 workspace = -1); +_IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref*, BMessage*, int32 workspace, bool asynch); -_IMPEXP_TRACKER void FSOpenWithDocuments(const entry_ref *executableToLaunch, - BMessage *documentEntryRefs); -_IMPEXP_TRACKER status_t FSLaunchUsing(const entry_ref *ref, BMessage *listOfRefs); +_IMPEXP_TRACKER void FSOpenWithDocuments(const entry_ref* executableToLaunch, + BMessage* documentEntryRefs); +_IMPEXP_TRACKER status_t FSLaunchUsing(const entry_ref* ref, BMessage* listOfRefs); // some extra directory_which values @@ -278,7 +279,7 @@ class WellKnowEntryList { // system hierarchy public: struct WellKnownEntry { - WellKnownEntry(const node_ref *node, directory_which which, const char *name) + WellKnownEntry(const node_ref* node, directory_which which, const char* name) : node(*node), which(which), @@ -304,20 +305,20 @@ class WellKnowEntryList { BString name; }; - static directory_which Match(const node_ref *); - static const WellKnownEntry *MatchEntry(const node_ref *); + static directory_which Match(const node_ref*); + static const WellKnownEntry* MatchEntry(const node_ref*); static void Quit(); private: - const WellKnownEntry *MatchEntryCommon(const node_ref *); + const WellKnownEntry* MatchEntryCommon(const node_ref*); WellKnowEntryList(); - void AddOne(directory_which, const char *name); - void AddOne(directory_which, const char *path, const char *name); - void AddOne(directory_which, directory_which base, const char *extension, - const char *name); + void AddOne(directory_which, const char* name); + void AddOne(directory_which, const char* path, const char* name); + void AddOne(directory_which, directory_which base, const char* extension, + const char* name); std::vector entries; - static WellKnowEntryList *self; + static WellKnowEntryList* self; }; #if B_BEOS_VERSION_DANO @@ -328,4 +329,4 @@ class WellKnowEntryList { using namespace BPrivate; -#endif /* FS_UTILS_H */ +#endif // FS_UTILS_H diff --git a/src/kits/tracker/FavoritesMenu.cpp b/src/kits/tracker/FavoritesMenu.cpp index 0e716622cf..44a0924840 100644 --- a/src/kits/tracker/FavoritesMenu.cpp +++ b/src/kits/tracker/FavoritesMenu.cpp @@ -60,9 +60,9 @@ All rights reserved. #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "FavoritesMenu" -FavoritesMenu::FavoritesMenu(const char *title, BMessage *openFolderMessage, - BMessage *openFileMessage, const BMessenger &target, - bool isSavePanel, BRefFilter *filter) +FavoritesMenu::FavoritesMenu(const char* title, BMessage* openFolderMessage, + BMessage* openFileMessage, const BMessenger &target, + bool isSavePanel, BRefFilter* filter) : BSlowMenu(title), fOpenFolderMessage(openFolderMessage), fOpenFileMessage(openFileMessage), @@ -84,7 +84,7 @@ FavoritesMenu::~FavoritesMenu() void -FavoritesMenu::SetRefFilter(BRefFilter *filter) +FavoritesMenu::SetRefFilter(BRefFilter* filter) { fRefFilter = filter; } @@ -138,7 +138,7 @@ FavoritesMenu::AddNextItem() if (startModel.IsQuery()) fContainer = new QueryEntryListCollection(&startModel); else - fContainer = new DirectoryEntryList(*dynamic_cast + fContainer = new DirectoryEntryList(*dynamic_cast (startModel.Node())); ThrowOnInitCheckError(fContainer); @@ -162,7 +162,7 @@ FavoritesMenu::AddNextItem() if (!ShouldShowModel(&model)) return true; - BMenuItem *item = BNavMenu::NewModelItem(&model, + BMenuItem* item = BNavMenu::NewModelItem(&model, model.IsDirectory() ? fOpenFolderMessage : fOpenFileMessage, fTarget); @@ -214,7 +214,7 @@ FavoritesMenu::AddNextItem() if (!ShouldShowModel(&model)) return true; - BMenuItem *item = BNavMenu::NewModelItem(&model, fOpenFileMessage, fTarget); + BMenuItem* item = BNavMenu::NewModelItem(&model, fOpenFileMessage, fTarget); if (item) { if (!fAddedSeparatorForSection) { fAddedSeparatorForSection = true; @@ -262,7 +262,7 @@ FavoritesMenu::AddNextItem() if (!ShouldShowModel(&model)) return true; - BMenuItem *item = BNavMenu::NewModelItem(&model, fOpenFolderMessage, + BMenuItem* item = BNavMenu::NewModelItem(&model, fOpenFolderMessage, fTarget, true); if (item) { if (!fAddedSeparatorForSection) { @@ -302,7 +302,7 @@ FavoritesMenu::ClearMenuBuildingState() bool -FavoritesMenu::ShouldShowModel(const Model *model) +FavoritesMenu::ShouldShowModel(const Model* model) { if (fIsSavePanel && model->IsFile()) return false; @@ -321,7 +321,8 @@ FavoritesMenu::ShouldShowModel(const Model *model) // #pragma mark - -RecentsMenu::RecentsMenu(const char *name,int32 which,uint32 what,BHandler *target) +RecentsMenu::RecentsMenu(const char* name, int32 which, uint32 what, + BHandler* target) : BNavMenu(name, what, target), fWhich(which), fRecentsCount(0), @@ -356,7 +357,7 @@ RecentsMenu::StartBuildingItemList() { int32 count = CountItems()-1; for (int32 index = count; index >= 0; index--) { - BMenuItem *item = ItemAt(index); + BMenuItem* item = ItemAt(index); ASSERT(item); RemoveItem(index); @@ -413,7 +414,7 @@ RecentsMenu::AddRecents(int32 count) if (ref.name && strlen(ref.name) > 0) { Model model(&ref, true); - ModelMenuItem *item = BNavMenu::NewModelItem(&model, + ModelMenuItem* item = BNavMenu::NewModelItem(&model, new BMessage(fMessage.what), Target(), false, NULL, TypesList()); @@ -459,4 +460,3 @@ RecentsMenu::ClearMenuBuildingState() fMenuBuilt = false; BNavMenu::ClearMenuBuildingState(); } - diff --git a/src/kits/tracker/FavoritesMenu.h b/src/kits/tracker/FavoritesMenu.h index df68e52aaf..4a416f7424 100644 --- a/src/kits/tracker/FavoritesMenu.h +++ b/src/kits/tracker/FavoritesMenu.h @@ -31,15 +31,16 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef __FAVORITES_MENU__ #define __FAVORITES_MENU__ + #include #include "NavMenu.h" #include "ObjectList.h" + class BRefFilter; namespace BPrivate { @@ -48,28 +49,29 @@ class EntryListBase; #define kGoDirectory "Tracker/Go" + class FavoritesMenu : public BSlowMenu { // FavoritesMenu is used in the FilePanel - // displays recent files, recent folders and favorites items public: - FavoritesMenu(const char *title, BMessage *openFolderMessage, - BMessage *openFileMessage, const BMessenger &, - bool isSavePanel, BRefFilter *filter = NULL); + FavoritesMenu(const char* title, BMessage* openFolderMessage, + BMessage* openFileMessage, const BMessenger &, + bool isSavePanel, BRefFilter* filter = NULL); virtual ~FavoritesMenu(); - void SetRefFilter(BRefFilter *filter); + void SetRefFilter(BRefFilter* filter); private: // override the necessary SlowMenu hooks virtual bool StartBuildingItemList(); virtual bool AddNextItem(); - virtual void DoneBuildingItemList(); + virtual void DoneBuildingItemList(); virtual void ClearMenuBuildingState(); - bool ShouldShowModel(const Model *model); + bool ShouldShowModel(const Model* model); - BMessage *fOpenFolderMessage; - BMessage *fOpenFileMessage; + BMessage* fOpenFolderMessage; + BMessage* fOpenFileMessage; BMessenger fTarget; enum State { @@ -89,12 +91,12 @@ class FavoritesMenu : public BSlowMenu { // next inserted item BMessage fItems; - EntryListBase *fContainer; - BObjectList *fItemList; + EntryListBase* fContainer; + BObjectList* fItemList; int32 fInitialItemCount; std::vector fUniqueRefCheck; bool fIsSavePanel; - BRefFilter *fRefFilter; + BRefFilter* fRefFilter; typedef BSlowMenu _inherited; }; @@ -106,22 +108,23 @@ enum recent_type { kRecentFolders = 2 }; + class RecentsMenu : public BNavMenu { public: - RecentsMenu(const char *name,int32 which,uint32 what,BHandler *target); + RecentsMenu(const char* name,int32 which,uint32 what,BHandler* target); void DetachedFromWindow(); - int32 RecentsCount(); + int32 RecentsCount(); - private: + private: virtual bool StartBuildingItemList(); virtual bool AddNextItem(); bool AddRecents(int32 count); - virtual void DoneBuildingItemList(); + virtual void DoneBuildingItemList(); virtual void ClearMenuBuildingState(); - private: + private: int32 fWhich; int32 fRecentsCount; diff --git a/src/kits/tracker/FilePanel.cpp b/src/kits/tracker/FilePanel.cpp index 4c0b7af977..ae89580f9e 100644 --- a/src/kits/tracker/FilePanel.cpp +++ b/src/kits/tracker/FilePanel.cpp @@ -34,6 +34,7 @@ All rights reserved. // Implementation for the public FilePanel object. + #include #include @@ -64,6 +65,7 @@ run_open_panel() (new TFilePanel())->Show(); } + void run_save_panel() { @@ -74,9 +76,9 @@ run_save_panel() // #pragma mark - -BFilePanel::BFilePanel(file_panel_mode mode, BMessenger *target, - const entry_ref *ref, uint32 nodeFlavors, bool multipleSelection, - BMessage *message, BRefFilter *filter, bool modal, +BFilePanel::BFilePanel(file_panel_mode mode, BMessenger* target, + const entry_ref* ref, uint32 nodeFlavors, bool multipleSelection, + BMessage* message, BRefFilter* filter, bool modal, bool hideWhenDone) { // boost file descriptor limit so file panels in other apps don't have @@ -92,17 +94,19 @@ BFilePanel::BFilePanel(file_panel_mode mode, BMessenger *target, modal ? B_MODAL_APP_WINDOW_FEEL : B_NORMAL_WINDOW_FEEL, hideWhenDone); - static_cast(fWindow)->SetClientObject(this); + static_cast(fWindow)->SetClientObject(this); fWindow->SetIsFilePanel(true); } + BFilePanel::~BFilePanel() { if (fWindow->Lock()) fWindow->Quit(); } + void BFilePanel::Show() { @@ -124,6 +128,7 @@ BFilePanel::Show() fWindow->Activate(); } + void BFilePanel::Hide() { @@ -135,6 +140,7 @@ BFilePanel::Hide() fWindow->QuitRequested(); } + bool BFilePanel::IsShowing() const { @@ -147,11 +153,12 @@ BFilePanel::IsShowing() const void -BFilePanel::SendMessage(const BMessenger *messenger, BMessage *message) +BFilePanel::SendMessage(const BMessenger* messenger, BMessage* message) { messenger->SendMessage(message); } + file_panel_mode BFilePanel::PanelMode() const { @@ -159,12 +166,13 @@ BFilePanel::PanelMode() const if (!lock) return B_OPEN_PANEL; - if (static_cast(fWindow)->IsSavePanel()) + if (static_cast(fWindow)->IsSavePanel()) return B_SAVE_PANEL; return B_OPEN_PANEL; } + BMessenger BFilePanel::Messenger() const { @@ -174,9 +182,10 @@ BFilePanel::Messenger() const if (!lock) return target; - return *static_cast(fWindow)->Target(); + return *static_cast(fWindow)->Target(); } + void BFilePanel::SetTarget(BMessenger target) { @@ -184,19 +193,21 @@ BFilePanel::SetTarget(BMessenger target) if (!lock) return; - static_cast(fWindow)->SetTarget(target); + static_cast(fWindow)->SetTarget(target); } + void -BFilePanel::SetMessage(BMessage *message) +BFilePanel::SetMessage(BMessage* message) { AutoLock lock(fWindow); if (!lock) return; - static_cast(fWindow)->SetMessage(message); + static_cast(fWindow)->SetMessage(message); } + void BFilePanel::Refresh() { @@ -204,71 +215,78 @@ BFilePanel::Refresh() if (!lock) return; - static_cast(fWindow)->Refresh(); + static_cast(fWindow)->Refresh(); } -BRefFilter * + +BRefFilter* BFilePanel::RefFilter() const { AutoLock lock(fWindow); if (!lock) return 0; - return static_cast(fWindow)->Filter(); + return static_cast(fWindow)->Filter(); } + void -BFilePanel::SetRefFilter(BRefFilter *filter) +BFilePanel::SetRefFilter(BRefFilter* filter) { AutoLock lock(fWindow); if (!lock) return; - static_cast(fWindow)->SetRefFilter(filter); + static_cast(fWindow)->SetRefFilter(filter); } + void -BFilePanel::SetButtonLabel(file_panel_button button, const char *text) +BFilePanel::SetButtonLabel(file_panel_button button, const char* text) { AutoLock lock(fWindow); if (!lock) return; - static_cast(fWindow)->SetButtonLabel(button, text); + static_cast(fWindow)->SetButtonLabel(button, text); } + void -BFilePanel::GetPanelDirectory(entry_ref *ref) const +BFilePanel::GetPanelDirectory(entry_ref* ref) const { AutoLock lock(fWindow); if (!lock) return; - *ref = *static_cast(fWindow)->TargetModel()->EntryRef(); + *ref = *static_cast(fWindow)->TargetModel()->EntryRef(); } + void -BFilePanel::SetSaveText(const char *text) +BFilePanel::SetSaveText(const char* text) { AutoLock lock(fWindow); if (!lock) return; - static_cast(fWindow)->SetSaveText(text); + static_cast(fWindow)->SetSaveText(text); } + void -BFilePanel::SetPanelDirectory(const entry_ref *ref) +BFilePanel::SetPanelDirectory(const entry_ref* ref) { AutoLock lock(fWindow); if (!lock) return; - static_cast(fWindow)->SetTo(ref); + static_cast(fWindow)->SetTo(ref); } + void -BFilePanel::SetPanelDirectory(const char *path) +BFilePanel::SetPanelDirectory(const char* path) { entry_ref ref; status_t err = get_ref_for_path(path, &ref); @@ -279,11 +297,12 @@ BFilePanel::SetPanelDirectory(const char *path) if (!lock) return; - static_cast(fWindow)->SetTo(&ref); + static_cast(fWindow)->SetTo(&ref); } + void -BFilePanel::SetPanelDirectory(const BEntry *entry) +BFilePanel::SetPanelDirectory(const BEntry* entry) { entry_ref ref; @@ -291,8 +310,9 @@ BFilePanel::SetPanelDirectory(const BEntry *entry) SetPanelDirectory(&ref); } + void -BFilePanel::SetPanelDirectory(const BDirectory *dir) +BFilePanel::SetPanelDirectory(const BDirectory* dir) { BEntry entry; @@ -300,12 +320,14 @@ BFilePanel::SetPanelDirectory(const BDirectory *dir) SetPanelDirectory(&entry); } -BWindow * + +BWindow* BFilePanel::Window() const { return fWindow; } + void BFilePanel::Rewind() { @@ -313,17 +335,18 @@ BFilePanel::Rewind() if (!lock) return; - static_cast(fWindow)->Rewind(); + static_cast(fWindow)->Rewind(); } + status_t -BFilePanel::GetNextSelectedRef(entry_ref *ref) +BFilePanel::GetNextSelectedRef(entry_ref* ref) { AutoLock lock(fWindow); if (!lock) return B_ERROR; - return static_cast(fWindow)->GetNextEntryRef(ref); + return static_cast(fWindow)->GetNextEntryRef(ref); } @@ -335,9 +358,10 @@ BFilePanel::SetHideWhenDone(bool on) if (!lock) return; - static_cast(fWindow)->SetHideWhenDone(on); + static_cast(fWindow)->SetHideWhenDone(on); } + bool BFilePanel::HidesWhenDone(void) const { @@ -345,18 +369,19 @@ BFilePanel::HidesWhenDone(void) const if (!lock) return false; - return static_cast(fWindow)->HidesWhenDone(); + return static_cast(fWindow)->HidesWhenDone(); } + void BFilePanel::WasHidden() { // hook function } + void BFilePanel::SelectionChanged() { // hook function } - diff --git a/src/kits/tracker/FilePanelPriv.cpp b/src/kits/tracker/FilePanelPriv.cpp index a4a9b419b5..5131a96855 100644 --- a/src/kits/tracker/FilePanelPriv.cpp +++ b/src/kits/tracker/FilePanelPriv.cpp @@ -79,11 +79,11 @@ All rights reserved. #include -const char *kDefaultFilePanelTemplate = "FilePanelSettings"; +const char* kDefaultFilePanelTemplate = "FilePanelSettings"; static uint32 -GetLinkFlavor(const Model *model, bool resolve = true) +GetLinkFlavor(const Model* model, bool resolve = true) { if (model && model->IsSymLink()) { if (!resolve) @@ -101,17 +101,17 @@ GetLinkFlavor(const Model *model, bool resolve = true) static filter_result -key_down_filter(BMessage *message, BHandler **handler, BMessageFilter *filter) +key_down_filter(BMessage* message, BHandler** handler, BMessageFilter* filter) { - TFilePanel *panel = dynamic_cast(filter->Looper()); + TFilePanel* panel = dynamic_cast(filter->Looper()); ASSERT(panel); - BPoseView *view = panel->PoseView(); + BPoseView* view = panel->PoseView(); if (panel->TrackingMenu()) return B_DISPATCH_MESSAGE; uchar key; - if (message->FindInt8("byte", (int8 *)&key) != B_OK) + if (message->FindInt8("byte", (int8*)&key) != B_OK) return B_DISPATCH_MESSAGE; int32 modifier = 0; @@ -141,9 +141,9 @@ key_down_filter(BMessage *message, BHandler **handler, BMessageFilter *filter) #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "FilePanelPriv" -TFilePanel::TFilePanel(file_panel_mode mode, BMessenger *target, - const BEntry *startDir, uint32 nodeFlavors, bool multipleSelection, - BMessage *message, BRefFilter *filter, uint32 containerWindowFlags, +TFilePanel::TFilePanel(file_panel_mode mode, BMessenger* target, + const BEntry* startDir, uint32 nodeFlavors, bool multipleSelection, + BMessage* message, BRefFilter* filter, uint32 containerWindowFlags, window_look look, window_feel feel, bool hideWhenDone) : BContainerWindow(0, containerWindowFlags, look, feel, 0, B_CURRENT_WORKSPACE), fDirMenu(NULL), @@ -181,7 +181,7 @@ TFilePanel::TFilePanel(file_panel_mode mode, BMessenger *target, = BLocaleRoster::Default()->IsFilesystemTranslationPreferred(); // check for legal starting directory - Model *model = new Model(); + Model* model = new Model(); bool useRoot = true; if (startDir) { @@ -246,9 +246,9 @@ TFilePanel::~TFilePanel() filter_result -TFilePanel::MessageDropFilter(BMessage *message, BHandler **, BMessageFilter *filter) +TFilePanel::MessageDropFilter(BMessage* message, BHandler**, BMessageFilter* filter) { - TFilePanel *panel = dynamic_cast(filter->Looper()); + TFilePanel* panel = dynamic_cast(filter->Looper()); if (panel == NULL || !message->WasDropped()) return B_SKIP_MESSAGE; @@ -300,8 +300,8 @@ TFilePanel::MessageDropFilter(BMessage *message, BHandler **, BMessageFilter *fi panel->fTaskLoop->RunLater(NewMemberFunctionObjectWithResult (&TFilePanel::SelectChildInParent, panel, - const_cast(&ref), - const_cast(&child)), + const_cast(&ref), + const_cast(&child)), ref == *panel->TargetModel()->EntryRef() ? 0 : 100000, 200000, 5000000); // if the target directory is already current, we won't // delay the initial selection try @@ -318,20 +318,20 @@ TFilePanel::MessageDropFilter(BMessage *message, BHandler **, BMessageFilter *fi filter_result -TFilePanel::FSFilter(BMessage *message, BHandler **, BMessageFilter *filter) +TFilePanel::FSFilter(BMessage* message, BHandler**, BMessageFilter* filter) { switch (message->FindInt32("opcode")) { case B_ENTRY_MOVED: { node_ref itemNode; node_ref dirNode; - TFilePanel *panel = dynamic_cast(filter->Looper()); + TFilePanel* panel = dynamic_cast(filter->Looper()); message->FindInt32("device", &dirNode.device); itemNode.device = dirNode.device; - message->FindInt64("to directory", (int64 *)&dirNode.node); - message->FindInt64("node", (int64 *)&itemNode.node); - const char *name; + message->FindInt64("to directory", (int64*)&dirNode.node); + message->FindInt64("node", (int64*)&itemNode.node); + const char* name; if (message->FindString("name", &name) != B_OK) break; @@ -347,9 +347,9 @@ TFilePanel::FSFilter(BMessage *message, BHandler **, BMessageFilter *filter) case B_ENTRY_REMOVED: { node_ref itemNode; - TFilePanel *panel = dynamic_cast(filter->Looper()); + TFilePanel* panel = dynamic_cast(filter->Looper()); message->FindInt32("device", &itemNode.device); - message->FindInt64("node", (int64 *)&itemNode.node); + message->FindInt64("node", (int64*)&itemNode.node); // if folder we're watching is deleted, switch to root // or Desktop @@ -379,7 +379,7 @@ TFilePanel::FSFilter(BMessage *message, BHandler **, BMessageFilter *filter) void -TFilePanel::DispatchMessage(BMessage *message, BHandler *handler) +TFilePanel::DispatchMessage(BMessage* message, BHandler* handler) { _inherited::DispatchMessage(message, handler); if (message->what == B_KEY_DOWN || message->what == B_MOUSE_DOWN) @@ -387,11 +387,11 @@ TFilePanel::DispatchMessage(BMessage *message, BHandler *handler) } -BFilePanelPoseView * +BFilePanelPoseView* TFilePanel::PoseView() const { - ASSERT(dynamic_cast(fPoseView)); - return static_cast(fPoseView); + ASSERT(dynamic_cast(fPoseView)); + return static_cast(fPoseView); } @@ -421,7 +421,7 @@ TFilePanel::QuitRequested() } -BRefFilter * +BRefFilter* TFilePanel::Filter() const { return fPoseView->RefFilter(); @@ -436,7 +436,7 @@ TFilePanel::SetTarget(BMessenger target) void -TFilePanel::SetMessage(BMessage *message) +TFilePanel::SetMessage(BMessage* message) { delete fMessage; fMessage = new BMessage(*message); @@ -444,7 +444,7 @@ TFilePanel::SetMessage(BMessage *message) void -TFilePanel::SetRefFilter(BRefFilter *filter) +TFilePanel::SetRefFilter(BRefFilter* filter) { if (!filter) return; @@ -452,7 +452,7 @@ TFilePanel::SetRefFilter(BRefFilter *filter) fPoseView->SetRefFilter(filter); fPoseView->CommitActivePose(); fPoseView->Refresh(); - FavoritesMenu* menu = dynamic_cast + FavoritesMenu* menu = dynamic_cast (fMenuBar->FindItem(B_TRANSLATE("Favorites"))->Submenu()); if (menu) menu->SetRefFilter(filter); @@ -460,7 +460,7 @@ TFilePanel::SetRefFilter(BRefFilter *filter) void -TFilePanel::SetTo(const entry_ref *ref) +TFilePanel::SetTo(const entry_ref* ref) { if (!ref) return; @@ -493,7 +493,7 @@ TFilePanel::Rewind() void -TFilePanel::SetClientObject(BFilePanel *panel) +TFilePanel::SetClientObject(BFilePanel* panel) { fClientObject = panel; } @@ -503,12 +503,12 @@ void TFilePanel::AdjustButton() { // adjust button state - BButton *button = dynamic_cast(FindView("default button")); + BButton* button = dynamic_cast(FindView("default button")); if (!button) return; - BTextControl *textControl = dynamic_cast(FindView("text view")); - BObjectList *selectionList = fPoseView->SelectionList(); + BTextControl* textControl = dynamic_cast(FindView("text view")); + BObjectList* selectionList = fPoseView->SelectionList(); BString buttonText = fButtonText; bool enabled = false; @@ -517,7 +517,7 @@ TFilePanel::AdjustButton() if (fPoseView->IsFocus()) { fPoseView->ShowSelection(true); if (selectionList->CountItems() == 1) { - Model *model = selectionList->FirstItem()->TargetModel(); + Model* model = selectionList->FirstItem()->TargetModel(); if (model->ResolveIfLink()->IsDirectory()) { enabled = true; buttonText = B_TRANSLATE("Open"); @@ -536,7 +536,7 @@ TFilePanel::AdjustButton() // go through selection list looking at content for (int32 index = 0; index < count; index++) { - Model *model = selectionList->ItemAt(index)->TargetModel(); + Model* model = selectionList->ItemAt(index)->TargetModel(); uint32 modelFlavor = GetLinkFlavor(model, false); uint32 linkFlavor = GetLinkFlavor(model, true); @@ -573,12 +573,12 @@ TFilePanel::SelectionChanged() status_t -TFilePanel::GetNextEntryRef(entry_ref *ref) +TFilePanel::GetNextEntryRef(entry_ref* ref) { if (!ref) return B_ERROR; - BPose *pose = fPoseView->SelectionList()->ItemAt(fSelectionIterator++); + BPose* pose = fPoseView->SelectionList()->ItemAt(fSelectionIterator++); if (!pose) return B_ERROR; @@ -587,15 +587,15 @@ TFilePanel::GetNextEntryRef(entry_ref *ref) } -BPoseView * -TFilePanel::NewPoseView(Model *model, BRect rect, uint32) +BPoseView* +TFilePanel::NewPoseView(Model* model, BRect rect, uint32) { return new BFilePanelPoseView(model, rect); } void -TFilePanel::Init(const BMessage *) +TFilePanel::Init(const BMessage*) { BRect windRect(Bounds()); AddChild(fBackView = new BackgroundView(windRect)); @@ -628,7 +628,7 @@ TFilePanel::Init(const BMessage *) item = fMenuBar->FindItem(B_TRANSLATE("File")); if (item) { - BMenu *menu = item->Submenu(); + BMenu* menu = item->Submenu(); if (menu) { item = menu->FindItem(kOpenSelection); if (item && menu->RemoveItem(item)) @@ -753,7 +753,7 @@ TFilePanel::Init(const BMessage *) float default_width = be_plain_font->StringWidth(fButtonText.String()) + 20; rect.left = (default_width > 75) ? (rect.right - default_width) : (rect.right - 75); - BButton *default_button = new BButton(rect, "default button", fButtonText.String(), + BButton* default_button = new BButton(rect, "default button", fButtonText.String(), new BMessage(kDefaultButton), B_FOLLOW_RIGHT + B_FOLLOW_BOTTOM); fBackView->AddChild(default_button); @@ -836,13 +836,13 @@ TFilePanel::SaveState(BMessage &message) const void -TFilePanel::RestoreWindowState(AttributeStreamNode *node) +TFilePanel::RestoreWindowState(AttributeStreamNode* node) { SetSizeLimits(360, 10000, 200, 10000); if (!node) return; - const char *rectAttributeName = kAttrWindowFrame; + const char* rectAttributeName = kAttrWindowFrame; BRect frame(Frame()); if (node->Read(rectAttributeName, 0, B_RECT_TYPE, sizeof(BRect), &frame) == sizeof(BRect)) { @@ -867,7 +867,7 @@ TFilePanel::RestoreWindowState(const BMessage &message) void -TFilePanel::AddFileContextMenus(BMenu *menu) +TFilePanel::AddFileContextMenus(BMenu* menu) { menu->AddItem(new BMenuItem(B_TRANSLATE("Get info"), new BMessage(kGetInfo), 'I')); @@ -889,7 +889,7 @@ TFilePanel::AddFileContextMenus(BMenu *menu) void -TFilePanel::AddVolumeContextMenus(BMenu *menu) +TFilePanel::AddVolumeContextMenus(BMenu* menu) { menu->AddItem(new BMenuItem(B_TRANSLATE("Open"), new BMessage(kOpenSelection), 'O')); @@ -908,7 +908,7 @@ TFilePanel::AddVolumeContextMenus(BMenu *menu) void -TFilePanel::AddWindowContextMenus(BMenu *menu) +TFilePanel::AddWindowContextMenus(BMenu* menu) { BMenuItem* item = new BMenuItem(B_TRANSLATE("New folder"), new BMessage(kNewFolder), 'N'); @@ -944,7 +944,7 @@ TFilePanel::AddWindowContextMenus(BMenu *menu) void -TFilePanel::AddDropContextMenus(BMenu *) +TFilePanel::AddDropContextMenus(BMenu*) { } @@ -975,7 +975,7 @@ TFilePanel::MenusEnded() void -TFilePanel::ShowContextMenu(BPoint point, const entry_ref *ref, BView *view) +TFilePanel::ShowContextMenu(BPoint point, const entry_ref* ref, BView* view) { EnableNamedMenuItem(fWindowContextMenu, kNewFolder, !TargetModel()->IsRoot()); EnableNamedMenuItem(fWindowContextMenu, kOpenParentDir, !TargetModel()->IsRoot()); @@ -986,19 +986,19 @@ TFilePanel::ShowContextMenu(BPoint point, const entry_ref *ref, BView *view) void -TFilePanel::SetupNavigationMenu(const entry_ref *, BMenu *) +TFilePanel::SetupNavigationMenu(const entry_ref*, BMenu*) { // do nothing here so nav menu doesn't get added } void -TFilePanel::SetButtonLabel(file_panel_button selector, const char *text) +TFilePanel::SetButtonLabel(file_panel_button selector, const char* text) { switch (selector) { case B_CANCEL_BUTTON: { - BButton *button = dynamic_cast(FindView("cancel button")); + BButton* button = dynamic_cast(FindView("cancel button")); if (!button) break; @@ -1016,7 +1016,7 @@ TFilePanel::SetButtonLabel(file_panel_button selector, const char *text) { fButtonText = text; float delta = 0; - BButton *button = dynamic_cast(FindView("default button")); + BButton* button = dynamic_cast(FindView("default button")); if (button) { float old_width = button->StringWidth(button->Label()); button->SetLabel(text); @@ -1028,7 +1028,7 @@ TFilePanel::SetButtonLabel(file_panel_button selector, const char *text) } // now must move cancel button - button = dynamic_cast(FindView("cancel button")); + button = dynamic_cast(FindView("cancel button")); if (button) button->MoveBy(delta, 0); } @@ -1038,19 +1038,19 @@ TFilePanel::SetButtonLabel(file_panel_button selector, const char *text) void -TFilePanel::SetSaveText(const char *text) +TFilePanel::SetSaveText(const char* text) { if (!text) return; - BTextControl *textControl = dynamic_cast(FindView("text view")); + BTextControl* textControl = dynamic_cast(FindView("text view")); textControl->SetText(text); textControl->TextView()->SelectAll(); } void -TFilePanel::MessageReceived(BMessage *message) +TFilePanel::MessageReceived(BMessage* message) { entry_ref ref; @@ -1075,7 +1075,7 @@ TFilePanel::MessageReceived(BMessage *message) // Otherwise, we have a file or a link to a file. // AdjustButton has already tested the flavor; // all we have to do is see if the button is enabled. - BButton *button = dynamic_cast(FindView("default button")); + BButton* button = dynamic_cast(FindView("default button")); if (!button) break; @@ -1199,7 +1199,7 @@ TFilePanel::MessageReceived(BMessage *message) if (fIsSavePanel) { if (PoseView()->IsFocus() && PoseView()->SelectionList()->CountItems() == 1) { - Model *model = (PoseView()->SelectionList()->FirstItem())->TargetModel(); + Model* model = (PoseView()->SelectionList()->FirstItem())->TargetModel(); if (model->ResolveIfLink()->IsDirectory()) { PoseView()->CommitActivePose(); PoseView()->OpenSelection(); @@ -1239,11 +1239,11 @@ TFilePanel::MessageReceived(BMessage *message) void TFilePanel::OpenDirectory() { - BObjectList *list = PoseView()->SelectionList(); + BObjectList* list = PoseView()->SelectionList(); if (list->CountItems() != 1) return; - Model *model = list->FirstItem()->TargetModel(); + Model* model = list->FirstItem()->TargetModel(); if (model->ResolveIfLink()->IsDirectory()) { BMessage message(B_REFS_RECEIVED); message.AddRef("refs", model->EntryRef()); @@ -1280,7 +1280,7 @@ TFilePanel::OpenParent() // shows up fTaskLoop->RunLater(NewMemberFunctionObjectWithResult (&TFilePanel::SelectChildInParent, this, - const_cast(&ref), + const_cast(&ref), oldModel.NodeRef()), 100000, 200000, 5000000); } } @@ -1334,7 +1334,7 @@ TFilePanel::SwitchDirToDesktopIfNeeded(entry_ref &ref) bool -TFilePanel::SelectChildInParent(const entry_ref *, const node_ref *child) +TFilePanel::SelectChildInParent(const entry_ref*, const node_ref* child) { AutoLock lock(this); @@ -1342,7 +1342,7 @@ TFilePanel::SelectChildInParent(const entry_ref *, const node_ref *child) return false; int32 index; - BPose *pose = PoseView()->FindPose(child, &index); + BPose* pose = PoseView()->FindPose(child, &index); if (!pose) return false; @@ -1355,10 +1355,10 @@ TFilePanel::SelectChildInParent(const entry_ref *, const node_ref *child) int32 -TFilePanel::ShowCenteredAlert(const char *text, const char *button1, - const char *button2, const char *button3) +TFilePanel::ShowCenteredAlert(const char* text, const char* button1, + const char* button2, const char* button3) { - BAlert *alert = new BAlert("", text, button1, button2, button3, + BAlert* alert = new BAlert("", text, button1, button2, button3, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->MoveTo(Frame().left + 10, Frame().top + 10); @@ -1447,7 +1447,7 @@ TFilePanel::HandleSaveButton() void -TFilePanel::OpenSelectionCommon(BMessage *openMessage) +TFilePanel::OpenSelectionCommon(BMessage* openMessage) { if (!openMessage->HasRef("refs")) return; @@ -1483,12 +1483,12 @@ void TFilePanel::HandleOpenButton() { PoseView()->CommitActivePose(); - BObjectList *selection = PoseView()->SelectionList(); + BObjectList* selection = PoseView()->SelectionList(); // if we have only one directory and we're not opening dirs, enter. if ((fNodeFlavors & B_DIRECTORY_NODE) == 0 && selection->CountItems() == 1) { - Model *model = selection->FirstItem()->TargetModel(); + Model* model = selection->FirstItem()->TargetModel(); if (model->IsDirectory() || (model->IsSymLink() && !(fNodeFlavors & B_SYMLINK_NODE) @@ -1507,7 +1507,7 @@ TFilePanel::HandleOpenButton() BMessage message(*fMessage); // go through selection and add appropriate items for (int32 index = 0; index < selection->CountItems(); index++) { - Model *model = selection->ItemAt(index)->TargetModel(); + Model* model = selection->ItemAt(index)->TargetModel(); if (((fNodeFlavors & B_DIRECTORY_NODE) != 0 && model->ResolveIfLink()->IsDirectory()) @@ -1522,7 +1522,7 @@ TFilePanel::HandleOpenButton() void -TFilePanel::SwitchDirMenuTo(const entry_ref *ref) +TFilePanel::SwitchDirMenuTo(const entry_ref* ref) { BEntry entry(ref); for (int32 index = fDirMenu->CountItems() - 1; index >= 0; index--) @@ -1531,7 +1531,7 @@ TFilePanel::SwitchDirMenuTo(const entry_ref *ref) fDirMenuField->MenuBar()->RemoveItem((int32)0); fDirMenu->Populate(&entry, 0, true, true, false, true); - ModelMenuItem *item = dynamic_cast( + ModelMenuItem* item = dynamic_cast( fDirMenuField->MenuBar()->ItemAt(0)); ASSERT(item); item->SetEntry(&entry); @@ -1550,7 +1550,7 @@ TFilePanel::WindowActivated(bool active) // #pragma mark - -BFilePanelPoseView::BFilePanelPoseView(Model *model, BRect frame, uint32 resizeMask) +BFilePanelPoseView::BFilePanelPoseView(Model* model, BRect frame, uint32 resizeMask) : BPoseView(model, frame, kListMode, resizeMask), fIsDesktop(model->IsDesktop()) { @@ -1580,7 +1580,7 @@ BFilePanelPoseView::StopWatching() bool -BFilePanelPoseView::FSNotification(const BMessage *message) +BFilePanelPoseView::FSNotification(const BMessage* message) { if (IsDesktopView()) { // Pretty much copied straight from DesktopPoseView. Would be better @@ -1613,7 +1613,7 @@ BFilePanelPoseView::FSNotification(const BMessage *message) void -BFilePanelPoseView::RestoreState(AttributeStreamNode *node) +BFilePanelPoseView::RestoreState(AttributeStreamNode* node) { _inherited::RestoreState(node); fViewState->SetViewMode(kListMode); @@ -1628,13 +1628,13 @@ BFilePanelPoseView::RestoreState(const BMessage &message) void -BFilePanelPoseView::SavePoseLocations(BRect *) +BFilePanelPoseView::SavePoseLocations(BRect*) { } -EntryListBase * -BFilePanelPoseView::InitDirentIterator(const entry_ref *ref) +EntryListBase* +BFilePanelPoseView::InitDirentIterator(const entry_ref* ref) { if (IsDesktopView()) return DesktopPoseView::InitDesktopDirentIterator(this, ref); @@ -1677,14 +1677,14 @@ BFilePanelPoseView::ShowVolumes(bool visible, bool showShared) } - TFilePanel *filepanel = dynamic_cast(Window()); + TFilePanel* filepanel = dynamic_cast(Window()); if (filepanel) filepanel->SetTo(TargetModel()->EntryRef()); } void -BFilePanelPoseView::AdaptToVolumeChange(BMessage *message) +BFilePanelPoseView::AdaptToVolumeChange(BMessage* message) { bool showDisksIcon; bool mountVolumesOnDesktop; @@ -1719,7 +1719,7 @@ BFilePanelPoseView::AdaptToVolumeChange(BMessage *message) void -BFilePanelPoseView::AdaptToDesktopIntegrationChange(BMessage *message) +BFilePanelPoseView::AdaptToDesktopIntegrationChange(BMessage* message) { bool mountVolumesOnDesktop = true; bool mountSharedVolumesOntoDesktop = true; @@ -1730,4 +1730,3 @@ BFilePanelPoseView::AdaptToDesktopIntegrationChange(BMessage *message) ShowVolumes(false, mountSharedVolumesOntoDesktop); ShowVolumes(mountVolumesOnDesktop, mountSharedVolumesOntoDesktop); } - diff --git a/src/kits/tracker/FilePanelPriv.h b/src/kits/tracker/FilePanelPriv.h index 7756980c63..b9de5c944b 100644 --- a/src/kits/tracker/FilePanelPriv.h +++ b/src/kits/tracker/FilePanelPriv.h @@ -31,16 +31,17 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef _FILE_PANEL_PRIV_H #define _FILE_PANEL_PRIV_H + #include #include "ContainerWindow.h" #include "PoseView.h" #include "TaskLoop.h" + class BTextControl; class BFilePanel; class BRefFilter; @@ -57,9 +58,9 @@ class BFilePanelPoseView; class TFilePanel : public BContainerWindow { public: TFilePanel(file_panel_mode = B_OPEN_PANEL, - BMessenger *target = NULL, const BEntry *startDirectory = NULL, + BMessenger* target = NULL, const BEntry* startDirectory = NULL, uint32 nodeFlavors = B_FILE_NODE | B_SYMLINK_NODE, - bool multipleSelection = true, BMessage * = NULL, BRefFilter * = NULL, + bool multipleSelection = true, BMessage* = NULL, BRefFilter* = NULL, uint32 containerWindowFlags = 0, window_look look = B_DOCUMENT_WINDOW_LOOK, window_feel feel = B_NORMAL_WINDOW_FEEL, @@ -67,33 +68,33 @@ public: virtual ~TFilePanel(); - BFilePanelPoseView *PoseView() const; + BFilePanelPoseView* PoseView() const; virtual bool QuitRequested(); virtual void MenusBeginning(); - virtual void MenusEnded(); - virtual void DispatchMessage(BMessage *message, BHandler *handler); - virtual void ShowContextMenu(BPoint, const entry_ref *, BView *); + virtual void MenusEnded(); + virtual void DispatchMessage(BMessage* message, BHandler* handler); + virtual void ShowContextMenu(BPoint, const entry_ref*, BView*); - void SetClientObject(BFilePanel *); - void SetRefFilter(BRefFilter *); - void SetSaveText(const char *text); - void SetButtonLabel(file_panel_button, const char *text); - void SetTo(const entry_ref *ref); + void SetClientObject(BFilePanel*); + void SetRefFilter(BRefFilter*); + void SetSaveText(const char* text); + void SetButtonLabel(file_panel_button, const char* text); + void SetTo(const entry_ref* ref); virtual void SelectionChanged(); - void HandleOpenButton(); - void HandleSaveButton(); - void Rewind(); - bool IsSavePanel() const; - void Refresh(); - const BMessenger *Target() const; - BRefFilter *Filter() const; + void HandleOpenButton(); + void HandleSaveButton(); + void Rewind(); + bool IsSavePanel() const; + void Refresh(); + const BMessenger* Target() const; + BRefFilter* Filter() const; void SetTarget(BMessenger); - void SetMessage(BMessage *message); + void SetMessage(BMessage* message); - virtual status_t GetNextEntryRef(entry_ref *); - virtual void MessageReceived(BMessage *); + virtual status_t GetNextEntryRef(entry_ref*); + virtual void MessageReceived(BMessage*); void SetHideWhenDone(bool); bool HidesWhenDone(void); @@ -101,96 +102,97 @@ public: bool TrackingMenu() const; protected: - BPoseView *NewPoseView(Model *model, BRect rect, uint32 viewMode); - virtual void Init(const BMessage *message = NULL); + BPoseView* NewPoseView(Model* model, BRect rect, uint32 viewMode); + virtual void Init(const BMessage* message = NULL); virtual void SaveState(bool hide = true); virtual void SaveState(BMessage &) const; virtual void RestoreState(); - virtual void RestoreWindowState(AttributeStreamNode *); - virtual void RestoreWindowState(const BMessage &); - virtual void RestoreState(const BMessage &); + virtual void RestoreWindowState(AttributeStreamNode*); + virtual void RestoreWindowState(const BMessage&); + virtual void RestoreState(const BMessage&); - virtual void AddFileContextMenus(BMenu *); - virtual void AddWindowContextMenus(BMenu *); - virtual void AddDropContextMenus(BMenu *); - virtual void AddVolumeContextMenus(BMenu *); + virtual void AddFileContextMenus(BMenu*); + virtual void AddWindowContextMenus(BMenu*); + virtual void AddDropContextMenus(BMenu*); + virtual void AddVolumeContextMenus(BMenu*); - virtual void SetupNavigationMenu(const entry_ref *, BMenu *); - virtual void OpenDirectory(); - virtual void OpenParent(); + virtual void SetupNavigationMenu(const entry_ref*, BMenu*); + virtual void OpenDirectory(); + virtual void OpenParent(); virtual void WindowActivated(bool state); - static filter_result FSFilter(BMessage *, BHandler **, BMessageFilter *); - static filter_result MessageDropFilter(BMessage *, BHandler **, BMessageFilter *); - int32 ShowCenteredAlert(const char *text, const char *button1, const char *button2 = NULL, - const char *button3 = NULL); + static filter_result FSFilter(BMessage*, BHandler**, BMessageFilter*); + static filter_result MessageDropFilter(BMessage*, BHandler**, BMessageFilter*); + int32 ShowCenteredAlert(const char* text, const char* button1, + const char* button2 = NULL, const char* button3 = NULL); private: - bool SwitchDirToDesktopIfNeeded(entry_ref &ref); - bool CanOpenParent() const; - void SwitchDirMenuTo(const entry_ref *ref); - void AdjustButton(); - bool SelectChildInParent(const entry_ref *parent, const node_ref *child); - void OpenSelectionCommon(BMessage *); + bool SwitchDirToDesktopIfNeeded(entry_ref &ref); + bool CanOpenParent() const; + void SwitchDirMenuTo(const entry_ref* ref); + void AdjustButton(); + bool SelectChildInParent(const entry_ref* parent, + const node_ref* child); + void OpenSelectionCommon(BMessage*); + bool fIsSavePanel; + uint32 fNodeFlavors; + BackgroundView* fBackView; + BDirMenu* fDirMenu; + BMenuField* fDirMenuField; + BTextControl* fTextControl; + BMessenger fTarget; + BFilePanel* fClientObject; + int32 fSelectionIterator; + BMessage* fMessage; + BString fButtonText; + bool fHideWhenDone; + bool fIsTrackingMenu; - bool fIsSavePanel; - uint32 fNodeFlavors; - BackgroundView *fBackView; - BDirMenu *fDirMenu; - BMenuField *fDirMenuField; - BTextControl *fTextControl; - BMessenger fTarget; - BFilePanel *fClientObject; - int32 fSelectionIterator; - BMessage *fMessage; - BString fButtonText; - bool fHideWhenDone; - bool fIsTrackingMenu; + typedef BContainerWindow _inherited; - typedef BContainerWindow _inherited; - -friend class BackgroundView; + friend class BackgroundView; }; class BFilePanelPoseView : public BPoseView { public: - BFilePanelPoseView(Model *, BRect, uint32 resizeMask = B_FOLLOW_ALL); + BFilePanelPoseView(Model*, BRect, uint32 resizeMask = B_FOLLOW_ALL); virtual bool IsFilePanel() const; - virtual bool FSNotification(const BMessage *); + virtual bool FSNotification(const BMessage*); void SetIsDesktop(bool); protected: // don't do any volume watching and memtamime watching in file panels for now - virtual void StartWatching(); - virtual void StopWatching(); + virtual void StartWatching(); + virtual void StopWatching(); - virtual void RestoreState(AttributeStreamNode *); - virtual void RestoreState(const BMessage &); - virtual void SavePoseLocations(BRect * = NULL); + virtual void RestoreState(AttributeStreamNode*); + virtual void RestoreState(const BMessage &); + virtual void SavePoseLocations(BRect* = NULL); - virtual EntryListBase *InitDirentIterator(const entry_ref *); - virtual void AddPosesCompleted(); - virtual bool IsDesktopView() const; + virtual EntryListBase* InitDirentIterator(const entry_ref*); + virtual void AddPosesCompleted(); + virtual bool IsDesktopView() const; - void ShowVolumes(bool visible, bool showShared); + void ShowVolumes(bool visible, bool showShared); - void AdaptToVolumeChange(BMessage *); - void AdaptToDesktopIntegrationChange(BMessage *); + void AdaptToVolumeChange(BMessage*); + void AdaptToDesktopIntegrationChange(BMessage*); private: - bool fIsDesktop; - // this flags makes the distinction between the Desktop as the Root of - // the world and "/boot/home/Desktop" to which we might have navigated - // from the home dir + bool fIsDesktop; + // This flags makes the distinction between the Desktop as + // the root of the world and "/boot/home/Desktop" to which + // we might have navigated from the home dir. - typedef BPoseView _inherited; + typedef BPoseView _inherited; }; + // inlines follow inline bool @@ -199,36 +201,42 @@ BFilePanelPoseView::IsFilePanel() const return true; } + inline bool TFilePanel::IsSavePanel() const { return fIsSavePanel; } -inline const BMessenger * + +inline const BMessenger* TFilePanel::Target() const { return &fTarget; } + inline void TFilePanel::Refresh() { fPoseView->Refresh(); } + inline bool TFilePanel::HidesWhenDone(void) { return fHideWhenDone; } + inline void TFilePanel::SetHideWhenDone(bool on) { fHideWhenDone = on; } + inline bool TFilePanel::TrackingMenu() const { diff --git a/src/kits/tracker/FilePermissionsView.cpp b/src/kits/tracker/FilePermissionsView.cpp index 069ceecb8c..6efe30810c 100644 --- a/src/kits/tracker/FilePermissionsView.cpp +++ b/src/kits/tracker/FilePermissionsView.cpp @@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include "FilePermissionsView.h" #include @@ -50,7 +51,7 @@ const uint32 kNewGroupEntered = 'nwgr'; #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "FilePermissionsView" -FilePermissionsView::FilePermissionsView(BRect rect, Model *model) +FilePermissionsView::FilePermissionsView(BRect rect, Model* model) : BView(rect, "FilePermissionsView", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW), fModel(model) { @@ -58,7 +59,7 @@ FilePermissionsView::FilePermissionsView(BRect rect, Model *model) const float kColumnLabelMiddle = 77, kColumnLabelTop = 6, kColumnLabelSpacing = 37, kColumnLabelBottom = 20, kColumnLabelWidth = 35, kAttribFontHeight = 10; - BStringView *strView; + BStringView* strView; strView = new BStringView(BRect(kColumnLabelMiddle - kColumnLabelWidth / 2, kColumnLabelTop, kColumnLabelMiddle + kColumnLabelWidth / 2, kColumnLabelBottom), @@ -116,7 +117,7 @@ FilePermissionsView::FilePermissionsView(BRect rect, Model *model) kHorizontalSpacing = kColumnLabelSpacing, kVerticalSpacing = kRowLabelVerticalSpacing, kCheckBoxWidth = 18, kCheckBoxHeight = 18; - FocusCheckBox **checkBoxArray[3][3] = { + FocusCheckBox** checkBoxArray[3][3] = { { &fReadUserCheckBox, &fReadGroupCheckBox, &fReadOtherCheckBox }, { &fWriteUserCheckBox, &fWriteGroupCheckBox, &fWriteOtherCheckBox }, { &fExecuteUserCheckBox, &fExecuteGroupCheckBox, &fExecuteOtherCheckBox }}; @@ -172,7 +173,7 @@ FilePermissionsView::FilePermissionsView(BRect rect, Model *model) void -FilePermissionsView::ModelChanged(Model *model) +FilePermissionsView::ModelChanged(Model* model) { fModel = model; @@ -270,7 +271,7 @@ FilePermissionsView::ModelChanged(Model *model) void -FilePermissionsView::MessageReceived(BMessage *message) +FilePermissionsView::MessageReceived(BMessage* message) { switch(message->what) { case kPermissionsChanged: @@ -358,4 +359,3 @@ FilePermissionsView::AttachedToWindow() fOwnerTextControl->SetTarget(this); fGroupTextControl->SetTarget(this); } - diff --git a/src/kits/tracker/FilePermissionsView.h b/src/kits/tracker/FilePermissionsView.h index a3f00c3542..06ce35469f 100644 --- a/src/kits/tracker/FilePermissionsView.h +++ b/src/kits/tracker/FilePermissionsView.h @@ -31,21 +31,22 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef FILE_PERMISSIONS_VIEW_H #define FILE_PERMISSIONS_VIEW_H + #include #include #include "Model.h" + namespace BPrivate { class FocusCheckBox : public BCheckBox { public: - FocusCheckBox(BRect rect, const char *name, const char *label, - BMessage *message) + FocusCheckBox(BRect rect, const char* name, const char* label, + BMessage* message) : BCheckBox(rect, name, label, message) { } @@ -56,44 +57,46 @@ class FocusCheckBox : public BCheckBox { if (IsFocus()) { SetHighColor(0, 0, 255); - StrokeRect(BRect(2 , 4, 12, 14)); - } + StrokeRect(BRect(2 , 4, 12, 14)); + } } }; + class FilePermissionsView : public BView { public: - FilePermissionsView(BRect, Model *); + FilePermissionsView(BRect, Model*); - void ModelChanged(Model *); + void ModelChanged(Model*); protected: - virtual void MessageReceived(BMessage *); + virtual void MessageReceived(BMessage*); virtual void AttachedToWindow(); private: - Model *fModel; + Model* fModel; - FocusCheckBox *fReadUserCheckBox; - FocusCheckBox *fReadGroupCheckBox; - FocusCheckBox *fReadOtherCheckBox; + FocusCheckBox* fReadUserCheckBox; + FocusCheckBox* fReadGroupCheckBox; + FocusCheckBox* fReadOtherCheckBox; - FocusCheckBox *fWriteUserCheckBox; - FocusCheckBox *fWriteGroupCheckBox; - FocusCheckBox *fWriteOtherCheckBox; + FocusCheckBox* fWriteUserCheckBox; + FocusCheckBox* fWriteGroupCheckBox; + FocusCheckBox* fWriteOtherCheckBox; - FocusCheckBox *fExecuteUserCheckBox; - FocusCheckBox *fExecuteGroupCheckBox; - FocusCheckBox *fExecuteOtherCheckBox; + FocusCheckBox* fExecuteUserCheckBox; + FocusCheckBox* fExecuteGroupCheckBox; + FocusCheckBox* fExecuteOtherCheckBox; - BTextControl *fOwnerTextControl; - BTextControl *fGroupTextControl; + BTextControl* fOwnerTextControl; + BTextControl* fGroupTextControl; typedef BView _inherited; }; + } // namespace BPrivate using namespace BPrivate; -#endif /* FILE_PERMISSIONS_VIEW_H */ +#endif // FILE_PERMISSIONS_VIEW_H diff --git a/src/kits/tracker/FindPanel.cpp b/src/kits/tracker/FindPanel.cpp index 1f74cf32cd..55643e2a4b 100644 --- a/src/kits/tracker/FindPanel.cpp +++ b/src/kits/tracker/FindPanel.cpp @@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include #include #include @@ -79,7 +80,7 @@ All rights reserved. #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "FindPanel" -const char *kAllMimeTypes = "mime/ALLTYPES"; +const char* kAllMimeTypes = "mime/ALLTYPES"; const BRect kInitialRect(100, 100, 530, 210); const int32 kInitialAttrModeWindowHeight = 140; @@ -94,7 +95,7 @@ const uint32 kRunSaveAsTemplatePanel = 'svtm'; const char* kDragNDropTypes [] = { B_QUERY_MIMETYPE, B_QUERY_TEMPLATE_MIMETYPE }; -static const char *kDragNDropActionSpecifiers [] = { +static const char* kDragNDropActionSpecifiers [] = { B_TRANSLATE_MARK("Create a Query"), B_TRANSLATE_MARK("Create a Query template") }; @@ -105,26 +106,26 @@ namespace BPrivate { class MostUsedNames { public: - MostUsedNames(const char *fileName, const char *directory, int32 maxCount = 5); + MostUsedNames(const char* fileName, const char* directory, int32 maxCount = 5); ~MostUsedNames(); - bool ObtainList(BList *list); + bool ObtainList(BList* list); void ReleaseList(); - void AddName(const char *); + void AddName(const char*); protected: struct list_entry { - char *name; + char* name; int32 count; }; - static int CompareNames(const void *a, const void *b); + static int CompareNames(const void* a, const void* b); void LoadList(); void UpdateList(); - const char *fFileName; - const char *fDirectory; + const char* fFileName; + const char* fDirectory; bool fLoaded; mutable Benaphore fLock; BList fList; @@ -135,14 +136,14 @@ MostUsedNames gMostUsedMimeTypes("MostUsedMimeTypes", "Tracker"); void -MoreOptionsStruct::EndianSwap(void *) +MoreOptionsStruct::EndianSwap(void*) { // noop for now } void -MoreOptionsStruct::SetQueryTemporary(BNode *node, bool on) +MoreOptionsStruct::SetQueryTemporary(BNode* node, bool on) { MoreOptionsStruct saveMoreOptions; @@ -156,7 +157,7 @@ MoreOptionsStruct::SetQueryTemporary(BNode *node, bool on) bool -MoreOptionsStruct::QueryTemporary(const BNode *node) +MoreOptionsStruct::QueryTemporary(const BNode* node) { MoreOptionsStruct saveMoreOptions; @@ -229,13 +230,13 @@ FindWindow::~FindWindow() } -BFile * -FindWindow::TryOpening(const entry_ref *ref) +BFile* +FindWindow::TryOpening(const entry_ref* ref) { if (!ref) return NULL; - BFile *result = new BFile(ref, O_RDWR); + BFile* result = new BFile(ref, O_RDWR); if (result->InitCheck() != B_OK) { delete result; result = NULL; @@ -258,7 +259,7 @@ FindWindow::GetDefaultQuery(BEntry &entry) bool -FindWindow::IsQueryTemplate(BNode *file) +FindWindow::IsQueryTemplate(BNode* file) { char type[B_MIME_TYPE_LENGTH]; if (BNodeInfo(file).GetType(type) != B_OK) @@ -269,7 +270,7 @@ FindWindow::IsQueryTemplate(BNode *file) void -FindWindow::SwitchToTemplate(const entry_ref *ref) +FindWindow::SwitchToTemplate(const entry_ref* ref) { try { BEntry entry(ref, true); @@ -287,7 +288,7 @@ FindWindow::SwitchToTemplate(const entry_ref *ref) } -const char * +const char* FindWindow::QueryName() const { if (fFromTemplate) { @@ -303,7 +304,7 @@ FindWindow::QueryName() const } -static const char * +static const char* MakeValidFilename(BString &string) { // make a file name that is legal under bfs and hfs - possibly could @@ -315,7 +316,7 @@ MakeValidFilename(BString &string) // replace slashes int32 length = string.Length(); - char *buf = string.LockBuffer(length); + char* buf = string.LockBuffer(length); for (int32 index = length; index-- > 0;) if (buf[index] == '/' /*|| buf[index] == ':'*/) buf[index] = '_'; @@ -329,7 +330,7 @@ void FindWindow::GetPredicateString(BString &predicate, bool &dynamicDate) { BQuery query; - BTextControl *textControl = dynamic_cast(FindView("TextControl")); + BTextControl* textControl = dynamic_cast(FindView("TextControl")); switch (fBackground->Mode()) { case kByNameItem: fBackground->GetByNamePredicate(&query); @@ -367,7 +368,7 @@ FindWindow::GetDefaultName(BString &result) void -FindWindow::SaveQueryAttributes(BNode *file, bool queryTemplate) +FindWindow::SaveQueryAttributes(BNode* file, bool queryTemplate) { ThrowOnError( BNodeInfo(file).SetType( queryTemplate ? B_QUERY_TEMPLATE_MIMETYPE : B_QUERY_MIMETYPE) ); @@ -381,8 +382,8 @@ FindWindow::SaveQueryAttributes(BNode *file, bool queryTemplate) status_t -FindWindow::SaveQueryAsAttributes(BNode *file, BEntry *entry, bool queryTemplate, - const BMessage *oldAttributes, const BPoint *oldLocation) +FindWindow::SaveQueryAsAttributes(BNode* file, BEntry* entry, bool queryTemplate, + const BMessage* oldAttributes, const BPoint* oldLocation) { if (oldAttributes) // revive old window settings @@ -407,7 +408,7 @@ FindWindow::SaveQueryAsAttributes(BNode *file, BEntry *entry, bool queryTemplate file->WriteAttr("_trk/recentQuery", B_INT32_TYPE, 0, &tmp, sizeof(int32)); // write some useful info to help locate the volume to query - BMenuItem *item = fBackground->VolMenu()->FindMarked(); + BMenuItem* item = fBackground->VolMenu()->FindMarked(); if (item) { dev_t dev; BMessage message; @@ -415,7 +416,7 @@ FindWindow::SaveQueryAsAttributes(BNode *file, BEntry *entry, bool queryTemplate int32 itemCount = fBackground->VolMenu()->CountItems(); for (int32 index = 2; index < itemCount; index++) { - BMenuItem *item = fBackground->VolMenu()->ItemAt(index); + BMenuItem* item = fBackground->VolMenu()->ItemAt(index); if (!item->IsMarked()) continue; @@ -448,17 +449,17 @@ FindWindow::SaveQueryAsAttributes(BNode *file, BEntry *entry, bool queryTemplate // write out all the dialog items as attributes so that the query can // be reopened and edited later - BView *focusedItem = CurrentFocus(); + BView* focusedItem = CurrentFocus(); if (focusedItem) { // text controls never get the focus, their internal text views do - BView *parent = focusedItem->Parent(); - if (dynamic_cast(parent)) + BView* parent = focusedItem->Parent(); + if (dynamic_cast(parent)) focusedItem = parent; // write out the current focus and, if text control, selection BString name(focusedItem->Name()); file->WriteAttrString("_trk/focusedView", &name); - BTextControl *textControl = dynamic_cast(focusedItem); + BTextControl* textControl = dynamic_cast(focusedItem); if (textControl) { int32 selStart, selEnd; textControl->TextView()->GetSelection(&selStart, &selEnd); @@ -488,7 +489,7 @@ FindWindow::Find() if (!FindSaveCommon(true)) { // have to wait for the node monitor to force old query to close // to avoid a race condition - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); ASSERT(tracker); for (int32 timeOut = 0; ; timeOut++) { if (!tracker->EntryHasWindowOpen(&fRef)) @@ -533,7 +534,7 @@ FindWindow::FindSaveCommon(bool find) BMessage oldAttributes; BPoint location; bool hadLocation = false; - const char *userSpecifiedName = fBackground->UserSpecifiedName(); + const char* userSpecifiedName = fBackground->UserSpecifiedName(); if (readFromOldFile) { entry.SetTo(&fRef); @@ -587,7 +588,7 @@ FindWindow::FindSaveCommon(bool find) void -FindWindow::MessageReceived(BMessage *message) +FindWindow::MessageReceived(BMessage* message) { switch (message->what) { case kFindButton: @@ -601,7 +602,7 @@ FindWindow::MessageReceived(BMessage *message) case kAttachFile: { entry_ref dir; - const char *name; + const char* name; bool queryTemplate; if (message->FindString("name", &name) == B_OK && message->FindRef("directory", &dir) == B_OK @@ -657,7 +658,7 @@ FindWindow::MessageReceived(BMessage *message) // #pragma mark - -FindPanel::FindPanel(BRect frame, BFile *node, FindWindow *parent, +FindPanel::FindPanel(BRect frame, BFile* node, FindWindow* parent, bool , bool editTemplateOnly) : BView(frame, "MainView", B_FOLLOW_ALL, B_WILL_DRAW), fMode(kByNameItem), @@ -714,7 +715,7 @@ FindPanel::FindPanel(BRect frame, BFile *node, FindWindow *parent, rect.left = rect.right + 10; rect.right = rect.left + 100; rect.bottom = rect.top + 15; - BMenuField *menuField = new BMenuField(rect, "", "", fSearchModeMenu); + BMenuField* menuField = new BMenuField(rect, "", "", fSearchModeMenu); menuField->SetDivider(0.0f); AddChild(menuField); @@ -811,7 +812,7 @@ FindPanel::FindPanel(BRect frame, BFile *node, FindWindow *parent, rect.top = rect.bottom - 30; rect.right = rect.left + 60; rect.bottom = rect.top + 20; - BButton *button; + BButton* button; if (editTemplateOnly) { button = new BButton(rect, "save", B_TRANSLATE("Save"), new BMessage(kSaveButton), B_FOLLOW_RIGHT + B_FOLLOW_BOTTOM); @@ -832,7 +833,7 @@ FindPanel::~FindPanel() void FindPanel::AttachedToWindow() { - BNode *node = dynamic_cast(Window())->QueryNode(); + BNode* node = dynamic_cast(Window())->QueryNode(); fSearchModeMenu->SetTargetForItems(this); fQueryName->SetTarget(this); fLatch->SetTarget(fMoreOptionsPane); @@ -844,22 +845,22 @@ FindPanel::AttachedToWindow() if (!Window()->CurrentFocus()) { // try to pick a good focus if we restore to one already - BTextControl *textControl = dynamic_cast(FindView("TextControl")); + BTextControl* textControl = dynamic_cast(FindView("TextControl")); if (!textControl) { // pick the last text control in the attribute view BString title("TextEntry"); title << (fAttrViewList.CountItems() - 1); - textControl = dynamic_cast(FindView(title.String())); + textControl = dynamic_cast(FindView(title.String())); } if (textControl) textControl->MakeFocus(); } - BButton *button = dynamic_cast(FindView("remove")); + BButton* button = dynamic_cast(FindView("remove")); if (button) button->SetTarget(this); - button = dynamic_cast(FindView("add")); + button = dynamic_cast(FindView("add")); if (button) button->SetTarget(this); @@ -867,7 +868,7 @@ FindPanel::AttachedToWindow() // set target for MIME type items for (int32 index = MimeTypeMenu()->CountItems();index-- > 2;) { - BMenu *submenu = MimeTypeMenu()->ItemAt(index)->Submenu(); + BMenu* submenu = MimeTypeMenu()->ItemAt(index)->Submenu(); if (submenu != NULL) submenu->SetTargetForItems(this); } @@ -883,7 +884,7 @@ FindPanel::AttachedToWindow() const float kAttrViewDelta = 30; BRect -FindPanel::InitialViewSize(const BNode *node) +FindPanel::InitialViewSize(const BNode* node) { if (!node || InitialMode(node) != (int32)kByAttributeItem) return kInitialRect; @@ -936,10 +937,10 @@ FindPanel::BoxHeightForMode(uint32 mode, bool /*moreOptions*/) static void -PopUpMenuSetTitle(BMenu *menu, const char *title) +PopUpMenuSetTitle(BMenu* menu, const char* title) { // This should really be in BMenuField - BMenu *bar = menu->Supermenu(); + BMenu* bar = menu->Supermenu(); ASSERT(bar); ASSERT(bar->ItemAt(0)); @@ -962,9 +963,9 @@ FindPanel::ShowVolumeMenuLabel() // find out if more than one items are marked int32 count = fVolMenu->CountItems(); int32 countSelected = 0; - BMenuItem *tmpItem = NULL; + BMenuItem* tmpItem = NULL; for (int32 index = 2; index < count; index++) { - BMenuItem *item = fVolMenu->ItemAt(index); + BMenuItem* item = fVolMenu->ItemAt(index); if (item->IsMarked()) { countSelected++; tmpItem = item; @@ -989,24 +990,24 @@ FindPanel::ShowVolumeMenuLabel() void -FindPanel::MessageReceived(BMessage *message) +FindPanel::MessageReceived(BMessage* message) { entry_ref dir; - const char *name; + const char* name; switch (message->what) { case kVolumeItem: { // volume changed - BMenuItem *invokedItem; + BMenuItem* invokedItem; dev_t dev; - if (message->FindPointer("source", (void **)&invokedItem) != B_OK) + if (message->FindPointer("source", (void**)&invokedItem) != B_OK) return; if (message->FindInt32("device", &dev) != B_OK) break; - BMenu *menu = invokedItem->Menu(); + BMenu* menu = invokedItem->Menu(); ASSERT(menu); if (dev == -1) { @@ -1027,7 +1028,7 @@ FindPanel::MessageReceived(BMessage *message) // toggle mark on invoked item int32 count = menu->CountItems(); for (int32 index = 2; index < count; index++) { - BMenuItem *item = menu->ItemAt(index); + BMenuItem* item = menu->ItemAt(index); if (invokedItem == item) { // we just selected this @@ -1058,8 +1059,8 @@ FindPanel::MessageReceived(BMessage *message) case kMIMETypeItem: { - BMenuItem *item; - if (message->FindPointer("source", (void **)&item) == B_OK) { + BMenuItem* item; + if (message->FindPointer("source", (void**)&item) == B_OK) { // don't add the "All files and folders" to the list if (fMimeTypeMenu->IndexOf(item) != 0) gMostUsedMimeTypes.AddName(item->Label()); @@ -1077,7 +1078,7 @@ FindPanel::MessageReceived(BMessage *message) Window()->ResizeTo(Window()->Frame().Width(), ViewHeightForMode(kByAttributeItem, fLatch->Value() != 0)); - BBox *box = dynamic_cast(FindView("Box")); + BBox* box = dynamic_cast(FindView("Box")); ASSERT(box); box->ResizeTo(box->Bounds().Width(), BoxHeightForMode(kByAttributeItem, fLatch->Value() != 0)); @@ -1119,9 +1120,9 @@ FindPanel::MessageReceived(BMessage *message) case B_COPY_TARGET: { // finish drag&drop - const char *str; - const char *mimeType = NULL; - const char *actionSpecifier = NULL; + const char* str; + const char* mimeType = NULL; + const char* actionSpecifier = NULL; if (message->FindString("be:types", &str) == B_OK && strcasecmp(str, B_FILE_MIME_TYPE) == 0 && (message->FindString("be:actionspecifier", &actionSpecifier) == B_OK @@ -1162,7 +1163,7 @@ FindPanel::MessageReceived(BMessage *message) void -FindPanel::SaveAsQueryOrTemplate(const entry_ref *dir, const char *name, bool queryTemplate) +FindPanel::SaveAsQueryOrTemplate(const entry_ref* dir, const char* name, bool queryTemplate) { BDirectory directory(dir); BFile file(&directory, name, O_RDWR | O_CREAT | O_TRUNC); @@ -1177,35 +1178,35 @@ FindPanel::SaveAsQueryOrTemplate(const entry_ref *dir, const char *name, bool qu void -FindPanel::BuildAttrQuery(BQuery *query, bool &dynamicDate) const +FindPanel::BuildAttrQuery(BQuery* query, bool &dynamicDate) const { dynamicDate = false; // go through each attrview and add the attr and comparison info for (int32 index = 0; index < fAttrViewList.CountItems(); index++) { - TAttrView *view = fAttrViewList.ItemAt(index); + TAttrView* view = fAttrViewList.ItemAt(index); BString title; title << "TextEntry" << index; - BTextControl *textControl = dynamic_cast + BTextControl* textControl = dynamic_cast (view->FindView(title.String())); if (!textControl) return; - BMenuField *menuField = dynamic_cast(view->FindView("MenuField")); + BMenuField* menuField = dynamic_cast(view->FindView("MenuField")); if (!menuField) return; - BMenuItem *item = menuField->Menu()->FindMarked(); + BMenuItem* item = menuField->Menu()->FindMarked(); if (!item) continue; - BMessage *message = item->Message(); + BMessage* message = item->Message(); int32 type; if (message->FindInt32("type", &type) == B_OK) { - const char *str; + const char* str; if (message->FindString("name", &str) == B_OK) query->PushAttr(str); else @@ -1286,22 +1287,22 @@ FindPanel::BuildAttrQuery(BQuery *query, bool &dynamicDate) const } query_op theOperator; - BMenuItem *operatorItem = item->Submenu()->FindMarked(); + BMenuItem* operatorItem = item->Submenu()->FindMarked(); if (operatorItem && operatorItem->Message() != NULL) { - operatorItem->Message()->FindInt32("operator", (int32 *)&theOperator); + operatorItem->Message()->FindInt32("operator", (int32*)&theOperator); query->PushOp(theOperator); } else query->PushOp(B_EQ); // add logic based on selection in Logic menufield if (index > 0) { - TAttrView *prevView = fAttrViewList.ItemAt(index - 1); - menuField = dynamic_cast(prevView->FindView("Logic")); + TAttrView* prevView = fAttrViewList.ItemAt(index - 1); + menuField = dynamic_cast(prevView->FindView("Logic")); if (menuField) { item = menuField->Menu()->FindMarked(); if (item) { message = item->Message(); - message->FindInt32("combine", (int32 *)&theOperator); + message->FindInt32("combine", (int32*)&theOperator); query->PushOp(theOperator); } } else @@ -1312,9 +1313,9 @@ FindPanel::BuildAttrQuery(BQuery *query, bool &dynamicDate) const void -FindPanel::PushMimeType(BQuery *query) const +FindPanel::PushMimeType(BQuery* query) const { - const char *type; + const char* type; if (CurrentMimeType(&type) == NULL) return; @@ -1336,7 +1337,7 @@ FindPanel::PushMimeType(BQuery *query) const void -FindPanel::GetByAttrPredicate(BQuery *query, bool &dynamicDate) const +FindPanel::GetByAttrPredicate(BQuery* query, bool &dynamicDate) const { ASSERT(Mode() == (int32)kByAttributeItem); BuildAttrQuery(query, dynamicDate); @@ -1347,7 +1348,7 @@ FindPanel::GetByAttrPredicate(BQuery *query, bool &dynamicDate) const void FindPanel::GetDefaultName(BString &result) const { - BTextControl *textControl = dynamic_cast(FindView("TextControl")); + BTextControl* textControl = dynamic_cast(FindView("TextControl")); switch (Mode()) { case kByNameItem: result.SetTo(B_TRANSLATE_COMMENT("Name = %name", @@ -1363,7 +1364,7 @@ FindPanel::GetDefaultName(BString &result) const case kByAttributeItem: { - BMenuItem *item = fMimeTypeMenu->FindMarked(); + BMenuItem* item = fMimeTypeMenu->FindMarked(); if (item != NULL) result << item->Label() << ": "; @@ -1378,7 +1379,7 @@ FindPanel::GetDefaultName(BString &result) const } -const char * +const char* FindPanel::UserSpecifiedName() const { if (fQueryName->Text()[0] == '\0') @@ -1389,10 +1390,10 @@ FindPanel::UserSpecifiedName() const void -FindPanel::GetByNamePredicate(BQuery *query) const +FindPanel::GetByNamePredicate(BQuery* query) const { ASSERT(Mode() == (int32)kByNameItem); - BTextControl *textControl = dynamic_cast(FindView("TextControl")); + BTextControl* textControl = dynamic_cast(FindView("TextControl")); ASSERT(textControl); query->PushAttr("name"); @@ -1415,7 +1416,7 @@ FindPanel::SwitchMode(uint32 mode) // no work, bail return; - BBox *box = dynamic_cast(FindView("Box")); + BBox* box = dynamic_cast(FindView("Box")); ASSERT(box); uint32 oldMode = fMode; @@ -1453,7 +1454,7 @@ FindPanel::SwitchMode(uint32 mode) if (buffer.Length()) { ASSERT(mode == kByFormulaItem || oldMode == kByAttributeItem); - BTextControl *textControl = dynamic_cast + BTextControl* textControl = dynamic_cast (FindView("TextControl")); textControl->SetText(buffer.String()); } @@ -1469,7 +1470,7 @@ FindPanel::SwitchMode(uint32 mode) Window()->ResizeTo(Window()->Frame().Width(), ViewHeightForMode(mode, fLatch->Value() != 0)); - BTextControl *textControl = dynamic_cast + BTextControl* textControl = dynamic_cast (FindView("TextControl")); if (textControl) { @@ -1485,11 +1486,11 @@ FindPanel::SwitchMode(uint32 mode) } -BMenuItem * -FindPanel::CurrentMimeType(const char **type) const +BMenuItem* +FindPanel::CurrentMimeType(const char** type) const { // search for marked item in the list - BMenuItem *item = MimeTypeMenu()->FindMarked(); + BMenuItem* item = MimeTypeMenu()->FindMarked(); // if it's one of the most used items, ignore it if (item != NULL && MimeTypeMenu()->IndexOf(item) != 0 && item->Submenu() == NULL) @@ -1497,14 +1498,14 @@ FindPanel::CurrentMimeType(const char **type) const if (item == NULL) { for (int32 index = MimeTypeMenu()->CountItems(); index-- > 0;) { - BMenu *submenu = MimeTypeMenu()->ItemAt(index)->Submenu(); + BMenu* submenu = MimeTypeMenu()->ItemAt(index)->Submenu(); if (submenu != NULL && (item = submenu->FindMarked()) != NULL) break; } } if (type && item != NULL) { - BMessage *message = item->Message(); + BMessage* message = item->Message(); if (!message) return NULL; @@ -1516,11 +1517,11 @@ FindPanel::CurrentMimeType(const char **type) const status_t -FindPanel::SetCurrentMimeType(BMenuItem *item) +FindPanel::SetCurrentMimeType(BMenuItem* item) { // unmark old MIME type (in most used list, and the tree) - BMenuItem *marked = CurrentMimeType(); + BMenuItem* marked = CurrentMimeType(); if (marked != NULL) { marked->SetMarked(false); @@ -1534,7 +1535,7 @@ FindPanel::SetCurrentMimeType(BMenuItem *item) item->SetMarked(true); fMimeTypeField->MenuItem()->SetLabel(item->Label()); - BMenuItem *search; + BMenuItem* search; for (int32 i = 2;(search = MimeTypeMenu()->ItemAt(i)) != NULL;i++) { if (item == search || !search->Label()) continue; @@ -1542,10 +1543,10 @@ FindPanel::SetCurrentMimeType(BMenuItem *item) search->SetMarked(true); break; } - BMenu *submenu = search->Submenu(); + BMenu* submenu = search->Submenu(); if (submenu) { for (int32 j = submenu->CountItems();j-- > 0;) { - BMenuItem *sub = submenu->ItemAt(j); + BMenuItem* sub = submenu->ItemAt(j); if (!strcmp(item->Label(),sub->Label())) { sub->SetMarked(true); break; @@ -1559,11 +1560,11 @@ FindPanel::SetCurrentMimeType(BMenuItem *item) status_t -FindPanel::SetCurrentMimeType(const char *label) +FindPanel::SetCurrentMimeType(const char* label) { // unmark old MIME type (in most used list, and the tree) - BMenuItem *marked = CurrentMimeType(); + BMenuItem* marked = CurrentMimeType(); if (marked != NULL) { marked->SetMarked(false); @@ -1577,11 +1578,11 @@ FindPanel::SetCurrentMimeType(const char *label) bool found = false; for (int32 index = MimeTypeMenu()->CountItems(); index-- > 0;) { - BMenuItem *item = MimeTypeMenu()->ItemAt(index); - BMenu *submenu = item->Submenu(); + BMenuItem* item = MimeTypeMenu()->ItemAt(index); + BMenu* submenu = item->Submenu(); if (submenu != NULL && !found) { for (int32 subIndex = submenu->CountItems(); subIndex-- > 0;) { - BMenuItem *subItem = submenu->ItemAt(subIndex); + BMenuItem* subItem = submenu->ItemAt(subIndex); if (subItem->Label() != NULL && !strcmp(label, subItem->Label())) { subItem->SetMarked(true); found = true; @@ -1599,9 +1600,9 @@ FindPanel::SetCurrentMimeType(const char *label) bool -FindPanel::AddOneMimeTypeToMenu(const ShortMimeInfo *info, void *castToMenu) +FindPanel::AddOneMimeTypeToMenu(const ShortMimeInfo* info, void* castToMenu) { - BPopUpMenu *menu = static_cast(castToMenu); + BPopUpMenu* menu = static_cast(castToMenu); BMimeType type(info->InternalName()); BMimeType super; @@ -1609,9 +1610,9 @@ FindPanel::AddOneMimeTypeToMenu(const ShortMimeInfo *info, void *castToMenu) if (super.InitCheck() < B_OK) return false; - BMenuItem *superItem = menu->FindItem(super.Type()); + BMenuItem* superItem = menu->FindItem(super.Type()); if (superItem != NULL) { - BMessage *msg = new BMessage(kMIMETypeItem); + BMessage* msg = new BMessage(kMIMETypeItem); msg->AddString("mimetype", info->InternalName()); superItem->Submenu()->AddItem(new IconMenuItem(info->ShortDescription(), @@ -1625,7 +1626,7 @@ FindPanel::AddOneMimeTypeToMenu(const ShortMimeInfo *info, void *castToMenu) void FindPanel::AddMimeTypesToMenu() { - BMessage *itemMessage = new BMessage(kMIMETypeItem); + BMessage* itemMessage = new BMessage(kMIMETypeItem); itemMessage->AddString("mimetype", kAllMimeTypes); MimeTypeMenu()->AddItem(new BMenuItem(B_TRANSLATE("All files and folders"), itemMessage)); @@ -1634,19 +1635,19 @@ FindPanel::AddMimeTypesToMenu() // add recent MIME types - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); BList list; if (gMostUsedMimeTypes.ObtainList(&list) && tracker) { int32 count = 0; for (int32 index = 0; index < list.CountItems(); index++) { - const char *name = (const char *)list.ItemAt(index); + const char* name = (const char*)list.ItemAt(index); - const ShortMimeInfo *info; + const ShortMimeInfo* info; if ((info = tracker->MimeTypes()->FindMimeType(name)) == NULL) continue; - BMessage *message = new BMessage(kMIMETypeItem); + BMessage* message = new BMessage(kMIMETypeItem); message->AddString("mimetype", info->InternalName()); MimeTypeMenu()->AddItem(new BMenuItem(name, message)); @@ -1662,13 +1663,13 @@ FindPanel::AddMimeTypesToMenu() BMessage types; if (BMimeType::GetInstalledSupertypes(&types) == B_OK) { - const char *superType; + const char* superType; int32 index = 0; while (types.FindString("super_types",index++,&superType) == B_OK) { - BMenu *superMenu = new BMenu(superType); + BMenu* superMenu = new BMenu(superType); - BMessage *message = new BMessage(kMIMETypeItem); + BMessage* message = new BMessage(kMIMETypeItem); message->AddString("mimetype", superType); MimeTypeMenu()->AddItem(new IconMenuItem(superMenu, message, @@ -1686,8 +1687,8 @@ FindPanel::AddMimeTypesToMenu() // remove empty super type menus (and set target) for (int32 index = MimeTypeMenu()->CountItems();index-- > 2;) { - BMenuItem *item = MimeTypeMenu()->ItemAt(index); - BMenu *submenu = item->Submenu(); + BMenuItem* item = MimeTypeMenu()->ItemAt(index); + BMenu* submenu = item->Submenu(); if (submenu != NULL) { if (submenu->CountItems() == 0) { MimeTypeMenu()->RemoveItem(item); @@ -1702,11 +1703,11 @@ FindPanel::AddMimeTypesToMenu() void -FindPanel::AddVolumes(BMenu *menu) +FindPanel::AddVolumes(BMenu* menu) { // ToDo: add calls to this to rebuild the menu when a volume gets mounted - BMessage *message = new BMessage(kVolumeItem); + BMessage* message = new BMessage(kVolumeItem); message->AddInt32("device", -1); menu->AddItem(new BMenuItem(B_TRANSLATE("All disks"), message)); menu->AddSeparatorItem(); @@ -1744,30 +1745,30 @@ FindPanel::AddVolumes(BMenu *menu) typedef std::pair EntryWithDate; static int -SortByDatePredicate(const EntryWithDate *entry1, const EntryWithDate *entry2) +SortByDatePredicate(const EntryWithDate* entry1, const EntryWithDate* entry2) { return entry1->second > entry2->second ? -1 : (entry1->second == entry2->second ? 0 : 1); } struct AddOneRecentParams { - BMenu *menu; - const BMessenger *target; + BMenu* menu; + const BMessenger* target; uint32 what; }; -static const entry_ref * -AddOneRecentItem(const entry_ref *ref, void *castToParams) +static const entry_ref* +AddOneRecentItem(const entry_ref* ref, void* castToParams) { - AddOneRecentParams *params = (AddOneRecentParams *)castToParams; + AddOneRecentParams* params = (AddOneRecentParams*)castToParams; - BMessage *message = new BMessage(params->what); + BMessage* message = new BMessage(params->what); message->AddRef("refs", ref); char type[B_MIME_TYPE_LENGTH]; BNode node(ref); BNodeInfo(&node).GetType(type); - BMenuItem *item = new IconMenuItem(ref->name, message, type, B_MINI_ICON); + BMenuItem* item = new IconMenuItem(ref->name, message, type, B_MINI_ICON); item->SetTarget(*params->target); params->menu->AddItem(item); @@ -1776,7 +1777,7 @@ AddOneRecentItem(const entry_ref *ref, void *castToParams) void -FindPanel::AddRecentQueries(BMenu *menu, bool addSaveAsItem, const BMessenger *target, +FindPanel::AddRecentQueries(BMenu* menu, bool addSaveAsItem, const BMessenger* target, uint32 what) { BObjectList templates(10, true); @@ -1847,7 +1848,7 @@ FindPanel::AddRecentQueries(BMenu *menu, bool addSaveAsItem, const BMessenger *t if (count || templates.CountItems()) menu->AddSeparatorItem(); - BMessage *message = new BMessage(kRunSaveAsTemplatePanel); + BMessage* message = new BMessage(kRunSaveAsTemplatePanel); BMenuItem* item = new BMenuItem( B_TRANSLATE("Save Query as template"B_UTF8_ELLIPSIS), message); menu->AddItem(item); @@ -1856,9 +1857,9 @@ FindPanel::AddRecentQueries(BMenu *menu, bool addSaveAsItem, const BMessenger *t void -FindPanel::AddOneAttributeItem(BBox *box, BRect rect) +FindPanel::AddOneAttributeItem(BBox* box, BRect rect) { - TAttrView *attrView = new TAttrView(rect, fAttrViewList.CountItems()); + TAttrView* attrView = new TAttrView(rect, fAttrViewList.CountItems()); fAttrViewList.AddItem(attrView); box->AddChild(attrView); @@ -1867,10 +1868,10 @@ FindPanel::AddOneAttributeItem(BBox *box, BRect rect) void -FindPanel::SetUpAddRemoveButtons(BBox *box) +FindPanel::SetUpAddRemoveButtons(BBox* box) { - BButton *button = Window() != NULL - ? dynamic_cast(Window()->FindView("remove")) + BButton* button = Window() != NULL + ? dynamic_cast(Window()->FindView("remove")) : NULL; if (button == NULL) { BRect rect = box->Bounds(); @@ -1880,7 +1881,7 @@ FindPanel::SetUpAddRemoveButtons(BBox *box) + be_plain_font->StringWidth(B_TRANSLATE("Add")); button = new BButton(rect, "add", B_TRANSLATE("Add"), - new BMessage(kAddItem), B_FOLLOW_RIGHT + B_FOLLOW_BOTTOM); + new BMessage(kAddItem), B_FOLLOW_RIGHT + B_FOLLOW_BOTTOM); button->SetTarget(this); box->AddChild(button); @@ -1900,7 +1901,7 @@ FindPanel::SetUpAddRemoveButtons(BBox *box) void -FindPanel::FillCurrentQueryName(BTextControl *queryName, FindWindow *window) +FindPanel::FillCurrentQueryName(BTextControl* queryName, FindWindow* window) { ASSERT(window); queryName->SetText(window->QueryName()); @@ -1910,10 +1911,10 @@ FindPanel::FillCurrentQueryName(BTextControl *queryName, FindWindow *window) void FindPanel::AddAttrView() { - BBox *box = dynamic_cast(FindView("Box")); + BBox* box = dynamic_cast(FindView("Box")); BRect bounds(Bounds()); - TAttrView *previous = fAttrViewList.LastItem(); + TAttrView* previous = fAttrViewList.LastItem(); if (previous) Window()->ResizeBy(0, 30); @@ -1940,7 +1941,7 @@ FindPanel::AddAttrView() SetUpAddRemoveButtons(box); // populate mime popup - TAttrView *last = fAttrViewList.LastItem(); + TAttrView* last = fAttrViewList.LastItem(); last->AddMimeTypeAttrs(); } @@ -1951,8 +1952,8 @@ FindPanel::RemoveAttrView() if (fAttrViewList.CountItems() < 2) return; - BBox *box = dynamic_cast(FindView("Box")); - TAttrView *attrView = fAttrViewList.LastItem(); + BBox* box = dynamic_cast(FindView("Box")); + TAttrView* attrView = fAttrViewList.LastItem(); if (!box || !attrView) return; @@ -1973,21 +1974,21 @@ FindPanel::RemoveAttrView() if (fAttrViewList.CountItems() != 1) return; - BButton *button = dynamic_cast(Window()->FindView("remove")); + BButton* button = dynamic_cast(Window()->FindView("remove")); if (button) button->SetEnabled(false); } uint32 -FindPanel::InitialMode(const BNode *node) +FindPanel::InitialMode(const BNode* node) { if (!node || node->InitCheck() != B_OK) return kByNameItem; uint32 result; if (node->ReadAttr(kAttrQueryInitialMode, B_INT32_TYPE, 0, - (int32 *)&result, sizeof(int32)) <= 0) + (int32*)&result, sizeof(int32)) <= 0) return kByNameItem; return result; @@ -1995,7 +1996,7 @@ FindPanel::InitialMode(const BNode *node) int32 -FindPanel::InitialAttrCount(const BNode *node) +FindPanel::InitialAttrCount(const BNode* node) { if (!node || node->InitCheck() != B_OK) return 1; @@ -2010,10 +2011,10 @@ FindPanel::InitialAttrCount(const BNode *node) static int32 -SelectItemWithLabel(BMenu *menu, const char *label) +SelectItemWithLabel(BMenu* menu, const char* label) { for (int32 index = menu->CountItems(); index-- > 0;) { - BMenuItem *item = menu->ItemAt(index); + BMenuItem* item = menu->ItemAt(index); if (strcmp(label, item->Label()) == 0) { item->SetMarked(true); @@ -2025,11 +2026,11 @@ SelectItemWithLabel(BMenu *menu, const char *label) void -FindPanel::SaveWindowState(BNode *node, bool editTemplate) +FindPanel::SaveWindowState(BNode* node, bool editTemplate) { ASSERT(node->InitCheck() == B_OK); - BMenuItem *item = CurrentMimeType(); + BMenuItem* item = CurrentMimeType(); if (item) { BString label(item->Label()); node->WriteAttrString(kAttrQueryInitialMime, &label); @@ -2037,7 +2038,7 @@ FindPanel::SaveWindowState(BNode *node, bool editTemplate) uint32 mode = Mode(); node->WriteAttr(kAttrQueryInitialMode, B_INT32_TYPE, 0, - (int32 *)&mode, sizeof(int32)); + (int32*)&mode, sizeof(int32)); MoreOptionsStruct saveMoreOptions; saveMoreOptions.showMoreOptions = fLatch->Value() != 0; @@ -2068,7 +2069,7 @@ FindPanel::SaveWindowState(BNode *node, bool editTemplate) fAttrViewList.ItemAt(index)->SaveState(&message, index); ssize_t size = message.FlattenedSize(); - char *buffer = new char[size]; + char* buffer = new char[size]; status_t result = message.Flatten(buffer, size); if (result == B_OK) { node->WriteAttr(kAttrQueryInitialAttrs, B_MESSAGE_TYPE, 0, @@ -2081,7 +2082,7 @@ FindPanel::SaveWindowState(BNode *node, bool editTemplate) case kByNameItem: case kByFormulaItem: { - BTextControl *textControl = dynamic_cast + BTextControl* textControl = dynamic_cast (FindView("TextControl")); ASSERT(textControl); BString formula(textControl->TextView()->Text()); @@ -2093,7 +2094,7 @@ FindPanel::SaveWindowState(BNode *node, bool editTemplate) void -FindPanel::SwitchToTemplate(const BNode *node) +FindPanel::SwitchToTemplate(const BNode* node) { if (fLatch->Value()) { // this is kind of a hack - the following code up to @@ -2122,7 +2123,7 @@ FindPanel::SwitchToTemplate(const BNode *node) void -FindPanel::RestoreMimeTypeMenuSelection(const BNode *node) +FindPanel::RestoreMimeTypeMenuSelection(const BNode* node) { if (Mode() == (int32)kByFormulaItem || node == NULL || node->InitCheck() != B_OK) return; @@ -2134,7 +2135,7 @@ FindPanel::RestoreMimeTypeMenuSelection(const BNode *node) void -FindPanel::RestoreWindowState(const BNode *node) +FindPanel::RestoreWindowState(const BNode* node) { fMode = InitialMode(node); if (!node || node->InitCheck() != B_OK) @@ -2163,7 +2164,7 @@ FindPanel::RestoreWindowState(const BNode *node) fTemporaryCheck->SetValue(saveMoreOptions.temporary); fQueryName->SetModificationMessage(NULL); - FillCurrentQueryName(fQueryName, dynamic_cast(Window())); + FillCurrentQueryName(fQueryName, dynamic_cast(Window())); // set modification message after checking the temporary check box, // and filling out the text control so that we do not @@ -2176,7 +2177,7 @@ FindPanel::RestoreWindowState(const BNode *node) attr_info info; if (node->GetAttrInfo(kAttrQueryVolume, &info) == B_OK) { - char *buffer = new char[info.size]; + char* buffer = new char[info.size]; if (node->ReadAttr(kAttrQueryVolume, B_MESSAGE_TYPE, 0, buffer, (size_t)info.size) == info.size) { BMessage message; @@ -2213,7 +2214,7 @@ FindPanel::RestoreWindowState(const BNode *node) attr_info info; if (node->GetAttrInfo(kAttrQueryInitialAttrs, &info) != B_OK) break; - char *buffer = new char[info.size]; + char* buffer = new char[info.size]; if (node->ReadAttr(kAttrQueryInitialAttrs, B_MESSAGE_TYPE, 0, buffer, (size_t)info.size) == info.size) { BMessage message; @@ -2230,7 +2231,7 @@ FindPanel::RestoreWindowState(const BNode *node) { BString buffer; if (node->ReadAttrString(kAttrQueryInitialString, &buffer) == B_OK) { - BTextControl *textControl = dynamic_cast + BTextControl* textControl = dynamic_cast (FindView("TextControl")); ASSERT(textControl); @@ -2243,10 +2244,10 @@ FindPanel::RestoreWindowState(const BNode *node) // try to restore focus and possibly text selection BString focusedView; if (node->ReadAttrString("_trk/focusedView", &focusedView) == B_OK) { - BView *view = FindView(focusedView.String()); + BView* view = FindView(focusedView.String()); if (view != NULL) { view->MakeFocus(); - BTextControl *textControl = dynamic_cast(view); + BTextControl* textControl = dynamic_cast(view); if (textControl != NULL && Mode() == kByFormulaItem) { int32 selStart = 0; int32 selEnd = LONG_MAX; @@ -2262,9 +2263,9 @@ FindPanel::RestoreWindowState(const BNode *node) void -FindPanel::ResizeAttributeBox(const BNode *node) +FindPanel::ResizeAttributeBox(const BNode* node) { - BBox *box = dynamic_cast(FindView("Box")); + BBox* box = dynamic_cast(FindView("Box")); BRect bounds(box->Bounds()); int32 count = InitialAttrCount(node); @@ -2274,9 +2275,9 @@ FindPanel::ResizeAttributeBox(const BNode *node) void -FindPanel::AddByAttributeItems(const BNode *node) +FindPanel::AddByAttributeItems(const BNode* node) { - BBox *box = dynamic_cast(FindView("Box")); + BBox* box = dynamic_cast(FindView("Box")); ASSERT(box); BRect bounds(box->Bounds()); @@ -2299,11 +2300,11 @@ FindPanel::AddByAttributeItems(const BNode *node) void FindPanel::AddByNameOrFormulaItems() { - BBox *box = dynamic_cast(FindView("Box")); + BBox* box = dynamic_cast(FindView("Box")); BRect bounds(box->Bounds()); bounds.InsetBy(10, 10); - BTextControl *textControl = new BTextControl(bounds, "TextControl", "", "", NULL); + BTextControl* textControl = new BTextControl(bounds, "TextControl", "", "", NULL); textControl->SetDivider(0.0f); box->AddChild(textControl); textControl->MakeFocus(); @@ -2314,7 +2315,7 @@ void FindPanel::RemoveAttrViewItems() { for (;;) { - BView *view = FindView("AttrView"); + BView* view = FindView("AttrView"); if (view == NULL) break; view->RemoveSelf(); @@ -2329,7 +2330,7 @@ void FindPanel::RemoveByAttributeItems() { RemoveAttrViewItems(); - BView *view = FindView("add"); + BView* view = FindView("add"); if (view) { view->RemoveSelf(); delete view; @@ -2341,7 +2342,7 @@ FindPanel::RemoveByAttributeItems() delete view; } - view = dynamic_cast(FindView("TextControl")); + view = dynamic_cast(FindView("TextControl")); if (view) { view->RemoveSelf(); delete view; @@ -2352,7 +2353,7 @@ FindPanel::RemoveByAttributeItems() void FindPanel::ShowOrHideMimeTypeMenu() { - BMenuField *menuField = dynamic_cast(FindView("MimeTypeMenu")); + BMenuField* menuField = dynamic_cast(FindView("MimeTypeMenu")); if (Mode() == (int32)kByFormulaItem && !menuField->IsHidden()) menuField->Hide(); else if (menuField->IsHidden()) @@ -2369,16 +2370,16 @@ TAttrView::TAttrView(BRect frame, int32 index) SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - BPopUpMenu *menu = new BPopUpMenu("PopUp"); + BPopUpMenu* menu = new BPopUpMenu("PopUp"); // add NAME attribute to popup BMenu* submenu = new BMenu(B_TRANSLATE("Name")); submenu->SetRadioMode(true); submenu->SetFont(be_plain_font); - BMessage *message = new BMessage(kAttributeItemMain); + BMessage* message = new BMessage(kAttributeItemMain); message->AddString("name", "name"); message->AddInt32("type", B_STRING_TYPE); - BMenuItem *item = new BMenuItem(submenu, message); + BMenuItem* item = new BMenuItem(submenu, message); menu->AddItem(item); const int32 operators[] = { @@ -2387,7 +2388,7 @@ TAttrView::TAttrView(BRect frame, int32 index) B_NE, B_BEGINS_WITH, B_ENDS_WITH}; - static const char *operatorLabels[] = { + static const char* operatorLabels[] = { B_TRANSLATE_MARK("contains"), B_TRANSLATE_MARK("is"), B_TRANSLATE_MARK("is not"), @@ -2475,7 +2476,7 @@ TAttrView::~TAttrView() void TAttrView::AttachedToWindow() { - BMenu *menu = fMenuField->Menu(); + BMenu* menu = fMenuField->Menu(); // target everything menu->SetTargetForItems(this); @@ -2494,12 +2495,12 @@ TAttrView::MakeTextViewFocus() void TAttrView::RestoreState(const BMessage &message, int32 index) { - BMenu *menu = fMenuField->Menu(); + BMenu* menu = fMenuField->Menu(); // decode menu selections AddMimeTypeAttrs(menu); - const char *label; + const char* label; if (message.FindString("menuSelection", index, &label) == B_OK) { int32 itemIndex = SelectItemWithLabel(menu, label); if (itemIndex >=0) { @@ -2512,12 +2513,12 @@ TAttrView::RestoreState(const BMessage &message, int32 index) // decode attribute text ASSERT(fTextControl); - const char *string; + const char* string; if (message.FindString("attrViewText", index, &string) == B_OK) fTextControl->TextView()->SetText(string); int32 logicMenuSelectedIndex; - BMenuField *field = dynamic_cast(FindView("Logic")); + BMenuField* field = dynamic_cast(FindView("Logic")); if (message.FindInt32("logicalRelation", index, &logicMenuSelectedIndex) == B_OK) { if (field) @@ -2529,18 +2530,18 @@ TAttrView::RestoreState(const BMessage &message, int32 index) void -TAttrView::SaveState(BMessage *message, int32) +TAttrView::SaveState(BMessage* message, int32) { - BMenu *menu = fMenuField->Menu(); + BMenu* menu = fMenuField->Menu(); // encode main attribute menu selection - BMenuItem *item = menu->FindMarked(); + BMenuItem* item = menu->FindMarked(); message->AddString("menuSelection", item ? item->Label() : ""); // encode submenu selection - const char *label = ""; + const char* label = ""; if (item) { - BMenu *submenu = menu->SubmenuAt(menu->IndexOf(item)); + BMenu* submenu = menu->SubmenuAt(menu->IndexOf(item)); if (submenu) { item = submenu->FindMarked(); if (item) @@ -2553,9 +2554,9 @@ TAttrView::SaveState(BMessage *message, int32) ASSERT(fTextControl); message->AddString("attrViewText", fTextControl->TextView()->Text()); - BMenuField *field = dynamic_cast(FindView("Logic")); + BMenuField* field = dynamic_cast(FindView("Logic")); if (field) { - BMenuItem *item = field->Menu()->FindMarked(); + BMenuItem* item = field->Menu()->FindMarked(); ASSERT(item); message->AddInt32("logicalRelation", item ? field->Menu()->IndexOf(item) : 0); } @@ -2565,8 +2566,8 @@ void TAttrView::AddLogicMenu(bool selectAnd) { // add "AND/OR" menu - BPopUpMenu *menu = new BPopUpMenu(""); - BMessage *message = new BMessage(); + BPopUpMenu* menu = new BPopUpMenu(""); + BMessage* message = new BMessage(); message->AddInt32("combine", B_AND); BMenuItem* item = new BMenuItem(B_TRANSLATE("And"), message); menu->AddItem(item); @@ -2585,7 +2586,7 @@ TAttrView::AddLogicMenu(bool selectAnd) BRect bounds(Bounds()); bounds.left = bounds.right - 40; bounds.bottom = bounds.top + 15; - BMenuField *menufield = new BMenuField(bounds, "Logic", "", menu); + BMenuField* menufield = new BMenuField(bounds, "Logic", "", menu); menufield->SetDivider(0.0f); menufield->HidePopUpMarker(); AddChild(menufield); @@ -2595,7 +2596,7 @@ TAttrView::AddLogicMenu(bool selectAnd) void TAttrView::RemoveLogicMenu() { - BMenuField *menufield = dynamic_cast(FindView("Logic")); + BMenuField* menufield = dynamic_cast(FindView("Logic")); if (menufield) { menufield->RemoveSelf(); delete menufield; @@ -2606,7 +2607,7 @@ TAttrView::RemoveLogicMenu() void TAttrView::Draw(BRect) { - BMenuItem *item = fMenuField->Menu()->FindMarked(); + BMenuItem* item = fMenuField->Menu()->FindMarked(); if (!item) return; @@ -2623,13 +2624,13 @@ TAttrView::Draw(BRect) void -TAttrView::MessageReceived(BMessage *message) +TAttrView::MessageReceived(BMessage* message) { - BMenuItem *item; + BMenuItem* item; switch (message->what) { case kAttributeItem: - if (message->FindPointer("source", (void **)&item) != B_OK) + if (message->FindPointer("source", (void**)&item) != B_OK) return; item->Menu()->Superitem()->SetMarked(true); @@ -2639,7 +2640,7 @@ TAttrView::MessageReceived(BMessage *message) case kAttributeItemMain: // in case someone selected just and attribute without the // comparator - if (message->FindPointer("source", (void **)&item) != B_OK) + if (message->FindPointer("source", (void**)&item) != B_OK) return; if (item->Submenu()->ItemAt(0)) @@ -2657,13 +2658,13 @@ TAttrView::MessageReceived(BMessage *message) void TAttrView::AddMimeTypeAttrs() { - BMenu *menu = fMenuField->Menu(); + BMenu* menu = fMenuField->Menu(); AddMimeTypeAttrs(menu); } void -TAttrView::AddAttributes(BMenu *menu, const BMimeType &mimeType) +TAttrView::AddAttributes(BMenu* menu, const BMimeType &mimeType) { // only add things to menu which have "user-visible" data BMessage attributeMessage; @@ -2675,14 +2676,14 @@ TAttrView::AddAttributes(BMenu *menu, const BMimeType &mimeType) // go through each field in meta mime and add it to a menu for (int32 index = 0; ; index++) { - const char *publicName; + const char* publicName; if (attributeMessage.FindString("attr:public_name", index, &publicName) != B_OK) break; if (!attributeMessage.FindBool("attr:viewable")) continue; - const char *attributeName; + const char* attributeName; if (attributeMessage.FindString("attr:name", index, &attributeName) != B_OK) continue; @@ -2690,13 +2691,13 @@ TAttrView::AddAttributes(BMenu *menu, const BMimeType &mimeType) if (attributeMessage.FindInt32("attr:type", index, &type) != B_OK) continue; - BMenu *submenu = new BMenu(publicName); + BMenu* submenu = new BMenu(publicName); submenu->SetRadioMode(true); submenu->SetFont(be_plain_font); - BMessage *message = new BMessage(kAttributeItemMain); + BMessage* message = new BMessage(kAttributeItemMain); message->AddString("name", attributeName); message->AddInt32("type", type); - BMenuItem *item = new BMenuItem(submenu, message); + BMenuItem* item = new BMenuItem(submenu, message); menu->AddItem(item); menu->SetTargetForItems(this); @@ -2771,14 +2772,14 @@ TAttrView::AddAttributes(BMenu *menu, const BMimeType &mimeType) void -TAttrView::AddMimeTypeAttrs(BMenu *menu) +TAttrView::AddMimeTypeAttrs(BMenu* menu) { - FindPanel *mainView = dynamic_cast(Parent()-> + FindPanel* mainView = dynamic_cast(Parent()-> Parent()->FindView("MainView")); if (!mainView) return; - const char *typeName; + const char* typeName; if (mainView->CurrentMimeType(&typeName) == NULL) return; @@ -2800,7 +2801,7 @@ TAttrView::AddMimeTypeAttrs(BMenu *menu) void TAttrView::GetDefaultName(BString &result) const { - BMenuItem *item = NULL; + BMenuItem* item = NULL; if (fMenuField->Menu() != NULL) item = fMenuField->Menu()->FindMarked(); if (item != NULL) @@ -2904,7 +2905,7 @@ DeleteTransientQueriesTask::GetSome() const int32 kDaysToExpire = 7; static bool -QueryOldEnough(Model *model) +QueryOldEnough(Model* model) { // check if it is old and ready to be deleted time_t now = time(0); @@ -2925,7 +2926,7 @@ QueryOldEnough(Model *model) bool -DeleteTransientQueriesTask::ProcessOneRef(Model *model) +DeleteTransientQueriesTask::ProcessOneRef(Model* model) { BModelOpener opener(model); @@ -2938,10 +2939,10 @@ DeleteTransientQueriesTask::ProcessOneRef(Model *model) if (!QueryOldEnough(model)) return false; - ASSERT(dynamic_cast(be_app)); + ASSERT(dynamic_cast(be_app)); // check that it is not showing - if (dynamic_cast(be_app)->EntryHasWindowOpen(model->EntryRef())) { + if (dynamic_cast(be_app)->EntryHasWindowOpen(model->EntryRef())) { PRINT(("query %s, showing, can't delete\n", model->Name())); return false; } @@ -2956,7 +2957,7 @@ DeleteTransientQueriesTask::ProcessOneRef(Model *model) class DeleteTransientQueriesFunctor : public FunctionObjectWithResult { public: - DeleteTransientQueriesFunctor(DeleteTransientQueriesTask *task) + DeleteTransientQueriesFunctor(DeleteTransientQueriesTask* task) : task(task) {} @@ -2969,7 +2970,7 @@ public: { result = task->DoSomeWork(); } private: - DeleteTransientQueriesTask *task; + DeleteTransientQueriesTask* task; }; @@ -2978,9 +2979,9 @@ DeleteTransientQueriesTask::StartUpTransientQueryCleaner() { // set up a task that wakes up when the machine is idle and starts // killing off old transient queries - DeleteTransientQueriesFunctor *worker + DeleteTransientQueriesFunctor* worker = new DeleteTransientQueriesFunctor(new DeleteTransientQueriesTask()); - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); ASSERT(tracker); tracker->MainTaskLoop()->RunWhenIdle(worker, 30 * 60 * 1000000, // half an hour initial delay @@ -2992,7 +2993,7 @@ DeleteTransientQueriesTask::StartUpTransientQueryCleaner() // #pragma mark - -RecentFindItemsMenu::RecentFindItemsMenu(const char *title, const BMessenger *target, +RecentFindItemsMenu::RecentFindItemsMenu(const char* title, const BMessenger* target, uint32 what) : BMenu(title, B_ITEMS_IN_COLUMN), fTarget(*target), @@ -3016,8 +3017,8 @@ RecentFindItemsMenu::AttachedToWindow() #if !B_BEOS_VERSION_DANO _IMPEXP_TRACKER #endif -BMenu * -TrackerBuildRecentFindItemsMenu(const char *title) +BMenu* +TrackerBuildRecentFindItemsMenu(const char* title) { BMessenger tracker(kTrackerSignature); return new RecentFindItemsMenu(title, &tracker, B_REFS_RECEIVED); @@ -3027,8 +3028,8 @@ TrackerBuildRecentFindItemsMenu(const char *title) // #pragma mark - -DraggableQueryIcon::DraggableQueryIcon(BRect frame, const char *name, - const BMessage *message, BMessenger messenger, uint32 resizeFlags, uint32 flags) +DraggableQueryIcon::DraggableQueryIcon(BRect frame, const char* name, + const BMessage* message, BMessenger messenger, uint32 resizeFlags, uint32 flags) : DraggableIcon(frame, name, B_QUERY_MIMETYPE, B_LARGE_ICON, message, messenger, resizeFlags, flags) { @@ -3036,12 +3037,12 @@ DraggableQueryIcon::DraggableQueryIcon(BRect frame, const char *name, bool -DraggableQueryIcon::DragStarted(BMessage *dragMessage) +DraggableQueryIcon::DragStarted(BMessage* dragMessage) { // override to substitute the user-specified query name dragMessage->RemoveData("be:clip_name"); - FindWindow *window = dynamic_cast(Window()); + FindWindow* window = dynamic_cast(Window()); ASSERT(window); dragMessage->AddString("be:clip_name", window->BackgroundView()->UserSpecifiedName() ? @@ -3055,7 +3056,7 @@ DraggableQueryIcon::DragStarted(BMessage *dragMessage) // #pragma mark - -MostUsedNames::MostUsedNames(const char *fileName, const char *directory, int32 maxCount) +MostUsedNames::MostUsedNames(const char* fileName, const char* directory, int32 maxCount) : fFileName(fileName), fDirectory(directory), @@ -3082,7 +3083,7 @@ MostUsedNames::~MostUsedNames() BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE); if (file.InitCheck() == B_OK) { for (int32 i = 0; i < fList.CountItems(); i++) { - list_entry *entry = static_cast(fList.ItemAt(i)); + list_entry* entry = static_cast(fList.ItemAt(i)); char line[B_FILE_NAME_LENGTH + 5]; @@ -3105,7 +3106,7 @@ MostUsedNames::~MostUsedNames() // free data for (int32 i = fList.CountItems(); i-- > 0;) { - list_entry *entry = static_cast(fList.ItemAt(i)); + list_entry* entry = static_cast(fList.ItemAt(i)); free(entry->name); delete entry; } @@ -3113,7 +3114,7 @@ MostUsedNames::~MostUsedNames() bool -MostUsedNames::ObtainList(BList *list) +MostUsedNames::ObtainList(BList* list) { if (!list) return false; @@ -3125,7 +3126,7 @@ MostUsedNames::ObtainList(BList *list) list->MakeEmpty(); for (int32 i = 0; i < fCount; i++) { - list_entry *entry = static_cast(fList.ItemAt(i)); + list_entry* entry = static_cast(fList.ItemAt(i)); if (entry == NULL) return true; @@ -3143,7 +3144,7 @@ MostUsedNames::ReleaseList() void -MostUsedNames::AddName(const char *name) +MostUsedNames::AddName(const char* name) { fLock.Lock(); @@ -3153,10 +3154,10 @@ MostUsedNames::AddName(const char *name) // remove last entry if there are more than // 2*fCount entries in the list - list_entry *entry = NULL; + list_entry* entry = NULL; if (fList.CountItems() > fCount * 2) { - entry = static_cast(fList.RemoveItem(fList.CountItems() - 1)); + entry = static_cast(fList.RemoveItem(fList.CountItems() - 1)); // is this the name we want to add here? if (strcmp(name, entry->name)) { @@ -3168,7 +3169,7 @@ MostUsedNames::AddName(const char *name) } if (entry == NULL) { - for (int32 i = 0; (entry = static_cast(fList.ItemAt(i))) != NULL; i++) + for (int32 i = 0; (entry = static_cast(fList.ItemAt(i))) != NULL; i++) if (!strcmp(entry->name, name)) break; } @@ -3190,10 +3191,10 @@ MostUsedNames::AddName(const char *name) int -MostUsedNames::CompareNames(const void *a,const void *b) +MostUsedNames::CompareNames(const void* a,const void* b) { - list_entry *entryA = *(list_entry **)a; - list_entry *entryB = *(list_entry **)b; + list_entry* entryA = *(list_entry**)a; + list_entry* entryB = *(list_entry**)b; if (entryA->count == entryB->count) return strcasecmp(entryA->name,entryB->name); @@ -3218,7 +3219,7 @@ MostUsedNames::LoadList() path.Append(fDirectory); path.Append(fFileName); - FILE *file = fopen(path.Path(), "r"); + FILE* file = fopen(path.Path(), "r"); if (file == NULL) return; @@ -3230,11 +3231,11 @@ MostUsedNames::LoadList() int32 count = atoi(line); - char *name = strchr(line, ' '); + char* name = strchr(line, ' '); if (name == NULL || *(++name) == '\0') continue; - list_entry *entry = new list_entry; + list_entry* entry = new list_entry; entry->name = strdup(name); entry->count = count; diff --git a/src/kits/tracker/FindPanel.h b/src/kits/tracker/FindPanel.h index 8819702159..a858e5d45f 100644 --- a/src/kits/tracker/FindPanel.h +++ b/src/kits/tracker/FindPanel.h @@ -31,7 +31,6 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef _FIND_PANEL_H #define _FIND_PANEL_H @@ -40,13 +39,13 @@ All rights reserved. #include #include - #include "DialogPane.h" #include "ObjectList.h" #include "MimeTypeList.h" #include "Utilities.h" #include "NodeWalker.h" + class BFilePanel; class BQuery; class BBox; @@ -74,7 +73,7 @@ const uint32 kRemoveItem = 'Frem'; #ifdef _IMPEXP_TRACKER _IMPEXP_TRACKER #endif -BMenu *TrackerBuildRecentFindItemsMenu(const char *title); +BMenu* TrackerBuildRecentFindItemsMenu(const char* title); struct MoreOptionsStruct { bool showMoreOptions; @@ -110,62 +109,62 @@ struct MoreOptionsStruct { reserved8(0) {} - static void EndianSwap(void *castToThis); + static void EndianSwap(void* castToThis); - static void SetQueryTemporary(BNode *, bool on); - static bool QueryTemporary(const BNode *); + static void SetQueryTemporary(BNode*, bool on); + static bool QueryTemporary(const BNode*); }; class FindWindow : public BWindow { public: - FindWindow(const entry_ref *ref = NULL, + FindWindow(const entry_ref* ref = NULL, bool editIfTemplateOnly = false); virtual ~FindWindow(); - FindPanel *BackgroundView() const + FindPanel* BackgroundView() const { return fBackground; } - BNode *QueryNode() const + BNode* QueryNode() const { return fFile; } - const char *QueryName() const; + const char* QueryName() const; // reads in the query name from either a saved name in a template or // form a saved query name - static bool IsQueryTemplate(BNode *file); + static bool IsQueryTemplate(BNode* file); protected: - virtual void MessageReceived(BMessage *message); + virtual void MessageReceived(BMessage* message); private: - static BFile *TryOpening(const entry_ref *ref); + static BFile* TryOpening(const entry_ref* ref); static void GetDefaultQuery(BEntry &entry); // when opening an empty panel, use the default query to set the panel up - void SaveQueryAttributes(BNode *file, bool templateQuery); + void SaveQueryAttributes(BNode* file, bool templateQuery); void Find(); // retrieve the results void Save(); // save the contents of the find window into the query file - void SwitchToTemplate(const entry_ref *); + void SwitchToTemplate(const entry_ref*); bool FindSaveCommon(bool find); - status_t SaveQueryAsAttributes(BNode *, BEntry *, bool queryTemplate, - const BMessage *oldAttributes = 0, const BPoint *oldLocation = 0); + status_t SaveQueryAsAttributes(BNode*, BEntry*, bool queryTemplate, + const BMessage* oldAttributes = 0, const BPoint* oldLocation = 0); void GetDefaultName(BString &); void GetPredicateString(BString &, bool &dynamicDate); // dynamic date is a date such as 'today' - BFile *fFile; + BFile* fFile; entry_ref fRef; bool fFromTemplate; bool fEditTemplateOnly; - FindPanel *fBackground; + FindPanel* fBackground; mutable BString fQueryNameFromTemplate; - BFilePanel *fSaveAsTemplatePanel; + BFilePanel* fSaveAsTemplatePanel; typedef BWindow _inherited; }; @@ -173,45 +172,45 @@ class FindWindow : public BWindow { class FindPanel : public BView { public: - FindPanel(BRect, BFile *, FindWindow *parent, bool fromTemplate, + FindPanel(BRect, BFile*, FindWindow* parent, bool fromTemplate, bool editTemplateOnly); virtual ~FindPanel(); virtual void AttachedToWindow(); virtual void MessageReceived(BMessage*); - void BuildAttrQuery(BQuery *, bool &dynamicDate) const; - BPopUpMenu *MimeTypeMenu() const + void BuildAttrQuery(BQuery*, bool &dynamicDate) const; + BPopUpMenu* MimeTypeMenu() const { return fMimeTypeMenu; } - BMenuItem *CurrentMimeType(const char **type = NULL) const; - status_t SetCurrentMimeType(BMenuItem *item); - status_t SetCurrentMimeType(const char *label); + BMenuItem* CurrentMimeType(const char** type = NULL) const; + status_t SetCurrentMimeType(BMenuItem* item); + status_t SetCurrentMimeType(const char* label); - BPopUpMenu *VolMenu() const + BPopUpMenu* VolMenu() const { return fVolMenu; } uint32 Mode() const { return fMode; } - static BRect InitialViewSize(const BNode *); + static BRect InitialViewSize(const BNode*); // used when showing window, does not account for more options, // those if used will force a resize later - static uint32 InitialMode(const BNode *entry); - void SaveWindowState(BNode *, bool editTemplate); + static uint32 InitialMode(const BNode* entry); + void SaveWindowState(BNode*, bool editTemplate); - void SwitchToTemplate(const BNode *); + void SwitchToTemplate(const BNode*); - void GetByAttrPredicate(BQuery *, bool &dynamicDate) const; + void GetByAttrPredicate(BQuery*, bool &dynamicDate) const; // build up a query from by-attribute items void GetByNamePredicate(BQuery *) const; // build up a simple query from the name we are searching for void GetDefaultName(BString &) const; - const char *UserSpecifiedName() const; + const char* UserSpecifiedName() const; // name filled out in the query name text field - static void AddRecentQueries(BMenu *, bool addSaveAsItem, - const BMessenger *target, uint32 what); + static void AddRecentQueries(BMenu*, bool addSaveAsItem, + const BMessenger* target, uint32 what); // populate the recent query menu with query templates and recent // queries @@ -223,9 +222,9 @@ class FindPanel : public BView { void AddMimeTypesToMenu(); // populates the type menu - static bool AddOneMimeTypeToMenu(const ShortMimeInfo *, void *); + static bool AddOneMimeTypeToMenu(const ShortMimeInfo*, void*); - void AddVolumes(BMenu *); + void AddVolumes(BMenu*); // populates the volume menu void ShowVolumeMenuLabel(); @@ -236,10 +235,10 @@ class FindPanel : public BView { void AddFirstAttr(); // panel building/restoring calls - void RestoreWindowState(const BNode *); - void RestoreMimeTypeMenuSelection(const BNode *); - void AddByAttributeItems(const BNode *); - void ResizeAttributeBox(const BNode *); + void RestoreWindowState(const BNode*); + void RestoreMimeTypeMenuSelection(const BNode*); + void AddByAttributeItems(const BNode*); + void ResizeAttributeBox(const BNode*); void RemoveByAttributeItems(); void RemoveAttrViewItems(); void ShowOrHideMimeTypeMenu(); @@ -247,35 +246,35 @@ class FindPanel : public BView { void ShowOrHideMoreOptions(bool show); // fMode gets set by this and the call relies on it being up-to-date - static int32 InitialAttrCount(const BNode *); - void FillCurrentQueryName(BTextControl *, FindWindow *); + static int32 InitialAttrCount(const BNode*); + void FillCurrentQueryName(BTextControl*, FindWindow*); void AddByNameOrFormulaItems(); - void AddOneAttributeItem(BBox *box, BRect); - void SetUpAddRemoveButtons(BBox *box); + void AddOneAttributeItem(BBox* box, BRect); + void SetUpAddRemoveButtons(BBox* box); void SwitchMode(uint32); // go from search by name to search by attribute, etc. - void PushMimeType(BQuery *query) const; + void PushMimeType(BQuery* query) const; - void SaveAsQueryOrTemplate(const entry_ref *, const char *, bool queryTemplate); + void SaveAsQueryOrTemplate(const entry_ref*, const char*, bool queryTemplate); uint32 fMode; BObjectList fAttrViewList; - BPopUpMenu *fMimeTypeMenu; - BMenuField *fMimeTypeField; - BPopUpMenu *fVolMenu; - BPopUpMenu *fSearchModeMenu; - BPopUpMenu *fRecentQueries; - DialogPane *fMoreOptionsPane; - BTextControl *fQueryName; + BPopUpMenu* fMimeTypeMenu; + BMenuField* fMimeTypeField; + BPopUpMenu* fVolMenu; + BPopUpMenu* fSearchModeMenu; + BPopUpMenu* fRecentQueries; + DialogPane* fMoreOptionsPane; + BTextControl* fQueryName; BString fInitialQueryName; - BCheckBox *fTemporaryCheck; - BCheckBox *fSearchTrashCheck; + BCheckBox* fTemporaryCheck; + BCheckBox* fSearchTrashCheck; - PaneSwitch *fLatch; - DraggableIcon *fDraggableIcon; + PaneSwitch* fLatch; + DraggableIcon* fDraggableIcon; typedef BView _inherited; @@ -292,10 +291,10 @@ class TAttrView : public BView { virtual void AttachedToWindow(); void RestoreState(const BMessage &settings, int32 index); - void SaveState(BMessage *settings, int32 index); + void SaveState(BMessage* settings, int32 index); virtual void Draw(BRect updateRect); - virtual void MessageReceived(BMessage *message); + virtual void MessageReceived(BMessage* message); void AddLogicMenu(bool selectAnd = true); void RemoveLogicMenu(); @@ -305,11 +304,11 @@ class TAttrView : public BView { void GetDefaultName(BString &result) const; private: - void AddAttributes(BMenu *menu, const BMimeType &type); - void AddMimeTypeAttrs(BMenu *menu); + void AddAttributes(BMenu* menu, const BMimeType &type); + void AddMimeTypeAttrs(BMenu* menu); - BMenuField *fMenuField; - BTextControl *fTextControl; + BMenuField* fMenuField; + BTextControl* fTextControl; typedef BView _inherited; }; @@ -340,16 +339,16 @@ class DeleteTransientQueriesTask { void Initialize(); bool GetSome(); - bool ProcessOneRef(Model *); + bool ProcessOneRef(Model*); private: - BTrackerPrivate::TNodeWalker *fWalker; + BTrackerPrivate::TNodeWalker* fWalker; }; class RecentFindItemsMenu : public BMenu { public: - RecentFindItemsMenu(const char *title, const BMessenger *target, uint32 what); + RecentFindItemsMenu(const char* title, const BMessenger* target, uint32 what); protected: virtual void AttachedToWindow(); @@ -363,12 +362,12 @@ class RecentFindItemsMenu : public BMenu { class DraggableQueryIcon : public DraggableIcon { // query/query template drag&drop helper public: - DraggableQueryIcon(BRect frame, const char *name, const BMessage *message, + DraggableQueryIcon(BRect frame, const char* name, const BMessage* message, BMessenger target, uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP, uint32 flags = B_WILL_DRAW); protected: - virtual bool DragStarted(BMessage *); + virtual bool DragStarted(BMessage*); }; } // namespace BPrivate diff --git a/src/kits/tracker/FunctionObject.h b/src/kits/tracker/FunctionObject.h index bcd8f6e6ef..0e8241a18e 100644 --- a/src/kits/tracker/FunctionObject.h +++ b/src/kits/tracker/FunctionObject.h @@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef __FUNCTION_OBJECT__ #define __FUNCTION_OBJECT__ + #include #include #include @@ -42,6 +42,7 @@ All rights reserved. #include #include + // parameter binders serve to store a copy of a struct and // pass it in and out by pointers, allowing struct parameters to share // the same syntax as scalar ones @@ -71,17 +72,17 @@ private: template<> -class ParameterBinder { +class ParameterBinder { public: ParameterBinder() {} - ParameterBinder(const BEntry *p) + ParameterBinder(const BEntry* p) : p(*p) {} - ParameterBinder &operator=(const BEntry *newp) + ParameterBinder &operator=(const BEntry* newp) { p = *newp; return *this; } - const BEntry *Pass() const + const BEntry* Pass() const { return &p; } private: BEntry p; @@ -89,19 +90,19 @@ private: template<> -class ParameterBinder { +class ParameterBinder { public: ParameterBinder() {} - ParameterBinder(const entry_ref *p) + ParameterBinder(const entry_ref* p) { if (p) this->p = *p; } - ParameterBinder &operator=(const entry_ref *newp) + ParameterBinder &operator=(const entry_ref* newp) { p = *newp; return *this; } - const entry_ref *Pass() const + const entry_ref* Pass() const { return &p; } private: entry_ref p; @@ -109,17 +110,17 @@ private: template<> -class ParameterBinder { +class ParameterBinder { public: ParameterBinder() {} - ParameterBinder(const node_ref * p) + ParameterBinder(const node_ref* p) : p(*p) {} - ParameterBinder &operator=(const node_ref *newp) + ParameterBinder &operator=(const node_ref* newp) { p = *newp; return *this; } - const node_ref *Pass() const + const node_ref* Pass() const { return &p; } private: node_ref p; @@ -127,10 +128,10 @@ private: template<> -class ParameterBinder { +class ParameterBinder { public: ParameterBinder() {} - ParameterBinder(const BMessage *p) + ParameterBinder(const BMessage* p) : p(p ? new BMessage(*p) : NULL) {} @@ -139,18 +140,18 @@ public: delete p; } - ParameterBinder &operator=(const BMessage *newp) + ParameterBinder &operator=(const BMessage* newp) { delete p; p = (newp ? new BMessage(*newp) : NULL); return *this; } - const BMessage *Pass() const + const BMessage* Pass() const { return p; } private: - BMessage *p; + BMessage* p; }; @@ -164,8 +165,7 @@ public: template class FunctionObjectWithResult : public FunctionObject { public: - const R &Result() const - { return result; } + const R &Result() const { return result; } protected: R result; @@ -181,10 +181,8 @@ public: p1(p1) { } - - - virtual void operator()() - { (function)(p1.Pass()); } + + virtual void operator()() { (function)(p1.Pass()); } private: void (*function)(Param1); @@ -193,15 +191,15 @@ private: template -class SingleParamFunctionObjectWithResult : public FunctionObjectWithResult { +class SingleParamFunctionObjectWithResult : public + FunctionObjectWithResult { public: SingleParamFunctionObjectWithResult(Result (*function)(Param1), Param1 p1) : function(function), p1(p1) { } - - + virtual void operator()() { FunctionObjectWithResult::result = (function)(p1.Pass()); } @@ -222,8 +220,7 @@ public: { } - virtual void operator()() - { (function)(p1.Pass(), p2.Pass()); } + virtual void operator()() { (function)(p1.Pass(), p2.Pass()); } private: void (*function)(Param1, Param2); @@ -244,9 +241,7 @@ public: { } - - virtual void operator()() - { (function)(p1.Pass(), p2.Pass(), p3.Pass()); } + virtual void operator()() { (function)(p1.Pass(), p2.Pass(), p3.Pass()); } private: void (*function)(Param1, Param2, Param3); @@ -267,7 +262,7 @@ public: p3(p3) { } - + virtual void operator()() { FunctionObjectWithResult::result = (function)(p1.Pass(), p2.Pass(), p3.Pass()); } @@ -292,7 +287,7 @@ public: p4(p4) { } - + virtual void operator()() { (function)(p1.Pass(), p2.Pass(), p3.Pass(), p4.Pass()); } @@ -317,7 +312,7 @@ public: p4(p4) { } - + virtual void operator()() { FunctionObjectWithResult::result = (function)(p1.Pass(), p2.Pass(), p3.Pass(), p4.Pass()); } @@ -334,7 +329,7 @@ private: template class PlainMemberFunctionObject : public FunctionObject { public: - PlainMemberFunctionObject(void (T::*function)(), T *onThis) + PlainMemberFunctionObject(void (T::*function)(), T* onThis) : function(function), target(onThis) { @@ -345,14 +340,14 @@ public: private: void (T::*function)(); - T *target; + T* target; }; template class PlainLockingMemberFunctionObject : public FunctionObject { public: - PlainLockingMemberFunctionObject(void (T::*function)(), T *target) + PlainLockingMemberFunctionObject(void (T::*function)(), T* target) : function(function), messenger(target) { @@ -360,7 +355,7 @@ public: virtual void operator()() { - T *target = dynamic_cast(messenger.Target(NULL)); + T* target = dynamic_cast(messenger.Target(NULL)); if (!target || !messenger.LockTarget()) return; (target->*function)(); @@ -376,7 +371,7 @@ private: template class PlainMemberFunctionObjectWithResult : public FunctionObjectWithResult { public: - PlainMemberFunctionObjectWithResult(R (T::*function)(), T *onThis) + PlainMemberFunctionObjectWithResult(R (T::*function)(), T* onThis) : function(function), target(onThis) { @@ -388,14 +383,14 @@ public: private: R (T::*function)(); - T *target; + T* target; }; template class SingleParamMemberFunctionObject : public FunctionObject { public: - SingleParamMemberFunctionObject(void (T::*function)(Param1), T *onThis, Param1 p1) + SingleParamMemberFunctionObject(void (T::*function)(Param1), T* onThis, Param1 p1) : function(function), target(onThis), p1(p1) @@ -407,7 +402,7 @@ public: private: void (T::*function)(Param1); - T *target; + T* target; ParameterBinder p1; }; @@ -415,7 +410,7 @@ private: template class TwoParamMemberFunctionObject : public FunctionObject { public: - TwoParamMemberFunctionObject(void (T::*function)(Param1, Param2), T *onThis, + TwoParamMemberFunctionObject(void (T::*function)(Param1, Param2), T* onThis, Param1 p1, Param2 p2) : function(function), target(onThis), @@ -430,7 +425,7 @@ public: protected: void (T::*function)(Param1, Param2); - T *target; + T* target; ParameterBinder p1; ParameterBinder p2; }; @@ -439,7 +434,7 @@ protected: template class SingleParamMemberFunctionObjectWithResult : public FunctionObjectWithResult { public: - SingleParamMemberFunctionObjectWithResult(R (T::*function)(Param1), T *onThis, + SingleParamMemberFunctionObjectWithResult(R (T::*function)(Param1), T* onThis, Param1 p1) : function(function), target(onThis), @@ -452,7 +447,7 @@ public: protected: R (T::*function)(Param1); - T *target; + T* target; ParameterBinder p1; }; @@ -460,7 +455,7 @@ protected: template class TwoParamMemberFunctionObjectWithResult : public FunctionObjectWithResult { public: - TwoParamMemberFunctionObjectWithResult(R (T::*function)(Param1, Param2), T *onThis, + TwoParamMemberFunctionObjectWithResult(R (T::*function)(Param1, Param2), T* onThis, Param1 p1, Param2 p2) : function(function), target(onThis), @@ -475,7 +470,7 @@ public: protected: R (T::*function)(Param1, Param2); - T *target; + T* target; ParameterBinder p1; ParameterBinder p2; }; @@ -490,7 +485,7 @@ protected: // ... add the missing ones as needed template -SingleParamFunctionObject * +SingleParamFunctionObject* NewFunctionObject(void (*function)(Param1), Param1 p1) { return new SingleParamFunctionObject(function, p1); @@ -498,7 +493,7 @@ NewFunctionObject(void (*function)(Param1), Param1 p1) template -TwoParamFunctionObject * +TwoParamFunctionObject* NewFunctionObject(void (*function)(Param1, Param2), Param1 p1, Param2 p2) { return new TwoParamFunctionObject(function, p1, p2); @@ -506,7 +501,7 @@ NewFunctionObject(void (*function)(Param1, Param2), Param1 p1, Param2 p2) template -ThreeParamFunctionObject * +ThreeParamFunctionObject* NewFunctionObject(void (*function)(Param1, Param2, Param3), Param1 p1, Param2 p2, Param3 p3) { @@ -515,24 +510,24 @@ NewFunctionObject(void (*function)(Param1, Param2, Param3), template -PlainMemberFunctionObject * -NewMemberFunctionObject(void (T::*function)(), T *onThis) +PlainMemberFunctionObject* +NewMemberFunctionObject(void (T::*function)(), T* onThis) { return new PlainMemberFunctionObject(function, onThis); } template -SingleParamMemberFunctionObject * -NewMemberFunctionObject(void (T::*function)(Param1), T *onThis, Param1 p1) +SingleParamMemberFunctionObject* +NewMemberFunctionObject(void (T::*function)(Param1), T* onThis, Param1 p1) { return new SingleParamMemberFunctionObject(function, onThis, p1); } template -TwoParamMemberFunctionObject * -NewMemberFunctionObject(void (T::*function)(Param1, Param2), T *onThis, +TwoParamMemberFunctionObject* +NewMemberFunctionObject(void (T::*function)(Param1, Param2), T* onThis, Param1 p1, Param2 p2) { return new TwoParamMemberFunctionObject(function, onThis, @@ -541,9 +536,9 @@ NewMemberFunctionObject(void (T::*function)(Param1, Param2), T *onThis, template -TwoParamMemberFunctionObjectWithResult * +TwoParamMemberFunctionObjectWithResult* NewMemberFunctionObjectWithResult(R (T::*function)(Param1, Param2), - T *onThis, Param1 p1, Param2 p2) + T* onThis, Param1 p1, Param2 p2) { return new TwoParamMemberFunctionObjectWithResult (function, onThis, p1, p2); @@ -551,9 +546,9 @@ NewMemberFunctionObjectWithResult(R (T::*function)(Param1, Param2), template -PlainLockingMemberFunctionObject * +PlainLockingMemberFunctionObject* NewLockingMemberFunctionObject(void (HandlerOrSubclass::*function)(), - HandlerOrSubclass *onThis) + HandlerOrSubclass* onThis) { return new PlainLockingMemberFunctionObject(function, onThis); } @@ -562,5 +557,4 @@ NewLockingMemberFunctionObject(void (HandlerOrSubclass::*function)(), using namespace BPrivate; -#endif - +#endif // __FUNCTION_OBJECT__ diff --git a/src/kits/tracker/GroupedMenu.cpp b/src/kits/tracker/GroupedMenu.cpp index 4bbd430953..8eb4dfbcb3 100644 --- a/src/kits/tracker/GroupedMenu.cpp +++ b/src/kits/tracker/GroupedMenu.cpp @@ -7,7 +7,7 @@ using namespace BPrivate; -TMenuItemGroup::TMenuItemGroup(const char *name) +TMenuItemGroup::TMenuItemGroup(const char* name) : fMenu(NULL), fFirstItemIndex(-1), @@ -23,10 +23,10 @@ TMenuItemGroup::TMenuItemGroup(const char *name) TMenuItemGroup::~TMenuItemGroup() { - free((char *)fName); + free((char*)fName); if (fMenu == NULL) { - BMenuItem *item; + BMenuItem* item; while ((item = RemoveItem(0L)) != NULL) delete item; } @@ -34,7 +34,7 @@ TMenuItemGroup::~TMenuItemGroup() bool -TMenuItemGroup::AddItem(BMenuItem *item) +TMenuItemGroup::AddItem(BMenuItem* item) { if (!fList.AddItem(item)) return false; @@ -48,7 +48,7 @@ TMenuItemGroup::AddItem(BMenuItem *item) bool -TMenuItemGroup::AddItem(BMenuItem *item, int32 atIndex) +TMenuItemGroup::AddItem(BMenuItem* item, int32 atIndex) { if (!fList.AddItem(item, atIndex)) return false; @@ -62,9 +62,9 @@ TMenuItemGroup::AddItem(BMenuItem *item, int32 atIndex) bool -TMenuItemGroup::AddItem(BMenu *menu) +TMenuItemGroup::AddItem(BMenu* menu) { - BMenuItem *item = new BMenuItem(menu); + BMenuItem* item = new BMenuItem(menu); if (item == NULL) return false; @@ -78,9 +78,9 @@ TMenuItemGroup::AddItem(BMenu *menu) bool -TMenuItemGroup::AddItem(BMenu *menu, int32 atIndex) +TMenuItemGroup::AddItem(BMenu* menu, int32 atIndex) { - BMenuItem *item = new BMenuItem(menu); + BMenuItem* item = new BMenuItem(menu); if (item == NULL) return false; @@ -94,7 +94,7 @@ TMenuItemGroup::AddItem(BMenu *menu, int32 atIndex) bool -TMenuItemGroup::RemoveItem(BMenuItem *item) +TMenuItemGroup::RemoveItem(BMenuItem* item) { if (fMenu) fMenu->RemoveGroupItem(this, item); @@ -104,9 +104,9 @@ TMenuItemGroup::RemoveItem(BMenuItem *item) bool -TMenuItemGroup::RemoveItem(BMenu *menu) +TMenuItemGroup::RemoveItem(BMenu* menu) { - BMenuItem *item = menu->Superitem(); + BMenuItem* item = menu->Superitem(); if (item == NULL) return false; @@ -114,10 +114,10 @@ TMenuItemGroup::RemoveItem(BMenu *menu) } -BMenuItem * +BMenuItem* TMenuItemGroup::RemoveItem(int32 index) { - BMenuItem *item = ItemAt(index); + BMenuItem* item = ItemAt(index); if (item == NULL) return NULL; @@ -128,10 +128,10 @@ TMenuItemGroup::RemoveItem(int32 index) } -BMenuItem * +BMenuItem* TMenuItemGroup::ItemAt(int32 index) { - return static_cast(fList.ItemAt(index)); + return static_cast(fList.ItemAt(index)); } @@ -167,7 +167,7 @@ TMenuItemGroup::HasSeparator() // #pragma mark - -TGroupedMenu::TGroupedMenu(const char *name) +TGroupedMenu::TGroupedMenu(const char* name) : BMenu(name) { } @@ -175,14 +175,14 @@ TGroupedMenu::TGroupedMenu(const char *name) TGroupedMenu::~TGroupedMenu() { - TMenuItemGroup *group; - while ((group = static_cast(fGroups.RemoveItem(0L))) != NULL) + TMenuItemGroup* group; + while ((group = static_cast(fGroups.RemoveItem(0L))) != NULL) delete group; } bool -TGroupedMenu::AddGroup(TMenuItemGroup *group) +TGroupedMenu::AddGroup(TMenuItemGroup* group) { if (!fGroups.AddItem(group)) return false; @@ -198,7 +198,7 @@ TGroupedMenu::AddGroup(TMenuItemGroup *group) bool -TGroupedMenu::AddGroup(TMenuItemGroup *group, int32 atIndex) +TGroupedMenu::AddGroup(TMenuItemGroup* group, int32 atIndex) { if (!fGroups.AddItem(group, atIndex)) return false; @@ -214,7 +214,7 @@ TGroupedMenu::AddGroup(TMenuItemGroup *group, int32 atIndex) bool -TGroupedMenu::RemoveGroup(TMenuItemGroup *group) +TGroupedMenu::RemoveGroup(TMenuItemGroup* group) { if (group->HasSeparator()) { delete RemoveItem(group->fFirstItemIndex); @@ -232,10 +232,10 @@ TGroupedMenu::RemoveGroup(TMenuItemGroup *group) } -TMenuItemGroup * +TMenuItemGroup* TGroupedMenu::GroupAt(int32 index) { - return static_cast(fGroups.ItemAt(index)); + return static_cast(fGroups.ItemAt(index)); } @@ -247,7 +247,7 @@ TGroupedMenu::CountGroups() void -TGroupedMenu::AddGroupItem(TMenuItemGroup *group, BMenuItem *item, int32 atIndex) +TGroupedMenu::AddGroupItem(TMenuItemGroup* group, BMenuItem* item, int32 atIndex) { int32 groupIndex = fGroups.IndexOf(group); bool addSeparator = false; @@ -256,12 +256,12 @@ TGroupedMenu::AddGroupItem(TMenuItemGroup *group, BMenuItem *item, int32 atIndex // find new home for this group if (groupIndex > 0) { // add this group after an existing one - TMenuItemGroup *previous = GroupAt(groupIndex - 1); + TMenuItemGroup* previous = GroupAt(groupIndex - 1); group->fFirstItemIndex = previous->fFirstItemIndex + previous->fItemsTotal; addSeparator = true; } else { // this is the first group - TMenuItemGroup *successor = GroupAt(groupIndex + 1); + TMenuItemGroup* successor = GroupAt(groupIndex + 1); if (successor != NULL) { group->fFirstItemIndex = successor->fFirstItemIndex; if (successor->fHasSeparator) { @@ -295,7 +295,7 @@ TGroupedMenu::AddGroupItem(TMenuItemGroup *group, BMenuItem *item, int32 atIndex void -TGroupedMenu::RemoveGroupItem(TMenuItemGroup *group, BMenuItem *item) +TGroupedMenu::RemoveGroupItem(TMenuItemGroup* group, BMenuItem* item) { int32 groupIndex = fGroups.IndexOf(group); bool removedSeparator = false; diff --git a/src/kits/tracker/GroupedMenu.h b/src/kits/tracker/GroupedMenu.h index ab6e2e765a..908eac88ae 100644 --- a/src/kits/tracker/GroupedMenu.h +++ b/src/kits/tracker/GroupedMenu.h @@ -13,19 +13,19 @@ class TGroupedMenu; class TMenuItemGroup { public: - TMenuItemGroup(const char *name); + TMenuItemGroup(const char* name); ~TMenuItemGroup(); - bool AddItem(BMenuItem *item); - bool AddItem(BMenuItem *item, int32 atIndex); - bool AddItem(BMenu *menu); - bool AddItem(BMenu *menu, int32 atIndex); + bool AddItem(BMenuItem* item); + bool AddItem(BMenuItem* item, int32 atIndex); + bool AddItem(BMenu* menu); + bool AddItem(BMenu* menu, int32 atIndex); - bool RemoveItem(BMenuItem *item); - bool RemoveItem(BMenu *menu); - BMenuItem *RemoveItem(int32 index); + bool RemoveItem(BMenuItem* item); + bool RemoveItem(BMenu* menu); + BMenuItem* RemoveItem(int32 index); - BMenuItem *ItemAt(int32 index); + BMenuItem* ItemAt(int32 index); int32 CountItems(); private: @@ -34,9 +34,9 @@ class TMenuItemGroup { bool HasSeparator(); private: - const char *fName; + const char* fName; BList fList; - TGroupedMenu *fMenu; + TGroupedMenu* fMenu; int32 fFirstItemIndex; int32 fItemsTotal; bool fHasSeparator; @@ -45,21 +45,21 @@ class TMenuItemGroup { class TGroupedMenu : public BMenu { public: - TGroupedMenu(const char *name); + TGroupedMenu(const char* name); ~TGroupedMenu(); - bool AddGroup(TMenuItemGroup *group); - bool AddGroup(TMenuItemGroup *group, int32 atIndex); + bool AddGroup(TMenuItemGroup* group); + bool AddGroup(TMenuItemGroup* group, int32 atIndex); - bool RemoveGroup(TMenuItemGroup *group); + bool RemoveGroup(TMenuItemGroup* group); - TMenuItemGroup *GroupAt(int32 index); + TMenuItemGroup* GroupAt(int32 index); int32 CountGroups(); private: friend class TMenuItemGroup; - void AddGroupItem(TMenuItemGroup *group, BMenuItem *item, int32 atIndex); - void RemoveGroupItem(TMenuItemGroup *group, BMenuItem *item); + void AddGroupItem(TMenuItemGroup* group, BMenuItem* item, int32 atIndex); + void RemoveGroupItem(TMenuItemGroup* group, BMenuItem* item); private: BList fGroups; @@ -67,4 +67,4 @@ class TGroupedMenu : public BMenu { } // namespace BPrivate -#endif /* GROUPED_MENU_H */ +#endif // GROUPED_MENU_H diff --git a/src/kits/tracker/IconCache.cpp b/src/kits/tracker/IconCache.cpp index e9ad7801d9..bfdc610f3d 100644 --- a/src/kits/tracker/IconCache.cpp +++ b/src/kits/tracker/IconCache.cpp @@ -128,24 +128,24 @@ IconCacheEntry::~IconCacheEntry() void -IconCacheEntry::SetAliasFor(const SharedIconCache *sharedCache, - const SharedCacheEntry *entry) +IconCacheEntry::SetAliasFor(const SharedIconCache* sharedCache, + const SharedCacheEntry* entry) { sharedCache->SetAliasFor(this, entry); ASSERT(fAliasForIndex >= 0); } -IconCacheEntry * -IconCacheEntry::ResolveIfAlias(const SharedIconCache *sharedCache) +IconCacheEntry* +IconCacheEntry::ResolveIfAlias(const SharedIconCache* sharedCache) { return sharedCache->ResolveIfAlias(this); } -IconCacheEntry * -IconCacheEntry::ResolveIfAlias(const SharedIconCache *sharedCache, - IconCacheEntry *entry) +IconCacheEntry* +IconCacheEntry::ResolveIfAlias(const SharedIconCache* sharedCache, + IconCacheEntry* entry) { if (!entry) return NULL; @@ -188,7 +188,7 @@ IconCacheEntry::HaveIconBitmap(IconDrawMode mode, icon_size size) const } -BBitmap * +BBitmap* IconCacheEntry::IconForMode(IconDrawMode mode, icon_size size) const { ASSERT(mode == kSelected || mode == kNormalIcon); @@ -213,11 +213,11 @@ bool IconCacheEntry::IconHitTest(BPoint where, IconDrawMode mode, icon_size size) const { ASSERT(where.x < size && where.y < size); - BBitmap *bitmap = IconForMode(mode, size); + BBitmap* bitmap = IconForMode(mode, size); if (!bitmap) return false; - uchar *bits = (uchar *)bitmap->Bits(); + uchar* bits = (uchar*)bitmap->Bits(); ASSERT(bits); BRect bounds(bitmap->Bounds()); @@ -241,9 +241,9 @@ IconCacheEntry::IconHitTest(BPoint where, IconDrawMode mode, icon_size size) con } -BBitmap * -IconCacheEntry::ConstructBitmap(BBitmap *constructFrom, IconDrawMode requestedMode, - IconDrawMode constructFromMode, icon_size size, LazyBitmapAllocator *lazyBitmap) +BBitmap* +IconCacheEntry::ConstructBitmap(BBitmap* constructFrom, IconDrawMode requestedMode, + IconDrawMode constructFromMode, icon_size size, LazyBitmapAllocator* lazyBitmap) { ASSERT(requestedMode == kSelected && constructFromMode == kNormalIcon); // for now @@ -254,11 +254,11 @@ IconCacheEntry::ConstructBitmap(BBitmap *constructFrom, IconDrawMode requestedMo } -BBitmap * +BBitmap* IconCacheEntry::ConstructBitmap(IconDrawMode requestedMode, icon_size size, - LazyBitmapAllocator *lazyBitmap) + LazyBitmapAllocator* lazyBitmap) { - BBitmap *source = (size == B_MINI_ICON) ? fMiniIcon : fLargeIcon; + BBitmap* source = (size == B_MINI_ICON) ? fMiniIcon : fLargeIcon; ASSERT(source); return ConstructBitmap(source, requestedMode, kNormalIcon, size, lazyBitmap); } @@ -278,7 +278,7 @@ IconCacheEntry::AlternateModeForIconConstructing(IconDrawMode requestedMode, void -IconCacheEntry::SetIcon(BBitmap *bitmap, IconDrawMode mode, icon_size size, +IconCacheEntry::SetIcon(BBitmap* bitmap, IconDrawMode mode, icon_size size, bool /*create*/) { if (mode == kNormalIcon) { @@ -311,10 +311,10 @@ IconCache::IconCache() // icon is not available // for now the code only looks for normal icons, selected icons are auto-generated -IconCacheEntry * -IconCache::GetIconForPreferredApp(const char *fileTypeSignature, - const char *preferredApp, IconDrawMode mode, icon_size size, - LazyBitmapAllocator *lazyBitmap, IconCacheEntry *entry) +IconCacheEntry* +IconCache::GetIconForPreferredApp(const char* fileTypeSignature, + const char* preferredApp, IconDrawMode mode, icon_size size, + LazyBitmapAllocator* lazyBitmap, IconCacheEntry* entry) { ASSERT(fSharedCache.IsLocked()); @@ -346,7 +346,7 @@ IconCache::GetIconForPreferredApp(const char *fileTypeSignature, size) != B_OK) return NULL; - BBitmap *bitmap = lazyBitmap->Adopt(); + BBitmap* bitmap = lazyBitmap->Adopt(); if (!entry) { PRINT_ADD_ITEM(("File %s; Line %d # adding entry for preferredApp %s, type %s\n", __FILE__, __LINE__, preferredApp, fileTypeSignature)); @@ -365,9 +365,9 @@ IconCache::GetIconForPreferredApp(const char *fileTypeSignature, } -IconCacheEntry * -IconCache::GetIconFromMetaMime(const char *fileType, IconDrawMode mode, - icon_size size, LazyBitmapAllocator *lazyBitmap, IconCacheEntry *entry) +IconCacheEntry* +IconCache::GetIconFromMetaMime(const char* fileType, IconDrawMode mode, + icon_size size, LazyBitmapAllocator* lazyBitmap, IconCacheEntry* entry) { ASSERT(fSharedCache.IsLocked()); @@ -393,12 +393,12 @@ IconCache::GetIconFromMetaMime(const char *fileType, IconDrawMode mode, if (mime.GetPreferredApp(preferredAppSig) != B_OK) return NULL; - SharedCacheEntry *aliasTo = NULL; + SharedCacheEntry* aliasTo = NULL; if (entry) - aliasTo = (SharedCacheEntry *)entry->ResolveIfAlias(&fSharedCache); + aliasTo = (SharedCacheEntry*)entry->ResolveIfAlias(&fSharedCache); // look for icon defined by preferred app from metamime - aliasTo = (SharedCacheEntry *)GetIconForPreferredApp(fileType, + aliasTo = (SharedCacheEntry*)GetIconForPreferredApp(fileType, preferredAppSig, mode, size, lazyBitmap, aliasTo); if (aliasTo == NULL) @@ -417,7 +417,7 @@ IconCache::GetIconFromMetaMime(const char *fileType, IconDrawMode mode, } // at this point, we've found an icon for the MIME type - BBitmap *bitmap = lazyBitmap->Adopt(); + BBitmap* bitmap = lazyBitmap->Adopt(); if (!entry) { PRINT_ADD_ITEM(("File %s; Line %d # adding entry for type %s\n", __FILE__, __LINE__, fileType)); @@ -443,17 +443,17 @@ IconCache::GetIconFromMetaMime(const char *fileType, IconDrawMode mode, } -IconCacheEntry * -IconCache::GetIconFromFileTypes(ModelNodeLazyOpener *modelOpener, +IconCacheEntry* +IconCache::GetIconFromFileTypes(ModelNodeLazyOpener* modelOpener, IconSource &source, IconDrawMode mode, icon_size size, - LazyBitmapAllocator *lazyBitmap, IconCacheEntry *entry) + LazyBitmapAllocator* lazyBitmap, IconCacheEntry* entry) { ASSERT(fSharedCache.IsLocked()); // use file types to get the icon - Model *model = modelOpener->TargetModel(); + Model* model = modelOpener->TargetModel(); - const char *fileType = model->MimeType(); - const char *nodePreferredApp = model->PreferredAppSignature(); + const char* fileType = model->MimeType(); + const char* nodePreferredApp = model->PreferredAppSignature(); if (source == kUnknownSource || source == kUnknownNotFromNode || source == kPreferredAppForNode) { @@ -483,7 +483,7 @@ IconCache::GetIconFromFileTypes(ModelNodeLazyOpener *modelOpener, if (!mime.IsSupertypeOnly()) { BMimeType superType; mime.GetSupertype(&superType); - const char *superTypeFileType = superType.Type(); + const char* superTypeFileType = superType.Type(); if (superTypeFileType) entry = GetIconFromMetaMime(superTypeFileType, mode, size, lazyBitmap, entry); @@ -505,9 +505,9 @@ IconCache::GetIconFromFileTypes(ModelNodeLazyOpener *modelOpener, PRINT_ADD_ITEM(("File %s; Line %d # adding entry as alias for preferredApp %s, type %s\n", __FILE__, __LINE__, nodePreferredApp, fileType)); - IconCacheEntry *aliasedEntry = fSharedCache.AddItem((SharedCacheEntry **)&entry, + IconCacheEntry* aliasedEntry = fSharedCache.AddItem((SharedCacheEntry**)&entry, fileType, nodePreferredApp); - aliasedEntry->SetAliasFor(&fSharedCache, (SharedCacheEntry *)entry); + aliasedEntry->SetAliasFor(&fSharedCache, (SharedCacheEntry*)entry); // OK to cast here, have a runtime check source = kPreferredAppForNode; // set source as preferred for node, so that next time we get a hit in @@ -523,17 +523,17 @@ IconCache::GetIconFromFileTypes(ModelNodeLazyOpener *modelOpener, return entry; } -IconCacheEntry * -IconCache::GetVolumeIcon(AutoLock *nodeCacheLocker, - AutoLock *sharedCacheLocker, - AutoLock **resultingOpenCache, - Model *model, IconSource &source, - IconDrawMode mode, icon_size size, LazyBitmapAllocator *lazyBitmap) +IconCacheEntry* +IconCache::GetVolumeIcon(AutoLock*nodeCacheLocker, + AutoLock* sharedCacheLocker, + AutoLock** resultingOpenCache, + Model* model, IconSource &source, + IconDrawMode mode, icon_size size, LazyBitmapAllocator* lazyBitmap) { *resultingOpenCache = nodeCacheLocker; nodeCacheLocker->Lock(); - IconCacheEntry *entry = 0; + IconCacheEntry* entry = 0; if (source != kUnknownSource) { // cached in the node cache entry = fNodeCache.FindItem(model->NodeRef()); @@ -560,7 +560,7 @@ IconCache::GetVolumeIcon(AutoLock *nodeCacheLocker, if (volume.IsShared()) { // Check if it's a network share and give it a special icon - BBitmap *bitmap = lazyBitmap->Get(); + BBitmap* bitmap = lazyBitmap->Get(); GetTrackerResources()->GetIconResource(R_ShareIcon, size, bitmap); if (!entry) { PRINT_ADD_ITEM(("File %s; Line %d # adding entry for model %s\n", @@ -570,7 +570,7 @@ IconCache::GetVolumeIcon(AutoLock *nodeCacheLocker, entry->SetIcon(lazyBitmap->Adopt(), kNormalIcon, size); } else if (volume.GetIcon(lazyBitmap->Get(), size) == B_OK) { // Ask the device for an icon - BBitmap *bitmap = lazyBitmap->Adopt(); + BBitmap* bitmap = lazyBitmap->Adopt(); ASSERT(bitmap); if (!entry) { PRINT_ADD_ITEM(("File %s; Line %d # adding entry for model %s\n", @@ -599,12 +599,12 @@ IconCache::GetVolumeIcon(AutoLock *nodeCacheLocker, } -IconCacheEntry * -IconCache::GetRootIcon(AutoLock *, - AutoLock *sharedCacheLocker, - AutoLock **resultingOpenCache, - Model *, IconSource &source, IconDrawMode mode, - icon_size size, LazyBitmapAllocator *lazyBitmap) +IconCacheEntry* +IconCache::GetRootIcon(AutoLock*, + AutoLock* sharedCacheLocker, + AutoLock** resultingOpenCache, + Model*, IconSource &source, IconDrawMode mode, + icon_size size, LazyBitmapAllocator* lazyBitmap) { *resultingOpenCache = sharedCacheLocker; (*resultingOpenCache)->Lock(); @@ -614,19 +614,19 @@ IconCache::GetRootIcon(AutoLock *, } -IconCacheEntry * -IconCache::GetWellKnownIcon(AutoLock *, - AutoLock *sharedCacheLocker, - AutoLock **resultingOpenCache, - Model *model, IconSource &source, IconDrawMode mode, icon_size size, - LazyBitmapAllocator *lazyBitmap) +IconCacheEntry* +IconCache::GetWellKnownIcon(AutoLock*, + AutoLock* sharedCacheLocker, + AutoLock** resultingOpenCache, + Model* model, IconSource &source, IconDrawMode mode, icon_size size, + LazyBitmapAllocator* lazyBitmap) { - const WellKnowEntryList::WellKnownEntry *wellKnownEntry + const WellKnowEntryList::WellKnownEntry* wellKnownEntry = WellKnowEntryList::MatchEntry(model->NodeRef()); if (!wellKnownEntry) return NULL; - IconCacheEntry *entry = NULL; + IconCacheEntry* entry = NULL; BString type("tracker/active_"); type += wellKnownEntry->name; @@ -709,7 +709,7 @@ IconCache::GetWellKnownIcon(AutoLock *, entry = fSharedCache.AddItem(type.String()); - BBitmap *bitmap = lazyBitmap->Get(); + BBitmap* bitmap = lazyBitmap->Get(); GetTrackerResources()->GetIconResource(resid, size, bitmap); entry->SetIcon(lazyBitmap->Adopt(), kNormalIcon, size); } @@ -725,13 +725,13 @@ IconCache::GetWellKnownIcon(AutoLock *, } -IconCacheEntry * -IconCache::GetNodeIcon(ModelNodeLazyOpener *modelOpener, - AutoLock *nodeCacheLocker, - AutoLock **resultingOpenCache, - Model *model, IconSource &source, +IconCacheEntry* +IconCache::GetNodeIcon(ModelNodeLazyOpener* modelOpener, + AutoLock* nodeCacheLocker, + AutoLock** resultingOpenCache, + Model* model, IconSource &source, IconDrawMode mode, icon_size size, - LazyBitmapAllocator *lazyBitmap, IconCacheEntry *entry, bool permanent) + LazyBitmapAllocator* lazyBitmap, IconCacheEntry* entry, bool permanent) { *resultingOpenCache = nodeCacheLocker; (*resultingOpenCache)->Lock(); @@ -740,13 +740,13 @@ IconCache::GetNodeIcon(ModelNodeLazyOpener *modelOpener, if (!entry || !entry->HaveIconBitmap(NORMAL_ICON_ONLY, size)) { modelOpener->OpenNode(); - BFile *file = NULL; + BFile* file = NULL; // if we are dealing with an application, use the BAppFileInfo // superset of node; this makes GetIcon grab the proper icon for // an app if (model->IsExecutable()) - file = dynamic_cast(model->Node()); + file = dynamic_cast(model->Node()); PRINT_DISK_HITS(("File %s; Line %d # hitting disk for node %s\n", __FILE__, __LINE__, model->Name())); @@ -760,7 +760,7 @@ IconCache::GetNodeIcon(ModelNodeLazyOpener *modelOpener, if (result == B_OK) { // node has it's own icon, use it - BBitmap *bitmap = lazyBitmap->Adopt(); + BBitmap* bitmap = lazyBitmap->Adopt(); PRINT_ADD_ITEM(("File %s; Line %d # adding entry for model %s\n", __FILE__, __LINE__, model->Name())); entry = fNodeCache.AddItem(model->NodeRef(), permanent); @@ -788,12 +788,12 @@ IconCache::GetNodeIcon(ModelNodeLazyOpener *modelOpener, } -IconCacheEntry * -IconCache::GetGenericIcon(AutoLock *sharedCacheLocker, - AutoLock **resultingOpenCache, - Model *model, IconSource &source, +IconCacheEntry* +IconCache::GetGenericIcon(AutoLock* sharedCacheLocker, + AutoLock** resultingOpenCache, + Model* model, IconSource &source, IconDrawMode mode, icon_size size, - LazyBitmapAllocator *lazyBitmap, IconCacheEntry *entry) + LazyBitmapAllocator* lazyBitmap, IconCacheEntry* entry) { *resultingOpenCache = sharedCacheLocker; (*resultingOpenCache)->Lock(); @@ -809,10 +809,10 @@ IconCache::GetGenericIcon(AutoLock *sharedCacheLocker, PRINT_ADD_ITEM(("File %s; Line %d # adding entry for preferredApp %s, type %s\n", __FILE__, __LINE__, model->PreferredAppSignature(), model->MimeType())); - IconCacheEntry *aliasedEntry = fSharedCache.AddItem( - (SharedCacheEntry **)&entry, model->MimeType(), + IconCacheEntry* aliasedEntry = fSharedCache.AddItem( + (SharedCacheEntry**)&entry, model->MimeType(), model->PreferredAppSignature()); - aliasedEntry->SetAliasFor(&fSharedCache, (SharedCacheEntry *)entry); + aliasedEntry->SetAliasFor(&fSharedCache, (SharedCacheEntry*)entry); source = kMetaMime; @@ -821,11 +821,11 @@ IconCache::GetGenericIcon(AutoLock *sharedCacheLocker, } -IconCacheEntry * -IconCache::GetFallbackIcon(AutoLock *sharedCacheLocker, - AutoLock **resultingOpenCache, - Model *model, IconDrawMode mode, icon_size size, - LazyBitmapAllocator *lazyBitmap, IconCacheEntry *entry) +IconCacheEntry* +IconCache::GetFallbackIcon(AutoLock* sharedCacheLocker, + AutoLock** resultingOpenCache, + Model* model, IconDrawMode mode, icon_size size, + LazyBitmapAllocator* lazyBitmap, IconCacheEntry* entry) { *resultingOpenCache = sharedCacheLocker; (*resultingOpenCache)->Lock(); @@ -833,7 +833,7 @@ IconCache::GetFallbackIcon(AutoLock *sharedCacheLocker, entry = fSharedCache.AddItem(model->MimeType(), model->PreferredAppSignature()); - BBitmap *bitmap = lazyBitmap->Get(); + BBitmap* bitmap = lazyBitmap->Get(); GetTrackerResources()->GetIconResource(R_FileIcon, size, bitmap); entry->SetIcon(lazyBitmap->Adopt(), kNormalIcon, size); @@ -847,16 +847,16 @@ IconCache::GetFallbackIcon(AutoLock *sharedCacheLocker, } -IconCacheEntry * -IconCache::Preload(AutoLock *nodeCacheLocker, - AutoLock *sharedCacheLocker, - AutoLock **resultingCache, - Model *model, IconDrawMode mode, icon_size size, +IconCacheEntry* +IconCache::Preload(AutoLock* nodeCacheLocker, + AutoLock* sharedCacheLocker, + AutoLock** resultingCache, + Model* model, IconDrawMode mode, icon_size size, bool permanent) { - IconCacheEntry *entry = NULL; + IconCacheEntry* entry = NULL; - AutoLock *resultingOpenCache = NULL; + AutoLock* resultingOpenCache = NULL; // resultingOpenCache is the locker that points to the cache that // ended with a hit and will be used for the drawing @@ -1031,7 +1031,7 @@ IconCache::Preload(AutoLock *nodeCacheLocker, void -IconCache::Draw(Model *model, BView *view, BPoint where, IconDrawMode mode, +IconCache::Draw(Model* model, BView* view, BPoint where, IconDrawMode mode, icon_size size, bool async) { // the following does not actually lock the caches, we are using the @@ -1040,8 +1040,8 @@ IconCache::Draw(Model *model, BView *view, BPoint where, IconDrawMode mode, AutoLock nodeCacheLocker(&fNodeCache, false); AutoLock sharedCacheLocker(&fSharedCache, false); - AutoLock *resultingCacheLocker; - IconCacheEntry *entry = Preload(&nodeCacheLocker, &sharedCacheLocker, + AutoLock* resultingCacheLocker; + IconCacheEntry* entry = Preload(&nodeCacheLocker, &sharedCacheLocker, &resultingCacheLocker, model, mode, size, false); // Preload finds/creates the appropriate entry, locking down the // cache it is in and returns the whole state back to here @@ -1061,15 +1061,15 @@ IconCache::Draw(Model *model, BView *view, BPoint where, IconDrawMode mode, void -IconCache::SyncDraw(Model *model, BView *view, BPoint where, IconDrawMode mode, - icon_size size, void (*blitFunc)(BView *, BPoint, BBitmap *, void *), - void *passThruState) +IconCache::SyncDraw(Model* model, BView* view, BPoint where, IconDrawMode mode, + icon_size size, void (*blitFunc)(BView*, BPoint, BBitmap*, void*), + void* passThruState) { AutoLock nodeCacheLocker(&fNodeCache, false); AutoLock sharedCacheLocker(&fSharedCache, false); - AutoLock *resultingCacheLocker; - IconCacheEntry *entry = Preload(&nodeCacheLocker, &sharedCacheLocker, + AutoLock* resultingCacheLocker; + IconCacheEntry* entry = Preload(&nodeCacheLocker, &sharedCacheLocker, &resultingCacheLocker, model, mode, size, false); if (!entry) @@ -1083,7 +1083,7 @@ IconCache::SyncDraw(Model *model, BView *view, BPoint where, IconDrawMode mode, void -IconCache::Preload(Model *model, IconDrawMode mode, icon_size size, bool permanent) +IconCache::Preload(Model* model, IconDrawMode mode, icon_size size, bool permanent) { AutoLock nodeCacheLocker(&fNodeCache, false); AutoLock sharedCacheLocker(&fSharedCache, false); @@ -1093,7 +1093,7 @@ IconCache::Preload(Model *model, IconDrawMode mode, icon_size size, bool permane status_t -IconCache::Preload(const char *fileType, IconDrawMode mode, icon_size size) +IconCache::Preload(const char* fileType, IconDrawMode mode, icon_size size) { AutoLock sharedCacheLocker(&fSharedCache); LazyBitmapAllocator lazyBitmap(size); @@ -1105,7 +1105,7 @@ IconCache::Preload(const char *fileType, IconDrawMode mode, icon_size size) return result; // try getting the icon from the preferred app for the signature - IconCacheEntry *entry = GetIconForPreferredApp(fileType, preferredAppSig, + IconCacheEntry* entry = GetIconForPreferredApp(fileType, preferredAppSig, mode, size, &lazyBitmap, 0); if (entry) return B_OK; @@ -1117,7 +1117,7 @@ IconCache::Preload(const char *fileType, IconDrawMode mode, icon_size size) return result; entry = fSharedCache.AddItem(fileType); - BBitmap *bitmap = lazyBitmap.Adopt(); + BBitmap* bitmap = lazyBitmap.Adopt(); entry->SetIcon(bitmap, kNormalIcon, size); if (mode != kNormalIcon) { entry->ConstructBitmap(mode, size, &lazyBitmap); @@ -1129,7 +1129,7 @@ IconCache::Preload(const char *fileType, IconDrawMode mode, icon_size size) void -IconCache::Deleting(const Model *model) +IconCache::Deleting(const Model* model) { AutoLock lock(&fNodeCache); @@ -1141,7 +1141,7 @@ IconCache::Deleting(const Model *model) void -IconCache::Removing(const Model *model) +IconCache::Removing(const Model* model) { AutoLock lock(&fNodeCache); @@ -1151,7 +1151,7 @@ IconCache::Removing(const Model *model) void -IconCache::Deleting(const BView *view) +IconCache::Deleting(const BView* view) { AutoLock lock(&fNodeCache); fNodeCache.Deleting(view); @@ -1159,7 +1159,7 @@ IconCache::Deleting(const BView *view) void -IconCache::IconChanged(Model *model) +IconCache::IconChanged(Model* model) { AutoLock lock(&fNodeCache); @@ -1171,16 +1171,16 @@ IconCache::IconChanged(Model *model) void -IconCache::IconChanged(const char *mimeType, const char *appSignature) +IconCache::IconChanged(const char* mimeType, const char* appSignature) { AutoLock sharedLock(&fSharedCache); - SharedCacheEntry *entry = fSharedCache.FindItem(mimeType, appSignature); + SharedCacheEntry* entry = fSharedCache.FindItem(mimeType, appSignature); if (!entry) return; AutoLock nodeLock(&fNodeCache); - entry = (SharedCacheEntry *)fSharedCache.ResolveIfAlias(entry); + entry = (SharedCacheEntry*)fSharedCache.ResolveIfAlias(entry); ASSERT(entry); int32 index = fSharedCache.EntryIndex(entry); @@ -1191,9 +1191,9 @@ IconCache::IconChanged(const char *mimeType, const char *appSignature) } -BBitmap * -IconCache::MakeSelectedIcon(const BBitmap *normal, icon_size size, - LazyBitmapAllocator *lazyBitmap) +BBitmap* +IconCache::MakeSelectedIcon(const BBitmap* normal, icon_size size, + LazyBitmapAllocator* lazyBitmap) { return MakeTransformedIcon(normal, size, fHiliteTable, lazyBitmap); } @@ -1201,7 +1201,7 @@ IconCache::MakeSelectedIcon(const BBitmap *normal, icon_size size, #if xDEBUG static void -DumpBitmap(const BBitmap *bitmap) +DumpBitmap(const BBitmap* bitmap) { if (!bitmap){ printf("NULL bitmap passed to DumpBitmap\n"); @@ -1212,7 +1212,7 @@ DumpBitmap(const BBitmap *bitmap) printf("data length %ld \n", length); int32 columns = (int32)bitmap->Bounds().Width() + 1; - const unsigned char *bitPtr = (const unsigned char *)bitmap->Bits(); + const unsigned char* bitPtr = (const unsigned char*)bitmap->Bits(); for (; length >= 0; length--) { for (int32 columnIndex = 0; columnIndex < columns; columnIndex++, length--) @@ -1242,7 +1242,7 @@ IconCache::InitHiliteTable() } -BBitmap * +BBitmap* IconCache::MakeTransformedIcon(const BBitmap* source, icon_size /*size*/, int32 colorTransformTable[], LazyBitmapAllocator* lazyBitmap) { @@ -1306,15 +1306,15 @@ IconCache::MakeTransformedIcon(const BBitmap* source, icon_size /*size*/, bool -IconCache::IconHitTest(BPoint where, const Model *model, IconDrawMode mode, +IconCache::IconHitTest(BPoint where, const Model* model, IconDrawMode mode, icon_size size) { AutoLock nodeCacheLocker(&fNodeCache, false); AutoLock sharedCacheLocker(&fSharedCache, false); - AutoLock *resultingCacheLocker; - IconCacheEntry *entry = Preload(&nodeCacheLocker, &sharedCacheLocker, - &resultingCacheLocker, const_cast(model), mode, size, false); + AutoLock* resultingCacheLocker; + IconCacheEntry* entry = Preload(&nodeCacheLocker, &sharedCacheLocker, + &resultingCacheLocker, const_cast(model), mode, size, false); // Preload finds/creates the appropriate entry, locking down the // cache it is in and returns the whole state back to here @@ -1326,7 +1326,7 @@ IconCache::IconHitTest(BPoint where, const Model *model, IconDrawMode mode, void -IconCacheEntry::RetireIcons(BObjectList *retiredBitmapList) +IconCacheEntry::RetireIcons(BObjectList* retiredBitmapList) { if (fLargeIcon) { retiredBitmapList->AddItem(fLargeIcon); @@ -1379,31 +1379,31 @@ SharedIconCache::SharedIconCache() void -SharedIconCache::Draw(IconCacheEntry *entry, BView *view, BPoint where, +SharedIconCache::Draw(IconCacheEntry* entry, BView* view, BPoint where, IconDrawMode mode, icon_size size, bool async) { - ((SharedCacheEntry *)entry)->Draw(view, where, mode, size, async); + ((SharedCacheEntry*)entry)->Draw(view, where, mode, size, async); } void -SharedIconCache::Draw(IconCacheEntry *entry, BView *view, BPoint where, - IconDrawMode mode, icon_size size, void (*blitFunc)(BView *, BPoint, - BBitmap *, void *), void *passThruState) +SharedIconCache::Draw(IconCacheEntry* entry, BView* view, BPoint where, + IconDrawMode mode, icon_size size, void (*blitFunc)(BView*, BPoint, + BBitmap*, void*), void* passThruState) { - ((SharedCacheEntry *)entry)->Draw(view, where, mode, size, + ((SharedCacheEntry*)entry)->Draw(view, where, mode, size, blitFunc, passThruState); } -SharedCacheEntry * -SharedIconCache::FindItem(const char *fileType, const char *appSignature) const +SharedCacheEntry* +SharedIconCache::FindItem(const char* fileType, const char* appSignature) const { ASSERT(fileType); if (!fileType) fileType = B_FILE_MIMETYPE; - SharedCacheEntry *result = fHashTable.FindFirst(SharedCacheEntry::Hash(fileType, + SharedCacheEntry* result = fHashTable.FindFirst(SharedCacheEntry::Hash(fileType, appSignature)); if (!result) @@ -1416,30 +1416,30 @@ SharedIconCache::FindItem(const char *fileType, const char *appSignature) const if (result->fNext < 0) break; - result = const_cast(&fElementArray.At(result->fNext)); + result = const_cast(&fElementArray.At(result->fNext)); } return NULL; } -SharedCacheEntry * -SharedIconCache::AddItem(const char *fileType, const char *appSignature) +SharedCacheEntry* +SharedIconCache::AddItem(const char* fileType, const char* appSignature) { ASSERT(fileType); if (!fileType) fileType = B_FILE_MIMETYPE; - SharedCacheEntry *result = fHashTable.Add(SharedCacheEntry::Hash(fileType, + SharedCacheEntry* result = fHashTable.Add(SharedCacheEntry::Hash(fileType, appSignature)); result->SetTo(fileType, appSignature); return result; } -SharedCacheEntry * -SharedIconCache::AddItem(SharedCacheEntry **outstandingEntry, const char *fileType, - const char *appSignature) +SharedCacheEntry* +SharedIconCache::AddItem(SharedCacheEntry** outstandingEntry, const char* fileType, + const char* appSignature) { int32 entryToken = fHashTable.ElementIndex(*outstandingEntry); ASSERT(entryToken >= 0); @@ -1448,7 +1448,7 @@ SharedIconCache::AddItem(SharedCacheEntry **outstandingEntry, const char *fileTy if (!fileType) fileType = B_FILE_MIMETYPE; - SharedCacheEntry *result = fHashTable.Add(SharedCacheEntry::Hash(fileType, + SharedCacheEntry* result = fHashTable.Add(SharedCacheEntry::Hash(fileType, appSignature)); result->SetTo(fileType, appSignature); *outstandingEntry = fHashTable.ElementAt(entryToken); @@ -1458,7 +1458,7 @@ SharedIconCache::AddItem(SharedCacheEntry **outstandingEntry, const char *fileTy void -SharedIconCache::IconChanged(SharedCacheEntry *entry) +SharedIconCache::IconChanged(SharedCacheEntry* entry) { // by now there should be no aliases to entry, just remove entry // itself @@ -1473,7 +1473,7 @@ SharedIconCache::RemoveAliasesTo(int32 aliasIndex) { int32 count = fHashTable.VectorSize(); for (int32 index = 0; index < count; index++) { - SharedCacheEntry *entry = fHashTable.ElementAt(index); + SharedCacheEntry* entry = fHashTable.ElementAt(index); if (entry->fAliasForIndex == aliasIndex) fHashTable.Remove(entry); } @@ -1481,7 +1481,7 @@ SharedIconCache::RemoveAliasesTo(int32 aliasIndex) void -SharedIconCache::SetAliasFor(IconCacheEntry *alias, const SharedCacheEntry *original) const +SharedIconCache::SetAliasFor(IconCacheEntry* alias, const SharedCacheEntry* original) const { alias->fAliasForIndex = fHashTable.ElementIndex(original); } @@ -1493,7 +1493,7 @@ SharedCacheEntry::SharedCacheEntry() } -SharedCacheEntry::SharedCacheEntry(const char *fileType, const char *appSignature) +SharedCacheEntry::SharedCacheEntry(const char* fileType, const char* appSignature) : fNext(-1), fFileType(fileType), fAppSignature(appSignature) @@ -1529,10 +1529,10 @@ SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size s void -SharedCacheEntry::Draw(BView *view, BPoint where, IconDrawMode mode, icon_size size, - void (*blitFunc)(BView *, BPoint ,BBitmap *, void *), void *passThruState) +SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size size, + void (*blitFunc)(BView*, BPoint, BBitmap*, void*), void* passThruState) { - BBitmap *bitmap = IconForMode(mode, size); + BBitmap* bitmap = IconForMode(mode, size); if (!bitmap) return; @@ -1548,7 +1548,7 @@ SharedCacheEntry::Draw(BView *view, BPoint where, IconDrawMode mode, icon_size s uint32 -SharedCacheEntry::Hash(const char *fileType, const char *appSignature) +SharedCacheEntry::Hash(const char* fileType, const char* appSignature) { uint32 hash = HashString(fileType, 0); if (appSignature && appSignature[0]) @@ -1577,7 +1577,7 @@ SharedCacheEntry::operator==(const SharedCacheEntry &entry) const void -SharedCacheEntry::SetTo(const char *fileType, const char *appSignature) +SharedCacheEntry::SetTo(const char* fileType, const char* appSignature) { fFileType = fileType; fAppSignature = appSignature; @@ -1590,7 +1590,7 @@ SharedCacheEntryArray::SharedCacheEntryArray(int32 initialSize) } -SharedCacheEntry * +SharedCacheEntry* SharedCacheEntryArray::Add() { return OpenHashElementArray::Add(); @@ -1607,7 +1607,7 @@ NodeCacheEntry::NodeCacheEntry(bool permanent) } -NodeCacheEntry::NodeCacheEntry(const node_ref *node, bool permanent) +NodeCacheEntry::NodeCacheEntry(const node_ref* node, bool permanent) : fNext(-1), fRef(*node), fPermanent(permanent) @@ -1616,10 +1616,10 @@ NodeCacheEntry::NodeCacheEntry(const node_ref *node, bool permanent) void -NodeCacheEntry::Draw(BView *view, BPoint where, IconDrawMode mode, icon_size size, +NodeCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size size, bool async) { - BBitmap *bitmap = IconForMode(mode, size); + BBitmap* bitmap = IconForMode(mode, size); if (!bitmap) return; @@ -1646,10 +1646,10 @@ NodeCacheEntry::Draw(BView *view, BPoint where, IconDrawMode mode, icon_size siz void -NodeCacheEntry::Draw(BView *view, BPoint where, IconDrawMode mode, icon_size size, - void (*blitFunc)(BView *, BPoint ,BBitmap *, void *), void *passThruState) +NodeCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size size, + void (*blitFunc)(BView*, BPoint, BBitmap*, void*), void* passThruState) { - BBitmap *bitmap = IconForMode(mode, size); + BBitmap* bitmap = IconForMode(mode, size); if (!bitmap) return; @@ -1664,7 +1664,7 @@ NodeCacheEntry::Draw(BView *view, BPoint where, IconDrawMode mode, icon_size siz } -const node_ref * +const node_ref* NodeCacheEntry::Node() const { return &fRef; @@ -1679,10 +1679,10 @@ NodeCacheEntry::Hash() const uint32 -NodeCacheEntry::Hash(const node_ref *node) +NodeCacheEntry::Hash(const node_ref* node) { - return node->device ^ ((uint32 *)&node->node)[0] - ^ ((uint32 *)&node->node)[1]; + return node->device ^ ((uint32*)&node->node)[0] + ^ ((uint32*)&node->node)[1]; } @@ -1694,7 +1694,7 @@ NodeCacheEntry::operator==(const NodeCacheEntry &entry) const void -NodeCacheEntry::SetTo(const node_ref *node) +NodeCacheEntry::SetTo(const node_ref* node) { fRef = *node; } @@ -1733,28 +1733,28 @@ NodeIconCache::NodeIconCache() void -NodeIconCache::Draw(IconCacheEntry *entry, BView *view, BPoint where, +NodeIconCache::Draw(IconCacheEntry* entry, BView* view, BPoint where, IconDrawMode mode, icon_size size, bool async) { - ((NodeCacheEntry *)entry)->Draw(view, where, mode, size, async); + ((NodeCacheEntry*)entry)->Draw(view, where, mode, size, async); } void -NodeIconCache::Draw(IconCacheEntry *entry, BView *view, BPoint where, - IconDrawMode mode, icon_size size, void (*blitFunc)(BView *, BPoint, - BBitmap *, void *), void *passThruState) +NodeIconCache::Draw(IconCacheEntry* entry, BView* view, BPoint where, + IconDrawMode mode, icon_size size, void (*blitFunc)(BView*, BPoint, + BBitmap*, void*), void* passThruState) { - ((NodeCacheEntry *)entry)->Draw(view, where, mode, size, + ((NodeCacheEntry*)entry)->Draw(view, where, mode, size, blitFunc, passThruState); } -NodeCacheEntry * -NodeIconCache::FindItem(const node_ref *node) const +NodeCacheEntry* +NodeIconCache::FindItem(const node_ref* node) const { - NodeCacheEntry *result = fHashTable.FindFirst(NodeCacheEntry::Hash(node)); + NodeCacheEntry* result = fHashTable.FindFirst(NodeCacheEntry::Hash(node)); if (!result) return NULL; @@ -1766,17 +1766,17 @@ NodeIconCache::FindItem(const node_ref *node) const if (result->fNext < 0) break; - result = const_cast(&fElementArray.At(result->fNext)); + result = const_cast(&fElementArray.At(result->fNext)); } return NULL; } -NodeCacheEntry * -NodeIconCache::AddItem(const node_ref *node, bool permanent) +NodeCacheEntry* +NodeIconCache::AddItem(const node_ref* node, bool permanent) { - NodeCacheEntry *result = fHashTable.Add(NodeCacheEntry::Hash(node)); + NodeCacheEntry* result = fHashTable.Add(NodeCacheEntry::Hash(node)); result->SetTo(node); if (permanent) result->MakePermanent(); @@ -1785,12 +1785,12 @@ NodeIconCache::AddItem(const node_ref *node, bool permanent) } -NodeCacheEntry * -NodeIconCache::AddItem(NodeCacheEntry **outstandingEntry, const node_ref *node) +NodeCacheEntry* +NodeIconCache::AddItem(NodeCacheEntry** outstandingEntry, const node_ref* node) { int32 entryToken = fHashTable.ElementIndex(*outstandingEntry); - NodeCacheEntry *result = fHashTable.Add(NodeCacheEntry::Hash(node)); + NodeCacheEntry* result = fHashTable.Add(NodeCacheEntry::Hash(node)); result->SetTo(node); *outstandingEntry = fHashTable.ElementAt(entryToken); @@ -1799,9 +1799,9 @@ NodeIconCache::AddItem(NodeCacheEntry **outstandingEntry, const node_ref *node) void -NodeIconCache::Deleting(const node_ref *node) +NodeIconCache::Deleting(const node_ref* node) { - NodeCacheEntry *entry = FindItem(node); + NodeCacheEntry* entry = FindItem(node); ASSERT(entry); if (!entry || entry->Permanent()) return; @@ -1811,9 +1811,9 @@ NodeIconCache::Deleting(const node_ref *node) void -NodeIconCache::Removing(const node_ref *node) +NodeIconCache::Removing(const node_ref* node) { - NodeCacheEntry *entry = FindItem(node); + NodeCacheEntry* entry = FindItem(node); ASSERT(entry); if (!entry) return; @@ -1823,7 +1823,7 @@ NodeIconCache::Removing(const node_ref *node) void -NodeIconCache::Deleting(const BView *) +NodeIconCache::Deleting(const BView*) { #ifdef NODE_CACHE_ASYNC_DRAWS TRESPASS(); @@ -1832,7 +1832,7 @@ NodeIconCache::Deleting(const BView *) void -NodeIconCache::IconChanged(const Model *model) +NodeIconCache::IconChanged(const Model* model) { Deleting(model->NodeRef()); } @@ -1843,7 +1843,7 @@ NodeIconCache::RemoveAliasesTo(int32 aliasIndex) { int32 count = fHashTable.VectorSize(); for (int32 index = 0; index < count; index++) { - NodeCacheEntry *entry = fHashTable.ElementAt(index); + NodeCacheEntry* entry = fHashTable.ElementAt(index); if (entry->fAliasForIndex == aliasIndex) fHashTable.Remove(entry); } @@ -1859,7 +1859,7 @@ NodeCacheEntryArray::NodeCacheEntryArray(int32 initialSize) } -NodeCacheEntry * +NodeCacheEntry* NodeCacheEntryArray::Add() { return OpenHashElementArray::Add(); @@ -1869,14 +1869,14 @@ NodeCacheEntryArray::Add() // #pragma mark - -SimpleIconCache::SimpleIconCache(const char *name) +SimpleIconCache::SimpleIconCache(const char* name) : fLock(name) { } void -SimpleIconCache::Draw(IconCacheEntry *, BView *, BPoint, IconDrawMode , +SimpleIconCache::Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode , icon_size , bool ) { TRESPASS(); @@ -1885,8 +1885,8 @@ SimpleIconCache::Draw(IconCacheEntry *, BView *, BPoint, IconDrawMode , void -SimpleIconCache::Draw(IconCacheEntry *, BView *, BPoint, IconDrawMode, icon_size, - void(*)(BView *, BPoint, BBitmap *, void *), void *) +SimpleIconCache::Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode, icon_size, + void(*)(BView*, BPoint, BBitmap*, void*), void*) { TRESPASS(); // pure virtual, do nothing @@ -1934,7 +1934,7 @@ LazyBitmapAllocator::~LazyBitmapAllocator() } -BBitmap * +BBitmap* LazyBitmapAllocator::Get() { if (!fBitmap) @@ -1944,16 +1944,16 @@ LazyBitmapAllocator::Get() } -BBitmap * +BBitmap* LazyBitmapAllocator::Adopt() { if (!fBitmap) Get(); - BBitmap *result = fBitmap; + BBitmap* result = fBitmap; fBitmap = NULL; return result; } -IconCache *IconCache::sIconCache; +IconCache* IconCache::sIconCache; diff --git a/src/kits/tracker/IconCache.h b/src/kits/tracker/IconCache.h index 100c120089..94690f609e 100644 --- a/src/kits/tracker/IconCache.h +++ b/src/kits/tracker/IconCache.h @@ -31,13 +31,14 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - -// Icon cache is used for drawing node icons; it caches icons -// and reuses them for successive draws - #ifndef __NU_ICON_CACHE__ #define __NU_ICON_CACHE__ + +// Icon cache is used for drawing node icons; it caches icons +// and reuses them for successive draws + + #include #include #include @@ -47,6 +48,7 @@ All rights reserved. #include "OpenHashTable.h" #include "Utilities.h" + // Icon cache splits icons into two caches - the shared cache, likely to get the // most hits and the node cache. Every icon that is found in a mime based // structure goes into the shared cache, only files that have their own private @@ -89,6 +91,7 @@ enum IconDrawMode { kDimmedIcon }; + #define NORMAL_ICON_ONLY kNormalIcon // replace use of these defines with mode once the respective getters // can get non-plain icons @@ -110,6 +113,7 @@ enum IconSource { kNode }; + class IconCacheEntry { // aliased entries don't own their icons, just point // to some other entry that does @@ -122,46 +126,46 @@ public: IconCacheEntry(); ~IconCacheEntry(); - void SetAliasFor(const SharedIconCache *, const SharedCacheEntry *); - static IconCacheEntry *ResolveIfAlias(const SharedIconCache *, IconCacheEntry *); - IconCacheEntry *ResolveIfAlias(const SharedIconCache *); + void SetAliasFor(const SharedIconCache*, const SharedCacheEntry*); + static IconCacheEntry* ResolveIfAlias(const SharedIconCache*, IconCacheEntry*); + IconCacheEntry* ResolveIfAlias(const SharedIconCache*); - void SetIcon(BBitmap *bitmap, IconDrawMode mode, icon_size size, + void SetIcon(BBitmap* bitmap, IconDrawMode mode, icon_size size, bool create = false); bool HaveIconBitmap(IconDrawMode mode, icon_size size) const; bool CanConstructBitmap(IconDrawMode mode, icon_size size) const; static bool AlternateModeForIconConstructing(IconDrawMode requestedMode, IconDrawMode &alternate, icon_size size); - BBitmap *ConstructBitmap(BBitmap *constructFrom, IconDrawMode requestedMode, + BBitmap* ConstructBitmap(BBitmap* constructFrom, IconDrawMode requestedMode, IconDrawMode constructFromMode, icon_size size, - LazyBitmapAllocator *); - BBitmap *ConstructBitmap(IconDrawMode requestedMode, icon_size size, - LazyBitmapAllocator *); - // same as above, always uses normal icon as source + LazyBitmapAllocator*); + BBitmap* ConstructBitmap(IconDrawMode requestedMode, icon_size size, + LazyBitmapAllocator*); + // same as above, always uses normal icon as source bool IconHitTest(BPoint, IconDrawMode, icon_size) const; // given a point, returns true if a non-transparent pixel was hit - void RetireIcons(BObjectList *retiredBitmapList); + void RetireIcons(BObjectList* retiredBitmapList); // can't just delete icons, they may be still drawing // async; instead, put them on the retired list and // only delete the list if it grows too much, way after // the icon finishes drawing - // + // // This could fail if we retire a lot of icons (10 * 1024) // while we are drawing them, shouldn't be a practical problem protected: - BBitmap *IconForMode(IconDrawMode mode, icon_size size) const; - void SetIconForMode(BBitmap *bitmap, IconDrawMode mode, icon_size size); + BBitmap* IconForMode(IconDrawMode mode, icon_size size) const; + void SetIconForMode(BBitmap* bitmap, IconDrawMode mode, icon_size size); // list of most common icons - BBitmap *fLargeIcon; - BBitmap *fMiniIcon; - BBitmap *fHilitedLargeIcon; - BBitmap *fHilitedMiniIcon; + BBitmap* fLargeIcon; + BBitmap* fMiniIcon; + BBitmap* fHilitedLargeIcon; + BBitmap* fHilitedMiniIcon; int32 fAliasForIndex; // list of other icon kinds would be added here @@ -170,15 +174,17 @@ protected: friend class NodeIconCache; }; + class SimpleIconCache { public: - SimpleIconCache(const char *); + SimpleIconCache(const char*); virtual ~SimpleIconCache() {} - virtual void Draw(IconCacheEntry *, BView *, BPoint, IconDrawMode mode, + virtual void Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode mode, icon_size size, bool async = false) = 0; - virtual void Draw(IconCacheEntry *, BView *, BPoint , IconDrawMode , - icon_size , void (*)(BView *, BPoint, BBitmap *, void *), void * = NULL) = 0; + virtual void Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode, + icon_size, void (*)(BView*, BPoint, BBitmap*, void*), + void* = NULL) = 0; bool Lock(); void Unlock(); @@ -188,25 +194,26 @@ private: Benaphore fLock; }; + class SharedCacheEntry : public IconCacheEntry { public: SharedCacheEntry(); - SharedCacheEntry(const char *fileType, const char *appSignature = 0); + SharedCacheEntry(const char* fileType, const char* appSignature = 0); - void Draw(BView *, BPoint, IconDrawMode mode, icon_size size, + void Draw(BView*, BPoint, IconDrawMode mode, icon_size size, bool async = false); - void Draw(BView *, BPoint , IconDrawMode , icon_size , - void (*)(BView *, BPoint, BBitmap *, void *), void * = NULL); + void Draw(BView*, BPoint, IconDrawMode, icon_size, + void (*)(BView*, BPoint, BBitmap*, void*), void* = NULL); - const char *FileType() const; - const char *AppSignature() const; + const char* FileType() const; + const char* AppSignature() const; // hash table support uint32 Hash() const; - static uint32 Hash(const char *fileType, const char *appSignature = 0); + static uint32 Hash(const char* fileType, const char* appSignature = 0); bool operator==(const SharedCacheEntry &) const; - void SetTo(const char *fileType, const char *appSignature = 0); + void SetTo(const char* fileType, const char* appSignature = 0); int32 fNext; private: @@ -216,35 +223,37 @@ private: friend class SharedIconCache; }; + class SharedCacheEntryArray : public OpenHashElementArray { // SharedIconCache stores all it's elements in this array public: SharedCacheEntryArray(int32 initialSize); - SharedCacheEntry *Add(); + SharedCacheEntry* Add(); }; + class SharedIconCache : public SimpleIconCache { // SharedIconCache is used for icons that come from the mime database public: SharedIconCache(); - virtual void Draw(IconCacheEntry *, BView *, BPoint, IconDrawMode mode, + virtual void Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode mode, icon_size size, bool async = false); - virtual void Draw(IconCacheEntry *, BView *, BPoint , IconDrawMode , - icon_size , void (*)(BView *, BPoint, BBitmap *, void *), void * = NULL); + virtual void Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode, + icon_size, void (*)(BView*, BPoint, BBitmap*, void*), void* = NULL); - SharedCacheEntry *FindItem(const char *fileType, const char *appSignature = 0) + SharedCacheEntry* FindItem(const char* fileType, const char* appSignature = 0) const; - SharedCacheEntry *AddItem(const char *fileType, const char *appSignature = 0); - SharedCacheEntry *AddItem(SharedCacheEntry **outstandingEntry, const char *fileType, - const char *appSignature = 0); + SharedCacheEntry* AddItem(const char* fileType, const char* appSignature = 0); + SharedCacheEntry* AddItem(SharedCacheEntry** outstandingEntry, const char* fileType, + const char* appSignature = 0); // same as previous AddItem, updates the pointer to outstandingEntry, because // adding to the hash table makes any pending pointer invalid - void IconChanged(SharedCacheEntry *); + void IconChanged(SharedCacheEntry*); - void SetAliasFor(IconCacheEntry *alias, const SharedCacheEntry *original) const; - IconCacheEntry *ResolveIfAlias(IconCacheEntry *entry) const; - int32 EntryIndex(const SharedCacheEntry *entry) const; + void SetAliasFor(IconCacheEntry* alias, const SharedCacheEntry* original) const; + IconCacheEntry* ResolveIfAlias(IconCacheEntry* entry) const; + int32 EntryIndex(const SharedCacheEntry* entry) const; void RemoveAliasesTo(int32 index); @@ -257,22 +266,23 @@ private: // and wait for the next sync to delete them }; + class NodeCacheEntry : public IconCacheEntry { public: NodeCacheEntry(bool permanent = false); - NodeCacheEntry(const node_ref *, bool permanent = false); - void Draw(BView *, BPoint, IconDrawMode mode, icon_size size, + NodeCacheEntry(const node_ref*, bool permanent = false); + void Draw(BView*, BPoint, IconDrawMode mode, icon_size size, bool async = false); - void Draw(BView *, BPoint , IconDrawMode , icon_size , - void (*)(BView *, BPoint, BBitmap *, void *), void * = NULL); + void Draw(BView*, BPoint, IconDrawMode, icon_size, + void (*)(BView*, BPoint, BBitmap*, void*), void* = NULL); - const node_ref *Node() const; + const node_ref* Node() const; uint32 Hash() const; - static uint32 Hash(const node_ref *); - bool operator==(const NodeCacheEntry &) const; - void SetTo(const node_ref *); + static uint32 Hash(const node_ref*); + bool operator==(const NodeCacheEntry&) const; + void SetTo(const node_ref*); void MakePermanent(); bool Permanent() const; @@ -285,35 +295,37 @@ private: friend class NodeIconCache; }; + class NodeCacheEntryArray : public OpenHashElementArray { // NodeIconCache stores all it's elements in this array public: NodeCacheEntryArray(int32 initialSize); - NodeCacheEntry *Add(); + NodeCacheEntry* Add(); }; + class NodeIconCache : public SimpleIconCache { // NodeIconCache is used for nodes that define their own icons public: NodeIconCache(); - virtual void Draw(IconCacheEntry *, BView *, BPoint, IconDrawMode , - icon_size , bool async = false); + virtual void Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode, + icon_size, bool async = false); - virtual void Draw(IconCacheEntry *, BView *, BPoint , IconDrawMode , - icon_size , void (*)(BView *, BPoint, BBitmap *, void *), void * = 0); + virtual void Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode, + icon_size, void (*)(BView*, BPoint, BBitmap*, void*), void* = 0); - NodeCacheEntry *FindItem(const node_ref *) const; - NodeCacheEntry *AddItem(const node_ref *, bool permanent = false); - NodeCacheEntry *AddItem(NodeCacheEntry **outstandingEntry, const node_ref *); + NodeCacheEntry* FindItem(const node_ref*) const; + NodeCacheEntry* AddItem(const node_ref*, bool permanent = false); + NodeCacheEntry* AddItem(NodeCacheEntry** outstandingEntry, const node_ref*); // same as previous AddItem, updates the pointer to outstandingEntry, because // adding to the hash table makes any pending pointer invalid - void Deleting(const node_ref *); + void Deleting(const node_ref*); // model for this node is getting deleted (not necessarily the node itself) - void Removing(const node_ref *); + void Removing(const node_ref*); // used by permanent NodeIconCache entries, when an entry gets deleted - void Deleting(const BView *); - void IconChanged(const Model *); + void Deleting(const BView*); + void IconChanged(const Model*); void RemoveAliasesTo(int32 index); @@ -323,20 +335,22 @@ private: NodeCacheEntryArray fElementArray; }; + const int32 kColorTransformTableSize = 256; + class IconCache { public: IconCache(); - void Draw(Model *, BView *, BPoint where, IconDrawMode mode, + void Draw(Model*, BView*, BPoint where, IconDrawMode mode, icon_size size, bool async = false); // draw an icon for a model, load the icon from the appropriate // location if not cached already - void SyncDraw(Model *, BView *, BPoint , IconDrawMode , - icon_size , void (*)(BView *, BPoint, BBitmap *, void *), - void *passThruState = 0); + void SyncDraw(Model*, BView*, BPoint, IconDrawMode, + icon_size, void (*)(BView*, BPoint, BBitmap*, void*), + void* passThruState = 0); // draw an icon for a model, load the icon from the appropriate // location if not cached already; only works for sync draws, // once the call returns, the bitmap may be deleted @@ -344,92 +358,91 @@ public: // preload calls used to ensure successive cache hit for the respective // icon, used for common tracker types, etc; Not calling these should only // cause a slowdown - void Preload(Model *, IconDrawMode mode, icon_size size, bool permanent = false); - status_t Preload(const char *mimeType, IconDrawMode mode, icon_size size); + void Preload(Model*, IconDrawMode mode, icon_size size, + bool permanent = false); + status_t Preload(const char* mimeType, IconDrawMode mode, icon_size size); - void Deleting(const Model *); - // hook to manage unloading icons for nodes that are going away - void Removing(const Model *model); + void Deleting(const Model*); + // hook to manage unloading icons for nodes that are going away + void Removing(const Model* model); // used by permanent NodeIconCache entries, when an entry gets // deleted - void Deleting(const BView *); + void Deleting(const BView*); // hook to manage deleting draw view caches for views that are // going away // icon changed calls, used when a node or a file type has an icon changed // the icons for the node/file type will be flushed and re-cached during // the next draw - void IconChanged(Model *); - void IconChanged(const char *mimeType, const char *appSignature); + void IconChanged(Model*); + void IconChanged(const char* mimeType, const char* appSignature); - bool IsIconFrom(const Model *, const char *mimeType, - const char *appSignature) const; + bool IsIconFrom(const Model*, const char* mimeType, + const char* appSignature) const; // called when metamime database changed to figure out which models // to redraw - bool IconHitTest(BPoint, const Model *, IconDrawMode , icon_size ); + bool IconHitTest(BPoint, const Model*, IconDrawMode, icon_size); // utility calls for building specialized icons - BBitmap *MakeSelectedIcon(const BBitmap *normal, icon_size, - LazyBitmapAllocator *); - - + BBitmap* MakeSelectedIcon(const BBitmap* normal, icon_size, + LazyBitmapAllocator*); + static bool NeedsDeletionNotification(IconSource); - static IconCache *sIconCache; + static IconCache* sIconCache; private: - // shared calls - IconCacheEntry *Preload(AutoLock *nodeCache, - AutoLock *sharedCache, - AutoLock **resultingLockedCache, - Model *, IconDrawMode mode, icon_size size, bool permanent); + IconCacheEntry* Preload(AutoLock* nodeCache, + AutoLock* sharedCache, + AutoLock** resultingLockedCache, + Model*, IconDrawMode mode, icon_size size, bool permanent); // preload uses lazy locking, returning the cache we decided // to use to get the icon // may be null if we don't care // shared mime-based icon retrieval calls - IconCacheEntry *GetIconForPreferredApp(const char *mimeTypeSignature, - const char *preferredApp, IconDrawMode mode, icon_size size, - LazyBitmapAllocator *, IconCacheEntry *); - IconCacheEntry *GetIconFromFileTypes(ModelNodeLazyOpener *, IconSource &source, - IconDrawMode mode, icon_size size, LazyBitmapAllocator *, - IconCacheEntry *); - IconCacheEntry *GetIconFromMetaMime(const char *fileType, IconDrawMode mode, - icon_size size, LazyBitmapAllocator *, - IconCacheEntry *); - IconCacheEntry *GetVolumeIcon(AutoLock *nodeCache, - AutoLock *sharedCache, - AutoLock **resultingLockedCache, - Model *, IconSource &, IconDrawMode mode, - icon_size size, LazyBitmapAllocator *); - IconCacheEntry *GetRootIcon(AutoLock *nodeCache, - AutoLock *sharedCache, - AutoLock **resultingLockedCache, - Model *, IconSource &, IconDrawMode mode, - icon_size size, LazyBitmapAllocator *); - IconCacheEntry *GetWellKnownIcon(AutoLock *nodeCache, - AutoLock *sharedCache, - AutoLock **resultingLockedCache, - Model *, IconSource &, IconDrawMode mode, - icon_size size, LazyBitmapAllocator *); - IconCacheEntry *GetNodeIcon(ModelNodeLazyOpener *, - AutoLock *nodeCache, - AutoLock **resultingLockedCache, - Model *, IconSource &, IconDrawMode mode, - icon_size size, LazyBitmapAllocator *, IconCacheEntry *, bool permanent); - IconCacheEntry *GetGenericIcon(AutoLock *sharedCache, - AutoLock **resultingLockedCache, - Model *, IconSource &, IconDrawMode mode, - icon_size size, LazyBitmapAllocator *, IconCacheEntry *); - IconCacheEntry *GetFallbackIcon(AutoLock *sharedCacheLocker, - AutoLock **resultingOpenCache, - Model *model, IconDrawMode mode, icon_size size, - LazyBitmapAllocator *lazyBitmap, IconCacheEntry *entry); + IconCacheEntry* GetIconForPreferredApp(const char* mimeTypeSignature, + const char* preferredApp, IconDrawMode mode, icon_size size, + LazyBitmapAllocator*, IconCacheEntry*); + IconCacheEntry* GetIconFromFileTypes(ModelNodeLazyOpener*, IconSource &source, + IconDrawMode mode, icon_size size, LazyBitmapAllocator*, + IconCacheEntry*); + IconCacheEntry* GetIconFromMetaMime(const char* fileType, IconDrawMode mode, + icon_size size, LazyBitmapAllocator*, + IconCacheEntry*); + IconCacheEntry* GetVolumeIcon(AutoLock* nodeCache, + AutoLock* sharedCache, + AutoLock** resultingLockedCache, + Model*, IconSource&, IconDrawMode mode, + icon_size size, LazyBitmapAllocator*); + IconCacheEntry* GetRootIcon(AutoLock* nodeCache, + AutoLock* sharedCache, + AutoLock** resultingLockedCache, + Model*, IconSource&, IconDrawMode mode, + icon_size size, LazyBitmapAllocator*); + IconCacheEntry* GetWellKnownIcon(AutoLock *nodeCache, + AutoLock* sharedCache, + AutoLock** resultingLockedCache, + Model*, IconSource&, IconDrawMode mode, + icon_size size, LazyBitmapAllocator*); + IconCacheEntry* GetNodeIcon(ModelNodeLazyOpener *, + AutoLock* nodeCache, + AutoLock** resultingLockedCache, + Model*, IconSource&, IconDrawMode mode, + icon_size size, LazyBitmapAllocator*, IconCacheEntry*, bool permanent); + IconCacheEntry* GetGenericIcon(AutoLock* sharedCache, + AutoLock** resultingLockedCache, + Model*, IconSource&, IconDrawMode mode, + icon_size size, LazyBitmapAllocator*, IconCacheEntry*); + IconCacheEntry* GetFallbackIcon(AutoLock* sharedCacheLocker, + AutoLock** resultingOpenCache, + Model* model, IconDrawMode mode, icon_size size, + LazyBitmapAllocator* lazyBitmap, IconCacheEntry* entry); - BBitmap *MakeTransformedIcon(const BBitmap *, icon_size, - int32 colorTransformTable [], LazyBitmapAllocator *); + BBitmap* MakeTransformedIcon(const BBitmap*, icon_size, + int32 colorTransformTable [], LazyBitmapAllocator*); NodeIconCache fNodeCache; SharedIconCache fSharedCache; @@ -451,37 +464,41 @@ public: bool preallocate = false); ~LazyBitmapAllocator(); - BBitmap *Get(); - BBitmap *Adopt(); + BBitmap* Get(); + BBitmap* Adopt(); private: - BBitmap *fBitmap; + BBitmap* fBitmap; icon_size fSize; color_space fColorSpace; }; -// nothing but inlines after here -inline const char * +// inlines follow + +inline const char* SharedCacheEntry::FileType() const { return fFileType.String(); } -inline const char * + +inline const char* SharedCacheEntry::AppSignature() const { return fAppSignature.String(); } -inline bool + +inline bool IconCache::NeedsDeletionNotification(IconSource from) { return from == kNode; } -inline IconCacheEntry * -SharedIconCache::ResolveIfAlias(IconCacheEntry *entry) const + +inline IconCacheEntry* +SharedIconCache::ResolveIfAlias(IconCacheEntry* entry) const { if (entry->fAliasForIndex < 0) return entry; @@ -489,8 +506,9 @@ SharedIconCache::ResolveIfAlias(IconCacheEntry *entry) const return fHashTable.ElementAt(entry->fAliasForIndex); } -inline int32 -SharedIconCache::EntryIndex(const SharedCacheEntry *entry) const + +inline int32 +SharedIconCache::EntryIndex(const SharedCacheEntry* entry) const { return fHashTable.ElementIndex(entry); } diff --git a/src/kits/tracker/IconMenuItem.cpp b/src/kits/tracker/IconMenuItem.cpp index 615d07f565..f28c0e01a0 100644 --- a/src/kits/tracker/IconMenuItem.cpp +++ b/src/kits/tracker/IconMenuItem.cpp @@ -43,7 +43,7 @@ All rights reserved. static void -DimmedIconBlitter(BView *view, BPoint where, BBitmap *bitmap, void *) +DimmedIconBlitter(BView* view, BPoint where, BBitmap* bitmap, void*) { if (bitmap->ColorSpace() == B_RGBA32) { rgb_color oldHighColor = view->HighColor(); @@ -63,8 +63,8 @@ DimmedIconBlitter(BView *view, BPoint where, BBitmap *bitmap, void *) // #pragma mark - -ModelMenuItem::ModelMenuItem(const Model *model, const char *title, - BMessage *message, char shortcut, uint32 modifiers, +ModelMenuItem::ModelMenuItem(const Model* model, const char* title, + BMessage* message, char shortcut, uint32 modifiers, bool drawText, bool extraPad) : BMenuItem(title, message, shortcut, modifiers), fModel(*model), @@ -88,7 +88,7 @@ ModelMenuItem::ModelMenuItem(const Model *model, const char *title, } -ModelMenuItem::ModelMenuItem(const Model *model, BMenu *menu, bool drawText, +ModelMenuItem::ModelMenuItem(const Model* model, BMenu* menu, bool drawText, bool extraPad) : BMenuItem(menu), fModel(*model), @@ -109,7 +109,7 @@ ModelMenuItem::~ModelMenuItem() status_t -ModelMenuItem::SetEntry(const BEntry *entry) +ModelMenuItem::SetEntry(const BEntry* entry) { return fModel.SetTo(entry); } @@ -171,7 +171,7 @@ ModelMenuItem::DrawIcon() void -ModelMenuItem::GetContentSize(float *width, float *height) +ModelMenuItem::GetContentSize(float* width, float* height) { _inherited::GetContentSize(width, height); fHeightDelta = 16 - *height; @@ -182,7 +182,7 @@ ModelMenuItem::GetContentSize(float *width, float *height) status_t -ModelMenuItem::Invoke(BMessage *message) +ModelMenuItem::Invoke(BMessage* message) { if (!Menu()) return B_ERROR; @@ -219,7 +219,7 @@ ModelMenuItem::Invoke(BMessage *message) It's used for example in the "Copy To" menu to indicate some special folders like the parent folder. */ -SpecialModelMenuItem::SpecialModelMenuItem(const Model *model, BMenu *menu) +SpecialModelMenuItem::SpecialModelMenuItem(const Model* model, BMenu* menu) : ModelMenuItem(model, menu) { } @@ -247,7 +247,7 @@ SpecialModelMenuItem::DrawContent() A menu item that draws an icon alongside the label. It's currently used in the mount and new file template menus. */ -IconMenuItem::IconMenuItem(const char *label, BMessage *message, BBitmap *icon) +IconMenuItem::IconMenuItem(const char* label, BMessage* message, BBitmap* icon) : PositionPassingMenuItem(label, message), fDeviceIcon(icon), fHeightDelta(0) @@ -258,8 +258,8 @@ IconMenuItem::IconMenuItem(const char *label, BMessage *message, BBitmap *icon) } -IconMenuItem::IconMenuItem(const char *label, BMessage *message, - const BNodeInfo *nodeInfo, icon_size which) +IconMenuItem::IconMenuItem(const char* label, BMessage* message, + const BNodeInfo* nodeInfo, icon_size which) : PositionPassingMenuItem(label, message), fDeviceIcon(NULL), fHeightDelta(0) @@ -283,8 +283,8 @@ IconMenuItem::IconMenuItem(const char *label, BMessage *message, } -IconMenuItem::IconMenuItem(const char *label, BMessage *message, - const char *iconType, icon_size which) +IconMenuItem::IconMenuItem(const char* label, BMessage* message, + const char* iconType, icon_size which) : PositionPassingMenuItem(label, message), fDeviceIcon(NULL), fHeightDelta(0) @@ -311,8 +311,8 @@ IconMenuItem::IconMenuItem(const char *label, BMessage *message, } -IconMenuItem::IconMenuItem(BMenu *submenu, BMessage *message, - const char *iconType, icon_size which) +IconMenuItem::IconMenuItem(BMenu* submenu, BMessage* message, + const char* iconType, icon_size which) : PositionPassingMenuItem(submenu, message), fDeviceIcon(NULL), fHeightDelta(0) @@ -346,7 +346,7 @@ IconMenuItem::~IconMenuItem() void -IconMenuItem::GetContentSize(float *width, float *height) +IconMenuItem::GetContentSize(float* width, float* height) { _inherited::GetContentSize(width, height); diff --git a/src/kits/tracker/IconMenuItem.h b/src/kits/tracker/IconMenuItem.h index a8fb8745da..2dc0ee1292 100644 --- a/src/kits/tracker/IconMenuItem.h +++ b/src/kits/tracker/IconMenuItem.h @@ -31,37 +31,39 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ +#ifndef ICON_MENU_ITEM_H +#define ICON_MENU_ITEM_H + // Menu item class with small icons. -#ifndef ICON_MENU_ITEM_H -#define ICON_MENU_ITEM_H #include #include "Model.h" #include "Utilities.h" -class BNodeInfo; +class BNodeInfo; + namespace BPrivate { const bigtime_t kSynchMenuInvokeTimeout = 5000000; class IconMenuItem : public PositionPassingMenuItem { public: - IconMenuItem(const char *label, BMessage *message, BBitmap *icon); - IconMenuItem(const char *label, BMessage *message, const char *iconType, + IconMenuItem(const char* label, BMessage* message, BBitmap* icon); + IconMenuItem(const char* label, BMessage* message, const char* iconType, icon_size which); - IconMenuItem(const char *label, BMessage *message, - const BNodeInfo *nodeInfo, icon_size which); - IconMenuItem(BMenu *, BMessage *, const char *iconType, icon_size which); + IconMenuItem(const char* label, BMessage* message, + const BNodeInfo* nodeInfo, icon_size which); + IconMenuItem(BMenu*, BMessage*, const char* iconType, icon_size which); virtual ~IconMenuItem(); - virtual void GetContentSize(float *width, float *height); + virtual void GetContentSize(float* width, float* height); virtual void DrawContent(); private: - BBitmap *fDeviceIcon; + BBitmap* fDeviceIcon; float fHeightDelta; typedef BMenuItem _inherited; @@ -70,20 +72,20 @@ class IconMenuItem : public PositionPassingMenuItem { class ModelMenuItem : public BMenuItem { public: - ModelMenuItem(const Model *, const char *title, BMessage *, char shortcut = '\0', + ModelMenuItem(const Model*, const char* title, BMessage*, char shortcut = '\0', uint32 modifiers = 0, bool drawText = true, bool extraPad = false); - ModelMenuItem(const Model *, BMenu *, bool drawText = true, bool extraPad = false); + ModelMenuItem(const Model*, BMenu*, bool drawText = true, bool extraPad = false); virtual ~ModelMenuItem(); - virtual status_t SetEntry(const BEntry *); + virtual status_t SetEntry(const BEntry*); virtual void DrawContent(); virtual void Highlight(bool isHighlighted); - virtual void GetContentSize(float *width, float *height); + virtual void GetContentSize(float* width, float* height); - const Model *TargetModel() const; + const Model* TargetModel() const; protected: - virtual status_t Invoke(BMessage * = NULL); + virtual status_t Invoke(BMessage* = NULL); // overriden to support B_OPTION_KEY private: @@ -98,7 +100,7 @@ class ModelMenuItem : public BMenuItem { }; -inline const Model * +inline const Model* ModelMenuItem::TargetModel() const { return &fModel; @@ -107,7 +109,7 @@ ModelMenuItem::TargetModel() const class SpecialModelMenuItem : public ModelMenuItem { public: - SpecialModelMenuItem(const Model *model, BMenu *menu); + SpecialModelMenuItem(const Model* model, BMenu* menu); virtual void DrawContent(); diff --git a/src/kits/tracker/InfoWindow.cpp b/src/kits/tracker/InfoWindow.cpp index 44db4c55df..fdb755165c 100644 --- a/src/kits/tracker/InfoWindow.cpp +++ b/src/kits/tracker/InfoWindow.cpp @@ -95,10 +95,10 @@ enum track_state { class TrackingView : public BControl { public: - TrackingView(BRect, const char *str, BMessage *message); + TrackingView(BRect, const char* str, BMessage* message); virtual void MouseDown(BPoint); - virtual void MouseMoved(BPoint, uint32 transit, const BMessage *message); + virtual void MouseMoved(BPoint, uint32 transit, const BMessage* message); virtual void MouseUp(BPoint); virtual void Draw(BRect); @@ -109,33 +109,33 @@ class TrackingView : public BControl { class AttributeView : public BView { public: - AttributeView(BRect, Model *); + AttributeView(BRect, Model*); ~AttributeView(); - void ModelChanged(Model *, BMessage *); - void ReLinkTargetModel(Model *); + void ModelChanged(Model*, BMessage*); + void ReLinkTargetModel(Model*); void BeginEditingTitle(); void FinishEditingTitle(bool); float CurrentFontHeight(float size = -1); - BTextView *TextView() const { return fTitleEditView; } + BTextView* TextView() const { return fTitleEditView; } - static filter_result TextViewFilter(BMessage *, BHandler **, BMessageFilter *); + static filter_result TextViewFilter(BMessage*, BHandler**, BMessageFilter*); off_t LastSize() const; void SetLastSize(off_t); - void SetSizeStr(const char *); + void SetSizeStr(const char*); - status_t BuildContextMenu(BMenu *parent); + status_t BuildContextMenu(BMenu* parent); void SetPermissionsSwitchState(int32 state); protected: virtual void MouseDown(BPoint); - virtual void MouseMoved(BPoint, uint32, const BMessage *); + virtual void MouseMoved(BPoint, uint32, const BMessage*); virtual void MouseUp(BPoint); - virtual void MessageReceived(BMessage *); + virtual void MessageReceived(BMessage*); virtual void AttachedToWindow(); virtual void Draw(BRect); virtual void Pulse(); @@ -143,7 +143,7 @@ class AttributeView : public BView { virtual void WindowActivated(bool); private: - void InitStrings(const Model *); + void InitStrings(const Model*); void CheckAndSetSize(); void OpenLinkSource(); void OpenLinkTarget(); @@ -168,20 +168,20 @@ class AttributeView : public BView { BPoint fClickPoint; float fDivider; - BMenuField *fPreferredAppMenu; - Model *fModel; - Model *fIconModel; - BBitmap *fIcon; + BMenuField* fPreferredAppMenu; + Model* fModel; + Model* fIconModel; + BBitmap* fIcon; bool fMouseDown; bool fDragging; bool fDoubleClick; track_state fTrackingState; bool fIsDropTarget; - BTextView *fTitleEditView; - PaneSwitch *fPermissionsSwitch; - BWindow *fPathWindow; - BWindow *fLinkWindow; - BWindow *fDescWindow; + BTextView* fTitleEditView; + PaneSwitch* fPermissionsSwitch; + BWindow* fPathWindow; + BWindow* fLinkWindow; + BWindow* fDescWindow; typedef BView _inherited; }; @@ -222,7 +222,7 @@ const uint32 kPaneSwitchOpen = 2; static void -OpenParentAndSelectOriginal(const entry_ref *ref) +OpenParentAndSelectOriginal(const entry_ref* ref) { BEntry entry(ref); node_ref node; @@ -241,9 +241,9 @@ OpenParentAndSelectOriginal(const entry_ref *ref) } -static BWindow * -OpenToolTipWindow(BScreen& screen, BRect rect, const char *name, - const char *string, BMessenger target, BMessage *message) +static BWindow* +OpenToolTipWindow(BScreen& screen, BRect rect, const char* name, + const char* string, BMessenger target, BMessage* message) { font_height fontHeight; be_plain_font->GetHeight(&fontHeight); @@ -257,13 +257,13 @@ OpenToolTipWindow(BScreen& screen, BRect rect, const char *name, else if (rect.right > screen.Frame().right) rect.OffsetBy(screen.Frame().right - rect.right, 0); - BWindow *window = new BWindow(rect, name, B_BORDERED_WINDOW_LOOK, + BWindow* window = new BWindow(rect, name, B_BORDERED_WINDOW_LOOK, B_FLOATING_ALL_WINDOW_FEEL, B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE | B_AVOID_FOCUS | B_NO_WORKSPACE_ACTIVATION | B_WILL_ACCEPT_FIRST_CLICK | B_ASYNCHRONOUS_CONTROLS); - TrackingView *trackingView = new TrackingView(window->Bounds(), + TrackingView* trackingView = new TrackingView(window->Bounds(), string, message); trackingView->SetTarget(target); window->AddChild(trackingView); @@ -278,7 +278,7 @@ OpenToolTipWindow(BScreen& screen, BRect rect, const char *name, // #pragma mark - -BInfoWindow::BInfoWindow(Model *model, int32 group_index, LockingList *list) +BInfoWindow::BInfoWindow(Model* model, int32 group_index, LockingList* list) : BWindow(BInfoWindow::InfoWindowRect(false), "InfoWindow", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_CURRENT_WORKSPACE), @@ -344,7 +344,7 @@ BInfoWindow::Quit() bool -BInfoWindow::IsShowing(const node_ref *node) const +BInfoWindow::IsShowing(const node_ref* node) const { return *TargetModel()->NodeRef() == *node; } @@ -409,7 +409,7 @@ BInfoWindow::Show() void -BInfoWindow::MessageReceived(BMessage *message) +BInfoWindow::MessageReceived(BMessage* message) { switch (message->what) { case kRestoreState: @@ -701,9 +701,9 @@ BInfoWindow::GetSizeString(BString &result, off_t size, int32 fileCount) int32 -BInfoWindow::CalcSize(void *castToWindow) +BInfoWindow::CalcSize(void* castToWindow) { - BInfoWindow *window = static_cast(castToWindow); + BInfoWindow* window = static_cast(castToWindow); BDirectory dir(window->TargetModel()->EntryRef()); BDirectory trashDir; FSGetTrashDir(&trashDir, window->TargetModel()->EntryRef()->device); @@ -782,16 +782,16 @@ BInfoWindow::CalcSize(void *castToWindow) void -BInfoWindow::SetSizeStr(const char *sizeStr) +BInfoWindow::SetSizeStr(const char* sizeStr) { - AttributeView *view = dynamic_cast(FindView("attr_view")); + AttributeView* view = dynamic_cast(FindView("attr_view")); if (view) view->SetSizeStr(sizeStr); } void -BInfoWindow::OpenFilePanel(const entry_ref *ref) +BInfoWindow::OpenFilePanel(const entry_ref* ref) { // Open a file dialog box to allow the user to select a new target // for the sym link @@ -825,7 +825,7 @@ BInfoWindow::OpenFilePanel(const entry_ref *ref) // #pragma mark - -AttributeView::AttributeView(BRect rect, Model *model) +AttributeView::AttributeView(BRect rect, Model* model) : BView(rect, "attr_view", B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_PULSE_NEEDED), fDivider(0), fPreferredAppMenu(NULL), @@ -847,7 +847,7 @@ AttributeView::AttributeView(BRect rect, Model *model) // If the model is a symlink, then we deference the model to // get the targets icon if (fModel->IsSymLink()) { - Model *resolvedModel = new Model(model->EntryRef(), true, true); + Model* resolvedModel = new Model(model->EntryRef(), true, true); if (resolvedModel->InitCheck() == B_OK) fIconModel = resolvedModel; // broken link, just show the symlink @@ -919,7 +919,7 @@ AttributeView::AttributeView(BRect rect, Model *model) mime.GetSupportingApps(&supportingAppList); // Add the default menu item and set it to marked - BMenuItem *result; + BMenuItem* result; result = new BMenuItem(B_TRANSLATE("Default application"), new BMessage(kSetPreferredApp)); result->SetTarget(this); @@ -927,7 +927,7 @@ AttributeView::AttributeView(BRect rect, Model *model) result->SetMarked(true); for (int32 index = 0; ; index++) { - const char *signature; + const char* signature; if (supportingAppList.FindString("applications", index, &signature) != B_OK) break; @@ -935,7 +935,7 @@ AttributeView::AttributeView(BRect rect, Model *model) if (index == 0) fPreferredAppMenu->Menu()->AddSeparatorItem(); - BMessage *itemMessage = new BMessage(kSetPreferredApp); + BMessage* itemMessage = new BMessage(kSetPreferredApp); itemMessage->AddString("signature", signature); status_t err = B_ERROR; @@ -988,7 +988,7 @@ AttributeView::~AttributeView() void -AttributeView::InitStrings(const Model *model) +AttributeView::InitStrings(const Model* model) { BMimeType mime; char kind[B_MIME_TYPE_LENGTH]; @@ -1076,7 +1076,7 @@ AttributeView::Pulse() void -AttributeView::ModelChanged(Model *model, BMessage *message) +AttributeView::ModelChanged(Model* model, BMessage* message) { BRect drawBounds(Bounds()); drawBounds.left = fDivider; @@ -1090,7 +1090,7 @@ AttributeView::ModelChanged(Model *model, BMessage *message) message->FindInt64("to directory", &dirNode.node); message->FindInt64("node", &itemNode.node); - const char *name; + const char* name; if (message->FindString("name", &name) != B_OK) return; @@ -1136,7 +1136,7 @@ AttributeView::ModelChanged(Model *model, BMessage *message) case B_ATTR_CHANGED: { // watch for icon updates - const char *attrName; + const char* attrName; if (message->FindString("attr", &attrName) == B_OK) { if (strcmp(attrName, kAttrLargeIcon) == 0 || strcmp(attrName, kAttrIcon) == 0) { @@ -1169,7 +1169,7 @@ AttributeView::ModelChanged(Model *model, BMessage *message) if (fModel->IsSymLink()) { // if we are looking at a symlink, deference the model and look at the // target - Model *resolvedModel = new Model(model->EntryRef(), true, true); + Model* resolvedModel = new Model(model->EntryRef(), true, true); if (resolvedModel->InitCheck() == B_OK) { if (fIconModel != fModel) delete fIconModel; @@ -1194,11 +1194,11 @@ AttributeView::ModelChanged(Model *model, BMessage *message) // would be nice) void -AttributeView::ReLinkTargetModel(Model *model) +AttributeView::ReLinkTargetModel(Model* model) { fModel = model; if (fModel->IsSymLink()) { - Model *resolvedModel = new Model(model->EntryRef(), true, true); + Model* resolvedModel = new Model(model->EntryRef(), true, true); if (resolvedModel->InitCheck() == B_OK) { if (fIconModel != fModel) delete fIconModel; @@ -1252,10 +1252,10 @@ AttributeView::MouseDown(BPoint point) fTrackingState = no_track; } else if (fIconRect.Contains(point)) { uint32 buttons; - Window()->CurrentMessage()->FindInt32("buttons", (int32 *)&buttons); + Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons); if (((modifiers() & B_CONTROL_KEY) != 0) || (buttons & B_SECONDARY_MOUSE_BUTTON) != 0) { // Show contextual menu - BPopUpMenu *contextMenu = new BPopUpMenu("FileContext", false, false); + BPopUpMenu* contextMenu = new BPopUpMenu("FileContext", false, false); if (contextMenu) { BuildContextMenu(contextMenu); contextMenu->SetAsyncAutoDestruct(true); @@ -1278,7 +1278,7 @@ AttributeView::MouseDown(BPoint point) int32 clickCount; Window()->CurrentMessage()->FindInt32("clicks", &clickCount); - // This checks the *previous* click point + // This checks the* previous* click point if (clickCount == 2) { offsetPoint.x = fClickPoint.x - fIconRect.left; offsetPoint.y = fClickPoint.y - fIconRect.top; @@ -1296,7 +1296,7 @@ AttributeView::MouseDown(BPoint point) void -AttributeView::MouseMoved(BPoint point, uint32, const BMessage *message) +AttributeView::MouseMoved(BPoint point, uint32, const BMessage* message) { // Highlight Drag target if (message && message->ReturnAddress() != BMessenger(this) @@ -1344,9 +1344,9 @@ AttributeView::MouseMoved(BPoint point, uint32, const BMessage *message) float height = CurrentFontHeight(kAttribFontHeight) + fIconRect.Height() + 8; BRect rect(0, 0, min_c(fIconRect.Width() + font.StringWidth(fModel->Name()) + 4, fIconRect.Width() * 3), height); - BBitmap *dragBitmap = new BBitmap(rect, B_RGBA32, true); + BBitmap* dragBitmap = new BBitmap(rect, B_RGBA32, true); dragBitmap->Lock(); - BView *view = new BView(dragBitmap->Bounds(), "", B_FOLLOW_NONE, 0); + BView* view = new BView(dragBitmap->Bounds(), "", B_FOLLOW_NONE, 0); dragBitmap->AddChild(view); view->SetOrigin(0, 0); BRect clipRect(view->Bounds()); @@ -1486,7 +1486,7 @@ AttributeView::OpenLinkTarget() } if (entry.InitCheck() != B_OK || !entry.Exists()) { // Open a file dialog panel to allow the user to relink. - BInfoWindow *window = dynamic_cast(Window()); + BInfoWindow* window = dynamic_cast(Window()); if (window) window->OpenFilePanel(fModel->EntryRef()); } else { @@ -1512,7 +1512,7 @@ AttributeView::MouseUp(BPoint point) } else if ((fTrackingState == icon_track || fTrackingState == open_only_track) && fIconRect.Contains(point)) { // If it was a double click, then tell Tracker to open the item - // The CurrentMessage() here does *not* have a "clicks" field, + // The CurrentMessage() here does* not* have a "clicks" field, // which is why we are tracking the clicks with this temp var if (fDoubleClick){ // Double click, launch. @@ -1600,7 +1600,7 @@ AttributeView::CheckAndSetSize() void -AttributeView::MessageReceived(BMessage *message) +AttributeView::MessageReceived(BMessage* message) { if (message->WasDropped() && message->what == B_SIMPLE_DATA @@ -1618,7 +1618,7 @@ AttributeView::MessageReceived(BMessage *message) BNode node(fModel->EntryRef()); BNodeInfo nodeInfo(&node); - const char *newSignature; + const char* newSignature; if (message->FindString("signature", &newSignature) != B_OK) newSignature = NULL; @@ -1891,7 +1891,7 @@ AttributeView::BeginEditingTitle() fTitleEditView->AddFilter( new BMessageFilter(B_KEY_DOWN, AttributeView::TextViewFilter)); - BScrollView *scrollView = new BScrollView("BorderView", fTitleEditView, + BScrollView* scrollView = new BScrollView("BorderView", fTitleEditView, 0, 0, false, false, B_PLAIN_BORDER); AddChild(scrollView); fTitleEditView->SelectAll(); @@ -1909,7 +1909,7 @@ AttributeView::FinishEditingTitle(bool commit) bool reopen = false; - const char *text = fTitleEditView->Text(); + const char* text = fTitleEditView->Text(); uint32 length = strlen(text); if (commit && strcmp(text, fModel->Name()) != 0 && length < B_FILE_NAME_LENGTH) { BEntry entry(fModel->EntryRef()); @@ -1949,7 +1949,7 @@ AttributeView::FinishEditingTitle(bool commit) } // Remove view - BView *scrollView = fTitleEditView->Parent(); + BView* scrollView = fTitleEditView->Parent(); RemoveChild(scrollView); delete scrollView; fTitleEditView = NULL; @@ -2008,7 +2008,7 @@ AttributeView::CurrentFontHeight(float size) status_t -AttributeView::BuildContextMenu(BMenu *parent) +AttributeView::BuildContextMenu(BMenu* parent) { // Add navigation menu if this is not a symlink // Symlink's to directories are OK however! @@ -2027,14 +2027,14 @@ AttributeView::BuildContextMenu(BMenu *parent) } else if (model.IsDirectory() || model.IsVolume()) navigate = true; } - ModelMenuItem *navigationItem = NULL; + ModelMenuItem* navigationItem = NULL; if (navigate) { navigationItem = new ModelMenuItem(new Model(model), new BNavMenu(model.Name(), B_REFS_RECEIVED, be_app, Window())); // setup a navigation menu item which will dynamically load items // as menu items are traversed - BNavMenu *navMenu = dynamic_cast(navigationItem->Submenu()); + BNavMenu* navMenu = dynamic_cast(navigationItem->Submenu()); navMenu->SetNavDir(&ref); navigationItem->SetLabel(model.Name()); navigationItem->SetEntry(&entry); @@ -2042,7 +2042,7 @@ AttributeView::BuildContextMenu(BMenu *parent) parent->AddItem(navigationItem, 0); parent->AddItem(new BSeparatorItem(), 1); - BMessage *message = new BMessage(B_REFS_RECEIVED); + BMessage* message = new BMessage(B_REFS_RECEIVED); message->AddRef("refs", &ref); navigationItem->SetMessage(message); navigationItem->SetTarget(be_app); @@ -2079,7 +2079,7 @@ AttributeView::BuildContextMenu(BMenu *parent) parent->AddItem(new BMenuItem(B_TRANSLATE("Empty Trash"), new BMessage(kEmptyTrash))); - BMenuItem *sizeItem = NULL; + BMenuItem* sizeItem = NULL; if (model.IsDirectory() && !model.IsVolume() && !model.IsRoot()) { parent->AddItem(sizeItem = new BMenuItem(B_TRANSLATE("Recalculate folder size"), new BMessage(kRecalculateSize))); @@ -2116,11 +2116,11 @@ AttributeView::SetPermissionsSwitchState(int32 state) filter_result -AttributeView::TextViewFilter(BMessage *message, BHandler **, BMessageFilter *filter) +AttributeView::TextViewFilter(BMessage* message, BHandler**, BMessageFilter* filter) { uchar key; - AttributeView *attribView = static_cast( - static_cast(filter->Looper())->FindView("attr_view")); + AttributeView* attribView = static_cast( + static_cast(filter->Looper())->FindView("attr_view")); // Adjust the size of the text rect BRect nuRect(attribView->TextView()->TextRect()); @@ -2129,7 +2129,7 @@ AttributeView::TextViewFilter(BMessage *message, BHandler **, BMessageFilter *fi // Make sure the cursor is in view attribView->TextView()->ScrollToSelection(); - if (message->FindInt8("byte", (int8 *)&key) != B_OK) + if (message->FindInt8("byte", (int8*)&key) != B_OK) return B_DISPATCH_MESSAGE; if (key == B_RETURN || key == B_ESCAPE) { @@ -2156,7 +2156,7 @@ AttributeView::SetLastSize(off_t lastSize) void -AttributeView::SetSizeStr(const char *sizeStr) +AttributeView::SetSizeStr(const char* sizeStr) { fSizeStr = sizeStr; @@ -2170,7 +2170,7 @@ AttributeView::SetSizeStr(const char *sizeStr) // #pragma mark - -TrackingView::TrackingView(BRect frame, const char *str, BMessage *message) +TrackingView::TrackingView(BRect frame, const char* str, BMessage* message) : BControl(frame, "trackingView", str, message, B_FOLLOW_ALL, B_WILL_DRAW), fMouseDown(false), fMouseInView(false) @@ -2192,7 +2192,7 @@ TrackingView::MouseDown(BPoint) void -TrackingView::MouseMoved(BPoint, uint32 transit, const BMessage *) +TrackingView::MouseMoved(BPoint, uint32 transit, const BMessage*) { if ((transit == B_ENTERED_VIEW || transit == B_EXITED_VIEW) && fMouseDown) InvertRect(Bounds()); @@ -2231,4 +2231,3 @@ TrackingView::Draw(BRect) DrawString(Label(), BPoint(3, Bounds().Height() - fontHeight.descent)); } - diff --git a/src/kits/tracker/InfoWindow.h b/src/kits/tracker/InfoWindow.h index b5d1df85bb..4f13a2a15f 100644 --- a/src/kits/tracker/InfoWindow.h +++ b/src/kits/tracker/InfoWindow.h @@ -52,48 +52,52 @@ namespace BPrivate { class Model; class AttributeView; + class BInfoWindow : public BWindow { public: - BInfoWindow(Model *, int32 groupIndex, LockingList *list = NULL); + BInfoWindow(Model*, int32 groupIndex, LockingList* list = NULL); ~BInfoWindow(); - virtual bool IsShowing(const node_ref *) const; - Model *TargetModel() const; - void SetSizeStr(const char *); + virtual bool IsShowing(const node_ref*) const; + Model* TargetModel() const; + void SetSizeStr(const char*); bool StopCalc(); - void OpenFilePanel(const entry_ref *); + void OpenFilePanel(const entry_ref*); static void GetSizeString(BString &result, off_t size, int32 fileCount); protected: virtual void Quit(); - virtual void MessageReceived(BMessage *); + virtual void MessageReceived(BMessage*); virtual void Show(); private: static BRect InfoWindowRect(bool displayingSymlink); - static int32 CalcSize(void *); + static int32 CalcSize(void*); - Model *fModel; + Model* fModel; volatile bool fStopCalc; - int32 fIndex; // tells where it lives with respect to other + int32 fIndex; + // tells where it lives with respect to other thread_id fCalcThreadID; - LockingList *fWindowList; - FilePermissionsView *fPermissionsView; - AttributeView *fAttributeView; - BFilePanel *fFilePanel; + LockingList* fWindowList; + FilePermissionsView* fPermissionsView; + AttributeView* fAttributeView; + BFilePanel* fFilePanel; bool fFilePanelOpen; typedef BWindow _inherited; }; + inline bool BInfoWindow::StopCalc() { return fStopCalc; } -inline Model * + +inline Model* BInfoWindow::TargetModel() const { return fModel; @@ -103,4 +107,4 @@ BInfoWindow::TargetModel() const using namespace BPrivate; -#endif +#endif // INFO_WINDOW_H diff --git a/src/kits/tracker/LockingList.h b/src/kits/tracker/LockingList.h index 05d5992d36..620dba785b 100644 --- a/src/kits/tracker/LockingList.h +++ b/src/kits/tracker/LockingList.h @@ -31,13 +31,14 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - -#ifndef _LOCKING_LIST_H +#ifndef _LOCKING_LIST_H #define _LOCKING_LIST_H + #include #include "ObjectList.h" + namespace BPrivate { template @@ -57,36 +58,39 @@ private: BLocker lock; }; + template LockingList::LockingList(int32 itemsPerBlock, bool owning) : BObjectList(itemsPerBlock, owning) { } + template -bool +bool LockingList::Lock() { return lock.Lock(); } + template -void +void LockingList::Unlock() { lock.Unlock(); } + template -bool +bool LockingList::IsLocked() const { return lock.IsLocked(); } - } // namespace BPrivate using namespace BPrivate; -#endif +#endif // _LOCKING_LIST_H diff --git a/src/kits/tracker/MimeTypeList.cpp b/src/kits/tracker/MimeTypeList.cpp index a837c3ffaf..aeecfece6a 100644 --- a/src/kits/tracker/MimeTypeList.cpp +++ b/src/kits/tracker/MimeTypeList.cpp @@ -59,30 +59,30 @@ ShortMimeInfo::ShortMimeInfo(const BMimeType &mimeType) } -ShortMimeInfo::ShortMimeInfo(const char *shortDescription) +ShortMimeInfo::ShortMimeInfo(const char* shortDescription) : fShortDescription(shortDescription) { } -const char * +const char* ShortMimeInfo::InternalName() const { return fPrivateName.String(); } -const char * +const char* ShortMimeInfo::ShortDescription() const { return fShortDescription.String(); } -int -ShortMimeInfo::CompareShortDescription(const ShortMimeInfo *a, const ShortMimeInfo *b) +int +ShortMimeInfo::CompareShortDescription(const ShortMimeInfo* a, const ShortMimeInfo* b) { return a->fShortDescription.ICompare(b->fShortDescription); } -bool +bool ShortMimeInfo::IsCommonMimeType() const { return fCommonMimeType; @@ -103,24 +103,24 @@ MimeTypeList::MimeTypeList() } static int -MatchOneShortDescription(const ShortMimeInfo *a, const ShortMimeInfo *b) +MatchOneShortDescription(const ShortMimeInfo* a, const ShortMimeInfo* b) { return strcasecmp(a->ShortDescription(), b->ShortDescription()); } -const ShortMimeInfo * -MimeTypeList::FindMimeType(const char *shortDescription) const +const ShortMimeInfo* +MimeTypeList::FindMimeType(const char* shortDescription) const { ShortMimeInfo tmp(shortDescription); - const ShortMimeInfo *result = fCommonMimeList.BinarySearch(tmp, + const ShortMimeInfo* result = fCommonMimeList.BinarySearch(tmp, &MatchOneShortDescription); return result; } -const ShortMimeInfo * -MimeTypeList::EachCommonType(bool (*func)(const ShortMimeInfo *, void *), - void *state) const +const ShortMimeInfo* +MimeTypeList::EachCommonType(bool (*func)(const ShortMimeInfo*, void*), + void* state) const { AutoLock locker(fLock); int32 count = fCommonMimeList.CountItems(); @@ -131,7 +131,7 @@ MimeTypeList::EachCommonType(bool (*func)(const ShortMimeInfo *, void *), return NULL; } -void +void MimeTypeList::Build() { ASSERT(fLock.IsLocked()); @@ -144,7 +144,7 @@ MimeTypeList::Build() message.GetInfo("types", &type, &count); for (int32 index = 0; index < count; index++) { - const char *str; + const char* str; if (message.FindString("types", index, &str) != B_OK) continue; @@ -152,9 +152,9 @@ MimeTypeList::Build() if (mimetype.InitCheck() != B_OK) continue; - ShortMimeInfo *mimeInfo = new ShortMimeInfo(mimetype); + ShortMimeInfo* mimeInfo = new ShortMimeInfo(mimetype); fMimeList.AddItem(mimeInfo); - if (mimeInfo->IsCommonMimeType()) + if (mimeInfo->IsCommonMimeType()) fCommonMimeList.AddItem(mimeInfo); } fCommonMimeList.SortItems(&ShortMimeInfo::CompareShortDescription); diff --git a/src/kits/tracker/MimeTypeList.h b/src/kits/tracker/MimeTypeList.h index 1b9ddb45b0..1275280500 100644 --- a/src/kits/tracker/MimeTypeList.h +++ b/src/kits/tracker/MimeTypeList.h @@ -31,14 +31,15 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef __MIME_TYPE_LIST__ #define __MIME_TYPE_LIST__ + #include #include "ObjectList.h" #include "Utilities.h" + namespace BPrivate { class MimeTypeList; @@ -46,15 +47,15 @@ class MimeTypeList; class ShortMimeInfo { public: ShortMimeInfo(const BMimeType &); - - const char *InternalName() const; - const char *ShortDescription() const; + + const char* InternalName() const; + const char* ShortDescription() const; bool IsCommonMimeType() const; - static int CompareShortDescription(const ShortMimeInfo *, - const ShortMimeInfo *); + static int CompareShortDescription(const ShortMimeInfo*, + const ShortMimeInfo*); private: - ShortMimeInfo(const char *shortDescription); + ShortMimeInfo(const char* shortDescription); BString fPrivateName; BString fShortDescription; @@ -63,21 +64,22 @@ private: friend class MimeTypeList; }; + class MimeTypeList { public: MimeTypeList(); - + // attributes for type // internal name from short description // update notification - const ShortMimeInfo *FindMimeType(const char *shortDescription) const; - const ShortMimeInfo *EachCommonType(bool (*)(const ShortMimeInfo *, void *), - void *) const; + const ShortMimeInfo* FindMimeType(const char* shortDescription) const; + const ShortMimeInfo* EachCommonType(bool (*)(const ShortMimeInfo*, void*), + void*) const; protected: void Build(); - + private: BObjectList fMimeList; BObjectList fCommonMimeList; @@ -88,4 +90,4 @@ private: using namespace BPrivate; -#endif +#endif // __MIME_TYPE_LIST__ diff --git a/src/kits/tracker/MimeTypes.h b/src/kits/tracker/MimeTypes.h index 47ab641312..22b200d34c 100644 --- a/src/kits/tracker/MimeTypes.h +++ b/src/kits/tracker/MimeTypes.h @@ -31,33 +31,33 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef _MIME_TYPES_H #define _MIME_TYPES_H + namespace BPrivate { -#define B_FILE_MIMETYPE "application/octet-stream" -#define B_DIR_MIMETYPE "application/x-vnd.Be-directory" -#define B_VOLUME_MIMETYPE "application/x-vnd.Be-volume" -#define B_QUERY_MIMETYPE "application/x-vnd.Be-query" -#define B_QUERY_TEMPLATE_MIMETYPE "application/x-vnd.Be-queryTemplate" -#define B_LINK_MIMETYPE "application/x-vnd.Be-symlink" -#define B_ROOT_MIMETYPE "application/x-vnd.Be-root" -#define B_BOOKMARK_MIMETYPE "application/x-vnd.Be-bookmark" -#define B_PERSON_MIMETYPE "application/x-person" +#define B_FILE_MIMETYPE "application/octet-stream" +#define B_DIR_MIMETYPE "application/x-vnd.Be-directory" +#define B_VOLUME_MIMETYPE "application/x-vnd.Be-volume" +#define B_QUERY_MIMETYPE "application/x-vnd.Be-query" +#define B_QUERY_TEMPLATE_MIMETYPE "application/x-vnd.Be-queryTemplate" +#define B_LINK_MIMETYPE "application/x-vnd.Be-symlink" +#define B_ROOT_MIMETYPE "application/x-vnd.Be-root" +#define B_BOOKMARK_MIMETYPE "application/x-vnd.Be-bookmark" +#define B_PERSON_MIMETYPE "application/x-person" -#define B_PRINTER_MIMETYPE "application/x-vnd.Be.printer" -#define B_PRINTER_SPOOL_MIMETYPE "application/x-vnd.Be.printer-spool" +#define B_PRINTER_MIMETYPE "application/x-vnd.Be.printer" +#define B_PRINTER_SPOOL_MIMETYPE "application/x-vnd.Be.printer-spool" -#define kPlainTextMimeType "text/plain" +#define kPlainTextMimeType "text/plain" -#define kBitmapMimeType "image/x-vnd.Be-bitmap" -#define kLargeIconType "icon/large" -#define kMiniIconType "icon/mini" +#define kBitmapMimeType "image/x-vnd.Be-bitmap" +#define kLargeIconType "icon/large" +#define kMiniIconType "icon/mini" } // namespace BPrivate using namespace BPrivate; -#endif +#endif // _MIME_TYPES_H diff --git a/src/kits/tracker/MiniMenuField.cpp b/src/kits/tracker/MiniMenuField.cpp index 13d45807bd..c67af408c7 100644 --- a/src/kits/tracker/MiniMenuField.cpp +++ b/src/kits/tracker/MiniMenuField.cpp @@ -32,13 +32,15 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include #include #include "MiniMenuField.h" #include "Utilities.h" -MiniMenuField::MiniMenuField(BRect frame, const char *name, BPopUpMenu *menu, + +MiniMenuField::MiniMenuField(BRect frame, const char* name, BPopUpMenu* menu, uint32 resizeFlags, uint32 flags) : BView(frame, name, resizeFlags, flags), fMenu(menu) @@ -46,12 +48,14 @@ MiniMenuField::MiniMenuField(BRect frame, const char *name, BPopUpMenu *menu, SetFont(be_plain_font, B_FONT_FAMILY_AND_STYLE | B_FONT_SIZE); } + MiniMenuField::~MiniMenuField() { delete fMenu; } -void + +void MiniMenuField::AttachedToWindow() { if (Parent()) { @@ -61,16 +65,18 @@ MiniMenuField::AttachedToWindow() SetHighColor(0, 0, 0); } -void + +void MiniMenuField::MakeFocus(bool on) { Invalidate(); BView::MakeFocus(on); } + void -MiniMenuField::KeyDown(const char *bytes, int32 numBytes) -{ +MiniMenuField::KeyDown(const char* bytes, int32 numBytes) +{ switch (bytes[0]) { case B_SPACE: case B_DOWN_ARROW: @@ -85,7 +91,8 @@ MiniMenuField::KeyDown(const char *bytes, int32 numBytes) } } -void + +void MiniMenuField::Draw(BRect) { BRect bounds(Bounds()); @@ -103,16 +110,16 @@ MiniMenuField::Draw(BRect) // draw frame and shadow BeginLineArray(10); - AddLine(rect.RightTop(), rect.RightBottom(), darkest); - AddLine(rect.RightBottom(), rect.LeftBottom(), darkest); - AddLine(rect.LeftBottom(), rect.LeftTop(), medium); + AddLine(rect.RightTop(), rect.RightBottom(), darkest); + AddLine(rect.RightBottom(), rect.LeftBottom(), darkest); + AddLine(rect.LeftBottom(), rect.LeftTop(), medium); AddLine(rect.LeftTop(), rect.RightTop(), medium); - AddLine(bounds.LeftBottom() + BPoint(2, 0), bounds.RightBottom(), dark); - AddLine(bounds.RightTop() + BPoint(0, 1), bounds.RightBottom(), dark); + AddLine(bounds.LeftBottom() + BPoint(2, 0), bounds.RightBottom(), dark); + AddLine(bounds.RightTop() + BPoint(0, 1), bounds.RightBottom(), dark); rect.InsetBy(1, 1); - AddLine(rect.RightTop(), rect.RightBottom(), medium); - AddLine(rect.RightBottom(), rect.LeftBottom(), medium); - AddLine(rect.LeftBottom(), rect.LeftTop(), light); + AddLine(rect.RightTop(), rect.RightBottom(), medium); + AddLine(rect.RightBottom(), rect.LeftBottom(), medium); + AddLine(rect.LeftBottom(), rect.LeftTop(), light); AddLine(rect.LeftTop(), rect.RightTop(), light); EndLineArray(); @@ -123,16 +130,16 @@ MiniMenuField::Draw(BRect) const rgb_color middleColor = {150, 150, 150, 255}; BeginLineArray(5); - AddLine(BPoint(rect.left + 3, rect.top + 1), + AddLine(BPoint(rect.left + 3, rect.top + 1), BPoint(rect.left + 3, rect.top + 7), outlineColor); - AddLine(BPoint(rect.left + 3, rect.top + 1), + AddLine(BPoint(rect.left + 3, rect.top + 1), BPoint(rect.left + 6, rect.top + 4), outlineColor); - AddLine(BPoint(rect.left + 6, rect.top + 4), + AddLine(BPoint(rect.left + 6, rect.top + 4), BPoint(rect.left + 3, rect.top + 7), outlineColor); - - AddLine(BPoint(rect.left + 4, rect.top + 3), + + AddLine(BPoint(rect.left + 4, rect.top + 3), BPoint(rect.left + 4, rect.top + 5), middleColor); - AddLine(BPoint(rect.left + 5, rect.top + 4), + AddLine(BPoint(rect.left + 5, rect.top + 4), BPoint(rect.left + 5, rect.top + 4), middleColor); EndLineArray(); @@ -151,10 +158,10 @@ MiniMenuField::Draw(BRect) AddLine(BPoint(bounds.left, bounds.bottom), BPoint(bounds.left, bounds.top), focused ? markColor : viewColor); EndLineArray(); - } -void + +void MiniMenuField::MouseDown(BPoint) { fMenu->Go(ConvertToScreen(BPoint(4, 4)), true); diff --git a/src/kits/tracker/MiniMenuField.h b/src/kits/tracker/MiniMenuField.h index b034b9a48a..d9689b76c5 100644 --- a/src/kits/tracker/MiniMenuField.h +++ b/src/kits/tracker/MiniMenuField.h @@ -31,20 +31,20 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef __MINI_MENU_FIELD__ #define __MINI_MENU_FIELD__ + #include + class BPopUpMenu; namespace BPrivate { - class MiniMenuField : public BView { public: - MiniMenuField(BRect frame, const char *name, BPopUpMenu *menu, + MiniMenuField(BRect frame, const char* name, BPopUpMenu* menu, uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP, uint32 flags = B_WILL_DRAW | B_NAVIGABLE); // ToDo: @@ -57,14 +57,14 @@ protected: virtual void Draw(BRect); virtual void MouseDown(BPoint ); virtual void MakeFocus(bool); - virtual void KeyDown(const char *, int32); + virtual void KeyDown(const char*, int32); private: - BPopUpMenu *fMenu; + BPopUpMenu* fMenu; }; } // namespace BPrivate using namespace BPrivate; -#endif +#endif // __MINI_MENU_FIELD__ diff --git a/src/kits/tracker/Model.cpp b/src/kits/tracker/Model.cpp index dcf5e3e889..ffe56b2d25 100644 --- a/src/kits/tracker/Model.cpp +++ b/src/kits/tracker/Model.cpp @@ -72,8 +72,8 @@ All rights reserved. #include "Utilities.h" #ifdef CHECK_OPEN_MODEL_LEAKS -BObjectList *writableOpenModelList = NULL; -BObjectList *readOnlyOpenModelList = NULL; +BObjectList* writableOpenModelList = NULL; +BObjectList* readOnlyOpenModelList = NULL; #endif namespace BPrivate { @@ -81,7 +81,7 @@ extern #ifdef _IMPEXP_BE _IMPEXP_BE #endif -bool CheckNodeIconHintPrivate(const BNode *, bool); +bool CheckNodeIconHintPrivate(const BNode*, bool); } @@ -131,7 +131,7 @@ Model::Model(const Model &cloneThis) } -Model::Model(const node_ref *dirNode, const node_ref *node, const char *name, +Model::Model(const node_ref* dirNode, const node_ref* node, const char* name, bool open, bool writable) : fPreferredAppName(NULL), @@ -143,7 +143,7 @@ Model::Model(const node_ref *dirNode, const node_ref *node, const char *name, } -Model::Model(const BEntry *entry, bool open, bool writable) +Model::Model(const BEntry* entry, bool open, bool writable) : fPreferredAppName(NULL), fWritable(false), @@ -154,7 +154,7 @@ Model::Model(const BEntry *entry, bool open, bool writable) } -Model::Model(const entry_ref *ref, bool traverse, bool open, bool writable) +Model::Model(const entry_ref* ref, bool traverse, bool open, bool writable) : fPreferredAppName(NULL), fBaseType(kUnknownNode), @@ -174,7 +174,7 @@ void Model::DeletePreferredAppVolumeNameLinkTo() { if (IsSymLink()) { - Model *tmp = fLinkTo; + Model* tmp = fLinkTo; // deal with link to link to self fLinkTo = NULL; delete tmp; @@ -212,7 +212,7 @@ Model::~Model() status_t -Model::SetTo(const BEntry *entry, bool open, bool writable) +Model::SetTo(const BEntry* entry, bool open, bool writable) { delete fNode; fNode = NULL; @@ -238,7 +238,7 @@ Model::SetTo(const BEntry *entry, bool open, bool writable) status_t -Model::SetTo(const entry_ref *newRef, bool traverse, bool open, bool writable) +Model::SetTo(const entry_ref* newRef, bool traverse, bool open, bool writable) { delete fNode; fNode = NULL; @@ -270,7 +270,7 @@ Model::SetTo(const entry_ref *newRef, bool traverse, bool open, bool writable) status_t -Model::SetTo(const node_ref *dirNode, const node_ref *nodeRef, const char *name, +Model::SetTo(const node_ref* dirNode, const node_ref* nodeRef, const char* name, bool open, bool writable) { delete fNode; @@ -312,13 +312,13 @@ Model::InitCheck() const int -Model::CompareFolderNamesFirst(const Model *compareModel) const +Model::CompareFolderNamesFirst(const Model* compareModel) const { if (compareModel == NULL) return -1; - const Model *resolvedCompareModel = compareModel->ResolveIfLink(); - const Model *resolvedMe = ResolveIfLink(); + const Model* resolvedCompareModel = compareModel->ResolveIfLink(); + const Model* resolvedMe = ResolveIfLink(); if (resolvedMe->IsVolume()) { if (!resolvedCompareModel->IsVolume()) @@ -336,7 +336,7 @@ Model::CompareFolderNamesFirst(const Model *compareModel) const } -const char * +const char* Model::Name() const { static const char* kRootNodeName = B_TRANSLATE_MARK("Disks"); @@ -437,7 +437,7 @@ Model::OpenNodeCommon(bool writable) fNode = new BDirectory(&fEntryRef); if (fBaseType == kDirectoryNode - && static_cast(fNode)->IsRootDirectory()) { + && static_cast(fNode)->IsRootDirectory()) { // promote from directory to volume fBaseType = kVolumeNode; } @@ -576,7 +576,7 @@ Model::CacheLocalizedName() static bool -HasVectorIconHint(BNode *node) +HasVectorIconHint(BNode* node) { attr_info info; return node->GetAttrInfo(kAttrIcon, &info) == B_OK; @@ -596,7 +596,7 @@ Model::FinishSettingUpType() // disk again for models that do not have an icon defined by the node if (IsNodeOpen() && fBaseType != kLinkNode - && !CheckNodeIconHintPrivate(fNode, dynamic_cast(be_app) == NULL) + && !CheckNodeIconHintPrivate(fNode, dynamic_cast(be_app) == NULL) && !HasVectorIconHint(fNode)) { // when checking for the node icon hint, if we are libtracker, only check // for small icons - checking for the large icons is a little more @@ -695,7 +695,7 @@ Model::FinishSettingUpType() case kExecutableNode: if (IsNodeOpen()) { char signature[B_MIME_TYPE_LENGTH]; - if (GetAppSignatureFromAttr(dynamic_cast(fNode), signature) + if (GetAppSignatureFromAttr(dynamic_cast(fNode), signature) == B_OK) { if (fPreferredAppName) @@ -728,11 +728,11 @@ Model::ResetIconFrom() // mirror the logic from FinishSettingUpType if ((fBaseType == kDirectoryNode || fBaseType == kVolumeNode || fBaseType == kTrashNode || fBaseType == kDesktopNode) - && !CheckNodeIconHintPrivate(fNode, dynamic_cast(be_app) == NULL)) { + && !CheckNodeIconHintPrivate(fNode, dynamic_cast(be_app) == NULL)) { if (WellKnowEntryList::Match(NodeRef()) > (directory_which)-1) { fIconFrom = kTrackerSupplied; return; - } else if (dynamic_cast(fNode)->IsRootDirectory()) { + } else if (dynamic_cast(fNode)->IsRootDirectory()) { fIconFrom = kVolume; return; } @@ -741,7 +741,7 @@ Model::ResetIconFrom() } -const char * +const char* Model::PreferredAppSignature() const { if (IsVolume() || IsSymLink()) @@ -752,7 +752,7 @@ Model::PreferredAppSignature() const void -Model::SetPreferredAppSignature(const char *signature) +Model::SetPreferredAppSignature(const char* signature) { ASSERT(!IsVolume() && !IsSymLink()); ASSERT(signature != fPreferredAppName); @@ -766,7 +766,7 @@ Model::SetPreferredAppSignature(const char *signature) } -const Model * +const Model* Model::ResolveIfLink() const { if (!IsSymLink()) @@ -779,7 +779,7 @@ Model::ResolveIfLink() const } -Model * +Model* Model::ResolveIfLink() { if (!IsSymLink()) @@ -793,7 +793,7 @@ Model::ResolveIfLink() void -Model::SetLinkTo(Model *model) +Model::SetLinkTo(Model* model) { ASSERT(IsSymLink()); ASSERT(!fLinkTo || (fLinkTo != model)); @@ -825,7 +825,7 @@ Model::GetPreferredAppForBrokenSymLink(BString &result) // Node monitor updating stuff void -Model::UpdateEntryRef(const node_ref *dirNode, const char *name) +Model::UpdateEntryRef(const node_ref* dirNode, const char* name) { if (IsVolume()) { if (fVolumeName) @@ -845,7 +845,7 @@ Model::UpdateEntryRef(const node_ref *dirNode, const char *name) status_t -Model::WatchVolumeAndMountPoint(uint32 , BHandler *target) +Model::WatchVolumeAndMountPoint(uint32 , BHandler* target) { ASSERT(IsVolume()); @@ -867,7 +867,7 @@ Model::WatchVolumeAndMountPoint(uint32 , BHandler *target) bool -Model::AttrChanged(const char *attrName) +Model::AttrChanged(const char* attrName) { // called on an attribute changed node monitor // sync up cached values of mime type and preferred app and @@ -936,7 +936,7 @@ Model::StatChanged() // Mime handling stuff bool -Model::IsDropTarget(const Model *forDocument, bool traverse) const +Model::IsDropTarget(const Model* forDocument, bool traverse) const { switch (CanHandleDrops()) { case kCanHandle: @@ -968,7 +968,7 @@ Model::IsDropTarget(const Model *forDocument, bool traverse) const return SupportsMimeType(mimeType, 0) != kDoesNotSupportType; } // do some mime-based matching - const char *documentMimeType = forDocument->MimeType(); + const char* documentMimeType = forDocument->MimeType(); if (!documentMimeType) return false; @@ -1011,7 +1011,7 @@ Model::CanHandleDrops() const inline bool -IsSuperHandlerSignature(const char *signature) +IsSuperHandlerSignature(const char* signature) { return strcasecmp(signature, B_FILE_MIMETYPE) == 0; } @@ -1024,7 +1024,7 @@ enum { }; static int32 -MatchMimeTypeString(/*const */BString *documentType, const char *handlerType) +MatchMimeTypeString(/*const */BString* documentType, const char* handlerType) { // perform a mime type wildcard match // handler types of the form "text" @@ -1032,7 +1032,7 @@ MatchMimeTypeString(/*const */BString *documentType, const char *handlerType) // for everything else a full string match is used int32 supertypeOnlyLength = 0; - const char *tmp = strstr(handlerType, "/"); + const char* tmp = strstr(handlerType, "/"); if (!tmp) // no subtype - supertype string only @@ -1057,7 +1057,7 @@ MatchMimeTypeString(/*const */BString *documentType, const char *handlerType) int32 -Model::SupportsMimeType(const char *type, const BObjectList *list, +Model::SupportsMimeType(const char* type, const BObjectList* list, bool exactReason) const { ASSERT((type == 0) != (list == 0)); @@ -1075,10 +1075,10 @@ Model::SupportsMimeType(const char *type, const BObjectList *list, for (int32 index = 0; ; index++) { // check if this model lists the type of dropped document as supported - const char *mimeSignature; + const char* mimeSignature; int32 bufferLength; - if (message.FindData("types", 'CSTR', index, (const void **)&mimeSignature, + if (message.FindData("types", 'CSTR', index, (const void**)&mimeSignature, &bufferLength)) return result; @@ -1096,7 +1096,7 @@ Model::SupportsMimeType(const char *type, const BObjectList *list, BString typeString(type); match = MatchMimeTypeString(&typeString, mimeSignature); } else - match = WhileEachListItem(const_cast *>(list), + match = WhileEachListItem(const_cast*>(list), MatchMimeTypeString, mimeSignature); // const_cast shouldnt be here, have to have it until MW cleans up @@ -1118,7 +1118,7 @@ Model::SupportsMimeType(const char *type, const BObjectList *list, bool -Model::IsDropTargetForList(const BObjectList *list) const +Model::IsDropTargetForList(const BObjectList* list) const { switch (CanHandleDrops()) { case kCanHandle: @@ -1147,10 +1147,10 @@ Model::IsSuperHandler() const return false; for (int32 index = 0; ; index++) { - const char *mimeSignature; + const char* mimeSignature; int32 bufferLength; - if (message.FindData("types", 'CSTR', index, (const void **)&mimeSignature, + if (message.FindData("types", 'CSTR', index, (const void**)&mimeSignature, &bufferLength)) return false; @@ -1162,14 +1162,14 @@ Model::IsSuperHandler() const void -Model::GetEntry(BEntry *entry) const +Model::GetEntry(BEntry* entry) const { entry->SetTo(EntryRef()); } void -Model::GetPath(BPath *path) const +Model::GetPath(BPath* path) const { BEntry entry(EntryRef()); entry.GetPath(path); @@ -1184,7 +1184,7 @@ Model::Mimeset(bool force) GetPath(&path); update_mime_info(path.Path(), 0, 1, force ? 2 : 0); - + AttrChanged(0); return !oldType.ICompare(MimeType()); @@ -1192,8 +1192,8 @@ Model::Mimeset(bool force) ssize_t -Model::WriteAttr(const char *attr, type_code type, off_t offset, - const void *buffer, size_t length) +Model::WriteAttr(const char* attr, type_code type, off_t offset, + const void* buffer, size_t length) { BModelWriteOpener opener(this); if (!fNode) @@ -1205,8 +1205,8 @@ Model::WriteAttr(const char *attr, type_code type, off_t offset, ssize_t -Model::WriteAttrKillForeign(const char *attr, const char *foreignAttr, - type_code type, off_t offset, const void *buffer, size_t length) +Model::WriteAttrKillForeign(const char* attr, const char* foreignAttr, + type_code type, off_t offset, const void* buffer, size_t length) { BModelWriteOpener opener(this); if (!fNode) diff --git a/src/kits/tracker/Model.h b/src/kits/tracker/Model.h index 31f8a3481e..cfe7a27c4f 100644 --- a/src/kits/tracker/Model.h +++ b/src/kits/tracker/Model.h @@ -31,11 +31,12 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ +#ifndef _NU_MODEL_H +#define _NU_MODEL_H + // Dedicated to BModel -#ifndef _NU_MODEL_H -#define _NU_MODEL_H #include #include @@ -76,24 +77,24 @@ class Model { public: Model(); Model(const Model &); - Model(const BEntry *entry, bool open = false, bool writable = false); - Model(const entry_ref *, bool traverse = false, bool open = false, + Model(const BEntry* entry, bool open = false, bool writable = false); + Model(const entry_ref*, bool traverse = false, bool open = false, bool writable = false); - Model(const node_ref *dirNode, const node_ref *node, const char *name, + Model(const node_ref* dirNode, const node_ref* node, const char* name, bool open = false, bool writable = false); ~Model(); - Model& operator=(const Model &); + Model& operator=(const Model&); status_t InitCheck() const; - status_t SetTo(const BEntry *, bool open = false, bool writable = false); - status_t SetTo(const entry_ref *, bool traverse = false, bool open = false, + status_t SetTo(const BEntry*, bool open = false, bool writable = false); + status_t SetTo(const entry_ref*, bool traverse = false, bool open = false, bool writable = false); - status_t SetTo(const node_ref *dirNode, const node_ref *node, const char *name, + status_t SetTo(const node_ref* dirNode, const node_ref* node, const char* name, bool open = false, bool writable = false); - int CompareFolderNamesFirst(const Model *compareModel) const; + int CompareFolderNamesFirst(const Model* compareModel) const; // node management status_t OpenNode(bool writable = false); @@ -107,20 +108,20 @@ class Model { // real, starts by rereading the stat structure // basic getters - const char *Name() const; - const entry_ref *EntryRef() const; - const node_ref *NodeRef() const; - const StatStruct *StatBuf() const; + const char* Name() const; + const entry_ref* EntryRef() const; + const node_ref* NodeRef() const; + const StatStruct* StatBuf() const; - BNode *Node() const; + BNode* Node() const; // returns null if not Open - void GetPath(BPath *) const; - void GetEntry(BEntry *) const; + void GetPath(BPath*) const; + void GetEntry(BEntry*) const; - const char *MimeType() const; - const char *PreferredAppSignature() const; + const char* MimeType() const; + const char* PreferredAppSignature() const; // only not-null if not default for type and not self for app - void SetPreferredAppSignature(const char *); + void SetPreferredAppSignature(const char*); void GetPreferredAppForBrokenSymLink(BString &result); // special purpose call - if a symlink is unresolvable, it makes sense @@ -149,36 +150,36 @@ class Model { // a new icon // symlink handling calls, mainly used by the IconCache - const Model *ResolveIfLink() const; - Model *ResolveIfLink(); + const Model* ResolveIfLink() const; + Model* ResolveIfLink(); // works on anything - Model *LinkTo() const; + Model* LinkTo() const; // fast, works only on symlinks - void SetLinkTo(Model *); + void SetLinkTo(Model*); status_t GetLongVersionString(BString &, version_kind); status_t GetVersionString(BString &, version_kind); - status_t AttrAsString(BString &, int64 *value, const char *attributeName, + status_t AttrAsString(BString &, int64* value, const char* attributeName, uint32 attributeType); // Node monitor update call - void UpdateEntryRef(const node_ref *dirRef, const char *name); - bool AttrChanged(const char *); + void UpdateEntryRef(const node_ref* dirRef, const char* name); + bool AttrChanged(const char*); // returns true if pose needs to update it's icon, etc. // pass null to force full update bool StatChanged(); // returns true if pose needs to update it's icon - status_t WatchVolumeAndMountPoint(uint32, BHandler *); + status_t WatchVolumeAndMountPoint(uint32, BHandler*); // correctly handles boot volume name watching - bool IsDropTarget(const Model *forDocument = 0, + bool IsDropTarget(const Model* forDocument = 0, bool traverse = false) const; // if nonzero passed, mime info is used to // resolve if document can be opened // if zero, all executables, directories and volumes pass // if traverse, dereference symlinks - bool IsDropTargetForList(const BObjectList *list) const; + bool IsDropTargetForList(const BObjectList* list) const; // contains mime types of all documents about to be handled // by model @@ -188,19 +189,19 @@ class Model { #endif bool IsSuperHandler() const; - int32 SupportsMimeType(const char *type, const BObjectList *list, + int32 SupportsMimeType(const char* type, const BObjectList* list, bool exactReason = false) const; // pass in one string in or a bunch in // if false, returns as soon as it figures out that // app supports a given type, if true, returns an exact reason // get rid of this?? - ssize_t WriteAttr(const char *attr, type_code type, off_t, - const void *buffer, size_t ); + ssize_t WriteAttr(const char* attr, type_code type, off_t, + const void* buffer, size_t ); // cover call, creates a writable node and writes out attributes // into it; work around for file nodes not being writeable - ssize_t WriteAttrKillForeign(const char *attr, const char *foreignAttr, - type_code type, off_t, const void *buffer, size_t); + ssize_t WriteAttrKillForeign(const char* attr, const char* foreignAttr, + type_code type, off_t, const void* buffer, size_t); bool Mimeset(bool force); // returns true if mime type changed @@ -214,8 +215,8 @@ class Model { void DeletePreferredAppVolumeNameLinkTo(); void CacheLocalizedName(); - status_t FetchOneQuery(const BQuery *, BHandler *target, - BObjectList*, BVolume *); + status_t FetchOneQuery(const BQuery*, BHandler* target, + BObjectList*, BVolume*); enum CanHandleResult { kCanHandle, @@ -245,15 +246,15 @@ class Model { // bit of overloading hackery here to save on footprint union { - char *fPreferredAppName; // used if we are neither a volume nor a symlink - char *fVolumeName; // used if we are a volume - Model *fLinkTo; // used if we are a symlink + char* fPreferredAppName; // used if we are neither a volume nor a symlink + char* fVolumeName; // used if we are a volume + Model* fLinkTo; // used if we are a symlink }; uint8 fBaseType; uint8 fIconFrom; bool fWritable; - BNode *fNode; + BNode* fNode; status_t fStatus; BString fLocalizedName; bool fHasLocalizedName; @@ -266,17 +267,17 @@ class ModelNodeLazyOpener { public: // consider failing when open does not succeed - ModelNodeLazyOpener(Model *model, bool writable = false, bool openLater = true); + ModelNodeLazyOpener(Model* model, bool writable = false, bool openLater = true); ~ModelNodeLazyOpener(); bool IsOpen() const; bool IsOpenForWriting() const; bool IsOpen(bool forWriting) const; - Model *TargetModel() const; + Model* TargetModel() const; status_t OpenNode(bool writable = false); private: - Model *fModel; + Model* fModel; bool fWasOpen; bool fWasOpenForWriting; }; @@ -284,7 +285,7 @@ class ModelNodeLazyOpener { // handy flavors of openers class BModelOpener : public ModelNodeLazyOpener { public: - BModelOpener(Model *model) + BModelOpener(Model* model) : ModelNodeLazyOpener(model, false, false) { } @@ -292,7 +293,7 @@ class BModelOpener : public ModelNodeLazyOpener { class BModelWriteOpener : public ModelNodeLazyOpener { public: - BModelWriteOpener(Model *model) + BModelWriteOpener(Model* model) : ModelNodeLazyOpener(model, true, false) { } @@ -310,36 +311,36 @@ void InitOpenModelDumping(); // inlines follow ----------------------------------- -inline const char * +inline const char* Model::MimeType() const { return fMimeType.String(); } -inline const entry_ref * +inline const entry_ref* Model::EntryRef() const { return &fEntryRef; } -inline const node_ref * +inline const node_ref* Model::NodeRef() const { // the stat structure begins with a node_ref - return (node_ref *)&fStatBuf; + return (node_ref*)&fStatBuf; } -inline BNode * +inline BNode* Model::Node() const { return fNode; } -inline const StatStruct * +inline const StatStruct* Model::StatBuf() const { return &fStatBuf; @@ -360,7 +361,7 @@ Model::SetIconFrom(IconSource from) } -inline Model * +inline Model* Model::LinkTo() const { ASSERT(IsSymLink()); @@ -462,7 +463,7 @@ Model::HasLocalizedName() const inline -ModelNodeLazyOpener::ModelNodeLazyOpener(Model *model, bool writable, bool openLater) +ModelNodeLazyOpener::ModelNodeLazyOpener(Model* model, bool writable, bool openLater) : fModel(model), fWasOpen(model->IsNodeOpen()), fWasOpenForWriting(model->IsNodeOpenForWriting()) @@ -505,7 +506,7 @@ ModelNodeLazyOpener::IsOpen(bool forWriting) const } -inline Model * +inline Model* ModelNodeLazyOpener::TargetModel() const { return fModel; @@ -524,8 +525,6 @@ ModelNodeLazyOpener::OpenNode(bool writable) return B_OK; } - } // namespace BPrivate - -#endif +#endif // _NU_MODEL_H diff --git a/src/kits/tracker/MountMenu.cpp b/src/kits/tracker/MountMenu.cpp index d0b32a71ac..6c0a84a4ee 100644 --- a/src/kits/tracker/MountMenu.cpp +++ b/src/kits/tracker/MountMenu.cpp @@ -61,8 +61,8 @@ class AddMenuItemVisitor : public BDiskDeviceVisitor { AddMenuItemVisitor(BMenu* menu); virtual ~AddMenuItemVisitor(); - virtual bool Visit(BDiskDevice *device); - virtual bool Visit(BPartition *partition, int32 level); + virtual bool Visit(BDiskDevice* device); + virtual bool Visit(BPartition* partition, int32 level); private: BMenu* fMenu; @@ -82,14 +82,14 @@ AddMenuItemVisitor::~AddMenuItemVisitor() bool -AddMenuItemVisitor::Visit(BDiskDevice *device) +AddMenuItemVisitor::Visit(BDiskDevice* device) { return Visit(device, 0); } bool -AddMenuItemVisitor::Visit(BPartition *partition, int32 level) +AddMenuItemVisitor::Visit(BPartition* partition, int32 level) { if (!partition->ContainsFileSystem()) return false; @@ -99,7 +99,7 @@ AddMenuItemVisitor::Visit(BPartition *partition, int32 level) if (name.Length() == 0) { name = partition->Name(); if (name.Length() == 0) { - const char *type = partition->ContentType(); + const char* type = partition->ContentType(); if (type == NULL) return false; @@ -119,19 +119,19 @@ AddMenuItemVisitor::Visit(BPartition *partition, int32 level) } // get icon - BBitmap *icon = new BBitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), + BBitmap* icon = new BBitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), B_RGBA32); if (partition->GetIcon(icon, B_MINI_ICON) != B_OK) { delete icon; icon = NULL; } - BMessage *message = new BMessage(partition->IsMounted() ? + BMessage* message = new BMessage(partition->IsMounted() ? kUnmountVolume : kMountVolume); message->AddInt32("id", partition->ID()); // TODO: for now, until we actually have disk device icons - BMenuItem *item; + BMenuItem* item; if (icon != NULL) item = new IconMenuItem(name.String(), message, icon); else @@ -159,7 +159,7 @@ AddMenuItemVisitor::Visit(BPartition *partition, int32 level) #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "MountMenu" -MountMenu::MountMenu(const char *name) +MountMenu::MountMenu(const char* name) : BMenu(name) { SetFont(be_plain_font); @@ -171,7 +171,7 @@ MountMenu::AddDynamicItem(add_state) { // remove old items for (;;) { - BMenuItem *item = RemoveItem(0L); + BMenuItem* item = RemoveItem(0L); if (item == NULL) break; delete item; @@ -192,7 +192,7 @@ MountMenu::AddDynamicItem(add_state) BVolume volume; while (volumeRoster.GetNextVolume(&volume) == B_OK) { if (volume.IsShared()) { - BBitmap *icon = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8); + BBitmap* icon = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8); fs_info info; if (fs_stat_dev(volume.Device(), &info) != B_OK) { PRINT(("Cannot get mount menu item icon; bad device ID\n")); @@ -203,12 +203,12 @@ MountMenu::AddDynamicItem(add_state) if (get_device_icon(info.device_name, icon->Bits(), B_MINI_ICON) != B_OK) GetTrackerResources()->GetIconResource(R_ShareIcon, B_MINI_ICON, icon); - BMessage *message = new BMessage(kUnmountVolume); + BMessage* message = new BMessage(kUnmountVolume); message->AddInt32("device_id", volume.Device()); char volumeName[B_FILE_NAME_LENGTH]; volume.GetName(volumeName); - BMenuItem *item = new IconMenuItem(volumeName, message, icon); + BMenuItem* item = new IconMenuItem(volumeName, message, icon); item->SetMarked(true); AddItem(item); } diff --git a/src/kits/tracker/MountMenu.h b/src/kits/tracker/MountMenu.h index ea25fdbaff..1d4d093bad 100644 --- a/src/kits/tracker/MountMenu.h +++ b/src/kits/tracker/MountMenu.h @@ -31,18 +31,19 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef MOUNTMENU_H #define MOUNTMENU_H + #include + namespace BPrivate { class MountMenu : public BMenu { public: - MountMenu(const char *); + MountMenu(const char*); protected: @@ -54,4 +55,4 @@ protected: using namespace BPrivate; -#endif +#endif // MOUNTMENU_H diff --git a/src/kits/tracker/NavMenu.cpp b/src/kits/tracker/NavMenu.cpp index abe86fff11..aa6526d383 100644 --- a/src/kits/tracker/NavMenu.cpp +++ b/src/kits/tracker/NavMenu.cpp @@ -128,7 +128,7 @@ SpringLoadedFolderCompareMessages(const BMessage* incoming, void SpringLoadedFolderSetMenuStates(const BMenu* menu, - const BObjectList *typeslist) + const BObjectList* typeslist) { if (!menu || !typeslist) return; @@ -139,7 +139,7 @@ SpringLoadedFolderSetMenuStates(const BMenu* menu, // set the enabled state of the item int32 count = menu->CountItems(); for (int32 index = 0 ; index < count ; index++) { - ModelMenuItem* item = dynamic_cast(menu->ItemAt(index)); + ModelMenuItem* item = dynamic_cast(menu->ItemAt(index)); if (!item) continue; @@ -177,7 +177,7 @@ SpringLoadedFolderSetMenuStates(const BMenu* menu, void SpringLoadedFolderAddUniqueTypeToList(entry_ref* ref, - BObjectList *typeslist) + BObjectList* typeslist) { if (!ref || !typeslist) return; @@ -221,17 +221,17 @@ SpringLoadedFolderAddUniqueTypeToList(entry_ref* ref, void -SpringLoadedFolderCacheDragData(const BMessage* incoming, BMessage* *message, - BObjectList **typeslist) +SpringLoadedFolderCacheDragData(const BMessage* incoming, BMessage** message, + BObjectList** typeslist) { if (!incoming) return; - delete *message; - delete *typeslist; + delete* message; + delete* typeslist; BMessage* localMessage = new BMessage(*incoming); - BObjectList *localTypesList = new BObjectList(10, true); + BObjectList* localTypesList = new BObjectList(10, true); for (int32 index = 0; incoming->HasRef("refs", index); index++) { entry_ref ref; @@ -255,7 +255,7 @@ SpringLoadedFolderCacheDragData(const BMessage* incoming, BMessage* *message, #define B_TRANSLATION_CONTEXT "NavMenu" BNavMenu::BNavMenu(const char* title, uint32 message, const BHandler* target, - BWindow* parentWindow, const BObjectList *list) + BWindow* parentWindow, const BObjectList* list) : BSlowMenu(title), fMessage(message), fMessenger(target, target->Looper()), @@ -272,7 +272,7 @@ BNavMenu::BNavMenu(const char* title, uint32 message, const BHandler* target, // add the parent window to the invocation message so that it // can be closed if option modifier held down during invocation BContainerWindow* originatingWindow = - dynamic_cast(fParentWindow); + dynamic_cast(fParentWindow); if (originatingWindow) fMessage.AddData("nodeRefsToClose", B_RAW_TYPE, originatingWindow->TargetModel()->NodeRef(), sizeof (node_ref)); @@ -284,7 +284,7 @@ BNavMenu::BNavMenu(const char* title, uint32 message, const BHandler* target, BNavMenu::BNavMenu(const char* title, uint32 message, const BMessenger& messenger, BWindow* parentWindow, - const BObjectList *list) + const BObjectList* list) : BSlowMenu(title), fMessage(message), fMessenger(messenger), @@ -301,7 +301,7 @@ BNavMenu::BNavMenu(const char* title, uint32 message, // add the parent window to the invocation message so that it // can be closed if option modifier held down during invocation BContainerWindow* originatingWindow = - dynamic_cast(fParentWindow); + dynamic_cast(fParentWindow); if (originatingWindow) fMessage.AddData("nodeRefsToClose", B_RAW_TYPE, originatingWindow->TargetModel()->NodeRef(), sizeof (node_ref)); @@ -443,11 +443,11 @@ BNavMenu::StartBuildingItemList() BDirectory trashDir; if (FSGetTrashDir(&trashDir, volume.Device()) == B_OK) - dynamic_cast(fContainer)-> + dynamic_cast(fContainer)-> AddItem(new DirectoryEntryList(trashDir)); } } else - fContainer = new DirectoryEntryList(*dynamic_cast + fContainer = new DirectoryEntryList(*dynamic_cast (startModel.Node())); if (fContainer == NULL || fContainer->InitCheck() != B_OK) @@ -549,7 +549,7 @@ void BNavMenu::AddOneItem(Model* model) { BMenuItem* item = NewModelItem(model, &fMessage, fMessenger, false, - dynamic_cast(fParentWindow), + dynamic_cast(fParentWindow), fTypesList, &fTrackingHook); if (item) @@ -560,7 +560,7 @@ BNavMenu::AddOneItem(Model* model) ModelMenuItem* BNavMenu::NewModelItem(Model* model, const BMessage* invokeMessage, const BMessenger& target, bool suppressFolderHierarchy, - BContainerWindow* parentWindow, const BObjectList *typeslist, + BContainerWindow* parentWindow, const BObjectList* typeslist, TrackingHookData* hook) { if (model->InitCheck() != B_OK) @@ -691,8 +691,8 @@ BNavMenu::BuildVolumeMenu() int BNavMenu::CompareFolderNamesFirstOne(const BMenuItem* i1, const BMenuItem* i2) { - const ModelMenuItem* item1 = dynamic_cast(i1); - const ModelMenuItem* item2 = dynamic_cast(i2); + const ModelMenuItem* item1 = dynamic_cast(i1); + const ModelMenuItem* item2 = dynamic_cast(i2); if (item1 != NULL && item2 != NULL) return item1->TargetModel()->CompareFolderNamesFirst(item2->TargetModel()); @@ -812,13 +812,13 @@ BNavMenu::SetShowParent(bool show) void -BNavMenu::SetTypesList(const BObjectList *list) +BNavMenu::SetTypesList(const BObjectList* list) { fTypesList = list; } -const BObjectList * +const BObjectList* BNavMenu::TypesList() const { return fTypesList; @@ -868,4 +868,3 @@ BNavMenu::SetTrackingHookDeep(BMenu* menu, bool (*func)(BMenu*, void*), SetTrackingHookDeep(submenu, func, state); } } - diff --git a/src/kits/tracker/Navigator.cpp b/src/kits/tracker/Navigator.cpp index bb684347de..81d8e01c09 100644 --- a/src/kits/tracker/Navigator.cpp +++ b/src/kits/tracker/Navigator.cpp @@ -31,6 +31,8 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + + #include "Bitmaps.h" #include "Commands.h" #include "ContainerWindow.h" @@ -38,9 +40,11 @@ All rights reserved. #include "Model.h" #include "Navigator.h" #include "Tracker.h" -#include + #include #include +#include + namespace BPrivate { @@ -49,50 +53,53 @@ static const int32 kMaxHistory = 32; } // BPictureButton() will crash when giving zero pointers, -// although we really want and have to set up the +// although we really want and have to set up the // pictures when we can, e.g. on a AttachedToWindow. static BPicture sPicture; -BNavigatorButton::BNavigatorButton(BRect rect, const char *name, BMessage *message, + +BNavigatorButton::BNavigatorButton(BRect rect, const char* name, BMessage* message, int32 resIDon, int32 resIDoff, int32 resIDdisabled) : BPictureButton(rect, name, &sPicture, &sPicture, message), fResIDOn(resIDon), fResIDOff(resIDoff), fResIDDisabled(resIDdisabled) { - // Clear to background color to - // avoid ugly border on click + // Clear to background color to avoid ugly border on click SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); } + BNavigatorButton::~BNavigatorButton() { } + void BNavigatorButton::AttachedToWindow() { - BBitmap *bmpOn = 0; + BBitmap* bmpOn = 0; GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, fResIDOn, &bmpOn); SetPicture(bmpOn, true, true); delete bmpOn; - BBitmap *bmpOff = 0; + BBitmap* bmpOff = 0; GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, fResIDOff, &bmpOff); SetPicture(bmpOff, true, false); delete bmpOff; - BBitmap *bmpDisabled = 0; + BBitmap* bmpDisabled = 0; GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, fResIDDisabled, &bmpDisabled); SetPicture(bmpDisabled, false, false); SetPicture(bmpDisabled, false, true); delete bmpDisabled; } + void -BNavigatorButton::SetPicture(BBitmap *bitmap, bool enabled, bool on) +BNavigatorButton::SetPicture(BBitmap* bitmap, bool enabled, bool on) { if (bitmap) { BPicture picture; @@ -115,11 +122,11 @@ BNavigatorButton::SetPicture(BBitmap *bitmap, bool enabled, bool on) SetDisabledOn(&picture); else SetDisabledOff(&picture); - } + } } -BNavigator::BNavigator(const Model *model, BRect rect, uint32 resizeMask) +BNavigator::BNavigator(const Model* model, BRect rect, uint32 resizeMask) : BView(rect, "Navigator", resizeMask, B_WILL_DRAW), fBack(0), fForw(0), @@ -158,16 +165,17 @@ BNavigator::BNavigator(const Model *model, BRect rect, uint32 resizeMask) B_FOLLOW_LEFT_RIGHT); fLocation->SetDivider(0); AddChild(fLocation); - } + BNavigator::~BNavigator() { } -void + +void BNavigator::AttachedToWindow() -{ +{ // Inital setup of widget states UpdateLocation(0, kActionSet); @@ -178,7 +186,8 @@ BNavigator::AttachedToWindow() fLocation->SetTarget(this); } -void + +void BNavigator::Draw(BRect) { rgb_color bgColor = ui_color(B_PANEL_BACKGROUND_COLOR); @@ -194,8 +203,9 @@ BNavigator::Draw(BRect) EndLineArray(); } -void -BNavigator::MessageReceived(BMessage *message) + +void +BNavigator::MessageReceived(BMessage* message) { switch (message->what) { case kNavigatorCommandBackward: @@ -213,30 +223,30 @@ BNavigator::MessageReceived(BMessage *message) case kNavigatorCommandLocation: GoTo(); break; - + default: - { - // Catch any dropped refs and try - // to switch to this new directory - entry_ref ref; - if (message->FindRef("refs", &ref) == B_OK) { - BMessage message(kSwitchDirectory); - BEntry entry(&ref, true); - if (!entry.IsDirectory()) { - entry.GetRef(&ref); - BPath path(&ref); - path.GetParent(&path); - get_ref_for_path(path.Path(), &ref); - } - message.AddRef("refs", &ref); - message.AddInt32("action", kActionSet); - Window()->PostMessage(&message); + { + // Catch any dropped refs and try to switch to this new directory + entry_ref ref; + if (message->FindRef("refs", &ref) == B_OK) { + BMessage message(kSwitchDirectory); + BEntry entry(&ref, true); + if (!entry.IsDirectory()) { + entry.GetRef(&ref); + BPath path(&ref); + path.GetParent(&path); + get_ref_for_path(path.Path(), &ref); } + message.AddRef("refs", &ref); + message.AddInt32("action", kActionSet); + Window()->PostMessage(&message); } + } } } -void + +void BNavigator::GoBackward(bool option) { int32 itemCount = fBackHistory.CountItems(); @@ -247,7 +257,8 @@ BNavigator::GoBackward(bool option) } } -void + +void BNavigator::GoForward(bool option) { if (fForwHistory.CountItems() >= 1) { @@ -257,7 +268,8 @@ BNavigator::GoForward(bool option) } } -void + +void BNavigator::GoUp(bool option) { BEntry entry; @@ -268,8 +280,9 @@ BNavigator::GoUp(bool option) } } + void -BNavigator::SendNavigationMessage(NavigationAction action, BEntry *entry, bool option) +BNavigator::SendNavigationMessage(NavigationAction action, BEntry* entry, bool option) { entry_ref ref; @@ -279,7 +292,7 @@ BNavigator::SendNavigationMessage(NavigationAction action, BEntry *entry, bool o message.AddInt32("action", action); // get the node of this folder for selecting it in the new location - const node_ref *nodeRef; + const node_ref* nodeRef; if (Window() && Window()->TargetModel()) nodeRef = Window()->TargetModel()->NodeRef(); else @@ -306,13 +319,14 @@ BNavigator::SendNavigationMessage(NavigationAction action, BEntry *entry, bool o // Todo: Change the locking behaviour of StandAloneTaskLoop::Run() and sub- // sequently called functions. if (nodeRef) - dynamic_cast(be_app)->SelectChildInParentSoon(&ref, nodeRef); + dynamic_cast(be_app)->SelectChildInParentSoon(&ref, nodeRef); LockLooper(); } } } -void + +void BNavigator::GoTo() { BString pathname = fLocation->Text(); @@ -329,25 +343,24 @@ BNavigator::GoTo() BMessage message(kSwitchDirectory); message.AddRef("refs", &ref); message.AddInt32("action", kActionLocation); - Window()->PostMessage(&message); + Window()->PostMessage(&message); } else { BPath path; - if (Window() - && Window()->TargetModel()) { + if (Window() && Window()->TargetModel()) { Window()->TargetModel()->GetPath(&path); fLocation->SetText(path.Path()); } } } -void -BNavigator::UpdateLocation(const Model *newmodel, int32 action) + +void +BNavigator::UpdateLocation(const Model* newmodel, int32 action) { if (newmodel) newmodel->GetPath(&fPath); - // Modify history according to commands switch (action) { case kActionBackward: @@ -362,9 +375,9 @@ BNavigator::UpdateLocation(const Model *newmodel, int32 action) fForwHistory.MakeEmpty(); fBackHistory.AddItem(new BPath(fPath)); - for (;fBackHistory.CountItems()>kMaxHistory;) + for (; fBackHistory.CountItems() > kMaxHistory;) fBackHistory.RemoveItem(fBackHistory.FirstItem(), true); - break; + break; } // Enable Up button when there is any parent @@ -383,6 +396,7 @@ BNavigator::UpdateLocation(const Model *newmodel, int32 action) fLocation->SetText(fPath.Path()); } + float BNavigator::CalcNavigatorHeight(void) { diff --git a/src/kits/tracker/Navigator.h b/src/kits/tracker/Navigator.h index 1242324fa0..be31770547 100644 --- a/src/kits/tracker/Navigator.h +++ b/src/kits/tracker/Navigator.h @@ -34,11 +34,13 @@ All rights reserved. #ifndef _NAVIGATOR_H_ #define _NAVIGATOR_H_ + #include "Model.h" #include #include + class BTextControl; class BEntry; @@ -59,18 +61,19 @@ enum NavigationAction kNavigatorCommandLocation = 'NVLC' }; + // Custom BPictureButton which takes // bitmap resource IDs as arguments class BNavigatorButton : public BPictureButton { public: - BNavigatorButton(BRect rect, const char *name, BMessage *message, int32 resIDon, + BNavigatorButton(BRect rect, const char* name, BMessage* message, int32 resIDon, int32 resIDoff, int32 resIDdisabled); ~BNavigatorButton(); virtual void AttachedToWindow(); - void SetPicture(BBitmap *, bool enabled, bool on); + void SetPicture(BBitmap*, bool enabled, bool on); private: int32 fResIDOn; @@ -78,36 +81,37 @@ private: int32 fResIDDisabled; }; + class BNavigator : public BView { public: - BNavigator(const Model *model, BRect rect, uint32 resizeMask = B_FOLLOW_LEFT_RIGHT); + BNavigator(const Model* model, BRect rect, + uint32 resizeMask = B_FOLLOW_LEFT_RIGHT); ~BNavigator(); - - void UpdateLocation(const Model *newmodel, int32 action); + + void UpdateLocation(const Model* newmodel, int32 action); static float CalcNavigatorHeight(void); - BContainerWindow *Window() const; + BContainerWindow* Window() const; protected: virtual void Draw(BRect rect); - virtual void MessageReceived(BMessage *msg); + virtual void MessageReceived(BMessage* msg); virtual void AttachedToWindow(); - + void GoForward(bool option); // is option key held down? void GoBackward(bool option); void GoUp(bool option); - void SendNavigationMessage(NavigationAction, BEntry *, bool option); - + void SendNavigationMessage(NavigationAction, BEntry*, bool option); + void GoTo(); private: - - BPath fPath; - BNavigatorButton *fBack; - BNavigatorButton *fForw; - BNavigatorButton *fUp; - BTextControl *fLocation; + BPath fPath; + BNavigatorButton* fBack; + BNavigatorButton* fForw; + BNavigatorButton* fUp; + BTextControl* fLocation; BObjectList fBackHistory; BObjectList fForwHistory; @@ -115,11 +119,12 @@ private: typedef BView _inherited; }; + inline -BContainerWindow * +BContainerWindow* BNavigator::Window() const { - return dynamic_cast(_inherited::Window()); + return dynamic_cast(_inherited::Window()); } @@ -127,4 +132,4 @@ BNavigator::Window() const using namespace BPrivate; -#endif +#endif // _NAVIGATOR_H_ diff --git a/src/kits/tracker/NodePreloader.cpp b/src/kits/tracker/NodePreloader.cpp index 4a090a740a..d01333868a 100644 --- a/src/kits/tracker/NodePreloader.cpp +++ b/src/kits/tracker/NodePreloader.cpp @@ -51,10 +51,10 @@ All rights reserved. #include "Tracker.h" -NodePreloader * -NodePreloader::InstallNodePreloader(const char *name, BLooper *host) +NodePreloader* +NodePreloader::InstallNodePreloader(const char* name, BLooper* host) { - NodePreloader *result = new NodePreloader(name); + NodePreloader* result = new NodePreloader(name); { AutoLock lock(host); if (!lock) @@ -66,7 +66,7 @@ NodePreloader::InstallNodePreloader(const char *name, BLooper *host) } -NodePreloader::NodePreloader(const char *name) +NodePreloader::NodePreloader(const char* name) : BHandler(name), fModelList(20, true), fQuitRequested(false) @@ -82,7 +82,7 @@ NodePreloader::~NodePreloader() } -void +void NodePreloader::Run() { fLock.Lock(); @@ -90,72 +90,74 @@ NodePreloader::Run() } -Model * +Model* NodePreloader::FindModel(node_ref itemNode) const { for (int32 count = fModelList.CountItems() - 1; count >= 0; count--) { - Model *model = fModelList.ItemAt(count); - if (*model->NodeRef() == itemNode) + Model* model = fModelList.ItemAt(count); + if (*model->NodeRef() == itemNode) return model; } return NULL; } -void -NodePreloader::MessageReceived(BMessage *message) +void +NodePreloader::MessageReceived(BMessage* message) { // respond to node monitor notifications node_ref itemNode; switch (message->what) { case B_NODE_MONITOR: + { switch (message->FindInt32("opcode")) { case B_ENTRY_REMOVED: - { - AutoLock locker(fLock); - message->FindInt32("device", &itemNode.device); - message->FindInt64("node", &itemNode.node); - Model *model = FindModel(itemNode); - if (!model) - break; -// PRINT(("preloader removing file %s\n", model->Name())); - IconCache::sIconCache->Removing(model); - fModelList.RemoveItem(model); + { + AutoLock locker(fLock); + message->FindInt32("device", &itemNode.device); + message->FindInt64("node", &itemNode.node); + Model* model = FindModel(itemNode); + if (!model) break; - } + //PRINT(("preloader removing file %s\n", model->Name())); + IconCache::sIconCache->Removing(model); + fModelList.RemoveItem(model); + break; + } case B_ATTR_CHANGED: case B_STAT_CHANGED: - { - AutoLock locker(fLock); - message->FindInt32("device", &itemNode.device); - message->FindInt64("node", &itemNode.node); + { + AutoLock locker(fLock); + message->FindInt32("device", &itemNode.device); + message->FindInt64("node", &itemNode.node); - const char *attrName; - message->FindString("attr", &attrName); - Model *model = FindModel(itemNode); - if (!model) - break; - BModelOpener opener(model); - IconCache::sIconCache->IconChanged(model->ResolveIfLink()); -// PRINT(("preloader updating file %s\n", model->Name())); + const char* attrName; + message->FindString("attr", &attrName); + Model* model = FindModel(itemNode); + if (!model) break; - } + BModelOpener opener(model); + IconCache::sIconCache->IconChanged(model->ResolveIfLink()); + //PRINT(("preloader updating file %s\n", model->Name())); + break; + } } break; + } default: _inherited::MessageReceived(message); - break; + break; } } -void -NodePreloader::PreloadOne(const char *dirPath) +void +NodePreloader::PreloadOne(const char* dirPath) { -// PRINT(("preloading directory %s\n", dirPath)); + //PRINT(("preloading directory %s\n", dirPath)); BDirectory dir(dirPath); if (!dir.InitCheck() == B_OK) return; @@ -177,7 +179,7 @@ NodePreloader::PreloadOne(const char *dirPath) // only interrested in files continue; - Model *model = new Model(&ref, true); + Model* model = new Model(&ref, true); if (model->InitCheck() == B_OK && model->IconFrom() == kUnknownSource) { TTracker::WatchNode(model->NodeRef(), B_WATCH_STAT | B_WATCH_ATTR, this); @@ -187,11 +189,10 @@ NodePreloader::PreloadOne(const char *dirPath) } else delete model; } - } -void +void NodePreloader::Preload() { for (int32 count = 100; count >= 0; count--) { @@ -211,11 +212,10 @@ NodePreloader::Preload() ASSERT(fLock.IsLocked()); BPath path; - if (find_directory(B_BEOS_APPS_DIRECTORY, &path) == B_OK) + if (find_directory(B_BEOS_APPS_DIRECTORY, &path) == B_OK) PreloadOne(path.Path()); if (find_directory(B_BEOS_PREFERENCES_DIRECTORY, &path) == B_OK) PreloadOne(path.Path()); - + fLock.Unlock(); } - diff --git a/src/kits/tracker/NodePreloader.h b/src/kits/tracker/NodePreloader.h index 3de1c7c8cc..b4e2b224ba 100644 --- a/src/kits/tracker/NodePreloader.h +++ b/src/kits/tracker/NodePreloader.h @@ -42,34 +42,34 @@ All rights reserved. // aliasing after a deletion, etc. // // The node preloader knows which icons to preload - #ifndef __NODE_CACHE_PRELOADER__ #define __NODE_CACHE_PRELOADER__ + #include #include "ObjectList.h" #include "Model.h" + namespace BPrivate { class NodePreloader : public BHandler { public: - static NodePreloader *InstallNodePreloader(const char *name, BLooper *host); + static NodePreloader* InstallNodePreloader(const char* name, BLooper* host); virtual ~NodePreloader(); protected: - NodePreloader(const char *name); - virtual void MessageReceived(BMessage *); + NodePreloader(const char* name); + virtual void MessageReceived(BMessage*); void Run(); private: - void PreloadOne(const char *dirPath); + void PreloadOne(const char* dirPath); virtual void Preload(); // for now just preload apps and prefs - Model *FindModel(node_ref) const; - + Model* FindModel(node_ref) const; BObjectList fModelList; Benaphore fLock; @@ -82,4 +82,4 @@ private: using namespace BPrivate; -#endif +#endif // __NODE_CACHE_PRELOADER__ diff --git a/src/kits/tracker/NodeWalker.cpp b/src/kits/tracker/NodeWalker.cpp index bba97a47f8..e95ef660a8 100644 --- a/src/kits/tracker/NodeWalker.cpp +++ b/src/kits/tracker/NodeWalker.cpp @@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include #include #include @@ -40,6 +41,7 @@ All rights reserved. #include "NodeWalker.h" + namespace BTrackerPrivate { TWalker::~TWalker() @@ -48,21 +50,21 @@ TWalker::~TWalker() // all the following calls are pure viruals, should not get called status_t -TWalker::GetNextEntry(BEntry *, bool ) +TWalker::GetNextEntry(BEntry*, bool ) { TRESPASS(); return B_ERROR; } status_t -TWalker::GetNextRef(entry_ref *) +TWalker::GetNextRef(entry_ref*) { TRESPASS(); return B_ERROR; } int32 -TWalker::GetNextDirents(struct dirent *, size_t, int32) +TWalker::GetNextDirents(struct dirent*, size_t, int32) { TRESPASS(); return 0; @@ -96,7 +98,7 @@ TNodeWalker::TNodeWalker(bool includeTopDirectory) } -TNodeWalker::TNodeWalker(const char *path, bool includeTopDirectory) +TNodeWalker::TNodeWalker(const char* path, bool includeTopDirectory) : fDirs(20), fTopIndex(-1), fTopDir(0), @@ -122,7 +124,7 @@ TNodeWalker::TNodeWalker(const char *path, bool includeTopDirectory) } -TNodeWalker::TNodeWalker(const entry_ref *ref, bool includeTopDirectory) +TNodeWalker::TNodeWalker(const entry_ref* ref, bool includeTopDirectory) : fDirs(20), fTopIndex(-1), fTopDir(0), @@ -148,7 +150,7 @@ TNodeWalker::TNodeWalker(const entry_ref *ref, bool includeTopDirectory) } -TNodeWalker::TNodeWalker(const BDirectory *dir, bool includeTopDirectory) +TNodeWalker::TNodeWalker(const BDirectory* dir, bool includeTopDirectory) : fDirs(20), fTopIndex(-1), fTopDir(0), @@ -175,7 +177,7 @@ TNodeWalker::TNodeWalker() { } -TNodeWalker::TNodeWalker(const char *path) +TNodeWalker::TNodeWalker(const char* path) : fDirs(20), fTopIndex(-1), fTopDir(0), @@ -200,7 +202,7 @@ TNodeWalker::TNodeWalker(const char *path) } } -TNodeWalker::TNodeWalker(const entry_ref *ref) +TNodeWalker::TNodeWalker(const entry_ref* ref) : fDirs(20), fTopIndex(-1), fTopDir(0), @@ -225,7 +227,7 @@ TNodeWalker::TNodeWalker(const entry_ref *ref) } } -TNodeWalker::TNodeWalker(const BDirectory *dir) +TNodeWalker::TNodeWalker(const BDirectory* dir) : fDirs(20), fTopIndex(-1), fTopDir(0), @@ -245,7 +247,7 @@ TNodeWalker::~TNodeWalker() delete fOriginalJustFile; for (;;) { - BDirectory *directory = fDirs.RemoveItemAt(fTopIndex--); + BDirectory* directory = fDirs.RemoveItemAt(fTopIndex--); if (directory == NULL) break; delete directory; @@ -274,7 +276,7 @@ TNodeWalker::PopDirCommon() } void -TNodeWalker::PushDirCommon(const entry_ref *ref) +TNodeWalker::PushDirCommon(const entry_ref* ref) { fTopDir = new BDirectory(ref); // OK to ignore error here. Will @@ -284,7 +286,7 @@ TNodeWalker::PushDirCommon(const entry_ref *ref) } status_t -TNodeWalker::GetNextEntry(BEntry *entry, bool traverse) +TNodeWalker::GetNextEntry(BEntry* entry, bool traverse) { if (fJustFile) { *entry = *fJustFile; @@ -316,14 +318,14 @@ TNodeWalker::GetNextEntry(BEntry *entry, bool traverse) entry_ref ref; err = entry->GetRef(&ref); - if (err == B_OK && fTopDir->Contains(ref.name, B_DIRECTORY_NODE)) + if (err == B_OK && fTopDir->Contains(ref.name, B_DIRECTORY_NODE)) PushDirCommon(&ref); return err; } status_t -TNodeWalker::GetNextRef(entry_ref *ref) +TNodeWalker::GetNextRef(entry_ref* ref) { if (fJustFile) { fJustFile->GetRef(ref); @@ -363,7 +365,7 @@ TNodeWalker::GetNextRef(entry_ref *ref) } static int32 -build_dirent(const BEntry *source, struct dirent *ent, +build_dirent(const BEntry* source, struct dirent* ent, size_t size, int32 count) { entry_ref ref; @@ -397,7 +399,7 @@ build_dirent(const BEntry *source, struct dirent *ent, } int32 -TNodeWalker::GetNextDirents(struct dirent *ent, size_t size, int32 count) +TNodeWalker::GetNextDirents(struct dirent* ent, size_t size, int32 count) { if (fJustFile) { if (!count) @@ -440,7 +442,7 @@ TNodeWalker::GetNextDirents(struct dirent *ent, size_t size, int32 count) entry_ref ref(ent->d_dev, ent->d_ino, ent->d_name); PushDirCommon(&ref); } - ent = (dirent *)((char *)ent + ent->d_reclen); + ent = (dirent*)((char*)ent + ent->d_reclen); } return result; @@ -457,7 +459,7 @@ TNodeWalker::Rewind() // pop all the directories and point to the initial one for (;;) { - BDirectory *directory = fDirs.RemoveItemAt(fTopIndex--); + BDirectory* directory = fDirs.RemoveItemAt(fTopIndex--); if (!directory) break; delete directory; @@ -484,11 +486,8 @@ TVolWalker::TVolWalker(bool knowsAttributes, bool writable, bool includeTopDirec fKnowsAttr(knowsAttributes), fWritable(writable) { - - /* - Get things initialized. Find first volume, or find the first volume - that supports attributes. - */ + // Get things initialized. Find first volume, or find the first volume + // that supports attributes. NextVolume(); } @@ -528,7 +527,7 @@ TVolWalker::NextVolume() } status_t -TVolWalker::GetNextEntry(BEntry *entry, bool traverse) +TVolWalker::GetNextEntry(BEntry* entry, bool traverse) { if (!fTopDir) return B_ENTRY_NOT_FOUND; @@ -548,7 +547,7 @@ TVolWalker::GetNextEntry(BEntry *entry, bool traverse) } status_t -TVolWalker::GetNextRef(entry_ref *ref) +TVolWalker::GetNextRef(entry_ref* ref) { if (!fTopDir) return B_ENTRY_NOT_FOUND; @@ -568,7 +567,7 @@ TVolWalker::GetNextRef(entry_ref *ref) } int32 -TVolWalker::GetNextDirents(struct dirent *ent, size_t size, int32 count) +TVolWalker::GetNextDirents(struct dirent* ent, size_t size, int32 count) { if (!fTopDir) return B_ENTRY_NOT_FOUND; @@ -594,7 +593,7 @@ TVolWalker::Rewind() return NextVolume(); } -TQueryWalker::TQueryWalker(const char *predicate) +TQueryWalker::TQueryWalker(const char* predicate) : TWalker(), fQuery(), fVolRoster(), fVol() { fPredicate = strdup(predicate); @@ -608,7 +607,7 @@ TQueryWalker::~TQueryWalker() } status_t -TQueryWalker::GetNextEntry(BEntry *entry, bool traverse) +TQueryWalker::GetNextEntry(BEntry* entry, bool traverse) { status_t err; @@ -624,7 +623,7 @@ TQueryWalker::GetNextEntry(BEntry *entry, bool traverse) } status_t -TQueryWalker::GetNextRef(entry_ref *ref) +TQueryWalker::GetNextRef(entry_ref* ref) { status_t err; @@ -642,7 +641,7 @@ TQueryWalker::GetNextRef(entry_ref *ref) } int32 -TQueryWalker::GetNextDirents(struct dirent *ent, size_t size, int32 count) +TQueryWalker::GetNextDirents(struct dirent* ent, size_t size, int32 count) { int32 result; diff --git a/src/kits/tracker/NodeWalker.h b/src/kits/tracker/NodeWalker.h index 0b3449ad0e..f13f65e23b 100644 --- a/src/kits/tracker/NodeWalker.h +++ b/src/kits/tracker/NodeWalker.h @@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef WALKER_H #define WALKER_H + #ifndef _BE_BUILD_H #include #endif @@ -48,8 +48,8 @@ All rights reserved. #include "ObjectList.h" -namespace BTrackerPrivate { +namespace BTrackerPrivate { class TWalker : public BEntryList { // adds a virtual destructor that is severely missing in BEntryList @@ -58,40 +58,41 @@ class TWalker : public BEntryList { public: virtual ~TWalker(); - virtual status_t GetNextEntry(BEntry *, bool traverse = false) = 0; - virtual status_t GetNextRef(entry_ref *) = 0; - virtual int32 GetNextDirents(struct dirent *, size_t, + virtual status_t GetNextEntry(BEntry*, bool traverse = false) = 0; + virtual status_t GetNextRef(entry_ref*) = 0; + virtual int32 GetNextDirents(struct dirent*, size_t, int32 count = INT_MAX) = 0; virtual status_t Rewind() = 0; virtual int32 CountEntries() = 0; }; + class TNodeWalker : public TWalker { // TNodeWalker supports iterating a single volume, starting from a specified // entry; if passed a non-directory entry it returns just that one entry public: TNodeWalker(bool includeTopDirectory); - TNodeWalker(const char *path, bool includeTopDirectory); - TNodeWalker(const entry_ref *ref, bool includeTopDirectory); - TNodeWalker(const BDirectory *dir, bool includeTopDirectory); + TNodeWalker(const char* path, bool includeTopDirectory); + TNodeWalker(const entry_ref* ref, bool includeTopDirectory); + TNodeWalker(const BDirectory* dir, bool includeTopDirectory); virtual ~TNodeWalker(); // Backwards compatibility with Tracker compiled for R5 (remove when this // gets integrated into the official release). TNodeWalker(); - TNodeWalker(const char *path); - TNodeWalker(const entry_ref *ref); - TNodeWalker(const BDirectory *dir); + TNodeWalker(const char* path); + TNodeWalker(const entry_ref* ref); + TNodeWalker(const BDirectory* dir); - virtual status_t GetNextEntry(BEntry *, bool traverse = false); - virtual status_t GetNextRef(entry_ref *); - virtual int32 GetNextDirents(struct dirent *, size_t, + virtual status_t GetNextEntry(BEntry*, bool traverse = false); + virtual status_t GetNextRef(entry_ref*); + virtual int32 GetNextDirents(struct dirent*, size_t, int32 count = INT_MAX); virtual status_t Rewind(); protected: status_t PopDirCommon(); - void PushDirCommon(const entry_ref *); + void PushDirCommon(const entry_ref*); private: virtual int32 CountEntries(); @@ -100,17 +101,18 @@ private: protected: BObjectList fDirs; int32 fTopIndex; - BDirectory *fTopDir; + BDirectory* fTopDir; bool fIncludeTopDir; bool fOriginalIncludeTopDir; - -private: - BEntry *fJustFile; + +private: + BEntry* fJustFile; BDirectory fOriginalDirCopy; - BEntry *fOriginalJustFile; + BEntry* fOriginalJustFile; // keep around to support Rewind }; + class TVolWalker : public TNodeWalker { // TNodeWalker supports iterating over all the mounted volumes; // non-attribute and read-only volumes may optionaly be filtered out @@ -119,15 +121,15 @@ public: bool includeTopDirectory = true); virtual ~TVolWalker(); - virtual status_t GetNextEntry(BEntry *, bool traverse = false); - virtual status_t GetNextRef(entry_ref *); - virtual int32 GetNextDirents(struct dirent *, size_t, + virtual status_t GetNextEntry(BEntry*, bool traverse = false); + virtual status_t GetNextRef(entry_ref*); + virtual int32 GetNextDirents(struct dirent*, size_t, int32 count = INT_MAX); - virtual status_t Rewind(); + virtual status_t Rewind(); - virtual status_t NextVolume(); + virtual status_t NextVolume(); // skips to the next volume - // Note: it would be cool to return const BVolume * + // Note: it would be cool to return const BVolume* // that way a subclass could implement a volume filter - // it would just override, call inherited for as long as there // are volumes and it does not like them @@ -139,19 +141,20 @@ private: BVolume fVol; bool fKnowsAttr; bool fWritable; - + typedef TNodeWalker _inherited; }; + class TQueryWalker : public TWalker { public: - TQueryWalker(const char *predicate); + TQueryWalker(const char* predicate); virtual ~TQueryWalker(); // Does an in-fix walk of all entries - virtual status_t GetNextEntry(BEntry *, bool traverse = false); - virtual status_t GetNextRef(entry_ref *); - virtual int32 GetNextDirents(struct dirent *, size_t, + virtual status_t GetNextEntry(BEntry*, bool traverse = false); + virtual status_t GetNextRef(entry_ref*); + virtual int32 GetNextDirents(struct dirent*, size_t, int32 count = INT_MAX); virtual status_t NextVolume(); @@ -159,16 +162,16 @@ public: virtual status_t Rewind(); private: - virtual int32 CountEntries(); + virtual int32 CountEntries(); // can't count BQuery fQuery; BVolumeRoster fVolRoster; BVolume fVol; bigtime_t fTime; - const char *fPredicate; + const char* fPredicate; - typedef TQueryWalker _inherited; + typedef TQueryWalker _inherited; }; } // namespace BTrackerPrivate diff --git a/src/kits/tracker/OpenWithWindow.cpp b/src/kits/tracker/OpenWithWindow.cpp index 9b9b8ac478..ff957d0205 100644 --- a/src/kits/tracker/OpenWithWindow.cpp +++ b/src/kits/tracker/OpenWithWindow.cpp @@ -58,7 +58,7 @@ All rights reserved. #include -const char *kDefaultOpenWithTemplate = "OpenWithSettings"; +const char* kDefaultOpenWithTemplate = "OpenWithSettings"; // ToDo: // filter out trash @@ -76,8 +76,8 @@ const rgb_color kOpenWithDefaultColor = { 0xFF, 0xFF, 0xCC, 255}; #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "OpenWithWindow" -OpenWithContainerWindow::OpenWithContainerWindow(BMessage *entriesToOpen, - LockingList *windowList, window_look look, window_feel feel, +OpenWithContainerWindow::OpenWithContainerWindow(BMessage* entriesToOpen, + LockingList* windowList, window_look look, window_feel feel, uint32 flags, uint32 workspace) : BContainerWindow(windowList, 0, look, feel, flags, workspace), fEntriesToOpen(entriesToOpen) @@ -91,7 +91,7 @@ OpenWithContainerWindow::OpenWithContainerWindow(BMessage *entriesToOpen, // add a background view; use the standard BackgroundView here, the same // as the file panel is using BRect rect(Bounds()); - BackgroundView *backgroundView = new BackgroundView(rect); + BackgroundView* backgroundView = new BackgroundView(rect); AddChild(backgroundView); rect = Bounds(); @@ -118,7 +118,7 @@ OpenWithContainerWindow::OpenWithContainerWindow(BMessage *entriesToOpen, fLaunchAndMakeDefaultButton->SetEnabled(false); buttonRect = fLaunchAndMakeDefaultButton->Frame(); - BButton *button = new BButton(buttonRect, "cancel", B_TRANSLATE("Cancel"), + BButton* button = new BButton(buttonRect, "cancel", B_TRANSLATE("Cancel"), new BMessage(kCancelButton), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); button->ResizeToPreferred(); button->MoveBy(- 10 - button->Bounds().Width(), 0); @@ -166,22 +166,22 @@ OpenWithContainerWindow::~OpenWithContainerWindow() } -BPoseView * -OpenWithContainerWindow::NewPoseView(Model *, BRect rect, uint32) +BPoseView* +OpenWithContainerWindow::NewPoseView(Model*, BRect rect, uint32) { return new OpenWithPoseView(rect); } -OpenWithPoseView * +OpenWithPoseView* OpenWithContainerWindow::PoseView() const { - ASSERT(dynamic_cast(fPoseView)); - return static_cast(fPoseView); + ASSERT(dynamic_cast(fPoseView)); + return static_cast(fPoseView); } -const BMessage * +const BMessage* OpenWithContainerWindow::EntryList() const { return fEntriesToOpen; @@ -200,20 +200,20 @@ OpenWithContainerWindow::OpenWithSelection() } -static const BString * -FindOne(const BString *element, void *castToString) +static const BString* +FindOne(const BString* element, void* castToString) { - if (strcasecmp(element->String(), (const char *)castToString) == 0) + if (strcasecmp(element->String(), (const char*)castToString) == 0) return element; return 0; } -static const entry_ref * -AddOneUniqueDocumentType(const entry_ref *ref, void *castToList) +static const entry_ref* +AddOneUniqueDocumentType(const entry_ref* ref, void* castToList) { - BObjectList *list = (BObjectList *)castToList; + BObjectList* list = (BObjectList*)castToList; BEntry entry(ref, true); // traverse symlinks @@ -238,10 +238,10 @@ AddOneUniqueDocumentType(const entry_ref *ref, void *castToList) } -static const BString * -SetDefaultAppForOneType(const BString *element, void *castToEntryRef) +static const BString* +SetDefaultAppForOneType(const BString* element, void* castToEntryRef) { - const entry_ref *appRef = (const entry_ref *)castToEntryRef; + const entry_ref* appRef = (const entry_ref*)castToEntryRef; // set entry as default handler for one mime string BMimeType mime(element->String()); @@ -288,7 +288,7 @@ OpenWithContainerWindow::MakeDefaultAndOpen() if (!count) return; - BPose *selectedAppPose = PoseView()->SelectionList()->FirstItem(); + BPose* selectedAppPose = PoseView()->SelectionList()->FirstItem(); ASSERT(selectedAppPose); if (!selectedAppPose) return; @@ -300,7 +300,7 @@ OpenWithContainerWindow::MakeDefaultAndOpen() // set the default application to be the selected pose for all the // mime types in the list openedFileTypes.EachElement(SetDefaultAppForOneType, - (void *)selectedAppPose->TargetModel()->EntryRef()); + (void*)selectedAppPose->TargetModel()->EntryRef()); // done setting the default application, now launch the app with the // documents @@ -309,7 +309,7 @@ OpenWithContainerWindow::MakeDefaultAndOpen() void -OpenWithContainerWindow::MessageReceived(BMessage *message) +OpenWithContainerWindow::MessageReceived(BMessage* message) { switch (message->what) { case kDefaultButton: @@ -338,11 +338,11 @@ OpenWithContainerWindow::MessageReceived(BMessage *message) filter_result -OpenWithContainerWindow::KeyDownFilter(BMessage *message, BHandler **, - BMessageFilter *filter) +OpenWithContainerWindow::KeyDownFilter(BMessage* message, BHandler**, + BMessageFilter* filter) { uchar key; - if (message->FindInt8("byte", (int8 *)&key) != B_OK) + if (message->FindInt8("byte", (int8*)&key) != B_OK) return B_DISPATCH_MESSAGE; int32 modifier=0; @@ -364,7 +364,7 @@ OpenWithContainerWindow::ShouldAddMenus() const void -OpenWithContainerWindow::ShowContextMenu(BPoint, const entry_ref *, BView *) +OpenWithContainerWindow::ShowContextMenu(BPoint, const entry_ref*, BView*) { } @@ -378,10 +378,10 @@ OpenWithContainerWindow::AddShortcuts() void -OpenWithContainerWindow::NewAttributeMenu(BMenu *menu) +OpenWithContainerWindow::NewAttributeMenu(BMenu* menu) { _inherited::NewAttributeMenu(menu); - BMessage *message = new BMessage(kAttributeItem); + BMessage* message = new BMessage(kAttributeItem); message->AddString("attr_name", kAttrOpenWithRelation); message->AddInt32("attr_type", B_STRING_TYPE); message->AddInt32("attr_hash", (int32)AttrHashString(kAttrOpenWithRelation, B_STRING_TYPE)); @@ -389,7 +389,7 @@ OpenWithContainerWindow::NewAttributeMenu(BMenu *menu) message->AddInt32("attr_align", B_ALIGN_LEFT); message->AddBool("attr_editable", false); message->AddBool("attr_statfield", false); - BMenuItem *item = new BMenuItem(B_TRANSLATE("Relation"), message); + BMenuItem* item = new BMenuItem(B_TRANSLATE("Relation"), message); menu->AddItem(item); message = new BMessage(kAttributeItem); message->AddString("attr_name", kAttrAppVersion); @@ -425,7 +425,7 @@ OpenWithContainerWindow::SaveState(BMessage &message) const void -OpenWithContainerWindow::Init(const BMessage *message) +OpenWithContainerWindow::Init(const BMessage* message) { _inherited::Init(message); } @@ -454,13 +454,13 @@ OpenWithContainerWindow::RestoreState(const BMessage &message) void -OpenWithContainerWindow::RestoreWindowState(AttributeStreamNode *node) +OpenWithContainerWindow::RestoreWindowState(AttributeStreamNode* node) { SetSizeLimits(fMinimalWidth, 10000, 160, 10000); if (!node) return; - const char *rectAttributeName = kAttrWindowFrame; + const char* rectAttributeName = kAttrWindowFrame; BRect frame(Frame()); if (node->Read(rectAttributeName, 0, B_RECT_TYPE, sizeof(BRect), &frame) == sizeof(BRect)) { @@ -491,14 +491,14 @@ OpenWithContainerWindow::SetUpDefaultState() bool -OpenWithContainerWindow::IsShowing(const node_ref *) const +OpenWithContainerWindow::IsShowing(const node_ref*) const { return false; } bool -OpenWithContainerWindow::IsShowing(const entry_ref *) const +OpenWithContainerWindow::IsShowing(const entry_ref*) const { return false; } @@ -532,11 +532,11 @@ OpenWithPoseView::OpenWithPoseView(BRect frame, uint32 resizeMask) } -OpenWithContainerWindow * +OpenWithContainerWindow* OpenWithPoseView::ContainerWindow() const { - ASSERT(dynamic_cast(Window())); - return static_cast(Window()); + ASSERT(dynamic_cast(Window())); + return static_cast(Window()); } @@ -550,15 +550,15 @@ OpenWithPoseView::AttachedToWindow() bool -OpenWithPoseView::CanHandleDragSelection(const Model *, const BMessage *, bool) +OpenWithPoseView::CanHandleDragSelection(const Model*, const BMessage*, bool) { return false; } static void -AddSupportingAppForTypeToQuery(SearchForSignatureEntryList *queryIterator, - const char *type) +AddSupportingAppForTypeToQuery(SearchForSignatureEntryList* queryIterator, + const char* type) { // get supporting apps for type BMimeType mime(type); @@ -570,7 +570,7 @@ AddSupportingAppForTypeToQuery(SearchForSignatureEntryList *queryIterator, // push each of the supporting apps signature uniquely - const char *signature; + const char* signature; for (int32 index = 0; message.FindString("applications", index, &signature) == B_OK; index++) { queryIterator->PushUniqueSignature(signature); @@ -578,14 +578,14 @@ AddSupportingAppForTypeToQuery(SearchForSignatureEntryList *queryIterator, } -static const entry_ref * -AddOneRefSignatures(const entry_ref *ref, void *castToIterator) +static const entry_ref* +AddOneRefSignatures(const entry_ref* ref, void* castToIterator) { // TODO: resolve cases where each entry has a different type and // their supporting apps are disjoint sets - SearchForSignatureEntryList *queryIterator = - (SearchForSignatureEntryList *)castToIterator; + SearchForSignatureEntryList* queryIterator = + (SearchForSignatureEntryList*)castToIterator; Model model(ref, true, true); if (model.InitCheck() != B_OK) @@ -625,12 +625,12 @@ AddOneRefSignatures(const entry_ref *ref, void *castToIterator) } -EntryListBase * -OpenWithPoseView::InitDirentIterator(const entry_ref *) +EntryListBase* +OpenWithPoseView::InitDirentIterator(const entry_ref*) { - OpenWithContainerWindow *window = ContainerWindow(); + OpenWithContainerWindow* window = ContainerWindow(); - const BMessage *entryList = window->EntryList(); + const BMessage* entryList = window->EntryList(); fIterator = new SearchForSignatureEntryList(true); @@ -653,9 +653,9 @@ OpenWithPoseView::InitDirentIterator(const entry_ref *) void -OpenWithPoseView::OpenSelection(BPose *pose, int32 *) +OpenWithPoseView::OpenSelection(BPose* pose, int32*) { - OpenWithContainerWindow *window = ContainerWindow(); + OpenWithContainerWindow* window = ContainerWindow(); int32 count = fSelectionList->CountItems(); if (!count) @@ -723,7 +723,7 @@ OpenWithPoseView::Pulse() // // disable the Open button if no apps selected - OpenWithContainerWindow *window = ContainerWindow(); + OpenWithContainerWindow* window = ContainerWindow(); if (!fSelectionList->CountItems()) { window->SetCanSetAppAsDefault(false); @@ -734,7 +734,7 @@ OpenWithPoseView::Pulse() // if we selected a non-handling application, don't allow setting // it as preferred - Model *firstSelected = fSelectionList->FirstItem()->TargetModel(); + Model* firstSelected = fSelectionList->FirstItem()->TargetModel(); if (OpenWithRelation(firstSelected) == kNoRelation) { window->SetCanSetAppAsDefault(false); window->SetCanOpen(true); @@ -768,10 +768,10 @@ OpenWithPoseView::SetUpDefaultColumnsIfNeeded() if (fColumnList->CountItems() != 0) return; - BColumn *nameColumn = new BColumn(B_TRANSLATE("Name"), kColumnStart, 125, + BColumn* nameColumn = new BColumn(B_TRANSLATE("Name"), kColumnStart, 125, B_ALIGN_LEFT, kAttrStatName, B_STRING_TYPE, true, true); fColumnList->AddItem(nameColumn); - BColumn *relationColumn = new BColumn(B_TRANSLATE("Relation"), 180, 100, + BColumn* relationColumn = new BColumn(B_TRANSLATE("Relation"), 180, 100, B_ALIGN_LEFT, kAttrOpenWithRelation, B_STRING_TYPE, false, false); fColumnList->AddItem(relationColumn); fColumnList->AddItem(new BColumn(B_TRANSLATE("Location"), 290, 225, @@ -786,16 +786,16 @@ OpenWithPoseView::SetUpDefaultColumnsIfNeeded() bool -OpenWithPoseView::AddPosesThreadValid(const entry_ref *) const +OpenWithPoseView::AddPosesThreadValid(const entry_ref*) const { return true; } void -OpenWithPoseView::CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count, - BPose **resultingPoses, bool insertionSort, int32 *lastPoseIndexPtr, - BRect *boundsPtr, bool forceDraw) +OpenWithPoseView::CreatePoses(Model** models, PoseInfo* poseInfoArray, int32 count, + BPose** resultingPoses, bool insertionSort, int32* lastPoseIndexPtr, + BRect* boundsPtr, bool forceDraw) { // overridden to try to select the preferred handling app _inherited::CreatePoses(models, poseInfoArray, count, resultingPoses, insertionSort, @@ -814,7 +814,7 @@ OpenWithPoseView::CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 cou void -OpenWithPoseView::KeyDown(const char *bytes, int32 count) +OpenWithPoseView::KeyDown(const char* bytes, int32 count) { if (bytes[0] == B_TAB) { // just shift the focus, don't tab to the next pose @@ -825,14 +825,14 @@ OpenWithPoseView::KeyDown(const char *bytes, int32 count) void -OpenWithPoseView::SaveState(AttributeStreamNode *node) +OpenWithPoseView::SaveState(AttributeStreamNode* node) { _inherited::SaveState(node); } void -OpenWithPoseView::RestoreState(AttributeStreamNode *node) +OpenWithPoseView::RestoreState(AttributeStreamNode* node) { _inherited::RestoreState(node); fViewState->SetViewMode(kListMode); @@ -855,7 +855,7 @@ OpenWithPoseView::RestoreState(const BMessage &message) void -OpenWithPoseView::SavePoseLocations(BRect *) +OpenWithPoseView::SavePoseLocations(BRect*) { // do nothing } @@ -868,40 +868,40 @@ OpenWithPoseView::MoveSelectionToTrash(bool) void -OpenWithPoseView::MoveSelectionTo(BPoint, BPoint, BContainerWindow *) +OpenWithPoseView::MoveSelectionTo(BPoint, BPoint, BContainerWindow*) { } void -OpenWithPoseView::MoveSelectionInto(Model *, BContainerWindow *, bool, bool) +OpenWithPoseView::MoveSelectionInto(Model*, BContainerWindow*, bool, bool) { } bool -OpenWithPoseView::Represents(const node_ref *) const +OpenWithPoseView::Represents(const node_ref*) const { return false; } bool -OpenWithPoseView::Represents(const entry_ref *) const +OpenWithPoseView::Represents(const entry_ref*) const { return false; } bool -OpenWithPoseView::HandleMessageDropped(BMessage *DEBUG_ONLY(message)) +OpenWithPoseView::HandleMessageDropped(BMessage* DEBUG_ONLY(message)) { #if DEBUG // in debug mode allow tweaking the colors - const rgb_color *color; + const rgb_color* color; int32 size; // handle roColour-style color drops - if (message->FindData("RGBColor", 'RGBC', (const void **)&color, &size) == B_OK) { + if (message->FindData("RGBColor", 'RGBC', (const void**)&color, &size) == B_OK) { SetViewColor(*color); SetLowColor(*color); Invalidate(); @@ -913,9 +913,9 @@ OpenWithPoseView::HandleMessageDropped(BMessage *DEBUG_ONLY(message)) int32 -OpenWithPoseView::OpenWithRelation(const Model *model) const +OpenWithPoseView::OpenWithRelation(const Model* model) const { - OpenWithContainerWindow *window = ContainerWindow(); + OpenWithContainerWindow* window = ContainerWindow(); return SearchForSignatureEntryList::Relation(window->EntryList(), model, fHaveCommonPreferredApp ? &fPreferredRef : 0, 0); @@ -923,10 +923,10 @@ OpenWithPoseView::OpenWithRelation(const Model *model) const void -OpenWithPoseView::OpenWithRelationDescription(const Model *model, - BString *description) const +OpenWithPoseView::OpenWithRelationDescription(const Model* model, + BString* description) const { - OpenWithContainerWindow *window = ContainerWindow(); + OpenWithContainerWindow* window = ContainerWindow(); SearchForSignatureEntryList::RelationDescription(window->EntryList(), model, description, fHaveCommonPreferredApp ? &fPreferredRef : 0, 0); @@ -934,9 +934,9 @@ OpenWithPoseView::OpenWithRelationDescription(const Model *model, bool -OpenWithPoseView::ShouldShowPose(const Model *model, const PoseInfo *poseInfo) +OpenWithPoseView::ShouldShowPose(const Model* model, const PoseInfo* poseInfo) { - OpenWithContainerWindow *window = ContainerWindow(); + OpenWithContainerWindow* window = ContainerWindow(); // filter for add_poses if (!fIterator->CanOpenWithFilter(model, window->EntryList(), fHaveCommonPreferredApp ? &fPreferredRef : 0)) @@ -949,7 +949,7 @@ OpenWithPoseView::ShouldShowPose(const Model *model, const PoseInfo *poseInfo) // #pragma mark - -RelationCachingModelProxy::RelationCachingModelProxy(Model *model) +RelationCachingModelProxy::RelationCachingModelProxy(Model* model) : fModel(model), fRelation(kUnknownRelation) @@ -964,8 +964,8 @@ RelationCachingModelProxy::~RelationCachingModelProxy() int32 -RelationCachingModelProxy::Relation(SearchForSignatureEntryList *iterator, - BMessage *entries) const +RelationCachingModelProxy::Relation(SearchForSignatureEntryList* iterator, + BMessage* entries) const { if (fRelation == kUnknownRelation) fRelation = iterator->Relation(entries, fModel); @@ -977,8 +977,8 @@ RelationCachingModelProxy::Relation(SearchForSignatureEntryList *iterator, // #pragma mark - -OpenWithMenu::OpenWithMenu(const char *label, const BMessage *entriesToOpen, - BWindow *parentWindow, BHandler *target) +OpenWithMenu::OpenWithMenu(const char* label, const BMessage* entriesToOpen, + BWindow* parentWindow, BHandler* target) : BSlowMenu(label), fEntriesToOpen(*entriesToOpen), target(target), @@ -995,8 +995,8 @@ OpenWithMenu::OpenWithMenu(const char *label, const BMessage *entriesToOpen, } -OpenWithMenu::OpenWithMenu(const char *label, const BMessage *entriesToOpen, - BWindow *parentWindow, const BMessenger &messenger) +OpenWithMenu::OpenWithMenu(const char* label, const BMessage* entriesToOpen, + BWindow* parentWindow, const BMessenger &messenger) : BSlowMenu(label), fEntriesToOpen(*entriesToOpen), target(NULL), @@ -1017,10 +1017,10 @@ OpenWithMenu::OpenWithMenu(const char *label, const BMessage *entriesToOpen, namespace BPrivate { int -SortByRelationAndName(const RelationCachingModelProxy *model1, - const RelationCachingModelProxy *model2, void *castToMenu) +SortByRelationAndName(const RelationCachingModelProxy* model1, + const RelationCachingModelProxy* model2, void* castToMenu) { - OpenWithMenu *menu = (OpenWithMenu *)castToMenu; + OpenWithMenu* menu = (OpenWithMenu*)castToMenu; // find out the relations of app models to the opened entries int32 relation1 = model1->Relation(menu->fIterator, &menu->fEntriesToOpen); @@ -1070,7 +1070,7 @@ OpenWithMenu::AddNextItem() if (fIterator->GetNextEntry(&entry) != B_OK) return false; - Model *model = new Model(&entry, true); + Model* model = new Model(&entry, true); if (model->InitCheck() != B_OK || !fIterator->CanOpenWithFilter(model, &fEntriesToOpen, fHaveCommonPreferredApp ? &fPreferredRef : 0)) { @@ -1109,11 +1109,11 @@ OpenWithMenu::DoneBuildingItemList() int32 lastRelation = -1; for (int32 index = 0; index < count ; index++) { - RelationCachingModelProxy *modelProxy = fSupportingAppList->ItemAt(index); - Model *model = modelProxy->fModel; - BMessage *message = new BMessage(fEntriesToOpen); + RelationCachingModelProxy* modelProxy = fSupportingAppList->ItemAt(index); + Model* model = modelProxy->fModel; + BMessage* message = new BMessage(fEntriesToOpen); message->AddRef("handler", model->EntryRef()); - BContainerWindow *window = dynamic_cast(fParentWindow); + BContainerWindow* window = dynamic_cast(fParentWindow); if (window) message->AddData("nodeRefsToClose", B_RAW_TYPE, window->TargetModel()->NodeRef(), sizeof (node_ref)); @@ -1148,7 +1148,7 @@ OpenWithMenu::DoneBuildingItemList() AddSeparatorItem(); lastRelation = relation; - ModelMenuItem *item = new ModelMenuItem(model, result.String(), message); + ModelMenuItem* item = new ModelMenuItem(model, result.String(), message); AddItem(item); // mark item if it represents the preferred app if (fHaveCommonPreferredApp && *(model->EntryRef()) == fPreferredRef) { @@ -1204,10 +1204,10 @@ SearchForSignatureEntryList::~SearchForSignatureEntryList() void -SearchForSignatureEntryList::PushUniqueSignature(const char *str) +SearchForSignatureEntryList::PushUniqueSignature(const char* str) { // do a unique add - if (fSignatures.EachElement(FindOne, (void *)str)) + if (fSignatures.EachElement(FindOne, (void*)str)) return; fSignatures.AddItem(new BString(str)); @@ -1215,21 +1215,21 @@ SearchForSignatureEntryList::PushUniqueSignature(const char *str) status_t -SearchForSignatureEntryList::GetNextEntry(BEntry *entry, bool) +SearchForSignatureEntryList::GetNextEntry(BEntry* entry, bool) { return fIteratorList->GetNextEntry(entry); } status_t -SearchForSignatureEntryList::GetNextRef(entry_ref *ref) +SearchForSignatureEntryList::GetNextRef(entry_ref* ref) { return fIteratorList->GetNextRef(ref); } int32 -SearchForSignatureEntryList::GetNextDirents(struct dirent *buffer, +SearchForSignatureEntryList::GetNextDirents(struct dirent* buffer, size_t length, int32 count) { return fIteratorList->GetNextDirents(buffer, length, count); @@ -1237,14 +1237,14 @@ SearchForSignatureEntryList::GetNextDirents(struct dirent *buffer, struct AddOneTermParams { - BString *result; + BString* result; bool first; }; -static const BString * -AddOnePredicateTerm(const BString *item, void *castToParams) +static const BString* +AddOnePredicateTerm(const BString* item, void* castToParams) { - AddOneTermParams *params = (AddOneTermParams *)castToParams; + AddOneTermParams* params = (AddOneTermParams*)castToParams; if (!params->first) (*params->result) << " || "; (*params->result) << kAttrAppSignature << " = " << item->String(); @@ -1297,7 +1297,7 @@ SearchForSignatureEntryList::CountEntries() bool -SearchForSignatureEntryList::GetPreferredApp(entry_ref *ref) const +SearchForSignatureEntryList::GetPreferredApp(entry_ref* ref) const { if (fPreferredAppCount == 1) *ref = fPreferredRef; @@ -1307,7 +1307,7 @@ SearchForSignatureEntryList::GetPreferredApp(entry_ref *ref) const void -SearchForSignatureEntryList::TrySettingPreferredApp(const entry_ref *ref) +SearchForSignatureEntryList::TrySettingPreferredApp(const entry_ref* ref) { if (!fPreferredAppCount) { fPreferredRef = *ref; @@ -1319,7 +1319,7 @@ SearchForSignatureEntryList::TrySettingPreferredApp(const entry_ref *ref) void -SearchForSignatureEntryList::TrySettingPreferredAppForFile(const entry_ref *ref) +SearchForSignatureEntryList::TrySettingPreferredAppForFile(const entry_ref* ref) { if (!fPreferredAppForFileCount) { fPreferredRefForFile = *ref; @@ -1353,8 +1353,8 @@ SearchForSignatureEntryList::ShowAllApplications() const int32 -SearchForSignatureEntryList::Relation(const Model *nodeModel, - const Model *applicationModel) +SearchForSignatureEntryList::Relation(const Model* nodeModel, + const Model* applicationModel) { switch (applicationModel->SupportsMimeType(nodeModel->MimeType(), 0, true)) { case kDoesNotSupportType: @@ -1376,8 +1376,8 @@ SearchForSignatureEntryList::Relation(const Model *nodeModel, int32 -SearchForSignatureEntryList::Relation(const BMessage *entriesToOpen, - const Model *model) const +SearchForSignatureEntryList::Relation(const BMessage* entriesToOpen, + const Model* model) const { return Relation(entriesToOpen, model, fPreferredAppCount == 1 ? &fPreferredRef : 0, @@ -1386,8 +1386,8 @@ SearchForSignatureEntryList::Relation(const BMessage *entriesToOpen, void -SearchForSignatureEntryList::RelationDescription(const BMessage *entriesToOpen, - const Model *model, BString *description) const +SearchForSignatureEntryList::RelationDescription(const BMessage* entriesToOpen, + const Model* model, BString* description) const { RelationDescription(entriesToOpen, model, description, fPreferredAppCount == 1 ? &fPreferredRef : 0, @@ -1396,9 +1396,9 @@ SearchForSignatureEntryList::RelationDescription(const BMessage *entriesToOpen, int32 -SearchForSignatureEntryList::Relation(const BMessage *entriesToOpen, - const Model *applicationModel, const entry_ref *preferredApp, - const entry_ref *preferredAppForFile) +SearchForSignatureEntryList::Relation(const BMessage* entriesToOpen, + const Model* applicationModel, const entry_ref* preferredApp, + const entry_ref* preferredAppForFile) { for (int32 index = 0; ; index++) { entry_ref ref; @@ -1432,9 +1432,9 @@ SearchForSignatureEntryList::Relation(const BMessage *entriesToOpen, void -SearchForSignatureEntryList::RelationDescription(const BMessage *entriesToOpen, - const Model *applicationModel, BString *description, const entry_ref *preferredApp, - const entry_ref *preferredAppForFile) +SearchForSignatureEntryList::RelationDescription(const BMessage* entriesToOpen, + const Model* applicationModel, BString* description, const entry_ref* preferredApp, + const entry_ref* preferredAppForFile) { for (int32 index = 0; ;index++) { entry_ref ref; @@ -1465,8 +1465,8 @@ SearchForSignatureEntryList::RelationDescription(const BMessage *entriesToOpen, mimeType.SetTo(model.MimeType()); // status_t result = mimeType.GetSupertype(&mimeType); - char *type = (char *)mimeType.Type(); - char *tmp = strchr(type, '/'); + char* type = (char*)mimeType.Type(); + char* tmp = strchr(type, '/'); if (tmp) *tmp = '\0'; @@ -1503,8 +1503,8 @@ SearchForSignatureEntryList::RelationDescription(const BMessage *entriesToOpen, bool -SearchForSignatureEntryList::CanOpenWithFilter(const Model *appModel, - const BMessage *entriesToOpen, const entry_ref *preferredApp) +SearchForSignatureEntryList::CanOpenWithFilter(const Model* appModel, + const BMessage* entriesToOpen, const entry_ref* preferredApp) { if (!appModel->IsExecutable() || !appModel->Node()) { // weed out non-executable @@ -1522,10 +1522,10 @@ SearchForSignatureEntryList::CanOpenWithFilter(const Model *appModel, return false; } - ASSERT(dynamic_cast(appModel->Node())); + ASSERT(dynamic_cast(appModel->Node())); char signature[B_MIME_TYPE_LENGTH]; status_t result = GetAppSignatureFromAttr( - dynamic_cast(appModel->Node()), signature); + dynamic_cast(appModel->Node()), signature); if (result == B_OK && strcasecmp(signature, kTrackerSignature) == 0) { // special case the Tracker - make sure only the running copy is @@ -1558,7 +1558,7 @@ SearchForSignatureEntryList::CanOpenWithFilter(const Model *appModel, // don't check for these if we didn't look for every single app // to not slow filtering down uint32 flags; - BAppFileInfo appFileInfo(dynamic_cast(appModel->Node())); + BAppFileInfo appFileInfo(dynamic_cast(appModel->Node())); if (appFileInfo.GetAppFlags(&flags) != B_OK) return false; @@ -1597,7 +1597,7 @@ SearchForSignatureEntryList::CanOpenWithFilter(const Model *appModel, ConditionalAllAppsIterator::ConditionalAllAppsIterator( - SearchForSignatureEntryList *parent) + SearchForSignatureEntryList* parent) : fParent(parent), fWalker(NULL) @@ -1625,7 +1625,7 @@ ConditionalAllAppsIterator::~ConditionalAllAppsIterator() status_t -ConditionalAllAppsIterator::GetNextEntry(BEntry *entry, bool traverse) +ConditionalAllAppsIterator::GetNextEntry(BEntry* entry, bool traverse) { if (!Iterate()) return B_ENTRY_NOT_FOUND; @@ -1636,7 +1636,7 @@ ConditionalAllAppsIterator::GetNextEntry(BEntry *entry, bool traverse) status_t -ConditionalAllAppsIterator::GetNextRef(entry_ref *ref) +ConditionalAllAppsIterator::GetNextRef(entry_ref* ref) { if (!Iterate()) return B_ENTRY_NOT_FOUND; @@ -1647,7 +1647,7 @@ ConditionalAllAppsIterator::GetNextRef(entry_ref *ref) int32 -ConditionalAllAppsIterator::GetNextDirents(struct dirent *buffer, size_t length, +ConditionalAllAppsIterator::GetNextDirents(struct dirent* buffer, size_t length, int32 count) { if (!Iterate()) @@ -1685,4 +1685,3 @@ ConditionalAllAppsIterator::Iterate() const { return fParent->ShowAllApplications(); } - diff --git a/src/kits/tracker/OpenWithWindow.h b/src/kits/tracker/OpenWithWindow.h index b644b7bfff..ade2d702be 100644 --- a/src/kits/tracker/OpenWithWindow.h +++ b/src/kits/tracker/OpenWithWindow.h @@ -31,10 +31,13 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - -#ifndef _OPEN_WITH_WINDOW_H +#ifndef _OPEN_WITH_WINDOW_H #define _OPEN_WITH_WINDOW_H + +// OpenWithContainerWindow supports the Open With feature + + #include #include "ContainerWindow.h" @@ -45,12 +48,11 @@ All rights reserved. #include "SlowMenu.h" #include "Utilities.h" + namespace BPrivate { class OpenWithPoseView; -// OpenWithContainerWindow supports the Open With feature - enum { kUnknownRelation = -1, kNoRelation = 0, @@ -61,6 +63,7 @@ enum { kPreferredForFile }; + // pass in a predicate; a query will search for matches // matches will be returned in iteration class SearchForSignatureEntryList : public EntryListBase { @@ -68,43 +71,43 @@ class SearchForSignatureEntryList : public EntryListBase { SearchForSignatureEntryList(bool canAddAllApps); virtual ~SearchForSignatureEntryList(); - void PushUniqueSignature(const char *); + void PushUniqueSignature(const char*); // add one signature to search for // entry list iterators - virtual status_t GetNextEntry(BEntry *entry, bool traverse = false); - virtual status_t GetNextRef(entry_ref *ref); - virtual int32 GetNextDirents(struct dirent *buffer, size_t length, + virtual status_t GetNextEntry(BEntry* entry, bool traverse = false); + virtual status_t GetNextRef(entry_ref* ref); + virtual int32 GetNextDirents(struct dirent* buffer, size_t length, int32 count = INT_MAX); virtual status_t Rewind(); virtual int32 CountEntries(); - bool GetPreferredApp(entry_ref *ref) const; + bool GetPreferredApp(entry_ref* ref) const; // gets the preferred app for all the files it was asked to // find supporting apps for, returns false if no preferred app // found or if more than one found - void TrySettingPreferredApp(const entry_ref *); - void TrySettingPreferredAppForFile(const entry_ref *); + void TrySettingPreferredApp(const entry_ref*); + void TrySettingPreferredAppForFile(const entry_ref*); - int32 Relation(const BMessage *entriesToOpen, const Model *) const; + int32 Relation(const BMessage* entriesToOpen, const Model*) const; // returns the reason why an application is shown in Open With window - void RelationDescription(const BMessage *entriesToOpen, const Model *, - BString *) const; + void RelationDescription(const BMessage* entriesToOpen, const Model*, + BString*) const; // returns a string describing why application handles files to open - static int32 Relation(const BMessage *entriesToOpen, - const Model *, const entry_ref *preferredApp, - const entry_ref *preferredAppForFile); + static int32 Relation(const BMessage* entriesToOpen, + const Model*, const entry_ref* preferredApp, + const entry_ref* preferredAppForFile); // returns the reason why an application is shown in Open With window // static version, needs the preferred app for preformance - static void RelationDescription(const BMessage *entriesToOpen, - const Model *, BString *, const entry_ref *preferredApp, - const entry_ref *preferredAppForFile); + static void RelationDescription(const BMessage* entriesToOpen, + const Model*, BString*, const entry_ref* preferredApp, + const entry_ref* preferredAppForFile); // returns a string describing why application handles files to open - bool CanOpenWithFilter(const Model *appModel, const BMessage *entriesToOpen, - const entry_ref *preferredApp); + bool CanOpenWithFilter(const Model* appModel, const BMessage* entriesToOpen, + const entry_ref* preferredApp); void NonGenericFileFound(); bool GenericFilesOnly() const; @@ -112,10 +115,10 @@ class SearchForSignatureEntryList : public EntryListBase { bool ShowAllApplications() const; private: - static int32 Relation(const Model *node, const Model *app); + static int32 Relation(const Model* node, const Model* app); // returns the reason why an application is shown in Open With window - CachedEntryIteratorList *fIteratorList; + CachedEntryIteratorList* fIteratorList; BObjectList fSignatures; entry_ref fPreferredRef; @@ -127,47 +130,48 @@ class SearchForSignatureEntryList : public EntryListBase { bool fFoundOneNonSuperHandler; }; + class OpenWithContainerWindow : public BContainerWindow { public: - OpenWithContainerWindow(BMessage *entriesToOpen, - LockingList *windowList, + OpenWithContainerWindow(BMessage* entriesToOpen, + LockingList* windowList, window_look look = B_DOCUMENT_WINDOW_LOOK, window_feel feel = B_NORMAL_WINDOW_FEEL, uint32 flags = 0, uint32 workspace = B_CURRENT_WORKSPACE); // eventually get opened by the selected app virtual ~OpenWithContainerWindow(); - virtual void Init(const BMessage *message); + virtual void Init(const BMessage* message); - const BMessage *EntryList() const; + const BMessage* EntryList() const; // return the list of the entries we are supposed to open void SetCanSetAppAsDefault(bool); void SetCanOpen(bool); - OpenWithPoseView *PoseView() const; + OpenWithPoseView* PoseView() const; protected: - virtual BPoseView *NewPoseView(Model *model, BRect rect, uint32 viewMode); + virtual BPoseView* NewPoseView(Model* model, BRect rect, uint32 viewMode); virtual bool ShouldAddMenus() const; - virtual void ShowContextMenu(BPoint, const entry_ref *, BView *); + virtual void ShowContextMenu(BPoint, const entry_ref*, BView*); virtual void AddShortcuts(); - virtual void NewAttributeMenu(BMenu *); + virtual void NewAttributeMenu(BMenu*); virtual void RestoreState(); - virtual void RestoreState(const BMessage &); - virtual void RestoreWindowState(AttributeStreamNode *); - virtual void RestoreWindowState(const BMessage &); + virtual void RestoreState(const BMessage&); + virtual void RestoreWindowState(AttributeStreamNode*); + virtual void RestoreWindowState(const BMessage&); virtual bool NeedsDefaultStateSetup(); virtual void SaveState(bool hide = true); - virtual void SaveState(BMessage &) const; + virtual void SaveState(BMessage&) const; virtual void SetUpDefaultState(); - virtual bool IsShowing(const node_ref *) const; - virtual bool IsShowing(const entry_ref *) const; + virtual bool IsShowing(const node_ref*) const; + virtual bool IsShowing(const entry_ref*) const; - virtual void MessageReceived(BMessage *); + virtual void MessageReceived(BMessage*); void OpenWithSelection(); // open entries with the selected app @@ -175,31 +179,32 @@ class OpenWithContainerWindow : public BContainerWindow { // open entries with the selected app and make it the default handler private: - static filter_result KeyDownFilter(BMessage *, BHandler **, BMessageFilter *); + static filter_result KeyDownFilter(BMessage*, BHandler**, BMessageFilter*); - BMessage *fEntriesToOpen; - BButton *fLaunchButton; - BButton *fLaunchAndMakeDefaultButton; + BMessage* fEntriesToOpen; + BButton* fLaunchButton; + BButton* fLaunchAndMakeDefaultButton; float fMinimalWidth; typedef BContainerWindow _inherited; }; + class OpenWithPoseView : public BPoseView { public: OpenWithPoseView(BRect, uint32 resizeMask = B_FOLLOW_ALL); - virtual void OpenSelection(BPose *, int32 *); + virtual void OpenSelection(BPose*, int32*); // open entries with the selected app - int32 OpenWithRelation(const Model *) const; + int32 OpenWithRelation(const Model*) const; // returns the reason why an application is shown in Open With window - void OpenWithRelationDescription(const Model *, BString *) const; + void OpenWithRelationDescription(const Model*, BString*) const; // returns a string describing why application handles files to open - OpenWithContainerWindow *ContainerWindow() const; + OpenWithContainerWindow* ContainerWindow() const; - virtual bool AddPosesThreadValid(const entry_ref *) const; + virtual bool AddPosesThreadValid(const entry_ref*) const; protected: // don't do any volume watching and memtamime watching in open with panels for now @@ -207,69 +212,71 @@ class OpenWithPoseView : public BPoseView { virtual void FinalStopWatching() {} virtual void AttachedToWindow(); - EntryListBase *InitDirentIterator(const entry_ref *ref); + EntryListBase* InitDirentIterator(const entry_ref* ref); virtual void SetUpDefaultColumnsIfNeeded(); // show launch window specific columns // empty overrides for functions that depend on having an fModel - virtual void SaveState(AttributeStreamNode *); - virtual void RestoreState(AttributeStreamNode *); - virtual void SaveState(BMessage &) const; - virtual void RestoreState(const BMessage &); - virtual void SavePoseLocations(BRect * = NULL); + virtual void SaveState(AttributeStreamNode*); + virtual void RestoreState(AttributeStreamNode*); + virtual void SaveState(BMessage&) const; + virtual void RestoreState(const BMessage&); + virtual void SavePoseLocations(BRect* = NULL); virtual void MoveSelectionToTrash(bool selectNext = true); virtual void MoveSelectionTo(BPoint, BPoint, BContainerWindow*); - virtual void MoveSelectionInto(Model* destFolder, BContainerWindow *srcWindow, + virtual void MoveSelectionInto(Model* destFolder, BContainerWindow* srcWindow, bool forceCopy, bool create_link = false); - virtual bool HandleMessageDropped(BMessage *); - virtual bool CanHandleDragSelection(const Model *, const BMessage *, bool); + virtual bool HandleMessageDropped(BMessage*); + virtual bool CanHandleDragSelection(const Model*, const BMessage*, bool); - virtual bool Represents(const node_ref *) const; - virtual bool Represents(const entry_ref *) const; + virtual bool Represents(const node_ref*) const; + virtual bool Represents(const entry_ref*) const; - virtual void CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count, - BPose **resultingPoses, bool insertionSort = true, int32 *lastPoseIndexPtr = NULL, - BRect *boundsPtr = NULL, bool forceDraw = false); + virtual void CreatePoses(Model** models, PoseInfo* poseInfoArray, int32 count, + BPose** resultingPoses, bool insertionSort = true, int32* lastPoseIndexPtr = NULL, + BRect* boundsPtr = NULL, bool forceDraw = false); // override to add selecting the default handling app for selection - virtual bool ShouldShowPose(const Model *, const PoseInfo *); + virtual bool ShouldShowPose(const Model*, const PoseInfo*); virtual void Pulse(); - virtual void KeyDown(const char *bytes, int32 count); + virtual void KeyDown(const char* bytes, int32 count); private: entry_ref fPreferredRef; bool fHaveCommonPreferredApp; - SearchForSignatureEntryList *fIterator; + SearchForSignatureEntryList* fIterator; // private copy of the iterator pointer typedef BPoseView _inherited; }; + class RelationCachingModelProxy { public: - RelationCachingModelProxy(Model *model); + RelationCachingModelProxy(Model* model); ~RelationCachingModelProxy(); - int32 Relation(SearchForSignatureEntryList *iterator, BMessage *entries) const; + int32 Relation(SearchForSignatureEntryList* iterator, BMessage* entries) const; - Model *fModel; + Model* fModel; mutable int32 fRelation; }; + class OpenWithMenu : public BSlowMenu { public: - OpenWithMenu(const char *label, const BMessage *entriesToOpen, - BWindow *parentWindow, BHandler *target); - OpenWithMenu(const char *label, const BMessage *entriesToOpen, - BWindow *parentWindow, const BMessenger &target); + OpenWithMenu(const char* label, const BMessage* entriesToOpen, + BWindow* parentWindow, BHandler* target); + OpenWithMenu(const char* label, const BMessage* entriesToOpen, + BWindow* parentWindow, const BMessenger &target); private: - friend int SortByRelationAndName(const RelationCachingModelProxy *, - const RelationCachingModelProxy *, void *); + friend int SortByRelationAndName(const RelationCachingModelProxy*, + const RelationCachingModelProxy*, void*); virtual bool StartBuildingItemList(); virtual bool AddNextItem(); @@ -277,29 +284,30 @@ class OpenWithMenu : public BSlowMenu { virtual void ClearMenuBuildingState(); BMessage fEntriesToOpen; - BHandler *target; + BHandler* target; BMessenger fMessenger; // menu building state - SearchForSignatureEntryList *fIterator; + SearchForSignatureEntryList* fIterator; entry_ref fPreferredRef; - BObjectList *fSupportingAppList; + BObjectList* fSupportingAppList; bool fHaveCommonPreferredApp; - BWindow *fParentWindow; + BWindow* fParentWindow; typedef BSlowMenu _inherited; }; + // used for optionally showing the list of all apps. Do nothing // until asked to iterate and only if supposed to do so class ConditionalAllAppsIterator : public EntryListBase { public: - ConditionalAllAppsIterator(SearchForSignatureEntryList *parent); + ConditionalAllAppsIterator(SearchForSignatureEntryList* parent); ~ConditionalAllAppsIterator(); - virtual status_t GetNextEntry(BEntry *entry, bool traverse = false); - virtual status_t GetNextRef(entry_ref *ref); - virtual int32 GetNextDirents(struct dirent *buffer, size_t length, + virtual status_t GetNextEntry(BEntry* entry, bool traverse = false); + virtual status_t GetNextRef(entry_ref* ref); + virtual int32 GetNextDirents(struct dirent* buffer, size_t length, int32 count = INT_MAX); virtual status_t Rewind(); @@ -310,8 +318,8 @@ class ConditionalAllAppsIterator : public EntryListBase { void Instantiate(); private: - SearchForSignatureEntryList *fParent; - BTrackerPrivate::TWalker *fWalker; + SearchForSignatureEntryList* fParent; + BTrackerPrivate::TWalker* fWalker; }; } // namespace BPrivate diff --git a/src/kits/tracker/OverrideAlert.cpp b/src/kits/tracker/OverrideAlert.cpp index 0e2de3d19f..8431b3bc1f 100644 --- a/src/kits/tracker/OverrideAlert.cpp +++ b/src/kits/tracker/OverrideAlert.cpp @@ -34,15 +34,17 @@ All rights reserved. // defines the status area drawn in the bottom left corner of a Tracker window + #include #include #include "OverrideAlert.h" -OverrideAlert::OverrideAlert(const char *title, const char *text, - const char *button1, uint32 modifiers1, - const char *button2, uint32 modifiers2, - const char *button3, uint32 modifiers3, + +OverrideAlert::OverrideAlert(const char* title, const char* text, + const char* button1, uint32 modifiers1, + const char* button2, uint32 modifiers2, + const char* button3, uint32 modifiers3, button_width width, alert_type type) : BAlert(title, text, button1, button2, button3, width, type), fCurModifiers(0) @@ -56,10 +58,11 @@ OverrideAlert::OverrideAlert(const char *title, const char *text, MoveTo(where.x, where.y); } -OverrideAlert::OverrideAlert(const char *title, const char *text, - const char *button1, uint32 modifiers1, - const char *button2, uint32 modifiers2, - const char *button3, uint32 modifiers3, + +OverrideAlert::OverrideAlert(const char* title, const char* text, + const char* button1, uint32 modifiers1, + const char* button2, uint32 modifiers2, + const char* button3, uint32 modifiers3, button_width width, button_spacing spacing, alert_type type) : BAlert(title, text, button1, button2, button3, width, spacing, type), fCurModifiers(0) @@ -73,30 +76,33 @@ OverrideAlert::OverrideAlert(const char *title, const char *text, MoveTo(where.x, where.y); } + OverrideAlert::~OverrideAlert() { } + void -OverrideAlert::DispatchMessage(BMessage *message, BHandler *handler) +OverrideAlert::DispatchMessage(BMessage* message, BHandler* handler) { if (message->what == B_KEY_DOWN || message->what == B_KEY_UP || message->what == B_UNMAPPED_KEY_DOWN || message->what == B_UNMAPPED_KEY_UP) { uint32 modifiers; - if (message->FindInt32("modifiers", (int32 *)&modifiers) == B_OK) + if (message->FindInt32("modifiers", (int32*)&modifiers) == B_OK) UpdateButtons(modifiers); } BAlert::DispatchMessage(message, handler); } + BPoint OverrideAlert::OverPosition(float width, float height) { // This positions the alert window like a normal alert, put // places it on top of the calling window if possible. - BWindow *window = dynamic_cast(BLooper::LooperForThread(find_thread(NULL))); + BWindow* window = dynamic_cast(BLooper::LooperForThread(find_thread(NULL))); BRect screenFrame; BRect desirableRect; screenFrame = BScreen(window).Frame(); @@ -133,6 +139,7 @@ OverrideAlert::OverPosition(float width, float height) return desirableRect.LeftTop(); } + void OverrideAlert::UpdateButtons(uint32 modifiers, bool force) { @@ -141,7 +148,7 @@ OverrideAlert::UpdateButtons(uint32 modifiers, bool force) fCurModifiers = modifiers; for (int32 i = 0; i < 3; i++) { - BButton *button = ButtonAt(i); + BButton* button = ButtonAt(i); if (button) button->SetEnabled(((fButtonModifiers[i] & fCurModifiers) == fButtonModifiers[i])); } diff --git a/src/kits/tracker/OverrideAlert.h b/src/kits/tracker/OverrideAlert.h index 5109d5474b..6c2ae5d7e5 100644 --- a/src/kits/tracker/OverrideAlert.h +++ b/src/kits/tracker/OverrideAlert.h @@ -31,7 +31,6 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef _OVERRIDE_ALERT_H #define _OVERRIDE_ALERT_H @@ -45,33 +44,35 @@ All rights reserved. // This allows it to work when confirming rename operations with // Focus Follows Mouse turned on. + #include + namespace BPrivate { class OverrideAlert : public BAlert { public: - OverrideAlert(const char *title, const char *text, - const char *button1, uint32 modifiers1, - const char *button2, uint32 modifiers2, - const char *button3, uint32 modifiers3, + OverrideAlert(const char* title, const char* text, + const char* button1, uint32 modifiers1, + const char* button2, uint32 modifiers2, + const char* button3, uint32 modifiers3, button_width width = B_WIDTH_AS_USUAL, alert_type type = B_INFO_ALERT); - OverrideAlert(const char *title, const char *text, - const char *button1, uint32 modifiers1, - const char *button2, uint32 modifiers2, - const char *button3, uint32 modifiers3, + OverrideAlert(const char* title, const char* text, + const char* button1, uint32 modifiers1, + const char* button2, uint32 modifiers2, + const char* button3, uint32 modifiers3, button_width width, button_spacing spacing, alert_type type = B_INFO_ALERT); virtual ~OverrideAlert(); - virtual void DispatchMessage(BMessage *, BHandler *); + virtual void DispatchMessage(BMessage*, BHandler*); static BPoint OverPosition(float width, float height); private: void UpdateButtons(uint32 modifiers, bool force = false); - + uint32 fCurModifiers; uint32 fButtonModifiers[3]; }; @@ -80,4 +81,4 @@ private: using namespace BPrivate; -#endif +#endif // _OVERRIDE_ALERT_H diff --git a/src/kits/tracker/PendingNodeMonitorCache.cpp b/src/kits/tracker/PendingNodeMonitorCache.cpp index 4586323ec3..a3005c15d0 100644 --- a/src/kits/tracker/PendingNodeMonitorCache.cpp +++ b/src/kits/tracker/PendingNodeMonitorCache.cpp @@ -32,33 +32,39 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include "PendingNodeMonitorCache.h" #include "PoseView.h" + const bigtime_t kDelayedNodeMonitorLifetime = 10000000; // after this much the pending node monitor gets discarded as // too old -PendingNodeMonitorEntry::PendingNodeMonitorEntry(const node_ref *node, - const BMessage *nodeMonitor) + +PendingNodeMonitorEntry::PendingNodeMonitorEntry(const node_ref* node, + const BMessage* nodeMonitor) : fExpiresAfter(system_time() + kDelayedNodeMonitorLifetime), fNodeMonitor(*nodeMonitor), fNode(*node) { } -const BMessage * + +const BMessage* PendingNodeMonitorEntry::NodeMonitor() const { return &fNodeMonitor; } + bool -PendingNodeMonitorEntry::Match(const node_ref *node) const +PendingNodeMonitorEntry::Match(const node_ref* node) const { return fNode == *node; } + bool PendingNodeMonitorEntry::TooOld(bigtime_t now) const { @@ -76,8 +82,9 @@ PendingNodeMonitorCache::~PendingNodeMonitorCache() { } + void -PendingNodeMonitorCache::Add(const BMessage *message) +PendingNodeMonitorCache::Add(const BMessage* message) { #if xDEBUG PRINT(("adding pending node monitor\n")); @@ -85,14 +92,15 @@ PendingNodeMonitorCache::Add(const BMessage *message) #endif node_ref node; if (message->FindInt32("device", &node.device) != B_OK - || message->FindInt64("node", (int64 *)&node.node) != B_OK) + || message->FindInt64("node", (int64*)&node.node) != B_OK) return; fList.AddItem(new PendingNodeMonitorEntry(&node, message)); } + void -PendingNodeMonitorCache::RemoveEntries(const node_ref *nodeRef) +PendingNodeMonitorCache::RemoveEntries(const node_ref* nodeRef) { int32 count = fList.CountItems(); for (int32 index = count - 1; index >= 0; index--) @@ -100,6 +108,7 @@ PendingNodeMonitorCache::RemoveEntries(const node_ref *nodeRef) delete fList.RemoveItemAt(index); } + void PendingNodeMonitorCache::RemoveOldEntries() { @@ -112,12 +121,14 @@ PendingNodeMonitorCache::RemoveOldEntries() } } + void -PendingNodeMonitorCache::PoseCreatedOrMoved(BPoseView *poseView, const BPose *pose) +PendingNodeMonitorCache::PoseCreatedOrMoved(BPoseView* poseView, + const BPose* pose) { bigtime_t now = system_time(); for (int32 index = 0; index < fList.CountItems();) { - PendingNodeMonitorEntry *item = fList.ItemAt(index); + PendingNodeMonitorEntry* item = fList.ItemAt(index); if (item->TooOld(now)) { PRINT(("removing old entry from pending node monitor cache\n")); delete fList.RemoveItemAt(index); @@ -136,4 +147,3 @@ PendingNodeMonitorCache::PoseCreatedOrMoved(BPoseView *poseView, const BPose *po index++; } } - diff --git a/src/kits/tracker/PendingNodeMonitorCache.h b/src/kits/tracker/PendingNodeMonitorCache.h index 3d56c28c43..68d598e150 100644 --- a/src/kits/tracker/PendingNodeMonitorCache.h +++ b/src/kits/tracker/PendingNodeMonitorCache.h @@ -39,15 +39,16 @@ All rights reserved. // The respective node montior messages are stored in a list and applied // later, when their target shows up. They get nuked when they become too // old. - #ifndef __PENDING_NODEMONITOR_CACHE_H__ #define __PENDING_NODEMONITOR_CACHE_H__ + #include #include #include "ObjectList.h" + namespace BPrivate { class BPoseView; @@ -55,27 +56,28 @@ class BPose; class PendingNodeMonitorEntry { public: - PendingNodeMonitorEntry(const node_ref *node, const BMessage *); - const BMessage *NodeMonitor() const; - bool Match(const node_ref *) const; + PendingNodeMonitorEntry(const node_ref* node, const BMessage*); + const BMessage* NodeMonitor() const; + bool Match(const node_ref*) const; bool TooOld(bigtime_t now) const; - + private: bigtime_t fExpiresAfter; BMessage fNodeMonitor; node_ref fNode; }; + class PendingNodeMonitorCache { public: PendingNodeMonitorCache(); ~PendingNodeMonitorCache(); - void Add(const BMessage *); - void RemoveEntries(const node_ref *); + void Add(const BMessage*); + void RemoveEntries(const node_ref*); void RemoveOldEntries(); - void PoseCreatedOrMoved(BPoseView *, const BPose *); + void PoseCreatedOrMoved(BPoseView*, const BPose*); private: BObjectList fList; @@ -85,5 +87,4 @@ private: using namespace BPrivate; -#endif - +#endif // __PENDING_NODEMONITOR_CACHE_H__ diff --git a/src/kits/tracker/Pose.cpp b/src/kits/tracker/Pose.cpp index 45230b410d..f35bd15607 100644 --- a/src/kits/tracker/Pose.cpp +++ b/src/kits/tracker/Pose.cpp @@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include #include @@ -49,7 +50,7 @@ All rights reserved. int32 -CalcFreeSpace(BVolume *volume) +CalcFreeSpace(BVolume* volume) { off_t capacity = volume->Capacity(); if (capacity == 0) @@ -68,8 +69,7 @@ CalcFreeSpace(BVolume *volume) // symlink pose uses the resolved model to retrieve the icon, if not broken // everything else, like the attributes, etc. is retrieved directly from the // symlink itself - -BPose::BPose(Model *model, BPoseView *view, uint32 clipboardMode, bool selected) +BPose::BPose(Model* model, BPoseView* view, uint32 clipboardMode, bool selected) : fModel(model), fWidgetList(4, true), fClipboardMode(clipboardMode), @@ -88,13 +88,13 @@ BPose::BPose(Model *model, BPoseView *view, uint32 clipboardMode, bool selected) if (model->IsVolume()) { fs_info info; dev_t device = model->NodeRef()->device; - BVolume *volume = new BVolume(device); + BVolume* volume = new BVolume(device); if (volume->InitCheck() == B_OK && fs_stat_dev(device, &info) == B_OK) { // Philosophy here: // Bars go on all read/write volumes // Exceptions: Not on CDDA - if (strcmp(info.fsh_name,"cdda") != 0 + if (strcmp(info.fsh_name,"cdda") != 0 && !volume->IsReadOnly()) { // The volume is ok and we want space bars on it gPeriodicUpdatePoses.AddPose(this, view, @@ -113,8 +113,8 @@ BPose::~BPose() { if (fModel->IsVolume()) { // we might be registered for periodic updates - BVolume *volume = NULL; - if (gPeriodicUpdatePoses.RemovePose(this, (void **)&volume)) + BVolume* volume = NULL; + if (gPeriodicUpdatePoses.RemovePose(this, (void**)&volume)) delete volume; } @@ -123,10 +123,10 @@ BPose::~BPose() void -BPose::CreateWidgets(BPoseView *poseView) +BPose::CreateWidgets(BPoseView* poseView) { for (int32 index = 0; ; index++) { - BColumn *column = poseView->ColumnAt(index); + BColumn* column = poseView->ColumnAt(index); if (!column) break; fWidgetList.AddItem(new BTextWidget(fModel, column, poseView)); @@ -134,48 +134,48 @@ BPose::CreateWidgets(BPoseView *poseView) } -BTextWidget * -BPose::AddWidget(BPoseView *poseView, BColumn *column) +BTextWidget* +BPose::AddWidget(BPoseView* poseView, BColumn* column) { BModelOpener opener(fModel); if (fModel->InitCheck() != B_OK) return NULL; - BTextWidget *widget = new BTextWidget(fModel, column, poseView); + BTextWidget* widget = new BTextWidget(fModel, column, poseView); fWidgetList.AddItem(widget); return widget; } -BTextWidget * -BPose::AddWidget(BPoseView *poseView, BColumn *column, ModelNodeLazyOpener &opener) +BTextWidget* +BPose::AddWidget(BPoseView* poseView, BColumn* column, ModelNodeLazyOpener &opener) { opener.OpenNode(); if (fModel->InitCheck() != B_OK) return NULL; - BTextWidget *widget = new BTextWidget(fModel, column, poseView); + BTextWidget* widget = new BTextWidget(fModel, column, poseView); fWidgetList.AddItem(widget); return widget; } void -BPose::RemoveWidget(BPoseView *, BColumn *column) +BPose::RemoveWidget(BPoseView*, BColumn* column) { int32 index; - BTextWidget *widget = WidgetFor(column->AttrHash(), &index); - if (widget) + BTextWidget* widget = WidgetFor(column->AttrHash(), &index); + if (widget) delete fWidgetList.RemoveItemAt(index); } void -BPose::Commit(bool saveChanges, BPoint loc, BPoseView *poseView, int32 poseIndex) +BPose::Commit(bool saveChanges, BPoint loc, BPoseView* poseView, int32 poseIndex) { int32 count = fWidgetList.CountItems(); for (int32 index = 0; index < count; index++) { - BTextWidget *widget = fWidgetList.ItemAt(index); + BTextWidget* widget = fWidgetList.ItemAt(index); if (widget->IsActive()) { widget->StopEdit(saveChanges, loc, poseView, this, poseIndex); break; @@ -185,7 +185,7 @@ BPose::Commit(bool saveChanges, BPoint loc, BPoseView *poseView, int32 poseIndex inline bool -OneMouseUp(BTextWidget *widget, BPose *pose, BPoseView *poseView, BColumn *column, +OneMouseUp(BTextWidget* widget, BPose* pose, BPoseView* poseView, BColumn* column, BPoint poseLoc, BPoint where) { BRect rect; @@ -203,22 +203,22 @@ OneMouseUp(BTextWidget *widget, BPose *pose, BPoseView *poseView, BColumn *colum void -BPose::MouseUp(BPoint poseLoc, BPoseView *poseView, BPoint where, int32) +BPose::MouseUp(BPoint poseLoc, BPoseView* poseView, BPoint where, int32) { WhileEachTextWidget(this, poseView, OneMouseUp, poseLoc, where); } inline void -OneCheckAndUpdate(BTextWidget *widget, BPose *, BPoseView *poseView, - BColumn *column, BPoint poseLoc) +OneCheckAndUpdate(BTextWidget* widget, BPose*, BPoseView* poseView, + BColumn* column, BPoint poseLoc) { widget->CheckAndUpdate(poseLoc, column, poseView, true); } void -BPose::UpdateAllWidgets(int32, BPoint poseLoc, BPoseView *poseView) +BPose::UpdateAllWidgets(int32, BPoint poseLoc, BPoseView* poseView) { if (poseView->ViewMode() != kListMode) poseLoc = Location(poseView); @@ -229,8 +229,8 @@ BPose::UpdateAllWidgets(int32, BPoint poseLoc, BPoseView *poseView) void -BPose::UpdateWidgetAndModel(Model *resolvedModel, const char *attrName, - uint32 attrType, int32, BPoint poseLoc, BPoseView *poseView, bool visible) +BPose::UpdateWidgetAndModel(Model* resolvedModel, const char* attrName, + uint32 attrType, int32, BPoint poseLoc, BPoseView* poseView, bool visible) { if (poseView->ViewMode() != kListMode) poseLoc = Location(poseView); @@ -245,18 +245,18 @@ BPose::UpdateWidgetAndModel(Model *resolvedModel, const char *attrName, // ToDo: the following code is wrong, because this sort of hashing // may overlap and we get aliasing uint32 attrHash = AttrHashString(attrName, attrType); - BTextWidget *widget = WidgetFor(attrHash); + BTextWidget* widget = WidgetFor(attrHash); if (widget) { - BColumn *column = poseView->ColumnFor(attrHash); - if (column) + BColumn* column = poseView->ColumnFor(attrHash); + if (column) widget->CheckAndUpdate(poseLoc, column, poseView, visible); } else if (attrType == 0) { // attribute got likely removed, so let's search the // column for the matching attribute name int32 count = fWidgetList.CountItems(); for (int32 i = 0; i < count; i++) { - BTextWidget *widget = fWidgetList.ItemAt(i); - BColumn *column = poseView->ColumnFor(widget->AttrHash()); + BTextWidget* widget = fWidgetList.ItemAt(i); + BColumn* column = poseView->ColumnFor(widget->AttrHash()); if (column != NULL && !strcmp(column->AttrName(), attrName)) { widget->CheckAndUpdate(poseLoc, column, poseView, visible); break; @@ -277,13 +277,13 @@ BPose::UpdateWidgetAndModel(Model *resolvedModel, const char *attrName, // distribute stat changes for (int32 index = 0; ; index++) { - BColumn *column = poseView->ColumnAt(index); + BColumn* column = poseView->ColumnAt(index); if (!column) break; if (column->StatField()) { - BTextWidget *widget = WidgetFor(column->AttrHash()); - if (widget) + BTextWidget* widget = WidgetFor(column->AttrHash()); + if (widget) widget->CheckAndUpdate(poseLoc, column, poseView, visible); } } @@ -292,14 +292,14 @@ BPose::UpdateWidgetAndModel(Model *resolvedModel, const char *attrName, bool -BPose::_PeriodicUpdateCallback(BPose *pose, void *cookie) +BPose::_PeriodicUpdateCallback(BPose* pose, void* cookie) { - return pose->UpdateVolumeSpaceBar((BVolume *)cookie); + return pose->UpdateVolumeSpaceBar((BVolume*)cookie); } bool -BPose::UpdateVolumeSpaceBar(BVolume *volume) +BPose::UpdateVolumeSpaceBar(BVolume* volume) { bool enabled = TrackerSettings().ShowVolumeSpaceBar(); if (!enabled) { @@ -319,12 +319,12 @@ BPose::UpdateVolumeSpaceBar(BVolume *volume) return true; } - return false; + return false; } void -BPose::UpdateIcon(BPoint poseLoc, BPoseView *poseView) +BPose::UpdateIcon(BPoint poseLoc, BPoseView* poseView) { IconCache::sIconCache->IconChanged(ResolvedModel()); @@ -348,8 +348,8 @@ BPose::UpdateIcon(BPoint poseLoc, BPoseView *poseView) } -void -BPose::UpdateBrokenSymLink(BPoint poseLoc, BPoseView *poseView) +void +BPose::UpdateBrokenSymLink(BPoint poseLoc, BPoseView* poseView) { ASSERT(TargetModel()->IsSymLink()); ASSERT(!TargetModel()->LinkTo()); @@ -357,8 +357,8 @@ BPose::UpdateBrokenSymLink(BPoint poseLoc, BPoseView *poseView) } -void -BPose::UpdateWasBrokenSymlink(BPoint poseLoc, BPoseView *poseView) +void +BPose::UpdateWasBrokenSymlink(BPoint poseLoc, BPoseView* poseView) { if (!fModel->IsSymLink()) return; @@ -376,12 +376,12 @@ BPose::UpdateWasBrokenSymlink(BPoint poseLoc, BPoseView *poseView) void -BPose::EditFirstWidget(BPoint poseLoc, BPoseView *poseView) +BPose::EditFirstWidget(BPoint poseLoc, BPoseView* poseView) { // find first editable widget - BColumn *column; + BColumn* column; for (int32 i = 0;(column = poseView->ColumnAt(i)) != NULL;i++) { - BTextWidget *widget = WidgetFor(column->AttrHash()); + BTextWidget* widget = WidgetFor(column->AttrHash()); if (widget && widget->IsEditable()) { BRect bounds; @@ -399,16 +399,16 @@ BPose::EditFirstWidget(BPoint poseLoc, BPoseView *poseView) void -BPose::EditPreviousNextWidgetCommon(BPoseView *poseView, bool next) +BPose::EditPreviousNextWidgetCommon(BPoseView* poseView, bool next) { bool found = false; int32 delta = next ? 1 : -1; for (int32 index = next ? 0 : poseView->CountColumns() - 1; ; index += delta) { - BColumn *column = poseView->ColumnAt(index); + BColumn* column = poseView->ColumnAt(index); if (!column) break; - BTextWidget *widget = WidgetFor(column->AttrHash()); + BTextWidget* widget = WidgetFor(column->AttrHash()); if (widget && widget->IsActive()) { poseView->CommitActivePose(); found = true; @@ -419,7 +419,7 @@ BPose::EditPreviousNextWidgetCommon(BPoseView *poseView, bool next) BRect bounds; if (poseView->ViewMode() == kListMode) { int32 poseIndex = poseView->IndexOfPose(this); - BPoint poseLoc(0, poseIndex * poseView->ListElemHeight()); + BPoint poseLoc(0, poseIndex* poseView->ListElemHeight()); bounds = widget->CalcRect(poseLoc, column, poseView); } else bounds = widget->CalcRect(Location(poseView), 0, poseView); @@ -432,21 +432,21 @@ BPose::EditPreviousNextWidgetCommon(BPoseView *poseView, bool next) void -BPose::EditNextWidget(BPoseView *poseView) +BPose::EditNextWidget(BPoseView* poseView) { EditPreviousNextWidgetCommon(poseView, true); } void -BPose::EditPreviousWidget(BPoseView *poseView) +BPose::EditPreviousWidget(BPoseView* poseView) { EditPreviousNextWidgetCommon(poseView, false); } bool -BPose::PointInPose(const BPoseView *poseView, BPoint where) const +BPose::PointInPose(const BPoseView* poseView, BPoint where) const { ASSERT(poseView->ViewMode() != kListMode); @@ -464,11 +464,11 @@ BPose::PointInPose(const BPoseView *poseView, BPoint where) const kNormalIcon, poseView->IconSize()); - BTextWidget *widget = WidgetFor(poseView->FirstColumn()->AttrHash()); + BTextWidget* widget = WidgetFor(poseView->FirstColumn()->AttrHash()); if (widget) { float textWidth = ceilf(widget->TextWidth(poseView) + 1); rect.left += (poseView->IconSizeInt() - textWidth) / 2; - rect.right = rect.left + textWidth; + rect.right = rect.left + textWidth; } rect.top = location.y + poseView->IconSizeInt(); @@ -481,7 +481,7 @@ BPose::PointInPose(const BPoseView *poseView, BPoint where) const BRect rect(location, location); rect.right += B_MINI_ICON + kMiniIconSeparator; rect.bottom += poseView->IconPoseHeight(); - BTextWidget *widget = WidgetFor(poseView->FirstColumn()->AttrHash()); + BTextWidget* widget = WidgetFor(poseView->FirstColumn()->AttrHash()); if (widget) rect.right += ceil(widget->TextWidth(poseView) + 1); @@ -490,8 +490,8 @@ BPose::PointInPose(const BPoseView *poseView, BPoint where) const bool -BPose::PointInPose(BPoint loc, const BPoseView *poseView, BPoint where, - BTextWidget **hitWidget) const +BPose::PointInPose(BPoint loc, const BPoseView* poseView, BPoint where, + BTextWidget** hitWidget) const { if (hitWidget) *hitWidget = NULL; @@ -506,10 +506,10 @@ BPose::PointInPose(BPoint loc, const BPoseView *poseView, BPoint where, return true; for (int32 index = 0; ; index++) { - BColumn *column = poseView->ColumnAt(index); + BColumn* column = poseView->ColumnAt(index); if (!column) break; - BTextWidget *widget = WidgetFor(column->AttrHash()); + BTextWidget* widget = WidgetFor(column->AttrHash()); if (widget && widget->CalcClickRect(loc, column, poseView).Contains(where)) { if (hitWidget) *hitWidget = widget; @@ -522,7 +522,7 @@ BPose::PointInPose(BPoint loc, const BPoseView *poseView, BPoint where, void -BPose::Draw(BRect rect, const BRect& updateRect, BPoseView *poseView, BView *drawView, +BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView, BView* drawView, bool fullDraw, BPoint offset, bool selected) { // If the background wasn't cleared and Draw() is not called after @@ -559,12 +559,12 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView *poseView, BView *dra columnsToDraw = poseView->CountColumns(); for (int32 index = 0; index < columnsToDraw; index++) { - BColumn *column = poseView->ColumnAt(index); + BColumn* column = poseView->ColumnAt(index); if (!column) break; // if widget doesn't exist, create it - BTextWidget *widget = WidgetFor(column, poseView, modelOpener); + BTextWidget* widget = WidgetFor(column, poseView, modelOpener); if (widget && widget->IsVisible()) { BRect widgetRect(widget->ColumnRect(rect.LeftTop(), column, @@ -618,11 +618,11 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView *poseView, BView *dra DrawIcon(iconOrigin, drawView, poseView->IconSize(), directDraw, !windowActive && !showSelectionWhenInactive); - BColumn *column = poseView->FirstColumn(); + BColumn* column = poseView->FirstColumn(); if (!column) return; - BTextWidget *widget = WidgetFor(column, poseView, modelOpener); + BTextWidget* widget = WidgetFor(column, poseView, modelOpener); if (!widget || !widget->IsVisible()) return; @@ -659,7 +659,7 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView *poseView, BView *dra void -BPose::DeselectWithoutErasingBackground(BRect, BPoseView *poseView) +BPose::DeselectWithoutErasingBackground(BRect, BPoseView* poseView) { ASSERT(poseView->ViewMode() != kListMode); ASSERT(!IsSelected()); @@ -672,11 +672,11 @@ BPose::DeselectWithoutErasingBackground(BRect, BPoseView *poseView) else UpdateIcon(location, poseView); - BColumn *column = poseView->FirstColumn(); + BColumn* column = poseView->FirstColumn(); if (!column) return; - BTextWidget *widget = WidgetFor(column->AttrHash()); + BTextWidget* widget = WidgetFor(column->AttrHash()); if (!widget || !widget->IsVisible()) return; @@ -686,7 +686,7 @@ BPose::DeselectWithoutErasingBackground(BRect, BPoseView *poseView) void -BPose::MoveTo(BPoint point, BPoseView *poseView, bool inval) +BPose::MoveTo(BPoint point, BPoseView* poseView, bool inval) { point.x = floorf(point.x); point.y = floorf(point.y); @@ -704,7 +704,7 @@ BPose::MoveTo(BPoint point, BPoseView *poseView, bool inval) // might need to move a text view if we're active if (poseView->ActivePose() == this) { - BView *border_view = poseView->FindView("BorderView"); + BView* border_view = poseView->FindView("BorderView"); if (border_view) border_view->MoveBy(point.x - oldLocation.x, point.y - oldLocation.y); } @@ -726,11 +726,11 @@ BPose::MoveTo(BPoint point, BPoseView *poseView, bool inval) } -BTextWidget * +BTextWidget* BPose::ActiveWidget() const { for (int32 i = fWidgetList.CountItems(); i-- > 0;) { - BTextWidget *widget = fWidgetList.ItemAt(i); + BTextWidget* widget = fWidgetList.ItemAt(i); if (widget->IsActive()) return widget; } @@ -738,12 +738,12 @@ BPose::ActiveWidget() const } -BTextWidget * -BPose::WidgetFor(uint32 attr, int32 *index) const +BTextWidget* +BPose::WidgetFor(uint32 attr, int32* index) const { int32 count = fWidgetList.CountItems(); for (int32 i = 0; i < count; i++) { - BTextWidget *widget = fWidgetList.ItemAt(i); + BTextWidget* widget = fWidgetList.ItemAt(i); if (widget->AttrHash() == attr) { if (index) *index = i; @@ -755,11 +755,11 @@ BPose::WidgetFor(uint32 attr, int32 *index) const } -BTextWidget * -BPose::WidgetFor(BColumn *column, BPoseView *poseView, ModelNodeLazyOpener &opener, - int32 *index) +BTextWidget* +BPose::WidgetFor(BColumn* column, BPoseView* poseView, ModelNodeLazyOpener &opener, + int32* index) { - BTextWidget *widget = WidgetFor(column->AttrHash(), index); + BTextWidget* widget = WidgetFor(column->AttrHash(), index); if (!widget) widget = AddWidget(poseView, column, opener); @@ -767,18 +767,17 @@ BPose::WidgetFor(BColumn *column, BPoseView *poseView, ModelNodeLazyOpener &open } -/* deprecated */ +// the following method is deprecated bool BPose::TestLargeIconPixel(BPoint point) const { return IconCache::sIconCache->IconHitTest(point, ResolvedModel(), kNormalIcon, B_LARGE_ICON); } -/* deprecated */ void -BPose::DrawIcon(BPoint where, BView *view, icon_size kind, bool direct, bool drawUnselected) +BPose::DrawIcon(BPoint where, BView* view, icon_size kind, bool direct, bool drawUnselected) { if (fClipboardMode == kMoveSelectionTo) { view->SetDrawingMode(B_OP_ALPHA); @@ -795,8 +794,8 @@ BPose::DrawIcon(BPoint where, BView *view, icon_size kind, bool direct, bool dra } -void -BPose::DrawBar(BPoint where,BView *view,icon_size kind) +void +BPose::DrawBar(BPoint where,BView* view,icon_size kind) { view->PushState(); @@ -813,7 +812,7 @@ BPose::DrawBar(BPoint where,BView *view,icon_size kind) barHeight = size - 4 - 2 * yOffset; } - // the black shadowed line + // the black shadowed line view->SetHighColor(32, 32, 32, 92); view->MovePenTo(BPoint(where.x + size, where.y + 1 + yOffset)); view->StrokeLine(BPoint(where.x + size, where.y + size - yOffset)); @@ -855,14 +854,14 @@ BPose::DrawBar(BPoint where,BView *view,icon_size kind) void -BPose::DrawToggleSwitch(BRect, BPoseView *) +BPose::DrawToggleSwitch(BRect, BPoseView*) { return; } BPoint -BPose::Location(const BPoseView *poseView) const +BPose::Location(const BPoseView* poseView) const { float scale = 1.0; if (poseView->ViewMode() == kIconMode) @@ -873,7 +872,7 @@ BPose::Location(const BPoseView *poseView) const void -BPose::SetLocation(BPoint point, const BPoseView *poseView) +BPose::SetLocation(BPoint point, const BPoseView* poseView) { float scale = 1.0; if (poseView->ViewMode() == kIconMode) @@ -887,11 +886,11 @@ debugger("BPose::SetLocation() - infinite location"); BRect -BPose::CalcRect(BPoint loc, const BPoseView *poseView, bool minimalRect) const +BPose::CalcRect(BPoint loc, const BPoseView* poseView, bool minimalRect) const { ASSERT(poseView->ViewMode() == kListMode); - BColumn *column = poseView->LastColumn(); + BColumn* column = poseView->LastColumn(); BRect rect; rect.left = loc.x; rect.top = loc.y; @@ -899,8 +898,8 @@ BPose::CalcRect(BPoint loc, const BPoseView *poseView, bool minimalRect) const rect.bottom = rect.top + poseView->ListElemHeight(); if (minimalRect) { - BTextWidget *widget = WidgetFor(poseView->FirstColumn()->AttrHash()); - if (widget) + BTextWidget* widget = WidgetFor(poseView->FirstColumn()->AttrHash()); + if (widget) rect.right = widget->CalcRect(loc, poseView->FirstColumn(), poseView).right; } @@ -909,7 +908,7 @@ BPose::CalcRect(BPoint loc, const BPoseView *poseView, bool minimalRect) const BRect -BPose::CalcRect(const BPoseView *poseView) const +BPose::CalcRect(const BPoseView* poseView) const { ASSERT(poseView->ViewMode() != kListMode); @@ -919,12 +918,12 @@ BPose::CalcRect(const BPoseView *poseView) const rect.left = location.x; rect.right = rect.left + poseView->IconSizeInt(); - BTextWidget *widget = WidgetFor(poseView->FirstColumn()->AttrHash()); + BTextWidget* widget = WidgetFor(poseView->FirstColumn()->AttrHash()); if (widget) { float textWidth = ceilf(widget->TextWidth(poseView) + 1); if (textWidth > poseView->IconSizeInt()) { rect.left += (poseView->IconSizeInt() - textWidth) / 2; - rect.right = rect.left + textWidth; + rect.right = rect.left + textWidth; } } @@ -936,7 +935,7 @@ BPose::CalcRect(const BPoseView *poseView) const rect.top = location.y; rect.right = rect.left + B_MINI_ICON + kMiniIconSeparator; rect.bottom = rect.top + poseView->IconPoseHeight(); - BTextWidget *widget = WidgetFor(poseView->FirstColumn()->AttrHash()); + BTextWidget* widget = WidgetFor(poseView->FirstColumn()->AttrHash()); if (widget) rect.right += ceil(widget->TextWidth(poseView) + 1); } diff --git a/src/kits/tracker/Pose.h b/src/kits/tracker/Pose.h index d9957062b5..d03a6ef5d0 100644 --- a/src/kits/tracker/Pose.h +++ b/src/kits/tracker/Pose.h @@ -31,16 +31,17 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - -#ifndef _POSE_H +#ifndef _POSE_H #define _POSE_H + #include #include "TextWidget.h" #include "Model.h" #include "Utilities.h" + namespace BPrivate { class BPoseView; @@ -54,28 +55,28 @@ enum { class BPose { public: - BPose(Model *adopt, BPoseView *, uint32 clipboardMode, bool selected = false); + BPose(Model* adopt, BPoseView*, uint32 clipboardMode, bool selected = false); virtual ~BPose(); - BTextWidget *AddWidget(BPoseView *, BColumn *); - BTextWidget *AddWidget(BPoseView *, BColumn *, ModelNodeLazyOpener &opener); - void RemoveWidget(BPoseView *, BColumn *); - void SetLocation(BPoint, const BPoseView *); - void MoveTo(BPoint, BPoseView *, bool inval = true); + BTextWidget* AddWidget(BPoseView*, BColumn*); + BTextWidget* AddWidget(BPoseView*, BColumn*, ModelNodeLazyOpener &opener); + void RemoveWidget(BPoseView*, BColumn*); + void SetLocation(BPoint, const BPoseView*); + void MoveTo(BPoint, BPoseView*, bool inval = true); - void Draw(BRect poseRect, const BRect& updateRect, BPoseView *, + void Draw(BRect poseRect, const BRect& updateRect, BPoseView*, bool fullDraw = true); - void Draw(BRect poseRect, const BRect& updateRect, BPoseView *, - BView *drawView, bool fullDraw, BPoint offset, bool selected); - void DeselectWithoutErasingBackground(BRect rect, BPoseView *poseView); + void Draw(BRect poseRect, const BRect& updateRect, BPoseView*, + BView* drawView, bool fullDraw, BPoint offset, bool selected); + void DeselectWithoutErasingBackground(BRect rect, BPoseView* poseView); // special purpose draw call for deselecting over a textured // background - void DrawBar(BPoint where,BView *view,icon_size kind); + void DrawBar(BPoint where, BView* view, icon_size kind); - void DrawIcon(BPoint, BView *, icon_size, bool direct, bool drawUnselected = false); - void DrawToggleSwitch(BRect, BPoseView *); - void MouseUp(BPoint poseLoc, BPoseView *, BPoint where, int32 index); + void DrawIcon(BPoint, BView*, icon_size, bool direct, bool drawUnselected = false); + void DrawToggleSwitch(BRect, BPoseView*); + void MouseUp(BPoint poseLoc, BPoseView*, BPoint where, int32 index); Model* TargetModel() const; Model* ResolvedModel() const; void Select(bool selected); @@ -83,35 +84,35 @@ class BPose { // Rename to IsHighlighted bigtime_t SelectionTime() const; - BTextWidget *ActiveWidget() const; - BTextWidget *WidgetFor(uint32 hashAttr, int32 *index = 0) const; - BTextWidget *WidgetFor(BColumn *column, BPoseView *poseView, ModelNodeLazyOpener &opener, - int32 *index = NULL); + BTextWidget* ActiveWidget() const; + BTextWidget* WidgetFor(uint32 hashAttr, int32* index = 0) const; + BTextWidget* WidgetFor(BColumn* column, BPoseView* poseView, + ModelNodeLazyOpener &opener, int32* index = NULL); // adds the widget if needed - bool PointInPose(BPoint poseLoc, const BPoseView *, BPoint where, - BTextWidget ** = NULL) const; - bool PointInPose(const BPoseView *, BPoint where) const ; - BRect CalcRect(BPoint loc, const BPoseView *, + bool PointInPose(BPoint poseLoc, const BPoseView*, BPoint where, + BTextWidget** = NULL) const; + bool PointInPose(const BPoseView*, BPoint where) const; + BRect CalcRect(BPoint loc, const BPoseView*, bool minimal_rect = false) const; - BRect CalcRect(const BPoseView *) const; - void UpdateAllWidgets(int32 poseIndex, BPoint poseLoc, BPoseView *); - void UpdateWidgetAndModel(Model *resolvedModel, const char *attrName, + BRect CalcRect(const BPoseView*) const; + void UpdateAllWidgets(int32 poseIndex, BPoint poseLoc, BPoseView*); + void UpdateWidgetAndModel(Model* resolvedModel, const char* attrName, uint32 attrType, int32 poseIndex, BPoint poseLoc, - BPoseView *view, bool visible); - bool UpdateVolumeSpaceBar(BVolume *volume); - void UpdateIcon(BPoint poseLoc, BPoseView *); + BPoseView* view, bool visible); + bool UpdateVolumeSpaceBar(BVolume* volume); + void UpdateIcon(BPoint poseLoc, BPoseView*); - //void UpdateFixedSymlink(BPoint poseLoc, BPoseView *); - void UpdateBrokenSymLink(BPoint poseLoc, BPoseView *); - void UpdateWasBrokenSymlink(BPoint poseLoc, BPoseView *poseView); + //void UpdateFixedSymlink(BPoint poseLoc, BPoseView*); + void UpdateBrokenSymLink(BPoint poseLoc, BPoseView*); + void UpdateWasBrokenSymlink(BPoint poseLoc, BPoseView* poseView); - void Commit(bool saveChanges, BPoint loc, BPoseView *, int32 index); - void EditFirstWidget(BPoint poseLoc, BPoseView *); - void EditNextWidget(BPoseView *); - void EditPreviousWidget(BPoseView *); + void Commit(bool saveChanges, BPoint loc, BPoseView*, int32 index); + void EditFirstWidget(BPoint poseLoc, BPoseView*); + void EditNextWidget(BPoseView*); + void EditPreviousWidget(BPoseView*); - BPoint Location(const BPoseView *poseView) const; + BPoint Location(const BPoseView* poseView) const; bool DelayedEdit() const; void SetDelayedEdit(bool delay); bool ListModeInited() const; @@ -129,12 +130,12 @@ class BPose { #endif private: - static bool _PeriodicUpdateCallback(BPose *pose, void *cookie); - void EditPreviousNextWidgetCommon(BPoseView *poseView, bool next); - void CreateWidgets(BPoseView *); + static bool _PeriodicUpdateCallback(BPose* pose, void* cookie); + void EditPreviousNextWidgetCommon(BPoseView* poseView, bool next); + void CreateWidgets(BPoseView*); bool TestLargeIconPixel(BPoint) const; - Model *fModel; + Model* fModel; BObjectList fWidgetList; BPoint fLocation; @@ -152,14 +153,14 @@ class BPose { }; -inline Model * +inline Model* BPose::TargetModel() const { return fModel; } -inline Model * +inline Model* BPose::ResolvedModel() const { return fModel->IsSymLink() ? @@ -233,16 +234,16 @@ BPose::HasLocation() const inline void -BPose::Draw(BRect poseRect, const BRect& updateRect, BPoseView *view, +BPose::Draw(BRect poseRect, const BRect& updateRect, BPoseView* view, bool fullDraw) { - Draw(poseRect, updateRect, view, (BView *)view, fullDraw, BPoint(0, 0), + Draw(poseRect, updateRect, view, (BView*)view, fullDraw, BPoint(0, 0), IsSelected()); } inline uint32 -BPose::ClipboardMode() const +BPose::ClipboardMode() const { return fClipboardMode; } @@ -258,4 +259,4 @@ BPose::SetClipboardMode(uint32 clipboardMode) using namespace BPrivate; -#endif +#endif // _POSE_H diff --git a/src/kits/tracker/PoseList.cpp b/src/kits/tracker/PoseList.cpp index 987308fd7e..9d0f83e766 100644 --- a/src/kits/tracker/PoseList.cpp +++ b/src/kits/tracker/PoseList.cpp @@ -41,54 +41,60 @@ All rights reserved. #include "Pose.h" -BPose * -PoseList::FindPose(const node_ref *node, int32 *resultingIndex) const +BPose* +PoseList::FindPose(const node_ref* node, int32* resultingIndex) const { int32 count = CountItems(); for (int32 index = 0; index < count; index++) { - BPose *pose = ItemAt(index); + BPose* pose = ItemAt(index); ASSERT(pose->TargetModel()); if (*pose->TargetModel()->NodeRef() == *node) { if (resultingIndex) *resultingIndex = index; + return pose; } } return NULL; } -BPose * -PoseList::FindPose(const entry_ref *entry, int32 *resultingIndex) const + +BPose* +PoseList::FindPose(const entry_ref* entry, int32* resultingIndex) const { int32 count = CountItems(); for (int32 index = 0; index < count; index++) { - BPose *pose = ItemAt(index); + BPose* pose = ItemAt(index); ASSERT(pose->TargetModel()); if (*pose->TargetModel()->EntryRef() == *entry) { if (resultingIndex) *resultingIndex = index; + return pose; } } return NULL; } -BPose * -PoseList::FindPose(const Model *model, int32 *resultingIndex) const + +BPose* +PoseList::FindPose(const Model* model, int32* resultingIndex) const { return FindPose(model->NodeRef(), resultingIndex); } -BPose * -PoseList::DeepFindPose(const node_ref *node, int32 *resultingIndex) const + +BPose* +PoseList::DeepFindPose(const node_ref* node, int32* resultingIndex) const { int32 count = CountItems(); for (int32 index = 0; index < count; index++) { - BPose *pose = ItemAt(index); - Model *model = pose->TargetModel(); + BPose* pose = ItemAt(index); + Model* model = pose->TargetModel(); if (*model->NodeRef() == *node) { if (resultingIndex) *resultingIndex = index; + return pose; } // if model is a symlink, try matching node with the target @@ -98,6 +104,7 @@ PoseList::DeepFindPose(const node_ref *node, int32 *resultingIndex) const if (model && *model->NodeRef() == *node) { if (resultingIndex) *resultingIndex = index; + return pose; } } diff --git a/src/kits/tracker/PoseList.h b/src/kits/tracker/PoseList.h index b16b5d89f7..4e8c287073 100644 --- a/src/kits/tracker/PoseList.h +++ b/src/kits/tracker/PoseList.h @@ -31,16 +31,18 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ +#ifndef _POSE_LIST_H +#define _POSE_LIST_H + // PoseList is a commonly used instance of BObjectList // Defines convenience find and iteration calls -#ifndef _POSE_LIST_H -#define _POSE_LIST_H #include "ObjectList.h" #include "Pose.h" + struct node_ref; struct entry_ref; @@ -58,50 +60,53 @@ public: : BObjectList(list) {} - BPose *FindPose(const node_ref *node, int32 *index = NULL) const; - BPose *FindPose(const entry_ref *entry, int32 *index = NULL) const; - BPose *FindPose(const Model *model, int32 *index = NULL) const; - BPose *DeepFindPose(const node_ref *node, int32 *index = NULL) const; + BPose* FindPose(const node_ref* node, int32* index = NULL) const; + BPose* FindPose(const entry_ref* entry, int32* index = NULL) const; + BPose* FindPose(const Model* model, int32* index = NULL) const; + BPose* DeepFindPose(const node_ref* node, int32* index = NULL) const; // same as FindPose, node can be a target of the actual // pose if the pose is a symlink }; // iteration glue, add permutations as needed + template void -EachPoseAndModel(PoseList *list, void (*eachFunction)(BPose *, Model *, EachParam1), +EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, EachParam1), EachParam1 eachParam1) { for (int32 index = list->CountItems() - 1; index >= 0; index--) { - BPose *pose = list->ItemAt(index); - Model *model = pose->TargetModel(); + BPose* pose = list->ItemAt(index); + Model* model = pose->TargetModel(); if (model) (eachFunction)(pose, model, eachParam1); } } + template void -EachPoseAndModel(PoseList *list, void (*eachFunction)(BPose *, Model *, int32 , +EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, int32 , EachParam1), EachParam1 eachParam1) { for (int32 index = list->CountItems() - 1; index >= 0; index--) { - BPose *pose = list->ItemAt(index); - Model *model = pose->TargetModel(); + BPose* pose = list->ItemAt(index); + Model* model = pose->TargetModel(); if (model) (eachFunction)(pose, model, index, eachParam1); } } + template void -EachPoseAndModel(PoseList *list, void (*eachFunction)(BPose *, Model *, EachParam1, +EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, EachParam1, EachParam2), EachParam1 eachParam1, EachParam2 eachParam2) { for (int32 index = list->CountItems() - 1; index >= 0; index--) { - BPose *pose = list->ItemAt(index); - Model *model = pose->TargetModel(); + BPose* pose = list->ItemAt(index); + Model* model = pose->TargetModel(); if (model) (eachFunction)(pose, model, eachParam1, eachParam2); } @@ -109,12 +114,12 @@ EachPoseAndModel(PoseList *list, void (*eachFunction)(BPose *, Model *, EachPara template void -EachPoseAndModel(PoseList *list, void (*eachFunction)(BPose *, Model *, int32, +EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, int32, EachParam1, EachParam2), EachParam1 eachParam1, EachParam2 eachParam2) { for (int32 index = list->CountItems() - 1; index >= 0; index--) { - BPose *pose = list->ItemAt(index); - Model *model = pose->TargetModel(); + BPose* pose = list->ItemAt(index); + Model* model = pose->TargetModel(); if (model) (eachFunction)(pose, model, index, eachParam1, eachParam2); } @@ -122,12 +127,12 @@ EachPoseAndModel(PoseList *list, void (*eachFunction)(BPose *, Model *, int32, template void -EachPoseAndResolvedModel(PoseList *list, void (*eachFunction)(BPose *, Model *, EachParam1), +EachPoseAndResolvedModel(PoseList* list, void (*eachFunction)(BPose*, Model*, EachParam1), EachParam1 eachParam1) { for (int32 index = list->CountItems() - 1; index >= 0; index--) { - BPose *pose = list->ItemAt(index); - Model *model = pose->TargetModel()->ResolveIfLink(); + BPose* pose = list->ItemAt(index); + Model* model = pose->TargetModel()->ResolveIfLink(); if (model) (eachFunction)(pose, model, eachParam1); } @@ -135,12 +140,12 @@ EachPoseAndResolvedModel(PoseList *list, void (*eachFunction)(BPose *, Model *, template void -EachPoseAndResolvedModel(PoseList *list, void (*eachFunction)(BPose *, Model *, int32 , +EachPoseAndResolvedModel(PoseList* list, void (*eachFunction)(BPose*, Model*, int32 , EachParam1), EachParam1 eachParam1) { for (int32 index = list->CountItems() - 1; index >= 0; index--) { - BPose *pose = list->ItemAt(index); - Model *model = pose->TargetModel()->ResolveIfLink(); + BPose* pose = list->ItemAt(index); + Model* model = pose->TargetModel()->ResolveIfLink(); if (model) (eachFunction)(pose, model, index, eachParam1); } @@ -148,12 +153,12 @@ EachPoseAndResolvedModel(PoseList *list, void (*eachFunction)(BPose *, Model *, template void -EachPoseAndResolvedModel(PoseList *list, void (*eachFunction)(BPose *, Model *, EachParam1, +EachPoseAndResolvedModel(PoseList* list, void (*eachFunction)(BPose*, Model*, EachParam1, EachParam2), EachParam1 eachParam1, EachParam2 eachParam2) { for (int32 index = list->CountItems() - 1; index >= 0; index--) { - BPose *pose = list->ItemAt(index); - Model *model = pose->TargetModel()->ResolveIfLink(); + BPose* pose = list->ItemAt(index); + Model* model = pose->TargetModel()->ResolveIfLink(); if (model) (eachFunction)(pose, model, eachParam1, eachParam2); } @@ -161,12 +166,12 @@ EachPoseAndResolvedModel(PoseList *list, void (*eachFunction)(BPose *, Model *, template void -EachPoseAndResolvedModel(PoseList *list, void (*eachFunction)(BPose *, Model *, int32, +EachPoseAndResolvedModel(PoseList* list, void (*eachFunction)(BPose*, Model*, int32, EachParam1, EachParam2), EachParam1 eachParam1, EachParam2 eachParam2) { for (int32 index = list->CountItems() - 1; index >= 0; index--) { - BPose *pose = list->ItemAt(index); - Model *model = pose->TargetModel()->ResolveIfLink(); + BPose* pose = list->ItemAt(index); + Model* model = pose->TargetModel()->ResolveIfLink(); if (model) (eachFunction)(pose, model, index, eachParam1, eachParam2); } @@ -176,4 +181,4 @@ EachPoseAndResolvedModel(PoseList *list, void (*eachFunction)(BPose *, Model *, using namespace BPrivate; -#endif +#endif // _POSE_LIST_H diff --git a/src/kits/tracker/PoseView.cpp b/src/kits/tracker/PoseView.cpp index cef804fb78..47d15731c6 100644 --- a/src/kits/tracker/PoseView.cpp +++ b/src/kits/tracker/PoseView.cpp @@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include "PoseView.h" #include @@ -120,7 +121,7 @@ const uint32 kMsgMouseLongDown = 'Mold'; const int32 kRoomForLine = 2; namespace BPrivate { -extern bool delete_point(void *); +extern bool delete_point(void*); // TODO: exterminate this } @@ -149,13 +150,11 @@ const BPoint kTransparentDragThreshold(256, 192); // maximum size of the transparent drag bitmap, use a drag rect // if larger in any direction - struct attr_column_relation { uint32 attrHash; int32 fieldMask; }; - static struct attr_column_relation sAttrColumnMap[] = { { AttrHashString(kAttrStatModified, B_TIME_TYPE), B_STAT_MODIFICATION_TIME }, @@ -167,12 +166,11 @@ static struct attr_column_relation sAttrColumnMap[] = { B_STAT_MODE } }; - struct AddPosesResult { ~AddPosesResult(); void ReleaseModels(); - Model *fModels[kMaxAddPosesChunk]; + Model* fModels[kMaxAddPosesChunk]; PoseInfo fPoseInfos[kMaxAddPosesChunk]; int32 fCount; }; @@ -193,19 +191,19 @@ AddPosesResult::ReleaseModels(void) } -static BPose * -BSearch(PoseList *table, const BPose* key, BPoseView *view, - int (*cmp)(const BPose *, const BPose *, BPoseView *), +static BPose* +BSearch(PoseList* table, const BPose* key, BPoseView* view, + int (*cmp)(const BPose*, const BPose*, BPoseView*), bool returnClosest = true); static int -PoseCompareAddWidget(const BPose *p1, const BPose *p2, BPoseView *view); +PoseCompareAddWidget(const BPose* p1, const BPose* p2, BPoseView* view); // #pragma mark - -BPoseView::BPoseView(Model *model, BRect bounds, uint32 viewMode, uint32 resizeMask) +BPoseView::BPoseView(Model* model, BRect bounds, uint32 viewMode, uint32 resizeMask) : BView(bounds, "PoseView", resizeMask, B_WILL_DRAW | B_PULSE_NEEDED), fIsDrawingSelectionRect(false), fHScrollBar(NULL), @@ -291,7 +289,7 @@ BPoseView::~BPoseView() void -BPoseView::Init(AttributeStreamNode *node) +BPoseView::Init(AttributeStreamNode* node) { RestoreState(node); InitCommon(); @@ -309,7 +307,7 @@ BPoseView::Init(const BMessage &message) void BPoseView::InitCommon() { - BContainerWindow *window = ContainerWindow(); + BContainerWindow* window = ContainerWindow(); // create title view for window BRect rect(Frame()); @@ -366,7 +364,7 @@ BPoseView::InitCommon() static int -CompareColumns(const BColumn *c1, const BColumn *c2) +CompareColumns(const BColumn* c1, const BColumn* c2) { if (c1->Offset() > c2->Offset()) return 1; @@ -378,12 +376,12 @@ CompareColumns(const BColumn *c1, const BColumn *c2) void -BPoseView::RestoreColumnState(AttributeStreamNode *node) +BPoseView::RestoreColumnState(AttributeStreamNode* node) { fColumnList->MakeEmpty(); if (node) { - const char *columnsAttr; - const char *columnsAttrForeign; + const char* columnsAttr; + const char* columnsAttrForeign; if (TargetModel() && TargetModel()->IsRoot()) { columnsAttr = kAttrDisksColumns; columnsAttrForeign = kAttrDisksColumnsForeign; @@ -393,7 +391,7 @@ BPoseView::RestoreColumnState(AttributeStreamNode *node) } bool wrongEndianness = false; - const char *name = columnsAttr; + const char* name = columnsAttr; size_t size = (size_t)node->Contains(name, B_RAW_TYPE); if (!size) { name = columnsAttrForeign; @@ -403,7 +401,7 @@ BPoseView::RestoreColumnState(AttributeStreamNode *node) if (size > 0 && size < 10000) { // check for invalid sizes here to protect against munged attributes - char *buffer = new char[size]; + char* buffer = new char[size]; off_t result = node->Read(name, 0, B_RAW_TYPE, size, buffer); if (result) { BMallocIO stream; @@ -416,7 +414,7 @@ BPoseView::RestoreColumnState(AttributeStreamNode *node) // for overlaps below. BObjectList tempSortedList; for (;;) { - BColumn *column = BColumn::InstantiateFromStream(&stream, + BColumn* column = BColumn::InstantiateFromStream(&stream, wrongEndianness); if (!column) break; @@ -445,7 +443,7 @@ BPoseView::RestoreColumnState(const BMessage &message) BObjectList tempSortedList; for (int32 index = 0; ; index++) { - BColumn *column = BColumn::InstantiateFromMessage(message, index); + BColumn* column = BColumn::InstantiateFromMessage(message, index); if (!column) break; tempSortedList.AddItem(column); @@ -465,13 +463,13 @@ BPoseView::RestoreColumnState(const BMessage &message) void -BPoseView::AddColumnList(BObjectList *list) +BPoseView::AddColumnList(BObjectList* list) { list->SortItems(&CompareColumns); float nextLeftEdge = 0; for (int32 columIndex = 0; columIndex < list->CountItems(); columIndex++) { - BColumn *column = list->ItemAt(columIndex); + BColumn* column = list->ItemAt(columIndex); // Make sure that columns don't overlap if (column->Offset() < nextLeftEdge) { @@ -490,13 +488,13 @@ BPoseView::AddColumnList(BObjectList *list) void -BPoseView::RestoreState(AttributeStreamNode *node) +BPoseView::RestoreState(AttributeStreamNode* node) { RestoreColumnState(node); if (node) { - const char *viewStateAttr; - const char *viewStateAttrForeign; + const char* viewStateAttr; + const char* viewStateAttrForeign; if (TargetModel() && TargetModel()->IsRoot()) { viewStateAttr = kAttrDisksViewState; @@ -507,7 +505,7 @@ BPoseView::RestoreState(AttributeStreamNode *node) } bool wrongEndianness = false; - const char *name = viewStateAttr; + const char* name = viewStateAttr; size_t size = (size_t)node->Contains(name, B_RAW_TYPE); if (!size) { name = viewStateAttrForeign; @@ -517,13 +515,13 @@ BPoseView::RestoreState(AttributeStreamNode *node) if (size > 0 && size < 10000) { // check for invalid sizes here to protect against munged attributes - char *buffer = new char[size]; + char* buffer = new char[size]; off_t result = node->Read(name, 0, B_RAW_TYPE, size, buffer); if (result) { BMallocIO stream; stream.WriteAt(0, buffer, size); stream.Seek(0, SEEK_SET); - BViewState *viewstate = BViewState::InstantiateFromStream(&stream, + BViewState* viewstate = BViewState::InstantiateFromStream(&stream, wrongEndianness); if (viewstate) { delete fViewState; @@ -545,7 +543,7 @@ BPoseView::RestoreState(const BMessage &message) { RestoreColumnState(message); - BViewState *viewstate = BViewState::InstantiateFromMessage(message); + BViewState* viewstate = BViewState::InstantiateFromMessage(message); if (viewstate) { delete fViewState; @@ -562,8 +560,8 @@ BPoseView::RestoreState(const BMessage &message) namespace BPrivate { bool -ClearViewOriginOne(const char *DEBUG_ONLY(name), uint32 type, off_t size, - void *viewStateArchive, void *) +ClearViewOriginOne(const char* DEBUG_ONLY(name), uint32 type, off_t size, + void* viewStateArchive, void*) { ASSERT(strcmp(name, kAttrViewState) == 0); @@ -576,7 +574,7 @@ ClearViewOriginOne(const char *DEBUG_ONLY(name), uint32 type, off_t size, BMallocIO stream; stream.WriteAt(0, viewStateArchive, (size_t)size); stream.Seek(0, SEEK_SET); - BViewState *viewstate = BViewState::InstantiateFromStream(&stream, false); + BViewState* viewstate = BViewState::InstantiateFromStream(&stream, false); if (!viewstate) return false; @@ -613,14 +611,14 @@ BPoseView::SetUpDefaultColumnsIfNeeded() } -const char * +const char* BPoseView::ViewStateAttributeName() const { return IsDesktopView() ? kAttrDesktopViewState : kAttrViewState; } -const char * +const char* BPoseView::ForeignViewStateAttributeName() const { return IsDesktopView() ? kAttrDesktopViewStateForeign @@ -629,17 +627,17 @@ BPoseView::ForeignViewStateAttributeName() const void -BPoseView::SaveColumnState(AttributeStreamNode *node) +BPoseView::SaveColumnState(AttributeStreamNode* node) { BMallocIO stream; for (int32 index = 0; ; index++) { - const BColumn *column = ColumnAt(index); + const BColumn* column = ColumnAt(index); if (!column) break; column->ArchiveToStream(&stream); } - const char *columnsAttr; - const char *columnsAttrForeign; + const char* columnsAttr; + const char* columnsAttrForeign; if (TargetModel() && TargetModel()->IsRoot()) { columnsAttr = kAttrDisksColumns; columnsAttrForeign = kAttrDisksColumnsForeign; @@ -656,7 +654,7 @@ void BPoseView::SaveColumnState(BMessage &message) const { for (int32 index = 0; ; index++) { - const BColumn *column = ColumnAt(index); + const BColumn* column = ColumnAt(index); if (!column) break; column->ArchiveToMessage(message); @@ -665,7 +663,7 @@ BPoseView::SaveColumnState(BMessage &message) const void -BPoseView::SaveState(AttributeStreamNode *node) +BPoseView::SaveState(AttributeStreamNode* node) { SaveColumnState(node); @@ -675,8 +673,8 @@ BPoseView::SaveState(AttributeStreamNode *node) stream.Seek(0, SEEK_SET); fViewState->ArchiveToStream(&stream); - const char *viewStateAttr; - const char *viewStateAttrForeign; + const char* viewStateAttr; + const char* viewStateAttrForeign; if (TargetModel() && TargetModel()->IsRoot()) { viewStateAttr = kAttrDisksViewState; viewStateAttrForeign = kAttrDisksViewStateForeign; @@ -701,7 +699,7 @@ BPoseView::SaveState(BMessage &message) const float -BPoseView::StringWidth(const char *str) const +BPoseView::StringWidth(const char* str) const { return BPrivate::gWidthBuffer->StringWidth(str, 0, (int32)strlen(str), &sCurrentFont); @@ -709,7 +707,7 @@ BPoseView::StringWidth(const char *str) const float -BPoseView::StringWidth(const char *str, int32 len) const +BPoseView::StringWidth(const char* str, int32 len) const { ASSERT(strlen(str) == (uint32)len); return BPrivate::gWidthBuffer->StringWidth(str, 0, len, &sCurrentFont); @@ -717,7 +715,7 @@ BPoseView::StringWidth(const char *str, int32 len) const void -BPoseView::SavePoseLocations(BRect *frameIfDesktop) +BPoseView::SavePoseLocations(BRect* frameIfDesktop) { PoseInfo poseInfo; @@ -743,9 +741,9 @@ BPoseView::SavePoseLocations(BRect *frameIfDesktop) int32 count = fPoseList->CountItems(); for (int32 index = 0; index < count; index++) { - BPose *pose = fPoseList->ItemAt(index); + BPose* pose = fPoseList->ItemAt(index); if (pose->NeedsSaveLocation() && pose->HasLocation()) { - Model *model = pose->TargetModel(); + Model* model = pose->TargetModel(); poseInfo.fInvisible = false; if (model->IsRoot()) @@ -755,7 +753,7 @@ BPoseView::SavePoseLocations(BRect *frameIfDesktop) poseInfo.fLocation = pose->Location(this); - ExtendedPoseInfo *extendedPoseInfo = NULL; + ExtendedPoseInfo* extendedPoseInfo = NULL; size_t extendedPoseInfoSize = 0; ModelNodeLazyOpener opener(model, true); @@ -768,7 +766,7 @@ BPoseView::SavePoseLocations(BRect *frameIfDesktop) if (!extendedPoseInfo) { // don't have one yet, allocate one size_t size = ExtendedPoseInfo::Size(1); - extendedPoseInfo = (ExtendedPoseInfo *) + extendedPoseInfo = (ExtendedPoseInfo*) new char [size]; memset(extendedPoseInfo, 0, size); @@ -785,7 +783,7 @@ BPoseView::SavePoseLocations(BRect *frameIfDesktop) } if (model->InitCheck() != B_OK) { - delete[] (char *)extendedPoseInfo; + delete[] (char*)extendedPoseInfo; continue; } @@ -797,9 +795,9 @@ BPoseView::SavePoseLocations(BRect *frameIfDesktop) if (model->IsRoot() || isTrash) { BDirectory dir; if (FSGetDeskDir(&dir) == B_OK) { - const char *poseInfoAttr = isTrash ? kAttrTrashPoseInfo + const char* poseInfoAttr = isTrash ? kAttrTrashPoseInfo : kAttrDisksPoseInfo; - const char *poseInfoAttrForeign = isTrash + const char* poseInfoAttrForeign = isTrash ? kAttrTrashPoseInfoForeign : kAttrDisksPoseInfoForeign; if (dir.WriteAttr(poseInfoAttr, B_RAW_TYPE, 0, @@ -825,7 +823,7 @@ BPoseView::SavePoseLocations(BRect *frameIfDesktop) } } - delete [] (char *)extendedPoseInfo; + delete [] (char*)extendedPoseInfo; // TODO: fix up this mess } } @@ -859,7 +857,7 @@ BPoseView::DetachedFromWindow() if (fTitleView && !fTitleView->Window()) delete fTitleView; - if (TTracker *app = dynamic_cast(be_app)) { + if (TTracker* app = dynamic_cast(be_app)) { app->Lock(); app->StopWatching(this, kShowSelectionWhenInactiveChanged); app->StopWatching(this, kTransparentSelectionChanged); @@ -879,7 +877,7 @@ BPoseView::DetachedFromWindow() void BPoseView::Pulse() { - BContainerWindow *window = ContainerWindow(); + BContainerWindow* window = ContainerWindow(); if (!window) return; @@ -933,7 +931,7 @@ BPoseView::ScrollTo(BPoint point) void BPoseView::AttachedToWindow() { - fIsDesktopWindow = (dynamic_cast(Window()) != 0); + fIsDesktopWindow = (dynamic_cast(Window()) != 0); if (fIsDesktopWindow) AddFilter(new TPoseViewFilter(this)); @@ -959,7 +957,7 @@ BPoseView::AttachedToWindow() sFontHeight = sFontInfo.ascent + sFontInfo.descent + sFontInfo.leading; } - if (TTracker *app = dynamic_cast(be_app)) { + if (TTracker* app = dynamic_cast(be_app)) { app->Lock(); app->StartWatching(this, kShowSelectionWhenInactiveChanged); app->StartWatching(this, kTransparentSelectionChanged); @@ -995,7 +993,7 @@ BPoseView::SetIconPoseHeight() void -BPoseView::GetLayoutInfo(uint32 mode, BPoint *grid, BPoint *offset) const +BPoseView::GetLayoutInfo(uint32 mode, BPoint* grid, BPoint* offset) const { switch (mode) { case kMiniIconMode: @@ -1026,7 +1024,7 @@ BPoseView::MakeFocus(bool focused) _inherited::MakeFocus(focused); if (inval) { - BackgroundView *view = dynamic_cast(Parent()); + BackgroundView* view = dynamic_cast(Parent()); if (view) view->PoseViewFocused(focused); } @@ -1048,7 +1046,7 @@ BPoseView::WindowActivated(bool activated) void -BPoseView::SetActivePose(BPose *pose) +BPoseView::SetActivePose(BPose* pose) { if (pose != ActivePose()) { CommitActivePose(); @@ -1072,8 +1070,8 @@ BPoseView::CommitActivePose(bool saveChanges) } -EntryListBase * -BPoseView::InitDirentIterator(const entry_ref *ref) +EntryListBase* +BPoseView::InitDirentIterator(const entry_ref* ref) { // set up a directory iteration Model sourceModel(ref, false, true); @@ -1083,10 +1081,10 @@ BPoseView::InitDirentIterator(const entry_ref *ref) ASSERT(!sourceModel.IsQuery()); ASSERT(sourceModel.Node()); - BDirectory *directory = dynamic_cast(sourceModel.Node()); + BDirectory* directory = dynamic_cast(sourceModel.Node()); ASSERT(directory); - EntryListBase *result = new CachedDirectoryEntryList(*directory); + EntryListBase* result = new CachedDirectoryEntryList(*directory); if (result->Rewind() != B_OK) { delete result; @@ -1113,14 +1111,14 @@ BPoseView::WatchNewNodeMask() status_t -BPoseView::WatchNewNode(const node_ref *item) +BPoseView::WatchNewNode(const node_ref* item) { return WatchNewNode(item, WatchNewNodeMask(), BMessenger(this)); } status_t -BPoseView::WatchNewNode(const node_ref *item, uint32 mask, BMessenger messenger) +BPoseView::WatchNewNode(const node_ref* item, uint32 mask, BMessenger messenger) { status_t result = TTracker::WatchNode(item, mask, messenger); @@ -1147,7 +1145,7 @@ BPoseView::IsValidAddPosesThread(thread_id currentThread) const void -BPoseView::AddPoses(Model *model) +BPoseView::AddPoses(Model* model) { // if model is zero, PoseView has other means of iterating through all // the entries that it adds @@ -1164,7 +1162,7 @@ BPoseView::AddPoses(Model *model) ShowBarberPole(); - AddPosesParams *params = new AddPosesParams(); + AddPosesParams* params = new AddPosesParams(); BMessenger tmp(this); params->target = tmp; @@ -1202,7 +1200,7 @@ class AutoLockingMessenger { ~AutoLockingMessenger() { if (hasLock) { - BLooper *looper; + BLooper* looper; messenger.Target(&looper); ASSERT(looper->IsLocked()); looper->Unlock(); @@ -1225,7 +1223,7 @@ class AutoLockingMessenger { void Unlock() { if (hasLock) { - BLooper *looper; + BLooper* looper; messenger.Target(&looper); ASSERT(looper); looper->Unlock(); @@ -1233,14 +1231,14 @@ class AutoLockingMessenger { } } - BLooper *Looper() const + BLooper* Looper() const { - BLooper *looper; + BLooper* looper; messenger.Target(&looper); return looper; } - BHandler *Handler() const + BHandler* Handler() const { ASSERT(hasLock); return messenger.Target(0); @@ -1261,12 +1259,12 @@ class failToLock { /* exception in AddPoses*/ }; status_t -BPoseView::AddPosesTask(void *castToParams) +BPoseView::AddPosesTask(void* castToParams) { // AddPosesTask reeds a bunch of models and passes them off to // the pose placing and drawing routine. // - AddPosesParams *params = (AddPosesParams *)castToParams; + AddPosesParams* params = (AddPosesParams*)castToParams; BMessenger target(params->target); entry_ref ref(params->ref); @@ -1279,23 +1277,23 @@ BPoseView::AddPosesTask(void *castToParams) thread_id threadID = find_thread(NULL); - BPoseView *view = dynamic_cast(lock.Handler()); + BPoseView* view = dynamic_cast(lock.Handler()); ASSERT(view); - // BWindow *window = dynamic_cast(lock.Looper()); - ASSERT(dynamic_cast(lock.Looper())); + // BWindow* window = dynamic_cast(lock.Looper()); + ASSERT(dynamic_cast(lock.Looper())); // allocate the iterator we will use for adding poses; this // can be a directory or any other collection of entry_refs, such // as results of a query; subclasses override this to provide // other than standard directory iterations - EntryListBase *container = view->InitDirentIterator(&ref); + EntryListBase* container = view->InitDirentIterator(&ref); if (!container) { view->HideBarberPole(); return B_ERROR; } - AddPosesResult *posesResult = new AddPosesResult; + AddPosesResult* posesResult = new AddPosesResult; posesResult->fCount = 0; int32 modelChunkIndex = 0; bigtime_t nextChunkTime = 0; @@ -1305,7 +1303,7 @@ BPoseView::AddPosesTask(void *castToParams) #if DEBUG for (int32 index = 0; index < kMaxAddPosesChunk; index++) - posesResult->fModels[index] = (Model *)0xdeadbeef; + posesResult->fModels[index] = (Model*)0xdeadbeef; #endif try { @@ -1314,8 +1312,8 @@ BPoseView::AddPosesTask(void *castToParams) status_t result = B_OK; char entBuf[1024]; - dirent *eptr = (dirent *)entBuf; - Model *model = 0; + dirent* eptr = (dirent*)entBuf; + Model* model = 0; node_ref dirNode; node_ref itemNode; @@ -1517,9 +1515,9 @@ BPoseView::RemoveRootPoses() int32 index; int32 count = fPoseList->CountItems(); for (index = 0; index < count;) { - BPose *pose = fPoseList->ItemAt(index); + BPose* pose = fPoseList->ItemAt(index); if (pose) { - Model *model = pose->TargetModel(); + Model* model = pose->TargetModel(); if (model) { if (model->IsVolume()) { DeletePose(model->NodeRef()); @@ -1563,7 +1561,7 @@ BPoseView::AddTrashPoses() void BPoseView::AddPosesCompleted() { - BContainerWindow *containerWindow = ContainerWindow(); + BContainerWindow* containerWindow = ContainerWindow(); if (containerWindow) containerWindow->AddMimeTypesToMenu(); @@ -1587,7 +1585,7 @@ BPoseView::AddPosesCompleted() void -BPoseView::CreateVolumePose(BVolume *volume, bool watchIndividually) +BPoseView::CreateVolumePose(BVolume* volume, bool watchIndividually) { if (volume->InitCheck() != B_OK || !volume->IsPersistent()) { // We never want to create poses for those volumes; the file @@ -1610,7 +1608,7 @@ BPoseView::CreateVolumePose(BVolume *volume, bool watchIndividually) dirNode.device = ref.device; dirNode.node = ref.directory; - BPose *pose = EntryCreated(&dirNode, &itemNode, ref.name, 0); + BPose* pose = EntryCreated(&dirNode, &itemNode, ref.name, 0); if (pose && watchIndividually) { // make sure volume names still get watched, even though @@ -1633,7 +1631,7 @@ BPoseView::CreateTrashPose() if (FSGetTrashDir(&trash, volume.Device()) == B_OK && trash.GetEntry(&entry) == B_OK && entry.GetNodeRef(&ref) == B_OK) { WatchNewNode(&ref); - Model *model = new Model(&entry); + Model* model = new Model(&entry); PoseInfo info; ReadPoseInfo(model, &info); CreatePose(model, &info, false, NULL, NULL, true); @@ -1642,11 +1640,11 @@ BPoseView::CreateTrashPose() } -BPose * -BPoseView::CreatePose(Model *model, PoseInfo *poseInfo, bool insertionSort, - int32 *indexPtr, BRect *boundsPtr, bool forceDraw) +BPose* +BPoseView::CreatePose(Model* model, PoseInfo* poseInfo, bool insertionSort, + int32* indexPtr, BRect* boundsPtr, bool forceDraw) { - BPose *result; + BPose* result; CreatePoses(&model, poseInfo, 1, &result, insertionSort, indexPtr, boundsPtr, forceDraw); return result; @@ -1675,15 +1673,15 @@ BPoseView::FinishPendingScroll(float &listViewScrollBy, BRect srcRect) bool -BPoseView::AddPosesThreadValid(const entry_ref *ref) const +BPoseView::AddPosesThreadValid(const entry_ref* ref) const { return *(TargetModel()->EntryRef()) == *ref || ContainerWindow()->IsTrash(); } void -BPoseView::AddPoseToList(PoseList *list, bool visibleList, bool insertionSort, - BPose *pose, BRect &viewBounds, float &listViewScrollBy, bool forceDraw, int32 *indexPtr) +BPoseView::AddPoseToList(PoseList* list, bool visibleList, bool insertionSort, + BPose* pose, BRect &viewBounds, float &listViewScrollBy, bool forceDraw, int32* indexPtr) { int32 poseIndex = list->CountItems(); @@ -1770,9 +1768,9 @@ BPoseView::AddPoseToList(PoseList *list, bool visibleList, bool insertionSort, void -BPoseView::CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count, - BPose **resultingPoses, bool insertionSort, int32 *lastPoseIndexPtr, - BRect *boundsPtr, bool forceDraw) +BPoseView::CreatePoses(Model** models, PoseInfo* poseInfoArray, int32 count, + BPose** resultingPoses, bool insertionSort, int32* lastPoseIndexPtr, + BRect* boundsPtr, bool forceDraw) { // were we passed the bounds of the view? BRect viewBounds; @@ -1787,7 +1785,7 @@ BPoseView::CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count, uint32 clipboardMode = 0; float listViewScrollBy = 0; for (int32 modelIndex = 0; modelIndex < count; modelIndex++) { - Model *model = models[modelIndex]; + Model* model = models[modelIndex]; // pose adopts model and deletes it when done if (fInsertedNodes.find(*(model->NodeRef())) != fInsertedNodes.end() @@ -1807,8 +1805,8 @@ BPoseView::CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count, model->OpenNode(); ASSERT(model->IsNodeOpen()); - PoseInfo *poseInfo = &poseInfoArray[modelIndex]; - BPose *pose = new BPose(model, this, clipboardMode); + PoseInfo* poseInfo = &poseInfoArray[modelIndex]; + BPose* pose = new BPose(model, this, clipboardMode); if (resultingPoses) resultingPoses[modelIndex] = pose; @@ -1901,14 +1899,14 @@ BPoseView::CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count, bool -BPoseView::PoseVisible(const Model *model, const PoseInfo *poseInfo) +BPoseView::PoseVisible(const Model* model, const PoseInfo* poseInfo) { return !poseInfo->fInvisible; } bool -BPoseView::ShouldShowPose(const Model *model, const PoseInfo *poseInfo) +BPoseView::ShouldShowPose(const Model* model, const PoseInfo* poseInfo) { if (!PoseVisible(model, poseInfo)) return false; @@ -1925,7 +1923,7 @@ BPoseView::ShouldShowPose(const Model *model, const PoseInfo *poseInfo) } -const char * +const char* BPoseView::MimeTypeAt(int32 index) { if (fMimeTypeListIsDirty) @@ -1946,7 +1944,7 @@ BPoseView::CountMimeTypes() void -BPoseView::AddMimeType(const char *mimeType) +BPoseView::AddMimeType(const char* mimeType) { int32 count = fMimeTypeList->CountItems(); for (int32 index = 0; index < count; index++) { @@ -1965,7 +1963,7 @@ BPoseView::RefreshMimeTypeList() fMimeTypeListIsDirty = false; for (int32 index = 0;; index++) { - BPose *pose = PoseAtIndex(index); + BPose* pose = PoseAtIndex(index); if (!pose) break; @@ -1976,8 +1974,8 @@ BPoseView::RefreshMimeTypeList() void -BPoseView::InsertPoseAfter(BPose *pose, int32 *index, int32 orientation, - BRect *invalidRect) +BPoseView::InsertPoseAfter(BPose* pose, int32* index, int32 orientation, + BRect* invalidRect) { if (orientation == kInsertAfter) { // TODO: get rid of this @@ -2005,9 +2003,9 @@ void BPoseView::DisableScrollBars() { if (fHScrollBar) - fHScrollBar->SetTarget((BView *)NULL); + fHScrollBar->SetTarget((BView*)NULL); if (fVScrollBar) - fVScrollBar->SetTarget((BView *)NULL); + fVScrollBar->SetTarget((BView*)NULL); } @@ -2087,7 +2085,7 @@ BPoseView::AddCountView() void -BPoseView::MessageReceived(BMessage *message) +BPoseView::MessageReceived(BMessage* message) { if (message->WasDropped() && HandleMessageDropped(message)) return; @@ -2098,10 +2096,10 @@ BPoseView::MessageReceived(BMessage *message) switch (message->what) { case kAddNewPoses: { - AddPosesResult *currentPoses; + AddPosesResult* currentPoses; entry_ref ref; message->FindPointer("currentPoses", - reinterpret_cast(¤tPoses)); + reinterpret_cast(¤tPoses)); message->FindRef("ref", &ref); // check if CreatePoses should be called (abort if dir has been @@ -2196,7 +2194,7 @@ BPoseView::MessageReceived(BMessage *message) case B_SELECT_ALL: { // Select widget if there is an active one - BTextWidget *widget; + BTextWidget* widget; if (ActivePose() && ((widget = ActivePose()->ActiveWidget())) != 0) widget->SelectAll(this); else @@ -2347,7 +2345,7 @@ BPoseView::MessageReceived(BMessage *message) if (ActivePose()) break; - BPose *pose = fSelectionList->FirstItem(); + BPose* pose = fSelectionList->FirstItem(); if (pose) { pose->EditFirstWidget(BPoint(0, CurrentPoseList()->IndexOf(pose) * fListElemHeight), this); @@ -2362,7 +2360,7 @@ BPoseView::MessageReceived(BMessage *message) case kCopyAttributes: if (be_clipboard->Lock()) { be_clipboard->Clear(); - BMessage *data = be_clipboard->Data(); + BMessage* data = be_clipboard->Data(); if (data != NULL) { // copy attributes to the clipboard BMessage state; @@ -2380,16 +2378,16 @@ BPoseView::MessageReceived(BMessage *message) break; case kPasteAttributes: if (be_clipboard->Lock()) { - BMessage *data = be_clipboard->Data(); + BMessage* data = be_clipboard->Data(); if (data != NULL) { // find the attributes in the clipboard - const void *buffer; + const void* buffer; ssize_t size; if (data->FindData("application/tracker-columns", B_MIME_TYPE, &buffer, &size) == B_OK) { BMessage state; - if (state.Unflatten((const char *)buffer) == B_OK) { + if (state.Unflatten((const char*)buffer) == B_OK) { // remove all current columns (one always stays) - BColumn *old; + BColumn* old; while ((old = ColumnAt(0)) != NULL) { if (!RemoveColumn(old, false)) break; @@ -2397,7 +2395,7 @@ BPoseView::MessageReceived(BMessage *message) // add new columns for (int32 index = 0; ; index++) { - BColumn *column = BColumn::InstantiateFromMessage(state, index); + BColumn* column = BColumn::InstantiateFromMessage(state, index); if (!column) break; AddColumn(column); @@ -2407,7 +2405,7 @@ BPoseView::MessageReceived(BMessage *message) RemoveColumn(old, false); // set sorting mode - BViewState *viewState = BViewState::InstantiateFromMessage(state); + BViewState* viewState = BViewState::InstantiateFromMessage(state); if (viewState != NULL) { SetPrimarySort(viewState->PrimarySort()); SetSecondarySort(viewState->SecondarySort()); @@ -2571,12 +2569,12 @@ BPoseView::MessageReceived(BMessage *message) bool -BPoseView::RemoveColumn(BColumn *columnToRemove, bool runAlert) +BPoseView::RemoveColumn(BColumn* columnToRemove, bool runAlert) { // make sure last column is not removed if (CountColumns() == 1) { if (runAlert) { - BAlert *alert = new BAlert("", + BAlert* alert = new BAlert("", B_TRANSLATE("You must have at least one attribute showing."), B_TRANSLATE("Cancel"), 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetShortcut(0, B_ESCAPE); @@ -2601,7 +2599,7 @@ BPoseView::RemoveColumn(BColumn *columnToRemove, bool runAlert) count = CountColumns(); for (int32 index = columnIndex; index < count; index++) { - BColumn *column = ColumnAt(index); + BColumn* column = ColumnAt(index); column->SetOffset(column->Offset() - (attrWidth + kTitleColumnExtraMargin)); } @@ -2616,7 +2614,7 @@ BPoseView::RemoveColumn(BColumn *columnToRemove, bool runAlert) bool anyDateAttributesLeft = false; for (int32 i = 0; iAttrType() == B_TIME_TYPE) anyDateAttributesLeft = true; @@ -2636,7 +2634,7 @@ BPoseView::RemoveColumn(BColumn *columnToRemove, bool runAlert) bool -BPoseView::AddColumn(BColumn *newColumn, const BColumn *after) +BPoseView::AddColumn(BColumn* newColumn, const BColumn* after) { if (!after) after = LastColumn(); @@ -2659,13 +2657,13 @@ BPoseView::AddColumn(BColumn *newColumn, const BColumn *after) BRect rect(Bounds()); // add widget for all visible poses - PoseList *poseList = CurrentPoseList(); + PoseList* poseList = CurrentPoseList(); int32 count = poseList->CountItems(); int32 startIndex = (int32)(rect.top / fListElemHeight); - BPoint loc(0, startIndex * fListElemHeight); + BPoint loc(0, startIndex* fListElemHeight); for (int32 index = startIndex; index < count; index++) { - BPose *pose = poseList->ItemAt(index); + BPose* pose = poseList->ItemAt(index); if (!pose->WidgetFor(newColumn->AttrHash())) pose->AddWidget(this, newColumn); @@ -2680,7 +2678,7 @@ BPoseView::AddColumn(BColumn *newColumn, const BColumn *after) count = CountColumns(); for (int32 index = afterColumnIndex + 2; index < count; index++) { - BColumn *column = ColumnAt(index); + BColumn* column = ColumnAt(index); ASSERT(newColumn != column); column->SetOffset(column->Offset() + (attrWidth + kTitleColumnExtraMargin)); @@ -2702,30 +2700,30 @@ BPoseView::AddColumn(BColumn *newColumn, const BColumn *after) void -BPoseView::HandleAttrMenuItemSelected(BMessage *message) +BPoseView::HandleAttrMenuItemSelected(BMessage* message) { // see if source was a menu item - BMenuItem *item; - if (message->FindPointer("source", (void **)&item) != B_OK) + BMenuItem* item; + if (message->FindPointer("source", (void**)&item) != B_OK) item = NULL; // find out which column was selected uint32 attrHash; - if (message->FindInt32("attr_hash", (int32 *)&attrHash) != B_OK) + if (message->FindInt32("attr_hash", (int32*)&attrHash) != B_OK) return; - BColumn *column = ColumnFor(attrHash); + BColumn* column = ColumnFor(attrHash); if (column) { RemoveColumn(column, true); return; } else { // collect info about selected attribute - const char *attrName; + const char* attrName; if (message->FindString("attr_name", &attrName) != B_OK) return; uint32 attrType; - if (message->FindInt32("attr_type", (int32 *)&attrType) != B_OK) + if (message->FindInt32("attr_type", (int32*)&attrType) != B_OK) return; float attrWidth; @@ -2733,7 +2731,7 @@ BPoseView::HandleAttrMenuItemSelected(BMessage *message) return; alignment attrAlign; - if (message->FindInt32("attr_align", (int32 *)&attrAlign) != B_OK) + if (message->FindInt32("attr_align", (int32*)&attrAlign) != B_OK) return; bool isEditable; @@ -2760,7 +2758,7 @@ const int32 kSanePoseLocation = 50000; void -BPoseView::ReadPoseInfo(Model *model, PoseInfo *poseInfo) +BPoseView::ReadPoseInfo(Model* model, PoseInfo* poseInfo) { BModelOpener opener(model); if (!model->Node()) @@ -2776,9 +2774,9 @@ BPoseView::ReadPoseInfo(Model *model, PoseInfo *poseInfo) if (model->IsRoot() || isTrash) { BDirectory dir; if (FSGetDeskDir(&dir) == B_OK) { - const char *poseInfoAttr = isTrash ? kAttrTrashPoseInfo + const char* poseInfoAttr = isTrash ? kAttrTrashPoseInfo : kAttrDisksPoseInfo; - const char *poseInfoAttrForeign = isTrash ? kAttrTrashPoseInfoForeign + const char* poseInfoAttrForeign = isTrash ? kAttrTrashPoseInfoForeign : kAttrDisksPoseInfoForeign; result = ReadAttr(&dir, poseInfoAttr, poseInfoAttrForeign, B_RAW_TYPE, 0, poseInfo, sizeof(*poseInfo), &PoseInfo::EndianSwap); @@ -2805,7 +2803,7 @@ BPoseView::ReadPoseInfo(Model *model, PoseInfo *poseInfo) if (ViewMode() == kListMode) break; - const StatStruct *stat = model->StatBuf(); + const StatStruct* stat = model->StatBuf(); if (stat->st_crtime < now - 5 || stat->st_crtime > now) break; @@ -2832,8 +2830,8 @@ BPoseView::ReadPoseInfo(Model *model, PoseInfo *poseInfo) } -ExtendedPoseInfo * -BPoseView::ReadExtendedPoseInfo(Model *model) +ExtendedPoseInfo* +BPoseView::ReadExtendedPoseInfo(Model* model) { BModelOpener opener(model); if (!model->Node()) @@ -2841,8 +2839,8 @@ BPoseView::ReadExtendedPoseInfo(Model *model) ReadAttrResult result = kReadAttrFailed; - const char *extendedPoseInfoAttrName; - const char *extendedPoseInfoAttrForeignName; + const char* extendedPoseInfoAttrName; + const char* extendedPoseInfoAttrForeignName; // special case the "root" disks icon if (model->IsRoot()) { @@ -2865,8 +2863,8 @@ BPoseView::ReadExtendedPoseInfo(Model *model) if (result == kReadAttrFailed) return NULL; - char *buffer = new char[ExtendedPoseInfo::SizeWithHeadroom(size)]; - ExtendedPoseInfo *poseInfo = reinterpret_cast(buffer); + char* buffer = new char[ExtendedPoseInfo::SizeWithHeadroom(size)]; + ExtendedPoseInfo* poseInfo = reinterpret_cast(buffer); result = ReadAttr(model->Node(), extendedPoseInfoAttrName, extendedPoseInfoAttrForeignName, @@ -2927,7 +2925,7 @@ BPoseView::SetViewMode(uint32 newMode) } // toggle view layout between listmode and non-listmode, if necessary - BContainerWindow *window = ContainerWindow(); + BContainerWindow* window = ContainerWindow(); if (oldMode == kListMode) { if (fFiltering) ClearFilter(); @@ -2979,7 +2977,7 @@ BPoseView::SetViewMode(uint32 newMode) if (newMode != kListMode) { int32 count = fPoseList->CountItems(); for (int32 index = 0; index < count; index++) { - BPose *pose = fPoseList->ItemAt(index); + BPose* pose = fPoseList->ItemAt(index); if (pose->HasLocation() == false) { newPoseList.AddItem(pose); } else if (checkLocations && !IsValidLocation(pose)) { @@ -3018,7 +3016,7 @@ BPoseView::SetViewMode(uint32 newMode) ResetPosePlacementHint(); int32 count = newPoseList.CountItems(); for (int32 index = 0; index < count; index++) { - BPose *pose = newPoseList.ItemAt(index); + BPose* pose = newPoseList.ItemAt(index); PlacePose(pose, bounds); AddToVSList(pose); } @@ -3035,7 +3033,7 @@ BPoseView::SetViewMode(uint32 newMode) void -BPoseView::MapToNewIconMode(BPose *pose, BPoint oldGrid, BPoint oldOffset) +BPoseView::MapToNewIconMode(BPose* pose, BPoint oldGrid, BPoint oldOffset) { BPoint delta; BPoint poseLoc; @@ -3078,12 +3076,12 @@ void BPoseView::SetPosesClipboardMode(uint32 clipboardMode) { if (ViewMode() == kListMode) { - PoseList *poseList = CurrentPoseList(); + PoseList* poseList = CurrentPoseList(); int32 count = poseList->CountItems(); BPoint loc(0,0); for (int32 index = 0; index < count; index++) { - BPose *pose = poseList->ItemAt(index); + BPose* pose = poseList->ItemAt(index); if (pose->ClipboardMode() != clipboardMode) { pose->SetClipboardMode(clipboardMode); Invalidate(pose->CalcRect(loc, this, false)); @@ -3093,7 +3091,7 @@ BPoseView::SetPosesClipboardMode(uint32 clipboardMode) } else { int32 count = fPoseList->CountItems(); for (int32 index = 0; index < count; index++) { - BPose *pose = fPoseList->ItemAt(index); + BPose* pose = fPoseList->ItemAt(index); if (pose->ClipboardMode() != clipboardMode) { pose->SetClipboardMode(clipboardMode); BRect poseRect(pose->CalcRect(this)); @@ -3105,7 +3103,7 @@ BPoseView::SetPosesClipboardMode(uint32 clipboardMode) void -BPoseView::UpdatePosesClipboardModeFromClipboard(BMessage *clipboardReport) +BPoseView::UpdatePosesClipboardModeFromClipboard(BMessage* clipboardReport) { CommitActivePose(); fSelectionPivotPose = NULL; @@ -3123,7 +3121,7 @@ BPoseView::UpdatePosesClipboardModeFromClipboard(BMessage *clipboardReport) // clear all poses int32 count = fPoseList->CountItems(); for (int32 index = 0; index < count; index++) { - BPose *pose = fPoseList->ItemAt(index); + BPose* pose = fPoseList->ItemAt(index); pose->Select(false); pose->SetClipboardMode(0); } @@ -3137,11 +3135,11 @@ BPoseView::UpdatePosesClipboardModeFromClipboard(BMessage *clipboardReport) bool hasPosesInClipboard = false; int32 foundNodeIndex = 0; - TClipboardNodeRef *clipNode = NULL; + TClipboardNodeRef* clipNode = NULL; ssize_t size; for (int32 index = 0; clipboardReport->FindData("tcnode", T_CLIPBOARD_NODE, index, - (const void **)&clipNode, &size) == B_OK; index++) { - BPose *pose = fPoseList->FindPose(&clipNode->node, &foundNodeIndex); + (const void**)&clipNode, &size) == B_OK; index++) { + BPose* pose = fPoseList->FindPose(&clipNode->node, &foundNodeIndex); if (pose == NULL) continue; @@ -3187,7 +3185,7 @@ BPoseView::UpdatePosesClipboardModeFromClipboard(BMessage *clipboardReport) void -BPoseView::PlaceFolder(const entry_ref *ref, const BMessage *message) +BPoseView::PlaceFolder(const entry_ref* ref, const BMessage* message) { BNode node(ref); BPoint location; @@ -3216,7 +3214,7 @@ BPoseView::PlaceFolder(const entry_ref *ref, const BMessage *message) void -BPoseView::NewFileFromTemplate(const BMessage *message) +BPoseView::NewFileFromTemplate(const BMessage* message) { ASSERT(TargetModel()); @@ -3248,7 +3246,7 @@ BPoseView::NewFileFromTemplate(const BMessage *message) BFile destFile(&destDir, fileName, B_READ_WRITE | B_CREATE_FILE); // copy the data from the template file - char *buffer = new char[1024]; + char* buffer = new char[1024]; ssize_t result; do { result = srcFile.Read(buffer, 1024); @@ -3277,7 +3275,7 @@ BPoseView::NewFileFromTemplate(const BMessage *message) // start renaming the entry int32 index; - BPose *pose = EntryCreated(TargetModel()->NodeRef(), &destNodeRef, + BPose* pose = EntryCreated(TargetModel()->NodeRef(), &destNodeRef, destEntryRef.name, &index); if (pose) { @@ -3291,7 +3289,7 @@ BPoseView::NewFileFromTemplate(const BMessage *message) void -BPoseView::NewFolder(const BMessage *message) +BPoseView::NewFolder(const BMessage* message) { ASSERT(TargetModel()); @@ -3304,7 +3302,7 @@ BPoseView::NewFolder(const BMessage *message) PlaceFolder(&ref, message); int32 index; - BPose *pose = EntryCreated(TargetModel()->NodeRef(), &nodeRef, ref.name, &index); + BPose* pose = EntryCreated(TargetModel()->NodeRef(), &nodeRef, ref.name, &index); if (pose) { UpdateScrollRange(); CommitActivePose(); @@ -3321,7 +3319,7 @@ BPoseView::Cleanup(bool doAll) if (ViewMode() == kListMode) return; - BContainerWindow *window = ContainerWindow(); + BContainerWindow* window = ContainerWindow(); if (!window) return; @@ -3344,7 +3342,7 @@ BPoseView::Cleanup(bool doAll) fVSPoseList->MakeEmpty(); int32 count = fPoseList->CountItems(); for (int32 index = 0; index < count; index++) { - BPose *pose = fPoseList->ItemAt(index); + BPose* pose = fPoseList->ItemAt(index); PlacePose(pose, viewBounds); AddToVSList(pose); } @@ -3370,7 +3368,7 @@ BPoseView::Cleanup(bool doAll) BRect viewBounds(Bounds()); int32 count = fPoseList->CountItems(); for (int32 index = 0; index < count; index++) { - BPose *pose = fPoseList->ItemAt(index); + BPose* pose = fPoseList->ItemAt(index); BPoint location(pose->Location(this)); BPoint newLocation(PinToGrid(location, fGrid, fOffset)); @@ -3406,7 +3404,7 @@ BPoseView::Cleanup(bool doAll) void -BPoseView::PlacePose(BPose *pose, BRect &viewBounds) +BPoseView::PlacePose(BPose* pose, BRect &viewBounds) { // move pose to probable location pose->SetLocation(fHintLocation, this); @@ -3443,7 +3441,7 @@ BPoseView::PlacePose(BPose *pose, BRect &viewBounds) bool -BPoseView::IsValidLocation(const BPose *pose) +BPoseView::IsValidLocation(const BPose* pose) { if (!IsDesktopWindow()) return true; @@ -3512,7 +3510,7 @@ BPoseView::CheckAutoPlacedPoses() int32 count = fPoseList->CountItems(); for (int32 index = 0; index < count; index++) { - BPose *pose = fPoseList->ItemAt(index); + BPose* pose = fPoseList->ItemAt(index); if (pose->WasAutoPlaced()) { RemoveFromVSList(pose); fHintLocation = pose->Location(this); @@ -3532,7 +3530,7 @@ BPoseView::CheckAutoPlacedPoses() void -BPoseView::CheckPoseVisibility(BRect *newFrame) +BPoseView::CheckPoseVisibility(BRect* newFrame) { bool desktop = IsDesktopWindow() && newFrame != 0; @@ -3549,15 +3547,15 @@ BPoseView::CheckPoseVisibility(BRect *newFrame) int32 count = fPoseList->CountItems(); for (int32 index = 0; index < count; index++) { - BPose *pose = fPoseList->ItemAt(index); + BPose* pose = fPoseList->ItemAt(index); BPoint newLocation(pose->Location(this)); bool locationNeedsUpdating = false; if (desktop) { // we just switched screen resolution, pick up the right // icon locations for the new resolution - Model *model = pose->TargetModel(); - ExtendedPoseInfo *info = ReadExtendedPoseInfo(model); + Model* model = pose->TargetModel(); + ExtendedPoseInfo* info = ReadExtendedPoseInfo(model); if (info && info->HasLocationForFrame(deskFrame)) { BPoint locationForFrame = info->LocationForFrame(deskFrame); if (locationForFrame != newLocation) { @@ -3571,7 +3569,7 @@ BPoseView::CheckPoseVisibility(BRect *newFrame) // set the new location } } - delete [] (char *)info; + delete [] (char*)info; // TODO: fix up this mess } @@ -3638,7 +3636,7 @@ BPoseView::SlotOccupied(BRect poseRect, BRect viewBounds) const void -BPoseView::NextSlot(BPose *pose, BRect &poseRect, BRect viewBounds) +BPoseView::NextSlot(BPose* pose, BRect &poseRect, BRect viewBounds) { // move to next slot poseRect.OffsetBy(fGrid.x, 0); @@ -3699,7 +3697,7 @@ BPoseView::FirstIndexAtOrBelow(int32 y, bool constrainIndex) const void -BPoseView::AddToVSList(BPose *pose) +BPoseView::AddToVSList(BPose* pose) { int32 index = FirstIndexAtOrBelow((int32)pose->Location(this).y, false); fVSPoseList->AddItem(pose, index); @@ -3707,7 +3705,7 @@ BPoseView::AddToVSList(BPose *pose) int32 -BPoseView::RemoveFromVSList(const BPose *pose) +BPoseView::RemoveFromVSList(const BPose* pose) { //int32 index = FirstIndexAtOrBelow((int32)pose->Location(this).y); // This optimisation is buggy and the index returned can be greater @@ -3719,7 +3717,7 @@ BPoseView::RemoveFromVSList(const BPose *pose) int32 count = fVSPoseList->CountItems(); for (; index < count; index++) { - BPose *matchingPose = fVSPoseList->ItemAt(index); + BPose* matchingPose = fVSPoseList->ItemAt(index); ASSERT(matchingPose); if (!matchingPose) return -1; @@ -3779,10 +3777,10 @@ BPoseView::SelectPoses(int32 start, int32 end) BPoint loc(0, start * fListElemHeight); BRect bounds(Bounds()); - PoseList *poseList = CurrentPoseList(); + PoseList* poseList = CurrentPoseList(); int32 count = poseList->CountItems(); for (int32 index = start; index < end && index < count; index++) { - BPose *pose = poseList->ItemAt(index); + BPose* pose = poseList->ItemAt(index); fSelectionList->AddItem(pose); if (index == start) fSelectionPivotPose = pose; @@ -3805,7 +3803,7 @@ BPoseView::SelectPoses(int32 start, int32 end) void -BPoseView::ScrollIntoView(BPose *pose, int32 index) +BPoseView::ScrollIntoView(BPose* pose, int32 index) { ScrollIntoView(CalcPoseRect(pose, index, true)); } @@ -3830,7 +3828,7 @@ BPoseView::ScrollIntoView(BRect poseRect) void -BPoseView::SelectPose(BPose *pose, int32 index, bool scrollIntoView) +BPoseView::SelectPose(BPose* pose, int32 index, bool scrollIntoView) { if (!pose || fSelectionList->CountItems() > 1 || !pose->IsSelected()) ClearSelection(); @@ -3840,7 +3838,7 @@ BPoseView::SelectPose(BPose *pose, int32 index, bool scrollIntoView) void -BPoseView::AddPoseToSelection(BPose *pose, int32 index, bool scrollIntoView) +BPoseView::AddPoseToSelection(BPose* pose, int32 index, bool scrollIntoView) { // TODO: need to check if pose is member of selection list if (pose && !pose->IsSelected()) { @@ -3860,7 +3858,7 @@ BPoseView::AddPoseToSelection(BPose *pose, int32 index, bool scrollIntoView) void -BPoseView::RemovePoseFromSelection(BPose *pose) +BPoseView::RemovePoseFromSelection(BPose* pose) { if (fSelectionPivotPose == pose) fSelectionPivotPose = NULL; @@ -3875,7 +3873,7 @@ BPoseView::RemovePoseFromSelection(BPose *pose) if (ViewMode() == kListMode) { // TODO: need a simple call to CalcRect that works both in listView and // icon view modes without the need for an index/pos - PoseList *poseList = CurrentPoseList(); + PoseList* poseList = CurrentPoseList(); int32 count = poseList->CountItems(); BPoint loc(0, 0); for (int32 index = 0; index < count; index++) { @@ -3894,21 +3892,21 @@ BPoseView::RemovePoseFromSelection(BPose *pose) bool -BPoseView::EachItemInDraggedSelection(const BMessage *message, - bool (*func)(BPose *, BPoseView *, void *), BPoseView *poseView, void *passThru) +BPoseView::EachItemInDraggedSelection(const BMessage* message, + bool (*func)(BPose*, BPoseView*, void*), BPoseView* poseView, void* passThru) { - BContainerWindow *srcWindow; - message->FindPointer("src_window", (void **)&srcWindow); + BContainerWindow* srcWindow; + message->FindPointer("src_window", (void**)&srcWindow); AutoLock lock(srcWindow); if (!lock) return false; - PoseList *selectionList = srcWindow->PoseView()->SelectionList(); + PoseList* selectionList = srcWindow->PoseView()->SelectionList(); int32 count = selectionList->CountItems(); for (int32 index = 0; index < count; index++) { - BPose *pose = selectionList->ItemAt(index); + BPose* pose = selectionList->ItemAt(index); if (func(pose, poseView, passThru)) // early iteration termination return true; @@ -3918,14 +3916,14 @@ BPoseView::EachItemInDraggedSelection(const BMessage *message, static bool -ContainsOne(BString *string, const char *matchString) +ContainsOne(BString* string, const char* matchString) { return strcmp(string->String(), matchString) == 0; } bool -BPoseView::FindDragNDropAction(const BMessage *dragMessage, bool &canCopy, +BPoseView::FindDragNDropAction(const BMessage* dragMessage, bool &canCopy, bool &canMove, bool &canLink, bool &canErase) { canCopy = false; @@ -3961,15 +3959,15 @@ BPoseView::FindDragNDropAction(const BMessage *dragMessage, bool &canCopy, bool -BPoseView::CanTrashForeignDrag(const Model *targetModel) +BPoseView::CanTrashForeignDrag(const Model* targetModel) { return targetModel->IsTrash(); } bool -BPoseView::CanCopyOrMoveForeignDrag(const Model *targetModel, - const BMessage *dragMessage) +BPoseView::CanCopyOrMoveForeignDrag(const Model* targetModel, + const BMessage* dragMessage) { if (!targetModel->IsDirectory()) return false; @@ -3977,7 +3975,7 @@ BPoseView::CanCopyOrMoveForeignDrag(const Model *targetModel, // in order to handle a clipping file, the drag initiator must be able // do deal with B_FILE_MIME_TYPE for (int32 index = 0; ; index++) { - const char *type; + const char* type; if (dragMessage->FindString("be:types", index, &type) != B_OK) break; @@ -3990,7 +3988,7 @@ BPoseView::CanCopyOrMoveForeignDrag(const Model *targetModel, bool -BPoseView::CanHandleDragSelection(const Model *target, const BMessage *dragMessage, +BPoseView::CanHandleDragSelection(const Model* target, const BMessage* dragMessage, bool ignoreTypes) { if (ignoreTypes) @@ -3998,8 +3996,8 @@ BPoseView::CanHandleDragSelection(const Model *target, const BMessage *dragMessa ASSERT(dragMessage); - BContainerWindow *srcWindow; - dragMessage->FindPointer("src_window", (void **)&srcWindow); + BContainerWindow* srcWindow; + dragMessage->FindPointer("src_window", (void**)&srcWindow); if (!srcWindow) { // handle a foreign drag bool canCopy; @@ -4041,9 +4039,9 @@ BPoseView::CanHandleDragSelection(const Model *target, const BMessage *dragMessa AutoLock lock(srcWindow); if (!lock) return false; - BObjectList *mimeTypeList = srcWindow->PoseView()->MimeTypesInSelection(); + BObjectList* mimeTypeList = srcWindow->PoseView()->MimeTypesInSelection(); if (mimeTypeList->IsEmpty()) { - PoseList *selectionList = srcWindow->PoseView()->SelectionList(); + PoseList* selectionList = srcWindow->PoseView()->SelectionList(); if (!selectionList->IsEmpty()) { // no cached data yet, build the cache int32 count = selectionList->CountItems(); @@ -4064,8 +4062,8 @@ BPoseView::CanHandleDragSelection(const Model *target, const BMessage *dragMessa mime.GetType(mimeType); // add unique type string - if (!WhileEachListItem(mimeTypeList, ContainsOne, (const char *)mimeType)) { - BString *newMimeString = new BString(mimeType); + if (!WhileEachListItem(mimeTypeList, ContainsOne, (const char*)mimeType)) { + BString* newMimeString = new BString(mimeType); mimeTypeList->AddItem(newMimeString); } } @@ -4077,7 +4075,7 @@ BPoseView::CanHandleDragSelection(const Model *target, const BMessage *dragMessa void -BPoseView::TrySettingPoseLocation(BNode *node, BPoint point) +BPoseView::TrySettingPoseLocation(BNode* node, BPoint point) { if (ViewMode() == kListMode) return; @@ -4093,13 +4091,13 @@ BPoseView::TrySettingPoseLocation(BNode *node, BPoint point) status_t -BPoseView::CreateClippingFile(BPoseView *poseView, BFile &result, char *resultingName, - BDirectory *dir, BMessage *message, const char *fallbackName, +BPoseView::CreateClippingFile(BPoseView* poseView, BFile &result, char* resultingName, + BDirectory* dir, BMessage* message, const char* fallbackName, bool setLocation, BPoint dropPoint) { // build a file name // try picking it up from the message - const char *suggestedName; + const char* suggestedName; if (message && message->FindString("be:clip_name", &suggestedName) == B_OK) strncpy(resultingName, suggestedName, B_FILE_NAME_LENGTH - 1); else @@ -4120,8 +4118,8 @@ BPoseView::CreateClippingFile(BPoseView *poseView, BFile &result, char *resultin static int32 -RunMimeTypeDestinationMenu(const char *actionText, const BObjectList *types, - const BObjectList *specificItems, BPoint where) +RunMimeTypeDestinationMenu(const char* actionText, const BObjectList* types, + const BObjectList* specificItems, BPoint where) { int32 count; @@ -4133,12 +4131,12 @@ RunMimeTypeDestinationMenu(const char *actionText, const BObjectList *t if (!count) return 0; - BPopUpMenu *menu = new BPopUpMenu("create clipping"); + BPopUpMenu* menu = new BPopUpMenu("create clipping"); menu->SetFont(be_plain_font); for (int32 index = 0; index < count; index++) { - const char *embedTypeAs = NULL; + const char* embedTypeAs = NULL; char buffer[256]; if (types) { types->ItemAt(index)->String(); @@ -4177,7 +4175,7 @@ RunMimeTypeDestinationMenu(const char *actionText, const BObjectList *t menu->AddItem(new BMenuItem(B_TRANSLATE("Cancel"), 0)); int32 result = -1; - BMenuItem *resultingItem = menu->Go(where, false, true); + BMenuItem* resultingItem = menu->Go(where, false, true); if (resultingItem) { int32 index = menu->IndexOf(resultingItem); if (index < count) @@ -4191,7 +4189,7 @@ RunMimeTypeDestinationMenu(const char *actionText, const BObjectList *t bool -BPoseView::HandleMessageDropped(BMessage *message) +BPoseView::HandleMessageDropped(BMessage* message) { ASSERT(message->WasDropped()); @@ -4207,8 +4205,8 @@ BPoseView::HandleMessageDropped(BMessage *message) if (message->HasData("RGBColor", 'RGBC')) { // do not handle roColor-style drops here, pass them on to the desktop - if (dynamic_cast(Window())) - BMessenger((BHandler *)Window()).SendMessage(message); + if (dynamic_cast(Window())) + BMessenger((BHandler*)Window()).SendMessage(message); return true; } @@ -4225,9 +4223,9 @@ BPoseView::HandleMessageDropped(BMessage *message) // tenatively figure out the pose we dropped the file onto int32 index; - BPose *targetPose = FindPose(dropPt, &index); + BPose* targetPose = FindPose(dropPt, &index); Model tmpTarget; - Model *targetModel = NULL; + Model* targetModel = NULL; if (targetPose) { targetModel = targetPose->TargetModel(); if (targetModel->IsSymLink() @@ -4240,19 +4238,19 @@ BPoseView::HandleMessageDropped(BMessage *message) bool -BPoseView::HandleDropCommon(BMessage *message, Model *targetModel, BPose *targetPose, - BView *view, BPoint dropPt) +BPoseView::HandleDropCommon(BMessage* message, Model* targetModel, BPose* targetPose, + BView* view, BPoint dropPt) { uint32 buttons = (uint32)message->FindInt32("buttons"); - BContainerWindow *containerWindow = NULL; - BPoseView *poseView = dynamic_cast(view); + BContainerWindow* containerWindow = NULL; + BPoseView* poseView = dynamic_cast(view); if (poseView) containerWindow = poseView->ContainerWindow(); // look for srcWindow to determine whether drag was initiated in tracker - BContainerWindow *srcWindow = NULL; - message->FindPointer("src_window", (void **)&srcWindow); + BContainerWindow* srcWindow = NULL; + message->FindPointer("src_window", (void**)&srcWindow); if (!srcWindow) { // drag was from another app @@ -4290,7 +4288,7 @@ BPoseView::HandleDropCommon(BMessage *message, Model *targetModel, BPose *target // fish for specification of specialized menu items BObjectList actionSpecifiers(10, true); for (int32 index = 0; ; index++) { - const char *string; + const char* string; if (message->FindString("be:actionspecifier", index, &string) != B_OK) break; @@ -4302,14 +4300,14 @@ BPoseView::HandleDropCommon(BMessage *message, Model *targetModel, BPose *target BObjectList types(10, true); BObjectList typeNames(10, true); for (int32 index = 0; ; index++) { - const char *string; + const char* string; if (message->FindString("be:filetypes", index, &string) != B_OK) break; ASSERT(string); types.AddItem(new BString(string)); - const char *typeName = ""; + const char* typeName = ""; message->FindString("be:type_descriptions", index, &typeName); typeNames.AddItem(new BString(typeName)); } @@ -4377,7 +4375,7 @@ BPoseView::HandleDropCommon(BMessage *message, Model *targetModel, BPose *target // copy over all the file types the drag initiator claimed to // support for (int32 index = 0; ; index++) { - const char *type; + const char* type; if (message->FindString("be:filetypes", index, &type) != B_OK) break; reply.AddString("be:filetypes", type); @@ -4438,7 +4436,7 @@ BPoseView::HandleDropCommon(BMessage *message, Model *targetModel, BPose *target } // handle refs by performing a copy - BObjectList *entryList = new BObjectList(10, true); + BObjectList* entryList = new BObjectList(10, true); for (int32 index = 0; ; index++) { // copy all enclosed refs into a list @@ -4450,7 +4448,7 @@ BPoseView::HandleDropCommon(BMessage *message, Model *targetModel, BPose *target int32 count = entryList->CountItems(); if (count) { - BList *pointList = 0; + BList* pointList = 0; if (poseView && !targetPose) { // calculate a pointList to make the icons land were we dropped them pointList = new BList(count); @@ -4484,8 +4482,8 @@ BPoseView::HandleDropCommon(BMessage *message, Model *targetModel, BPose *target // find the text int32 textLength; - const char *text; - if (message->FindData(kPlainTextMimeType, B_MIME_TYPE, (const void **)&text, + const char* text; + if (message->FindData(kPlainTextMimeType, B_MIME_TYPE, (const void**)&text, &textLength) != B_OK) return false; @@ -4509,12 +4507,12 @@ BPoseView::HandleDropCommon(BMessage *message, Model *targetModel, BPose *target } // pick up TextView styles if available and save them with the file - const text_run_array *textRuns = NULL; + const text_run_array* textRuns = NULL; int32 dataSize = 0; if (message->FindData("application/x-vnd.Be-text_run_array", B_MIME_TYPE, - (const void **)&textRuns, &dataSize) == B_OK && textRuns && dataSize) { + (const void**)&textRuns, &dataSize) == B_OK && textRuns && dataSize) { // save styles the same way StyledEdit does - void *data = BTextView::FlattenRunArray(textRuns, &dataSize); + void* data = BTextView::FlattenRunArray(textRuns, &dataSize); file.WriteAttr("styles", B_RAW_TYPE, 0, data, (size_t)dataSize); free(data); } @@ -4555,7 +4553,7 @@ BPoseView::HandleDropCommon(BMessage *message, Model *targetModel, BPose *target // bail if too large return false; - char *buffer = new char [size]; + char* buffer = new char [size]; embeddedBitmap.Flatten(buffer, size); // write out the file @@ -4625,16 +4623,16 @@ BPoseView::HandleDropCommon(BMessage *message, Model *targetModel, BPose *target struct LaunchParams { - Model *app; + Model* app; bool checkTypes; - BMessage *refsMessage; + BMessage* refsMessage; }; static bool -AddOneToLaunchMessage(BPose *pose, BPoseView *, void *castToParams) +AddOneToLaunchMessage(BPose* pose, BPoseView*, void* castToParams) { - LaunchParams *params = (LaunchParams *)castToParams; + LaunchParams* params = (LaunchParams*)castToParams; ASSERT(pose->TargetModel()); if (params->app->IsDropTarget(params->checkTypes ? pose->TargetModel() : 0, true)) @@ -4645,7 +4643,7 @@ AddOneToLaunchMessage(BPose *pose, BPoseView *, void *castToParams) void -BPoseView::LaunchAppWithSelection(Model *appModel, const BMessage *dragMessage, +BPoseView::LaunchAppWithSelection(Model* appModel, const BMessage* dragMessage, bool checkTypes) { // launch items from the current selection with ; only pass the same @@ -4657,8 +4655,8 @@ BPoseView::LaunchAppWithSelection(Model *appModel, const BMessage *dragMessage, params.refsMessage = &refs; // add Tracker token so that refs received recipients can script us - BContainerWindow *srcWindow; - dragMessage->FindPointer("src_window", (void **)&srcWindow); + BContainerWindow* srcWindow; + dragMessage->FindPointer("src_window", (void**)&srcWindow); if (srcWindow) params.refsMessage->AddMessenger("TrackerViewToken", BMessenger( srcWindow->PoseView())); @@ -4670,22 +4668,22 @@ BPoseView::LaunchAppWithSelection(Model *appModel, const BMessage *dragMessage, static bool -OneMatches(BPose *pose, BPoseView *, void *castToPose) +OneMatches(BPose* pose, BPoseView*, void* castToPose) { - return pose == (const BPose *)castToPose; + return pose == (const BPose*)castToPose; } bool -BPoseView::DragSelectionContains(const BPose *target, - const BMessage *dragMessage) +BPoseView::DragSelectionContains(const BPose* target, + const BMessage* dragMessage) { - return EachItemInDraggedSelection(dragMessage, OneMatches, 0, (void *)target); + return EachItemInDraggedSelection(dragMessage, OneMatches, 0, (void*)target); } static void -CopySelectionListToBListAsEntryRefs(const PoseList *original, BObjectList *copy) +CopySelectionListToBListAsEntryRefs(const PoseList* original, BObjectList* copy) { int32 count = original->CountItems(); for (int32 index = 0; index < count; index++) @@ -4694,7 +4692,7 @@ CopySelectionListToBListAsEntryRefs(const PoseList *original, BObjectList lock(srcWindow); @@ -4750,7 +4748,7 @@ BPoseView::MoveSelectionInto(Model *destFolder, BContainerWindow *srcWindow, // make sure source and destination folders are different if (!createLink && !createRelativeLink && (*srcWindow->PoseView()->TargetModel()->NodeRef() == *destFolder->NodeRef())) { - BPoseView *targetView = srcWindow->PoseView(); + BPoseView* targetView = srcWindow->PoseView(); if (forceCopy) { targetView->DuplicateSelection(&clickPt, &loc); return; @@ -4762,7 +4760,7 @@ BPoseView::MoveSelectionInto(Model *destFolder, BContainerWindow *srcWindow, BPoint delta = loc - clickPt; int32 count = targetView->fSelectionList->CountItems(); for (int32 index = 0; index < count; index++) { - BPose *pose = targetView->fSelectionList->ItemAt(index); + BPose* pose = targetView->fSelectionList->ItemAt(index); // remove pose from VSlist before changing location // so that we "find" the correct pose to remove @@ -4789,7 +4787,7 @@ BPoseView::MoveSelectionInto(Model *destFolder, BContainerWindow *srcWindow, } - BEntry *destEntry = new BEntry(destFolder->EntryRef()); + BEntry* destEntry = new BEntry(destFolder->EntryRef()); bool destIsTrash = destFolder->IsTrash(); // perform asynchronous copy/move @@ -4798,7 +4796,7 @@ BPoseView::MoveSelectionInto(Model *destFolder, BContainerWindow *srcWindow, bool okToMove = true; if (destFolder->IsRoot()) { - BAlert *alert = new BAlert("", + BAlert* alert = new BAlert("", B_TRANSLATE("You must drop items on one of the disk icons " "in the \"Disks\" window."), B_TRANSLATE("Cancel"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); @@ -4809,7 +4807,7 @@ BPoseView::MoveSelectionInto(Model *destFolder, BContainerWindow *srcWindow, // can't copy items into the trash if (forceCopy && destIsTrash) { - BAlert *alert = new BAlert("", + BAlert* alert = new BAlert("", B_TRANSLATE("Sorry, you can't copy items to the Trash."), B_TRANSLATE("Cancel"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); @@ -4820,7 +4818,7 @@ BPoseView::MoveSelectionInto(Model *destFolder, BContainerWindow *srcWindow, // can't create symlinks into the trash if (createLink && destIsTrash) { - BAlert *alert = new BAlert("", + BAlert* alert = new BAlert("", B_TRANSLATE("Sorry, you can't create links in the Trash."), B_TRANSLATE("Cancel"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); @@ -4833,7 +4831,7 @@ BPoseView::MoveSelectionInto(Model *destFolder, BContainerWindow *srcWindow, if (srcWindow->TargetModel()->IsQuery() && !forceCopy && !destIsTrash && !createLink) { srcWindow->UpdateIfNeeded(); - BAlert *alert = new BAlert("", + BAlert* alert = new BAlert("", B_TRANSLATE("Are you sure you want to move or copy the selected " "item(s) to this folder?"), B_TRANSLATE("Cancel"), B_TRANSLATE("Move"), NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); @@ -4842,10 +4840,10 @@ BPoseView::MoveSelectionInto(Model *destFolder, BContainerWindow *srcWindow, } if (okToMove) { - PoseList *selectionList = srcWindow->PoseView()->SelectionList(); - BList *pointList = destWindow->PoseView()->GetDropPointList(clickPt, loc, selectionList, + PoseList* selectionList = srcWindow->PoseView()->SelectionList(); + BList* pointList = destWindow->PoseView()->GetDropPointList(clickPt, loc, selectionList, srcWindow->PoseView()->ViewMode() == kListMode, dropOnGrid); - BObjectList *srcList = new BObjectList( + BObjectList* srcList = new BObjectList( selectionList->CountItems(), true); CopySelectionListToBListAsEntryRefs(selectionList, srcList); @@ -4878,7 +4876,7 @@ BPoseView::MoveSelectionTo(BPoint dropPt, BPoint clickPt, { // Moves selection from srcWindow into this window, copying if necessary. - BContainerWindow *window = ContainerWindow(); + BContainerWindow* window = ContainerWindow(); if (!window) return; @@ -4897,8 +4895,8 @@ BPoseView::MoveSelectionTo(BPoint dropPt, BPoint clickPt, inline void -UpdateWasBrokenSymlinkBinder(BPose *pose, Model *, BPoseView *poseView, - BPoint *loc) +UpdateWasBrokenSymlinkBinder(BPose* pose, Model*, BPoseView* poseView, + BPoint* loc) { pose->UpdateWasBrokenSymlink(*loc, poseView); loc->y += poseView->ListElemHeight(); @@ -4919,8 +4917,8 @@ BPoseView::TryUpdatingBrokenLinks() void -BPoseView::PoseHandleDeviceUnmounted(BPose *pose, Model *model, int32 index, - BPoseView *poseView, dev_t device) +BPoseView::PoseHandleDeviceUnmounted(BPose* pose, Model* model, int32 index, + BPoseView* poseView, dev_t device) { if (model->NodeRef()->device == device) poseView->DeletePose(model->NodeRef()); @@ -4932,8 +4930,8 @@ BPoseView::PoseHandleDeviceUnmounted(BPose *pose, Model *model, int32 index, static void -OneMetaMimeChanged(BPose *pose, Model *model, int32 index, - BPoseView *poseView, const char *type) +OneMetaMimeChanged(BPose* pose, Model* model, int32 index, + BPoseView* poseView, const char* type) { ASSERT(model); if (model->IconFrom() != kNode @@ -4950,7 +4948,7 @@ OneMetaMimeChanged(BPose *pose, Model *model, int32 index, void -BPoseView::MetaMimeChanged(const char *type, const char *preferredApp) +BPoseView::MetaMimeChanged(const char* type, const char* preferredApp) { IconCache::sIconCache->IconChanged(type, preferredApp); // wait for other windows to do the same before we start @@ -4967,25 +4965,25 @@ class MetaMimeChangedAccumulator : public AccumulatingFunctionObject { // pools up matching metamime change notices, executing them as a single // update public: - MetaMimeChangedAccumulator(void (BPoseView::*func)(const char *type, - const char *preferredApp), - BContainerWindow *window, const char *type, const char *preferredApp) + MetaMimeChangedAccumulator(void (BPoseView::*func)(const char* type, + const char* preferredApp), + BContainerWindow* window, const char* type, const char* preferredApp) : fCallOnThis(window), fFunc(func), fType(type), fPreferredApp(preferredApp) {} - virtual bool CanAccumulate(const AccumulatingFunctionObject *functor) const + virtual bool CanAccumulate(const AccumulatingFunctionObject* functor) const { - return dynamic_cast(functor) - && dynamic_cast(functor)->fType + return dynamic_cast(functor) + && dynamic_cast(functor)->fType == fType - && dynamic_cast(functor)-> + && dynamic_cast(functor)-> fPreferredApp == fPreferredApp; } - virtual void Accumulate(AccumulatingFunctionObject *DEBUG_ONLY(functor)) + virtual void Accumulate(AccumulatingFunctionObject* DEBUG_ONLY(functor)) { ASSERT(CanAccumulate(functor)); // do nothing, no further accumulating needed @@ -5007,15 +5005,15 @@ protected: } private: - BContainerWindow *fCallOnThis; - void (BPoseView::*fFunc)(const char *type, const char *preferredApp); + BContainerWindow* fCallOnThis; + void (BPoseView::*fFunc)(const char* type, const char* preferredApp); BString fType; BString fPreferredApp; }; bool -BPoseView::NoticeMetaMimeChanged(const BMessage *message) +BPoseView::NoticeMetaMimeChanged(const BMessage* message) { int32 change; if (message->FindInt32("be:which", &change) != B_OK) @@ -5026,8 +5024,8 @@ BPoseView::NoticeMetaMimeChanged(const BMessage *message) bool preferredAppChanged = (change & B_APP_HINT_CHANGED) || (change & B_PREFERRED_APP_CHANGED); - const char *type = NULL; - const char *preferredApp = NULL; + const char* type = NULL; + const char* preferredApp = NULL; if (iconChanged || preferredAppChanged) message->FindString("be:type", &type); @@ -5038,7 +5036,7 @@ BPoseView::NoticeMetaMimeChanged(const BMessage *message) } if (iconChanged || preferredAppChanged || iconForTypeChanged) { - TaskLoop *taskLoop = ContainerWindow()->DelayedTaskLoop(); + TaskLoop* taskLoop = ContainerWindow()->DelayedTaskLoop(); ASSERT(taskLoop); taskLoop->AccumulatedRunLater(new MetaMimeChangedAccumulator( &BPoseView::MetaMimeChanged, ContainerWindow(), type, preferredApp), @@ -5049,7 +5047,7 @@ BPoseView::NoticeMetaMimeChanged(const BMessage *message) bool -BPoseView::FSNotification(const BMessage *message) +BPoseView::FSNotification(const BMessage* message) { node_ref itemNode; dev_t device; @@ -5060,8 +5058,8 @@ BPoseView::FSNotification(const BMessage *message) message->FindInt32("device", &itemNode.device); node_ref dirNode; dirNode.device = itemNode.device; - message->FindInt64("directory", (int64 *)&dirNode.node); - message->FindInt64("node", (int64 *)&itemNode.node); + message->FindInt64("directory", (int64*)&dirNode.node); + message->FindInt64("node", (int64*)&itemNode.node); ASSERT(TargetModel()); @@ -5076,7 +5074,7 @@ BPoseView::FSNotification(const BMessage *message) // stray notification break; - const char *name; + const char* name; if (message->FindString("name", &name) == B_OK) EntryCreated(&dirNode, &itemNode, name); #if DEBUG @@ -5091,7 +5089,7 @@ BPoseView::FSNotification(const BMessage *message) case B_ENTRY_REMOVED: message->FindInt32("device", &itemNode.device); - message->FindInt64("node", (int64 *)&itemNode.node); + message->FindInt64("node", (int64*)&itemNode.node); // our window itself may be deleted // we must check to see if this comes as a query @@ -5114,7 +5112,7 @@ BPoseView::FSNotification(const BMessage *message) } } else { int32 index; - BPose *pose = fPoseList->FindPose(&itemNode, &index); + BPose* pose = fPoseList->FindPose(&itemNode, &index); if (!pose) { // couldn't find pose, first check if the node might be // target of a symlink pose; @@ -5157,7 +5155,7 @@ BPoseView::FSNotification(const BMessage *message) AddPoses(&model); } } - TaskLoop *taskLoop = ContainerWindow()->DelayedTaskLoop(); + TaskLoop* taskLoop = ContainerWindow()->DelayedTaskLoop(); ASSERT(taskLoop); taskLoop->RunLater(NewMemberFunctionObject( &BPoseView::TryUpdatingBrokenLinks, this), 500000); @@ -5189,10 +5187,10 @@ BPoseView::FSNotification(const BMessage *message) bool -BPoseView::CreateSymlinkPoseTarget(Model *symlink) +BPoseView::CreateSymlinkPoseTarget(Model* symlink) { - Model *newResolvedModel = NULL; - Model *result = symlink->LinkTo(); + Model* newResolvedModel = NULL; + Model* result = symlink->LinkTo(); if (!result) { newResolvedModel = new Model(symlink->EntryRef(), true, true); @@ -5228,9 +5226,9 @@ BPoseView::CreateSymlinkPoseTarget(Model *symlink) } -BPose * -BPoseView::EntryCreated(const node_ref *dirNode, const node_ref *itemNode, - const char *name, int32 *indexPtr) +BPose* +BPoseView::EntryCreated(const node_ref* dirNode, const node_ref* itemNode, + const char* name, int32* indexPtr) { // reject notification if pose already exists if (fPoseList->FindPose(itemNode) || FindZombie(itemNode)) @@ -5238,7 +5236,7 @@ BPoseView::EntryCreated(const node_ref *dirNode, const node_ref *itemNode, BPoseView::WatchNewNode(itemNode); // have to node monitor ahead of time because Model will // cache up the file type and preferred app - Model *model = new Model(dirNode, itemNode, name, true); + Model* model = new Model(dirNode, itemNode, name, true); if (model->InitCheck() != B_OK) { // if we have trouble setting up model then we stuff it into @@ -5276,7 +5274,7 @@ BPoseView::EntryCreated(const node_ref *dirNode, const node_ref *itemNode, bool -BPoseView::EntryMoved(const BMessage *message) +BPoseView::EntryMoved(const BMessage* message) { ino_t oldDir; node_ref dirNode; @@ -5284,11 +5282,11 @@ BPoseView::EntryMoved(const BMessage *message) message->FindInt32("device", &dirNode.device); itemNode.device = dirNode.device; - message->FindInt64("to directory", (int64 *)&dirNode.node); - message->FindInt64("node", (int64 *)&itemNode.node); - message->FindInt64("from directory", (int64 *)&oldDir); + message->FindInt64("to directory", (int64*)&dirNode.node); + message->FindInt64("node", (int64*)&itemNode.node); + message->FindInt64("from directory", (int64*)&oldDir); - const char *name; + const char* name; if (message->FindString("name", &name) != B_OK) return true; // handle special case of notifying a name change for a volume @@ -5327,14 +5325,14 @@ BPoseView::EntryMoved(const BMessage *message) if (thisDirNode == itemNode) { TargetModel()->UpdateEntryRef(&dirNode, name); - assert_cast(Window())->UpdateTitle(); + assert_cast(Window())->UpdateTitle(); } if (oldDir == dirNode.node || TargetModel()->IsQuery()) { // rename or move of entry in this directory (or query) int32 index; - BPose *pose = fPoseList->FindPose(&itemNode, &index); + BPose* pose = fPoseList->FindPose(&itemNode, &index); if (pose) { pose->TargetModel()->UpdateEntryRef(&dirNode, name); @@ -5362,7 +5360,7 @@ BPoseView::EntryMoved(const BMessage *message) } } else { // also must watch for renames on zombies - Model *zombie = FindZombie(&itemNode, &index); + Model* zombie = FindZombie(&itemNode, &index); if (zombie) { PRINT(("converting model %s from a zombie\n", zombie->Name())); zombie->UpdateEntryRef(&dirNode, name); @@ -5381,20 +5379,20 @@ BPoseView::EntryMoved(const BMessage *message) bool -BPoseView::AttributeChanged(const BMessage *message) +BPoseView::AttributeChanged(const BMessage* message) { node_ref itemNode; message->FindInt32("device", &itemNode.device); - message->FindInt64("node", (int64 *)&itemNode.node); + message->FindInt64("node", (int64*)&itemNode.node); - const char *attrName; + const char* attrName; message->FindString("attr", &attrName); if (TargetModel() != NULL && *TargetModel()->NodeRef() == itemNode && TargetModel()->AttrChanged(attrName)) { // the icon of our target has changed, update drag icon // TODO: make this simpler (ie. store the icon with the window) - BView *view = Window()->FindView("MenuBar"); + BView* view = Window()->FindView("MenuBar"); if (view != NULL) { view = view->FindView("ThisContainer"); if (view != NULL) { @@ -5405,7 +5403,7 @@ BPoseView::AttributeChanged(const BMessage *message) } int32 index; - BPose *pose = fPoseList->DeepFindPose(&itemNode, &index); + BPose* pose = fPoseList->DeepFindPose(&itemNode, &index); attr_info info; memset(&info, 0, sizeof(attr_info)); if (pose) { @@ -5416,7 +5414,7 @@ BPoseView::AttributeChanged(const BMessage *message) BPoint loc(0, index * fListElemHeight); - Model *model = pose->TargetModel(); + Model* model = pose->TargetModel(); if (model->IsSymLink() && *model->NodeRef() != itemNode) // change happened on symlink's target model = model->ResolveIfLink(); @@ -5487,7 +5485,7 @@ BPoseView::AttributeChanged(const BMessage *message) // that although we couldn't open the node the first time, it seems // to be fine now since we're receiving notifications about it, it might // be a good time to convert it to a non-zombie state. cf. test in #4130 - Model *zombie = FindZombie(&itemNode, &index); + Model* zombie = FindZombie(&itemNode, &index); if (zombie) { PRINT(("converting model %s from a zombie\n", zombie->Name())); return ConvertZombieToPose(zombie, index) != NULL; @@ -5502,13 +5500,13 @@ BPoseView::AttributeChanged(const BMessage *message) void -BPoseView::UpdateIcon(BPose *pose) +BPoseView::UpdateIcon(BPose* pose) { BPoint location; if (ViewMode() == kListMode) { // need to find the index of the pose in the pose list bool found = false; - PoseList *poseList = CurrentPoseList(); + PoseList* poseList = CurrentPoseList(); int32 count = poseList->CountItems(); for (int32 index = 0; index < count; index++) { if (poseList->ItemAt(index) == pose) { @@ -5526,8 +5524,8 @@ BPoseView::UpdateIcon(BPose *pose) } -BPose * -BPoseView::ConvertZombieToPose(Model *zombie, int32 index) +BPose* +BPoseView::ConvertZombieToPose(Model* zombie, int32 index) { if (zombie->UpdateStatAndOpenNode() != B_OK) return NULL; @@ -5547,17 +5545,17 @@ BPoseView::ConvertZombieToPose(Model *zombie, int32 index) } -BList * -BPoseView::GetDropPointList(BPoint dropStart, BPoint dropEnd, const PoseList *poses, +BList* +BPoseView::GetDropPointList(BPoint dropStart, BPoint dropEnd, const PoseList* poses, bool sourceInListMode, bool dropOnGrid) const { if (ViewMode() == kListMode) return NULL; int32 count = poses->CountItems(); - BList *pointList = new BList(count); + BList* pointList = new BList(count); for (int32 index = 0; index < count; index++) { - BPose *pose = poses->ItemAt(index); + BPose* pose = poses->ItemAt(index); BPoint poseLoc; if (sourceInListMode) poseLoc = dropEnd + BPoint(0, index * (IconPoseHeight() + 3)); @@ -5575,14 +5573,14 @@ BPoseView::GetDropPointList(BPoint dropStart, BPoint dropEnd, const PoseList *po void -BPoseView::DuplicateSelection(BPoint *dropStart, BPoint *dropEnd) +BPoseView::DuplicateSelection(BPoint* dropStart, BPoint* dropEnd) { // If there is a volume or trash folder, remove them from the list // because they cannot get copied int32 selectionSize = fSelectionList->CountItems(); for (int32 index = 0; index < selectionSize; index++) { - BPose *pose = (BPose*)fSelectionList->ItemAt(index); - Model *model = pose->TargetModel(); + BPose* pose = (BPose*)fSelectionList->ItemAt(index); + Model* model = pose->TargetModel(); // can't duplicate a volume or the trash if (model->IsTrash() || model->IsVolume()) { @@ -5603,7 +5601,7 @@ BPoseView::DuplicateSelection(BPoint *dropStart, BPoint *dropEnd) fSelectionList->CountItems(), true); CopySelectionListToBListAsEntryRefs(fSelectionList, srcList); - BList *dropPoints = NULL; + BList* dropPoints = NULL; if (dropStart) dropPoints = GetDropPointList(*dropStart, *dropEnd, fSelectionList, ViewMode() == kListMode, (modifiers() & B_COMMAND_KEY) != 0); @@ -5618,7 +5616,7 @@ void BPoseView::SelectPoseAtLocation(BPoint point) { int32 index; - BPose *pose = FindPose(point, &index); + BPose* pose = FindPose(point, &index); if (pose) SelectPose(pose, index); } @@ -5640,18 +5638,18 @@ BPoseView::MoveListToTrash(BObjectList *list, bool selectNext, taskList->AddItem(NewFunctionObject(FSDeleteRefList, list, false, true)); else taskList->AddItem(NewFunctionObject(FSMoveToTrash, list, - (BList *)NULL, false)); + (BList*)NULL, false)); if (selectNext && ViewMode() == kListMode) { // next, if in list view mode try selecting the next item after - BPose *pose = fSelectionList->ItemAt(0); + BPose* pose = fSelectionList->ItemAt(0); // find a point in the pose BPoint pointInPose(kListOffset + 5, 5); int32 index = IndexOfPose(pose); pointInPose.y += fListElemHeight * index; - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); ASSERT(TargetModel()); if (tracker) @@ -5669,8 +5667,8 @@ BPoseView::MoveListToTrash(BObjectList *list, bool selectNext, inline void -CopyOneTrashedRefAsEntry(const entry_ref *ref, BObjectList *trashList, - BObjectList *noTrashList, std::map *deviceHasTrash) +CopyOneTrashedRefAsEntry(const entry_ref* ref, BObjectList* trashList, + BObjectList* noTrashList, std::map* deviceHasTrash) { std::map &deviceHasTrashTmp = *deviceHasTrash; // work around stupid binding problems with EachListItem @@ -5697,8 +5695,8 @@ CopyOneTrashedRefAsEntry(const entry_ref *ref, BObjectList *trashList static void -CopyPoseOneAsEntry(BPose *pose, BObjectList *trashList, - BObjectList *noTrashList, std::map *deviceHasTrash) +CopyPoseOneAsEntry(BPose* pose, BObjectList* trashList, + BObjectList* noTrashList, std::map* deviceHasTrash) { CopyOneTrashedRefAsEntry(pose->TargetModel()->EntryRef(), trashList, noTrashList, deviceHasTrash); @@ -5706,11 +5704,11 @@ CopyPoseOneAsEntry(BPose *pose, BObjectList *trashList, static bool -CheckVolumeReadOnly(const entry_ref *ref) +CheckVolumeReadOnly(const entry_ref* ref) { BVolume volume (ref->device); if (volume.IsReadOnly()) { - BAlert *alert = new BAlert ("", + BAlert* alert = new BAlert ("", B_TRANSLATE("Files cannot be moved or deleted from a read-only " "volume."), B_TRANSLATE("Cancel"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); @@ -5724,11 +5722,11 @@ CheckVolumeReadOnly(const entry_ref *ref) void -BPoseView::MoveSelectionOrEntryToTrash(const entry_ref *ref, bool selectNext) +BPoseView::MoveSelectionOrEntryToTrash(const entry_ref* ref, bool selectNext) { - BObjectList *entriesToTrash = new + BObjectList* entriesToTrash = new BObjectList(fSelectionList->CountItems()); - BObjectList *entriesToDeleteOnTheSpot = new + BObjectList* entriesToDeleteOnTheSpot = new BObjectList(20, true); std::map deviceHasTrash; @@ -5762,7 +5760,7 @@ BPoseView::MoveSelectionOrEntryToTrash(const entry_ref *ref, bool selectNext) "(This operation cannot be reverted.)")); } - BAlert *alert = new BAlert("", alertText.String(), + BAlert* alert = new BAlert("", alertText.String(), B_TRANSLATE("Cancel"), B_TRANSLATE("Delete")); alert->SetShortcut(0, B_ESCAPE); if (alert->Go() == 0) @@ -5788,7 +5786,7 @@ BPoseView::MoveSelectionToTrash(bool selectNext) void -BPoseView::MoveEntryToTrash(const entry_ref *ref, bool selectNext) +BPoseView::MoveEntryToTrash(const entry_ref* ref, bool selectNext) { MoveSelectionOrEntryToTrash(ref, selectNext); } @@ -5804,7 +5802,7 @@ BPoseView::DeleteSelection(bool selectNext, bool askUser) if (!CheckVolumeReadOnly(fSelectionList->ItemAt(0)->TargetModel()->EntryRef())) return; - BObjectList *entriesToDelete = new BObjectList(count, true); + BObjectList* entriesToDelete = new BObjectList(count, true); for (int32 index = 0; index < count; index++) entriesToDelete->AddItem(new entry_ref((*fSelectionList->ItemAt(index) @@ -5821,7 +5819,7 @@ BPoseView::RestoreSelectionFromTrash(bool selectNext) if (count <= 0) return; - BObjectList *entriesToRestore = new BObjectList(count, true); + BObjectList* entriesToRestore = new BObjectList(count, true); for (int32 index = 0; index < count; index++) entriesToRestore->AddItem(new entry_ref((*fSelectionList->ItemAt(index) @@ -5834,7 +5832,7 @@ BPoseView::RestoreSelectionFromTrash(bool selectNext) void BPoseView::Delete(const entry_ref &ref, bool selectNext, bool askUser) { - BObjectList *entriesToDelete = new BObjectList(1, true); + BObjectList* entriesToDelete = new BObjectList(1, true); entriesToDelete->AddItem(new entry_ref(ref)); Delete(entriesToDelete, selectNext, askUser); @@ -5842,14 +5840,14 @@ BPoseView::Delete(const entry_ref &ref, bool selectNext, bool askUser) void -BPoseView::Delete(BObjectList *list, bool selectNext, bool askUser) +BPoseView::Delete(BObjectList* list, bool selectNext, bool askUser) { if (list->CountItems() == 0) { delete list; return; } - BObjectList *taskList = + BObjectList* taskList = new BObjectList(2, true); // first move selection to trash, @@ -5857,14 +5855,14 @@ BPoseView::Delete(BObjectList *list, bool selectNext, bool askUser) if (selectNext && ViewMode() == kListMode) { // next, if in list view mode try selecting the next item after - BPose *pose = fSelectionList->ItemAt(0); + BPose* pose = fSelectionList->ItemAt(0); // find a point in the pose BPoint pointInPose(kListOffset + 5, 5); int32 index = IndexOfPose(pose); pointInPose.y += fListElemHeight * index; - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); ASSERT(TargetModel()); if (tracker) @@ -5882,14 +5880,14 @@ BPoseView::Delete(BObjectList *list, bool selectNext, bool askUser) void -BPoseView::RestoreItemsFromTrash(BObjectList *list, bool selectNext) +BPoseView::RestoreItemsFromTrash(BObjectList* list, bool selectNext) { if (list->CountItems() == 0) { delete list; return; } - BObjectList *taskList = + BObjectList* taskList = new BObjectList(2, true); // first restoree selection @@ -5897,14 +5895,14 @@ BPoseView::RestoreItemsFromTrash(BObjectList *list, bool selectNext) if (selectNext && ViewMode() == kListMode) { // next, if in list view mode try selecting the next item after - BPose *pose = fSelectionList->ItemAt(0); + BPose* pose = fSelectionList->ItemAt(0); // find a point in the pose BPoint pointInPose(kListOffset + 5, 5); int32 index = IndexOfPose(pose); pointInPose.y += fListElemHeight * index; - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); ASSERT(TargetModel()); if (tracker) @@ -5937,10 +5935,10 @@ BPoseView::SelectAll() bool iconMode = ViewMode() != kListMode; - PoseList *poseList = CurrentPoseList(); + PoseList* poseList = CurrentPoseList(); int32 count = poseList->CountItems(); for (int32 index = startIndex; index < count; index++) { - BPose *pose = poseList->ItemAt(index); + BPose* pose = poseList->ItemAt(index); fSelectionList->AddItem(pose); if (index == startIndex) fSelectionPivotPose = pose; @@ -5986,10 +5984,10 @@ BPoseView::InvertSelection() bool iconMode = ViewMode() != kListMode; - PoseList *poseList = CurrentPoseList(); + PoseList* poseList = CurrentPoseList(); int32 count = poseList->CountItems(); for (int32 index = startIndex; index < count; index++) { - BPose *pose = poseList->ItemAt(index); + BPose* pose = poseList->ItemAt(index); if (pose->IsSelected()) { fSelectionList->RemoveItem(pose); @@ -6019,7 +6017,7 @@ BPoseView::InvertSelection() int32 -BPoseView::SelectMatchingEntries(const BMessage *message) +BPoseView::SelectMatchingEntries(const BMessage* message) { int32 matchCount = 0; SetMultipleSelection(true); @@ -6028,7 +6026,7 @@ BPoseView::SelectMatchingEntries(const BMessage *message) TrackerStringExpressionType expressionType; BString expression; - const char *expressionPointer; + const char* expressionPointer; bool invertSelection; bool ignoreCase; @@ -6039,7 +6037,7 @@ BPoseView::SelectMatchingEntries(const BMessage *message) expression = expressionPointer; - PoseList *poseList = CurrentPoseList(); + PoseList* poseList = CurrentPoseList(); int32 count = poseList->CountItems(); TrackerString name; @@ -6065,7 +6063,7 @@ BPoseView::SelectMatchingEntries(const BMessage *message) // TrackerString::CompileRegExp and reuse the expression. However, then we // have to take care of the case sensitivity ourselves. for (int32 index = 0; index < count; index++) { - BPose *pose = poseList->ItemAt(index); + BPose* pose = poseList->ItemAt(index); name = pose->TargetModel()->Name(); if (name.Matches(expression.String(), !ignoreCase, expressionType) ^ invertSelection) { matchCount++; @@ -6090,7 +6088,7 @@ BPoseView::ShowSelectionWindow() void -BPoseView::KeyDown(const char *bytes, int32 count) +BPoseView::KeyDown(const char* bytes, int32 count) { char key = bytes[0]; @@ -6101,7 +6099,7 @@ BPoseView::KeyDown(const char *bytes, int32 count) case B_DOWN_ARROW: { int32 index; - BPose *pose = FindNearbyPose(key, &index); + BPose* pose = FindNearbyPose(key, &index); if (pose == NULL) break; @@ -6131,8 +6129,8 @@ BPoseView::KeyDown(const char *bytes, int32 count) // select the first entry (if in listview mode), and // scroll to the top of the view if (ViewMode() == kListMode) { - PoseList *poseList = CurrentPoseList(); - BPose *pose = fSelectionList->LastItem(); + PoseList* poseList = CurrentPoseList(); + BPose* pose = fSelectionList->LastItem(); if (pose != NULL && fMultipleSelection && (modifiers() & B_SHIFT_KEY) != 0) { int32 index = poseList->IndexOf(pose); @@ -6157,8 +6155,8 @@ BPoseView::KeyDown(const char *bytes, int32 count) // select the last entry (if in listview mode), and // scroll to the bottom of the view if (ViewMode() == kListMode) { - PoseList *poseList = CurrentPoseList(); - BPose *pose = fSelectionList->FirstItem(); + PoseList* poseList = CurrentPoseList(); + BPose* pose = fSelectionList->FirstItem(); if (pose != NULL && fMultipleSelection && (modifiers() & B_SHIFT_KEY) != 0) { int32 index = poseList->IndexOf(pose); @@ -6211,14 +6209,14 @@ BPoseView::KeyDown(const char *bytes, int32 count) if (fSelectionList->IsEmpty()) sMatchString.Truncate(0); else { - BPose *pose = fSelectionList->FirstItem(); + BPose* pose = fSelectionList->FirstItem(); sMatchString.SetTo(pose->TargetModel()->Name()); } bool reverse = (Window()->CurrentMessage()->FindInt32("modifiers") & B_SHIFT_KEY) != 0; int32 index; - BPose *pose = FindNextMatch(&index, reverse); + BPose* pose = FindNextMatch(&index, reverse); if (!pose) { // wrap around if (reverse) sMatchString.SetTo(0x7f, 1); @@ -6252,7 +6250,7 @@ BPoseView::KeyDown(const char *bytes, int32 count) case B_BACKSPACE: { if (fFiltering) { - BString *lastString = fFilterStrings.LastItem(); + BString* lastString = fFilterStrings.LastItem(); if (lastString->Length() == 0) { int32 stringCount = fFilterStrings.CountItems(); if (stringCount > 1) @@ -6279,7 +6277,7 @@ BPoseView::KeyDown(const char *bytes, int32 count) // select our new string int32 index; - BPose *pose = FindBestMatch(&index); + BPose* pose = FindBestMatch(&index); if (!pose) break; @@ -6288,7 +6286,7 @@ BPoseView::KeyDown(const char *bytes, int32 count) } case B_FUNCTION_KEY: - if (BMessage *message = Window()->CurrentMessage()) { + if (BMessage* message = Window()->CurrentMessage()) { int32 key; if (message->FindInt32("key", &key) == B_OK) { switch (key) { @@ -6354,7 +6352,7 @@ BPoseView::KeyDown(const char *bytes, int32 count) fCountView->SetTypeAhead(sMatchString.String()); int32 index; - BPose *pose = FindBestMatch(&index); + BPose* pose = FindBestMatch(&index); if (!pose) break; @@ -6365,16 +6363,16 @@ BPoseView::KeyDown(const char *bytes, int32 count) } -BPose * -BPoseView::FindNextMatch(int32 *matchingIndex, bool reverse) +BPose* +BPoseView::FindNextMatch(int32* matchingIndex, bool reverse) { char bestSoFar[B_FILE_NAME_LENGTH] = { 0 }; - BPose *poseToSelect = NULL; + BPose* poseToSelect = NULL; // loop through all poses to find match int32 count = fPoseList->CountItems(); for (int32 index = 0; index < count; index++) { - BPose *pose = fPoseList->ItemAt(index); + BPose* pose = fPoseList->ItemAt(index); if (reverse) { if (sMatchString.ICompare(pose->TargetModel()->Name()) > 0) @@ -6398,25 +6396,25 @@ BPoseView::FindNextMatch(int32 *matchingIndex, bool reverse) } -BPose * -BPoseView::FindBestMatch(int32 *index) +BPose* +BPoseView::FindBestMatch(int32* index) { - BPose *poseToSelect = NULL; + BPose* poseToSelect = NULL; float bestScore = -1; int32 count = fPoseList->CountItems(); // loop through all poses to find match for (int32 j = 0; j < CountColumns(); j++) { - BColumn *column = ColumnAt(j); + BColumn* column = ColumnAt(j); for (int32 i = 0; i < count; i++) { - BPose *pose = fPoseList->ItemAt(i); + BPose* pose = fPoseList->ItemAt(i); float score = -1; if (ViewMode() == kListMode) { ModelNodeLazyOpener modelOpener(pose->TargetModel()); - BTextWidget *widget = pose->WidgetFor(column, this, modelOpener); - const char *text = NULL; + BTextWidget* widget = pose->WidgetFor(column, this, modelOpener); + const char* text = NULL; if (widget != NULL) text = widget->Text(this); @@ -6456,15 +6454,15 @@ LinesIntersect(float s1, float e1, float s2, float e2) } -BPose * -BPoseView::FindNearbyPose(char arrowKey, int32 *poseIndex) +BPose* +BPoseView::FindNearbyPose(char arrowKey, int32* poseIndex) { int32 resultingIndex = -1; - BPose *poseToSelect = NULL; - BPose *selectedPose = fSelectionList->LastItem(); + BPose* poseToSelect = NULL; + BPose* selectedPose = fSelectionList->LastItem(); if (ViewMode() == kListMode) { - PoseList *poseList = CurrentPoseList(); + PoseList* poseList = CurrentPoseList(); switch (arrowKey) { case B_UP_ARROW: @@ -6508,7 +6506,7 @@ BPoseView::FindNearbyPose(char arrowKey, int32 *poseIndex) // find the upper-left pose (I know it's ugly!) poseToSelect = fVSPoseList->FirstItem(); for (int32 index = 0; ;index++) { - BPose *pose = fVSPoseList->ItemAt(++index); + BPose* pose = fVSPoseList->ItemAt(++index); if (!pose) break; @@ -6531,7 +6529,7 @@ BPoseView::FindNearbyPose(char arrowKey, int32 *poseIndex) // we're not in list mode so scan visually for pose to select int32 count = fPoseList->CountItems(); for (int32 index = 0; index < count; index++) { - BPose *pose = fPoseList->ItemAt(index); + BPose* pose = fPoseList->ItemAt(index); BRect poseRect(pose->CalcRect(this)); switch (arrowKey) { @@ -6591,13 +6589,13 @@ BPoseView::FindNearbyPose(char arrowKey, int32 *poseIndex) void BPoseView::ShowContextMenu(BPoint where) { - BContainerWindow *window = ContainerWindow(); + BContainerWindow* window = ContainerWindow(); if (!window) return; // handle pose selection int32 index; - BPose *pose = FindPose(where, &index); + BPose* pose = FindPose(where, &index); if (pose) { if (!pose->IsSelected()) { ClearSelection(); @@ -6644,7 +6642,7 @@ BPoseView::_BeginSelectionRect(const BPoint& point, bool shouldExtend) static void -AddIfPoseSelected(BPose *pose, PoseList *list) +AddIfPoseSelected(BPose* pose, PoseList* list) { if (pose->IsSelected()) list->AddItem(pose); @@ -6806,7 +6804,7 @@ BPoseView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage) void -BPoseView::MouseDragged(const BMessage *message) +BPoseView::MouseDragged(const BMessage* message) { fTrackRightMouseUp = false; @@ -6828,7 +6826,7 @@ BPoseView::MouseDragged(const BMessage *message) void -BPoseView::MouseLongDown(const BMessage *message) +BPoseView::MouseLongDown(const BMessage* message) { fTrackRightMouseUp = false; @@ -6841,7 +6839,7 @@ BPoseView::MouseLongDown(const BMessage *message) void -BPoseView::MouseIdle(const BMessage *message) +BPoseView::MouseIdle(const BMessage* message) { BPoint where; uint32 buttons = 0; @@ -6867,7 +6865,7 @@ BPoseView::MouseDown(BPoint where) { // handle disposing of drag data lazily DragStop(); - BContainerWindow *window = ContainerWindow(); + BContainerWindow* window = ContainerWindow(); if (!window) return; @@ -6891,7 +6889,7 @@ BPoseView::MouseDown(BPoint where) CommitActivePose(); int32 index; - BPose *pose = FindPose(where, &index); + BPose* pose = FindPose(where, &index); if (pose) { AddRemoveSelectionRange(where, extendSelection, pose); @@ -6959,13 +6957,13 @@ BPoseView::MouseUp(BPoint where) bool -BPoseView::WasClickInPath(const BPose *pose, int32 index, BPoint mouseLoc) const +BPoseView::WasClickInPath(const BPose* pose, int32 index, BPoint mouseLoc) const { if (!pose || (ViewMode() != kListMode)) return false; BPoint loc(0, index * fListElemHeight); - BTextWidget *widget; + BTextWidget* widget; if (!pose->PointInPose(loc, this, mouseLoc, &widget) || !widget) return false; @@ -6991,7 +6989,7 @@ BPoseView::WasClickInPath(const BPose *pose, int32 index, BPoint mouseLoc) const bool -BPoseView::WasDoubleClick(const BPose *pose, BPoint point) +BPoseView::WasDoubleClick(const BPose* pose, BPoint point) { // check time and proximity BPoint delta = point - fLastClickPt; @@ -7022,7 +7020,7 @@ BPoseView::WasDoubleClick(const BPose *pose, BPoint point) static void -AddPoseRefToMessage(BPose *, Model *model, BMessage *message) +AddPoseRefToMessage(BPose *, Model* model, BMessage* message) { // Make sure that every file added to the message has its // MIME type set. @@ -7042,7 +7040,7 @@ AddPoseRefToMessage(BPose *, Model *model, BMessage *message) void -BPoseView::DragSelectedPoses(const BPose *pose, BPoint clickPoint) +BPoseView::DragSelectedPoses(const BPose* pose, BPoint clickPoint) { if (!fDragEnabled) return; @@ -7072,7 +7070,7 @@ BPoseView::DragSelectedPoses(const BPose *pose, BPoint clickPoint) int32 index = CurrentPoseList()->IndexOf(pose); message.AddInt32("buttons", (int32)button); BRect dragRect(GetDragRect(index)); - BBitmap *dragBitmap = NULL; + BBitmap* dragBitmap = NULL; BPoint offset; // The bitmap is now always created (if DRAG_FRAME is not defined) @@ -7096,7 +7094,7 @@ BPoseView::DragSelectedPoses(const BPose *pose, BPoint clickPoint) } -BBitmap * +BBitmap* BPoseView::MakeDragBitmap(BRect dragRect, BPoint clickedPoint, int32 clickedPoseIndex, BPoint &offset) { @@ -7143,9 +7141,9 @@ BPoseView::MakeDragBitmap(BRect dragRect, BPoint clickedPoint, BRect rect(inner); rect.OffsetTo(B_ORIGIN); - BBitmap *bitmap = new BBitmap(rect, B_RGBA32, true); + BBitmap* bitmap = new BBitmap(rect, B_RGBA32, true); bitmap->Lock(); - BView *view = new BView(bitmap->Bounds(), "", B_FOLLOW_NONE, 0); + BView* view = new BView(bitmap->Bounds(), "", B_FOLLOW_NONE, 0); bitmap->AddChild(view); view->SetOrigin(0, 0); @@ -7164,8 +7162,8 @@ BPoseView::MakeDragBitmap(BRect dragRect, BPoint clickedPoint, BRect bounds(Bounds()); - PoseList *poseList = CurrentPoseList(); - BPose *pose = poseList->ItemAt(clickedPoseIndex); + PoseList* poseList = CurrentPoseList(); + BPose* pose = poseList->ItemAt(clickedPoseIndex); if (ViewMode() == kListMode) { int32 count = poseList->CountItems(); int32 startIndex = (int32)(bounds.top / fListElemHeight); @@ -7208,7 +7206,7 @@ BPoseView::MakeDragBitmap(BRect dragRect, BPoint clickedPoint, // Fade out the contents if necessary if (fade) { - uint32 *bits = (uint32 *)bitmap->Bits(); + uint32* bits = (uint32*)bitmap->Bits(); int32 width = bitmap->BytesPerRow() / 4; if (fadeLeft) @@ -7235,8 +7233,8 @@ BPoseView::GetDragRect(int32 clickedPoseIndex) BRect result; BRect bounds(Bounds()); - PoseList *poseList = CurrentPoseList(); - BPose *pose = poseList->ItemAt(clickedPoseIndex); + PoseList* poseList = CurrentPoseList(); + BPose* pose = poseList->ItemAt(clickedPoseIndex); if (ViewMode() == kListMode) { // get starting rect of clicked pose result = CalcPoseRectList(pose, clickedPoseIndex, true); @@ -7263,7 +7261,7 @@ BPoseView::GetDragRect(int32 clickedPoseIndex) int32 count = fVSPoseList->CountItems(); for (int32 index = FirstIndexAtOrBelow((int32)(bounds.top - IconPoseHeight())); index < count; index++) { - BPose *pose = fVSPoseList->ItemAt(index); + BPose* pose = fVSPoseList->ItemAt(index); if (pose) { if (pose->IsSelected()) result = result | pose->CalcRect(this); @@ -7281,12 +7279,12 @@ BPoseView::GetDragRect(int32 clickedPoseIndex) // TODO: SelectPosesListMode and SelectPosesIconMode are terrible and share // most code void -BPoseView::SelectPosesListMode(BRect selectionRect, BList **oldList) +BPoseView::SelectPosesListMode(BRect selectionRect, BList** oldList) { ASSERT(ViewMode() == kListMode); // collect all the poses which are enclosed inside the selection rect - BList *newList = new BList; + BList* newList = new BList; BRect bounds(Bounds()); SetDrawingMode(B_OP_COPY); // TODO: I _think_ there is no more synchronous drawing here, @@ -7298,17 +7296,18 @@ BPoseView::SelectPosesListMode(BRect selectionRect, BList **oldList) BPoint loc(0, startIndex * fListElemHeight); - PoseList *poseList = CurrentPoseList(); + PoseList* poseList = CurrentPoseList(); int32 count = poseList->CountItems(); for (int32 index = startIndex; index < count; index++) { - BPose *pose = poseList->ItemAt(index); + BPose* pose = poseList->ItemAt(index); BRect poseRect(pose->CalcRect(loc, this)); if (selectionRect.Intersects(poseRect)) { bool selected = pose->IsSelected(); pose->Select(!fSelectionList->HasItem(pose)); - newList->AddItem((void *)index); // this sucks, need to clean up - // using a vector class instead of BList + newList->AddItem((void*)index); + // this sucks, need to clean up using a vector class instead + // of BList if ((selected != pose->IsSelected()) && poseRect.Intersects(bounds)) { Invalidate(poseRect); @@ -7330,8 +7329,8 @@ BPoseView::SelectPosesListMode(BRect selectionRect, BList **oldList) for (int32 index = 0; index < count; index++) { int32 oldIndex = (int32)(*oldList)->ItemAt(index); - if (!newList->HasItem((void *)oldIndex)) { - BPose *pose = poseList->ItemAt(oldIndex); + if (!newList->HasItem((void*)oldIndex)) { + BPose* pose = poseList->ItemAt(oldIndex); pose->Select(!pose->IsSelected()); loc.Set(0, oldIndex * fListElemHeight); BRect poseRect(pose->CalcRect(loc, this)); @@ -7342,18 +7341,18 @@ BPoseView::SelectPosesListMode(BRect selectionRect, BList **oldList) } } - delete *oldList; + delete* oldList; *oldList = newList; } void -BPoseView::SelectPosesIconMode(BRect selectionRect, BList **oldList) +BPoseView::SelectPosesIconMode(BRect selectionRect, BList** oldList) { ASSERT(ViewMode() != kListMode); // collect all the poses which are enclosed inside the selection rect - BList *newList = new BList; + BList* newList = new BList; BRect bounds(Bounds()); SetDrawingMode(B_OP_COPY); @@ -7363,14 +7362,14 @@ BPoseView::SelectPosesIconMode(BRect selectionRect, BList **oldList) int32 count = fPoseList->CountItems(); for (int32 index = startIndex; index < count; index++) { - BPose *pose = fVSPoseList->ItemAt(index); + BPose* pose = fVSPoseList->ItemAt(index); if (pose) { BRect poseRect(pose->CalcRect(this)); if (selectionRect.Intersects(poseRect)) { bool selected = pose->IsSelected(); pose->Select(!fSelectionList->HasItem(pose)); - newList->AddItem((void *)index); + newList->AddItem((void*)index); if ((selected != pose->IsSelected()) && poseRect.Intersects(bounds)) { @@ -7393,8 +7392,8 @@ BPoseView::SelectPosesIconMode(BRect selectionRect, BList **oldList) for (int32 index = 0; index < count; index++) { int32 oldIndex = (int32)(*oldList)->ItemAt(index); - if (!newList->HasItem((void *)oldIndex)) { - BPose *pose = fVSPoseList->ItemAt(oldIndex); + if (!newList->HasItem((void*)oldIndex)) { + BPose* pose = fVSPoseList->ItemAt(oldIndex); pose->Select(!pose->IsSelected()); BRect poseRect(pose->CalcRect(this)); @@ -7403,13 +7402,13 @@ BPoseView::SelectPosesIconMode(BRect selectionRect, BList **oldList) } } - delete *oldList; + delete* oldList; *oldList = newList; } void -BPoseView::AddRemoveSelectionRange(BPoint where, bool extendSelection, BPose *pose) +BPoseView::AddRemoveSelectionRange(BPoint where, bool extendSelection, BPose* pose) { ASSERT(pose); @@ -7427,13 +7426,13 @@ BPoseView::AddRemoveSelectionRange(BPoint where, bool extendSelection, BPose *po if (!extendSelection) { // Remember fSelectionPivotPose because ClearSelection() NULLs it // and we need it to be preserved. - const BPose *savedPivotPose = fSelectionPivotPose; + const BPose* savedPivotPose = fSelectionPivotPose; ClearSelection(); fSelectionPivotPose = savedPivotPose; } if (ViewMode() == kListMode) { - PoseList *poseList = CurrentPoseList(); + PoseList* poseList = CurrentPoseList(); int32 currSelIndex = poseList->IndexOf(pose); int32 lastSelIndex = poseList->IndexOf(fSelectionPivotPose); @@ -7479,7 +7478,7 @@ BPoseView::AddRemoveSelectionRange(BPoint where, bool extendSelection, BPose *po int32 count = fPoseList->CountItems(); for (int32 index = count - 1; index >= 0; index--) { - BPose *currPose = fPoseList->ItemAt(index); + BPose* currPose = fPoseList->ItemAt(index); // TODO: works only in non-list mode? if (selection.Intersects(currPose->CalcRect(this))) AddRemovePoseFromSelection(currPose, index, select); @@ -7514,7 +7513,7 @@ BPoseView::AddRemoveSelectionRange(BPoint where, bool extendSelection, BPose *po void -BPoseView::DeleteSymLinkPoseTarget(const node_ref *itemNode, BPose *pose, +BPoseView::DeleteSymLinkPoseTarget(const node_ref* itemNode, BPose* pose, int32 index) { ASSERT(pose->TargetModel()->IsSymLink()); @@ -7526,7 +7525,7 @@ BPoseView::DeleteSymLinkPoseTarget(const node_ref *itemNode, BPose *pose, bool -BPoseView::DeletePose(const node_ref *itemNode, BPose *pose, int32 index) +BPoseView::DeletePose(const node_ref* itemNode, BPose* pose, int32 index) { watch_node(itemNode, B_STOP_WATCHING, this); @@ -7536,7 +7535,7 @@ BPoseView::DeletePose(const node_ref *itemNode, BPose *pose, int32 index) if (pose) { fInsertedNodes.erase(fInsertedNodes.find(*itemNode)); if (TargetModel()->IsSymLink()) { - Model *target = pose->TargetModel()->LinkTo(); + Model* target = pose->TargetModel()->LinkTo(); if (target) watch_node(target->NodeRef(), B_STOP_WATCHING, this); } @@ -7597,7 +7596,7 @@ BPoseView::DeletePose(const node_ref *itemNode, BPose *pose, int32 index) if (ViewMode() == kListMode) { BRect bounds(Bounds()); int32 index = (int32)(bounds.bottom / fListElemHeight); - BPose *pose = CurrentPoseList()->ItemAt(index); + BPose* pose = CurrentPoseList()->ItemAt(index); if (!pose && bounds.top > 0) // scroll up a little BView::ScrollTo(bounds.left, @@ -7609,7 +7608,7 @@ BPoseView::DeletePose(const node_ref *itemNode, BPose *pose, int32 index) } else { // we might be getting a delete for an item in the zombie list - Model *zombie = FindZombie(itemNode, &index); + Model* zombie = FindZombie(itemNode, &index); if (zombie) { PRINT(("deleting zombie model %s\n", zombie->Name())); fZombieList->RemoveItemAt(index); @@ -7621,12 +7620,12 @@ BPoseView::DeletePose(const node_ref *itemNode, BPose *pose, int32 index) } -Model * -BPoseView::FindZombie(const node_ref *itemNode, int32 *resultingIndex) +Model* +BPoseView::FindZombie(const node_ref* itemNode, int32* resultingIndex) { int32 count = fZombieList->CountItems(); for (int32 index = 0; index < count; index++) { - Model *zombie = fZombieList->ItemAt(index); + Model* zombie = fZombieList->ItemAt(index); if (*zombie->NodeRef() == *itemNode) { if (resultingIndex) *resultingIndex = index; @@ -7640,8 +7639,8 @@ BPoseView::FindZombie(const node_ref *itemNode, int32 *resultingIndex) // return pose at location h,v (search list starting from bottom so // drawing and hit detection reflect the same pose ordering) -BPose * -BPoseView::FindPose(BPoint point, int32 *poseIndex) const +BPose* +BPoseView::FindPose(BPoint point, int32* poseIndex) const { if (ViewMode() == kListMode) { int32 index = (int32)(point.y / fListElemHeight); @@ -7649,13 +7648,13 @@ BPoseView::FindPose(BPoint point, int32 *poseIndex) const *poseIndex = index; BPoint loc(0, index * fListElemHeight); - BPose *pose = CurrentPoseList()->ItemAt(index); + BPose* pose = CurrentPoseList()->ItemAt(index); if (pose && pose->PointInPose(loc, this, point)) return pose; } else { int32 count = fPoseList->CountItems(); for (int32 index = count - 1; index >= 0; index--) { - BPose *pose = fPoseList->ItemAt(index); + BPose* pose = fPoseList->ItemAt(index); if (pose->PointInPose(this, point)) { if (poseIndex) *poseIndex = index; @@ -7669,9 +7668,9 @@ BPoseView::FindPose(BPoint point, int32 *poseIndex) const void -BPoseView::OpenSelection(BPose *clickedPose, int32 *index) +BPoseView::OpenSelection(BPose* clickedPose, int32* index) { - BPose *singleWindowBrowsePose = clickedPose; + BPose* singleWindowBrowsePose = clickedPose; TrackerSettings settings; // Get first selected pose in selection if none was clicked @@ -7702,26 +7701,26 @@ BPoseView::OpenSelection(BPose *clickedPose, int32 *index) void -BPoseView::OpenSelectionUsing(BPose *clickedPose, int32 *index) +BPoseView::OpenSelectionUsing(BPose* clickedPose, int32* index) { OpenSelectionCommon(clickedPose, index, true); } void -BPoseView::OpenSelectionCommon(BPose *clickedPose, int32 *poseIndex, +BPoseView::OpenSelectionCommon(BPose* clickedPose, int32* poseIndex, bool openWith) { int32 count = fSelectionList->CountItems(); if (!count) return; - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); BMessage message(B_REFS_RECEIVED); for (int32 index = 0; index < count; index++) { - BPose *pose = fSelectionList->ItemAt(index); + BPose* pose = fSelectionList->ItemAt(index); message.AddRef("refs", pose->TargetModel()->EntryRef()); @@ -7794,11 +7793,11 @@ BPoseView::UnmountSelectedVolumes() int32 select_count = fSelectionList->CountItems(); for (int32 index = 0; index < select_count; index++) { - BPose *pose = fSelectionList->ItemAt(index); + BPose* pose = fSelectionList->ItemAt(index); if (!pose) continue; - Model *model = pose->TargetModel(); + Model* model = pose->TargetModel(); if (model->IsVolume()) { BVolume volume(model->NodeRef()->device); if (volume != boot) { @@ -7844,14 +7843,14 @@ BPoseView::ClearPoses() void -BPoseView::SwitchDir(const entry_ref *newDirRef, AttributeStreamNode *node) +BPoseView::SwitchDir(const entry_ref* newDirRef, AttributeStreamNode* node) { ASSERT(TargetModel()); if (*newDirRef == *TargetModel()->EntryRef()) // no change return; - Model *model = new Model(newDirRef, true); + Model* model = new Model(newDirRef, true); if (model->InitCheck() != B_OK || !model->IsDirectory()) { delete model; return; @@ -7881,7 +7880,7 @@ BPoseView::SwitchDir(const entry_ref *newDirRef, AttributeStreamNode *node) uint32 oldMode = ViewMode(); bool viewStateRestored = false; if (node) { - BViewState *previousState = fViewState; + BViewState* previousState = fViewState; RestoreState(node); viewStateRestored = (fViewState != previousState); } @@ -8012,7 +8011,7 @@ BPoseView::SendSelectionAsRefs(uint32 what, bool onlyQueries) message.what = what; for (int32 index = 0; index < numItems; index++) { - BPose *pose = fSelectionList->ItemAt(index); + BPose* pose = fSelectionList->ItemAt(index); if (onlyQueries) { // to check if pose is a query, follow any symlink first BEntry resolvedEntry(pose->TargetModel()->EntryRef(), true); @@ -8042,7 +8041,7 @@ BPoseView::OpenInfoWindows() { BMessenger tracker(kTrackerSignature); if (!tracker.IsValid()) { - BAlert *alert = new BAlert("", + BAlert* alert = new BAlert("", B_TRANSLATE("The Tracker must be running to see Info windows."), B_TRANSLATE("Cancel"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); @@ -8059,7 +8058,7 @@ BPoseView::SetDefaultPrinter() { BMessenger tracker(kTrackerSignature); if (!tracker.IsValid()) { - BAlert *alert = new BAlert("", + BAlert* alert = new BAlert("", B_TRANSLATE("The Tracker must be running to see set the default " "printer."), B_TRANSLATE("Cancel"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); @@ -8098,7 +8097,7 @@ BPoseView::OpenParent() BMessage message(B_REFS_RECEIVED); message.AddRef("refs", &ref); - if (dynamic_cast(be_app)) { + if (dynamic_cast(be_app)) { // add information about the child, so that we can select it // in the parent view message.AddData("nodeRefToSelect", B_RAW_TYPE, TargetModel()->NodeRef(), @@ -8126,7 +8125,7 @@ BPoseView::IdentifySelection() bool force = (modifiers() & B_SHIFT_KEY) != 0; int32 count = fSelectionList->CountItems(); for (int32 index = 0; index < count; index++) { - BPose *pose = fSelectionList->ItemAt(index); + BPose* pose = fSelectionList->ItemAt(index); BEntry entry(pose->TargetModel()->EntryRef()); if (entry.InitCheck() == B_OK) { BPath path; @@ -8153,10 +8152,10 @@ BPoseView::ClearSelection() int32 startIndex = (int32)(bounds.top / fListElemHeight); BPoint loc(0, startIndex * fListElemHeight); - PoseList *poseList = CurrentPoseList(); + PoseList* poseList = CurrentPoseList(); int32 count = poseList->CountItems(); for (int32 index = startIndex; index < count; index++) { - BPose *pose = poseList->ItemAt(index); + BPose* pose = poseList->ItemAt(index); if (pose->IsSelected()) { pose->Select(false); Invalidate(pose->CalcRect(loc, this, false)); @@ -8170,7 +8169,7 @@ BPoseView::ClearSelection() int32 startIndex = FirstIndexAtOrBelow((int32)(bounds.top - IconPoseHeight()), true); int32 count = fVSPoseList->CountItems(); for (int32 index = startIndex; index < count; index++) { - BPose *pose = fVSPoseList->ItemAt(index); + BPose* pose = fVSPoseList->ItemAt(index); if (pose) { if (pose->IsSelected()) { pose->Select(false); @@ -8211,10 +8210,10 @@ BPoseView::ShowSelection(bool show) int32 startIndex = (int32)(bounds.top / fListElemHeight); BPoint loc(0, startIndex * fListElemHeight); - PoseList *poseList = CurrentPoseList(); + PoseList* poseList = CurrentPoseList(); int32 count = poseList->CountItems(); for (int32 index = startIndex; index < count; index++) { - BPose *pose = poseList->ItemAt(index); + BPose* pose = poseList->ItemAt(index); if (fSelectionList->HasItem(pose)) if (pose->IsSelected() != show || fShowSelectionWhenInactive) { if (!fShowSelectionWhenInactive) @@ -8232,7 +8231,7 @@ BPoseView::ShowSelection(bool show) (int32)(bounds.top - IconPoseHeight()), true); int32 count = fVSPoseList->CountItems(); for (int32 index = startIndex; index < count; index++) { - BPose *pose = fVSPoseList->ItemAt(index); + BPose* pose = fVSPoseList->ItemAt(index); if (pose) { if (fSelectionList->HasItem(pose)) if (pose->IsSelected() != show || fShowSelectionWhenInactive) { @@ -8250,7 +8249,7 @@ BPoseView::ShowSelection(bool show) // now set all other poses int32 count = fSelectionList->CountItems(); for (int32 index = 0; index < count; index++) { - BPose *pose = fSelectionList->ItemAt(index); + BPose* pose = fSelectionList->ItemAt(index); if (pose->IsSelected() != show && !fShowSelectionWhenInactive) pose->Select(show); } @@ -8269,7 +8268,7 @@ BPoseView::ShowSelection(bool show) void -BPoseView::AddRemovePoseFromSelection(BPose *pose, int32 index, bool select) +BPoseView::AddRemovePoseFromSelection(BPose* pose, int32 index, bool select) { // Do not allow double selection/deselection. if (select == pose->IsSelected()) @@ -8324,7 +8323,7 @@ BPoseView::Extent() const BRect rect; if (ViewMode() == kListMode) { - BColumn *column = fColumnList->LastItem(); + BColumn* column = fColumnList->LastItem(); if (column) { rect.left = rect.top = 0; rect.right = column->Offset() + column->Width() @@ -8452,7 +8451,7 @@ BPoseView::UpdateScrollRange() void -BPoseView::DrawPose(BPose *pose, int32 index, bool fullDraw) +BPoseView::DrawPose(BPose* pose, int32 index, bool fullDraw) { BRect rect = CalcPoseRect(pose, index, fullDraw); @@ -8468,7 +8467,7 @@ rgb_color BPoseView::DeskTextColor() const { rgb_color color = ViewColor(); - float thresh = color.red + (color.green * 1.5f) + (color.blue * .50f); + float thresh = color.red + (color.green * 1.5f) + (color.blue * 0.50f); if (thresh >= 300) { color.red = 0; @@ -8573,7 +8572,7 @@ void BPoseView::DrawViewCommon(const BRect &updateRect) { if (ViewMode() == kListMode) { - PoseList *poseList = CurrentPoseList(); + PoseList* poseList = CurrentPoseList(); int32 count = poseList->CountItems(); int32 startIndex = (int32)((updateRect.top - fListElemHeight) / fListElemHeight); if (startIndex < 0) @@ -8582,7 +8581,7 @@ BPoseView::DrawViewCommon(const BRect &updateRect) BPoint loc(0, startIndex * fListElemHeight); for (int32 index = startIndex; index < count; index++) { - BPose *pose = poseList->ItemAt(index); + BPose* pose = poseList->ItemAt(index); BRect poseRect(pose->CalcRect(loc, this, true)); pose->Draw(poseRect, updateRect, this, true); loc.y += fListElemHeight; @@ -8592,7 +8591,7 @@ BPoseView::DrawViewCommon(const BRect &updateRect) } else { int32 count = fPoseList->CountItems(); for (int32 index = 0; index < count; index++) { - BPose *pose = fPoseList->ItemAt(index); + BPose* pose = fPoseList->ItemAt(index); BRect poseRect(pose->CalcRect(this)); if (updateRect.Intersects(poseRect)) pose->Draw(poseRect, updateRect, this, true); @@ -8618,7 +8617,7 @@ BPoseView::ColumnRedraw(BRect updateRect) if (startIndex < 0) startIndex = 0; - PoseList *poseList = CurrentPoseList(); + PoseList* poseList = CurrentPoseList(); int32 count = poseList->CountItems(); if (!count) return; @@ -8627,14 +8626,14 @@ BPoseView::ColumnRedraw(BRect updateRect) BRect srcRect = poseList->ItemAt(0)->CalcRect(BPoint(0, 0), this, false); srcRect.right += 1024; // need this to erase correctly sOffscreen->BeginUsing(srcRect); - BView *offscreenView = sOffscreen->View(); + BView* offscreenView = sOffscreen->View(); BRegion updateRegion; updateRegion.Set(updateRect); ConstrainClippingRegion(&updateRegion); for (int32 index = startIndex; index < count; index++) { - BPose *pose = poseList->ItemAt(index); + BPose* pose = poseList->ItemAt(index); offscreenView->SetDrawingMode(B_OP_COPY); offscreenView->SetLowColor(LowColor()); @@ -8660,7 +8659,7 @@ BPoseView::ColumnRedraw(BRect updateRect) void -BPoseView::CloseGapInList(BRect *invalidRect) +BPoseView::CloseGapInList(BRect* invalidRect) { (*invalidRect).bottom = Extent().bottom + fListElemHeight; BRect bounds(Bounds()); @@ -8683,14 +8682,14 @@ BPoseView::CloseGapInList(BRect *invalidRect) void -BPoseView::CheckPoseSortOrder(BPose *pose, int32 oldIndex) +BPoseView::CheckPoseSortOrder(BPose* pose, int32 oldIndex) { _CheckPoseSortOrder(CurrentPoseList(), pose, oldIndex); } void -BPoseView::_CheckPoseSortOrder(PoseList *poseList, BPose *pose, int32 oldIndex) +BPoseView::_CheckPoseSortOrder(PoseList* poseList, BPose* pose, int32 oldIndex) { if (ViewMode() != kListMode) return; @@ -8729,33 +8728,33 @@ BPoseView::_CheckPoseSortOrder(PoseList *poseList, BPose *pose, int32 oldIndex) static int -PoseCompareAddWidget(const BPose *p1, const BPose *p2, BPoseView *view) +PoseCompareAddWidget(const BPose* p1, const BPose* p2, BPoseView* view) { // pose comparison and lazy text widget adding uint32 sort = view->PrimarySort(); - BColumn *column = view->ColumnFor(sort); + BColumn* column = view->ColumnFor(sort); if (!column) return 0; - BPose *primary; - BPose *secondary; + BPose* primary; + BPose* secondary; if (!view->ReverseSort()) { - primary = const_cast(p1); - secondary = const_cast(p2); + primary = const_cast(p1); + secondary = const_cast(p2); } else { - primary = const_cast(p2); - secondary = const_cast(p1); + primary = const_cast(p2); + secondary = const_cast(p1); } int32 result = 0; for (int32 count = 0; ; count++) { - BTextWidget *widget1 = primary->WidgetFor(sort); + BTextWidget* widget1 = primary->WidgetFor(sort); if (!widget1) widget1 = primary->AddWidget(view, column); - BTextWidget *widget2 = secondary->WidgetFor(sort); + BTextWidget* widget2 = secondary->WidgetFor(sort); if (!widget2) widget2 = secondary->AddWidget(view, column); @@ -8783,12 +8782,12 @@ PoseCompareAddWidget(const BPose *p1, const BPose *p2, BPoseView *view) } -static BPose * -BSearch(PoseList *table, const BPose* key, BPoseView *view, - int (*cmp)(const BPose *, const BPose *, BPoseView *), bool returnClosest) +static BPose* +BSearch(PoseList* table, const BPose* key, BPoseView* view, + int (*cmp)(const BPose*, const BPose*, BPoseView*), bool returnClosest) { int32 r = table->CountItems(); - BPose *result = 0; + BPose* result = 0; for (int32 l = 1; l <= r;) { int32 m = (l + r) / 2; @@ -8809,14 +8808,14 @@ BSearch(PoseList *table, const BPose* key, BPoseView *view, int32 -BPoseView::BSearchList(PoseList *poseList, const BPose *pose, - int32 *resultingIndex, int32 oldIndex) +BPoseView::BSearchList(PoseList* poseList, const BPose* pose, + int32* resultingIndex, int32 oldIndex) { // check to see if insertion should be at beginning of list - const BPose *firstPose = poseList->FirstItem(); + const BPose* firstPose = poseList->FirstItem(); if (!firstPose) - return kInsertAtFront; - + return kInsertAtFront; + if (PoseCompareAddWidget(pose, firstPose, this) < 0) { *resultingIndex = 0; return kInsertAtFront; @@ -8836,10 +8835,10 @@ BPoseView::BSearchList(PoseList *poseList, const BPose *pose, *resultingIndex = oldIndex - 1; return kInsertAfter; } - + *resultingIndex = count - 1; - const BPose *searchResult = BSearch(poseList, pose, this, + const BPose* searchResult = BSearch(poseList, pose, this, PoseCompareAddWidget); if (searchResult) { @@ -8867,7 +8866,7 @@ BPoseView::BSearchList(PoseList *poseList, const BPose *pose, void BPoseView::SetPrimarySort(uint32 attrHash) { - BColumn *column = ColumnFor(attrHash); + BColumn* column = ColumnFor(attrHash); if (column) { fViewState->SetPrimarySort(attrHash); @@ -8879,7 +8878,7 @@ BPoseView::SetPrimarySort(uint32 attrHash) void BPoseView::SetSecondarySort(uint32 attrHash) { - BColumn *column = ColumnFor(attrHash); + BColumn* column = ColumnFor(attrHash); if (column) { fViewState->SetSecondarySort(attrHash); @@ -8899,28 +8898,28 @@ BPoseView::SetReverseSort(bool reverse) inline int -PoseCompareAddWidgetBinder(const BPose *p1, const BPose *p2, void *castToPoseView) +PoseCompareAddWidgetBinder(const BPose* p1, const BPose* p2, void* castToPoseView) { - return PoseCompareAddWidget(p1, p2, (BPoseView *)castToPoseView); + return PoseCompareAddWidget(p1, p2, (BPoseView*)castToPoseView); } -struct PoseComparator : public std::binary_function +struct PoseComparator : public std::binary_function { - PoseComparator(BPoseView *poseView): fPoseView(poseView) { } + PoseComparator(BPoseView* poseView): fPoseView(poseView) { } - bool operator() (const BPose *p1, const BPose *p2) { + bool operator() (const BPose* p1, const BPose* p2) { return PoseCompareAddWidget(p1, p2, fPoseView) < 0; } - BPoseView * fPoseView; + BPoseView* fPoseView; }; #if xDEBUG -static BPose * -DumpOne(BPose *pose, void *) +static BPose* +DumpOne(BPose* pose, void*) { pose->TargetModel()->PrintToStream(0); return 0; @@ -8938,11 +8937,11 @@ BPoseView::SortPoses() PRINT(("===================\n")); #endif - BPose **poses = reinterpret_cast( + BPose** poses = reinterpret_cast( PoseList::Private(fPoseList).AsBList()->Items()); std::stable_sort(poses, &poses[fPoseList->CountItems()], PoseComparator(this)); if (fFiltering) { - poses = reinterpret_cast( + poses = reinterpret_cast( PoseList::Private(fFilteredPoseList).AsBList()->Items()); std::stable_sort(poses, &poses[fFilteredPoseList->CountItems()], PoseComparator(this)); @@ -8950,12 +8949,12 @@ BPoseView::SortPoses() } -BColumn * +BColumn* BPoseView::ColumnFor(uint32 attr) const { int32 count = fColumnList->CountItems(); for (int32 index = 0; index < count; index++) { - BColumn *column = ColumnAt(index); + BColumn* column = ColumnAt(index); if (column->AttrHash() == attr) return column; } @@ -8965,16 +8964,16 @@ BPoseView::ColumnFor(uint32 attr) const bool // returns true if actually resized -BPoseView::ResizeColumnToWidest(BColumn *column) +BPoseView::ResizeColumnToWidest(BColumn* column) { ASSERT(ViewMode() == kListMode); float maxWidth = kMinColumnWidth; - PoseList *poseList = CurrentPoseList(); + PoseList* poseList = CurrentPoseList(); int32 count = poseList->CountItems(); for (int32 i = 0; i < count; ++i) { - BTextWidget *widget = poseList->ItemAt(i)->WidgetFor(column->AttrHash()); + BTextWidget* widget = poseList->ItemAt(i)->WidgetFor(column->AttrHash()); if (widget) { float width = widget->PreferredWidth(this); if (width > maxWidth) @@ -8992,10 +8991,10 @@ BPoseView::ResizeColumnToWidest(BColumn *column) BPoint -BPoseView::ResizeColumn(BColumn *column, float newSize, - float *lastLineDrawPos, - void (*drawLineFunc)(BPoseView *, BPoint, BPoint), - void (*undrawLineFunc)(BPoseView *, BPoint, BPoint)) +BPoseView::ResizeColumn(BColumn* column, float newSize, + float* lastLineDrawPos, + void (*drawLineFunc)(BPoseView*, BPoint, BPoint), + void (*undrawLineFunc)(BPoseView*, BPoint, BPoint)) { BRect sourceRect(Bounds()); BPoint result(sourceRect.RightBottom()); @@ -9021,7 +9020,7 @@ BPoseView::ResizeColumn(BColumn *column, float newSize, column->SetWidth(newSize); float offset = kColumnStart; - BColumn *last = fColumnList->FirstItem(); + BColumn* last = fColumnList->FirstItem(); int32 count = fColumnList->CountItems(); @@ -9069,7 +9068,7 @@ BPoseView::ResizeColumn(BColumn *column, float newSize, void -BPoseView::MoveColumnTo(BColumn *src, BColumn *dest) +BPoseView::MoveColumnTo(BColumn* src, BColumn* dest) { // find the leftmost boundary of columns we are about to reshuffle float miny = src->Offset(); @@ -9082,11 +9081,11 @@ BPoseView::MoveColumnTo(BColumn *src, BColumn *dest) fColumnList->AddItem(src, index); float offset = kColumnStart; - BColumn *last = fColumnList->FirstItem(); + BColumn* last = fColumnList->FirstItem(); int32 count = fColumnList->CountItems(); for (int32 index = 0; index < count; index++) { - BColumn *column = fColumnList->ItemAt(index); + BColumn* column = fColumnList->ItemAt(index); column->SetOffset(offset); last = column; offset = last->Offset() + last->Width() + kTitleColumnExtraMargin; @@ -9102,13 +9101,13 @@ BPoseView::MoveColumnTo(BColumn *src, BColumn *dest) bool -BPoseView::UpdateDropTarget(BPoint mouseLoc, const BMessage *dragMessage, +BPoseView::UpdateDropTarget(BPoint mouseLoc, const BMessage* dragMessage, bool trackingContextMenu) { ASSERT(dragMessage); int32 index; - BPose *targetPose = FindPose(mouseLoc, &index); + BPose* targetPose = FindPose(mouseLoc, &index); if (targetPose != NULL && DragSelectionContains(targetPose, dragMessage)) targetPose = NULL; @@ -9125,7 +9124,7 @@ BPoseView::UpdateDropTarget(BPoint mouseLoc, const BMessage *dragMessage, fDropTarget = targetPose; // dereference if symlink - Model *targetModel = NULL; + Model* targetModel = NULL; if (targetPose) targetModel = targetPose->TargetModel(); Model tmpTarget; @@ -9170,13 +9169,13 @@ BPoseView::UpdateDropTarget(BPoint mouseLoc, const BMessage *dragMessage, bool -BPoseView::FrameForPose(BPose *targetpose, bool convert, BRect *poseRect) +BPoseView::FrameForPose(BPose* targetpose, bool convert, BRect* poseRect) { bool returnvalue = false; BRect bounds(Bounds()); if (ViewMode() == kListMode) { - PoseList *poseList = CurrentPoseList(); + PoseList* poseList = CurrentPoseList(); int32 count = poseList->CountItems(); int32 startIndex = (int32)(bounds.top / fListElemHeight); @@ -9198,7 +9197,7 @@ BPoseView::FrameForPose(BPose *targetpose, bool convert, BRect *poseRect) int32 count = fVSPoseList->CountItems(); for (int32 index = startIndex; index < count; index++) { - BPose *pose = fVSPoseList->ItemAt(index); + BPose* pose = fVSPoseList->ItemAt(index); if (pose) { if (pose == fDropTarget) { *poseRect = pose->CalcRect(this); @@ -9223,7 +9222,7 @@ BPoseView::FrameForPose(BPose *targetpose, bool convert, BRect *poseRect) const int32 kMenuTrackMargin = 20; bool -BPoseView::MenuTrackingHook(BMenu *menu, void *) +BPoseView::MenuTrackingHook(BMenu* menu, void*) { // return true if the menu should go away if (!menu->LockLooper()) @@ -9250,9 +9249,9 @@ BPoseView::MenuTrackingHook(BMenu *menu, void *) for (int32 index = 0 ; index < count; index++) { // iterate through all of the items in the menu // if the submenu is showing, see if the mouse is in the submenu - BMenuItem *item = menu->ItemAt(index); + BMenuItem* item = menu->ItemAt(index); if (item && item->Submenu()) { - BWindow *window = item->Submenu()->Window(); + BWindow* window = item->Submenu()->Window(); bool inSubmenu = false; if (window && window->Lock()) { if (!window->IsHidden()) { @@ -9282,7 +9281,7 @@ void BPoseView::DragStop() { fStartFrame.Set(0, 0, 0, 0); - BContainerWindow *window = ContainerWindow(); + BContainerWindow* window = ContainerWindow(); if (window) window->DragStop(); } @@ -9321,7 +9320,7 @@ BPoseView::HiliteDropTarget(bool hiliteState) BRect bounds(Bounds()); if (ViewMode() == kListMode) { - PoseList *poseList = CurrentPoseList(); + PoseList* poseList = CurrentPoseList(); int32 count = poseList->CountItems(); int32 startIndex = (int32)(bounds.top / fListElemHeight); @@ -9343,7 +9342,7 @@ BPoseView::HiliteDropTarget(bool hiliteState) int32 count = fVSPoseList->CountItems(); for (int32 index = startIndex; index < count; index++) { - BPose *pose = fVSPoseList->ItemAt(index); + BPose* pose = fVSPoseList->ItemAt(index); if (pose) { if (pose == fDropTarget) { BRect poseRect = pose->CalcRect(this); @@ -9545,7 +9544,7 @@ BPoseView::HandleAutoScroll() BRect -BPoseView::CalcPoseRect(const BPose *pose, int32 index, +BPoseView::CalcPoseRect(const BPose* pose, int32 index, bool firstColumnOnly) const { if (ViewMode() == kListMode) @@ -9556,14 +9555,14 @@ BPoseView::CalcPoseRect(const BPose *pose, int32 index, BRect -BPoseView::CalcPoseRectIcon(const BPose *pose) const +BPoseView::CalcPoseRectIcon(const BPose* pose) const { return pose->CalcRect(this); } BRect -BPoseView::CalcPoseRectList(const BPose *pose, int32 index, +BPoseView::CalcPoseRectList(const BPose* pose, int32 index, bool firstColumnOnly) const { return pose->CalcRect(BPoint(0, index * fListElemHeight), this, @@ -9572,14 +9571,14 @@ BPoseView::CalcPoseRectList(const BPose *pose, int32 index, bool -BPoseView::Represents(const node_ref *node) const +BPoseView::Represents(const node_ref* node) const { return *(fModel->NodeRef()) == *node; } bool -BPoseView::Represents(const entry_ref *ref) const +BPoseView::Represents(const entry_ref* ref) const { return *fModel->EntryRef() == *ref; } @@ -9655,14 +9654,14 @@ BPoseView::StopWatchDateFormatChange() void -BPoseView::UpdateDateColumns(BMessage *message) +BPoseView::UpdateDateColumns(BMessage* message) { int32 columnCount = CountColumns(); BRect columnRect(Bounds()); for (int32 i = 0; i < columnCount; i++) { - BColumn *col = ColumnAt(i); + BColumn* col = ColumnAt(i); if (col && col->AttrType() == B_TIME_TYPE) { columnRect.left = col->Offset(); columnRect.right = columnRect.left + col->Width(); @@ -9673,13 +9672,13 @@ BPoseView::UpdateDateColumns(BMessage *message) void -BPoseView::AdaptToVolumeChange(BMessage *) +BPoseView::AdaptToVolumeChange(BMessage*) { } void -BPoseView::AdaptToDesktopIntegrationChange(BMessage *) +BPoseView::AdaptToDesktopIntegrationChange(BMessage*) { } @@ -9699,7 +9698,7 @@ BPoseView::SetWidgetTextOutline(bool on) void -BPoseView::EnsurePoseUnselected(BPose *pose) +BPoseView::EnsurePoseUnselected(BPose* pose) { if (pose == fDropTarget) fDropTarget = NULL; @@ -9722,7 +9721,7 @@ BPoseView::EnsurePoseUnselected(BPose *pose) void -BPoseView::RemoveFilteredPose(BPose *pose, int32 index) +BPoseView::RemoveFilteredPose(BPose* pose, int32 index) { EnsurePoseUnselected(pose); fFilteredPoseList->RemoveItemAt(index); @@ -9758,7 +9757,7 @@ BPoseView::FilterChanged() } else { int32 count = fFilteredPoseList->CountItems(); for (int32 i = count - 1; i >= 0; i--) { - BPose *pose = fFilteredPoseList->ItemAt(i); + BPose* pose = fFilteredPoseList->ItemAt(i); if (!FilterPose(pose)) RemoveFilteredPose(pose, i); } @@ -9776,7 +9775,7 @@ BPoseView::UpdateAfterFilterChange() { UpdateCount(); - BPose *pose = fFilteredPoseList->LastItem(); + BPose* pose = fFilteredPoseList->LastItem(); if (pose == NULL) BView::ScrollTo(0, 0); else { @@ -9791,7 +9790,7 @@ BPoseView::UpdateAfterFilterChange() bool -BPoseView::FilterPose(BPose *pose) +BPoseView::FilterPose(BPose* pose) { if (!fFiltering || pose == NULL) return false; @@ -9804,8 +9803,8 @@ BPoseView::FilterPose(BPose *pose) ModelNodeLazyOpener modelOpener(pose->TargetModel()); for (int32 i = 0; i < CountColumns(); i++) { - BTextWidget *widget = pose->WidgetFor(ColumnAt(i), this, modelOpener); - const char *text = NULL; + BTextWidget* widget = pose->WidgetFor(ColumnAt(i), this, modelOpener); + const char* text = NULL; if (widget == NULL) continue; @@ -9839,7 +9838,7 @@ BPoseView::StartFiltering() fFiltering = true; int32 count = fPoseList->CountItems(); for (int32 i = 0; i < count; i++) { - BPose *pose = fPoseList->ItemAt(i); + BPose* pose = fPoseList->ItemAt(i); if (FilterPose(pose)) fFilteredPoseList->AddItem(pose); else @@ -9891,7 +9890,7 @@ BPoseView::ClearFilter() // #pragma mark - -BHScrollBar::BHScrollBar(BRect bounds, const char *name, BView *target) +BHScrollBar::BHScrollBar(BRect bounds, const char* name, BView* target) : BScrollBar(bounds, name, target, 0, 1, B_HORIZONTAL), fTitleView(0) { @@ -9910,7 +9909,7 @@ BHScrollBar::ValueChanged(float value) } -TPoseViewFilter::TPoseViewFilter(BPoseView *pose) +TPoseViewFilter::TPoseViewFilter(BPoseView* pose) : BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE), fPoseView(pose) { @@ -9923,7 +9922,7 @@ TPoseViewFilter::~TPoseViewFilter() filter_result -TPoseViewFilter::Filter(BMessage *message, BHandler **) +TPoseViewFilter::Filter(BMessage* message, BHandler**) { filter_result result = B_DISPATCH_MESSAGE; @@ -9944,5 +9943,5 @@ TPoseViewFilter::Filter(BMessage *message, BHandler **) float BPoseView::sFontHeight = -1; font_height BPoseView::sFontInfo = { 0, 0, 0 }; BFont BPoseView::sCurrentFont; -OffscreenBitmap *BPoseView::sOffscreen = new OffscreenBitmap; +OffscreenBitmap* BPoseView::sOffscreen = new OffscreenBitmap; BString BPoseView::sMatchString = ""; diff --git a/src/kits/tracker/PoseView.h b/src/kits/tracker/PoseView.h index ce6fd0b728..81e3b3de18 100644 --- a/src/kits/tracker/PoseView.h +++ b/src/kits/tracker/PoseView.h @@ -31,17 +31,17 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - -// -// BPoseView is a container for poses, handling all of the interaction, drawing, -// etc. The three different view modes are handled here. -// -// this is by far the fattest Tracker class and over time will undergo a lot of -// trimming - #ifndef _POSE_VIEW_H #define _POSE_VIEW_H + +// BPoseView is a container for poses, handling all of the interaction, drawing, +// etc. The three different view modes are handled here. +// +// this is by far the fattest Tracker class and over time will undergo a lot of +// trimming + + #include "AttributeStream.h" #include "ContainerWindow.h" #include "Model.h" @@ -104,42 +104,42 @@ const uint32 kCheckTypeahead = 'Tcty'; class BPoseView : public BView { public: - BPoseView(Model *, BRect, uint32 viewMode, uint32 resizeMask = B_FOLLOW_ALL); + BPoseView(Model*, BRect, uint32 viewMode, uint32 resizeMask = B_FOLLOW_ALL); virtual ~BPoseView(); // setup, teardown - virtual void Init(AttributeStreamNode *); - virtual void Init(const BMessage &); + virtual void Init(AttributeStreamNode*); + virtual void Init(const BMessage&); void InitCommon(); virtual void DetachedFromWindow(); // Returns true if for instance, node ref is a remote desktop directory and // this is a desktop pose view. - virtual bool Represents(const node_ref *) const; - virtual bool Represents(const entry_ref *) const; + virtual bool Represents(const node_ref*) const; + virtual bool Represents(const entry_ref*) const; - BContainerWindow *ContainerWindow() const; - const char *ViewStateAttributeName() const; - const char *ForeignViewStateAttributeName() const; - Model *TargetModel() const; + BContainerWindow* ContainerWindow() const; + const char* ViewStateAttributeName() const; + const char* ForeignViewStateAttributeName() const; + Model* TargetModel() const; virtual bool IsFilePanel() const; bool IsDesktopWindow() const; virtual bool IsDesktopView() const; // state saving/restoring - virtual void SaveState(AttributeStreamNode *node); - virtual void RestoreState(AttributeStreamNode *); - virtual void RestoreColumnState(AttributeStreamNode *); - void AddColumnList(BObjectList *list); - virtual void SaveColumnState(AttributeStreamNode *); - virtual void SavePoseLocations(BRect *frameIfDesktop = NULL); + virtual void SaveState(AttributeStreamNode* node); + virtual void RestoreState(AttributeStreamNode*); + virtual void RestoreColumnState(AttributeStreamNode*); + void AddColumnList(BObjectList*list); + virtual void SaveColumnState(AttributeStreamNode*); + virtual void SavePoseLocations(BRect* frameIfDesktop = NULL); void DisableSaveLocation(); - virtual void SaveState(BMessage &) const; - virtual void RestoreState(const BMessage &); - virtual void RestoreColumnState(const BMessage &); - virtual void SaveColumnState(BMessage &) const; + virtual void SaveState(BMessage&) const; + virtual void RestoreState(const BMessage&); + virtual void RestoreColumnState(const BMessage&); + virtual void SaveColumnState(BMessage&) const; bool StateNeedsSaving(); @@ -148,8 +148,8 @@ class BPoseView : public BView { uint32 ViewMode() const; // re-use the pose view for a new directory - virtual void SwitchDir(const entry_ref *, - AttributeStreamNode *node = NULL); + virtual void SwitchDir(const entry_ref*, + AttributeStreamNode* node = NULL); // in the rare cases where a pose view needs to be explicitly refreshed // (for instance in a query window with a dynamic date query), this is @@ -157,19 +157,19 @@ class BPoseView : public BView { virtual void Refresh(); // callbacks - virtual void MessageReceived(BMessage *); + virtual void MessageReceived(BMessage*); virtual void AttachedToWindow(); virtual void WindowActivated(bool); virtual void MakeFocus(bool = true); virtual void Draw(BRect update_rect); virtual void DrawAfterChildren(BRect update_rect); - virtual void MouseMoved(BPoint, uint32, const BMessage *); + virtual void MouseMoved(BPoint, uint32, const BMessage*); virtual void MouseDown(BPoint where); virtual void MouseUp(BPoint where); - virtual void MouseDragged(const BMessage *); - virtual void MouseLongDown(const BMessage *); - virtual void MouseIdle(const BMessage *); - virtual void KeyDown(const char *, int32); + virtual void MouseDragged(const BMessage*); + virtual void MouseLongDown(const BMessage*); + virtual void MouseIdle(const BMessage*); + virtual void KeyDown(const char*, int32); virtual void Pulse(); virtual void MoveBy(float, float); virtual void ScrollTo(BPoint point); @@ -187,10 +187,10 @@ class BPoseView : public BView { void SetAutoScroll(bool); void SetPoseEditing(bool); - void UpdateIcon(BPose *pose); + void UpdateIcon(BPose* pose); // file change notification handler - virtual bool FSNotification(const BMessage *); + virtual bool FSNotification(const BMessage*); // scrollbars virtual void UpdateScrollRange(); @@ -212,8 +212,8 @@ class BPoseView : public BView { uint32 SecondarySort() const; uint32 SecondarySortType() const; bool ReverseSort() const; - void CheckPoseSortOrder(BPose *, int32 index); - void CheckPoseVisibility(BRect * = NULL); + void CheckPoseSortOrder(BPose*, int32 index); + void CheckPoseVisibility(BRect* = NULL); // make sure pose fits the screen and/or window bounds if needed // view metrics @@ -228,7 +228,7 @@ class BPoseView : public BView { icon_size IconSize() const; BRect Extent() const; - void GetLayoutInfo(uint32 viewMode, BPoint *grid, BPoint *offset) const; + void GetLayoutInfo(uint32 viewMode, BPoint* grid, BPoint* offset) const; int32 CountItems() const; void UpdateCount(); @@ -243,37 +243,37 @@ class BPoseView : public BView { // column handling void ColumnRedraw(BRect updateRect); - bool AddColumn(BColumn *, const BColumn *after = NULL); - bool RemoveColumn(BColumn *column, bool runAlert); - void MoveColumnTo(BColumn *src, BColumn *dest); - bool ResizeColumnToWidest(BColumn *column); - BPoint ResizeColumn(BColumn *, float, float *lastLineDrawPos = NULL, - void (*drawLineFunc)(BPoseView *, BPoint, BPoint) = 0, - void (*undrawLineFunc)(BPoseView *, BPoint, BPoint) = 0); + bool AddColumn(BColumn*, const BColumn* after = NULL); + bool RemoveColumn(BColumn* column, bool runAlert); + void MoveColumnTo(BColumn* src, BColumn* dest); + bool ResizeColumnToWidest(BColumn* column); + BPoint ResizeColumn(BColumn*, float, float* lastLineDrawPos = NULL, + void (*drawLineFunc)(BPoseView*, BPoint, BPoint) = 0, + void (*undrawLineFunc)(BPoseView*, BPoint, BPoint) = 0); // returns the bottom right of the last pose drawn or bottom right of // bounds - BColumn *ColumnAt(int32 index) const; - BColumn *ColumnFor(uint32 attribute_hash) const; - BColumn *FirstColumn() const; - BColumn *LastColumn() const; - int32 IndexOfColumn(const BColumn *) const; + BColumn* ColumnAt(int32 index) const; + BColumn* ColumnFor(uint32 attribute_hash) const; + BColumn* FirstColumn() const; + BColumn* LastColumn() const; + int32 IndexOfColumn(const BColumn*) const; int32 CountColumns() const; // pose access - int32 IndexOfPose(const BPose *) const; - BPose *PoseAtIndex(int32 index) const; + int32 IndexOfPose(const BPose*) const; + BPose* PoseAtIndex(int32 index) const; - BPose *FindPose(BPoint where, int32 *index = NULL) const; + BPose* FindPose(BPoint where, int32* index = NULL) const; // return pose at location h, v (search list starting from bottom so // drawing and hit detection reflect the same pose ordering) - BPose *FindPose(const Model *, int32 *index = NULL) const; - BPose *FindPose(const node_ref *, int32 *index = NULL) const; - BPose *FindPose(const entry_ref *, int32 *index = NULL) const; - BPose *FindPose(const entry_ref *, int32 specifierForm, int32 *index) const; + BPose* FindPose(const Model*, int32* index = NULL) const; + BPose* FindPose(const node_ref*, int32* index = NULL) const; + BPose* FindPose(const entry_ref*, int32* index = NULL) const; + BPose* FindPose(const entry_ref*, int32 specifierForm, int32* index) const; // special form of FindPose used for scripting, may // ask for previous or next pose - BPose *DeepFindPose(const node_ref *node, int32 *index = NULL) const; + BPose* DeepFindPose(const node_ref* node, int32* index = NULL) const; // same as FindPose, node can be a target of the actual // pose if the pose is a symlink @@ -284,108 +284,108 @@ class BPoseView : public BView { void UnmountSelectedVolumes(); virtual void OpenParent(); - virtual void OpenSelection(BPose *clicked_pose = NULL, int32 *index = NULL); - void OpenSelectionUsing(BPose *clicked_pose = NULL, int32 *index = NULL); + virtual void OpenSelection(BPose* clicked_pose = NULL, int32* index = NULL); + void OpenSelectionUsing(BPose* clicked_pose = NULL, int32* index = NULL); // launches the open with window - virtual void MoveSelectionTo(BPoint, BPoint, BContainerWindow *); - void DuplicateSelection(BPoint *dropStart = NULL, BPoint *dropEnd = NULL); + virtual void MoveSelectionTo(BPoint, BPoint, BContainerWindow*); + void DuplicateSelection(BPoint* dropStart = NULL, BPoint* dropEnd = NULL); // Move to trash calls try to select the next pose in the view when they // are dones virtual void MoveSelectionToTrash(bool selectNext = true); virtual void DeleteSelection(bool selectNext = true, bool askUser = true); - virtual void MoveEntryToTrash(const entry_ref *, bool selectNext = true); + virtual void MoveEntryToTrash(const entry_ref*, bool selectNext = true); void RestoreSelectionFromTrash(bool selectNext = true); // selection - PoseList *SelectionList() const; + PoseList* SelectionList() const; void SelectAll(); void InvertSelection(); - int32 SelectMatchingEntries(const BMessage *); + int32 SelectMatchingEntries(const BMessage*); void ShowSelectionWindow(); void ClearSelection(); void ShowSelection(bool); - void AddRemovePoseFromSelection(BPose *pose, int32 index, bool select); + void AddRemovePoseFromSelection(BPose* pose, int32 index, bool select); - BLooper *SelectionHandler(); - void SetSelectionHandler(BLooper *); + BLooper* SelectionHandler(); + void SetSelectionHandler(BLooper*); - BObjectList *MimeTypesInSelection(); + BObjectList*MimeTypesInSelection(); // pose selection - void SelectPose(BPose *, int32 index, bool scrollIntoView = true); - void AddPoseToSelection(BPose *, int32 index, + void SelectPose(BPose*, int32 index, bool scrollIntoView = true); + void AddPoseToSelection(BPose*, int32 index, bool scrollIntoView = true); - void RemovePoseFromSelection(BPose *); + void RemovePoseFromSelection(BPose*); void SelectPoseAtLocation(BPoint); void SelectPoses(int32 start, int32 end); // pose handling - void ScrollIntoView(BPose *pose, int32 index); + void ScrollIntoView(BPose* pose, int32 index); void ScrollIntoView(BRect poseRect); - void SetActivePose(BPose *); - BPose *ActivePose() const; + void SetActivePose(BPose*); + BPose* ActivePose() const; void CommitActivePose(bool saveChanges = true); - static bool PoseVisible(const Model *, const PoseInfo *); - bool FrameForPose(BPose *targetpose, bool convert, BRect *poseRect); - bool CreateSymlinkPoseTarget(Model *symlink); + static bool PoseVisible(const Model*, const PoseInfo*); + bool FrameForPose(BPose* targetpose, bool convert, BRect* poseRect); + bool CreateSymlinkPoseTarget(Model* symlink); // used to complete a symlink pose; returns true if // target symlink should not be shown void ResetPosePlacementHint(); - void PlaceFolder(const entry_ref *, const BMessage *); + void PlaceFolder(const entry_ref*, const BMessage*); // clipboard handling for poses inline bool HasPosesInClipboard(); inline void SetHasPosesInClipboard(bool hasPoses); void SetPosesClipboardMode(uint32 clipboardMode); - void UpdatePosesClipboardModeFromClipboard(BMessage *clipboardReport = NULL); + void UpdatePosesClipboardModeFromClipboard(BMessage* clipboardReport = NULL); // filtering - void SetRefFilter(BRefFilter *); - BRefFilter *RefFilter() const; + void SetRefFilter(BRefFilter*); + BRefFilter* RefFilter() const; // access for mime types represented in the pose view void AddMimeType(const char* mimeType); - const char *MimeTypeAt(int32 index); + const char* MimeTypeAt(int32 index); int32 CountMimeTypes(); void RefreshMimeTypeList(); // drag&drop handling - virtual bool HandleMessageDropped(BMessage *); - static bool HandleDropCommon(BMessage *dragMessage, Model *target, BPose *, - BView *view, BPoint dropPt); + virtual bool HandleMessageDropped(BMessage*); + static bool HandleDropCommon(BMessage* dragMessage, Model* target, BPose*, + BView* view, BPoint dropPt); // used by pose views and info windows - static bool CanHandleDragSelection(const Model *target, - const BMessage *dragMessage, bool ignoreTypes); - virtual void DragSelectedPoses(const BPose *clickedPose, BPoint); + static bool CanHandleDragSelection(const Model* target, + const BMessage* dragMessage, bool ignoreTypes); + virtual void DragSelectedPoses(const BPose* clickedPose, BPoint); - void MoveSelectionInto(Model *destFolder, BContainerWindow *srcWindow, + void MoveSelectionInto(Model* destFolder, BContainerWindow* srcWindow, bool forceCopy, bool forceMove = false, bool createLink = false, bool relativeLink = false); - static void MoveSelectionInto(Model *destFolder, BContainerWindow *srcWindow, - BContainerWindow *destWindow, uint32 buttons, BPoint loc, + static void MoveSelectionInto(Model* destFolder, BContainerWindow* srcWindow, + BContainerWindow* destWindow, uint32 buttons, BPoint loc, bool forceCopy, bool forceMove = false, bool createLink = false, bool relativeLink = false, BPoint clickPt = BPoint(0, 0), bool pinToGrid = false); - bool UpdateDropTarget(BPoint, const BMessage *, bool trackingContextMenu); + bool UpdateDropTarget(BPoint, const BMessage*, bool trackingContextMenu); // return true if drop target changed void HiliteDropTarget(bool hiliteState); void DragStop(); // throw away cached up structures - static bool MenuTrackingHook(BMenu *menu, void *castToThis); + static bool MenuTrackingHook(BMenu* menu, void* castToThis); // hook for spring loaded nav-menus // scripting - virtual BHandler *ResolveSpecifier(BMessage *message, int32 index, - BMessage *specifier, int32 form, const char *property); - virtual status_t GetSupportedSuites(BMessage *); + virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, + BMessage* specifier, int32 form, const char* property); + virtual status_t GetSupportedSuites(BMessage*); // string width calls that use local width caches, faster than using // the general purpose BView::StringWidth - float StringWidth(const char *) const; - float StringWidth(const char *, int32) const; + float StringWidth(const char*) const; + float StringWidth(const char*, int32) const; // deliberately hide the BView StringWidth here - this makes it // easy to have the right StringWidth picked up by // template instantiation, as used by WidgetAttributeText @@ -405,73 +405,73 @@ class BPoseView : public BView { // type ahead filtering bool IsFiltering() const; - void UpdateDateColumns(BMessage *); - virtual void AdaptToVolumeChange(BMessage *); - virtual void AdaptToDesktopIntegrationChange(BMessage *); + void UpdateDateColumns(BMessage*); + virtual void AdaptToVolumeChange(BMessage*); + virtual void AdaptToDesktopIntegrationChange(BMessage*); protected: // view setup virtual void SetUpDefaultColumnsIfNeeded(); - virtual EntryListBase *InitDirentIterator(const entry_ref *); + virtual EntryListBase* InitDirentIterator(const entry_ref*); // sets up an entry iterator for _add_poses_ // overriden by QueryPoseView, etc. to provide different iteration void Cleanup(bool doAll = false); // clean up poses - void NewFolder(const BMessage *); + void NewFolder(const BMessage*); // create a new folder, optionally specify a location - void NewFileFromTemplate(const BMessage *); + void NewFileFromTemplate(const BMessage*); // create a new file based on a template, optionally specify a location void ShowContextMenu(BPoint); // scripting handlers - virtual bool HandleScriptingMessage(BMessage *message); - bool SetProperty(BMessage *message, BMessage *specifier, int32 form, - const char *property, BMessage *reply); - bool GetProperty(BMessage *, int32, const char *, BMessage *); - bool CreateProperty(BMessage *message, BMessage *specifier, int32, - const char *, BMessage *reply); - bool ExecuteProperty(BMessage *specifier, int32, const char *, BMessage *reply); - bool CountProperty(BMessage *, int32, const char *, BMessage *); - bool DeleteProperty(BMessage *, int32, const char *, BMessage *); + virtual bool HandleScriptingMessage(BMessage* message); + bool SetProperty(BMessage* message, BMessage* specifier, int32 form, + const char* property, BMessage* reply); + bool GetProperty(BMessage*, int32, const char*, BMessage*); + bool CreateProperty(BMessage* message, BMessage* specifier, int32, + const char*, BMessage* reply); + bool ExecuteProperty(BMessage* specifier, int32, const char*, BMessage* reply); + bool CountProperty(BMessage*, int32, const char*, BMessage*); + bool DeleteProperty(BMessage*, int32, const char*, BMessage*); void ClearPoses(); // remove all the current poses from the view // pose info read/write calls - void ReadPoseInfo(Model *, PoseInfo *); - ExtendedPoseInfo *ReadExtendedPoseInfo(Model *); + void ReadPoseInfo(Model*, PoseInfo*); + ExtendedPoseInfo* ReadExtendedPoseInfo(Model*); - void _CheckPoseSortOrder(PoseList *list, BPose *, int32 index); + void _CheckPoseSortOrder(PoseList* list, BPose*, int32 index); // pose creation - BPose *EntryCreated(const node_ref *, const node_ref *, const char *, int32 *index = 0); + BPose* EntryCreated(const node_ref*, const node_ref*, const char*, int32* index = 0); - void AddPoseToList(PoseList *list, bool visibleList, bool insertionSort, - BPose *pose, BRect &viewBounds, float &listViewScrollBy, - bool forceDraw, int32 *indexPtr = NULL); - BPose *CreatePose(Model *, PoseInfo *, bool insertionSort = true, - int32 *index = 0, BRect *boundsPtr = 0, bool forceDraw = true); - virtual void CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count, - BPose **resultingPoses, bool insertionSort = true, int32 *lastPoseIndexPtr = 0, - BRect *boundsPtr = 0, bool forceDraw = false); - virtual bool ShouldShowPose(const Model *, const PoseInfo *); + void AddPoseToList(PoseList* list, bool visibleList, bool insertionSort, + BPose* pose, BRect&viewBounds, float&listViewScrollBy, + bool forceDraw, int32* indexPtr = NULL); + BPose* CreatePose(Model*, PoseInfo*, bool insertionSort = true, + int32* index = 0, BRect* boundsPtr = 0, bool forceDraw = true); + virtual void CreatePoses(Model**models, PoseInfo* poseInfoArray, int32 count, + BPose**resultingPoses, bool insertionSort = true, int32* lastPoseIndexPtr = 0, + BRect* boundsPtr = 0, bool forceDraw = false); + virtual bool ShouldShowPose(const Model*, const PoseInfo*); // filter, subclasses override to control which poses show up // subclasses should always call inherited - void CreateVolumePose(BVolume *, bool watchIndividually); + void CreateVolumePose(BVolume*, bool watchIndividually); void CreateTrashPose(); - virtual bool AddPosesThreadValid(const entry_ref *) const; + virtual bool AddPosesThreadValid(const entry_ref*) const; // verifies whether or not the current set of AddPoses threads // are valid and allowed to be adding poses -- returns false // in the case where the directory has been switched while populating // the view - virtual void AddPoses(Model *model = NULL); + virtual void AddPoses(Model* model = NULL); // if is zero, PoseView has other means of iterating through all // the entries thaat it adds @@ -483,109 +483,109 @@ class BPoseView : public BView { virtual void RemoveRootPoses(); virtual void AddTrashPoses(); - virtual bool DeletePose(const node_ref *, BPose *pose = NULL, int32 index = 0); - virtual void DeleteSymLinkPoseTarget(const node_ref *itemNode, BPose *pose, + virtual bool DeletePose(const node_ref*, BPose* pose = NULL, int32 index = 0); + virtual void DeleteSymLinkPoseTarget(const node_ref* itemNode, BPose* pose, int32 index); // the pose itself wasn't deleted but it's target node was - the // pose must be a symlink - static void PoseHandleDeviceUnmounted(BPose *pose, Model *model, int32 index, - BPoseView *poseView, dev_t device); - static void RemoveNonBootDesktopModels(BPose *, Model *model, int32, - BPoseView *poseView, dev_t); + static void PoseHandleDeviceUnmounted(BPose* pose, Model* model, int32 index, + BPoseView* poseView, dev_t device); + static void RemoveNonBootDesktopModels(BPose*, Model* model, int32, + BPoseView* poseView, dev_t); // pose placement void CheckAutoPlacedPoses(); // find poses that need placing and place them in a new spot - void PlacePose(BPose *, BRect &); + void PlacePose(BPose*, BRect&); // find a new place for a pose, starting at fHintLocation and place it - bool IsValidLocation(const BPose *pose); + bool IsValidLocation(const BPose* pose); bool IsValidLocation(const BRect& rect); status_t GetDeskbarFrame(BRect* frame); bool SlotOccupied(BRect poseRect, BRect viewBounds) const; - void NextSlot(BPose *, BRect &poseRect, BRect viewBounds); - void TrySettingPoseLocation(BNode *node, BPoint point); + void NextSlot(BPose*, BRect&poseRect, BRect viewBounds); + void TrySettingPoseLocation(BNode* node, BPoint point); BPoint PinToGrid(BPoint, BPoint grid, BPoint offset) const; // zombie pose handling - Model *FindZombie(const node_ref *, int32 *index = 0); - BPose *ConvertZombieToPose(Model *zombie, int32 index); + Model* FindZombie(const node_ref*, int32* index = 0); + BPose* ConvertZombieToPose(Model* zombie, int32 index); // pose handling - BRect CalcPoseRect(const BPose *, int32 index, + BRect CalcPoseRect(const BPose*, int32 index, bool firstColumnOnly = false) const; - BRect CalcPoseRectIcon(const BPose *) const; - BRect CalcPoseRectList(const BPose *, int32 index, + BRect CalcPoseRectIcon(const BPose*) const; + BRect CalcPoseRectList(const BPose*, int32 index, bool firstColumnOnly = false) const; - void DrawPose(BPose *, int32 index, bool fullDraw = true); - void DrawViewCommon(const BRect &updateRect); + void DrawPose(BPose*, int32 index, bool fullDraw = true); + void DrawViewCommon(const BRect&updateRect); // pose list handling - int32 BSearchList(PoseList *poseList, const BPose *, int32 *index, + int32 BSearchList(PoseList* poseList, const BPose*, int32* index, int32 oldIndex); - void InsertPoseAfter(BPose *pose, int32 *index, int32 orientation, - BRect *invalidRect); + void InsertPoseAfter(BPose* pose, int32* index, int32 orientation, + BRect* invalidRect); // does a CopyBits to scroll poses making room for a new pose, // returns rectangle that needs invalidating - void CloseGapInList(BRect *invalidRect); + void CloseGapInList(BRect* invalidRect); int32 FirstIndexAtOrBelow(int32 y, bool constrainIndex = true) const; - void AddToVSList(BPose *); - int32 RemoveFromVSList(const BPose *); - BPose *FindNearbyPose(char arrow, int32 *index); - BPose *FindBestMatch(int32 *index); - BPose *FindNextMatch(int32 *index, bool reverse = false); + void AddToVSList(BPose*); + int32 RemoveFromVSList(const BPose*); + BPose* FindNearbyPose(char arrow, int32* index); + BPose* FindBestMatch(int32* index); + BPose* FindNextMatch(int32* index, bool reverse = false); // node monitoring calls virtual void StartWatching(); virtual void StopWatching(); - status_t WatchNewNode(const node_ref *item); + status_t WatchNewNode(const node_ref* item); // the above would ideally be the only call of these three and it would // be a virtual, overriding the specific watch mask in query pose view, etc. // however we need to call WatchNewNode from inside AddPosesTask while // the window is unlocked - we have to use the static and a cached // messenger and masks. - static status_t WatchNewNode(const node_ref *, uint32, BMessenger); + static status_t WatchNewNode(const node_ref*, uint32, BMessenger); virtual uint32 WatchNewNodeMask(); // override to change different watch modes for query pose view, etc. // drag&drop handling - static bool EachItemInDraggedSelection(const BMessage *message, - bool (*)(BPose *, BPoseView *, void *), BPoseView *poseView, - void * = NULL); + static bool EachItemInDraggedSelection(const BMessage* message, + bool (*)(BPose*, BPoseView*, void*), BPoseView* poseView, + void* = NULL); // iterates through each pose in current selectiond in the source // window of the current drag message; locks the window // add const version BRect GetDragRect(int32 clickedPoseIndex); - BBitmap *MakeDragBitmap(BRect dragRect, BPoint clickedPoint, int32 clickedPoseIndex, BPoint &offset); - static bool FindDragNDropAction(const BMessage *dragMessage, bool &canCopy, - bool &canMove, bool &canLink, bool &canErase); + BBitmap* MakeDragBitmap(BRect dragRect, BPoint clickedPoint, int32 clickedPoseIndex, BPoint&offset); + static bool FindDragNDropAction(const BMessage* dragMessage, bool&canCopy, + bool&canMove, bool&canLink, bool&canErase); - static bool CanTrashForeignDrag(const Model *); - static bool CanCopyOrMoveForeignDrag(const Model *, const BMessage *); - static bool DragSelectionContains(const BPose *target, const BMessage *dragMessage); - static status_t CreateClippingFile(BPoseView *poseView, BFile &result, - char *resultingName, BDirectory *dir, BMessage *message, const char *fallbackName, + static bool CanTrashForeignDrag(const Model*); + static bool CanCopyOrMoveForeignDrag(const Model*, const BMessage*); + static bool DragSelectionContains(const BPose* target, const BMessage* dragMessage); + static status_t CreateClippingFile(BPoseView* poseView, BFile&result, + char* resultingName, BDirectory* dir, BMessage* message, const char* fallbackName, bool setLocation = false, BPoint dropPoint = BPoint(0, 0)); // opening files, lanunching - void OpenSelectionCommon(BPose *, int32 *, bool); + void OpenSelectionCommon(BPose*, int32*, bool); // used by OpenSelection and OpenSelectionUsing - static void LaunchAppWithSelection(Model *, const BMessage *, bool checkTypes = true); + static void LaunchAppWithSelection(Model*, const BMessage*, bool checkTypes = true); // node monitoring calls - virtual bool EntryMoved(const BMessage *); - virtual bool AttributeChanged(const BMessage *); - virtual bool NoticeMetaMimeChanged(const BMessage *); - virtual void MetaMimeChanged(const char *, const char *); + virtual bool EntryMoved(const BMessage*); + virtual bool AttributeChanged(const BMessage*); + virtual bool NoticeMetaMimeChanged(const BMessage*); + virtual void MetaMimeChanged(const char*, const char*); // click handling - bool WasDoubleClick(const BPose *, BPoint); - bool WasClickInPath(const BPose *, int32 index, BPoint) const; + bool WasDoubleClick(const BPose*, BPoint); + bool WasClickInPath(const BPose*, int32 index, BPoint) const; // selection - void SelectPosesListMode(BRect, BList **); - void SelectPosesIconMode(BRect, BList **); - void AddRemoveSelectionRange(BPoint where, bool extendSelection, BPose *); + void SelectPosesListMode(BRect, BList**); + void SelectPosesIconMode(BRect, BList**); + void AddRemoveSelectionRange(BPoint where, bool extendSelection, BPose*); void _BeginSelectionRect(const BPoint& point, bool extendSelection); void _UpdateSelectionRect(const BPoint& point); @@ -600,90 +600,90 @@ class BPoseView : public BView { // view extent handling void RecalcExtent(); - void AddToExtent(const BRect &); + void AddToExtent(const BRect&); void ClearExtent(); - void RemoveFromExtent(const BRect &); + void RemoveFromExtent(const BRect&); virtual void EditQueries(); virtual void AddCountView(); - void HandleAttrMenuItemSelected(BMessage *); + void HandleAttrMenuItemSelected(BMessage*); void TryUpdatingBrokenLinks(); // ran a little after a volume gets mounted - void MapToNewIconMode(BPose *, BPoint oldGrid, BPoint oldOffset); + void MapToNewIconMode(BPose*, BPoint oldGrid, BPoint oldOffset); void ResetOrigin(); - void PinPointToValidRange(BPoint &); + void PinPointToValidRange(BPoint&); // used to ensure pose locations make sense after getting them // in pose info from attributes, etc. - void FinishPendingScroll(float &listViewScrollBy, BRect bounds); + void FinishPendingScroll(float&listViewScrollBy, BRect bounds); // utility call for CreatePoses // background AddPoses task calls - static status_t AddPosesTask(void *); + static status_t AddPosesTask(void*); virtual void AddPosesCompleted(); bool IsValidAddPosesThread(thread_id) const; // typeahead filtering - void EnsurePoseUnselected(BPose *pose); - void RemoveFilteredPose(BPose *pose, int32 index); + void EnsurePoseUnselected(BPose* pose); + void RemoveFilteredPose(BPose* pose, int32 index); void FilterChanged(); void UpdateAfterFilterChange(); - bool FilterPose(BPose *pose); + bool FilterPose(BPose* pose); void StartFiltering(); void StopFiltering(); void ClearFilter(); - PoseList *CurrentPoseList() const; + PoseList* CurrentPoseList() const; // misc - BList *GetDropPointList(BPoint dropPoint, BPoint startPoint, const PoseList *, + BList* GetDropPointList(BPoint dropPoint, BPoint startPoint, const PoseList*, bool sourceInListMode, bool dropOnGrid) const; void SendSelectionAsRefs(uint32 what, bool onlyQueries = false); - void MoveListToTrash(BObjectList *, bool selectNext, bool deleteDirectly); - void Delete(BObjectList *, bool selectNext, bool askUser); - void Delete(const entry_ref &ref, bool selectNext, bool askUser); - void RestoreItemsFromTrash(BObjectList *, bool selectNext); + void MoveListToTrash(BObjectList*, bool selectNext, bool deleteDirectly); + void Delete(BObjectList*, bool selectNext, bool askUser); + void Delete(const entry_ref&ref, bool selectNext, bool askUser); + void RestoreItemsFromTrash(BObjectList*, bool selectNext); private: void DrawOpenAnimation(BRect); - void MoveSelectionOrEntryToTrash(const entry_ref *ref, bool selectNext); + void MoveSelectionOrEntryToTrash(const entry_ref* ref, bool selectNext); protected: - BHScrollBar *fHScrollBar; - BScrollBar *fVScrollBar; - Model *fModel; - BPose *fActivePose; + BHScrollBar* fHScrollBar; + BScrollBar* fVScrollBar; + Model* fModel; + BPose* fActivePose; BRect fExtent; // the following should probably be just member lists, not pointers - PoseList *fPoseList; - PoseList *fFilteredPoseList; - PoseList *fVSPoseList; - PoseList *fSelectionList; + PoseList* fPoseList; + PoseList* fFilteredPoseList; + PoseList* fVSPoseList; + PoseList* fSelectionList; NodeSet fInsertedNodes; BObjectList fMimeTypesInSelectionCache; // used for mime string based icon highliting during a drag - BObjectList *fZombieList; + BObjectList* fZombieList; PendingNodeMonitorCache pendingNodeMonitorCache; - BObjectList *fColumnList; - BObjectList *fMimeTypeList; + BObjectList* fColumnList; + BObjectList* fMimeTypeList; bool fMimeTypeListIsDirty; - BViewState *fViewState; + BViewState* fViewState; bool fStateNeedsSaving; - BCountView *fCountView; + BCountView* fCountView; float fListElemHeight; float fIconPoseHeight; - BPose *fDropTarget; - BPose *fAlreadySelectedDropTarget; - BLooper *fSelectionHandler; + BPose* fDropTarget; + BPose* fAlreadySelectedDropTarget; + BLooper* fSelectionHandler; BPoint fLastClickPt; bigtime_t fLastClickTime; - const BPose *fLastClickedPose; + const BPose* fLastClickedPose; BPoint fLastLeftTop; BRect fLastExtent; - BTitleView *fTitleView; - BRefFilter *fRefFilter; + BTitleView* fTitleView; + BRefFilter* fRefFilter; BPoint fGrid; BPoint fOffset; BPoint fHintLocation; @@ -691,9 +691,9 @@ class BPoseView : public BView { int32 fAutoScrollState; std::set fAddPosesThreads; bool fWidgetTextOutline; - const BPose *fSelectionPivotPose; - const BPose *fRealPivotPose; - BMessageRunner *fKeyRunner; + const BPose* fSelectionPivotPose; + const BPose* fRealPivotPose; + BMessageRunner* fKeyRunner; bool fTrackRightMouseUp; struct SelectionRectInfo { @@ -743,7 +743,7 @@ class BPoseView : public BView { bigtime_t fLastDeskbarFrameCheckTime; BRect fDeskbarFrame; - static OffscreenBitmap *sOffscreen; + static OffscreenBitmap* sOffscreen; typedef BView _inherited; }; @@ -751,14 +751,14 @@ class BPoseView : public BView { class BHScrollBar : public BScrollBar { public: - BHScrollBar(BRect, const char *, BView *); - void SetTitleView(BView *); + BHScrollBar(BRect, const char*, BView*); + void SetTitleView(BView*); // BScrollBar overrides virtual void ValueChanged(float); private: - BView *fTitleView; + BView* fTitleView; typedef BScrollBar _inherited; }; @@ -766,30 +766,30 @@ class BHScrollBar : public BScrollBar { class TPoseViewFilter : public BMessageFilter { public: - TPoseViewFilter(BPoseView *pose); + TPoseViewFilter(BPoseView* pose); ~TPoseViewFilter(); - filter_result Filter(BMessage *, BHandler **); + filter_result Filter(BMessage*, BHandler**); private: - filter_result ObjectDropFilter(BMessage *, BHandler **); + filter_result ObjectDropFilter(BMessage*, BHandler**); - BPoseView *fPoseView; + BPoseView* fPoseView; }; extern bool -ClearViewOriginOne(const char *name, uint32 type, off_t size, void *data, void *params); +ClearViewOriginOne(const char* name, uint32 type, off_t size, void* data, void* params); // inlines follow -inline BContainerWindow * +inline BContainerWindow* BPoseView::ContainerWindow() const { - return dynamic_cast(Window()); + return dynamic_cast(Window()); } -inline Model * +inline Model* BPoseView::TargetModel() const { return fModel; @@ -819,16 +819,16 @@ BPoseView::IconSize() const return (icon_size)fViewState->IconSize(); } -inline PoseList * +inline PoseList* BPoseView::SelectionList() const { return fSelectionList; } -inline BObjectList * +inline BObjectList* BPoseView::MimeTypesInSelection() { - return &fMimeTypesInSelectionCache; + return&fMimeTypesInSelectionCache; } inline BHScrollBar* @@ -873,7 +873,7 @@ BPoseView::FontHeight() const return sFontHeight; } -inline BPose * +inline BPose* BPoseView::ActivePose() const { return fActivePose; @@ -946,7 +946,7 @@ BPoseView::SetIconMapping(bool on) } inline void -BPoseView::AddToExtent(const BRect &rect) +BPoseView::AddToExtent(const BRect&rect) { fExtent = fExtent | rect; } @@ -966,34 +966,34 @@ BPoseView::CountColumns() const inline int32 BPoseView::IndexOfColumn(const BColumn* column) const { - return fColumnList->IndexOf(const_cast(column)); + return fColumnList->IndexOf(const_cast(column)); } inline int32 -BPoseView::IndexOfPose(const BPose *pose) const +BPoseView::IndexOfPose(const BPose* pose) const { return CurrentPoseList()->IndexOf(pose); } -inline BPose * +inline BPose* BPoseView::PoseAtIndex(int32 index) const { return CurrentPoseList()->ItemAt(index); } -inline BColumn * +inline BColumn* BPoseView::ColumnAt(int32 index) const { return fColumnList->ItemAt(index); } -inline BColumn * +inline BColumn* BPoseView::FirstColumn() const { return fColumnList->FirstItem(); } -inline BColumn * +inline BColumn* BPoseView::LastColumn() const { return fColumnList->LastItem(); @@ -1061,43 +1061,43 @@ BPoseView::SetEnsurePosesVisible(bool state) } inline void -BPoseView::SetSelectionHandler(BLooper *looper) +BPoseView::SetSelectionHandler(BLooper* looper) { fSelectionHandler = looper; } inline void -BPoseView::SetRefFilter(BRefFilter *filter) +BPoseView::SetRefFilter(BRefFilter* filter) { fRefFilter = filter; } -inline BRefFilter * +inline BRefFilter* BPoseView::RefFilter() const { return fRefFilter; } inline void -BHScrollBar::SetTitleView(BView *view) +BHScrollBar::SetTitleView(BView* view) { fTitleView = view; } -inline BPose * -BPoseView::FindPose(const Model *model, int32 *index) const +inline BPose* +BPoseView::FindPose(const Model* model, int32* index) const { return CurrentPoseList()->FindPose(model, index); } -inline BPose * -BPoseView::FindPose(const node_ref *node, int32 *index) const +inline BPose* +BPoseView::FindPose(const node_ref* node, int32* index) const { return CurrentPoseList()->FindPose(node, index); } -inline BPose * -BPoseView::FindPose(const entry_ref *entry, int32 *index) const +inline BPose* +BPoseView::FindPose(const entry_ref* entry, int32* index) const { return CurrentPoseList()->FindPose(entry, index); } @@ -1117,7 +1117,7 @@ BPoseView::SetHasPosesInClipboard(bool hasPoses) } -inline PoseList * +inline PoseList* BPoseView::CurrentPoseList() const { return fFiltering ? fFilteredPoseList : fPoseList; @@ -1126,15 +1126,15 @@ BPoseView::CurrentPoseList() const template void -EachTextWidget(BPose *pose, BPoseView *poseView, - void (*func)(BTextWidget *, BPose *, BPoseView *, BColumn *, Param1), Param1 p1) +EachTextWidget(BPose* pose, BPoseView* poseView, + void (*func)(BTextWidget*, BPose*, BPoseView*, BColumn*, Param1), Param1 p1) { for (int32 index = 0; ;index++) { - BColumn *column = poseView->ColumnAt(index); + BColumn* column = poseView->ColumnAt(index); if (!column) break; - BTextWidget *widget = pose->WidgetFor(column->AttrHash()); + BTextWidget* widget = pose->WidgetFor(column->AttrHash()); if (widget) (func)(widget, pose, poseView, column, p1); } @@ -1143,16 +1143,16 @@ EachTextWidget(BPose *pose, BPoseView *poseView, template void -EachTextWidget(BPose *pose, BPoseView *poseView, - void (*func)(BTextWidget *, BPose *, BPoseView *, BColumn *, +EachTextWidget(BPose* pose, BPoseView* poseView, + void (*func)(BTextWidget*, BPose*, BPoseView*, BColumn*, Param1, Param2), Param1 p1, Param2 p2) { for (int32 index = 0; ;index++) { - BColumn *column = poseView->ColumnAt(index); + BColumn* column = poseView->ColumnAt(index); if (!column) break; - BTextWidget *widget = pose->WidgetFor(column->AttrHash()); + BTextWidget* widget = pose->WidgetFor(column->AttrHash()); if (widget) (func)(widget, pose, poseView, column, p1, p2); } @@ -1161,16 +1161,16 @@ EachTextWidget(BPose *pose, BPoseView *poseView, template Result -WhileEachTextWidget(BPose *pose, BPoseView *poseView, - Result (*func)(BTextWidget *, BPose *, BPoseView *, BColumn *, +WhileEachTextWidget(BPose* pose, BPoseView* poseView, + Result (*func)(BTextWidget*, BPose*, BPoseView*, BColumn*, Param1, Param2), Param1 p1, Param2 p2) { for (int32 index = 0; ;index++) { - BColumn *column = poseView->ColumnAt(index); + BColumn* column = poseView->ColumnAt(index); if (!column) break; - BTextWidget *widget = pose->WidgetFor(column->AttrHash()); + BTextWidget* widget = pose->WidgetFor(column->AttrHash()); if (widget) { Result result = (func)(widget, pose, poseView, column, p1, p2); if (result) @@ -1185,4 +1185,4 @@ WhileEachTextWidget(BPose *pose, BPoseView *poseView, using namespace BPrivate; -#endif /* _POSE_VIEW_H */ +#endif // _POSE_VIEW_H diff --git a/src/kits/tracker/PoseViewScripting.cpp b/src/kits/tracker/PoseViewScripting.cpp index 51a76d493c..d668e6dd9a 100644 --- a/src/kits/tracker/PoseViewScripting.cpp +++ b/src/kits/tracker/PoseViewScripting.cpp @@ -203,12 +203,13 @@ const property_info kPosesPropertyList[] = { #endif + status_t -BPoseView::GetSupportedSuites(BMessage *_SCRIPTING_ONLY(data)) +BPoseView::GetSupportedSuites(BMessage* _SCRIPTING_ONLY(data)) { #if _SUPPORTS_FEATURE_SCRIPTING data->AddString("suites", kPosesSuites); - BPropertyInfo propertyInfo(const_cast(kPosesPropertyList)); + BPropertyInfo propertyInfo(const_cast(kPosesPropertyList)); data->AddFlat("messages", &propertyInfo); return _inherited::GetSupportedSuites(data); @@ -217,8 +218,9 @@ BPoseView::GetSupportedSuites(BMessage *_SCRIPTING_ONLY(data)) #endif } + bool -BPoseView::HandleScriptingMessage(BMessage *_SCRIPTING_ONLY(message)) +BPoseView::HandleScriptingMessage(BMessage* _SCRIPTING_ONLY(message)) { #if _SUPPORTS_FEATURE_SCRIPTING if (message->what != B_GET_PROPERTY @@ -231,7 +233,7 @@ BPoseView::HandleScriptingMessage(BMessage *_SCRIPTING_ONLY(message)) // dispatch scripting messages BMessage reply(B_REPLY); - const char *property = 0; + const char* property = 0; bool handled = false; int32 index = 0; @@ -240,7 +242,7 @@ BPoseView::HandleScriptingMessage(BMessage *_SCRIPTING_ONLY(message)) status_t result = message->GetCurrentSpecifier(&index, &specifier, &form, &property); - if (result != B_OK || index == -1) + if (result != B_OK || index == -1) return false; ASSERT(property); @@ -271,19 +273,22 @@ BPoseView::HandleScriptingMessage(BMessage *_SCRIPTING_ONLY(message)) break; } - if (handled) + if (handled) { // done handling message, send a reply message->SendReply(&reply); + } + return handled; #else return false; #endif } + bool -BPoseView::ExecuteProperty(BMessage *_SCRIPTING_ONLY(specifier), - int32 _SCRIPTING_ONLY(form), const char *_SCRIPTING_ONLY(property), - BMessage *_SCRIPTING_ONLY(reply)) +BPoseView::ExecuteProperty(BMessage* _SCRIPTING_ONLY(specifier), + int32 _SCRIPTING_ONLY(form), const char* _SCRIPTING_ONLY(property), + BMessage* _SCRIPTING_ONLY(reply)) { #if _SUPPORTS_FEATURE_SCRIPTING status_t error = B_OK; @@ -303,7 +308,7 @@ BPoseView::ExecuteProperty(BMessage *_SCRIPTING_ONLY(specifier), int32 specifyingIndex; for (int32 index = 0; specifier->FindInt32("index", index, &specifyingIndex) == B_OK; index++) { - BPose *pose = PoseAtIndex(specifyingIndex); + BPose* pose = PoseAtIndex(specifyingIndex); if (!pose) { error = B_ENTRY_NOT_FOUND; @@ -334,10 +339,11 @@ BPoseView::ExecuteProperty(BMessage *_SCRIPTING_ONLY(specifier), #endif } + bool -BPoseView::CreateProperty(BMessage *_SCRIPTING_ONLY(specifier), BMessage *, - int32 _SCRIPTING_ONLY(form), const char *_SCRIPTING_ONLY(property), - BMessage *_SCRIPTING_ONLY(reply)) +BPoseView::CreateProperty(BMessage* _SCRIPTING_ONLY(specifier), BMessage*, + int32 _SCRIPTING_ONLY(form), const char* _SCRIPTING_ONLY(property), + BMessage* _SCRIPTING_ONLY(reply)) { #if _SUPPORTS_FEATURE_SCRIPTING status_t error = B_OK; @@ -357,7 +363,7 @@ BPoseView::CreateProperty(BMessage *_SCRIPTING_ONLY(specifier), BMessage *, == B_OK; index++) { int32 poseIndex; - BPose *pose = FindPose(&ref, form, &poseIndex); + BPose* pose = FindPose(&ref, form, &poseIndex); if (!pose) { error = B_ENTRY_NOT_FOUND; @@ -374,7 +380,7 @@ BPoseView::CreateProperty(BMessage *_SCRIPTING_ONLY(specifier), BMessage *, for (int32 index = 0; specifier->FindInt32("data", index, &specifyingIndex) == B_OK; index++) { - BPose *pose = PoseAtIndex(specifyingIndex); + BPose* pose = PoseAtIndex(specifyingIndex); if (!pose) { error = B_BAD_INDEX; handled = true; @@ -396,10 +402,11 @@ BPoseView::CreateProperty(BMessage *_SCRIPTING_ONLY(specifier), BMessage *, #endif } + bool -BPoseView::DeleteProperty(BMessage *_SCRIPTING_ONLY(specifier), - int32 _SCRIPTING_ONLY(form), const char *_SCRIPTING_ONLY(property), - BMessage *_SCRIPTING_ONLY(reply)) +BPoseView::DeleteProperty(BMessage* _SCRIPTING_ONLY(specifier), + int32 _SCRIPTING_ONLY(form), const char* _SCRIPTING_ONLY(property), + BMessage* _SCRIPTING_ONLY(reply)) { #if _SUPPORTS_FEATURE_SCRIPTING status_t error = B_OK; @@ -416,7 +423,7 @@ BPoseView::DeleteProperty(BMessage *_SCRIPTING_ONLY(specifier), == B_OK; index++) { int32 poseIndex; - BPose *pose = FindPose(&ref, form, &poseIndex); + BPose* pose = FindPose(&ref, form, &poseIndex); if (!pose) { error = B_ENTRY_NOT_FOUND; @@ -432,7 +439,7 @@ BPoseView::DeleteProperty(BMessage *_SCRIPTING_ONLY(specifier), int32 specifyingIndex; for (int32 index = 0; specifier->FindInt32("index", index, &specifyingIndex) == B_OK; index++) { - BPose *pose = PoseAtIndex(specifyingIndex); + BPose* pose = PoseAtIndex(specifyingIndex); if (!pose) { error = B_BAD_INDEX; @@ -449,8 +456,8 @@ BPoseView::DeleteProperty(BMessage *_SCRIPTING_ONLY(specifier), // deleting entries is handled by moving entries to trash // build a list of entries, specified by the specifier - BObjectList *entryList = new BObjectList(); - // list will be deleted for us by the trashing thread + BObjectList* entryList = new BObjectList(); + // list will be deleted for us by the trashing thread if (form == (int32)B_ENTRY_SPECIFIER) { // move all poses specified by entry_ref to Trash @@ -464,7 +471,7 @@ BPoseView::DeleteProperty(BMessage *_SCRIPTING_ONLY(specifier), int32 specifyingIndex; for (int32 index = 0; specifier->FindInt32("index", index, &specifyingIndex) == B_OK; index++) { - BPose *pose = PoseAtIndex(specifyingIndex); + BPose* pose = PoseAtIndex(specifyingIndex); if (!pose) { error = B_BAD_INDEX; @@ -498,9 +505,10 @@ BPoseView::DeleteProperty(BMessage *_SCRIPTING_ONLY(specifier), #endif } + bool -BPoseView::CountProperty(BMessage *, int32, const char *_SCRIPTING_ONLY(property), - BMessage *_SCRIPTING_ONLY(reply)) +BPoseView::CountProperty(BMessage*, int32, const char* _SCRIPTING_ONLY(property), + BMessage* _SCRIPTING_ONLY(reply)) { #if _SUPPORTS_FEATURE_SCRIPTING bool handled = false; @@ -520,10 +528,11 @@ BPoseView::CountProperty(BMessage *, int32, const char *_SCRIPTING_ONLY(property #endif } + bool -BPoseView::GetProperty(BMessage *_SCRIPTING_ONLY(specifier), - int32 _SCRIPTING_ONLY(form), const char *_SCRIPTING_ONLY(property), - BMessage *_SCRIPTING_ONLY(reply)) +BPoseView::GetProperty(BMessage* _SCRIPTING_ONLY(specifier), + int32 _SCRIPTING_ONLY(form), const char* _SCRIPTING_ONLY(property), + BMessage* _SCRIPTING_ONLY(reply)) { #if _SUPPORTS_FEATURE_SCRIPTING // PRINT(("GetProperty %s\n", property)); @@ -535,7 +544,7 @@ BPoseView::GetProperty(BMessage *_SCRIPTING_ONLY(specifier), handled = true; if (!TargetModel()) error = B_NOT_A_DIRECTORY; - else + else reply->AddRef("result", TargetModel()->EntryRef()); } } else if (strcmp(property, kPropertySelection) == 0) { @@ -543,7 +552,7 @@ BPoseView::GetProperty(BMessage *_SCRIPTING_ONLY(specifier), switch (form) { case B_DIRECT_SPECIFIER: // return entries of all poses in selection - for (int32 index = 0; index < count; index++) + for (int32 index = 0; index < count; index++) reply->AddRef("result", fSelectionList->ItemAt(index)-> TargetModel()->EntryRef()); @@ -560,7 +569,7 @@ BPoseView::GetProperty(BMessage *_SCRIPTING_ONLY(specifier), break; int32 poseIndex; - BPose *pose = FindPose(&ref, &poseIndex); + BPose* pose = FindPose(&ref, &poseIndex); for (;;) { if (form == (int32)kPreviousSpecifier) @@ -588,52 +597,56 @@ BPoseView::GetProperty(BMessage *_SCRIPTING_ONLY(specifier), int32 count = fPoseList->CountItems(); switch (form) { case B_DIRECT_SPECIFIER: + { // return all entries of all poses in PoseView - for (int32 index = 0; index < count; index++) + for (int32 index = 0; index < count; index++) reply->AddRef("result", PoseAtIndex(index)->TargetModel()->EntryRef()); handled = true; break; + } + case B_INDEX_SPECIFIER: - { - // return entry at index - int32 index; - if (specifier->FindInt32("index", &index) != B_OK) - break; - - if (!PoseAtIndex(index)) { - error = B_BAD_INDEX; - handled = true; - break; - } - reply->AddRef("result", PoseAtIndex(index)->TargetModel()->EntryRef()); - + { + // return entry at index + int32 index; + if (specifier->FindInt32("index", &index) != B_OK) + break; + + if (!PoseAtIndex(index)) { + error = B_BAD_INDEX; handled = true; break; } + reply->AddRef("result", PoseAtIndex(index)->TargetModel()->EntryRef()); + + handled = true; + break; + } + case kPreviousSpecifier: case kNextSpecifier: - { - // return entry and index of pose before or after specified pose - entry_ref ref; - if (specifier->FindRef("data", &ref) != B_OK) - break; - - int32 tmp; - BPose *pose = FindPose(&ref, form, &tmp); - - if (!pose) { - error = B_ENTRY_NOT_FOUND; - handled = true; - break; - } - - reply->AddRef("result", pose->TargetModel()->EntryRef()); - reply->AddInt32("index", IndexOfPose(pose)); - + { + // return entry and index of pose before or after specified pose + entry_ref ref; + if (specifier->FindRef("data", &ref) != B_OK) + break; + + int32 tmp; + BPose* pose = FindPose(&ref, form, &tmp); + + if (!pose) { + error = B_ENTRY_NOT_FOUND; handled = true; break; } + + reply->AddRef("result", pose->TargetModel()->EntryRef()); + reply->AddInt32("index", IndexOfPose(pose)); + + handled = true; + break; + } } } @@ -646,10 +659,11 @@ BPoseView::GetProperty(BMessage *_SCRIPTING_ONLY(specifier), #endif } + bool -BPoseView::SetProperty(BMessage *_SCRIPTING_ONLY(message), BMessage *, - int32 _SCRIPTING_ONLY(form), const char *_SCRIPTING_ONLY(property), - BMessage *_SCRIPTING_ONLY(reply)) +BPoseView::SetProperty(BMessage* _SCRIPTING_ONLY(message), BMessage*, + int32 _SCRIPTING_ONLY(form), const char* _SCRIPTING_ONLY(property), + BMessage* _SCRIPTING_ONLY(reply)) { #if _SUPPORTS_FEATURE_SCRIPTING status_t error = B_OK; @@ -660,56 +674,55 @@ BPoseView::SetProperty(BMessage *_SCRIPTING_ONLY(message), BMessage *, switch (form) { case B_DIRECT_SPECIFIER: - { - int32 selStart; - int32 selEnd; - if (message->FindInt32("data", 0, &selStart) == B_OK - && message->FindInt32("data", 1, &selEnd) == B_OK) { + { + int32 selStart; + int32 selEnd; + if (message->FindInt32("data", 0, &selStart) == B_OK + && message->FindInt32("data", 1, &selEnd) == B_OK) { - if (selStart < 0 || selStart >= fPoseList->CountItems() - || selEnd < 0 || selEnd >= fPoseList->CountItems()) { - error = B_BAD_INDEX; - handled = true; - break; - } - - SelectPoses(selStart, selEnd); + if (selStart < 0 || selStart >= fPoseList->CountItems() + || selEnd < 0 || selEnd >= fPoseList->CountItems()) { + error = B_BAD_INDEX; handled = true; break; } + + SelectPoses(selStart, selEnd); + handled = true; + break; } - // fall thru + } // fall thru case kPreviousSpecifier: case kNextSpecifier: - { - // PRINT(("SetProperty direct/previous/next %s\n", property)); - // select/unselect poses specified by entries - bool clearSelection = true; - for (int32 index = 0; message->FindRef("data", index, &ref) - == B_OK; index++) { - - int32 poseIndex; - BPose *pose = FindPose(&ref, form, &poseIndex); - - if (!pose) { - error = B_ENTRY_NOT_FOUND; - handled = true; - break; - } - - if (clearSelection) { - // first selected item must call SelectPose so the selection - // gets cleared first - SelectPose(pose, poseIndex); - clearSelection = false; - } else - AddPoseToSelection(pose, poseIndex); + { + // PRINT(("SetProperty direct/previous/next %s\n", property)); + // select/unselect poses specified by entries + bool clearSelection = true; + for (int32 index = 0; message->FindRef("data", index, &ref) + == B_OK; index++) { + int32 poseIndex; + BPose* pose = FindPose(&ref, form, &poseIndex); + + if (!pose) { + error = B_ENTRY_NOT_FOUND; handled = true; + break; } - break; - } - } + + if (clearSelection) { + // first selected item must call SelectPose so the selection + // gets cleared first + SelectPose(pose, poseIndex); + clearSelection = false; + } else + AddPoseToSelection(pose, poseIndex); + + handled = true; + } + break; + } + } } if (error != B_OK) @@ -721,13 +734,14 @@ BPoseView::SetProperty(BMessage *_SCRIPTING_ONLY(message), BMessage *, #endif } -BHandler * -BPoseView::ResolveSpecifier(BMessage *_SCRIPTING_ONLY(message), - int32 _SCRIPTING_ONLY(index), BMessage *_SCRIPTING_ONLY(specifier), - int32 _SCRIPTING_ONLY(form), const char *_SCRIPTING_ONLY(property)) + +BHandler* +BPoseView::ResolveSpecifier(BMessage* _SCRIPTING_ONLY(message), + int32 _SCRIPTING_ONLY(index), BMessage* _SCRIPTING_ONLY(specifier), + int32 _SCRIPTING_ONLY(form), const char* _SCRIPTING_ONLY(property)) { #if _SUPPORTS_FEATURE_SCRIPTING - BPropertyInfo propertyInfo(const_cast(kPosesPropertyList)); + BPropertyInfo propertyInfo(const_cast(kPosesPropertyList)); int32 result = propertyInfo.FindMatch(message, index, specifier, form, property); if (result < 0) { @@ -742,14 +756,15 @@ BPoseView::ResolveSpecifier(BMessage *_SCRIPTING_ONLY(message), #endif } -BPose * -BPoseView::FindPose(const entry_ref *_SCRIPTING_ONLY(ref), - int32 _SCRIPTING_ONLY(specifierForm), int32 *_SCRIPTING_ONLY(index)) const + +BPose* +BPoseView::FindPose(const entry_ref* _SCRIPTING_ONLY(ref), + int32 _SCRIPTING_ONLY(specifierForm), int32* _SCRIPTING_ONLY(index)) const { #if _SUPPORTS_FEATURE_SCRIPTING // flavor of FindPose, used by previous/next specifiers - BPose *pose = FindPose(ref, index); + BPose* pose = FindPose(ref, index); if (specifierForm == (int32)kPreviousSpecifier) return PoseAtIndex(--*index); @@ -761,4 +776,3 @@ BPoseView::FindPose(const entry_ref *_SCRIPTING_ONLY(ref), return NULL; #endif } - diff --git a/src/kits/tracker/PublicCommands.h b/src/kits/tracker/PublicCommands.h index bb18e0eafc..daa7be0c2a 100644 --- a/src/kits/tracker/PublicCommands.h +++ b/src/kits/tracker/PublicCommands.h @@ -31,12 +31,13 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef __PUBLIC_COMMANDS__ #define __PUBLIC_COMMANDS__ + #include + // commands that may be issued to the tracker by other apps using messengers namespace BPrivate { @@ -56,4 +57,4 @@ const uint32 kFSClipboardChanges = 'TCch'; using namespace BPrivate; -#endif /* __PUBLIC_COMMANDS__ */ +#endif // __PUBLIC_COMMANDS__ diff --git a/src/kits/tracker/QueryContainerWindow.cpp b/src/kits/tracker/QueryContainerWindow.cpp index 5f5763a719..748de2b8f1 100644 --- a/src/kits/tracker/QueryContainerWindow.cpp +++ b/src/kits/tracker/QueryContainerWindow.cpp @@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include #include #include @@ -50,7 +51,7 @@ All rights reserved. #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "QueryContainerWindow" -BQueryContainerWindow::BQueryContainerWindow(LockingList *windowList, +BQueryContainerWindow::BQueryContainerWindow(LockingList* windowList, uint32 containerWindowFlags, window_look look, window_feel feel, uint32 flags, uint32 workspace) : BContainerWindow(windowList, containerWindowFlags, look, feel, @@ -59,22 +60,22 @@ BQueryContainerWindow::BQueryContainerWindow(LockingList *windowList, } -BPoseView * -BQueryContainerWindow::NewPoseView(Model *model, BRect rect, uint32) +BPoseView* +BQueryContainerWindow::NewPoseView(Model* model, BRect rect, uint32) { return new BQueryPoseView(model, rect); } -BQueryPoseView * +BQueryPoseView* BQueryContainerWindow::PoseView() const { - return static_cast(fPoseView); + return static_cast(fPoseView); } void -BQueryContainerWindow::CreatePoseView(Model *model) +BQueryContainerWindow::CreatePoseView(Model* model) { BRect rect(Bounds()); rect.right -= B_V_SCROLL_BAR_WIDTH; @@ -86,9 +87,9 @@ BQueryContainerWindow::CreatePoseView(Model *model) void -BQueryContainerWindow::AddWindowMenu(BMenu *menu) +BQueryContainerWindow::AddWindowMenu(BMenu* menu) { - BMenuItem *item; + BMenuItem* item; item = new BMenuItem(B_TRANSLATE("Resize to fit"), new BMessage(kResizeToFit), 'Y'); @@ -117,8 +118,8 @@ BQueryContainerWindow::AddWindowMenu(BMenu *menu) } -void -BQueryContainerWindow::AddWindowContextMenus(BMenu *menu) +void +BQueryContainerWindow::AddWindowContextMenus(BMenu* menu) { BMenuItem* resizeItem = new BMenuItem(B_TRANSLATE("Resize to fit"), new BMessage(kResizeToFit), 'Y'); @@ -137,7 +138,7 @@ BQueryContainerWindow::AddWindowContextMenus(BMenu *menu) } -void +void BQueryContainerWindow::SetUpDefaultState() { BNode defaultingNode; @@ -152,7 +153,7 @@ BQueryContainerWindow::SetUpDefaultState() defaultStatePath += '/'; int32 length = sanitizedType.Length(); - char *buf = sanitizedType.LockBuffer(length); + char* buf = sanitizedType.LockBuffer(length); for (int32 index = length - 1; index >= 0; index--) if (buf[index] == '/') buf[index] = '_'; @@ -170,7 +171,7 @@ BQueryContainerWindow::SetUpDefaultState() // copy over the attributes // set up a filter of the attributes we want copied - const char *allowAttrs[] = { + const char* allowAttrs[] = { kAttrWindowFrame, kAttrViewState, kAttrViewStateForeign, @@ -187,9 +188,8 @@ BQueryContainerWindow::SetUpDefaultState() } -bool +bool BQueryContainerWindow::ActiveOnDevice(dev_t device) const { return PoseView()->ActiveOnDevice(device); } - diff --git a/src/kits/tracker/QueryContainerWindow.h b/src/kits/tracker/QueryContainerWindow.h index 228c1d1d09..dfbb1a6acf 100644 --- a/src/kits/tracker/QueryContainerWindow.h +++ b/src/kits/tracker/QueryContainerWindow.h @@ -31,39 +31,40 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - -#ifndef _QUERY_CONTAINER_WINDOW_H +#ifndef _QUERY_CONTAINER_WINDOW_H #define _QUERY_CONTAINER_WINDOW_H -#include "ContainerWindow.h" - -namespace BPrivate { // Container window specificaly used for displaying BQueryPoseViews // Adds query window specific menus +#include "ContainerWindow.h" + + +namespace BPrivate { + #define kQueryTemplates "DefaultQueryTemplates" class BQueryPoseView; class BQueryContainerWindow : public BContainerWindow { public: - BQueryContainerWindow(LockingList *windowList, + BQueryContainerWindow(LockingList* windowList, uint32 containerWindowFlags, window_look look = B_DOCUMENT_WINDOW_LOOK, - window_feel feel = B_NORMAL_WINDOW_FEEL, + window_feel feel = B_NORMAL_WINDOW_FEEL, uint32 flags = B_WILL_ACCEPT_FIRST_CLICK | B_NO_WORKSPACE_ACTIVATION, uint32 workspace = B_CURRENT_WORKSPACE); - BQueryPoseView *PoseView() const; + BQueryPoseView* PoseView() const; bool ActiveOnDevice(dev_t) const; protected: - virtual void CreatePoseView(Model *); - virtual BPoseView *NewPoseView(Model *model, BRect rect, uint32 viewMode); - virtual void AddWindowMenu(BMenu *menu); - virtual void AddWindowContextMenus(BMenu *menu); + virtual void CreatePoseView(Model*); + virtual BPoseView* NewPoseView(Model* model, BRect rect, uint32 viewMode); + virtual void AddWindowMenu(BMenu* menu); + virtual void AddWindowContextMenus(BMenu* menu); virtual void SetUpDefaultState(); @@ -75,4 +76,4 @@ private: using namespace BPrivate; -#endif +#endif // _QUERY_CONTAINER_WINDOW_H diff --git a/src/kits/tracker/QueryPoseView.cpp b/src/kits/tracker/QueryPoseView.cpp index 80948de6a0..bd17d1da77 100644 --- a/src/kits/tracker/QueryPoseView.cpp +++ b/src/kits/tracker/QueryPoseView.cpp @@ -31,6 +31,8 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + + #include "QueryPoseView.h" #include @@ -69,7 +71,7 @@ using std::nothrow; // query results and add/remove appropriately. Right now only moving to // Trash is supported -BQueryPoseView::BQueryPoseView(Model *model, BRect frame, uint32 resizeMask) +BQueryPoseView::BQueryPoseView(Model* model, BRect frame, uint32 resizeMask) : BPoseView(model, frame, kListMode, resizeMask), fShowResultsFromTrash(false), fQueryList(NULL), @@ -85,8 +87,8 @@ BQueryPoseView::~BQueryPoseView() } -void -BQueryPoseView::MessageReceived(BMessage *message) +void +BQueryPoseView::MessageReceived(BMessage* message) { switch (message->what) { case kFSClipboardChanges: @@ -103,7 +105,7 @@ BQueryPoseView::MessageReceived(BMessage *message) } -void +void BQueryPoseView::EditQueries() { BMessage message(kEditQuery); @@ -139,15 +141,15 @@ BQueryPoseView::AttachedToWindow() } -void -BQueryPoseView::RestoreState(AttributeStreamNode *node) +void +BQueryPoseView::RestoreState(AttributeStreamNode* node) { _inherited::RestoreState(node); fViewState->SetViewMode(kListMode); } -void +void BQueryPoseView::RestoreState(const BMessage &message) { _inherited::RestoreState(message); @@ -155,25 +157,25 @@ BQueryPoseView::RestoreState(const BMessage &message) } -void -BQueryPoseView::SavePoseLocations(BRect *) +void +BQueryPoseView::SavePoseLocations(BRect*) { } -void +void BQueryPoseView::SetViewMode(uint32) { } -void +void BQueryPoseView::OpenParent() { } -void +void BQueryPoseView::Refresh() { PRINT(("refreshing dynamic date query\n")); @@ -182,7 +184,7 @@ BQueryPoseView::Refresh() fAddPosesThreads.clear(); delete fQueryListContainer; fQueryListContainer = NULL; - + fCreateOldPoseList = true; AddPoses(TargetModel()); TargetModel()->CloseNode(); @@ -193,22 +195,22 @@ BQueryPoseView::Refresh() bool -BQueryPoseView::ShouldShowPose(const Model *model, const PoseInfo *poseInfo) +BQueryPoseView::ShouldShowPose(const Model* model, const PoseInfo* poseInfo) { // add_poses, etc. filter ASSERT(TargetModel()); if (!fShowResultsFromTrash - && dynamic_cast(be_app)->InTrashNode(model->EntryRef())) + && dynamic_cast(be_app)->InTrashNode(model->EntryRef())) return false; bool result = _inherited::ShouldShowPose(model, poseInfo); - PoseList *oldPoseList = fQueryListContainer->OldPoseList(); + PoseList* oldPoseList = fQueryListContainer->OldPoseList(); if (result && oldPoseList) { // pose will get added - remove it from the old pose list // because it is supposed to be showing - BPose *pose = oldPoseList->FindPose(model); + BPose* pose = oldPoseList->FindPose(model); if (pose) oldPoseList->RemoveItem(pose); } @@ -216,16 +218,16 @@ BQueryPoseView::ShouldShowPose(const Model *model, const PoseInfo *poseInfo) } -void +void BQueryPoseView::AddPosesCompleted() { ASSERT(Window()->IsLocked()); - PoseList *oldPoseList = fQueryListContainer->OldPoseList(); + PoseList* oldPoseList = fQueryListContainer->OldPoseList(); if (oldPoseList) { int32 count = oldPoseList->CountItems(); for (int32 index = count - 1; index >= 0; index--) { - BPose *pose = oldPoseList->ItemAt(index); + BPose* pose = oldPoseList->ItemAt(index); DeletePose(pose->TargetModel()->NodeRef()); } fQueryListContainer->ClearOldPoseList(); @@ -238,22 +240,22 @@ BQueryPoseView::AddPosesCompleted() // When using dynamic dates, such as "today", need to refresh the query // window every now and then -EntryListBase * -BQueryPoseView::InitDirentIterator(const entry_ref *ref) +EntryListBase* +BQueryPoseView::InitDirentIterator(const entry_ref* ref) { BEntry entry(ref); - if (entry.InitCheck() != B_OK) + if (entry.InitCheck() != B_OK) return NULL; Model sourceModel(&entry, true); - if (sourceModel.InitCheck() != B_OK) + if (sourceModel.InitCheck() != B_OK) return NULL; ASSERT(sourceModel.IsQuery()); // old pose list is used for finding poses that no longer match a // dynamic date query during a Refresh call - PoseList *oldPoseList = NULL; + PoseList* oldPoseList = NULL; if (fCreateOldPoseList) { oldPoseList = new PoseList(10, false); oldPoseList->AddList(fPoseList); @@ -280,30 +282,33 @@ BQueryPoseView::InitDirentIterator(const entry_ref *ref) // calculate the time to trigger the query refresh - next midnight time_t now = time(0); - time_t nextMidnight = now + 60 * 60 * 24; // move ahead by a day + time_t nextMidnight = now + 60 * 60 * 24; + // move ahead by a day tm timeData; localtime_r(&nextMidnight, &timeData); timeData.tm_sec = 0; timeData.tm_min = 0; timeData.tm_hour = 0; - nextMidnight = mktime(&timeData); + nextMidnight = mktime(&timeData); - time_t nextHour = now + 60 * 60; // move ahead by a hour + time_t nextHour = now + 60 * 60; + // move ahead by a hour localtime_r(&nextHour, &timeData); timeData.tm_sec = 0; timeData.tm_min = 0; - nextHour = mktime(&timeData); + nextHour = mktime(&timeData); PRINT(("%ld minutes, %ld seconds till next hour\n", (nextHour - now) / 60, (nextHour - now) % 60)); - time_t nextMinute = now + 60; // move ahead by a minute + time_t nextMinute = now + 60; + // move ahead by a minute localtime_r(&nextMinute, &timeData); timeData.tm_sec = 0; - nextMinute = mktime(&timeData); - + nextMinute = mktime(&timeData); + PRINT(("%ld seconds till next minute\n", nextMinute - now)); - + bigtime_t delta; if (fQueryListContainer->DynamicDateRefreshEveryMinute()) delta = nextMinute - now; @@ -330,11 +335,11 @@ BQueryPoseView::InitDirentIterator(const entry_ref *ref) PRINT(("next refresh in %ld hours, %ld minutes, %ld seconds\n", refreshInHours, refreshInMinutes, refreshInSeconds)); #endif - + // bump up to microseconds delta *= 1000000; - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); ASSERT(tracker); tracker->MainTaskLoop()->RunLater( NewLockingMemberFunctionObject(&BQueryPoseView::Refresh, this), delta); @@ -344,34 +349,35 @@ BQueryPoseView::InitDirentIterator(const entry_ref *ref) } -uint32 +uint32 BQueryPoseView::WatchNewNodeMask() { return B_WATCH_NAME | B_WATCH_STAT | B_WATCH_ATTR; } -const char * +const char* BQueryPoseView::SearchForType() const { if (!fSearchForMimeType.Length()) { BModelOpener opener(TargetModel()); BString buffer; attr_info attrInfo; + // read the type of files we are looking for status_t status = TargetModel()->Node()->GetAttrInfo(kAttrQueryInitialMime, &attrInfo); - if (status == B_OK) + if (status == B_OK) TargetModel()->Node()->ReadAttrString(kAttrQueryInitialMime, &buffer); - + if (buffer.Length()) { - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); if (tracker) { - const ShortMimeInfo *info = tracker->MimeTypes()->FindMimeType(buffer.String()); - if (info) + const ShortMimeInfo* info = tracker->MimeTypes()->FindMimeType(buffer.String()); + if (info) fSearchForMimeType = info->InternalName(); - } } + if (!fSearchForMimeType.Length()) fSearchForMimeType = B_FILE_MIMETYPE; } @@ -380,11 +386,11 @@ BQueryPoseView::SearchForType() const } -bool +bool BQueryPoseView::ActiveOnDevice(dev_t device) const { int32 count = fQueryList->CountItems(); - for (int32 index = 0; index < count; index++) + for (int32 index = 0; index < count; index++) if (fQueryList->ItemAt(index)->TargetDevice() == device) return true; @@ -395,8 +401,8 @@ BQueryPoseView::ActiveOnDevice(dev_t device) const // #pragma mark - -QueryEntryListCollection::QueryEntryListCollection(Model *model, BHandler *target, - PoseList *oldPoseList) +QueryEntryListCollection::QueryEntryListCollection(Model* model, BHandler* target, + PoseList* oldPoseList) : fQueryListRep(new QueryListRep(new BObjectList(5, true))) { Rewind(); @@ -410,7 +416,7 @@ QueryEntryListCollection::QueryEntryListCollection(Model *model, BHandler *targe // read the actual query string fStatus = model->Node()->GetAttrInfo(kAttrQueryString, &info); - if (fStatus != B_OK) + if (fStatus != B_OK) return; BString buffer; @@ -426,11 +432,12 @@ QueryEntryListCollection::QueryEntryListCollection(Model *model, BHandler *targe MoreOptionsStruct saveMoreOptions; if (ReadAttr(model->Node(), kAttrQueryMoreOptions, kAttrQueryMoreOptionsForeign, B_RAW_TYPE, 0, &saveMoreOptions, sizeof(MoreOptionsStruct), - &MoreOptionsStruct::EndianSwap) != kReadAttrFailed) + &MoreOptionsStruct::EndianSwap) != kReadAttrFailed) { fQueryListRep->fShowResultsFromTrash = saveMoreOptions.searchTrash; - + } + fStatus = query.SetPredicate(buffer.String()); - + fQueryListRep->fOldPoseList = oldPoseList; fQueryListRep->fDynamicDateQuery = false; @@ -438,8 +445,9 @@ QueryEntryListCollection::QueryEntryListCollection(Model *model, BHandler *targe fQueryListRep->fRefreshEveryMinute = false; if (model->Node()->ReadAttr(kAttrDynamicDateQuery, B_BOOL_TYPE, 0, - &fQueryListRep->fDynamicDateQuery, sizeof(bool)) != sizeof(bool)) + &fQueryListRep->fDynamicDateQuery, sizeof(bool)) != sizeof(bool)) { fQueryListRep->fDynamicDateQuery = false; + } if (fQueryListRep->fDynamicDateQuery) { // only refresh every minute on debug builds @@ -453,7 +461,7 @@ QueryEntryListCollection::QueryEntryListCollection(Model *model, BHandler *targe fQueryListRep->fRefreshEveryMinute = false; #endif } - + if (fStatus != B_OK) return; @@ -462,11 +470,11 @@ QueryEntryListCollection::QueryEntryListCollection(Model *model, BHandler *targe // get volumes to perform query on if (model->Node()->GetAttrInfo(kAttrQueryVolume, &info) == B_OK) { - char *buffer = NULL; + char* buffer = NULL; - if ((buffer = (char *)malloc((size_t)info.size)) != NULL + if ((buffer = (char*)malloc((size_t)info.size)) != NULL && model->Node()->ReadAttr(kAttrQueryVolume, B_MESSAGE_TYPE, 0, buffer, - (size_t)info.size) == info.size) { + (size_t)info.size) == info.size) { BMessage message; if (message.Unflatten(buffer) == B_OK) { @@ -478,16 +486,17 @@ QueryEntryListCollection::QueryEntryListCollection(Model *model, BHandler *targe if (result == B_OK) { // start the query on this volume result = FetchOneQuery(&query, target, - fQueryListRep->fQueryList, &volume); + fQueryListRep->fQueryList, &volume); if (result != B_OK) continue; searchAllVolumes = false; - } else if (result != B_DEV_BAD_DRIVE_NUM) + } else if (result != B_DEV_BAD_DRIVE_NUM) { // if B_DEV_BAD_DRIVE_NUM, the volume just isn't mounted this // time around, keep looking for more // if other error, bail break; + } } } } @@ -503,7 +512,8 @@ QueryEntryListCollection::QueryEntryListCollection(Model *model, BHandler *targe roster.Rewind(); while (roster.GetNextVolume(&volume) == B_OK) if (volume.IsPersistent() && volume.KnowsQuery()) { - result = FetchOneQuery(&query, target, fQueryListRep->fQueryList, &volume); + result = FetchOneQuery(&query, target, + fQueryListRep->fQueryList, &volume); if (result != B_OK) continue; } @@ -515,28 +525,29 @@ QueryEntryListCollection::QueryEntryListCollection(Model *model, BHandler *targe status_t -QueryEntryListCollection::FetchOneQuery(const BQuery *copyThis, - BHandler *target, BObjectList *list, BVolume *volume) +QueryEntryListCollection::FetchOneQuery(const BQuery* copyThis, + BHandler* target, BObjectList* list, BVolume* volume) { - BQuery *query = new (nothrow) BQuery; + BQuery* query = new (nothrow) BQuery; if (query == NULL) return B_NO_MEMORY; + // have to fake a copy constructor here because BQuery doesn't have // a copy constructor - BString buffer; - const_cast(copyThis)->GetPredicate(&buffer); + const_cast(copyThis)->GetPredicate(&buffer); query->SetPredicate(buffer.String()); query->SetTarget(BMessenger(target)); query->SetVolume(volume); - + status_t result = query->Fetch(); if (result != B_OK) { PRINT(("fetch error %s\n", strerror(result))); delete query; return result; } + list->AddItem(query); return B_OK; @@ -545,12 +556,12 @@ QueryEntryListCollection::FetchOneQuery(const BQuery *copyThis, QueryEntryListCollection::~QueryEntryListCollection() { - if (fQueryListRep->CloseQueryList()) + if (fQueryListRep->CloseQueryList()) delete fQueryListRep; } -QueryEntryListCollection * +QueryEntryListCollection* QueryEntryListCollection::Clone() { fQueryListRep->OpenQueryList(); @@ -567,7 +578,7 @@ QueryEntryListCollection::QueryEntryListCollection( } -void +void QueryEntryListCollection::ClearOldPoseList() { delete fQueryListRep->fOldPoseList; @@ -575,8 +586,8 @@ QueryEntryListCollection::ClearOldPoseList() } -status_t -QueryEntryListCollection::GetNextEntry(BEntry *entry, bool traverse) +status_t +QueryEntryListCollection::GetNextEntry(BEntry* entry, bool traverse) { status_t result = B_ERROR; @@ -592,8 +603,8 @@ QueryEntryListCollection::GetNextEntry(BEntry *entry, bool traverse) } -int32 -QueryEntryListCollection::GetNextDirents(struct dirent *buffer, size_t length, +int32 +QueryEntryListCollection::GetNextDirents(struct dirent* buffer, size_t length, int32 count) { int32 result = 0; @@ -611,8 +622,8 @@ QueryEntryListCollection::GetNextDirents(struct dirent *buffer, size_t length, } -status_t -QueryEntryListCollection::GetNextRef(entry_ref *ref) +status_t +QueryEntryListCollection::GetNextRef(entry_ref* ref) { status_t result = B_ERROR; @@ -630,7 +641,7 @@ QueryEntryListCollection::GetNextRef(entry_ref *ref) } -status_t +status_t QueryEntryListCollection::Rewind() { fQueryListRep->fQueryListIndex = 0; @@ -639,37 +650,36 @@ QueryEntryListCollection::Rewind() } -int32 +int32 QueryEntryListCollection::CountEntries() { return 0; } -bool +bool QueryEntryListCollection::ShowResultsFromTrash() const { return fQueryListRep->fShowResultsFromTrash; } -bool +bool QueryEntryListCollection::DynamicDateQuery() const { return fQueryListRep->fDynamicDateQuery; } -bool +bool QueryEntryListCollection::DynamicDateRefreshEveryHour() const { return fQueryListRep->fRefreshEveryHour; } -bool +bool QueryEntryListCollection::DynamicDateRefreshEveryMinute() const { return fQueryListRep->fRefreshEveryMinute; } - diff --git a/src/kits/tracker/QueryPoseView.h b/src/kits/tracker/QueryPoseView.h index c1473d94d1..48c1a91db6 100644 --- a/src/kits/tracker/QueryPoseView.h +++ b/src/kits/tracker/QueryPoseView.h @@ -31,15 +31,16 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - -#ifndef _QUERY_POSE_VIEW_H +#ifndef _QUERY_POSE_VIEW_H #define _QUERY_POSE_VIEW_H -class BQuery; #include "EntryIterator.h" #include "PoseView.h" + +class BQuery; + namespace BPrivate { class BQueryContainerWindow; @@ -47,13 +48,13 @@ class QueryEntryListCollection; class BQueryPoseView : public BPoseView { public: - BQueryPoseView(Model *, BRect, uint32 resizeMask = B_FOLLOW_ALL); + BQueryPoseView(Model*, BRect, uint32 resizeMask = B_FOLLOW_ALL); virtual ~BQueryPoseView(); - - virtual void MessageReceived(BMessage *message); - const char *SearchForType() const; - BQueryContainerWindow *ContainerWindow() const; + virtual void MessageReceived(BMessage* message); + + const char* SearchForType() const; + BQueryContainerWindow* ContainerWindow() const; bool ActiveOnDevice(dev_t) const; void Refresh(); @@ -64,16 +65,16 @@ public: protected: virtual void AttachedToWindow(); - virtual void RestoreState(AttributeStreamNode *); - virtual void RestoreState(const BMessage &); - virtual void SavePoseLocations(BRect * = NULL); + virtual void RestoreState(AttributeStreamNode*); + virtual void RestoreState(const BMessage&); + virtual void SavePoseLocations(BRect* = NULL); virtual void SetUpDefaultColumnsIfNeeded(); virtual void SetViewMode(uint32); virtual void OpenParent(); virtual void EditQueries(); - virtual EntryListBase *InitDirentIterator(const entry_ref *); + virtual EntryListBase* InitDirentIterator(const entry_ref*); virtual uint32 WatchNewNodeMask(); - virtual bool ShouldShowPose(const Model *, const PoseInfo *); + virtual bool ShouldShowPose(const Model*, const PoseInfo*); virtual void AddPosesCompleted(); private: @@ -84,9 +85,9 @@ private: bool fShowResultsFromTrash; mutable BString fSearchForMimeType; - BObjectList *fQueryList; - QueryEntryListCollection *fQueryListContainer; - + BObjectList* fQueryList; + QueryEntryListCollection* fQueryListContainer; + bool fCreateOldPoseList; typedef BPoseView _inherited; @@ -98,36 +99,35 @@ class QueryEntryListCollection : public EntryListBase { // PoseView, allowing PoseView to have an arbitrary collection of // elements that behave as an EntryList // For now just manage a list of BQueries - class QueryListRep { public: - QueryListRep(BObjectList *queryList) + QueryListRep(BObjectList* queryList) : fQueryList(queryList), fRefCount(0), fShowResultsFromTrash(0), fOldPoseList(NULL) {} - + ~QueryListRep() { ASSERT(fRefCount <= 0); delete fQueryList; delete fOldPoseList; } - - BObjectList *OpenQueryList() + + BObjectList* OpenQueryList() { fRefCount++; return fQueryList; } - + bool CloseQueryList() - { - return atomic_add(&fRefCount, -1) == 0; - } - - BObjectList *fQueryList; + { + return atomic_add(&fRefCount, -1) == 0; + } + + BObjectList* fQueryList; int32 fRefCount; bool fShowResultsFromTrash; int32 fQueryListIndex; @@ -135,30 +135,29 @@ class QueryEntryListCollection : public EntryListBase { bool fRefreshEveryHour; bool fRefreshEveryMinute; - PoseList *fOldPoseList; + PoseList* fOldPoseList; // when doing a Refresh, this list is used to detect poses that // are no longer a part of a fDynamicDateQuery and need to be removed }; public: - - QueryEntryListCollection(Model *, BHandler * = NULL, PoseList *oldPoseList = NULL); + QueryEntryListCollection(Model*, BHandler* = NULL, PoseList* oldPoseList = NULL); virtual ~QueryEntryListCollection(); - QueryEntryListCollection *Clone(); + QueryEntryListCollection* Clone(); - BObjectList *QueryList() const + BObjectList* QueryList() const { return fQueryListRep->fQueryList; } - PoseList *OldPoseList() const + PoseList* OldPoseList() const { return fQueryListRep->fOldPoseList; } void ClearOldPoseList(); - - virtual status_t GetNextEntry(BEntry *entry, bool traverse = false); - virtual status_t GetNextRef(entry_ref *ref); - virtual int32 GetNextDirents(struct dirent *buffer, size_t length, + + virtual status_t GetNextEntry(BEntry* entry, bool traverse = false); + virtual status_t GetNextRef(entry_ref* ref); + virtual int32 GetNextDirents(struct dirent* buffer, size_t length, int32 count = INT_MAX); - + virtual status_t Rewind(); virtual int32 CountEntries(); @@ -166,18 +165,18 @@ public: bool DynamicDateQuery() const; bool DynamicDateRefreshEveryHour() const; bool DynamicDateRefreshEveryMinute() const; - -private: - QueryEntryListCollection(const QueryEntryListCollection &); - // only to be used by the Clone routine - status_t FetchOneQuery(const BQuery *, BHandler *target, - BObjectList *, BVolume *); - QueryListRep *fQueryListRep; +private: + QueryEntryListCollection(const QueryEntryListCollection&); + // only to be used by the Clone routine + status_t FetchOneQuery(const BQuery*, BHandler* target, + BObjectList*, BVolume*); + + QueryListRep* fQueryListRep; }; } // namespace BPrivate using namespace BPrivate; -#endif +#endif // _QUERY_POSE_VIEW_H diff --git a/src/kits/tracker/RecentItems.cpp b/src/kits/tracker/RecentItems.cpp index 1b8c8cd036..244d2675eb 100644 --- a/src/kits/tracker/RecentItems.cpp +++ b/src/kits/tracker/RecentItems.cpp @@ -49,8 +49,8 @@ All rights reserved. class RecentItemsMenu : public BSlowMenu { public: - RecentItemsMenu(const char *title, BMessage *openMessage, - BHandler *itemTarget, int32 maxItems) + RecentItemsMenu(const char* title, BMessage* openMessage, + BHandler* itemTarget, int32 maxItems) : BSlowMenu(title), fTargetMesage(openMessage), fItemTarget(itemTarget), @@ -64,14 +64,14 @@ public: virtual void ClearMenuBuildingState(); protected: - virtual const BMessage *FileMessage() + virtual const BMessage* FileMessage() { return fTargetMesage; } - virtual const BMessage *ContainerMessage() + virtual const BMessage* ContainerMessage() { return fTargetMesage; } - BRecentItemsList *fTterator; - BMessage *fTargetMesage; - BHandler *fItemTarget; + BRecentItemsList* fTterator; + BMessage* fTargetMesage; + BHandler* fItemTarget; int32 fCount; int32 fSanityCount; int32 fMaxCount; @@ -80,39 +80,39 @@ protected: class RecentFilesMenu : public RecentItemsMenu { public: - RecentFilesMenu(const char *title, BMessage *openFileMessage, - BMessage *openFolderMessage, BHandler *target, - int32 maxItems, bool navMenuFolders, const char *ofType, - const char *openedByAppSig); + RecentFilesMenu(const char* title, BMessage* openFileMessage, + BMessage* openFolderMessage, BHandler* target, + int32 maxItems, bool navMenuFolders, const char* ofType, + const char* openedByAppSig); - RecentFilesMenu(const char *title, BMessage *openFileMessage, - BMessage *openFolderMessage, BHandler *target, - int32 maxItems, bool navMenuFolders, const char *ofTypeList[], - int32 ofTypeListCount, const char *openedByAppSig); + RecentFilesMenu(const char* title, BMessage* openFileMessage, + BMessage* openFolderMessage, BHandler* target, + int32 maxItems, bool navMenuFolders, const char* ofTypeList[], + int32 ofTypeListCount, const char* openedByAppSig); virtual ~RecentFilesMenu(); protected: - virtual const BMessage *ContainerMessage() + virtual const BMessage* ContainerMessage() { return openFolderMessage; } private: - BMessage *openFolderMessage; + BMessage* openFolderMessage; }; class RecentFoldersMenu : public RecentItemsMenu { public: - RecentFoldersMenu(const char *title, BMessage *openMessage, - BHandler *target, int32 maxItems, bool navMenuFolders, - const char *openedByAppSig); + RecentFoldersMenu(const char* title, BMessage* openMessage, + BHandler* target, int32 maxItems, bool navMenuFolders, + const char* openedByAppSig); }; class RecentAppsMenu : public RecentItemsMenu { public: - RecentAppsMenu(const char *title, BMessage *openMessage, - BHandler *target, int32 maxItems); + RecentAppsMenu(const char* title, BMessage* openMessage, + BHandler* target, int32 maxItems); }; @@ -129,7 +129,7 @@ RecentItemsMenu::~RecentItemsMenu() bool RecentItemsMenu::AddNextItem() { - BMenuItem *item = fTterator->GetNextMenuItem(FileMessage(), + BMenuItem* item = fTterator->GetNextMenuItem(FileMessage(), ContainerMessage(), fItemTarget); if (item) { @@ -171,9 +171,9 @@ RecentItemsMenu::ClearMenuBuildingState() // #pragma mark - -RecentFilesMenu::RecentFilesMenu(const char *title, BMessage *openFileMessage, - BMessage *openFolderMessage, BHandler *target, int32 maxItems, - bool navMenuFolders, const char *ofType, const char *openedByAppSig) +RecentFilesMenu::RecentFilesMenu(const char* title, BMessage* openFileMessage, + BMessage* openFolderMessage, BHandler* target, int32 maxItems, + bool navMenuFolders, const char* ofType, const char* openedByAppSig) : RecentItemsMenu(title, openFileMessage, target, maxItems), openFolderMessage(openFolderMessage) @@ -183,10 +183,10 @@ RecentFilesMenu::RecentFilesMenu(const char *title, BMessage *openFileMessage, } -RecentFilesMenu::RecentFilesMenu(const char *title, BMessage *openFileMessage, - BMessage *openFolderMessage, BHandler *target, int32 maxItems, - bool navMenuFolders, const char *ofTypeList[], int32 ofTypeListCount, - const char *openedByAppSig) +RecentFilesMenu::RecentFilesMenu(const char* title, BMessage* openFileMessage, + BMessage* openFolderMessage, BHandler* target, int32 maxItems, + bool navMenuFolders, const char* ofTypeList[], int32 ofTypeListCount, + const char* openedByAppSig) : RecentItemsMenu(title, openFileMessage, target, maxItems), openFolderMessage(openFolderMessage) @@ -205,9 +205,9 @@ RecentFilesMenu::~RecentFilesMenu() // #pragma mark - -RecentFoldersMenu::RecentFoldersMenu(const char *title, BMessage *openMessage, - BHandler *target, int32 maxItems, bool navMenuFolders, - const char *openedByAppSig) +RecentFoldersMenu::RecentFoldersMenu(const char* title, BMessage* openMessage, + BHandler* target, int32 maxItems, bool navMenuFolders, + const char* openedByAppSig) : RecentItemsMenu(title, openMessage, target, maxItems) { @@ -219,8 +219,8 @@ RecentFoldersMenu::RecentFoldersMenu(const char *title, BMessage *openMessage, // #pragma mark - -RecentAppsMenu::RecentAppsMenu(const char *title, BMessage *openMessage, - BHandler *target, int32 maxItems) +RecentAppsMenu::RecentAppsMenu(const char* title, BMessage* openMessage, + BHandler* target, int32 maxItems) : RecentItemsMenu(title, openMessage, target, maxItems) { fTterator = new BRecentAppsList(maxItems); @@ -249,10 +249,10 @@ BRecentItemsList::Rewind() } -BMenuItem * -BRecentItemsList::GetNextMenuItem(const BMessage *fileOpenInvokeMessage, - const BMessage *containerOpenInvokeMessage, BHandler *target, - entry_ref *currentItemRef) +BMenuItem* +BRecentItemsList::GetNextMenuItem(const BMessage* fileOpenInvokeMessage, + const BMessage* containerOpenInvokeMessage, BHandler* target, + entry_ref* currentItemRef) { entry_ref ref; if (GetNextRef(&ref) != B_OK) @@ -265,8 +265,8 @@ BRecentItemsList::GetNextMenuItem(const BMessage *fileOpenInvokeMessage, bool container = false; if (model.IsSymLink()) { - Model *newResolvedModel = NULL; - Model *result = model.LinkTo(); + Model* newResolvedModel = NULL; + Model* result = model.LinkTo(); if (!result) { newResolvedModel = new Model(model.EntryRef(), true, true); @@ -305,7 +305,7 @@ BRecentItemsList::GetNextMenuItem(const BMessage *fileOpenInvokeMessage, if (currentItemRef) *currentItemRef = ref; - BMessage *message; + BMessage* message; if (container && containerOpenInvokeMessage) message = new BMessage(*containerOpenInvokeMessage); else if (!container && fileOpenInvokeMessage) @@ -320,12 +320,12 @@ BRecentItemsList::GetNextMenuItem(const BMessage *fileOpenInvokeMessage, be_plain_font->TruncateString(&truncatedString, B_TRUNCATE_END, BNavMenu::GetMaxMenuWidth()); - ModelMenuItem *item = NULL; + ModelMenuItem* item = NULL; if (!container || !fNavMenuFolders) item = new ModelMenuItem(&model, truncatedString.String(), message); else { // add another nav menu item if it's a directory - BNavMenu *menu = new BNavMenu(truncatedString.String(), message->what, + BNavMenu* menu = new BNavMenu(truncatedString.String(), message->what, target, 0); menu->SetNavDir(&ref); @@ -341,7 +341,7 @@ BRecentItemsList::GetNextMenuItem(const BMessage *fileOpenInvokeMessage, status_t -BRecentItemsList::GetNextRef(entry_ref *result) +BRecentItemsList::GetNextRef(entry_ref* result) { return fItems.FindRef("refs", fIndex++, result); } @@ -351,7 +351,7 @@ BRecentItemsList::GetNextRef(entry_ref *result) BRecentFilesList::BRecentFilesList(int32 maxItems, bool navMenuFolders, - const char *ofType, const char *openedByAppSig) + const char* ofType, const char* openedByAppSig) : BRecentItemsList(maxItems, navMenuFolders), fType(ofType), @@ -363,7 +363,7 @@ BRecentFilesList::BRecentFilesList(int32 maxItems, bool navMenuFolders, BRecentFilesList::BRecentFilesList(int32 maxItems, bool navMenuFolders, - const char *ofTypeList[], int32 ofTypeListCount, const char *openedByAppSig) + const char* ofTypeList[], int32 ofTypeListCount, const char* openedByAppSig) : BRecentItemsList(maxItems, navMenuFolders), fType(NULL), @@ -390,13 +390,13 @@ BRecentFilesList::~BRecentFilesList() status_t -BRecentFilesList::GetNextRef(entry_ref *ref) +BRecentFilesList::GetNextRef(entry_ref* ref) { if (fIndex == 0) { // Lazy roster Get if (fTypes) BRoster().GetRecentDocuments(&fItems, fMaxItems, - const_cast(fTypes), + const_cast(fTypes), fTypeCount, fAppSig.Length() ? fAppSig.String() : NULL); else BRoster().GetRecentDocuments(&fItems, fMaxItems, @@ -408,22 +408,22 @@ BRecentFilesList::GetNextRef(entry_ref *ref) } -BMenu * -BRecentFilesList::NewFileListMenu(const char *title, - BMessage *openFileMessage, BMessage *openFolderMessage, - BHandler *target, int32 maxItems, bool navMenuFolders, const char *ofType, - const char *openedByAppSig) +BMenu* +BRecentFilesList::NewFileListMenu(const char* title, + BMessage* openFileMessage, BMessage* openFolderMessage, + BHandler* target, int32 maxItems, bool navMenuFolders, const char* ofType, + const char* openedByAppSig) { return new RecentFilesMenu(title, openFileMessage, openFolderMessage, target, maxItems, navMenuFolders, ofType, openedByAppSig); } -BMenu * -BRecentFilesList::NewFileListMenu(const char *title, - BMessage *openFileMessage, BMessage *openFolderMessage, - BHandler *target, int32 maxItems, bool navMenuFolders, const char *ofTypeList[], - int32 ofTypeListCount, const char *openedByAppSig) +BMenu* +BRecentFilesList::NewFileListMenu(const char* title, + BMessage* openFileMessage, BMessage* openFolderMessage, + BHandler* target, int32 maxItems, bool navMenuFolders, const char* ofTypeList[], + int32 ofTypeListCount, const char* openedByAppSig) { return new RecentFilesMenu(title, openFileMessage, openFolderMessage, target, maxItems, navMenuFolders, ofTypeList, @@ -434,10 +434,10 @@ BRecentFilesList::NewFileListMenu(const char *title, // #pragma mark - -BMenu * -BRecentFoldersList::NewFolderListMenu(const char *title, - BMessage *openMessage, BHandler *target, int32 maxItems, - bool navMenuFolders, const char *openedByAppSig) +BMenu* +BRecentFoldersList::NewFolderListMenu(const char* title, + BMessage* openMessage, BHandler* target, int32 maxItems, + bool navMenuFolders, const char* openedByAppSig) { return new RecentFoldersMenu(title, openMessage, target, maxItems, navMenuFolders, openedByAppSig); @@ -445,7 +445,7 @@ BRecentFoldersList::NewFolderListMenu(const char *title, BRecentFoldersList::BRecentFoldersList(int32 maxItems, bool navMenuFolders, - const char *openedByAppSig) + const char* openedByAppSig) : BRecentItemsList(maxItems, navMenuFolders), fAppSig(openedByAppSig) @@ -454,7 +454,7 @@ BRecentFoldersList::BRecentFoldersList(int32 maxItems, bool navMenuFolders, status_t -BRecentFoldersList::GetNextRef(entry_ref *ref) +BRecentFoldersList::GetNextRef(entry_ref* ref) { if (fIndex == 0) { // Lazy roster Get @@ -477,7 +477,7 @@ BRecentAppsList::BRecentAppsList(int32 maxItems) status_t -BRecentAppsList::GetNextRef(entry_ref *ref) +BRecentAppsList::GetNextRef(entry_ref* ref) { if (fIndex == 0) { // Lazy roster Get @@ -487,9 +487,9 @@ BRecentAppsList::GetNextRef(entry_ref *ref) } -BMenu * -BRecentAppsList::NewAppListMenu(const char *title, BMessage *openMessage, - BHandler *target, int32 maxItems) +BMenu* +BRecentAppsList::NewAppListMenu(const char* title, BMessage* openMessage, + BHandler* target, int32 maxItems) { return new RecentAppsMenu(title, openMessage, target, maxItems); } diff --git a/src/kits/tracker/RecentItems.h b/src/kits/tracker/RecentItems.h index 8a94d942b0..e392419568 100644 --- a/src/kits/tracker/RecentItems.h +++ b/src/kits/tracker/RecentItems.h @@ -31,19 +31,20 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef __RECENT_ITEMS_LIST__ #define __RECENT_ITEMS_LIST__ + +// BRecentItemsList classes allow creating an entire menu with +// recent files, folders, apps. If the user wishes to add items to +// their own menu, they can instead use the GetNextMenuItem call to +// get one menu at a time to add it to their app. + + #include #include #include -/* BRecentItemsList classes allow creating an entire menu with - * recent files, folders, apps. If the user wishes to add items to - * their own menu, they can instead use the GetNextMenuItem call to - * get one menu at a time to add it to their app. - */ class BMenuItem; class BMenu; @@ -51,29 +52,27 @@ class BMenu; class BRecentItemsList { public: BRecentItemsList(int32 maxItems, bool navMenuFolders); - /* if passed, folder items get NavMenu-style - * subdirectories attached to them - */ + // if passed, folder items get NavMenu-style + // subdirectories attached to them virtual ~BRecentItemsList() {} - - virtual void Rewind(); - /* resets the iteration */ - - virtual BMenuItem *GetNextMenuItem(const BMessage *fileOpenMessage = NULL, - const BMessage *containerOpenMessage = NULL, - BHandler *target = NULL, entry_ref *currentItemRef = NULL); - /* if specified, the item for a file gets a copy with - * the item ref attached as "refs", otherwise a default B_REFS_RECEIVED - * message message gets attached - * if specified, the item for a folder, volume or query - * gets a copy with the item ref attached as "refs", otherwise a default - * B_REFS_RECEIVED message message gets attached - * if gets passed, the caller gets to look at the - * entry_ref corresponding to the item - */ - virtual status_t GetNextRef(entry_ref *); + virtual void Rewind(); + // resets the iteration + + virtual BMenuItem* GetNextMenuItem(const BMessage* fileOpenMessage = NULL, + const BMessage* containerOpenMessage = NULL, + BHandler* target = NULL, entry_ref* currentItemRef = NULL); + // if specified, the item for a file gets a copy with + // the item ref attached as "refs", otherwise a default B_REFS_RECEIVED + // message message gets attached + // if specified, the item for a folder, volume or query + // gets a copy with the item ref attached as "refs", otherwise a default + // B_REFS_RECEIVED message message gets attached + // if gets passed, the caller gets to look at the + // entry_ref corresponding to the item + + virtual status_t GetNextRef(entry_ref*); protected: BMessage fItems; @@ -82,7 +81,6 @@ protected: bool fNavMenuFolders; private: - virtual void _r1(); virtual void _r2(); virtual void _r3(); @@ -94,39 +92,38 @@ private: virtual void _r9(); virtual void _r10(); - uint32 _reserved[20]; + uint32 _reserved[20]; }; + class BRecentFilesList : public BRecentItemsList { public: - - /* use one of the two constructors to set up next item iteration */ + // use one of the two constructors to set up next item iteration BRecentFilesList(int32 maxItems = 10, bool navMenuFolders = false, - const char *ofType = NULL, const char *openedByAppSig = NULL); - BRecentFilesList(int32 maxItems, bool navMenuFolders, const char *ofTypeList[], - int32 ofTypeListCount, const char *openedByAppSig = NULL); + const char* ofType = NULL, const char* openedByAppSig = NULL); + BRecentFilesList(int32 maxItems, bool navMenuFolders, const char* ofTypeList[], + int32 ofTypeListCount, const char* openedByAppSig = NULL); virtual ~BRecentFilesList(); - /* use one of the two NewFileListMenu calls to get an entire menu */ - static BMenu *NewFileListMenu(const char *title, - BMessage *openFileMessage = NULL, BMessage *openFolderMessage = NULL, - BHandler *target = NULL, + // use one of the two NewFileListMenu calls to get an entire menu + static BMenu* NewFileListMenu(const char* title, + BMessage* openFileMessage = NULL, BMessage* openFolderMessage = NULL, + BHandler* target = NULL, int32 maxItems = 10, bool navMenuFolders = false, - const char *ofType = NULL, const char *openedByAppSig = NULL); + const char* ofType = NULL, const char* openedByAppSig = NULL); - static BMenu *NewFileListMenu(const char *title, - BMessage *openFileMessage, BMessage *openFolderMessage, - BHandler *target, + static BMenu* NewFileListMenu(const char* title, + BMessage* openFileMessage, BMessage* openFolderMessage, + BHandler* target, int32 maxItems, bool navMenuFolders, - const char *ofTypeList[], int32 ofTypeListCount, - const char *openedByAppSig); + const char* ofTypeList[], int32 ofTypeListCount, + const char* openedByAppSig); - virtual status_t GetNextRef(entry_ref *); + virtual status_t GetNextRef(entry_ref*); protected: - BString fType; - char **fTypes; + char** fTypes; int32 fTypeCount; BString fAppSig; @@ -142,24 +139,25 @@ private: virtual void _r19(); virtual void _r110(); - uint32 _reserved[20]; + uint32 _reserved[20]; }; + class BRecentFoldersList : public BRecentItemsList { public: - /* use the constructor to set up next item iteration */ + // use the constructor to set up next item iteration BRecentFoldersList(int32 maxItems, bool navMenuFolders = false, - const char *openedByAppSig = NULL); + const char* openedByAppSig = NULL); - /* use NewFolderListMenu to get an entire menu */ - static BMenu *NewFolderListMenu(const char *title, - BMessage *openMessage = NULL, BHandler *target = NULL, + // use NewFolderListMenu to get an entire menu + static BMenu* NewFolderListMenu(const char* title, + BMessage* openMessage = NULL, BHandler* target = NULL, int32 maxItems = 10, bool navMenuFolders = false, - const char *openedByAppSig = NULL); + const char* openedByAppSig = NULL); - virtual status_t GetNextRef(entry_ref *); + virtual status_t GetNextRef(entry_ref*); -protected: +protected: BString fAppSig; private: @@ -174,20 +172,21 @@ private: virtual void _r29(); virtual void _r210(); - uint32 _reserved[20]; + uint32 _reserved[20]; }; + class BRecentAppsList : public BRecentItemsList { public: - /* use the constructor to set up next item iteration */ + // use the constructor to set up next item iteration BRecentAppsList(int32 maxItems); - /* use NewFolderListMenu to get an entire menu */ - static BMenu *NewAppListMenu(const char *title, - BMessage *openMessage = NULL, BHandler *target = NULL, + // use NewFolderListMenu to get an entire menu + static BMenu* NewAppListMenu(const char* title, + BMessage* openMessage = NULL, BHandler* target = NULL, int32 maxItems = 10); - virtual status_t GetNextRef(entry_ref *); + virtual status_t GetNextRef(entry_ref*); private: virtual void _r31(); @@ -201,7 +200,7 @@ private: virtual void _r39(); virtual void _r310(); - uint32 _reserved[20]; + uint32 _reserved[20]; }; -#endif +#endif // __RECENT_ITEMS_LIST__ diff --git a/src/kits/tracker/RegExp.cpp b/src/kits/tracker/RegExp.cpp index 573a3e00ed..0359c04f21 100644 --- a/src/kits/tracker/RegExp.cpp +++ b/src/kits/tracker/RegExp.cpp @@ -61,6 +61,7 @@ All rights reserved. // ALTERED VERSION: Adapted to ANSI C and C++ for the OpenTracker // project (www.opentracker.org), Jul 11, 2000. + #include #include #include @@ -69,6 +70,7 @@ All rights reserved. #include "RegExp.h" + // The first byte of the regexp internal "program" is actually this magic // number; the start node begins in the second byte. @@ -105,7 +107,7 @@ const uint8 kRegExpMagic = 0234; // because of operator precedence.) The operand of some types of node is // a literal string; for others, it is a node leading into a sub-FSM. In // particular, the operand of a kRegExpBranch node is the first node of the branch. -// (NB this is *not* a tree structure: the tail of the branch connects +// (NB this is* not* a tree structure: the tail of the branch connects // to the thing following the set of kRegExpBranches.) The opcodes are: // @@ -161,7 +163,7 @@ enum { // but allows patterns to get big without disasters. // -const char *kMeta = "^$.[()|?+*\\"; +const char* kMeta = "^$.[()|?+*\\"; const int32 kMaxSize = 32767L; // Probably could be 65535L. // Flags to be passed up and down: @@ -172,7 +174,7 @@ enum { kWorst = 0 // Worst case. }; -const char *kRegExpErrorStringArray[] = { +const char* kRegExpErrorStringArray[] = { "Unmatched parenthesis.", "Expression too long.", "Too many parenthesis.", @@ -200,13 +202,15 @@ RegExp::RegExp() { } -RegExp::RegExp(const char *pattern) + +RegExp::RegExp(const char* pattern) : fError(B_OK), fRegExp(NULL) { fRegExp = Compile(pattern); } + RegExp::RegExp(const BString &pattern) : fError(B_OK), fRegExp(NULL) @@ -214,21 +218,22 @@ RegExp::RegExp(const BString &pattern) fRegExp = Compile(pattern.String()); } + RegExp::~RegExp() { free(fRegExp); } - status_t RegExp::InitCheck() const { return fError; } + status_t -RegExp::SetTo(const char *pattern) +RegExp::SetTo(const char* pattern) { fError = B_OK; free(fRegExp); @@ -236,6 +241,7 @@ RegExp::SetTo(const char *pattern) return fError; } + status_t RegExp::SetTo(const BString &pattern) { @@ -245,8 +251,9 @@ RegExp::SetTo(const BString &pattern) return fError; } + bool -RegExp::Matches(const char *string) const +RegExp::Matches(const char* string) const { if (!fRegExp || !string) return false; @@ -254,6 +261,7 @@ RegExp::Matches(const char *string) const return RunMatcher(fRegExp, string) == 1; } + bool RegExp::Matches(const BString &string) const { @@ -278,13 +286,12 @@ RegExp::Matches(const BString &string) const // // Beware that the optimization-preparation code in here knows about some // of the structure of the compiled regexp. - -regexp * -RegExp::Compile(const char *exp) +regexp* +RegExp::Compile(const char* exp) { - regexp *r; - const char *scan; - const char *longest; + regexp* r; + const char* scan; + const char* longest; int32 len; int32 flags; @@ -308,8 +315,8 @@ RegExp::Compile(const char *exp) return NULL; } - // Allocate space. - r = (regexp *)malloc(sizeof(regexp) + fCodeSize); + r = (regexp*)malloc(sizeof(regexp) + fCodeSize); + // Allocate space if (!r) { SetError(B_NO_MEMORY); @@ -331,8 +338,10 @@ RegExp::Compile(const char *exp) r->reganch = 0; r->regmust = NULL; r->regmlen = 0; - scan = r->program + 1; // First kRegExpBranch. - if (*Next((char *)scan) == kRegExpEnd) { // Only one top-level choice. + scan = r->program + 1; + // First kRegExpBranch. + if (*Next((char*)scan) == kRegExpEnd) { + // Only one top-level choice. scan = Operand(scan); // Starting-point info. @@ -341,18 +350,16 @@ RegExp::Compile(const char *exp) else if (*scan == kRegExpBol) r->reganch++; - // // If there's something expensive in the r.e., find the // longest literal string that must appear and make it the // regmust. Resolve ties in favor of later strings, since // the regstart check works with the beginning of the r.e. // and avoiding duplication strengthens checking. Not a // strong reason, but sufficient in the absence of others. - // if (flags&kSPStart) { longest = NULL; len = 0; - for (; scan != NULL; scan = Next((char *)scan)) + for (; scan != NULL; scan = Next((char*)scan)) if (*scan == kRegExpExactly && (int32)strlen(Operand(scan)) >= len) { longest = Operand(scan); len = (int32)strlen(Operand(scan)); @@ -365,13 +372,15 @@ RegExp::Compile(const char *exp) return r; } -regexp * + +regexp* RegExp::Expression() const { return fRegExp; } -const char * + +const char* RegExp::ErrorString() const { if (fError >= REGEXP_UNMATCHED_PARENTHESIS @@ -398,12 +407,12 @@ RegExp::SetError(status_t error) const // is a trifle forced, but the need to tie the tails of the branches to what // follows makes it hard to avoid. // -char * -RegExp::Reg(int32 paren, int32 *flagp) +char* +RegExp::Reg(int32 paren, int32* flagp) { - char *ret; - char *br; - char *ender; + char* ret; + char* br; + char* ender; int32 parno = 0; int32 flags; @@ -469,17 +478,18 @@ RegExp::Reg(int32 paren, int32 *flagp) return ret; } + // // - Branch - one alternative of an | operator // // Implements the concatenation operator. // -char * -RegExp::Branch(int32 *flagp) +char* +RegExp::Branch(int32* flagp) { - char *ret; - char *chain; - char *latest; + char* ret; + char* chain; + char* latest; int32 flags; *flagp = kWorst; // Tentatively. @@ -505,6 +515,7 @@ RegExp::Branch(int32 *flagp) return ret; } + // // - Piece - something followed by possible [*+?] // @@ -514,12 +525,12 @@ RegExp::Branch(int32 *flagp) // It might seem that this node could be dispensed with entirely, but the // endmarker role is not redundant. // -char * -RegExp::Piece(int32 *flagp) +char* +RegExp::Piece(int32* flagp) { - char *ret; + char* ret; char op; - char *next; + char* next; int32 flags; ret = Atom(&flags); @@ -572,6 +583,7 @@ RegExp::Piece(int32 *flagp) return ret; } + // // - Atom - the lowest level // @@ -580,10 +592,10 @@ RegExp::Piece(int32 *flagp) // faster to run. Backslashed characters are exceptions, each becoming a // separate node; the code is simpler that way and it's not worth fixing. // -char * -RegExp::Atom(int32 *flagp) +char* +RegExp::Atom(int32* flagp) { - char *ret; + char* ret; int32 flags; *flagp = kWorst; // Tentatively. @@ -695,14 +707,15 @@ RegExp::Atom(int32 *flagp) return ret; } + // // - Node - emit a node // -char * // Location. +char* // Location. RegExp::Node(char op) { - char *ret; - char *ptr; + char* ret; + char* ptr; ret = fCodeEmitPointer; if (ret == &fDummy) { @@ -719,6 +732,7 @@ RegExp::Node(char op) return ret; } + // // - Char - emit (if appropriate) a byte of code // @@ -731,17 +745,18 @@ RegExp::Char(char b) fCodeSize++; } + // // - Insert - insert an operator in front of already-emitted operand // // Means relocating the operand. // void -RegExp::Insert(char op, char *opnd) +RegExp::Insert(char op, char* opnd) { - char *src; - char *dst; - char *place; + char* src; + char* dst; + char* place; if (fCodeEmitPointer == &fDummy) { fCodeSize += 3; @@ -760,14 +775,15 @@ RegExp::Insert(char op, char *opnd) *place++ = '\0'; } + // // - Tail - set the next-pointer at the end of a node chain // void -RegExp::Tail(char *p, char *val) +RegExp::Tail(char* p, char* val) { - char *scan; - char *temp; + char* scan; + char* temp; int32 offset; if (p == &fDummy) @@ -791,11 +807,12 @@ RegExp::Tail(char *p, char *val) scan[2] = (char)(offset & 0377); } + // // - OpTail - Tail on operand of first argument; nop if operandless // void -RegExp::OpTail(char *p, char *val) +RegExp::OpTail(char* p, char* val) { // "Operandless" and "op != kRegExpBranch" are synonymous in practice. if (p == NULL || p == &fDummy || *p != kRegExpBranch) @@ -807,13 +824,14 @@ RegExp::OpTail(char *p, char *val) // RunMatcher and friends // + // // - RunMatcher - match a regexp against a string // int32 -RegExp::RunMatcher(regexp *prog, const char *string) const +RegExp::RunMatcher(regexp* prog, const char* string) const { - const char *s; + const char* s; // Be paranoid... if (prog == NULL || string == NULL) { @@ -866,11 +884,12 @@ RegExp::RunMatcher(regexp *prog, const char *string) const return 0; } + // // - Try - try match at specific point // int32 // 0 failure, 1 success -RegExp::Try(regexp *prog, const char *string) const +RegExp::Try(regexp* prog, const char* string) const { int32 i; const char **sp; @@ -894,6 +913,7 @@ RegExp::Try(regexp *prog, const char *string) const return 0; } + // // - Match - main matching routine // @@ -905,10 +925,10 @@ RegExp::Try(regexp *prog, const char *string) const // by recursion. /// int32 // 0 failure, 1 success -RegExp::Match(const char *prog) const +RegExp::Match(const char* prog) const { - const char *scan; // Current node. - const char *next; // Next node. + const char* scan; // Current node. + const char* next; // Next node. scan = prog; #ifdef DEBUG @@ -938,7 +958,7 @@ RegExp::Match(const char *prog) const break; case kRegExpExactly: { - const char *opnd = Operand(scan); + const char* opnd = Operand(scan); // Inline the first character, for speed. if (*opnd != *fStringInputPointer) return 0; @@ -977,7 +997,7 @@ RegExp::Match(const char *prog) const case kRegExpOpen + 9: { int32 no; - const char *save; + const char* save; no = *scan - kRegExpOpen; save = fStringInputPointer; @@ -1006,7 +1026,7 @@ RegExp::Match(const char *prog) const case kRegExpClose + 9: { int32 no; - const char *save; + const char* save; no = *scan - kRegExpClose; save = fStringInputPointer; @@ -1026,7 +1046,7 @@ RegExp::Match(const char *prog) const break; case kRegExpBranch: { - const char *save; + const char* save; if (*next != kRegExpBranch) // No choice. next = Operand(scan); // Avoid recursion. @@ -1048,7 +1068,7 @@ RegExp::Match(const char *prog) const { char nextch; int32 no; - const char *save; + const char* save; int32 min; // @@ -1092,15 +1112,16 @@ RegExp::Match(const char *prog) const return 0; } + // // - Repeat - repeatedly match something simple, report how many // int32 -RegExp::Repeat(const char *p) const +RegExp::Repeat(const char* p) const { int32 count = 0; - const char *scan; - const char *opnd; + const char* scan; + const char* opnd; scan = fStringInputPointer; opnd = Operand(p); @@ -1141,11 +1162,12 @@ RegExp::Repeat(const char *p) const return count; } + // // - Next - dig the "next" pointer out of a node // -char * -RegExp::Next(char *p) +char* +RegExp::Next(char* p) { int32 offset; @@ -1162,8 +1184,9 @@ RegExp::Next(char *p) return p + offset; } -const char * -RegExp::Next(const char *p) const + +const char* +RegExp::Next(const char* p) const { int32 offset; @@ -1180,24 +1203,28 @@ RegExp::Next(const char *p) const return p + offset; } + inline int32 -RegExp::UCharAt(const char *p) const +RegExp::UCharAt(const char* p) const { return (int32)*(unsigned char *)p; } -inline char * + +inline char* RegExp::Operand(char* p) const { return p + 3; } -inline const char * + +inline const char* RegExp::Operand(const char* p) const { return p + 3; } + inline bool RegExp::IsMult(char c) const { @@ -1207,15 +1234,16 @@ RegExp::IsMult(char c) const #ifdef DEBUG + // // - Dump - dump a regexp onto stdout in vaguely comprehensible form // void RegExp::Dump() { - const char *s; + const char* s; char op = kRegExpExactly; // Arbitrary non-kRegExpEnd op. - const char *next; + const char* next; s = fRegExp->program + 1; while (op != kRegExpEnd) { // While that wasn't kRegExpEnd last time... @@ -1248,13 +1276,14 @@ RegExp::Dump() printf("\n"); } + // // - Prop - printable representation of opcode // -char * -RegExp::Prop(const char *op) const +char* +RegExp::Prop(const char* op) const { - const char *p = NULL; + const char* p = NULL; static char buf[50]; (void) strcpy(buf, ":"); @@ -1331,8 +1360,9 @@ RegExp::Prop(const char *op) const return buf; } + void -RegExp::RegExpError(const char *) const +RegExp::RegExpError(const char*) const { // does nothing now, perhaps it should printf? } diff --git a/src/kits/tracker/RegExp.h b/src/kits/tracker/RegExp.h index 509f496768..699e0d66ad 100644 --- a/src/kits/tracker/RegExp.h +++ b/src/kits/tracker/RegExp.h @@ -31,6 +31,8 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ +#ifndef _REG_EXP_H +#define _REG_EXP_H // This code is based on regexp.c, v.1.3 by Henry Spencer: @@ -62,13 +64,13 @@ All rights reserved. // ALTERED VERSION: Adapted to ANSI C and C++ for the OpenTracker // project (www.opentracker.org), Jul 11, 2000. -#ifndef _REG_EXP_H -#define _REG_EXP_H #include + namespace BPrivate { + enum { REGEXP_UNMATCHED_PARENTHESIS = B_ERRORS_END, REGEXP_TOO_BIG, @@ -90,21 +92,21 @@ enum { const int32 kSubExpressionMax = 10; struct regexp { - const char *startp[kSubExpressionMax]; - const char *endp[kSubExpressionMax]; - char regstart; /* Internal use only. See RegExp.cpp for details. */ - char reganch; /* Internal use only. */ - const char *regmust;/* Internal use only. */ - int regmlen; /* Internal use only. */ - char program[1]; /* Unwarranted chumminess with compiler. */ + const char* startp[kSubExpressionMax]; + const char* endp[kSubExpressionMax]; + char regstart; // Internal use only. See RegExp.cpp for details. + char reganch; // Internal use only. + const char* regmust;// Internal use only. + int regmlen; // Internal use only. + char program[1]; // Unwarranted chumminess with compiler. }; -class RegExp { +class RegExp { public: RegExp(); - RegExp(const char *); - RegExp(const BString &); + RegExp(const char*); + RegExp(const BString&); ~RegExp(); status_t InitCheck() const; @@ -112,73 +114,73 @@ public: status_t SetTo(const char*); status_t SetTo(const BString &); - bool Matches(const char *string) const; + bool Matches(const char* string) const; bool Matches(const BString &) const; - int32 RunMatcher(regexp *, const char *) const; - regexp *Compile(const char *); - regexp *Expression() const; - const char *ErrorString() const; + int32 RunMatcher(regexp*, const char*) const; + regexp* Compile(const char*); + regexp* Expression() const; + const char* ErrorString() const; #ifdef DEBUG void Dump(); #endif private: - void SetError(status_t error) const; // Working functions for Compile(): - char *Reg(int32, int32 *); - char *Branch(int32 *); - char *Piece(int32 *); - char *Atom(int32 *); - char *Node(char); - char *Next(char *); - const char *Next(const char *) const; + char* Reg(int32, int32*); + char* Branch(int32*); + char* Piece(int32*); + char* Atom(int32*); + char* Node(char); + char* Next(char*); + const char* Next(const char*) const; void Char(char); - void Insert(char, char *); - void Tail(char *, char *); - void OpTail(char *, char *); + void Insert(char, char*); + void Tail(char*, char*); + void OpTail(char*, char*); // Working functions for RunMatcher(): - int32 Try(regexp *, const char *) const; - int32 Match(const char *) const; - int32 Repeat(const char *) const; + int32 Try(regexp*, const char*) const; + int32 Match(const char*) const; + int32 Repeat(const char*) const; // Utility functions: #ifdef DEBUG - char *Prop(const char *) const; - void RegExpError(const char *) const; + char* Prop(const char*) const; + void RegExpError(const char*) const; #endif - inline int32 UCharAt(const char *p) const; - inline char *Operand(char* p) const; - inline const char *Operand(const char* p) const; + inline int32 UCharAt(const char* p) const; + inline char* Operand(char* p) const; + inline const char* Operand(const char* p) const; inline bool IsMult(char c) const; // --------- Variables ------------- mutable status_t fError; - regexp *fRegExp; + regexp* fRegExp; // Work variables for Compile(). - - const char *fInputScanPointer; - int32 fParenthesisCount; + const char* fInputScanPointer; + int32 fParenthesisCount; char fDummy; - char *fCodeEmitPointer; // &fDummy = don't. - long fCodeSize; + char* fCodeEmitPointer; + // &fDummy = don't. + long fCodeSize; // Work variables for RunMatcher(). - - mutable const char *fStringInputPointer; - mutable const char *fRegBol; // Beginning of input, for ^ check. - mutable const char **fStartPArrayPointer; - mutable const char **fEndPArrayPointer; + mutable const char* fStringInputPointer; + mutable const char* fRegBol; + // Beginning of input, for ^ check. + mutable const char** fStartPArrayPointer; + mutable const char** fEndPArrayPointer; }; + } // namespace BPrivate using namespace BPrivate; -#endif +#endif // _REG_EXP_H diff --git a/src/kits/tracker/SelectionWindow.cpp b/src/kits/tracker/SelectionWindow.cpp index 6743d65865..f3ca9f6a29 100644 --- a/src/kits/tracker/SelectionWindow.cpp +++ b/src/kits/tracker/SelectionWindow.cpp @@ -70,11 +70,11 @@ SelectionWindow::SelectionWindow(BContainerWindow* window) AddToSubset(fParentWindow); - BView *backgroundView = new BView(Bounds(), "bgView", B_FOLLOW_ALL, B_WILL_DRAW); + BView* backgroundView = new BView(Bounds(), "bgView", B_FOLLOW_ALL, B_WILL_DRAW); backgroundView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(backgroundView); - BMenu *menu = new BPopUpMenu(""); + BMenu* menu = new BPopUpMenu(""); menu->AddItem(new BMenuItem(B_TRANSLATE("starts with"), NULL)); menu->AddItem(new BMenuItem(B_TRANSLATE("ends with"), NULL)); menu->AddItem(new BMenuItem(B_TRANSLATE("contains"), NULL)); @@ -188,7 +188,7 @@ SelectionWindow::SelectionWindow(BContainerWindow* window) void -SelectionWindow::MessageReceived(BMessage *message) +SelectionWindow::MessageReceived(BMessage* message) { switch (message->what) { case kSelectButtonPressed: @@ -200,7 +200,7 @@ SelectionWindow::MessageReceived(BMessage *message) // (Hide is synhcronous, while PostMessage is not.) // See PoseView::SelectMatchingEntries(). - BMessage *selectionInfo = new BMessage(kSelectMatchingEntries); + BMessage* selectionInfo = new BMessage(kSelectMatchingEntries); selectionInfo->AddInt32("ExpressionType", ExpressionType()); BString expression; Expression(expression); @@ -256,7 +256,7 @@ SelectionWindow::ExpressionType() const if (!fMatchingTypeMenuField->LockLooper()) return kNone; - BMenuItem *item = fMatchingTypeMenuField->Menu()->FindMarked(); + BMenuItem* item = fMatchingTypeMenuField->Menu()->FindMarked(); if (!item) { fMatchingTypeMenuField->UnlockLooper(); return kNone; diff --git a/src/kits/tracker/SelectionWindow.h b/src/kits/tracker/SelectionWindow.h index 2ac72d35fa..c4f37ef2d3 100644 --- a/src/kits/tracker/SelectionWindow.h +++ b/src/kits/tracker/SelectionWindow.h @@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - -#ifndef _SELECTION_WINDOW_H +#ifndef _SELECTION_WINDOW_H #define _SELECTION_WINDOW_H + #include #include #include @@ -44,32 +44,33 @@ All rights reserved. #include "TrackerString.h" + namespace BPrivate { class BContainerWindow; class SelectionWindow : public BWindow { public: - SelectionWindow(BContainerWindow *); + SelectionWindow(BContainerWindow*); - void MessageReceived(BMessage *); + void MessageReceived(BMessage*); bool QuitRequested(); - + void MoveCloseToMouse(); - + TrackerStringExpressionType ExpressionType() const; void Expression(BString &result) const; bool IgnoreCase() const; bool Invert() const; - -private: - BContainerWindow *fParentWindow; - BMenuField *fMatchingTypeMenuField; - BTextControl *fExpressionTextControl; - BCheckBox *fInverseCheckBox; - BCheckBox *fIgnoreCaseCheckBox; - BButton *fSelectButton; +private: + BContainerWindow* fParentWindow; + + BMenuField* fMatchingTypeMenuField; + BTextControl* fExpressionTextControl; + BCheckBox* fInverseCheckBox; + BCheckBox* fIgnoreCaseCheckBox; + BButton* fSelectButton; typedef BWindow _inherited; }; @@ -78,4 +79,4 @@ private: using namespace BPrivate; -#endif +#endif // _SELECTION_WINDOW_H diff --git a/src/kits/tracker/Settings.cpp b/src/kits/tracker/Settings.cpp index c67c2f0805..ef07761dcd 100644 --- a/src/kits/tracker/Settings.cpp +++ b/src/kits/tracker/Settings.cpp @@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include #include @@ -40,12 +41,13 @@ All rights reserved. #include "TrackerSettings.h" -Settings *settings = NULL; + +Settings* settings = NULL; // generic setting handler classes -StringValueSetting::StringValueSetting(const char *name, const char *defaultValue, - const char *valueExpectedErrorString, const char *wrongValueErrorString) +StringValueSetting::StringValueSetting(const char* name, const char* defaultValue, + const char* valueExpectedErrorString, const char* wrongValueErrorString) : SettingsArgvDispatcher(name), fDefaultValue(defaultValue), fValueExpectedErrorString(valueExpectedErrorString), @@ -54,57 +56,67 @@ StringValueSetting::StringValueSetting(const char *name, const char *defaultValu { } + StringValueSetting::~StringValueSetting() { } -void -StringValueSetting::ValueChanged(const char *newValue) + +void +StringValueSetting::ValueChanged(const char* newValue) { fValue = newValue; } -const char * + +const char* StringValueSetting::Value() const { return fValue.String(); } -void -StringValueSetting::SaveSettingValue(Settings *settings) + +void +StringValueSetting::SaveSettingValue(Settings* settings) { settings->Write("\"%s\"", fValue.String()); } -bool + +bool StringValueSetting::NeedsSaving() const { // needs saving if different than default return fValue != fDefaultValue; } -const char * -StringValueSetting::Handle(const char *const *argv) + +const char* +StringValueSetting::Handle(const char* const* argv) { - if (!*++argv) + if (!*++argv) return fValueExpectedErrorString; - ValueChanged(*argv); + ValueChanged(*argv); return 0; } + // #pragma mark - -EnumeratedStringValueSetting::EnumeratedStringValueSetting(const char *name, - const char *defaultValue, const char *const *values, const char *valueExpectedErrorString, - const char *wrongValueErrorString) - : StringValueSetting(name, defaultValue, valueExpectedErrorString, wrongValueErrorString), + +EnumeratedStringValueSetting::EnumeratedStringValueSetting(const char* name, + const char* defaultValue, const char* const* values, + const char* valueExpectedErrorString, const char* wrongValueErrorString) + : StringValueSetting(name, defaultValue, valueExpectedErrorString, + wrongValueErrorString), fValues(values) { } -void -EnumeratedStringValueSetting::ValueChanged(const char *newValue) + +void +EnumeratedStringValueSetting::ValueChanged(const char* newValue) { #if DEBUG // must be one of the enumerated values @@ -112,8 +124,10 @@ EnumeratedStringValueSetting::ValueChanged(const char *newValue) for (int32 index = 0; ; index++) { if (!fValues[index]) break; - if (strcmp(fValues[index], newValue) != 0) + + if (strcmp(fValues[index], newValue) != 0) continue; + found = true; break; } @@ -122,33 +136,38 @@ EnumeratedStringValueSetting::ValueChanged(const char *newValue) StringValueSetting::ValueChanged(newValue); } -const char * -EnumeratedStringValueSetting::Handle(const char *const *argv) + +const char* +EnumeratedStringValueSetting::Handle(const char* const* argv) { - if (!*++argv) + if (!*++argv) return fValueExpectedErrorString; bool found = false; for (int32 index = 0; ; index++) { if (!fValues[index]) break; - if (strcmp(fValues[index], *argv) != 0) + + if (strcmp(fValues[index], *argv) != 0) continue; + found = true; break; - } - + } + if (!found) return fWrongValueErrorString; - - ValueChanged(*argv); + + ValueChanged(*argv); return 0; } + // #pragma mark - -ScalarValueSetting::ScalarValueSetting(const char *name, int32 defaultValue, - const char *valueExpectedErrorString, const char *wrongValueErrorString, + +ScalarValueSetting::ScalarValueSetting(const char* name, int32 defaultValue, + const char* valueExpectedErrorString, const char* wrongValueErrorString, int32 min, int32 max) : SettingsArgvDispatcher(name), fDefaultValue(defaultValue), @@ -160,7 +179,8 @@ ScalarValueSetting::ScalarValueSetting(const char *name, int32 defaultValue, { } -void + +void ScalarValueSetting::ValueChanged(int32 newValue) { ASSERT(newValue > fMin); @@ -168,22 +188,25 @@ ScalarValueSetting::ValueChanged(int32 newValue) fValue = newValue; } + int32 ScalarValueSetting::Value() const { return fValue; } -void -ScalarValueSetting::GetValueAsString(char *buffer) const + +void +ScalarValueSetting::GetValueAsString(char* buffer) const { sprintf(buffer, "%ld", fValue); } -const char * -ScalarValueSetting::Handle(const char *const *argv) + +const char* +ScalarValueSetting::Handle(const char* const* argv) { - if (!*++argv) + if (!*++argv) return fValueExpectedErrorString; int32 newValue; @@ -194,68 +217,79 @@ ScalarValueSetting::Handle(const char *const *argv) if (newValue < fMin || newValue > fMax) return fWrongValueErrorString; - - fValue = newValue; + + fValue = newValue; return NULL; } -void -ScalarValueSetting::SaveSettingValue(Settings *settings) + +void +ScalarValueSetting::SaveSettingValue(Settings* settings) { settings->Write("%ld", fValue); } -bool + +bool ScalarValueSetting::NeedsSaving() const { return fValue != fDefaultValue; } + // #pragma mark - -HexScalarValueSetting::HexScalarValueSetting(const char *name, int32 defaultValue, - const char *valueExpectedErrorString, const char *wrongValueErrorString, + +HexScalarValueSetting::HexScalarValueSetting(const char* name, int32 defaultValue, + const char* valueExpectedErrorString, const char* wrongValueErrorString, int32 min, int32 max) : ScalarValueSetting(name, defaultValue, valueExpectedErrorString, wrongValueErrorString, min, max) { } -void -HexScalarValueSetting::GetValueAsString(char *buffer) const + +void +HexScalarValueSetting::GetValueAsString(char* buffer) const { sprintf(buffer, "0x%08lx", fValue); } -void -HexScalarValueSetting::SaveSettingValue(Settings *settings) + +void +HexScalarValueSetting::SaveSettingValue(Settings* settings) { settings->Write("0x%08lx", fValue); } + // #pragma mark - -BooleanValueSetting::BooleanValueSetting(const char *name, bool defaultValue) + +BooleanValueSetting::BooleanValueSetting(const char* name, bool defaultValue) : ScalarValueSetting(name, defaultValue, 0, 0) { } -bool + +bool BooleanValueSetting::Value() const { return fValue != 0; } + void BooleanValueSetting::SetValue(bool value) { - fValue = value; + fValue = value; } -const char * -BooleanValueSetting::Handle(const char *const *argv) + +const char* +BooleanValueSetting::Handle(const char* const* argv) { - if (!*++argv) + if (!*++argv) return "on or off expected"; if (strcmp(*argv, "on") == 0) @@ -268,9 +302,9 @@ BooleanValueSetting::Handle(const char *const *argv) return 0; } -void -BooleanValueSetting::SaveSettingValue(Settings *settings) + +void +BooleanValueSetting::SaveSettingValue(Settings* settings) { settings->Write(fValue ? "on" : "off"); } - diff --git a/src/kits/tracker/Settings.h b/src/kits/tracker/Settings.h index 3fc385796a..3758b6f938 100644 --- a/src/kits/tracker/Settings.h +++ b/src/kits/tracker/Settings.h @@ -31,37 +31,38 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef _SETTINGS_H_ #define _SETTINGS_H_ + #include #include "SettingsHandler.h" + namespace BPrivate { -extern Settings *settings; +extern Settings* settings; class StringValueSetting : public SettingsArgvDispatcher { // simple string setting public: - StringValueSetting(const char *name, const char *defaultValue, - const char *valueExpectedErrorString, - const char *wrongValueErrorString); + StringValueSetting(const char* name, const char* defaultValue, + const char* valueExpectedErrorString, + const char* wrongValueErrorString); virtual ~StringValueSetting(); - void ValueChanged(const char *newValue); - const char *Value() const; - virtual const char *Handle(const char *const *argv); + void ValueChanged(const char* newValue); + const char* Value() const; + virtual const char* Handle(const char* const *argv); protected: - virtual void SaveSettingValue(Settings *); + virtual void SaveSettingValue(Settings*); virtual bool NeedsSaving() const; - const char *fDefaultValue; - const char *fValueExpectedErrorString; - const char *fWrongValueErrorString; + const char* fDefaultValue; + const char* fValueExpectedErrorString; + const char* fWrongValueErrorString; BString fValue; }; @@ -69,31 +70,31 @@ class EnumeratedStringValueSetting : public StringValueSetting { // string setting, values that do not match string enumeration // are rejected public: - EnumeratedStringValueSetting(const char *name, const char *defaultValue, - const char *const *values, const char *valueExpectedErrorString, - const char *wrongValueErrorString); + EnumeratedStringValueSetting(const char* name, const char* defaultValue, + const char* const* values, const char* valueExpectedErrorString, + const char* wrongValueErrorString); - void ValueChanged(const char *newValue); - virtual const char *Handle(const char *const *argv); + void ValueChanged(const char* newValue); + virtual const char* Handle(const char* const *argv); protected: - const char *const *fValues; + const char* const* fValues; }; class ScalarValueSetting : public SettingsArgvDispatcher { // simple int32 setting public: - ScalarValueSetting(const char *name, int32 defaultValue, - const char *valueExpectedErrorString, const char *wrongValueErrorString, + ScalarValueSetting(const char* name, int32 defaultValue, + const char* valueExpectedErrorString, const char* wrongValueErrorString, int32 min = LONG_MIN, int32 max = LONG_MAX); void ValueChanged(int32 newValue); int32 Value() const; - void GetValueAsString(char *) const; - virtual const char *Handle(const char *const *argv); + void GetValueAsString(char*) const; + virtual const char* Handle(const char* const *argv); protected: - virtual void SaveSettingValue(Settings *); + virtual void SaveSettingValue(Settings*); virtual bool NeedsSaving() const; int32 fDefaultValue; @@ -101,38 +102,38 @@ protected: int32 fMax; int32 fMin; - const char *fValueExpectedErrorString; - const char *fWrongValueErrorString; + const char* fValueExpectedErrorString; + const char* fWrongValueErrorString; }; class HexScalarValueSetting : public ScalarValueSetting { // hexadecimal int32 setting public: - HexScalarValueSetting(const char *name, int32 defaultValue, - const char *valueExpectedErrorString, const char *wrongValueErrorString, + HexScalarValueSetting(const char* name, int32 defaultValue, + const char* valueExpectedErrorString, const char* wrongValueErrorString, int32 min = LONG_MIN, int32 max = LONG_MAX); - void GetValueAsString(char *buffer) const; + void GetValueAsString(char* buffer) const; protected: - virtual void SaveSettingValue(Settings *settings); + virtual void SaveSettingValue(Settings* settings); }; class BooleanValueSetting : public ScalarValueSetting { // on-off setting public: - BooleanValueSetting(const char *name, bool defaultValue); + BooleanValueSetting(const char* name, bool defaultValue); bool Value() const; void SetValue(bool value); - virtual const char *Handle(const char *const *argv); + virtual const char* Handle(const char* const *argv); protected: - virtual void SaveSettingValue(Settings *); + virtual void SaveSettingValue(Settings*); }; } using namespace BPrivate; -#endif /* _SETTINGS_H_ */ +#endif // _SETTINGS_H_ diff --git a/src/kits/tracker/SettingsHandler.cpp b/src/kits/tracker/SettingsHandler.cpp index 4bfba1cfc1..d2b2cdf9d0 100644 --- a/src/kits/tracker/SettingsHandler.cpp +++ b/src/kits/tracker/SettingsHandler.cpp @@ -49,7 +49,7 @@ All rights reserved. #include "SettingsHandler.h" -ArgvParser::ArgvParser(const char *name) +ArgvParser::ArgvParser(const char* name) : fFile(0), fBuffer(NULL), fPos(-1), @@ -84,7 +84,8 @@ ArgvParser::~ArgvParser() fclose(fFile); } -void + +void ArgvParser::MakeArgvEmpty() { // done with current argv, free it up @@ -94,13 +95,14 @@ ArgvParser::MakeArgvEmpty() fArgc = 0; } -status_t -ArgvParser::SendArgv(ArgvHandler argvHandlerFunc, void *passThru) + +status_t +ArgvParser::SendArgv(ArgvHandler argvHandlerFunc, void* passThru) { if (fArgc) { NextArgv(); fCurrentArgv[fArgc] = 0; - const char *result = (argvHandlerFunc)(fArgc, fCurrentArgv, passThru); + const char* result = (argvHandlerFunc)(fArgc, fCurrentArgv, passThru); if (result) printf("File %s; Line %ld # %s", fFileName, fLineNo, result); MakeArgvEmpty(); @@ -111,7 +113,8 @@ ArgvParser::SendArgv(ArgvHandler argvHandlerFunc, void *passThru) return B_OK; } -void + +void ArgvParser::NextArgv() { if (fSawBackslash) { @@ -128,7 +131,8 @@ ArgvParser::NextArgv() fArgc++; } -void + +void ArgvParser::NextArgvIfNotEmpty() { if (!fSawBackslash && fCurrentArgsPos < 0) @@ -137,7 +141,8 @@ ArgvParser::NextArgvIfNotEmpty() NextArgv(); } -char + +char ArgvParser::GetCh() { if (fPos < 0 || fBuffer[fPos] == 0) { @@ -150,15 +155,19 @@ ArgvParser::GetCh() return fBuffer[fPos++]; } -status_t -ArgvParser::EachArgv(const char *name, ArgvHandler argvHandlerFunc, void *passThru) + +status_t +ArgvParser::EachArgv(const char* name, ArgvHandler argvHandlerFunc, + void* passThru) { ArgvParser parser(name); return parser.EachArgvPrivate(name, argvHandlerFunc, passThru); } -status_t -ArgvParser::EachArgvPrivate(const char *name, ArgvHandler argvHandlerFunc, void *passThru) + +status_t +ArgvParser::EachArgvPrivate(const char* name, ArgvHandler argvHandlerFunc, + void* passThru) { status_t result; @@ -183,17 +192,19 @@ ArgvParser::EachArgvPrivate(const char *name, ArgvHandler argvHandlerFunc, void result = B_ERROR; break; } - fLineNo++; + + fLineNo++; if (fSawBackslash) { fSawBackslash = false; continue; } + // end of line, flush all argv result = SendArgv(argvHandlerFunc, passThru); continue; } - + if (fEatComment) continue; @@ -241,13 +252,14 @@ ArgvParser::EachArgvPrivate(const char *name, ArgvHandler argvHandlerFunc, void } -SettingsArgvDispatcher::SettingsArgvDispatcher(const char *name) +SettingsArgvDispatcher::SettingsArgvDispatcher(const char* name) : name(name) { } -void -SettingsArgvDispatcher::SaveSettings(Settings *settings, bool onlyIfNonDefault) + +void +SettingsArgvDispatcher::SaveSettings(Settings* settings, bool onlyIfNonDefault) { if (!onlyIfNonDefault || NeedsSaving()) { settings->Write("%s ", Name()); @@ -256,8 +268,9 @@ SettingsArgvDispatcher::SaveSettings(Settings *settings, bool onlyIfNonDefault) } } -bool -SettingsArgvDispatcher::HandleRectValue(BRect &result, const char *const *argv, + +bool +SettingsArgvDispatcher::HandleRectValue(BRect &result, const char* const* argv, bool printError) { if (!*argv) { @@ -266,35 +279,41 @@ SettingsArgvDispatcher::HandleRectValue(BRect &result, const char *const *argv, return false; } result.left = atoi(*argv); + if (!*++argv) { if (printError) printf("rect top expected"); return false; } result.top = atoi(*argv); + if (!*++argv) { if (printError) printf("rect right expected"); return false; } result.right = atoi(*argv); + if (!*++argv) { if (printError) printf("rect bottom expected"); return false; } result.bottom = atoi(*argv); + return true; } -void -SettingsArgvDispatcher::WriteRectValue(Settings *setting, BRect rect) + +void +SettingsArgvDispatcher::WriteRectValue(Settings* setting, BRect rect) { setting->Write("%d %d %d %d", (int32)rect.left, (int32)rect.top, (int32)rect.right, (int32)rect.bottom); } -Settings::Settings(const char *filename, const char *settingsDirName) + +Settings::Settings(const char* filename, const char* settingsDirName) : fFileName(filename), fSettingsDir(settingsDirName), fList(0), @@ -302,7 +321,8 @@ Settings::Settings(const char *filename, const char *settingsDirName) fListSize(30), fCurrentSettings(0) { - fList = (SettingsArgvDispatcher **)calloc((size_t)fListSize, sizeof(SettingsArgvDispatcher *)); + fList = (SettingsArgvDispatcher**)calloc((size_t)fListSize, + sizeof(SettingsArgvDispatcher*)); } @@ -310,25 +330,27 @@ Settings::~Settings() { for (int32 index = 0; index < fCount; index++) delete fList[index]; - + free(fList); } -const char * -Settings::ParseUserSettings(int, const char *const *argv, void *castToThis) +const char* +Settings::ParseUserSettings(int, const char* const* argv, void* castToThis) { if (!*argv) return 0; - SettingsArgvDispatcher *handler = ((Settings *)castToThis)->Find(*argv); + SettingsArgvDispatcher* handler = ((Settings*)castToThis)->Find(*argv); if (!handler) return "unknown command"; + return handler->Handle(argv); } -bool -Settings::Add(SettingsArgvDispatcher *setting) + +bool +Settings::Add(SettingsArgvDispatcher* setting) { // check for uniqueness if (Find(setting->Name())) @@ -336,15 +358,16 @@ Settings::Add(SettingsArgvDispatcher *setting) if (fCount >= fListSize) { fListSize += 30; - fList = (SettingsArgvDispatcher **)realloc(fList, - fListSize * sizeof(SettingsArgvDispatcher *)); + fList = (SettingsArgvDispatcher**)realloc(fList, + fListSize * sizeof(SettingsArgvDispatcher*)); } fList[fCount++] = setting; return true; } -SettingsArgvDispatcher * -Settings::Find(const char *name) + +SettingsArgvDispatcher* +Settings::Find(const char* name) { for (int32 index = 0; index < fCount; index++) if (strcmp(name, fList[index]->Name()) == 0) @@ -353,7 +376,8 @@ Settings::Find(const char *name) return NULL; } -void + +void Settings::TryReadingSettings() { BPath prefsPath; @@ -366,14 +390,16 @@ Settings::TryReadingSettings() } } -void + +void Settings::SaveSettings(bool onlyIfNonDefault) { SaveCurrentSettings(onlyIfNonDefault); } -void -Settings::MakeSettingsDirectory(BDirectory *resultingSettingsDir) + +void +Settings::MakeSettingsDirectory(BDirectory* resultingSettingsDir) { BPath path; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) != B_OK) @@ -382,10 +408,10 @@ Settings::MakeSettingsDirectory(BDirectory *resultingSettingsDir) // make sure there is a directory // mkdir() will only make one leaf at a time, unfortunately path.Append(fSettingsDir); - char * ptr = (char *)alloca(strlen(path.Path()) + 1); + char* ptr = (char *)alloca(strlen(path.Path()) + 1); strcpy(ptr, path.Path()); - char * end = ptr+strlen(ptr); - char * mid = ptr+1; + char* end = ptr+strlen(ptr); + char* mid = ptr+1; while (mid < end) { mid = strchr(mid, '/'); if (!mid) break; @@ -398,7 +424,8 @@ Settings::MakeSettingsDirectory(BDirectory *resultingSettingsDir) resultingSettingsDir->SetTo(path.Path()); } -void + +void Settings::SaveCurrentSettings(bool onlyIfNonDefault) { BDirectory settingsDir; @@ -406,24 +433,25 @@ Settings::SaveCurrentSettings(bool onlyIfNonDefault) if (settingsDir.InitCheck() != B_OK) return; - + // nuke old settings BEntry entry(&settingsDir, fFileName); entry.Remove(); - + BFile prefs(&entry, O_RDWR | O_CREAT); if (prefs.InitCheck() != B_OK) return; fCurrentSettings = &prefs; - for (int32 index = 0; index < fCount; index++) + for (int32 index = 0; index < fCount; index++) fList[index]->SaveSettings(this, onlyIfNonDefault); fCurrentSettings = NULL; } -void -Settings::Write(const char *format, ...) + +void +Settings::Write(const char* format, ...) { va_list args; @@ -432,8 +460,9 @@ Settings::Write(const char *format, ...) va_end(args); } -void -Settings::VSWrite(const char *format, va_list arg) + +void +Settings::VSWrite(const char* format, va_list arg) { char fBuffer[2048]; vsprintf(fBuffer, format, arg); diff --git a/src/kits/tracker/SettingsHandler.h b/src/kits/tracker/SettingsHandler.h index 399398f2a3..255d889e09 100644 --- a/src/kits/tracker/SettingsHandler.h +++ b/src/kits/tracker/SettingsHandler.h @@ -31,16 +31,17 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef __SETTINGS_FILE__ #define __SETTINGS_FILE__ + #include #include #include #include #include + class BFile; class BDirectory; class BRect; @@ -49,9 +50,8 @@ namespace BPrivate { class Settings; -typedef const char *(*ArgvHandler)(int argc, const char *const *argv, void *params); +typedef const char* (*ArgvHandler)(int argc, const char* const *argv, void* params); // return 0 or error string if parsing failed - const int32 kBufferSize = 1024; @@ -59,18 +59,18 @@ class ArgvParser { // this class opens a text file and passes the context in argv // format to a specified handler public: - static status_t EachArgv(const char *name, - ArgvHandler argvHandlerFunc, void *passThru); + static status_t EachArgv(const char* name, + ArgvHandler argvHandlerFunc, void* passThru); private: - ArgvParser(const char *name); + ArgvParser(const char* name); ~ArgvParser(); - status_t EachArgvPrivate(const char *name, - ArgvHandler argvHandlerFunc, void *passThru); + status_t EachArgvPrivate(const char* name, + ArgvHandler argvHandlerFunc, void* passThru); char GetCh(); - - status_t SendArgv(ArgvHandler argvHandlerFunc, void *passThru); + + status_t SendArgv(ArgvHandler argvHandlerFunc, void* passThru); // done with a whole line of argv, send it off and get ready // to build a new one @@ -81,15 +81,15 @@ private: void MakeArgvEmpty(); - FILE *fFile; - char *fBuffer; + FILE* fFile; + char* fBuffer; int32 fPos; int fArgc; - char **fCurrentArgv; + char** fCurrentArgv; int32 fCurrentArgsPos; - char fCurrentArgs [1024]; + char fCurrentArgs[1024]; bool fSawBackslash; bool fEatComment; @@ -97,77 +97,78 @@ private: bool fInSingleQuote; int32 fLineNo; - const char *fFileName; + const char* fFileName; }; class SettingsArgvDispatcher { // base class for a single setting item public: - SettingsArgvDispatcher(const char *name); + SettingsArgvDispatcher(const char* name); virtual ~SettingsArgvDispatcher() {}; - void SaveSettings(Settings *settings, bool onlyIfNonDefault); + void SaveSettings(Settings* settings, bool onlyIfNonDefault); - const char *Name() const - { return name; } + const char* Name() const { return name; } // name as it appears in the settings file - virtual const char *Handle(const char *const *argv) = 0; + virtual const char* Handle(const char* const *argv) = 0; // override this adding an argv parser that reads in the // values in argv format for this setting // return a pointer to an error message or null if parsed OK - // some handy reader/writer calls - bool HandleRectValue(BRect &, const char *const *argv, bool printError = true); - void WriteRectValue(Settings *, BRect); + bool HandleRectValue(BRect&, const char* const *argv, bool printError = true); + void WriteRectValue(Settings*, BRect); protected: - virtual void SaveSettingValue(Settings *settings) = 0; + virtual void SaveSettingValue(Settings* settings) = 0; // override this to save the current value of this setting in a // text format - + virtual bool NeedsSaving() const { return true; } // override to return false if current value is equal to the default // and does not need saving + private: - const char *name; + const char* name; }; + class Settings { // this class is a list of all the settings handlers, reads and // saves the settings file public: - Settings(const char *filename, const char *settingsDirName); + Settings(const char* filename, const char* settingsDirName); ~Settings(); void TryReadingSettings(); void SaveSettings(bool onlyIfNonDefault = true); - bool Add(SettingsArgvDispatcher *); + bool Add(SettingsArgvDispatcher*); // return false if argv dispatcher with the same name already // registered - void Write(const char *format, ...); - void VSWrite(const char *, va_list); + void Write(const char* format, ...); + void VSWrite(const char*, va_list); private: - void MakeSettingsDirectory(BDirectory *); + void MakeSettingsDirectory(BDirectory*); - SettingsArgvDispatcher *Find(const char *); - static const char *ParseUserSettings(int, const char *const *argv, void *); + SettingsArgvDispatcher* Find(const char*); + static const char* ParseUserSettings(int, const char* const *argv, void*); void SaveCurrentSettings(bool onlyIfNonDefault); - const char *fFileName; - const char *fSettingsDir; // currently unused - SettingsArgvDispatcher **fList; + const char* fFileName; + const char* fSettingsDir; + // currently unused + SettingsArgvDispatcher** fList; int32 fCount; int32 fListSize; - BFile *fCurrentSettings; + BFile* fCurrentSettings; }; } using namespace BPrivate; -#endif +#endif // __SETTINGS_FILE__ diff --git a/src/kits/tracker/SettingsViews.cpp b/src/kits/tracker/SettingsViews.cpp index 5249f67b6f..28f1b9b261 100644 --- a/src/kits/tracker/SettingsViews.cpp +++ b/src/kits/tracker/SettingsViews.cpp @@ -67,9 +67,9 @@ static const rgb_color kDefaultWarningSpaceColor = {203, 0, 0, kSpaceBarAlpha}; static void -send_bool_notices(uint32 what, const char *name, bool value) +send_bool_notices(uint32 what, const char* name, bool value) { - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); if (!tracker) return; @@ -220,9 +220,9 @@ DesktopSettingsView::AttachedToWindow() void -DesktopSettingsView::MessageReceived(BMessage *message) +DesktopSettingsView::MessageReceived(BMessage* message) { - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); if (!tracker) return; @@ -345,7 +345,7 @@ DesktopSettingsView::Revert() void DesktopSettingsView::_SendNotices() { - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); if (!tracker) return; @@ -467,9 +467,9 @@ WindowsSettingsView::AttachedToWindow() void -WindowsSettingsView::MessageReceived(BMessage *message) +WindowsSettingsView::MessageReceived(BMessage* message) { - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); if (!tracker) return; TrackerSettings settings; @@ -545,7 +545,7 @@ WindowsSettingsView::MessageReceived(BMessage *message) void WindowsSettingsView::SetDefaults() { - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); if (!tracker) return; @@ -605,7 +605,7 @@ WindowsSettingsView::IsDefaultable() const void WindowsSettingsView::Revert() { - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); if (!tracker) return; @@ -757,9 +757,9 @@ SpaceBarSettingsView::AttachedToWindow() void -SpaceBarSettingsView::MessageReceived(BMessage *message) +SpaceBarSettingsView::MessageReceived(BMessage* message) { - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); if (!tracker) return; TrackerSettings settings; @@ -823,7 +823,7 @@ SpaceBarSettingsView::MessageReceived(BMessage *message) void SpaceBarSettingsView::SetDefaults() { - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); if (!tracker) return; @@ -862,7 +862,7 @@ SpaceBarSettingsView::IsDefaultable() const void SpaceBarSettingsView::Revert() { - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); if (!tracker) return; @@ -969,9 +969,9 @@ TrashSettingsView::AttachedToWindow() void -TrashSettingsView::MessageReceived(BMessage *message) +TrashSettingsView::MessageReceived(BMessage* message) { - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); if (!tracker) return; TrackerSettings settings; @@ -1037,7 +1037,7 @@ TrashSettingsView::Revert() void TrashSettingsView::_SendNotices() { - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); if (!tracker) return; diff --git a/src/kits/tracker/SettingsViews.h b/src/kits/tracker/SettingsViews.h index 89299ab945..bc3474bb26 100644 --- a/src/kits/tracker/SettingsViews.h +++ b/src/kits/tracker/SettingsViews.h @@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef _SETTINGS_VIEWS #define _SETTINGS_VIEWS + #include #include #include @@ -43,6 +43,7 @@ All rights reserved. #include "TrackerSettings.h" + const uint32 kSettingsContentsModified = 'Scmo'; class BButton; @@ -72,7 +73,7 @@ class DesktopSettingsView : public SettingsView { public: DesktopSettingsView(); - virtual void MessageReceived(BMessage *message); + virtual void MessageReceived(BMessage* message); virtual void AttachedToWindow(); virtual void SetDefaults(); @@ -85,11 +86,11 @@ class DesktopSettingsView : public SettingsView { private: void _SendNotices(); - BRadioButton *fShowDisksIconRadioButton; - BRadioButton *fMountVolumesOntoDesktopRadioButton; - BCheckBox *fMountSharedVolumesOntoDesktopCheckBox; - BCheckBox *fIntegrateNonBootBeOSDesktopsCheckBox; - BButton *fMountButton; + BRadioButton* fShowDisksIconRadioButton; + BRadioButton* fMountVolumesOntoDesktopRadioButton; + BCheckBox* fMountSharedVolumesOntoDesktopCheckBox; + BCheckBox* fIntegrateNonBootBeOSDesktopsCheckBox; + BButton* fMountButton; bool fShowDisksIcon; bool fMountVolumesOntoDesktop; @@ -104,7 +105,7 @@ class WindowsSettingsView : public SettingsView { public: WindowsSettingsView(); - virtual void MessageReceived(BMessage *message); + virtual void MessageReceived(BMessage* message); virtual void AttachedToWindow(); virtual void SetDefaults(); @@ -115,13 +116,13 @@ class WindowsSettingsView : public SettingsView { virtual bool IsRevertable() const; private: - BCheckBox *fShowFullPathInTitleBarCheckBox; - BCheckBox *fSingleWindowBrowseCheckBox; - BCheckBox *fShowNavigatorCheckBox; - BCheckBox *fShowSelectionWhenInactiveCheckBox; - BCheckBox *fOutlineSelectionCheckBox; - BCheckBox *fSortFolderNamesFirstCheckBox; - BCheckBox *fTypeAheadFilteringCheckBox; + BCheckBox* fShowFullPathInTitleBarCheckBox; + BCheckBox* fSingleWindowBrowseCheckBox; + BCheckBox* fShowNavigatorCheckBox; + BCheckBox* fShowSelectionWhenInactiveCheckBox; + BCheckBox* fOutlineSelectionCheckBox; + BCheckBox* fSortFolderNamesFirstCheckBox; + BCheckBox* fTypeAheadFilteringCheckBox; bool fShowFullPathInTitleBar; bool fSingleWindowBrowse; @@ -138,7 +139,7 @@ class SpaceBarSettingsView : public SettingsView { SpaceBarSettingsView(); virtual ~SpaceBarSettingsView(); - virtual void MessageReceived(BMessage *message); + virtual void MessageReceived(BMessage* message); virtual void AttachedToWindow(); virtual void SetDefaults(); @@ -149,9 +150,9 @@ class SpaceBarSettingsView : public SettingsView { virtual bool IsRevertable() const; private: - BCheckBox *fSpaceBarShowCheckBox; - BColorControl *fColorControl; - BMenuField *fColorPicker; + BCheckBox* fSpaceBarShowCheckBox; + BColorControl* fColorControl; + BMenuField* fColorPicker; int32 fCurrentColor; bool fSpaceBarShow; @@ -162,11 +163,12 @@ class SpaceBarSettingsView : public SettingsView { typedef SettingsView _inherited; }; + class TrashSettingsView : public SettingsView { public: TrashSettingsView(); - virtual void MessageReceived(BMessage *message); + virtual void MessageReceived(BMessage* message); virtual void AttachedToWindow(); virtual void SetDefaults(); @@ -179,8 +181,8 @@ class TrashSettingsView : public SettingsView { private: void _SendNotices(); - BCheckBox *fDontMoveFilesToTrashCheckBox; - BCheckBox *fAskBeforeDeleteFileCheckBox; + BCheckBox* fDontMoveFilesToTrashCheckBox; + BCheckBox* fAskBeforeDeleteFileCheckBox; bool fDontMoveFilesToTrash; bool fAskBeforeDeleteFile; diff --git a/src/kits/tracker/SlowContextPopup.cpp b/src/kits/tracker/SlowContextPopup.cpp index e81201dbaf..95c33668aa 100644 --- a/src/kits/tracker/SlowContextPopup.cpp +++ b/src/kits/tracker/SlowContextPopup.cpp @@ -65,7 +65,7 @@ All rights reserved. #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "SlowContextPopup" -BSlowContextMenu::BSlowContextMenu(const char *title) +BSlowContextMenu::BSlowContextMenu(const char* title) : BPopUpMenu(title, false, false), fMenuBuilt(false), fMessage(B_REFS_RECEIVED), @@ -130,7 +130,7 @@ BSlowContextMenu::DetachedFromWindow() void -BSlowContextMenu::SetNavDir(const entry_ref *ref) +BSlowContextMenu::SetNavDir(const entry_ref* ref) { ForceRebuild(); // reset the slow menu building mechanism so we can add more stuff @@ -139,7 +139,7 @@ BSlowContextMenu::SetNavDir(const entry_ref *ref) } -void +void BSlowContextMenu::ForceRebuild() { ClearMenuBuildingState(); @@ -147,7 +147,7 @@ BSlowContextMenu::ForceRebuild() } -bool +bool BSlowContextMenu::NeedsToRebuild() const { return !fMenuBuilt; @@ -178,10 +178,12 @@ BSlowContextMenu::ClearMenuBuildingState() } } + const int32 kItemsToAddChunk = 20; const bigtime_t kMaxTimeBuildingMenu = 200000; -bool + +bool BSlowContextMenu::AddDynamicItem(add_state state) { if (fMenuBuilt) @@ -218,12 +220,13 @@ BSlowContextMenu::AddDynamicItem(add_state state) bool BSlowContextMenu::StartBuildingItemList() { - // return false when done building + // return false when done building BEntry entry; if (fNavDir.device < 0 || entry.SetTo(&fNavDir) != B_OK - || !entry.Exists()) + || !entry.Exists()) { return false; + } fIteratingDesktop = false; @@ -236,13 +239,13 @@ BSlowContextMenu::StartBuildingItemList() if (fVolsOnly) return true; - + Model startModel(&entry, true); if (startModel.InitCheck() == B_OK) { if (!startModel.IsContainer()) return false; - if (startModel.IsQuery()) + if (startModel.IsQuery()) fContainer = new QueryEntryListCollection(&startModel); else if (startModel.IsDesktop()) { fIteratingDesktop = true; @@ -250,10 +253,11 @@ BSlowContextMenu::StartBuildingItemList() startModel.EntryRef()); AddRootItemsIfNeeded(); AddTrashItem(); - } else - fContainer = new DirectoryEntryList(*dynamic_cast + } else { + fContainer = new DirectoryEntryList(*dynamic_cast (startModel.Node())); - + } + if (fContainer->InitCheck() != B_OK) return false; @@ -338,24 +342,24 @@ BSlowContextMenu::AddNextItem() } -void -BSlowContextMenu::AddOneItem(Model *model) +void +BSlowContextMenu::AddOneItem(Model* model) { - BMenuItem *item = NewModelItem(model, &fMessage, fMessenger, false, - dynamic_cast(fParentWindow) ? - dynamic_cast(fParentWindow) : 0, + BMenuItem* item = NewModelItem(model, &fMessage, fMessenger, false, + dynamic_cast(fParentWindow) ? + dynamic_cast(fParentWindow) : 0, fTypesList, &fTrackingHook); - if (item) + if (item) fItemList->AddItem(item); } -ModelMenuItem * -BSlowContextMenu::NewModelItem(Model *model, const BMessage *invokeMessage, +ModelMenuItem* +BSlowContextMenu::NewModelItem(Model* model, const BMessage* invokeMessage, const BMessenger &target, bool suppressFolderHierarchy, - BContainerWindow *parentWindow, const BObjectList *typeslist, - TrackingHookData *hook) + BContainerWindow* parentWindow, const BObjectList* typeslist, + TrackingHookData* hook) { if (model->InitCheck() != B_OK) return NULL; @@ -364,8 +368,8 @@ BSlowContextMenu::NewModelItem(Model *model, const BMessage *invokeMessage, bool container = false; if (model->IsSymLink()) { - Model *newResolvedModel = NULL; - Model *result = model->LinkTo(); + Model* newResolvedModel = NULL; + Model* result = model->LinkTo(); if (!result) { newResolvedModel = new Model(model->EntryRef(), true, true); @@ -401,7 +405,7 @@ BSlowContextMenu::NewModelItem(Model *model, const BMessage *invokeMessage, container = model->IsContainer(); } - BMessage *message = new BMessage(*invokeMessage); + BMessage* message = new BMessage(*invokeMessage); message->AddRef("refs", model->EntryRef()); // Truncate the name if necessary @@ -409,13 +413,13 @@ BSlowContextMenu::NewModelItem(Model *model, const BMessage *invokeMessage, be_plain_font->TruncateString(&truncatedString, B_TRUNCATE_END, BNavMenu::GetMaxMenuWidth()); - ModelMenuItem *item = NULL; + ModelMenuItem* item = NULL; if (!container || suppressFolderHierarchy) { item = new ModelMenuItem(model, truncatedString.String(), message); if (invokeMessage->what != B_REFS_RECEIVED) item->SetEnabled(false); } else { - BNavMenu *menu = new BNavMenu(truncatedString.String(), + BNavMenu* menu = new BNavMenu(truncatedString.String(), invokeMessage->what, target, parentWindow, typeslist); menu->SetNavDir(&ref); @@ -448,13 +452,13 @@ BSlowContextMenu::BuildVolumeMenu() BEntry entry; startDir.GetEntry(&entry); - Model *model = new Model(&entry); + Model* model = new Model(&entry); if (model->InitCheck() != B_OK) { delete model; continue; } - BNavMenu *menu = new BNavMenu(model->Name(), fMessage.what, + BNavMenu* menu = new BNavMenu(model->Name(), fMessage.what, fMessenger, fParentWindow, fTypesList); menu->SetNavDir(model->EntryRef()); @@ -463,8 +467,8 @@ BSlowContextMenu::BuildVolumeMenu() ASSERT(menu->Name()); - ModelMenuItem *item = new ModelMenuItem(model, menu); - BMessage *message = new BMessage(fMessage); + ModelMenuItem* item = new ModelMenuItem(model, menu); + BMessage* message = new BMessage(fMessage); message->AddRef("refs", model->EntryRef()); item->SetMessage(message); @@ -485,7 +489,7 @@ BSlowContextMenu::DoneBuildingItemList() fItemList->SortItems(&BNavMenu::CompareOne); int32 count = fItemList->CountItems(); - for (int32 index = 0; index < count; index++) + for (int32 index = 0; index < count; index++) AddItem(fItemList->ItemAt(index)); fItemList->MakeEmpty(); @@ -501,7 +505,7 @@ BSlowContextMenu::DoneBuildingItemList() void -BSlowContextMenu::SetTypesList(const BObjectList *list) +BSlowContextMenu::SetTypesList(const BObjectList* list) { fTypesList = list; } @@ -514,9 +518,9 @@ BSlowContextMenu::SetTarget(const BMessenger &target) } -TrackingHookData * -BSlowContextMenu::InitTrackingHook(bool (*hook)(BMenu *, void *), const BMessenger *target, - const BMessage *dragMessage) +TrackingHookData* +BSlowContextMenu::InitTrackingHook(bool (*hook)(BMenu*, void*), const BMessenger* target, + const BMessage* dragMessage) { fTrackingHook.fTrackingHook = hook; if (target) @@ -527,17 +531,17 @@ BSlowContextMenu::InitTrackingHook(bool (*hook)(BMenu *, void *), const BMesseng } -void -BSlowContextMenu::SetTrackingHookDeep(BMenu *menu, bool (*func)(BMenu *, void *), void *state) +void +BSlowContextMenu::SetTrackingHookDeep(BMenu* menu, bool (*func)(BMenu*, void*), void* state) { menu->SetTrackingHook(func, state); int32 count = menu->CountItems(); for (int32 index = 0; index < count; index++) { - BMenuItem *item = menu->ItemAt(index); + BMenuItem* item = menu->ItemAt(index); if (!item) continue; - BMenu *submenu = item->Submenu(); + BMenu* submenu = item->Submenu(); if (submenu) SetTrackingHookDeep(submenu, func, state); } diff --git a/src/kits/tracker/SlowContextPopup.h b/src/kits/tracker/SlowContextPopup.h index 2f980f3845..d03fd8e65a 100644 --- a/src/kits/tracker/SlowContextPopup.h +++ b/src/kits/tracker/SlowContextPopup.h @@ -31,24 +31,25 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef SLOW_CONTEXT_POPUP_H #define SLOW_CONTEXT_POPUP_H + #include #include "NavMenu.h" + namespace BPrivate { class BSlowContextMenu : public BPopUpMenu { public: - BSlowContextMenu(const char *title); - virtual ~BSlowContextMenu(); + BSlowContextMenu(const char* title); + virtual ~BSlowContextMenu(); virtual void AttachedToWindow(); virtual void DetachedFromWindow(); - - void SetNavDir(const entry_ref *); + + void SetNavDir(const entry_ref*); void ClearMenu(); @@ -58,53 +59,53 @@ public: void SetTarget(const BMessenger &); const BMessenger Target() const; - - void SetTypesList(const BObjectList *list); - const BObjectList *TypesList() const; - - static ModelMenuItem *NewModelItem(Model *, const BMessage *, const BMessenger &, - bool suppressFolderHierarchy=false, BContainerWindow * = NULL, - const BObjectList *typeslist = NULL, - TrackingHookData *hook = NULL); - - TrackingHookData *InitTrackingHook(bool (*)(BMenu *, void *), - const BMessenger *target, const BMessage *dragMessage); + + void SetTypesList(const BObjectList* list); + const BObjectList* TypesList() const; + + static ModelMenuItem* NewModelItem(Model*, const BMessage*, const BMessenger&, + bool suppressFolderHierarchy = false, BContainerWindow* = NULL, + const BObjectList* typeslist = NULL, + TrackingHookData* hook = NULL); + + TrackingHookData* InitTrackingHook(bool (*)(BMenu*, void*), + const BMessenger* target, const BMessage* dragMessage); const bool IsShowing() const; - + protected: virtual bool AddDynamicItem(add_state state); virtual bool StartBuildingItemList(); virtual bool AddNextItem(); - virtual void DoneBuildingItemList(); + virtual void DoneBuildingItemList(); virtual void ClearMenuBuildingState(); void BuildVolumeMenu(); - - void AddOneItem(Model *); + + void AddOneItem(Model*); void AddRootItemsIfNeeded(); void AddTrashItem(); - static void SetTrackingHookDeep(BMenu *, bool (*)(BMenu *, void *), void *); - + static void SetTrackingHookDeep(BMenu*, bool (*)(BMenu*, void*), void*); + bool fMenuBuilt; -private: +private: entry_ref fNavDir; BMessage fMessage; BMessenger fMessenger; - BWindow *fParentWindow; - + BWindow* fParentWindow; + // menu building state bool fVolsOnly; - BObjectList *fItemList; - EntryListBase *fContainer; + BObjectList* fItemList; + EntryListBase* fContainer; bool fIteratingDesktop; - const BObjectList *fTypesList; - + const BObjectList* fTypesList; + TrackingHookData fTrackingHook; bool fIsShowing; - // see note in AttachedToWindow + // see note in AttachedToWindow }; @@ -112,22 +113,25 @@ private: using namespace BPrivate; -inline const BObjectList * + +inline const BObjectList* BSlowContextMenu::TypesList() const { return fTypesList; } + inline const BMessenger BSlowContextMenu::Target() const { return fMessenger; } + inline const bool BSlowContextMenu::IsShowing() const { return fIsShowing; } -#endif +#endif // SLOW_CONTEXT_POPUP_H diff --git a/src/kits/tracker/SlowMenu.cpp b/src/kits/tracker/SlowMenu.cpp index e4705ff732..45a4f52c0c 100644 --- a/src/kits/tracker/SlowMenu.cpp +++ b/src/kits/tracker/SlowMenu.cpp @@ -32,18 +32,22 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include "SlowMenu.h" -BSlowMenu::BSlowMenu(const char *title, menu_layout layout) + +BSlowMenu::BSlowMenu(const char* title, menu_layout layout) : BMenu(title, layout), fMenuBuilt(false) { } + const int32 kItemsToAddChunk = 20; const bigtime_t kMaxTimeBuildingMenu = 200000; -bool + +bool BSlowMenu::AddDynamicItem(add_state state) { if (fMenuBuilt) @@ -68,39 +72,45 @@ BSlowMenu::AddDynamicItem(add_state state) return false; // done with menu, don't call again } - if (system_time() > timeToBail) - // we have been in here long enough, come back later + + if (system_time() > timeToBail) { + // we've been in here long enough, come back later break; + } } - return true; // call me again, got more to show + return true; + // call me again, got more to show } -bool + +bool BSlowMenu::StartBuildingItemList() { return true; } -bool + +bool BSlowMenu::AddNextItem() { TRESPASS(); - // pure virtual, shouldn't be here + // pure virtual, shouldn't be here return true; } -void + +void BSlowMenu::DoneBuildingItemList() { TRESPASS(); - // pure virtual, shouldn't be here + // pure virtual, shouldn't be here } -void + +void BSlowMenu::ClearMenuBuildingState() { TRESPASS(); - // pure virtual, shouldn't be here + // pure virtual, shouldn't be here } - diff --git a/src/kits/tracker/SlowMenu.h b/src/kits/tracker/SlowMenu.h index 62e9156b07..46c2c37a0d 100644 --- a/src/kits/tracker/SlowMenu.h +++ b/src/kits/tracker/SlowMenu.h @@ -31,24 +31,26 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef __SLOW_MENU__ #define __SLOW_MENU__ -#include -#include -#include // SlowMenu is a convenience class that makes it easier to // use the AddDynamicItem callback to implement a menu that can // checks periodically between creating new items and quits // early if needed + +#include +#include +#include + + namespace BPrivate { class BSlowMenu : public BMenu { public: - BSlowMenu(const char *title, menu_layout layout = B_ITEMS_IN_COLUMN); + BSlowMenu(const char* title, menu_layout layout = B_ITEMS_IN_COLUMN); protected: virtual bool StartBuildingItemList(); @@ -73,4 +75,4 @@ class BSlowMenu : public BMenu { using namespace BPrivate; -#endif /* __SLOW_MENU__ */ +#endif // __SLOW_MENU__ diff --git a/src/kits/tracker/StatusWindow.cpp b/src/kits/tracker/StatusWindow.cpp index 74d6151de0..755da3f150 100644 --- a/src/kits/tracker/StatusWindow.cpp +++ b/src/kits/tracker/StatusWindow.cpp @@ -86,7 +86,7 @@ public: namespace BPrivate { -BStatusWindow *gStatusWindow = NULL; +BStatusWindow* gStatusWindow = NULL; } @@ -246,7 +246,7 @@ BStatusWindow::CreateStatusItem(thread_id thread, StatusWindowState type) AutoLock lock(be_app); int32 count = be_app->CountWindows(); for (int32 index = 0; index < count; index++) { - if (dynamic_cast(be_app->WindowAt(index)) + if (dynamic_cast(be_app->WindowAt(index)) && be_app->WindowAt(index)->IsActive()) { desktopActive = true; break; @@ -842,7 +842,7 @@ BStatusView::AttachedToWindow() void -BStatusView::MessageReceived(BMessage *message) +BStatusView::MessageReceived(BMessage* message) { switch (message->what) { case kPauseButton: @@ -888,7 +888,7 @@ BStatusView::MessageReceived(BMessage *message) void -BStatusView::UpdateStatus(const char *curItem, off_t itemSize, bool optional) +BStatusView::UpdateStatus(const char* curItem, off_t itemSize, bool optional) { if (!fShowCount) { fStatusBar->Update((float)fItemSize / fTotalSize); @@ -911,7 +911,7 @@ BStatusView::UpdateStatus(const char *curItem, off_t itemSize, bool optional) buffer << fCurItem << " "; // if we don't have curItem, take the one from the stash - const char *statusItem = curItem != NULL + const char* statusItem = curItem != NULL ? curItem : fPendingStatusString; fStatusBar->Update((float)fItemSize / fTotalSize, statusItem, diff --git a/src/kits/tracker/StatusWindow.h b/src/kits/tracker/StatusWindow.h index 75019ad4c0..4f8af426fa 100644 --- a/src/kits/tracker/StatusWindow.h +++ b/src/kits/tracker/StatusWindow.h @@ -31,7 +31,7 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ -#ifndef STATUS_WINDOW_H +#ifndef STATUS_WINDOW_H #define STATUS_WINDOW_H @@ -203,4 +203,5 @@ extern BStatusWindow* gStatusWindow; using namespace BPrivate; + #endif // STATUS_WINDOW_H diff --git a/src/kits/tracker/TaskLoop.cpp b/src/kits/tracker/TaskLoop.cpp index 08eb249eb5..dfcc7fab38 100644 --- a/src/kits/tracker/TaskLoop.cpp +++ b/src/kits/tracker/TaskLoop.cpp @@ -48,7 +48,7 @@ DelayedTask::~DelayedTask() { } -OneShotDelayedTask::OneShotDelayedTask(FunctionObject *functor, bigtime_t delay) +OneShotDelayedTask::OneShotDelayedTask(FunctionObject* functor, bigtime_t delay) : DelayedTask(delay), fFunctor(functor) { @@ -72,8 +72,9 @@ OneShotDelayedTask::RunIfNeeded(bigtime_t currentTime) } -PeriodicDelayedTask::PeriodicDelayedTask(FunctionObjectWithResult *functor, - bigtime_t initialDelay, bigtime_t period) +PeriodicDelayedTask::PeriodicDelayedTask( + FunctionObjectWithResult* functor, bigtime_t initialDelay, + bigtime_t period) : DelayedTask(initialDelay), fPeriod(period), fFunctor(functor) @@ -100,7 +101,7 @@ PeriodicDelayedTask::RunIfNeeded(bigtime_t currentTime) PeriodicDelayedTaskWithTimeout::PeriodicDelayedTaskWithTimeout( - FunctionObjectWithResult *functor, bigtime_t initialDelay, + FunctionObjectWithResult* functor, bigtime_t initialDelay, bigtime_t period, bigtime_t timeout) : PeriodicDelayedTask(functor, initialDelay, period), fTimeoutAfter(system_time() + timeout) @@ -124,8 +125,8 @@ PeriodicDelayedTaskWithTimeout::RunIfNeeded(bigtime_t currentTime) } -RunWhenIdleTask::RunWhenIdleTask(FunctionObjectWithResult *functor, bigtime_t - initialDelay, bigtime_t idleFor, bigtime_t heartBeat) +RunWhenIdleTask::RunWhenIdleTask(FunctionObjectWithResult* functor, + bigtime_t initialDelay, bigtime_t idleFor, bigtime_t heartBeat) : PeriodicDelayedTask(functor, initialDelay, heartBeat), fIdleFor(idleFor), fState(kInitialDelay) @@ -251,21 +252,21 @@ TaskLoop::~TaskLoop() void -TaskLoop::RunLater(DelayedTask *task) +TaskLoop::RunLater(DelayedTask* task) { AddTask(task); } void -TaskLoop::RunLater(FunctionObject *functor, bigtime_t delay) +TaskLoop::RunLater(FunctionObject* functor, bigtime_t delay) { RunLater(new OneShotDelayedTask(functor, delay)); } void -TaskLoop::RunLater(FunctionObjectWithResult *functor, +TaskLoop::RunLater(FunctionObjectWithResult* functor, bigtime_t delay, bigtime_t period) { RunLater(new PeriodicDelayedTask(functor, delay, period)); @@ -273,16 +274,17 @@ TaskLoop::RunLater(FunctionObjectWithResult *functor, void -TaskLoop::RunLater(FunctionObjectWithResult *functor, bigtime_t delay, +TaskLoop::RunLater(FunctionObjectWithResult* functor, bigtime_t delay, bigtime_t period, bigtime_t timeout) { - RunLater(new PeriodicDelayedTaskWithTimeout(functor, delay, period, timeout)); + RunLater(new PeriodicDelayedTaskWithTimeout(functor, delay, period, + timeout)); } void -TaskLoop::RunWhenIdle(FunctionObjectWithResult *functor, bigtime_t initialDelay, - bigtime_t idleTime, bigtime_t heartBeat) +TaskLoop::RunWhenIdle(FunctionObjectWithResult* functor, + bigtime_t initialDelay, bigtime_t idleTime, bigtime_t heartBeat) { RunLater(new RunWhenIdleTask(functor, initialDelay, idleTime, heartBeat)); } @@ -291,7 +293,7 @@ TaskLoop::RunWhenIdle(FunctionObjectWithResult *functor, bigtime_t initial class AccumulatedOneShotDelayedTask : public OneShotDelayedTask { // supports accumulating functors public: - AccumulatedOneShotDelayedTask(AccumulatingFunctionObject *functor, bigtime_t delay, + AccumulatedOneShotDelayedTask(AccumulatingFunctionObject* functor, bigtime_t delay, bigtime_t maxAccumulatingTime = 0, int32 maxAccumulateCount = 0) : OneShotDelayedTask(functor, delay), maxAccumulateCount(maxAccumulateCount), @@ -300,7 +302,7 @@ public: initialTime(system_time()) {} - bool CanAccumulate(const AccumulatingFunctionObject *accumulateThis) const + bool CanAccumulate(const AccumulatingFunctionObject* accumulateThis) const { if (maxAccumulateCount && accumulateCount > maxAccumulateCount) // don't accumulate if too may accumulated already @@ -310,15 +312,15 @@ public: // don't accumulate if too late past initial task return false; - return static_cast(fFunctor)->CanAccumulate(accumulateThis); + return static_cast(fFunctor)->CanAccumulate(accumulateThis); } - virtual void Accumulate(AccumulatingFunctionObject *accumulateThis, bigtime_t delay) + virtual void Accumulate(AccumulatingFunctionObject* accumulateThis, bigtime_t delay) { fRunAfter = system_time() + delay; // reset fRunAfter accumulateCount++; - static_cast(fFunctor)->Accumulate(accumulateThis); + static_cast(fFunctor)->Accumulate(accumulateThis); } private: @@ -329,7 +331,7 @@ private: }; void -TaskLoop::AccumulatedRunLater(AccumulatingFunctionObject *functor, bigtime_t delay, +TaskLoop::AccumulatedRunLater(AccumulatingFunctionObject* functor, bigtime_t delay, bigtime_t maxAccumulatingTime, int32 maxAccumulateCount) { AutoLock autoLock(&fLock); @@ -338,8 +340,9 @@ TaskLoop::AccumulatedRunLater(AccumulatingFunctionObject *functor, bigtime_t del } int32 count = fTaskList.CountItems(); for (int32 index = 0; index < count; index++) { - AccumulatedOneShotDelayedTask *task = dynamic_cast - (fTaskList.ItemAt(index)); + AccumulatedOneShotDelayedTask* task + = dynamic_cast( + fTaskList.ItemAt(index)); if (!task) continue; @@ -362,7 +365,7 @@ TaskLoop::Pulse() if (count > 0) { bigtime_t currentTime = system_time(); for (int32 index = 0; index < count; ) { - DelayedTask *task = fTaskList.ItemAt(index); + DelayedTask* task = fTaskList.ItemAt(index); // give every task a try if (task->RunIfNeeded(currentTime)) { // if done, remove from list @@ -384,7 +387,7 @@ TaskLoop::LatestRunTime() const bigtime_t result = kInfinity; #if xDEBUG - DelayedTask *nextTask = 0; + DelayedTask* nextTask = 0; #endif int32 count = fTaskList.CountItems(); for (int32 index = 0; index < count; index++) { @@ -411,7 +414,7 @@ TaskLoop::LatestRunTime() const void -TaskLoop::RemoveTask(DelayedTask *task) +TaskLoop::RemoveTask(DelayedTask* task) { ASSERT(fLock.IsLocked()); // remove the task @@ -419,7 +422,7 @@ TaskLoop::RemoveTask(DelayedTask *task) } void -TaskLoop::AddTask(DelayedTask *task) +TaskLoop::AddTask(DelayedTask* task) { AutoLock autoLock(&fLock); if (!autoLock.IsLocked()) { @@ -489,9 +492,9 @@ StandAloneTaskLoop::KeepPulsingWhenEmpty() const } status_t -StandAloneTaskLoop::RunBinder(void *castToThis) +StandAloneTaskLoop::RunBinder(void* castToThis) { - StandAloneTaskLoop *self = (StandAloneTaskLoop *)castToThis; + StandAloneTaskLoop* self = (StandAloneTaskLoop*)castToThis; self->Run(); return B_OK; } @@ -535,7 +538,7 @@ StandAloneTaskLoop::Run() } void -StandAloneTaskLoop::AddTask(DelayedTask *delayedTask) +StandAloneTaskLoop::AddTask(DelayedTask* delayedTask) { _inherited::AddTask(delayedTask); if (fScanThread < 0) @@ -589,4 +592,3 @@ PiggybackTaskLoop::StartPulsingIfNeeded() { fPulseMe = true; } - diff --git a/src/kits/tracker/TaskLoop.h b/src/kits/tracker/TaskLoop.h index e0b65ecbef..30b8d99bfd 100644 --- a/src/kits/tracker/TaskLoop.h +++ b/src/kits/tracker/TaskLoop.h @@ -31,23 +31,23 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - -// -// Delayed Tasks, Periodic Delayed Tasks, Periodic Delayed Tasks with timeout, -// Run when idle tasks, accumulating delayed tasks -// - - #ifndef __TASK_LOOP__ #define __TASK_LOOP__ + +// Delayed Tasks, Periodic Delayed Tasks, Periodic Delayed Tasks with timeout, +// Run when idle tasks, accumulating delayed tasks + + #include #include "FunctionObject.h" #include "ObjectList.h" + namespace BPrivate { + // Task flavors class DelayedTask { @@ -57,29 +57,31 @@ public: virtual bool RunIfNeeded(bigtime_t currentTime) = 0; // returns true if done and should not be called again - + bigtime_t RunAfterTime() const; protected: bigtime_t fRunAfter; }; -class OneShotDelayedTask : public DelayedTask { + // called once after a specified delay +class OneShotDelayedTask : public DelayedTask { public: - OneShotDelayedTask(FunctionObject *functor, bigtime_t delay); + OneShotDelayedTask(FunctionObject* functor, bigtime_t delay); virtual ~OneShotDelayedTask(); virtual bool RunIfNeeded(bigtime_t currentTime); protected: - FunctionObject *fFunctor; + FunctionObject* fFunctor; }; -class PeriodicDelayedTask : public DelayedTask { + // called periodically till functor return true +class PeriodicDelayedTask : public DelayedTask { public: - PeriodicDelayedTask(FunctionObjectWithResult *functor, + PeriodicDelayedTask(FunctionObjectWithResult* functor, bigtime_t initialDelay, bigtime_t period); virtual ~PeriodicDelayedTask(); @@ -87,13 +89,14 @@ public: protected: bigtime_t fPeriod; - FunctionObjectWithResult *fFunctor; + FunctionObjectWithResult* fFunctor; }; -class PeriodicDelayedTaskWithTimeout : public PeriodicDelayedTask { + // called periodically till functor returns true or till time out +class PeriodicDelayedTaskWithTimeout : public PeriodicDelayedTask { public: - PeriodicDelayedTaskWithTimeout(FunctionObjectWithResult *functor, + PeriodicDelayedTaskWithTimeout(FunctionObjectWithResult* functor, bigtime_t initialDelay, bigtime_t period, bigtime_t timeout); virtual bool RunIfNeeded(bigtime_t currentTime); @@ -102,11 +105,12 @@ protected: bigtime_t fTimeoutAfter; }; -class RunWhenIdleTask : public PeriodicDelayedTask { + // after initial delay starts periodically calling functor if system is idle // until functor returns true +class RunWhenIdleTask : public PeriodicDelayedTask { public: - RunWhenIdleTask(FunctionObjectWithResult *functor, bigtime_t initialDelay, + RunWhenIdleTask(FunctionObjectWithResult* functor, bigtime_t initialDelay, bigtime_t idleFor, bigtime_t heartBeat); virtual ~RunWhenIdleTask(); @@ -125,8 +129,8 @@ protected: kInitialIdleWait, kInIdleState }; - - State fState; + + State fState; bigtime_t fActivityLevelStart; bigtime_t fActivityLevel; bigtime_t fLastCPUTooBusyTime; @@ -135,15 +139,16 @@ private: typedef PeriodicDelayedTask _inherited; }; + +// This class is used for clumping up function objects that +// can be done as a single object. For instance the mime +// notification mechanism sends out multiple notifications on +// a single change and we need to accumulate the resulting +// icon update into a single one class AccumulatingFunctionObject : public FunctionObject { - // This class is used for clumping up function objects that - // can be done as a single object. For instance the mime - // notification mechanism sends out multiple notifications on - // a single change and we need to accumulate the resulting - // icon update into a single one public: - virtual bool CanAccumulate(const AccumulatingFunctionObject *) const = 0; - virtual void Accumulate(AccumulatingFunctionObject *) = 0; + virtual bool CanAccumulate(const AccumulatingFunctionObject*) const = 0; + virtual void Accumulate(AccumulatingFunctionObject*) = 0; }; @@ -155,37 +160,39 @@ public: TaskLoop(bigtime_t heartBeat = 10000); virtual ~TaskLoop(); - void RunLater(DelayedTask *); - void RunLater(FunctionObject *functor, bigtime_t delay); + void RunLater(DelayedTask*); + void RunLater(FunctionObject* functor, bigtime_t delay); // execute a function object after a delay - - void RunLater(FunctionObjectWithResult *functor, bigtime_t delay, - bigtime_t period); - // periodically execute function object after initial delay until function - // object returns true - - void RunLater(FunctionObjectWithResult *functor, bigtime_t delay, - bigtime_t period, bigtime_t timeout); - // periodically execute function object after initial delay until function - // object returns true or timeout is reached - void AccumulatedRunLater(AccumulatingFunctionObject *functor, bigtime_t delay, - bigtime_t maxAccumulatingTime = 0, int32 maxAccumulateCount = 0); + void RunLater(FunctionObjectWithResult* functor, bigtime_t delay, + bigtime_t period); + // periodically execute function object after initial delay until + // function object returns true + + void RunLater(FunctionObjectWithResult* functor, bigtime_t delay, + bigtime_t period, bigtime_t timeout); + // periodically execute function object after initial delay until + // function object returns true or timeout is reached + + void AccumulatedRunLater(AccumulatingFunctionObject* functor, + bigtime_t delay, bigtime_t maxAccumulatingTime = 0, + int32 maxAccumulateCount = 0); // will search the delayed task loop for other accumulating functors // and will accumulate with them, else will create a new delayed task - // the task will no longer accumulate if past the delay - // unless is zero + // the task will no longer accumulate if past the + // delay unless is zero // no more than will get accumulated, unless // is zero - - void RunWhenIdle(FunctionObjectWithResult *functor, bigtime_t initialDelay, - bigtime_t idleTime, bigtime_t heartBeat = 1000000); + + void RunWhenIdle(FunctionObjectWithResult* functor, + bigtime_t initialDelay, bigtime_t idleTime, + bigtime_t heartBeat = 1000000); // after initialDelay starts looking for a slot when the system is // idle for at least idleTime protected: - void AddTask(DelayedTask *); - void RemoveTask(DelayedTask *); + void AddTask(DelayedTask*); + void RemoveTask(DelayedTask*); bool Pulse(); // return true if quitting @@ -199,6 +206,7 @@ protected: bigtime_t fHeartBeat; }; + class StandAloneTaskLoop : public TaskLoop { // this task loop can work on it's own, just instantiate it // and use it; It has to start it's own thread @@ -207,10 +215,10 @@ public: ~StandAloneTaskLoop(); protected: - void AddTask(DelayedTask *); + void AddTask(DelayedTask*); private: - static status_t RunBinder(void *); + static status_t RunBinder(void*); void Run(); virtual bool KeepPulsingWhenEmpty() const; @@ -223,6 +231,7 @@ private: typedef TaskLoop _inherited; }; + class PiggybackTaskLoop : public TaskLoop { // this TaskLoop needs periodic calls from a viewable's Pulse // or some similar pulsing mechanism @@ -241,14 +250,15 @@ private: }; -inline bigtime_t +inline bigtime_t DelayedTask::RunAfterTime() const { return fRunAfter; } + } // namespace BPrivate using namespace BPrivate; -#endif +#endif // __TASK_LOOP__ diff --git a/src/kits/tracker/TemplatesMenu.cpp b/src/kits/tracker/TemplatesMenu.cpp index 9315029b74..fb251abd31 100644 --- a/src/kits/tracker/TemplatesMenu.cpp +++ b/src/kits/tracker/TemplatesMenu.cpp @@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include #include #include @@ -59,22 +60,23 @@ All rights reserved. namespace BPrivate { -const char *kTemplatesDirectory = "Tracker/Tracker New Templates"; +const char* kTemplatesDirectory = "Tracker/Tracker New Templates"; +} // namespace BPrivate -} - -TemplatesMenu::TemplatesMenu(const BMessenger &target, const char *label) +TemplatesMenu::TemplatesMenu(const BMessenger &target, const char* label) : BMenu(label), fTarget(target), fOpenItem(NULL) { } + TemplatesMenu::~TemplatesMenu() { } + void TemplatesMenu::AttachedToWindow() { @@ -83,30 +85,36 @@ TemplatesMenu::AttachedToWindow() SetTargetForItems(fTarget); } + status_t -TemplatesMenu::SetTargetForItems(BHandler *target) +TemplatesMenu::SetTargetForItems(BHandler* target) { status_t result = BMenu::SetTargetForItems(target); if (fOpenItem) fOpenItem->SetTarget(be_app_messenger); + return result; } + status_t TemplatesMenu::SetTargetForItems(BMessenger messenger) { status_t result = BMenu::SetTargetForItems(messenger); if (fOpenItem) fOpenItem->SetTarget(be_app_messenger); + return result; } + void TemplatesMenu::UpdateMenuState() { BuildMenu(false); } + bool TemplatesMenu::BuildMenu(bool addItems) { @@ -127,9 +135,9 @@ TemplatesMenu::BuildMenu(bool addItems) find_directory (B_USER_SETTINGS_DIRECTORY, &path, true); path.Append(kTemplatesDirectory); mkdir(path.Path(), 0777); - + count = 0; - + BEntry entry; BDirectory templatesDir(path.Path()); while (templatesDir.GetNextEntry(&entry) == B_OK) { @@ -140,48 +148,46 @@ TemplatesMenu::BuildMenu(bool addItems) if (nodeInfo.InitCheck() == B_OK) { char mimeType[B_MIME_TYPE_LENGTH]; nodeInfo.GetType(mimeType); - + BMimeType mime(mimeType); if (mime.IsValid()) { - if (count == 0) AddSeparatorItem(); - + count++; - + // If not adding items, we are just seeing if there // are any to list. So if we find one, immediately // bail and return the result. if (!addItems) break; - + entry_ref ref; entry.GetRef(&ref); - BMessage *message = new BMessage(kNewEntryFromTemplate); + BMessage* message = new BMessage(kNewEntryFromTemplate); message->AddRef("refs_template", &ref); message->AddString("name", fileName); AddItem(new IconMenuItem(fileName, message, &nodeInfo, B_MINI_ICON)); } - } } - + AddSeparatorItem(); - + // This is the message sent to open the templates folder. - BMessage *message = new BMessage(B_REFS_RECEIVED); + BMessage* message = new BMessage(B_REFS_RECEIVED); entry_ref dirRef; if (templatesDir.GetEntry(&entry) == B_OK) entry.GetRef(&dirRef); message->AddRef("refs", &dirRef); - + // Add item to show templates folder. fOpenItem = new BMenuItem(B_TRANSLATE("Edit templates" B_UTF8_ELLIPSIS), message); AddItem(fOpenItem); if (dirRef == entry_ref()) fOpenItem->SetEnabled(false); - + return count > 0; } diff --git a/src/kits/tracker/TemplatesMenu.h b/src/kits/tracker/TemplatesMenu.h index edf1c44dab..5f453ccb93 100644 --- a/src/kits/tracker/TemplatesMenu.h +++ b/src/kits/tracker/TemplatesMenu.h @@ -31,13 +31,13 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef __TEMPLATES_MENU__ #define __TEMPLATES_MENU__ #include + namespace BPrivate { extern const char* kTemplatesDirectory; @@ -45,27 +45,25 @@ extern const char* kTemplatesMenuName; class TemplatesMenu : public BMenu { public: - TemplatesMenu(const BMessenger &target, - const char *label); - virtual ~TemplatesMenu(); - + TemplatesMenu(const BMessenger& target, const char* label); + virtual ~TemplatesMenu(); virtual void AttachedToWindow(); - virtual status_t SetTargetForItems(BHandler *); + virtual status_t SetTargetForItems(BHandler*); virtual status_t SetTargetForItems(BMessenger); void UpdateMenuState(); private: bool BuildMenu(bool addItems = true); - + BMessenger fTarget; - BMenuItem *fOpenItem; + BMenuItem* fOpenItem; }; } // namespace BPrivate using namespace BPrivate; -#endif +#endif // __TEMPLATES_MENU__ diff --git a/src/kits/tracker/Tests.cpp b/src/kits/tracker/Tests.cpp index f45887d991..2591229286 100644 --- a/src/kits/tracker/Tests.cpp +++ b/src/kits/tracker/Tests.cpp @@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #if DEBUG #include "Tests.h" @@ -51,9 +52,7 @@ All rights reserved. #include "Thread.h" - - -const char *pathsToSearch[] = { +const char* pathsToSearch[] = { // "/boot/home/config/settings/NetPositive/Bookmarks/", #ifdef __HAIKU__ "/boot/system", @@ -65,13 +64,14 @@ const char *pathsToSearch[] = { 0 }; + namespace BTrackerPrivate { class IconSpewer : public SimpleThread { public: IconSpewer(bool newCache = true); ~IconSpewer(); - void SetTarget(BWindow *target) + void SetTarget(BWindow* target) { this->target = target; } void Quit(); @@ -80,13 +80,13 @@ public: protected: void DrawSomeNew(); void DrawSomeOld(); - const entry_ref *NextRef(); + const entry_ref* NextRef(); private: BLocker locker; bool quitting; - BWindow *target; - TNodeWalker *walker; - CachedEntryIterator *cachingIterator; + BWindow* target; + TNodeWalker* walker; + CachedEntryIterator* cachingIterator; int32 searchPathIndex; bigtime_t cycleTime; bigtime_t lastCycleLap; @@ -98,6 +98,7 @@ private: entry_ref ref; }; + class IconTestWindow : public BWindow { public: IconTestWindow(); @@ -120,7 +121,7 @@ IconSpewer::IconSpewer(bool newCache) newCache(newCache) { walker = new TNodeWalker(pathsToSearch[searchPathIndex++]); - if (newCache) + if (newCache) cachingIterator = new CachedEntryIterator(walker, 40); } @@ -131,16 +132,17 @@ IconSpewer::~IconSpewer() delete cachingIterator; } -void + +void IconSpewer::Run() { BStopWatch watch("", true); for (;;) { AutoLock lock(locker); - + if (!lock || quitting) break; - + lock.Unlock(); if (newCache) DrawSomeNew(); @@ -149,22 +151,25 @@ IconSpewer::Run() } } -void + +void IconSpewer::Quit() { kill_thread(fScanThread); fScanThread = -1; } + const icon_size kIconSize = B_LARGE_ICON; const int32 kRowCount = 10; const int32 kColumnCount = 10; -void + +void IconSpewer::DrawSomeNew() { target->Lock(); - BView *view = target->FindView("iconView"); + BView* view = target->FindView("iconView"); ASSERT(view); BRect bounds(target->Bounds()); @@ -177,15 +182,17 @@ IconSpewer::DrawSomeNew() sprintf(buffer, "last cycle time %Ld ms", cycleTime/1000); view->DrawString(buffer, BPoint(20, bounds.bottom - 20)); } + if (numDrawn) { sprintf(buffer, "average draw time %Ld us per icon", watch.ElapsedTime() / numDrawn); view->DrawString(buffer, BPoint(20, bounds.bottom - 30)); } + sprintf(buffer, "directory: %s", currentPath.Path()); view->DrawString(buffer, BPoint(20, bounds.bottom - 40)); target->Unlock(); - + for (int32 row = 0; row < kRowCount; row++) { for (int32 column = 0; column < kColumnCount; column++) { BEntry entry(NextRef()); @@ -194,7 +201,7 @@ IconSpewer::DrawSomeNew() if (!target->Lock()) return; - if (model.IsDirectory()) + if (model.IsDirectory()) entry.GetPath(¤tPath); IconCache::sIconCache->Draw(&model, view, BPoint(column * (kIconSize + 2), @@ -205,8 +212,11 @@ IconSpewer::DrawSomeNew() } } + bool oldIconCacheInited = false; -void + + +void IconSpewer::DrawSomeOld() { #if 0 @@ -215,7 +225,7 @@ IconSpewer::DrawSomeOld() target->Lock(); target->SetTitle("old cache"); - BView *view = target->FindView("iconView"); + BView* view = target->FindView("iconView"); ASSERT(view); BRect bounds(target->Bounds()); @@ -236,20 +246,20 @@ IconSpewer::DrawSomeOld() view->DrawString(buffer, BPoint(20, bounds.bottom - 40)); target->Unlock(); - + for (int32 row = 0; row < kRowCount; row++) { for (int32 column = 0; column < kColumnCount; column++) { BEntry entry(NextRef()); BModel model(&entry, true); - + if (!target->Lock()) return; - if (model.IsDirectory()) + if (model.IsDirectory()) entry.GetPath(¤tPath); BIconCache::LockIconCache(); - BIconCache *iconCache = BIconCache::GetIconCache(&model, kIconSize); + BIconCache* iconCache = BIconCache::GetIconCache(&model, kIconSize); iconCache->Draw(view, BPoint(column * (kIconSize + 2), row * (kIconSize + 2)), B_NORMAL_ICON, kIconSize, true); BIconCache::UnlockIconCache(); @@ -261,7 +271,8 @@ IconSpewer::DrawSomeOld() #endif } -const entry_ref * + +const entry_ref* IconSpewer::NextRef() { status_t result; @@ -295,6 +306,8 @@ IconSpewer::NextRef() } +// #pragma mark - + IconTestWindow::IconTestWindow() : BWindow(BRect(100, 100, 500, 600), "icon cache test", B_TITLED_WINDOW_LOOK, @@ -302,18 +315,20 @@ IconTestWindow::IconTestWindow() iconSpewer(modifiers() == 0) { iconSpewer.SetTarget(this); - BView *view = new BView(Bounds(), "iconView", B_FOLLOW_ALL, B_WILL_DRAW); + BView* view = new BView(Bounds(), "iconView", B_FOLLOW_ALL, B_WILL_DRAW); AddChild(view); iconSpewer.Go(); } -bool + +bool IconTestWindow::QuitRequested() { iconSpewer.Quit(); return true; } + void RunIconCacheTests() { diff --git a/src/kits/tracker/TextWidget.cpp b/src/kits/tracker/TextWidget.cpp index da368cfbcc..c788972ac5 100644 --- a/src/kits/tracker/TextWidget.cpp +++ b/src/kits/tracker/TextWidget.cpp @@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include #include @@ -61,7 +62,7 @@ All rights reserved. const float kWidthMargin = 20; -BTextWidget::BTextWidget(Model *model, BColumn *column, BPoseView *view) +BTextWidget::BTextWidget(Model* model, BColumn* column, BPoseView* view) : fText(WidgetAttributeText::NewWidgetText(model, column, view)), fAttrHash(column->AttrHash()), @@ -81,16 +82,16 @@ BTextWidget::~BTextWidget() int -BTextWidget::Compare(const BTextWidget &with, BPoseView *view) const +BTextWidget::Compare(const BTextWidget& with, BPoseView* view) const { return fText->Compare(*with.fText, view); } -const char * -BTextWidget::Text(const BPoseView *view) const +const char* +BTextWidget::Text(const BPoseView* view) const { - StringAttributeText *textAttribute = dynamic_cast(fText); + StringAttributeText* textAttribute = dynamic_cast(fText); if (textAttribute == NULL) return NULL; @@ -99,22 +100,22 @@ BTextWidget::Text(const BPoseView *view) const float -BTextWidget::TextWidth(const BPoseView *pose) const +BTextWidget::TextWidth(const BPoseView* pose) const { return fText->Width(pose); } float -BTextWidget::PreferredWidth(const BPoseView *pose) const +BTextWidget::PreferredWidth(const BPoseView* pose) const { return fText->PreferredWidth(pose) + 1; } BRect -BTextWidget::ColumnRect(BPoint poseLoc, const BColumn *column, - const BPoseView *view) +BTextWidget::ColumnRect(BPoint poseLoc, const BColumn* column, + const BPoseView* view) { if (view->ViewMode() != kListMode) { // ColumnRect only makes sense in list view, return @@ -131,8 +132,8 @@ BTextWidget::ColumnRect(BPoint poseLoc, const BColumn *column, BRect -BTextWidget::CalcRectCommon(BPoint poseLoc, const BColumn *column, - const BPoseView *view, float textWidth) +BTextWidget::CalcRectCommon(BPoint poseLoc, const BColumn* column, + const BPoseView* view, float textWidth) { BRect result; if (view->ViewMode() == kListMode) { @@ -182,23 +183,23 @@ BTextWidget::CalcRectCommon(BPoint poseLoc, const BColumn *column, BRect -BTextWidget::CalcRect(BPoint poseLoc, const BColumn *column, - const BPoseView *view) +BTextWidget::CalcRect(BPoint poseLoc, const BColumn* column, + const BPoseView* view) { return CalcRectCommon(poseLoc, column, view, fText->Width(view)); } BRect -BTextWidget::CalcOldRect(BPoint poseLoc, const BColumn *column, - const BPoseView *view) +BTextWidget::CalcOldRect(BPoint poseLoc, const BColumn* column, + const BPoseView* view) { return CalcRectCommon(poseLoc, column, view, fText->CurrentWidth()); } BRect -BTextWidget::CalcClickRect(BPoint poseLoc, const BColumn *column, +BTextWidget::CalcClickRect(BPoint poseLoc, const BColumn* column, const BPoseView* view) { BRect result = CalcRect(poseLoc, column, view); @@ -215,7 +216,7 @@ BTextWidget::CalcClickRect(BPoint poseLoc, const BColumn *column, void -BTextWidget::MouseUp(BRect bounds, BPoseView *view, BPose *pose, BPoint) +BTextWidget::MouseUp(BRect bounds, BPoseView* view, BPose* pose, BPoint) { // Start editing without delay if the pose was selected recently and this // click is not the second click of a doubleclick. @@ -270,13 +271,13 @@ BTextWidget::MouseUp(BRect bounds, BPoseView *view, BPose *pose, BPoint) static filter_result -TextViewFilter(BMessage *message, BHandler **, BMessageFilter *filter) +TextViewFilter(BMessage* message, BHandler**, BMessageFilter* filter) { uchar key; - if (message->FindInt8("byte", (int8 *)&key) != B_OK) + if (message->FindInt8("byte", (int8*)&key) != B_OK) return B_DISPATCH_MESSAGE; - BPoseView *poseView = dynamic_cast(filter->Looper())-> + BPoseView* poseView = dynamic_cast(filter->Looper())-> PoseView(); if (key == B_RETURN || key == B_ESCAPE) { @@ -299,9 +300,9 @@ TextViewFilter(BMessage *message, BHandler **, BMessageFilter *filter) // we try to work-around this "bug" here. // find the text editing view - BView *scrollView = poseView->FindView("BorderView"); + BView* scrollView = poseView->FindView("BorderView"); if (scrollView != NULL) { - BTextView *textView = dynamic_cast(scrollView->FindView("WidgetTextView")); + BTextView* textView = dynamic_cast(scrollView->FindView("WidgetTextView")); if (textView != NULL) { BRect rect = scrollView->Frame(); @@ -316,7 +317,7 @@ TextViewFilter(BMessage *message, BHandler **, BMessageFilter *filter) void -BTextWidget::StartEdit(BRect bounds, BPoseView *view, BPose *pose) +BTextWidget::StartEdit(BRect bounds, BPoseView* view, BPose* pose) { if (!IsEditable()) return; @@ -342,7 +343,7 @@ BTextWidget::StartEdit(BRect bounds, BPoseView *view, BPose *pose) BFont font; view->GetFont(&font); - BTextView *textView = new BTextView(rect, "WidgetTextView", textRect, &font, 0, + BTextView* textView = new BTextView(rect, "WidgetTextView", textRect, &font, 0, B_FOLLOW_ALL, B_WILL_DRAW); textView->SetWordWrap(false); @@ -374,7 +375,7 @@ BTextWidget::StartEdit(BRect bounds, BPoseView *view, BPose *pose) textView->MoveTo(rect.LeftTop()); textView->ResizeTo(rect.Width(), rect.Height()); - BScrollView *scrollView = new BScrollView("BorderView", textView, 0, 0, false, + BScrollView* scrollView = new BScrollView("BorderView", textView, 0, 0, false, false, B_PLAIN_BORDER); view->AddChild(scrollView); @@ -412,21 +413,21 @@ BTextWidget::StartEdit(BRect bounds, BPoseView *view, BPose *pose) void -BTextWidget::StopEdit(bool saveChanges, BPoint poseLoc, BPoseView *view, - BPose *pose, int32 poseIndex) +BTextWidget::StopEdit(bool saveChanges, BPoint poseLoc, BPoseView* view, + BPose* pose, int32 poseIndex) { // find the text editing view - BView *scrollView = view->FindView("BorderView"); + BView* scrollView = view->FindView("BorderView"); ASSERT(scrollView); if (!scrollView) return; - BTextView *textView = dynamic_cast(scrollView->FindView("WidgetTextView")); + BTextView* textView = dynamic_cast(scrollView->FindView("WidgetTextView")); ASSERT(textView); if (!textView) return; - BColumn *column = view->ColumnFor(fAttrHash); + BColumn* column = view->ColumnFor(fAttrHash); ASSERT(column); if (!column) return; @@ -453,7 +454,7 @@ BTextWidget::StopEdit(bool saveChanges, BPoint poseLoc, BPoseView *view, void -BTextWidget::CheckAndUpdate(BPoint loc, const BColumn *column, BPoseView *view, +BTextWidget::CheckAndUpdate(BPoint loc, const BColumn* column, BPoseView* view, bool visible) { BRect oldRect; @@ -471,17 +472,17 @@ BTextWidget::CheckAndUpdate(BPoint loc, const BColumn *column, BPoseView *view, void -BTextWidget::SelectAll(BPoseView *view) +BTextWidget::SelectAll(BPoseView* view) { - BTextView *text = dynamic_cast(view->FindView("WidgetTextView")); + BTextView* text = dynamic_cast(view->FindView("WidgetTextView")); if (text) text->SelectAll(); } void -BTextWidget::Draw(BRect eraseRect, BRect textRect, float, BPoseView *view, - BView *drawView, bool selected, uint32 clipboardMode, BPoint offset, bool direct) +BTextWidget::Draw(BRect eraseRect, BRect textRect, float, BPoseView* view, + BView* drawView, bool selected, uint32 clipboardMode, BPoint offset, bool direct) { textRect.OffsetBy(offset); diff --git a/src/kits/tracker/TextWidget.h b/src/kits/tracker/TextWidget.h index 24fc2f8239..9fdc10a052 100644 --- a/src/kits/tracker/TextWidget.h +++ b/src/kits/tracker/TextWidget.h @@ -32,7 +32,7 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ -#ifndef _TEXT_WIDGET_H +#ifndef _TEXT_WIDGET_H #define _TEXT_WIDGET_H #include "Model.h" @@ -46,36 +46,36 @@ class BColumn; class BTextWidget { public: - BTextWidget(Model *, BColumn *, BPoseView *); + BTextWidget(Model*, BColumn*, BPoseView*); virtual ~BTextWidget(); - void Draw(BRect widgetRect, BRect widgetTextRect, float width, BPoseView *, + void Draw(BRect widgetRect, BRect widgetTextRect, float width, BPoseView*, bool selected, uint32 clipboardMode); - void Draw(BRect widgetRect, BRect widgetTextRect, float width, BPoseView *, - BView *drawView, bool selected, uint32 clipboardMode, BPoint offset, bool direct); + void Draw(BRect widgetRect, BRect widgetTextRect, float width, BPoseView*, + BView* drawView, bool selected, uint32 clipboardMode, BPoint offset, bool direct); // second call is used for offscreen drawing, where PoseView // and current drawing view are different - void MouseUp(BRect bounds, BPoseView *, BPose *, BPoint mouseLoc); + void MouseUp(BRect bounds, BPoseView*, BPose*, BPoint mouseLoc); - BRect CalcRect(BPoint poseLoc, const BColumn *, const BPoseView *); + BRect CalcRect(BPoint poseLoc, const BColumn*, const BPoseView*); // returns the rect derived from the formatted string width // may force WidgetAttributeText recalculation - BRect CalcClickRect(BPoint poseLoc, const BColumn *, const BPoseView *); + BRect CalcClickRect(BPoint poseLoc, const BColumn*, const BPoseView*); // calls CalcRect, if result too narow, returns a wider rect for // easy clicking - BRect ColumnRect(BPoint poseLoc, const BColumn *, const BPoseView *); + BRect ColumnRect(BPoint poseLoc, const BColumn*, const BPoseView*); // returns the rect of the widget in a column, regardless // of the string width; faster than CalcRect - BRect CalcOldRect(BPoint poseLoc, const BColumn *, const BPoseView *); + BRect CalcOldRect(BPoint poseLoc, const BColumn*, const BPoseView*); // after an update call this to determine the old rect so that // we can invalidate properly - void StartEdit(BRect bounds, BPoseView *, BPose *); - void StopEdit(bool saveChanges, BPoint loc, BPoseView *, BPose *, int32 index); + void StartEdit(BRect bounds, BPoseView*, BPose*); + void StopEdit(bool saveChanges, BPoint loc, BPoseView*, BPose*, int32 index); - void SelectAll(BPoseView *view); - void CheckAndUpdate(BPoint, const BColumn *, BPoseView *, bool visible); + void SelectAll(BPoseView* view); + void CheckAndUpdate(BPoint, const BColumn*, BPoseView*, bool visible); uint32 AttrHash() const; bool IsEditable() const; @@ -84,19 +84,21 @@ public: void SetVisible(bool); bool IsActive() const; void SetActive(bool); - - const char *Text(const BPoseView *view) const; + + const char* Text(const BPoseView* view) const; // returns the untruncated version of the text - float TextWidth(const BPoseView *) const; - float PreferredWidth(const BPoseView *) const; - int Compare(const BTextWidget &, BPoseView *) const; + float TextWidth(const BPoseView*) const; + float PreferredWidth(const BPoseView*) const; + int Compare(const BTextWidget&, BPoseView*) const; // used for sorting in PoseViews private: - BRect CalcRectCommon(BPoint poseLoc, const BColumn *, const BPoseView *, float width); + BRect CalcRectCommon(BPoint poseLoc, const BColumn*, const BPoseView*, + float width); - WidgetAttributeText *fText; - uint32 fAttrHash; // ToDo: get rid of this + WidgetAttributeText* fText; + uint32 fAttrHash; + // TODO: get rid of this alignment fAlignment; bool fEditable : 1; @@ -105,42 +107,49 @@ private: bool fSymLink : 1; }; + inline uint32 BTextWidget::AttrHash() const { return fAttrHash; } + inline void BTextWidget::SetEditable(bool on) { fEditable = on; } + inline bool BTextWidget::IsEditable() const { return fEditable && fText->IsEditable(); } + inline bool BTextWidget::IsVisible() const { return fVisible; } + inline void BTextWidget::SetVisible(bool on) { fVisible = on; } + inline bool BTextWidget::IsActive() const { return fActive; } + inline void BTextWidget::SetActive(bool on) { @@ -150,9 +159,9 @@ BTextWidget::SetActive(bool on) inline void BTextWidget::Draw(BRect widgetRect, BRect widgetTextRect, float width, - BPoseView *view, bool selected, uint32 clipboardMode) + BPoseView* view, bool selected, uint32 clipboardMode) { - Draw(widgetRect, widgetTextRect, width, view, (BView *)view, selected, + Draw(widgetRect, widgetTextRect, width, view, (BView*)view, selected, clipboardMode, BPoint(0, 0), true); } @@ -160,4 +169,4 @@ BTextWidget::Draw(BRect widgetRect, BRect widgetTextRect, float width, using namespace BPrivate; -#endif +#endif // _TEXT_WIDGET_H diff --git a/src/kits/tracker/Thread.cpp b/src/kits/tracker/Thread.cpp index c5caee4e2b..79e64d5e66 100644 --- a/src/kits/tracker/Thread.cpp +++ b/src/kits/tracker/Thread.cpp @@ -32,10 +32,12 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include "Thread.h" #include "FunctionObject.h" -SimpleThread::SimpleThread(int32 priority, const char *name) + +SimpleThread::SimpleThread(int32 priority, const char* name) : fScanThread(-1), fPriority(priority), fName(name) @@ -45,48 +47,53 @@ SimpleThread::SimpleThread(int32 priority, const char *name) SimpleThread::~SimpleThread() { - if (fScanThread > 0 && fScanThread != find_thread(NULL)) + if (fScanThread > 0 && fScanThread != find_thread(NULL)) { // kill the thread if it is not the one we are running in kill_thread(fScanThread); + } } -void + +void SimpleThread::Go() { - fScanThread = spawn_thread(SimpleThread::RunBinder, fName ? fName : "TrackerTaskLoop", - fPriority, this); + fScanThread = spawn_thread(SimpleThread::RunBinder, + fName ? fName : "TrackerTaskLoop", fPriority, this); resume_thread(fScanThread); } -status_t -SimpleThread::RunBinder(void *castToThis) + +status_t +SimpleThread::RunBinder(void* castToThis) { - SimpleThread *self = static_cast(castToThis); + SimpleThread* self = static_cast(castToThis); self->Run(); return B_OK; } -void -Thread::Launch(FunctionObject *functor, int32 priority, const char *name) + +void +Thread::Launch(FunctionObject* functor, int32 priority, const char* name) { new Thread(functor, priority, name); } -Thread::Thread(FunctionObject *functor, int32 priority, const char *name) +Thread::Thread(FunctionObject* functor, int32 priority, const char* name) : SimpleThread(priority, name), fFunctor(functor) { Go(); } + Thread::~Thread() { delete fFunctor; } -void +void Thread::Run() { (*fFunctor)(); @@ -94,18 +101,19 @@ Thread::Run() // commit suicide } -void -ThreadSequence::Launch(BObjectList *list, bool async, int32 priority) + +void +ThreadSequence::Launch(BObjectList* list, bool async, int32 priority) { - if (!async) + if (!async) { // if not async, don't even create a thread, just do it right away Run(list); - else + } else new ThreadSequence(list, priority); } -ThreadSequence::ThreadSequence(BObjectList *list, int32 priority) +ThreadSequence::ThreadSequence(BObjectList* list, int32 priority) : SimpleThread(priority), fFunctorList(list) { @@ -118,15 +126,17 @@ ThreadSequence::~ThreadSequence() delete fFunctorList; } -void -ThreadSequence::Run(BObjectList *list) + +void +ThreadSequence::Run(BObjectList* list) { int32 count = list->CountItems(); for (int32 index = 0; index < count; index++) (*list->ItemAt(index))(); } -void + +void ThreadSequence::Run() { Run(fFunctorList); diff --git a/src/kits/tracker/Thread.h b/src/kits/tracker/Thread.h index b71c57c176..c35bcdce81 100644 --- a/src/kits/tracker/Thread.h +++ b/src/kits/tracker/Thread.h @@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef __THREAD__ #define __THREAD__ + #include #include @@ -42,54 +42,55 @@ All rights reserved. #include "FunctionObject.h" #include "Utilities.h" + namespace BPrivate { class SimpleThread { // this should only be used as a base class, // subclass needs to add proper locking mechanism public: - SimpleThread(int32 priority = B_LOW_PRIORITY, const char *name = 0); + SimpleThread(int32 priority = B_LOW_PRIORITY, const char* name = 0); virtual ~SimpleThread(); void Go(); private: - static status_t RunBinder(void *); + static status_t RunBinder(void*); virtual void Run() = 0; protected: thread_id fScanThread; int32 fPriority; - const char *fName; + const char* fName; }; class Thread : private SimpleThread { public: - static void Launch(FunctionObject *functor, - int32 priority = B_LOW_PRIORITY, const char *name = 0); + static void Launch(FunctionObject* functor, + int32 priority = B_LOW_PRIORITY, const char* name = 0); private: - Thread(FunctionObject *, int32 priority, const char *name); + Thread(FunctionObject*, int32 priority, const char* name); ~Thread(); virtual void Run(); - FunctionObject *fFunctor; + FunctionObject* fFunctor; }; class ThreadSequence : private SimpleThread { public: - static void Launch(BObjectList *, bool async = true, + static void Launch(BObjectList*, bool async = true, int32 priority = B_LOW_PRIORITY); private: - ThreadSequence(BObjectList *, int32 priority); + ThreadSequence(BObjectList*, int32 priority); ~ThreadSequence(); virtual void Run(); - static void Run(BObjectList *list); + static void Run(BObjectList*list); - BObjectList *fFunctorList; + BObjectList* fFunctorList; }; // would use SingleParamFunctionObjectWithResult, except mwcc won't handle this @@ -116,13 +117,12 @@ private: template class SimpleMemberFunctionObjectWorkaround : public FunctionObjectWithResult { public: - SimpleMemberFunctionObjectWorkaround(status_t (T::*function)(), T *onThis) + SimpleMemberFunctionObjectWorkaround(status_t (T::*function)(), T* onThis) : fFunction(function), fOnThis(onThis) { } - virtual void operator()() { (fOnThis->*fFunction)(); } @@ -133,6 +133,7 @@ private: T fOnThis; }; + template class TwoParamFunctionObjectWorkaround : public FunctionObjectWithResult { public: @@ -155,6 +156,7 @@ private: Param2 fParam2; }; + template class ThreeParamFunctionObjectWorkaround : public FunctionObjectWithResult { public: @@ -179,6 +181,7 @@ private: Param3 fParam3; }; + template class FourParamFunctionObjectWorkaround : public FunctionObjectWithResult { public: @@ -205,35 +208,42 @@ private: Param4 fParam4; }; + template void -LaunchInNewThread(const char *name, int32 priority, status_t (*func)(Param1), Param1 p1) +LaunchInNewThread(const char* name, int32 priority, status_t (*func)(Param1), + Param1 p1) { Thread::Launch(new SingleParamFunctionObjectWorkaround(func, p1), priority, name); } + template void -LaunchInNewThread(const char *name, int32 priority, status_t (T::*function)(), T *onThis) +LaunchInNewThread(const char* name, int32 priority, status_t (T::*function)(), + T* onThis) { - Thread::Launch(new SimpleMemberFunctionObjectWorkaround(function, onThis), - priority, name); + Thread::Launch(new SimpleMemberFunctionObjectWorkaround(function, + onThis), priority, name); } + template void -LaunchInNewThread(const char *name, int32 priority, +LaunchInNewThread(const char* name, int32 priority, status_t (*func)(Param1, Param2), Param1 p1, Param2 p2) { - Thread::Launch(new TwoParamFunctionObjectWorkaround(func, p1, p2), - priority, name); + Thread::Launch(new + TwoParamFunctionObjectWorkaround(func, p1, p2), + priority, name); } + template void -LaunchInNewThread(const char *name, int32 priority, +LaunchInNewThread(const char* name, int32 priority, status_t (*func)(Param1, Param2, Param3), Param1 p1, Param2 p2, Param3 p3) { @@ -241,9 +251,10 @@ LaunchInNewThread(const char *name, int32 priority, Param3>(func, p1, p2, p3), priority, name); } + template void -LaunchInNewThread(const char *name, int32 priority, +LaunchInNewThread(const char* name, int32 priority, status_t (*func)(Param1, Param2, Param3, Param4), Param1 p1, Param2 p2, Param3 p3, Param4 p4) { @@ -251,14 +262,15 @@ LaunchInNewThread(const char *name, int32 priority, Param3, Param4>(func, p1, p2, p3, p4), priority, name); } + template class MouseDownThread { public: - static void TrackMouse(View *view, void (View::*)(BPoint), + static void TrackMouse(View* view, void (View::*)(BPoint), void (View::*)(BPoint, uint32) = 0, bigtime_t pressingPeriod = 100000); protected: - MouseDownThread(View *view, void (View::*)(BPoint), + MouseDownThread(View* view, void (View::*)(BPoint), void (View::*)(BPoint, uint32), bigtime_t pressingPeriod); virtual ~MouseDownThread(); @@ -266,9 +278,9 @@ protected: void Go(); virtual void Track(); - static status_t TrackBinder(void *); -private: + static status_t TrackBinder(void*); +private: BMessenger fOwner; void (View::*fDonePressing)(BPoint); void (View::*fPressing)(BPoint, uint32); @@ -279,7 +291,7 @@ private: template void -MouseDownThread::TrackMouse(View *view, +MouseDownThread::TrackMouse(View* view, void(View::*donePressing)(BPoint), void(View::*pressing)(BPoint, uint32), bigtime_t pressingPeriod) { @@ -288,7 +300,7 @@ MouseDownThread::TrackMouse(View *view, template -MouseDownThread::MouseDownThread(View *view, +MouseDownThread::MouseDownThread(View* view, void (View::*donePressing)(BPoint), void (View::*pressing)(BPoint, uint32), bigtime_t pressingPeriod) : fOwner(view, view->Window()), @@ -314,25 +326,27 @@ template void MouseDownThread::Go() { - fThreadID = spawn_thread(&MouseDownThread::TrackBinder, "MouseTrackingThread", - B_NORMAL_PRIORITY, this); + fThreadID = spawn_thread(&MouseDownThread::TrackBinder, + "MouseTrackingThread", B_NORMAL_PRIORITY, this); if (fThreadID <= 0 || resume_thread(fThreadID) != B_OK) // didn't start, don't leak self delete this; } + template status_t -MouseDownThread::TrackBinder(void *castToThis) +MouseDownThread::TrackBinder(void* castToThis) { - MouseDownThread *self = static_cast(castToThis); + MouseDownThread* self = static_cast(castToThis); self->Track(); // dead at this point TRESPASS(); return B_OK; } + template void MouseDownThread::Track() @@ -342,8 +356,8 @@ MouseDownThread::Track() if (!lock) break; - BLooper *looper; - View *view = dynamic_cast(fOwner.Target(&looper)); + BLooper* looper; + View* view = dynamic_cast(fOwner.Target(&looper)); if (!view) break; @@ -369,4 +383,4 @@ MouseDownThread::Track() using namespace BPrivate; -#endif +#endif // __THREAD__ diff --git a/src/kits/tracker/TitleView.cpp b/src/kits/tracker/TitleView.cpp index 6b015d90c5..f22cd61aa4 100644 --- a/src/kits/tracker/TitleView.cpp +++ b/src/kits/tracker/TitleView.cpp @@ -32,7 +32,10 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + // ListView title drawing and mouse manipulation classes + + #include "TitleView.h" #include @@ -50,6 +53,7 @@ All rights reserved. #include "PoseView.h" #include "Utilities.h" + #define APP_SERVER_CLEARS_BACKGROUND 1 static rgb_color sTitleBackground; @@ -63,7 +67,7 @@ const rgb_color kHighlightColor = {100, 100, 210, 255}; static void -_DrawLine(BPoseView *view, BPoint from, BPoint to) +_DrawLine(BPoseView* view, BPoint from, BPoint to) { rgb_color highColor = view->HighColor(); view->SetHighColor(tint_color(view->LowColor(), B_DARKEN_1_TINT)); @@ -73,14 +77,14 @@ _DrawLine(BPoseView *view, BPoint from, BPoint to) static void -_UndrawLine(BPoseView *view, BPoint from, BPoint to) +_UndrawLine(BPoseView* view, BPoint from, BPoint to) { view->StrokeLine(from, to, B_SOLID_LOW); } static void -_DrawOutline(BView *view, BRect where) +_DrawOutline(BView* view, BRect where) { if (be_control_look != NULL) { where.right++; @@ -97,7 +101,7 @@ _DrawOutline(BView *view, BRect where) // #pragma mark - -BTitleView::BTitleView(BRect frame, BPoseView *view) +BTitleView::BTitleView(BRect frame, BPoseView* view) : BView(frame, "TitleView", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW), fPoseView(view), fTitleList(10, true), @@ -140,7 +144,7 @@ BTitleView::Reset() fTitleList.MakeEmpty(); for (int32 index = 0; ; index++) { - BColumn *column = fPoseView->ColumnAt(index); + BColumn* column = fPoseView->ColumnAt(index); if (!column) break; fTitleList.AddItem(new BColumnTitle(this, column)); @@ -150,13 +154,13 @@ BTitleView::Reset() void -BTitleView::AddTitle(BColumn *column, const BColumn *after) +BTitleView::AddTitle(BColumn* column, const BColumn* after) { int32 count = fTitleList.CountItems(); int32 index; if (after) { for (index = 0; index < count; index++) { - BColumn *titleColumn = fTitleList.ItemAt(index)->Column(); + BColumn* titleColumn = fTitleList.ItemAt(index)->Column(); if (after == titleColumn) { index++; @@ -172,11 +176,11 @@ BTitleView::AddTitle(BColumn *column, const BColumn *after) void -BTitleView::RemoveTitle(BColumn *column) +BTitleView::RemoveTitle(BColumn* column) { int32 count = fTitleList.CountItems(); for (int32 index = 0; index < count; index++) { - BColumnTitle *title = fTitleList.ItemAt(index); + BColumnTitle* title = fTitleList.ItemAt(index); if (title->Column() == column) { fTitleList.RemoveItem(title); break; @@ -194,13 +198,13 @@ BTitleView::Draw(BRect rect) } -void +void BTitleView::Draw(BRect /*updateRect*/, bool useOffscreen, bool updateOnly, - const BColumnTitle *pressedColumn, - void (*trackRectBlitter)(BView *, BRect), BRect passThru) + const BColumnTitle* pressedColumn, + void (*trackRectBlitter)(BView*, BRect), BRect passThru) { BRect bounds(Bounds()); - BView *view; + BView* view; if (useOffscreen) { ASSERT(sOffscreen); @@ -246,7 +250,7 @@ BTitleView::Draw(BRect /*updateRect*/, bool useOffscreen, bool updateOnly, float minx = bounds.right; float maxx = bounds.left; for (int32 index = 0; index < count; index++) { - BColumnTitle *title = fTitleList.ItemAt(index); + BColumnTitle* title = fTitleList.ItemAt(index); title->Draw(view, title == pressedColumn); BRect titleBounds(title->Bounds()); if (titleBounds.left < minx) @@ -280,6 +284,7 @@ BTitleView::Draw(BRect /*updateRect*/, bool useOffscreen, bool updateOnly, if (useOffscreen) { if (trackRectBlitter) (trackRectBlitter)(view, passThru); + view->Sync(); DrawBitmap(sOffscreen->Bitmap()); sOffscreen->DoneUsing(); @@ -300,8 +305,8 @@ BTitleView::MouseDown(BPoint where) // finish any pending edits fPoseView->CommitActivePose(); - BColumnTitle *title = FindColumnTitle(where); - BColumnTitle *resizedTitle = InColumnResizeArea(where); + BColumnTitle* title = FindColumnTitle(where); + BColumnTitle* resizedTitle = InColumnResizeArea(where); uint32 buttons; GetMouse(&where, &buttons); @@ -310,9 +315,9 @@ BTitleView::MouseDown(BPoint where) // if so, display the attribute menu: if (buttons & B_SECONDARY_MOUSE_BUTTON) { - BContainerWindow *window = dynamic_cast + BContainerWindow* window = dynamic_cast (Window()); - BPopUpMenu *menu = new BPopUpMenu("Attributes", false, false); + BPopUpMenu* menu = new BPopUpMenu("Attributes", false, false); menu->SetFont(be_plain_font); window->NewAttributeMenu(menu); window->AddMimeTypesToMenu(menu); @@ -369,7 +374,7 @@ BTitleView::MouseUp(BPoint where) void -BTitleView::MouseMoved(BPoint where, uint32 code, const BMessage *message) +BTitleView::MouseMoved(BPoint where, uint32 code, const BMessage* message) { if (fTrackingState != NULL) { int32 buttons = 0; @@ -395,12 +400,12 @@ BTitleView::MouseMoved(BPoint where, uint32 code, const BMessage *message) } -BColumnTitle * +BColumnTitle* BTitleView::InColumnResizeArea(BPoint where) const { int32 count = fTitleList.CountItems(); for (int32 index = 0; index < count; index++) { - BColumnTitle *title = fTitleList.ItemAt(index); + BColumnTitle* title = fTitleList.ItemAt(index); if (title->InColumnResizeArea(where)) return title; } @@ -409,12 +414,12 @@ BTitleView::InColumnResizeArea(BPoint where) const } -BColumnTitle * +BColumnTitle* BTitleView::FindColumnTitle(BPoint where) const { int32 count = fTitleList.CountItems(); for (int32 index = 0; index < count; index++) { - BColumnTitle *title = fTitleList.ItemAt(index); + BColumnTitle* title = fTitleList.ItemAt(index); if (title->Bounds().Contains(where)) return title; } @@ -423,12 +428,12 @@ BTitleView::FindColumnTitle(BPoint where) const } -BColumnTitle * -BTitleView::FindColumnTitle(const BColumn *column) const +BColumnTitle* +BTitleView::FindColumnTitle(const BColumn* column) const { int32 count = fTitleList.CountItems(); for (int32 index = 0; index < count; index++) { - BColumnTitle *title = fTitleList.ItemAt(index); + BColumnTitle* title = fTitleList.ItemAt(index); if (title->Column() == column) return title; } @@ -440,7 +445,7 @@ BTitleView::FindColumnTitle(const BColumn *column) const // #pragma mark - -BColumnTitle::BColumnTitle(BTitleView *view, BColumn *column) +BColumnTitle::BColumnTitle(BTitleView* view, BColumn* column) : fColumn(column), fParent(view) @@ -448,7 +453,7 @@ BColumnTitle::BColumnTitle(BTitleView *view, BColumn *column) } -bool +bool BColumnTitle::InColumnResizeArea(BPoint where) const { BRect edge(Bounds()); @@ -470,7 +475,7 @@ BColumnTitle::Bounds() const void -BColumnTitle::Draw(BView *view, bool pressed) +BColumnTitle::Draw(BView* view, bool pressed) { BRect bounds(Bounds()); BPoint loc(0, bounds.bottom - 4); @@ -555,7 +560,7 @@ BColumnTitle::Draw(BView *view, bool pressed) view->BeginLineArray(4); // draw lighter gray and white inset lines - rect.InsetBy(1, 1); + rect.InsetBy(1, 1); view->AddLine(rect.LeftBottom(), rect.RightBottom(), pressed ? sLightShadowColor : sLightShadowColor); view->AddLine(rect.LeftTop(), rect.RightTop(), @@ -574,7 +579,7 @@ BColumnTitle::Draw(BView *view, bool pressed) // #pragma mark - -ColumnTrackState::ColumnTrackState(BTitleView *view, BColumnTitle *title, +ColumnTrackState::ColumnTrackState(BTitleView* view, BColumnTitle* title, BPoint where, bigtime_t pastClickTime) : fTitleView(view), @@ -589,9 +594,9 @@ ColumnTrackState::ColumnTrackState(BTitleView *view, BColumnTitle *title, void ColumnTrackState::MouseUp(BPoint where) { - // if it is pressed shortly and not moved, it is a click - // all else is a track - if (system_time() <= fPastClickTime && !fHasMoved) + // if it is pressed shortly and not moved, it is a click + // else it is a track + if (system_time() <= fPastClickTime && !fHasMoved) Clicked(where); else Done(where); @@ -617,7 +622,7 @@ ColumnTrackState::MouseMoved(BPoint where, uint32 buttons) // #pragma mark - -ColumnResizeState::ColumnResizeState(BTitleView *view, BColumnTitle *title, +ColumnResizeState::ColumnResizeState(BTitleView* view, BColumnTitle* title, BPoint where, bigtime_t pastClickTime) : ColumnTrackState(view, title, where, pastClickTime), fLastLineDrawPos(-1), @@ -644,12 +649,12 @@ ColumnResizeState::Moved(BPoint where, uint32) float newWidth = where.x + fInitialTrackOffset - fTitle->fColumn->Offset(); if (newWidth < kMinColumnWidth) newWidth = kMinColumnWidth; - - BPoseView *poseView = fTitleView->PoseView(); -// bool shrink = (newWidth < fTitle->fColumn->Width()); + BPoseView* poseView = fTitleView->PoseView(); - // resize the column + //bool shrink = (newWidth < fTitle->fColumn->Width()); + + // resize the column poseView->ResizeColumn(fTitle->fColumn, newWidth, &fLastLineDrawPos, _DrawLine, _UndrawLine); @@ -657,7 +662,7 @@ ColumnResizeState::Moved(BPoint where, uint32) bounds.left = fTitle->fColumn->Offset(); // force title redraw - fTitleView->Draw(bounds, true, false); + fTitleView->Draw(bounds, true, false); } @@ -678,7 +683,7 @@ ColumnResizeState::Clicked(BPoint /*where*/) void ColumnResizeState::DrawLine() { - BPoseView *poseView = fTitleView->PoseView(); + BPoseView* poseView = fTitleView->PoseView(); ASSERT(!poseView->IsDesktopWindow()); BRect poseViewBounds(poseView->Bounds()); @@ -708,7 +713,7 @@ ColumnResizeState::UndrawLine() // #pragma mark - -ColumnDragState::ColumnDragState(BTitleView *view, BColumnTitle *columnTitle, +ColumnDragState::ColumnDragState(BTitleView* view, BColumnTitle* columnTitle, BPoint where, bigtime_t pastClickTime) : ColumnTrackState(view, columnTitle, where, pastClickTime), fInitialMouseTrackOffset(where.x), @@ -731,7 +736,7 @@ ColumnDragState::Moved(BPoint where, uint32) // figure out where we are with the mouse BRect titleBounds(fTitleView->Bounds()); bool overTitleView = titleBounds.Contains(where); - BColumnTitle *overTitle = overTitleView + BColumnTitle* overTitle = overTitleView ? fTitleView->FindColumnTitle(where) : 0; BRect titleBoundsWithMargin(titleBounds); titleBoundsWithMargin.InsetBy(0, -kRemoveTitleMargin); @@ -746,11 +751,12 @@ ColumnDragState::Moved(BPoint where, uint32) // back fTitleView->EndRectTracking(); fColumnArchive.Seek(0, SEEK_SET); - BColumn *column = BColumn::InstantiateFromStream(&fColumnArchive); + BColumn* column = BColumn::InstantiateFromStream(&fColumnArchive); ASSERT(column); - const BColumn *after = NULL; - if (overTitle) + const BColumn* after = NULL; + if (overTitle) after = overTitle->Column(); + fTitleView->PoseView()->AddColumn(column, after); fTrackingRemovedColumn = false; fTitle = fTitleView->FindColumnTitle(column); @@ -761,7 +767,7 @@ ColumnDragState::Moved(BPoint where, uint32) if (!inMarginRect) { // dragged a title out of the hysteresis margin around the // title bar - remove it and start dragging it as a dotted outline - + BRect rect(fTitle->Bounds()); rect.OffsetBy(where.x - fInitialMouseTrackOffset, where.y - 5); fColumnArchive.Seek(0, SEEK_SET); @@ -780,7 +786,7 @@ ColumnDragState::Moved(BPoint where, uint32) || where.x < overTitle->Bounds().left + fTitle->Bounds().Width())){ // over the one to the left, far enough to not snap right back - BColumn *column = fTitle->Column(); + BColumn* column = fTitle->Column(); fInitialMouseTrackOffset -= fTitle->Bounds().left; // swap the columns fTitleView->PoseView()->MoveColumnTo(column, overTitle->Column()); @@ -812,7 +818,7 @@ ColumnDragState::Done(BPoint /*where*/) void ColumnDragState::Clicked(BPoint /*where*/) { - BPoseView *poseView = fTitleView->PoseView(); + BPoseView* poseView = fTitleView->PoseView(); uint32 hash = fTitle->Column()->AttrHash(); uint32 primarySort = poseView->PrimarySort(); uint32 secondarySort = poseView->SecondarySort(); @@ -871,11 +877,11 @@ ColumnDragState::DrawOutline(float pos) } -void +void ColumnDragState::UndrawOutline() { fTitleView->Draw(fTitleView->Bounds(), true, false); } -OffscreenBitmap *BTitleView::sOffscreen = new OffscreenBitmap; +OffscreenBitmap* BTitleView::sOffscreen = new OffscreenBitmap; diff --git a/src/kits/tracker/TitleView.h b/src/kits/tracker/TitleView.h index baabfe6d88..9df1d20141 100644 --- a/src/kits/tracker/TitleView.h +++ b/src/kits/tracker/TitleView.h @@ -31,18 +31,20 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef _TITLE_VIEW_H #define _TITLE_VIEW_H + #include #include #include #include "ObjectList.h" + namespace BPrivate { + class BPoseView; class BColumn; class BColumnTitle; @@ -62,7 +64,7 @@ const int32 kColumnStart = 40; class BTitleView : public BView { public: - BTitleView(BRect, BPoseView *); + BTitleView(BRect, BPoseView*); virtual ~BTitleView(); virtual void MouseDown(BPoint where); @@ -71,33 +73,33 @@ public: void Draw(BRect, bool useOffscreen = false, bool updateOnly = true, - const BColumnTitle *pressedColumn = 0, - void (*trackRectBlitter)(BView *, BRect) = 0, + const BColumnTitle* pressedColumn = 0, + void (*trackRectBlitter)(BView*, BRect) = 0, BRect passThru = BRect(0, 0, 0, 0)); - void AddTitle(BColumn *, const BColumn *after = 0); - void RemoveTitle(BColumn *); + void AddTitle(BColumn*, const BColumn* after = 0); + void RemoveTitle(BColumn*); void Reset(); - BPoseView *PoseView() const; + BPoseView* PoseView() const; protected: - void MouseMoved(BPoint, uint32, const BMessage *); + void MouseMoved(BPoint, uint32, const BMessage*); private: - BColumnTitle *FindColumnTitle(BPoint) const; - BColumnTitle *InColumnResizeArea(BPoint) const; - BColumnTitle *FindColumnTitle(const BColumn *) const; + BColumnTitle* FindColumnTitle(BPoint) const; + BColumnTitle* InColumnResizeArea(BPoint) const; + BColumnTitle* FindColumnTitle(const BColumn*) const; - BPoseView *fPoseView; + BPoseView* fPoseView; BObjectList fTitleList; BCursor fHorizontalResizeCursor; - - BColumnTitle *fPreviouslyClickedColumnTitle; + + BColumnTitle* fPreviouslyClickedColumnTitle; bigtime_t fPreviousLeftClickTime; ColumnTrackState* fTrackingState; - static OffscreenBitmap *sOffscreen; + static OffscreenBitmap* sOffscreen; typedef BView _inherited; @@ -105,30 +107,31 @@ private: friend class ColumnDragState; }; + class BColumnTitle { public: - BColumnTitle(BTitleView *, BColumn *); + BColumnTitle(BTitleView*, BColumn*); virtual ~BColumnTitle() {} - virtual void Draw(BView *, bool pressed = false); + virtual void Draw(BView*, bool pressed = false); - - BColumn *Column() const; + BColumn* Column() const; BRect Bounds() const; - + bool InColumnResizeArea(BPoint) const; private: - BColumn *fColumn; - BTitleView *fParent; + BColumn* fColumn; + BTitleView* fParent; friend class ColumnResizeState; }; + // Utility classes to handle dragging state class ColumnTrackState { public: - ColumnTrackState(BTitleView *titleView, BColumnTitle *columnTitle, + ColumnTrackState(BTitleView* titleView, BColumnTitle* columnTitle, BPoint where, bigtime_t pastClickTime); virtual ~ColumnTrackState() {} @@ -139,15 +142,16 @@ protected: virtual void Moved(BPoint where, uint32 buttons) = 0; virtual void Clicked(BPoint where) = 0; virtual void Done(BPoint where) = 0; - virtual bool ValueChanged(BPoint where) = 0; + virtual bool ValueChanged(BPoint where) = 0; - BTitleView *fTitleView; - BColumnTitle *fTitle; - BPoint fFirstClickPoint; - bigtime_t fPastClickTime; - bool fHasMoved; + BTitleView* fTitleView; + BColumnTitle* fTitle; + BPoint fFirstClickPoint; + bigtime_t fPastClickTime; + bool fHasMoved; }; + class ColumnResizeState : public ColumnTrackState { public: ColumnResizeState(BTitleView* titleView, BColumnTitle* columnTitle, @@ -157,7 +161,7 @@ protected: virtual void Moved(BPoint where, uint32 buttons); virtual void Done(BPoint where); virtual void Clicked(BPoint where); - virtual bool ValueChanged(BPoint); + virtual bool ValueChanged(BPoint); void DrawLine(); void UndrawLine(); @@ -169,6 +173,7 @@ private: typedef ColumnTrackState _inherited; }; + class ColumnDragState : public ColumnTrackState { public: ColumnDragState(BTitleView* titleView, BColumnTitle* columnTitle, @@ -178,8 +183,8 @@ protected: virtual void Moved(BPoint where, uint32 buttons); virtual void Done(BPoint where); virtual void Clicked(BPoint where); - virtual bool ValueChanged(BPoint); - + virtual bool ValueChanged(BPoint); + void DrawOutline(float); void UndrawOutline(); void DrawPressNoOutline(); @@ -192,18 +197,21 @@ private: typedef ColumnTrackState _inherited; }; -inline BColumn * + +inline BColumn* BColumnTitle::Column() const { return fColumn; } -inline BPoseView * + +inline BPoseView* BTitleView::PoseView() const { return fPoseView; } + } // namespace BPrivate using namespace BPrivate; diff --git a/src/kits/tracker/Tracker.cpp b/src/kits/tracker/Tracker.cpp index 178afe2690..552081a8cc 100644 --- a/src/kits/tracker/Tracker.cpp +++ b/src/kits/tracker/Tracker.cpp @@ -32,12 +32,15 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include #include #include #include #include +#include "Tracker.h" + #include #include #include @@ -75,7 +78,6 @@ All rights reserved. #include "PoseView.h" #include "QueryContainerWindow.h" #include "StatusWindow.h" -#include "Tracker.h" #include "TrackerSettings.h" #include "TrashWatcher.h" #include "FunctionObject.h" @@ -104,7 +106,7 @@ const uint32 PSV_MAKE_PRINTER_ACTIVE_QUIETLY = 'pmaq'; namespace BPrivate { -NodePreloader *gPreloader = NULL; +NodePreloader* gPreloader = NULL; class LaunchLooper : public BLooper { public: @@ -115,14 +117,14 @@ public: } virtual void - MessageReceived(BMessage *message) + MessageReceived(BMessage* message) { - void (*function)(const entry_ref *, const BMessage *, bool); + void (*function)(const entry_ref*, const BMessage*, bool); BMessage refs; bool openWithOK; entry_ref appRef; - if (message->FindPointer("function", (void **)&function) != B_OK + if (message->FindPointer("function", (void**)&function) != B_OK || message->FindMessage("refs", &refs) != B_OK || message->FindBool("openWithOK", &openWithOK) != B_OK) { printf("incomplete launch message\n"); @@ -136,10 +138,12 @@ public: } }; -BLooper *gLaunchLooper = NULL; +BLooper* gLaunchLooper = NULL; + // #pragma mark - + void InitIconPreloader() { @@ -159,7 +163,7 @@ InitIconPreloader() // only start the node preloader if its Tracker or the Deskbar itself - don't // start it for file panels - bool preload = dynamic_cast(be_app) != NULL; + bool preload = dynamic_cast(be_app) != NULL; if (!preload) { // check for deskbar app_info info; @@ -179,7 +183,7 @@ InitIconPreloader() uint32 -GetVolumeFlags(Model *model) +GetVolumeFlags(Model* model) { fs_info info; if (model->IsVolume()) { @@ -263,7 +267,7 @@ TTracker::QuitRequested() if (CurrentMessage() && CurrentMessage()->FindBool("shortcut")) { // but allow quitting to hide fSettingsWindow int32 index = 0; - BWindow *window = NULL; + BWindow* window = NULL; while ((window = WindowAt(index++)) != NULL) { if (window == fSettingsWindow) { if (fSettingsWindow->Lock()) { @@ -286,7 +290,7 @@ TTracker::QuitRequested() // save open windows in a message inside an attribute of the desktop int32 count = fWindowList.CountItems(); for (int32 i = 0; i < count; i++) { - BContainerWindow *window = dynamic_cast + BContainerWindow* window = dynamic_cast (fWindowList.ItemAt(i)); if (window && window->Lock()) { @@ -297,7 +301,7 @@ TTracker::QuitRequested() else { BEntry entry; BPath path; - const entry_ref *ref = window->TargetModel()->EntryRef(); + const entry_ref* ref = window->TargetModel()->EntryRef(); if (entry.SetTo(ref) == B_OK && entry.GetPath(&path) == B_OK) { int8 flags = window->IsMinimized() ? kOpenWindowMinimized : kOpenWindowNoFlags; uint32 deviceFlags = GetVolumeFlags(window->TargetModel()); @@ -314,7 +318,7 @@ TTracker::QuitRequested() message.AddMessage("window state", &stateMessage); flags |= kOpenWindowHasState; } - const char *target; + const char* target; bool pathAlreadyExists = false; for (int32 index = 0;message.FindString("paths", index, &target) == B_OK;index++) { if (!strcmp(target,path.Path())) { @@ -339,7 +343,7 @@ TTracker::QuitRequested() // if message is empty, delete the corresponding attribute if (message.CountNames(B_ANY_TYPE)) { size_t size = (size_t)message.FlattenedSize(); - char *buffer = new char[size]; + char* buffer = new char[size]; message.Flatten(buffer, (ssize_t)size); deskDir.WriteAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer, size); delete [] buffer; @@ -381,7 +385,7 @@ TTracker::Quit() void -TTracker::MessageReceived(BMessage *message) +TTracker::MessageReceived(BMessage* message) { if (HandleScriptingMessage(message)) return; @@ -397,10 +401,10 @@ TTracker::MessageReceived(BMessage *message) case kCloseWindowAndChildren: { - const node_ref *itemNode; + const node_ref* itemNode; int32 bytes; message->FindData("node_ref", B_RAW_TYPE, - (const void **)&itemNode, &bytes); + (const void**)&itemNode, &bytes); CloseWindowAndChildren(itemNode); break; } @@ -467,7 +471,7 @@ TTracker::MessageReceived(BMessage *message) case kRestoreBackgroundImage: { - BDeskWindow *desktop = GetDeskWindow(); + BDeskWindow* desktop = GetDeskWindow(); AutoLock lock(desktop); desktop->UpdateDesktopBackgroundImages(); break; @@ -536,7 +540,7 @@ TTracker::Pulse() void -TTracker::SetDefaultPrinter(const BMessage *message) +TTracker::SetDefaultPrinter(const BMessage* message) { // get the first item selected int32 count = 0; @@ -571,7 +575,7 @@ TTracker::SetDefaultPrinter(const BMessage *message) void -TTracker::MoveRefsToTrash(const BMessage *message) +TTracker::MoveRefsToTrash(const BMessage* message) { int32 count; uint32 type; @@ -580,7 +584,7 @@ TTracker::MoveRefsToTrash(const BMessage *message) if (count <= 0) return; - BObjectList *srcList = new BObjectList(count, true); + BObjectList* srcList = new BObjectList(count, true); for (int32 index = 0; index < count; index++) { @@ -590,7 +594,7 @@ TTracker::MoveRefsToTrash(const BMessage *message) continue; AutoLock lock(&fWindowList); - BContainerWindow *window = FindParentContainerWindow(&ref); + BContainerWindow* window = FindParentContainerWindow(&ref); if (window) // if we have a window open for this entry, ask the pose to // delete it, this will select the next entry @@ -608,8 +612,8 @@ TTracker::MoveRefsToTrash(const BMessage *message) template class EntryAndNodeDoSoonWithMessageFunctor : public FunctionObjectWithResult { public: - EntryAndNodeDoSoonWithMessageFunctor(FT func, T *target, const entry_ref *child, - const node_ref *parent, const BMessage *message) + EntryAndNodeDoSoonWithMessageFunctor(FT func, T* target, const entry_ref* child, + const node_ref* parent, const BMessage* message) : fFunc(func), fTarget(target), fNode(*parent), @@ -626,7 +630,7 @@ public: protected: FT fFunc; - T *fTarget; + T* fTarget; node_ref fNode; entry_ref fEntry; BMessage fMessage; @@ -635,8 +639,8 @@ protected: bool -TTracker::LaunchAndCloseParentIfOK(const entry_ref *launchThis, - const node_ref *closeThis, const BMessage *messageToBundle) +TTracker::LaunchAndCloseParentIfOK(const entry_ref* launchThis, + const node_ref* closeThis, const BMessage* messageToBundle) { BMessage refsReceived(B_REFS_RECEIVED); if (messageToBundle) { @@ -655,11 +659,11 @@ TTracker::LaunchAndCloseParentIfOK(const entry_ref *launchThis, status_t -TTracker::OpenRef(const entry_ref *ref, const node_ref *nodeToClose, - const node_ref *nodeToSelect, OpenSelector selector, - const BMessage *messageToBundle) +TTracker::OpenRef(const entry_ref* ref, const node_ref* nodeToClose, + const node_ref* nodeToSelect, OpenSelector selector, + const BMessage* messageToBundle) { - Model *model = NULL; + Model* model = NULL; BEntry entry(ref, true); status_t result = entry.InitCheck(); @@ -727,8 +731,8 @@ TTracker::OpenRef(const entry_ref *ref, const node_ref *nodeToClose, // and close parent if successfull if (nodeToClose) Thread::Launch(new EntryAndNodeDoSoonWithMessageFunctor(&TTracker::LaunchAndCloseParentIfOK, this, + bool (TTracker::*)(const entry_ref*, const node_ref*, + const BMessage*)>(&TTracker::LaunchAndCloseParentIfOK, this, ref, nodeToClose, messageToBundle)); else { BMessage refsReceived(B_REFS_RECEIVED); @@ -753,7 +757,7 @@ TTracker::OpenRef(const entry_ref *ref, const node_ref *nodeToClose, void -TTracker::RefsReceived(BMessage *message) +TTracker::RefsReceived(BMessage* message) { OpenSelector selector = kOpen; if (message->HasInt32("launchUsingSelector")) @@ -802,7 +806,7 @@ TTracker::RefsReceived(BMessage *message) { // copy over "Poses" messenger so that refs received recipients know // where the open came from - BMessage *bundleThis = NULL; + BMessage* bundleThis = NULL; BMessenger messenger; if (message->FindMessenger("TrackerViewToken", &messenger) == B_OK) { bundleThis = new BMessage(); @@ -813,14 +817,14 @@ TTracker::RefsReceived(BMessage *message) entry_ref ref; message->FindRef("refs", index, &ref); - const node_ref *nodeToClose = NULL; - const node_ref *nodeToSelect = NULL; + const node_ref* nodeToClose = NULL; + const node_ref* nodeToSelect = NULL; ssize_t numBytes; message->FindData("nodeRefsToClose", B_RAW_TYPE, index, - (const void **)&nodeToClose, &numBytes); + (const void**)&nodeToClose, &numBytes); message->FindData("nodeRefToSelect", B_RAW_TYPE, index, - (const void **)&nodeToSelect, &numBytes); + (const void**)&nodeToSelect, &numBytes); OpenRef(&ref, nodeToClose, nodeToSelect, selector, bundleThis); } @@ -833,10 +837,10 @@ TTracker::RefsReceived(BMessage *message) void -TTracker::ArgvReceived(int32 argc, char **argv) +TTracker::ArgvReceived(int32 argc, char** argv) { - BMessage *message = CurrentMessage(); - const char *currentWorkingDirectoryPath = NULL; + BMessage* message = CurrentMessage(); + const char* currentWorkingDirectoryPath = NULL; entry_ref ref; if (message->FindString("cwd", ¤tWorkingDirectoryPath) == B_OK) { @@ -853,12 +857,12 @@ TTracker::ArgvReceived(int32 argc, char **argv) } void -TTracker::OpenContainerWindow(Model *model, BMessage *originalRefsList, +TTracker::OpenContainerWindow(Model* model, BMessage* originalRefsList, OpenSelector openSelector, uint32 openFlags, bool checkAlreadyOpen, - const BMessage *stateMessage) + const BMessage* stateMessage) { AutoLock lock(&fWindowList); - BContainerWindow *window = NULL; + BContainerWindow* window = NULL; if (checkAlreadyOpen && openSelector != kRunOpenWithWindow) // find out if window already open window = FindContainerWindow(model->NodeRef()); @@ -886,7 +890,7 @@ TTracker::OpenContainerWindow(Model *model, BMessage *originalRefsList, // we open a new one. if (openSelector == kRunOpenWithWindow) { - BMessage *refList = NULL; + BMessage* refList = NULL; if (!originalRefsList) { // when passing just a single model, stuff it's entry in a single // element list anyway @@ -922,7 +926,7 @@ TTracker::OpenContainerWindow(Model *model, BMessage *originalRefsList, void -TTracker::EditQueries(const BMessage *message) +TTracker::EditQueries(const BMessage* message) { bool editOnlyIfTemplate; if (message->FindBool("editQueryOnPose", &editOnlyIfTemplate) != B_OK) @@ -942,7 +946,7 @@ TTracker::EditQueries(const BMessage *message) void -TTracker::OpenInfoWindows(BMessage *message) +TTracker::OpenInfoWindows(BMessage* message) { type_code type; int32 count; @@ -953,14 +957,14 @@ TTracker::OpenInfoWindows(BMessage *message) message->FindRef("refs", index, &ref); BEntry entry; if (entry.SetTo(&ref) == B_OK) { - Model *model = new Model(&entry); + Model* model = new Model(&entry); if (model->InitCheck() != B_OK) { delete model; continue; } AutoLock lock(&fWindowList); - BInfoWindow *wind = FindInfoWindow(model->NodeRef()); + BInfoWindow* wind = FindInfoWindow(model->NodeRef()); if (wind) { wind->Activate(); @@ -974,12 +978,12 @@ TTracker::OpenInfoWindows(BMessage *message) } -BDeskWindow * +BDeskWindow* TTracker::GetDeskWindow() const { int32 count = fWindowList.CountItems(); for (int32 index = 0; index < count; index++) { - BDeskWindow *window = dynamic_cast + BDeskWindow* window = dynamic_cast (fWindowList.ItemAt(index)); if (window) @@ -990,8 +994,8 @@ TTracker::GetDeskWindow() const } -BContainerWindow * -TTracker::FindContainerWindow(const node_ref *node, int32 number) const +BContainerWindow* +TTracker::FindContainerWindow(const node_ref* node, int32 number) const { ASSERT(fWindowList.IsLocked()); @@ -1000,7 +1004,7 @@ TTracker::FindContainerWindow(const node_ref *node, int32 number) const int32 windowsFound = 0; for (int32 index = 0; index < count; index++) { - BContainerWindow *window = dynamic_cast + BContainerWindow* window = dynamic_cast (fWindowList.ItemAt(index)); if (window && window->IsShowing(node) && number == windowsFound++) @@ -1010,8 +1014,8 @@ TTracker::FindContainerWindow(const node_ref *node, int32 number) const } -BContainerWindow * -TTracker::FindContainerWindow(const entry_ref *entry, int32 number) const +BContainerWindow* +TTracker::FindContainerWindow(const entry_ref* entry, int32 number) const { ASSERT(fWindowList.IsLocked()); @@ -1020,7 +1024,7 @@ TTracker::FindContainerWindow(const entry_ref *entry, int32 number) const int32 windowsFound = 0; for (int32 index = 0; index < count; index++) { - BContainerWindow *window = dynamic_cast + BContainerWindow* window = dynamic_cast (fWindowList.ItemAt(index)); if (window && window->IsShowing(entry) && number == windowsFound++) @@ -1031,15 +1035,15 @@ TTracker::FindContainerWindow(const entry_ref *entry, int32 number) const bool -TTracker::EntryHasWindowOpen(const entry_ref *entry) +TTracker::EntryHasWindowOpen(const entry_ref* entry) { AutoLock lock(&fWindowList); return FindContainerWindow(entry) != NULL; } -BContainerWindow * -TTracker::FindParentContainerWindow(const entry_ref *ref) const +BContainerWindow* +TTracker::FindParentContainerWindow(const entry_ref* ref) const { BEntry entry(ref); BEntry parent; @@ -1054,7 +1058,7 @@ TTracker::FindParentContainerWindow(const entry_ref *ref) const int32 count = fWindowList.CountItems(); for (int32 index = 0; index < count; index++) { - BContainerWindow *window = dynamic_cast + BContainerWindow* window = dynamic_cast (fWindowList.ItemAt(index)); if (window && window->IsShowing(&parentRef)) return window; @@ -1063,14 +1067,14 @@ TTracker::FindParentContainerWindow(const entry_ref *ref) const } -BInfoWindow * +BInfoWindow* TTracker::FindInfoWindow(const node_ref* node) const { ASSERT(fWindowList.IsLocked()); int32 count = fWindowList.CountItems(); for (int32 index = 0; index < count; index++) { - BInfoWindow *window = dynamic_cast + BInfoWindow* window = dynamic_cast (fWindowList.ItemAt(index)); if (window && window->IsShowing(node)) return window; @@ -1085,8 +1089,8 @@ TTracker::QueryActiveForDevice(dev_t device) AutoLock lock(&fWindowList); int32 count = fWindowList.CountItems(); for (int32 index = 0; index < count; index++) { - BQueryContainerWindow *window = dynamic_cast - (fWindowList.ItemAt(index)); + BQueryContainerWindow* window + = dynamic_cast(fWindowList.ItemAt(index)); if (window) { AutoLock lock(window); if (window->ActiveOnDevice(device)) @@ -1105,8 +1109,8 @@ TTracker::CloseActiveQueryWindows(dev_t device) bool closed = false; AutoLock lock(fWindowList); for (int32 index = fWindowList.CountItems(); index >= 0; index--) { - BQueryContainerWindow *window = dynamic_cast - (fWindowList.ItemAt(index)); + BQueryContainerWindow* window + = dynamic_cast(fWindowList.ItemAt(index)); if (window) { AutoLock lock(window); if (window->ActiveOnDevice(device)) { @@ -1131,12 +1135,12 @@ TTracker::SaveAllPoseLocations() { int32 numWindows = fWindowList.CountItems(); for (int32 windowIndex = 0; windowIndex < numWindows; windowIndex++) { - BContainerWindow *window = dynamic_cast - (fWindowList.ItemAt(windowIndex)); + BContainerWindow* window + = dynamic_cast(fWindowList.ItemAt(windowIndex)); if (window) { AutoLock lock(window); - BDeskWindow *deskWindow = dynamic_cast(window); + BDeskWindow* deskWindow = dynamic_cast(window); if (deskWindow) deskWindow->SaveDesktopPoseLocations(); @@ -1148,7 +1152,7 @@ TTracker::SaveAllPoseLocations() void -TTracker::CloseWindowAndChildren(const node_ref *node) +TTracker::CloseWindowAndChildren(const node_ref* node) { BDirectory dir(node); if (dir.InitCheck() != B_OK) @@ -1160,7 +1164,7 @@ TTracker::CloseWindowAndChildren(const node_ref *node) // make a list of all windows to be closed // count from end to beginning so we can remove items safely for (int32 index = fWindowList.CountItems() - 1; index >= 0; index--) { - BContainerWindow *window = dynamic_cast + BContainerWindow* window = dynamic_cast (fWindowList.ItemAt(index)); if (window && window->TargetModel()) { BEntry wind_entry; @@ -1180,7 +1184,7 @@ TTracker::CloseWindowAndChildren(const node_ref *node) // now really close the windows int32 numItems = closeList.CountItems(); for (int32 index = 0; index < numItems; index++) { - BContainerWindow *window = closeList.ItemAt(index); + BContainerWindow* window = closeList.ItemAt(index); window->PostMessage(B_QUIT_REQUESTED); } } @@ -1194,11 +1198,11 @@ TTracker::CloseAllInWorkspace() int32 currentWorkspace = 1 << current_workspace(); // count from end to beginning so we can remove items safely for (int32 index = fWindowList.CountItems() - 1; index >= 0; index--) { - BWindow *window = fWindowList.ItemAt(index); + BWindow* window = fWindowList.ItemAt(index); if (window->Workspaces() & currentWorkspace) // avoid the desktop - if (!dynamic_cast(window) - && !dynamic_cast(window)) + if (!dynamic_cast(window) + && !dynamic_cast(window)) window->PostMessage(B_QUIT_REQUESTED); } } @@ -1215,17 +1219,17 @@ TTracker::CloseAllWindows() int32 count = CountWindows(); for (int32 index = 0; index < count; index++) { - BWindow *window = WindowAt(index); + BWindow* window = WindowAt(index); // avoid the desktop - if (!dynamic_cast(window) - && !dynamic_cast(window)) + if (!dynamic_cast(window) + && !dynamic_cast(window)) window->PostMessage(B_QUIT_REQUESTED); } // count from end to beginning so we can remove items safely for (int32 index = fWindowList.CountItems() - 1; index >= 0; index--) { - BWindow *window = fWindowList.ItemAt(index); - if (!dynamic_cast(window) - && !dynamic_cast(window)) + BWindow* window = fWindowList.ItemAt(index); + if (!dynamic_cast(window) + && !dynamic_cast(window)) // ToDo: // get rid of the Remove here, BContainerWindow::Quit does it fWindowList.RemoveItemAt(index); @@ -1246,7 +1250,7 @@ TTracker::_OpenPreviouslyOpenedWindows(const char* pathFilter) || deskDir.GetAttrInfo(kAttrOpenWindows, &attrInfo) != B_OK) return; - char *buffer = (char *)malloc((size_t)attrInfo.size); + char* buffer = (char*)malloc((size_t)attrInfo.size); BMessage message; if (deskDir.ReadAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer, (size_t)attrInfo.size) != attrInfo.size @@ -1261,7 +1265,7 @@ TTracker::_OpenPreviouslyOpenedWindows(const char* pathFilter) deskDir.GetNodeRef(&nodeRef); int32 stateMessageCounter = 0; - const char *path; + const char* path; for (int32 i = 0; message.FindString("paths", i, &path) == B_OK; i++) { if (strncmp(path, pathFilter, filterLength)) continue; @@ -1272,7 +1276,7 @@ TTracker::_OpenPreviouslyOpenedWindows(const char* pathFilter) int8 flags = 0; for (int32 j = 0; message.FindInt8(path, j, &flags) == B_OK; j++) { - Model *model = new Model(&entry); + Model* model = new Model(&entry); if (model->InitCheck() == B_OK && model->IsContainer()) { BMessage state; bool restoreStateFromMessage = false; @@ -1327,13 +1331,13 @@ TTracker::ReadyToRun() fTaskLoop = new StandAloneTaskLoop(true); // open desktop window - BContainerWindow *deskWindow = NULL; + BContainerWindow* deskWindow = NULL; BDirectory deskDir; if (FSGetDeskDir(&deskDir) == B_OK) { // create desktop BEntry entry; deskDir.GetEntry(&entry); - Model *model = new Model(&entry, true); + Model* model = new Model(&entry, true); if (model->InitCheck() == B_OK) { AutoLock lock(&fWindowList); deskWindow = new BDeskWindow(&fWindowList); @@ -1372,15 +1376,15 @@ TTracker::ReadyToRun() } } -MimeTypeList * +MimeTypeList* TTracker::MimeTypes() const { return fMimeTypeList; } void -TTracker::SelectChildInParentSoon(const entry_ref *parent, - const node_ref *child) +TTracker::SelectChildInParentSoon(const entry_ref* parent, + const node_ref* child) { fTaskLoop->RunLater(NewMemberFunctionObjectWithResult (&TTracker::SelectChildInParent, this, parent, child), @@ -1388,8 +1392,8 @@ TTracker::SelectChildInParentSoon(const entry_ref *parent, } void -TTracker::CloseParentWaitingForChildSoon(const entry_ref *child, - const node_ref *parent) +TTracker::CloseParentWaitingForChildSoon(const entry_ref* child, + const node_ref* parent) { fTaskLoop->RunLater(NewMemberFunctionObjectWithResult (&TTracker::CloseParentWaitingForChild, this, child, parent), @@ -1408,7 +1412,7 @@ void TTracker::SelectPoseAtLocationInParent(node_ref parent, BPoint pointInPose) { AutoLock lock(&fWindowList); - BContainerWindow *parentWindow = FindContainerWindow(&parent); + BContainerWindow* parentWindow = FindContainerWindow(&parent); if (parentWindow) { AutoLock lock(parentWindow); parentWindow->PoseView()->SelectPoseAtLocation(pointInPose); @@ -1416,12 +1420,12 @@ TTracker::SelectPoseAtLocationInParent(node_ref parent, BPoint pointInPose) } bool -TTracker::CloseParentWaitingForChild(const entry_ref *child, - const node_ref *parent) +TTracker::CloseParentWaitingForChild(const entry_ref* child, + const node_ref* parent) { AutoLock lock(&fWindowList); - BContainerWindow *parentWindow = FindContainerWindow(parent); + BContainerWindow* parentWindow = FindContainerWindow(parent); if (!parentWindow) // parent window already closed, give up return true; @@ -1433,7 +1437,7 @@ TTracker::CloseParentWaitingForChild(const entry_ref *child, if (entry.GetRef(&resolvedChild) != B_OK) resolvedChild = *child; - BContainerWindow *window = FindContainerWindow(&resolvedChild); + BContainerWindow* window = FindContainerWindow(&resolvedChild); if (window) { AutoLock lock(window); if (!window->IsHidden()) @@ -1470,11 +1474,11 @@ TTracker::ShowSettingsWindow() } bool -TTracker::CloseParentWindowCommon(BContainerWindow *window) +TTracker::CloseParentWindowCommon(BContainerWindow* window) { ASSERT(fWindowList.IsLocked()); - if (dynamic_cast(window)) + if (dynamic_cast(window)) // don't close the destop return false; @@ -1483,11 +1487,11 @@ TTracker::CloseParentWindowCommon(BContainerWindow *window) } bool -TTracker::SelectChildInParent(const entry_ref *parent, const node_ref *child) +TTracker::SelectChildInParent(const entry_ref* parent, const node_ref* child) { AutoLock lock(&fWindowList); - BContainerWindow *window = FindContainerWindow(parent); + BContainerWindow* window = FindContainerWindow(parent); if (!window) // parent window already closed, give up return false; @@ -1495,9 +1499,9 @@ TTracker::SelectChildInParent(const entry_ref *parent, const node_ref *child) AutoLock windowLock(window); if (windowLock.IsLocked()) { - BPoseView *view = window->PoseView(); + BPoseView* view = window->PoseView(); int32 index; - BPose *pose = view->FindPose(child, &index); + BPose* pose = view->FindPose(child, &index); if (pose) { view->SelectPose(pose, index); return true; @@ -1526,7 +1530,7 @@ TTracker::NeedMoreNodeMonitors() } status_t -TTracker::WatchNode(const node_ref *node, uint32 flags, +TTracker::WatchNode(const node_ref* node, uint32 flags, BMessenger target) { status_t result = watch_node(node, flags, target); @@ -1539,7 +1543,7 @@ TTracker::WatchNode(const node_ref *node, uint32 flags, PRINT(("failed to start monitoring, trying to allocate more " "node monitors\n")); - TTracker *tracker = dynamic_cast(be_app); + TTracker* tracker = dynamic_cast(be_app); if (!tracker) { // we are the file panel only, just fail return result; @@ -1566,7 +1570,7 @@ TTracker::MountServer() const bool -TTracker::InTrashNode(const entry_ref *node) const +TTracker::InTrashNode(const entry_ref* node) const { return FSInTrashDir(node); } @@ -1580,8 +1584,7 @@ TTracker::TrashFull() const bool -TTracker::IsTrashNode(const node_ref *node) const +TTracker::IsTrashNode(const node_ref* node) const { return fTrashWatcher->IsTrashNode(node); } - diff --git a/src/kits/tracker/Tracker.h b/src/kits/tracker/Tracker.h index e3995767f7..5a31f782cc 100644 --- a/src/kits/tracker/Tracker.h +++ b/src/kits/tracker/Tracker.h @@ -31,9 +31,9 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ +#ifndef _TRACKER_H +#define _TRACKER_H -#ifndef _TRACKER_H -#define _TRACKER_H #include #include @@ -83,25 +83,25 @@ class TTracker : public BApplication { virtual void Quit(); virtual bool QuitRequested(); virtual void ReadyToRun(); - virtual void MessageReceived(BMessage *); + virtual void MessageReceived(BMessage*); virtual void Pulse(); - virtual void RefsReceived(BMessage *); - virtual void ArgvReceived(int32 argc, char **argv); + virtual void RefsReceived(BMessage*); + virtual void ArgvReceived(int32 argc, char** argv); - MimeTypeList *MimeTypes() const; + MimeTypeList* MimeTypes() const; // list of mime types that have a description and do not have // themselves as a preferred handler (case of applications) bool TrashFull() const; - bool IsTrashNode(const node_ref *) const; - bool InTrashNode(const entry_ref *) const; + bool IsTrashNode(const node_ref*) const; + bool InTrashNode(const entry_ref*) const; - void CloseParentWaitingForChildSoon(const entry_ref *child, - const node_ref *parent); + void CloseParentWaitingForChildSoon(const entry_ref* child, + const node_ref* parent); // closes parent, waits for child to open first - void SelectChildInParentSoon(const entry_ref *child, - const node_ref *parent); + void SelectChildInParentSoon(const entry_ref* child, + const node_ref* parent); // waits till child shows up in parent and selects it void SelectPoseAtLocationSoon(node_ref parent, BPoint location); @@ -113,19 +113,19 @@ class TTracker : public BApplication { kRunOpenWithWindow }; - bool EntryHasWindowOpen(const entry_ref *); + bool EntryHasWindowOpen(const entry_ref*); // return true if there is an open window for an entry status_t NeedMoreNodeMonitors(); // call if ran out of node monitors to allocate more // return false if already using all we can get - static status_t WatchNode(const node_ref *, uint32 flags, + static status_t WatchNode(const node_ref*, uint32 flags, BMessenger target); // cover call for watch_node; if first watch_node fails, // tries bumping the node monitor limit and calls watch_node // again - TaskLoop *MainTaskLoop() const; + TaskLoop* MainTaskLoop() const; BMessenger MountServer() const; bool QueryActiveForDevice(dev_t); @@ -137,45 +137,45 @@ class TTracker : public BApplication { void ShowSettingsWindow(); - BContainerWindow *FindContainerWindow(const node_ref *, int32 number = 0) const; - BContainerWindow *FindContainerWindow(const entry_ref *, int32 number = 0) const; - BContainerWindow *FindParentContainerWindow(const entry_ref *) const; + BContainerWindow* FindContainerWindow(const node_ref*, int32 number = 0) const; + BContainerWindow* FindContainerWindow(const entry_ref*, int32 number = 0) const; + BContainerWindow* FindParentContainerWindow(const entry_ref*) const; // right now works just on plain windows, not on query windows - BClipboardRefsWatcher *ClipboardRefsWatcher() const; + BClipboardRefsWatcher* ClipboardRefsWatcher() const; protected: // scripting - virtual BHandler *ResolveSpecifier(BMessage *, int32, BMessage *, - int32, const char *); - virtual status_t GetSupportedSuites(BMessage *); + virtual BHandler* ResolveSpecifier(BMessage*, int32, BMessage*, + int32, const char*); + virtual status_t GetSupportedSuites(BMessage*); - bool HandleScriptingMessage(BMessage *); + bool HandleScriptingMessage(BMessage*); - bool ExecuteProperty(BMessage *, int32, const char *, BMessage *); - bool CreateProperty(BMessage *, BMessage *, int32, const char *, - BMessage *); - bool DeleteProperty(BMessage *, int32, - const char *, BMessage *); - bool CountProperty(BMessage *, int32, const char *, BMessage *); - bool GetProperty(BMessage *, int32, const char *, BMessage *); - bool SetProperty(BMessage *, BMessage *, int32, const char *, BMessage *); + bool ExecuteProperty(BMessage*, int32, const char*, BMessage*); + bool CreateProperty(BMessage*, BMessage*, int32, const char*, + BMessage*); + bool DeleteProperty(BMessage*, int32, + const char*, BMessage*); + bool CountProperty(BMessage*, int32, const char*, BMessage*); + bool GetProperty(BMessage*, int32, const char*, BMessage*); + bool SetProperty(BMessage*, BMessage*, int32, const char*, BMessage*); private: // callbacks for ChildParentSoon calls - bool CloseParentWaitingForChild(const entry_ref *child, - const node_ref *parent); - bool LaunchAndCloseParentIfOK(const entry_ref *launchThis, - const node_ref *closeThis, const BMessage *messageToBundle); - bool SelectChildInParent(const entry_ref *child, - const node_ref *parent); + bool CloseParentWaitingForChild(const entry_ref* child, + const node_ref* parent); + bool LaunchAndCloseParentIfOK(const entry_ref* launchThis, + const node_ref* closeThis, const BMessage* messageToBundle); + bool SelectChildInParent(const entry_ref* child, + const node_ref* parent); void SelectPoseAtLocationInParent(node_ref parent, BPoint location); - bool CloseParentWindowCommon(BContainerWindow *); + bool CloseParentWindowCommon(BContainerWindow*); void InitMimeTypes(); - bool InstallMimeIfNeeded(const char *type, int32 bitsID, - const char *shortDescription, const char *longDescription, - const char *preferredAppSignature, uint32 forceMask = 0); + bool InstallMimeIfNeeded(const char* type, int32 bitsID, + const char* shortDescription, const char* longDescription, + const char* preferredAppSignature, uint32 forceMask = 0); // used by InitMimeTypes - checks if a metamime of a given is // installed and if it has all the specified attributes; if not, the // whole mime type is installed and all attributes are set; nulls can @@ -190,47 +190,48 @@ class TTracker : public BApplication { void InstallIndices(dev_t); void CloseAllWindows(); - void CloseWindowAndChildren(const node_ref *); + void CloseWindowAndChildren(const node_ref*); void CloseAllInWorkspace(); void OpenInfoWindows(BMessage*); - void MoveRefsToTrash(const BMessage *); - void OpenContainerWindow(Model *, BMessage *refsList = NULL, - OpenSelector openSelector = kOpen, uint32 openFlags = 0, - bool checkAlreadyOpen = true, const BMessage *stateMessage = NULL); + void MoveRefsToTrash(const BMessage*); + void OpenContainerWindow(Model*, BMessage* refsList = NULL, + OpenSelector openSelector = kOpen, uint32 openFlags = 0, + bool checkAlreadyOpen = true, const BMessage* stateMessage = NULL); // pass either a Model or a list of entries to open void _OpenPreviouslyOpenedWindows(const char* pathFilter = NULL); - void SetDefaultPrinter(const BMessage *); - void EditQueries(const BMessage *); + void SetDefaultPrinter(const BMessage*); + void EditQueries(const BMessage*); - BInfoWindow *FindInfoWindow(const node_ref *) const; + BInfoWindow* FindInfoWindow(const node_ref*) const; - BDeskWindow *GetDeskWindow() const; + BDeskWindow* GetDeskWindow() const; - status_t OpenRef(const entry_ref *, const node_ref *nodeToClose = NULL, - const node_ref *nodeToSelect = NULL, OpenSelector selector = kOpen, - const BMessage *messageToBundle = NULL); + status_t OpenRef(const entry_ref*, const node_ref* nodeToClose = NULL, + const node_ref* nodeToSelect = NULL, OpenSelector selector = kOpen, + const BMessage* messageToBundle = NULL); - MimeTypeList *fMimeTypeList; - WindowList fWindowList; - BClipboardRefsWatcher *fClipboardRefsWatcher; - BTrashWatcher *fTrashWatcher; - TaskLoop *fTaskLoop; - int32 fNodeMonitorCount; + MimeTypeList* fMimeTypeList; + WindowList fWindowList; + BClipboardRefsWatcher* fClipboardRefsWatcher; + BTrashWatcher* fTrashWatcher; + TaskLoop* fTaskLoop; + int32 fNodeMonitorCount; - TrackerSettingsWindow *fSettingsWindow; + TrackerSettingsWindow* fSettingsWindow; typedef BApplication _inherited; }; -inline TaskLoop * +inline TaskLoop* TTracker::MainTaskLoop() const { return fTaskLoop; } -inline BClipboardRefsWatcher * + +inline BClipboardRefsWatcher* TTracker::ClipboardRefsWatcher() const { return fClipboardRefsWatcher; @@ -240,4 +241,4 @@ TTracker::ClipboardRefsWatcher() const using namespace BPrivate; -#endif /* _TRACKER_H */ +#endif // _TRACKER_H diff --git a/src/kits/tracker/TrackerInitialState.cpp b/src/kits/tracker/TrackerInitialState.cpp index 9229de3e5c..1c0c12abac 100644 --- a/src/kits/tracker/TrackerInitialState.cpp +++ b/src/kits/tracker/TrackerInitialState.cpp @@ -36,6 +36,7 @@ All rights reserved. // add code to initialize a subset of the mime database, including // important sniffer rules + #include #include #include @@ -62,6 +63,7 @@ All rights reserved. #include "QueryContainerWindow.h" #include "Tracker.h" + enum { kForceLargeIcon = 0x1, kForceMiniIcon = 0x2, @@ -71,23 +73,23 @@ enum { }; -const char *kAttrName = "META:name"; -const char *kAttrCompany = "META:company"; -const char *kAttrAddress = "META:address"; -const char *kAttrCity = "META:city"; -const char *kAttrState = "META:state"; -const char *kAttrZip = "META:zip"; -const char *kAttrCountry = "META:country"; -const char *kAttrHomePhone = "META:hphone"; -const char *kAttrWorkPhone = "META:wphone"; -const char *kAttrFax = "META:fax"; -const char *kAttrEmail = "META:email"; -const char *kAttrURL = "META:url"; -const char *kAttrGroup = "META:group"; -const char *kAttrNickname = "META:nickname"; +const char* kAttrName = "META:name"; +const char* kAttrCompany = "META:company"; +const char* kAttrAddress = "META:address"; +const char* kAttrCity = "META:city"; +const char* kAttrState = "META:state"; +const char* kAttrZip = "META:zip"; +const char* kAttrCountry = "META:country"; +const char* kAttrHomePhone = "META:hphone"; +const char* kAttrWorkPhone = "META:wphone"; +const char* kAttrFax = "META:fax"; +const char* kAttrEmail = "META:email"; +const char* kAttrURL = "META:url"; +const char* kAttrGroup = "META:group"; +const char* kAttrNickname = "META:nickname"; -const char *kNetPositiveSignature = "application/x-vnd.Be-NPOS"; -const char *kPeopleSignature = "application/x-vnd.Be-PEPL"; +const char* kNetPositiveSignature = "application/x-vnd.Be-NPOS"; +const char* kPeopleSignature = "application/x-vnd.Be-PEPL"; // the following templates are in big endian and we rely on the Tracker // translation support to swap them on little endian machines @@ -102,13 +104,15 @@ const int32 kDefaultQueryTemplateCount = 3; const AttributeTemplate kDefaultQueryTemplate[] = /* /boot/home/config/settings/Tracker/DefaultQueryTemplates/application_octet-stream */ { - { /* default frame */ + { + // default frame kAttrWindowFrame, B_RECT_TYPE, 16, - (const char *)&kDefaultFrame + (const char*)&kDefaultFrame }, - { /* attr: _trk/viewstate */ + { + // attr: _trk/viewstate kAttrViewState_be, B_RAW_TYPE, 49, @@ -116,7 +120,8 @@ const AttributeTemplate kDefaultQueryTemplate[] = "\000\000\000\000\000\000\000\000\000\000\357\323\335RCSTR\000\000\000" "\000\000\000\000\000\000" }, - { /* attr: _trk/columns */ + { + // attr: _trk/columns kAttrColumns_be, B_RAW_TYPE, 223, @@ -135,13 +140,15 @@ const AttributeTemplate kDefaultQueryTemplate[] = const AttributeTemplate kBookmarkQueryTemplate[] = /* /boot/home/config/settings/Tracker/DefaultQueryTemplates/application_x-vnd.Be-bookmark */ { - { /* default frame */ + { + // default frame kAttrWindowFrame, B_RECT_TYPE, 16, - (const char *)&kDefaultFrame + (const char*)&kDefaultFrame }, - { /* attr: _trk/viewstate */ + { + // attr: _trk/viewstate kAttrViewState_be, B_RAW_TYPE, 49, @@ -149,7 +156,8 @@ const AttributeTemplate kBookmarkQueryTemplate[] = "\000\000\000\000\000\000\000\000\000\000w\373\175RCSTR\000\000\000" "\000\000\000\000\000\000" }, - { /* attr: _trk/columns */ + { + // attr: _trk/columns kAttrColumns_be, B_RAW_TYPE, 163, @@ -166,13 +174,15 @@ const AttributeTemplate kBookmarkQueryTemplate[] = const AttributeTemplate kPersonQueryTemplate[] = /* /boot/home/config/settings/Tracker/DefaultQueryTemplates/application_x-vnd.Be-bookmark */ { - { /* default frame */ + { + // default frame kAttrWindowFrame, B_RECT_TYPE, 16, - (const char *)&kDefaultFrame + (const char*)&kDefaultFrame }, - { /* attr: _trk/viewstate */ + { + // attr: _trk/viewstate kAttrViewState_be, B_RAW_TYPE, 49, @@ -180,7 +190,8 @@ const AttributeTemplate kPersonQueryTemplate[] = "\000\000\000\000\000\000\000\000\000\000\357\323\335RCSTR\000\000\000" "\000\000\000\000\000\000" }, - { /* attr: _trk/columns */ + { + // attr: _trk/columns kAttrColumns_be, B_RAW_TYPE, 230, @@ -199,13 +210,15 @@ const AttributeTemplate kPersonQueryTemplate[] = const AttributeTemplate kEmailQueryTemplate[] = /* /boot/home/config/settings/Tracker/DefaultQueryTemplates/text_x-email */ { - { /* default frame */ + { + // default frame kAttrWindowFrame, B_RECT_TYPE, 16, - (const char *)&kDefaultFrame + (const char*)&kDefaultFrame }, - { /* attr: _trk/viewstate */ + { + // attr: _trk/viewstate kAttrViewState_be, B_RAW_TYPE, 49, @@ -213,7 +226,8 @@ const AttributeTemplate kEmailQueryTemplate[] = "\000\000\000\000\000\000\000\000\000\000\366_\377ETIME\000\000\000" "\000\000\000\000\000\000" }, - { /* attr: _trk/columns */ + { + // attr: _trk/columns kAttrColumns_be, B_RAW_TYPE, 222, @@ -234,10 +248,10 @@ namespace BPrivate { class ExtraAttributeLazyInstaller { public: - ExtraAttributeLazyInstaller(const char *type); + ExtraAttributeLazyInstaller(const char* type); ~ExtraAttributeLazyInstaller(); - bool AddExtraAttribute(const char *publicName, const char *name, + bool AddExtraAttribute(const char* publicName, const char* name, uint32 type, bool viewable, bool editable, float width, int32 alignment, bool extra); @@ -251,7 +265,7 @@ public: } // namespace BPrivate -ExtraAttributeLazyInstaller::ExtraAttributeLazyInstaller(const char *type) +ExtraAttributeLazyInstaller::ExtraAttributeLazyInstaller(const char* type) : fMimeType(type), fDirty(false) @@ -269,12 +283,12 @@ ExtraAttributeLazyInstaller::~ExtraAttributeLazyInstaller() bool -ExtraAttributeLazyInstaller::AddExtraAttribute(const char *publicName, - const char *name, uint32 type, bool viewable, bool editable, float width, +ExtraAttributeLazyInstaller::AddExtraAttribute(const char* publicName, + const char* name, uint32 type, bool viewable, bool editable, float width, int32 alignment, bool extra) { for (int32 index = 0; ; index++) { - const char *oldPublicName; + const char* oldPublicName; if (fExtraAttrs.FindString("attr:public_name", index, &oldPublicName) != B_OK) break; @@ -317,7 +331,7 @@ InstallTemporaryBackgroundImages(BNode* node, BMessage* message) static void -AddTemporaryBackgroundImages(BMessage *message, const char *imagePath, +AddTemporaryBackgroundImages(BMessage* message, const char* imagePath, BackgroundImage::Mode mode, BPoint offset, uint32 workspaces, bool textWidgetOutlines) { @@ -336,9 +350,9 @@ AddTemporaryBackgroundImages(BMessage *message, const char *imagePath, #define B_TRANSLATION_CONTEXT "TrackerInitialState" bool -TTracker::InstallMimeIfNeeded(const char *type, int32 bitsID, - const char *shortDescription, const char *longDescription, - const char *preferredAppSignature, uint32 forceMask) +TTracker::InstallMimeIfNeeded(const char* type, int32 bitsID, + const char* shortDescription, const char* longDescription, + const char* preferredAppSignature, uint32 forceMask) { // used by InitMimeTypes - checks if a metamime of a given is // installed and if it has all the specified attributes; if not, the diff --git a/src/kits/tracker/TrackerScripting.cpp b/src/kits/tracker/TrackerScripting.cpp index b59a71da7c..0776e13f08 100644 --- a/src/kits/tracker/TrackerScripting.cpp +++ b/src/kits/tracker/TrackerScripting.cpp @@ -50,7 +50,7 @@ doo Tracker create Folder to '/boot/home/Desktop/hello' ToDo: Create file: on a "Tracker" "File" "B_CREATE_PROPERTY" "name" Create query: on a "Tracker" "Query" "B_CREATE_PROPERTY" "name" -Open a folder: Tracker Execute "Folder" bla +Open a folder: Tracker Execute "Folder" bla Find a window for a path #endif @@ -98,21 +98,21 @@ const property_info kTrackerPropertyList[] = { status_t -TTracker::GetSupportedSuites(BMessage *data) +TTracker::GetSupportedSuites(BMessage* data) { data->AddString("suites", kTrackerSuites); - BPropertyInfo propertyInfo(const_cast(kTrackerPropertyList)); + BPropertyInfo propertyInfo(const_cast(kTrackerPropertyList)); data->AddFlat("messages", &propertyInfo); return _inherited::GetSupportedSuites(data); } -BHandler * -TTracker::ResolveSpecifier(BMessage *message, int32 index, - BMessage *specifier, int32 form, const char *property) +BHandler* +TTracker::ResolveSpecifier(BMessage* message, int32 index, + BMessage* specifier, int32 form, const char* property) { - BPropertyInfo propertyInfo(const_cast(kTrackerPropertyList)); + BPropertyInfo propertyInfo(const_cast(kTrackerPropertyList)); int32 result = propertyInfo.FindMatch(message, index, specifier, form, property); if (result < 0) { @@ -126,7 +126,7 @@ TTracker::ResolveSpecifier(BMessage *message, int32 index, bool -TTracker::HandleScriptingMessage(BMessage *message) +TTracker::HandleScriptingMessage(BMessage* message) { if (message->what != B_GET_PROPERTY && message->what != B_SET_PROPERTY @@ -138,7 +138,7 @@ TTracker::HandleScriptingMessage(BMessage *message) // dispatch scripting messages BMessage reply(B_REPLY); - const char *property = 0; + const char* property = 0; bool handled = false; int32 index = 0; @@ -148,7 +148,7 @@ TTracker::HandleScriptingMessage(BMessage *message) status_t result = message->GetCurrentSpecifier(&index, &specifier, &form, &property); - if (result != B_OK || index == -1) + if (result != B_OK || index == -1) return false; ASSERT(property); @@ -179,17 +179,18 @@ TTracker::HandleScriptingMessage(BMessage *message) break; } - if (handled) + if (handled) { // done handling message, send a reply message->SendReply(&reply); + } return handled; } bool -TTracker::CreateProperty(BMessage *message, BMessage *, int32 form, - const char *property, BMessage *reply) +TTracker::CreateProperty(BMessage* message, BMessage* , int32 form, + const char* property, BMessage* reply) { bool handled = false; status_t error = B_OK; @@ -203,7 +204,7 @@ TTracker::CreateProperty(BMessage *message, BMessage *, int32 form, message->FindRef("data", index, &ref) == B_OK; index++) { BEntry entry(&ref); - if (!entry.Exists()) + if (!entry.Exists()) error = FSCreateNewFolder(&ref); if (error != B_OK) @@ -221,8 +222,8 @@ TTracker::CreateProperty(BMessage *message, BMessage *, int32 form, bool -TTracker::DeleteProperty(BMessage */*specifier*/, int32 form, - const char *property, BMessage */*reply*/) +TTracker::DeleteProperty(BMessage* /*specifier*/, int32 form, + const char* property, BMessage* /*reply*/) { if (strcmp(property, kPropertyTrash) == 0) { // deleting on a selection is handled as removing a part of the selection @@ -237,54 +238,54 @@ TTracker::DeleteProperty(BMessage */*specifier*/, int32 form, return true; } - return false; + return false; } -#else /* _SUPPORTS_FEATURE_SCRIPTING */ +#else // _SUPPORTS_FEATURE_SCRIPTING status_t -TTracker::GetSupportedSuites(BMessage */*data*/) +TTracker::GetSupportedSuites(BMessage* /*data*/) { return B_UNSUPPORTED; } -BHandler * -TTracker::ResolveSpecifier(BMessage */*message*/, - int32 /*index*/, BMessage */*specifier*/, - int32 /*form*/, const char */*property*/) +BHandler* +TTracker::ResolveSpecifier(BMessage* /*message*/, + int32 /*index*/, BMessage* /*specifier*/, + int32 /*form*/, const char* /*property*/) { return NULL; } bool -TTracker::HandleScriptingMessage(BMessage */*message*/) +TTracker::HandleScriptingMessage(BMessage* /*message*/) { return false; } bool -TTracker::CreateProperty(BMessage */*message*/, BMessage *, int32 /*form*/, - const char */*property*/, BMessage */*reply*/) +TTracker::CreateProperty(BMessage* /*message*/, BMessage*, int32 /*form*/, + const char* /*property*/, BMessage* /*reply*/) { return false; } bool -TTracker::DeleteProperty(BMessage */*specifier*/, int32 /*form*/, - const char */*property*/, BMessage *) +TTracker::DeleteProperty(BMessage* /*specifier*/, int32 /*form*/, + const char* /*property*/, BMessage*) { return false; } -#endif /* _SUPPORTS_FEATURE_SCRIPTING */ +#endif // _SUPPORTS_FEATURE_SCRIPTING bool -TTracker::ExecuteProperty(BMessage *, int32 form, const char *property, BMessage *) +TTracker::ExecuteProperty(BMessage*, int32 form, const char* property, BMessage*) { if (strcmp(property, kPropertyPreferences) == 0) { @@ -301,22 +302,21 @@ TTracker::ExecuteProperty(BMessage *, int32 form, const char *property, BMessage bool -TTracker::CountProperty(BMessage *, int32, const char *, BMessage *) +TTracker::CountProperty(BMessage*, int32, const char*, BMessage*) { - return false; + return false; } bool -TTracker::GetProperty(BMessage *, int32, const char *, BMessage *) +TTracker::GetProperty(BMessage*, int32, const char*, BMessage*) { - return false; + return false; } bool -TTracker::SetProperty(BMessage *, BMessage *, int32, const char *, BMessage *) +TTracker::SetProperty(BMessage*, BMessage*, int32, const char*, BMessage*) { - return false; + return false; } - diff --git a/src/kits/tracker/TrackerSettings.cpp b/src/kits/tracker/TrackerSettings.cpp index b63ca2e7bd..3792eae6a6 100644 --- a/src/kits/tracker/TrackerSettings.cpp +++ b/src/kits/tracker/TrackerSettings.cpp @@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include "TrackerSettings.h" #include @@ -42,7 +43,7 @@ All rights reserved. class TTrackerState : public Settings { public: - static TTrackerState *Get(); + static TTrackerState* Get(); void Release(); void LoadSettingsIfNeeded(); @@ -57,32 +58,32 @@ class TTrackerState : public Settings { static void InitIfNeeded(); TTrackerState(const TTrackerState&); - BooleanValueSetting *fShowDisksIcon; - BooleanValueSetting *fMountVolumesOntoDesktop; - BooleanValueSetting *fDesktopFilePanelRoot; - BooleanValueSetting *fMountSharedVolumesOntoDesktop; - BooleanValueSetting *fEjectWhenUnmounting; + BooleanValueSetting* fShowDisksIcon; + BooleanValueSetting* fMountVolumesOntoDesktop; + BooleanValueSetting* fDesktopFilePanelRoot; + BooleanValueSetting* fMountSharedVolumesOntoDesktop; + BooleanValueSetting* fEjectWhenUnmounting; - BooleanValueSetting *fShowFullPathInTitleBar; - BooleanValueSetting *fSingleWindowBrowse; - BooleanValueSetting *fShowNavigator; - BooleanValueSetting *fShowSelectionWhenInactive; - BooleanValueSetting *fTransparentSelection; - BooleanValueSetting *fSortFolderNamesFirst; - BooleanValueSetting *fHideDotFiles; - BooleanValueSetting *fTypeAheadFiltering; + BooleanValueSetting* fShowFullPathInTitleBar; + BooleanValueSetting* fSingleWindowBrowse; + BooleanValueSetting* fShowNavigator; + BooleanValueSetting* fShowSelectionWhenInactive; + BooleanValueSetting* fTransparentSelection; + BooleanValueSetting* fSortFolderNamesFirst; + BooleanValueSetting* fHideDotFiles; + BooleanValueSetting* fTypeAheadFiltering; - ScalarValueSetting *fRecentApplicationsCount; - ScalarValueSetting *fRecentDocumentsCount; - ScalarValueSetting *fRecentFoldersCount; + ScalarValueSetting* fRecentApplicationsCount; + ScalarValueSetting* fRecentDocumentsCount; + ScalarValueSetting* fRecentFoldersCount; - BooleanValueSetting *fShowVolumeSpaceBar; - HexScalarValueSetting *fUsedSpaceColor; - HexScalarValueSetting *fFreeSpaceColor; - HexScalarValueSetting *fWarningSpaceColor; + BooleanValueSetting* fShowVolumeSpaceBar; + HexScalarValueSetting* fUsedSpaceColor; + HexScalarValueSetting* fFreeSpaceColor; + HexScalarValueSetting* fWarningSpaceColor; - BooleanValueSetting *fDontMoveFilesToTrash; - BooleanValueSetting *fAskBeforeDeleteFile; + BooleanValueSetting* fDontMoveFilesToTrash; + BooleanValueSetting* fAskBeforeDeleteFile; Benaphore fInitLock; bool fInited; @@ -455,7 +456,7 @@ TrackerSettings::SetShowNavigator(bool enabled) void -TrackerSettings::RecentCounts(int32 *applications, int32 *documents, int32 *folders) +TrackerSettings::RecentCounts(int32* applications, int32* documents, int32* folders) { if (applications) *applications = gTrackerState.fRecentApplicationsCount->Value(); @@ -513,4 +514,3 @@ TrackerSettings::SetAskBeforeDeleteFile(bool enabled) { gTrackerState.fAskBeforeDeleteFile->SetValue(enabled); } - diff --git a/src/kits/tracker/TrackerSettings.h b/src/kits/tracker/TrackerSettings.h index ed8ae4650e..efec805a58 100644 --- a/src/kits/tracker/TrackerSettings.h +++ b/src/kits/tracker/TrackerSettings.h @@ -31,9 +31,8 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - -#ifndef _TRACKER_SETTINGS_H -#define _TRACKER_SETTINGS_H +#ifndef _TRACKER_SETTINGS_H +#define _TRACKER_SETTINGS_H #include "Utilities.h" @@ -51,7 +50,7 @@ enum FormatSeparator { kDotSeparator, kSeparatorsEnd }; - + enum DateOrder { kYMDFormat, kDMYFormat, @@ -60,12 +59,11 @@ enum DateOrder { }; - class TrackerSettings { public: TrackerSettings(); - //TTrackerState *Settings() const { return fSettings; } + //TTrackerState* Settings() const { return fSettings; } void SaveSettings(bool onlyIfNonDefault = true); bool ShowDisksIcon(); @@ -101,17 +99,18 @@ class TrackerSettings { void SetShowSelectionWhenInactive(bool); bool TransparentSelection(); void SetTransparentSelection(bool); - + bool SingleWindowBrowse(); void SetSingleWindowBrowse(bool); bool ShowNavigator(); void SetShowNavigator(bool); - - void RecentCounts(int32 *applications, int32 *documents, int32 *folders); + + void RecentCounts(int32* applications, int32* documents, + int32* folders); void SetRecentApplicationsCount(int32); void SetRecentDocumentsCount(int32); void SetRecentFoldersCount(int32); - + FormatSeparator TimeFormatSeparator(); void SetTimeFormatSeparator(FormatSeparator); DateOrder DateOrderFormat(); @@ -125,9 +124,9 @@ class TrackerSettings { void SetAskBeforeDeleteFile(bool); private: - //TTrackerState *fSettings; + //TTrackerState* fSettings; }; } // namespace BPrivate -#endif /* _TRACKER_SETTINGS_H */ +#endif // _TRACKER_SETTINGS_H diff --git a/src/kits/tracker/TrackerSettingsWindow.cpp b/src/kits/tracker/TrackerSettingsWindow.cpp index 42cc6904b3..84973a582e 100644 --- a/src/kits/tracker/TrackerSettingsWindow.cpp +++ b/src/kits/tracker/TrackerSettingsWindow.cpp @@ -32,30 +32,30 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include #include #include #include +#include #include "SettingsViews.h" #include "TrackerSettings.h" #include "TrackerSettingsWindow.h" -#include - namespace BPrivate { class SettingsItem : public BStringItem { public: - SettingsItem(const char *label, SettingsView *view); + SettingsItem(const char* label, SettingsView* view); - void DrawItem(BView *owner, BRect rect, bool drawEverything); + void DrawItem(BView* owner, BRect rect, bool drawEverything); - SettingsView *View(); + SettingsView* View(); private: - SettingsView *fSettingsView; + SettingsView* fSettingsView; }; } // namespace BPrivate @@ -149,7 +149,7 @@ TrackerSettingsWindow::QuitRequested() void -TrackerSettingsWindow::MessageReceived(BMessage *message) +TrackerSettingsWindow::MessageReceived(BMessage* message) { switch (message->what) { case kSettingsContentsModified: @@ -195,13 +195,13 @@ TrackerSettingsWindow::Show() } -SettingsView * +SettingsView* TrackerSettingsWindow::_ViewAt(int32 i) { if (!Lock()) return NULL; - SettingsItem *item = dynamic_cast(fSettingsTypeListView->ItemAt(i)); + SettingsItem* item = dynamic_cast(fSettingsTypeListView->ItemAt(i)); Unlock(); @@ -212,7 +212,7 @@ TrackerSettingsWindow::_ViewAt(int32 i) void TrackerSettingsWindow::_HandleChangedContents() { - fSettingsTypeListView->Invalidate(); + fSettingsTypeListView->Invalidate(); _UpdateButtons(); TrackerSettings().SaveSettings(false); @@ -272,18 +272,18 @@ TrackerSettingsWindow::_HandleChangedSettingsView() if (currentSelection < 0) return; - BView *oldView = fSettingsContainerBox->ChildAt(0); + BView* oldView = fSettingsContainerBox->ChildAt(0); if (oldView) oldView->RemoveSelf(); - SettingsItem *selectedItem = + SettingsItem* selectedItem = dynamic_cast(fSettingsTypeListView->ItemAt(currentSelection)); if (selectedItem) { fSettingsContainerBox->SetLabel(selectedItem->Text()); - BView *view = selectedItem->View(); + BView* view = selectedItem->View(); view->SetViewColor(fSettingsContainerBox->ViewColor()); view->Hide(); fSettingsContainerBox->AddChild(view); @@ -296,7 +296,7 @@ TrackerSettingsWindow::_HandleChangedSettingsView() // #pragma mark - -SettingsItem::SettingsItem(const char *label, SettingsView *view) +SettingsItem::SettingsItem(const char* label, SettingsView* view) : BStringItem(label), fSettingsView(view) { @@ -304,7 +304,7 @@ SettingsItem::SettingsItem(const char *label, SettingsView *view) void -SettingsItem::DrawItem(BView *owner, BRect rect, bool drawEverything) +SettingsItem::DrawItem(BView* owner, BRect rect, bool drawEverything) { const rgb_color kModifiedColor = {0, 0, 255, 0}; const rgb_color kBlack = {0, 0, 0, 0}; @@ -314,27 +314,27 @@ SettingsItem::DrawItem(BView *owner, BRect rect, bool drawEverything) bool isRevertable = fSettingsView->IsRevertable(); bool isSelected = IsSelected(); - if (isSelected || drawEverything) { - rgb_color color; - if (isSelected) - color = kSelectedColor; - else - color = owner->ViewColor(); + if (isSelected || drawEverything) { + rgb_color color; + if (isSelected) + color = kSelectedColor; + else + color = owner->ViewColor(); - owner->SetHighColor(color); - owner->SetLowColor(color); - owner->FillRect(rect); + owner->SetHighColor(color); + owner->SetLowColor(color); + owner->FillRect(rect); } if (isRevertable) owner->SetHighColor(kModifiedColor); - else + else owner->SetHighColor(kBlack); font_height fheight; owner->GetFontHeight(&fheight); - owner->DrawString(Text(), BPoint(rect.left + 4, rect.top + owner->DrawString(Text(), BPoint(rect.left + 4, rect.top + fheight.ascent + 2 + floorf(fheight.leading / 2))); owner->SetHighColor(kBlack); @@ -343,7 +343,7 @@ SettingsItem::DrawItem(BView *owner, BRect rect, bool drawEverything) } -SettingsView * +SettingsView* SettingsItem::View() { return fSettingsView; diff --git a/src/kits/tracker/TrackerSettingsWindow.h b/src/kits/tracker/TrackerSettingsWindow.h index 7817ecdf2d..45600cdd3b 100644 --- a/src/kits/tracker/TrackerSettingsWindow.h +++ b/src/kits/tracker/TrackerSettingsWindow.h @@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef TRACKER_SETTINGS_WINDOW_H #define TRACKER_SETTINGS_WINDOW_H + #include #include #include @@ -51,12 +51,11 @@ class TrackerSettingsWindow : public BWindow { TrackerSettingsWindow(); bool QuitRequested(); - void MessageReceived(BMessage *message); + void MessageReceived(BMessage* message); void Show(); - private: - SettingsView *_ViewAt(int32 i); + SettingsView* _ViewAt(int32 i); void _HandleChangedContents(); void _HandlePressedDefaultsButton(); @@ -64,10 +63,10 @@ class TrackerSettingsWindow : public BWindow { void _HandleChangedSettingsView(); void _UpdateButtons(); - BListView *fSettingsTypeListView; - BBox *fSettingsContainerBox; - BButton *fDefaultsButton; - BButton *fRevertButton; + BListView* fSettingsTypeListView; + BBox* fSettingsContainerBox; + BButton* fDefaultsButton; + BButton* fRevertButton; typedef BWindow _inherited; }; diff --git a/src/kits/tracker/TrackerString.cpp b/src/kits/tracker/TrackerString.cpp index 2168ebbe82..14b4291f89 100644 --- a/src/kits/tracker/TrackerString.cpp +++ b/src/kits/tracker/TrackerString.cpp @@ -42,7 +42,7 @@ TrackerString::TrackerString() } -TrackerString::TrackerString(const char *string) +TrackerString::TrackerString(const char* string) : BString(string) { } @@ -54,7 +54,7 @@ TrackerString::TrackerString(const TrackerString &string) } -TrackerString::TrackerString(const char *string, int32 maxLength) +TrackerString::TrackerString(const char* string, int32 maxLength) : BString(string, maxLength) { } @@ -66,7 +66,7 @@ TrackerString::~TrackerString() bool -TrackerString::Matches(const char *string, bool caseSensitivity, +TrackerString::Matches(const char* string, bool caseSensitivity, TrackerStringExpressionType expressionType) const { switch (expressionType) { @@ -93,7 +93,7 @@ TrackerString::Matches(const char *string, bool caseSensitivity, bool -TrackerString::MatchesRegExp(const char *pattern, bool caseSensitivity) const +TrackerString::MatchesRegExp(const char* pattern, bool caseSensitivity) const { BString patternString(pattern); BString textString(String()); @@ -113,14 +113,14 @@ TrackerString::MatchesRegExp(const char *pattern, bool caseSensitivity) const bool -TrackerString::MatchesGlob(const char *string, bool caseSensitivity) const +TrackerString::MatchesGlob(const char* string, bool caseSensitivity) const { return StringMatchesPattern(String(), string, caseSensitivity); } bool -TrackerString::EndsWith(const char *string, bool caseSensitivity) const +TrackerString::EndsWith(const char* string, bool caseSensitivity) const { // If "string" is longer than "this", // we should simply return false @@ -136,17 +136,17 @@ TrackerString::EndsWith(const char *string, bool caseSensitivity) const bool -TrackerString::StartsWith(const char *string, bool caseSensitivity) const +TrackerString::StartsWith(const char* string, bool caseSensitivity) const { if (caseSensitivity) return FindFirst(string) == 0; - else + else return IFindFirst(string) == 0; } bool -TrackerString::Contains(const char *string, bool caseSensitivity) const +TrackerString::Contains(const char* string, bool caseSensitivity) const { if (caseSensitivity) return FindFirst(string) > -1; @@ -175,7 +175,7 @@ TrackerString::FindFirst(const BString &string) const int32 -TrackerString::FindFirst(const char *string) const +TrackerString::FindFirst(const char* string) const { return FindFirst(string, 0); } @@ -189,7 +189,7 @@ TrackerString::FindFirst(const BString &string, int32 fromOffset) const int32 -TrackerString::FindFirst(const char *string, int32 fromOffset) const +TrackerString::FindFirst(const char* string, int32 fromOffset) const { if (!string) return -1; @@ -246,7 +246,7 @@ TrackerString::FindLast(const BString &string) const int32 -TrackerString::FindLast(const char *string) const +TrackerString::FindLast(const char* string) const { return FindLast(string, Length() - 1); } @@ -260,7 +260,7 @@ TrackerString::FindLast(const BString &string, int32 beforeOffset) const int32 -TrackerString::FindLast(const char *string, int32 beforeOffset) const +TrackerString::FindLast(const char* string, int32 beforeOffset) const { if (!string) return -1; @@ -276,7 +276,7 @@ TrackerString::FindLast(const char *string, int32 beforeOffset) const if (stringLength == 0) return beforeOffset; - int32 start = MIN(beforeOffset, length - static_cast(stringLength)); + int32 start = MIN(beforeOffset, length - static_cast(stringLength)); int32 stop = 0; int32 position = -1; @@ -316,7 +316,7 @@ TrackerString::IFindFirst(const BString &string) const int32 -TrackerString::IFindFirst(const char *string) const +TrackerString::IFindFirst(const char* string) const { return IFindFirst(string, 0); } @@ -330,7 +330,7 @@ TrackerString::IFindFirst(const BString &string, int32 fromOffset) const int32 -TrackerString::IFindFirst(const char *string, int32 fromOffset) const +TrackerString::IFindFirst(const char* string, int32 fromOffset) const { if (!string) return -1; @@ -346,7 +346,7 @@ TrackerString::IFindFirst(const char *string, int32 fromOffset) const if (stringLength == 0) return fromOffset; - int32 stop = length - static_cast(stringLength); + int32 stop = length - static_cast(stringLength); int32 start = MAX(0, MIN(fromOffset, stop)); int32 position = -1; @@ -370,7 +370,7 @@ TrackerString::IFindLast(const BString &string) const int32 -TrackerString::IFindLast(const char *string) const +TrackerString::IFindLast(const char* string) const { return IFindLast(string, Length() - 1); } @@ -384,7 +384,7 @@ TrackerString::IFindLast(const BString &string, int32 beforeOffset) const int32 -TrackerString::IFindLast(const char *string, int32 beforeOffset) const +TrackerString::IFindLast(const char* string, int32 beforeOffset) const { if (!string) return -1; @@ -400,7 +400,7 @@ TrackerString::IFindLast(const char *string, int32 beforeOffset) const if (stringLength == 0) return beforeOffset; - int32 start = MIN(beforeOffset, length - static_cast(stringLength)); + int32 start = MIN(beforeOffset, length - static_cast(stringLength)); int32 stop = 0; int32 position = -1; @@ -421,7 +421,7 @@ TrackerString::IFindLast(const char *string, int32 beforeOffset) const // The reason is that an encountered '[' will be taken literally. // (Makes it possible to match a '[' with the expression '[[]'). bool -TrackerString::MatchesBracketExpression(const char *string, const char *pattern, +TrackerString::MatchesBracketExpression(const char* string, const char* pattern, bool caseSensitivity) const { bool GlyphMatch = IsStartOfGlyph(string[0]); @@ -436,7 +436,7 @@ TrackerString::MatchesBracketExpression(const char *string, const char *pattern, // We allow both ^ and ! as a initial inverting character. if (inverse) - pattern++; + pattern++; while (!match && *pattern != ']' && *pattern != '\0') { switch (*pattern) { @@ -473,7 +473,7 @@ TrackerString::MatchesBracketExpression(const char *string, const char *pattern, if (IsInsideGlyph(pattern[0])) pattern = MoveToEndOfGlyph(pattern); } - } + } // Consider an unmatched bracket a failure // (i.e. when detecting a '\0' instead of a ']'.) if (*pattern == '\0') @@ -484,102 +484,108 @@ TrackerString::MatchesBracketExpression(const char *string, const char *pattern, bool -TrackerString::StringMatchesPattern(const char *string, const char *pattern, +TrackerString::StringMatchesPattern(const char* string, const char* pattern, bool caseSensitivity) const { // One could do this dynamically, counting the number of *'s, // but then you have to free them at every exit of this // function, which is awkward and ugly. const int32 kWildCardMaximum = 100; - const char *pStorage[kWildCardMaximum]; - const char *sStorage[kWildCardMaximum]; + const char* pStorage[kWildCardMaximum]; + const char* sStorage[kWildCardMaximum]; int32 patternLevel = 0; - + if (string == NULL || pattern == NULL) return false; - - while (*pattern != '\0') { + while (*pattern != '\0') { switch (*pattern) { - case '?': pattern++; string++; if (IsInsideGlyph(string[0])) string = MoveToEndOfGlyph(string); + break; case '*': - { - // Collapse any ** and *? constructions: - while (*pattern == '*' || *pattern == '?') { - pattern++; - if (*pattern == '?' && string != '\0') { - string++; - if (IsInsideGlyph(string[0])) - string = MoveToEndOfGlyph(string); - } - } - - if (*pattern == '\0') - // An ending * matches all strings. - return true; - - bool match = false; - const char *pBefore = pattern - 1; - - if (*pattern == '[') { - pattern++; - - while (!match && *string != '\0') - match = MatchesBracketExpression(string++, pattern, caseSensitivity); - - // Skip the rest of the bracket: - while (*pattern != ']' && *pattern != '\0') - pattern++; - - // Failure if no closing bracket; - if (*pattern == '\0') - return false; - - } - else { - // No bracket, just one character: - while (!match && *string != '\0') { - if (IsGlyph(string[0])) - match = UTF8CharsAreEqual(string++, pattern); - else - match = CharsAreEqual(*string++, *pattern, caseSensitivity); - } - } - if (!match) - return false; - else { - pStorage[patternLevel] = pBefore; + { + // Collapse any ** and *? constructions: + while (*pattern == '*' || *pattern == '?') { + pattern++; + if (*pattern == '?' && string != '\0') { + string++; if (IsInsideGlyph(string[0])) string = MoveToEndOfGlyph(string); - sStorage[patternLevel++] = string; - if (patternLevel > kWildCardMaximum) - return false; - pattern++; - if (IsInsideGlyph(pattern[0])) - pattern = MoveToEndOfGlyph(pattern); } } - break; + + if (*pattern == '\0') { + // An ending * matches all strings. + return true; + } + + bool match = false; + const char* pBefore = pattern - 1; + + if (*pattern == '[') { + pattern++; + + while (!match && *string != '\0') { + match = MatchesBracketExpression(string++, pattern, + caseSensitivity); + } + + while (*pattern != ']' && *pattern != '\0') { + // Skip the rest of the bracket: + pattern++; + } + + if (*pattern == '\0') { + // Failure if no closing bracket; + return false; + } + } else { + // No bracket, just one character: + while (!match && *string != '\0') { + if (IsGlyph(string[0])) + match = UTF8CharsAreEqual(string++, pattern); + else { + match = CharsAreEqual(*string++, *pattern, + caseSensitivity); + } + } + } + + if (!match) + return false; + else { + pStorage[patternLevel] = pBefore; + if (IsInsideGlyph(string[0])) + string = MoveToEndOfGlyph(string); + + sStorage[patternLevel++] = string; + if (patternLevel > kWildCardMaximum) + return false; + + pattern++; + if (IsInsideGlyph(pattern[0])) + pattern = MoveToEndOfGlyph(pattern); + } + break; + } case '[': pattern++; - - if (!MatchesBracketExpression(string, pattern, caseSensitivity)) + + if (!MatchesBracketExpression(string, pattern, caseSensitivity)) { if (patternLevel > 0) { pattern = pStorage[--patternLevel]; string = sStorage[patternLevel]; } else return false; - else { - + } else { // Skip the rest of the bracket: while (*pattern != ']' && *pattern != '\0') pattern++; @@ -587,78 +593,78 @@ TrackerString::StringMatchesPattern(const char *string, const char *pattern, // Failure if no closing bracket; if (*pattern == '\0') return false; - + string++; if (IsInsideGlyph(string[0])) string = MoveToEndOfGlyph(string); pattern++; } break; - + default: - { - bool equal = false; - if (IsGlyph(string[0])) - equal = UTF8CharsAreEqual(string, pattern); - else - equal = CharsAreEqual(*string, *pattern, caseSensitivity); - - if (equal) { - pattern++; - if (IsInsideGlyph(pattern[0])) - pattern = MoveToEndOfGlyph(pattern); - string++; - if (IsInsideGlyph(string[0])) - string = MoveToEndOfGlyph(string); - } else if (patternLevel > 0) { - pattern = pStorage[--patternLevel]; - string = sStorage[patternLevel]; - } else - return false; - } - break; + { + bool equal = false; + if (IsGlyph(string[0])) + equal = UTF8CharsAreEqual(string, pattern); + else + equal = CharsAreEqual(*string, *pattern, caseSensitivity); + + if (equal) { + pattern++; + if (IsInsideGlyph(pattern[0])) + pattern = MoveToEndOfGlyph(pattern); + string++; + if (IsInsideGlyph(string[0])) + string = MoveToEndOfGlyph(string); + } else if (patternLevel > 0) { + pattern = pStorage[--patternLevel]; + string = sStorage[patternLevel]; + } else + return false; + + break; + } } - + if (*pattern == '\0' && *string != '\0' && patternLevel > 0) { pattern = pStorage[--patternLevel]; string = sStorage[patternLevel]; } } - + return *string == '\0' && *pattern == '\0'; } bool -TrackerString::UTF8CharsAreEqual(const char *string1, const char *string2) const +TrackerString::UTF8CharsAreEqual(const char* string1, const char* string2) const { - const char *s1 = string1; - const char *s2 = string2; - + const char* s1 = string1; + const char* s2 = string2; + if (IsStartOfGlyph(*s1) && *s1 == *s2) { s1++; s2++; - + while (IsInsideGlyph(*s1) && *s1 == *s2) { s1++; s2++; } - + return !IsInsideGlyph(*s1) && !IsInsideGlyph(*s2) && *(s1 - 1) == *(s2 - 1); - } else return false; } -const char * -TrackerString::MoveToEndOfGlyph(const char *string) const +const char* +TrackerString::MoveToEndOfGlyph(const char* string) const { - const char *ptr = string; - + const char* ptr = string; + while (IsInsideGlyph(*ptr)) ptr++; - + return ptr; } diff --git a/src/kits/tracker/TrackerString.h b/src/kits/tracker/TrackerString.h index ed32241ec2..b3df746064 100644 --- a/src/kits/tracker/TrackerString.h +++ b/src/kits/tracker/TrackerString.h @@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef _TRACKER_STRING_H #define _TRACKER_STRING_H + #include #include @@ -42,6 +42,7 @@ All rights reserved. #include "RegExp.h" + namespace BPrivate { enum TrackerStringExpressionType { @@ -53,70 +54,73 @@ enum TrackerStringExpressionType { kRegexpMatch }; -class TrackerString : public BString + +class TrackerString : public BString { public: TrackerString(); - TrackerString(const char *); - TrackerString(const TrackerString &); - TrackerString(const char *, int32 maxLength); + TrackerString(const char*); + TrackerString(const TrackerString&); + TrackerString(const char*, int32 maxLength); ~TrackerString(); - - bool Matches(const char *, bool caseSensitivity = false, + + bool Matches(const char*, bool caseSensitivity = false, TrackerStringExpressionType expressionType = kGlobMatch) const; - bool MatchesRegExp(const char *, bool caseSensitivity = true) const; - bool MatchesRegExp(const RegExp &) const; - bool MatchesRegExp(const RegExp *) const; + bool MatchesRegExp(const char*, bool caseSensitivity = true) const; + bool MatchesRegExp(const RegExp&) const; + bool MatchesRegExp(const RegExp*) const; - bool MatchesGlob(const char *, bool caseSensitivity = false) const; - bool EndsWith(const char *, bool caseSensitivity = false) const; - bool StartsWith(const char *, bool caseSensitivity = false) const; - bool Contains(const char *, bool caseSensitivity = false) const; + bool MatchesGlob(const char*, bool caseSensitivity = false) const; + bool EndsWith(const char*, bool caseSensitivity = false) const; + bool StartsWith(const char*, bool caseSensitivity = false) const; + bool Contains(const char*, bool caseSensitivity = false) const; - int32 FindFirst(const BString &) const; - int32 FindFirst(const char *) const; - int32 FindFirst(const BString &, int32 fromOffset) const; - int32 FindFirst(const char *, int32 fromOffset) const; + int32 FindFirst(const BString&) const; + int32 FindFirst(const char*) const; + int32 FindFirst(const BString&, int32 fromOffset) const; + int32 FindFirst(const char*, int32 fromOffset) const; int32 FindFirst(char) const; int32 FindFirst(char, int32 fromOffset) const; - int32 FindLast(const BString &) const; - int32 FindLast(const char *) const; - int32 FindLast(const BString &, int32 beforeOffset) const; - int32 FindLast(const char *, int32 beforeOffset) const; + int32 FindLast(const BString&) const; + int32 FindLast(const char*) const; + int32 FindLast(const BString&, int32 beforeOffset) const; + int32 FindLast(const char*, int32 beforeOffset) const; int32 FindLast(char) const; int32 FindLast(char, int32 beforeOffset) const; - int32 IFindFirst(const BString &) const; - int32 IFindFirst(const char *) const; - int32 IFindFirst(const BString &, int32 fromOffset) const; - int32 IFindFirst(const char *, int32 fromOffset) const; + int32 IFindFirst(const BString&) const; + int32 IFindFirst(const char*) const; + int32 IFindFirst(const BString&, int32 fromOffset) const; + int32 IFindFirst(const char*, int32 fromOffset) const; - int32 IFindLast(const BString &) const; - int32 IFindLast(const char *) const; - int32 IFindLast(const BString &, int32 beforeOffset) const; - int32 IFindLast(const char *, int32 beforeOffset) const; + int32 IFindLast(const BString&) const; + int32 IFindLast(const char*) const; + int32 IFindLast(const BString&, int32 beforeOffset) const; + int32 IFindLast(const char*, int32 beforeOffset) const; private: bool IsGlyph(char) const; - bool IsInsideGlyph(char) const; // Not counting start! + bool IsInsideGlyph(char) const; + // Not counting start! bool IsStartOfGlyph(char) const; - const char *MoveToEndOfGlyph(const char *) const; + const char* MoveToEndOfGlyph(const char*) const; // Functions for Glob matching: - bool MatchesBracketExpression(const char *string, const char *pattern, + bool MatchesBracketExpression(const char* string, const char* pattern, bool caseSensitivity) const; - bool StringMatchesPattern(const char *string, const char *pattern, + bool StringMatchesPattern(const char* string, const char* pattern, bool caseSensitivity) const; char ConditionalToLower(char c, bool toLower) const; - bool CharsAreEqual(char char1, char char2, bool toLower) const; - bool UTF8CharsAreEqual(const char *string1, const char *string2) const; + bool CharsAreEqual(char char1, char char2, bool toLower) const; + bool UTF8CharsAreEqual(const char* string1, const char* string2) const; }; + inline bool -TrackerString::MatchesRegExp(const RegExp *expression) const +TrackerString::MatchesRegExp(const RegExp* expression) const { if (expression == NULL || expression->InitCheck() != B_OK) return false; @@ -124,30 +128,33 @@ TrackerString::MatchesRegExp(const RegExp *expression) const return expression->Matches(*this); } + inline bool TrackerString::MatchesRegExp(const RegExp &expression) const { if (expression.InitCheck() != B_OK) return false; - return expression.Matches(*this); + return expression.Matches(*this); } + inline char TrackerString::ConditionalToLower(char c, bool caseSensitivity) const { return caseSensitivity ? c : (char)tolower(c); -} +} + inline bool TrackerString::CharsAreEqual(char char1, char char2, bool caseSensitivity) const { return ConditionalToLower(char1, caseSensitivity) == ConditionalToLower(char2, caseSensitivity); -} +} } // namespace BPrivate using namespace BPrivate; -#endif +#endif // _TRACKER_STRING_H diff --git a/src/kits/tracker/TrashWatcher.cpp b/src/kits/tracker/TrashWatcher.cpp index 145f1235b1..6decfe2290 100644 --- a/src/kits/tracker/TrashWatcher.cpp +++ b/src/kits/tracker/TrashWatcher.cpp @@ -70,11 +70,11 @@ BTrashWatcher::~BTrashWatcher() bool -BTrashWatcher::IsTrashNode(const node_ref *testNode) const +BTrashWatcher::IsTrashNode(const node_ref* testNode) const { int32 count = fTrashNodeList.CountItems(); for (int32 index = 0; index < count; index++) { - node_ref *nref = fTrashNodeList.ItemAt(index); + node_ref* nref = fTrashNodeList.ItemAt(index); if (nref->node == testNode->node && nref->device == testNode->device) return true; } @@ -84,7 +84,7 @@ BTrashWatcher::IsTrashNode(const node_ref *testNode) const void -BTrashWatcher::MessageReceived(BMessage *message) +BTrashWatcher::MessageReceived(BMessage* message) { if (message->what != B_NODE_MONITOR) { _inherited::MessageReceived(message); @@ -109,12 +109,8 @@ BTrashWatcher::MessageReceived(BMessage *message) message->FindInt64("to directory", &toDir); if (fromDir == toDir) break; - } - // fall thru - - case B_DEVICE_UNMOUNTED: - // fall thru - + } // fall thru + case B_DEVICE_UNMOUNTED: // fall thru case B_ENTRY_REMOVED: { bool full = CheckTrashDirs(); @@ -153,7 +149,7 @@ void BTrashWatcher::UpdateTrashIcons() { BVolumeRoster roster; - BVolume volume; + BVolume volume; roster.Rewind(); BDirectory trashDir; @@ -163,35 +159,35 @@ BTrashWatcher::UpdateTrashIcons() // apply them onto the trash directory node size_t largeSize = 0; size_t smallSize = 0; - const void *largeData = GetTrackerResources()->LoadResource('ICON', + const void* largeData = GetTrackerResources()->LoadResource('ICON', fTrashFull ? R_TrashFullIcon : R_TrashIcon, &largeSize); - - const void *smallData = GetTrackerResources()->LoadResource('MICN', + + const void* smallData = GetTrackerResources()->LoadResource('MICN', fTrashFull ? R_TrashFullIcon : R_TrashIcon, &smallSize); - + #ifdef HAIKU_TARGET_PLATFORM_HAIKU size_t vectorSize = 0; - const void *vectorData = GetTrackerResources()->LoadResource( + const void* vectorData = GetTrackerResources()->LoadResource( B_VECTOR_ICON_TYPE, fTrashFull ? R_TrashFullIcon : R_TrashIcon, &vectorSize); - if (vectorData) + if (vectorData) { trashDir.WriteAttr(kAttrIcon, B_VECTOR_ICON_TYPE, 0, vectorData, vectorSize); - else + } else TRESPASS(); #endif - - if (largeData) + + if (largeData) { trashDir.WriteAttr(kAttrLargeIcon, 'ICON', 0, largeData, largeSize); - else + } else TRESPASS(); - if (smallData) + if (smallData) { trashDir.WriteAttr(kAttrMiniIcon, 'MICN', 0, smallData, smallSize); - else + } else TRESPASS(); } } diff --git a/src/kits/tracker/TrashWatcher.h b/src/kits/tracker/TrashWatcher.h index d252eaea57..789666a9a4 100644 --- a/src/kits/tracker/TrashWatcher.h +++ b/src/kits/tracker/TrashWatcher.h @@ -31,13 +31,14 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - -#ifndef _TRASH_WATCHER_H +#ifndef _TRASH_WATCHER_H #define _TRASH_WATCHER_H + #include #include "ObjectList.h" + namespace BPrivate { class BTrashWatcher : public BLooper { @@ -48,10 +49,10 @@ public: virtual ~BTrashWatcher(); bool CheckTrashDirs(); - bool IsTrashNode(const node_ref *) const; + bool IsTrashNode(const node_ref*) const; protected: - virtual void MessageReceived(BMessage *); + virtual void MessageReceived(BMessage*); private: void WatchTrashDirs(); @@ -67,4 +68,4 @@ private: using namespace BPrivate; -#endif +#endif // _TRASH_WATCHER_H diff --git a/src/kits/tracker/Utilities.cpp b/src/kits/tracker/Utilities.cpp index 4d37dc9e93..17020a289a 100644 --- a/src/kits/tracker/Utilities.cpp +++ b/src/kits/tracker/Utilities.cpp @@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include "Attributes.h" #include "MimeTypes.h" #include "Model.h" @@ -71,7 +72,7 @@ extern _IMPEXP_BE const uint32 LARGE_ICON_TYPE; extern _IMPEXP_BE const uint32 MINI_ICON_TYPE; -FILE *logFile = NULL; +FILE* logFile = NULL; static const float kMinSeparatorStubX = 10; static const float kStubToStringSlotX = 5; @@ -86,7 +87,7 @@ bool gLocalizedNamePreferred; uint32 -HashString(const char *string, uint32 seed) +HashString(const char* string, uint32 seed) { char ch; uint32 result = seed; @@ -102,7 +103,7 @@ HashString(const char *string, uint32 seed) uint32 -AttrHashString(const char *string, uint32 type) +AttrHashString(const char* string, uint32 type) { char c; uint32 hash = 0; @@ -122,7 +123,7 @@ AttrHashString(const char *string, uint32 type) bool -ValidateStream(BMallocIO *stream, uint32 key, int32 version) +ValidateStream(BMallocIO* stream, uint32 key, int32 version) { uint32 testKey; int32 testVersion; @@ -136,14 +137,14 @@ ValidateStream(BMallocIO *stream, uint32 key, int32 version) void -DisallowFilenameKeys(BTextView *textView) +DisallowFilenameKeys(BTextView* textView) { textView->DisallowChar('/'); } void -DisallowMetaKeys(BTextView *textView) +DisallowMetaKeys(BTextView* textView) { textView->DisallowChar(B_TAB); textView->DisallowChar(B_ESCAPE); @@ -174,10 +175,10 @@ PeriodicUpdatePoses::~PeriodicUpdatePoses() void -PeriodicUpdatePoses::AddPose(BPose *pose, BPoseView *poseView, - PeriodicUpdateCallback callback, void *cookie) +PeriodicUpdatePoses::AddPose(BPose* pose, BPoseView* poseView, + PeriodicUpdateCallback callback, void* cookie) { - periodic_pose *periodic = new periodic_pose; + periodic_pose* periodic = new periodic_pose; periodic->pose = pose; periodic->pose_view = poseView; periodic->callback = callback; @@ -187,7 +188,7 @@ PeriodicUpdatePoses::AddPose(BPose *pose, BPoseView *poseView, bool -PeriodicUpdatePoses::RemovePose(BPose *pose, void **cookie) +PeriodicUpdatePoses::RemovePose(BPose* pose, void** cookie) { int32 count = fPoseList.CountItems(); for (int32 index = 0; index < count; index++) { @@ -195,7 +196,7 @@ PeriodicUpdatePoses::RemovePose(BPose *pose, void **cookie) if (!fLock->Lock()) return false; - periodic_pose *periodic = fPoseList.RemoveItemAt(index); + periodic_pose* periodic = fPoseList.RemoveItemAt(index); if (cookie) *cookie = periodic->cookie; delete periodic; @@ -216,7 +217,7 @@ PeriodicUpdatePoses::DoPeriodicUpdate(bool forceRedraw) int32 count = fPoseList.CountItems(); for (int32 index = 0; index < count; index++) { - periodic_pose *periodic = fPoseList.ItemAt(index); + periodic_pose* periodic = fPoseList.ItemAt(index); if (periodic->callback(periodic->pose, periodic->cookie) || forceRedraw) { periodic->pose_view->LockLooper(); @@ -236,9 +237,9 @@ PeriodicUpdatePoses gPeriodicUpdatePoses; void -PoseInfo::EndianSwap(void *castToThis) +PoseInfo::EndianSwap(void* castToThis) { - PoseInfo *self = (PoseInfo *)castToThis; + PoseInfo* self = (PoseInfo*)castToThis; PRINT(("swapping PoseInfo\n")); @@ -349,9 +350,9 @@ ExtendedPoseInfo::SetLocationForFrame(BPoint newLocation, BRect frame) void -ExtendedPoseInfo::EndianSwap(void *castToThis) +ExtendedPoseInfo::EndianSwap(void* castToThis) { - ExtendedPoseInfo *self = (ExtendedPoseInfo *)castToThis; + ExtendedPoseInfo* self = (ExtendedPoseInfo *)castToThis; PRINT(("swapping ExtendedPoseInfo\n")); @@ -412,7 +413,7 @@ OffscreenBitmap::NewBitmap(BRect bounds) delete fBitmap; fBitmap = new(std::nothrow) BBitmap(bounds, B_RGB32, true); if (fBitmap && fBitmap->Lock()) { - BView *view = new BView(fBitmap->Bounds(), "", B_FOLLOW_NONE, 0); + BView* view = new BView(fBitmap->Bounds(), "", B_FOLLOW_NONE, 0); fBitmap->AddChild(view); BRect clipRect = view->Bounds(); @@ -428,7 +429,7 @@ OffscreenBitmap::NewBitmap(BRect bounds) } -BView * +BView* OffscreenBitmap::BeginUsing(BRect frame) { if (!fBitmap || fBitmap->Bounds() != frame) @@ -446,7 +447,7 @@ OffscreenBitmap::DoneUsing() } -BBitmap * +BBitmap* OffscreenBitmap::Bitmap() const { ASSERT(fBitmap); @@ -455,7 +456,7 @@ OffscreenBitmap::Bitmap() const } -BView * +BView* OffscreenBitmap::View() const { ASSERT(fBitmap); @@ -468,12 +469,11 @@ OffscreenBitmap::View() const namespace BPrivate { -/*! Changes the alpha value of the given bitmap to create a nice - horizontal fade out in the specified region. - "from" is always transparent, "to" opaque. -*/ +// Changes the alpha value of the given bitmap to create a nice +// horizontal fade out in the specified region. +// "from" is always transparent, "to" opaque. void -FadeRGBA32Horizontal(uint32 *bits, int32 width, int32 height, int32 from, +FadeRGBA32Horizontal(uint32* bits, int32 width, int32 height, int32 from, int32 to) { // check parameters @@ -507,7 +507,7 @@ FadeRGBA32Horizontal(uint32 *bits, int32 width, int32 height, int32 from, "from" is always transparent, "to" opaque. */ void -FadeRGBA32Vertical(uint32 *bits, int32 width, int32 height, int32 from, +FadeRGBA32Vertical(uint32* bits, int32 width, int32 height, int32 from, int32 to) { // check parameters @@ -545,8 +545,8 @@ FadeRGBA32Vertical(uint32 *bits, int32 width, int32 height, int32 from, // #pragma mark - -DraggableIcon::DraggableIcon(BRect rect, const char *name, const char *mimeType, - icon_size size, const BMessage *message, BMessenger target, +DraggableIcon::DraggableIcon(BRect rect, const char* name, const char* mimeType, + icon_size size, const BMessage* message, BMessenger target, uint32 resizeMask, uint32 flags) : BView(rect, name, resizeMask, flags), @@ -591,7 +591,7 @@ DraggableIcon::PreferredRect(BPoint offset, icon_size size) void DraggableIcon::AttachedToWindow() { - BView *parent = Parent(); + BView* parent = Parent(); if (parent != NULL) { SetViewColor(parent->ViewColor()); SetLowColor(parent->LowColor()); @@ -606,9 +606,9 @@ DraggableIcon::MouseDown(BPoint point) return; BRect rect(Bounds()); - BBitmap *dragBitmap = new BBitmap(rect, B_RGBA32, true); + BBitmap* dragBitmap = new BBitmap(rect, B_RGBA32, true); dragBitmap->Lock(); - BView *view = new BView(dragBitmap->Bounds(), "", B_FOLLOW_NONE, 0); + BView* view = new BView(dragBitmap->Bounds(), "", B_FOLLOW_NONE, 0); dragBitmap->AddChild(view); view->SetOrigin(0, 0); BRect clipRect(view->Bounds()); @@ -631,7 +631,7 @@ DraggableIcon::MouseDown(BPoint point) bool -DraggableIcon::DragStarted(BMessage *) +DraggableIcon::DragStarted(BMessage*) { return true; } @@ -649,8 +649,8 @@ DraggableIcon::Draw(BRect) // #pragma mark - -FlickerFreeStringView::FlickerFreeStringView(BRect bounds, const char *name, - const char *text, uint32 resizeFlags, uint32 flags) +FlickerFreeStringView::FlickerFreeStringView(BRect bounds, const char* name, + const char* text, uint32 resizeFlags, uint32 flags) : BStringView(bounds, name, text, resizeFlags, flags), fBitmap(NULL), @@ -659,8 +659,8 @@ FlickerFreeStringView::FlickerFreeStringView(BRect bounds, const char *name, } -FlickerFreeStringView::FlickerFreeStringView(BRect bounds, const char *name, - const char *text, BBitmap *inBitmap, uint32 resizeFlags, uint32 flags) +FlickerFreeStringView::FlickerFreeStringView(BRect bounds, const char* name, + const char* text, BBitmap* inBitmap, uint32 resizeFlags, uint32 flags) : BStringView(bounds, name, text, resizeFlags, flags), fBitmap(NULL), @@ -682,7 +682,7 @@ FlickerFreeStringView::Draw(BRect) if (!fBitmap) fBitmap = new OffscreenBitmap(Bounds()); - BView *offscreen = fBitmap->BeginUsing(bounds); + BView* offscreen = fBitmap->BeginUsing(bounds); if (Parent()) { fViewColor = Parent()->ViewColor(); @@ -785,7 +785,7 @@ FlickerFreeStringView::SetLowColor(rgb_color color) // #pragma mark - -TitledSeparatorItem::TitledSeparatorItem(const char *label) +TitledSeparatorItem::TitledSeparatorItem(const char* label) : BMenuItem(label, 0) { @@ -806,7 +806,7 @@ TitledSeparatorItem::SetEnabled(bool) void -TitledSeparatorItem::GetContentSize(float *width, float *height) +TitledSeparatorItem::GetContentSize(float* width, float* height) { _inherited::GetContentSize(width, height); } @@ -824,7 +824,7 @@ TitledSeparatorItem::Draw() { BRect frame(Frame()); - BMenu *parent = Menu(); + BMenu* parent = Menu(); ASSERT(parent); menu_info minfo; @@ -918,7 +918,7 @@ TitledSeparatorItem::Draw() ShortcutFilter::ShortcutFilter(uint32 shortcutKey, uint32 shortcutModifier, - uint32 shortcutWhat, BHandler *target) + uint32 shortcutWhat, BHandler* target) : BMessageFilter(B_KEY_DOWN), fShortcutKey(shortcutKey), @@ -930,7 +930,7 @@ ShortcutFilter::ShortcutFilter(uint32 shortcutKey, uint32 shortcutModifier, filter_result -ShortcutFilter::Filter(BMessage *message, BHandler **) +ShortcutFilter::Filter(BMessage* message, BHandler**) { if (message->what == B_KEY_DOWN) { uint32 modifiers; @@ -938,9 +938,9 @@ ShortcutFilter::Filter(BMessage *message, BHandler **) uint8 byte = 0; int32 key = 0; - if (message->FindInt32("modifiers", (int32 *)&modifiers) != B_OK - || message->FindInt32("raw_char", (int32 *)&rawKeyChar) != B_OK - || message->FindInt8("byte", (int8 *)&byte) != B_OK + if (message->FindInt32("modifiers", (int32*)&modifiers) != B_OK + || message->FindInt32("raw_char", (int32*)&rawKeyChar) != B_OK + || message->FindInt8("byte", (int8*)&byte) != B_OK || message->FindInt32("key", &key) != B_OK) return B_DISPATCH_MESSAGE; @@ -966,7 +966,7 @@ namespace BPrivate { void -EmbedUniqueVolumeInfo(BMessage *message, const BVolume *volume) +EmbedUniqueVolumeInfo(BMessage* message, const BVolume* volume) { BDirectory rootDirectory; time_t created; @@ -985,7 +985,7 @@ EmbedUniqueVolumeInfo(BMessage *message, const BVolume *volume) status_t -MatchArchivedVolume(BVolume *result, const BMessage *message, int32 index) +MatchArchivedVolume(BVolume* result, const BMessage* message, int32 index) { time_t created; off_t capacity; @@ -1069,7 +1069,7 @@ MatchArchivedVolume(BVolume *result, const BMessage *message, int32 index) void -StringFromStream(BString *string, BMallocIO *stream, bool endianSwap) +StringFromStream(BString* string, BMallocIO* stream, bool endianSwap) { int32 length; stream->Read(&length, sizeof(length)); @@ -1083,14 +1083,14 @@ StringFromStream(BString *string, BMallocIO *stream, bool endianSwap) return; } - char *buffer = string->LockBuffer(length + 1); + char* buffer = string->LockBuffer(length + 1); stream->Read(buffer, (size_t)length + 1); string->UnlockBuffer(length); } void -StringToStream(const BString *string, BMallocIO *stream) +StringToStream(const BString* string, BMallocIO* stream) { int32 length = string->Length(); stream->Write(&length, sizeof(int32)); @@ -1099,14 +1099,14 @@ StringToStream(const BString *string, BMallocIO *stream) int32 -ArchiveSize(const BString *string) +ArchiveSize(const BString* string) { return string->Length() + 1 + (ssize_t)sizeof(int32); } int32 -CountRefs(const BMessage *message) +CountRefs(const BMessage* message) { uint32 type; int32 count; @@ -1116,9 +1116,9 @@ CountRefs(const BMessage *message) } -static entry_ref * -EachEntryRefCommon(BMessage *message, entry_ref *(*func)(entry_ref *, void *), - void *passThru, int32 maxCount) +static entry_ref* +EachEntryRefCommon(BMessage* message, entry_ref *(*func)(entry_ref*, void*), + void* passThru, int32 maxCount) { uint32 type; int32 count; @@ -1130,7 +1130,7 @@ EachEntryRefCommon(BMessage *message, entry_ref *(*func)(entry_ref *, void *), for (int32 index = 0; index < count; index++) { entry_ref ref; message->FindRef("refs", index, &ref); - entry_ref *result = (func)(&ref, passThru); + entry_ref* result = (func)(&ref, passThru); if (result) return result; } @@ -1140,7 +1140,7 @@ EachEntryRefCommon(BMessage *message, entry_ref *(*func)(entry_ref *, void *), bool -ContainsEntryRef(const BMessage *message, const entry_ref *ref) +ContainsEntryRef(const BMessage* message, const entry_ref* ref) { entry_ref match; for (int32 index = 0; (message->FindRef("refs", index, &match) == B_OK); @@ -1153,35 +1153,36 @@ ContainsEntryRef(const BMessage *message, const entry_ref *ref) } -entry_ref * -EachEntryRef(BMessage *message, entry_ref *(*func)(entry_ref *, void *), - void *passThru) +entry_ref* +EachEntryRef(BMessage* message, entry_ref* (*func)(entry_ref*, void*), + void* passThru) { return EachEntryRefCommon(message, func, passThru, -1); } typedef entry_ref *(*EachEntryIteratee)(entry_ref *, void *); -const entry_ref * -EachEntryRef(const BMessage *message, - const entry_ref *(*func)(const entry_ref *, void *), void *passThru) + +const entry_ref* +EachEntryRef(const BMessage* message, + const entry_ref* (*func)(const entry_ref*, void*), void* passThru) { - return EachEntryRefCommon(const_cast(message), + return EachEntryRefCommon(const_cast(message), (EachEntryIteratee)func, passThru, -1); } -entry_ref * -EachEntryRef(BMessage *message, entry_ref *(*func)(entry_ref *, void *), - void *passThru, int32 maxCount) +entry_ref* +EachEntryRef(BMessage* message, entry_ref* (*func)(entry_ref*, void*), + void* passThru, int32 maxCount) { return EachEntryRefCommon(message, func, passThru, maxCount); } const entry_ref * -EachEntryRef(const BMessage *message, - const entry_ref *(*func)(const entry_ref *, void *), void *passThru, +EachEntryRef(const BMessage* message, + const entry_ref *(*func)(const entry_ref *, void *), void* passThru, int32 maxCount) { return EachEntryRefCommon(const_cast(message), @@ -1190,7 +1191,7 @@ EachEntryRef(const BMessage *message, void -TruncateLeaf(BString *string) +TruncateLeaf(BString* string) { for (int32 index = string->Length(); index >= 0; index--) { if ((*string)[index] == '/') { @@ -1202,12 +1203,12 @@ TruncateLeaf(BString *string) int64 -StringToScalar(const char *text) +StringToScalar(const char* text) { - char *end; + char* end; int64 val; - char *buffer = new char [strlen(text) + 1]; + char* buffer = new char [strlen(text) + 1]; strcpy(buffer, text); if (strstr(buffer, "k") || strstr(buffer, "K")) { @@ -1248,7 +1249,7 @@ LineBounds(BPoint where, float length, bool vertical) SeparatorLine::SeparatorLine(BPoint where, float length, bool vertical, - const char *name) + const char* name) : BView(LineBounds(where, length, vertical), name, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW) @@ -1280,11 +1281,11 @@ SeparatorLine::Draw(BRect) void -HexDump(const void *buf, int32 length) +HexDump(const void* buf, int32 length) { const int32 kBytesPerLine = 16; int32 offset; - unsigned char *buffer = (unsigned char *)buf; + unsigned char* buffer = (unsigned char*)buf; for (offset = 0; ; offset += kBytesPerLine, buffer += kBytesPerLine) { int32 remain = length; @@ -1318,53 +1319,53 @@ HexDump(const void *buf, int32 length) void -EnableNamedMenuItem(BMenu *menu, const char *itemName, bool on) +EnableNamedMenuItem(BMenu* menu, const char* itemName, bool on) { - BMenuItem *item = menu->FindItem(itemName); + BMenuItem* item = menu->FindItem(itemName); if (item) item->SetEnabled(on); } void -MarkNamedMenuItem(BMenu *menu, const char *itemName, bool on) +MarkNamedMenuItem(BMenu* menu, const char* itemName, bool on) { - BMenuItem *item = menu->FindItem(itemName); + BMenuItem* item = menu->FindItem(itemName); if (item) item->SetMarked(on); } void -EnableNamedMenuItem(BMenu *menu, uint32 commandName, bool on) +EnableNamedMenuItem(BMenu* menu, uint32 commandName, bool on) { - BMenuItem *item = menu->FindItem(commandName); + BMenuItem* item = menu->FindItem(commandName); if (item) item->SetEnabled(on); } void -MarkNamedMenuItem(BMenu *menu, uint32 commandName, bool on) +MarkNamedMenuItem(BMenu* menu, uint32 commandName, bool on) { - BMenuItem *item = menu->FindItem(commandName); + BMenuItem* item = menu->FindItem(commandName); if (item) item->SetMarked(on); } void -DeleteSubmenu(BMenuItem *submenuItem) +DeleteSubmenu(BMenuItem* submenuItem) { if (!submenuItem) return; - BMenu *menu = submenuItem->Submenu(); + BMenu* menu = submenuItem->Submenu(); if (!menu) return; for (;;) { - BMenuItem *item = menu->RemoveItem((int32)0); + BMenuItem* item = menu->RemoveItem((int32)0); if (!item) return; @@ -1374,7 +1375,7 @@ DeleteSubmenu(BMenuItem *submenuItem) status_t -GetAppSignatureFromAttr(BFile *file, char *result) +GetAppSignatureFromAttr(BFile* file, char* result) { // This call is a performance improvement that // avoids using the BAppFileInfo API when retrieving the @@ -1397,7 +1398,7 @@ GetAppSignatureFromAttr(BFile *file, char *result) status_t -GetAppIconFromAttr(BFile *file, BBitmap *result, icon_size size) +GetAppIconFromAttr(BFile* file, BBitmap* result, icon_size size) { // This call is a performance improvement that // avoids using the BAppFileInfo API when retrieving the @@ -1409,7 +1410,7 @@ GetAppIconFromAttr(BFile *file, BBitmap *result, icon_size size) return appFileInfo.GetIcon(result, size); //#else // -// const char *attrName = kAttrIcon; +// const char* attrName = kAttrIcon; // uint32 type = B_VECTOR_ICON_TYPE; // // // try vector icon @@ -1452,7 +1453,7 @@ GetAppIconFromAttr(BFile *file, BBitmap *result, icon_size size) status_t -GetFileIconFromAttr(BNode *file, BBitmap *result, icon_size size) +GetFileIconFromAttr(BNode* file, BBitmap* result, icon_size size) { BNodeInfo fileInfo(file); return fileInfo.GetIcon(result, size); @@ -1467,18 +1468,18 @@ PrintToStream(rgb_color color) } -extern BMenuItem * -EachMenuItem(BMenu *menu, bool recursive, BMenuItem *(*func)(BMenuItem *)) +extern BMenuItem* +EachMenuItem(BMenu* menu, bool recursive, BMenuItem* (*func)(BMenuItem *)) { int32 count = menu->CountItems(); for (int32 index = 0; index < count; index++) { - BMenuItem *item = menu->ItemAt(index); - BMenuItem *result = (func)(item); + BMenuItem* item = menu->ItemAt(index); + BMenuItem* result = (func)(item); if (result) return result; if (recursive) { - BMenu *submenu = menu->SubmenuAt(index); + BMenu* submenu = menu->SubmenuAt(index); if (submenu) return EachMenuItem(submenu, true, func); } @@ -1488,19 +1489,19 @@ EachMenuItem(BMenu *menu, bool recursive, BMenuItem *(*func)(BMenuItem *)) } -extern const BMenuItem * -EachMenuItem(const BMenu *menu, bool recursive, - BMenuItem *(*func)(const BMenuItem *)) +extern const BMenuItem* +EachMenuItem(const BMenu* menu, bool recursive, + BMenuItem* (*func)(const BMenuItem *)) { int32 count = menu->CountItems(); for (int32 index = 0; index < count; index++) { - BMenuItem *item = menu->ItemAt(index); - BMenuItem *result = (func)(item); + BMenuItem* item = menu->ItemAt(index); + BMenuItem* result = (func)(item); if (result) return result; if (recursive) { - BMenu *submenu = menu->SubmenuAt(index); + BMenu* submenu = menu->SubmenuAt(index); if (submenu) return EachMenuItem(submenu, true, func); } @@ -1510,15 +1511,15 @@ EachMenuItem(const BMenu *menu, bool recursive, } -PositionPassingMenuItem::PositionPassingMenuItem(const char *title, - BMessage *message, char shortcut, uint32 modifiers) +PositionPassingMenuItem::PositionPassingMenuItem(const char* title, + BMessage* message, char shortcut, uint32 modifiers) : BMenuItem(title, message, shortcut, modifiers) { } -PositionPassingMenuItem::PositionPassingMenuItem(BMenu *menu, BMessage *message) +PositionPassingMenuItem::PositionPassingMenuItem(BMenu* menu, BMessage* message) : BMenuItem(menu, message) { @@ -1526,7 +1527,7 @@ PositionPassingMenuItem::PositionPassingMenuItem(BMenu *menu, BMessage *message) status_t -PositionPassingMenuItem::Invoke(BMessage *message) +PositionPassingMenuItem::Invoke(BMessage* message) { if (!Menu()) return B_ERROR; @@ -1547,7 +1548,7 @@ PositionPassingMenuItem::Invoke(BMessage *message) // embed the invoke location of the menu so that we can create // a new folder, etc. on the spot - BMenu *menu = Menu(); + BMenu* menu = Menu(); for (;;) { if (!menu->Supermenu()) @@ -1557,7 +1558,7 @@ PositionPassingMenuItem::Invoke(BMessage *message) // use the window position only, if the item was invoked from the menu // menu->Window() points to the window the item was invoked from - if (dynamic_cast(menu->Window()) == NULL) { + if (dynamic_cast(menu->Window()) == NULL) { LooperAutoLocker lock(menu); if (lock.IsLocked()) { BPoint invokeOrigin(menu->Window()->Frame().LeftTop()); @@ -1572,13 +1573,13 @@ PositionPassingMenuItem::Invoke(BMessage *message) bool BootedInSafeMode() { - const char *safeMode = getenv("SAFEMODE"); + const char* safeMode = getenv("SAFEMODE"); return (safeMode && strcmp(safeMode, "yes") == 0); } float -ComputeTypeAheadScore(const char *text, const char *match, bool wordMode) +ComputeTypeAheadScore(const char* text, const char* match, bool wordMode) { // highest score: exact match const char* found = strcasestr(text, match); @@ -1627,7 +1628,7 @@ ComputeTypeAheadScore(const char *text, const char *match, bool wordMode) void -_ThrowOnError(status_t error, const char *DEBUG_ONLY(file), +_ThrowOnError(status_t error, const char* DEBUG_ONLY(file), int32 DEBUG_ONLY(line)) { if (error != B_OK) { @@ -1638,7 +1639,7 @@ _ThrowOnError(status_t error, const char *DEBUG_ONLY(file), void -_ThrowIfNotSize(ssize_t size, const char *DEBUG_ONLY(file), +_ThrowIfNotSize(ssize_t size, const char* DEBUG_ONLY(file), int32 DEBUG_ONLY(line)) { if (size < B_OK) { @@ -1649,8 +1650,8 @@ _ThrowIfNotSize(ssize_t size, const char *DEBUG_ONLY(file), void -_ThrowOnError(status_t error, const char *DEBUG_ONLY(debugString), - const char *DEBUG_ONLY(file), int32 DEBUG_ONLY(line)) +_ThrowOnError(status_t error, const char* DEBUG_ONLY(debugString), + const char* DEBUG_ONLY(file), int32 DEBUG_ONLY(line)) { if (error != B_OK) { PRINT(("failing %s, %s at %s:%d\n", debugString, strerror(error), file, @@ -1659,5 +1660,4 @@ _ThrowOnError(status_t error, const char *DEBUG_ONLY(debugString), } } - } // namespace BPrivate diff --git a/src/kits/tracker/Utilities.h b/src/kits/tracker/Utilities.h index 1a6a2dbb89..51ed40dd45 100644 --- a/src/kits/tracker/Utilities.h +++ b/src/kits/tracker/Utilities.h @@ -31,7 +31,6 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef _UTILITIES_H #define _UTILITIES_H @@ -104,23 +103,23 @@ class PeriodicUpdatePoses { PeriodicUpdatePoses(); ~PeriodicUpdatePoses(); - typedef bool (*PeriodicUpdateCallback)(BPose *pose, void *cookie); + typedef bool (*PeriodicUpdateCallback)(BPose* pose, void* cookie); - void AddPose(BPose *pose, BPoseView *poseView, - PeriodicUpdateCallback callback, void *cookie); - bool RemovePose(BPose *pose, void **cookie); + void AddPose(BPose* pose, BPoseView* poseView, + PeriodicUpdateCallback callback, void* cookie); + bool RemovePose(BPose* pose, void** cookie); void DoPeriodicUpdate(bool forceRedraw); private: struct periodic_pose { - BPose *pose; - BPoseView *pose_view; + BPose* pose; + BPoseView* pose_view; PeriodicUpdateCallback callback; - void *cookie; + void* cookie; }; - Benaphore *fLock; + Benaphore* fLock; BObjectList fPoseList; }; @@ -131,7 +130,7 @@ extern PeriodicUpdatePoses gPeriodicUpdatePoses; // disk, defining the node's position and visibility class PoseInfo { public: - static void EndianSwap(void *castToThis); + static void EndianSwap(void* castToThis); void PrintToStream(); bool fInvisible; @@ -158,7 +157,7 @@ class ExtendedPoseInfo { BPoint LocationForFrame(BRect) const; bool SetLocationForFrame(BPoint, BRect); - static void EndianSwap(void *castToThis); + static void EndianSwap(void* castToThis); void PrintToStream(); uint32 fWorkspaces; @@ -183,15 +182,15 @@ class ExtendedPoseInfo { }; // misc functions -void DisallowMetaKeys(BTextView *); -void DisallowFilenameKeys(BTextView *); +void DisallowMetaKeys(BTextView*); +void DisallowFilenameKeys(BTextView*); -bool ValidateStream(BMallocIO *, uint32, int32 version); +bool ValidateStream(BMallocIO*, uint32, int32 version); -uint32 HashString(const char *string, uint32 seed); -uint32 AttrHashString(const char *string, uint32 type); +uint32 HashString(const char* string, uint32 seed); +uint32 AttrHashString(const char* string, uint32 type); class OffscreenBitmap { @@ -201,33 +200,33 @@ class OffscreenBitmap { OffscreenBitmap(); ~OffscreenBitmap(); - BView *BeginUsing(BRect bounds); + BView* BeginUsing(BRect bounds); void DoneUsing(); - BBitmap *Bitmap() const; + BBitmap* Bitmap() const; // blit this to your view when you are done rendering - BView *View() const; + BView* View() const; // use this to render your image private: void NewBitmap(BRect frame); - BBitmap *fBitmap; + BBitmap* fBitmap; }; // bitmap functions -extern void FadeRGBA32Horizontal(uint32 *bits, int32 width, int32 height, int32 from, int32 to); -extern void FadeRGBA32Vertical(uint32 *bits, int32 width, int32 height, int32 from, int32 to); +extern void FadeRGBA32Horizontal(uint32* bits, int32 width, int32 height, int32 from, int32 to); +extern void FadeRGBA32Vertical(uint32* bits, int32 width, int32 height, int32 from, int32 to); class FlickerFreeStringView : public BStringView { // Adds support for offscreen bitmap drawing for string views that update often // this would be better implemented as an option of BStringView public: - FlickerFreeStringView(BRect bounds, const char *name, - const char *text, uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP, + FlickerFreeStringView(BRect bounds, const char* name, + const char* text, uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP, uint32 flags = B_WILL_DRAW); - FlickerFreeStringView(BRect bounds, const char *name, - const char *text, BBitmap *existingOffscreen, + FlickerFreeStringView(BRect bounds, const char* name, + const char* text, BBitmap* existingOffscreen, uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP, uint32 flags = B_WILL_DRAW); virtual ~FlickerFreeStringView(); @@ -237,10 +236,10 @@ class FlickerFreeStringView : public BStringView { virtual void SetLowColor(rgb_color); private: - OffscreenBitmap *fBitmap; + OffscreenBitmap* fBitmap; rgb_color fViewColor; rgb_color fLowColor; - BBitmap *fOrigBitmap; + BBitmap* fOrigBitmap; typedef BStringView _inherited; }; @@ -249,8 +248,8 @@ class FlickerFreeStringView : public BStringView { class DraggableIcon : public BView { // used to determine a save location for a file public: - DraggableIcon(BRect, const char *, const char *mimeType, icon_size, - const BMessage *, BMessenger, + DraggableIcon(BRect, const char*, const char* mimeType, icon_size, + const BMessage*, BMessenger, uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP, uint32 flags = B_WILL_DRAW); virtual ~DraggableIcon(); @@ -263,10 +262,10 @@ class DraggableIcon : public BView { virtual void MouseDown(BPoint); virtual void Draw(BRect); - virtual bool DragStarted(BMessage *dragMessage); + virtual bool DragStarted(BMessage* dragMessage); protected: - BBitmap *fBitmap; + BBitmap* fBitmap; BMessage fMessage; BMessenger fTarget; }; @@ -274,13 +273,13 @@ class DraggableIcon : public BView { class PositionPassingMenuItem : public BMenuItem { public: - PositionPassingMenuItem(const char *title, BMessage *, char shortcut = 0, + PositionPassingMenuItem(const char* title, BMessage*, char shortcut = 0, uint32 modifiers = 0); - PositionPassingMenuItem(BMenu *, BMessage *); + PositionPassingMenuItem(BMenu*, BMessage*); protected: - virtual status_t Invoke(BMessage * = 0); + virtual status_t Invoke(BMessage* = 0); // appends the invoke location for NewFolder, etc. to use private: @@ -291,7 +290,7 @@ class PositionPassingMenuItem : public BMenuItem { class Benaphore { // aka benaphore public: - Benaphore(const char *name = "Light Lock") + Benaphore(const char* name = "Light Lock") : fSemaphore(create_sem(0, name)), fCount(1) { @@ -329,21 +328,21 @@ class Benaphore { class SeparatorLine : public BView { public: - SeparatorLine(BPoint , float , bool vertical, const char *name = ""); - virtual void Draw(BRect bounds); + SeparatorLine(BPoint, float, bool vertical, const char* name = ""); + virtual void Draw(BRect bounds); }; class TitledSeparatorItem : public BMenuItem { public: - TitledSeparatorItem(const char *); + TitledSeparatorItem(const char*); virtual ~TitledSeparatorItem(); virtual void SetEnabled(bool state); protected: - virtual void GetContentSize(float *width, float *height); - virtual void Draw(); + virtual void GetContentSize(float* width, float* height); + virtual void Draw(); private: typedef BMenuItem _inherited; @@ -352,7 +351,7 @@ class TitledSeparatorItem : public BMenuItem { class LooperAutoLocker { public: - LooperAutoLocker(BHandler *handler) + LooperAutoLocker(BHandler* handler) : fHandler(handler), fHasLock(handler->LockLooper()) { @@ -375,7 +374,7 @@ class LooperAutoLocker { } private: - BHandler *fHandler; + BHandler* fHandler; bool fHasLock; }; @@ -383,10 +382,10 @@ class LooperAutoLocker { class MessengerAutoLocker { // move this into AutoLock.h public: - MessengerAutoLocker(BMessenger *messenger) + MessengerAutoLocker(BMessenger* messenger) : fMessenger(messenger), fHasLock(messenger->LockTarget()) - { } + {} ~MessengerAutoLocker() { @@ -406,7 +405,7 @@ class MessengerAutoLocker { void Unlock() { if (fHasLock) { - BLooper *looper; + BLooper* looper; fMessenger->Target(&looper); if (looper) looper->Unlock(); @@ -415,7 +414,7 @@ class MessengerAutoLocker { } private: - BMessenger *fMessenger; + BMessenger* fMessenger; bool fHasLock; }; @@ -423,54 +422,54 @@ class MessengerAutoLocker { class ShortcutFilter : public BMessageFilter { public: ShortcutFilter(uint32 shortcutKey, uint32 shortcutModifier, - uint32 shortcutWhat, BHandler *target); + uint32 shortcutWhat, BHandler* target); protected: - filter_result Filter(BMessage *, BHandler **); + filter_result Filter(BMessage*, BHandler**); private: uint32 fShortcutKey; uint32 fShortcutModifier; uint32 fShortcutWhat; - BHandler *fTarget; + BHandler* fTarget; }; // iterates over all the refs in a message -entry_ref *EachEntryRef(BMessage *, entry_ref *(*)(entry_ref *, void *), - void *passThru = 0); -const entry_ref *EachEntryRef(const BMessage *, - const entry_ref *(*)(const entry_ref *, void *), void *passThru = 0); +entry_ref* EachEntryRef(BMessage*, entry_ref* (*)(entry_ref*, void*), + void* passThru = 0); +const entry_ref* EachEntryRef(const BMessage*, + const entry_ref* (*)(const entry_ref*, void*), void* passThru = 0); -entry_ref *EachEntryRef(BMessage *, entry_ref *(*)(entry_ref *, void *), - void *passThru, int32 maxCount); -const entry_ref *EachEntryRef(const BMessage *, - const entry_ref *(*)(const entry_ref *, void *), void *passThru, int32 maxCount); +entry_ref* EachEntryRef(BMessage*, entry_ref* (*)(entry_ref*, void*), + void* passThru, int32 maxCount); +const entry_ref* EachEntryRef(const BMessage*, + const entry_ref* (*)(const entry_ref*, void*), void* passThru, int32 maxCount); -bool ContainsEntryRef(const BMessage *, const entry_ref *); -int32 CountRefs(const BMessage *); +bool ContainsEntryRef(const BMessage*, const entry_ref*); +int32 CountRefs(const BMessage*); -BMenuItem *EachMenuItem(BMenu *menu, bool recursive, BMenuItem *(*func)(BMenuItem *)); -const BMenuItem *EachMenuItem(const BMenu *menu, bool recursive, - BMenuItem *(*func)(const BMenuItem *)); +BMenuItem* EachMenuItem(BMenu* menu, bool recursive, BMenuItem* (*func)(BMenuItem*)); +const BMenuItem* EachMenuItem(const BMenu* menu, bool recursive, + BMenuItem* (*func)(const BMenuItem*)); -int64 StringToScalar(const char *text); +int64 StringToScalar(const char* text); // string to num, understands kB, MB, etc. // misc calls -void EmbedUniqueVolumeInfo(BMessage *, const BVolume *); -status_t MatchArchivedVolume(BVolume *, const BMessage *, int32 index = 0); -void TruncateLeaf(BString *string); +void EmbedUniqueVolumeInfo(BMessage*, const BVolume*); +status_t MatchArchivedVolume(BVolume*, const BMessage*, int32 index = 0); +void TruncateLeaf(BString* string); -void StringFromStream(BString *, BMallocIO *, bool endianSwap = false); -void StringToStream(const BString *, BMallocIO *); -int32 ArchiveSize(const BString *); +void StringFromStream(BString*, BMallocIO*, bool endianSwap = false); +void StringToStream(const BString*, BMallocIO*); +int32 ArchiveSize(const BString*); -extern void EnableNamedMenuItem(BMenu *menu, const char *itemName, bool on); -extern void MarkNamedMenuItem(BMenu *menu, const char *itemName, bool on); -extern void EnableNamedMenuItem(BMenu *menu, uint32 commandName, bool on); -extern void MarkNamedMenuItem(BMenu *menu, uint32 commandName, bool on); -extern void DeleteSubmenu(BMenuItem *submenuItem); +extern void EnableNamedMenuItem(BMenu* menu, const char* itemName, bool on); +extern void MarkNamedMenuItem(BMenu* menu, const char* itemName, bool on); +extern void EnableNamedMenuItem(BMenu* menu, uint32 commandName, bool on); +extern void MarkNamedMenuItem(BMenu* menu, uint32 commandName, bool on); +extern void DeleteSubmenu(BMenuItem* submenuItem); extern bool BootedInSafeMode(); @@ -478,8 +477,8 @@ extern bool BootedInSafeMode(); #if B_BEOS_VERSION <= B_BEOS_VERSION_MAUI && !defined(__HAIKU__) // Should be in kits -bool operator==(const rgb_color &, const rgb_color &); -bool operator!=(const rgb_color &, const rgb_color &); +bool operator==(const rgb_color&, const rgb_color&); +bool operator!=(const rgb_color&, const rgb_color&); #endif @@ -499,10 +498,11 @@ void PrintToStream(rgb_color color); template void -ThrowOnInitCheckError(InitCheckable *item) +ThrowOnInitCheckError(InitCheckable* item) { if (!item) throw (status_t)B_ERROR; + status_t error = item->InitCheck(); if (error != B_OK) throw (status_t)error; @@ -518,52 +518,57 @@ ThrowOnInitCheckError(InitCheckable *item) #define ThrowOnErrorWithMessage(error, debugStr) _ThrowOnError(error, debugStr, __FILE__, __LINE__) #endif -void _ThrowOnError(status_t, const char *, int32); -void _ThrowIfNotSize(ssize_t, const char *, int32); -void _ThrowOnError(status_t, const char *debugStr, const char *, int32); +void _ThrowOnError(status_t, const char*, int32); +void _ThrowIfNotSize(ssize_t, const char*, int32); +void _ThrowOnError(status_t, const char* debugStr, const char*, int32); // stub calls that work around BAppFile info inefficiency -status_t GetAppSignatureFromAttr(BFile *, char *); -status_t GetAppIconFromAttr(BFile *, BBitmap *, icon_size); -status_t GetFileIconFromAttr(BNode *, BBitmap *, icon_size); +status_t GetAppSignatureFromAttr(BFile*, char*); +status_t GetAppIconFromAttr(BFile*, BBitmap*, icon_size); +status_t GetFileIconFromAttr(BNode*, BBitmap*, icon_size); // debugging -void HexDump(const void *buffer, int32 length); +void HexDump(const void* buffer, int32 length); #if xDEBUG inline void -PrintRefToStream(const entry_ref *ref, const char *trailer = "\n") +PrintRefToStream(const entry_ref* ref, const char* trailer = "\n") { - if (!ref) { + if (ref == NULL) { PRINT(("NULL entry_ref%s", trailer)); return; } + BPath path; BEntry entry(ref); entry.GetPath(&path); PRINT(("%s%s", path.Path(), trailer)); } + inline void -PrintEntryToStream(const BEntry *entry, const char *trailer = "\n") +PrintEntryToStream(const BEntry* entry, const char* trailer = "\n") { - if (!entry) { + if (entry == NULL) { PRINT(("NULL entry%s", trailer)); return; } + BPath path; entry->GetPath(&path); PRINT(("%s%s", path.Path(), trailer)); } + inline void -PrintDirToStream(const BDirectory *dir, const char *trailer = "\n") +PrintDirToStream(const BDirectory* dir, const char* trailer = "\n") { - if (!dir) { + if (dir == NULL) { PRINT(("NULL entry_ref%s", trailer)); return; } + BPath path; BEntry entry; dir->GetEntry(&entry); @@ -573,20 +578,20 @@ PrintDirToStream(const BDirectory *dir, const char *trailer = "\n") #else -inline void PrintRefToStream(const entry_ref *, const char * = 0) {} -inline void PrintEntryToStream(const BEntry *, const char * = 0) {} -inline void PrintDirToStream(const BDirectory *, const char * = 0) {} +inline void PrintRefToStream(const entry_ref*, const char* = 0) {} +inline void PrintEntryToStream(const BEntry*, const char* = 0) {} +inline void PrintDirToStream(const BDirectory*, const char* = 0) {} #endif #ifdef xDEBUG - extern FILE *logFile; + extern FILE* logFile; - inline void PrintToLogFile(const char *fmt, ...) + inline void PrintToLogFile(const char* format, ...) { - va_list ap; - va_start(ap, fmt); + va_list ap; + va_start(ap, fmt); vfprintf(logFile, fmt, ap); va_end(ap); } @@ -606,7 +611,7 @@ inline void PrintDirToStream(const BDirectory *, const char * = 0) {} #else - #define WRITELOG(_ARGS_) +#define WRITELOG(_ARGS_) #endif @@ -621,14 +626,16 @@ inline NewType assert_cast(OldType castedPointer) { // B_SWAP_INT32 have broken signedness, simple cover calls to fix that // should fix up in ByteOrder.h -inline int32 SwapInt32(int32 value) { return (int32)B_SWAP_INT32((uint32)value); } +inline int32 SwapInt32(int32 value) + { return (int32)B_SWAP_INT32((uint32)value); } inline uint32 SwapUInt32(uint32 value) { return B_SWAP_INT32(value); } -inline int64 SwapInt64(int64 value) { return (int64)B_SWAP_INT64((uint64)value); } +inline int64 SwapInt64(int64 value) + { return (int64)B_SWAP_INT64((uint64)value); } inline uint64 SwapUInt64(uint64 value) { return B_SWAP_INT64(value); } extern const float kExactMatchScore; -float ComputeTypeAheadScore(const char *text, const char *match, +float ComputeTypeAheadScore(const char* text, const char* match, bool wordMode = false); } // namespace BPrivate diff --git a/src/kits/tracker/ViewState.cpp b/src/kits/tracker/ViewState.cpp index 20fc4d5aae..ae80f1cbcf 100644 --- a/src/kits/tracker/ViewState.cpp +++ b/src/kits/tracker/ViewState.cpp @@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include #include #include @@ -47,38 +48,38 @@ All rights reserved. #include -const char *kColumnVersionName = "BColumn:version"; -const char *kColumnTitleName = "BColumn:fTitle"; -const char *kColumnOffsetName = "BColumn:fOffset"; -const char *kColumnWidthName = "BColumn:fWidth"; -const char *kColumnAlignmentName = "BColumn:fAlignment"; -const char *kColumnAttrName = "BColumn:fAttrName"; -const char *kColumnAttrHashName = "BColumn:fAttrHash"; -const char *kColumnAttrTypeName = "BColumn:fAttrType"; -const char *kColumnDisplayAsName = "BColumn:fDisplayAs"; -const char *kColumnStatFieldName = "BColumn:fStatField"; -const char *kColumnEditableName = "BColumn:fEditable"; +const char* kColumnVersionName = "BColumn:version"; +const char* kColumnTitleName = "BColumn:fTitle"; +const char* kColumnOffsetName = "BColumn:fOffset"; +const char* kColumnWidthName = "BColumn:fWidth"; +const char* kColumnAlignmentName = "BColumn:fAlignment"; +const char* kColumnAttrName = "BColumn:fAttrName"; +const char* kColumnAttrHashName = "BColumn:fAttrHash"; +const char* kColumnAttrTypeName = "BColumn:fAttrType"; +const char* kColumnDisplayAsName = "BColumn:fDisplayAs"; +const char* kColumnStatFieldName = "BColumn:fStatField"; +const char* kColumnEditableName = "BColumn:fEditable"; -const char *kViewStateVersionName = "ViewState:version"; -const char *kViewStateViewModeName = "ViewState:fViewMode"; -const char *kViewStateLastIconModeName = "ViewState:fLastIconMode"; -const char *kViewStateListOriginName = "ViewState:fListOrigin"; -const char *kViewStateIconOriginName = "ViewState:fIconOrigin"; -const char *kViewStatePrimarySortAttrName = "ViewState:fPrimarySortAttr"; -const char *kViewStatePrimarySortTypeName = "ViewState:fPrimarySortType"; -const char *kViewStateSecondarySortAttrName = "ViewState:fSecondarySortAttr"; -const char *kViewStateSecondarySortTypeName = "ViewState:fSecondarySortType"; -const char *kViewStateReverseSortName = "ViewState:fReverseSort"; -const char *kViewStateIconSizeName = "ViewState:fIconSize"; -const char *kViewStateLastIconSizeName = "ViewState:fLastIconSize"; +const char* kViewStateVersionName = "ViewState:version"; +const char* kViewStateViewModeName = "ViewState:fViewMode"; +const char* kViewStateLastIconModeName = "ViewState:fLastIconMode"; +const char* kViewStateListOriginName = "ViewState:fListOrigin"; +const char* kViewStateIconOriginName = "ViewState:fIconOrigin"; +const char* kViewStatePrimarySortAttrName = "ViewState:fPrimarySortAttr"; +const char* kViewStatePrimarySortTypeName = "ViewState:fPrimarySortType"; +const char* kViewStateSecondarySortAttrName = "ViewState:fSecondarySortAttr"; +const char* kViewStateSecondarySortTypeName = "ViewState:fSecondarySortType"; +const char* kViewStateReverseSortName = "ViewState:fReverseSort"; +const char* kViewStateIconSizeName = "ViewState:fIconSize"; +const char* kViewStateLastIconSizeName = "ViewState:fLastIconSize"; static const int32 kColumnStateMinArchiveVersion = 21; // bump version when layout changes -BColumn::BColumn(const char *title, float offset, float width, - alignment align, const char *attributeName, uint32 attrType, +BColumn::BColumn(const char* title, float offset, float width, + alignment align, const char* attributeName, uint32 attrType, const char* displayAs, bool statField, bool editable) { _Init(title, offset, width, align, attributeName, attrType, displayAs, @@ -86,8 +87,8 @@ BColumn::BColumn(const char *title, float offset, float width, } -BColumn::BColumn(const char *title, float offset, float width, - alignment align, const char *attributeName, uint32 attrType, +BColumn::BColumn(const char* title, float offset, float width, + alignment align, const char* attributeName, uint32 attrType, bool statField, bool editable) { _Init(title, offset, width, align, attributeName, attrType, NULL, @@ -100,7 +101,7 @@ BColumn::~BColumn() } -BColumn::BColumn(BMallocIO *stream, int32 version, bool endianSwap) +BColumn::BColumn(BMallocIO* stream, int32 version, bool endianSwap) { StringFromStream(&fTitle, stream, endianSwap); stream->Read(&fOffset, sizeof(float)); @@ -131,10 +132,10 @@ BColumn::BColumn(const BMessage &message, int32 index) message.FindString(kColumnTitleName, index, &fTitle); message.FindFloat(kColumnOffsetName, index, &fOffset); message.FindFloat(kColumnWidthName, index, &fWidth); - message.FindInt32(kColumnAlignmentName, index, (int32 *)&fAlignment); + message.FindInt32(kColumnAlignmentName, index, (int32*)&fAlignment); message.FindString(kColumnAttrName, index, &fAttrName); - message.FindInt32(kColumnAttrHashName, index, (int32 *)&fAttrHash); - message.FindInt32(kColumnAttrTypeName, index, (int32 *)&fAttrType); + message.FindInt32(kColumnAttrHashName, index, (int32*)&fAttrHash); + message.FindInt32(kColumnAttrTypeName, index, (int32*)&fAttrType); message.FindString(kColumnDisplayAsName, index, &fDisplayAs); message.FindBool(kColumnStatFieldName, index, &fStatField); message.FindBool(kColumnEditableName, index, &fEditable); @@ -142,8 +143,8 @@ BColumn::BColumn(const BMessage &message, int32 index) void -BColumn::_Init(const char *title, float offset, float width, - alignment align, const char *attributeName, uint32 attrType, +BColumn::_Init(const char* title, float offset, float width, + alignment align, const char* attributeName, uint32 attrType, const char* displayAs, bool statField, bool editable) { fTitle = title; @@ -159,8 +160,8 @@ BColumn::_Init(const char *title, float offset, float width, } -BColumn * -BColumn::InstantiateFromStream(BMallocIO *stream, bool endianSwap) +BColumn* +BColumn::InstantiateFromStream(BMallocIO* stream, bool endianSwap) { // compare stream header in canonical form @@ -185,7 +186,7 @@ BColumn::InstantiateFromStream(BMallocIO *stream, bool endianSwap) } -BColumn * +BColumn* BColumn::InstantiateFromMessage(const BMessage &message, int32 index) { int32 version = kColumnStateArchiveVersion; @@ -202,7 +203,7 @@ BColumn::InstantiateFromMessage(const BMessage &message, int32 index) void -BColumn::ArchiveToStream(BMallocIO *stream) const +BColumn::ArchiveToStream(BMallocIO* stream) const { // write class identifier and version info uint32 key = AttrHashString("BColumn", B_OBJECT_TYPE); @@ -245,7 +246,7 @@ BColumn::ArchiveToMessage(BMessage &message) const BColumn * -BColumn::_Sanitize(BColumn *column) +BColumn::_Sanitize(BColumn* column) { if (column == NULL) return NULL; @@ -283,7 +284,7 @@ BViewState::BViewState() } -BViewState::BViewState(BMallocIO *stream, bool endianSwap) +BViewState::BViewState(BMallocIO* stream, bool endianSwap) { _Init(); stream->Read(&fViewMode, sizeof(uint32)); @@ -322,20 +323,20 @@ BViewState::BViewState(BMallocIO *stream, bool endianSwap) BViewState::BViewState(const BMessage &message) { _Init(); - message.FindInt32(kViewStateViewModeName, (int32 *)&fViewMode); - message.FindInt32(kViewStateLastIconModeName, (int32 *)&fLastIconMode); - message.FindInt32(kViewStateLastIconSizeName,(int32 *)&fLastIconSize); - message.FindInt32(kViewStateIconSizeName, (int32 *)&fIconSize); + message.FindInt32(kViewStateViewModeName, (int32*)&fViewMode); + message.FindInt32(kViewStateLastIconModeName, (int32*)&fLastIconMode); + message.FindInt32(kViewStateLastIconSizeName,(int32*)&fLastIconSize); + message.FindInt32(kViewStateIconSizeName, (int32*)&fIconSize); message.FindPoint(kViewStateListOriginName, &fListOrigin); message.FindPoint(kViewStateIconOriginName, &fIconOrigin); message.FindInt32(kViewStatePrimarySortAttrName, - (int32 *)&fPrimarySortAttr); + (int32*)&fPrimarySortAttr); message.FindInt32(kViewStatePrimarySortTypeName, - (int32 *)&fPrimarySortType); + (int32*)&fPrimarySortType); message.FindInt32(kViewStateSecondarySortAttrName, - (int32 *)&fSecondarySortAttr); + (int32*)&fSecondarySortAttr); message.FindInt32(kViewStateSecondarySortTypeName, - (int32 *)&fSecondarySortType); + (int32*)&fSecondarySortType); message.FindBool(kViewStateReverseSortName, &fReverseSort); _StorePreviousState(); @@ -344,7 +345,7 @@ BViewState::BViewState(const BMessage &message) void -BViewState::ArchiveToStream(BMallocIO *stream) const +BViewState::ArchiveToStream(BMallocIO* stream) const { // write class identifier and verison info uint32 key = AttrHashString("BViewState", B_OBJECT_TYPE); @@ -391,8 +392,8 @@ BViewState::ArchiveToMessage(BMessage &message) const } -BViewState * -BViewState::InstantiateFromStream(BMallocIO *stream, bool endianSwap) +BViewState* +BViewState::InstantiateFromStream(BMallocIO* stream, bool endianSwap) { // compare stream header in canonical form uint32 key = AttrHashString("BViewState", B_OBJECT_TYPE); @@ -410,7 +411,7 @@ BViewState::InstantiateFromStream(BMallocIO *stream, bool endianSwap) } -BViewState * +BViewState* BViewState::InstantiateFromMessage(const BMessage &message) { int32 version = kViewStateArchiveVersion; @@ -460,8 +461,8 @@ BViewState::_StorePreviousState() } -BViewState * -BViewState::_Sanitize(BViewState *state, bool fixOnly) +BViewState* +BViewState::_Sanitize(BViewState* state, bool fixOnly) { if (state == NULL) return NULL; @@ -508,4 +509,3 @@ BViewState::_Sanitize(BViewState *state, bool fixOnly) return state; } - diff --git a/src/kits/tracker/ViewState.h b/src/kits/tracker/ViewState.h index dbdfb65724..396438dd8d 100644 --- a/src/kits/tracker/ViewState.h +++ b/src/kits/tracker/ViewState.h @@ -46,21 +46,21 @@ const int32 kColumnStateArchiveVersion = 22; class BColumn { public: - BColumn(const char *title, float offset, float width, - alignment align, const char *attributeName, uint32 attrType, + BColumn(const char* title, float offset, float width, + alignment align, const char* attributeName, uint32 attrType, const char* displayAs, bool statField, bool editable); - BColumn(const char *title, float offset, float width, - alignment align, const char *attributeName, uint32 attrType, + BColumn(const char* title, float offset, float width, + alignment align, const char* attributeName, uint32 attrType, bool statField, bool editable); ~BColumn(); - BColumn(BMallocIO *stream, int32 version, bool endianSwap = false); + BColumn(BMallocIO* stream, int32 version, bool endianSwap = false); BColumn(const BMessage &, int32 index = 0); - static BColumn *InstantiateFromStream(BMallocIO *stream, + static BColumn* InstantiateFromStream(BMallocIO* stream, bool endianSwap = false); - static BColumn *InstantiateFromMessage(const BMessage &archive, + static BColumn* InstantiateFromMessage(const BMessage &archive, int32 index = 0); - void ArchiveToStream(BMallocIO *stream) const; + void ArchiveToStream(BMallocIO* stream) const; void ArchiveToMessage(BMessage &) const; const char* Title() const; @@ -78,8 +78,8 @@ class BColumn { void SetWidth(float); private: - void _Init(const char *title, float offset, float width, - alignment align, const char *attributeName, uint32 attrType, + void _Init(const char* title, float offset, float width, + alignment align, const char* attributeName, uint32 attrType, const char* displayAs, bool statField, bool editable); static BColumn* _Sanitize(BColumn* column); @@ -103,11 +103,11 @@ class BViewState { public: BViewState(); - BViewState(BMallocIO *stream, bool endianSwap = false); + BViewState(BMallocIO* stream, bool endianSwap = false); BViewState(const BMessage &message); - static BViewState *InstantiateFromStream(BMallocIO *stream, bool endianSwap = false); - static BViewState *InstantiateFromMessage(const BMessage &message); - void ArchiveToStream(BMallocIO *stream) const; + static BViewState* InstantiateFromStream(BMallocIO* stream, bool endianSwap = false); + static BViewState* InstantiateFromMessage(const BMessage &message); + void ArchiveToStream(BMallocIO* stream) const; void ArchiveToMessage(BMessage &message) const; uint32 ViewMode() const; @@ -137,38 +137,38 @@ class BViewState { bool StateNeedsSaving(); private: - static BViewState *_Sanitize(BViewState *state, bool fixOnly = false); + static BViewState* _Sanitize(BViewState* state, bool fixOnly = false); - uint32 fViewMode; - uint32 fLastIconMode; - uint32 fIconSize; - uint32 fLastIconSize; - BPoint fListOrigin; - BPoint fIconOrigin; - uint32 fPrimarySortAttr; - uint32 fSecondarySortAttr; - uint32 fPrimarySortType; - uint32 fSecondarySortType; - bool fReverseSort; + uint32 fViewMode; + uint32 fLastIconMode; + uint32 fIconSize; + uint32 fLastIconSize; + BPoint fListOrigin; + BPoint fIconOrigin; + uint32 fPrimarySortAttr; + uint32 fSecondarySortAttr; + uint32 fPrimarySortType; + uint32 fSecondarySortType; + bool fReverseSort; void _Init(); void _StorePreviousState(); - uint32 fPreviousViewMode; - uint32 fPreviousLastIconMode; - uint32 fPreviousIconSize; - uint32 fPreviousLastIconSize; - BPoint fPreviousListOrigin; - BPoint fPreviousIconOrigin; - uint32 fPreviousPrimarySortAttr; - uint32 fPreviousSecondarySortAttr; - uint32 fPreviousPrimarySortType; - uint32 fPreviousSecondarySortType; - bool fPreviousReverseSort; + uint32 fPreviousViewMode; + uint32 fPreviousLastIconMode; + uint32 fPreviousIconSize; + uint32 fPreviousLastIconSize; + BPoint fPreviousListOrigin; + BPoint fPreviousIconOrigin; + uint32 fPreviousPrimarySortAttr; + uint32 fPreviousSecondarySortAttr; + uint32 fPreviousPrimarySortType; + uint32 fPreviousSecondarySortType; + bool fPreviousReverseSort; }; -inline const char * +inline const char* BColumn::Title() const { return fTitle.String(); @@ -196,7 +196,7 @@ BColumn::Alignment() const } -inline const char * +inline const char* BColumn::AttrName() const { return fAttrName.String(); @@ -217,7 +217,7 @@ BColumn::AttrType() const } -inline const char * +inline const char* BColumn::DisplayAs() const { return fDisplayAs.String(); @@ -422,4 +422,4 @@ BViewState::StateNeedsSaving() using namespace BPrivate; -#endif +#endif // _VIEW_STATE_H diff --git a/src/kits/tracker/VolumeWindow.cpp b/src/kits/tracker/VolumeWindow.cpp index a43bc87148..453f21b6db 100644 --- a/src/kits/tracker/VolumeWindow.cpp +++ b/src/kits/tracker/VolumeWindow.cpp @@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include #include #include @@ -53,7 +54,7 @@ All rights reserved. #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "VolumeWindow" -BVolumeWindow::BVolumeWindow(LockingList *windowList, uint32 openFlags) +BVolumeWindow::BVolumeWindow(LockingList* windowList, uint32 openFlags) : BContainerWindow(windowList, openFlags) { } @@ -74,7 +75,7 @@ BVolumeWindow::MenusBeginning() int32 count = PoseView()->SelectionList()->CountItems(); for (int32 index = 0; index < count; index++) { - Model *model = PoseView()->SelectionList()->ItemAt(index)->TargetModel(); + Model* model = PoseView()->SelectionList()->ItemAt(index)->TargetModel(); if (model->IsVolume()) { BVolume volume; volume.SetTo(model->NodeRef()->device); @@ -92,7 +93,7 @@ BVolumeWindow::MenusBeginning() void -BVolumeWindow::AddFileMenu(BMenu *menu) +BVolumeWindow::AddFileMenu(BMenu* menu) { menu->AddItem(new BMenuItem(B_TRANSLATE("Find"B_UTF8_ELLIPSIS), new BMessage(kFindButton), 'F')); @@ -120,7 +121,7 @@ BVolumeWindow::AddFileMenu(BMenu *menu) void -BVolumeWindow::AddWindowContextMenus(BMenu *menu) +BVolumeWindow::AddWindowContextMenus(BMenu* menu) { if (fPoseView != NULL && fPoseView->TargetModel() != NULL && !fPoseView->TargetModel()->IsRoot()) { @@ -163,4 +164,3 @@ BVolumeWindow::AddWindowContextMenus(BMenu *menu) closeItem->SetTarget(this); resizeItem->SetTarget(this); } - diff --git a/src/kits/tracker/VolumeWindow.h b/src/kits/tracker/VolumeWindow.h index d8f683995b..53dc0117c2 100644 --- a/src/kits/tracker/VolumeWindow.h +++ b/src/kits/tracker/VolumeWindow.h @@ -31,24 +31,28 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - -#ifndef _VOLUME_WINDOW_H +#ifndef _VOLUME_WINDOW_H #define _VOLUME_WINDOW_H + +// The volume window displays the virtual file system root with +// all mounted volumes. Does not show up unless the corresponding Tracker +// setting is enabled + + #include "ContainerWindow.h" + namespace BPrivate { class BVolumeWindow : public BContainerWindow { - // The volume window displays the virtual file system root with - // all mounted volumes. Does not show up unless the corresponding Tracker - // setting is enabled public: - BVolumeWindow(LockingList *windowList, uint32 containerWindowFlags); + BVolumeWindow(LockingList* windowList, + uint32 containerWindowFlags); protected: - virtual void AddFileMenu(BMenu *menu); - virtual void AddWindowContextMenus(BMenu *); + virtual void AddFileMenu(BMenu* menu); + virtual void AddWindowContextMenus(BMenu*); virtual void MenusBeginning(); @@ -60,4 +64,4 @@ class BVolumeWindow : public BContainerWindow { using namespace BPrivate; -#endif +#endif // _VOLUME_WINDOW_H diff --git a/src/kits/tracker/WidgetAttributeText.cpp b/src/kits/tracker/WidgetAttributeText.cpp index 6fd7df3e80..98e34c5dd4 100644 --- a/src/kits/tracker/WidgetAttributeText.cpp +++ b/src/kits/tracker/WidgetAttributeText.cpp @@ -2129,4 +2129,3 @@ VersionAttributeText::ReadValue(BString* result) } *result = "-"; } - diff --git a/src/kits/tracker/WidgetAttributeText.h b/src/kits/tracker/WidgetAttributeText.h index 1d85d7ddce..49c0518f72 100644 --- a/src/kits/tracker/WidgetAttributeText.h +++ b/src/kits/tracker/WidgetAttributeText.h @@ -31,14 +31,15 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef __TEXT_WIDGET_ATTRIBUTE__ #define __TEXT_WIDGET_ATTRIBUTE__ + #include #include "TrackerSettings.h" + namespace BPrivate { class Model; @@ -56,50 +57,50 @@ class WidgetAttributeText { // view // It is being asked for the string value by the TextWidget object public: - WidgetAttributeText(const Model *, const BColumn *); + WidgetAttributeText(const Model*, const BColumn*); virtual ~WidgetAttributeText(); virtual bool CheckAttributeChanged() = 0; // returns true if attribute value changed - bool CheckViewChanged(const BPoseView *); + bool CheckViewChanged(const BPoseView*); // returns true if fitted text changed, either because value // changed or because width/view changed virtual bool CheckSettingsChanged(); // override if the text rendering depends on a setting - const char *FittingText(const BPoseView *); + const char* FittingText(const BPoseView*); // returns text, recalculating if not yet calculated - virtual int Compare(WidgetAttributeText &, BPoseView *view) = 0; + virtual int Compare(WidgetAttributeText&, BPoseView* view) = 0; // override to define a compare of two different attributes for // sorting - static WidgetAttributeText *NewWidgetText(const Model *, const BColumn *, - const BPoseView *); + static WidgetAttributeText* NewWidgetText(const Model*, const BColumn*, + const BPoseView*); // WidgetAttributeText factory // call this to make the right WidgetAttributeText type for a // given column - float Width(const BPoseView *); + float Width(const BPoseView*); // respects the width of the corresponding column float CurrentWidth() const; // return the item width we got during our last fitting attempt - virtual void SetUpEditing(BTextView *); + virtual void SetUpEditing(BTextView*); // set up the passed textView for the specifics of a given // attribute editing - virtual bool CommitEditedText(BTextView *) = 0; + virtual bool CommitEditedText(BTextView*) = 0; // return true if attribute actually changed - virtual float PreferredWidth(const BPoseView *) const = 0; + virtual float PreferredWidth(const BPoseView*) const = 0; - static status_t AttrAsString(const Model *model, BString *result, - const char *attrName, int32 attrType, float width, - BView *view, int64 *value = 0); + static status_t AttrAsString(const Model* model, BString* result, + const char* attrName, int32 attrType, float width, + BView* view, int64* value = 0); - Model *TargetModel() const; + Model* TargetModel() const; virtual bool IsEditable() const; @@ -107,23 +108,24 @@ class WidgetAttributeText { protected: // generic fitting routines used by the different attributes - static float TruncString(BString *result, const char *src, - int32 length, const BPoseView *, float width, + static float TruncString(BString* result, const char* src, + int32 length, const BPoseView*, float width, uint32 truncMode = B_TRUNCATE_MIDDLE); - static float TruncTime(BString *result, int64 src, - const BPoseView *view, float width); + static float TruncTime(BString* result, int64 src, + const BPoseView* view, float width); - static float TruncFileSize(BString *result, int64 src, - const BPoseView *view, float width); + static float TruncFileSize(BString* result, int64 src, + const BPoseView* view, float width); - virtual void FitValue(BString *result, const BPoseView *) = 0; + virtual void FitValue(BString* result, const BPoseView*) = 0; // override FitValue to do a specific text fitting for a given // attribute - mutable Model *fModel; - const BColumn *fColumn; - float fOldWidth; // ToDo: make these int32 only + mutable Model* fModel; + const BColumn* fColumn; + // TODO: make these int32 only + float fOldWidth; float fTruncatedWidth; bool fDirty; // if true, need to recalculate text next time we try to use it @@ -133,7 +135,7 @@ class WidgetAttributeText { // in the last FittingText call }; -inline Model * +inline Model* WidgetAttributeText::TargetModel() const { return fModel; @@ -142,25 +144,25 @@ WidgetAttributeText::TargetModel() const class StringAttributeText : public WidgetAttributeText { public: - StringAttributeText(const Model *, const BColumn *); + StringAttributeText(const Model*, const BColumn*); - virtual const char *ValueAsText(const BPoseView *view); - // returns the untrucated text that corresponds to the attribute - // value + virtual const char* ValueAsText(const BPoseView* view); + // returns the untrucated text that corresponds to + // the attribute value virtual bool CheckAttributeChanged(); - virtual float PreferredWidth(const BPoseView *) const; + virtual float PreferredWidth(const BPoseView*) const; - virtual bool CommitEditedText(BTextView *); + virtual bool CommitEditedText(BTextView*); protected: - virtual bool CommitEditedTextFlavor(BTextView *) { return false; } + virtual bool CommitEditedTextFlavor(BTextView*) { return false; } - virtual void FitValue(BString *result, const BPoseView *); - virtual void ReadValue(BString *result) = 0; + virtual void FitValue(BString* result, const BPoseView*); + virtual void ReadValue(BString* result) = 0; - virtual int Compare(WidgetAttributeText &, BPoseView *view); + virtual int Compare(WidgetAttributeText &, BPoseView* view); BString fFullValueText; bool fValueDirty; @@ -170,17 +172,17 @@ class StringAttributeText : public WidgetAttributeText { class ScalarAttributeText : public WidgetAttributeText { public: - ScalarAttributeText(const Model *, const BColumn *); + ScalarAttributeText(const Model*, const BColumn*); int64 Value(); virtual bool CheckAttributeChanged(); - virtual float PreferredWidth(const BPoseView *) const; + virtual float PreferredWidth(const BPoseView*) const; - virtual bool CommitEditedText(BTextView *) { return false; } + virtual bool CommitEditedText(BTextView*) { return false; } // return true if attribute actually changed protected: virtual int64 ReadValue() = 0; - virtual int Compare(WidgetAttributeText &, BPoseView *view); + virtual int Compare(WidgetAttributeText&, BPoseView* view); int64 fValue; bool fValueDirty; // used for lazy read, managed by ReadValue @@ -188,21 +190,21 @@ class ScalarAttributeText : public WidgetAttributeText { union GenericValueStruct { - time_t time_tt; - off_t off_tt; + time_t time_tt; + off_t off_tt; - bool boolt; - int8 int8t; - uint8 uint8t; - int16 int16t; - int16 uint16t; - int32 int32t; - int32 uint32t; - int64 int64t; - int64 uint64t; + bool boolt; + int8 int8t; + uint8 uint8t; + int16 int16t; + int16 uint16t; + int32 int32t; + int32 uint32t; + int64 int64t; + int64 uint64t; - float floatt; - double doublet; + float floatt; + double doublet; }; @@ -287,10 +289,10 @@ private: class TimeAttributeText : public ScalarAttributeText { public: - TimeAttributeText(const Model *, const BColumn *); + TimeAttributeText(const Model*, const BColumn*); protected: - virtual float PreferredWidth(const BPoseView *) const; - virtual void FitValue(BString *result, const BPoseView *); + virtual float PreferredWidth(const BPoseView*) const; + virtual void FitValue(BString* result, const BPoseView*); virtual bool CheckSettingsChanged(); TrackerSettings fSettings; @@ -302,40 +304,40 @@ class TimeAttributeText : public ScalarAttributeText { class PathAttributeText : public StringAttributeText { public: - PathAttributeText(const Model *, const BColumn *); + PathAttributeText(const Model*, const BColumn*); protected: - virtual void ReadValue(BString *result); + virtual void ReadValue(BString* result); }; class OriginalPathAttributeText : public StringAttributeText { public: - OriginalPathAttributeText(const Model *, const BColumn *); + OriginalPathAttributeText(const Model*, const BColumn*); protected: - virtual void ReadValue(BString *result); + virtual void ReadValue(BString* result); }; class KindAttributeText : public StringAttributeText { public: - KindAttributeText(const Model *, const BColumn *); + KindAttributeText(const Model*, const BColumn*); protected: - virtual void ReadValue(BString *result); + virtual void ReadValue(BString* result); }; class NameAttributeText : public StringAttributeText { public: - NameAttributeText(const Model *, const BColumn *); - virtual void SetUpEditing(BTextView *); - virtual void FitValue(BString *result, const BPoseView *); + NameAttributeText(const Model*, const BColumn*); + virtual void SetUpEditing(BTextView*); + virtual void FitValue(BString* result, const BPoseView*); virtual bool IsEditable() const; static void SetSortFolderNamesFirst(bool); protected: - virtual bool CommitEditedTextFlavor(BTextView *); - virtual int Compare(WidgetAttributeText &, BPoseView *view); - virtual void ReadValue(BString *result); + virtual bool CommitEditedTextFlavor(BTextView*); + virtual int Compare(WidgetAttributeText&, BPoseView* view); + virtual void ReadValue(BString* result); static bool sSortFolderNamesFirst; }; @@ -343,17 +345,17 @@ class NameAttributeText : public StringAttributeText { class RealNameAttributeText : public StringAttributeText { public: - RealNameAttributeText(const Model *, - const BColumn *); - virtual void SetUpEditing(BTextView *); - virtual void FitValue(BString *result, const BPoseView *); + RealNameAttributeText(const Model*, + const BColumn*); + virtual void SetUpEditing(BTextView*); + virtual void FitValue(BString* result, const BPoseView*); static void SetSortFolderNamesFirst(bool); protected: - virtual bool CommitEditedTextFlavor(BTextView *); - virtual int Compare(WidgetAttributeText &, BPoseView *view); - virtual void ReadValue(BString *result); + virtual bool CommitEditedTextFlavor(BTextView*); + virtual int Compare(WidgetAttributeText&, BPoseView* view); + virtual void ReadValue(BString* result); static bool sSortFolderNamesFirst; }; @@ -363,47 +365,50 @@ protected: class OwnerAttributeText : public StringAttributeText { public: - OwnerAttributeText(const Model *, const BColumn *); + OwnerAttributeText(const Model*, const BColumn*); protected: - virtual void ReadValue(BString *result); + virtual void ReadValue(BString* result); }; class GroupAttributeText : public StringAttributeText { public: - GroupAttributeText(const Model *, const BColumn *); + GroupAttributeText(const Model*, const BColumn*); protected: - virtual void ReadValue(BString *result); + virtual void ReadValue(BString* result); }; -#endif /* OWNER_GROUP_ATTRIBUTES */ +#endif // OWNER_GROUP_ATTRIBUTES + class ModeAttributeText : public StringAttributeText { public: - ModeAttributeText(const Model *, const BColumn *); + ModeAttributeText(const Model*, const BColumn*); protected: - virtual void ReadValue(BString *result); + virtual void ReadValue(BString* result); }; + const int64 kUnknownSize = -1; + class SizeAttributeText : public ScalarAttributeText { public: - SizeAttributeText(const Model *, const BColumn *); + SizeAttributeText(const Model*, const BColumn*); protected: - virtual void FitValue(BString *result, const BPoseView *); + virtual void FitValue(BString* result, const BPoseView*); virtual int64 ReadValue(); - virtual float PreferredWidth(const BPoseView *) const; + virtual float PreferredWidth(const BPoseView*) const; }; class CreationTimeAttributeText : public TimeAttributeText { public: - CreationTimeAttributeText(const Model *, const BColumn *); + CreationTimeAttributeText(const Model*, const BColumn*); protected: virtual int64 ReadValue(); }; @@ -411,7 +416,7 @@ class CreationTimeAttributeText : public TimeAttributeText { class ModificationTimeAttributeText : public TimeAttributeText { public: - ModificationTimeAttributeText(const Model *, const BColumn *); + ModificationTimeAttributeText(const Model*, const BColumn*); protected: virtual int64 ReadValue(); @@ -420,25 +425,26 @@ class ModificationTimeAttributeText : public TimeAttributeText { class OpenWithRelationAttributeText : public ScalarAttributeText { public: - OpenWithRelationAttributeText(const Model *, const BColumn *, - const BPoseView *); + OpenWithRelationAttributeText(const Model*, const BColumn*, + const BPoseView*); protected: - virtual void FitValue(BString *result, const BPoseView *); + virtual void FitValue(BString* result, const BPoseView*); virtual int64 ReadValue(); - virtual float PreferredWidth(const BPoseView *) const; + virtual float PreferredWidth(const BPoseView*) const; - const BPoseView *fPoseView; + const BPoseView* fPoseView; BString fRelationText; }; class VersionAttributeText : public StringAttributeText { public: - VersionAttributeText(const Model *, const BColumn *, bool appVersion); + VersionAttributeText(const Model*, const BColumn*, bool appVersion); protected: - virtual void ReadValue(BString *result); + virtual void ReadValue(BString* result); + private: bool fAppVersion; }; @@ -446,7 +452,8 @@ class VersionAttributeText : public StringAttributeText { class AppShortVersionAttributeText : public VersionAttributeText { public: - AppShortVersionAttributeText(const Model *model, const BColumn *column) + AppShortVersionAttributeText(const Model* model, + const BColumn* column) : VersionAttributeText(model, column, true) { } @@ -455,7 +462,7 @@ class AppShortVersionAttributeText : public VersionAttributeText { class SystemShortVersionAttributeText : public VersionAttributeText { public: - SystemShortVersionAttributeText(const Model *model, const BColumn *column) + SystemShortVersionAttributeText(const Model* model, const BColumn* column) : VersionAttributeText(model, column, false) { } @@ -469,4 +476,4 @@ extern status_t TimeFormat(BString &string, int32 index, FormatSeparator format, using namespace BPrivate; -#endif /* __TEXT_WIDGET_ATTRIBUTE__ */ +#endif // __TEXT_WIDGET_ATTRIBUTE__