Ejemplo n.º 1
0
int main(int argc, char* argv[])
{
    QApplication app(argc, argv);

    QFrame frame;
    QVBoxLayout verticalLayout;
    QLineEdit filterText;

    ProblemsTableModel submissions;

    // add data here

    QSortFilterProxyModel proxy;
    proxy.setSortCaseSensitivity(Qt::CaseInsensitive);
    proxy.setFilterCaseSensitivity(Qt::CaseInsensitive);
    proxy.setSourceModel(&submissions);
    // sort and filter by "Full name" column
    proxy.setFilterKeyColumn(2);

    QTableView tableView;
    tableView.setModel(&proxy);
    tableView.setSortingEnabled(true);

    verticalLayout.addWidget(&filterText);
    verticalLayout.addWidget(&tableView);
    frame.setLayout(&verticalLayout);

    QObject::connect(&filterText, &QLineEdit::textChanged, &proxy, &QSortFilterProxyModel::setFilterFixedString);

    frame.show();

    return app.exec();
}
void kiptablesgenerator::setupNewHostDialog()
{
  newHostDialog = new KDialogBase(this, 0, true, i18n("Add Host"), KDialogBase::Ok | KDialogBase::Cancel);
  
  QFrame *dialogArea = new QFrame(newHostDialog);
  QGridLayout *layout = new QGridLayout(dialogArea, 5, 2);
  
  QLabel *intro = new QLabel(i18n(
    "<p>Here you can tell netfilter to allow all connections from a given host regardless of other rules, "
    "or block all connections from a given host regardless of other rules.</p>"
    "<p>You can specify a host either by IP address or MAC address.</p>"), dialogArea);
  intro->show();
  layout->addMultiCellWidget(intro, 0, 0, 0, 1);

  QButtonGroup *whitelistOrBlacklist = new QButtonGroup(dialogArea);
  whitelistOrBlacklist->hide();
  
  QRadioButton *whitelist = new QRadioButton(i18n("&Allow"), dialogArea);
  whitelist->setChecked(true);
  whitelist->show();
  layout->addWidget(whitelist, 1, 0);
  namedWidgets["newHost_allow"] = whitelist;
  whitelistOrBlacklist->insert(whitelist);
  
  QRadioButton *blacklist = new QRadioButton(i18n("&Block"), dialogArea);
  blacklist->setChecked(false);
  blacklist->show();
  layout->addWidget(blacklist, 1, 1);
  whitelistOrBlacklist->insert(blacklist);
  
  QButtonGroup *ipOrMAC = new QButtonGroup(dialogArea);
  ipOrMAC->hide();
  
  QRadioButton *useIP = new QRadioButton(i18n("&Use IP"), dialogArea);
  useIP->setChecked(true);
  useIP->show();
  layout->addWidget(useIP, 2, 0);
  namedWidgets["newHost_useIP"] = useIP;
  ipOrMAC->insert(useIP);
  
  QRadioButton *useMAC = new QRadioButton(i18n("U&se MAC"), dialogArea);
  useMAC->show();
  layout->addWidget(useMAC, 2, 1);
  ipOrMAC->insert(useMAC);
  
  QLabel *hostLabel = new QLabel(i18n("Host:"), dialogArea);
  hostLabel->show();
  layout->addMultiCellWidget(hostLabel, 3, 3, 0, 1);
  
  KLineEdit *host = new KLineEdit(dialogArea);
  host->show();
  namedWidgets["newHost_address"] = host;
  layout->addMultiCellWidget(host, 4, 4, 0, 1);
  
  connect(newHostDialog, SIGNAL(okClicked()), this, SLOT(slotAddHost()));
  
  dialogArea->show();
  newHostDialog->setMainWidget(dialogArea);
}
Ejemplo n.º 3
0
void FilmListItemWidget::mouseReleaseEvent(QMouseEvent*){
    this->setStyleSheet("FilmListItemWidget { background-color: #ddffdd} ");
    QFrame* popup = new QFrame(FilterForm::instance, Qt::Popup | Qt::Dialog);
    popup->resize(560,220);
    popup->setFrameStyle(6);
    new FilmDisplay(popup, film_);
    popup->show();
}
Ejemplo n.º 4
0
/**
 * Entry point of the program. Creates a new Qt application
 * and makes the window visible.
 */
