void TemplKatalogView::slEditTemplate()
{
  TemplKatalogListView* listview = static_cast<TemplKatalogListView*>(getListView());

  if( listview )
  {
    QTreeWidgetItem *item = listview->currentItem();
    if( listview->isChapter(item) ) {
      // check if the chapter is empty. If so, switch to slNewTempalte()
      // if there others, open the chapter.
      if( !listview->isRoot( item ) && item->childCount() == 0 ) {
        slNewTemplate();
      } else {
        // do nothing.
      }
    } else {
      // the clicked item is not a chapter
      FloskelTemplate *currTempl = static_cast<FloskelTemplate*> (listview->currentItemData());
      if( currTempl ) {
        QTreeWidgetItem *item = (QTreeWidgetItem*) listview->currentItem();
        openDialog( item, currTempl, false );
      }
    }
  }
}
void MaterialKatalogView::slEditTemplate()
{
  MaterialKatalogListView *listview = static_cast<MaterialKatalogListView*>(getListView());
  if( listview )
  {
    QTreeWidgetItem *item = listview->currentItem();
    if( listview->isChapter(item) ) {
      // check if the chapter is empty. If so, switch to slNewTempalte()
      // if there others, open the chapter.
      if( !listview->isRoot( item ) && item->childCount() == 0 ) {
        slNewTemplate();
      } else {
        // do nothing.
      }
    } else {
      kDebug() << "Editing the material" << endl;

      if( listview )
      {
        StockMaterial *currTempl = static_cast<StockMaterial*> ( listview->currentItemData() );
        if( currTempl ) {
          QTreeWidgetItem *item = (QTreeWidgetItem*) listview->currentItem();
          openDialog( item, currTempl, false );
        }
      }
    }
  }
}
Beispiel #3
0
void KatalogView::initActions()
{  
  m_acEditChapter = actionCollection()->addAction( "edit_chapter", this, SLOT( slEditSubChapter() ) );
  m_acEditChapter->setText( i18n("Edit Sub chapter") );
  m_acEditChapter->setIcon( QIcon::fromTheme("folder-documents"));
  m_acEditChapter->setStatusTip(i18n("Edit a catalog sub chapter"));
  m_acEditChapter->setEnabled(true);

  m_acAddChapter = actionCollection()->addAction( "add_chapter", this, SLOT( slAddSubChapter() ) );
  m_acAddChapter->setText( i18n("Add a sub chapter") );
  m_acAddChapter->setIcon( QIcon::fromTheme("document-edit"));
  m_acAddChapter->setStatusTip(i18n("Add a sub chapter below the selected one"));
  m_acAddChapter->setEnabled(false);

  m_acRemChapter = actionCollection()->addAction( "remove_chapter", this, SLOT( slRemoveSubChapter() ) );
  m_acRemChapter->setText( i18n("Remove a sub chapter") );
  m_acRemChapter->setIcon( QIcon::fromTheme("document-edit"));
  m_acRemChapter->setStatusTip(i18n("Remove a sub chapter"));
  m_acRemChapter->setEnabled(false);

  m_acEditItem = actionCollection()->addAction( "edit_template", this, SLOT( slEditTemplate() ) );
  m_acEditItem->setText( i18n("Edit template") );
  m_acEditItem->setIcon( QIcon::fromTheme("document-edit"));
  m_acEditItem->setStatusTip(i18n("Opens the editor window for templates to edit the selected one"));
  m_acEditItem->setEnabled(false);

  m_acNewItem = actionCollection()->addAction( "new_template", this, SLOT( slNewTemplate() ) );
  m_acNewItem->setText( i18n("New template") );
  m_acNewItem->setShortcut( QKeySequence::New );
  m_acNewItem->setIcon( QIcon::fromTheme("document-new"));
  m_acNewItem->setStatusTip(i18n("Opens the editor window for templates to enter a new template"));
  m_acNewItem->setEnabled(true);

  m_acDeleteItem = actionCollection()->addAction( "delete_template", this, SLOT( slDeleteTemplate() ) );
  m_acDeleteItem->setText( i18n("Delete template") );
  m_acDeleteItem->setShortcut( QKeySequence::Delete);
  m_acDeleteItem->setIcon( QIcon::fromTheme("document-delete"));
  m_acDeleteItem->setStatusTip(i18n("Deletes the template"));
  m_acDeleteItem->setEnabled(true);

  m_acExport = actionCollection()->addAction( "export_catalog", this, SLOT( slExport() ) );
  m_acExport->setText( i18n("Export catalog") );
  m_acExport->setStatusTip(i18n("Export the whole catalog as XML encoded file"));
  m_acExport->setEnabled(false); // FIXME: Repair XML Export

  // use the absolute path to your kraftui.rc file for testing purpose in createGUI();
  QString prjPath = QString::fromUtf8(qgetenv( "KRAFT_HOME" ));
  if( !prjPath.isEmpty() ) {
      createGUI(prjPath + QLatin1String("/src/katalogview.rc"));
  } else {
      createGUI("katalogview.rc");
  }

}