--- a/taskswitcher/server/src/tsstorage.cpp Fri Sep 17 08:32:18 2010 +0300
+++ b/taskswitcher/server/src/tsstorage.cpp Mon Oct 04 00:38:31 2010 +0300
@@ -17,6 +17,8 @@
#include <tstaskmonitorglobals.h>
#include "tsstorage.h"
#include "tsmodelitemkeymsg.h"
+
+const TInt KTsDataLimit(10);
// -----------------------------------------------------------------------------
/**
* Two phase construction. Create and initialize storage instance.
@@ -199,6 +201,16 @@
// -----------------------------------------------------------------------------
/**
* Interface implementation
+ * @see MTsModel::IsMandatoryL(TInt) const
+ */
+TBool CTsStorage::IsMandatoryL( TInt aOffset ) const
+ {
+ return iData[aOffset].IsMandatoryL();
+ }
+
+// -----------------------------------------------------------------------------
+/**
+ * Interface implementation
* @see MTsModel::CloseL(TTsModelItemKey)
*/
TBool CTsStorage::CloseL( TTsModelItemKey aKey ) const
@@ -282,7 +294,8 @@
for( TInt next(prev + 1); next < iData.Count(); ++next )
{
const TTsModelItem prevItem(iData[prev]), nextItem(iData[next]);
- if( prevItem.TimestampL() < nextItem.TimestampL() )
+ if( ( !prevItem.IsMandatoryL() && nextItem.IsMandatoryL() ) ||
+ ( prevItem.TimestampL() < nextItem.TimestampL() && prevItem.IsMandatoryL() == nextItem.IsMandatoryL() ) )
{
iData.Remove(prev);
iData.InsertL(nextItem, prev);
@@ -292,4 +305,16 @@
}
}
}
+ TrimDataL();
}
+
+// -----------------------------------------------------------------------------
+void CTsStorage::TrimDataL()
+ {
+ const TInt lastItemOffset(iData.Count() -1);
+ if(KTsDataLimit <= lastItemOffset && !iData[lastItemOffset].IsMandatoryL())
+ {
+ iData.Remove(lastItemOffset);
+ TrimDataL();
+ }
+ }