예제 #1
0
void SelectorWidget::mouseReleaseEvent(QMouseEvent *event)
{
  int flag = flagAt(event->x(), event->y());

  if (event->button()==Qt::LeftButton) {
    selected_ = flag;
    if (only_one_) {
      for (auto &q : my_items_)
        q.visible = false;
      if ((flag > -1) && (flag < my_items_.size()))
        my_items_[flag].visible = true;
    }
    update();
    if ((flag > -1) && (flag < my_items_.size()))
      emit itemSelected(my_items_[flag]);
    else
      emit itemSelected(SelectorItem());
  }

  if ((!only_one_) && (event->button()==Qt::RightButton) && (flag > -1) && (flag < my_items_.size())) {
    my_items_[flag].visible = !my_items_[flag].visible;
    update();
    emit itemToggled(my_items_[flag]);
  }
}
예제 #2
0
void SelectorWidget::mouseDoubleClickEvent(QMouseEvent *event)
{
  int flag = flagAt(event->x(), event->y());

  if (event->button()==Qt::LeftButton) {
    selected_ = flag;
    update();
    if ((flag > -1) && (flag < my_items_.size()))
      emit itemDoubleclicked(my_items_[flag]);
    else
      emit itemDoubleclicked(SelectorItem());
  }

//  if ((event->button()==Qt::RightButton) && (flag > -1) && (flag < my_items_.size())) {
//    emit itemDoubleclicked(my_items_[flag]);
//  }
}
예제 #3
0
void	ZKMORHP_SelectorControl::Initialize()
{
	//	clear the current items
	mSelectorMap.clear();
	
	//	Insert items into mSelectorMap for all the items in this control. Here, we just stick in a
	//	few fake items.
	for(UInt32 theItemIndex = 0; theItemIndex < 4; ++theItemIndex)
	{
		//	make a name for the item
		CACFString theName(CFStringCreateWithFormat(NULL, NULL, CFSTR("Item %u"), theItemIndex));
		
		//	insert it into the map, using the item index as the item ID
		mSelectorMap.insert(SelectorMap::value_type(theItemIndex, SelectorItem(theName.CopyCFString(), 0)));
	}
	
	//	cache the current item ID
	CacheCurrentItemID();
}
예제 #4
0
SelectorItem SelectorWidget::selected() {
  if ((selected_ > -1) && (selected_ < my_items_.size()))
    return my_items_[selected_];
  else
    return SelectorItem();
}