Exemple #1
0
void SPHtmlDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
    QStyleOptionViewItemV4 options = option;
    initStyleOption(&options, index);

    QTextDocument doc;
    //doc.setDocumentMargin(0);
    doc.setHtml(index.data().toString());

    painter->save();
    options.text = QString();  // clear old text
    options.widget->style()->drawControl(QStyle::CE_ItemViewItem, &options, painter, options.widget);

    // draw area
    QRect clip = options.widget->style()->subElementRect(QStyle::SE_ItemViewItemText, &options);
    QFontMetrics metrics(options.font);
    if (index.flags() == Qt::NoItemFlags) {
        painter->setBrush(QBrush(QWidget().palette().color(QPalette::Base)));
        painter->setPen(QWidget().palette().color(QPalette::Base));
        painter->drawRect(QRect(clip.topLeft() - QPoint(20, metrics.descent()), clip.bottomRight()));
        painter->translate(clip.topLeft() - QPoint(20, metrics.descent()));
    }
    else {
        painter->translate(clip.topLeft() - QPoint(0, metrics.descent()));
    }
    QAbstractTextDocumentLayout::PaintContext pcontext;
    doc.documentLayout()->draw(painter, pcontext);

    painter->restore();
}
Exemple #2
0
void TestEnv::mousePressEvent(QMouseEvent *event)
{
   if (!started)
   {
      QWidget(event);
   }
   else
   {
      if (curTarget->contains(event->pos()))
      {
         emit TestEnv::emitHit(--remainingTargets);
         if (remainingTargets == 0)
         {
            TestEnv::stop();
         }
         else
         {
            newTarget();
            update();
         }
      }
      else
      {
         emit TestEnv::emitError(++errors);
      }
   }
}
void ColormapEditWidget::updateWidget()
{
    if( m_buttonPanel->layout() )
    {
        QWidget().setLayout( m_buttonPanel->layout() );
    }
    m_buttonPanel->setLayout( createButtonPanel() );
}
ProjectWidget::ProjectWidget(ProjectWidget *p, MainWindow *q)
{
    if(q){

        QWidget(q);
    }else{

        QWidget(p);
    }

    parent = p;
    mainParent = q;



    projectName = "";

}
Exemple #5
0
WidgetHisto::WidgetHisto(char*pFile)
{
   QWidget();

   ph = new PanelHisto(pFile);
   pb = new PanelButtons(this, ph);
   layout = new QVBoxLayout();

}
Exemple #6
0
PanelHisto::PanelHisto(char*pFile):m_oImg(pFile)
{
    QWidget();
    couleur = -1;

    // read original image as input
    h = new Histogramme(m_oImg);

}
Exemple #7
0
    QVLCFrame( intf_thread_t *_p_intf ) : QWidget( NULL, Qt::Window ), p_intf( _p_intf )
#else
    QVLCFrame( intf_thread_t *_p_intf ) : QWidget( NULL ), p_intf( _p_intf )
#endif
    {};
    virtual ~QVLCFrame()   {};

    void toggleVisible()
    {
        if( isVisible() ) hide();
        else show();
    }
protected:
Exemple #8
0
void HandViewWindow::clearViews()
{
//! First clear the grid if necessary:
  views.clear();
 // vbox2->removeWidget(grid);
  if(grid)
    QWidget().setLayout(grid);
  delete grid;
  //if ( grid->layout() != NULL )
  //{
  //  QWidget().setLayout(grid->layout());
  //}
    /*QLayoutItem* item;
    while ( ( item = grid->layout()->takeAt( 0 ) ) != NULL )
    {
        grid->remove(item->widget());
        delete item->widget();
        delete item;
    }

    //delete grid->layout();
  }*/
}
void myTestFunction_data() {
    QTest.addColumn<int>("intval")
    QTest.addColumn<QString>("str")
    QTest.addColumn<double>("dbl")

    QTest.newRow("row1") << 1 << "hello" << 1.5
}
//! [21]


//! [22]
void MyTestClass.cleanup()
{
    if (qstrcmp(currentTestFunction(), "myDatabaseTest") == 0) {
        // clean up all database connections
        closeAllDatabases()
    }
}
//! [22]


//! [23]
QTest.qSleep(250)
//! [23]