int main( int argc, char * argv[] )
{
	QApplication app(argc, argv);
	app.setApplicationName("XY Model");
	
	QFrame* mainFrame = new SimulationWidget();
	mainFrame->show();
	
	return app.exec();
}
void kiptablesgenerator::setupNewForwardDialog()
{
  newForwardDialog = new KDialogBase(this, 0, true, i18n("Add Forward"), KDialogBase::Ok | KDialogBase::Cancel);
  
  QFrame *dialogArea = new QFrame(newForwardDialog);
  QGridLayout *layout = new QGridLayout(dialogArea, 4, 2);
  
  QLabel *intro = new QLabel(i18n(
      "<p><i>Advanced users only</i></p>"
      "<p>Here you can tell netfilter to forward connections to given ports to another address/port.</p>"
      "<p>This is using netfilter's DNAT functionality - incoming redirects go in the prerouting chain,"
      "outgoing redirects go in the output chain.</p>"
      "<p>The destination should be of the from destination.computer.ip.address:destinationPort</p>"), dialogArea);
  intro->show();
  layout->addMultiCellWidget(intro, 0, 0, 0, 1);
  
  QButtonGroup *direction = new QButtonGroup(dialogArea);
  direction->hide();
  
  QRadioButton *incoming = new QRadioButton(i18n("&Incoming"), dialogArea);
  incoming->setChecked(true);
  incoming->show();
  layout->addWidget(incoming, 1, 0);
  namedWidgets["forward_incoming"] = incoming;
  direction->insert(incoming);
  
  QRadioButton *outgoing = new QRadioButton(i18n("&Outgoing"), dialogArea);
  outgoing->show();
  layout->addWidget(outgoing, 1, 1);
  direction->insert(outgoing);
  
  QLabel *label = new QLabel(i18n("Port:"), dialogArea);
  label->show();
  layout->addWidget(label, 2, 0);
  
  KLineEdit *port = new KLineEdit(dialogArea);
  port->show();
  layout->addWidget(port, 2, 1);
  namedWidgets["forward_port"] = port;
  
  label = new QLabel(i18n("Destination:"), dialogArea);
  label->show();
  layout->addWidget(label, 3, 0);
  
  KLineEdit *destination = new KLineEdit(dialogArea);
  destination->show();
  layout->addWidget(destination, 3, 1);
  namedWidgets["forward_destination"] = destination;
 

  connect(newForwardDialog, SIGNAL(okClicked()), this, SLOT(slotAddForward()));
	
  dialogArea->show();
  newForwardDialog->setMainWidget(dialogArea);
}
Ejemplo n.º 6
0
int main(int argc, char *argv[]) 
{
    QApplication application(argc, argv);

    QFrame* frame = new QFrame;
    frame->resize(800, 600);
    frame->show();

    GameCanvas* canvas = new GameCanvas(frame, QPoint(), frame->size());
    canvas->show();

    return application.exec();
}
Ejemplo n.º 7
0
int main(int argc, char * argv[])	{
    QApplication app(argc, argv);

	VRProductInterface w;
	QFrame *f = new QFrame;
	w.setupUi(f);

	//To get a widget without a "TitleBar"
	f->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowMinMaxButtonsHint | Qt::WindowSystemMenuHint);

	f->show();

	int nRetCode = app.exec();

    return nRetCode;
}
Ejemplo n.º 8
0
int     main(int ac, char **av)
{
    QApplication    app(ac, av);
    QFrame          *mainFrame = new QFrame;
    GameManager     engine(MAP_SIZE, MAP_SIZE, MAP_UNIT);
    EventManager    events(*mainFrame, engine, 2);
    Canvas          myCanvas(*mainFrame, QPoint(0, 0), QSize(MAP_SIZE * MAP_UNIT + 1, MAP_SIZE * MAP_UNIT + 1), engine);

    mainFrame->setWindowTitle("Nibbler");
    mainFrame->resize(QSize(MAP_SIZE * MAP_UNIT + 1, MAP_SIZE * MAP_UNIT + 1));
    mainFrame->show();

    events.show();
    myCanvas.show();

    app.exec();
    return (0);
}
Ejemplo n.º 9
0
    AlignmentView(Gui::Document* pcDocument, QWidget* parent, QGLWidget* shareWidget=0, Qt::WindowFlags wflags=0)
        : AbstractSplitView(pcDocument, parent, wflags)
    {
        QSplitter* mainSplitter=0;
        mainSplitter = new QSplitter(Qt::Horizontal, this);
        _viewer.push_back(new View3DInventorViewer(mainSplitter, shareWidget));
        _viewer.back()->setDocument(pcDocument);
        _viewer.push_back(new View3DInventorViewer(mainSplitter, shareWidget));
        _viewer.back()->setDocument(pcDocument);

        QFrame* vbox = new QFrame(this);
        QVBoxLayout* layout = new QVBoxLayout();
        layout->setMargin(0);
        layout->setSpacing(0);
        vbox->setLayout(layout);

        myLabel = new QLabel(this);
        myLabel->setAutoFillBackground(true);
        QPalette pal = myLabel->palette();
        pal.setColor(QPalette::Window, Qt::darkGray);
        pal.setColor(QPalette::WindowText, Qt::white);
        myLabel->setPalette(pal);
        mainSplitter->setPalette(pal);
        myLabel->setAlignment(Qt::AlignCenter);
        myLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
        QFont font = myLabel->font();
        font.setPointSize(14);
        myLabel->setFont(font);
        layout->addWidget(myLabel);
        layout->addWidget(mainSplitter);

        vbox->show();
        setCentralWidget(vbox);

        // apply the user settings
        setupSettings();

        static_cast<SoGroup*>(getViewer(0)->getSoRenderManager()->getSceneGraph())->
            addChild(setupHeadUpDisplay(tr("Movable object")));
        static_cast<SoGroup*>(getViewer(1)->getSoRenderManager()->getSceneGraph())->
            addChild(setupHeadUpDisplay(tr("Fixed object")));
    }
