27 #ifndef __SBLOCALDATABASETREEVIEW_H__
28 #define __SBLOCALDATABASETREEVIEW_H__
32 #include <nsIClassInfo.h>
33 #include <nsIObserver.h>
34 #include <nsITreeView.h>
35 #include <nsITreeSelection.h>
36 #include <nsIWeakReference.h>
37 #include <nsIWeakReferenceUtils.h>
39 #include <sbILocalDatabaseGUIDArray.h>
40 #include <sbILocalDatabaseTreeView.h>
41 #include <sbIMediacoreEventListener.h>
42 #include <sbIMediaListViewTreeView.h>
43 #include <sbIMediaListViewSelection.h>
44 #include <sbIPlayQueueService.h>
47 #include <nsDataHashtable.h>
48 #include <nsInterfaceHashtable.h>
49 #include <nsISerializable.h>
50 #include <nsClassHashtable.h>
51 #include <nsStringGlue.h>
53 #include <nsTObserverArray.h>
57 class nsIObjectInputStream;
58 class nsIObjectOutputStream;
59 class nsISupportsArray;
60 class nsITreeBoxObject;
62 class nsITreeSelection;
93 typedef nsresult (*PR_CALLBACK sbSelectionEnumeratorCallbackFunc)
94 (PRUint32 aIndex,
const nsAString& aId,
const nsAString& aGuid,
void* aUserData);
101 NS_DECL_SBILOCALDATABASEGUIDARRAYLISTENER
102 NS_DECL_SBIMEDIALISTVIEWTREEVIEW
103 NS_DECL_SBILOCALDATABASETREEVIEW
104 NS_DECL_SBIMEDIACOREEVENTLISTENER
105 NS_DECL_SBIMEDIALISTVIEWSELECTIONLISTENER
106 NS_DECL_SBIPLAYQUEUESERVICELISTENER
129 nsISupportsArray* aAtomArray);
142 enum PageCacheStatus {
154 nsresult GetPropertyForTreeColumn(nsITreeColumn* aTreeColumn,
155 nsAString& aProperty);
157 nsresult GetTreeColumnForProperty(
const nsAString& aProperty,
158 nsITreeColumn** aTreeColumn);
160 nsresult GetCellPropertyValue(PRInt32 aIndex,
161 nsITreeColumn *aTreeColumn,
164 nsresult SaveSelectionList();
166 nsresult RestoreSelection();
168 nsresult EnumerateSelection(sbSelectionEnumeratorCallbackFunc aFunc,
171 nsresult GetUniqueIdForIndex(PRUint32 aIndex, nsAString& aId);
173 void SetSelectionIsAll(PRBool aSelectionIsAll);
175 void ClearSelectionList();
177 nsresult UpdateColumnSortAttributes(
const nsAString& aProperty,
180 static nsresult PR_CALLBACK
181 SelectionListSavingEnumeratorCallback(PRUint32 aIndex,
182 const nsAString& aId,
183 const nsAString& aGuid,
186 static nsresult PR_CALLBACK
187 SelectionListGuidsEnumeratorCallback(PRUint32 aIndex,
188 const nsAString& aId,
189 const nsAString& aGuid,
192 inline PRUint32 TreeToArray(PRInt32 aRow) {
193 return (PRUint32) (mFakeAllRow ? aRow - 1 : aRow);
196 inline PRUint32 ArrayToTree(PRUint32 aIndex) {
197 return (PRInt32) (mFakeAllRow ? aIndex + 1 : aIndex);
200 inline PRBool IsAllRow(PRInt32 aRow) {
201 return mFakeAllRow && aRow == 0;
204 inline nsresult GetColumnPropertyInfo(nsITreeColumn* aColumn,
207 nsresult GetPropertyInfoAndValue(PRInt32 aRow,
208 nsITreeColumn* aColumn,
212 nsresult GetPlayingProperty(PRUint32 aIndex,
213 nsISupportsArray* properties);
215 nsresult GetOriginNotInMainLibraryProperty(PRUint32 aIndex,
216 nsISupportsArray* properties);
218 nsresult GetItemDisabledStatus(PRUint32 aIndex,
219 nsISupportsArray* properties);
221 nsresult GetPlayQueueStatus(PRUint32 aIndex,
222 nsISupportsArray* properties);
224 nsresult GetIsListReadOnly(PRBool *aOutIsReadOnly);
226 nsresult GetBag(PRUint32 aIndex,
229 nsresult GetBag(
const nsAString& aGuid,
233 nsCOMPtr<sbIPropertyManager> mPropMan;
236 PRBool mViewingDeviceContent;
239 MediaListType mListType;
247 nsCOMPtr<sbILocalDatabaseGUIDArray> mArray;
250 PRUint32 mArrayLength;
257 nsCOMPtr<sbILocalDatabasePropertyCache> mPropertyCache;
260 nsString mCurrentSortProperty;
264 nsCOMPtr<nsITreeSelection> mRealSelection;
265 nsCOMPtr<nsITreeBoxObject> mTreeBoxObject;
268 nsCOMPtr<nsIWeakReference> mObserver;
271 PRBool mManageSelection;
275 PRBool mHaveSavedSelection;
279 PRUint32 mMouseState;
280 PRInt32 mMouseStateRow;
281 nsCOMPtr<nsITreeColumn> mMouseStateColumn;
284 nsString mPlayingItemUID;
285 nsCOMPtr<nsIWeakReference> mMediacoreManager;
288 PRPackedBool mSelectionIsAll;
291 PRPackedBool mCurrentSortDirectionIsAscending;
294 PRPackedBool mFakeAllRow;
297 PRPackedBool mIsListeningToPlayback;
300 PRPackedBool mShouldPreventRebuild;
302 nsString mLocalizedAll;
304 static PRInt32
const NOT_SET = -1;
306 PRInt32 mFirstCachedRow;
307 PRInt32 mLastCachedRow;
310 nsCOMPtr<sbIPlayQueueService> mPlayQueueService;
313 PRUint32 mPlayQueueIndex;
327 GuidArray() : mItems(0) {}
331 void SetCapacity(PRUint32 aCapacity) {
332 mTempGuids.SetCapacity(aCapacity);
333 mTempGuidChars.SetCapacity(aCapacity);
339 nsresult Append(nsString
const & aGuid) {
341 if (mItems < mTempGuids.Length()) {
342 mTempGuids[mItems] = aGuid;
343 mTempGuidChars[mItems] = mTempGuids[mItems].get();
347 NS_ASSERTION(mItems == mTempGuids.Length(),
348 "sbLocalDatabaseTreeView::GuidArray's array is out of sync");
349 nsString * newGuid = mTempGuids.AppendElement(aGuid);
350 NS_ENSURE_TRUE(newGuid, NS_ERROR_OUT_OF_MEMORY);
352 mTempGuidChars.AppendElement(newGuid->get());
366 PRUint32 Length()
const {
372 PRUnichar
const *
const * AsCharArray()
const {
373 return mTempGuidChars.Elements();
376 nsTArray<nsString> mTempGuids;
377 nsTArray<PRUnichar const *> mTempGuidChars;
380 GuidArray mGuidWorkArray;
388 NS_DECL_NSISERIALIZABLE
nsDataHashtable< nsStringHashKey, nsString > sbSelectionList
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
NS_DECL_ISUPPORTS NS_DECL_NSICLASSINFO NS_DECL_NSIOBSERVER NS_DECL_NSITREEVIEW NS_DECL_SBILOCALDATABASEGUIDARRAYLISTENER NS_DECL_SBIMEDIALISTVIEWTREEVIEW NS_DECL_SBILOCALDATABASETREEVIEW NS_DECL_SBIMEDIACOREEVENTLISTENER NS_DECL_SBIMEDIALISTVIEWSELECTIONLISTENER NS_DECL_SBIPLAYQUEUESERVICELISTENER sbLocalDatabaseTreeView()
sbSelectionList mSelectionList
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
nsresult TokenizeProperties(const nsAString &aProperties, nsISupportsArray *aAtomArray)
Parses a string and separates space-delimited substrings into nsIAtom elements.
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
~sbLocalDatabaseTreeView()
void SetShouldPreventRebuild(PRBool aShouldPreventRebuild)
sbLocalDatabaseTreeViewState()
nsCOMPtr< sbILibrarySort > mSort
PRBool GetShouldPreventRebuild()
nsresult Init(sbLocalDatabaseMediaListView *aListView, sbILocalDatabaseGUIDArray *aArray, sbIPropertyArray *aCurrentSort, sbLocalDatabaseTreeViewState *aState)
Listener for the Play Queue service.
nsresult OnTrackIndexChange(sbIMediacoreEvent *aEvent)
An interface used to describe a metadata property for use by the UI and other sbILibrary interfaces (...
PRPackedBool mSelectionIsAll
Media library abstraction.
A sort that can be applied to a media list view.
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
void ClearMediaListView()
nsresult ToString(nsAString &aStr)
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
nsresult GetState(sbLocalDatabaseTreeViewState **aState)
An interface to carry around arrays of nsIProperty instances. Users of this interface should only QI ...
Manager for system wide metadata properties.
NS_DECL_ISUPPORTS NS_DECL_NSISERIALIZABLE nsresult Init()