示例#1
0
int ComboTabBar::insertTab(int index, const QString &text)
{
    return insertTab(index, QIcon(), text);
}
/**
 *         \fn qt4DiaFactoryRunTabs
 */
uint8_t qt4DiaFactoryRunTabs(const char *title,uint32_t nb,diaElemTabs **tabs)
{
    QDialog dialog(qtLastRegisteredDialog());

        qtRegisterDialog(&dialog);
  
  ADM_assert(title);
  ADM_assert(nb);
  ADM_assert(tabs);
  
  dialog.setWindowTitle(QString::fromUtf8(title));

  QVBoxLayout *vboxLayout = new QVBoxLayout();
  QGridLayout *layout = new QGridLayout();
  QSpacerItem *spacer = new QSpacerItem(20, 16, QSizePolicy::Minimum, QSizePolicy::Fixed);
  QTabWidget *wtabs = new QTabWidget();
  QDialogButtonBox *buttonBox = new QDialogButtonBox();

    buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);

     QObject::connect(buttonBox, SIGNAL(accepted()), &dialog, SLOT(accept()));
     QObject::connect(buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject()));

     for(int i=0;i<nb;i++)
     {
        ADM_assert(tabs[i]);
        insertTab(i,tabs[i],wtabs);
      }

         vboxLayout->addLayout(layout);
     vboxLayout->addWidget(wtabs,0,0);
         vboxLayout->addItem(spacer);
     vboxLayout->addWidget(buttonBox,1,0);

         dialog.setLayout(vboxLayout);

         // Expand to see all tabs but still allow the window to be resized smaller
         wtabs->setUsesScrollButtons(false);
         dialog.adjustSize();
         wtabs->setUsesScrollButtons(true);

  if(dialog.exec()==QDialog::Accepted)
  {
      // Read tabs
       for(int tab=0;tab<nb;tab++)
     {
        ADM_assert(tabs[tab]);
        diaElemTabs *myTab=tabs[tab];
        for(int i=0;i<myTab->nbElems;i++)
        {
          myTab->dias[i]->getMe();
        }
    
      }
           qtUnregisterDialog(&dialog);

      return 1;
  }

  qtUnregisterDialog(&dialog);

  return 0;
  
}
示例#3
0
int ComboTabBar::addTab(const QIcon &icon, const QString &text)
{
    return insertTab(-1, icon, text);
}
void InsertTextCommand::doApply()
{
    ASSERT(m_text.find('\n') == notFound);

    if (!endingSelection().isNonOrphanedCaretOrRange())
        return;

    // Delete the current selection.
    // FIXME: This delete operation blows away the typing style.
    if (endingSelection().isRange()) {
        if (performTrivialReplace(m_text, m_selectInsertedText))
            return;
        deleteSelection(false, true, true, false, false);
        // deleteSelection eventually makes a new endingSelection out of a Position. If that Position doesn't have
        // a renderer (e.g. it is on a <frameset> in the DOM), the VisibleSelection cannot be canonicalized to 
        // anything other than NoSelection. The rest of this function requires a real endingSelection, so bail out.
        if (endingSelection().isNone())
            return;
    } else if (document()->frame()->editor().isOverwriteModeEnabled()) {
        if (performOverwrite(m_text, m_selectInsertedText))
            return;
    }

    Position startPosition(endingSelection().start());
    
    Position placeholder;
    // We want to remove preserved newlines and brs that will collapse (and thus become unnecessary) when content 
    // is inserted just before them.
    // FIXME: We shouldn't really have to do this, but removing placeholders is a workaround for 9661.
    // If the caret is just before a placeholder, downstream will normalize the caret to it.
    Position downstream(startPosition.downstream());
    if (lineBreakExistsAtPosition(downstream)) {
        // FIXME: This doesn't handle placeholders at the end of anonymous blocks.
        VisiblePosition caret(startPosition);
        if (isEndOfBlock(caret) && isStartOfParagraph(caret))
            placeholder = downstream;
        // Don't remove the placeholder yet, otherwise the block we're inserting into would collapse before
        // we get a chance to insert into it.  We check for a placeholder now, though, because doing so requires
        // the creation of a VisiblePosition, and if we did that post-insertion it would force a layout.
    }
    
    // Insert the character at the leftmost candidate.
    startPosition = startPosition.upstream();
    
    // It is possible for the node that contains startPosition to contain only unrendered whitespace,
    // and so deleteInsignificantText could remove it.  Save the position before the node in case that happens.
    Position positionBeforeStartNode(positionInParentBeforeNode(startPosition.containerNode()));
    deleteInsignificantText(startPosition.upstream(), startPosition.downstream());
    if (!startPosition.anchorNode()->inDocument())
        startPosition = positionBeforeStartNode;
    if (!startPosition.isCandidate())
        startPosition = startPosition.downstream();
    
    startPosition = positionAvoidingSpecialElementBoundary(startPosition);
    
    Position endPosition;
    
    if (m_text == "\t") {
        endPosition = insertTab(startPosition);
        startPosition = endPosition.previous();
        if (placeholder.isNotNull())
            removePlaceholderAt(placeholder);
    } else {
        // Make sure the document is set up to receive m_text
        startPosition = positionInsideTextNode(startPosition);
        ASSERT(startPosition.anchorType() == Position::PositionIsOffsetInAnchor);
        ASSERT(startPosition.containerNode());
        ASSERT(startPosition.containerNode()->isTextNode());
        if (placeholder.isNotNull())
            removePlaceholderAt(placeholder);
        RefPtr<Text> textNode = startPosition.containerText();
        const unsigned offset = startPosition.offsetInContainerNode();

        insertTextIntoNode(textNode, offset, m_text);
        endPosition = Position(textNode, offset + m_text.length());
        if (m_markerSupplier)
            m_markerSupplier->addMarkersToTextNode(textNode.get(), offset, m_text);

        if (m_rebalanceType == RebalanceLeadingAndTrailingWhitespaces) {
            // The insertion may require adjusting adjacent whitespace, if it is present.
            rebalanceWhitespaceAt(endPosition);
            // Rebalancing on both sides isn't necessary if we've inserted only spaces.
            if (!shouldRebalanceLeadingWhitespaceFor(m_text))
                rebalanceWhitespaceAt(startPosition);
        } else {
            ASSERT(m_rebalanceType == RebalanceAllWhitespaces);
            if (canRebalance(startPosition) && canRebalance(endPosition))
                rebalanceWhitespaceOnTextSubstring(textNode, startPosition.offsetInContainerNode(), endPosition.offsetInContainerNode());
        }
    }

    setEndingSelectionWithoutValidation(startPosition, endPosition);

    // Handle the case where there is a typing style.
    if (RefPtr<EditingStyle> typingStyle = document()->frame()->selection()->typingStyle()) {
        typingStyle->prepareToApplyAt(endPosition, EditingStyle::PreserveWritingDirection);
        if (!typingStyle->isEmpty())
            applyStyle(typingStyle.get());
    }

    if (!m_selectInsertedText)
        setEndingSelection(VisibleSelection(endingSelection().end(), endingSelection().affinity(), endingSelection().isDirectional()));
}
void InsertTextCommand::input(const String& text, bool selectInsertedText)
{
    
    ASSERT(text.find('\n') == notFound);

    if (!endingSelection().isNonOrphanedCaretOrRange())
        return;

    // Delete the current selection.
    // FIXME: This delete operation blows away the typing style.
    if (endingSelection().isRange()) {
        if (performTrivialReplace(text, selectInsertedText))
            return;
        deleteSelection(false, true, true, false);
    }

    Position startPosition(endingSelection().start());
    
    Position placeholder;
    // We want to remove preserved newlines and brs that will collapse (and thus become unnecessary) when content 
    // is inserted just before them.
    // FIXME: We shouldn't really have to do this, but removing placeholders is a workaround for 9661.
    // If the caret is just before a placeholder, downstream will normalize the caret to it.
    Position downstream(startPosition.downstream());
    if (lineBreakExistsAtPosition(downstream)) {
        // FIXME: This doesn't handle placeholders at the end of anonymous blocks.
        VisiblePosition caret(startPosition);
        if (isEndOfBlock(caret) && isStartOfParagraph(caret))
            placeholder = downstream;
        // Don't remove the placeholder yet, otherwise the block we're inserting into would collapse before
        // we get a chance to insert into it.  We check for a placeholder now, though, because doing so requires
        // the creation of a VisiblePosition, and if we did that post-insertion it would force a layout.
    }
    
    // Insert the character at the leftmost candidate.
    startPosition = startPosition.upstream();
    
    // It is possible for the node that contains startPosition to contain only unrendered whitespace,
    // and so deleteInsignificantText could remove it.  Save the position before the node in case that happens.
    Position positionBeforeStartNode(positionInParentBeforeNode(startPosition.node()));
    deleteInsignificantText(startPosition.upstream(), startPosition.downstream());
    if (!startPosition.node()->inDocument())
        startPosition = positionBeforeStartNode;
    if (!startPosition.isCandidate())
        startPosition = startPosition.downstream();
    
    startPosition = positionAvoidingSpecialElementBoundary(startPosition);
    
    Position endPosition;
    
    if (text == "\t") {
        endPosition = insertTab(startPosition);
        startPosition = endPosition.previous();
        if (placeholder.isNotNull())
            removePlaceholderAt(placeholder);
        m_charactersAdded += 1;
    } else {
        // Make sure the document is set up to receive text
        startPosition = prepareForTextInsertion(startPosition);
        if (placeholder.isNotNull())
            removePlaceholderAt(placeholder);
        Text *textNode = static_cast<Text *>(startPosition.node());
        int offset = startPosition.deprecatedEditingOffset();

        insertTextIntoNode(textNode, offset, text);
        endPosition = Position(textNode, offset + text.length());

        // The insertion may require adjusting adjacent whitespace, if it is present.
        rebalanceWhitespaceAt(endPosition);
        // Rebalancing on both sides isn't necessary if we've inserted a space.
        if (text != " ") 
            rebalanceWhitespaceAt(startPosition);
            
        m_charactersAdded += text.length();
    }

    // We could have inserted a part of composed character sequence,
    // so we are basically treating ending selection as a range to avoid validation.
    // <http://bugs.webkit.org/show_bug.cgi?id=15781>
    VisibleSelection forcedEndingSelection;
    forcedEndingSelection.setWithoutValidation(startPosition, endPosition);
    setEndingSelection(forcedEndingSelection);

    // Handle the case where there is a typing style.
    CSSMutableStyleDeclaration* typingStyle = document()->frame()->selection()->typingStyle();
    RefPtr<CSSComputedStyleDeclaration> endingStyle = endPosition.computedStyle();
    RefPtr<CSSValue> unicodeBidi;
    RefPtr<CSSValue> direction;
    if (typingStyle) {
        unicodeBidi = typingStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi);
        direction = typingStyle->getPropertyCSSValue(CSSPropertyDirection);
    }
    endingStyle->diff(typingStyle);
    if (typingStyle && unicodeBidi) {
        ASSERT(unicodeBidi->isPrimitiveValue());
        typingStyle->setProperty(CSSPropertyUnicodeBidi, static_cast<CSSPrimitiveValue*>(unicodeBidi.get())->getIdent());
        if (direction) {
            ASSERT(direction->isPrimitiveValue());
            typingStyle->setProperty(CSSPropertyDirection, static_cast<CSSPrimitiveValue*>(direction.get())->getIdent());
        }
    }

    if (typingStyle && typingStyle->length())
        applyStyle(typingStyle);

    if (!selectInsertedText)
        setEndingSelection(VisibleSelection(endingSelection().end(), endingSelection().affinity()));
}
示例#6
0
文件: tabwidget.cpp 项目: bochi/kueue
TabWidget::TabWidget( QWidget* parent )
{
    qDebug() << "[TABWIDGET] Constructing";

    mGrabbedWidget = 0;
    mTabs = 0;

    // set the tab position

    setTabsPosition();
    mStatusBar = &mStatusBar->getInstance();

    // create the tabbar

    mBar = new TabBar;
    setTabBar( mBar );

    // connect the mouse clicks

    connect( mBar, SIGNAL( tabRightClicked( int, QPoint ) ),
             this, SLOT( tabRightClicked( int, QPoint ) ) );

    connect( mBar, SIGNAL( tabMiddleClicked( int, QPoint ) ),
             this, SLOT( tabMiddleClicked( int, QPoint ) ) );

    TabButton* newTabButton = new TabButton( this );
    TabButton* mMenuButton = new TabButton( this );

    connect( newTabButton, SIGNAL( clicked() ),
             this, SLOT( addUnityBrowser()) );

    connect( newTabButton, SIGNAL( middleClicked() ),
             this, SLOT( addUnityBrowserWithSR() ) );

    connect( mMenuButton, SIGNAL( clicked() ),
             mMenuButton, SLOT( showMenu()) );

    mMenuButton->setMenu( kueueMainMenu() );

    newTabButton->setIcon( QIcon( ":icons/menus/newtab.png" ) );
    mMenuButton->setIcon( QIcon(":/icons/kueue.png") );

    if ( Settings::unityEnabled() )
    {
        setCornerWidget( newTabButton, Qt::TopRightCorner );
    }

    setCornerWidget( mMenuButton, Qt::TopLeftCorner );

    // create the main browser tabs...

    mQueueBrowser = new QueueBrowser( this );

    mSubownerBrowser = new SubownerBrowser( this );

    mPersonalTab = new BrowserWithSearch( mQueueBrowser, this );

    mSubownerTab = new BrowserWithSearch( mSubownerBrowser, this );

    connect( mQueueBrowser, SIGNAL( setMenus() ),
             this, SLOT( setMenus() ) );

    connect( mSubownerBrowser, SIGNAL( setMenus() ),
             this, SLOT( setMenus() ) );

    connect( mQueueBrowser, SIGNAL( expandAll() ),
             this, SLOT( expandAllTables() ) );

    connect( mQueueBrowser, SIGNAL( closeAll() ),
             this, SLOT( closeAllTables() ) );

    mQmonBrowser = new QMonBrowser( this );
    mMonitorTab = new BrowserWithSearch( mQmonBrowser, this );

    mStatsBrowser = new StatsBrowser( this );
    mStatsTab = new BrowserWithSearch( mStatsBrowser, this );

    if ( Settings::unityEnabled() )
    {
        addUnityBrowser();
        rebuildMaps();
    }

    mSubVisible = true;

    // ...and add them to the tabbar

    insertTab( 0, mPersonalTab, QIcon( ":icons/conf/targets.png" ), "Personal queue" );
    insertTab( 1, mSubownerTab, QIcon( ":icons/conf/targets.png" ), "Subowned SRs" );
    insertTab( 2, mMonitorTab, QIcon( ":/icons/conf/monitor.png" ), "Queue monitor" );
    insertTab( 3, mStatsTab, QIcon( ":/icons/conf/stats.png" ), "Statistics" );

    QShortcut* search = new QShortcut( QKeySequence( Qt::CTRL + Qt::Key_F ), this );

    connect( search, SIGNAL( activated() ),
             this, SLOT( showSearch() ) );

    refreshTabs();
}
示例#7
0
DebuggerUI::DebuggerUI(QWidget* parent, const char *name)
  : KTabWidget(parent, name)
{  
  setGeometry(0,0,0,height()/15);
  QWidget* globalVarTab = new QWidget(this);
  QVBoxLayout* globalVarTabLayout = new QVBoxLayout(globalVarTab, 1, 1);

  m_globalVariableListView = new VariableListView(DebuggerUI::GlobalVarListID, globalVarTab);
  globalVarTabLayout->addWidget(m_globalVariableListView);
  insertTab(globalVarTab, i18n("Global"));

  m_localTab = new LocalTab(this);
  insertTab(m_localTab, i18n("Local"));

  m_watchTab = new WatchTab(this);
  insertTab(m_watchTab, i18n("Watch"));

  QWidget* breakpointTab = new QWidget(this);
  QVBoxLayout* breakpointTabLayout = new QVBoxLayout(breakpointTab, 1, 1);

  m_breakpointListView = new BreakpointListView(breakpointTab);
  breakpointTabLayout->addWidget(m_breakpointListView);
  insertTab(breakpointTab, i18n("Breakpoints"));

  QWidget* messageTab = new QWidget(this);
  QVBoxLayout* logTabLayout = new QVBoxLayout(messageTab, 1, 1);

  m_messageListView = new MessageListView(messageTab);
  logTabLayout->addWidget(m_messageListView);
  insertTab(messageTab, i18n("Messages"));

  QWidget* outputTab = new QWidget(this);
  QVBoxLayout* outputTabLayout = new QVBoxLayout(outputTab, 1, 1);

  m_edOutput = new KTextEdit(outputTab);
  outputTabLayout->addWidget(m_edOutput);
  m_edOutput->setReadOnly(true);
  m_edOutput->setTextFormat(Qt::PlainText);
  m_edOutput->setPaper(QBrush(QColor("white")));
  insertTab(outputTab, i18n("Output"));

//   m_console = new ConsoleWidget(this);
//   insertTab(m_console, i18n("Console"));


  connect(m_globalVariableListView, SIGNAL(sigVarModified(Variable*)),
    this, SIGNAL(sigGlobalVarModified(Variable*)));

  connect(m_globalVariableListView, SIGNAL(sigNeedChildren(int, Variable*)),
    this, SLOT(slotNeedChildren( int, Variable* )));

  connect(m_localTab->localVarList(), SIGNAL(sigVarModified(Variable*)),
    this, SIGNAL(sigLocalVarModified(Variable*)));

  connect(m_localTab->localVarList(), SIGNAL(sigNeedChildren(int, Variable*)),
    this, SLOT(slotNeedChildren( int, Variable* )));

  connect(m_localTab->comboStack(), 
      SIGNAL(changed(DebuggerExecutionPoint*, DebuggerExecutionPoint*)),
      this, SIGNAL(sigStackchanged(DebuggerExecutionPoint*, DebuggerExecutionPoint*)));

  connect(m_watchTab, SIGNAL(sigWatchAdded(const QString&)),
    this, SIGNAL(sigWatchAdded(const QString&)));

  connect(m_watchTab->watchListView(), SIGNAL(sigVarModified(Variable*)),
    this, SIGNAL(sigWatchModified(Variable*)));

  connect(m_watchTab->watchListView(), SIGNAL(sigWatchRemoved(Variable*)),
    this, SIGNAL(sigWatchRemoved(Variable*)));

  connect(m_watchTab->watchListView(), SIGNAL(sigNeedChildren(int, Variable*)),
    this, SLOT(slotNeedChildren( int, Variable* )));

  connect(m_breakpointListView, SIGNAL(sigBreakpointChanged(DebuggerBreakpoint*)),
    this, SIGNAL(sigBreakpointChanged(DebuggerBreakpoint*)));

  connect(m_breakpointListView, SIGNAL(sigBreakpointCreated(DebuggerBreakpoint*)),
    this, SIGNAL(sigBreakpointCreated(DebuggerBreakpoint*)));

  connect(m_breakpointListView, SIGNAL(sigBreakpointRemoved(DebuggerBreakpoint*)),
    this, SIGNAL(sigBreakpointRemoved(DebuggerBreakpoint*)));

  connect(m_breakpointListView, SIGNAL(sigDoubleClick(const KURL&, int)),
    this, SIGNAL(sigGotoFileAndLine(const KURL&, int)));

  connect(m_messageListView, SIGNAL(sigDoubleClick(const KURL&, int)),
    this, SIGNAL(sigGotoFileAndLine(const KURL&, int)));

// //   connect(m_console, SIGNAL(sigExecuteCmd(const QString&)),
// //     this, SIGNAL(sigExecuteCmd(const QString&)));
}
/*!
    \overload

    This is a low-level function for adding tabs. It is useful if you
    are using setTabBar() to set a QTabBar subclass with an overridden
    QTabBar::paint() function for a subclass of QTab. The \a child is
    the new page and \a tab is the tab to put the \a child on.
*/
void QTabWidget::addTab( QWidget *child, QTab* tab )
{
    insertTab( child, tab );
}
/*!
    \overload

    Adds another tab and page to the tab view.

    This function is the same as addTab(), but with an additional \a
    iconset.
*/
void QTabWidget::addTab( QWidget *child, const QIconSet& iconset, const QString &label )
{
    insertTab( child, iconset, label );
}
/*!
    Adds another tab and page to the tab view.

    The new page is \a child; the tab's label is \a label. Note the
    difference between the widget name (which you supply to widget
    constructors and to setTabEnabled(), for example) and the tab
    label. The name is internal to the program and invariant, whereas
    the label is shown on-screen and may vary according to language
    and other factors.

    If the tab's \a label contains an ampersand, the letter following
    the ampersand is used as an accelerator for the tab, e.g. if the
    label is "Bro\&wse" then Alt+W becomes an accelerator which will
    move the focus to this tab.

    If you call addTab() after show() the screen will flicker and the
    user may be confused.

    \sa insertTab()
*/
void QTabWidget::addTab( QWidget *child, const QString &label)
{
    insertTab( child, label );
}