This class is used to create module lists. A module list is the list of files the user has added in APlayer. If you want to access this list, you can use this class. All the items in the list are of the APModuleListItem type. This class hold what type of file the current item is, the filename etc. If you want to show the module list to the user, like in the module list editor, you have to add a list view with the AddModuleList() function. When you then need to access the items in the list, do not use the functions in your list view, but use the functions in the APModuleList class instead. This class will then make sure, all the changes you made, like adding a new item, will be processed on all the list views added. This make sure the data is coincident everywhere.
Derived from: BStringItem on BeOS
Declared in: APModuleList.h
APModuleListItem(PString text, PString fileName);
It initialize all the member variables. The arguments are the string you want to be showed in the list view and the filename with full path. If the file is an archive, the fileName argument is the file inside the archive with path. The constructor sets the item type to Normal.
virtual ~APModuleListItem(void);
Does nothing.
PString GetFileName(void);
Returns the filename you have given in the constructor.
ItemType GetItemType(void);
Returns the type of the current item. The type can be one of the following:
Name | Description |
Normal | The item is just a normal item, which means it points to a file and not an archive. |
bool IsPlaying(void);
Returns true if the current item is the one APlayer is playing, else false.
void SetPlayingFlag(bool flag);
Call this function to change the playing state of the item. If the flag is true, the item will be drawn with another color than the standard one. If it's false, the standard color is used. This is used to indicate what item APlayer currently plays.
Derived from: None
Declared in: APModuleList.h
APModuleList(APGlobalData *globalData);
It initialize all the member variables. The argument is a pointer to the global data area class.
virtual ~APModuleList(void);
Does nothing.
void AddModuleListItem(APModuleListItem *item, index = -1, bool callPlugins = true); void AddModuleListItem(PList<APModuleListItem *> &list, int32 index = -1, bool callPlugins = true);
This function will add a module item to all the module lists stored in the global module list at the index given. If the index is -1, it will add the item to the end of the lists. There will be made a copy of the item you give, so it's save to delete it after calling this function. If the callPlugins argument is true, it will call all plug-ins which have plugged-in in the AfterAddingFiles place. If you want to add a lot of items, you can set this to false and when you adding the last item, you can set it to true or you can call the CallAfterAddingFilesPlugins() function in the global data area when you're done.
The second version will add a whole list of items to the list. There will also be made a copy of each item, so you have to delete the list you give by yourself.
If the item you add is an archive item, it will get all the names in the archive and add them. See also the AddModuleList() function.
void AddModuleList(BListView *list);
Windows:
void AddModuleList(CListBox *list);
If you have a list you want to use as a module list, like the one in the main window, you had to add your list to the global module list. APlayer will then add or remove module names to your list every time it needs it. If you want to add or remove something to all the module lists, you should call the AddModuleListItem() or the RemoveModuleListItem() functions.
void AppendModuleList(PString fileName, int32 index = -1); throw(PFileException);
This function will append a module list file to the current module list. The arguments is the filename with full path to the file to load and where to insert the new list. If the last argument is -1, the list will be added to the end of the current list.
ListType CheckModuleListFile(PString fileName); throw(PFileException);
This function will check a file to see if it's one of the supported module list formats. The function will return the result of the test, and the value can be one of the following: Unknown, APlayer, CL_Amp, SoundPlay and WinAmp.
int32 CountModuleItems(void);
If you need the number of items in the module list, you can call this function. It will return the number of items in the list.
void LockList(void);
This function will lock the module lists, so you are the only one which access them. You have to call this function if you want to access your own list by yourself and not with the functions in this class or if you want to do multiple things on the list. Use UnlockList() to unlock the lists again.
bool LockListWithTimeout(uint32 timeout);
This function will lock the module lists using the timeout value you give on each lock call, so you are the only one which access them. If the function couldn't get access to all the lists, it will return false. It will return true if all the lists has been locked. The argument is the timeout in milliseconds. You have to call this function if you want to access your own list by yourself and not with the functions in this class or if you want to do multiple things on the list. Use UnlockList() to unlock the lists again.
void MoveModuleListItem(int32 oldIndex, int32 newIndex);
If you want to move a module item to another place in the module list, you can use this function. It will move the item at the index you give as the first argument to the new position given in the second argument. Both arguments indexes indicates the indexes before anything is done.
void MoveModuleListItemToBottom(int32 index);
If you want to move a module item to the bottom of the module lists, you can use this function. It will move the item at the index you give to the bottom of all the lists.
void MoveModuleListItemToTop(int32 index);
If you want to move a module item to the top of the module lists, you can use this function. It will move the item at the index you give to the top of all the lists.
void RemoveModuleItems(void);
This function will clear all the items in all the module lists added with the AddModuleList() function. It will call the delete operator on all the items.
void RemoveModuleList(BListView *list);
Windows:
void RemoveModuleList(CListBox *list);
This function will remove your list from the global module list. See the AddModuleList() function for more information.
void RemoveModuleListItem(int32 index, bool callPlugins = true);
This function will remove a module item from all the module lists stored in the global module list at the index given. If the callPlugins argument is true, it will call all plug-ins which have plugged-in in the AfterRemovingFiles place. If you want to remove a lot of items, you can set this to false and when your remove the last item you can set it to true or you can call the CallAfterRemovingFilesPlugins() function when you're done. See also the AddModuleList() function.
void SaveModuleList(PString fileName); throw(PFileException);
This function will save to current module list to a file. The argument is the filename with full path to save to list to. The list will be saved in APlayer module list format.
void ShuffleModuleList(int32 firstItem = -1);
This function will shuffle all the items in the module lists, which means they will be in random order. If the firstItem argument is not -1, it has to be an index number in the list to the item you want to be the first in the list. -1 means all the items will be shuffled.
void SwapModuleListItems(int32 index1, int32 index2);
This function will swap two items in the module lists. The arguments is the indexes to the items you want to be swapped.
void SortModuleList(bool ascending = true);
This function will sort the module list. You can select between ascending (A-Z) or descending (Z-A) order. Default is ascending.
void UnlockList(void);
This function will unlock the module lists again, so others can access it. See the LockList() or LockListWithTimeout() functions for more information.