⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 configdialog.cpp

📁 bookcase,by shell script and c++ and perl
💻 CPP
📖 第 1 页 / 共 2 页
字号:
  //the stretches center the buttons top to bottom  bb->addStretch();  QPixmap pixLeft = KGlobal::iconLoader()->loadIcon(QString::fromLatin1("1leftarrow"),                                                KIcon::Toolbar);  QPushButton* left = bb->addButton(QString::null, this, SLOT(slotFieldLeft()));  left->setPixmap(pixLeft);  QPixmap pixRight = KGlobal::iconLoader()->loadIcon(QString::fromLatin1("1rightarrow"),                                                KIcon::Toolbar);  QPushButton* right = bb->addButton(QString::null, this, SLOT(slotFieldRight()));  right->setPixmap(pixRight);  bb->addStretch();    QVBox* sBox = new QVBox(fieldsGroup);  (void) new QLabel(i18n("Selected Fields"), sBox);  m_lbSelectedFields = new KListBox(sBox);  QWhatsThis::add(m_lbSelectedFields, i18n("These are the selected fields in the collection."));  KButtonBox* bb2 = new KButtonBox(fieldsGroup, Qt::Vertical);  bb2->addStretch();  QPixmap pixUp = KGlobal::iconLoader()->loadIcon(QString::fromLatin1("1uparrow"),                                                KIcon::Toolbar);  QPushButton* up = bb2->addButton(QString::null, this, SLOT(slotFieldUp()));  up->setPixmap(pixUp);  QPixmap pixDown = KGlobal::iconLoader()->loadIcon(QString::fromLatin1("1downarrow"),                                                KIcon::Toolbar);  QPushButton* down = bb2->addButton(QString::null, this, SLOT(slotFieldDown()));  down->setPixmap(pixDown);  bb2->addStretch();  // stretch to fill lower area  l->addStretch(1);}//void ConfigDialog::setupBookPage() {//  QPixmap pix = KGlobal::iconLoader()->loadIcon(QString::fromLatin1("book"), KIcon::User,//                                                 KIcon::SizeMedium);//  QFrame* frame = addPage(i18n("Books"), i18n("Book Collection Options"), pix);//  QVBoxLayout* l = new QVBoxLayout(frame, 0, spacingHint());//  l->addStretch(1);//}////void ConfigDialog::setupAudioPage() {//  QPixmap pix = KGlobal::iconLoader()->loadIcon(QString::fromLatin1("cd"), KIcon::User,//                                                KIcon::SizeMedium);//  QFrame* frame = addPage(i18n("CDs"), i18n("Audio Collection Options"), pix);//  QVBoxLayout* l = new QVBoxLayout(frame, 0, spacingHint());//  l->addStretch(1);//}////void ConfigDialog::setupVideoPage() {//  QPixmap pix = KGlobal::iconLoader()->loadIcon(QString::fromLatin1("video"), KIcon::User,//                                                KIcon::SizeMedium);//  QFrame* frame = addPage(i18n("Videos"), i18n("Video Collection Options"), pix);//  QVBoxLayout* l = new QVBoxLayout(frame, 0, spacingHint());//  l->addStretch(1);//}void ConfigDialog::readConfiguration(KConfig* config_) {  config_->setGroup("General Options");    bool openLastFile = config_->readBoolEntry("Reopen Last File", true);  m_cbOpenLastFile->setChecked(openLastFile);  bool autoCapitals = config_->readBoolEntry("Auto Capitalization", true);  m_cbCapitalize->setChecked(autoCapitals);  bool autoFormat = config_->readBoolEntry("Auto Format", true);  m_cbFormat->setChecked(autoFormat);  bool showCount = config_->readBoolEntry("Show Group Count", false);  m_cbShowCount->setChecked(showCount);  // PRINTING  config_->setGroup("Printing");    bool printHeaders = config_->readBoolEntry("Print Field Headers", false);  m_cbPrintHeaders->setChecked(printHeaders);  bool printFormatted = config_->readBoolEntry("Print Formatted", true);  m_cbPrintFormatted->setChecked(printFormatted);  bool printGrouped = config_->readBoolEntry("Print Grouped", true);  m_cbPrintGrouped->setChecked(printGrouped);  m_cbPrintGroupAttribute->setEnabled(printGrouped);    QString printGroupAttribute = config_->readEntry("Print Grouped Attribute",                                                   QString::fromLatin1("author"));  QString selectedGroup = m_doc->collectionById(0)->attributeTitleByName(printGroupAttribute);  int idx = m_groupAttributes.findIndex(selectedGroup);  if(idx > -1 && idx < m_cbPrintGroupAttribute->count()) {    m_cbPrintGroupAttribute->setCurrentItem(idx);  }  QStringList printAttNames = config_->readListEntry("Print Fields - book");  if(printAttNames.isEmpty()) {    printAttNames = BookCollection::defaultPrintAttributes();  }  QStringList printAttTitles;  QStringList::iterator it;  for(it = printAttNames.begin(); it != printAttNames.end(); ++it) {    //TODO:: fix me for multiple collections    printAttTitles += m_doc->collectionById(0)->attributeTitleByName(*it);  }  m_lbSelectedFields->clear();  m_lbSelectedFields->insertStringList(printAttTitles);    QStringList availTitles;  BCAttributeList list = m_doc->uniqueAttributes(BCCollection::Book);  BCAttributeListIterator attIt(list);  for( ; attIt.current(); ++attIt) {    if(printAttTitles.contains(attIt.current()->title()) == 0) {      availTitles += attIt.current()->title();    }  }  m_lbAvailableFields->insertStringList(availTitles);}void ConfigDialog::saveConfiguration(KConfig* config_) {  config_->setGroup("General Options");  config_->writeEntry("Reopen Last File", m_cbOpenLastFile->isChecked());  bool autoCapitals = m_cbCapitalize->isChecked();  config_->writeEntry("Auto Capitalization", autoCapitals);  // TODO: somehow, this should take immediate effect, but that's complicated  BCAttribute::setAutoCapitalize(autoCapitals);    bool autoFormat = m_cbFormat->isChecked();  config_->writeEntry("Auto Format", autoFormat);  // TODO: somehow, this should take immediate effect, but that's complicated  BCAttribute::setAutoFormat(autoFormat);  config_->writeEntry("Show Group Count", m_cbShowCount->isChecked());  // there might be spaces before or after the commas in the lineedit box  QString articlesStr = m_leArticles->text().replace(QRegExp(QString::fromLatin1("\\s*,\\s*")),                                                     QString::fromLatin1(","));  QStringList articles = QStringList::split(QString::fromLatin1(","), articlesStr, false);// ok for articles to be empty//  if(!articles.isEmpty()) {    config_->writeEntry("Articles", articles, ',');    BCAttribute::setArticleList(articles);//  }  // there might be spaces before or after the commas in the lineedit box  QString suffixesStr = m_leSuffixes->text().replace(QRegExp(QString::fromLatin1("\\s*,\\s*")),                                                     QString::fromLatin1(","));  QStringList suffixes = QStringList::split(QString::fromLatin1(","), suffixesStr, false);// ok to be empty//  if(!suffixes.isEmpty()) {    config_->writeEntry("Name Suffixes", suffixes, ',');    BCAttribute::setSuffixList(suffixes);//  }  config_->setGroup("Printing");  config_->writeEntry("Print Field Headers", m_cbPrintHeaders->isChecked());  config_->writeEntry("Print Formatted", m_cbPrintFormatted->isChecked());  config_->writeEntry("Print Grouped", m_cbPrintGrouped->isChecked());  QString groupTitle = m_cbPrintGroupAttribute->currentText();  QString groupName = m_doc->collectionById(0)->attributeNameByTitle(groupTitle);  config_->writeEntry("Print Grouped Attribute", groupName);  QStringList printAttNames;  for(QListBoxItem* item = m_lbSelectedFields->firstItem(); item; item = item->next()) {    printAttNames += m_doc->collectionById(0)->attributeNameByTitle(item->text());  }  config_->writeEntry("Print Fields - book", printAttNames, ',');  config_->sync();}bool ConfigDialog::configValue(const QString& key_) {  QCheckBox* cb = m_cbDict.find(key_);  return cb && cb->isChecked();}void ConfigDialog::slotFieldLeft() {  QListBoxItem* item;#if QT_VERSION >= 0x030100  item = m_lbSelectedFields->selectedItem();#else  item = m_lbSelectedFields->item(m_lbSelectedFields->currentItem());#endif  if(item) {    m_lbAvailableFields->insertItem(item->text());    if(item->next()) {      m_lbSelectedFields->setSelected(item->next(), true);    } else if(item->prev()) {      m_lbSelectedFields->setSelected(item->prev(), true);    } else {      m_lbSelectedFields->clearSelection();    }    delete item;  }  m_lbAvailableFields->clearSelection();}void ConfigDialog::slotFieldRight() {  QListBoxItem* item;#if QT_VERSION >= 0x030100  item = m_lbAvailableFields->selectedItem();#else  item = m_lbAvailableFields->item(m_lbAvailableFields->currentItem());#endif  if(item) {    m_lbSelectedFields->insertItem(item->text());    if(item->next()) {      m_lbAvailableFields->setSelected(item->next(), true);    } else if(item->prev()) {      m_lbAvailableFields->setSelected(item->prev(), true);    } else {      m_lbAvailableFields->clearSelection();    }    delete item;  }  m_lbSelectedFields->clearSelection();}void ConfigDialog::slotFieldUp() {  QListBoxItem* item;#if QT_VERSION >= 0x030100  item = m_lbSelectedFields->selectedItem();#else  item = m_lbSelectedFields->item(m_lbSelectedFields->currentItem());#endif  if(item) {    QListBoxItem* prev = item->prev(); // could be 0    if(prev) {      (void) new QListBoxText(m_lbSelectedFields, prev->text(), item);      delete prev;    }  }}void ConfigDialog::slotFieldDown() {  QListBoxItem* item;#if QT_VERSION >= 0x030100  item = m_lbSelectedFields->selectedItem();#else  item = m_lbSelectedFields->item(m_lbSelectedFields->currentItem());#endif  if(item) {    QListBoxItem* next = item->next(); // could be 0    if(next) {      QListBoxItem* newItem = new QListBoxText(m_lbSelectedFields, item->text(), next);      delete item;      m_lbSelectedFields->setSelected(newItem, true);    }  }}void ConfigDialog::slotTogglePrintGrouped(bool checked_) {  m_cbPrintGroupAttribute->setEnabled(checked_);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -