Closed
Bug 479283
Opened 15 years ago
Closed 15 years ago
add some scriptability to nsIMsgDBView for message pane work
Categories
(MailNews Core :: Backend, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
Thunderbird 3.0b3
People
(Reporter: Bienvenu, Assigned: Bienvenu)
Details
Attachments
(1 file, 1 obsolete file)
15.69 KB,
patch
|
neil
:
review+
neil
:
superreview+
|
Details | Diff | Splinter Review |
DavidA was asking for a view method to select a set of messages. I thought, instead of adding a view method to do that, I'd expose some api's on the view so he could write it in js, and not have to get a headache looking at nsMsgDBView.cpp. This patch exposes enough functionality to do that and a bit more.
Attachment #363162 -
Flags: superreview?(neil)
Attachment #363162 -
Flags: review?(neil)
Assignee | ||
Comment 1•15 years ago
|
||
with this patch, you can write things like the following: function AddThreadIndexToSelection(index) { let thread = gDBView.getThreadContainingIndex(index); let flags = gDBView.getFlagsAt(index); let treeView = gDBView.QueryInterface(Components.interfaces.nsITreeView); if (flags & Components.interfaces.nsMsgMessageFlags.Elided) treeView.toggleOpenState(index); let selection = treeView.selection; selection.rangedSelect(index, index, true); let numChildren = thread.numChildren; for (let i = 1; i < numChildren; i++) { let child = thread.getChildHdrAt(i); let childIndex = gDBView.findIndexOfMsgHdr(child, false); if (childIndex != -1) selection.rangedSelect(childIndex, childIndex, true); } } N.B. - you wouldn't want to actually implement selectthread this way, since it's much more efficient to just select from the start of the thread to the end of the thread, but I wanted to be able to test findIndexOfMsgHdr. Also, you could determine the elided bit from nsITreeView but in general it might be useful to expose the view flags.
Comment 2•15 years ago
|
||
Comment on attachment 363162 [details] [diff] [review] expose some nsIMsgDBView functionality >+ if (m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay) >+ { >+ nsMsgViewIndex threadIndex = ThreadIndexOfMsgHdr(aMsgHdr); >+ if (threadIndex != nsMsgViewIndex_None) >+ { >+ if (m_flags[threadIndex] & nsMsgMessageFlags::Elided) >+ ExpandByIndex(threadIndex, nsnull); >+ *aIndex = FindHdr(aMsgHdr, threadIndex); >+ } >+ } But what happens if we don't find the thread index?
Assignee | ||
Comment 3•15 years ago
|
||
(In reply to comment #2) > But what happens if we don't find the thread index? we should return nsMsgViewIndex_None - I'll attach a new patch.
Assignee | ||
Comment 4•15 years ago
|
||
I've also taken away the extra braces around the else clauses because I think the code reads fine w/o them (sometimes they can be helpful if the code is complicated...)
Attachment #363162 -
Attachment is obsolete: true
Attachment #363320 -
Flags: superreview?(neil)
Attachment #363320 -
Flags: review?(neil)
Attachment #363162 -
Flags: superreview?(neil)
Attachment #363162 -
Flags: review?(neil)
Comment 5•15 years ago
|
||
Comment on attachment 363320 [details] [diff] [review] address Neil's comment >- virtual nsresult GetThreadContainingIndex(nsMsgViewIndex index, nsIMsgThread **thread); >+// virtual nsresult GetThreadContainingIndex(nsMsgViewIndex index, nsIMsgThread **thread); I don't think this is correct ;-)
Attachment #363320 -
Flags: superreview?(neil)
Attachment #363320 -
Flags: superreview+
Attachment #363320 -
Flags: review?(neil)
Attachment #363320 -
Flags: review+
Assignee | ||
Comment 6•15 years ago
|
||
fix checked in, with commented out line removed - davida, let me know if there's other things you'd like to do with views from js.
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•