void KateCodeFoldingTree::ensureVisible( uint line ) { // first have a look, if the line is really hidden bool found=false; for (TQValueList<KateHiddenLineBlock>::ConstIterator it=hiddenLines.begin();it!=hiddenLines.end();++it) { if ( ((*it).start<=line) && ((*it).start+(*it).length>line) ) { found=true; break; } } if (!found) return; kdDebug(13000)<<"line "<<line<<" is really hidden ->show block"<<endl; // it looks like we really have to ensure visibility KateCodeFoldingNode *n = findNodeForLine( line ); do { if ( ! n->visible ) toggleRegionVisibility( getStartLine( n ) ); n = n->parentNode; } while( n ); }
void KateCodeFoldingTree::addNodeToRemoveList(KateCodeFoldingNode *node,unsigned int line) { bool add=false; #ifdef __GNUC__ #warning "FIXME: make this multiple region changes per line save"; #endif unsigned int startLine=getStartLine(node); if ((startLine==line) && (node->startLineValid)) { add=true; node->deleteOpening = true; } if ((startLine+node->endLineRel==line) || ((node->endLineValid==false) && (node->deleteOpening))) { int myPos=node->parentNode->findChild(node); // this has to be implemented nicely if ((int)node->parentNode->childCount()>myPos+1) addNodeToRemoveList(node->parentNode->child(myPos+1),line); add=true; node->deleteEnding = true; } if(add) markedForDeleting.append(node); }
void KateCodeFoldingTree::updateHiddenSubNodes(KateCodeFoldingNode *node) { for (uint i=0; i < node->childCount(); ++i) { KateCodeFoldingNode *iter = node->child(i); if (!iter->visible) addHiddenLineBlock(iter, getStartLine(iter)); else updateHiddenSubNodes(iter); } }
void KateCodeFoldingTree::getLineInfo(KateLineInfo *info, unsigned int line) { // Initialze the returned structure, this will also be returned if the root node has no child nodes // or the line is not within a childnode's range. info->topLevel = true; info->startsVisibleBlock = false; info->startsInVisibleBlock = false; info->endsBlock = false; info->invalidBlockEnd = false; if (m_root.noChildren()) return; //let's look for some information for ( uint i=0; i < m_root.childCount(); ++i ) { KateCodeFoldingNode *node = m_root.child(i); if ((node->startLineRel<=line) && (line<=node->startLineRel+node->endLineRel)) // we found a node, which contains the given line -> do a complete lookup { info->topLevel = false; //we are definitly not toplevel findAllNodesOpenedOrClosedAt(line); //lookup all nodes, which start or and at the given line for ( KateCodeFoldingNode *node = nodesForLine.first(); node; node = nodesForLine.next() ) { uint startLine = getStartLine(node); // type<0 means, that a region has been closed, but not opened // eg. parantheses missmatch if (node->type < 0) info->invalidBlockEnd=true; else { if (startLine != line) // does the region we look at not start at the given line info->endsBlock = true; // than it has to be an ending else { // The line starts a new region, now determine, if it's a visible or a hidden region if (node->visible) info->startsVisibleBlock=true; else info->startsInVisibleBlock=true; } } } return; } } return; }
bool KateCodeFoldingTree::removeOpening(KateCodeFoldingNode *node,unsigned int line) { signed char type; if ((type=node->type) == 0) { dontDeleteOpening(node); dontDeleteEnding(node); return false; } if (!node->visible) { toggleRegionVisibility(getStartLine(node)); } KateCodeFoldingNode *parent = node->parentNode; int mypos = parent->findChild(node); if (mypos > -1) { //move childnodes() up for(; node->childCount()>0 ;) { KateCodeFoldingNode *tmp; parent->insertChild(mypos, tmp=node->takeChild(0)); tmp->parentNode = parent; tmp->startLineRel += node->startLineRel; mypos++; } // remove the node //mypos = parent->findChild(node); bool endLineValid = node->endLineValid; int endLineRel = node->endLineRel; uint endCol=node->endCol; // removes + deletes KateCodeFoldingNode *child = parent->takeChild(mypos); markedForDeleting.removeRef(child); delete child; if ((type>0) && (endLineValid)) correctEndings(-type, parent, line+endLineRel/*+1*/,endCol, mypos); // why the hell did I add a +1 here ? } return true; }
void KateCodeFoldingTree::lineHasBeenRemoved(unsigned int line) { lineMapping.clear(); dontIgnoreUnchangedLines.insert(line, &trueVal); dontIgnoreUnchangedLines.insert(line-1, &trueVal); dontIgnoreUnchangedLines.insert(line+1, &trueVal); hiddenLinesCountCacheValid = false; #if JW_DEBUG kdDebug(13000)<<TQString("KateCodeFoldingTree::lineHasBeenRemoved: %1").arg(line)<<endl; #endif //line ++; findAndMarkAllNodesforRemovalOpenedOrClosedAt(line); //It's an ugly solution cleanupUnneededNodes(line); //It's an ugly solution KateCodeFoldingNode *node = findNodeForLine(line); //????? if (node->endLineValid) { int startLine = getStartLine(node); if (startLine == (int)line) node->startLineRel--; else { if (node->endLineRel == 0) node->endLineValid = false; node->endLineRel--; } int count = node->childCount(); for (int i=0; i<count; i++) { if (node->child(i)->startLineRel+startLine >= line) node->child(i)->startLineRel--; } } if (node->parentNode) decrementBy1(node->parentNode, node); for (TQValueList<KateHiddenLineBlock>::Iterator it=hiddenLines.begin(); it!=hiddenLines.end(); ++it) { if ((*it).start > line) (*it).start--; else if ((*it).start+(*it).length > line) (*it).length--; } }
bool KateCodeFoldingTree::existsOpeningAtLineAfter(unsigned int line, KateCodeFoldingNode *node) { for(KateCodeFoldingNode *tmp = node->parentNode; tmp; tmp=tmp->parentNode) { KateCodeFoldingNode *tmp2; unsigned int startLine=getStartLine(tmp); if ((tmp2 = tmp->child(tmp->findChild(node) + 1)) && ((tmp2->startLineRel + startLine) == line)) return true; if ((startLine + tmp->endLineRel) > line) return false; } return false; }
void KateCodeFoldingTree::lineHasBeenInserted(unsigned int line) { lineMapping.clear(); dontIgnoreUnchangedLines.insert(line, &trueVal); dontIgnoreUnchangedLines.insert(line-1, &trueVal); dontIgnoreUnchangedLines.insert(line+1, &trueVal); hiddenLinesCountCacheValid = false; //return; #if JW_DEBUG kdDebug(13000)<<TQString("KateCodeFoldingTree::lineHasBeenInserted: %1").arg(line)<<endl; #endif // findAndMarkAllNodesforRemovalOpenedOrClosedAt(line); // cleanupUnneededNodes(line); KateCodeFoldingNode *node = findNodeForLine(line); // ???????? if (node->endLineValid) { int startLine=getStartLine(node); if (node->type < 0) node->startLineRel++; else node->endLineRel++; for (uint i=0; i < node->childCount(); ++i) { KateCodeFoldingNode *iter = node->child(i); if (iter->startLineRel+startLine >= line) iter->startLineRel++; } } if (node->parentNode) incrementBy1(node->parentNode, node); for (TQValueList<KateHiddenLineBlock>::Iterator it=hiddenLines.begin(); it!=hiddenLines.end(); ++it) { if ((*it).start > line) (*it).start++; else if ((*it).start+(*it).length > line) (*it).length++; } }
void KateCodeFoldingTree::toggleRegionVisibility(unsigned int line) { // hl whole file m_buffer->line (m_buffer->count()-1); lineMapping.clear(); hiddenLinesCountCacheValid = false; kdDebug(13000)<<TQString(TQString("KateCodeFoldingTree::toggleRegionVisibility() %1").arg(line))<<endl; findAllNodesOpenedOrClosedAt(line); for (int i=0; i<(int)nodesForLine.count(); i++) { KateCodeFoldingNode *node=nodesForLine.at(i); if ( (!node->startLineValid) || (getStartLine(node) != line) ) { nodesForLine.remove(i); i--; } } if (nodesForLine.isEmpty()) return; nodesForLine.at(0)->visible = !nodesForLine.at(0)->visible; if (!nodesForLine.at(0)->visible) addHiddenLineBlock(nodesForLine.at(0),line); else { for (TQValueList<KateHiddenLineBlock>::Iterator it=hiddenLines.begin(); it!=hiddenLines.end();++it) if ((*it).start == line+1) { hiddenLines.remove(it); break; } updateHiddenSubNodes(nodesForLine.at(0)); } emit regionVisibilityChangedAt(line); }
void KateCodeFoldingTree::findAndMarkAllNodesforRemovalOpenedOrClosedAt(unsigned int line) { #ifdef __GNUC__ #warning "FIXME: make this multiple region changes per line save"; #endif // return; markedForDeleting.clear(); KateCodeFoldingNode *node = findNodeForLine(line); if (node->type == 0) return; addNodeToRemoveList(node, line); while (((node->parentNode) && (node->parentNode->type!=0)) && (getStartLine(node->parentNode)==line)) { node = node->parentNode; addNodeToRemoveList(node, line); } #if JW_DEBUG kdDebug(13000)<<" added line to markedForDeleting list"<<endl; #endif }
void KateCodeFoldingTree::findAllNodesOpenedOrClosedAt(unsigned int line) { nodesForLine.clear(); KateCodeFoldingNode *node = findNodeForLine(line); if (node->type == 0) return; unsigned int startLine = getStartLine(node); if (startLine == line) nodesForLine.append(node); else if ((startLine+node->endLineRel == line)) nodesForLine.append(node); while (node->parentNode) { addNodeToFoundList(node->parentNode, line, node->parentNode->findChild(node)); node = node->parentNode; } #if JW_DEBUG kdDebug(13000)<<" added line to nodesForLine list"<<endl; #endif }
void KateCodeFoldingTree::addNodeToFoundList(KateCodeFoldingNode *node,unsigned int line,int childpos) { unsigned int startLine = getStartLine(node); if ((startLine==line) && (node->type!=0)) nodesForLine.append(node); else if ((startLine+node->endLineRel==line) && (node->type!=0)) nodesForLine.append(node); for (int i=childpos+1; i<(int)node->childCount(); i++) { KateCodeFoldingNode *child = node->child(i); if (startLine+child->startLineRel == line) { nodesForLine.append(child); addNodeToFoundList(child, line, 0); } else break; } }
bool KateCodeFoldingTree::correctEndings(signed char data, KateCodeFoldingNode *node,unsigned int line,unsigned int endCol,int insertPos) { // if (node->type==0) {kdError()<<"correct Ending should never be called with the root node"<<endl; return true;} uint startLine = getStartLine(node); if (data != -node->type) { #if JW_DEBUG kdDebug(13000)<<"data!=-node->type (correctEndings)"<<endl; #endif //invalid close -> add to unopend list dontDeleteEnding(node); if (data == node->type) { node->endCol=endCol; return false; } KateCodeFoldingNode *newNode = new KateCodeFoldingNode (node,data,line-startLine); something_changed = true; newNode->startLineValid = false; newNode->endLineValid = true; newNode->endLineRel = 0; newNode->endCol=endCol; if ((insertPos==-1) || (insertPos==(int)node->childCount())) node->appendChild(newNode); else node->insertChild(insertPos,newNode); // find correct position return false; } else { something_changed = true; dontDeleteEnding(node); // valid closing region if (!node->endLineValid) { node->endLineValid = true; node->endLineRel = line - startLine; node->endCol=endCol; //moving moveSubNodesUp(node); } else { #if JW_DEBUG kdDebug(13000)<<"Closing a node which had already a valid end"<<endl; #endif // block has already an ending if (startLine+node->endLineRel == line) { node->endCol=endCol; // we won, just skip #if JW_DEBUG kdDebug(13000)<< "We won, just skipping (correctEndings)"<<endl; #endif } else { int bakEndLine = node->endLineRel+startLine; uint bakEndCol = node->endCol; node->endLineRel = line-startLine; node->endCol=endCol; #if JW_DEBUG kdDebug(13000)<< "reclosed node had childnodes()"<<endl; kdDebug(13000)<<"It could be, that childnodes() need to be moved up"<<endl; #endif moveSubNodesUp(node); if (node->parentNode) { correctEndings(data,node->parentNode,bakEndLine, bakEndCol,node->parentNode->findChild(node)+1); // ???? } else { //add to unopened list (bakEndLine) } } } } return true; }
bool KateCodeFoldingTree::removeEnding(KateCodeFoldingNode *node,unsigned int /* line */) { KateCodeFoldingNode *parent = node->parentNode; if (!parent) return false; if (node->type == 0) return false; if (node->type < 0) { // removes + deletes int i = parent->findChild (node); if (i >= 0) { KateCodeFoldingNode *child = parent->takeChild(i); markedForDeleting.removeRef(child); delete child; } return true; } int mypos = parent->findChild(node); int count = parent->childCount(); for (int i=mypos+1; i<count; i++) { if (parent->child(i)->type == -node->type) { node->endLineValid = true; node->endLineRel = parent->child(i)->startLineRel - node->startLineRel; KateCodeFoldingNode *child = parent->takeChild(i); markedForDeleting.removeRef(child); delete child; count = i-mypos-1; if (count > 0) { for (int i=0; i<count; i++) { KateCodeFoldingNode *tmp = parent->takeChild(mypos+1); tmp->startLineRel -= node->startLineRel; tmp->parentNode = node; //should help 16.04.2002 node->appendChild(tmp); } } return false; } } if ( (parent->type == node->type) || /*temporary fix */ (!parent->parentNode)) { for (int i=mypos+1; i<(int)parent->childCount(); i++) { KateCodeFoldingNode *tmp = parent->takeChild(mypos+1); tmp->startLineRel -= node->startLineRel; tmp->parentNode = node; // SHOULD HELP 16.04.2002 node->appendChild(tmp); } // this should fix the bug of wrongly closed nodes if (!parent->parentNode) node->endLineValid=false; else node->endLineValid = parent->endLineValid; node->endLineRel = parent->endLineRel-node->startLineRel; if (node->endLineValid) return removeEnding(parent, getStartLine(parent)+parent->endLineRel); return false; } node->endLineValid = false; node->endLineRel = parent->endLineRel - node->startLineRel; return false; }
/* That's one of the most important functions ;) */ void KateCodeFoldingTree::updateLine(unsigned int line, TQMemArray<uint> *regionChanges, bool *updated,bool changed,bool colsChanged) { if ( (!changed) || colsChanged) { if (dontIgnoreUnchangedLines.isEmpty()) return; if (dontIgnoreUnchangedLines[line]) dontIgnoreUnchangedLines.remove(line); else return; } something_changed = false; findAndMarkAllNodesforRemovalOpenedOrClosedAt(line); if (regionChanges->isEmpty()) { // KateCodeFoldingNode *node=findNodeForLine(line); // if (node->type!=0) // if (getStartLine(node)+node->endLineRel==line) removeEnding(node,line); } else { for (unsigned int i=0;i<regionChanges->size() / 4;i++) { signed char tmp=(*regionChanges)[regionChanges->size()-2-i*2]; uint tmppos=(*regionChanges)[regionChanges->size()-1-i*2]; (*regionChanges)[regionChanges->size()-2-i*2]=(*regionChanges)[i*2]; (*regionChanges)[regionChanges->size()-1-i*2]=(*regionChanges)[i*2+1]; (*regionChanges)[i*2]=tmp; (*regionChanges)[i*2+1]=tmppos; } signed char data= (*regionChanges)[regionChanges->size()-2]; uint charPos=(*regionChanges)[regionChanges->size()-1]; regionChanges->resize (regionChanges->size()-2); int insertPos=-1; KateCodeFoldingNode *node = findNodeForLine(line); if (data<0) { // if (insertPos==-1) { unsigned int tmpLine=line-getStartLine(node); for ( uint i=0; i < node->childCount(); ++i ) { if (node->child(i)->startLineRel >= tmpLine) { insertPos=i; break; } } } } else { for (; (node->parentNode) && (getStartLine(node->parentNode)==line) && (node->parentNode->type!=0); node=node->parentNode); if ((getStartLine(node)==line) && (node->type!=0)) { insertPos=node->parentNode->findChild(node); node = node->parentNode; } else { for ( uint i=0; i < node->childCount(); ++i ) { if (getStartLine(node->child(i))>=line) { insertPos=i; break; } } } } do { if (data<0) { if (correctEndings(data,node,line,charPos,insertPos)) { insertPos=node->parentNode->findChild(node)+1; node=node->parentNode; } else { if (insertPos!=-1) insertPos++; } } else { int startLine=getStartLine(node); if ((insertPos==-1) || (insertPos>=(int)node->childCount())) { KateCodeFoldingNode *newNode = new KateCodeFoldingNode (node,data,line-startLine); something_changed = true; node->appendChild(newNode); addOpening(newNode, data, regionChanges, line,charPos); insertPos = node->findChild(newNode)+1; } else { if (node->child(insertPos)->startLineRel == line-startLine) { addOpening(node->child(insertPos), data, regionChanges, line,charPos); insertPos++; } else { // kdDebug(13000)<<"ADDING NODE "<<endl; KateCodeFoldingNode *newNode = new KateCodeFoldingNode (node,data,line-startLine); something_changed = true; node->insertChild(insertPos, newNode); addOpening(newNode, data, regionChanges, line,charPos); insertPos++; } } } if (regionChanges->isEmpty()) data = 0; else { data = (*regionChanges)[regionChanges->size()-2]; charPos=(*regionChanges)[regionChanges->size()-1]; regionChanges->resize (regionChanges->size()-2); } } while (data!=0); } cleanupUnneededNodes(line); // if (something_changed) emit regionBeginEndAddedRemoved(line); (*updated) = something_changed; }
void KateCodeFoldingTree::addOpening(KateCodeFoldingNode *node,signed char nType, TQMemArray<uint>* list,unsigned int line,unsigned int charPos) { uint startLine = getStartLine(node); if ((startLine==line) && (node->type!=0)) { #if JW_DEBUG kdDebug(13000)<<"startLine equals line"<<endl; #endif if (nType == node->type) { #if JW_DEBUG kdDebug(13000)<<"Node exists"<<endl; #endif node->deleteOpening = false; node->startCol=charPos; KateCodeFoldingNode *parent = node->parentNode; if (!node->endLineValid) { int current = parent->findChild(node); int count = parent->childCount()-(current+1); node->endLineRel = parent->endLineRel - node->startLineRel; // EXPERIMENTAL TEST BEGIN // move this afte the test for unopened, but closed regions within the parent node, or if there are no siblings, bubble up if (parent) if (parent->type == node->type) { if (parent->endLineValid) { removeEnding(parent, line); node->endLineValid = true; } } // EXPERIMENTAL TEST BEGIN if (current != (int)parent->childCount()-1) { //search for an unopened but closed region, even if the parent is of the same type #ifdef __GNUC__ #warning "FIXME: why does this seem to work?" #endif // if (node->type != parent->type) { for (int i=current+1; i<(int)parent->childCount(); i++) { if (parent->child(i)->type == -node->type) { count = (i-current-1); node->endLineValid = true; node->endLineRel = getStartLine(parent->child(i))-line; node->endCol = parent->child(i)->endCol; KateCodeFoldingNode *child = parent->takeChild(i); markedForDeleting.removeRef( child ); delete child; break; } } } // else // { // parent->endLineValid = false; // parent->endLineRel = 20000; // } if (count>0) { for (int i=0;i<count;i++) { KateCodeFoldingNode *tmp; node->appendChild(tmp=parent->takeChild(current+1)); tmp->startLineRel -= node->startLineRel; tmp->parentNode = node; } } } } addOpening_further_iterations(node, nType, list, line, 0, startLine,node->startCol); } //else ohoh, much work to do same line, but other region type } else { // create a new region KateCodeFoldingNode *newNode = new KateCodeFoldingNode (node,nType,line-startLine); something_changed = true; int insert_position=-1; for (int i=0; i<(int)node->childCount(); i++) { if (startLine+node->child(i)->startLineRel > line) { insert_position=i; break; } } int current; if (insert_position==-1) { node->appendChild(newNode); current = node->childCount()-1; } else { node->insertChild(insert_position, newNode); current = insert_position; } // if (node->type==newNode->type) // { // newNode->endLineValid=true; // node->endLineValid=false; // newNode->endLineRel=node->endLineRel-newNode->startLineRel; // node->endLineRel=20000; //FIXME int count = node->childCount() - (current+1); newNode->endLineRel -= newNode->startLineRel; if (current != (int)node->childCount()-1) { if (node->type != newNode->type) { for (int i=current+1; i<(int)node->childCount(); i++) { if (node->child(i)->type == -newNode->type) { count = node->childCount() - i - 1; newNode->endLineValid = true; newNode->endLineRel = line - getStartLine(node->child(i)); KateCodeFoldingNode *child = node->takeChild(i); markedForDeleting.removeRef( child ); delete child; break; } } } else { node->endLineValid = false; node->endLineRel = 10000; } if (count > 0) { for (int i=0;i<count;i++) { KateCodeFoldingNode *tmp; newNode->appendChild(tmp=node->takeChild(current+1)); tmp->parentNode=newNode; } } // } } addOpening(newNode, nType, list, line,charPos); addOpening_further_iterations(node, node->type, list, line, current, startLine,node->startCol); } }
bool TextImportConfig::parserToOneColumn() { if(!m_parser->isValid()) { return false; } m_data.clear(); m_parser->seek(0); QString line; int lineCount = 0; int startLine = getStartLine(); int endLine = getEndLine(); saDebug(QString("[start parser] startLine:%1 ,endLine:%2 ").arg(startLine).arg(endLine)); double d = 0; bool isOK = false; auto pd = SAValueManager::makeData<SAVectorDouble>(); m_data.append(std::static_pointer_cast<SAAbstractDatas>(pd)); do{ line = m_parser->readLine(); ++lineCount; if(startLine > 0) {//需要忽略头n行 if(lineCount<startLine) continue; } if(endLine > 0) {//有指定结束范围 if(lineCount>endLine) { break; } } QStringList strlist; if(Txt == m_textType) { QString seperator = getSpliter(); if(seperator.isEmpty ()) {//没有指定分割 strlist << line; } else {//指定了分割,先进行分割 strlist = line.split (seperator); } } else if(Csv == m_textType) { strlist = SACsvParser::fromCsvLine(line); } int sps = strlist.size (); for(int i=0;i<sps;++i) { d = strlist[i].toDouble(&isOK); if(isOK) { pd->append(d); } } }while(!line.isNull ()); emit dataChanged(); return true; }
void KateCodeFoldingTree::addOpening_further_iterations(KateCodeFoldingNode *node,signed char /* nType */, TQMemArray<uint>* list,unsigned int line,int current, unsigned int startLine,unsigned int charPos) { while (!(list->isEmpty())) { if (list->isEmpty()) return; else { signed char data = (*list)[list->size()-2]; uint charPos=(*list)[list->size()-1]; list->resize (list->size()-2); if (data<0) { #if JW_DEBUG kdDebug(13000)<<"An ending was found"<<endl; #endif if (correctEndings(data,node,line,charPos,-1)) return; // -1 ? #if 0 if(data == -nType) { if (node->endLineValid) { if (node->endLineRel+startLine==line) // We've won again { //handle next node; } else { // much moving node->endLineRel=line-startLine; node->endLineValid=true; } return; // next higher level should do the rest } else { node->endLineRel=line-startLine; node->endLineValid=true; //much moving } } //else add to unopened list #endif } else { bool needNew = true; if (current < (int)node->childCount()) { if (getStartLine(node->child(current)) == line) needNew=false; } if (needNew) { something_changed = true; KateCodeFoldingNode *newNode = new KateCodeFoldingNode(node, data, line-startLine); node->insertChild(current, newNode); //find the correct position later } addOpening(node->child(current), data, list, line,charPos); current++; //lookup node or create subnode } } } // end while }
int SearchDialog::find() { QRegExp searchTextRegExp; QDltMsg msg; QByteArray buf; QString text; int searchLine; int searchBorder; if(file->sizeFilter()==0) return 0; //setSearchColour(QColor(0,0,0),QColor(255,255,255)); if(getMatch() || getSearchFromBeginning()==false){ QModelIndexList list = table->selectionModel()->selection().indexes(); if(list.count()<=0) { QMessageBox::critical(0, QString("DLT Viewer"),QString("No message selected")); setMatch(false); //table->clearSelection(); //setSearchColour(QColor(255,255,255),QColor(255,102,102)); return 0; } QModelIndex index; for(int num=0; num < list.count();num++) { index = list[num]; if(index.column()==0) { break; } } setStartLine(index.row()); } searchLine = getStartLine(); searchBorder = getStartLine();; if(searchBorder < 0){ if(getNextClicked()){ searchBorder = file->sizeFilter()==0?0:file->sizeFilter()-1; }else{ searchBorder = 0; } } if(getRegExp()) { searchTextRegExp.setPattern(getText()); searchTextRegExp.setCaseSensitivity(getCaseSensitive()?Qt::CaseSensitive:Qt::CaseInsensitive); if (!searchTextRegExp.isValid()) { QMessageBox::warning(0, QString("Search"), QString("Invalid regular expression!")); //setSearchColour(QColor(255,255,255),QColor(255,102,102)); return 0; } } QProgressDialog fileprogress("Searching...", "Abort", 0, file->sizeFilter(), this); fileprogress.setWindowTitle("DLT Viewer"); fileprogress.setWindowModality(Qt::WindowModal); fileprogress.show(); do { if(getNextClicked()){ searchLine++; if(searchLine >= file->sizeFilter()){ searchLine = 0; //QMessageBox::information(0, QString("Search"),QString("End of file reached. Search start from top.")); } }else{ searchLine--; if(searchLine <= -1){ searchLine = file->sizeFilter()-1; //QMessageBox::information(0, QString("Search"),QString("Top of file reached. Search start from bottom.")); } } //qDebug()<<"startLine: "<<getStartLine(); //qDebug()<<"searchBorder: "<<searchBorder; //qDebug()<<"searchLine: "<<searchLine; if(getNextClicked()){ fileprogress.setValue(searchLine+1); }else{ fileprogress.setValue(file->sizeFilter()-searchLine); } /* get the message with the selected item id */ buf = file->getMsgFilter(searchLine); msg.setMsg(buf); for(int num2 = 0; num2 < plugin->topLevelItemCount (); num2++) { PluginItem *item = (PluginItem*)plugin->topLevelItem(num2); if(item->getMode() != item->ModeDisable && item->plugindecoderinterface && item->plugindecoderinterface->isMsg(msg,1)) { item->plugindecoderinterface->decodeMsg(msg,1); break; } } bool pluginFound = false; /* search header */ if(!pluginFound || text.isEmpty()) { text += msg.toStringHeader(); } if(getHeader()) { if (getRegExp()) { if(text.contains(searchTextRegExp)) { table->selectRow(searchLine); setStartLine(searchLine); setMatch(true); break; }else { setMatch(false); } } else { if(text.contains(getText(),getCaseSensitive()? Qt::CaseSensitive : Qt::CaseInsensitive )) { table->selectRow(searchLine); setStartLine(searchLine); setMatch(true); break; }else { setMatch(false); } } } /* search payload */ text.clear(); if(!pluginFound || text.isEmpty()) { text += msg.toStringPayload(); } if(getPayload()) { if (getRegExp()) { if(text.contains(searchTextRegExp)) { table->selectRow(searchLine); setMatch(true); setStartLine(searchLine); break; }else { setMatch(false); } } else { if(text.contains(getText(),getCaseSensitive()?Qt::CaseSensitive:Qt::CaseInsensitive)) { table->selectRow(searchLine); setMatch(true); setStartLine(searchLine); break; } else { setMatch(false); } } } }while(searchBorder != searchLine); if(getMatch()) { return 1; } //table->clearSelection(); //setSearchColour(QColor(255,255,255),QColor(255,102,102)); return 0; }