static void parseStyle (xmlDocPtr doc, xmlNodePtr cur, FB2Content *fb) { xmlChar *content; xmlChar *prop; int start = fb->utf8_current_index; prop = xmlGetProp(cur, (const xmlChar *)"name"); cur = cur->children; while (cur != NULL) { if (xmlNodeIsText(cur)) { content = xmlNodeGetContent(cur); if (content) bufferAppend(content, xmlStrlen(content), fb); xmlFree(content); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"style")) { parseStyle(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"strong")) { content = xmlNodeGetContent(cur->children); if (content) { int st = fb->utf8_current_index; bufferAppend(content, xmlStrlen(content), fb); addMark(st, fb->utf8_current_index, STRONG_TYPE, NULL, fb); } xmlFree(content); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"emphasis")) { content = xmlNodeGetContent(cur->children); if (content) { int st = fb->utf8_current_index; bufferAppend(content, xmlStrlen(content), fb); addMark(st, fb->utf8_current_index, EMPHASIS_TYPE, NULL, fb); } xmlFree(content); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"a")) { parseLink(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"image")) { parseImage(doc, cur, fb); } cur = cur->next; } if (prop && (!xmlStrcmp(prop, (const xmlChar *)"italic"))) { addMark(start, fb->utf8_current_index, EMPHASIS_TYPE, NULL, fb); xmlFree(prop); } return; }
static void parseTitle (xmlDocPtr doc, xmlNodePtr cur, FB2Content *fb) { int start; bufferAppend("\n", 1, fb); start = fb->utf8_current_index; cur = cur->children; while (cur != NULL) { if (!xmlStrcmp(cur->name, (const xmlChar *)"p")) { parseP(doc, cur, 0, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"empty-line")) { bufferAppend("\n", 1, fb); } cur = cur->next; } addMark(start, fb->utf8_current_index-1, BOOKMARK_TYPE, NULL, fb); bufferAppend("\n", 1, fb); return; }
void TextMarkRegistry::add(TextMark *mark) { m_marks[FileName::fromString(mark->fileName())].insert(mark); auto document = qobject_cast<TextDocument*>(DocumentModel::documentForFilePath(mark->fileName())); if (!document) return; document->addMark(mark); }
void TextMarkRegistry::editorOpened(IEditor *editor) { auto document = qobject_cast<TextDocument *>(editor ? editor->document() : 0); if (!document) return; if (!m_marks.contains(document->filePath())) return; foreach (TextMark *mark, m_marks.value(document->filePath())) document->addMark(mark); }
void GraphicalBoardFrame::recreateWidgets() { Quackle::Board emptyBoard; emptyBoard.prepareEmptyBoard(); for (QSize currentTile(0, 0); currentTile.height() < m_boardSize.height(); currentTile.setHeight(currentTile.height() + 1)) { for (currentTile.setWidth(0); currentTile.width() < m_boardSize.width(); currentTile.setWidth(currentTile.width() + 1)) { TileWidget *newTile = new TileWidget; newTile->setLocation(currentTile); newTile->setAlwaysShowVerboseLabels(m_alwaysShowVerboseLabels); newTile->setOriginalInformation(emptyBoard.tileInformation(currentTile.height(), currentTile.width())); addTile(currentTile, newTile); } } for (int row = 0; row <= m_boardSize.height(); ++row) { MarkWidget *newMark = new MarkWidget; if (row == 0) newMark->setCapstone(); else newMark->setRow(row); addMark(QSize(0, row), newMark); } for (int col = 1; col <= m_boardSize.width(); ++col) { MarkWidget *newMark = new MarkWidget; newMark->setCol(col); addMark(QSize(col, 0), newMark); } }
static void parseSection (xmlDocPtr doc, xmlNodePtr cur, FB2Content *fb) { FB2Mark *mark; mark = getLink(cur, fb); cur = cur->children; while (cur != NULL) { if (!xmlStrcmp(cur->name, (const xmlChar *)"title")) { parseTitle(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"section")) { parseSection(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"poem")) { parsePoem(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"cite")) { parseCite(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"epigraph")) { parseEpigraph(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"p")) { parseP(doc, cur, 1, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"subtitle")) { int start = fb->utf8_current_index; parseP(doc, cur, 0, fb); addMark(start, fb->utf8_current_index, BOOKMARK_TYPE, NULL, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"empty-line")) { bufferAppend("\n", 1, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"image")) { parseImage(doc, cur, fb); } cur = cur->next; } if (mark) mark->link_end = fb->text_current_index; return; }
static void parseImage (xmlDocPtr doc, xmlNodePtr cur, FB2Content *fb) { xmlChar *prop; prop = xmlGetProp(cur, (const xmlChar *)"href"); if (prop) { bufferAppend("\n\n", 2, fb); addMark(fb->utf8_current_index-1, fb->utf8_current_index, IMAGE_TYPE, prop, fb); } xmlFree(prop); return; }
static void parseBody (xmlDocPtr doc, xmlNodePtr cur, FB2Content *fb) { xmlChar *prop; prop = xmlGetProp(cur, (const xmlChar *)"name"); if (prop) { int start = fb->utf8_current_index; bufferAppend("\n\n", 2, fb); bufferAppend(prop, xmlStrlen(prop), fb); bufferAppend("\n\n", 2, fb); addMark(start, fb->utf8_current_index, BOOKMARK_TYPE, NULL, fb); xmlFree(prop); } cur = cur->children; while (cur != NULL) { if (!xmlStrcmp(cur->name, (const xmlChar *)"section")) { parseSection(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"title")) { parseTitle(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"image")) { parseImage(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"epigraph")) { parseEpigraph(doc, cur, fb); } cur = cur->next; } return; }
/*----------------------------------------------------------------* * checkArgs: * * Check command line parameters * *----------------------------------------------------------------*/ static void checkArgs(int argc, char *argv[]) { strcpy(prgName, (char *)argv[0]); strcpy(name, prgName); while (--argc > 0) { ++argv; /* next parameter. */ match = 0; /* no match so far. */ if (strcmp((char *)argv[0],"-region")==0) { if ((argc-1)>0 && (*(argv+1))[0] != '-') { --argc; ++argv; strcpy(rpName, (char *)argv[0]); } else strcat(rpName, dotEnd); printf("Region profiling to output file %s.\n", rpName); match = 1; makeRP = 1; } if (strcmp((char *)argv[0],"-stack")==0) { if ((argc-1)>0 && (*(argv+1))[0] != '-') { --argc; ++argv; strcpy(stackName, (char *)argv[0]); } else strcat(stackName, dotEnd); printf("Stack profiling to output file %s.\n", stackName); match = 1; makeSP = 1; } if (strcmp((char *)argv[0],"-object")==0) { if (--argc > 0 && (*++argv)[0]) { /* Is there a region number. */ if ((regionNo = atoi((char *)argv[0])) == 0) { printf("Something wrong with the region number after the -object switch.\n"); printUsage(); } } else { printf("No region number after the -object switch.\n"); printUsage(); } if ((argc-1)>0 && (*(argv+1))[0] != '-') { --argc; ++argv; strcpy(objName, (char *)argv[0]); } else { sprintf(tempStr, "%d", regionNo); strcat(objName, tempStr); strcat(objName, dotEnd); } printf("Object profiling on region %d to output file %s.\n", regionNo, objName); match = 1; makeObjP = 1; } if (strcmp((char *)argv[0],"-findPrgPoint")==0) { if (--argc > 0 && (*++argv)[0]) { /* Is there a number. */ if ((prgPoint = atoi((char *)argv[0])) == 0) { printf("Something wrong with the number after the -findPrgPoint switch.\n"); printUsage(); } } else { printf("No number after the -findPrgPoint switch.\n"); printUsage(); } printf("Find program point %d.\n", prgPoint); findPrgPoint = 1; match = 1; } if (strcmp((char *)argv[0],"-noOfBands")==0) { if (--argc > 0 && (*++argv)[0]) { /* Is there a number. */ if ((noOfBands = atoi((char *)argv[0])) == 0) { printf("Something wrong with the number after the -noOfBands switch.\n"); printUsage(); } } else { printf("No number after the -noOfBands switch.\n"); printUsage(); } noOfBands = min(noOfBands, MAX_NO_OF_BANDS); printf("Show %d bands on graph.\n", noOfBands); match = 1; } if (strcmp((char *)argv[0],"-fixedYRange")==0) { if (--argc > 0 && (*++argv)[0]) { /* Is there a number. */ if ((fixedYRange = atoi((char *)argv[0])) == 0) { printf("Something wrong with the number after the -fixedYRange switch.\n"); printUsage(); } } else { printf("No number after the -fixedYRange switch.\n"); printUsage(); } if (fixedYRange < 0) printf("Do not use fixed range on y-axis.\n"); else printf("Use %d bytes as fixed range on y-axis.\n", fixedYRange); match = 1; } if (strcmp((char *)argv[0], "-print")==0) { printf("Print profile\n"); printProfile = 1; match = 1; } if (strcmp((char *)argv[0], "-interactive")==0) { printf("Interactive\n"); match = 1; interact = 1; } if ((strcmp((char *)argv[0], "-h")==0) || (strcmp((char *)argv[0], "-help")==0)) { printf("Help\n"); match = 1; printUsage(); } if (strcmp((char *)argv[0],"-pregion")==0) { if (--argc > 0 && (*++argv)[0]) { /* Is there a region number. */ if ((regionNo2 = atoi((char *)argv[0])) == 0) { printf("Something wrong with the region number after the -pregion switch.\n"); printUsage(); } } else { printf("No region number after the -pregion switch.\n"); printUsage(); } printf("Print region %d.\n", regionNo2); match = 1; printRegion = 1; } if (strcmp((char *)argv[0],"-source")==0) { if ((argc-1)>0 && (*(argv+1))[0] != '-') { --argc; ++argv; strcpy(logName, (char *)argv[0]); } else { printf("No filename after the -source switch.\n"); printUsage(); } printf("Using input file %s.\n", logName); match = 1; } if (strcmp((char *)argv[0],"-name")==0) { if ((argc-1)>0 && (*(argv+1))[0] != '-') { --argc; ++argv; strcpy(name, (char *)argv[0]); } else { printf("No name after the -name switch.\n"); printUsage(); } printf("Using name %s.\n", name); match = 1; } if (strcmp((char *)argv[0], "-stat")==0) { printf("Print some statistics\n"); match = 1; printSomeStat = 1; } if (strcmp((char *)argv[0],"-eps")==0) { if (--argc > 0 && (*++argv)[0]) { /* Is there a width. */ if ((epsfwidth = atof((char *)argv[0])) == 0) { printf("Something wrong with width after the -eps switch.\n"); printUsage(); } if (--argc > 0 && (*++argv)[0]) { /* in, mm or pt. */ if (strcmp((char *)argv[0], "in") == 0) epsfwidth *= 72.0; else if (strcmp((char *)argv[0], "mm") == 0) epsfwidth = (float) (epsfwidth*2.834646); else if (strcmp((char *)argv[0], "pt") != 0) { printf("No/wrong in, mm or pt after -eps width switch\n"); printUsage(); } } else { printf("No in, mm or pt after -eps width switch\n"); printUsage(); } } else { printf("No width after -eps switch.\n"); printUsage(); } printf("Using encapsulated postscript with width %0.0f pt.\n", epsfwidth); eflag = 1; match = 1; } if (strcmp((char *)argv[0],"-comment")==0) { if (--argc > 0 && (*++argv)[0]) { /* Is there a time. */ if ((commenttime = atof((char *)argv[0])) == 0) { printf("Something wrong with time after the -comment switch.\n"); printUsage(); } if (--argc > 0 && (*++argv)[0]) { /* comment string. */ addComment(commenttime, (char *)argv[0]); } else { printf("No comment string after -comment time switch\n"); printUsage(); } } else { printf("No time after -comment switch.\n"); printUsage(); } printf("Inserting comment %s at time %4.2f.\n", (char*)argv[0], commenttime); cflag = 1; match = 1; } if (strcmp((char *)argv[0],"-mark")==0) { if (--argc > 0 && (*++argv)[0]) { /* Is there a time. */ if ((commenttime = atof((char *)argv[0])) == 0) { printf("Something wrong with time after the -mark switch.\n"); printUsage(); } else { addMark(commenttime); } } else { printf("No time after -mark switch.\n"); printUsage(); } printf("Inserting mark at time %4.2f.\n", commenttime); mflag = 1; match = 1; } if (strcmp((char *)argv[0], "-vert")==0) { printf("Show vertical lines in graph.\n"); yflag = 1; match = 1; } if (strcmp((char *)argv[0], "-sortByTime")==0) { printf("Chose sampleMax samples equally distributed over sample numbers.\n"); sortOpt = TAKE_BY_SAMPLE_NO; match = 1; } if (strcmp((char *)argv[0], "-sortBySize")==0) { printf("Chose the sampleMax largest samples.\n"); sortOpt = TAKE_BY_SIZE; match = 1; } if (strcmp((char *)argv[0], "-useTickNo")==0) { printf("Use tick numbers on x-axis instead of elapsed time.\n"); useTickNo = 1; match = 1; } if (strcmp((char *)argv[0],"-sampleMax")==0) { if (--argc > 0 && (*++argv)[0]) { /* Is there a number. */ if ((SampleMax = atoi((char *)argv[0])) == 0) { printf("Something wrong with the number after the -sampleMax switch.\n"); printUsage(); } } else { printf("No number after the -sampleMax switch.\n"); printUsage(); } printf("Using %d samples.\n", SampleMax); match = 1; } if (match == 0) { printf("Something wrong with the switches, maybe an unknown switch...\n"); printUsage(); } } return; }
/* * This handles the main envent with qGo : something has been clicked on the board */ void qGoBoard::slotBoardClicked(bool , int x, int y , Qt::MouseButton mouseState) { bool blackToPlay = getBlackTurn(); switch (boardwindow->getGamePhase()) { case phaseInit: //should not happen return ; case phaseNavTo: { boardwindow->getBoardHandler()->findMoveByPos(x, y); return; } case phaseEdit: { switch (boardwindow->getEditMark()) { case markNone: { if(tree->getCurrent()->getMatrix()->getStoneAt(x,y) == stoneNone) addStone(mouseState == Qt::LeftButton ? stoneBlack : stoneWhite, x, y); else addStone(stoneErase, x, y); setModified(true); return; } default: { if (mouseState == Qt::LeftButton) addMark(x,y, boardwindow->getEditMark()); else removeMark(x,y); setModified(true); return; } } return; } case phaseEnded: return; case phaseScore: { localMarkDeadRequest(x,y); return; } case phaseOngoing: if (blackToPlay && boardwindow->getMyColorIsBlack()) localMoveRequest(stoneBlack,x,y); if (!blackToPlay && boardwindow->getMyColorIsWhite()) localMoveRequest(stoneWhite,x,y); return; } }
/** Adds visible mark to plot, centered on coordinates xpos, ypos */ void addMark(Plotdata &x, Plotdata &y, double xpos, double ypos) { addMark(x, y,xpos, ypos, RED); }
static void parseLink (xmlDocPtr doc, xmlNodePtr cur, FB2Content *fb) { xmlChar *content; xmlChar *href_prop, *note_prop; int start = fb->utf8_current_index; /* id */ href_prop = xmlGetProp(cur, (const xmlChar *)"href"); /* type="note" */ note_prop = xmlGetProp(cur, (const xmlChar *)"type"); if (note_prop && (!xmlStrcmp(note_prop, (const xmlChar *)"note"))) bufferAppend("[", 1, fb); cur = cur->children; /*bufferAppend("[", 1, fb);*/ while (cur != NULL) { if (xmlNodeIsText(cur)) { content = xmlNodeGetContent(cur); if (content) bufferAppend(content, xmlStrlen(content), fb); xmlFree(content); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"style")) { parseStyle(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"strong")) { content = xmlNodeGetContent(cur->children); if (content) { int st = fb->utf8_current_index; bufferAppend(content, xmlStrlen(content), fb); addMark(st, fb->utf8_current_index, STRONG_TYPE, NULL, fb); } xmlFree(content); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"emphasis")) { content = xmlNodeGetContent(cur->children); if (content) { int st = fb->utf8_current_index; bufferAppend(content, xmlStrlen(content), fb); addMark(st, fb->utf8_current_index, EMPHASIS_TYPE, NULL, fb); } xmlFree(content); } cur = cur->next; } if (href_prop) { if (note_prop && (!xmlStrcmp(note_prop, (const xmlChar *)"note"))) { bufferAppend("]", 1, fb); addMark(start, fb->utf8_current_index, NOTE_TYPE, href_prop, fb); xmlFree(note_prop); } else { addMark(start, fb->utf8_current_index, LINK_TYPE, href_prop, fb); } xmlFree(href_prop); } return; }
static void parseP (xmlDocPtr doc, xmlNodePtr cur, int add_tab, FB2Content *fb) { xmlChar *content; FB2Mark *mark; mark = getLink(cur, fb); cur = cur->children; if (add_tab) bufferAppend("\t", 1, fb); while (cur != NULL) { if (xmlNodeIsText(cur)) { content = xmlNodeGetContent(cur); if (content) { /* int len; len = removeSpaces(content, xmlStrlen(content)); bufferAppend(content, len, fb); */ bufferAppend(content, xmlStrlen(content), fb); } xmlFree(content); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"style")) { parseStyle(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"strong")) { content = xmlNodeGetContent(cur->children); if (content) { int start = fb->utf8_current_index; bufferAppend(content, xmlStrlen(content), fb); addMark(start, fb->utf8_current_index, STRONG_TYPE, NULL, fb); } xmlFree(content); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"emphasis")) { content = xmlNodeGetContent(cur->children); if (content) { int start = fb->utf8_current_index; bufferAppend(content, xmlStrlen(content), fb); addMark(start, fb->utf8_current_index, EMPHASIS_TYPE, NULL, fb); } xmlFree(content); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"a")) { parseLink(doc, cur, fb); } cur = cur->next; } bufferAppend("\n", 1, fb); if (mark) mark->link_end = fb->text_current_index; return; }