⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 engine.h

📁 《UIQ 3 The Complete Guide》书的源代码
💻 H
字号:
//
// Engine.h - SignedApp Engine
//
// Copyright (C) UIQ Technology AB, 2007
//
// This material is provided "as is" without any warranty to its performance or functionality. 
// In no event shall UIQ Technology be liable for any damages whatsoever arising out of the
// use or inabilty to use this material. 
//

#ifndef __ENGINE_H__
#define __ENGINE_H__

// these pragmas stop the compiler complaining that params to functions not being used in body
#ifdef __CW32__
#pragma warn_unusedarg off
#endif // __CW32__
#pragma warning(disable : 4100)

#include <e32std.h>
#include <e32base.h>
#include <f32file.h>
#include <s32file.h>


/////////////////////////////////////////////////////////////////////////////////////////////
// a class representing each of the possible categories

const TInt KCategoryNameMaxLength=20;

class TAppCategoryEntry
	{
public:
	void ExternalizeL(RWriteStream& aStream) const;
	void InternalizeL(RReadStream& aStream);
public:
	TInt iCategoryId;								// Id assigned to the category name
	TBuf<KCategoryNameMaxLength> iCategoryName;		// textual name of the category
	};

/////////////////////////////////////////////////////////////////////////////////////////////
enum TFolderEntrySortType
	{
	EFolderEntrySortByName,			// deliberately first so defines the default sort order
	EFolderEntrySortBySize,
	EFolderEntrySortByModified,
	EFolderEntrySortByType,

	EFolderEntrySortLastItem
	};

enum TFolderEntrySortOrder
	{
	ESortOrderAscending,
	ESortOrderDescending
	};

class TFolderEntry
	{
protected:

public:
	void Construct(const TEntry& aItem);

	inline TInt EntryCategory() const {return(iCategory);};
	inline TInt EntrySize() const {return(iSize);};
	inline TTime EntryModified() const {return(iModified);};
	inline const TDesC& EntryName() const {return(iName);};

	inline void UpdateCategory(const TInt aCategory) {iCategory=aCategory;};
	inline void UpdateName(const TDesC& aName) {iName=aName;};
	inline void UpdateModified(const TTime& aTime) {iModified=aTime;};

	void ExternalizeL(RWriteStream& aStream) const;
	void InternalizeL(RReadStream& aStream);
protected:
	TInt iCategory;					// which UI category the entry is assigned

	TUint iAttributes;				// entry attributes, e.g. KEntryAttNormal,KEntryAttHidden
	TInt iSize;						// size of the entry, in bytes
	TTime iModified;				// time of last modification, in universal time.
	TUidType iUidType;				// the entry's UIDtype
	TBuf<KMaxFileName> iName;		// name of the entry
	};

/////////////////////////////////////////////////////////////////////////////////////////////
class CAppEngine : public CBase
	{
protected:
#ifdef _DEBUG
	void Panic(const TInt aReason) const;
	void __DbgTestInvariant() const;
#endif // _DEBUG

	CArrayFixFlat<TInt>* BuildIndexL(RArray<TFolderEntry>* aList,const TInt aCategory);
	void BuildDirectoryListL(const TDesC& aPath);

	TInt EntryListCount() const;
	TFolderEntry& EntryListAt(const TInt aIndex) const;
	void LimitCurrentEntryVal();

public:
	~CAppEngine();
	CAppEngine(RFs& aFs,const TInt aZoomLevel);
	void ConstructL();
	void SetDefaultPathL(const TDesC& aPath);

	// entry support in the engine
	void UpdateCurrentEntryL(const TFolderEntry& aUpdate);
	TInt EntryCount() const;
	const TFolderEntry& Entry(const TInt aIndex) const;
	const TFolderEntry& CurrentEntry() const;
	void SetCurrentEntry(const TInt aIndex);
	inline TInt CurrentEntryIndex() const {return(iCurrentEntry);};
	void EntryFullName(TDes& aName);
	void DeleteCurrentEntryL();

	// category support in the engine
	TInt CategoryListCount() const;
	TAppCategoryEntry& CategoryListAt(const TInt aIndex) const;
	inline TInt CurrentCategory() const {return(iCurrentCategory);};
	void AddCategoryL(const TInt aHandle,const TDesC& aName);
	void UpdateCategoryName(const TInt aHandle,const TDesC& aNewName);
	TInt DeleteCategoryL(const TInt aHandle);
	void ChangeCategoryL(const TInt aHandle);

	// sort support in the engine
	inline TFolderEntrySortType SortType() const {return(iSortType);};
	inline TFolderEntrySortOrder SortOrder() const {return(iSortOrder);};
	void SortEntries(const TFolderEntrySortType aSortType,const TFolderEntrySortOrder aOrder);

	inline TInt ListViewZoomState() const {return(iZoomLevel);};
	TInt SetListViewZoomState(const TInt aZoomLevel);

	// the << and >> operators dictate the method names to handle ld/save
	void ExternalizeL(RWriteStream& aStream) const;
	void InternalizeL(RReadStream& aStream);

protected:
	RFs& iFs;								// our connection to the File Server process
	TInt iZoomLevel;						// list view zoom level

	// the list of items being manipulated
	RArray<TFolderEntry>* iFolderEntryList;
	TFileName iPath;						// path to files being manipulated

	// support for sorting and filtering
	TFolderEntrySortType iSortType;			// what the current sort mode is
	TFolderEntrySortOrder iSortOrder;		// whether current list is sorted in descending order or not
	TInt iCurrentEntry;						// which entry the UI perceives as the current one
	CArrayFixFlat<TInt>* iFolderEntryIndex;

	// category support
	TInt iCurrentCategory;					// users currently chosen category
	RArray<TAppCategoryEntry>* iCategoryList;	// list of categories we have
	};


#endif // __ENGINE_H__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -