/**
 *	@brief	Stops or restarts selection changed notification.
 *	@param[in]	doStop	true to stop, false to restart.
 */
void BeListViewAdapter::StopSelectionChangedNotification(bool doStop)
{
	BListView* listView = getListView();
	if (doStop)
	{
		if (0 == stoppedSelectionChangedNotificationCount)
		{
			BMessage* message = listView->SelectionMessage();
			if (NULL != message)
			{
				stoppedSelectionChangedCommand = message->what;
				message->what = ID_NULL;
			}
		}
		stoppedSelectionChangedNotificationCount++;
	}
	else
	{
		stoppedSelectionChangedNotificationCount--;
		if (0 == stoppedSelectionChangedNotificationCount)
		{
			BMessage* message = listView->SelectionMessage();
			if (NULL != message)
			{
				message->what = stoppedSelectionChangedCommand;
				stoppedSelectionChangedCommand = ID_NULL;
			}
		}
	}
}
void TemplKatalogView::slDeleteTemplate()
{
  kDebug() << "delete template hit";
  TemplKatalogListView* listview = static_cast<TemplKatalogListView*>(getListView());
  if( listview )
  {
    FloskelTemplate *currTempl = static_cast<FloskelTemplate*> (listview->currentItemData());
    if( currTempl ) {
      int id = currTempl->getTemplID();
      if( KMessageBox::questionYesNo( this,
                                     i18n( "Do you really want to delete the template from the catalog?" ),
                                     i18n( "Delete Template" ),
                                     KStandardGuiItem::yes(), KStandardGuiItem::no(), "DeleteTemplate" )
          == KMessageBox::Yes )
      {

        kDebug() << "Delete item with id " << id;
        TemplKatalog *k = static_cast<TemplKatalog*>( getKatalog( m_katalogName ) );

        if( k ) {
          k->deleteTemplate( id );
          listview->removeTemplateItem( listview->currentItem());
        }
      }
    }
  }
}
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 );
}
Exemple #4
0
Katalog* KatalogView::getKatalog( const QString& name )
{

  KatalogMan::self()->registerKatalogListView( name, getListView() );

  return 0;
}
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::slNewTemplate()
{
  KatalogListView *listview = getListView();
  if( !listview ) return;
  MaterialKatalogListView *matListView = static_cast<MaterialKatalogListView*>(listview);

  StockMaterial *newMat = new StockMaterial();
  newMat->setName( i18n( "<new material>" ) );
  QTreeWidgetItem *parentItem = static_cast<QTreeWidgetItem*>( listview->currentItem() );
  if ( parentItem ) {
    if ( ! ( matListView->isRoot( parentItem ) || matListView->isChapter( parentItem ) ) ) {
      parentItem = ( QTreeWidgetItem* ) parentItem->parent();
    }
  }

  if( parentItem && listview->isChapter( parentItem )) {
    // try to find out which catalog is open/current
    CatalogChapter *chap = static_cast<CatalogChapter*>(listview->itemData( parentItem ));
    newMat->setChapter( chap->id().toInt() );
  }

  mNewItem = matListView->addMaterialToView( parentItem, newMat );
  openDialog( mNewItem, newMat, true );

}
Exemple #7
0
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 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 );
        }
      }
    }
  }
}
Exemple #9
0
void KatalogView::slAddSubChapter()
{
  slotStatusMsg( i18n("Creating a new sub chapter..."));
  KatalogListView *listview = getListView();
  if( listview )
    listview->slotCreateNewChapter();
  slotStatusMsg( i18n("Ready."));
}
Exemple #10
0
void KatalogView::slEditSubChapter()
{
  slotStatusMsg( i18n("Editing a sub chapter..."));
  KatalogListView *listview = getListView();
  if( listview )
    listview->slotEditCurrentChapter();
  slotStatusMsg( i18n("Ready."));
}
/**
 *	@brief	Sets associated data of specified index.
 *	@param[in]	index	item index.
 *	@param[in]	data	associated data.
 */
void BeListViewAdapter::SetItemData(SInt32 index, void* data)
{
	BListView* listView = getListView();
	BeGenericDataStringItem* listItem = dynamic_cast<BeGenericDataStringItem*>(listView->ItemAt(index));
	if (NULL != listItem)
	{
		listItem->SetItemData(data);
	}
}
/**
 *	@brief	Sets a string at specified index from the control.
 *	@param[in]	index	index
 *	@param[out]	text	a string value to set.
 */
void BeListViewAdapter::SetItemText(SInt32 index, ConstAStr text)
{
	BListView* listView = getListView();
	BeGenericDataStringItem* listItem = dynamic_cast<BeGenericDataStringItem*>(listView->ItemAt(index));
	if (NULL != listItem)
	{
		listItem->SetText(text);
	}
}
/**
 *	@brief	Removes one item from the control.
 *	@param[in]	index	item index.
 */
void BeListViewAdapter::RemoveItem(SInt32 index)
{
	BListView* listView = getListView();
	BListItem* listItem = listView->RemoveItem(index);
	if (NULL != listItem)
	{
		delete listItem;
	}
}
/**
 *	@brief	Adds one item to the control.
 *	@param[in]	text	item text.
 *	@param[in]	data	associated data of adding item.
 *	@return	the index of added item.
 */
SInt32 BeListViewAdapter::AddItem(ConstAStr text, void* data)
{
	BeGenericDataStringItem* listItem = new BeGenericDataStringItem(text);
	listItem->SetItemData(data);
	
	BListView* listView = getListView();
	listView->AddItem(listItem);
	return listView->CountItems() - 1;
}
/**
 *	@brief	Makes specified item selected.
 *	@param[in]	index	item index. if this is -1, no item is selected.
 */
void BeListViewAdapter::SetSelectedItem(SInt32 index)
{
	BListView* listView = getListView();
	int32 current = listView->CurrentSelection(0);
	if (current != index)
	{
		listView->DeselectAll();
		listView->Select(index);
	}
}
Exemple #16
0
void PlayList::save()
{
    QStringList urlList;
    
    PlayListViewItem* item = dynamic_cast<PlayListViewItem*>( getListView()->topLevelItem(0) );

    while (item) {
        urlList << item->getURL().toString();
//         item = dynamic_cast<PlayListViewItem*>( item->nextSibling() );
        item = dynamic_cast<PlayListViewItem*>( getListView()->itemBelow( item ) );
    }

    QSettings kc ; // was: KGlobal::config()
    
//     KConfigGroupSaver cs(kc, PlayListConfigGroup);    //&&&
    kc.beginGroup( PlayListConfigGroup );
    kc.setValue("Playlist Files", urlList);

//     getListView()->saveLayout(kc, PlayListConfigGroup);    //&&&
    kc.endGroup();
}
/**
 *	@brief	Returns associated data of specified index.
 *	@param[in]	index	item index.
 *	@return	associated data.
 */
void* BeListViewAdapter::GetItemData(SInt32 index)
{
	BListView* listView = getListView();
	BeGenericDataStringItem* listItem = dynamic_cast<BeGenericDataStringItem*>(listView->ItemAt(index));
	if (NULL != listItem)
	{
		return listItem->GetItemData();
	}
	else
	{
		return NULL;
	}
}
/**
 *	@brief	Gets a string at specified index from the control.
 *	@param[in]	index	index
 *	@param[out]	text	a string value is returned.
 */
void BeListViewAdapter::GetItemText(SInt32 index, MBCString& text)
{
	BListView* listView = getListView();
	BStringItem* listItem = dynamic_cast<BStringItem*>(listView->ItemAt(index));
	if (NULL != listItem)
	{
		text = listItem->Text();
	}
	else
	{
		text.Empty();
	}
}
/**
 *	@brief	Returns an index of selected item.
 *	@return	item index of selected item. or -1 if no item is selected.
 */
SInt32 BeListViewAdapter::GetSelectedItem()
{
	BListView* listView = getListView();
	int32 ret = listView->CurrentSelection(0);
	if (ret < 0)
	{
		return -1;
	}
	else
	{
		return ret;
	}
}
/**
 *	@brief	Removes all item from the control.
 */
void BeListViewAdapter::RemoveAllItem()
{
	BListView* listView = getListView();
	int32 count = listView->CountItems();
	int32 index;
	for (index = count - 1; index >= 0; index--)
	{
		BListItem* listItem = listView->RemoveItem(index);
		if (NULL != listItem)
		{
			delete listItem;
		}
	}
}
CalcPartList TemplKatalogView::currentItemsCalcParts()
{
  TemplKatalogListView* listview = static_cast<TemplKatalogListView*>(getListView());
  CalcPartList cpList;

  if( listview )
  {
    FloskelTemplate *currTempl = static_cast<FloskelTemplate*> (listview->currentItemData());
    if ( currTempl ) {
      cpList = currTempl->getCalcPartsList();
    }
  }
  return cpList;
}
/**
 *	@brief	Makes the control enabled or disabled.
 *	@param[in]	doEnable	true to enable the control, or false to disable the control.
 */
