void MToolBarLayoutPolicy::insertWidgetAndRemoveOverflow(int widgetIndex, QGraphicsLayoutItem *item)
{
    widgetIndex = qMin((uint)widgetIndex, (uint)widgetCount());
    Q_ASSERT(item);

    //A ugly hack to try to cope with QTBUG-11134
    item->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);

    if (dynamic_cast<MTextEdit *>(item->graphicsItem())) {
        if (textEditIndex != -1)  //Remove any previous text edit
            removeWidgetAtPreservingSpacers(textEditIndex);
        textEditIndex = widgetIndex;
    } else if (widgetIndex <= textEditIndex)
        textEditIndex++;

    int policyIndex = widgetIndexToPolicyIndex(widgetIndex);
    Q_ASSERT(MLinearLayoutPolicy::count() >= policyIndex);

    if (widgetCount() > 0) {
        bool lastItem = (widgetIndex == widgetCount());
        if (lastItem) {
            MLinearLayoutPolicy::insertItem(policyIndex-1, item, Qt::AlignVCenter);
            insertSpacer(policyIndex-1);
        } else {
            MLinearLayoutPolicy::insertItem(policyIndex, item, Qt::AlignVCenter);
            insertSpacer(policyIndex+1);
        }
    } else
        MLinearLayoutPolicy::insertItem(policyIndex, item, Qt::AlignVCenter);

    updateLayoutPositionDueToInsert(widgetIndex);
    removeOverflownWidgets();
    updateSpacers();
}
Ejemplo n.º 2
0
ToolBarEditor::ToolBarEditor(QWidget *parent)
  : QWidget(parent), m_ui(new Ui::ToolBarEditor) {
  m_ui->setupUi(this);

  // Create connections.
  connect(m_ui->m_btnInsertSeparator, SIGNAL(clicked()), this, SLOT(insertSeparator()));
  connect(m_ui->m_btnInsertSpacer, SIGNAL(clicked()), this, SLOT(insertSpacer()));

  connect(m_ui->m_btnAddSelectedAction, SIGNAL(clicked()), this, SLOT(addSelectedAction()));
  connect(m_ui->m_btnDeleteAllActions, SIGNAL(clicked()), this, SLOT(deleteAllActions()));
  connect(m_ui->m_btnDeleteSelectedAction, SIGNAL(clicked()), this, SLOT(deleteSelectedAction()));
  connect(m_ui->m_btnMoveActionUp, SIGNAL(clicked()), this, SLOT(moveActionUp()));
  connect(m_ui->m_btnMoveActionDown, SIGNAL(clicked()), this, SLOT(moveActionDown()));

  connect(m_ui->m_listAvailableActions, SIGNAL(itemSelectionChanged()), this, SLOT(updateActionsAvailability()));
  connect(m_ui->m_listActivatedActions, SIGNAL(itemSelectionChanged()), this, SLOT(updateActionsAvailability()));
  connect(m_ui->m_listActivatedActions, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(deleteSelectedAction()));
  connect(m_ui->m_listAvailableActions, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(addSelectedAction()));

  m_ui->m_listActivatedActions->installEventFilter(this);
}
void Sliderule :: insertBlankSpacer (int height) {
	insertSpacer (height);
	for (int ind = 0; ind < 16; ind++) {root -> root -> draw_lines [ind] = false;}
}