예제 #1
0
void KexiBlobTableEdit::updateFocus(const QRect& r)
{
    if (!d->readOnly) {
        if (d->button->width() > r.width())
            moveChild(d->button, r.right() + 1, r.top());
        else
            moveChild(d->button, r.right() - d->button->width(), r.top());
    }
}
예제 #2
0
// internal
void KexiComboBoxTableEdit::updateFocus(const QRect& r)
{
    if (!column()->isReadOnly()) {
        if (d->button->width() > r.width())
            moveChild(d->button, r.right() + 1, r.top());
        else
            moveChild(d->button, r.right() - d->button->width(), r.top());
    }
}
void KexiSimplePrintPreviewScrollView::setFullWidth()
{
    viewport()->setUpdatesEnabled(false);
    double widthMM = KoPageFormat::width(
                         m_window->settings().pageLayout.format,
                         m_window->settings().pageLayout.orientation);
    double heightMM = KoPageFormat::height(
                          m_window->settings().pageLayout.format, m_window->settings().pageLayout.orientation);
// int constantWidth = m_window->width()- KexiSimplePrintPreviewScrollView_MARGIN*6;
    double constantWidth = width() - KexiSimplePrintPreviewScrollView_MARGIN * 6;
    double heightForWidth = constantWidth * heightMM / widthMM;
// heightForWidth = qMin(kapp->desktop()->height()*4/5, heightForWidth);
    kDebug() << "1: " << heightForWidth;
#if 0 //todo we can use this if we want to fix the height to width of the page
    heightForWidth = qMin(height(), heightForWidth);
    kDebug() << "2: " << heightForWidth;
#endif
    constantWidth = heightForWidth * widthMM / heightMM;
    widget->resize((int)constantWidth, (int)heightForWidth); //keep aspect
    resizeContents(int(widget->width() + 2*KexiSimplePrintPreviewScrollView_MARGIN),
                   int(widget->height() + 2*KexiSimplePrintPreviewScrollView_MARGIN));
    moveChild(widget, (contentsWidth() - widget->width()) / 2,
              (contentsHeight() - widget->height()) / 2);
    viewport()->setUpdatesEnabled(true);
    resize(size() + QSize(1, 1)); //to update pos.
    widget->enablePainting = true;
    widget->repaint();
}
예제 #4
0
    void reorderChildren (const OwnedArray<ValueTree>& newOrder, UndoManager* undoManager)
    {
        jassert (newOrder.size() == children.size());

        if (undoManager == nullptr)
        {
            children.clear();
            children.ensureStorageAllocated (newOrder.size());

            for (int i = 0; i < newOrder.size(); ++i)
                children.add (newOrder.getUnchecked(i)->object);

            sendChildOrderChangedMessage();
        }
        else
        {
            for (int i = 0; i < children.size(); ++i)
            {
                SharedObject* const child = newOrder.getUnchecked(i)->object;

                if (children.getObjectPointerUnchecked (i) != child)
                {
                    const int oldIndex = children.indexOf (child);
                    jassert (oldIndex >= 0);
                    moveChild (oldIndex, i, undoManager);
                }
            }
        }
    }
예제 #5
0
파일: Container.cpp 프로젝트: Lectem/luib
 void Container::move(int x, int y)
 {
     Element::move(x, y);
     for(Element_shared_ptr e:_children)
     {
         moveChild(e.get(),x,y);
     }
 }
