void SocketApi::onLostConnection() { DEBUG << "Lost connection " << sender(); QIODevice* socket = qobject_cast<QIODevice*>(sender()); _listeners.removeAll(socket); socket->deleteLater(); }
void QWebdav::replyDeleteLater(QNetworkReply* reply) { #ifdef DEBUG_WEBDAV qDebug() << "QWebdav::replyDeleteLater()"; #endif QIODevice *outDataDevice = m_outDataDevices.value(reply, 0); if (outDataDevice!=0) outDataDevice->deleteLater(); m_outDataDevices.remove(reply); }
/** * \brief Loads the file from the given path * \author Peter Grasch * * @fixme This function assumes the system-charset to be ISO-8859-1 and WILL destroy special characters if it isn't * * @param path If the path is empty the path set by the constructor is used */ void BOMPDict::load(QString path, QString encodingName) { emit progress(0); QIODevice *dict = KFilterDev::deviceForFile(path, KMimeType::findByFileContent(path)->name()); if (!dict) return; if (!dict->open(QIODevice::ReadOnly)) { dict->deleteLater(); return; } int maxProg=0; KMimeType::Ptr mimeType = KMimeType::findByFileContent(path); if (mimeType->is("text/plain")) { //not compressed QFileInfo info; QFile f(path); info.setFile(f); maxProg = info.size(); } int currentProg = 0; QTextStream *dictStream = new QTextStream(dict); dictStream->setCodec(QTextCodec::codecForName(encodingName.toAscii())); emit loaded(); QString line, xsp, category; int wordend, termend; line = dictStream->readLine(1000); QString filteredXsp; QString xspFertig; QString currentPhoneme; QString currentCategory; QString currentFinalXsp; QString currentWord; while (!line.isNull()) { wordend = line.indexOf("\t"); termend = line.indexOf("\t", wordend+1); xsp = line.mid(termend).trimmed(); // xsp.remove(QRegExp("^'*?*")); xsp.remove('\''); xsp.remove('|'); xsp.remove(','); currentFinalXsp = segmentSampa(adaptToSimonPhonemeSet(xsp)); currentWord = line.left(wordend); currentCategory = line.mid(wordend, termend-wordend).trimmed(); QStringList currentCategories = currentCategory.split(':', QString::SkipEmptyParts); QStringList currentCategoriesUnique; if (currentCategories.isEmpty()) { line = dictStream->readLine(1000); continue; } QString currentCategoryStr = currentCategories[0]; currentCategoriesUnique << currentCategoryStr; words << currentWord; categories << currentCategoryStr; pronunciations << currentFinalXsp; for (int k=1; k < currentCategories.count(); k++) { currentCategoryStr = currentCategories[k]; if (!currentCategoriesUnique.contains(currentCategoryStr)) { currentCategoriesUnique << currentCategoryStr; words << currentWord; categories << currentCategoryStr; pronunciations << currentFinalXsp; } } currentProg += line.length(); if (maxProg != 0) emit progress((int) (((((double)currentProg) / ((double)maxProg)))*1000)); else emit progress(-1); line = dictStream->readLine(1000); } delete dictStream; dict->close(); delete dict; }