// Constructor; // the first parameter is the book whose TOC // is being edited, the second is the dialog's parent HeadingSelector::HeadingSelector( QSharedPointer< Book > book, QWidget *parent ) : QDialog( parent ), m_Book( book ) { ui.setupUi( this ); ConnectSignalsToSlots(); ui.tvTOCDisplay->setModel( &m_TableOfContents ); LockHTMLResources(); QList< Headings::Heading > flat_headings = Headings::GetHeadingList( m_Book->GetFolderKeeper().GetResourceTypeList< HTMLResource >( true ), true ); m_Headings = Headings::MakeHeadingHeirarchy( flat_headings ); PopulateSelectHeadingCombo( GetMaxHeadingLevel( flat_headings ) ); CreateTOCModel(); // Set the initial display state if ( ui.cbTOCItemsOnly->checkState() == Qt::Checked ) RemoveExcludedItems( m_TableOfContents.invisibleRootItem() ); UpdateTreeViewDisplay(); ReadSettings(); }
// Switches the display between showing all headings // and showing only headings that are to be included in the TOC void HeadingSelector::ChangeDisplayType(int new_check_state) { // If checked, show only TOC items if (new_check_state == Qt::Checked) { RemoveExcludedItems(m_TableOfContents.invisibleRootItem()); } // If unchecked, show all items else { CreateTOCModel(); UpdateTreeViewDisplay(); } }
void HeadingSelector::UpdateHeadingElements() { // We recreate the model to make sure even those // headings marked as "don't include" are in the model. CreateTOCModel(); UpdateOneHeadingElement(m_TableOfContents.invisibleRootItem()); QStringList ids; foreach (Headings::Heading heading, m_Headings) { ids = UpdateOneFile(heading, ids); }
void HeadingSelector::UpdateHeadingElements() { QApplication::setOverrideCursor(Qt::WaitCursor); // We recreate the model to make sure even those // headings marked as "don't include" are in the model. CreateTOCModel(); // Identify any existing hrefs to an id that will indicate we can't change it QStringList used_ids = m_Book->GetIdsInHrefs(); // Iterate through our headings, applying their changes to the underlying resources // if required, setting ids etc. int next_toc_id = 1; UpdateOneHeadingElement(m_TableOfContents.invisibleRootItem(), used_ids, next_toc_id); // Now iterate through the headings one final time, to save the underlying resources // that we have changed. QStringList ids; foreach(Headings::Heading heading, m_Headings) { ids = UpdateOneFile(heading, ids); }
EditTOC::EditTOC(QSharedPointer<Book> book, QList<Resource *> resources, QWidget *parent) : QDialog(parent), m_Book(book), m_Resources(resources), m_TableOfContents(new QStandardItemModel(this)), m_ContextMenu(new QMenu(this)), m_NCXModel(new NCXModel(this)) { ui.setupUi(this); ui.TOCTree->setContextMenuPolicy(Qt::CustomContextMenu); ui.TOCTree->installEventFilter(this); ui.TOCTree->setModel(m_TableOfContents); ui.TOCTree->setIndentation(COLUMN_INDENTATION); CreateContextMenuActions(); ConnectSignalsToSlots(); CreateTOCModel(); UpdateTreeViewDisplay(); ReadSettings(); }