Пример #1
0
int QBoxLayoutProto::indexOf(QWidget *widget) const
{
  QBoxLayout *item = qscriptvalue_cast<QBoxLayout*>(thisObject());
  if (item)
    return item->indexOf(widget);
  return 0;
}
Пример #2
0
void tst_QBoxLayout::replaceWidget()
{
    QWidget w;
    QBoxLayout *boxLayout = new QVBoxLayout(&w);

    QLineEdit *replaceFrom = new QLineEdit;
    QLineEdit *replaceTo = new QLineEdit;
    boxLayout->addWidget(new QLineEdit());
    boxLayout->addWidget(replaceFrom);
    boxLayout->addWidget(new QLineEdit());

    QCOMPARE(boxLayout->indexOf(replaceFrom), 1);
    QCOMPARE(boxLayout->indexOf(replaceTo), -1);
    boxLayout->replaceWidget(replaceFrom, replaceTo);

    QCOMPARE(boxLayout->indexOf(replaceFrom), -1);
    QCOMPARE(boxLayout->indexOf(replaceTo), 1);
}
Пример #3
0
void TestBox::stretchRequested(int i) {
    int val = stretch->itemData(i).value<int>();

    QObject* pa = parent();
    QWidget* parent = qobject_cast<QWidget*>(pa);
    if (parent->layout()->inherits("QBoxLayout")) {
        QBoxLayout* box = qobject_cast<QBoxLayout*>(parent->layout());
        box->setStretch(box->indexOf(this), val);
    }
    /*else if (parent->layout()->inherits("QGridLayout")) {
        QGridLayout* grid = qobject_cast<QGridLayout*>(parent->layout());
        int index = grid->indexOf(this);
        int row = index/2;
        int col = index%2;
        grid->setRowStretch(row, val);
        grid->setColumnStretch(col, val);
    }*/
}
Пример #4
0
void replaceWidget(QWidget *a, QWidget *b)
{
	if(!a) {
		return;
	}

	QLayout *lo = rw_findLayoutOf(a);
	if(!lo) {
		return;
	}
	//printf("decided on this: %p\n", lo);

	if(lo->inherits("QBoxLayout")) {
		QBoxLayout *bo = (QBoxLayout *)lo;
		int n = bo->indexOf(a);
		bo->insertWidget(n+1, b);
		delete a;
	}
}
logical OControlLayout :: PositionElement (ODataWidget *pODataWidget, ADK_VertPos verti_pos, ADK_HoriPos hori_pos )
{
  QBoxLayout            *layout = NULL;
  logical                term   = NO;
  switch ( verti_pos )
  {
    case VPS_OuterTop : 
         switch ( hori_pos )
         {
           case HPS_OuterLeft  : layout = ProvideCornerLayout(0,Qt::AlignBottom | Qt::AlignRight);
                                 break;
           case HPS_OuterRight : layout = ProvideCornerLayout(1,Qt::AlignBottom | Qt::AlignLeft);
                                 break;
           case HPS_InnerLeft  : layout = ProvideTopLayout(Qt::AlignLeft);
                                 break;
           case HPS_InnerRight : layout = ProvideTopLayout(Qt::AlignRight);
                                 break;
           default             : ;
         }
         break;
    
    case VPS_InnerTop :
         switch ( hori_pos )
         {
           case HPS_OuterLeft  : layout = ProvideLeftLayout(Qt::AlignTop);
                                 break;
           case HPS_OuterRight : layout = ProvideRightLayout(Qt::AlignTop);
                                 break;
           default             : ;
         }
         break;
    
    case VPS_InnerBottom :
         switch ( hori_pos )
         {
           case HPS_OuterLeft  : layout = ProvideLeftLayout(Qt::AlignBottom);
                                 break;
           case HPS_OuterRight : layout = ProvideRightLayout(Qt::AlignBottom);
                                 break;
           default             : ;
         }
         break;
    
    case VPS_OuterBottom : 
         switch ( hori_pos )
         {
           case HPS_OuterLeft  : layout = ProvideCornerLayout(2,Qt::AlignTop | Qt::AlignRight);
                                 break;
           case HPS_OuterRight : layout = ProvideCornerLayout(3,Qt::AlignTop | Qt::AlignLeft);
                                 break;
           case HPS_InnerLeft  : layout = ProvideBottomLayout(Qt::AlignLeft);
                                 break;
           case HPS_InnerRight : layout = ProvideBottomLayout(Qt::AlignRight);
                                 break;
           default             : ;
         }
    break;
    default : ;
  }

  if ( layout && layout->indexOf(pODataWidget->WidgetQ()) < 0 )
    layout->addWidget(pODataWidget->WidgetQ());

  return(term);
}
Пример #6
0
pFileDialog::pFileDialog( QWidget* parent, const QString& caption, const QString& directory, const QString& filter, bool textCodecEnabled, bool openReadOnlyEnabled )
	: QFileDialog( parent, caption, directory, filter )
{
	setFileMode( QFileDialog::AnyFile );
	setOption( QFileDialog::DontUseNativeDialog );
	
	// get grid layout
	glDialog = qobject_cast<QGridLayout*>( layout() );
	
	// assert on gridlayout
	Q_ASSERT( glDialog );
	
	// relook the dialog to be more friendly
	QLabel* lLookIn = findChild<QLabel*>( "lookInLabel" );
	QComboBox* cbLookIn = findChild<QComboBox*>( "lookInCombo" );
	QToolButton* tbNewFolder = findChild<QToolButton*>( "newFolderButton" );
	QAbstractItemView* sidebar = findChild<QAbstractItemView*>( "sidebar" );
	QFrame* fFrame = findChild<QFrame*>( "frame" );
	QBoxLayout* hLayout = 0;
	
	// search layout containing tbNewFolder
	foreach ( QLayout* layout, findChildren<QLayout*>() ) {
		if ( layout->indexOf( tbNewFolder ) != -1 ) {
			hLayout = qobject_cast<QBoxLayout*>( layout );
			break;
		}
	}
	
	if ( lLookIn ) {
		lLookIn->setVisible( false );
	}
	
	if ( hLayout ) {
		hLayout->setSpacing( 3 );
		hLayout->insertStretch( hLayout->indexOf( tbNewFolder ) );
	}
	
	if ( cbLookIn && fFrame ) {
		QBoxLayout* vLayout = qobject_cast<QBoxLayout*>( fFrame->layout() );
		
		if ( vLayout ) {
			vLayout->setSpacing( 3 );
			vLayout->insertWidget( 0, cbLookIn );
			
			if ( hLayout ) {
				glDialog->removeItem( hLayout );
				hLayout->setParent( 0 );
				vLayout->insertLayout( 0, hLayout );
			}
		}
	}
	
	if ( sidebar ) {
		QWidget* viewport = sidebar->viewport();
		QPalette pal = viewport->palette();
		pal.setColor( viewport->backgroundRole(), QColor( Qt::transparent ) );
		viewport->setPalette( pal );
		sidebar->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
		sidebar->setIconSize( QSize( 16, 16 ) );
	}
	
	// text codec
	mTextCodecEnabled = true;
	
	lCodec = new QLabel( tr( "Codec:" ), this );
	cbCodec = new QComboBox( this );
	cbCodec->addItems( pCoreUtils::textCodecs() );
	setTextCodec( QTextCodec::codecForLocale()->name() );
	
	glDialog->addWidget( lCodec, 4, 0 );
	glDialog->addWidget( cbCodec, 4, 1 );
	
	// read only
	mOpenReadOnlyEnabled = true;
	
	cbOpenReadOnly = new QCheckBox( tr( "Open in read only." ), this );
	
	glDialog->addWidget( cbOpenReadOnly, 5, 1 );
	
	// configuration
	setTextCodecEnabled( textCodecEnabled );
	setOpenReadOnlyEnabled( openReadOnlyEnabled );
}