class ImageViewerPresentationModel
: public IImageProviderEventListener
- , public Tizen::Io::IFileEventListener
+ , public Tizen::Content::IContentUpdateEventListener
{
public:
static ImageViewerPresentationModel* GetInstance();
virtual void OnImageReceivedN(Tizen::Base::Runtime::IEventArg& eventArg);
- virtual void OnFileEventOccured (const unsigned long events, const Tizen::Base::String &path, const unsigned int eventId);
+ //From IContentUpdateEventListener
+ virtual void OnContentFileCreated(Tizen::Content::ContentId contentId, Tizen::Content::ContentType contentType, result r);
+ virtual void OnContentFileUpdated(Tizen::Content::ContentId contentId, Tizen::Content::ContentType contentType, result r);
+ virtual void OnContentFileDeleted(Tizen::Content::ContentId contentId, Tizen::Content::ContentType contentType, result r);
+ virtual void OnContentDirectoryScanCompleted(const Tizen::Base::String& directoryPath, result r);
+
private:
ImageViewerPresentationModel(void);
static void DestroyInstance(void);
void LoadSettingValue();
- int GetImageCacheIndex(const Tizen::Base::String &path);
+ int GetImageCacheIndex(const Tizen::Base::String& );
bool GetImageRotateStatus(void) const;
private:
Tizen::Base::String __type;
int __durationOfSlideShow;
SlideShowTransitionEffect __transitionEffectOfSlideShow;
- Tizen::Io::FileEventManager* __pFileEventManager;
+ Tizen::Content::ContentManager* __pCntMgr;
SettingPresentationModel* __pSettingPresentationModel;
bool __isImageRotated;
+ bool __ivTriggeredEvent;
+ short __contentFileEventType;
+ Tizen::Content::ContentId __contentId;
+ bool __ivTriggeredDeleteEvent;
};
#endif /* _IV_VIEWER_PRESENTATION_MODEL_H_ */
GetLabelText(__pGallery->GetCurrentItemIndex(), strItemIdxText);
+ __pLabel->SetText(strItemIdxText);
+
if (__visible == true)
{
ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
void ImageViewerForm::OnFormFileEventOccuered(const int index, const unsigned long eventId)
{
AppLogDebug(" ENTER");
- bool eventDelete = (eventId & FILE_EVENT_TYPE_DELETE_SELF);
- bool eventMove = (eventId & 0x8000);// (eventId & FILE_EVENT_TYPE_MOVE_SELF);
int currentIndex = __pGallery->GetCurrentItemIndex();
- int countPath = __pPresentationModel->GetFileCount();
+ int fileCount = __pPresentationModel->GetFileCount();
- if (countPath == 0 && eventDelete)
+ if (fileCount == 0 && eventId == IV_FILE_DELETE)
{
UiApp* pApp = UiApp::GetInstance();
pApp->Terminate();
AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
}
- AppLogDebug(" countPath is %d", countPath);
- AppLogDebug(" currentIndex is %d", currentIndex);
- if (countPath == currentIndex && eventDelete)
+ if (fileCount <= currentIndex && eventId == IV_FILE_DELETE)
{
- __pGallery->SetCurrentItemIndex(--currentIndex);
+ currentIndex = fileCount - 1;
}
- else if (eventMove)
+ else if (eventId == IV_FILE_CREATE)
{
currentIndex = index;
- __pGallery->SetCurrentItemIndex(currentIndex);
}
- String strItemIdxText(EMPTY_SPACE);
+ String strItemIdxText(EMPTY_SPACE);
+ __pGallery->SetCurrentItemIndex(currentIndex);
__pGallery->UpdateGallery();
- AppLogDebug(" UpdateGallery is %d", currentIndex);
String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
__pPresentationModel->RequestImage(filePath);
, __setterIndex(0)
, __durationOfSlideShow(0)
, __transitionEffectOfSlideShow(SLIDE_SHOW_TRANSITION_EFFECT_SLIDE)
- , __pFileEventManager(null)
, __pSettingPresentationModel(null)
, __isImageRotated(false)
+ , __ivTriggeredEvent(false)
+ , __contentFileEventType(-1)
+ ,__ivTriggeredDeleteEvent(false)
{
AppLogDebug("ENTER");
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
{
AppLogDebug("ENTER");
delete __pImageCaches;
- delete __pFileEventManager;
delete __pFileUpdateListener;
+ __pCntMgr->RemoveContentUpdateEventListener(*this);
+ delete __pCntMgr;
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
}
delete __pImageCaches;
}
- __pFileEventManager = new (std::nothrow) FileEventManager;
- __pFileEventManager->Construct(*this);
__pImageCaches = new (std::nothrow) ArrayList(SingleObjectDeleter);
__pImageCaches->Construct();
__pImageEvent->AddListener(*pImageProviderEventListener, true);
__pImageProvider = ImageProvider::GetInstance();
-
+ __pCntMgr = new (std::nothrow) ContentManager;
+ __pCntMgr->Construct();
+ __pCntMgr->AddContentUpdateEventListener(*this);
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
return E_SUCCESS;
ImageViewerPresentationModel::DeleteFilePathAt(const int index)
{
AppLogDebug("ENTER");
+ __ivTriggeredEvent = true;
__pImageCaches->RemoveAt(index, true);
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
}
AppLogDebug("ENTER index(%d) filePath(%ls)", index, filePath.GetPointer());
ImageInfo* pImageInfo = static_cast<ImageInfo*>(__pImageCaches->GetAt(index));
pImageInfo->SetFilePath(filePath);
+ __ivTriggeredEvent = true;
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
}
queryString.Append(L"'");
queryString.Append(GetFileName(filePath));
queryString.Append(L"'");
-
pContentInfoList = contentSearch.SearchN(PAGE_NO_CONTENT_SEARCH, COUNT_PER_PAGE_CONTENT_SEARCH, totalPage,
totalCount, queryString, EMPTY_SPACE, SORT_ORDER_NONE);
{
continue;
}
-
if (pResultItem->GetContentInfo()->GetContentPath().CompareTo(filePath) == 0)
{
contentId = pResultItem->GetContentInfo()->GetContentId();
}
}
-int ImageViewerPresentationModel::GetImageCacheIndex(const String &path)
+int ImageViewerPresentationModel::GetImageCacheIndex(const String& afilePath)
{
int loopCount = __pImageCaches->GetCount();
- String string;
+ String filePath;
ImageInfo* pImageInfo;
for (int i = 0; i < loopCount; ++i)
{
pImageInfo = static_cast<ImageInfo*>(__pImageCaches->GetAt(i));
- string = pImageInfo->GetFilePath();
- if (string.CompareTo(path) == 0)
+ filePath = pImageInfo->GetFilePath();
+ AppLogDebug(" the filePath %ls", filePath.GetPointer());
+ if (afilePath == filePath)
{
+ AppLogDebug(" returning the index %d", i);
return i;
}
}
return __isImageRotated;
}
-void ImageViewerPresentationModel::OnFileEventOccured (const unsigned long events, const String &path, const unsigned int eventId)
+void ImageViewerPresentationModel::OnContentFileCreated(Tizen::Content::ContentId contentId, Tizen::Content::ContentType contentType, result r)
+{
+ AppLogDebug(" Enter");
+ AppLogDebug(" Exit");
+}
+void ImageViewerPresentationModel::OnContentFileUpdated(Tizen::Content::ContentId contentId, Tizen::Content::ContentType contentType, result r)
+{
+ AppLogDebug(" Enter");
+ AppLogDebug(" Exit");
+}
+void ImageViewerPresentationModel::OnContentFileDeleted(Tizen::Content::ContentId contentId, Tizen::Content::ContentType contentType, result r)
{
AppLogDebug("Enter");
- bool eventDelete = (events & FILE_EVENT_TYPE_DELETE_SELF);
- /*bool eventMove = (events & FILE_EVENT_TYPE_MOVE_SELF);
- bool eventMoveSelf = (events & 0x8000);*/
- AppLogDebug("event delete is %d", eventDelete);
- //AppLogDebug(" event move is %d", eventMoveSelf);
- int index = GetImageCacheIndex(path);
- if (index != -1 && eventDelete && GetImageRotateStatus() == false)
- {
- AppLogDebug("event index is %d, removing the index", index);
- __pImageCaches->RemoveAt(index, true);
- IEnumerator* pEventEnum = __pFileUpdateListener->GetEnumeratorN();
- IFileUpdateEventListener* pEventListener = null;
- while (pEventEnum->MoveNext() == E_SUCCESS)
- {
- pEventListener = static_cast<IFileUpdateEventListener*>(pEventEnum->GetCurrent());
- pEventListener->OnFormFileEventOccuered(index, events);
- }
- }
- /** TODO This is for rename, however there seems to be some problem with OnFileEventOccured.
- * It is returning 0x8000(which is an illegal value) for move, and File::GetAttributes(path, attr);
- * returns E_FILE_NOT_FOUND for renamed file
- if (eventMoveSelf)
+ __contentId = contentId;
+ __ivTriggeredDeleteEvent = true;
+ AppLogDebug("Exit");
+}
+void ImageViewerPresentationModel::OnContentDirectoryScanCompleted(const Tizen::Base::String& filePath, result r)
+{
+ AppLogDebug(" Enter");
+ AppLogDebug(" directory path is %ls", filePath.GetPointer());
+ if ( !__ivTriggeredEvent && __ivTriggeredDeleteEvent)
{
- ImageInfo* pImageInfo = null;
- FileAttributes attr;
- result r = File::GetAttributes(path, attr);
- AppLogDebug(" event index is %d, adding the index", index);
- AppLogDebug(" __pFileEventManager AddPath %ls", path.GetPointer());
- AppLogDebug(" GetAttr result is %d", r);
- AppLogDebug(" GetAttr result invalid arg %d", E_INVALID_ARG);
- AppLogDebug(" GetAttr result illegal arg %d", E_ILLEGAL_ACCESS);
- AppLogDebug(" GetAttr result is IO %d", E_IO);
- AppLogDebug(" GetAttr result is FILE NOT FOUND %d", E_FILE_NOT_FOUND);
-
- AppLogDebug(" GetAttr is dir %d", attr.IsDirectory());
- if (r == E_SUCCESS && attr.IsDirectory() != true)
+ int index = GetImageCacheIndex(filePath);
+ AppLogDebug("index is %d", index);
+ if ( -1 != index )
{
- pImageInfo = new (std::nothrow) ImageInfo();
- pImageInfo->Construct(path, null);
- __pImageCaches->Add(pImageInfo);
- AppLogDebug("__pFileEventManager AddPath %ls", path.GetPointer());
- __pFileEventManager->AddPath(path, FILE_EVENTS);
- AppLogDebug("__pFileEventManager events %d", FILE_EVENTS);
+ __pImageCaches->RemoveAt(index, true);
+ AppLogDebug("removed the index %d", index);
IEnumerator* pEventEnum = __pFileUpdateListener->GetEnumeratorN();
IFileUpdateEventListener* pEventListener = null;
while (pEventEnum->MoveNext() == E_SUCCESS)
{
pEventListener = static_cast<IFileUpdateEventListener*>(pEventEnum->GetCurrent());
- pEventListener->OnFormFileEventOccuered(__pImageCaches->GetCount() - 1, events);
+ pEventListener->OnFormFileEventOccuered(index, 0);
}
}
- }*/
+ }
+ if (__ivTriggeredDeleteEvent)
+ {
+ __ivTriggeredEvent = false;
+ }
AppLogDebug("Exit");
}
+