NewsList::NewsList() : m_curAccount(0) { m_ui.setupUi(this); m_ui.tableGroups->setModel(&m_model); m_ui.tableGroups->setColumnWidth(0, 150); m_ui.progressBar->setMaximum(0); m_ui.progressBar->setMinimum(0); m_ui.progressBar->setValue(0); m_ui.progressBar->setVisible(false); m_ui.actionRefresh->setShortcut(QKeySequence::Refresh); m_ui.actionRefresh->setEnabled(false); m_ui.actionFavorite->setEnabled(false); m_ui.actionStop->setEnabled(false); m_ui.chkShowEmpty->setChecked(false); const auto nameWidth = m_ui.tableGroups->columnWidth((int)app::NewsList::Columns::Name); m_ui.tableGroups->setColumnWidth((int)app::NewsList::Columns::Name, nameWidth * 3); m_ui.tableGroups->setColumnWidth((int)app::NewsList::Columns::Subscribed, 32); QObject::connect(app::g_accounts, SIGNAL(accountsUpdated()), this, SLOT(accountsUpdated())); QObject::connect(&m_model, SIGNAL(progressUpdated(quint32, quint32, quint32)), this, SLOT(progressUpdated(quint32, quint32, quint32))); QObject::connect(&m_model, SIGNAL(loadComplete(quint32)), this, SLOT(loadComplete(quint32))); QObject::connect(&m_model, SIGNAL(makeComplete(quint32)), this, SLOT(makeComplete(quint32))); }
void QImageLoadThreadPool::internalThreadRun(QString path) { QImage img = QImage(path); controlExternal.lock(); controlInternal.lock(); emit loadComplete(path, img); controlInternal.unlock(); controlExternal.unlock(); }
void SaveTilesetThread::saveMultiple() { QString filePath = "D:/tiles/"; // Project Folder QVector<Tile> *tileSet = &(tileSetIndex? memory->spritesTileSet:memory->backgroundTileSet); for(int i=0; i<256; i++){ (*tileSet)[i].getImage().saveToFile((filePath+QString::number(i)+".png").toStdString()); emit loadingNumberChanged(i); } emit loadComplete(); }
void SaveTilesetThread::saveSingle() { QVector<Tile> *tileSet = &(tileSetIndex? memory->spritesTileSet:memory->backgroundTileSet); sf::Image tilesetimg; tilesetimg.create(256,256); for(int i=0; i<16; i++){ for(int j=0; j<16; j++){ tilesetimg.copy((*tileSet)[i*16+j].getImage(),j*16,i*16,IntRect(0,0,16,16)); emit loadingNumberChanged(i*16+j); } } tilesetimg.saveToFile(fileName.toStdString()); emit loadComplete(); }
void CounterInterface::connections() { connect(DSBValueProduct, SIGNAL(valueChanged(double)), SLOT(valueChanged_DSBValueProduct(double))); connect(this, SIGNAL(setInput()), wPizzaMixed, SLOT(input())); connect(this, SIGNAL(setInput()), wPaymentView, SLOT(input())); connect(lPizza, SIGNAL(onClick()), SLOT(onClick_lPizza())); connect(wPaymentView, SIGNAL(save()), SLOT(onClick_pbSaveOrdered())); connect(wPaymentView, SIGNAL(clear()), SLOT(onClick_pbClearOrdered())); connect(wPaymentView, SIGNAL(cancel()), SLOT(onClick_pbCancelOrdered())); connect(wPaymentView, SIGNAL(pizza()), SLOT(onClick_lPizza())); connect(wPizzaMixed, SIGNAL(emitPizzaMista(QList<int>,QList<QString>,QList<QString>,QString,int,double,QString,bool,int)), this, SLOT(slotPizzaMista(QList<int>,QList<QString>,QList<QString>,QString,int,double,QString,bool,int))); connect(searchProduct, SIGNAL(textSearch(QString)), SLOT(getSearchProduct(QString))); connect(pbConfirmProduct, SIGNAL(clicked()), SLOT(onClick_pbConfirmProduct())); connect(pbLeaveProduct, SIGNAL(clicked()), SLOT(onClick_pbLeaveProduct())); connect(tableItem, SIGNAL(doubleClicked(QModelIndex)), SLOT(doubleClicked_tableItem(QModelIndex))); connect(this, SIGNAL(editPizzaMixed(QList<int>,QList<QString>,QList<QString>,QString,int,double,QString,int)), wPizzaMixed, SLOT(editPizzaMixed(QList<int>,QList<QString>,QList<QString>,QString,int,double,QString,int))); connect(sbAmount, SIGNAL(valueChanged(int)), SLOT(valueChanged_sbAmount(int))); connect(cbSize, SIGNAL(currentIndexChanged(int)), SLOT(currentIndexChanged_cbSize(int))); connect(pbRemoveItem, SIGNAL(clicked()), SLOT(onClick_pbRemoveItem())); connect(pbClearOrdered, SIGNAL(clicked()), SLOT(onClick_pbClearOrdered())); connect(pbCancelOrdered, SIGNAL(clicked()), SLOT(onClick_pbCancelOrdered())); connect(pbSaveOrdered, SIGNAL(clicked()), SLOT(onClick_pbSaveOrdered())); connect(actionName,SIGNAL(triggered()),SLOT(onTriggered_actionName())); connect(actionNickName,SIGNAL(triggered()),SLOT(onTriggered_actionNickName())); connect(wPaymentView->order, SIGNAL(loadComplete()), SLOT(loadDataOrder())); connect(sbAmount, SIGNAL(returnPressed()), SLOT(onClick_pbConfirmProduct())); }
void Resources::loadCallback(const Path& filePath, HResource& resource) { SPtr<Resource> rawResource = loadFromDiskAndDeserialize(filePath); { Lock lock(mInProgressResourcesMutex); // Check if all my dependencies are loaded ResourceLoadData* myLoadData = mInProgressResources[resource.getUUID()]; myLoadData->loadedData = rawResource; myLoadData->remainingDependencies--; } loadComplete(resource); }
void KNLibHashPixmapList::loadImages() { QDir albumArt(m_folderPath); QStringList albumArtFiles=albumArt.entryList(QStringList("*.png")); int fileCount=albumArtFiles.size(); QString currentFile; QImage imageCache; while(fileCount--) { currentFile=albumArtFiles.takeFirst(); if(currentFile=="." || currentFile=="..") { continue; } imageCache=QImage(m_folderPath+currentFile); currentFile.resize(currentFile.size()-4); m_list[currentFile]=imageCache; } emit loadComplete(); }
//============================================================================== bool AztecDVBR_Matrix::readFromFile(const char *filename){ // //readFromFile should be able to be called after the matrix is constructed, //and before allocate has been called. i.e., example usage should include: // // AztecDVBR_Matrix A(map, update); // A.readFromFile(fileName); // A.matvec(b, c); // //i.e., readFromFile can take the place of the allocate and loadComplete //calls. // FILE *infile = NULL; MPI_Comm thisComm = amap_->getCommunicator(); MPI_Barrier(thisComm); infile = fopen(filename, "r"); if (!infile) messageAbort("readFromFile: couldn't open file."); int* num_nz_blocks = NULL; int* blk_col_inds = NULL; readAllocateInfo(infile, num_nz_blocks, blk_col_inds); allocate(num_nz_blocks, blk_col_inds); delete [] num_nz_blocks; delete [] blk_col_inds; fclose(infile); infile = fopen(filename, "r"); readMatrixData(infile); fclose(infile); loadComplete(); return(true); }
void DbTreeViewPanel::selectLinkedObjects() { QList<DbTreeModel::DbTreeNodeType> fullyCheckedObjectTypes; QList<DbTreeModel::DbTreeNodeType> uncheckedObjectTypes; DbTreeModel *model=dbTree->getModel(); int topLevelRowCount = model->rowCount(QModelIndex()); availableObjectTypes.clear(); for(int i=0; i<topLevelRowCount; ++i){ DbTreeItem *item = static_cast<DbTreeItem*>(model->index(i, 0, QModelIndex()).internalPointer()); availableObjectTypes.append(item->getItemType()); Qt::CheckState checkState = item->checkState(); if(checkState==Qt::Checked){ fullyCheckedObjectTypes.append(item->getItemType()); }else if(checkState==Qt::Unchecked){ uncheckedObjectTypes.append(item->getItemType()); } } if(fullyCheckedObjectTypes.size()==topLevelRowCount || uncheckedObjectTypes.size()==topLevelRowCount){ QString title = fullyCheckedObjectTypes.size()==topLevelRowCount ? tr("All items selected") : tr("Nothing selected"); QString message = fullyCheckedObjectTypes.size()==topLevelRowCount ? tr("All items are already selected.") : tr("Please, select at least one item and try again."); QMessageBox::information(this->window(), title, message); return; } if(selectLinkedObjectsDialog==0){ selectLinkedObjectsDialog = new SelectLinkedObjectsDialog(this); selectLinkedObjectsDialog->setAvailableObjectTypes(availableObjectTypes); } if(!selectLinkedObjectsDialog->exec()){ return; } selectedObjectTypes = selectLinkedObjectsDialog->getSelectedItemTypes(); for(int i=0; i<fullyCheckedObjectTypes.size(); ++i){ selectedObjectTypes.removeOne(fullyCheckedObjectTypes.at(i)); } if(selectedObjectTypes.isEmpty()){ QMessageBox::information(this->window(), tr("Nothing to find"), tr("Nothing to search for. Please, select more object types and try again.")); return; } findOnlyTables = selectedObjectTypes.size()==1 && selectedObjectTypes.at(0)==DbTreeModel::Tables && !uncheckedObjectTypes.contains(DbTreeModel::Tables) && uncheckedObjectTypes.size()==topLevelRowCount-1; setInProgress(true); DbTreeModelNodeExpander *expander = new DbTreeModelNodeExpander(model); connect(expander, SIGNAL(loadComplete()), this, SLOT(childrenLoaded())); connect(expander, SIGNAL(loadError(OciException)), this, SLOT(childrenLoadError(OciException))); expander->loadChildren(QModelIndex(), availableObjectTypes); }
HResource Resources::loadInternal(const String& UUID, const Path& filePath, bool synchronous, bool loadDependencies, bool keepInternalReference) { HResource outputResource; bool alreadyLoading = false; bool loadInProgress = false; { // Check if resource is already being loaded on a worker thread Lock inProgressLock(mInProgressResourcesMutex); auto iterFind2 = mInProgressResources.find(UUID); if (iterFind2 != mInProgressResources.end()) { LoadedResourceData& resData = iterFind2->second->resData; outputResource = resData.resource.lock(); if (keepInternalReference) { resData.numInternalRefs++; outputResource.addInternalRef(); } alreadyLoading = true; loadInProgress = true; } // Previously being loaded as async but now we want it synced, so we wait if (loadInProgress && synchronous) outputResource.blockUntilLoaded(); if (!alreadyLoading) { Lock loadedLock(mLoadedResourceMutex); auto iterFind = mLoadedResources.find(UUID); if (iterFind != mLoadedResources.end()) // Resource is already loaded { LoadedResourceData& resData = iterFind->second; outputResource = resData.resource.lock(); if (keepInternalReference) { resData.numInternalRefs++; outputResource.addInternalRef(); } alreadyLoading = true; } } } // Not loaded and not in progress, start loading of new resource // (or if already loaded or in progress, load any dependencies) if (!alreadyLoading) { // Check if the handle already exists Lock lock(mLoadedResourceMutex); auto iterFind = mHandles.find(UUID); if (iterFind != mHandles.end()) outputResource = iterFind->second.lock(); else { outputResource = HResource(UUID); mHandles[UUID] = outputResource.getWeak(); } } // We have nowhere to load from, warn and complete load if a file path was provided, // otherwise pass through as we might just want to load from memory. if (filePath.isEmpty()) { if (!alreadyLoading) { LOGWRN_VERBOSE("Cannot load resource. Resource with UUID '" + UUID + "' doesn't exist."); // Complete the load as that the depedency counter is properly reduced, in case this // is a dependency of some other resource. loadComplete(outputResource); return outputResource; } } else if (!FileSystem::isFile(filePath)) { LOGWRN_VERBOSE("Cannot load resource. Specified file: " + filePath.toString() + " doesn't exist."); // Complete the load as that the depedency counter is properly reduced, in case this // is a dependency of some other resource. loadComplete(outputResource); assert(!loadInProgress); // Resource already being loaded but we can't find its path now? return outputResource; } // Load dependency data if a file path is provided SPtr<SavedResourceData> savedResourceData; if (!filePath.isEmpty()) { FileDecoder fs(filePath); savedResourceData = std::static_pointer_cast<SavedResourceData>(fs.decode()); } // If already loading keep the old load operation active, otherwise create a new one if (!alreadyLoading) { { Lock lock(mInProgressResourcesMutex); ResourceLoadData* loadData = bs_new<ResourceLoadData>(outputResource.getWeak(), 0); mInProgressResources[UUID] = loadData; loadData->resData = outputResource.getWeak(); if (keepInternalReference) { loadData->resData.numInternalRefs++; outputResource.addInternalRef(); } loadData->remainingDependencies = 1; loadData->notifyImmediately = synchronous; // Make resource listener trigger before exit if loading synchronously // Register dependencies and count them so we know when the resource is fully loaded if (loadDependencies && savedResourceData != nullptr) { for (auto& dependency : savedResourceData->getDependencies()) { if (dependency != UUID) { mDependantLoads[dependency].push_back(loadData); loadData->remainingDependencies++; } } } } if (loadDependencies && savedResourceData != nullptr) { const Vector<String>& dependencyUUIDs = savedResourceData->getDependencies(); UINT32 numDependencies = (UINT32)dependencyUUIDs.size(); Vector<HResource> dependencies(numDependencies); for (UINT32 i = 0; i < numDependencies; i++) dependencies[i] = loadFromUUID(dependencyUUIDs[i], !synchronous, true, false); // Keep dependencies alive until the parent is done loading { Lock lock(mInProgressResourcesMutex); // At this point the resource is guaranteed to still be in-progress, so it's safe to update its dependency list mInProgressResources[UUID]->dependencies = dependencies; } } } else if (loadDependencies && savedResourceData != nullptr) // Queue dependencies in case they aren't already loaded { const Vector<String>& dependencies = savedResourceData->getDependencies(); if (!dependencies.empty()) { { Lock lock(mInProgressResourcesMutex); ResourceLoadData* loadData = nullptr; auto iterFind = mInProgressResources.find(UUID); if (iterFind == mInProgressResources.end()) // Fully loaded { loadData = bs_new<ResourceLoadData>(outputResource.getWeak(), 0); loadData->resData = outputResource.getWeak(); loadData->remainingDependencies = 0; loadData->notifyImmediately = synchronous; // Make resource listener trigger before exit if loading synchronously mInProgressResources[UUID] = loadData; } else { loadData = iterFind->second; } // Register dependencies and count them so we know when the resource is fully loaded for (auto& dependency : dependencies) { if (dependency != UUID) { bool registerDependency = true; auto iterFind2 = mDependantLoads.find(dependency); if (iterFind2 != mDependantLoads.end()) { Vector<ResourceLoadData*>& dependantData = iterFind2->second; auto iterFind3 = std::find_if(dependantData.begin(), dependantData.end(), [&](ResourceLoadData* x) { return x->resData.resource.getUUID() == outputResource.getUUID(); }); registerDependency = iterFind3 == dependantData.end(); } if (registerDependency) { mDependantLoads[dependency].push_back(loadData); loadData->remainingDependencies++; loadData->dependencies.push_back(_getResourceHandle(dependency)); } } } } for (auto& dependency : dependencies) loadFromUUID(dependency, !synchronous, true, false); } } // Actually start the file read operation if not already loaded or in progress if (!alreadyLoading && !filePath.isEmpty()) { // Synchronous or the resource doesn't support async, read the file immediately if (synchronous || !savedResourceData->allowAsyncLoading()) { loadCallback(filePath, outputResource); } else // Asynchronous, read the file on a worker thread { String fileName = filePath.getFilename(); String taskName = "Resource load: " + fileName; SPtr<Task> task = Task::create(taskName, std::bind(&Resources::loadCallback, this, filePath, outputResource)); TaskScheduler::instance().addTask(task); } } else // File already loaded or in progress { // Complete the load unless its in progress in which case we wait for its worker thread to complete it. // In case file is already loaded this will only decrement dependency count in case this resource is a dependency. if (!loadInProgress) loadComplete(outputResource); else { // In case loading finished in the meantime we cannot be sure at what point ::loadComplete was triggered, // so trigger it manually so that the dependency count is properly decremented in case this resource // is a dependency. Lock lock(mLoadedResourceMutex); auto iterFind = mLoadedResources.find(UUID); if (iterFind != mLoadedResources.end()) loadComplete(outputResource); } } return outputResource; }
void Resources::loadComplete(HResource& resource) { String uuid = resource.getUUID(); ResourceLoadData* myLoadData = nullptr; bool finishLoad = true; Vector<ResourceLoadData*> dependantLoads; { Lock inProgresslock(mInProgressResourcesMutex); auto iterFind = mInProgressResources.find(uuid); if (iterFind != mInProgressResources.end()) { myLoadData = iterFind->second; finishLoad = myLoadData->remainingDependencies == 0; if (finishLoad) mInProgressResources.erase(iterFind); } auto iterFind2 = mDependantLoads.find(uuid); if (iterFind2 != mDependantLoads.end()) dependantLoads = iterFind2->second; if (finishLoad) { mDependantLoads.erase(uuid); // If loadedData is null then we're probably completing load on an already loaded resource, triggered // by its dependencies. if (myLoadData != nullptr && myLoadData->loadedData != nullptr) { Lock loadedLock(mLoadedResourceMutex); mLoadedResources[uuid] = myLoadData->resData; resource.setHandleData(myLoadData->loadedData, uuid); } for (auto& dependantLoad : dependantLoads) dependantLoad->remainingDependencies--; } } for (auto& dependantLoad : dependantLoads) { HResource dependant = dependantLoad->resData.resource.lock(); loadComplete(dependant); } if (finishLoad && myLoadData != nullptr) { onResourceLoaded(resource); // This should only ever be true on the main thread if (myLoadData->notifyImmediately) ResourceListenerManager::instance().notifyListeners(uuid); bs_delete(myLoadData); } }