void CollectionView::openWithBook(BookDescriptionPtr book) { RebuildCollectionRunnable runnable(*this); ZLDialogManager::instance().wait(ZLResourceKey("loadingBookList"), runnable); if (book != 0) { selectBook(book); } }
void CollectionView::editBookInfo(BookDescriptionPtr book) { if (!book.isNull() && BookInfoDialog(myCollection, book->fileName()).dialog().run()) { myCollection.rebuild(false); myDoUpdateModel = true; selectBook(book); application().refreshWindow(); } }
void CollectionView::removeTag(const std::string &tag) { if (tag.empty()) { return; } ZLResourceKey boxKey("removeTagBox"); const std::string message = ZLStringUtil::printf(ZLDialogManager::dialogMessage(boxKey), tag); enum { REMOVE_TAG, REMOVE_SUBTREE, DONT_REMOVE } code = DONT_REMOVE; if (myCollection.hasSubtags(tag)) { if (myCollection.hasBooks(tag)) { switch (ZLDialogManager::instance().questionBox(boxKey, message, ZLResourceKey("thisOnly"), ZLResourceKey("withSubtags"), ZLDialogManager::CANCEL_BUTTON )) { case 0: code = REMOVE_TAG; break; case 1: code = REMOVE_SUBTREE; break; } } else { if (ZLDialogManager::instance().questionBox(boxKey, message, ZLResourceKey("withSubtags"), ZLDialogManager::CANCEL_BUTTON) == 0) { code = REMOVE_SUBTREE; } } } else { if (ZLDialogManager::instance().questionBox(boxKey, message, ZLDialogManager::YES_BUTTON, ZLDialogManager::CANCEL_BUTTON) == 0) { code = REMOVE_TAG; } } if (code != DONT_REMOVE) { collectionModel().removeAllMarks(); myCollection.removeTag(tag, code == REMOVE_SUBTREE); myCollection.rebuild(true); myDoUpdateModel = true; selectBook(mySelectedBook); application().refreshWindow(); } }
docItem::docItem(QList<int> _list, int _curr, int _doc, QWidget *parent):QDialog(parent){ ui.setupUi(this); list = _list; curr = _curr; doc = _doc; QSqlQuery _v(QString("select docs.vid from docs where docs.id = \'%1\'").arg(doc)); _v.next(); vid = _v.value(0).toInt(); ui.spinBox_id_book->hide(); ui.tableWidget_res->setColumnHidden(0, true); ui.tableWidget_res->setColumnHidden(7, true); ui.tableWidget_res->setColumnHidden(8, true); if (vid == 1){ ui.tableWidget_res->setColumnHidden(6, true); ui.radioButton_identifier->hide(); } else if (vid == 2){ ui.lineEdit_place->hide(); ui.label_3->hide(); ui.lineEdit_identifier->setReadOnly(true); } openItem(); readSetting(); connect(ui.pushButton_close, SIGNAL(clicked()), this, SLOT(close())); connect(ui.lineEdit_search, SIGNAL(textEdited(QString)), this, SLOT(searchBook(QString))); connect(ui.tableWidget_res, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(selectBook())); connect(ui.pushButton_save, SIGNAL(clicked()), this, SLOT(saveItem())); connect(ui.pushButton_del, SIGNAL(clicked()), this, SLOT(deleteItem())); connect(ui.pushButton_toFirst, SIGNAL(clicked()), this, SLOT(toFirst())); connect(ui.pushButton_toLast, SIGNAL(clicked()), this, SLOT(toLast())); connect(ui.pushButton_toNext, SIGNAL(clicked()), this, SLOT(toNext())); connect(ui.pushButton_toPrev, SIGNAL(clicked()), this, SLOT(toPrev())); }
void CollectionView::paint() { if (myDoSynchronizeCollection) { myDoSynchronizeCollection = false; RebuildCollectionRunnable runnable(*this); ZLDialogManager::instance().wait(ZLResourceKey("loadingBookList"), runnable); } if ((myOrganizeByTags != organizeByTags()) || (myShowAllBooksList != ShowAllBooksTagOption.value())) { myOrganizeByTags = organizeByTags(); myShowAllBooksList = ShowAllBooksTagOption.value(); myDoUpdateModel = true; } if (myDoUpdateModel) { shared_ptr<ZLTextModel> oldModel = model(); setModel(0, ""); ((CollectionModel&)*oldModel).update(); setModel(oldModel, ""); myDoUpdateModel = false; selectBook(mySelectedBook); } FBView::paint(); }
void CollectionView::removeBook(BookDescriptionPtr book) { if (book.isNull()) { return; } if (book == mySelectedBook) { mySelectedBook = 0; } CollectionModel &cModel = collectionModel(); ZLResourceKey boxKey("removeBookBox"); const std::string message = ZLStringUtil::printf(ZLDialogManager::dialogMessage(boxKey), book->title()); if (ZLDialogManager::instance().questionBox(boxKey, message, ZLDialogManager::YES_BUTTON, ZLDialogManager::NO_BUTTON) == 0) { cModel.removeAllMarks(); BookList().removeFileName(book->fileName()); cModel.removeBook(book); if (cModel.paragraphsNumber() == 0) { setStartCursor(0); } else { size_t index = startCursor().paragraphCursor().index(); if (index >= cModel.paragraphsNumber()) { index = cModel.paragraphsNumber() - 1; } while (!((ZLTextTreeParagraph*)cModel[index])->parent()->isOpen()) { --index; } gotoParagraph(index); } rebuildPaintInfo(true); selectBook(mySelectedBook); application().refreshWindow(); myCollection.rebuild(false); } }
void search::on_pushButton_clicked() { QString selectBook("select * from BOOKS where"); QString ANDFIX(" AND "); QSqlQuery query; int countSBook = 0; //ui->tableWidget->clear(); bool isFirst = true; if(!ui->authorName->text().isEmpty()){ QString fix = QString(tr("'%1'")).arg(ui->authorName->text()); if(isFirst){ selectBook = selectBook + " O_AUTHOR = " + fix; isFirst = false; } else{ selectBook = selectBook + ANDFIX + " O_AUTHOR = " + fix; } } if(!ui->bookName->text().isEmpty()){ QString fix = QString(tr("'%1'")).arg(ui->bookName->text()); if(isFirst){ selectBook = selectBook + " O_NAME = " + fix; isFirst = false; } else{ selectBook = selectBook + ANDFIX + " O_NAME = " + fix; } } if(!ui->ISBN->text().isEmpty()){ QString fix = QString(tr("'%1'")).arg(ui->ISBN->text()); if(isFirst){ selectBook = selectBook + " O_ISBN = " + fix; isFirst = false; } else{ selectBook = selectBook + ANDFIX + " O_ISBN = " + fix; } } if(!ui->flei->text().isEmpty()){ QString fix = QString(tr("'%1'")).arg(ui->flei->text()); if(isFirst){ selectBook = selectBook + " O_CLASS = " + fix; isFirst = false; } else{ selectBook = selectBook + ANDFIX + " O_CLASS = " + fix; } } qDebug()<<selectBook; query.exec(selectBook); isFirst = true; while(ui->tableWidget->rowCount()){ ui->tableWidget->removeRow(ui->tableWidget->rowCount()-1); } while(query.next()){ int i = ui->tableWidget->rowCount(); ui->tableWidget->insertRow(i); QString NUM = query.value(5).toString(); ui->tableWidget->setItem(i,0,new QTableWidgetItem(query.value(0).toString())); ui->tableWidget->setItem(i,1,new QTableWidgetItem(query.value(1).toString())); ui->tableWidget->setItem(i,2,new QTableWidgetItem(query.value(2).toString())); ui->tableWidget->setItem(i,3,new QTableWidgetItem(query.value(3).toString())); ui->tableWidget->setItem(i,4,new QTableWidgetItem(query.value(4).toString())); ui->tableWidget->setItem(i,5,new QTableWidgetItem(NUM)); ui->tableWidget->setItem(i,6,new QTableWidgetItem(query.value(6).toString())); countSBook += NUM.toInt(); isFirst=false; } if(isFirst){ QMessageBox::information(this,tr("提示"),tr("没有记录"),QMessageBox::Ok); } else{ int i = ui->tableWidget->rowCount(); QString temss = QString(tr("共有%1条记录,共计本%2书")).arg(i).arg(countSBook); QMessageBox::information(this,tr("提示"),temss,QMessageBox::Ok); } query.clear(); }