コード例 #1
0
ファイル: sortdialog.cpp プロジェクト: Atronax/XCel
// SLOTS
void SortDialog::onMoreButton(bool show)
{
    if (show)
    {
        QGridLayout* layout = qobject_cast<QGridLayout*>(this->layout());
        layout->addWidget(gb_secondary, 3, 0, 3, 3);
        layout->addWidget(gb_tertiary, 6, 0, 3, 3);
        setLayout(layout);

        gb_secondary->show();
        gb_tertiary->show();
    }
    else
    {
        QGridLayout* layout = qobject_cast<QGridLayout*>(this->layout());
        layout->removeWidget(gb_secondary);
        layout->removeWidget(gb_tertiary);
        setLayout(layout);

        gb_secondary->hide();
        gb_tertiary->hide();
    }

    setFixedSize(sizeHint());
}
コード例 #2
0
ファイル: ctkFileDialog.cpp プロジェクト: Eric89GXL/CTK
//------------------------------------------------------------------------------
void ctkFileDialog::setBottomWidget(QWidget* widget, const QString& label)
{
  QGridLayout* gridLayout = qobject_cast<QGridLayout*>(this->layout());
  QWidget* oldBottomWidget = this->bottomWidget();
  // remove the old widget from the layout if any
  if (oldBottomWidget)
    {
    if (oldBottomWidget == widget)
      {
      return;
      }
    gridLayout->removeWidget(oldBottomWidget);
    delete oldBottomWidget;
    }
  if (widget == 0)
    {
    return;
    }
  if (!label.isEmpty())
    {
    gridLayout->addWidget(new QLabel(label), 4, 0);
    gridLayout->addWidget(widget,4, 1,1, 1);
    }
  else
    {
    gridLayout->addWidget(widget,4, 0,1, 2);
    }
  // The dialog button box is no longer spanned on 2 rows but on 3 rows if
  // there is a "bottom widget" 
  QDialogButtonBox* buttonBox = this->findChild<QDialogButtonBox*>();
  Q_ASSERT(buttonBox);
  gridLayout->removeWidget(buttonBox);
  gridLayout->addWidget(buttonBox, 2, 2, widget ? 3 : 2, 1);
}
コード例 #3
0
void AbstractEditableLabelWidget::toEditionMode() {
	m_isInEditionMode = true;

	hide();
	QGridLayout *layout = (QGridLayout*)this->layout();

	m_label->hide();
	layout->removeWidget(m_label);

	if(!m_edited) {
		setEmptyTextToEdit();
	}
	myEditionWidget()->show();
	layout->addWidget(myEditionWidget(),1,0,1,5);
	m_acceptButton->show();
	layout->addWidget(m_acceptButton,2,3);
	m_cancelButton->show();
	layout->addWidget(m_cancelButton,2,4);

	setNoSpacing(layout);

	updateGeometry();
	show();

	emit editionStarted();
}
コード例 #4
0
void DialogEditSIMDRegister::hideColumns(EntriesCols afterLastToHide)
{
	QGridLayout* layout = dynamic_cast<QGridLayout*>(this->layout());
	for(int col=ENTRIES_FIRST_COL;col<afterLastToHide;++col)
	{
		int i=numBytes-1-(col-ENTRIES_FIRST_COL);
		Q_ASSERT(0<i && std::size_t(i)<bytes.size());

		columnLabels[i]->hide();

		// Spanned entries shouldn't just be hidden. If they are still in the grid,
		// then we get extra spacing between invisible columns, which is unwanted.
		// So we have to also remove them from the layout.
		layout->removeWidget(bytes[i]);
		bytes[i]->hide();

		layout->removeWidget(words[i/2]);
		words[i/2]->hide();

		layout->removeWidget(dwords[i/4]);
		dwords[i/4]->hide();

		layout->removeWidget(qwords[i/8]);
		qwords[i/8]->hide();

		layout->removeWidget(floats32[i/4]);
		floats32[i/4]->hide();

		layout->removeWidget(floats64[i/8]);
		floats64[i/8]->hide();
	}
	layout->removeItem(hexSignOKCancelLayout);
	hexSignOKCancelLayout->setParent(nullptr);
	layout->addLayout(hexSignOKCancelLayout, ROW_AFTER_ENTRIES, afterLastToHide, 1, TOTAL_COLS-afterLastToHide);
}
コード例 #5
0
logical DesignerMode :: UpdateOWGeometry ( )
{
logical   term         = NO;
QRect     new_geometry = parent_owidget->WidgetQ()->geometry();
QPoint    cell_pos;
BEGINSEQ
if ( !ctx_design || !control)                      ERROR

if ( ctx_design->LoadFieldAttribute(control, "allign.arrange") == PropertyHandle("AT_Absolut") )
{
  if ( geometry.width() != cw_geometry.width() )
    ctx_design->StoreFieldAttribute(control, "size.oszwdth", cw_geometry.width());
  if ( geometry.height() != cw_geometry.height() )
    ctx_design->StoreFieldAttribute(control, "size.oszhgth", cw_geometry.height());
  if ( geometry.x() != cw_geometry.x() )
    ctx_design->StoreFieldAttribute(control, "position.opsx", cw_geometry.x());
  if ( geometry.y() != cw_geometry.y() )
    ctx_design->StoreFieldAttribute(control, "position.opsy", cw_geometry.y());
}

if ( ctx_design->LoadFieldAttribute(control, "allign.arrange") == PropertyHandle("AT_Grid") )
{ 
  if ( geometry.width() != cw_geometry.width() )
    ctx_design->StoreFieldAttribute(control, "size.oszwdth", cw_geometry.width());
  if ( geometry.height() != cw_geometry.height() )
    ctx_design->StoreFieldAttribute(control, "size.oszhgth", cw_geometry.height());

  cell_pos = ((DesignerModeControl*)control->GetParent()->GetDesignMode())->CellizePosition(new_geometry.topLeft());
  
  QWidget     * parent;
  QGridLayout * layout;
  if (
       ( parent = (QWidget*)parent_owidget->WidgetQ()->parent() )
    && ( layout = (QGridLayout*)parent->layout() )
    && ( layout->inherits("QGridLayout") )
  ){
    layout->removeWidget(parent_owidget->WidgetQ());
    layout->addWidget(parent_owidget->WidgetQ(), cell_pos.y(), cell_pos.x());
  }   
  
  ctx_design->StoreFieldAttribute(control, "position.opsx", cell_pos.x());
  ctx_design->StoreFieldAttribute(control, "position.opsy", cell_pos.y());
  
  ((DesignerModeControl*)control->GetParent()->GetDesignMode())->Refresh();
}

RECOVER
  term = YES;
ENDSEQ
  geometry = new_geometry;
  return(term);
}
コード例 #6
0
// SLOT ConnectionsWidget::removeUserSlot( SmartUtente )
void ConnectionsWidget::removeUserSlot( const SmartUtente& su ) {
    int pos = contactsList.indexOf( su );
    if( pos > -1 )
        contactsList.remove( pos );

    for( int i = 0; i < userPreviewWidgetsList.size(); i++ ) {
        if( userPreviewWidgetsList[i]->getUser() == su ) {
            QGridLayout *layout = dynamic_cast<QGridLayout *>( userPreviewWidgetsLayout );
            layout->removeWidget( userPreviewWidgetsList[i] );

            UserPreviewWidget *aux = userPreviewWidgetsList.takeAt( i );
            delete aux;

            for( i; i < userPreviewWidgetsList.size(); i++ ) {
                layout->removeWidget( userPreviewWidgetsList[i] );
                layout->addWidget( userPreviewWidgetsList[i], static_cast<int>( i / 2 ), i % 2 );
            }
        }
    }

    emit contactToRemoveSignal( su );
}
コード例 #7
0
void AbstractEditableLabelWidget::toStandardMode() {
	m_isInEditionMode = false;

	hide();
	QGridLayout *layout = (QGridLayout*)this->layout();

	myEditionWidget()->hide();
	layout->removeWidget(myEditionWidget());
	m_acceptButton->hide();
	layout->removeWidget(m_acceptButton);
	m_cancelButton->hide();
	layout->removeWidget(m_cancelButton);

	m_label->show();
	layout->addWidget(m_label,1,0);

	setNoSpacing(layout);

	updateGeometry();
	show();

	emit editionFinished();
}
コード例 #8
0
ファイル: knightsview.cpp プロジェクト: KDE/knights
void KnightsView::updateOffers() {
	if ( m_offerWidgets.isEmpty() ) {
		ui->notificationWidget->hide();
		return;
	}
	QGridLayout* layout = qobject_cast<QGridLayout*>(ui->notificationWidget->layout());
	if ( !layout )
		return;
	ui->showAllOffers->setIcon ( QIcon::fromTheme(QLatin1String( m_showAllOffers ? "arrow-up-double" : "arrow-down-double" )) );
	ui->showAllOffers->setVisible ( m_offerWidgets.size() > 1 );
	foreach ( OfferWidget* widget, m_offerWidgets ) {
		layout->removeWidget ( widget );
		widget->hide();
	}
コード例 #9
0
void PokeSelection::toggleSearchWindow()
{
    if (search) {
        QGridLayout *gl = (QGridLayout*)layout();
        gl->removeWidget(search);
        search->deleteLater();
        search = NULL;

        setFixedWidth(oldwidth);
        move(oldx, y());
    } else {
        //Tricks to get a window at the correct size. Qt is annoying, not allowing resize() to work
        //properly on windows, i have to use setFixedWidth on the top level window :(
        oldwidth = width();
        oldx = x();

        QGridLayout *gl = (QGridLayout*)layout();
        search = new AdvancedSearch(this);
        search->setGen(getGen());

        ui->pokemonList->setFixedWidth(ui->pokemonList->width());
        ui->pokeEdit->setFixedWidth(ui->pokeEdit->width());
        ui->changeSpecies->setFixedWidth(ui->changeSpecies->width());
        search->setResultsWidth(ui->pokemonList->width());

        if (newwidth) {
            setFixedWidth(newwidth);
        }

        gl->addWidget(search, 0, 4, gl->rowCount(), 1);
        search->show();

        if (newwidth == 0) {
            newwidth = width();
        }

        connect(search, SIGNAL(pokemonSelected(Pokemon::uniqueId)), SLOT(setNum(Pokemon::uniqueId)));

        /* Moving the widget if it goes out of bounds */
        QWidget *top = ((QWidget*)parent())->window();

        if (x() + width() > top->x() + top->width()) {
            move(std::max(top->x(), top->x()+(top->width()-width())/2), y());
        }
    }
}
コード例 #10
0
ファイル: PhotoDrop.cpp プロジェクト: RedCraig/retroshare
void PhotoDrop::clearPhotos()
{
	std::cerr << "PhotoDrop::clearPhotos()";
	std::cerr << std::endl;

	/* grab the first PhotoItem - and get it size */
	const QObjectList &items = children();
	QObjectList::const_iterator qit;
	std::list<PhotoItem *> photoItems;
	std::list<PhotoItem *>::iterator pit;

	for(qit = items.begin(); qit != items.end(); qit++)
	{
		PhotoItem *item = dynamic_cast<PhotoItem *>(*qit);
		if (item)
		{
			photoItems.push_back(item);
			std::cerr << "PhotoDrop::clearPhotos() item: " << item;
			std::cerr << std::endl;
		}
		else
		{
			std::cerr << "PhotoDrop::clearPhotos() Found Child, which is not a PhotoItem???";
			std::cerr << std::endl;
		}
	}

	QLayout *alayout = layout();
	QGridLayout *glayout = dynamic_cast<QGridLayout *>(alayout);
	if (!glayout)
	{
		std::cerr << "PhotoDrop::clearPhotos() not GridLayout... not much we can do!";
		std::cerr << std::endl;
		return;
	}

	for(pit = photoItems.begin(); pit != photoItems.end(); pit++)
	{
		PhotoItem *item = *pit;
		glayout->removeWidget(item);
		delete item;
	}

	mSelected = NULL;
}
コード例 #11
0
void VBoxSnapshotDetailsDlg::getFromSnapshot (const CSnapshot &aSnapshot)
{
    mSnapshot = aSnapshot;
    CMachine machine = mSnapshot.GetMachine();

    /* Get general properties */
    mLeName->setText (aSnapshot.GetName());
    mTeDescription->setText (aSnapshot.GetDescription());

    /* Get timestamp info */
    QDateTime timestamp;
    timestamp.setTime_t (mSnapshot.GetTimeStamp() / 1000);
    bool dateTimeToday = timestamp.date() == QDate::currentDate();
    QString dateTime = dateTimeToday ? timestamp.time().toString (Qt::LocalDate) : timestamp.toString (Qt::LocalDate);
    mTxTaken->setText (dateTime);

    /* Get thumbnail if present */
    ULONG width = 0, height = 0;
    QVector <BYTE> thumbData = machine.ReadSavedThumbnailToArray (0, KBitmapFormat_BGR0, width, height);
    mThumbnail = thumbData.size() != 0 ? QPixmap::fromImage (QImage (thumbData.data(), width, height, QImage::Format_RGB32).copy()) : QPixmap();
    QVector <BYTE> screenData = machine.ReadSavedScreenshotToArray (0, KBitmapFormat_PNG, width, height);
    mScreenshot = screenData.size() != 0 ? QPixmap::fromImage (QImage::fromData (screenData.data(), screenData.size(), "PNG")) : QPixmap();

    QGridLayout *lt = qobject_cast <QGridLayout*> (layout());
    Assert (lt);
    if (mThumbnail.isNull())
    {
        lt->removeWidget (mLbThumbnail);
        mLbThumbnail->setHidden (true);

        lt->removeWidget (mLeName);
        lt->removeWidget (mTxTaken);
        lt->addWidget (mLeName, 0, 1, 1, 2);
        lt->addWidget (mTxTaken, 1, 1, 1, 2);
    }
    else
    {
        lt->removeWidget (mLeName);
        lt->removeWidget (mTxTaken);
        lt->addWidget (mLeName, 0, 1);
        lt->addWidget (mTxTaken, 1, 1);

        lt->removeWidget (mLbThumbnail);
        lt->addWidget (mLbThumbnail, 0, 2, 2, 1);
        mLbThumbnail->setHidden (false);
    }

    retranslateUi();
}
コード例 #12
0
void MyView::ChnageLayout(const int rows, const int columns)
{
    if (layout_.count() > 0)
    {
        for(NodeViewPtrIter it = views.begin(); it != views.end(); ++it)
        {
            layout_.removeWidget(it->get());
            (*it)->hide();
        }
    }

    for(int i = 0; i < rows; ++i)
    {
        for(int j = 0; j < columns; ++j)
        {
            layout_.addWidget(views[i * columns + j].get(), i, j);
            views[i * columns + j]->SetViewMode(mode_);
            views[i * columns + j]->show();
        }
    }
}
コード例 #13
0
ファイル: LabeledSection.cpp プロジェクト: Siddharthk/opticks
void LabeledSection::setSectionWidget(QWidget *pNewSectionWidget)
{
   QGridLayout* pLayout = dynamic_cast<QGridLayout*>(layout());
   VERIFYNRV(pLayout != NULL);

   if (mpSectionWidget != NULL)
   {
      mpSectionWidget->setParent(NULL);
      mpSectionWidget->removeEventFilter(this);
      pLayout->removeWidget(mpSectionWidget);
   }

   mpSectionWidget = pNewSectionWidget;
   if (mpSectionWidget != NULL)
   {
      mpSectionWidget->setParent(this);
      mpSectionWidget->installEventFilter(this);
      pLayout->addWidget(mpSectionWidget, 1, 1, 1, 2);
   }

   updateIndicator();
}
コード例 #14
0
void QGridLayoutProto::removeWidget(QWidget *widget)
{
  QGridLayout *item = qscriptvalue_cast<QGridLayout*>(thisObject());
  if (item)
    item->removeWidget(widget);
}
コード例 #15
0
ファイル: PhotoDrop.cpp プロジェクト: RedCraig/retroshare
void PhotoDrop::reorderPhotos()
{
	std::cerr << "PhotoDrop::reorderPhotos()";
	std::cerr << std::endl;

	/* now move the qwidgets around */
	QLayout *alayout = layout();
	QGridLayout *glayout = dynamic_cast<QGridLayout *>(alayout);
	if (!glayout)
	{
		std::cerr << "PhotoDrop::reorderPhotos() not GridLayout... not much we can do!";
		std::cerr << std::endl;
		return;
	}

	/* grab the first PhotoItem - and get it size */
	std::map<gridIndex, PhotoItem *> photoItems;
	std::map<gridIndex, PhotoItem *>::iterator pit;

	int count = glayout->count();
	int i = 0;
	for(i = 0; i < count; i++)
	{
		QLayoutItem *litem = glayout->itemAt(i);
		if (!litem)
		{
			std::cerr << "PhotoDrop::reorderPhotos() missing litem";
			std::cerr << std::endl;
			continue;
		}

		PhotoItem *item = dynamic_cast<PhotoItem *>(litem->widget());
		if (item)
		{
			
			int selectedRow;
			int selectedColumn;
			int rowSpan;
			int colSpan;
			glayout->getItemPosition(i, &selectedRow, &selectedColumn, &rowSpan, &colSpan);

			std::cerr << "PhotoDrop::reorderPhotos() item: " << item;
			std::cerr << " layoutIdx: " << i;
			std::cerr << " item pos(" << selectedRow << ", " << selectedColumn;
			std::cerr << ")" << std::endl;
			
			gridIndex idx(selectedRow, selectedColumn);
			photoItems[idx] = item;
	
		}
		else
		{
			std::cerr << "PhotoDrop::reorderPhotos() Found Child, which is not a PhotoItem???";
			std::cerr << std::endl;
		}
	}

	pit = photoItems.begin(); 
	if (pit == photoItems.end())
	{
		std::cerr << "PhotoDrop::reorderPhotos() No PhotoItems.";
		std::cerr << std::endl;

		mColumns = 1;

		// no PhotoItems here.
		return;
	}

	int minWidth = (pit->second)->minimumWidth();

#define EXPECTED_WIDTH 	(200)
	if (minWidth < EXPECTED_WIDTH)
	{
		minWidth = EXPECTED_WIDTH;
	}
	int space = width();
	mColumns = space / minWidth;
	// incase its too thin!
	if (mColumns < 1)
	{
		mColumns = 1;
	}

	std::cerr << "PhotoDrop::reorderPhotos() minWidth: " << minWidth << " space: " << space;
	std::cerr << " columns: " << mColumns;
	std::cerr << std::endl;

	std::cerr << "PhotoDrop::reorderPhotos() Getting ordered Items from Layout";
	std::cerr << std::endl;


	for(pit = photoItems.begin(); pit != photoItems.end(); pit++)
	{
		glayout->removeWidget(pit->second);
	}
	
	for(pit = photoItems.begin(), i = 0; pit != photoItems.end(); pit++, i++)
	{
		int row = i / mColumns;
		int column = i % mColumns;

		std::cerr << "Inserting item: " << pit->second << " at (" << row << "," << column << ")";
		std::cerr << std::endl;
		glayout->addWidget(pit->second, row, column, Qt::AlignCenter);
	}
}
コード例 #16
0
void QtGroupBoxPropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index)
{
  WidgetItem *item = m_indexToItem.value(index);

  m_indexToItem.remove(index);
  m_itemToIndex.remove(item);

  WidgetItem *parentItem = item->parent;

  int row = -1;

  if (parentItem)
  {
    row = parentItem->children.indexOf(item);
    parentItem->children.removeAt(row);
    if (hasHeader(parentItem))
      row += 2;
  }
  else
  {
    row = m_children.indexOf(item);
    m_children.removeAt(row);
  }

  if (item->widget)
    delete item->widget;
  if (item->label)
    delete item->label;
  if (item->widgetLabel)
    delete item->widgetLabel;
  if (item->groupBox)
    delete item->groupBox;

  if (!parentItem)
  {
    removeRow(m_mainLayout, row);
  }
  else if (parentItem->children.count() != 0)
  {
    removeRow(parentItem->layout, row);
  }
  else
  {
    WidgetItem *par = parentItem->parent;
    // QWidget *w = 0;
    QGridLayout *l = 0;
    // int oldRow = -1;
    if (!par)
    {
      // w = q_ptr;
      l = m_mainLayout;
      // oldRow = m_children.indexOf(parentItem);
      m_children.indexOf(parentItem);
    }
    else
    {
      // w = par->groupBox;
      l = par->layout;
      // oldRow = par->children.indexOf(parentItem);
      par->children.indexOf(parentItem);
      /*if (hasHeader(par))
        oldRow += 2;
        */
    }

    if (parentItem->widget)
    {
      parentItem->widget->hide();
      parentItem->widget->setParent(0);
    }
    else if (parentItem->widgetLabel)
    {
      parentItem->widgetLabel->hide();
      parentItem->widgetLabel->setParent(0);
    }
    else
    {
      // parentItem->widgetLabel = new QLabel(w);
    }
    l->removeWidget(parentItem->groupBox);
    delete parentItem->groupBox;
    parentItem->groupBox = 0;
    parentItem->line = 0;
    parentItem->layout = 0;
    if (!m_recreateQueue.contains(parentItem))
      m_recreateQueue.append(parentItem);
    updateLater();
  }
  m_recreateQueue.removeAll(item);

  delete item;
}
コード例 #17
0
void QtGroupBoxPropertyBrowserPrivate::propertyInserted(QtBrowserItem *index,
    QtBrowserItem *afterIndex)
{
  WidgetItem *afterItem = m_indexToItem.value(afterIndex);
  WidgetItem *parentItem = m_indexToItem.value(index->parent());

  WidgetItem *newItem = new WidgetItem();
  newItem->parent = parentItem;

  QGridLayout *layout = 0;
  QWidget *parentWidget = 0;
  int row = -1;
  if (!afterItem)
  {
    row = 0;
    if (parentItem)
      parentItem->children.insert(0, newItem);
    else
      m_children.insert(0, newItem);
  }
  else
  {
    if (parentItem)
    {
      row = parentItem->children.indexOf(afterItem) + 1;
      parentItem->children.insert(row, newItem);
    }
    else
    {
      row = m_children.indexOf(afterItem) + 1;
      m_children.insert(row, newItem);
    }
  }
  if (parentItem && hasHeader(parentItem))
    row += 2;

  if (!parentItem)
  {
    layout = m_mainLayout;
    parentWidget = q_ptr;
  }
  else
  {
    if (!parentItem->groupBox)
    {
      m_recreateQueue.removeAll(parentItem);
      WidgetItem *par = parentItem->parent;
      QWidget *w = 0;
      QGridLayout *l = 0;
      int oldRow = -1;
      if (!par)
      {
        w = q_ptr;
        l = m_mainLayout;
        oldRow = m_children.indexOf(parentItem);
      }
      else
      {
        w = par->groupBox;
        l = par->layout;
        oldRow = par->children.indexOf(parentItem);
        if (hasHeader(par))
          oldRow += 2;
      }
      parentItem->groupBox = new QGroupBox(w);
      parentItem->layout = new QGridLayout();
      parentItem->groupBox->setLayout(parentItem->layout);
      if (parentItem->label)
      {
        l->removeWidget(parentItem->label);
        delete parentItem->label;
        parentItem->label = 0;
      }
      if (parentItem->widget)
      {
        l->removeWidget(parentItem->widget);
        parentItem->widget->setParent(parentItem->groupBox);
        parentItem->layout->addWidget(parentItem->widget, 0, 0, 1, 2);
        parentItem->line = new QFrame(parentItem->groupBox);
      }
      else if (parentItem->widgetLabel)
      {
        l->removeWidget(parentItem->widgetLabel);
        delete parentItem->widgetLabel;
        parentItem->widgetLabel = 0;
      }
      if (parentItem->line)
      {
        parentItem->line->setFrameShape(QFrame::HLine);
        parentItem->line->setFrameShadow(QFrame::Sunken);
        parentItem->layout->addWidget(parentItem->line, 1, 0, 1, 2);
      }
      l->addWidget(parentItem->groupBox, oldRow, 0, 1, 2);
      updateItem(parentItem);
    }
    layout = parentItem->layout;
    parentWidget = parentItem->groupBox;
  }

  newItem->label = new QLabel(parentWidget);
  newItem->label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
        QSizePolicy::Fixed));
  newItem->widget = createEditor(index->property(), parentWidget);
  if (!newItem->widget)
  {
    newItem->widgetLabel = new QLabel(parentWidget);
    newItem->widgetLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored,
          QSizePolicy::Fixed));
    newItem->widgetLabel->setTextFormat(Qt::PlainText);
  }
  else
  {
    QObject::connect(newItem->widget, SIGNAL(destroyed()), q_ptr,
        SLOT(slotEditorDestroyed()));
    m_widgetToItem[newItem->widget] = newItem;
  }

  insertRow(layout, row);
  int span = 1;
  if (newItem->widget)
    layout->addWidget(newItem->widget, row, 1);
  else if (newItem->widgetLabel)
    layout->addWidget(newItem->widgetLabel, row, 1);
  else
    span = 2;
  layout->addWidget(newItem->label, row, 0, 1, span);

  m_itemToIndex[newItem] = index;
  m_indexToItem[index] = newItem;

  updateItem(newItem);
}
コード例 #18
0
ファイル: PhotoDrop.cpp プロジェクト: RedCraig/retroshare
void PhotoDrop::moveRight()
{
	std::cerr << "PhotoDrop::moveRight()";
	std::cerr << std::endl;

	QLayout *alayout = layout();
	if (!alayout)
	{
		std::cerr << "PhotoDrop::moveRight() No Layout";
		std::cerr << std::endl;
		return;
	}

	QGridLayout *glayout = dynamic_cast<QGridLayout *>(alayout);
	if (!glayout)
	{
		std::cerr << "PhotoDrop::moveRight() not GridLayout... not much we can do!";
		std::cerr << std::endl;
		return;
	}
	
	int count = alayout->count();
	if ((!mSelected) || (count < 2))
	{
		std::cerr << "PhotoDrop::moveRight() Not enough items";
		std::cerr << std::endl;
		return;
	}

	int index = alayout->indexOf(mSelected);
	int selectedRow;
	int selectedColumn;
	int rowSpan;
	int colSpan;
	glayout->getItemPosition(index, &selectedRow, &selectedColumn, &rowSpan, &colSpan);

	int maxRow = (count - 1) / mColumns;
	int maxCol = (count - 1) % mColumns;
	if ((selectedRow == maxRow) && (selectedColumn == maxCol))
	{
		std::cerr << "PhotoDrop::moveRight() Selected is last item";
		std::cerr << std::endl;
		return;
	}

	int swapRow = selectedRow;
	int swapColumn = selectedColumn + 1;

	if (swapColumn == mColumns)
	{
		swapRow++;
		swapColumn = 0;
	}

	std::cerr << "PhotoDrop::moveRight() Trying to swap (" << selectedRow << ",";
	std::cerr << selectedColumn << ") <-> (" << swapRow;
	std::cerr << "," << swapColumn << ")";
	std::cerr << std::endl;

	QLayoutItem *litem = glayout->itemAtPosition(swapRow, swapColumn);
	if (!litem)
	{
		std::cerr << "PhotoDrop::moveRight() No layout item to the right";
		std::cerr << std::endl;
		return;
	}

	QWidget *widget = litem->widget();

	if (!widget)
	{
		std::cerr << "PhotoDrop::moveRight() No item to the right";
		std::cerr << std::endl;
		return;
	}

	/* grab both items, and switch */
	std::cerr << "PhotoDrop::moveRight() could move index: " << index;
	std::cerr << std::endl;

	glayout->removeWidget(widget);
	glayout->removeWidget(mSelected);

	glayout->addWidget(widget, selectedRow, selectedColumn, Qt::AlignCenter);
	glayout->addWidget(mSelected, swapRow, swapColumn, Qt::AlignCenter);

	checkMoveButtons();
}