Closed
Bug 325342
Opened 19 years ago
Closed 17 years ago
Allow bookmark folders to be sorted
Categories
(Firefox :: Bookmarks & History, defect)
Firefox
Bookmarks & History
Tracking
()
VERIFIED
FIXED
Firefox 3 alpha5
People
(Reporter: brettw, Assigned: enndeakin)
References
Details
(Whiteboard: [Fx2-parity])
Attachments
(1 file, 6 obsolete files)
16.14 KB,
patch
|
asaf
:
review+
|
Details | Diff | Splinter Review |
Implement the "Sort by name" item in the context menu of the places view.
Reporter | ||
Comment 1•19 years ago
|
||
It might be nice to add the sorting function to the bookmark service so anybody could easily call it.
Priority: -- → P4
Target Milestone: --- → Firefox 2 alpha2
Updated•17 years ago
|
Assignee: bugs → nobody
Priority: P4 → --
Whiteboard: [Fx2-parity]
Target Milestone: Firefox 2 alpha2 → Firefox 3
Assignee | ||
Comment 3•17 years ago
|
||
Is this command supposed to just change the sort such that the tree is sorted by title, or is it supposed to take the contents of the folder that was context-clicked and sorts the underlying data permanently?
Comment 4•17 years ago
|
||
The later.
Assignee | ||
Comment 5•17 years ago
|
||
This is a work in progress. It sorts by name, but doesn't update the UI properly. The code in nsNavBookmarks::SetItemIndex needs to be updated to ensure this.
Assignee | ||
Comment 6•17 years ago
|
||
Assignee: nobody → enndeakin
Attachment #260666 -
Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #261901 -
Flags: review?
Assignee | ||
Updated•17 years ago
|
Attachment #261901 -
Flags: review? → review?(dietrich)
Comment 7•17 years ago
|
||
Comment on attachment 261901 [details] [diff] [review] add sort by name function >Index: browser/components/places/content/controller.js >=================================================================== >RCS file: /cvsroot/mozilla/browser/components/places/content/controller.js,v >retrieving revision 1.141 >diff -u -p -8 -r1.141 controller.js >--- browser/components/places/content/controller.js 30 Mar 2007 23:16:24 -0000 1.141 >+++ browser/components/places/content/controller.js 18 Apr 2007 00:31:43 -0000 >@@ -200,16 +200,20 @@ PlacesController.prototype = { > // children of a live bookmark (legacy bookmarks UI doesn't support > // this) > if (PlacesUtils.nodeIsURI() && > PlacesUtils.nodeIsLivemarkItem(selectedNode)) > return true; > #endif > } > return false; >+ case "placesCmd_sortby:name": "sortBy" would be more in line with the style here. > /** >+ * Changes the index for a bookmark item. >+ */ >+ void setItemIndex(in PRInt64 id, in PRInt32 index); >+ can you add @param documentation for this? > NS_IMETHODIMP >+nsNavBookmarks::SetItemIndex(PRInt64 aItemId, PRInt32 aNewIndex) >+{ >+ nsresult rv; >+ PRInt32 type = 0; >+ PRInt32 oldIndex = 0; >+ PRInt64 parent = 0; >+ PRInt64 folderKey = -1; >+ >+ mozIStorageConnection *dbConn = DBConn(); >+ nsCOMPtr<nsIURI> uri; >+ { >+ nsCOMPtr<mozIStorageStatement> getStatement; >+ rv = dbConn->CreateStatement(NS_LITERAL_CSTRING( >+ "SELECT b.type, p.url, b.position, b.parent, b.fk " >+ "FROM moz_bookmarks b " >+ "JOIN moz_places p ON b.fk = p.id " >+ "WHERE b.id = ?1"), >+ getter_AddRefs(getStatement)); >+ NS_ENSURE_SUCCESS(rv, rv); >+ can you add the type column to the mDBGetBookmarkProperties statement and use that, instead of creating a new one? >+ >+ if (type == TYPE_FOLDER) { >+ ENUMERATE_WEAKARRAY(mObservers, nsINavBookmarkObserver, >+ OnFolderRemoved(folderKey, parent, oldIndex)) >+ ENUMERATE_WEAKARRAY(mObservers, nsINavBookmarkObserver, >+ OnFolderAdded(folderKey, parent, aNewIndex)) >+ } >+ else if (type == TYPE_SEPARATOR) { >+ ENUMERATE_WEAKARRAY(mObservers, nsINavBookmarkObserver, >+ OnSeparatorRemoved(parent, oldIndex)) >+ ENUMERATE_WEAKARRAY(mObservers, nsINavBookmarkObserver, >+ OnSeparatorAdded(parent, aNewIndex)) >+ } >+ else { >+ ENUMERATE_WEAKARRAY(mObservers, nsINavBookmarkObserver, >+ OnItemRemoved(aItemId, uri, parent, oldIndex)) >+ ENUMERATE_WEAKARRAY(mObservers, nsINavBookmarkObserver, >+ OnItemAdded(aItemId, uri, parent, aNewIndex)) >+ } yikes, there's got to be a better way. can you file a followup bug for using onItemChanged for this?
Attachment #261901 -
Flags: review?(dietrich) → review-
Assignee | ||
Comment 8•17 years ago
|
||
Attachment #261901 -
Attachment is obsolete: true
Attachment #262033 -
Flags: review?(dietrich)
Comment 9•17 years ago
|
||
Comment on attachment 262033 [details] [diff] [review] address review comments r=me, please have mano do a pass on this as well. thanks neil! > /** >+ * Changes the index for a bookmark item. This method does not change >+ * the indicies of any other bookmarks in the same folder. nit: s/indicies/indices/
Attachment #262033 -
Flags: review?(dietrich) → review+
Comment 10•17 years ago
|
||
(In reply to comment #9) > (From update of attachment 262033 [details] [diff] [review]) > r=me, please have mano do a pass on this as well. thanks neil! > > > /** > >+ * Changes the index for a bookmark item. This method does not change > >+ * the indicies of any other bookmarks in the same folder. > > nit: s/indicies/indices/ > another request: please add a warning that calling setItemIndex *will* cause the indexes to be corrupted if not called for each child of a container. hrm, the whole deal should probably be moved into the bookmarks service at some point, would be safer.
Assignee | ||
Comment 11•17 years ago
|
||
Attachment #262037 -
Flags: review?(mano)
Comment 12•17 years ago
|
||
Comment on attachment 262037 [details] [diff] [review] adjust comments >Index: browser/components/places/content/controller.js >=================================================================== >@@ -200,16 +200,20 @@ PlacesController.prototype = { > // children of a live bookmark (legacy bookmarks UI doesn't support > // this) > if (PlacesUtils.nodeIsURI() && > PlacesUtils.nodeIsLivemarkItem(selectedNode)) > return true; > #endif > } > return false; >+ case "placesCmd_sortBy:name": >+ if (this._view.selectedNode) >+ return PlacesUtils.nodeIsFolder(this._view.selectedNode); This allows sorting a read-only folder (e.g. livemark-containers). > onEvent: function PC_onEvent(eventName) { }, >@@ -442,21 +449,21 @@ PlacesController.prototype = { > // be filtered (e.g. left list). > var enoughChildrenToSort = false; > if (PlacesUtils.nodeIsFolder(sortFolder)) { > var folder = asFolder(sortFolder); > var contents = this.getFolderContents(folder.folderId, false, false); > enoughChildrenToSort = contents.childCount > 1; > } > var metadata = this._buildSelectionMetadata(); >- this._setEnabled("placesCmd_sortby:name", >+ this._setEnabled("placesCmd_sortBy:name", > (sortingChildren || !inSysArea) && canInsert && viewIsFolder && > !("mixed" in metadata) && enoughChildrenToSort); > >- var command = document.getElementById("placesCmd_sortby:name"); >+ var command = document.getElementById("placesCmd_sortBy:name"); > just remove this code, it's no longer used. > /** >+ * Sort a folder by name >+ */ s/ a / the selected/ ? > /** >+ * Sort a folder by name >+ */ >+function PlacesSortFolderByNameTransaction(aFolderId, aFolderIndex) { >+ this._folderId = aFolderId; >+ this._folderIndex = aFolderIndex; >+ this._oldOrder = null, >+ this.redoTransaction = this.doTransaction; >+} >+PlacesSortFolderByNameTransaction.prototype = { >+ __proto__: PlacesBaseTransaction.prototype, >+ >+ doTransaction: function PSSFBN_doTransaction() { >+ this._oldOrder = []; >+ >+ var items = []; >+ var contents = PlacesUtils.getFolderContents(this._folderId, false, false); s/PlacesUtils/this.utils/ >Index: toolkit/components/places/src/nsNavBookmarks.cpp >=================================================================== >+ if (type == TYPE_FOLDER) { >+ ENUMERATE_WEAKARRAY(mObservers, nsINavBookmarkObserver, >+ OnFolderRemoved(folderKey, parent, oldIndex)) >+ ENUMERATE_WEAKARRAY(mObservers, nsINavBookmarkObserver, >+ OnFolderAdded(folderKey, parent, aNewIndex)) >+ } >+ else if (type == TYPE_SEPARATOR) { >+ ENUMERATE_WEAKARRAY(mObservers, nsINavBookmarkObserver, >+ OnSeparatorRemoved(parent, oldIndex)) >+ ENUMERATE_WEAKARRAY(mObservers, nsINavBookmarkObserver, >+ OnSeparatorAdded(parent, aNewIndex)) >+ } >+ else { >+ ENUMERATE_WEAKARRAY(mObservers, nsINavBookmarkObserver, >+ OnItemRemoved(aItemId, uri, parent, oldIndex)) >+ ENUMERATE_WEAKARRAY(mObservers, nsINavBookmarkObserver, >+ OnItemAdded(aItemId, uri, parent, aNewIndex)) >+ } >+ >+ return NS_OK; >+} So it would be nice if we could somehow batch the setItemIndex calls and then call invalidateContainer... file a bug please.
Attachment #262037 -
Flags: review?(mano) → review-
Assignee | ||
Comment 13•17 years ago
|
||
Attachment #262037 -
Attachment is obsolete: true
Attachment #262117 -
Flags: review?(mano)
Comment 14•17 years ago
|
||
Comment on attachment 262117 [details] [diff] [review] address review comments You were looking for PlacesUtils.folderIsReadonly as a general solution. Either way, nodeIsLivemarkItem checks if whether a node is a _child_ of a live bookmark
Attachment #262117 -
Flags: review?(mano) → review-
Assignee | ||
Comment 15•17 years ago
|
||
mano, so something like the following: case "placesCmd_sortBy:name": var selectedNode = this._view.selectedNode; return selectedNode && PlacesUtils.nodeIsFolder(selectedNode) && !PlacesUtils.nodeIsReadOnly(selectedNode);
Comment 16•17 years ago
|
||
Seems right.
Assignee | ||
Comment 17•17 years ago
|
||
Attachment #262117 -
Attachment is obsolete: true
Attachment #262490 -
Flags: review?(mano)
Comment 18•17 years ago
|
||
Comment on attachment 262490 [details] [diff] [review] check folders properly r=mano
Attachment #262490 -
Flags: review?(mano) → review+
Updated•17 years ago
|
Target Milestone: Firefox 3 → Firefox 3 alpha4
Assignee | ||
Comment 19•17 years ago
|
||
The patch in bug 376863 caused this to stop working, because the folders don't set the bookmarkId anymore. So what should I be using instead?
Comment 20•17 years ago
|
||
folderId for folder (asFolder(node).folderId that is). Dietrich has a bug on unifying the two, I think.
Comment 21•17 years ago
|
||
(In reply to comment #20) > folderId for folder (asFolder(node).folderId that is). > > Dietrich has a bug on unifying the two, I think. > neil, you should still use mano's recommendation for getting the folder id. my patch changed the source of the folder ids, but not the accessor.
Comment 22•17 years ago
|
||
yeah well, i'm planning to merge the two soon enough.
Comment 23•17 years ago
|
||
...and this is done now, the generic node interface has an itemId attribute.
Updated•17 years ago
|
Target Milestone: Firefox 3 alpha4 → Firefox 3 alpha5
Assignee | ||
Comment 24•17 years ago
|
||
Attachment #262033 -
Attachment is obsolete: true
Attachment #262490 -
Attachment is obsolete: true
Attachment #264466 -
Flags: review?
Assignee | ||
Updated•17 years ago
|
Attachment #264466 -
Flags: review? → review?(mano)
Comment 25•17 years ago
|
||
Comment on attachment 264466 [details] [diff] [review] update for itemid >Index: toolkit/components/places/public/nsINavBookmarksService.idl >=================================================================== > /** >+ * Changes the index for a bookmark item. This method does not change >+ * the indices of any other bookmarks in the same folder, so ensure that >+ * the new index does not already exist, or change the index of other >+ * bookmarks accordingly, otherwise the bookmark indices will become >+ * corrupted. >+ * >+ * @param id The bookmark id to modify >+ * @param index The new index >+ */ >+ void setItemIndex(in PRInt64 id, in PRInt32 index); >+ nit: use long long and long here. r=mano otherwise.
Attachment #264466 -
Flags: review?(mano) → review+
Comment 26•17 years ago
|
||
nit #2: aItemId and aIndex to match other methods. you should also remove "bookmark" from the method documentation - this method applies to all item types (bookmarks, folders and separators).
Assignee | ||
Updated•17 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Comment 27•17 years ago
|
||
verified with Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.9a7pre) Gecko/2007070504 Minefield/3.0a7pre
Status: RESOLVED → VERIFIED
Comment 28•17 years ago
|
||
Added test case http://litmus.mozilla.org/show_test.cgi?searchType=by_id&id=4454 to Litmus FFT
Flags: in-testsuite+
Updated•17 years ago
|
Flags: in-testsuite+ → in-litmus+
Comment 29•15 years ago
|
||
Bug 451915 - move Firefox/Places bugs to Firefox/Bookmarks and History. Remove all bugspam from this move by filtering for the string "places-to-b-and-h". In Thunderbird 3.0b, you do that as follows: Tools | Message Filters Make sure the correct account is selected. Click "New" Conditions: Body contains places-to-b-and-h Change the action to "Delete Message". Select "Manually Run" from the dropdown at the top. Click OK. Select the filter in the list, make sure "Inbox" is selected at the bottom, and click "Run Now". This should delete all the bugspam. You can then delete the filter. Gerv
Component: Places → Bookmarks & History
QA Contact: places → bookmarks
You need to log in
before you can comment on or make changes to this bug.
Description
•