FilterResultPtr Task::process(TaskStatus const& status, FilterData const& data) { status.throwIfCancelled(); Dependencies const deps(data.xform().resultingCropArea()); std::auto_ptr<Params> params(m_ptrSettings->getPageParams(m_pageId)); if (params.get() && !params->dependencies().matches(deps)) { params.reset(); } OptionsWidget::UiData ui_data; ui_data.setSizeCalc(PhysSizeCalc(data.xform())); if (params.get()) { ui_data.setContentRect(params->contentRect()); ui_data.setDependencies(params->dependencies()); ui_data.setMode(params->mode()); if (params->contentSizeMM().isEmpty() && !params->contentRect().isEmpty()) { // Backwards compatibilty: put the missing data where it belongs. Params const new_params( ui_data.contentRect(), ui_data.contentSizeMM(), params->dependencies(), params->mode() ); m_ptrSettings->setPageParams(m_pageId, new_params); } } else { QRectF const content_rect( ContentBoxFinder::findContentBox( status, data, m_ptrDbg.get() ) ); ui_data.setContentRect(content_rect); ui_data.setDependencies(deps); ui_data.setMode(MODE_AUTO); Params const new_params( ui_data.contentRect(), ui_data.contentSizeMM(), deps, MODE_AUTO ); m_ptrSettings->setPageParams(m_pageId, new_params); } status.throwIfCancelled(); if (m_ptrNextTask) { return m_ptrNextTask->process( status, FilterData(data, data.xform()), ui_data.contentRect() ); } else { return FilterResultPtr( new UiUpdater( m_ptrFilter, m_pageId, m_ptrDbg, data.origImage(), data.xform(), ui_data, m_batchProcessing ) ); } }
bool CSensorDataFilter::Filter(double &dfVal) { //add the value to our store of data //like a stack, we add to the top m_Data.push_front(dfVal); //do we have enough data to scan the window? if( m_Data.size() < GetWindowSize() ) return false; //mind the max size if( m_Data.size() > GetDataSize() ) m_Data.pop_back(); return FilterData(dfVal); }
/* This method builds prefix tree based on the list of filter strings. Every node of the tree contains subcategory name and, optionally, logging level - if node matches complete filter string. For example, given following filters: a (error) a.b.c (trace) a.b.x (trace) aa (error) aa.b (warn) The code builds following prefix tree: | |- a (error) -- b - c (trace) | | | `-- x (trace) | `- aa (error) - b (warn) */ spark::LogHandler::LogHandler(LogLevel level, const Filters &filters) : level_(level) { for (auto it = filters.begin(); it != filters.end(); ++it) { const char* const category = it->first; const LogLevel level = it->second; std::vector<FilterData> *filters = &filters_; // Root nodes size_t pos = 0; for (size_t i = 0;; ++i) { if (category[i] && category[i] != '.') { // Category name separator continue; } const size_t size = i - pos; if (!size) { break; // Invalid category name } const char* const name = category + pos; // Use binary search to find existent node or position for new node bool found = false; auto it = std::lower_bound(filters->begin(), filters->end(), std::make_pair(name, size), [&found](const FilterData &filter, const std::pair<const char*, size_t> &value) { const int cmp = std::strncmp(filter.name, value.first, std::min(filter.size, value.second)); if (cmp == 0) { if (filter.size == value.second) { found = true; } return filter.size < value.second; } return cmp < 0; }); if (!found) { it = filters->insert(it, FilterData(name, size)); // Add node } if (!category[i]) { it->level = level; break; } filters = &it->filters; pos = i + 1; } } }
bool FileFilter::FilterEdit() { if (bMenuOpen) return false; Changed = true; bMenuOpen = true; int ExitCode; bool bNeedUpdate=false; const auto FilterList = VMenu2::create(MSG(MFilterTitle), nullptr, 0, ScrY - 6); FilterList->SetHelp(L"FiltersMenu"); FilterList->SetPosition(-1,-1,0,0); FilterList->SetBottomTitle(MSG(MFilterBottom)); FilterList->SetMenuFlags(/*VMENU_SHOWAMPERSAND|*/VMENU_WRAPMODE); FilterList->SetId(FiltersMenuId); std::for_each(RANGE(FilterData(), i) { MenuItemEx ListItem(MenuString(&i)); ListItem.SetCheck(GetCheck(i)); FilterList->AddItem(ListItem); });
CPLErr VRTFilteredSource::RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, void *pData, int nBufXSize, int nBufYSize, GDALDataType eBufType, GSpacing nPixelSpace, GSpacing nLineSpace, GDALRasterIOExtraArg* psExtraArg ) { /* -------------------------------------------------------------------- */ /* For now we don't support filtered access to non-full */ /* resolution requests. Just collect the data directly without */ /* any operator. */ /* -------------------------------------------------------------------- */ if( nBufXSize != nXSize || nBufYSize != nYSize ) { return VRTComplexSource::RasterIO( nXOff, nYOff, nXSize, nYSize, pData, nBufXSize, nBufYSize, eBufType, nPixelSpace, nLineSpace, psExtraArg ); } // The window we will actually request from the source raster band. double dfReqXOff, dfReqYOff, dfReqXSize, dfReqYSize; int nReqXOff, nReqYOff, nReqXSize, nReqYSize; // The window we will actual set _within_ the pData buffer. int nOutXOff, nOutYOff, nOutXSize, nOutYSize; if( !GetSrcDstWindow( nXOff, nYOff, nXSize, nYSize, nBufXSize, nBufYSize, &dfReqXOff, &dfReqYOff, &dfReqXSize, &dfReqYSize, &nReqXOff, &nReqYOff, &nReqXSize, &nReqYSize, &nOutXOff, &nOutYOff, &nOutXSize, &nOutYSize ) ) return CE_None; pData = ((GByte *)pData) + nPixelSpace * nOutXOff + nLineSpace * nOutYOff; /* -------------------------------------------------------------------- */ /* Determine the data type we want to request. We try to match */ /* the source or destination request, and if both those fail we */ /* fallback to the first supported type at least as expressive */ /* as the request. */ /* -------------------------------------------------------------------- */ GDALDataType eOperDataType = GDT_Unknown; int i; if( IsTypeSupported( eBufType ) ) eOperDataType = eBufType; if( eOperDataType == GDT_Unknown && IsTypeSupported( poRasterBand->GetRasterDataType() ) ) eOperDataType = poRasterBand->GetRasterDataType(); if( eOperDataType == GDT_Unknown ) { for( i = 0; i < nSupportedTypesCount; i++ ) { if( GDALDataTypeUnion( aeSupportedTypes[i], eBufType ) == aeSupportedTypes[i] ) { eOperDataType = aeSupportedTypes[i]; } } } if( eOperDataType == GDT_Unknown ) { eOperDataType = aeSupportedTypes[0]; for( i = 1; i < nSupportedTypesCount; i++ ) { if( GDALGetDataTypeSize( aeSupportedTypes[i] ) > GDALGetDataTypeSize( eOperDataType ) ) { eOperDataType = aeSupportedTypes[i]; } } } /* -------------------------------------------------------------------- */ /* Allocate the buffer of data into which our imagery will be */ /* read, with the extra edge pixels as well. This will be the */ /* source data fed into the filter. */ /* -------------------------------------------------------------------- */ int nPixelOffset, nLineOffset; int nExtraXSize = nOutXSize + 2 * nExtraEdgePixels; int nExtraYSize = nOutYSize + 2 * nExtraEdgePixels; GByte *pabyWorkData; // FIXME? : risk of multiplication overflow pabyWorkData = (GByte *) VSICalloc( nExtraXSize * nExtraYSize, (GDALGetDataTypeSize(eOperDataType) / 8) ); if( pabyWorkData == NULL ) { CPLError( CE_Failure, CPLE_OutOfMemory, "Work buffer allocation failed." ); return CE_Failure; } nPixelOffset = GDALGetDataTypeSize( eOperDataType ) / 8; nLineOffset = nPixelOffset * nExtraXSize; /* -------------------------------------------------------------------- */ /* Allocate the output buffer if the passed in output buffer is */ /* not of the same type as our working format, or if the passed */ /* in buffer has an unusual organization. */ /* -------------------------------------------------------------------- */ GByte *pabyOutData; if( nPixelSpace != nPixelOffset || nLineSpace != nLineOffset || eOperDataType != eBufType ) { pabyOutData = (GByte *) VSIMalloc3(nOutXSize, nOutYSize, nPixelOffset ); if( pabyOutData == NULL ) { CPLError( CE_Failure, CPLE_OutOfMemory, "Work buffer allocation failed." ); return CE_Failure; } } else pabyOutData = (GByte *) pData; /* -------------------------------------------------------------------- */ /* Figure out the extended window that we want to load. Note */ /* that we keep track of the file window as well as the amount */ /* we will need to edge fill past the edge of the source dataset. */ /* -------------------------------------------------------------------- */ int nTopFill=0, nLeftFill=0, nRightFill=0, nBottomFill=0; int nFileXOff, nFileYOff, nFileXSize, nFileYSize; nFileXOff = nReqXOff - nExtraEdgePixels; nFileYOff = nReqYOff - nExtraEdgePixels; nFileXSize = nExtraXSize; nFileYSize = nExtraYSize; if( nFileXOff < 0 ) { nLeftFill = -nFileXOff; nFileXOff = 0; nFileXSize -= nLeftFill; } if( nFileYOff < 0 ) { nTopFill = -nFileYOff; nFileYOff = 0; nFileYSize -= nTopFill; } if( nFileXOff + nFileXSize > poRasterBand->GetXSize() ) { nRightFill = nFileXOff + nFileXSize - poRasterBand->GetXSize(); nFileXSize -= nRightFill; } if( nFileYOff + nFileYSize > poRasterBand->GetYSize() ) { nBottomFill = nFileYOff + nFileYSize - poRasterBand->GetYSize(); nFileYSize -= nBottomFill; } /* -------------------------------------------------------------------- */ /* Load the data. */ /* -------------------------------------------------------------------- */ CPLErr eErr; eErr = VRTComplexSource::RasterIOInternal( nFileXOff, nFileYOff, nFileXSize, nFileYSize, pabyWorkData + nLineOffset * nTopFill + nPixelOffset * nLeftFill, nFileXSize, nFileYSize, eOperDataType, nPixelOffset, nLineOffset, psExtraArg ); if( eErr != CE_None ) { if( pabyWorkData != pData ) VSIFree( pabyWorkData ); return eErr; } /* -------------------------------------------------------------------- */ /* Fill in missing areas. Note that we replicate the edge */ /* valid values out. We don't using "mirroring" which might be */ /* more suitable for some times of filters. We also don't mark */ /* these pixels as "nodata" though perhaps we should. */ /* -------------------------------------------------------------------- */ if( nLeftFill != 0 || nRightFill != 0 ) { for( i = nTopFill; i < nExtraYSize - nBottomFill; i++ ) { if( nLeftFill != 0 ) GDALCopyWords( pabyWorkData + nPixelOffset * nLeftFill + i * nLineOffset, eOperDataType, 0, pabyWorkData + i * nLineOffset, eOperDataType, nPixelOffset, nLeftFill ); if( nRightFill != 0 ) GDALCopyWords( pabyWorkData + i * nLineOffset + nPixelOffset * (nExtraXSize - nRightFill - 1), eOperDataType, 0, pabyWorkData + i * nLineOffset + nPixelOffset * (nExtraXSize - nRightFill), eOperDataType, nPixelOffset, nRightFill ); } } for( i = 0; i < nTopFill; i++ ) { memcpy( pabyWorkData + i * nLineOffset, pabyWorkData + nTopFill * nLineOffset, nLineOffset ); } for( i = nExtraYSize - nBottomFill; i < nExtraYSize; i++ ) { memcpy( pabyWorkData + i * nLineOffset, pabyWorkData + (nExtraYSize - nBottomFill - 1) * nLineOffset, nLineOffset ); } /* -------------------------------------------------------------------- */ /* Filter the data. */ /* -------------------------------------------------------------------- */ eErr = FilterData( nOutXSize, nOutYSize, eOperDataType, pabyWorkData, pabyOutData ); VSIFree( pabyWorkData ); if( eErr != CE_None ) { if( pabyOutData != pData ) VSIFree( pabyOutData ); return eErr; } /* -------------------------------------------------------------------- */ /* Copy from work buffer to target buffer. */ /* -------------------------------------------------------------------- */ if( pabyOutData != pData ) { for( i = 0; i < nOutYSize; i++ ) { GDALCopyWords( pabyOutData + i * (nPixelOffset * nOutXSize), eOperDataType, nPixelOffset, ((GByte *) pData) + i * nLineSpace, eBufType, nPixelSpace, nOutXSize ); } VSIFree( pabyOutData ); } return CE_None; }
CPLErr VRTFilteredSource::RasterIO( GDALDataType eBandDataType, int nXOff, int nYOff, int nXSize, int nYSize, void *pData, int nBufXSize, int nBufYSize, GDALDataType eBufType, GSpacing nPixelSpace, GSpacing nLineSpace, GDALRasterIOExtraArg* psExtraArg ) { /* -------------------------------------------------------------------- */ /* For now we don't support filtered access to non-full */ /* resolution requests. Just collect the data directly without */ /* any operator. */ /* -------------------------------------------------------------------- */ if( nBufXSize != nXSize || nBufYSize != nYSize ) { return VRTComplexSource::RasterIO( eBandDataType, nXOff, nYOff, nXSize, nYSize, pData, nBufXSize, nBufYSize, eBufType, nPixelSpace, nLineSpace, psExtraArg ); } // The window we will actually request from the source raster band. double dfReqXOff = 0.0; double dfReqYOff = 0.0; double dfReqXSize = 0.0; double dfReqYSize = 0.0; int nReqXOff = 0; int nReqYOff = 0; int nReqXSize = 0; int nReqYSize = 0; // The window we will actual set _within_ the pData buffer. int nOutXOff = 0; int nOutYOff = 0; int nOutXSize = 0; int nOutYSize = 0; if( !GetSrcDstWindow( nXOff, nYOff, nXSize, nYSize, nBufXSize, nBufYSize, &dfReqXOff, &dfReqYOff, &dfReqXSize, &dfReqYSize, &nReqXOff, &nReqYOff, &nReqXSize, &nReqYSize, &nOutXOff, &nOutYOff, &nOutXSize, &nOutYSize ) ) return CE_None; pData = reinterpret_cast<GByte *>( pData ) + nPixelSpace * nOutXOff + nLineSpace * nOutYOff; /* -------------------------------------------------------------------- */ /* Determine the data type we want to request. We try to match */ /* the source or destination request, and if both those fail we */ /* fallback to the first supported type at least as expressive */ /* as the request. */ /* -------------------------------------------------------------------- */ GDALDataType eOperDataType = GDT_Unknown; if( IsTypeSupported( eBufType ) ) eOperDataType = eBufType; if( eOperDataType == GDT_Unknown && IsTypeSupported( m_poRasterBand->GetRasterDataType() ) ) eOperDataType = m_poRasterBand->GetRasterDataType(); if( eOperDataType == GDT_Unknown ) { for( int i = 0; i < m_nSupportedTypesCount; i++ ) { if( GDALDataTypeUnion( m_aeSupportedTypes[i], eBufType ) == m_aeSupportedTypes[i] ) { eOperDataType = m_aeSupportedTypes[i]; } } } if( eOperDataType == GDT_Unknown ) { eOperDataType = m_aeSupportedTypes[0]; for( int i = 1; i < m_nSupportedTypesCount; i++ ) { if( GDALGetDataTypeSize( m_aeSupportedTypes[i] ) > GDALGetDataTypeSize( eOperDataType ) ) { eOperDataType = m_aeSupportedTypes[i]; } } } /* -------------------------------------------------------------------- */ /* Allocate the buffer of data into which our imagery will be */ /* read, with the extra edge pixels as well. This will be the */ /* source data fed into the filter. */ /* -------------------------------------------------------------------- */ if( nOutXSize > INT_MAX - 2 * m_nExtraEdgePixels || nOutYSize > INT_MAX - 2 * m_nExtraEdgePixels ) { return CE_Failure; } const int nExtraXSize = nOutXSize + 2 * m_nExtraEdgePixels; const int nExtraYSize = nOutYSize + 2 * m_nExtraEdgePixels; GByte *pabyWorkData = static_cast<GByte *>( VSI_MALLOC3_VERBOSE( nExtraXSize, nExtraYSize, GDALGetDataTypeSizeBytes(eOperDataType)) ); if( pabyWorkData == nullptr ) { return CE_Failure; } const GPtrDiff_t nPixelOffset = GDALGetDataTypeSizeBytes( eOperDataType ); const GPtrDiff_t nLineOffset = nPixelOffset * nExtraXSize; memset( pabyWorkData, 0, nLineOffset * nExtraYSize ); /* -------------------------------------------------------------------- */ /* Allocate the output buffer in the same dimensions as the work */ /* buffer. This allows the filter process to write edge pixels */ /* if needed for two-pass (separable) filtering. */ /* -------------------------------------------------------------------- */ GByte *pabyOutData = static_cast<GByte *>( VSI_MALLOC3_VERBOSE( nExtraXSize, nExtraYSize, nPixelOffset ) ); if( pabyOutData == nullptr ) { CPLFree( pabyWorkData ); return CE_Failure; } /* -------------------------------------------------------------------- */ /* Figure out the extended window that we want to load. Note */ /* that we keep track of the file window as well as the amount */ /* we will need to edge fill past the edge of the source dataset. */ /* -------------------------------------------------------------------- */ int nFileXOff = nReqXOff - m_nExtraEdgePixels; int nFileYOff = nReqYOff - m_nExtraEdgePixels; int nFileXSize = nExtraXSize; int nFileYSize = nExtraYSize; int nTopFill = 0; int nLeftFill = 0; int nRightFill = 0; int nBottomFill = 0; if( nFileXOff < 0 ) { nLeftFill = -nFileXOff; nFileXOff = 0; nFileXSize -= nLeftFill; } if( nFileYOff < 0 ) { nTopFill = -nFileYOff; nFileYOff = 0; nFileYSize -= nTopFill; } if( nFileXOff + nFileXSize > m_poRasterBand->GetXSize() ) { nRightFill = nFileXOff + nFileXSize - m_poRasterBand->GetXSize(); nFileXSize -= nRightFill; } if( nFileYOff + nFileYSize > m_poRasterBand->GetYSize() ) { nBottomFill = nFileYOff + nFileYSize - m_poRasterBand->GetYSize(); nFileYSize -= nBottomFill; } /* -------------------------------------------------------------------- */ /* Load the data. */ /* -------------------------------------------------------------------- */ { const bool bIsComplex = CPL_TO_BOOL( GDALDataTypeIsComplex(eOperDataType) ); const CPLErr eErr = VRTComplexSource::RasterIOInternal<float>( nFileXOff, nFileYOff, nFileXSize, nFileYSize, pabyWorkData + nLineOffset * nTopFill + nPixelOffset * nLeftFill, nFileXSize, nFileYSize, eOperDataType, nPixelOffset, nLineOffset, psExtraArg, bIsComplex ? GDT_CFloat32 : GDT_Float32 ); if( eErr != CE_None ) { VSIFree( pabyWorkData ); VSIFree( pabyOutData ); return eErr; } } /* -------------------------------------------------------------------- */ /* Fill in missing areas. Note that we replicate the edge */ /* valid values out. We don't using "mirroring" which might be */ /* more suitable for some times of filters. We also don't mark */ /* these pixels as "nodata" though perhaps we should. */ /* -------------------------------------------------------------------- */ if( nLeftFill != 0 || nRightFill != 0 ) { for( int i = nTopFill; i < nExtraYSize - nBottomFill; i++ ) { if( nLeftFill != 0 ) GDALCopyWords( pabyWorkData + nPixelOffset * nLeftFill + i * nLineOffset, eOperDataType, 0, pabyWorkData + i * nLineOffset, eOperDataType, static_cast<int>(nPixelOffset), nLeftFill ); if( nRightFill != 0 ) GDALCopyWords( pabyWorkData + i * nLineOffset + nPixelOffset * (nExtraXSize - nRightFill - 1), eOperDataType, 0, pabyWorkData + i * nLineOffset + nPixelOffset * (nExtraXSize - nRightFill), eOperDataType, static_cast<int>(nPixelOffset), nRightFill ); } } for( int i = 0; i < nTopFill; i++ ) { memcpy( pabyWorkData + i * nLineOffset, pabyWorkData + nTopFill * nLineOffset, nLineOffset ); } for( int i = nExtraYSize - nBottomFill; i < nExtraYSize; i++ ) { memcpy( pabyWorkData + i * nLineOffset, pabyWorkData + (nExtraYSize - nBottomFill - 1) * nLineOffset, nLineOffset ); } /* -------------------------------------------------------------------- */ /* Filter the data. */ /* -------------------------------------------------------------------- */ const CPLErr eErr = FilterData( nExtraXSize, nExtraYSize, eOperDataType, pabyWorkData, pabyOutData ); VSIFree( pabyWorkData ); if( eErr != CE_None ) { VSIFree( pabyOutData ); return eErr; } /* -------------------------------------------------------------------- */ /* Copy from work buffer to target buffer. */ /* -------------------------------------------------------------------- */ GByte *pabySrcRow = pabyOutData + (nLineOffset + nPixelOffset) * m_nExtraEdgePixels; GByte *pabyDstRow = reinterpret_cast<GByte *>( pData ); for( int i = 0; i < nOutYSize; i++, pabySrcRow += nLineOffset, pabyDstRow += nLineSpace ) { GDALCopyWords( pabySrcRow, eOperDataType, static_cast<int>(nPixelOffset), pabyDstRow, eBufType, static_cast<int>(nPixelSpace), nOutXSize ); } VSIFree( pabyOutData ); return CE_None; }
void game_list_frame::Refresh(bool fromDrive) { if (fromDrive) { // Load PSF m_game_data.clear(); const std::string& game_path = Emu.GetGameDir(); for (const auto& entry : fs::dir(Emu.GetGameDir())) { if (!entry.is_directory) { continue; } const std::string& dir = game_path + entry.name; const std::string& sfb = dir + "/PS3_DISC.SFB"; const std::string& sfo = dir + (fs::is_file(sfb) ? "/PS3_GAME/PARAM.SFO" : "/PARAM.SFO"); const fs::file sfo_file(sfo); if (!sfo_file) { continue; } const auto& psf = psf::load_object(sfo_file); GameInfo game; game.root = entry.name; game.serial = psf::get_string(psf, "TITLE_ID", ""); game.name = psf::get_string(psf, "TITLE", "unknown"); game.app_ver = psf::get_string(psf, "APP_VER", "unknown"); game.category = psf::get_string(psf, "CATEGORY", "unknown"); game.fw = psf::get_string(psf, "PS3_SYSTEM_VER", "unknown"); game.parental_lvl = psf::get_integer(psf, "PARENTAL_LEVEL"); game.resolution = psf::get_integer(psf, "RESOLUTION"); game.sound_format = psf::get_integer(psf, "SOUND_FORMAT"); if (game.category == "HG") { game.category = sstr(category::hdd_Game); game.icon_path = dir + "/ICON0.PNG"; } else if (game.category == "DG") { game.category = sstr(category::disc_Game); game.icon_path = dir + "/PS3_GAME/ICON0.PNG"; } else if (game.category == "HM") { game.category = sstr(category::home); game.icon_path = dir + "/ICON0.PNG"; } else if (game.category == "AV") { game.category = sstr(category::audio_Video); game.icon_path = dir + "/ICON0.PNG"; } else if (game.category == "GD") { game.category = sstr(category::game_Data); game.icon_path = dir + "/ICON0.PNG"; } else if (game.category == "unknown") { game.category = sstr(category::unknown); } // Load Image QImage img; QPixmap pxmap; if (!game.icon_path.empty() && img.load(qstr(game.icon_path))) { QImage scaled = img.scaled(m_Icon_Size, Qt::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation); pxmap = QPixmap::fromImage(scaled); } else { img = QImage(m_Icon_Size, QImage::Format_ARGB32); QString abspath = QDir(qstr(game.icon_path)).absolutePath(); LOG_ERROR(HLE, "Count not load image from path %s", sstr(abspath)); img.fill(QColor(0, 0, 0, 0)); pxmap = QPixmap::fromImage(img); } m_game_data.push_back({ game, img, pxmap }); } auto op = [](const GUI_GameInfo& game1, const GUI_GameInfo& game2) { return game1.info.name < game2.info.name; }; // Sort by name at the very least. std::sort(m_game_data.begin(), m_game_data.end(), op); } // Fill Game List / Game Grid if (m_isListLayout) { int row = PopulateGameList(); FilterData(); gameList->selectRow(row); gameList->sortByColumn(m_sortColumn, m_colSortOrder); gameList->verticalHeader()->setMinimumSectionSize(m_Icon_Size.height()); gameList->verticalHeader()->setMaximumSectionSize(m_Icon_Size.height()); gameList->resizeRowsToContents(); gameList->resizeColumnToContents(0); gameList->scrollTo(gameList->currentIndex()); } else { if (m_Icon_Size.width() > 0 && m_Icon_Size.height() > 0) { m_games_per_row = width() / (m_Icon_Size.width() + m_Icon_Size.width() * m_xgrid->getMarginFactor() * 2); } else { m_games_per_row = 0; } PopulateGameGrid(m_games_per_row, m_Icon_Size); connect(m_xgrid, &QTableWidget::doubleClicked, this, &game_list_frame::doubleClickedSlot); connect(m_xgrid, &QTableWidget::customContextMenuRequested, this, &game_list_frame::ShowContextMenu); m_Central_Widget->addWidget(m_xgrid); m_Central_Widget->setCurrentWidget(m_xgrid); m_xgrid->scrollTo(m_xgrid->currentIndex()); } }
//---------------------------------------------------------------------------------------------// STDMETHODIMP CMmTradeChannel::GetData(IEtsFilterData* ipFilter, IMmTradeInfoColl** ipResult) { try { __CHECK_POINTER(ipFilter); IEtsFilterDataPtr spFilter = NULL; spFilter.Attach(ipFilter, true); if (!ipResult) return E_POINTER; if(*ipResult){ (*ipResult)->Release(); *ipResult = NULL; }; IMmTradeInfoCollPtr spResult = IMmTradeInfoCollPtr(__uuidof(MmTradeInfoColl)); *ipResult = (IMmTradeInfoColl*)spResult; if (*ipResult) (*ipResult)->AddRef(); if (*ipResult){ CTradeInfoViewData filteredTrades; FilterData(spFilter, filteredTrades); if (filteredTrades.size() > 0){ CTradeInfoViewData::iterator it = filteredTrades.begin(); CTradeInfoViewData::iterator itEnd = filteredTrades.end(); for (; it != itEnd; it++) { long lTradeID = 0L; _CHK((*it)->get_TradeID(&lTradeID), _T("Fail to get trade id.")); DATE dtTradeDate = 0.; _CHK((*it)->get_TradeDate(&dtTradeDate), _T("Fail to get TradeDate.")); IMmTradeInfoAtomPtr spReturnPtr = NULL; IMmTradeInfoAtomPtr spTrade = (*it); spResult->Add(lTradeID, dtTradeDate, spTrade, &spReturnPtr); /*_CHK((*ipResult)->Add(lTradeID, dtTradeDate, spTrade, &spReturnPtr), _T("Fail to Add trade to collection."));*/ } } }; } catch (_com_error& err) { TRACE_COM_ERROR(err); ATLASSERT(FALSE); throw; } catch (...) { TRACE_UNKNOWN_ERROR(); ATLASSERT(FALSE); throw; }; return S_OK; };