コード例 #1
0
    void FilterWidget::filterButton_clicked()
    {
        TQueryMap opts;

		Attr *a = 0;
		for( int i = 0; i < attrList.size(); i++ )
		{
			QApplication::processEvents();

			a = attrList.at(i);

			if ( widgetMap.contains( a->getName() )  )
			{
				QWidget *w = widgetMap[a->getName() ];
				if ( false == w->isEnabled() )
					continue;

				QString v = getWidgetData( a, w );
				if ( !v.isEmpty() ) {

                    int flag = Like | Case;

					bool ok;
					v.toInt(&ok, 10);

					if ( ok ) {
						flag = Equal;
					}

                    if (a->getType() == Attr::Bool) {
                        flag = Equal;
                    }

					if ( opts.size() > 0 ) {
						flag |= And;
					}

					opts.insert(a->getName(),keeper->prepareParam(flag, v));
				}
			}
		}

        emit filterActivated(opts);
    }
コード例 #2
0
void dumpTree(std::ostream& result, Node node, std::string indent)
{
    while (node) {
        result << indent << node << '\n';
        Element element = interface_cast<Element>(node);
        if (element.getNodeType() == Node::ELEMENT_NODE) {
            ObjectArray<Attr> attrArray = element.getAttributes();
            assert(attrArray);
            for (unsigned int i = 0; i < attrArray.getLength(); ++i) {
                Attr attr = attrArray.getElement(i);
                assert(attr);
                result << indent << "  " << attr.getName() << "=\"" << attr.getValue() << "\"\n";
            }
        }
        if (node.hasChildNodes())
            dumpTree(result, node.getFirstChild(), indent + ((node.getNodeType() == Node::DOCUMENT_NODE) ? "| " : "  "));
        node = node.getNextSibling();
    }
}
コード例 #3
0
ファイル: hc_attrname.hpp プロジェクト: QuentinFiard/arabica
  /*
   * Runs the test case.
   */
  void runTest()
  {
     Document doc;
     NodeList addressList;
     Node testNode;
     NamedNodeMap attributes;
     Attr streetAttr;
     String strong1;
     String strong2;
     doc = (Document) baseT::load("hc_staff", false);
     addressList = doc.getElementsByTagName(SA::construct_from_utf8("acronym"));
     testNode = addressList.item(1);
     attributes = testNode.getAttributes();
     streetAttr = (Attr) attributes.getNamedItem(SA::construct_from_utf8("class"));
     strong1 = streetAttr.getNodeName();
     strong2 = streetAttr.getName();
     baseT::assertEquals("class", strong1, __LINE__, __FILE__);
 baseT::assertEquals("class", strong2, __LINE__, __FILE__);
 
  }
コード例 #4
0
ファイル: listwidget.cpp プロジェクト: alexey-zayats/melampig
    void ListWidget::actionAdd_clicked()
    {
        QModelIndex index = view->selectionModel()->currentIndex();

        int row = model->rowCount();
        try
        {
            if (!model->insertRow(row, index.parent() ))
                return;
        } catch (SqlError &err) {
            QMessageBox::critical( this, tr("Error"), err.getText() + "\n" + err.getQuery() );
        }

        updateActions();

        try
        {
            Attr *a;
            QList<Attr*> attr = obj->attrSchema();
            QStringList views = obj->getViewItem();
            for( int i = 0; i < attr.size(); i++ )
            {
                a = attr.at(i);
                QString name = a->getName();

                if ( !views.contains(name) )
                    continue;

                QModelIndex child = model->index(row, i, index.parent());
                model->setData(child, QVariant(), Qt::EditRole);
            }
        }
        catch ( SqlError &err )
        {
            QMessageBox::critical(this, tr("Sql error"), err.getText().append( err.getQuery() ) );
        }

    }
コード例 #5
0
    FilterWidget::FilterWidget(TQueryMap opts, QList<Attr*> list, Keeper *keeper, QWidget *parent) :
        QWidget(parent), keeper(keeper), attrList(list), parentWidget(parent), opts(opts)
    {
        innerWidget = new QWidget(this);

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

		innerLayout = new QGridLayout( innerWidget );
		innerLayout->setSpacing(2);
		innerLayout->setMargin(2);

		QWidget *w = 0;
		int row = 0;
		for( int i = 0; i < attrList.size(); i++ )
		{
			QApplication::processEvents();

			Attr *a = list.at(i);

			w = getAttrWidget( a, innerWidget );
			if ( !w ) continue;

            QCheckBox *box = new QCheckBox( a->getTitle(), innerWidget);

            if ( opts.contains(a->getName()) ) {
                box->setChecked(true);
                setWidgetData(a, w, opts[a->getName()]);
            } else {
                w->setEnabled(false);
            }
			widgetMap.insert( a->getName(), w );


			connect(box, SIGNAL(toggled(bool)), w, SLOT(setEnabled(bool)));

			innerLayout->addWidget( box, row++, 0 );
			innerLayout->addWidget( w, row++, 0);
		}

		filterButton = new QPushButton(tr("Filter"), innerWidget);
		filterButton->setIcon(QIcon(":/icons/magnifier.png"));

		clearButton = new QPushButton(tr("Clear"), innerWidget);
		clearButton->setIcon(QIcon(":/icons/cancel.png"));

		connect(filterButton, SIGNAL(clicked()), this, SLOT(filterButton_clicked()));
		connect(clearButton, SIGNAL(clicked()), this, SLOT(clearButton_clicked()));

		QBoxLayout *hlayout = new QBoxLayout(QBoxLayout::LeftToRight);
		hlayout->addWidget(filterButton);
		hlayout->addWidget(clearButton);
		hlayout->addItem(new QSpacerItem(10, 10 ));

		innerLayout->addLayout(hlayout, row++, 0);
		innerLayout->addItem( new QSpacerItem(20, 1200, QSizePolicy::Maximum, QSizePolicy::Maximum), row, 0);

        QGridLayout *glayout = new QGridLayout(this);
        glayout->addWidget(scrollArea,  0, 0);

		glayout->setSpacing(2);
		glayout->setMargin(2);

        setLayout(glayout);
    }