예제 #6
0
void PropertyEditor::createEditor(PropertyEditorItem * i) {
    int y = viewportToContents(QPoint(0, itemRect(i).y())).y();
    QRect geometry(columnWidth(0), y, columnWidth(1), i->height());

    delete m_currentEditor;

    m_editItem = i;
    PropertySubEditor *editor = 0;

    switch (i->type()) {
    case Variant::Type::String:
        editor = new PropertyEditorInput(viewport(), i->property());
        break;
    case Variant::Type::Port:
    case Variant::Type::Pin:
    case Variant::Type::Combo:
    case Variant::Type::VarName:
    case Variant::Type::Select:
    case Variant::Type::PenStyle:
    case Variant::Type::PenCapStyle:
    case Variant::Type::SevenSegment:
    case Variant::Type::KeyPad:
        editor = new PropertyEditorList(viewport(), i->property());
        break;
    case Variant::Type::FileName:
        editor = new PropertyEditorFile(viewport(), i->property());
        break;
    case Variant::Type::Int:
        editor = new PropertyEditorSpin(viewport(), i->property());
        break;
    case Variant::Type::Double:
        editor = new PropertyEditorDblSpin(viewport(), i->property());
        break;
    case Variant::Type::Color:
        editor = new PropertyEditorColor(viewport(), i->property());
        break;
    case Variant::Type::Bool:
        editor = new PropertyEditorBool(viewport(), i->property());
        break;
    case Variant::Type::Raw:
    case Variant::Type::Multiline:
    case Variant::Type::RichText:
    case Variant::Type::None:
        break;
    }

    if (editor) {
        addChild(editor);
        moveChild(editor, geometry.x(), geometry.y());
        editor->show();

        editor->setFocus();
    }

    m_currentEditor = editor;

    showDefaultsButton(i->property()->changed());
}
void TLFrameSequenceLayout::moveFrames( int x )
{
    //Move each frame sequence
    TLFrameSequence *frame_sequence_iterator;
    for ( frame_sequence_iterator = list_of_frame_sequences.first(); frame_sequence_iterator; frame_sequence_iterator = list_of_frame_sequences.next() )
    {
	moveChild( frame_sequence_iterator, x, childY( frame_sequence_iterator ) );
    }
}
void TLFrameSequenceLayout::slotMoveFrameSequenceDown()
{
    //If the current frame sequence is the last, do nothing
    if ( current_frame_sequence == last_frame_sequence )
        return;

    //Find the frame sequence above the current and reinsert it into the list in its new position
    TLFrameSequence *frame_sequence_below = list_of_frame_sequences.take( list_of_frame_sequences.find( current_frame_sequence ) + 1 );
    current_frame_sequence -> setPosition( current_frame_sequence -> position() + 1 );
    frame_sequence_below -> setPosition( frame_sequence_below -> position() - 1 );
    list_of_frame_sequences.insert( frame_sequence_below -> position() - 1, frame_sequence_below );
    if ( frame_sequence_below == last_frame_sequence )
        last_frame_sequence = current_frame_sequence;

    //Swap both frame sequences in the scroll view
    moveChild( frame_sequence_below, childX( frame_sequence_below ), childY( frame_sequence_below ) - 24 );
    moveChild( current_frame_sequence, childX( current_frame_sequence ), childY( current_frame_sequence ) + 24 );
    updateContentSize();
}
예제 #9
0
void K3bListView::placeEditor( K3bListViewItem* item, int col )
{
  ensureItemVisible( item );
  QRect r = itemRect( item );

  r.setX( contentsToViewport( QPoint(header()->sectionPos( col ), 0) ).x() );
  r.setWidth( header()->sectionSize( col ) - 1 );

  // check if the column is fully visible
  if( visibleWidth() < r.right() )
    r.setRight(visibleWidth());

  r = QRect( viewportToContents( r.topLeft() ), r.size() );

  if( item->pixmap( col ) ) {
    r.setX( r.x() + item->pixmap(col)->width() );
  }

  // the tree-stuff is painted in the first column
  if( col == 0 ) {
    r.setX( r.x() + item->depth() * treeStepSize() );
    if( rootIsDecorated() )
      r.setX( r.x() + treeStepSize() );
  }

  if( item->needButton(col) ) {
    prepareButton( item, col );
    m_editorButton->setFixedHeight( r.height() );
    // for now we make a square button
    m_editorButton->setFixedWidth( m_editorButton->height() );
    r.setWidth( r.width() - m_editorButton->width() );
    moveChild( m_editorButton, r.right(), r.y() );
  }

  if( QWidget* editor = prepareEditor( item, col ) ) {
    editor->resize( r.size() );
    //    editor->resize( QSize( r.width(), editor->minimumSizeHint().height() ) );
    moveChild( editor, r.x(), r.y() );
  }
}
void TLFrameSequenceLayout::slotSwapFrameSequences( int c_pos, int r_pos )
{
    Q_ASSERT( c_pos > 0 && r_pos > 0 );
    TLFrameSequence *release_frame_sequence;

    release_frame_sequence = NULL;

    //Above
    if ( c_pos > r_pos )
    {
        current_frame_sequence = list_of_frame_sequences.take( list_of_frame_sequences.find( current_frame_sequence ) );
        release_frame_sequence = list_of_frame_sequences.take( r_pos - 1 );
        current_frame_sequence -> setPosition( r_pos );
        release_frame_sequence -> setPosition( c_pos );
        list_of_frame_sequences.insert( current_frame_sequence -> position() - 1, current_frame_sequence );
        list_of_frame_sequences.insert( release_frame_sequence -> position() - 1, release_frame_sequence );
    }
    //Below
    else if ( c_pos < r_pos )
    {
        release_frame_sequence = list_of_frame_sequences.take( r_pos - 1 );
        current_frame_sequence = list_of_frame_sequences.take( list_of_frame_sequences.find( current_frame_sequence ) );
        current_frame_sequence -> setPosition( r_pos );
        release_frame_sequence -> setPosition( c_pos );
        list_of_frame_sequences.insert( release_frame_sequence -> position() - 1, release_frame_sequence );
        list_of_frame_sequences.insert( current_frame_sequence -> position() - 1, current_frame_sequence );
    }
    last_frame_sequence = list_of_frame_sequences.getLast();

    int cfs_old_x, cfs_old_y, rfs_old_x, rfs_old_y;
    cfs_old_x = childX( current_frame_sequence );
    cfs_old_y = childY( current_frame_sequence );
    rfs_old_x = childX( release_frame_sequence );
    rfs_old_y = childY( release_frame_sequence );
    moveChild( current_frame_sequence, rfs_old_x, rfs_old_y );
    moveChild( release_frame_sequence, cfs_old_x, cfs_old_y );
    updateContentSize();
}
예제 #11
0
파일: robjectlist.cpp 프로젝트: KDE/rkward
void RObjectList::updateEnvironments (const QStringList &_env_names, bool force_globalenv_update) {
	RK_TRACE (OBJECTS);

	RObjectMap newchildmap;
	QStringList env_names = _env_names;
	if (!env_names.isEmpty ()) {
		QString dummy = env_names.takeFirst ();
		RK_ASSERT (dummy == ".GlobalEnv");
		if (force_globalenv_update) {
			// for now, we only update the .GlobalEnv. All others we assume to be static
			getGlobalEnv ()->updateFromR (update_chain);
		}
	} else {
		RK_ASSERT (!env_names.isEmpty ());
	}

	// find which items are new, and copy the old ones
	for (int i = 0; i < env_names.count (); ++i) {
		QString name = env_names[i];

		RObject *obj = findChildByName (name);
		if (obj && (i > 0) && (env_names.lastIndexOf (name, i-1) > -1)) {		// duplicate environment names can happen (e.g. if a data.frame is attached multiple times)
			obj = 0;	// only copy the old item once
		}
		if (!obj) {
			obj = createTopLevelEnvironment (name);
			RKGlobals::tracker ()->beginAddObject (obj, this, i);
			childmap.insert (i, obj);
			RKGlobals::tracker ()->endAddObject (obj, this, i);
		}
		newchildmap.insert (i, obj);
	}

	// check which envs have been removed or changed position
	for (int i = 0; i < childmap.size (); ++i) {	// do *not* cache the childmap.size ()! We may change it in the loop.
		RObject *obj = childmap[i];
		int new_pos = newchildmap.indexOf (obj);
		
		if (new_pos < 0) {	// environment is gone
			RK_DEBUG (OBJECTS, DL_INFO, "removing toplevel environment %s from list", obj->getShortName ().toLatin1 ().data ());
			if (RKGlobals::tracker ()->removeObject (obj, 0, true)) --i;
			else (newchildmap.insert (i, obj));
		} else if (new_pos != i) {
			// this call is rather expensive, all in all, but fortunately called very rarely
			moveChild (obj, i, new_pos);
		}
	}

	RK_DO (RK_ASSERT (childmap == newchildmap), OBJECTS, DL_DEBUG);	// this is an expensive assert, hence wrapping it inside RK_DO
}
예제 #12
0
    void reorderChildren (const OwnedArray<ValueTree>& newOrder, UndoManager* undoManager)
    {
        jassert (newOrder.size() == children.size());

        for (int i = 0; i < children.size(); ++i)
        {
            SharedObject* const child = newOrder.getUnchecked(i)->object;

            if (children.getObjectPointerUnchecked (i) != child)
            {
                const int oldIndex = children.indexOf (child);
                jassert (oldIndex >= 0);
                moveChild (oldIndex, i, undoManager);
            }
        }
    }
