int main(void) { struct calendar birthday, today; int days; char* param; param = getParamString(); if (param == NULL){ printPage(ERROR, 0, NULL, NULL); return 0; } getParameter(param, &birthday); if (verifyDay(&birthday) == FAIL){ perror("Birthday verification failed"); printPage(INCORRECT, 0, NULL, NULL); return 0; } getToday(&today); if (verifyDay(&today) == FAIL){ perror("Today verification failed"); printPage(INCORRECT, 0, NULL, NULL); return 0; } if (isGreaterThan(birthday, today)){ // Birthday is future days = -computeDays(birthday, today); }else{ days = computeDays(today, birthday); } printPage(SUCCESS, days, &birthday, &today); return 0; }
void toListView::editPrint(void) { #if 0 TOPrinter printer; std::map<int, int> PageColumns; std::map<int, toTreeWidgetItem *> PageItems; int column = 0; int tree = rootIsDecorated() ? treeStepSize() : 0; int page = 1; PageColumns[1] = 0; toTreeWidgetItem *item = PageItems[1] = firstChild(); printer.setCreator(tr(TOAPPNAME)); QPainter painter(&printer); while ((item = printPage(&printer, &painter, item, column, tree, page++, false))) { PageColumns[page] = column; PageItems[page] = item; } printer.setMinMax(1, page - 1); printer.setFromTo(1, page - 1); if (printer.setup()) { QList<int> pages; for (int i = printer.fromPage(); i <= printer.toPage() || (printer.toPage() == 0 && i < page); i++) pages += i; for (QList<int>::iterator pageit = pages.begin(); pageit != pages.end(); pageit++) { page = *pageit; item = PageItems[page]; column = PageColumns[page]; printPage(&printer, &painter, item, column, tree, page, true); printer.newPage(); painter.resetXForm(); qApp->processEvents(); QString str = tr("Printing page %1").arg(page); toStatusMessage(str, false, false); } painter.end(); toStatusMessage(tr("Done printing"), false, false); } #endif }
/* * Status BTreeFile::Delete (const void *key, const RID rid) * * Remove specified data entry (<key, rid>) from an index. * Based on the value of headerPage->delete_fashion to use either naive delete * algorithm or full delete algorithm (involving merge & redistribution) */ Status BTreeFile::Delete(const void *key, const RID rid) { printPage(3); if (headerPage->delete_fashion == FULL_DELETE) return fullDelete(key, rid); else { // headerPage->delete_fashion == NAIVE_DELETE return naiveDelete(key, rid); } }
void Description::run() { area.add(new Window(100, 50, WIDTH, HEIGHT, L"blue.bmp")); area.add(new Label(titleFont, 250, 60, 300, 40, Label::ALIGN_CENTER, Label::ALIGN_MIDDLE, 255, 255, 0, msg(L"rules"))); area.add(new Button(110, 515, 80, 25, buttonFont, 255, 255, 0, L"blue.bmp", msg(L"prev"), prevCmd)); area.add(new Button(200, 515, 80, 25, buttonFont, 255, 255, 0, L"blue.bmp", msg(L"next"), nextCmd)); ExitCommand exitCmd(area); area.add(new Button(610, 515, 80, 25, buttonFont, 255, 255, 0, L"blue.bmp", msg(L"close"), &exitCmd)); area.add(new KeyAccel(SDLK_ESCAPE, &exitCmd)); printPage(); area.run(); }
/** Handles the algorithm selection, depending on which scheduling method was specified via the command line @param inputfile The name of the input file containing the processes @param algorithm The desired schedulaing algorithm @param quantum The desired time quantum (for round robin scheduling only) @param expire The time at which the memory state is cloned for printing to the output file @param mode The program mode. 0 represents Scheduler mode, 1 represents Virtual Memory mode */ void scheduler(char **inputfile, char **algorithm, int *quantum, int *expire,int *mode) { int length; process **proc = readFile(*inputfile, &length, mode); // Sort the processes and enqueue. QUEUE *pqueue = sort(proc, length); // Prepare and output file. FILE *file; if((file = fopen("out.file","w")) == NULL) { printf("Failed to create/open the file\n"); return; } // Algorithm selection if(strcmp(*algorithm, "FCFS") == 0) { firstCome(pqueue,expire,mode); } else if(strcmp(*algorithm, "RR") == 0) { roundRobin(pqueue, *quantum,expire,mode); } else if(strcmp(*algorithm, "SRT") == 0) { shortestRemaining(pqueue,expire,mode); } else if(strcmp(*algorithm, "SPN") == 0) { shortestNext(pqueue,expire,mode); } //prepare and print to the memory output file if the mode suggests to do so if(*mode == 1) { //append all virtual memory and page table data to the file printPage(); } fclose(file); return; }
void BTreeFile::printLeafPages() { Status st; BTLeafPage *leafp; RID dummy; // Find first leaf node. st = findRunStart( NULL, &leafp, &dummy ); if ( st != OK ) { cerr << "Error finding start of b-tree" << endl; return; } while ( leafp ) { printPage( leafp->page_no() ); PageId next = leafp->getNextPage(); st = MINIBASE_BM->unpinPage( leafp->page_no() ); if (st != OK) { MINIBASE_FIRST_ERROR(BTREE, BTreeFile::CANT_UNPIN_PAGE); cerr << "Can't unpin a b-tree page" << endl; return; } if ( next == INVALID_PAGE ) leafp = NULL; else { st = MINIBASE_BM->pinPage( next, (Page *&) leafp ); if (st != OK) { MINIBASE_FIRST_ERROR(BTREE, BTreeFile::CANT_PIN_PAGE); cerr << "Can't pin a b-tree page" << endl; return; } } } }
void EZUI_Menu::display(EZUI *UI){ LiquidCrystal_I2C *LCD = UI->LCD; if(refresh){ printPage(UI); refresh = false; } if (itemChanged){ //Print each menu item (3 items left on line) for(int i=0; i<4; i++){ LCD->setCursor(0,i); if (i==cursorLine){ LCD->print(">"); }else{ LCD->print(" "); } } } }
void WebView::printClickedFrame() { printPage(m_clickedFrame); }
void Description::updateInfo() { deleteWidgets(); printPage(); area.draw(); }
void updateWeb(){ //if (DEBUG_MEMORY) printMem(" Web 1 "); client_recv = server.available(); byte cptr; const char *slash = "/"; const char *space = " "; if (client_recv) { while (client_recv.connected()) { if (client_recv.available()) { char c = client_recv.read(); //read char by char HTTP request if (cptr < MAX_STRING_LEN-1) { temp[cptr++] = c; } else { cptr = 0; } temp[cptr] = '\0'; //if HTTP request has ended if (c == '\n') { if (DEBUG_WEB) dbg.println(temp); //print to serial monitor for debuging if (strstr(temp,"GET / ")) { // Root requested, then give page, else try to parse post parameters if (DEBUG_MEMORY) printMem("WebG "); printP(COMMAND_IO_RECV, HEADER_OK); client_recv.println(); printP(COMMAND_IO_RECV, HEADERPG2); printP(COMMAND_IO_RECV, HEADERPG3); for (byte deviceIdx = 0 ; deviceIdx < DEVICE_COUNT ; deviceIdx++ ) { mdevices[deviceIdx].readInput(); printP(COMMAND_IO_RECV, AOPEN); printP(COMMAND_IO_RECV, H3); // <H3> printP(COMMAND_IO_RECV, ACLOSE); switch (deviceIdx) { case 0: printP(COMMAND_IO_RECV, DEV_0); break; case 1: printP(COMMAND_IO_RECV, DEV_1); break; case 2: printP(COMMAND_IO_RECV, DEV_2); break; case 3: printP(COMMAND_IO_RECV, DEV_3); break; case 4: printP(COMMAND_IO_RECV, DEV_4); break; case 5: printP(COMMAND_IO_RECV, DEV_5); break; case 6: printP(COMMAND_IO_RECV, DEV_6); break; case 7: printP(COMMAND_IO_RECV, DEV_7); break; case 8: printP(COMMAND_IO_RECV, DEV_8); break; case 9: printP(COMMAND_IO_RECV, DEV_9); break; } printP(COMMAND_IO_RECV, AOPEN); printP(COMMAND_IO_RECV, SLASH); printP(COMMAND_IO_RECV, H3); // </H3> printP(COMMAND_IO_RECV, ACLOSE); printP(COMMAND_IO_RECV, AOPEN); printP(COMMAND_IO_RECV, SPAN); // <SPAN> printP(COMMAND_IO_RECV, ACLOSE); printPage(COMMAND_IO_RECV, deviceIdx); printP(COMMAND_IO_RECV, AOPEN); printP(COMMAND_IO_RECV, BR); printP(COMMAND_IO_RECV, SLASH); printP(COMMAND_IO_RECV, ACLOSE); printP(COMMAND_IO_RECV, AOPEN); printP(COMMAND_IO_RECV, SLASH); printP(COMMAND_IO_RECV, SPAN); // </SPAN> printP(COMMAND_IO_RECV, ACLOSE); } printP(COMMAND_IO_RECV, HEADERPGEND); } else { // parse // parse url POST /d/203/c/23/v/12 HTTP/1.1 if (DEBUG_MEMORY) printMem("WebP "); int deviceID = 0; int commandID = 0; int commandValue = 0; //temp = strtok(temp, " "); // POST /d/203/c/23/v/12 HTTP/1.1 char * token = strtok(temp, space); // POST /d/203/c/23/v/12 HTTP/1.1 byte deviceIdx = ERROR; byte result = ERROR; if (strcmp(token,"POST") == 0) { token = strtok(NULL, space); // Second part token = strtok(token, slash); // d token = strtok(NULL, slash); // deviceID deviceID = atoi(token); token = strtok(NULL, slash); // c token = strtok(NULL, slash); // commandID commandID = atoi(token); token = strtok(NULL, slash); // v if (token != NULL) { token = strtok(NULL, slash); // value ? commandValue = atoi(token); } deviceIdx = findDeviceIndex(deviceID); if (DEBUG_WEB) dbg.print("Idx "); if (DEBUG_WEB) dbg.println(deviceIdx); if (deviceIdx != ERROR) { result = deviceCommandHandler(deviceIdx, commandID, false, commandValue); } // return error? } if ( deviceIdx == ERROR || result == ERROR) { printP(COMMAND_IO_RECV, HEADER_ERR); client_recv.println(); printP(COMMAND_IO_RECV, HEADER_ERR_MESS); } else { printP(COMMAND_IO_RECV, HEADER_OK); client_recv.println(); if ( result == HNDLR_WRITE_RESULT) printResponse(COMMAND_IO_RECV, deviceIdx, false); } } delay(1); //stopping client client_recv.stop(); //clearing string for next read cptr = 0; temp[cptr] = '\0'; } } } } }
Status BTreeFile::_insert (const void *key, const RID rid, KeyDataEntry **goingUp, int *goingUpSize, PageId currentPageId) { Status st; SortedPage* rpPtr; assert(currentPageId != INVALID_PAGE); assert(*goingUp != NULL); st = MINIBASE_BM->pinPage(currentPageId,(Page *&) rpPtr); if (st != OK) return MINIBASE_FIRST_ERROR(BTREE, CANT_PIN_PAGE); NodeType pageType = rpPtr->get_type(); cerr<< "currentPageId IN _INSERT "<< currentPageId<<" pageType "<< pageType<<endl; // TWO CASES: // - pageType == INDEX: // recurse and then split if necessary // - pageType == LEAF: // try to insert pair (key, rid), maybe split switch (pageType) { case INDEX: { // two cases: // - *goingUp == NULL: one level lower no split has occurred: // we are done. // - *goingUp != NULL: one of the children has split and // **goingUp is the new data entry which has // to be inserted on this index page // TODO: fill the body BTIndexPage* indexPage = (BTIndexPage*) rpPtr; RID myRid; KeyDataEntry* newEntry = new KeyDataEntry(); int newEntrySize; PageId pageId; indexPage->get_page_no( key, headerPage->key_type, pageId); printf("in index page insert to %d\n", pageId); fflush(stdout); Status returnStatus = _insert(key, rid, &newEntry , &newEntrySize, pageId); if (returnStatus != OK) MINIBASE_FIRST_ERROR(BTREE, INSERT_FAILED); if( newEntry != NULL){ if( indexPage->available_space() >= newEntrySize){ st = indexPage->insertKey( (void*)(&newEntry->key), headerPage->key_type, newEntry->data.pageNo, myRid); if(st != OK) return MINIBASE_CHAIN_ERROR(BTREE, st); } else{ //pageFUll: //new a Indexpage "RightSibling" cout<<"*************************index_split"<<endl; BTIndexPage* rightSiblingIndexPage; PageId rightPageId; Status st; st = MINIBASE_BM->newPage( rightPageId, (Page*&)rightSiblingIndexPage ); rightSiblingIndexPage->init( rightPageId); if( st != OK) return MINIBASE_CHAIN_ERROR(BTREE, st); assert( st == OK); //chose a mediate_key to push up int numLeft = (indexPage->numberOfRecords()+1)/2; int numRight = indexPage->numberOfRecords()+1-numLeft; RID metaRid; Keytype iterKey; PageId iterPage; st = indexPage->get_first( metaRid, &iterKey, iterPage); if( st != OK) return MINIBASE_CHAIN_ERROR(BTREE, st); assert( st == OK); RID dummyRid; RID leftLastRid; Keytype medKey; PageId medPage; bool entryInserted = false; for( int i = 0 ; i < numLeft-1 ; i++){ st = indexPage->get_next( metaRid, &iterKey, iterPage); } if( !entryInserted && keyCompare( &(newEntry->key), &iterKey, headerPage->key_type) <=0){ //newEntry is in the left half st = indexPage->insertKey( (void*)(&newEntry->key), headerPage->key_type, newEntry->data.pageNo, dummyRid ); if( st != OK) return MINIBASE_CHAIN_ERROR(BTREE, st); medKey = iterKey; medPage = iterPage; st = indexPage->deleteKey( &iterKey, headerPage->key_type, dummyRid); if( st != OK) return MINIBASE_CHAIN_ERROR(BTREE, st); st = indexPage->get_next( metaRid, &iterKey, iterPage); entryInserted = true; } else{ // this is the middle key st = indexPage->get_next( metaRid, &iterKey, iterPage); if( !entryInserted && keyCompare( &(newEntry->key), &iterKey, headerPage->key_type) <=0){ medKey = newEntry->key; medPage = newEntry->data.pageNo; } else{ medKey = iterKey; medPage = iterPage; rightSiblingIndexPage->insertKey( (void*)&(newEntry->key), headerPage->key_type, newEntry->data.pageNo, dummyRid ); indexPage->deleteKey( &iterKey, headerPage->key_type, dummyRid); st = indexPage->get_next( metaRid, &iterKey, iterPage); entryInserted = true; } } while( st == OK){ st = indexPage->deleteKey( &iterKey, headerPage->key_type, dummyRid); if( st != OK) return MINIBASE_CHAIN_ERROR(BTREE, st); st = rightSiblingIndexPage->insertKey( (void*)&iterKey, headerPage->key_type, iterPage, dummyRid ); if( st != OK) return MINIBASE_CHAIN_ERROR(BTREE, st); st = indexPage->get_next( metaRid, &iterKey, iterPage); } rightSiblingIndexPage->setLeftLink( medPage); KeyDataEntry newEntry; Datatype entryData; entryData.pageNo = rightSiblingIndexPage->page_no(); int entryLen; make_entry( &newEntry, headerPage->key_type, (void*)&medKey,INDEX, entryData, &entryLen); **goingUp = newEntry; *goingUpSize = entryLen; st = MINIBASE_BM->unpinPage( rightPageId, TRUE ); if( st != OK) return MINIBASE_CHAIN_ERROR(BTREE, st); } } else{ *goingUp = NULL; printf("index do not split\n"); } break; } case LEAF: { BTLeafPage* leafPage = (BTLeafPage*) rpPtr; RID myRid; if( leafPage->available_space() >= sizeof(KeyDataEntry)){ Status myst = leafPage->insertRec(key, headerPage->key_type, rid, myRid); if(myst != OK) return MINIBASE_CHAIN_ERROR(BTREE, myst); *goingUp = NULL; } else{ //split fprintf(stderr, "leaf split start >>>>>>>>"); cout<<"**************************leaf_split"<<endl; printPage(currentPageId); int numberRec = leafPage->numberOfRecords(); BTLeafPage* newRight; // BTIndexPage* newRoot; Status myst; PageId newRightID; void* currentKey; RID currentDataRID; if((myst = MINIBASE_BM->newPage(newRightID, (Page*&)newRight)) != OK) return MINIBASE_CHAIN_ERROR(BTREE, myst); newRight->init(newRightID); RID firstRID; RID tmp; void* middleKey; RID middleDataRID; if((myst = leafPage->get_first(firstRID, currentKey, currentDataRID)) != OK) return MINIBASE_CHAIN_ERROR(BTREE, myst); int board = (numberRec)/2; for(int i = 1; i < board; i++){ if(myst != OK) return MINIBASE_CHAIN_ERROR(BTREE, myst); if((myst = leafPage->get_next(firstRID, currentKey, currentDataRID)) != OK) return MINIBASE_CHAIN_ERROR(BTREE, myst); } int k = 0; for(int j = board; j < numberRec; j++){ void* tmpKey = (void*) malloc(sizeof(currentKey)); memcpy(tmpKey, currentKey, sizeof(currentKey)); if(myst != OK) return MINIBASE_CHAIN_ERROR(BTREE, myst); if(j == board){ if((myst = leafPage->get_next(firstRID, currentKey, currentDataRID)) != OK) return MINIBASE_CHAIN_ERROR(BTREE, myst); } else{ leafPage->delUserRid(tmpKey, headerPage->key_type, currentDataRID); if((myst = leafPage->get_current(firstRID, currentKey, currentDataRID)) != OK) return MINIBASE_CHAIN_ERROR(BTREE, myst); } myst = newRight->insertRec(currentKey, headerPage->key_type, currentDataRID, tmp); if(myst != OK) return MINIBASE_CHAIN_ERROR(BTREE, myst); } leafPage->delUserRid(currentKey, headerPage->key_type, currentDataRID); if((myst = newRight->get_first(firstRID, currentKey, currentDataRID)) != OK) return MINIBASE_CHAIN_ERROR(BTREE, myst); middleKey = currentKey; middleDataRID = currentDataRID; if(keyCompare(key, middleKey, headerPage->key_type)>0){ myst = newRight->insertRec(key, headerPage->key_type, rid, tmp); if(myst != OK) return MINIBASE_CHAIN_ERROR(BTREE, myst); } else if(keyCompare(key, currentKey, headerPage->key_type) == 0){ assert("key values equal!!"); } else{ myst = leafPage->insertRec(key, headerPage->key_type, rid, tmp); if(myst != OK) return MINIBASE_CHAIN_ERROR(BTREE, myst); } PageId pre = leafPage->getPrevPage(); PageId nex = leafPage->getNextPage(); fprintf(stdout, "pre = %d\nnex = %d\n", pre, nex); newRight->setPrevPage(currentPageId); leafPage->setNextPage(newRightID); // fprintf(stdout, "c = %d\nn = %d\n", currentPageId, newRightID); BTLeafPage* tmpPage; if(nex >= 0){ if((myst = MINIBASE_BM->pinPage(nex,(Page *&) tmpPage)) != OK) return MINIBASE_CHAIN_ERROR(BTREE, myst); // tmpPage->init(newRightID); ((BTLeafPage*)tmpPage)->setPrevPage(newRightID); newRight->setNextPage(nex); fprintf(stdout, "before unpin\n"); if((myst = MINIBASE_BM->unpinPage(nex, TRUE)) != OK) return MINIBASE_CHAIN_ERROR(BTREE, myst); fprintf(stdout, "afterpin\n"); } fflush(stdout); if((myst = newRight->get_first(firstRID, currentKey, currentDataRID)) != OK) return MINIBASE_CHAIN_ERROR(BTREE, myst); fprintf(stderr, "\nysysys\n"); middleKey = currentKey; middleDataRID = currentDataRID; // KeyDataEntry* newEntry = (KeyDataEntry*)malloc(sizeof(KeyDataEntry)); KeyDataEntry newEntry; Datatype entryData; Keytype entryKey; entryData.pageNo = newRightID; fprintf(stderr, "sure:[%d]\n", entryData.pageNo); int entryLen; make_entry( &newEntry, headerPage->key_type, middleKey,INDEX,entryData, &entryLen); // make_entry( &newEntry, headerPage->key_type, middleKey,INDEX, newRightID, &entryLen); // (newEntry->key).intkey = *(int*)middleKey; // (newEntry->data).pageNo = newRightId; newEntry.data.pageNo=newRightID; // fprintf(stderr, "in leaf dataentry:should be [%d] [%d] but: [%d] [%d]\n",*((int*)middleKey), newRightID , newEntry.key.intkey, newEntry.data.pageNo); **goingUp = newEntry; // newEntry.data.pageNo = 1; *goingUpSize = entryLen; if((myst = MINIBASE_BM->unpinPage(newRightID, TRUE)) != OK) return MINIBASE_CHAIN_ERROR(BTREE, myst); fprintf(stderr,"\t leaf split end\n"); printPage(currentPageId); printPage(newRightID); } break; } default: // in case memory is scribbled upon & type is hosed fprintf(stderr, "currentPageId = (%d) pagetype%d\n", currentPageId, pageType ); assert(false); } if((st = MINIBASE_BM->unpinPage(currentPageId, TRUE)) != OK) return MINIBASE_CHAIN_ERROR(BTREE, st); return OK; }
void BTreeFile::printRoot() { cout << "\nPRINTING B-TREE ROOT PAGE-------------------\n"; if (headerPage->root != INVALID_PAGE) printPage( headerPage->root ); }
void MainMenu::init() { #define ADD_ACTION(name, menu, icon, trName, slot, shortcut) \ action = menu->addAction(icon, trName); \ action->setShortcut(QKeySequence(QSL(shortcut))); \ connect(action, SIGNAL(triggered()), this, slot); \ m_actions[QSL(name)] = action #define ADD_CHECKABLE_ACTION(name, menu, icon, trName, slot, shortcut) \ action = menu->addAction(icon, trName); \ action->setShortcut(QKeySequence(QSL(shortcut))); \ action->setCheckable(true); \ connect(action, SIGNAL(triggered(bool)), this, slot); \ m_actions[QSL(name)] = action // Standard actions - needed on Mac to be placed correctly in "application" menu QAction* action = new QAction(QIcon::fromTheme(QSL("help-about")), tr("&About QupZilla"), this); action->setMenuRole(QAction::AboutRole); connect(action, SIGNAL(triggered()), this, SLOT(showAboutDialog())); m_actions[QSL("Standard/About")] = action; action = new QAction(IconProvider::settingsIcon(), tr("Pr&eferences"), this); action->setMenuRole(QAction::PreferencesRole); action->setShortcut(QKeySequence(QKeySequence::Preferences)); connect(action, SIGNAL(triggered()), this, SLOT(showPreferences())); m_actions[QSL("Standard/Preferences")] = action; action = new QAction(QIcon::fromTheme(QSL("application-exit")), tr("Quit"), this); action->setMenuRole(QAction::QuitRole); // shortcut set from browserwindow connect(action, SIGNAL(triggered()), this, SLOT(quitApplication())); m_actions[QSL("Standard/Quit")] = action; // File menu m_menuFile = new QMenu(tr("&File")); connect(m_menuFile, SIGNAL(aboutToShow()), this, SLOT(aboutToShowFileMenu())); connect(m_menuFile, SIGNAL(aboutToHide()), this, SLOT(aboutToHideFileMenu())); ADD_ACTION("File/NewTab", m_menuFile, IconProvider::newTabIcon(), tr("New Tab"), SLOT(newTab()), "Ctrl+T"); ADD_ACTION("File/NewWindow", m_menuFile, IconProvider::newWindowIcon(), tr("&New Window"), SLOT(newWindow()), "Ctrl+N"); ADD_ACTION("File/NewPrivateWindow", m_menuFile, IconProvider::privateBrowsingIcon(), tr("New &Private Window"), SLOT(newPrivateWindow()), "Ctrl+Shift+P"); ADD_ACTION("File/OpenLocation", m_menuFile, QIcon::fromTheme(QSL("document-open-remote")), tr("Open Location"), SLOT(openLocation()), "Ctrl+L"); ADD_ACTION("File/OpenFile", m_menuFile, QIcon::fromTheme(QSL("document-open")), tr("Open &File..."), SLOT(openFile()), "Ctrl+O"); ADD_ACTION("File/CloseWindow", m_menuFile, QIcon::fromTheme(QSL("window-close")), tr("Close Window"), SLOT(closeWindow()), "Ctrl+Shift+W"); m_menuFile->addSeparator(); ADD_ACTION("File/SavePageAs", m_menuFile, QIcon::fromTheme(QSL("document-save")), tr("&Save Page As..."), SLOT(savePageAs()), "Ctrl+S"); ADD_ACTION("File/SavePageScreen", m_menuFile, QIcon::fromTheme(QSL("image-loading")), tr("Save Page Screen"), SLOT(savePageScreen()), "Ctrl+Shift+S"); ADD_ACTION("File/SendLink", m_menuFile, QIcon::fromTheme(QSL("mail-message-new")), tr("Send Link..."), SLOT(sendLink()), ""); ADD_ACTION("File/Print", m_menuFile, QIcon::fromTheme(QSL("document-print")), tr("&Print..."), SLOT(printPage()), "Ctrl+P"); m_menuFile->addSeparator(); ADD_CHECKABLE_ACTION("File/WorkOffline", m_menuFile, QIcon(), tr("Work &Offline"), SLOT(toggleOfflineMode()), ""); m_menuFile->addSeparator(); m_menuFile->addAction(m_actions[QSL("Standard/Quit")]); // Edit menu m_menuEdit = new QMenu(tr("&Edit")); connect(m_menuEdit, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEditMenu())); connect(m_menuEdit, SIGNAL(aboutToHide()), this, SLOT(aboutToHideEditMenu())); ADD_ACTION("Edit/Undo", m_menuEdit, QIcon::fromTheme(QSL("edit-undo")), tr("&Undo"), SLOT(editUndo()), "Ctrl+Z"); ADD_ACTION("Edit/Redo", m_menuEdit, QIcon::fromTheme(QSL("edit-redo")), tr("&Redo"), SLOT(editRedo()), "Ctrl+Shift+Z"); m_menuEdit->addSeparator(); ADD_ACTION("Edit/Cut", m_menuEdit, QIcon::fromTheme(QSL("edit-cut")), tr("&Cut"), SLOT(editCut()), "Ctrl+X"); ADD_ACTION("Edit/Copy", m_menuEdit, QIcon::fromTheme(QSL("edit-copy")), tr("C&opy"), SLOT(editCopy()), "Ctrl+C"); ADD_ACTION("Edit/Paste", m_menuEdit, QIcon::fromTheme(QSL("edit-paste")), tr("&Paste"), SLOT(editPaste()), "Ctrl+V"); m_menuEdit->addSeparator(); ADD_ACTION("Edit/SelectAll", m_menuEdit, QIcon::fromTheme(QSL("edit-select-all")), tr("Select &All"), SLOT(editSelectAll()), "Ctrl+A"); ADD_ACTION("Edit/Find", m_menuEdit, QIcon::fromTheme(QSL("edit-find")), tr("&Find"), SLOT(editFind()), "Ctrl+F"); m_menuEdit->addSeparator(); // View menu m_menuView = new QMenu(tr("&View")); connect(m_menuView, SIGNAL(aboutToShow()), this, SLOT(aboutToShowViewMenu())); connect(m_menuView, SIGNAL(aboutToHide()), this, SLOT(aboutToHideViewMenu())); QMenu* toolbarsMenu = new QMenu(tr("Toolbars")); connect(toolbarsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowToolbarsMenu())); QMenu* sidebarMenu = new QMenu(tr("Sidebar")); connect(sidebarMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowSidebarsMenu())); QMenu* encodingMenu = new QMenu(tr("Character &Encoding")); connect(encodingMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEncodingMenu())); // Create menus to make shortcuts available even before first showing the menu m_window->createToolbarsMenu(toolbarsMenu); m_window->createSidebarsMenu(sidebarMenu); m_menuView->addMenu(toolbarsMenu); m_menuView->addMenu(sidebarMenu); ADD_CHECKABLE_ACTION("View/ShowStatusBar", m_menuView, QIcon(), tr("Sta&tus Bar"), SLOT(showStatusBar()), ""); m_menuView->addSeparator(); ADD_ACTION("View/Stop", m_menuView, QIcon::fromTheme(QSL("process-stop")), tr("&Stop"), SLOT(stop()), "Esc"); ADD_ACTION("View/Reload", m_menuView, QIcon::fromTheme(QSL("view-refresh")), tr("&Reload"), SLOT(reload()), "F5"); m_menuView->addSeparator(); ADD_ACTION("View/ZoomIn", m_menuView, QIcon::fromTheme(QSL("zoom-in")), tr("Zoom &In"), SLOT(zoomIn()), "Ctrl++"); ADD_ACTION("View/ZoomOut", m_menuView, QIcon::fromTheme(QSL("zoom-out")), tr("Zoom &Out"), SLOT(zoomOut()), "Ctrl+-"); ADD_ACTION("View/ZoomReset", m_menuView, QIcon::fromTheme(QSL("zoom-original")), tr("Reset"), SLOT(zoomReset()), "Ctrl+0"); m_menuView->addSeparator(); ADD_CHECKABLE_ACTION("View/CaretBrowsing", m_menuView, QIcon(), tr("&Caret Browsing"), SLOT(toggleCaretBrowsing()), "F7"); m_menuView->addMenu(encodingMenu); m_menuView->addSeparator(); ADD_ACTION("View/PageSource", m_menuView, QIcon::fromTheme(QSL("text-html")), tr("&Page Source"), SLOT(showPageSource()), "Ctrl+U"); ADD_CHECKABLE_ACTION("View/FullScreen", m_menuView, QIcon(), tr("&FullScreen"), SLOT(showFullScreen()), "F11"); // Tools menu m_menuTools = new QMenu(tr("&Tools")); connect(m_menuTools, SIGNAL(aboutToShow()), this, SLOT(aboutToShowToolsMenu())); connect(m_menuTools, SIGNAL(aboutToHide()), this, SLOT(aboutToHideToolsMenu())); ADD_ACTION("Tools/WebSearch", m_menuTools, QIcon(), tr("&Web Search"), SLOT(webSearch()), "Ctrl+K"); ADD_ACTION("Tools/SiteInfo", m_menuTools, QIcon::fromTheme(QSL("dialog-information")), tr("Site &Info"), SLOT(showSiteInfo()), "Ctrl+I"); m_menuTools->addSeparator(); ADD_ACTION("Tools/DownloadManager", m_menuTools, QIcon(), tr("&Download Manager"), SLOT(showDownloadManager()), "Ctrl+Y"); ADD_ACTION("Tools/CookiesManager", m_menuTools, QIcon(), tr("&Cookies Manager"), SLOT(showCookieManager()), ""); ADD_ACTION("Tools/AdBlock", m_menuTools, QIcon(), tr("&AdBlock"), SLOT(showAdBlockDialog()), ""); ADD_ACTION("Tools/RssReader", m_menuTools, QIcon(), tr("RSS &Reader"), SLOT(showRssManager()), ""); ADD_ACTION("Tools/WebInspector", m_menuTools, QIcon(), tr("Web In&spector"), SLOT(showWebInspector()), "Ctrl+Shift+I"); ADD_ACTION("Tools/ClearRecentHistory", m_menuTools, QIcon::fromTheme(QSL("edit-clear")), tr("Clear Recent &History"), SLOT(showClearRecentHistoryDialog()), "Ctrl+Shift+Del"); m_menuTools->addSeparator(); // Help menu m_menuHelp = new QMenu(tr("&Help")); #ifndef Q_OS_MAC ADD_ACTION("Help/AboutQt", m_menuHelp, QIcon(QSL(":/icons/menu/qt.png")), tr("About &Qt"), SLOT(aboutQt()), ""); m_menuHelp->addAction(m_actions[QSL("Standard/About")]); m_menuHelp->addSeparator(); #endif ADD_ACTION("Help/InfoAboutApp", m_menuHelp, QIcon::fromTheme(QSL("help-contents")), tr("Information about application"), SLOT(showInfoAboutApp()), ""); ADD_ACTION("Help/ConfigInfo", m_menuHelp, QIcon(), tr("Configuration Information"), SLOT(showConfigInfo()), ""); ADD_ACTION("Help/ReportIssue", m_menuHelp, QIcon(), tr("Report &Issue"), SLOT(reportIssue()), ""); m_actions[QSL("Help/InfoAboutApp")]->setShortcut(QKeySequence(QKeySequence::HelpContents)); // History menu m_menuHistory = new HistoryMenu(); m_menuHistory->setMainWindow(m_window); // Bookmarks menu m_menuBookmarks = new BookmarksMenu(); m_menuBookmarks->setMainWindow(m_window); // Other actions action = new QAction(QIcon::fromTheme(QSL("user-trash")), tr("Restore &Closed Tab"), this); action->setShortcut(QKeySequence(QSL("Ctrl+Shift+T"))); connect(action, SIGNAL(triggered()), this, SLOT(restoreClosedTab())); m_actions[QSL("Other/RestoreClosedTab")] = action; #ifdef Q_OS_MAC m_actions[QSL("View/FullScreen")]->setShortcut(QKeySequence(QSL("F11"))); // Add standard actions to File Menu (as it won't be ever cleared) and Mac menubar should move them to "Application" menu m_menuFile->addAction(m_actions[QSL("Standard/About")]); m_menuFile->addAction(m_actions[QSL("Standard/Preferences")]); #endif #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) m_menuEdit->addAction(m_actions[QSL("Standard/Preferences")]); #elif !defined(Q_OS_MAC) m_menuTools->addAction(m_actions[QSL("Standard/Preferences")]); #endif #ifndef QTWEBKIT_FROM_2_3 m_actions[QSL("View/CaretBrowsing")]->setVisible(false); #endif // Menus are hidden by default aboutToHideFileMenu(); aboutToHideViewMenu(); aboutToHideEditMenu(); aboutToHideToolsMenu(); addActionsToWindow(); }
int main(int argc, char **argv) { char word[MAXWORDSIZE]; char cmd[MAXWORDSIZE]; /* string to hold a command */ char fname[MAXWORDSIZE]; /* name of input file */ PAGENO i; int goOn; int k; setparms(); /* reads the pagesize and the number of ptrs/postigs_record */ dbopen(); /* opens or creates the three files (btree, postings, text) */ goOn = TRUE; while (goOn) { printf("\n\t*** These are your commands .........\n"); printf("\t\"C\" to scan the tree\n"); printf("\t\"i\" to insert\n"); printf("\t\"p\" to print a btree page\n"); printf("\t\"s\" to search, and print the key\n"); printf("\t\"S\" to search, and print the key, posting list pairs\n"); printf("\t\">\" to print k successors\n"); printf("\t\"<\" to print k predecessors\n"); printf("\t\"T\" to print the btree in inorder format\n"); printf("\t\"#\" to reset and print stats\n"); printf("\t\"x\" to exit\n"); /* printf("\"d\" to display statistics, \"c\" to clear them,\n"); */ scanf("%s", cmd); assert(strlen(cmd) < MAXWORDSIZE); switch (cmd[0]) { case 'C': printf("\n*** Scanning... \n"); scanTree(&printOcc); break; case 'i': printf("\tgive input file name: "); scanf("%s", fname); assert(strlen(fname) < MAXWORDSIZE); printf("\n*** Inserting %s\n", fname); insert(fname); break; case 's': printf("enter search-word: "); scanf("%s", word); assert(strlen(word) < MAXWORDSIZE); printf("\n*** Searching for word %s \n", word); search(word, FALSE); break; case 'S': printf("enter search-word: "); scanf("%s", word); assert(strlen(word) < MAXWORDSIZE); printf("\n*** Searching for word %s \n", word); search(word, TRUE); break; case 'p': printf("pagenumber=?\n"); scanf("%s", cmd); assert(strlen(cmd) < MAXWORDSIZE); i = (PAGENO) atoi(cmd); printPage(i, fpbtree); break; case '>': printf("word=?\n"); scanf("%s", word); printf("k=?\n"); scanf("%d", &k); get_successors(word, k, NULL); break; case '<': printf("word=?\n"); scanf("%s", word); printf("k=?\n"); scanf("%d", &k); get_predecessors(word, k, NULL); break; case 'T': printf("\n*** Printing tree in order .........\n"); PrintTreeInOrder(ROOT, 0); break; case '#': printf("\n"); printFetchPageCnt(); printf("\n...reseted FetchPage counter\n"); break; case 'x': printf("\n*** Exiting .........\n"); goOn = FALSE; break; default: printf("\n*** Illegal command \"%s\"\n", cmd); break; } } dbclose(); return (0); }
int main(int argc, char **argv) { char word[MAXWORDSIZE]; char result[MAXWORDSIZE]; char temp[MAXWORDSIZE]; char cmd[MAXWORDSIZE]; /* string to hold a command */ char fname[MAXWORDSIZE]; /* name of input file */ PAGENO i; int goOn; // int k; setparms(); /* reads the pagesize and the number of ptrs/postigs_record */ dbopen(); /* opens or creates the three files (btree, postings, text) */ goOn = TRUE; while (goOn) { printf("\n\t*** These are your commands .........\n"); printf("\t\"C\" to scan the tree\n"); printf("\t\"i\" to insert\n"); printf("\t\"p\" to print a btree page\n"); printf("\t\"s\" to search, and print the key\n"); printf("\t\"S\" to search, and print the key, posting list pairs\n"); printf("\t\"]\" to print next key without given prefix\n"); printf("\t\"[\" to print previous key without given prefix\n"); printf("\t\"T\" to print the btree in inorder format\n"); printf("\t\"#\" to reset and print stats\n"); printf("\t\"x\" to exit\n"); /* printf("\"d\" to display statistics, \"c\" to clear them,\n"); */ scanf("%s", cmd); assert(strlen(cmd) < MAXWORDSIZE); switch (cmd[0]) { case 'C': printf("\n*** Scanning... \n"); scanTree(&printOcc); break; case 'i': printf("\tgive input file name: "); scanf("%s", fname); assert(strlen(fname) < MAXWORDSIZE); printf("\n*** Inserting %s\n", fname); insert(fname); break; case 's': printf("enter search-word: "); scanf("%s", word); assert(strlen(word) < MAXWORDSIZE); printf("\n*** Searching for word %s \n", word); search(word, FALSE); break; case 'S': printf("enter search-word: "); scanf("%s", word); assert(strlen(word) < MAXWORDSIZE); printf("\n*** Searching for word %s \n", word); search(word, TRUE); break; case 'p': printf("pagenumber=?\n"); scanf("%s", cmd); assert(strlen(cmd) < MAXWORDSIZE); i = (PAGENO) atoi(cmd); printPage(i, fpbtree); break; case ']': printf("word=?\n"); scanf("%s", word); assert(strlen(word) < MAXWORDSIZE); strcpy(temp, word);; get_rightbracket(word, result); printf("Right bracket of %s:\n%s\n", temp,result); break; case '[': printf("word=?\n"); scanf("%s", word); assert(strlen(word) < MAXWORDSIZE); // strcpy(temp, word);; get_leftbracket(word, result); printf("Left bracket of %s:\n%s\n", word,result); break; break; case 'T': printf("\n*** Printing tree in order .........\n"); PrintTreeInOrder(ROOT, 0); break; case '#': printf("\n*** #of reads on B-tree: %d", countPageFetch); countPageFetch = 0; break; case 'x': printf("\n*** Exiting .........\n"); goOn = FALSE; break; default: printf("\n*** Illegal command \"%s\"\n", cmd); break; } } dbclose(); return (0); }
PopupWindow::PopupWindow(PopupWebView* view) : QWidget() , m_view(view) , m_page(qobject_cast<PopupWebPage*>(view->page())) , m_search(0) { m_layout = new QVBoxLayout(this); m_layout->setContentsMargins(0, 0, 0, 0); m_layout->setSpacing(0); m_locationBar = new PopupLocationBar(this); m_locationBar->setView(m_view); m_statusBar = new QStatusBar(this); m_statusBar->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); m_progressBar = new ProgressBar(m_statusBar); m_statusBar->addPermanentWidget(m_progressBar); m_progressBar->hide(); m_view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_statusBarMessage = new PopupStatusBarMessage(this); m_menuBar = new QMenuBar(this); QMenu* menuFile = new QMenu(tr("File")); menuFile->addAction(QIcon::fromTheme("document-save"), tr("&Save Page As..."), m_view, SLOT(savePageAs()))->setShortcut(QKeySequence("Ctrl+S")); menuFile->addAction(tr("Save Page Screen"), this, SLOT(savePageScreen())); menuFile->addAction(QIcon::fromTheme("mail-message-new"), tr("Send Link..."), m_view, SLOT(sendPageByMail())); menuFile->addAction(QIcon::fromTheme("document-print"), tr("&Print..."), m_view, SLOT(printPage()))->setShortcut(QKeySequence("Ctrl+P")); menuFile->addSeparator(); menuFile->addAction(QIcon::fromTheme("window-close"), tr("Close"), this, SLOT(close()))->setShortcut(QKeySequence("Ctrl+W")); m_menuBar->addMenu(menuFile); m_menuEdit = new QMenu(tr("Edit")); m_menuEdit->addAction(QIcon::fromTheme("edit-undo"), tr("&Undo"), this, SLOT(editUndo()))->setShortcut(QKeySequence("Ctrl+Z")); m_menuEdit->addAction(QIcon::fromTheme("edit-redo"), tr("&Redo"), this, SLOT(editRedo()))->setShortcut(QKeySequence("Ctrl+Shift+Z")); m_menuEdit->addSeparator(); m_menuEdit->addAction(QIcon::fromTheme("edit-cut"), tr("&Cut"), this, SLOT(editCut()))->setShortcut(QKeySequence("Ctrl+X")); m_menuEdit->addAction(QIcon::fromTheme("edit-copy"), tr("C&opy"), this, SLOT(editCopy()))->setShortcut(QKeySequence("Ctrl+C")); m_menuEdit->addAction(QIcon::fromTheme("edit-paste"), tr("&Paste"), this, SLOT(editPaste()))->setShortcut(QKeySequence("Ctrl+V")); m_menuEdit->addSeparator(); m_menuEdit->addAction(QIcon::fromTheme("edit-select-all"), tr("Select All"), m_view, SLOT(selectAll()))->setShortcut(QKeySequence("Ctrl+A")); m_menuEdit->addAction(QIcon::fromTheme("edit-find"), tr("Find"), this, SLOT(searchOnPage()))->setShortcut(QKeySequence("Ctrl+F")); connect(m_menuEdit, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEditMenu())); m_menuBar->addMenu(m_menuEdit); m_menuView = new QMenu(tr("View")); m_actionStop = m_menuView->addAction(qIconProvider->standardIcon(QStyle::SP_BrowserStop), tr("&Stop"), m_view, SLOT(stop())); m_actionStop->setShortcut(QKeySequence("Esc")); m_actionReload = m_menuView->addAction(qIconProvider->standardIcon(QStyle::SP_BrowserReload), tr("&Reload"), m_view, SLOT(reload())); m_actionReload->setShortcut(QKeySequence("F5")); m_menuView->addSeparator(); m_menuView->addAction(QIcon::fromTheme("zoom-in"), tr("Zoom &In"), m_view, SLOT(zoomIn()))->setShortcut(QKeySequence("Ctrl++")); m_menuView->addAction(QIcon::fromTheme("zoom-out"), tr("Zoom &Out"), m_view, SLOT(zoomOut()))->setShortcut(QKeySequence("Ctrl+-")); m_menuView->addAction(QIcon::fromTheme("zoom-original"), tr("Reset"), m_view, SLOT(zoomReset()))->setShortcut(QKeySequence("Ctrl+0")); m_menuView->addSeparator(); m_menuView->addAction(QIcon::fromTheme("text-html"), tr("&Page Source"), m_view, SLOT(showSource()))->setShortcut(QKeySequence("Ctrl+U")); m_menuBar->addMenu(m_menuView); // Make shortcuts available even with hidden menubar QList<QAction*> actions = m_menuBar->actions(); foreach(QAction * action, actions) { if (action->menu()) { actions += action->menu()->actions(); } addAction(action); } m_layout->insertWidget(0, m_menuBar); m_layout->addWidget(m_locationBar); m_layout->addWidget(m_view); m_layout->addWidget(m_statusBar); setLayout(m_layout); connect(m_view, SIGNAL(showNotification(QWidget*)), this, SLOT(showNotification(QWidget*))); connect(m_view, SIGNAL(titleChanged(QString)), this, SLOT(titleChanged())); connect(m_view, SIGNAL(urlChanged(QUrl)), m_locationBar, SLOT(showUrl(QUrl))); connect(m_view, SIGNAL(iconChanged()), m_locationBar, SLOT(showIcon())); connect(m_view, SIGNAL(statusBarMessage(QString)), this, SLOT(showStatusBarMessage(QString))); connect(m_view, SIGNAL(loadStarted()), this, SLOT(loadStarted())); connect(m_view, SIGNAL(loadProgress(int)), this, SLOT(loadProgress(int))); connect(m_view, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished())); connect(m_page, SIGNAL(linkHovered(QString, QString, QString)), this, SLOT(showStatusBarMessage(QString))); connect(m_page, SIGNAL(geometryChangeRequested(QRect)), this, SLOT(setWindowGeometry(QRect))); connect(m_page, SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SLOT(setStatusBarVisibility(bool))); connect(m_page, SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SLOT(setMenuBarVisibility(bool))); connect(m_page, SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SLOT(setToolBarVisibility(bool))); m_view->setFocus(); titleChanged(); QUrl urlToShow = m_view->url(); if (urlToShow.isEmpty()) { urlToShow = m_view->page()->mainFrame()->requestedUrl(); } m_locationBar->showUrl(urlToShow); // Ensuring correct sizes for widgets in layout are calculated even // before calling QWidget::show() m_layout->invalidate(); m_layout->activate(); }