void CCP_MainApp::RefreshView() { CQPasteWnd *pWnd = QPasteWnd(); if(pWnd) { if(m_bAsynchronousRefreshView) pWnd->PostMessage(WM_REFRESH_VIEW); else pWnd->SendMessage(WM_REFRESH_VIEW); } }
void CCP_MainApp::RefreshClipOrder(int clipId) { CQPasteWnd *pWnd = QPasteWnd(); if(pWnd) { if(m_bAsynchronousRefreshView) { pWnd->PostMessage(WM_RELOAD_CLIP_ORDER, clipId, 0); } else { pWnd->SendMessage(WM_RELOAD_CLIP_ORDER, clipId, 0); } } }
void CQPasteWndThread::OnLoadItems(void *param) { CQPasteWnd *pasteWnd = (CQPasteWnd*)param; ResetEvent(m_SearchingEvent); while(true) { long startTick = GetTickCount(); int loadItemsIndex = 0; int loadItemsCount = 0; int loadCount = 0; CString localSql; bool clearFirstLoadItem = false; bool firstLoad = false; { ATL::CCritSecLock csLock(pasteWnd->m_CritSection.m_sect); if(pasteWnd->m_loadItems.size() > 0) { firstLoad = (pasteWnd->m_loadItems.begin()->x == -1); loadItemsIndex = max(pasteWnd->m_loadItems.begin()->x, 0); loadItemsCount = pasteWnd->m_loadItems.begin()->y - pasteWnd->m_loadItems.begin()->x; localSql = pasteWnd->m_SQL; pasteWnd->m_bStopQuery = false; clearFirstLoadItem = true; } } if(clearFirstLoadItem) { try { Log(StrF(_T("Load Items start = %d, count = %d"), loadItemsIndex, loadItemsCount)); CString limit; limit.Format(_T(" LIMIT %d OFFSET %d"), loadItemsCount, loadItemsIndex); localSql += limit; CMainTable table; CppSQLite3Query q = theApp.m_db.execQuery(localSql); while(!q.eof()) { pasteWnd->FillMainTable(table, q); { ATL::CCritSecLock csLock(pasteWnd->m_CritSection.m_sect); pasteWnd->m_listItems.push_back(table); } if(pasteWnd->m_bStopQuery) { Log(StrF(_T("StopQuery called exiting filling cache count = %d"), loadItemsIndex)); break; } q.nextRow(); if(firstLoad == false) { ::PostMessage(pasteWnd->m_hWnd, NM_REFRESH_ROW, table.m_lID, loadItemsIndex); } loadItemsIndex++; loadCount++; } if(firstLoad) { ::PostMessage(pasteWnd->m_hWnd, NM_REFRESH_ROW, -2, 0); //allow the next thread message to process, this should be the message to set the list count OnSetListCount(param); OnLoadAccelerators(param); } else { ::PostMessage(pasteWnd->m_hWnd, NM_REFRESH_ROW, -1, 0); } if(clearFirstLoadItem) { ATL::CCritSecLock csLock(pasteWnd->m_CritSection.m_sect); pasteWnd->m_loadItems.erase(pasteWnd->m_loadItems.begin()); } Log(StrF(_T("Load items End count = %d, time = %d"), loadCount, GetTickCount() - startTick)); } catch (CppSQLite3Exception& e) \ { \ Log(StrF(_T("ONLoadItems - SQLITE Exception %d - %s"), e.errorCode(), e.errorMessage())); \ ASSERT(FALSE); \ break; } } else { break; } } SetEvent(m_SearchingEvent); }