bool TemplKatalogView::currentItemToDocPosition( DocPosition& pos )
{
  TemplKatalogListView* listview = static_cast<TemplKatalogListView*>(getListView());
  bool res = false;
  if( listview )
  {
    FloskelTemplate *currTempl = static_cast<FloskelTemplate*> (listview->currentItemData());
    if( currTempl ) {
      // create a new position and offer it to the document manager
      pos.setText( currTempl->getText() );
      pos.setUnit( currTempl->unit() );
      pos.setUnitPrice( currTempl->unitPrice() );
      pos.setAmount( 1.0 );
      res = true;
    }
  }
  return res;
}
Exemple #2
0
DocPosition TemplKatalogListView::itemToDocPosition( QTreeWidgetItem *it )
{
  DocPosition pos;
  if ( ! it ) {
    it = currentItem();
  }

  if ( ! it ) return pos;

  FloskelTemplate *flos = it->data(0, Qt::UserRole).value<FloskelTemplate*>();

  if ( flos ) {
    pos.setText( flos->getText() );
    pos.setUnit( flos->unit() );
    pos.setUnitPrice( flos->unitPrice() );
  } else {
    kDebug() << "Can not find a template for the item" << endl;
  }

  return pos;
}
DocPosition TemplKatalogListView::itemToDocPosition( QTreeWidgetItem *it )
{
  DocPosition pos;
  if ( ! it ) {
    it = currentItem();
  }

  if ( ! it ) return pos;

  FloskelTemplate *flos = static_cast<FloskelTemplate*>( m_dataDict[ it ] );

  if ( flos ) {
    pos.setText( flos->getText() );
    pos.setUnit( flos->unit() );
    pos.setUnitPrice( flos->unitPrice() );
  } else {
    // qDebug () << "Can not find a template for the item" << endl;
  }

  return pos;
}