Exemple #1
0
WinConfig::WinConfig(QWidget *parent):
    QFrame(parent),m_drag(false)
{
    p_viewPort = new QFrame(this);
    p_viewPort->setObjectName("ViewPortWidget");
    p_viewPort->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding);
//    this->setMouseTracking(true);
    p_layout = new QVBoxLayout(p_viewPort);
    p_layout->addStretch();
    qDebug()<<p_layout->count();
    p_slider = new QSlider(Qt::Vertical,this);
    p_slider->resize(15,100);
    p_slider->setObjectName("Slider");
    p_slider->setRange(1,100);
    p_slider->setValue(100);
    connect(p_slider,SIGNAL(valueChanged(int)),this,SLOT(slotValueChanged(int)));

    p_upBtn = new QPushButton(this);
    p_upBtn->setObjectName("UpButton");
    p_upBtn->setAutoRepeat(true);
    connect(p_upBtn,SIGNAL(clicked()),this,SLOT(slotUpButtonClicked()));
    p_downBtn = new QPushButton(this);
    p_downBtn->setObjectName("DownButton");
    p_downBtn->setAutoRepeat(true);
    connect(p_downBtn,SIGNAL(clicked()),this,SLOT(slotDownButtonClicked()));
    p_timer = new QTimer(this);
    connect(p_timer,SIGNAL(timeout()),this,SLOT(slotHideSlider()));

    setStyleSheet("WinConfig{background-color:rgb(0,0,255);}QFrame#ViewPortWidget{background-color:rgb(0,0,0);}QPushButton{min-height:30px;}");
    slotHideSlider();
//    init();
}
Kleo::DNAttributeOrderConfigWidget::DNAttributeOrderConfigWidget( DNAttributeMapper * mapper, QWidget * parent, Qt::WindowFlags f )
  : QWidget( parent, f ), d( new Private )
{
  assert( mapper );
  d->mapper = mapper;

  QGridLayout * glay = new QGridLayout( this );
  glay->setMargin( 0 );
  glay->setSpacing( KDialog::spacingHint() );
  glay->setColumnStretch( 0, 1 );
  glay->setColumnStretch( 2, 1 );

  int row = -1;

  ++row;
  glay->addWidget( new QLabel( i18n("Available attributes:"), this ), row, 0 );
  glay->addWidget( new QLabel( i18n("Current attribute order:"), this ), row, 2 );


  ++row;
  glay->setRowStretch( row, 1 );

  d->availableLV = new Q3ListView( this );
  prepare( d->availableLV );
  d->availableLV->setSorting( 0 );
  glay->addWidget( d->availableLV, row, 0 );

  d->currentLV = new Q3ListView( this );
  prepare( d->currentLV );
  d->currentLV->setSorting( -1 );
  glay->addWidget( d->currentLV, row, 2 );

  connect( d->availableLV, SIGNAL(clicked(Q3ListViewItem*)),
	   SLOT(slotAvailableSelectionChanged(Q3ListViewItem*)) );
  connect( d->currentLV, SIGNAL(clicked(Q3ListViewItem*)),
	   SLOT(slotCurrentOrderSelectionChanged(Q3ListViewItem*)) );

  d->placeHolderItem = new Q3ListViewItem( d->availableLV, "_X_", i18n("All others") );

  // the up/down/left/right arrow cross:

  QGridLayout * xlay = new QGridLayout();
  xlay->setSpacing( 0 );
  xlay->setObjectName( "xlay" );
  xlay->setAlignment( Qt::AlignCenter );

  static const struct {
    const char * icon;
    int row, col;
    const char * tooltip;
    const char * slot;
  } navButtons[] = {
    { "go-top",    0, 1, I18N_NOOP( "Move to top" ),    SLOT(slotDoubleUpButtonClicked()) },
    { "go-up",    1, 1, I18N_NOOP( "Move one up" ),    SLOT(slotUpButtonClicked()) },
    { "go-previous",  2, 0, I18N_NOOP( "Remove from current attribute order" ), SLOT(slotLeftButtonClicked()) },
    { "go-next", 2, 2, I18N_NOOP( "Add to current attribute order" ), SLOT(slotRightButtonClicked()) },
    { "go-down",  3, 1, I18N_NOOP( "Move one down" ),  SLOT(slotDownButtonClicked()) },
    { "go-bottom",  4, 1, I18N_NOOP( "Move to bottom" ), SLOT(slotDoubleDownButtonClicked()) }
  };

  for ( unsigned int i = 0 ; i < sizeof navButtons / sizeof *navButtons ; ++i ) {
    QToolButton * tb = d->navTB[i] = new QToolButton( this );
    tb->setIcon( KIcon( navButtons[i].icon ) );
    tb->setEnabled( false );
    tb->setToolTip( i18n( navButtons[i].tooltip ) );
    xlay->addWidget( tb, navButtons[i].row, navButtons[i].col );
    connect( tb, SIGNAL(clicked()), navButtons[i].slot );
  }

  glay->addLayout( xlay, row, 1 );
}