void KatalogView::slTreeviewItemChanged( QTreeWidgetItem *newItem, QTreeWidgetItem * /* prevItem */ ) { KatalogListView *listview = getListView(); if( !listview ) return; if( ! newItem ) return; bool itemEdit = true; bool itemNew = true; bool chapterNew = false; bool chapterEdit = false; if( listview->isRoot(newItem) ) { // we have the root item, not editable itemEdit = false; itemNew = false; chapterNew = true; } else if( listview->isChapter(newItem) ) { itemEdit = false; chapterNew = true; chapterEdit = true; } m_acEditItem->setEnabled(itemEdit); m_acDeleteItem->setEnabled(itemEdit); m_acNewItem->setEnabled( itemNew ); m_acAddChapter->setEnabled( chapterNew ); m_acEditChapter->setEnabled( chapterEdit ); m_acRemChapter->setEnabled( chapterEdit ); }
void TemplKatalogView::slNewTemplate() { KatalogListView *listView = getListView(); if( !listView ) return; // create new template object FloskelTemplate *flosTempl = new FloskelTemplate(); flosTempl->setText( i18n( "<new template>" ) ); // find the corresponding parent (==chapter) item QTreeWidgetItem *parentItem = static_cast<QTreeWidgetItem*>(listView->currentItem()); if( parentItem ) { // if it is not a chapter nor root, take the parent if( ! (listView->isRoot(parentItem) || listView->isChapter(parentItem)) ) { parentItem = (QTreeWidgetItem*) parentItem->parent(); } } if( parentItem ) { // try to find out which catalog is open/current CatalogChapter *chap = static_cast<CatalogChapter*>( listView->itemData( parentItem ) ); if( chap ) { flosTempl->setChapterId( chap->id().toInt(), true ); } } TemplKatalogListView *templListView = static_cast<TemplKatalogListView*>(listView); QTreeWidgetItem *item = templListView->addFlosTemplate(parentItem, flosTempl); listView->scrollToItem( item ); listView->setCurrentItem( item ); openDialog( item, flosTempl, true ); }