예제 #13
0
void ThumbnailList::viewportResizeEvent( QResizeEvent * e )
{
	if ( m_thumbnails.count() < 1 || width() < 1 )
		return;

	// if width changed resize all the Thumbnails, reposition them to the
	// right place and recalculate the contents area
	if ( e->size().width() != e->oldSize().width() )
	{
		// runs the timer avoiding a thumbnail regeneration by 'contentsMoving'
		delayedRequestVisiblePixmaps( 2000 );

		// resize and reposition items
		int totalHeight = 0,
		    newWidth = e->size().width();
		QValueVector<ThumbnailWidget *>::iterator tIt = m_thumbnails.begin(), tEnd = m_thumbnails.end();
		for ( ; tIt != tEnd; ++tIt )
		{
			ThumbnailWidget *t = *tIt;
			moveChild( t, 0, totalHeight );
			t->resizeFitWidth( newWidth );
			totalHeight += t->heightHint() + 4;
		}

		// update scrollview's contents size (sets scrollbars limits)
		resizeContents( newWidth, totalHeight );

		// ensure selected item remains visible
		if ( m_selected )
			ensureVisible( 0, childY( m_selected ) + m_selected->height()/2, 0, visibleHeight()/2 );
	}
	else if ( e->size().height() <= e->oldSize().height() )
		return;

	// invalidate the bookmark overlay
	if ( m_bookmarkOverlay )
	{
		delete m_bookmarkOverlay;
		m_bookmarkOverlay = 0;
	}

	// update Thumbnails since width has changed or height has increased
	delayedRequestVisiblePixmaps( 500 );
}
예제 #14
0
void ValueTree::SharedObject::reorderChildren (const ReferenceCountedArray <SharedObject>& newOrder, UndoManager* undoManager)
{
    jassert (newOrder.size() == children.size());

    if (undoManager == 0)
    {
        children = newOrder;
        sendChildChangeMessage();
    }
    else
    {
        for (int i = 0; i < children.size(); ++i)
        {
            if (children.getUnchecked(i) != newOrder.getUnchecked(i))
            {
                jassert (children.contains (newOrder.getUnchecked(i)));
                moveChild (children.indexOf (newOrder.getUnchecked(i)), i, undoManager);
            }
        }
    }
}
예제 #15
0
void SortableView::dropEvent(QDropEvent *ev)
{
	SortableWidget *widget =
		(SortableWidget *)ev->mimeData()->data(m_mimeType).toULongLong();

	// Hide the indicator
	m_indicator.hide();

	// Get the position to insert the widget at
	int before = sortableIndexAtPos(
		ev->pos() + getScrollOffset(), widget->getLevel(), true);

	if(!isIndexValidForLevel(before, widget->getLevel()))
		return; // Invalid position

	// Forward the event for processing
	if(!moveChild(widget, before))
		return; // Failed to move

	// Notify the sender that we accepted the drop
	ev->acceptProposedAction();
}
void TLFrameSequenceLayout::slotRemoveFrameSequence()
{
   if ( number_of_frame_sequences > 1 )
   {
      TLFrameSequence *bridge_frame_sequence;
      number_of_frame_sequences--;

      //Case 1: When the sequence of frames is the last within the list
      if ( current_frame_sequence == last_frame_sequence )
      {
	  list_of_frame_sequences.remove( current_frame_sequence );
	  bridge_frame_sequence = list_of_frame_sequences.getLast();
	  delete current_frame_sequence;
	  current_frame_sequence = bridge_frame_sequence;
	  last_frame_sequence = current_frame_sequence;
	  current_frame = NULL;
      }
      //Case 2: When the sequence of frames is any except the last
      else
      {
	  bridge_frame_sequence = list_of_frame_sequences.at( list_of_frame_sequences.find( current_frame_sequence ) + 1 );

	  //Reaccomodate every frame_sequence next to the frame_sequence that is going to be deleted
	  TLFrameSequence *frame_sequence_iterator;
	  for ( frame_sequence_iterator = bridge_frame_sequence; frame_sequence_iterator; frame_sequence_iterator = list_of_frame_sequences.next() )
	  {
	      moveChild( frame_sequence_iterator, childX( frame_sequence_iterator ), childY( frame_sequence_iterator ) - frame_sequence_iterator -> height() );
	      frame_sequence_iterator -> setPosition( frame_sequence_iterator -> position() - 1 );
	  }

	  list_of_frame_sequences.remove( current_frame_sequence );
	  delete current_frame_sequence;
	  current_frame_sequence = bridge_frame_sequence;
	  current_frame = NULL;
      }
      updateContentSize();
   }
}
void KexiSimplePrintPreviewScrollView::resizeEvent(QResizeEvent *re)
{
    Q3ScrollView::resizeEvent(re);
// kDebug() << re->size().width() << " " << re->size().height();
// kDebug() << contentsWidth() << " " << contentsHeight();
// kDebug() << widget->width() << " " << widget->height();
    setUpdatesEnabled(false);
    if (re->size().width() > (widget->width() + 2*KexiSimplePrintPreviewScrollView_MARGIN)
            || re->size().height() > (widget->height() + 2*KexiSimplePrintPreviewScrollView_MARGIN)) {
        resizeContents(
            qMax(re->size().width(), widget->width() + 2*KexiSimplePrintPreviewScrollView_MARGIN),
            qMax(re->size().height(), widget->height() + 2*KexiSimplePrintPreviewScrollView_MARGIN));
        int vscrbarWidth = verticalScrollBar()->isVisible() ? verticalScrollBar()->width() : 0;
        int newContentsWidth
        = qMax(re->size().width(), widget->width() + 2 * KexiSimplePrintPreviewScrollView_MARGIN);
        int newContentsHeight
        = qMax(re->size().height(), widget->height() + 2 * KexiSimplePrintPreviewScrollView_MARGIN);
        moveChild(widget, (newContentsWidth - vscrbarWidth - widget->width()) / 2,
                  (newContentsHeight - widget->height()) / 2);
        resizeContents(newContentsWidth, newContentsHeight);
    }
    setUpdatesEnabled(true);
}
예제 #18
0
void gPanel::create(void)
{
	int i;
	GtkWidget *ch, *box;
	bool doReparent = false;
	bool was_visible = isVisible();
	GdkRectangle rect;
	int bg, fg;
	gControl *nextSibling;
	
	if (border)
	{
		getGeometry(&rect);
		bg = background();
		fg = foreground();
		nextSibling = next();
		parent()->remove(this);
		
		for (i = 0; i < childCount(); i++)
		{
			ch = child(i)->border;
			g_object_ref(G_OBJECT(ch));
			gtk_container_remove(GTK_CONTAINER(widget), ch);
		}
		
		_no_delete = true;
		gtk_widget_destroy(border);
		_no_delete = false;
		doReparent = true;
	}
	
	if (_bg_set)
	{
		border = gtk_event_box_new();
		widget = gtk_fixed_new();
		box = widget;
		//gtk_widget_set_app_paintable(border, TRUE);
		//gtk_widget_set_app_paintable(box, TRUE);
	}
	else
	{
		border = widget = gtk_fixed_new();
		box = NULL;
	}

	frame = widget;
	realize(true);
	
	//g_signal_connect(G_OBJECT(border), "size-allocate", G_CALLBACK(cb_size), (gpointer)this);
	//g_signal_connect(G_OBJECT(border), "expose-event", G_CALLBACK(cb_expose), (gpointer)this);
	
	if (doReparent)
	{
		if (box)
			gtk_widget_realize(box);
		
		setNext(nextSibling);
		setBackground(bg);
		setForeground(fg);
		updateFont();
		bufX = bufY = bufW = bufH = -1;
		setGeometry(&rect);
		
		for (i = 0; i < childCount(); i++)
		{
			ch = child(i)->border;
			gtk_container_add(GTK_CONTAINER(widget), ch);
			moveChild(child(i), child(i)->x(), child(i)->y());
			g_object_unref(G_OBJECT(ch));
		}
		
		if (was_visible)
			show();
		else
			hide();
		
		//gApplication::checkHoveredControl(this);
		
		if (_inside)
		{
			_inside = false;
			if (gApplication::_enter == this)
				gApplication::_enter = NULL;
			gApplication::_ignore_until_next_enter = this;
		}
	}
}
예제 #19
0
void PageView::layoutPages(bool zoomChanged)
{
  // Paranoid safety check
  if (widgetList == 0)
    return;

  // If there are no widgets, e.g. because the last widget has been
  // removed, the matter is easy: set the contents size to 0. If there
  // are no widgets because previously existing widgets were removed
  // (we detect that by looking at the contentsWidth and -Height).
  if (widgetList->isEmpty()) {
    if ((contentsWidth() != 0) || (contentsHeight() != 0)) {
      QScrollView::resizeContents(0,0);
    }
    return;
  }

  // Ok, now we are in a situation where we do have some widgets that
  // shall be centered.
  int distance = distanceBetweenWidgets;
  if (singlePageFullScreenMode())
  {
    // In single page fullscreen mode we don't want a margin around the pages
    distance = 0;
  }

  QMemArray<Q_UINT32> colWidth(nrCols);
  for(Q_UINT8 i=0; i<colWidth.size(); i++)
    colWidth[i] = 0;

  Q_UINT16 numRows;
  if(nrCols <= 2)
  {
    numRows = (widgetList->size()+2*nrCols-2) / nrCols;
  }
  else
  {
    numRows = (Q_INT16)ceil(((double)widgetList->size()) / nrCols);
  }

  QMemArray<Q_UINT32> rowHeight(numRows);
  for(Q_UINT16 i=0; i<rowHeight.size(); i++)
    rowHeight[i] = 0;

  // Now find the widths and heights of the columns
  for(Q_UINT16 i=0; i<widgetList->size(); i++) 
  {
    Q_UINT8 col;
    Q_UINT16 row;

    if (nrCols == 2) {
      // In two-column display, start with the right column
      col = (i+1+nrCols) % nrCols;
      row = (i+1+nrCols) / nrCols - 1;
    } else {
      col = (i+nrCols) % nrCols;
      row = (i+nrCols) / nrCols - 1;
    }

    colWidth[col] = QMAX(colWidth[col], (Q_UINT32)widgetList->at(i)->pageSize().width());
    rowHeight[row] = QMAX(rowHeight[row], (Q_UINT32)widgetList->at(i)->pageSize().height());
  }

  // Calculate the total width and height of the display
  Q_UINT32 totalHeight = 0;
  for(Q_UINT16 i=0; i<rowHeight.size(); i++)
    totalHeight += rowHeight[i];

  totalHeight += (numRows+1)*distance;
  Q_UINT32 totalWidth = 0;
  for(Q_UINT8 i=0; i<colWidth.size(); i++)
    totalWidth += colWidth[i];

  totalWidth += (nrCols+1)*distance;
  QSize newViewportSize = viewportSize( totalWidth, totalHeight );
  Q_UINT32 centeringLeft = 0;
  if( (Q_UINT32)newViewportSize.width() > totalWidth )
    centeringLeft = ( newViewportSize.width() - totalWidth )/2;
  Q_UINT32 centeringTop = 0;
  if( (Q_UINT32)newViewportSize.height() > totalHeight )
    centeringTop = ( newViewportSize.height() - totalHeight)/2;

  // Resize the viewport
  if (((Q_UINT32)contentsWidth() != totalWidth) || ((Q_UINT32)contentsHeight() != totalHeight))
  {
    // Calculate the point in the coordinates of the contents which is currently at the center of the viewport.
    QPoint midPoint = QPoint(visibleWidth() / 2 + contentsX(), visibleHeight() / 2 + contentsY()); 
    double midPointRatioX = (double)(midPoint.x()) / contentsWidth();
    double midPointRatioY = (double)(midPoint.y()) / contentsHeight();

    resizeContents(totalWidth,totalHeight);

    // If the zoom changed recenter the former midPoint
    if (zoomChanged)
      center((int)(contentsWidth() * midPointRatioX), (int)(contentsHeight() * midPointRatioY));
  }

  // Finally, calculate the left and top coordinates of each row and
  // column, respectively
  QMemArray<Q_UINT32> colLeft(nrCols);
  colLeft[0] = distance;
  for(Q_UINT8 i=1; i<colLeft.size(); i++)
    colLeft[i] = colLeft[i-1]+colWidth[i-1]+distance;

  QMemArray<Q_UINT32> rowTop(numRows);
  rowTop[0] = distance;
  for(Q_UINT16 i=1; i<rowTop.size(); i++)
    rowTop[i] = rowTop[i-1]+rowHeight[i-1]+distance;

  for(Q_UINT16 i=0; i<widgetList->size(); i++) 
  {
    Q_UINT8 col;
    Q_UINT16 row;
    if (nrCols == 2)
    {
      // In two column-mode start with the right column.
      col = (i+nrCols-1) % nrCols;
      row = (i+nrCols-1) / nrCols;
    }
    else
    {
      col = (i+nrCols) % nrCols;
      row = i / nrCols;
    }
    if (nrCols == 2)
    {
      // in 2-column mode right justify the first column, and leftjustify the second column
      int width = widgetList->at(i)->width();
      int left;
      if (col == 0)
        left = centeringLeft + colLeft[col] + colWidth[col]-width + distance/2;
      else
        left = centeringLeft + colLeft[col];
      moveChild( widgetList->at(i), left, centeringTop+rowTop[row]);
    }
    else
    {
      // in single column and overview mode center the widgets
      int widgetWidth = widgetList->at(i)->width();
      int left = centeringLeft + colLeft[col] + ((int)colWidth[col]-widgetWidth)/2;
      moveChild(widgetList->at(i), left, centeringTop+rowTop[row]);
    }
  }
  calculateCurrentPageNumber();
}
예제 #20
0
파일: Container.cpp 프로젝트: Lectem/luib
 void Container::moveChildTo(Element * child,int x, int y)
 {
     int dx = x- _aabb.x;
     int dy = y- _aabb.y;
     moveChild(child,dx, dy);
 }