bool FrameAttachmentPoint::attach(AttachableFrame* frame)
{
    QLayout* layout;
    QWidget* attWidget;
    QFrame* attFrame;
    QDockWidget* attDockWidget;
    QTabWidget* attTabWidget;
    QMainWindow* attMainWindow;
    int index = 0;

    if ((int)mAttachedFrames.size() >= mMaxAttachmentCount)
    {
        LOG_ERROR() << "FrameAttachmentPoint::attach(): cannot attach more than " << mMaxAttachmentCount <<
                       " Frame" << (mMaxAttachmentCount > 1 ? "s" : "") << " to Attachment Point " << mName << ".";
       return false;
    }

    //Attach the frame in a way depending on its type
    switch (mType)
    {
    case ATTACHMENT_NONE:
         LOG_ERROR() << "FrameAttachmentPoint::attach(): cannot attach to illegal Attachment Point.";
         return false;
        break;
    case ATTACHMENT_WIDGET:
        //Attach to Widget with adding a new layout
        layout = WindowManager::createNeutralLayout();
        layout->addWidget(&*frame);
        frame->show();
        attWidget = (dynamic_cast<QWidget*>(mAttachmentPoint));
        attWidget->setLayout(layout);
        attWidget->show();
        break;
    case ATTACHMENT_FRAME:
        //Attach to Frame with adding a new layout
        layout = WindowManager::createNeutralLayout();
        layout->addWidget(&*frame);
        frame->show();
        attFrame = (dynamic_cast<QFrame*>(mAttachmentPoint));
        attFrame->setLayout(layout);
        attFrame->show();
        break;
    case ATTACHMENT_TABWIDGET:
        //Attach to TabWidget with adding a new page and (automatically) a layout
        attTabWidget = (dynamic_cast<QTabWidget*>(mAttachmentPoint));
        index = attTabWidget->addTab(&*frame, frame->getCaption());
        WindowManager::changeToNeutralLayout(attTabWidget->widget(index)->layout());
        break;
    case ATTACHMENT_DOCKWIDGET:
        //Attach to DockWidget with adding a new layout
        layout = WindowManager::createNeutralLayout();
        layout->addWidget(&*frame);
        frame->show();
        attDockWidget = (dynamic_cast<QDockWidget*>(mAttachmentPoint));
        attDockWidget->setLayout(layout);
        attDockWidget->show();
        break;
    case ATTACHMENT_MAINWINDOW:
        //Attach to MainWindow with adding a new layout
        layout = WindowManager::createNeutralLayout();
        layout->addWidget(&*frame);
        frame->show();
        attMainWindow = (dynamic_cast<QMainWindow*>(mAttachmentPoint));
        attMainWindow->setLayout(layout);
        attMainWindow->show();
        break;
    default:
         LOG_ERROR() << "FrameAttachmentPoint::attach(): unknown Attachment Point.";
        return false;
        break;
    }

    //Store the attachment pointer
    mAttachedFrames.insert(frame->getPluginId(), frame);

    return true;
}
Ejemplo n.º 11
0
void QSAEditor::doObjectCompletion()
{
    QTextCursor cursor = textCursor();
    cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor);
    QString objectName = cursor.selectedText();
    if (objectName.endsWith(QLatin1Char('-')))
        objectName.chop(1);

    objectName = objectName.simplified();

    QString object = resolveFullyQualifiedValue(objectName, parseAssignments(functionCode()));

    bool assumedStatic = false;
    QSCompletionObject o;
    if(objectName == object) {
        QSObject stobj = env()->globalObject().get(object);
        if(stobj.isValid() && stobj.objectType()->valueType() == TypeClass) {
#if defined ( QSA_COMPLETION_DEBUG )
            printf(" -> assuming static\n");
#endif
            o = stobj;
            assumedStatic = true;
        }
    }
    if(o.type == QSCompletionObject::TNull) {
        o = queryObject(object);
    }

