void menu(vector<Book>& collection) { char exit = 'n'; do { int item; int& ritem = item; string choice; cout << " ___________________________________________________________________________________________________ " << endl << "| __________ __ _________ .__ .__ __ .__ |" << endl << "| \\______ \\ ____ ____ | | __ \\_ ___ \\ ____ | | | | ____ _____/ |_|__| ____ ____ |" << endl << "| | | _// _ \\ / _ \\| |/ / / \\ \\/ / _ \\| | | | _/ __ \\_/ ___\\ __\\ |/ _ \\ / \\ |" << endl << "| | | ( <_> | <_> ) < \\ \\___( <_> ) |_| |_\\ ___/\\ \\___| | | ( <_> ) | \\ |" << endl << "| |______ /\\____/ \\____/|__|_ \\ \\______ /\\____/|____/____/\\___ >\\___ >__| |__|\\____/|___| / |" << endl << "|_________\\/___________________\\/_________\\/______________________\\/_____\\/____________________\\/___|" << endl << "| |" << endl << "|1.View Collection 2.Add Book 3.Delete Book |" << endl << "|4.Search Collection 5.Save to File 6.Exit Program|" << endl << "|___________________________________________________________________________________________________|" << endl << "\t\t\tEnter a number to access a menu item:\t"; //addBook(collection); getline(cin, choice); try { ritem = stoi(choice); } catch (invalid_argument e) { cout << "Please enter a digit\n"; system("pause"); } switch (item) { case 1: viewCollection(collection); system("pause"); break; case 2: addBook(collection); break; case 3: deleteBook(collection); break; case 4: searchBook(collection); system("pause"); break; case 5: saveCollection(collection); break; case 6: exit = exitProgram(); break; default: cout << "Enter a number associated with a menu item (1-6).\n"; } system("cls"); }while(exit == 'n'); } // menu function
void signal_handler(int sig) { FILE* output = fopen(sh_fileName, "w"); printBook(output, sh_book); fclose(output); deleteBook(sh_book); return; }
void calcuTotal(Book b[], int n) { int i,j; for (i=0;i<n;i++) for (j=i+1;j<n;j++) if (equal(b[i],b[j],1)) /*如果存在两条同一书本的信息,销量相加并删去其中一条信息*/ { addBook(b,i,j); deleteBook(b,n,b[j]); } }
int baseManage(Book b[],int n) /*该函数完成基本信息管理*/ { int choice,t,find[NUM]; char judge1='n',judge2='n'; Book b1; do { menuBase( ); /*显示对应的二级菜单*/ printf("choose one operation you want to do:"); scanf("%d",&choice); /*读入选项*/ switch(choice) { case 1: readBook(&b1,1); /*读入一条待插入的图书信息*/ n=insertBook(b,n,b1); /*调用函数插入图书信息*/ break; case 2: printf("Input the ISBN deleted\n"); scanf("%s",b1.ISBN); /*读入一个待删除图书的ISBN*/ n=deleteBook(b,n,b1); /*调用函数删除指定ISBN的图书记录*/ break; case 3: do { printf("Input the ISBN you want search: \n"); scanf("%s",b1.ISBN); /*读入一个待查找图书的ISBN*/ getchar(); t=searchBook(b,n,b1,1,find) ; /*调用函数查找指定ISBN的图书记录*/ if (t) /*如果该ISBN的记录存在*/ { printf("change this information? (y/n)\n"); scanf("%c",&judge2); if (judge2 == 'y') /*判断是否修改该条信息*/ { readBook(&b1,1); /*读入一条完整的图书记录信息*/ b[find[0]]=b1; /*将刚读入的记录赋值给需要修改的数组记录*/ } } else /*如果ISBN的记录不存在*/ { printf("this book is not in.\ninput again? (y/n)\n"); /*输出提示信息*/ scanf("%c",&judge1); } } while (judge1 == 'y'); break; case 0: break; } } while (choice); return n; /*返回当前操作结束后的实际记录条数*/ }
int main() { FILE *fp; int choice; int i=0; if ((fp = fopen("books.dat","rb+"))==NULL) //create binary file with blank records if file pointer returns NULL { printf("File does not exist\nCreating Binary File with blank records..."); struct book blankBook = { "","",0,0,0.0,0.0}; fp = fopen("books.dat","wb+"); for ( i = 1; i <= 100; i++ ) //write 100 blank book structures { fwrite( &blankBook, sizeof( struct book ), 1, fp ); } fclose ( fp ); main(); } else //menu { while ( ( choice = enterChoice() ) != 5 ) { switch ( choice ) { case 1: writeToTextFile( fp ); break; case 2: updatePrice( fp ); break; case 3: newBook( fp ); break; case 4: deleteBook( fp ); break; default: printf( "Incorrect choice\n" ); break; } } fclose( fp ); } return 0; }
void Library::deleteBookCopies(string title, int aCopies) { CatalogueBook *thisBook = getBook(search(title)); if (thisBook->getAvailableCopies() >= aCopies) { if (thisBook->getTotalCopies() <= aCopies) { deleteBook(title); cout<<endl<<title<<" has been removed from the library!"<<endl; } else { thisBook->setTotalCopies(thisBook->getTotalCopies() - aCopies); thisBook->setAvailableCopies(thisBook->getAvailableCopies() - aCopies); cout<<endl<<endl<<aCopies<<" copies of "<<title<<" has been removed!"<<endl; } } else { cout <<endl<< "Note: Some copies needed to be removed has been leased out!" << endl; } }
void adminOptions() { int choice = 1; printf("Welcome, administrator.\n"); while (choice != 0) { choice = -1;//resets choice to an impossible value //If not, if they entered an integer and then entered a character later, it would automatically go into the option corresponding to the last integer they entered printf("01\tAdd New Book\n02\tModify Existing Book\n03\tDelete Book\n"); printf("04\tSearch\n00\tLog Out\n\n>"); scanf("%d", &choice); switch (choice) { case 1: addBook(); break; case 2: modifyDetails(); break; case 3: deleteBook(); break; case 4: searchMenu(0); break; case 0: isAdmin = 0; printf("You have successfully logged out.\n"); return; default: printf("Your input was not recognised\n"); } fflush(stdin);//stops the programme going into an infinite loop if user enters a character for choice //This is because if scanf can't deal with an input, it leaves it on the buffer so every time, it would otherwise try and fail to read it in } }
void menu(){ int wyb=0; int end=1; char pom[20]; while(end){ char pomInsert[50]; char pomInsert2[50]; char pomInsert3[50]; char sqlscript[300]="INSERT INTO ksiazka(id_autor,tytul,ksiazka_gatunek,cena,rabat)VALUES ("; char sqlscriptAut[300]="INSERT INTO autor(imie,nazwisko,rok_ur,pochodzenie)VALUES ('"; char sqlscriptUp[300]="UPDATE autor SET "; char sqlscriptUpKs[300]="UPDATE ksiazka SET "; char sqldeletescript[300]=""; printf("Co chcesz zrobic ?\n"); printf("[1] dodaj rekord\n");//jest printf("[2] usun rekord\n");//jest printf("[3] wyswietl wszystko\n");//jest printf("[4] modyfikuj rekord\n");//brak pomyslu printf("[5] szukaj\n");//jest printf("[6] generuj html\n");//jest printf("[7] zakoncz\n"); printf("Wybierasz : "); scanf("%d",&wyb); switch(wyb){ case 1: printf("Wybierz tabele\n"); printf("[1] autor\n"); printf("[2] ksiazka\n"); printf("Wybierasz : "); scanf("%d",&wyb); switch(wyb){ case 1: printf("Podaj imie autora : "); scanf("%s",pomInsert); strcat(sqlscriptAut,pomInsert); strcat(sqlscriptAut,"','"); printf("Podaj nazwisko autora : "); scanf("%s",pomInsert); strcat(sqlscriptAut,pomInsert); strcat(sqlscriptAut,"','"); printf("Podaj rok urodzenia : "); scanf("%s",pomInsert); strcat(sqlscriptAut,pomInsert); strcat(sqlscriptAut,"','"); printf("Podaj pochodzenie : "); scanf("%s",pomInsert); strcat(sqlscriptAut,pomInsert); strcat(sqlscriptAut,"');"); doSQL(conn,sqlscriptAut); continue; case 2: printf("Podaj id autora : "); scanf("%s",pomInsert); strcat(sqlscript,pomInsert); strcat(sqlscript,",'"); printf("Podaj tytul ksiazki uzwyajac _ zamiast spacji : "); scanf("%s",pomInsert); strcat(sqlscript,pomInsert); strcat(sqlscript,"','"); printf("Podaj gatunek : "); scanf("%s",pomInsert); strcat(sqlscript,pomInsert); strcat(sqlscript,"','"); printf("Podaj cene : "); scanf("%s",pomInsert); strcat(sqlscript,pomInsert); strcat(sqlscript,"','"); printf("Podaj rabat : "); scanf("%s",pomInsert); strcat(sqlscript,pomInsert); strcat(sqlscript,"');"); doSQL(conn,sqlscript); continue; } case 2: printf("Wybierz tabele\n"); printf("[1] autor\n"); printf("[2] ksiazka\n"); printf("Wybierasz : "); scanf("%d",&wyb); switch(wyb){ case 1: printf("podaj id autora : "); scanf("%s",pomInsert); deleteAutor(pomInsert); continue; case 2: printf("podaj id ksiazki : "); scanf("%s",pomInsert); deleteBook(pomInsert); continue; } case 3: printf("\n[KSIAZKA]\n\n"); doSQL(conn,"SELECT * FROM ksiazka;"); printf("\n[AUTOR]\n\n"); doSQL(conn,"SELECT * FROM autor;"); continue; case 4: printf("Wybierz tabele\n"); printf("[1] autor\n"); printf("[2] ksiazka\n"); printf("Wybierasz : "); scanf("%d",&wyb); switch(wyb){ case 1: printf("Podaj nazwisko autora ktorego chcesz edytowac : "); scanf("%s",pomInsert2); printf("\nCzy zmieniamy imie? Jesli nie wpisz 0 jesli tak podaj nowe imie : "); scanf("%s",pomInsert); if(strcmp(pomInsert,"0")!=0){ strcat(sqlscriptUp,"imie='"); strcat(sqlscriptUp,pomInsert); strcat(sqlscriptUp,"'"); } strcpy(pomInsert3, pomInsert); printf("\nCzy zmieniamy nazwisko? Jesli nie wpisz 0 jesli tak podaj nowe nazwisko : "); scanf("%s",pomInsert); if(strcmp(pomInsert,"0")!=0){ if(strcmp(pomInsert3,"0")!=0) strcat(sqlscriptUp,","); strcat(sqlscriptUp," nazwisko='"); strcat(sqlscriptUp,pomInsert); strcat(sqlscriptUp,"'"); strcpy(pomInsert3, pomInsert); } printf("\nCzy zmieniamy rok_urodzenia? Jesli nie wpisz 0 jesli tak podaj nowy rok_rodzenia : "); scanf("%s",pomInsert); if(strcmp(pomInsert,"0")!=0){ if(strcmp(pomInsert3,"0")!=0) strcat(sqlscriptUp,","); strcat(sqlscriptUp," rok_ur='"); strcat(sqlscriptUp,pomInsert); strcat(sqlscriptUp,"'"); strcpy(pomInsert3, pomInsert); } printf("\nCzy zmieniamy pochodzenie? Jesli nie wpisz 0 jesli tak podaj nowe pochodzenie : "); scanf("%s",pomInsert); if(strcmp(pomInsert,"0")!=0){ if(strcmp(pomInsert3,"0")!=0) strcat(sqlscriptUp,","); strcat(sqlscriptUp," pochodzenie='"); strcat(sqlscriptUp,pomInsert); strcat(sqlscriptUp,"'"); } strcat(sqlscriptUp," WHERE nazwisko='"); strcat(sqlscriptUp,pomInsert2); strcat(sqlscriptUp,"';"); doSQL(conn,sqlscriptUp); continue; case 2: printf("Podaj tytul ksiazki ktora chcesz edytowac : "); scanf("%s",pomInsert2); printf("\nCzy zmieniamy tytul? Jesli nie wpisz 0 jesli tak podaj nowy tytul : "); scanf("%s",pomInsert); if(strcmp(pomInsert,"0")!=0){ strcat(sqlscriptUpKs,"tytul='"); strcat(sqlscriptUpKs,pomInsert); strcat(sqlscriptUpKs,"'"); } strcpy(pomInsert3, pomInsert); printf("\nCzy zmieniamy gatunek? Jesli nie wpisz 0 jesli tak podaj nowy gatunek : "); scanf("%s",pomInsert); if(strcmp(pomInsert,"0")!=0){ if(strcmp(pomInsert3,"0")!=0) strcat(sqlscriptUpKs,","); strcat(sqlscriptUpKs," ksiazka_gatunek='"); strcat(sqlscriptUpKs,pomInsert); strcat(sqlscriptUpKs,"'"); strcpy(pomInsert3, pomInsert); } printf("\nCzy zmieniamy cene? Jesli nie wpisz 0 jesli tak podaj nowa cene : "); scanf("%s",pomInsert); if(strcmp(pomInsert,"0")!=0){ if(strcmp(pomInsert3,"0")!=0) strcat(sqlscriptUpKs,","); strcat(sqlscriptUpKs," cena='"); strcat(sqlscriptUpKs,pomInsert); strcat(sqlscriptUpKs,"'"); strcpy(pomInsert3, pomInsert); } printf("\nCzy zmieniamy rabat? Jesli nie wpisz 0 jesli tak podaj nowy rabat : "); scanf("%s",pomInsert); if(strcmp(pomInsert,"0")!=0){ if(strcmp(pomInsert3,"0")!=0) strcat(sqlscriptUpKs,","); strcat(sqlscriptUpKs," rabat='"); strcat(sqlscriptUpKs,pomInsert); strcat(sqlscriptUpKs,"'"); } strcat(sqlscriptUpKs," WHERE tytul='"); strcat(sqlscriptUpKs,pomInsert2); strcat(sqlscriptUpKs,"';"); doSQL(conn,sqlscriptUpKs); continue; } continue; case 5: printf("Wybierz tabele\n"); printf("[1] autor\n"); printf("[2] ksiazka\n"); printf("Wybierasz : "); scanf("%d",&wyb); switch(wyb){ case 1: printf("podaj nazwisko autora : "); scanf("%s",pomInsert); searchAutor(pomInsert); continue; case 2: printf("podaj tytul : "); scanf("%s",pomInsert); searchBook(pomInsert); continue; } case 6: generateHTML(); continue; case 7: end=0; printf("\n\t\tKoniec tego dobrego :)\n\n"); break; default: printf("\nBledny wybor sprobuj jeszcze raz.\n"); } } }
int main(int argc, char const *argv[]) { if (argc == 1) { printf("ERROR: the program takes one argument\n"); return 0; } argv[1]; FILE *input = fopen(argv[1], "r"); Book *book = createBook(); readBookFromFile(input, book); fclose(input); sh_fileName = argv[1]; sh_book = book; signal(SIGINT, signal_handler); char command[10]; char *name = NULL; //(char *) malloc(sizeof(char)*80); char *number = NULL; // (char *) malloc(sizeof(char)*80); char *str = NULL; //(char *) malloc(80); bool corName; bool corNumber; while (true) { corName = true; corNumber = true; scanf("%s", command); if(!strcmp(command, "debprint")) { fullPrint(book); } else if(!strcmp(command, "print")) { printBook(stdout, book); } else if(!strcmp(command, "find")) { str = read(stdin); printFound(stdout, book, str); free(str); } else if(!strcmp(command, "create")) { name = read(stdin); number = read(stdin); corName = correctName(name); corNumber = correctNumber(number); if (correctName && correctNumber) { appendBook(book, name, number); } free(name); free(number); } else if(!strcmp(command, "delete")) { int id; scanf("%d", &id); removeContact(book, id); } else if(!strcmp(command, "change")) { int id; scanf("%d%s", &id, command); str = read(stdin); if(!strcmp(command, "number")) { corName = correctName(str); if (corName) changeNumber(book, id, str); } else if (!strcmp(command, "name")) { corNumber = correctNumber(str); if (corNumber) changeName(book, id, str); } else { printf("ERROR: Expected \"name\" or \"number\" after id in the command change\n"); } free(str); } else if(!strcmp(command, "exit")) { FILE* output = fopen(argv[1], "w"); printBook(output, book); fclose(output); deleteBook(book); break; } else { printf("ERROR: Unknown command %s\n", command); } if (!corName) { printf("ERROR: Invalid name\n"); } if (!corNumber) { printf("ERROR: Invalid number\n"); } } return 0; }
//---------------------------------------------------------------------- // KJOTSMAIN //---------------------------------------------------------------------- KJotsComponent::KJotsComponent(QWidget* parent, KActionCollection *collection) : QWidget(parent) { actionCollection = collection; searchDialog = 0; activeAnchor.clear(); QDBusConnection dbus = QDBusConnection::sessionBus(); dbus.registerObject("/KJotsComponent", this, QDBusConnection::ExportScriptableSlots); // // Main widget // splitter = new QSplitter(this); splitter->setOpaqueResize( KGlobalSettings::opaqueResize() ); bookshelf = new Bookshelf(splitter); stackedWidget = new QStackedWidget(splitter); editor = new KJotsEdit(stackedWidget); editor->createActions(actionCollection); editor->setEnabled(false); stackedWidget->addWidget(editor); browser = new KJotsBrowser(stackedWidget); browser->setEnabled(false); stackedWidget->addWidget(browser); QVBoxLayout *bookGrid = new QVBoxLayout(this); bookGrid->setMargin(KDialog::marginHint()); bookGrid->setSpacing(KDialog::spacingHint()); bookGrid->addWidget(splitter, 0, 0); bookGrid->setMargin(0); splitter->setStretchFactor(1, 1); // I've moved as much I could into DelayedInitialization(), but the XML // gui builder won't insert things properly if they don't get in there early. KAction *action; action = actionCollection->addAction( "go_next_book"); action->setText( i18n("Next Book") ); action->setIcon(KIcon("go-down")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D)); connect(action, SIGNAL(triggered()), bookshelf, SLOT(nextBook())); action = actionCollection->addAction( "go_prev_book"); action->setText( i18n("Previous Book") ); action->setIcon(KIcon("go-up")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D)); connect(action, SIGNAL(triggered()), bookshelf, SLOT(prevBook())); action = actionCollection->addAction( "go_next_page"); action->setText( i18n("Next Page") ); action->setIcon(KIcon("go-next")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_PageDown)); connect(action, SIGNAL(triggered()), bookshelf, SLOT(nextPage())); action = actionCollection->addAction( "go_prev_page" ); action->setText( i18n("Previous Page") ); action->setIcon(KIcon("go-previous")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_PageUp)); connect(action, SIGNAL(triggered()), bookshelf, SLOT(prevPage())); action = actionCollection->addAction( "new_page"); action->setText( i18n("&New Page") ); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N)); action->setIcon(KIcon("document-new")); connect(action, SIGNAL(triggered()), SLOT(newPage())); action = actionCollection->addAction("new_book"); action->setText(i18n("New &Book...")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_N)); action->setIcon(KIcon("address-book-new")); connect(action, SIGNAL(triggered()), SLOT(createNewBook())); exportMenu = actionCollection->add<KActionMenu>("save_to"); exportMenu->setText(i18n("Export")); exportMenu->setIcon(KIcon("document-export")); action = actionCollection->addAction("save_to_ascii"); action->setText(i18n("To Text File...")); action->setIcon(KIcon("text-plain")); connect(action, SIGNAL(triggered()), SLOT(saveAscii())); exportMenu->menu()->addAction( action ); action = actionCollection->addAction("save_to_html"); action->setText(i18n("To HTML File...")); action->setIcon(KIcon("text-html")); connect(action, SIGNAL(triggered()), SLOT(saveHtml())); exportMenu->menu()->addAction( action ); action = actionCollection->addAction("save_to_book"); action->setText(i18n("To Book File...")); action->setIcon(KIcon("x-office-address-book")); connect(action, SIGNAL(triggered()), SLOT(saveNative())); exportMenu->menu()->addAction( action ); action = actionCollection->addAction("import"); action->setText(i18n("Import...")); action->setIcon(KIcon("document-import")); connect(action, SIGNAL(triggered()), SLOT(importBook())); action = actionCollection->addAction("del_page"); action->setText(i18n("&Delete Page")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Delete)); action->setIcon(KIcon("edit-delete-page")); connect(action, SIGNAL(triggered()), SLOT(deletePage())); action = actionCollection->addAction("del_folder"); action->setText(i18n("Delete Boo&k")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Delete)); action->setIcon(KIcon("edit-delete")); connect(action, SIGNAL(triggered()), SLOT(deleteBook())); action = actionCollection->addAction("del_mult"); action->setText(i18n("Delete Selected")); action->setIcon(KIcon("edit-delete")); connect(action, SIGNAL(triggered()), SLOT(deleteMultiple())); action = actionCollection->addAction("manual_save"); action->setText(i18n("Manual Save")); action->setIcon(KIcon("document-save")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S)); connect(action, SIGNAL(triggered()), SLOT(saveAll())); action = actionCollection->addAction("auto_bullet"); action->setText(i18n("Auto Bullets")); action->setIcon(KIcon("format-list-unordered")); action->setCheckable(true); action = actionCollection->addAction("auto_decimal"); action->setText(i18n("Auto Decimal List")); action->setIcon(KIcon("format-list-ordered")); action->setCheckable(true); action = actionCollection->addAction("manage_link"); action->setText(i18n("Link")); action->setIcon(KIcon("insert-link")); action = actionCollection->addAction("insert_checkmark"); action->setText(i18n("Insert Checkmark")); action->setIcon(KIcon("checkmark")); action->setEnabled(false); KStandardAction::print(this, SLOT(onPrint()), actionCollection); action = KStandardAction::cut(editor, SLOT(cut()), actionCollection); connect(editor, SIGNAL(copyAvailable(bool)), action, SLOT(setEnabled(bool))); action->setEnabled(false); action = KStandardAction::copy(this, SLOT(copy()), actionCollection); connect(editor, SIGNAL(copyAvailable(bool)), action, SLOT(setEnabled(bool))); connect(browser, SIGNAL(copyAvailable(bool)), action, SLOT(setEnabled(bool))); action->setEnabled(false); action = actionCollection->addAction("copyIntoTitle"); action->setText(i18n("Copy &into Page Title")); action->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_T)); action->setIcon(KIcon("edit-copy")); connect(action, SIGNAL(triggered()), SLOT(copySelection())); connect(editor, SIGNAL(copyAvailable(bool)), action, SLOT(setEnabled(bool))); action->setEnabled(false); KStandardAction::pasteText(editor, SLOT(paste()), actionCollection); KStandardAction::find( this, SLOT( onShowSearch() ), actionCollection ); action = KStandardAction::findNext( this, SLOT( onRepeatSearch() ), actionCollection ); action->setEnabled(false); KStandardAction::replace( this, SLOT( onShowReplace() ), actionCollection ); action = actionCollection->addAction("rename_entry"); action->setText(i18n("Rename...")); action->setIcon(KIcon("edit-rename")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); connect(action, SIGNAL(triggered()), SLOT(onRenameEntry())); action = actionCollection->addAction("insert_date"); action->setText(i18n("Insert Date")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I)); action->setIcon(KIcon("view-calendar-time-spent")); connect(action, SIGNAL(triggered()), SLOT(insertDate())); action = actionCollection->addAction("change_color"); action->setIcon(KIcon("format-fill-color")); action->setText(i18n("Change Color...")); // connected to protected slot in bookshelf.cpp action = actionCollection->addAction("copy_link_address"); action->setText(i18n("Copy Link Address")); // connected to protected slot in bookshelf.cpp action = actionCollection->addAction("paste_plain_text"); action->setText(i18nc("@action Paste the text in the clipboard without rich text formatting.", "Paste Plain Text")); connect(action, SIGNAL(triggered()), editor, SLOT(pastePlainText())); KStandardAction::preferences(this, SLOT(configure()), actionCollection); bookmarkMenu = actionCollection->add<KActionMenu>("bookmarks"); bookmarkMenu->setText(i18n("&Bookmarks")); KJotsBookmarks* bookmarks = new KJotsBookmarks(bookshelf); /*KBookmarkMenu *bmm =*/ new KBookmarkMenu( KBookmarkManager::managerForFile(KStandardDirs::locateLocal("data","kjots/bookmarks.xml"), "kjots"), bookmarks, bookmarkMenu->menu(), actionCollection); m_autosaveTimer = new QTimer(this); // // Set startup size. // if (!KJotsSettings::splitterSizes().isEmpty()) { splitter->setSizes(KJotsSettings::splitterSizes()); } updateConfiguration(); QTimer::singleShot(0, this, SLOT(DelayedInitialization())); //connect new slots connect(bookshelf, SIGNAL(itemSelectionChanged()), SLOT(updateCaption())); connect(bookshelf, SIGNAL(itemSelectionChanged()), SLOT(updateMenu())); connect(bookshelf, SIGNAL(itemChanged(QTreeWidgetItem*, int)), SLOT(onItemRenamed(QTreeWidgetItem*, int))); connect(m_autosaveTimer, SIGNAL(timeout()), SLOT(autoSave())); }