void BeListViewAdapter::Enable(bool doEnable)
{
	BListView* listView = getListView();
	int32 count = listView->CountItems();
	int32 index;
	for (index = 0; index < count; index++)
	{
		BListItem* listItem = listView->ItemAt(index);
		listItem->SetEnabled(doEnable);
	}
	listView->LockLooper();
	listView->Invalidate();
	listView->UnlockLooper();
	
	isEnabled = doEnable;
}
Exemple #23
0
void KatalogView::init(const QString& katName )
{
  m_katalogName = katName;
  initActions();

  ///////////////////////////////////////////////////////////////////
  // set up a vertical layout box
  QWidget *w = new QWidget(this);
  QBoxLayout *box = new QVBoxLayout(w);

  // start to set up the listview
  createCentralWidget(box, w);
  KatalogListView *listview = getListView();

  if( ! listview ) {
      // qDebug () << "ERROR: No listview created !!!" << endl;
  } else {
      m_filterHead = new FilterHeader(w, listview);
      box->insertWidget(0, m_filterHead);

      connect( listview, SIGNAL(currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem*)),
               this, SLOT(slTreeviewItemChanged( QTreeWidgetItem*, QTreeWidgetItem*)) );
      connect( listview, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
               this, SLOT(slEditTemplate()));
      connect( listview, SIGNAL(templateHoovered(CatalogTemplate*)),
               this, SLOT(slotShowTemplateDetails( CatalogTemplate*)));

      // Populate the context Menu
      (listview->contextMenu())->addAction( m_acEditItem );
      (listview->contextMenu())->addAction( m_acNewItem );
      (listview->contextMenu())->addAction( m_acDeleteItem );
      (listview->contextMenu())->addSeparator();
      (listview->contextMenu())->addAction( m_acAddChapter );
      (listview->contextMenu())->addAction( m_acEditChapter );
      (listview->contextMenu())->addAction( m_acRemChapter );
      getKatalog( katName );
      listview->addCatalogDisplay( katName );
  }

  setCentralWidget(w);
  m_editListViewItem = 0;
  // qDebug () << "Getting katalog!" << katName << endl;

  setAutoSaveSettings( QString::fromLatin1( "CatalogWindow" ),  true );
}
Exemple #24
0
void KatalogView::createCentralWidget(QBoxLayout *box, QWidget* )
{

  mTemplateText = new QLabel( "Nothing selected.");
  box->addWidget( mTemplateText );
  QHBoxLayout *hb = new QHBoxLayout;
  box->addLayout( hb );
  mTemplateStats = new QLabel( );
  mProgress = new QProgressBar;
  hb->addWidget( mTemplateStats );
  hb->addStretch();
  hb->addWidget( mProgress );

  connect( getListView(), SIGNAL( sequenceUpdateMaximum( int )),
           mProgress, SLOT( setMaximum(int) ) );
  connect( getListView(), SIGNAL( sequenceUpdateProgress( int ) ),
           this, SLOT( setProgressValue(int) ) );
}
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 #26
0
void PlayList::restore()
{
    QSettings kc ; // was: KGlobal::config()
//     getListView()->restoreLayout(kc, PlayListConfigGroup);    //&&&

//     KConfigGroupSaver cs(kc, PlayListConfigGroup);
    kc.beginGroup(PlayListConfigGroup);
    QStringList urlList = kc.value("Playlist Files").toStringList();
    QString ss;
    
    for( int i=0; i< urlList.count(); i ++ ){
        ss = urlList.at( i );
        new PlayListViewItem( getListView(), QUrl(ss) );
    }
    /*
    for (QStringList::Iterator it = urlList.begin();
            it != urlList.end(); ++it) {
        new PlayListViewItem(getListView(), QUrl(*it));
    }
    */
    kc.endGroup();
}
void MaterialKatalogView::slotEditOk( StockMaterial *mat )
{
  KatalogListView *listview = getListView();
  if( !listview ) return;
  MaterialKatalogListView *templListView = static_cast<MaterialKatalogListView*>(listview);
  kDebug() << "****** slotEditOk for Material" << endl;

  if( mDialog ) {
    MatKatalog *k = static_cast<MatKatalog*>( getKatalog( MaterialCatalogName ) );
    if ( mDialog->templateIsNew() ) {
      KLocale *locale = 0;
      if ( k ) {
        k->addNewMaterial( mat );
        locale = k->locale();
      }
      if( mNewItem ) {
        mNewItem->setSelected( true );
        templListView->slFreshupItem( mNewItem, mat, locale );
        // templListView->ensureItemVisible( mNewItem );
      }
    }
  }
  mNewItem = 0;
}
/**
 *	@brief	Returns item count in the control.
 *	@return	item count.
 */
SInt32 BeListViewAdapter::GetCount()
{
	BListView* listView = getListView();
	return listView->CountItems();
}