#if defined ( QSA_COMPLETION_DEBUG )
    printf(" -> type is: %d\n", o.type);
#endif

    o.resolve();
    if (o.isNull())
        return;

    QVector<CompletionEntry> res;

    QSObject nullObject;
    switch (o.type) {
    case QSCompletionObject::TQSObject:
#if defined ( QSA_COMPLETION_DEBUG )
        printf(" -> objectType is: %s\n", o.qsobj.objectType()->name().latin1());
#endif
        if(o.qsobj.objectType()->name() == QString::fromLatin1("FactoryObject")){
            QSObject sinst = ( (QSFactoryObjectProxy*) o.qsobj.objectType() )->staticInstance();
            if(!sinst.isValid())
                return;
            QSWrapperShared *shared = (QSWrapperShared*) sinst.shVal();
            completeQObject( shared->objects, object, res );
            break;
        }
        completeQSObject(o.qsobj, res, !assumedStatic);
        break;
    case QSCompletionObject::TQMetaObject:
        completeQMetaObject(o.meta, object, res, IncludeSuperClass, nullObject);
        break;
    case QSCompletionObject::TQObject:
        completeQObject(o.qobj, object, res);
        break;
    case QSCompletionObject::TNull:
        break;
    }

    if (!res.isEmpty()) {
        QFrame *f = new QFrame(0, Qt::Popup);
        f->setAttribute(Qt::WA_DeleteOnClose);

        QWidget *box = new CompletionBox(this, res);

        QVBoxLayout *layout = new QVBoxLayout;
        layout->addWidget(box);
        layout->setMargin(0);
        f->setLayout(layout);

        f->move(mapToGlobal(cursorRect().bottomLeft()));
        f->show();
        box->setFocus();
    }
}
Ejemplo n.º 12
0
void XmlSettingsDialog::ParseEntity (const QDomElement& entity, QWidget *baseWidget)
{
	QDomElement item = entity.firstChildElement ("item");
	while (!item.isNull ())
	{
		ParseItem (item, baseWidget);
		item = item.nextSiblingElement ("item");
	}

	QDomElement gbox = entity.firstChildElement ("groupbox");
	while (!gbox.isNull ())
	{
		QGroupBox *box = new QGroupBox (GetLabel (gbox));
		QGridLayout *groupLayout = new QGridLayout ();
		groupLayout->setContentsMargins (2, 2, 2, 2);
		box->setLayout (groupLayout);
		box->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
		ParseEntity (gbox, box);

		QGridLayout *lay = qobject_cast<QGridLayout*> (baseWidget->layout ());
		lay->addWidget (box, lay->rowCount (), 0);

		gbox = gbox.nextSiblingElement ("groupbox");

		QSpacerItem *verticalSpacer = new QSpacerItem (10, 20, QSizePolicy::Minimum, QSizePolicy::Expanding);
		groupLayout->addItem (verticalSpacer, groupLayout->rowCount (), 0);
	}

	QDomElement scroll = entity.firstChildElement ("scrollarea");
	while (!scroll.isNull ())
	{
		QScrollArea *area = new QScrollArea ();
		if (scroll.hasAttribute ("horizontalScroll"))
		{
			QString attr = scroll.attribute ("horizontalScroll");
			if (attr == "on")
				area->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOn);
			else if (attr == "off")
				area->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
		}
		if (scroll.hasAttribute ("verticalScroll"))
		{
			QString attr = scroll.attribute ("verticalScroll");
			if (attr == "on")
				area->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOn);
			else if (attr == "off")
				area->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
		}

		QFrame *areaWidget = new QFrame;
		QGridLayout *areaLayout = new QGridLayout;
		areaWidget->setLayout (areaLayout);
		ParseEntity (scroll, areaWidget);
		area->setWidget (areaWidget);
		areaWidget->show ();

		QGridLayout *lay = qobject_cast<QGridLayout*> (baseWidget->layout ());
		lay->addWidget (area, lay->rowCount (), 0, 1, 2);

		scroll = scroll.nextSiblingElement ("scrollarea");
		QSpacerItem *verticalSpacer = new QSpacerItem (10, 20, QSizePolicy::Minimum, QSizePolicy::Expanding);
		lay->addItem (verticalSpacer, lay->rowCount (), 0, 1, 1);
	}

	QDomElement tab = entity.firstChildElement ("tab");
	if (!tab.isNull ())
	{
		QTabWidget *tabs = new QTabWidget;
		QGridLayout *lay = qobject_cast<QGridLayout*> (baseWidget->layout ());
		lay->addWidget (tabs, lay->rowCount (), 0, 1, 2);
		while (!tab.isNull ())
		{
			QWidget *page = new QWidget;
			QGridLayout *widgetLay = new QGridLayout;
			widgetLay->setContentsMargins (0, 0, 0, 0);
			page->setLayout (widgetLay);
			page->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
			tabs->addTab (page, GetLabel (tab));
			ParseEntity (tab, page);
			tab = tab.nextSiblingElement ("tab");
			QSpacerItem *verticalSpacer = new QSpacerItem (10, 20, QSizePolicy::Minimum, QSizePolicy::Expanding);
			widgetLay->addItem (verticalSpacer, widgetLay->rowCount (), 0, 1, 1);
		}
	}
}
Ejemplo n.º 13
0
void pTreeComboBox::calculPopupGeometry()
{
    if ( !mView ) {
        return;
    }
    
    QStyle * const style = this->style();

    // set current item and select it
    view()->selectionModel()->setCurrentIndex( mCurrentIndex, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
    QFrame* container = mFrame;
    QStyleOptionComboBox opt;
    initStyleOption( &opt );
    QRect listRect( style->subControlRect( QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxListBoxPopup, this ) );
    QRect screen = popupGeometry( QApplication::desktop()->screenNumber( this ) );
    QPoint below = mapToGlobal( listRect.bottomLeft() );
    int belowHeight = screen.bottom() -below.y();
    QPoint above = mapToGlobal( listRect.topLeft() );
    int aboveHeight = above.y() -screen.y();
    bool boundToScreen = !window()->testAttribute( Qt::WA_DontShowOnScreen );
    
    listRect.moveTopLeft( mapToGlobal( rect().bottomLeft() ) );
    listRect.setSize( QSize( 
        qMax( qMax( view()->viewport()->width(), mFrame->width() ), width() )
        ,
        qMax( view()->viewport()->height(), mFrame->height() )
    ) );

    const bool usePopup = style->styleHint( QStyle::SH_ComboBox_Popup, &opt, this );
    {
        int listHeight = 0;
        int count = 0;
        QStack<QModelIndex> toCheck;
        toCheck.push( view()->rootIndex() );
#ifndef QT_NO_TREEVIEW
        QTreeView* treeView = qobject_cast<QTreeView*>( view() );
        if ( treeView && treeView->header() && !treeView->header()->isHidden() )
            listHeight += treeView->header()->height();
#endif
        while ( !toCheck.isEmpty() ) {
            QModelIndex parent = toCheck.pop();
            for ( int i = 0; i < model()->rowCount( parent ); ++i ) {
                QModelIndex idx = model()->index( i, mModelColumn, parent );
                if ( !idx.isValid() )
                    continue;
                listHeight += view()->visualRect( idx ).height();
#ifndef QT_NO_TREEVIEW
                if ( model()->hasChildren( idx ) && treeView && treeView->isExpanded( idx ) )
                    toCheck.push( idx );
#endif
                ++count;
                if ( !usePopup && count > mMaxVisibleItems ) {
                    toCheck.clear();
                    break;
                }
            }
        }
        listRect.setHeight( listHeight );
    }

    {
        // add the spacing for the grid on the top and the bottom;
        int heightMargin = 0;

        // add the frame of the container
        int marginTop, marginBottom;
        container->getContentsMargins( 0, &marginTop, 0, &marginBottom );
        heightMargin += marginTop +marginBottom;

        //add the frame of the view
        view()->getContentsMargins( 0, &marginTop, 0, &marginBottom );
        marginTop += 0/*static_cast<QAbstractScrollAreaPrivate *>(QObjectPrivate::get(view()))->top*/;
        marginBottom += 0/*static_cast<QAbstractScrollAreaPrivate *>(QObjectPrivate::get(view()))->bottom*/;
        heightMargin += marginTop +marginBottom;

        listRect.setHeight( listRect.height() +heightMargin );
    }

    // Add space for margin at top and bottom if the style wants it.
    if ( usePopup )
        listRect.setHeight( listRect.height() +style->pixelMetric( QStyle::PM_MenuVMargin, &opt, this ) *2 );

    // Make sure the popup is wide enough to display its contents.
    if ( usePopup ) {
        const int diff = sizeHint().width() /*d->computeWidthHint()*/ -width();
        if ( diff > 0 )
            listRect.setWidth( listRect.width() +diff );
    }

    //we need to activate the layout to make sure the min/maximum size are set when the widget was not yet show
    container->layout()->activate();
    //takes account of the minimum/maximum size of the container
    listRect.setSize( listRect.size().expandedTo(container->minimumSize())
                      .boundedTo(container->maximumSize()));

    // make sure the widget fits on screen
    if (boundToScreen) {
        if (listRect.width() > screen.width() )
            listRect.setWidth(screen.width());
        if (/*mapToGlobal(*/listRect/*.bottomRight())*/.x() > screen.right()) {
            below.setX(screen.x() + screen.width() - listRect.width());
            above.setX(screen.x() + screen.width() - listRect.width());
        }
        if (/*mapToGlobal(*/listRect/*.topLeft())*/.x() < screen.x() ) {
            below.setX(screen.x());
            above.setX(screen.x());
        }
    }

    if ( usePopup ) {
        // Position horizontally.
        listRect.moveLeft( above.x() );

        // Position vertically so the curently selected item lines up
        // with the combo box.
        /*const QRect currentItemRect = view()->visualRect( view()->currentIndex() );
        const int offset = listRect.top() -currentItemRect.top();
        listRect.moveTop( above.y() +offset -listRect.top() );*/

        // Clamp the listRect height and vertical position so we don't expand outside the
        // available screen geometry.This may override the vertical position, but it is more
        // important to show as much as possible of the popup.
        const int height = !boundToScreen ? listRect.height() : qMin(listRect.height(), screen.height());
        listRect.setHeight(height);
        if (boundToScreen) {
            if (listRect.top() < screen.top())
                listRect.moveTop(screen.top());
            if (listRect.bottom() > screen.bottom())
                listRect.moveBottom(screen.bottom());
        }
    } else if (!boundToScreen || listRect.height() <= belowHeight) {
        listRect.moveTopLeft(below);
    } else if (listRect.height() <= aboveHeight) {
        listRect.moveBottomLeft(above);
    } else if (belowHeight >= aboveHeight) {
        listRect.setHeight(belowHeight);
        listRect.moveTopLeft(below);
    } else {
        listRect.setHeight(aboveHeight);
        listRect.moveBottomLeft(above);
    }

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#ifndef QT_NO_IM
    if ( QInputContext *qic = inputContext() )
        qic->reset();
#endif
#endif
    QScrollBar* sb = view()->horizontalScrollBar();
    Qt::ScrollBarPolicy policy = view()->horizontalScrollBarPolicy();
    bool needHorizontalScrollBar = ( policy == Qt::ScrollBarAsNeeded || policy == Qt::ScrollBarAlwaysOn ) && sb->minimum() < sb->maximum();
    if ( needHorizontalScrollBar ) {
        listRect.adjust( 0, 0, 0, sb->height() );
    }
    
    container->setGeometry( listRect );

#ifndef Q_WS_MAC
    const bool updatesEnabled = container->updatesEnabled();
#endif

#if defined( Q_WS_WIN ) && !defined( QT_NO_EFFECTS )
// FIXME Fix me ASAP
    /*bool scrollDown = ( listRect.topLeft() == below );
    if ( QApplication::isEffectEnabled( Qt::UI_AnimateCombo ) 
        && !style->styleHint( QStyle::SH_ComboBox_Popup, &opt, this ) && !window()->testAttribute( Qt::WA_DontShowOnScreen ) )
        qScrollEffect( container, scrollDown ? QEffects::DownScroll : QEffects::UpScroll, 150 );*/
#endif

// Don't disable updates on Mac OS X. Windows are displayed immediately on this platform,
// which means that the window will be visible before the call to container->show() returns.
// If updates are disabled at this point we'll miss our chance at painting the popup 
// menu before it's shown, causing flicker since the window then displays the standard gray 
// background.
#ifndef Q_WS_MAC
    container->setUpdatesEnabled( false );
#endif

    container->raise();
    container->show();
    //container->updateScrollers();
    view()->setFocus();

    view()->scrollTo( view()->currentIndex(), style->styleHint( QStyle::SH_ComboBox_Popup, &opt, this ) ? QAbstractItemView::PositionAtCenter : QAbstractItemView::EnsureVisible );

#ifndef Q_WS_MAC
    container->setUpdatesEnabled( updatesEnabled );
#endif

    container->update();
#ifdef QT_KEYPAD_NAVIGATION
    if ( QApplication::keypadNavigationEnabled() )
        view()->setEditFocus( true );
#endif
}
Ejemplo n.º 14
0
void KstBasicDialogI::init() {

  KstBasicPluginPtr ptr;
  if (_newDialog) {
    ptr = kst_cast<KstBasicPlugin>(KstDataObject::plugin(_pluginName));
  } else {
    ptr = kst_cast<KstBasicPlugin>(findObject(_pluginName));
  }

  Q_ASSERT(ptr); //shouldn't happen

  if (_grid) { //reset
    QLayoutIterator it = _grid->iterator();
    while(QLayoutItem *item = it.takeCurrent()) {
      delete item->widget();
      delete item;
    }
    delete _grid;
    _grid = 0;
  }

  int cnt = 0;
  int numInputOutputs = ptr->inputVectorList().count()
                      + ptr->inputScalarList().count()
                      + ptr->inputStringList().count()
                      + ptr->outputVectorList().count()
                      + ptr->outputScalarList().count()
                      + ptr->outputStringList().count();

  _grid = new QGridLayout(_w->_frame, numInputOutputs + 1, 2, 0, 8);
  _grid->setColStretch(1,1);
  _grid->setColStretch(0,0);

  //create input widgets
  //First, the inputVectors...
  QStringList iv = ptr->inputVectorList();
  QStringList::ConstIterator ivI = iv.begin();
  for (; ivI != iv.end(); ++ivI) {
      createInputVector(*ivI, ++cnt);
  }

  //Now, the inputScalars...
  QStringList is = ptr->inputScalarList();
  QStringList::ConstIterator isI = is.begin();
  for (; isI != is.end(); ++isI) {
      createInputScalar(*isI, ++cnt);
  }

  //Finally, the inputStrings...
  QStringList istr = ptr->inputStringList();
  QStringList::ConstIterator istrI = istr.begin();
  for (; istrI != istr.end(); ++istrI) {
      createInputString(*istrI, ++cnt);
  }

  //create sep
  cnt++;
  QFrame* line = new QFrame(_w->_frame);
  line->setFrameShadow(QFrame::Sunken);
  line->setFrameShape(QFrame::HLine);
  _grid->addMultiCellWidget(line, cnt, cnt, 0, 1);
  line->show();
  cnt++;

  //create output widgets
  //output vectors...
  QStringList ov = ptr->outputVectorList();
  QStringList::ConstIterator ovI = ov.begin();
  for (; ovI != ov.end(); ++ovI) {
      createOutputWidget(*ovI, ++cnt);
  }

  //output scalars...
  QStringList os = ptr->outputScalarList();
  QStringList::ConstIterator osI = os.begin();
  for (; osI != os.end(); ++osI) {
      createOutputWidget(*osI, ++cnt);
  }

  //ouput strings...
  QStringList ostr = ptr->outputStringList();
  QStringList::ConstIterator ostrI = ostr.begin();
  for (; ostrI != ostr.end(); ++ostrI) {
      createOutputWidget(*ostrI, ++cnt);
  }
}
void kiptablesgenerator::setupNewServiceDialog()
{
  newServiceDialog = new KDialogBase(this, 0, true, i18n("Add Service"), KDialogBase::Ok | KDialogBase::Cancel);
  
  QFrame *dialogArea = new QFrame(newServiceDialog);
  QGridLayout *layout = new QGridLayout(dialogArea, 7, 2);
  
  QLabel *intro = new QLabel(i18n(
    "<p><i>Advanced users only</i></p>"
    "<p>Here you can allow or deny access to services through your firewall.<br />"
    "You can specify a port range in the box using this format: <tt>fromPort:toPort</tt></p>"), dialogArea);
  intro->show();
  layout->addMultiCellWidget(intro, 0, 0, 0, 1);
  
  QLabel *protocolLabel = new QLabel(i18n("&Protocol: "), dialogArea);
  protocolLabel->show();
  layout->addWidget(protocolLabel, 1, 0);
 
  KComboBox *protocols = new KComboBox(dialogArea);
  protocols->insertItem(i18n("TCP"));
  protocols->insertItem(i18n("UDP"));
  protocols->insertItem(i18n("TCP & UDP"));
  protocols->insertItem(i18n("ICMP"));
  protocols->setCurrentItem(2);
  protocols->show();
  layout->addWidget(protocols, 1, 1);
  protocolLabel->setBuddy(protocols);
  namedWidgets["newService_protocols"] = protocols;
  connect(protocols, SIGNAL(activated(int )), this, SLOT(slotChangedProtocol(int )));
  
  QLabel *selectByLabel = new QLabel(i18n("Select service by: "), dialogArea);
  selectByLabel->show();
  layout->addMultiCellWidget(selectByLabel, 2, 2, 0, 1);
  
  QButtonGroup *optNamedOrNumbered = new QButtonGroup(dialogArea);
  optNamedOrNumbered->hide();
  namedWidgets["newService_namedOrNumbered"] = optNamedOrNumbered;
  
  QRadioButton *optNamed = new QRadioButton(i18n("&Name: "), dialogArea);
  optNamed->setChecked(true);
  optNamed->setName("named");
  optNamedOrNumbered->insert(optNamed);
  optNamed->show();
  layout->addWidget(optNamed, 3, 0);
  namedWidgets["newService_named"] = optNamed;
  
  KComboBox *names = new KComboBox(dialogArea);
  names->show();
  layout->addWidget(names, 3, 1);
  namedWidgets["newService_names"] = names;
  
  QRadioButton *optNumbered = new QRadioButton(i18n("&Port number(s): "), dialogArea);
  optNumbered->setName("numbered");
  optNamedOrNumbered->insert(optNumbered);
  optNumbered->show();
  layout->addWidget(optNumbered, 4, 0);
  namedWidgets["newService_numbered"] = optNumbered;
  
  KLineEdit *ports = new KLineEdit(dialogArea);
  ports->show();
  layout->addWidget(ports, 4, 1);
  namedWidgets["newService_ports"] = ports;
  
  QButtonGroup *optAllowDeny = new QButtonGroup(dialogArea);
  optAllowDeny->hide();
  namedWidgets["newService_allowDeny"] = optAllowDeny;
  
  KSeparator *separator = new KSeparator(dialogArea);
  separator->show();
  layout->addMultiCellWidget(separator, 5, 5, 0, 1);
  
  QRadioButton *optAllow = new QRadioButton(i18n("&Accept"), dialogArea);
  optAllow->setName(i18n("Accept"));
  optAllow->setChecked(true);
  optAllow->show();
  optAllowDeny->insert(optAllow);
  layout->addWidget(optAllow, 6, 0);
  
  QRadioButton *optDeny = new QRadioButton(i18n("&Drop"), dialogArea);
  optDeny->setName(i18n("Drop"));
  optDeny->show();
  optAllowDeny->insert(optDeny);
  layout->addWidget(optDeny, 6, 1);
    
  dialogArea->show();
  newServiceDialog->setMainWidget(dialogArea);
  connect(newServiceDialog, SIGNAL(okClicked()), this, SLOT(slotAddService()));
  slotChangedProtocol(2); // TCP+UDP
}
Ejemplo n.º 16
0
void
TrackButtons::slotUpdateTracks()
{
#if 0
    RG_DEBUG << "TrackButtons::slotUpdateTracks()";
    static QTime t;
    RG_DEBUG << "  elapsed: " << t.restart();
#endif

    if (!m_doc)
        return;

    Composition &comp = m_doc->getComposition();
    const int newNbTracks = comp.getNbTracks();

    //RG_DEBUG << "TrackButtons::slotUpdateTracks > newNbTracks = " << newNbTracks;

    // If a track or tracks were deleted
    if (newNbTracks < m_tracks) {
        // For each deleted track, remove a button from the end.
        for (int i = m_tracks; i > newNbTracks; --i)
            removeButtons(i - 1);
    } else if (newNbTracks > m_tracks) {  // if added
        // For each added track
        for (int i = m_tracks; i < newNbTracks; ++i) {
            Track *track = m_doc->getComposition().getTrackByPosition(i);
            if (track) {
                // Make a new button
                QFrame *trackHBox = makeButton(track);

                if (trackHBox) {
                    trackHBox->show();
                    // Add the new button to the layout.
                    m_layout->insertWidget(i, trackHBox);
                    m_trackHBoxes.push_back(trackHBox);
                }
            } else
                RG_DEBUG << "TrackButtons::slotUpdateTracks - can't find TrackId for position " << i;
        }
    }

    m_tracks = newNbTracks;

    if (m_tracks != (int)m_trackHBoxes.size())
        RG_DEBUG << "WARNING  TrackButtons::slotUpdateTracks(): m_trackHBoxes.size() != m_tracks";
    if (m_tracks != (int)m_trackLabels.size())
        RG_DEBUG << "WARNING  TrackButtons::slotUpdateTracks(): m_trackLabels.size() != m_tracks";

    // For each track
    for (int i = 0; i < m_tracks; ++i) {

        Track *track = comp.getTrackByPosition(i);

        if (!track)
            continue;


        // *** Set Track Size ***

        // Track height can change when the user moves segments around and
        // they overlap.

        m_trackHBoxes[i]->setMinimumSize(labelWidth(), trackHeight(track->getId()));
        m_trackHBoxes[i]->setFixedHeight(trackHeight(track->getId()));

    }

    populateButtons();

    // This is necessary to update the widgets's sizeHint to reflect any change in child widget sizes
    // Make the TrackButtons QFrame big enough to hold all the track buttons.
    // Some may have grown taller due to segments that overlap.
    // Note: This appears to no longer be needed.  But it doesn't hurt.
    adjustSize();
}