예제 #21
0
bool ContactListProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
{
    if (action == Qt::IgnoreAction)
        return true;
    if (!data->hasFormat("application/qutim.item"))
        return false;
    if (column > 0)
        return false;
    QByteArray encoded_data = data->data("application/qutim.item");
    QDataStream stream(&encoded_data, QIODevice::ReadOnly);
    quint64 item_row,item_column;
    qint64 item_id;
    stream >> item_row >> item_column >> item_id;
    QModelIndex index = createIndex((int)item_row,(int)item_column,(quint32)item_id);
    if(!index.isValid())
        return false;
    int type = index.data(Qt::UserRole).toInt();
    int parent_type = parent.data(Qt::UserRole).toInt();
    switch(m_model_type)
    {
    case 0:
        switch(type)
        {
        case 0:
            if(parent_type==1) {
                TreeModelItem old_item = static_cast<TreeItem*>(getItem(index)->getSourceIndex().internalPointer())->getStructure();
                TreeModelItem new_item = old_item;
                new_item.m_account_name = static_cast<TreeItem*>(getItem(parent)->getSourceIndex().internalPointer())->getStructure().m_account_name;
                if(new_item.m_account_name!=old_item.m_account_name)
                    return false;
                new_item.m_parent_name = static_cast<TreeItem*>(getItem(parent)->getSourceIndex().internalPointer())->getStructure().m_item_name;
                if(new_item.m_parent_name==old_item.m_parent_name)
                    return false;
                PluginSystem::instance().moveItemSignalFromCL(old_item, new_item);
                return false;
            }
        case 1:
            if(parent_type==2) {
                if(parent!=index.parent())
                    return false;
                TreeItem *group = static_cast<TreeItem*>(getItem(index)->getSourceIndex().internalPointer());
                group->parent()->moveChild(group->getStructure().m_item_name,row);
                m_tree_view->setUpdatesEnabled(false);
                removeAllItems();
                m_tree_view->setUpdatesEnabled(true);
                return false;
            }
            return false;
        default:
            return false;
        }
    case 1:
        switch(type)
        {
        case 0:
            return false;
        case 1:
            if(parent==index.parent())
            {
                moveChild(getItem(index)->getName(),row);
                m_tree_view->setUpdatesEnabled(false);
                removeAllItems();
                m_tree_view->setUpdatesEnabled(true);
            }
            return false;
        }
        return false;
    default:
        return false;
    }
}