//! [24]
widget = QWidget()
widget.show()
QTest.qWaitForWindowShown(widget)
//! [24]
Exemple #10
0
int main(int argc, char* argv[])
{
#ifdef Q_OS_WIN
    _setmode(1, _O_BINARY);
    _setmode(2, _O_BINARY);
#endif

    // Suppress debug output from Qt if not started with -v
    bool suppressQtDebugOutput = true;
    for (int i = 1; i < argc; ++i) {
        if (!qstrcmp(argv[i], "-v")) {
            suppressQtDebugOutput = false;
            break;
        }
    }

    // Has to be done before QApplication is constructed in case
    // QApplication itself produces debug output.
    if (suppressQtDebugOutput)
        qInstallMsgHandler(messageHandler);

    WebKit::initializeTestFonts();

    QApplication::setGraphicsSystem("raster");
    QApplication::setStyle(new QWindowsStyle);

    QApplication app(argc, argv);
    app.setQuitOnLastWindowClosed(false);

#if HAVE(QT5)
    QCoreApplication::setAttribute(Qt::AA_Use96Dpi, true);
#else
#ifdef Q_WS_X11
    QX11Info::setAppDpiY(0, 96);
    QX11Info::setAppDpiX(0, 96);
#endif

   /*
    * QApplication will initialize the default application font based
    * on the application DPI at construction time, which might be
    * different from the DPI we explicitly set using QX11Info above.
    * See: https://bugreports.qt.nokia.com/browse/QTBUG-21603
    *
    * To ensure that the application font DPI matches the application
    * DPI, we override the application font using the font we get from
    * a QWidget, which has already been resolved against the existing
    * default font, but with the correct paint-device DPI.
   */
    QApplication::setFont(QWidget().font());
#endif

    WTFInstallReportBacktraceOnCrashHook();

    QStringList args = app.arguments();
    if (args.count() < (!suppressQtDebugOutput ? 3 : 2)) {
        printUsage();
        exit(1);
    }

    // Remove the first arguments, it is application name itself
    args.removeAt(0);

    WebCore::DumpRenderTree dumper;

    int index = args.indexOf(QLatin1String("--stdout"));
    if (index != -1) {
        QString fileName = takeOptionValue(args, index);
        dumper.setRedirectOutputFileName(fileName);
        if (fileName.isEmpty() || !freopen(qPrintable(fileName), "w", stdout)) {
            fprintf(stderr, "STDOUT redirection failed.");
            exit(1);
        }
    }
    index = args.indexOf(QLatin1String("--stderr"));
    if (index != -1) {
        QString fileName = takeOptionValue(args, index);
        dumper.setRedirectErrorFileName(fileName);
        if (!freopen(qPrintable(fileName), "w", stderr)) {
            fprintf(stderr, "STDERR redirection failed.");
            exit(1);
        }
    }
    QWebDatabase::removeAllDatabases();

    index = args.indexOf(QLatin1String("--timeout"));
    if (index != -1) {
        int timeout = takeOptionValue(args, index).toInt();
        dumper.setTimeout(timeout);
    }

    index = args.indexOf(QLatin1String("--no-timeout"));
    if (index != -1) {
        dumper.setShouldTimeout(false);
        args.removeAt(index);
    }

    index = args.indexOf(QLatin1String("-"));
    if (index != -1) {
        args.removeAt(index);

        // Continue waiting in STDIN for more test case after process one test case
        QObject::connect(&dumper, SIGNAL(ready()), &dumper, SLOT(readLine()), Qt::QueuedConnection);   

        // Read and only read the first test case, ignore the others 
        if (args.size() > 0) { 
            // Process the argument first
            dumper.processLine(args[0]);
        } else
           QTimer::singleShot(0, &dumper, SLOT(readLine()));
    } else {
        // Go into standalone mode
        // Standalone mode need at least one test case
        if (args.count() < 1) {
            printUsage();
            exit(1);
        }
        dumper.processArgsLine(args);
    }
    return app.exec();
}
void ColormapEditWidget::redrawWidget()
{
    if( layout() )
    {
        QWidget().setLayout( layout() );
    }

    QVBoxLayout* vLayout = new QVBoxLayout();
    vLayout->setContentsMargins( 1, 1, 1, 1 );
    vLayout->setSpacing( 1 );
    setLayout( vLayout );

    QHBoxLayout* hLayoutTop = new QHBoxLayout();
    m_nameEdit = new EditWithLabel( "name" );
    m_nameEdit->setText( ColormapFunctions::get( m_selected).getName() );

    m_sel = new SelectWithLabel( "colormap", 0 );
    for ( int k = 0; k < ColormapFunctions::size(); ++k )
    {
         m_sel->insertItem( k, ColormapFunctions::get( k ).getName() );

    }
    m_sel->setCurrentIndex( m_selected );
    connect( m_sel, SIGNAL( currentIndexChanged( int, int ) ), this, SLOT( selectionChanged( int) ) );

    hLayoutTop->addWidget( m_nameEdit );
    hLayoutTop->addWidget( m_sel );
    vLayout->addLayout( hLayoutTop );

    m_buttonPanel = new QWidget();
    m_buttonPanel->setLayout( createButtonPanel() );

    QScrollArea* scrollArea = new QScrollArea( this );
    scrollArea->setWidgetResizable( true );
    scrollArea->setWidget( m_buttonPanel );

    vLayout->addWidget( scrollArea );


    QHBoxLayout* hLayout5 = new QHBoxLayout();
    hLayout5->addStretch();
    CheckBox* contUpdating = new CheckBox( tr("continuous updating") );
    contUpdating->setChecked( false );
    contUpdating->setChecked( m_contUpdating );
    connect( contUpdating, SIGNAL( stateChanged( int, int ) ), this, SLOT( contUpdatingChanged( int ) ) );
    hLayout5->addWidget( contUpdating );
    QPushButton* updateButton = new QPushButton( tr("update") );
    connect( updateButton, SIGNAL( clicked() ), this, SLOT( update() ) );
    hLayout5->addWidget( updateButton );
    QPushButton* saveButton = new QPushButton( tr("save new") );
    connect( saveButton, SIGNAL( clicked() ), this, SLOT( save() ) );
    hLayout5->addWidget( saveButton );
    vLayout->addLayout( hLayout5 );

    QHBoxLayout* hLayout6 = new QHBoxLayout();
    hLayout6->addStretch();
    QPushButton* deleteButton = new QPushButton( tr("delete") );
    connect( deleteButton, SIGNAL( clicked() ), this, SLOT( deleteCM() ) );
    hLayout6->addWidget( deleteButton );
    vLayout->addLayout( hLayout6 );

    layout()->setContentsMargins( 1, 1, 1, 1 );
    layout()->setSpacing( 1 );

    repaint();
}
void SelectorWidget::setItems(QStringList items, QStringList tooltips)
{
	m_itemBoxes.clear();
	m_items = items;
	m_tooltips = tooltips;

	auto layout = this->layout();
	if (layout)
		QWidget().setLayout(layout); // Clean up

	auto mainLayout = new QVBoxLayout(this);
	mainLayout->setContentsMargins(5, 5, 5, 5);
	mainLayout->setSpacing(0);

	auto addFilterContainsIcon = QIcon("://icons/Add.png");
	auto addFilterDoesNotContainIcon = QIcon("://icons/Remove.png");
	auto removeFilterIcon = QIcon("://icons/Delete.png");

	int addFilterContainsMask = static_cast<int>(FilterActionType::addFilterContains) << 16;
	int addFilterDoesNotContainMask = static_cast<int>(FilterActionType::addFilterDoesNotContain) << 16;
	int removeFilterMask = static_cast<int>(FilterActionType::RemoveFilter) << 16;

	const int buttonSize = 24;

	for (int i = 0, nb = items.size(); i < nb; ++i)
	{
		auto boxWidget = new QWidget;
		auto boxLayout = new QHBoxLayout;
		boxLayout->setContentsMargins(0, 0, 0, 0);
		boxLayout->setSpacing(2);

		auto addFilterContainsAction = new QAction(boxWidget);
		addFilterContainsAction->setData(QVariant(i + addFilterContainsMask));
		auto addFilterContainsButton = new QPushButton(addFilterContainsIcon, "", boxWidget);
		addFilterContainsButton->setMaximumSize(buttonSize, buttonSize);
		addFilterContainsButton->setFlat(true);
		addFilterContainsButton->setToolTip(tr("Only show potions that contain this item"));
		connect(addFilterContainsButton, SIGNAL(clicked(bool)), addFilterContainsAction, SLOT(trigger()));
		connect(addFilterContainsAction, SIGNAL(triggered(bool)), this, SLOT(modifyFilter()));

		auto addFilterDoesNotContainAction = new QAction(boxWidget);
		addFilterDoesNotContainAction->setData(QVariant(i + addFilterDoesNotContainMask));
		auto addFilterDoesNotContainButton = new QPushButton(addFilterDoesNotContainIcon, "", boxWidget);
		addFilterDoesNotContainButton->setMaximumSize(buttonSize, buttonSize);
		addFilterDoesNotContainButton->setFlat(true);
		addFilterDoesNotContainButton->setToolTip(tr("Hide potions containing this item"));
		connect(addFilterDoesNotContainButton, SIGNAL(clicked(bool)), addFilterDoesNotContainAction, SLOT(trigger()));
		connect(addFilterDoesNotContainAction, SIGNAL(triggered(bool)), this, SLOT(modifyFilter()));

		auto removeFilterAction = new QAction(boxWidget);
		removeFilterAction->setData(QVariant(i + removeFilterMask));
		auto removeFilterButton = new QPushButton(removeFilterIcon, "", boxWidget);
		removeFilterButton->setMaximumSize(buttonSize, buttonSize);
		removeFilterButton->setFlat(true);
		connect(removeFilterButton, SIGNAL(clicked(bool)), removeFilterAction, SLOT(trigger()));
		connect(removeFilterAction, SIGNAL(triggered(bool)), this, SLOT(modifyFilter()));
		removeFilterButton->hide();

		boxLayout->addWidget(addFilterContainsButton);
		boxLayout->addWidget(removeFilterButton);
		boxLayout->addWidget(addFilterDoesNotContainButton);

		auto label = new QLabel(m_items[i]);
		label->setToolTip(m_tooltips[i]);
		boxLayout->addWidget(label);

		boxWidget->setLayout(boxLayout);
		mainLayout->addWidget(boxWidget);

		ItemBox itemBox;
		itemBox.widget = boxWidget;
		itemBox.addContainsButton = addFilterContainsButton;
		itemBox.addDoesNotContainButton = addFilterDoesNotContainButton;
		itemBox.removeButton = removeFilterButton;
		m_itemBoxes.push_back(itemBox);
	}
}