int insertKey(int offset, long long key, int* child_left_promoted, int* child_right_promoted, long long* key_promoted) { page_tree *curr_page; // pagina atual para busca page_tree *new_page; // pagina para split int pos = -1; // posicao em que a chave deveria ser inserida // trata o caso de arvore vazia if (offset == NIL) { *key_promoted = key; *child_right_promoted = NIL; *child_left_promoted = NIL; return PROMOTED; } curr_page = loadPage(offset); // carrega a pagina para inspecao if (pageSearch(curr_page, key, &pos) == SUCCESS) { fprintf(stderr, "Chave ja existe na arvore\n\n"); return ERROR; } int return_value = -1; int right_offset_child_promoted = -1; int left_offset_child_promoted = -1; long long key_promotion = -1; return_value = insertKey(curr_page->child[pos], key, &left_offset_child_promoted, &right_offset_child_promoted, &key_promotion); // verifica se nao eh necessaria mais nenhuma operacao na arvore // ou seja, a chave foi inserida mas nao ha promocao // ou entao a chave ja existia e foi retornado um erro if (return_value == NOT_PROMOTED || return_value == ERROR) { return return_value; } // verifica se a chave cabe na pagina atual if (curr_page->nKeys < ORDER-1) { pageInsert(curr_page, key_promotion, left_offset_child_promoted, right_offset_child_promoted); savePage(offset, curr_page); return NOT_PROMOTED; } // se a chave nao couber na pagina, realiza split //fprintf(stderr, "chamando split... offset vale %d e chave vale %lld\n", offset, key_promotion); split(key_promotion, right_offset_child_promoted, curr_page, key_promoted, child_left_promoted, child_right_promoted, &new_page); *child_left_promoted = offset; savePage(offset, curr_page); // salva a pagina atual savePage(*child_right_promoted, new_page); // salva a nova pagina apos split free(curr_page); free(new_page); return PROMOTED; }
int insert(int offset, long long key) { long long key_promoted = -1; int return_value = -1; int new_offset = -1; int offset_child_right = -1; int offset_child_left = -1; page_tree *page; // verifica se eh necessario criar um novo no raiz if ((return_value = insertKey(offset, key, &offset_child_left, &offset_child_right, &key_promoted)) == PROMOTED) { // aloca nova pagina na ram allocPage(&page); // insere chave na nova pagina criada (ainda na RAM) pageInsert(page, key_promoted, offset_child_left, offset_child_right); //emanuel page->child[0] = offset_left; page->child[0] = offset_child_left; // move o ponteiro para o final do arquivo para pegar a posicao da nova pagina fseek(bTreeFile, 0L, SEEK_END); new_offset = ftell(bTreeFile); // salva a pagina no disco savePage(new_offset, page); update_root_offset(new_offset); free(page); } return return_value; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); webView = new QWebView(); webView->setWindowTitle("contentEditor preview"); webView->setWindowFlags(Qt::WindowStaysOnTopHint); // | Qt::FramelessWindowHint pageHandler::loadPages(); pageHandler::treeWidget = ui->pagesList; pageHandler::pageStack = ui->pageStack; pageHandler::webView = webView; pageHandler::setup(); setGeometry(50, 50, 1200, 700); connect(ui->savePage,SIGNAL(triggered()),pageHandler::getSingleton(), SLOT(savePage())); connect(ui->togglePagesList,SIGNAL(triggered()),this, SLOT(togglePagesList())); connect(ui->toggleFullscreen,SIGNAL(triggered()),this, SLOT(toggleFullscreen())); connect(ui->togglePreview,SIGNAL(triggered()),this, SLOT(togglePreview())); connect(ui->newPage,SIGNAL(triggered()),this, SLOT(addPage())); connect(ui->newField,SIGNAL(triggered()),this, SLOT(addField())); connect(ui->backgroundColor, SIGNAL(triggered()), pageHandler::getSingleton(), SLOT(setFieldBackgroundColor())); connect(ui->addImage, SIGNAL(triggered()), pageHandler::getSingleton(), SLOT(addImage())); connect(ui->toggleText, SIGNAL(triggered()), pageHandler::getSingleton(), SLOT(toggleTextEdit())); connect(ui->pageBackgroundColor, SIGNAL(triggered()), pageHandler::getSingleton(), SLOT(setPageBackgroundColor())); connect(ui->printPDF, SIGNAL(triggered()), pageHandler::getSingleton(), SLOT(exportPDF())); lastWebViewGeometry = QRect(200,200,500,400); }
void ConfigureDialog::closeEvent(QCloseEvent *event) { PrinterPage *page = qobject_cast<PrinterPage*>(currentPage()->widget()); if (savePage(page)) { event->accept(); } else { event->ignore(); } }
void Reporter::next(){ log->info(__FUNCTION__) << " Pushing to next pad " << endl; currentPad++; if ( currentPad > dx*dy){ savePage(); newPage( dx, dy); } else { cd( currentPad ); } }
void ConfigureDialog::currentPageChanged(KPageWidgetItem *current, KPageWidgetItem *before) { PrinterPage *currentPage = qobject_cast<PrinterPage*>(current->widget()); PrinterPage *beforePage = qobject_cast<PrinterPage*>(before->widget()); // Check if the before page has changes savePage(beforePage); if (beforePage) { disconnect(beforePage, SIGNAL(changed(bool)), this, SLOT(enableButtonApply(bool))); } // connect the changed signal to the new page and check if it has changes connect(currentPage, SIGNAL(changed(bool)), this, SLOT(enableButtonApply(bool))); enableButtonApply(currentPage->hasChanges()); }
int webPage::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: loading((*reinterpret_cast< QString(*)>(_a[1]))); break; case 1: isLoading((*reinterpret_cast< QPixmap(*)>(_a[1]))); break; case 2: titleChanged((*reinterpret_cast< QString(*)>(_a[1]))); break; case 3: pageChanged((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break; case 4: showSources((*reinterpret_cast< QString(*)>(_a[1]))); break; case 5: speedDial(); break; case 6: needPrint((*reinterpret_cast< QPrinter*(*)>(_a[1]))); break; case 7: openTab((*reinterpret_cast< webPage*(*)>(_a[1]))); break; case 8: setFullScreen((*reinterpret_cast< bool(*)>(_a[1]))); break; case 9: startLoading(); break; case 10: finishLoading((*reinterpret_cast< bool(*)>(_a[1]))); break; case 11: changeTitle((*reinterpret_cast< QString(*)>(_a[1]))); break; case 12: changeUrl((*reinterpret_cast< QUrl(*)>(_a[1]))); break; case 13: goToHome(); break; case 14: loadUrl(); break; case 15: loadUrl((*reinterpret_cast< QUrl(*)>(_a[1]))); break; case 16: loadUrl((*reinterpret_cast< QString(*)>(_a[1]))); break; case 17: addToBookMark(); break; case 18: downloadFile((*reinterpret_cast< const QNetworkRequest(*)>(_a[1]))); break; case 19: downloadFile((*reinterpret_cast< QNetworkReply*(*)>(_a[1]))); break; case 20: loadBookMark(); break; case 21: showBookMark(); break; case 22: sources(); break; case 23: defineHome(); break; case 24: findNext(); break; case 25: findPrevious(); break; case 26: print(); break; case 27: createNewPage((*reinterpret_cast< WebView*(*)>(_a[1]))); break; case 28: createNewPage(); break; case 29: updateIcon(); break; case 30: copy(); break; case 31: authentification((*reinterpret_cast< QNetworkReply*(*)>(_a[1])),(*reinterpret_cast< QAuthenticator*(*)>(_a[2]))); break; case 32: inspectPage(); break; case 33: goToDial(); break; case 34: updateUrlIcon((*reinterpret_cast< QPixmap(*)>(_a[1]))); break; case 35: updateBookMark(); break; case 36: updateOptions(); break; case 37: showBar(); break; case 38: showPage(); break; case 39: showDial(); break; case 40: inCache(); break; case 41: showConsole(); break; case 42: zoomIn(); break; case 43: zoomOut(); break; case 44: restoreZoom(); break; case 45: savePage(); break; case 46: back(); break; case 47: forward(); break; default: ; } _id -= 48; } return _id; }