Example #1
0
/********************************************************************************************

>	FormatEntry* FilterManager::FindFormatEntryFromID(const FileFormatID) const

	Author:		Colin_Barfoot (Xara Group Ltd) <*****@*****.**>
	Created:	10/12/96
	Purpose:	Internally does the actual finding by ID
	See Also:	FindFormatFromID

********************************************************************************************/
FormatEntry* FilterManager::FindFormatEntryFromID(const FileFormatID FormatID) const
{
	ERROR2IF(FormatID == 0 || FormatID > GetLastFormatID(), NULL, 
				"Invalid FileFormatID");

	return GetFormats()[FormatID - 1];
}
Example #2
0
/********************************************************************************************

>	FileFormatID FilterManager::RegisterFileFormat(const FileFormat* pFormat, 
												const DESTRUCTION_METHOD dm)

	Author:		Colin_Barfoot (Xara Group Ltd) <*****@*****.**>
	Created:	10/12/96
	Inputs:		pFormat:	A pointer to the FileFormat to register
	Returns:	A FileFormatID by which the given FileFormat can be uniquely identified and
				quickly retrieved.
	Purpose:	Registers the given FileFormat with this FilterManager

********************************************************************************************/
FileFormatID FilterManager::RegisterFileFormat(	FileFormat* const pFormat, 
												const DESTRUCTION_METHOD DestructMethod)
{
	ERROR2IF(pFormat == NULL, 0, "NULL Args");

	// Look for one we might already have
	FileFormatID IDToReturn = FindFormatIDFromName(pFormat->GetName());
	if (IDToReturn == 0)
	{
		// Have to add a new one
		IDToReturn = GetNewFormatID();
		FormatEntry* pFormatEntry = new FormatEntry(IDToReturn, pFormat, DestructMethod);
		if (pFormatEntry == NULL)
		{
			goto AddFormatError;
		}

		if (!GetFormats().Add(pFormatEntry))
		{
			delete pFormatEntry;
			goto AddFormatError;
		}
	}
	else
	{
		// Use the duplicate then
	}
	
	return IDToReturn;

AddFormatError:

	return 0;
}
Example #3
0
BOOL FilterManager::DeInit()
{
	for (UINT32 index = 0; index < GetLastFormatID(); index++)
	{
		FormatEntry* pEntry = GetFormats()[index];
		ERROR2IF(pEntry == NULL, FALSE, "pEntry NULL");

		FileFormat* pFormat = pEntry->GetFormat();
		ERROR2IF(pFormat == NULL, FALSE, "pFormat NULL");

		if (pEntry->GetDestructionMethod() == DM_DELETE_WHEN_DONE)
		{
			delete pFormat;
		}
		delete pEntry;
		GetFormats()[index] = NULL;
	}

	// All ok
	return TRUE;
}
Example #4
0
ChannelTVFormat::ChannelTVFormat(const ChannelID &id) :
    ComboBoxSetting(this), ChannelDBStorage(this, id, "tvformat")
{
    setLabel(QCoreApplication::translate("(ChannelSettings)", "TV Format"));
    setHelpText(QCoreApplication::translate("(ChannelSettings)",
        "If this channel uses a format other than TV Format in the General "
        "Backend Setup screen, set it here."));

    addSelection(QCoreApplication::translate("(Common)", "Default"), "Default");

    QStringList list = GetFormats();
    for (int i = 0; i < list.size(); i++)
        addSelection(list[i]);
}
Example #5
0
ChannelTVFormat::ChannelTVFormat(const ChannelID &id) :
    ComboBoxSetting(this), ChannelDBStorage(this, id, "tvformat")
{
    setLabel(QObject::tr("TV Format"));
    setHelpText(
        QObject::tr(
            "If this channel uses a format other than TV "
            "Format in the General Backend Setup screen, set it here."));

    addSelection(QObject::tr("Default"), "Default");

    QStringList list = GetFormats();
    for (uint i = 0; i < list.size(); i++)
        addSelection(list[i]);
}
Example #6
0
/********************************************************************************************

>	FormatEntry* FilterManager::FindFormatEntryFromName(const StringBase& FormatName) const

	Author:		Colin_Barfoot (Xara Group Ltd) <*****@*****.**>
	Created:	10/12/96
	Inputs:		FormatName:	The name of a FileFormat given in the FileFormat's constructor
							which has subsequently been Added to this FilterManager.
	Returns:	A pointer to the FileFormat with the name given or NULL if none was found
	Purpose:	Finds the one & only FileFormat with the given FormatName
				Used by Xtra's mainly

********************************************************************************************/
FormatEntry* FilterManager::FindFormatEntryFromName(const StringBase& FormatName) const
{
	for (UINT32 index = 0; index < GetLastFormatID(); ++index)
	{
		FormatEntry* pFormatEntry = GetFormats()[index];
		if (pFormatEntry != NULL)
		{
			FileFormat* pFormat = pFormatEntry->GetFormat();
			if (pFormat->GetName() == FormatName)
			{
				return pFormatEntry;
			}
		}
		else
		{
			// we'll ignore this one
		}
	}

	return NULL;
}