Exemplo n.º 1
0
bool Model::Bonus::isCollides(Food *food, QVector<SnakePart *> *snake, QVector<Wall *> *walls) {
    if (isCollapsed(this, food)) return true;
    for (int j = 0; j<snake->size();j++) {
        if (isCollapsed(this, snake->at(j))) return true;
    }
    for (int j = 0; j<walls->size();j++) {
        if (isCollapsed(this, walls->at(j))) return true;
    }
}
void QgsCollapsibleGroupBox::checkToggled( bool chkd )
{
  mCollapseButton->setEnabled( true ); // always keep enabled
  // expand/collapse when toggled
  if ( chkd && isCollapsed() )
    setCollapsed( false );
  else if ( ! chkd && ! isCollapsed() )
    setCollapsed( true );
}
Exemplo n.º 3
0
Model::ObjectType Model::SnakePart::collidesWith(
        Food *food, Bonus *bonus, QVector<SnakePart *> *snake, QVector<Wall *> *walls) {
    if (isCollapsed(this, bonus)) return Model::BONUS;
    if (isCollapsed(this, food)) return Model::FOOD;
    for (int j = 0; j<walls->size();j++) {
        if (isCollapsed(this, walls->at(j))) return Model::WALL;
    }
    for (int j = 1; j<snake->size();j++) {
        if (isCollapsed(this, snake->at(j))) return Model::SNAKE_PART;
    }


}
Exemplo n.º 4
0
void TimeScene::drawTimeLog(const QModelIndex &index) {
    Task* task = _model->task(index);

    std::vector<TaskLog*> *logs = NULL;
    int groupLevel = 2;
    if (task != NULL) {
        logs = task->logs(true);
        groupLevel = (task->childCount() > 0) ? 1 : 2;
    } else {
        Project* project = _model->project(index);
        if (project != NULL) {
            logs = project->logs();
            groupLevel = 0;
        }
    }
    if ((logs != NULL) && (logs->size() != 0)) {
        std::sort(logs->begin(), logs->end(), compareTaskLog);

        DateTime* currentDay = NULL;
        DTime currentTime(0);

        for (std::vector<TaskLog*>::iterator iter = logs->begin(); iter != logs->end(); iter++) {
            TaskLog* log = *iter;
            DateTime logDate(log->start->getYear(), log->start->getMonth(), log->start->getDay());
            if (currentDay == NULL) {
                currentDay = new DateTime(logDate.toDouble());
                currentTime = (*log->end - *log->start);
            } else if (logDate == *currentDay) {
                currentTime = currentTime + (*log->end - *log->start);
            } else {
                drawTime(*currentDay, currentTime, index, groupLevel);
                if (currentDay != NULL) {
                    delete(currentDay);
                    currentDay = NULL;
                }
                currentDay = new DateTime(logDate.toDouble());
                currentTime = (*log->end - *log->start);
            }
        }
        if (currentTime.totalSecs() != 0) {
            drawTime(*currentDay, currentTime, index, groupLevel);
        }
        if (currentDay != NULL) {
            delete(currentDay);
            currentDay = NULL;
        }
    }
    _currentY += sizeHint(index).height();
    if (!isCollapsed(index)) {
        for (int x = 0; x < _model->rowCount(index); x++) {
            QModelIndex child = _model->index(x, 0, index);
            if (child.isValid()) {
                drawIndex(child);
            }
        }
    }
    if (logs != NULL) {
        delete(logs);
    }
}
bool fl_ContainerLayout::canContainPoint() const
{
	if(isCollapsed())
		return false;

	FV_View* pView = getDocLayout()->getView();
	bool bShowHidden = pView->getShowPara();

	bool bHidden = ((m_eHidden == FP_HIDDEN_TEXT && !bShowHidden)
	              || m_eHidden == FP_HIDDEN_REVISION
		          || m_eHidden == FP_HIDDEN_REVISION_AND_TEXT);

	if(bHidden)
		return false;
	
	if(!_canContainPoint())
		return false;

	// see if we are not inside a containing layout that cannot contain point
	fl_ContainerLayout * pMyLayout = myContainingLayout();

	if(!pMyLayout || pMyLayout->getContainerType() == FL_CONTAINER_DOCSECTION)
		return true;
	
	return pMyLayout->canContainPoint();
}
Exemplo n.º 6
0
QSize
CQGroupBox::
minimumSizeHint() const
{
  QFontMetrics fm(titleFont_);

  int baseWidth  = fm.width(title_) + 4;
  int baseHeight = fm.height();

  if (isCheckable())
    baseWidth += fm.height() + 4;

  if (isCollapsible())
    baseWidth += fm.height();

  QSize size;

  if (! isCollapsed()) {
    QStyleOptionGroupBox option;

    size = style()->sizeFromContents(QStyle::CT_GroupBox, &option,
                                     QSize(baseWidth, baseHeight), this);
  }
  else {
    size = QSize(baseWidth, baseHeight);
  }

  return size.expandedTo(QWidget::minimumSizeHint());
}
Exemplo n.º 7
0
void
CQGroupBox::
mouseReleaseEvent(QMouseEvent *e)
{
  if (isCheckable()) {
    bool inside = checkRect_.contains(e->pos()) || titleRect_.contains(e->pos());

    if (inside) {
      setChecked(! isChecked());

      checkPress_ = false;

      emit clicked(isChecked());

      update();
    }
  }

  if (isCollapsible()) {
    bool inside = collapseRect_.contains(e->pos());

    if (inside) {
      setCollapsed(! isCollapsed());

      collapsePress_ = false;

      update();
    }
  }

  QWidget::mouseReleaseEvent(e);
}
Exemplo n.º 8
0
void CollapsibleWidget::saveSettings(QSettings *pSettings) const
{
    // Keep track of our collapsable state

    for (int i = 0, iMax = mHeaders.count(); i < iMax; ++i)
        pSettings->setValue(SettingsCollapsed.arg(i), isCollapsed(i));
}
Exemplo n.º 9
0
Arquivo: WPanel.C Projeto: NovaWova/wt
void WPanel::setCollapsible(bool on)
{
  if (on && !collapseIcon_) {
    std::string resources = WApplication::relativeResourcesUrl();

    setTitleBar(true);
    collapseIcon_ = new WIconPair(resources + "collapse.gif",
				  resources + "expand.gif");
    collapseIcon_->setFloatSide(Left);
    
    WApplication *app = WApplication::instance();
    app->theme()->apply(this, collapseIcon_, PanelCollapseButtonRole);

    titleBarWidget()->insertWidget(0, collapseIcon_);

    collapseIcon_->icon1Clicked().connect(this, &WPanel::doCollapse);
    collapseIcon_->icon1Clicked().connect(this, &WPanel::onCollapse);
    collapseIcon_->icon1Clicked().preventPropagation();
    collapseIcon_->icon2Clicked().connect(this, &WPanel::doExpand);
    collapseIcon_->icon2Clicked().connect(this, &WPanel::onExpand);
    collapseIcon_->icon2Clicked().preventPropagation();
    collapseIcon_->setState(isCollapsed() ? 1 : 0);

    titleBarWidget()->clicked().connect(this, &WPanel::toggleCollapse);

  } else if (!on && collapseIcon_) {
    delete collapseIcon_;
    collapseIcon_ = 0;
  }
}
Exemplo n.º 10
0
Arquivo: WPanel.C Projeto: NovaWova/wt
void WPanel::doExpand()
{
  wasCollapsed_ = isCollapsed();

  centralArea()->animateShow(animation_);

  expandedSS_.emit(true);
}
Exemplo n.º 11
0
void
CQDividedAreaWidget::
updateState()
{
  w_->setVisible(! isCollapsed());

  titleWidget_->updateState();
}
Exemplo n.º 12
0
Arquivo: WPanel.C Projeto: NovaWova/wt
void WPanel::doCollapse()
{
  wasCollapsed_ = isCollapsed();

  centralArea()->animateHide(animation_);

  collapsedSS_.emit(true);
}
Exemplo n.º 13
0
void AMActionRunnerQueueView3::collapse(bool doCollapse)
{
	bool wasCollapsed = isCollapsed();
	treeView_->setHidden(doCollapse);
	isCollapsed_ = doCollapse;

	if(isCollapsed_ != wasCollapsed)
		emit collapsed(doCollapse);
}
void QgsCollapsibleGroupBox::saveState()
{
  if ( ! mSaveState )
    return;
  QSettings settings;
  QString key = saveKey();
  settings.setValue( key + "/checked", isChecked() );
  settings.setValue( key + "/collapsed", isCollapsed() );
}
Exemplo n.º 15
0
//=========================================================================
void TreeTaxNode::setCollapsed(bool b, bool updateGnode)
{
    if ( isCollapsed() == b )
        return;
    setFlag(flags, TTN_COLLAPSED, b);
    TaxTreeGraphNode *ttgnode = getTaxTreeGNode();
    if ( ttgnode != NULL && updateGnode )
        ttgnode->onNodeCollapsed(b);
    getTaxNodeSignalSender(this)->CollapsedChanged(b);
}
Exemplo n.º 16
0
void QgsCollapsibleGroupBox::saveState()
{
  if ( !isEnabled() || ( !mSaveCollapsedState && !mSaveCheckedState ) )
    return;

  QSettings settings;
  QString key = saveKey();

  if ( mSaveCheckedState )
    settings.setValue( key + "/checked", isChecked() );
  if ( mSaveCollapsedState )
    settings.setValue( key + "/collapsed", isCollapsed() );
}
Exemplo n.º 17
0
void
CQGroupBox::
setCollapsed(bool collapsed)
{
  if (collapsed != collapsed_) {
    collapsed_ = collapsed;

    if (isCollapsible()) {
      updateCollapsed();

      emit collapse(isCollapsed());

      update();
    }
  }
}
Exemplo n.º 18
0
void QMacSplitter::collapse(int index)
{
    if (isCollapsed()) expand();
    collapseIndex=index;
    expandIndex=-1;
    expandedMaxSize=widget(index)->maximumSize();
    expandedMinSize=widget(index)->minimumSize();
    if (!isVisible())
    {
        if (this->handle(0)->orientation()==Qt::Horizontal)
        {
            expandedSize=widget(index)->width();
            widget(index)->setMaximumWidth(0);
            widget(index)->setMinimumWidth(0);
        }
        else
        {
            expandedSize=widget(index)->height();
            widget(index)->setMaximumHeight(0);
            widget(index)->setMinimumHeight(0);
        }
        return;
    }
    a1->setTargetObject(widget(index));
    a2->setTargetObject(widget(index));
    if (this->handle(0)->orientation()==Qt::Horizontal)
    {
        expandedSize=widget(index)->width();
        a1->setPropertyName("maximumWidth");
        a1->setStartValue(widget(index)->width());
        a1->setEndValue(0);
        a2->setPropertyName("minimumWidth");
        a2->setStartValue(widget(index)->width());
        a2->setEndValue(0);
    }
    else
    {
        expandedSize=widget(index)->height();
        a1->setPropertyName("maximumHeight");
        a1->setStartValue(widget(index)->height());
        a1->setEndValue(0);
        a2->setPropertyName("minimumHeight");
        a2->setStartValue(widget(index)->height());
        a2->setEndValue(0);
    }
    anim->start();
}
Exemplo n.º 19
0
void DOMSelection::deleteFromDocument()
{
    if (!m_frame)
        return;

    FrameSelection* selection = m_frame->selection();

    if (selection->isNone())
        return;

    if (isCollapsed())
        selection->modify(FrameSelection::AlterationExtend, DirectionBackward, CharacterGranularity);

    RefPtr<Range> selectedRange = selection->selection().toNormalizedRange();
    if (!selectedRange)
        return;

    selectedRange->deleteContents(ASSERT_NO_EXCEPTION);

    setBaseAndExtent(selectedRange->startContainer(ASSERT_NO_EXCEPTION), selectedRange->startOffset(), selectedRange->startContainer(), selectedRange->startOffset(), ASSERT_NO_EXCEPTION);
}
Exemplo n.º 20
0
void DOMSelection::deleteFromDocument()
{
    if (!m_frame)
        return;

    SelectionController* selection = m_frame->selection();

    if (selection->isNone())
        return;

    if (isCollapsed())
        selection->modify(SelectionController::EXTEND, SelectionController::BACKWARD, CharacterGranularity);

    RefPtr<Range> selectedRange = selection->selection().toNormalizedRange();

    ExceptionCode ec = 0;
    selectedRange->deleteContents(ec);
    ASSERT(!ec);

    setBaseAndExtent(selectedRange->startContainer(ec), selectedRange->startOffset(ec), selectedRange->startContainer(ec), selectedRange->startOffset(ec), ec);
    ASSERT(!ec);
}
Exemplo n.º 21
0
void
CQGroupBox::
updateCollapsed()
{
  //area_->setVisible(isCollapsed());

  QObjectList childList = children();

  for (int i = 0; i < childList.size(); ++i) {
    QObject *o = childList.at(i);

    if (! o->isWidgetType()) continue;

    QWidget *w = static_cast<QWidget *>(o);

    w->setVisible(! isCollapsed());
  }

  QSize size = this->size();

  size.setHeight(minimumSizeHint().height());

  resize(size);
}
Exemplo n.º 22
0
void
CQGroupBox::
paintEvent(QPaintEvent *)
{
  QPainter p(this);

  p.setRenderHints(QPainter::Antialiasing);

  p.fillRect(rect(), QBrush(palette().color(QPalette::Background)));

  QFontMetrics fm(titleFont_);

  // set check size
  int checkSize = (isCheckable() ? fm.height() + 4 : 0);

  // set collapse size
  int collapseSize = (isCollapsible() ? fm.ascent() : 0);

  // set text position
  int textX = 0;

  int tw = (title_ != "" ? fm.width(title_) : 0);

  if      (titleAlignment_ & Qt::AlignRight)
    textX = width() - dx_ - tw - collapseSize;
  else if (titleAlignment_ & Qt::AlignHCenter)
    textX = (width() - tw - checkSize - collapseSize)/2 + checkSize;
  else if (titleAlignment_ & Qt::AlignLeft)
    textX = dx_ + checkSize;

  int textY = 0;

  if      (titleAlignment_ & Qt::AlignBottom)
    textY = spaceTop() - fm.descent() - 2;
  else if (titleAlignment_ & Qt::AlignTop)
    textY = fm.ascent() + 2;
  else if (titleAlignment_ & Qt::AlignVCenter)
    textY = spaceTop()/2 + fm.descent() + 2;

  // set check position
  int checkX = textX - checkSize;
  int checkY = textY - fm.ascent()/2;

  // set collapse position
  int collapseX = width() - collapseSize;
  int collapseY = textY - fm.ascent()/2;

  // draw top line
  if (hasLineTop()) {
    int lineY;

    if      (lineTopAlignment_ & Qt::AlignTop)
      lineY = 2;
    else if (lineTopAlignment_ & Qt::AlignVCenter)
      lineY = spaceTop()/2;
    else
      lineY = spaceTop() - 2;

    p.setPen(lineColor_);

    p.drawLine(dx_, lineY, width() - 2*dx_, lineY);
  }

  // draw title
  if (title_ != "") {
    p.setFont(titleFont_);

    int tw1 = width() - checkSize - collapseSize - 4*dx_;

    int tw2 = std::min(tw, tw1);

    titleRect_ = QRect(textX - dx_, textY - fm.ascent() + fm.descent(), tw2 + dx_, fm.height());

    p.fillRect(titleRect_, QBrush(palette().color(QPalette::Background)));

    if (isEnabled())
      p.setPen(palette().color(QPalette::Active, QPalette::WindowText));
    else
      p.setPen(palette().color(QPalette::Disabled, QPalette::WindowText));

    p.drawText(textX, textY, title_);
  }

  // draw bottom line
  if (lineBottom_) {
    int lineY;

    if      (lineTopAlignment_ & Qt::AlignTop)
      lineY = height() - spaceBottom() + 2;
    else if (lineTopAlignment_ & Qt::AlignVCenter)
      lineY = height() - spaceBottom()/2;
    else
      lineY = height() - 2;

    p.setPen(lineColor_);

    p.drawLine(dx_, lineY, width() - 2*dx_, lineY);
  }

  //------

  // draw check (if checkable)
  if (isCheckable()) {
    int checkX1    = checkX + 2;
    int checkSize1 = checkSize - 4;
    int checkY1    = checkY - checkSize1/2;

    checkRect_ = QRect(checkX1, checkY1, checkSize1, checkSize1);

    p.fillRect(QRect(checkX1 - 2, checkY1 - 2, checkSize1 + 4, checkSize1 + 4),
               QBrush(palette().color(QPalette::Background)));

    QStylePainter p(this);

    QStyleOptionButton opt;

    opt.initFrom(this);

    opt.rect = checkRect_;

    opt.state |= (isChecked() ? QStyle::State_On : QStyle::State_Off);

    if (checkPress_)
      opt.state |= QStyle::State_Sunken;

#if 0
    if (testAttribute(Qt::WA_Hover) && underMouse()) {
      if (d->hovering)
        opt.state |= QStyle::State_MouseOver;
      else
        opt.state &= ~QStyle::State_MouseOver;
    }

    opt.text = d->text;
    opt.icon = d->icon;
    opt.iconSize = iconSize();
#endif

    p.drawControl(QStyle::CE_CheckBox, opt);
  }

  //------

  // draw collpase state (if collapsible)
  if (isCollapsible()) {
    double collapseSize1 = collapseSize - 4;

    double collapseX1 = collapseX + 2;
    double collapseY1 = collapseY - collapseSize1/2;
    double collapseX2 = collapseX1 + collapseSize1;
    double collapseY2 = collapseY1 + collapseSize1;

    collapseRect_ = QRect(collapseX1, collapseY1, collapseSize1, collapseSize1);

    p.fillRect(QRect(collapseX1 - 2, collapseY1 - 2, collapseSize1 + 4, collapseSize1 + 4),
               QBrush(palette().color(QPalette::Background)));

    double collapseXM = (collapseX1 + collapseX2)/2;
    double collapseYM = (collapseY1 + collapseY2)/2;

    p.setPen(Qt::NoPen);

    if (collapsePress_)
      p.setBrush(palette().color(QPalette::Active, QPalette::Dark));
    else
      p.setBrush(palette().color(QPalette::Active, QPalette::Text));

    if (! isCollapsed()) {
      drawArcShape(&p, collapseXM, collapseYM, collapseSize1/2, 90, 3);
    }
    else {
      drawArcShape(&p, collapseXM, collapseYM, collapseSize1/2, -90, 3);
    }
  }
}
bool fl_ContainerLayout::isOnScreen() const
{
	// we check if any of our containers is on screen
	// however, we will not call fp_Container::isOnScreen() to avoid
	// unnecessary overhead

	if(isCollapsed())
		return false;

	UT_return_val_if_fail(getDocLayout(),false);
	
	FV_View *pView = getDocLayout()->getView();

	bool bShowHidden = pView && pView->getShowPara();

	bool bHidden = ((m_eHidden == FP_HIDDEN_TEXT && !bShowHidden)
	              || m_eHidden == FP_HIDDEN_REVISION
		          || m_eHidden == FP_HIDDEN_REVISION_AND_TEXT);


	if(bHidden)
		return false;
	
	UT_GenericVector<UT_Rect*> vRect;
	UT_GenericVector<fp_Page*> vPages;

	pView->getVisibleDocumentPagesAndRectangles(vRect, vPages);

	UT_uint32 iCount = vPages.getItemCount();

	if(!iCount)
		return false;
	
	bool bRet = false;
	fp_Container * pC = getFirstContainer();

	if(!pC)
		return false;

	fp_Container *pCEnd = getLastContainer();

	while(pC)
	{
		fp_Page * pMyPage = pC->getPage();

		if(pMyPage)
		{
			for(UT_uint32 i = 0; i < iCount; i++)
			{
				fp_Page * pPage = vPages.getNthItem(i);

				if(pPage == pMyPage)
				{
					UT_Rect r;
					UT_Rect *pR = vRect.getNthItem(i);

					if(!pC->getPageRelativeOffsets(r))
						break;
				
					bRet = r.intersectsRect(pR);
					break;
				}
		
			}
		}

		if(bRet || pC == pCEnd)
			break;

		pC = static_cast<fp_Container*>(pC->getNext());
	}
	
	UT_VECTOR_PURGEALL(UT_Rect*,vRect);
	return bRet;
}
Exemplo n.º 24
0
QGraphicsItem* LogScene::getGroupItem(const QModelIndex &index) {
//    Project* project = _model->project(index);
//    Task* task = _model->task(index);

//    DateTime* startDate = NULL;
//    DateTime* endDate = NULL;
//    if (task != NULL) {
//        startDate = task->startDate();
//        endDate = task->endDate();
//    } else {
//        if (project != NULL) {
//            startDate = project->startDate();
//            endDate = project->endDate();
//        } else {
//            startDate = &_startDate;
//            endDate = &_endDate;
//        }
//    }
//    // Only print group header for projects (not for summary)
//    if (project != NULL) {
//        int days = startDate->daysTo(*endDate) + 1;

//        QPen pblack(QColor("black"));
//        QBrush bblack(QColor("black"));

//        QSize size = sizeHint(index);

//        int daysToStart = _startDate.daysTo(*startDate);
//        int x1 = daysToStart * _dayWidth;
//        int y1 = _currentY + size.height() - 10;

//        int x2 = x1 + (days * _dayWidth);
//        int y2 = _currentY + size.height() - 6;

//        QGraphicsItem* item = addRect(x1 - 4, y1, (x2 - x1) + 8, (y2 - y1), pblack, bblack);
//        item->setZValue(1);
//        QVector<QPointF> trian1;
//        trian1 << QPointF(x1 - 4, y2);
//        trian1 << QPointF(x1, y2 + 4);
//        trian1 << QPointF(x1 + 4, y2);
//        QPolygonF poly1(trian1);
//        item = addPolygon(poly1, pblack, bblack);
//        item->setZValue(1);

//        QVector<QPointF> trian2;
//        trian2 << QPointF(x2 - 4 , y2);
//        trian2 << QPointF(x2, y2 + 4);
//        trian2 << QPointF(x2 + 4, y2);
//        QPolygonF poly2(trian2);

//        item = addPolygon(poly2, pblack, bblack);
//        item->setZValue(1);

//    }
    Task* task = _model->task(index);
    if (task != NULL) {
        getTaskItem(index);
    }
    _currentY += sizeHint(index).height();
    if (!isCollapsed(index)) {
        for (int x = 0; x < _model->rowCount(index); x++) {
            QModelIndex child = _model->index(x, 0, index);
            if (child.isValid()) {
                drawIndex(child);
            }
        }
    }
}
Exemplo n.º 25
0
Arquivo: WPanel.C Projeto: NovaWova/wt
void WPanel::toggleCollapse()
{
  setCollapsed(!isCollapsed());
}