Exemple #1
0
void RDHeaderView::mouseReleaseEvent(QMouseEvent *event)
{
  if(m_movingSection >= 0)
  {
    int mousePos = event->x();
    int idx = logicalIndexAt(mousePos);

    if(idx >= 0)
    {
      int secSize = sectionSize(idx);
      int secPos = sectionPosition(idx);

      int srcSection = visualIndex(m_movingSection);
      int dstSection = visualIndex(idx);

      if(srcSection >= 0 && dstSection >= 0 && srcSection != dstSection)
      {
        // the half-way point of the section decides whether we're dropping to the left
        // or the right of it.
        if(mousePos < secPos + secSize / 2)
        {
          // if we're moving from the left, place it to the left of dstSection
          if(srcSection < dstSection)
            moveSection(srcSection, dstSection - 1);
          else
            moveSection(srcSection, dstSection);
        }
        else
        {
          // if we're moving it from the right, place it to the right of dstSection
          if(srcSection > dstSection)
            moveSection(srcSection, dstSection + 1);
          else
            moveSection(srcSection, dstSection);
        }
      }
    }

    m_sectionPreview->hide();
  }

  m_movingSection = -1;

  if(m_customSizing)
  {
    m_resizeState = qMakePair(NoResize, -1);

    return QAbstractItemView::mouseReleaseEvent(event);
  }

  QHeaderView::mouseReleaseEvent(event);
}
Exemple #2
0
void MailListView::readConfig( QSettings *conf )
{
    if (singleColumnMode()) {
        horizontalHeader()->resizeSection( 0,
                        QApplication::desktop()->availableGeometry().width() );
        horizontalHeader()->hide();
        defineSort(3, false);
    } else {
        int y;
        QString s;
        y = conf->value("mailidcount", -1).toInt();
        for (int x = 0; x < columnCount(); x++) {
            s.setNum(x);
            if ( (y = conf->value("querycol" + s, -1).toInt()) != -1) {
                horizontalHeader()->resizeSection( x, y );
            }
            if ( (y = conf->value("querycollabelpos" + s, -1).toInt()) != -1) {
                if ( y != x)
                    moveSection(x, y);
            }
        }
        int col = conf->value( "querycolsort", 3 ).toInt();
        bool ascend = conf->value( "querycolsortascending", false ).toBool();
        if (col != -1) {
            setByArrival( conf->value( "arrivaldate" ).toBool() );
            defineSort(col, ascend);
        }

        bool hide = conf->value("showheader", false ).toBool();
        if ( hide )
            horizontalHeader()->hide();
    }
}
Exemple #3
0
void TupExposureHeader::moveHeaderSection(int position, int newPosition, bool isLocalRequest)
{
    if (isLocalRequest) {
        m_sectionOnMotion = true;
        moveSection(visualIndex(position), visualIndex(newPosition));
        m_sections.swap(position, newPosition);
        m_sectionOnMotion = false;
    } else {
        m_sections.swap(position, newPosition);
    }
}
Exemple #4
0
/*!
  \reimp
*/
void QHeader::mouseReleaseEvent( QMouseEvent *e )
{
    if ( e->button() != LeftButton )
	return;
    State oldState = state;
    state = Idle;
    switch ( oldState ) {
    case Pressed: {
	int section = d->i2s[handleIdx];
	repaint(sRect( handleIdx ), FALSE);
	emit released( section );
	if ( sRect( handleIdx ).contains( e->pos() ) ) {
	    emit sectionClicked( handleIdx );
	    emit clicked( section );
	}
	} break;
    case Sliding: {
	int c = orient == Horizontal ? e->pos().x() : e->pos().y();
	c += offset();
	handleColumnResize( handleIdx, c, TRUE );
	} break;
    case Moving: {
#ifndef QT_NO_CURSOR
	unsetCursor();
#endif
	int section = d->i2s[handleIdx];
	if ( handleIdx != moveToIdx && moveToIdx != -1 ) {
	    moveSection( section, moveToIdx );
	    repaint(); // a bit overkill, but removes the handle as well
	    emit moved( handleIdx, moveToIdx );
	    emit indexChange( section, handleIdx, moveToIdx );
	    emit released( section );
	} else {
	    repaint(sRect( handleIdx ), FALSE );
	    if ( sRect( handleIdx).contains( e->pos() ) ) {
		emit released( section );
		emit sectionClicked( handleIdx );
		emit clicked( section );
	    }
	}
	break;
    }
    case Blocked:
	//nothing
	break;
    default:
	// empty, probably.  Idle, at any rate.
	break;
    }
}
Exemple #5
0
void QHeader::moveCell( int fromIdx, int toIdx )
{
    moveSection( mapToSection(fromIdx), toIdx );
}
void KTExposureHeader::moveLayer(int position, int newPosition)
{
    m_blockSectionMoved = true;
    moveSection(position, newPosition);
    m_blockSectionMoved = false;
}