コード例 #1
0
ファイル: eventedittest.cpp プロジェクト: KDE/kdepim-addons
void EventEditTest::shouldHaveDefaultValuesOnCreation()
{
    MessageViewer::EventEdit edit;
    QVERIFY(edit.collection().isValid());
    QVERIFY(!edit.message());
    QLineEdit *eventedit = edit.findChild<QLineEdit *>(QStringLiteral("eventedit"));
    QVERIFY(eventedit);
    QCOMPARE(eventedit->text(), QString());

    QPushButton *openEditor = edit.findChild<QPushButton *>(QStringLiteral("open-editor-button"));
    QPushButton *save = edit.findChild<QPushButton *>(QStringLiteral("save-button"));
    QVERIFY(openEditor);
    QVERIFY(save);
    QCOMPARE(openEditor->isEnabled(), false);
    QCOMPARE(save->isEnabled(), false);

    QDateTime currentDateTime = QDateTime::currentDateTime();
    MessageViewer::EventDateTimeWidget *startDateTime = edit.findChild<MessageViewer::EventDateTimeWidget *>(QStringLiteral("startdatetimeedit"));
    QVERIFY(startDateTime);
    QCOMPARE(startDateTime->dateTime().date(), currentDateTime.date());
    QCOMPARE(startDateTime->dateTime().time().hour(), currentDateTime.time().hour());
    QCOMPARE(startDateTime->dateTime().time().minute(), currentDateTime.time().minute());

    MessageViewer::EventDateTimeWidget *endDateTime = edit.findChild<MessageViewer::EventDateTimeWidget *>(QStringLiteral("enddatetimeedit"));
    QVERIFY(endDateTime);
    currentDateTime = currentDateTime.addSecs(3600); // +1hour
    QCOMPARE(endDateTime->dateTime().date(), currentDateTime.date());
    QCOMPARE(endDateTime->dateTime().time().hour(), currentDateTime.time().hour());
    QCOMPARE(endDateTime->dateTime().time().minute(), currentDateTime.time().minute());
}
コード例 #2
0
void BlackListBalooEmailCompletionWidgetTest::shouldHaveDefaultValue()
{
    KPIM::BlackListBalooEmailCompletionWidget widget;
    widget.show();
    QTest::qWaitForWindowExposed(&widget);
    QLabel *searchLabel = widget.findChild<QLabel *>(QStringLiteral("search_label"));
    QVERIFY(searchLabel);

    KLineEdit *searchLineEdit = widget.findChild<KLineEdit *>(QStringLiteral("search_lineedit"));
    QVERIFY(searchLineEdit);
    QVERIFY(searchLineEdit->isClearButtonShown());
    QVERIFY(searchLineEdit->trapReturnKey());
    QVERIFY(searchLineEdit->text().isEmpty());

    QPushButton *seachButton = widget.findChild<QPushButton *>(QStringLiteral("search_button"));
    QVERIFY(seachButton);
    QVERIFY(!seachButton->isEnabled());

    QLabel *moreResult = widget.findChild<QLabel *>(QStringLiteral("moreresultlabel"));
    QVERIFY(moreResult);
    QVERIFY(!moreResult->isVisible());

    QLabel *mNumberOfEmailsFound = widget.findChild<QLabel *>(QStringLiteral("numberofemailsfound"));
    QVERIFY(mNumberOfEmailsFound);
    QVERIFY(mNumberOfEmailsFound->text().isEmpty());

    QPushButton *showAllBlackListedEmails = widget.findChild<QPushButton *>(QStringLiteral("show_blacklisted_email_button"));
    QVERIFY(showAllBlackListedEmails);

    KPIM::BlackListBalooEmailList *emailList = widget.findChild<KPIM::BlackListBalooEmailList *>(QStringLiteral("email_list"));
    QVERIFY(emailList);

    QPushButton *selectButton = widget.findChild<QPushButton *>(QStringLiteral("select_email"));
    QVERIFY(selectButton);
    QVERIFY(!selectButton->isEnabled());
    QPushButton *unselectButton = widget.findChild<QPushButton *>(QStringLiteral("unselect_email"));
    QVERIFY(unselectButton);
    QVERIFY(!unselectButton->isEnabled());

    QLabel *excludeDomainLabel = widget.findChild<QLabel *>(QStringLiteral("domain_label"));
    QVERIFY(excludeDomainLabel);

    KLineEdit *excludeDomainLineEdit = widget.findChild<KLineEdit *>(QStringLiteral("domain_lineedit"));
    QVERIFY(excludeDomainLineEdit);
    QVERIFY(excludeDomainLineEdit->trapReturnKey());
    QVERIFY(excludeDomainLineEdit->text().isEmpty());
    QVERIFY(excludeDomainLineEdit->isClearButtonShown());
    QVERIFY(!excludeDomainLineEdit->placeholderText().isEmpty());

    KListWidgetSearchLine *searchInResult = widget.findChild<KListWidgetSearchLine *>(QStringLiteral("searchinresultlineedit"));
    QVERIFY(searchInResult);
    QVERIFY(!searchInResult->placeholderText().isEmpty());
    QVERIFY(searchInResult->text().isEmpty());
    QVERIFY(searchInResult->isClearButtonEnabled());

    KPIM::BlackListBalooEmailWarning *blackListWarning = widget.findChild<KPIM::BlackListBalooEmailWarning *>(QStringLiteral("backlistwarning"));
    QVERIFY(blackListWarning);
}
コード例 #3
0
ファイル: eventedittest.cpp プロジェクト: KDE/kdepim-addons
void EventEditTest::shouldEnabledSaveOpenEditorButton()
{
    MessageViewer::EventEdit edit;
    KMime::Message::Ptr msg(new KMime::Message);
    msg->subject(true)->fromUnicodeString(QStringLiteral("Test note"), "us-ascii");
    edit.setMessage(msg);

    QLineEdit *noteedit = edit.findChild<QLineEdit *>(QStringLiteral("eventedit"));
    QVERIFY(noteedit);
    QPushButton *openEditor = edit.findChild<QPushButton *>(QStringLiteral("open-editor-button"));
    QPushButton *save = edit.findChild<QPushButton *>(QStringLiteral("save-button"));
    QCOMPARE(openEditor->isEnabled(), true);
    QCOMPARE(save->isEnabled(), true);
    noteedit->clear();

    QCOMPARE(openEditor->isEnabled(), false);
    QCOMPARE(save->isEnabled(), false);

    noteedit->setText(QStringLiteral(" "));
    QCOMPARE(openEditor->isEnabled(), false);
    QCOMPARE(save->isEnabled(), false);

    noteedit->setText(QStringLiteral(" foo"));
    QCOMPARE(openEditor->isEnabled(), true);
    QCOMPARE(save->isEnabled(), true);
}
コード例 #4
0
ファイル: eventedittest.cpp プロジェクト: KDE/kdepim-addons
void EventEditTest::shouldDisabledSaveOpenEditorButtonWhenCollectionComboBoxIsEmpty()
{
    MessageViewer::EventEdit edit;
    Akonadi::CollectionComboBox *akonadicombobox = edit.findChild<Akonadi::CollectionComboBox *>(QStringLiteral("akonadicombobox"));
    //Create an empty combobox
    akonadicombobox->setModel(new QStandardItemModel());
    KMime::Message::Ptr msg(new KMime::Message);
    msg->subject(true)->fromUnicodeString(QStringLiteral("Test note"), "us-ascii");
    edit.setMessage(msg);

    QPushButton *openEditor = edit.findChild<QPushButton *>(QStringLiteral("open-editor-button"));
    QPushButton *save = edit.findChild<QPushButton *>(QStringLiteral("save-button"));
    QCOMPARE(openEditor->isEnabled(), false);
    QCOMPARE(save->isEnabled(), false);
}
コード例 #5
0
void BlackListBalooEmailCompletionWidgetTest::shouldEnablePushButtonWhenTestSizeSupperiorToTwo()
{
    KPIM::BlackListBalooEmailCompletionWidget widget;
    KLineEdit *searchLineEdit = widget.findChild<KLineEdit *>(QStringLiteral("search_lineedit"));
    QPushButton *seachButton = widget.findChild<QPushButton *>(QStringLiteral("search_button"));
    QVERIFY(!seachButton->isEnabled());
    searchLineEdit->setText(QStringLiteral("fo"));
    QVERIFY(!seachButton->isEnabled());
    searchLineEdit->setText(QStringLiteral("foo"));
    QVERIFY(seachButton->isEnabled());

    searchLineEdit->setText(QStringLiteral("o  "));
    QVERIFY(!seachButton->isEnabled());
    searchLineEdit->setText(QStringLiteral(" o "));
    QVERIFY(!seachButton->isEnabled());
}
コード例 #6
0
void testGetNumeric(QInputDialog *dialog, SpinBoxType * = 0, ValueType * = 0)
{
    SpinBoxType *sbox = qFindChild<SpinBoxType *>(dialog);
    QVERIFY(sbox != 0);

    QLineEdit *ledit = qFindChild<QLineEdit *>(static_cast<QObject *>(sbox));
    QVERIFY(ledit != 0);

    QDialogButtonBox *bbox = qFindChild<QDialogButtonBox *>(dialog);
    QVERIFY(bbox != 0);
    QPushButton *okButton = bbox->button(QDialogButtonBox::Ok);
    QVERIFY(okButton != 0);

    QVERIFY(sbox->value() >= sbox->minimum());
    QVERIFY(sbox->value() <= sbox->maximum());
    QVERIFY(sbox->hasAcceptableInput());
    QCOMPARE(
        normalizeNumericString(ledit->selectedText()),
        normalizeNumericString(QString("%1").arg(sbox->value())));
    QVERIFY(okButton->isEnabled());

    const ValueType origValue = sbox->value();

    testInvalidateAndRestore<SpinBoxType, ValueType>(sbox, okButton, ledit);
    testTypingValue<SpinBoxType>(sbox, okButton, QString("%1").arg(sbox->minimum()));
    testTypingValue<SpinBoxType>(sbox, okButton, QString("%1").arg(sbox->maximum()));
    testTypingValue<SpinBoxType>(sbox, okButton, QString("%1").arg(sbox->minimum() - 1));
    testTypingValue<SpinBoxType>(sbox, okButton, QString("%1").arg(sbox->maximum() + 1));
    testTypingValue<SpinBoxType>(sbox, okButton, "0");
    testTypingValue<SpinBoxType>(sbox, okButton, "0.0");
    testTypingValue<SpinBoxType>(sbox, okButton, "foobar");

    testTypingValue<SpinBoxType>(sbox, okButton, QString("%1").arg(origValue));
}
コード例 #7
0
void testGetItem(QInputDialog *dialog)
{
    QComboBox *cbox = qFindChild<QComboBox *>(dialog);
    Q_ASSERT(cbox);

    QDialogButtonBox *bbox = qFindChild<QDialogButtonBox *>(dialog);
    Q_ASSERT(bbox);
    QPushButton *okButton = bbox->button(QDialogButtonBox::Ok);
    Q_ASSERT(okButton);

    QVERIFY(okButton->isEnabled());
    const int origIndex = cbox->currentIndex();
    cbox->setCurrentIndex(origIndex - 1);
    cbox->setCurrentIndex(origIndex);
    QVERIFY(okButton->isEnabled());
}
コード例 #8
0
void TaskView::keyPressEvent(QKeyEvent* ke)
{
    if (ActiveCtrl && ActiveDialog) {
        if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) {
            // get all buttons of the complete task dialog
            QList<QPushButton*> list = this->findChildren<QPushButton*>();
            for (int i=0; i<list.size(); ++i) {
                QPushButton *pb = list.at(i);
                if (pb->isDefault() && pb->isVisible()) {
                    if (pb->isEnabled())
                        pb->click();
                    return;
                }
            }
        }
        else if (ke->key() == Qt::Key_Escape) {
            // get only the buttons of the button box
            QDialogButtonBox* box = ActiveCtrl->standardButtons();
            QList<QAbstractButton*> list = box->buttons();
            for (int i=0; i<list.size(); ++i) {
                QAbstractButton *pb = list.at(i);
                if (box->buttonRole(pb) == QDialogButtonBox::RejectRole) {
                    if (pb->isEnabled())
                        pb->click();
                    return;
                }
            }
        }
    }
    else {
        QScrollArea::keyPressEvent(ke);
    }
}
コード例 #9
0
ファイル: VerticalTabWidget.cpp プロジェクト: NREL/OpenStudio
void VerticalTabWidget::setCurrentIndex(int index)
{
  int yPos = 25;

  for(unsigned i = 0; i < m_tabButtons.size(); i++)
  {
    QPushButton * button = m_tabButtons[i];

    button->move(0,yPos);

    yPos = yPos + button->height();

    QString imagePath;

    QString style;

    if (i == static_cast<unsigned>(index))
    {
      imagePath = m_selectedPixmaps[i];

      // Ignore clicks to the already active tab
      if(currentIndex != index){
        currentIndex = index;

        style.append("QPushButton { background-color: blue; background-image: url(\"");
        style.append(imagePath);
        style.append("\"); border: none; background-repeat: 0; }");

        button->setStyleSheet(style);

        currentIndex = index;

        emit tabSelected(m_ids[index]);
      }
    }
    else
    {
      if (button->isEnabled()){
        imagePath = m_unSelectedPixmaps[i];
        style.append("QPushButton { background-image: url(\"");
        style.append(imagePath);
        style.append("\"); border: none; background-color: red; background-repeat: 0; }");
      }
      else {
        imagePath = m_disabledPixmaps[i];
        style.append("QPushButton { background-image: url(\"");
        style.append(imagePath);
        style.append("\"); border: none; background-color: red; background-repeat: 0; }");
      }

      button->setStyleSheet(style);
    }
  }
}
コード例 #10
0
ファイル: DialogyWidget.cpp プロジェクト: szsolt/keepassx
bool DialogyWidget::clickButton(QDialogButtonBox::StandardButton standardButton)
{
    QPushButton* pb = qobject_cast<QPushButton*>(focusWidget());
    if (pb && pb->isVisible() && pb->isEnabled() && pb->hasFocus()) {
        pb->click();
        return true;
    }

    QList<QDialogButtonBox*> buttonBoxes = findChildren<QDialogButtonBox*>();
    for (int i = 0; i < buttonBoxes.size(); ++i) {
        QDialogButtonBox* buttonBox = buttonBoxes.at(i);
        pb = buttonBox->button(standardButton);
        if (pb && pb->isVisible() && pb->isEnabled()) {
            pb->click();
            return true;
        }
    }

    return false;
}
コード例 #11
0
bool QMultiFileDialog::eventFilter( QObject* watched, QEvent* event ) {
    QPushButton *btn = qobject_cast<QPushButton*>(watched);
    if (btn) {
        if(event->type()==QEvent::EnabledChange) {
            if (!btn->isEnabled()) {
                btn->setEnabled(true);
            }
        }
    }

    return QWidget::eventFilter(watched, event);
}
コード例 #12
0
ファイル: noteedittest.cpp プロジェクト: KDE/kdepim-addons
void NoteEditTest::shouldHaveDefaultValuesOnCreation()
{
    MessageViewer::NoteEdit edit;

    QVERIFY(edit.collection().isValid());
    QVERIFY(!edit.message());
    QLineEdit *noteedit = edit.findChild<QLineEdit *>(QStringLiteral("noteedit"));
    QPushButton *save = edit.findChild<QPushButton *>(QStringLiteral("save-button"));
    QVERIFY(save);
    QCOMPARE(save->isEnabled(), false);
    QVERIFY(noteedit);
    QCOMPARE(noteedit->text(), QString());
}
コード例 #13
0
ファイル: TaskView.cpp プロジェクト: AllenBootung/FreeCAD
void TaskView::keyPressEvent(QKeyEvent* ke)
{
    if (ActiveCtrl && ActiveDialog) {
        if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) {
            // get all buttons of the complete task dialog
            QList<QPushButton*> list = this->findChildren<QPushButton*>();
            for (int i=0; i<list.size(); ++i) {
                QPushButton *pb = list.at(i);
                if (pb->isDefault() && pb->isVisible()) {
                    if (pb->isEnabled()) {
#if defined(FC_OS_MACOSX)
                        // #0001354: Crash on using Enter-Key for confirmation of chamfer or fillet entries
                        QPoint pos = QCursor::pos();
                        QCursor::setPos(pb->parentWidget()->mapToGlobal(pb->pos()));
#endif
                        pb->click();
#if defined(FC_OS_MACOSX)
                        QCursor::setPos(pos);
#endif
                    }
                    return;
                }
            }
        }
        else if (ke->key() == Qt::Key_Escape) {
            // get only the buttons of the button box
            QDialogButtonBox* box = ActiveCtrl->standardButtons();
            QList<QAbstractButton*> list = box->buttons();
            for (int i=0; i<list.size(); ++i) {
                QAbstractButton *pb = list.at(i);
                if (box->buttonRole(pb) == QDialogButtonBox::RejectRole) {
                    if (pb->isEnabled()) {
#if defined(FC_OS_MACOSX)
                        // #0001354: Crash on using Enter-Key for confirmation of chamfer or fillet entries
                        QPoint pos = QCursor::pos();
                        QCursor::setPos(pb->parentWidget()->mapToGlobal(pb->pos()));
#endif
                        pb->click();
#if defined(FC_OS_MACOSX)
                        QCursor::setPos(pos);
#endif
                    }
                    return;
                }
            }
        }
    }
    else {
        QScrollArea::keyPressEvent(ke);
    }
}
コード例 #14
0
bool SequenceDialog::eventFilter( QObject* obj, QEvent* evt ) {
    if( evt->type() == QEvent::MouseButtonRelease ) {
        QMouseEvent* mouseEvt = (QMouseEvent*)evt;
        if( mouseEvt->button() == Qt::LeftButton ) {
            if( obj && obj->inherits( "QPushButton" ) ) {
                QPushButton* button = (QPushButton*)obj;
                if( button->isEnabled() ) {
                    addSequenceItem( button->text() );
                    return( true );
                }
            }
        }
    }
    return( false );
}
コード例 #15
0
void testGetText(QInputDialog *dialog)
{
    QLineEdit *ledit = qFindChild<QLineEdit *>(dialog);
    Q_ASSERT(ledit);

    QDialogButtonBox *bbox = qFindChild<QDialogButtonBox *>(dialog);
    Q_ASSERT(bbox);
    QPushButton *okButton = bbox->button(QDialogButtonBox::Ok);
    Q_ASSERT(okButton);

    QVERIFY(ledit->hasAcceptableInput());
    QCOMPARE(ledit->selectedText(), ledit->text());
    QVERIFY(okButton->isEnabled());
    const QString origValue = ledit->text();

    testTypingValue(ledit, okButton, origValue);
}
コード例 #16
0
ファイル: mainwindow.cpp プロジェクト: vladimiroff/regularity
void MainWindow::onAddedMaterial(std::string material)
{
    std::map<std::string,int>::const_iterator it = storage->materials().find(material);
    if(it != storage->materials().end()) {
        QString buttonName(material.c_str());
        QPushButton* pb = ui->storage->findChild<QPushButton*>(buttonName);

        if(pb == 0) {
            int buttons = storage->materials().size();
            QPushButton *pb = new QPushButton(buttonName);
            pb->setObjectName(buttonName);
            connect(pb, SIGNAL(clicked()), signalMapper, SLOT(map()));
            signalMapper->setMapping(pb, buttonName);
            QSize buttonSize(90, 70);
            ui->storageLayout->addWidget(pb, (buttons - 1) / 7, (buttons - 1) % 7);
            pb->setFixedSize(buttonSize);
        } else if (!pb->isEnabled()) {
            pb->setEnabled(true);
        }
    }
}
コード例 #17
0
void BlackListBalooEmailCompletionWidgetTest::shouldChangeEnableSelectUnSelectButton()
{
    KPIM::BlackListBalooEmailCompletionWidget widget;

    QPushButton *selectButton = widget.findChild<QPushButton *>(QStringLiteral("select_email"));
    QVERIFY(!selectButton->isEnabled());

    QPushButton *unselectButton = widget.findChild<QPushButton *>(QStringLiteral("unselect_email"));
    QVERIFY(!unselectButton->isEnabled());

    KPIM::BlackListBalooEmailList *emailList = widget.findChild<KPIM::BlackListBalooEmailList *>(QStringLiteral("email_list"));
    emailList->setEmailFound(QStringList() << QStringLiteral("foo") << QStringLiteral("bla") << QStringLiteral("bli"));

    emailList->selectAll();
    QVERIFY(unselectButton->isEnabled());
    QVERIFY(selectButton->isEnabled());

    emailList->clearSelection();
    QVERIFY(!unselectButton->isEnabled());
    QVERIFY(!selectButton->isEnabled());

}
コード例 #18
0
void TestQgsAttributeForm::testOKButtonStatus()
{
  // make a temporary vector layer
  QString def = QStringLiteral( "Point?field=col0:integer" );
  QgsVectorLayer* layer = new QgsVectorLayer( def, QStringLiteral( "test" ), QStringLiteral( "memory" ) );

  // add a feature to the vector layer
  QgsFeature ft( layer->dataProvider()->fields(), 1 );
  ft.setAttribute( QStringLiteral( "col0" ), 0 );
  ft.setValid( true );

  // set constraint
  layer->setConstraintExpression( 0, QString() );

  // build a form for this feature
  QgsAttributeForm form( layer );
  form.setFeature( ft );

  QPushButton *okButton = form.mButtonBox->button( QDialogButtonBox::Ok );

  // get wrapper
  QgsEditorWidgetWrapper *ww;
  ww = qobject_cast<QgsEditorWidgetWrapper*>( form.mWidgets[0] );

  // testing stuff
  QSignalSpy spy1( &form, SIGNAL( attributeChanged( QString, QVariant ) ) );
  QSignalSpy spy2( layer, SIGNAL( editingStarted() ) );
  QSignalSpy spy3( layer, SIGNAL( editingStopped() ) );

  // no constraint but layer not editable : OK button disabled
  QCOMPARE( layer->isEditable(), false );
  QCOMPARE( okButton->isEnabled(), false );

  // no constraint and editable layer : OK button enabled
  layer->startEditing();
  QCOMPARE( spy2.count(), 1 );
  QCOMPARE( layer->isEditable(), true );
  QCOMPARE( okButton->isEnabled(), true );

  // invalid constraint and editable layer : OK button disabled
  layer->setConstraintExpression( 0, QStringLiteral( "col0 = 0" ) );
  QgsAttributeForm form2( layer );
  form2.setFeature( ft );
  ww = qobject_cast<QgsEditorWidgetWrapper*>( form2.mWidgets[0] );
  okButton = form2.mButtonBox->button( QDialogButtonBox::Ok );
  ww->setValue( 1 );
  QCOMPARE( okButton->isEnabled(), false );

  // valid constraint and editable layer : OK button enabled
  layer->setConstraintExpression( 0, QStringLiteral( "col0 = 2" ) );
  QgsAttributeForm form3( layer );
  form3.setFeature( ft );
  ww = qobject_cast<QgsEditorWidgetWrapper*>( form3.mWidgets[0] );
  okButton = form3.mButtonBox->button( QDialogButtonBox::Ok );

  ww->setValue( 2 );
  QCOMPARE( okButton->isEnabled(), true );

  // valid constraint and not editable layer : OK button disabled
  layer->rollBack();
  QCOMPARE( spy3.count(), 1 );
  QCOMPARE( layer->isEditable(), false );
  QCOMPARE( okButton->isEnabled(), false );

  // set soft constraint
  layer->setFieldConstraint( 0, QgsFieldConstraints::ConstraintExpression, QgsFieldConstraints::ConstraintStrengthSoft );
  QgsAttributeForm form4( layer );
  form4.setFeature( ft );
  ww = qobject_cast<QgsEditorWidgetWrapper*>( form4.mWidgets[0] );
  okButton = form4.mButtonBox->button( QDialogButtonBox::Ok );
  ww->setValue( 1 );
  QVERIFY( !okButton->isEnabled() );
  layer->startEditing();
  // just a soft constraint, so OK should be enabled
  QVERIFY( okButton->isEnabled() );
  layer->rollBack();
  QVERIFY( !okButton->isEnabled() );
}
コード例 #19
0
bool Powerline_RateShowDlg::eventFilter(QObject *obj, QEvent *evt)
{
	if((obj == ui->prevPageBtn) || (obj == ui->nextPageBtn))
	{
		QPushButton *btn = qobject_cast<QPushButton *>(obj);

		if(evt->type() == QEvent::EnabledChange)
		{
			int *pbtnState = NULL;

			if(btn == ui->prevPageBtn)
			{
				pbtnState	= &m_prevPageBtnState;
			}
			else if(btn == ui->nextPageBtn)
			{
				pbtnState	= &m_nextPageBtnState;
			}

			if(btn->isEnabled())
			{
				*pbtnState	&= ~BTNSTATE_DISABLED;
			}
			else
			{
				*pbtnState	|= BTNSTATE_DISABLED;
			}
		}
		else if(evt->type() == QEvent::Enter)
		{
			if(btn == ui->prevPageBtn)
			{
				m_prevPageBtnState |= BTNSTATE_HOVER;
			}
			else
			{
				m_nextPageBtnState |= BTNSTATE_HOVER;
			}
		}
		else if(evt->type() == QEvent::Leave)
		{
			if(btn == ui->prevPageBtn)
			{
				m_prevPageBtnState &= ~BTNSTATE_HOVER ;
			}
			else
			{
				m_nextPageBtnState &= ~BTNSTATE_HOVER;
			}

		}
		else
		{
			return false;
		}
#ifndef TEST_PL_CODE
		retranslateImages();
#endif

		return true;
	}

	return QWidget::eventFilter(obj, evt);
}
コード例 #20
0
ファイル: tableitem.cpp プロジェクト: ghostro/fmstick
QByteArray TableItem::GenHTMLForm() {
    QString ret;
    QString objTypeName = obj->metaObject()->className();

    if(objTypeName == "QPlainTextEdit") {
        QPlainTextEdit *item = (QPlainTextEdit *) obj;

#if 0
        ret = QString("<form method=\"post\">"
                   "  <input type=\"hidden\" name=\"action\" value=\"%2\">"
                   "<div class=\"form_info\">%1</div>"
                   "<div class=\"form_editor\"><textarea name=\"%2\" cols=\"20\" rows=\"4\">%3</textarea></div>"
                   "<div class=\"form_submitter\"><input type=\"submit\" value=\"&gt;&gt;\"></div>"
                   "<div class=\"form_tooltip\">%4</div>"
                   "</form>")
                .arg(desc).arg(short_d).arg(item->toPlainText()).arg(item->toolTip());
#endif
        ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
                      "<div class=\"row\">"
                      "<div class=\"prop\"><p>%1:</p></div>"
                      "<div class=\"val\"><p><textarea name=\"%2\" cols=\"16\" rows=\"3\">%3</textarea></p></div>"
                      "<div class=\"submit\"><p> %4</p></div>"
                      "<div class=\"tooltip\"><p> %5</p></div>"
                      "</div></form>\n")
                .arg(desc)
                .arg(short_d)
                .arg(item->toPlainText())
                .arg((!item->isEnabled() || item->isReadOnly()) ? "" : "<input type=\"submit\" value=\"&gt;&gt;\" />")
                .arg(item->toolTip());
    }
    else if(objTypeName == "QLineEdit") {
        QLineEdit *item = (QLineEdit *) obj;

        ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
                      "<div class=\"row\">"
                        "<div class=\"prop\"><p>%1:</p></div>"
                        "<div class=\"val\"><p><input type=\"text\" name=\"%2\" value=\"%3\" /></p></div>"
                        "<div class=\"submit\"><p> %4</p></div>"
                        "<div class=\"tooltip\"><p> %5</p></div>"
                        "</div></form>\n")
                .arg(desc)
                .arg(short_d)
                .arg(item->text())
                .arg((!item->isEnabled() || item->isReadOnly()) ? "" : "<input type=\"submit\" value=\"&gt;&gt;\" />")
                .arg(item->toolTip());
    }
    else if(objTypeName == "QCheckBox") {
        QCheckBox *item = (QCheckBox *) obj;
        ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
                      "<div class=\"row\">"
                        "<div class=\"prop\"><p>%1:</p></div>"
                        "<div class=\"val\"><p><input type=\"checkbox\" name=\"%2\" value=\"true\" %3/></p></div>"
                        "<div class=\"submit\"><p> %4</p></div>"
                        "<div class=\"tooltip\"><p> %5</p></div>"
                        "</div></form>\n")
                .arg(desc)
                .arg(short_d)
                .arg(item->isChecked() ? "checked" : "")
                .arg((!item->isEnabled()) ? "" : "<input type=\"submit\" value=\"&gt;&gt;\" />")
                .arg(item->toolTip());
    }
    else if(objTypeName == "QSpinBox") {
        QSpinBox *item = (QSpinBox *) obj;

        ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
                      "<div class=\"row\">"
                        "<div class=\"prop\"><p>%1:</p></div>"
                        "<div class=\"val\"><p><input type=\"number\" name=\"%2\" value=\"%3\" min=\"%4\" max=\"%5\" step=\"%6\" /></p></div>"
                        "<div class=\"submit\"><p> %7</p></div>"
                        "<div class=\"tooltip\"><p> %8</p></div>"
                        "</div></form>\n")
                .arg(desc)
                .arg(short_d)
                .arg(item->value())
                .arg(item->minimum())
                .arg(item->maximum())
                .arg(item->singleStep())
                .arg((!item->isEnabled() || item->isReadOnly()) ? "" : "<input type=\"submit\" value=\"&gt;&gt;\" />")
                .arg(item->toolTip());
    }
    else if(objTypeName == "QDoubleSpinBox") {
        QDoubleSpinBox *item = (QDoubleSpinBox *) obj;

        ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
                      "<div class=\"row\">"
                        "<div class=\"prop\"><p>%1:</p></div>"
                        "<div class=\"val\"><p><input type=\"number\" name=\"%2\" value=\"%3\" min=\"%4\" max=\"%5\" step=\"%6\" /></p></div>"
                        "<div class=\"submit\"><p> %7</p></div>"
                        "<div class=\"tooltip\"><p> %8</p></div>"
                        "</div></form>\n")
                .arg(desc)
                .arg(short_d)
                .arg(item->value())
                .arg(item->minimum())
                .arg(item->maximum())
                .arg(item->singleStep())
                .arg((!item->isEnabled() || item->isReadOnly()) ? "" : "<input type=\"submit\" value=\"&gt;&gt;\" />")
                .arg(item->toolTip());
    }
    else if(objTypeName == "QComboBox") {
        QComboBox *item = (QComboBox *) obj;

        ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
                      "<div class=\"row\">"
                        "<div class=\"prop\"><p>%1:</p></div>"
                        "<div class=\"val\"><p>\n<select name=\"%2\" style=\"max-width:170px;\">\n").arg(desc).arg(short_d);
                      int current = item->currentIndex();
                      for (int i = 0; i < item->count(); i++) {
                          ret.append(QString("<option value=\"%1\" %2>%3</option>\n").arg(i).arg(i==current ? "selected" : "").arg(item->itemText(i)));
                      }

                      ret.append(QString("</select>\n</p></div>"
                        "<div class=\"submit\"><p> %1</p></div>"
                        "<div class=\"tooltip\"><p> %2</p></div>"
                        "</div></form>\n")
                        .arg((!item->isEnabled()) ? "" : "<input type=\"submit\" value=\"&gt;&gt;\" />")
                        .arg(item->toolTip()));

    }
    else if(objTypeName == "QRadioButton") {
        QRadioButton *item = (QRadioButton *) obj;

        QString rb_vals;

        if(item->objectName() == "radioButton_rds_music") {
            rb_vals = QString("<input type=\"radio\" name=\"%1\" value=\"true\" %2/> Music <input type=\"radio\" name=\"%1\" value=\"false\" %3/> Speech")
                .arg(short_d).arg(item->isChecked() ? "checked" : "").arg(item->isChecked() ? "" : "checked");
        }

        ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
                      "<div class=\"row\">"
                        "<div class=\"prop\"><p>%1:</p></div>"
                        "<div class=\"val\"><p>%3</p></div>"
                        "<div class=\"submit\"><p> %4</p></div>"
                        "<div class=\"tooltip\"><p> %5</p></div>"
                        "</div></form>\n")
                .arg(desc)
                .arg(short_d)
                .arg(rb_vals)
                .arg((!item->isEnabled()) ? "" : "<input type=\"submit\" value=\"&gt;&gt;\" />")
                .arg(item->toolTip());
    }
    else if(objTypeName == "QPushButton") {
        QPushButton *item = (QPushButton *) obj;

        ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
                      "<div class=\"row\">"
                        "<div class=\"prop\"><p>%1:</p></div>"
                        "<div class=\"val\"><p>%3</p></div>"
                        "<div class=\"submit\"><p> %4</p></div>"
                        "<div class=\"tooltip\"><p> %5</p></div>"
                        "</div></form>\n")
                .arg(desc)
                .arg(short_d)
                .arg("action")
                .arg((!item->isEnabled()) ? "" : "<input type=\"submit\" value=\"&gt;&gt;\" />")
                .arg(item->toolTip());
    }
    else {
        qDebug() << "unimplemented obj_type: " << objTypeName;
    }

    return ret.toUtf8();
};