void MainWindow::onMessage(IrcPrivateMessage *message) { auto messages = read.getMessages(message->target()); int messageCount = 150; // Subject to change via settings, currently set as twitch default PattyIrcMessage* pattyMsg = PattyIrcMessage::fromMessage(message); messages->append(pattyMsg); if (message->target() == this->currentChannel) { QString html; QWebFrame* frame = this->ui->baseChatWindow->page()->mainFrame(); this->scrollValue = frame->scrollBarValue(Qt::Vertical); this->autoScroll = (this->scrollValue >= frame->scrollBarMaximum(Qt::Vertical)); if (this->autoScroll) { while (messages->count() > messageCount) { delete messages->takeFirst(); QWebElement message = frame->findFirstElement("div.message"); message.removeFromDocument(); } } addMessage(pattyMsg); } else { if (messages->count() > messageCount) { delete messages->takeFirst(); } } }
void ULLineEditor::pushFirstGlyphAtLastOfPrevLine() { PageBuffer *PB = PageBuffer::getInstance(); if ( PB->maxId() == 0 ) return; uint prevlineId; uint curId; if ( reedit ) { prevlineId = reedit_id - 1; curId = reedit_id; } else { prevlineId = PB->maxId(); curId = prevlineId + 1; } ULGlyphItem *it=takeFirst(); qDebug() << it->key; slotEditGroup(m_mainScene->groupById(prevlineId)); addGlyph(it); slotEditGroup(m_mainScene->groupById(curId)); }
void AsyncRequestList::clear() { int cnt=count(); for (int i=0; i<cnt; i++) { delete takeFirst(); } }
void MainWindow::onLabelRemoved(medusa::Label const & label) { QString labelName = QString::fromStdString(label.GetName()); QListWidget *curList = nullptr; switch (label.GetType()) { case medusa::Label::LabelData: curList = dataList; break; case medusa::Label::LabelCode: curList = codeList; break; case medusa::Label::LabelString: curList = stringList; break; default: break; } if (curList != nullptr) { auto items = curList->findItems(labelName, Qt::MatchExactly); // something bad happened if (items.size() != 1) return; auto item = items.takeFirst(); curList->removeItemWidget(item); delete item; } if (label.GetType() & medusa::Label::LabelImported) curList = importedList; else if (label.GetType() & medusa::Label::LabelExported) curList = exportedList; if (curList != nullptr) { auto items = curList->findItems(labelName, Qt::MatchExactly); // something bad happened if (items.size() != 1) return; auto item = items.takeFirst(); curList->removeItemWidget(item); delete item; } }
void HttpRequestParser::parse(const QString &raw) { Q_D(HttpRequestParser); clear(); d->vaild = (raw.startsWith("GET")); if (!d->vaild){ return; } auto httpInfoList = raw.split("\r\n"); parseHead(httpInfoList.takeFirst()); parseHeader(httpInfoList); }
int main(int argc, char* argv[]) { QCoreApplication app(argc, argv); QCoreApplication::setApplicationName("XmlSchemaValidator"); QCoreApplication::setApplicationVersion("0.1"); QCommandLineParser parser; setupCommandLineParser(parser); parser.process(app); auto args = parser.positionalArguments(); if (args.size() < 2) return -1; auto schemaFile = args.takeFirst(); schemaFile = QDir::toNativeSeparators(schemaFile); XSV::MessageHandler messageHandler; XSV::XmlSchemaValidator validator{QUrl::fromLocalFile(schemaFile), &messageHandler}; QStringList messages; QObject::connect(&messageHandler, &XSV::MessageHandler::msg, [&messages](QtMsgType type, const QString& msg) { messages.push_back(msg); }); int failureCount = 0; for (const auto& arg : args) { qDebug("Validating XML file '%s'...", qPrintable(arg)); auto result = validator.validate(arg); if (result) { qDebug("%s is valid.", qPrintable(arg)); } else { qDebug("***%s is invalid.", qPrintable(arg)); failureCount++; } if (!messages.empty()) qDebug(qPrintable(messages.join("\n"))); qDebug("----------------------"); } return failureCount; }
void ULLineEditor::insertAtLastFirstGlyphOfNextLine() { PageBuffer *PB = PageBuffer::getInstance(); if ( !reedit ) //Last line is current return; if(reedit_id == PB->maxId())//We are the last return; uint nextlineId = reedit_id + 1; uint curId = reedit_id; slotEditGroup(m_mainScene->groupById(nextlineId)); ULGlyphItem *it = takeFirst(); slotEditGroup(m_mainScene->groupById(curId)); addGlyph(it); }
void GamesData::Reload() { while (!isEmpty()) delete takeFirst(); QDir gamesDir(GAMES_DATA_DIR); if (!gamesDir.exists()) { qWarning() << "Games Dir doesn't exist! (" << GAMES_DATA_DIR << ")"; return; } QStringList filter("*.ini"); QStringList fileList = gamesDir.entryList(filter, QDir::Files); QString str; foreach (str, fileList) { GameInfo * game = new GameInfo(GAMES_DATA_DIR"/" + str); append(game); }
CoreAttributesList::~CoreAttributesList() { if (autoDelete()) { setAutoDelete(false); while (!isEmpty()) { delete takeFirst(); } setAutoDelete(true); } // if (autoDelete()) // { // /* We need to make sure that the CoreAttributes are first removed from // * the list and then deleted. */ // setAutoDelete(false); // while (!isEmpty()) // { // CoreAttributes* tp = getFirst(); // removeRef(tp); // delete tp; // } // setAutoDelete(true); // } }
~KCmdLineArgsList() { while (count()) delete takeFirst(); }
void k9CellCopyList::clearList() { while (!isEmpty()) delete takeFirst(); }
GamesData::~GamesData() { while (!isEmpty()) delete takeFirst(); }
void ArtefactList::clear() { while( ! isEmpty() ) { delete takeFirst(); } }
pki_base::~pki_base(void) { while((childCount())) delete takeFirst(); pki_counter--; }