Exemplo n.º 1
0
	void ItemHandlerTreeView::Handle (const QDomElement& item, QWidget *pwidget)
	{
		QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ());

		QTreeView *tree = new QTreeView (XSD_);
		tree->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);

		QString prop = item.attribute ("property");
		tree->setObjectName (prop);

		tree->setHeaderHidden (item.attribute ("hideHeader") == "true");

		Factory_->RegisterDatasourceSetter (prop,
				[this] (const QString& str, QAbstractItemModel *m, Util::XmlSettingsDialog*)
					{ SetDataSource (str, m); });
		Propname2TreeView_ [prop] = tree;

		QLabel *label = new QLabel (XSD_->GetLabel (item));
		label->setWordWrap (false);

		tree->setProperty ("ItemHandler",
				QVariant::fromValue<QObject*> (this));

		int row = lay->rowCount ();
		lay->addWidget (label, row, 0, Qt::AlignLeft);
		lay->addWidget (tree, row + 1, 0, 1, -1);
	}
Exemplo n.º 2
0
XMLProcedureCall::XMLProcedureCall(CXMLDataSource *pDS, const char *pzProcName) :
	m_strRequest(4096)
{
	Init();
	SetProcedureName(pzProcName);
	SetDataSource(pDS);
}
	///////////////////////////////////////////////////////////////////////////////
	// constructor
	// Inputs:
	//	ProcessSystemBase*	processSystem	The ProcessSystem object to which
	//										this  belongs.
	//	ListenerRef		listener			The object that will receive messages for
	//										the .
	///////////////////////////////////////////////////////////////////////////////
	GeoLoadCombineAddressRange::GeoLoadCombineAddressRange(
		ProcessSystemBase* processSystem_,
		ListenerRef listener_
	) :
		SingleOutputProxy(
			processSystem_, 
			listener_
		)
	{
		SetDataSource(new DataSourceGeoLoadCombineAddressRange(this, "Output", listener_));
		configChanged = true;
	}
Exemplo n.º 4
0
	void ItemHandlerListView::Handle (const QDomElement& item, QWidget *pwidget)
	{
		QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ());

		QListView *list = new QListView (XSD_);

		const QString& prop = item.attribute ("property");
		list->setObjectName (prop);

		Factory_->RegisterDatasourceSetter (prop,
				[this] (const QString& str, QAbstractItemModel *m, Util::XmlSettingsDialog*)
					{ SetDataSource (str, m); });
		Propname2Listview_ [prop] = list;

		QLabel *label = new QLabel (XSD_->GetLabel (item));
		label->setWordWrap (false);

		list->setProperty ("ItemHandler", QVariant::fromValue<QObject*> (this));
		list->setProperty ("SearchTerms", label->text ());

		int row = lay->rowCount ();
		lay->addWidget (label, row, 0, Qt::AlignLeft);
		lay->addWidget (list, row + 1, 0);
	}
Exemplo n.º 5
0
void ItemHandlerCombobox::Handle (const QDomElement& item, QWidget *pwidget)
{
    QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ());

    QHBoxLayout *hboxLay = new QHBoxLayout;
    QComboBox *box = new QComboBox (XSD_->GetWidget ());

    hboxLay->addWidget (box);

    XSD_->SetTooltip (box, item);
    box->setObjectName (item.attribute ("property"));
    box->setSizeAdjustPolicy (QComboBox::AdjustToContents);
    if (item.hasAttribute ("maxVisibleItems"))
        box->setMaxVisibleItems (item.attribute ("maxVisibleItems").toInt ());

    bool mayHaveDataSource = item.hasAttribute ("mayHaveDataSource") &&
                             item.attribute ("mayHaveDataSource").toLower () == "true";
    if (mayHaveDataSource)
    {
        const QString& prop = item.attribute ("property");
        Factory_->RegisterDatasourceSetter (prop,
                                            [this] (const QString& str, QAbstractItemModel *m, Util::XmlSettingsDialog *xsd)
        {
            SetDataSource (str, m, xsd);
        });
        Propname2Combobox_ [prop] = box;
        Propname2Item_ [prop] = item;
    }

    hboxLay->addStretch ();

    if (item.hasAttribute ("moreThisStuff"))
    {
        QPushButton *moreButt = new QPushButton (tr ("More stuff..."));
        hboxLay->addWidget (moreButt);

        moreButt->setObjectName (item.attribute ("moreThisStuff"));
        connect (moreButt,
                 SIGNAL (released ()),
                 XSD_,
                 SLOT (handleMoreThisStuffRequested ()));
    }

    QDomElement option = item.firstChildElement ("option");
    while (!option.isNull ())
    {
        const auto& images = XSD_->GetImages (option);
        const auto& name = option.attribute ("name");

        auto label = XSD_->GetLabel (option);
        if (label.isEmpty ())
            label = name;

        if (!images.isEmpty ())
            box->addItem (QPixmap::fromImage (images.at (0)), label, name);
        else
            box->addItem (label, name);

        auto setColor = [&option, box] (const QString& attr, Qt::ItemDataRole role) -> void
        {
            if (option.hasAttribute (attr))
            {
                const QColor color (option.attribute (attr));
                box->setItemData (box->count () - 1, color, role);
            }
        };
        setColor ("color", Qt::ForegroundRole);
        setColor ("bgcolor", Qt::BackgroundRole);

        option = option.nextSiblingElement ("option");
    }

    connect (box,
             SIGNAL (currentIndexChanged (int)),
             this,
             SLOT (updatePreferences ()));

    QDomElement scriptContainer = item.firstChildElement ("scripts");
    if (!scriptContainer.isNull ())
    {
        Scripter scripter (scriptContainer);

        for (const auto& elm : scripter.GetOptions ())
            box->addItem (scripter.HumanReadableOption (elm), elm);
    }

    int pos = box->findData (XSD_->GetValue (item));
    if (pos != -1)
        box->setCurrentIndex (pos);
    else if (!mayHaveDataSource)
        qWarning () << Q_FUNC_INFO
                    << box
                    << XSD_->GetValue (item)
                    << "not found (and this item may not have a datasource)";

    QLabel *label = new QLabel (XSD_->GetLabel (item));
    label->setWordWrap (false);

    box->setProperty ("ItemHandler", QVariant::fromValue<QObject*> (this));
    box->setProperty ("SearchTerms", label->text ());

    int row = lay->rowCount ();
    lay->addWidget (label, row, 0, Qt::AlignRight);
    lay->addLayout (hboxLay, row, 1);
}
Exemplo n.º 6
0
// Adds the cell contents, and marks the row as loaded.
void ElementDataGridRow::Load(const DataQuery& row_information)
{
	// Check for a data source. If they're both set then we set
	// ourselves up with it.
	if (row_information.IsFieldSet(DataSource::CHILD_SOURCE))
	{
		Rocket::Core::String data_source = row_information.Get< Rocket::Core::String >(DataSource::CHILD_SOURCE, "");
		if (!data_source.Empty())
		{
			SetDataSource(data_source);
		}
		else
		{
			// If we've no data source, then we should remove any children.
			RemoveChildren();
		}
	}

	// Now load our cells.
	for (int i = 0; i < parent_grid->GetNumColumns(); i++)
	{
		Core::Element* cell = GetChild(i);

		if (cell)
		{
			// Fetch the column:
			const ElementDataGrid::Column* column = parent_grid->GetColumn(i);

			// Now we use the column's formatter to process the raw data into the
			// XML string, and parse that into the actual Core::Elements. If there is
			// no formatter, then we just send through the raw text, in CVS form.
			Rocket::Core::StringList raw_data;
			for (size_t i = 0; i < column->fields.size(); i++)
			{
				if (column->fields[i] == DataSource::DEPTH)
				{
					raw_data.push_back(Rocket::Core::String(8, "%d", depth));
				}
				else if (column->fields[i] == DataSource::NUM_CHILDREN)
				{
					raw_data.push_back(Rocket::Core::String(8, "%d", children.size()));
				}
				else
				{
					raw_data.push_back(row_information.Get< Rocket::Core::String >(column->fields[i], ""));
				}
			}

			Rocket::Core::String cell_string;
			if (column->formatter)
			{
				column->formatter->FormatData(cell_string, raw_data);
			}
			else
			{
				for (size_t i = 0; i < raw_data.size(); i++)
				{
					if (i > 0)
					{
						cell_string.Append(",");
					}
					cell_string.Append(raw_data[i]);
				}
			}

			// Remove all the cell's current contents.
			while (cell->GetNumChildren(true) > 0)
			{
				cell->RemoveChild(cell->GetChild(0));
			}

			// Add the new contents to the cell.
			Core::Factory::InstanceElementText(cell, cell_string);
		}
		else
		{
			ROCKET_ERROR;
		}
	}

	dirty_cells = false;
}
Exemplo n.º 7
0
	void ItemHandlerCombobox::Handle (const QDomElement& item, QWidget *pwidget)
	{
		QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ());

		QHBoxLayout *hboxLay = new QHBoxLayout;
		QComboBox *box = new QComboBox (XSD_);

		hboxLay->addWidget (box);

		XSD_->SetTooltip (box, item);
		box->setObjectName (item.attribute ("property"));
		box->setSizeAdjustPolicy (QComboBox::AdjustToContents);
		if (item.hasAttribute ("maxVisibleItems"))
			box->setMaxVisibleItems (item.attribute ("maxVisibleItems").toInt ());

		bool mayHaveDataSource = item.hasAttribute ("mayHaveDataSource") &&
				item.attribute ("mayHaveDataSource").toLower () == "true";
		if (mayHaveDataSource)
		{
			const QString& prop = item.attribute ("property");
			Factory_->RegisterDatasourceSetter (prop,
					[this] (const QString& str, QAbstractItemModel *m, Util::XmlSettingsDialog *xsd)
						{ SetDataSource (str, m, xsd); });
			Propname2Combobox_ [prop] = box;
			Propname2Item_ [prop] = item;
		}

		hboxLay->addStretch ();

		if (item.hasAttribute ("moreThisStuff"))
		{
			QPushButton *moreButt = new QPushButton (tr ("More stuff..."));
			hboxLay->addWidget (moreButt);

			moreButt->setObjectName (item.attribute ("moreThisStuff"));
			connect (moreButt,
					SIGNAL (released ()),
					XSD_,
					SLOT (handleMoreThisStuffRequested ()));
		}

		QDomElement option = item.firstChildElement ("option");
		while (!option.isNull ())
		{
			const auto& images = XSD_->GetImages (option);
			if (!images.isEmpty ())
			{
				const QIcon icon (QPixmap::fromImage (images.at (0)));
				box->addItem (icon,
						XSD_->GetLabel (option),
						option.attribute ("name"));
			}
			else
				box->addItem (XSD_->GetLabel (option),
						option.attribute ("name"));

			auto setColor = [&option, box] (const QString& attr, Qt::ItemDataRole role) -> void
			{
				if (option.hasAttribute (attr))
				{
					const QColor color (option.attribute (attr));
					box->setItemData (box->count () - 1, color, role);
				}
			};
			setColor ("color", Qt::ForegroundRole);
			setColor ("bgcolor", Qt::BackgroundRole);

			option = option.nextSiblingElement ("option");
		}

		connect (box,
				SIGNAL (currentIndexChanged (int)),
				this,
				SLOT (updatePreferences ()));

		QDomElement scriptContainer = item.firstChildElement ("scripts");
		if (!scriptContainer.isNull ())
		{
			Scripter scripter (scriptContainer);

			QStringList fromScript = scripter.GetOptions ();
			Q_FOREACH (const QString& elm, scripter.GetOptions ())
				box->addItem (scripter.HumanReadableOption (elm),
						elm);
		}
Exemplo n.º 8
0
XMLProcedureCall::XMLProcedureCall(CXMLDataSource *pDS) :
m_strRequest(4096)
{
	Init();
	SetDataSource(pDS);
}