void libraries_cb(GtkButton *button, GtkWindow *window) { GtkWidget *dialog; GArray *items; int result; dialog = gtk_dialog_new_with_buttons("Libraries", window, GTK_DIALOG_MODAL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); items = g_array_new(FALSE, FALSE, sizeof(GtkWidget*)); create_libraries_dialog(items, dialog); gtk_widget_show_all(dialog); result = gtk_dialog_run(GTK_DIALOG(dialog)); if (result == GTK_RESPONSE_ACCEPT) { update_library_list(items); update_file_lists(); save_project_settings(); } g_array_free(items, TRUE); gtk_widget_destroy(dialog); }
void Collection::open_library(const QString& file) { _current_library = new Library(); _libraries.push_back(_current_library); _current_library->set_library_file(file); _stdout << _current_library->get_library_file() << endl; if ( _current_library->open_library() ) update_library_list(); }
//---------------------------------------------------------------- void Collection::import_paper() { //we should not try to add a paper if no current library; if ( !_current_library ) { QMessageBox::about(this, tr("Error"), tr("Error: you have no Libraries defined\n" "you cannot create a new paper")); return; } QWebPage * page = _rss_box->page(); QWebFrame * frame = page->mainFrame(); //now create a new paper and parse out the values we want. _parser->setData(frame->toHtml()); _stdout << "Collection::import_paper title" << _parser->getTitle() << endl; _stdout << "Collection::import_paper authors" << _parser->getAuthors() << endl; Paper * paper = new Paper(); paper->set_title(_parser->getTitle()); paper->set_author(_parser->getAuthors()); paper->set_abstract(_parser->getAbstract()); paper->set_date(_parser->getDate()); paper->set_arxiv_number(_parser->getNumber()); //Download the damn thing _manager = new QNetworkAccessManager(this); _manager->get(QNetworkRequest(_parser->getDownloadLocation())); connect(_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(download_finished(QNetworkReply*))); QDir directory(_current_library->get_library_directory()+"/"+_parser->getPaperName()); _stdout << "Collection::import_paper " << directory.absolutePath() << endl; paper->set_file_name(directory.absolutePath()); //add the entry to the library _current_library->add_entry(paper); //add the entry to the list add_paper_to_list(*paper,_paper_list); update_library_list(); }
void Collection::delete_library() { QString question(tr("Do you want to delete the entry with\n" "name %1 \n").arg(_current_library->get_library_name())); if ( QMessageBox::warning(this,"Delete Library", question, QMessageBox::Ok|QMessageBox::Cancel) == QMessageBox::Ok ) { std::vector<Library *>::iterator iter = _libraries.begin(); for (; iter != _libraries.end(); iter++) if ( (*iter) == _current_library ) { _current_library->remove_library_file(); _libraries.erase(iter); _current_library=0; update_library_list(); } } }
//---------------------------------------------------------------- void Collection::delete_paper() { _stdout << "Short list " << _current_library->get_current_entry()->get_author_short() << endl; QString question(tr("Do you want to delete the entry with\n" "title %1 \n" "and author %2").arg( _current_library->get_current_entry()->get_title(), _current_library->get_current_entry()->get_author_short() ) ); if ( QMessageBox::warning(this,"Delete Paper", question, QMessageBox::Ok|QMessageBox::Cancel) == QMessageBox::Ok ) { paperEdit->setEnabled(false); paperDelete->setEnabled(false); paperOpen->setEnabled(false); _current_library->delete_current_entry(); update_paper_list(); update_library_list(); } }
//---------------------------------------------------------------- void Collection::new_paper() { //we should not try to add a paper if no current library; if ( !_current_library ) { QMessageBox::about(this, tr("Error"), tr("Error: you have no Libraries defined\n" "you cannot create a new paper")); return; } Paper * paper = new Paper(); if ( paper->open_new_dialog() == QDialog::Accepted ) { _stdout << "We should have some data in here now: " << paper->get_author() << endl; _stdout.flush(); //add the entry to the library _current_library->add_entry(paper); //add the entry to the list add_paper_to_list(*paper,_paper_list); update_library_list(); } }