📄 configdialog.cpp
字号:
/*************************************************************************** configdialog.cpp ------------------- begin : Wed Dec 5 2001 copyright : (C) 2001 by Robby Stephenson email : robby@periapsis.org ***************************************************************************//*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of version 2 of the GNU General Public License as * * published by the Free Software Foundation; * * * ***************************************************************************/#include "configdialog.h"#include "bcattribute.h"#include "bccollection.h"#include "bookcasedoc.h"#include "bookcollection.h"#include <kcombobox.h>#include <klineedit.h>#include <klocale.h>#include <kdebug.h>#include <kiconloader.h>#include <kconfig.h>#include <klistbox.h>#include <kbuttonbox.h>#include <qsize.h>#include <qlayout.h>#include <qlabel.h>#include <qcheckbox.h>#include <qstringlist.h>#include <qptrlist.h>#include <qpixmap.h>#include <qgrid.h>#include <qwhatsthis.h>#include <qregexp.h>#include <qhgroupbox.h>#include <qvgroupbox.h>#include <qpushbutton.h>#include <qvbox.h>#include <qhbox.h>static const int CONFIG_MIN_WIDTH = 600;static const int CONFIG_MIN_HEIGHT = 400;ConfigDialog::ConfigDialog(BookcaseDoc* doc_, QWidget* parent_, const char* name_/*=0*/) : KDialogBase(IconList, i18n("Configure Bookcase"), Ok|Apply|Cancel|Default, Ok, parent_, name_, true, false), m_doc(doc_) { setupGeneralPage(); setupPrintingPage(); //setupBookPage(); //setupAudioPage(); //setupVideoPage(); /* QWidget* page = addPage(i18n("Books")); QVBoxLayout* topLayout = new QVBoxLayout(page); QLabel* label = new QLabel(i18n("Text"), page); topLayout->addWidget(label); KComboBox* box1 = new KComboBox(page); BCCollection* books = BCCollection::Books(-1); BCAttributeListIterator attIt1(books->attributeList()); for( ; attIt1.current(); ++attIt1) { if(attIt1.current()->flags() & BCAttribute::AllowGrouped) { box1->insertItem(attIt1.current()->title()); } } topLayout->addWidget(box1); KComboBox* box2 = new KComboBox(page); BCCollection* videos = BCCollection::Videos(-1); BCAttributeListIterator attIt2(videos->attributeList()); for( ; attIt2.current(); ++attIt2) { if(attIt2.current()->flags() & BCAttribute::AllowGrouped) { box2->insertItem(attIt2.current()->title()); } } topLayout->addWidget(box2); KComboBox* box3 = new KComboBox(page); BCCollection* cds = BCCollection::CDs(-1); BCAttributeListIterator attIt3(cds->attributeList()); for( ; attIt3.current(); ++attIt3) { if(attIt3.current()->flags() & BCAttribute::AllowGrouped) { box3->insertItem(attIt3.current()->title()); } } topLayout->addWidget(box3); delete books; delete videos; delete cds; */ QSize s = sizeHint(); resize(QSize(QMAX(s.width(), CONFIG_MIN_WIDTH), QMAX(s.height(), CONFIG_MIN_HEIGHT)));}void ConfigDialog::slotOk() { slotApply(); accept();}void ConfigDialog::slotApply() { emit signalConfigChanged();}void ConfigDialog::slotDefault() { m_cbOpenLastFile->setChecked(true); m_cbCapitalize->setChecked(true); m_cbFormat->setChecked(true); m_cbShowCount->setChecked(false); m_leArticles->setText(BCAttribute::defaultArticleList().join(QString::fromLatin1(", "))); m_leSuffixes->setText(BCAttribute::defaultSuffixList().join(QString::fromLatin1(", "))); m_cbPrintHeaders->setChecked(false); m_cbPrintFormatted->setChecked(true); m_cbPrintGrouped->setChecked(true); QString authorTitle = m_doc->collectionById(0)->attributeTitleByName(QString::fromLatin1("author")); m_cbPrintGroupAttribute->setCurrentItem(authorTitle); QStringList 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)->attributeByName(*it)->title(); } 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->clear(); m_lbAvailableFields->insertStringList(availTitles);}void ConfigDialog::setupGeneralPage() { QPixmap pix = KGlobal::iconLoader()->loadIcon(QString::fromLatin1("bookcase"), KIcon::User, KIcon::SizeMedium); QFrame* frame = addPage(i18n("General"), i18n("General Options"), pix); QVBoxLayout* l = new QVBoxLayout(frame, 0, KDialog::spacingHint()); m_cbOpenLastFile = new QCheckBox(i18n("Reopen file at startup"), frame); QWhatsThis::add(m_cbOpenLastFile, i18n("If checked, the file that was last open " "will be re-opened at program start-up.")); l->addWidget(m_cbOpenLastFile); m_cbDict.insert(QString::fromLatin1("openLastFile"), m_cbOpenLastFile); m_cbCapitalize = new QCheckBox(i18n("Auto capitalize titles and names"), frame); QWhatsThis::add(m_cbCapitalize, i18n("If checked, titles and names will " "be automatically capitalized.")); l->addWidget(m_cbCapitalize); m_cbDict.insert(QString::fromLatin1("capitalize"), m_cbCapitalize); m_cbFormat = new QCheckBox(i18n("Auto format titles and names"), frame); QWhatsThis::add(m_cbFormat, i18n("If checked, titles and names will " "be automatically formatted.")); l->addWidget(m_cbFormat); m_cbDict.insert(QString::fromLatin1("format"), m_cbFormat); m_cbShowCount = new QCheckBox(i18n("Show number of items in group"), frame); QWhatsThis::add(m_cbShowCount, i18n("If checked, the number of items in the group " "will be appended to the group name.")); l->addWidget(m_cbShowCount); m_cbDict.insert(QString::fromLatin1("showCount"), m_cbShowCount); QGrid* g1 = new QGrid(2, frame); QLabel* l1 = new QLabel(i18n("Articles:"), g1); m_leArticles = new KLineEdit(g1); QStringList articles = BCAttribute::articleList(); if(!articles.isEmpty()) { m_leArticles->setText(articles.join(QString::fromLatin1(", "))); } QWhatsThis::add(l1, i18n("A comma-separated list of words which should be " "considered as articles if they are the first word " "in a title.")); QWhatsThis::add(m_leArticles, i18n("A comma-separated list of words which should be " "considered as articles if they are the first word " "in a title.")); QStringList suffixes = BCAttribute::suffixList(); QLabel* l2 = new QLabel(i18n("Personal suffixes:"), g1); m_leSuffixes = new KLineEdit(g1); if(!suffixes.isEmpty()) { m_leSuffixes->setText(suffixes.join(QString::fromLatin1(", "))); } QWhatsThis::add(l2, i18n("A comma-separated list of suffixes which might " "be used in personal names.")); QWhatsThis::add(m_leSuffixes, i18n("A comma-separated list of suffixes which might " "be used in personal names.")); l->addWidget(g1); // stretch to fill lower area l->addStretch(1);}void ConfigDialog::setupPrintingPage() { QPixmap pix = KGlobal::iconLoader()->loadIcon(QString::fromLatin1("print_printer"), KIcon::Toolbar, KIcon::SizeMedium); QFrame* frame = addPage(i18n("Printing"), i18n("Printing Options"), pix); QVBoxLayout* l = new QVBoxLayout(frame, KDialog::marginHint(), KDialog::spacingHint()); QVGroupBox* optionsGroup = new QVGroupBox(i18n("Formatting Options"), frame); l->addWidget(optionsGroup); m_cbPrintFormatted = new QCheckBox(i18n("Format titles and names"), optionsGroup); QWhatsThis::add(m_cbPrintFormatted, i18n("If checked, titles and names will " "be automatically formatted.")); m_cbDict.insert(QString::fromLatin1("printFormatted"), m_cbPrintFormatted); m_cbPrintHeaders = new QCheckBox(i18n("Print field headers"), optionsGroup); QWhatsThis::add(m_cbPrintHeaders, i18n("If checked, the field names will be " "printed as table headers.")); m_cbDict.insert(QString::fromLatin1("printHeaders"), m_cbPrintHeaders); QHBox* groupingBox = new QHBox(optionsGroup); m_cbPrintGrouped = new QCheckBox(i18n("Group the books"), groupingBox); QWhatsThis::add(m_cbPrintGrouped, i18n("If checked, the books will be grouped under " "the selected field.")); m_cbDict.insert(QString::fromLatin1("printGrouped"), m_cbPrintGrouped); connect(m_cbPrintGrouped, SIGNAL(toggled(bool)), this, SLOT(slotTogglePrintGrouped(bool))); m_cbPrintGroupAttribute = new KComboBox(groupingBox); QWhatsThis::add(m_cbPrintGroupAttribute, i18n("The collection is grouped by this field.")); BCAttributeList list = m_doc->collectionById(0)->attributeList(BCAttribute::AllowGrouped); BCAttributeListIterator it(list); for( ; it.current(); ++it) { m_groupAttributes += it.current()->title(); } m_cbPrintGroupAttribute->insertStringList(m_groupAttributes); QHGroupBox* fieldsGroup = new QHGroupBox(i18n("Fields"), frame);// fieldsGroup->layout()->setSpacing(KDialog::spacingHint()); l->addWidget(fieldsGroup); QVBox* aBox = new QVBox(fieldsGroup); (void) new QLabel(i18n("Available Fields"), aBox); m_lbAvailableFields = new KListBox(aBox); QWhatsThis::add(m_lbAvailableFields, i18n("These are the available fields in the collection.")); KButtonBox* bb = new KButtonBox(fieldsGroup, Qt::Vertical);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -