Exemplo n.º 1
0
void DataManipulationForm::setAttributes(Connection conn, const QString curr_schema, const QString curr_table)
{
	try
	{
		QString db_name;

    tmpl_conn_params=conn.getConnectionParams();
    db_name=QString("<strong>%1</strong>@<em>%2:%3</em>").arg(conn.getConnectionParam(Connection::PARAM_DB_NAME))
															 .arg(conn.getConnectionParam(Connection::PARAM_SERVER_IP).isEmpty() ?
																		conn.getConnectionParam(Connection::PARAM_SERVER_FQDN) : conn.getConnectionParam(Connection::PARAM_SERVER_IP))
															 .arg(conn.getConnectionParam(Connection::PARAM_PORT));

		db_name_lbl->setText(db_name);
    db_name.remove(QRegExp("<(/)?(strong|em)>"));
    this->setWindowTitle(this->windowTitle() + QString(" - ") + db_name);

		schema_cmb->clear();
		listObjects(schema_cmb, { OBJ_SCHEMA });

		schema_cmb->setCurrentText(curr_schema);
		table_cmb->setCurrentText(curr_table);
		disableControlButtons();

    if(!curr_table.isEmpty())
      retrieveData();
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(), e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
Exemplo n.º 2
0
int UIDnDHandler::sltGetData(      Qt::DropAction  dropAction,
                             const QString        &strMIMEType,
                                   QVariant::Type  vaType,
                                   QVariant       &vaData)
{
    int rc = retrieveData(dropAction, strMIMEType, vaType, vaData);
    LogFlowFuncLeaveRC(rc);
    return rc;
}
Exemplo n.º 3
0
 /** Clear Y and E vectors */
 void ManagedHistogram1D::clearData()
 {
   retrieveData();
   m_dirty = true;
   MantidVec & yValues = this->dataY();
   std::fill(yValues.begin(), yValues.end(), 0.0);
   MantidVec & eValues = this->dataE();
   std::fill(eValues.begin(), eValues.end(), 0.0);
 }
Exemplo n.º 4
0
Mpris2Player::Mpris2Player(const QString &service, QObject *parent)
    : QObject(parent)
    , m_serviceName(service)
    , m_fetchesPending(0)
    , m_capabilities(NoCapabilities)
    , m_metadata(new QQmlPropertyMap(this))
    , m_status(QStringLiteral("Stopped"))
    , m_fullScreen(false)
    , m_position(0)
    , m_rate(0)
    , m_minimumRate(0)
    , m_maximumRate(0)
    , m_volume(0)
{
    // Create D-Bus adaptors
    m_propsInterface = new OrgFreedesktopDBusPropertiesInterface(service, objectPath,
                                                                 QDBusConnection::sessionBus(),
                                                                 this);
    m_interface = new OrgMprisMediaPlayer2Interface(service, objectPath,
                                                    QDBusConnection::sessionBus(),
                                                    this);
    m_playerInterface = new OrgMprisMediaPlayer2PlayerInterface(service, objectPath,
                                                                QDBusConnection::sessionBus(),
                                                                this);

    // Receive properties changes
    connect(m_propsInterface, &OrgFreedesktopDBusPropertiesInterface::PropertiesChanged,
            [=](const QString &interface, const QVariantMap &changedProperties, const QStringList &invalidatedProperties) {
        Q_UNUSED(interface);

        updateFromMap(changedProperties);
        if (!invalidatedProperties.isEmpty())
            retrieveData();
    });
    connect(m_playerInterface, &OrgMprisMediaPlayer2PlayerInterface::Seeked, [=](qlonglong offset) {
        m_position = offset;
        Q_EMIT positionChanged();
    });

    // Retrieve data
    retrieveData();
}
Exemplo n.º 5
0
bool HDataRetriever::retrieveIcon(
    const QUrl& deviceLocation, const QUrl& iconUrl, QByteArray* data)
{
    HLOG2(H_AT, H_FUN, m_loggingIdentifier);

    HLOG_DBG(QString(
        "Attempting to retrieve icon [%1] from: [%2]").arg(
            iconUrl.toString(), deviceLocation.toString()));

    return retrieveData(deviceLocation, iconUrl, data);
}
Exemplo n.º 6
0
void CWTabBar::topicChanged(CWTopic * pNewTopic)
{
	ASSERTX(pNewTopic->IsKindOf(RUNTIME_CLASS(CWTopic)));

//RTRACE("TabBar topicChanged 1\n"); //!!
	retrieveData();

	// did just the topic (tree selection) change, or did
	// the user change to a whole new topic tab (click on the tab bar)?
	if (!m_pLastTab || pNewTopic->GetOwningTab() != m_pLastTab)
	{
		m_pLastTab = pNewTopic->GetOwningTab();
		getTopicTree()->TopicTabChanged();
	}


	SIZE	size;
	CRect	rect;
	GetClientRect(&rect);

	size.cx = kTREEWIDTH; //(rect.right - m_wndSplitterInner.GetSplitterWidth())/2;
	size.cy = rect.bottom;

	gTopicForViewCreation = pNewTopic; // use global because we can't send this information directly to the cformview constructor

	if(pNewTopic->IsKindOf(RUNTIME_CLASS(CWFormTopic)))
	{
///(" replacing form view...\n"); //!!
		m_wndSplitter.ReplaceView(0,1, RUNTIME_CLASS(CWFormView), size);
//RTRACE(" after replacing form view...\n"); //!!
	}
	else if (pNewTopic->IsKindOf(RUNTIME_CLASS(CWListTopic)))
	{	m_wndSplitter.ReplaceView(0,1, RUNTIME_CLASS(CWListView), size);
		// the following is a hack; it appears that the list
		// gets drawn, then everything but the header is deleted,
		// with the background color.  This causes it to be
		// redrawn yet again
		// Also, I note that when the list is drawn, the whole
		// Win95 screen is redrawn, which is a visiable flicker
		// even on my 233Mhz machine.
		getContentView()->Invalidate(FALSE);
	}
	else if (pNewTopic->IsKindOf(RUNTIME_CLASS(CWHeadingTopic)))
		m_wndSplitter.ReplaceView(0,1, RUNTIME_CLASS(CWHeadingView), size);
	else
		ASSERTX(FALSE);	// unhandled topic type

	// we want the focus to be on the data, not the topic tree
//	GetParentFrame()->SetActiveView((CView*)getContentView());
//	getContentView()->SetFocus();
	gTopicForViewCreation = NULL;
}
Exemplo n.º 7
0
bool testRetrieveData() {
    RetrieveData *retrieveObj;
    char *response = NULL;

    retrieveObj = createRetrieveDataObject(1410387088000, 1415301870434);
    addDeviceId(retrieveObj, "02-00-a7-81-77-ff");
    addDeviceId(retrieveObj, "c0-3f-d5-60-d0-74");
    addSensorId(retrieveObj, "madras7");
    addSensorId(retrieveObj, "madras9");

    response = retrieveData(retrieveObj);
    printf("Response Received :%s\n", response);

    return true;
}
Exemplo n.º 8
0
bool HDataRetriever::retrieveDeviceDescription(
    const QUrl& deviceLocation, QString* data)
{
    HLOG2(H_AT, H_FUN, m_loggingIdentifier);

    HLOG_DBG(QString(
        "Attempting to fetch a device description from: [%1]").arg(
            deviceLocation.toString()));

    QByteArray tmp;
    if (!retrieveData(deviceLocation, QUrl(), &tmp))
    {
        return false;
    }

    *data = QString::fromUtf8(tmp);
    return true;
}
Exemplo n.º 9
0
 std::map<DataSetId, std::string> terrama2::core::DataAccessorJsonCemaden::getFiles(const Filter& filter, std::shared_ptr<FileRemover> remover) const
 {
   auto& retrieverFactory = DataRetrieverFactory::getInstance();
   DataRetrieverPtr dataRetriever = retrieverFactory.make(dataProvider_);

   // Cemaden has only one service for all DCPs
   // all information is replicated in all DCPs
   auto dataset = dataSeries_->datasetList.front();
   auto uri = retrieveData(dataRetriever, dataset, filter, remover);

   // map all dataset to the same uri
   std::map<DataSetId, std::string> uriMap;
   for(const auto& dataset : dataSeries_->datasetList)
   {
     uriMap.emplace(dataset->id, uri);
   }

   return uriMap;
 }
Exemplo n.º 10
0
int UIDnDHandler::retrieveData(      Qt::DropAction  dropAction,
                               const QString        &strMIMEType,
                                     QVariant::Type  vaType,
                                     QVariant       &vaData)
{
    QVector<uint8_t> vecData;
    int rc = retrieveData(dropAction, strMIMEType, vecData);
    if (RT_SUCCESS(rc))
    {
        /* If no/an invalid variant is set, try to guess the variant type.
         * This can happen on OS X. */
        if (vaType == QVariant::Invalid)
            vaType = UIDnDMIMEData::getVariantType(strMIMEType);

        rc = UIDnDMIMEData::getDataAsVariant(vecData, strMIMEType, vaType, vaData);
    }

    LogFlowFuncLeaveRC(rc);
    return rc;
}
Exemplo n.º 11
0
void NewstuffModel::retrieveData()
{
    if ( d->m_currentReply && d->m_currentReply->isReadable() ) {
        // check if we are redirected
        const QVariant redirectionAttribute = d->m_currentReply->attribute( QNetworkRequest::RedirectionTargetAttribute );
        if ( !redirectionAttribute.isNull() ) {
            d->m_currentReply = d->m_networkAccessManager.get( QNetworkRequest( redirectionAttribute.toUrl() ) );
            QObject::connect( d->m_currentReply, SIGNAL(readyRead()), this, SLOT(retrieveData()) );
            QObject::connect( d->m_currentReply, SIGNAL(readChannelFinished()), this, SLOT(retrieveData()) );
            QObject::connect( d->m_currentReply, SIGNAL(downloadProgress(qint64,qint64)),
                              this, SLOT(updateProgress(qint64,qint64)) );
        } else {
            d->m_currentFile->write( d->m_currentReply->readAll() );
            if ( d->m_currentReply->isFinished() ) {
                d->m_currentReply->deleteLater();
                d->m_currentReply = nullptr;
                d->m_currentFile->flush();
                d->installMap();
            }
        }
    }
}
QVariant sipQMimeData::sipProtectVirt_retrieveData(bool sipSelfWasArg,const QString& a0,QVariant::Type a1) const
{
    return (sipSelfWasArg ? QMimeData::retrieveData(a0,a1) : retrieveData(a0,a1));
}
Exemplo n.º 13
0
 QVariant variantData(const QString &mime) { return retrieveData(mime, QVariant::Invalid); }
Exemplo n.º 14
0
void DataManipulationForm::saveChanges(void)
{
	int row=0;
  Connection conn=Connection(tmpl_conn_params);

	try
	{
		QString cmd;
		Messagebox msg_box;

    msg_box.show(trUtf8("<strong>WARNING:</strong> Once commited its not possible to undo the changes! Proceed with saving?"),
								 Messagebox::ALERT_ICON,
								 Messagebox::YES_NO_BUTTONS);

		if(msg_box.result()==QDialog::Accepted)
		{

			//Forcing the cell editor to be closed by selecting an unexistent cell and clearing the selection
			results_tbw->setCurrentCell(-1,-1, QItemSelectionModel::Clear);

      conn.connect();
      conn.executeDDLCommand(QString("START TRANSACTION"));

			for(unsigned idx=0; idx < changed_rows.size(); idx++)
			{
				row=changed_rows[idx];
				cmd=getDMLCommand(row);
        conn.executeDDLCommand(cmd);
			}

      conn.executeDDLCommand(QString("COMMIT"));
      conn.close();

			retrieveData();
			undo_tb->setEnabled(false);
			save_tb->setEnabled(false);
		}
	}
	catch(Exception &e)
	{
		map<unsigned, QString> op_names={{ OP_DELETE, trUtf8("delete") },
																		 { OP_UPDATE, trUtf8("update") },
																		 { OP_INSERT, trUtf8("insert") }};

		QString tab_name=QString("%1.%2")
										 .arg(schema_cmb->currentText())
										 .arg(table_cmb->currentText());

		unsigned op_type=results_tbw->verticalHeaderItem(row)->data(Qt::UserRole).toUInt();

    if(conn.isStablished())
		{
      conn.executeDDLCommand(QString("ROLLBACK"));
      conn.close();
		}

		results_tbw->selectRow(row);
		results_tbw->scrollToItem(results_tbw->item(row, 0));

		throw Exception(Exception::getErrorMessage(ERR_ROW_DATA_NOT_MANIPULATED)
										.arg(op_names[op_type]).arg(tab_name).arg(row + 1).arg(e.getErrorMessage()),
										ERR_ROW_DATA_NOT_MANIPULATED,__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
Exemplo n.º 15
0
DataManipulationForm::DataManipulationForm(QWidget * parent, Qt::WindowFlags f): QDialog(parent, f)
{
	setupUi(this);
  setWindowFlags(Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);

  filter_hl=new SyntaxHighlighter(filter_txt);
  filter_hl->loadConfiguration(GlobalAttributes::SQL_HIGHLIGHT_CONF_PATH);

	code_compl_wgt=new CodeCompletionWidget(filter_txt);
	code_compl_wgt->configureCompletion(nullptr, filter_hl);

	refresh_tb->setToolTip(refresh_tb->toolTip() + QString(" (%1)").arg(refresh_tb->shortcut().toString()));
	save_tb->setToolTip(save_tb->toolTip() + QString(" (%1)").arg(save_tb->shortcut().toString()));
	undo_tb->setToolTip(undo_tb->toolTip() + QString(" (%1)").arg(undo_tb->shortcut().toString()));
	export_tb->setToolTip(export_tb->toolTip() + QString(" (%1)").arg(export_tb->shortcut().toString()));
	delete_tb->setToolTip(delete_tb->toolTip() + QString(" (%1)").arg(delete_tb->shortcut().toString()));
	add_tb->setToolTip(add_tb->toolTip() + QString(" (%1)").arg(add_tb->shortcut().toString()));

  //Forcing the splitter that handles the bottom widgets to resize its children to their minimum size
  h_splitter->setSizes({500, 250, 500});
  v_splitter->setVisible(false);

	connect(close_btn, SIGNAL(clicked()), this, SLOT(reject()));
	connect(schema_cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(listTables()));
	connect(hide_views_chk, SIGNAL(toggled(bool)), this, SLOT(listTables()));
	connect(schema_cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(disableControlButtons()));
	connect(table_cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(disableControlButtons()));
	connect(table_cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(listColumns()));
  connect(table_cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(retrieveData()));
  connect(refresh_tb, SIGNAL(clicked()), this, SLOT(retrieveData()));
	connect(add_ord_col_tb, SIGNAL(clicked()), this, SLOT(addColumnToList()));
	connect(ord_columns_lst, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(removeColumnFromList()));
	connect(ord_columns_lst, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(changeOrderMode(QListWidgetItem*)));
	connect(rem_ord_col_tb, SIGNAL(clicked()), this, SLOT(removeColumnFromList()));
	connect(clear_ord_cols_tb, SIGNAL(clicked()), this, SLOT(clearColumnList()));
	connect(results_tbw, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(markUpdateOnRow(QTableWidgetItem *)));
	connect(delete_tb, SIGNAL(clicked()), this, SLOT(markDeleteOnRows()));
	connect(add_tb, SIGNAL(clicked()), this, SLOT(insertRow()));
	connect(undo_tb, SIGNAL(clicked()), this, SLOT(undoOperations()));
	connect(save_tb, SIGNAL(clicked()), this, SLOT(saveChanges()));
	connect(ord_columns_lst, SIGNAL(currentRowChanged(int)), this, SLOT(enableColumnControlButtons()));
	connect(move_down_tb, SIGNAL(clicked()), this, SLOT(swapColumns()));
	connect(move_up_tb, SIGNAL(clicked()), this, SLOT(swapColumns()));
  connect(filter_tb, SIGNAL(toggled(bool)), v_splitter, SLOT(setVisible(bool)));

	//Using the QueuedConnection here to avoid the "edit: editing failed" when editing and navigating through items using tab key
	connect(results_tbw, SIGNAL(currentCellChanged(int,int,int,int)), this, SLOT(insertRowOnTabPress(int,int,int,int)), Qt::QueuedConnection);

	connect(results_tbw, &QTableWidget::itemPressed,
          [=](){ SQLExecutionWidget::copySelection(results_tbw); });

	connect(copy_tb, &QToolButton::clicked,
          [=](){ SQLExecutionWidget::copySelection(results_tbw, false); });

	connect(export_tb, &QToolButton::clicked,
          [=](){ SQLExecutionWidget::exportResults(results_tbw); });

	connect(results_tbw, &QTableWidget::itemSelectionChanged,
					[=](){ 	QList<QTableWidgetSelectionRange> sel_ranges=results_tbw->selectedRanges();
									copy_tb->setEnabled(!sel_ranges.isEmpty());
									delete_tb->setEnabled(results_tbw->editTriggers()!=QAbstractItemView::NoEditTriggers && !sel_ranges.isEmpty()); });
}
Exemplo n.º 16
0
bool VoxelTree::readFromSchematicFile(const char *fileName) {
    _stopImport = false;
    emit importProgress(0);

    std::stringstream ss;
    int err = retrieveData(std::string(fileName), ss);
    if (err && ss.get() != TAG_Compound) {
        qDebug("[ERROR] Invalid schematic file.\n");
        return false;
    }

    ss.get();
    TagCompound schematics(ss);
    if (!schematics.getBlocksId() || !schematics.getBlocksData()) {
        qDebug("[ERROR] Invalid schematic data.\n");
        return false;
    }

    int max = (schematics.getWidth() > schematics.getLength()) ? schematics.getWidth() : schematics.getLength();
    max = (max > schematics.getHeight()) ? max : schematics.getHeight();

    int scale = 1;
    while (max > scale) {scale *= 2;}
    float size = 1.0f / scale;

    emit importSize(size * schematics.getWidth(),
                    size * schematics.getHeight(),
                    size * schematics.getLength());

    int create = 1;
    int red = 128, green = 128, blue = 128;
    int count = 0;

    for (int y = 0; y < schematics.getHeight(); ++y) {
        for (int z = 0; z < schematics.getLength(); ++z) {
            emit importProgress((int) 100 * (y * schematics.getLength() + z) / (schematics.getHeight() * schematics.getLength()));

            for (int x = 0; x < schematics.getWidth(); ++x) {
                if (_stopImport) {
                    qDebug("[DEBUG] Canceled import at %d voxels.\n", count);
                    _stopImport = false;
                    return true;
                }

                int pos  = ((y * schematics.getLength()) + z) * schematics.getWidth() + x;
                int id   = schematics.getBlocksId()[pos];
                int data = schematics.getBlocksData()[pos];

                create = 1;
                computeBlockColor(id, data, red, green, blue, create);

                switch (create) {
                    case 1:
                        createVoxel(size * x, size * y, size * z, size, red, green, blue, true);
                        ++count;
                        break;
                    case 2:
                        switch (data) {
                            case 0:
                                createVoxel(size * x + size / 2, size * y + size / 2, size * z           , size / 2, red, green, blue, true);
                                createVoxel(size * x + size / 2, size * y + size / 2, size * z + size / 2, size / 2, red, green, blue, true);
                                break;
                            case 1:
                                createVoxel(size * x           , size * y + size / 2, size * z           , size / 2, red, green, blue, true);
                                createVoxel(size * x           , size * y + size / 2, size * z + size / 2, size / 2, red, green, blue, true);
                                break;
                            case 2:
                                createVoxel(size * x           , size * y + size / 2, size * z + size / 2, size / 2, red, green, blue, true);
                                createVoxel(size * x + size / 2, size * y + size / 2, size * z + size / 2, size / 2, red, green, blue, true);
                                break;
                            case 3:
                                createVoxel(size * x           , size * y + size / 2, size * z           , size / 2, red, green, blue, true);
                                createVoxel(size * x + size / 2, size * y + size / 2, size * z           , size / 2, red, green, blue, true);
                                break;
                        }
                        count += 2;
                        // There's no break on purpose.
                    case 3:
                        createVoxel(size * x           , size * y, size * z           , size / 2, red, green, blue, true);
                        createVoxel(size * x + size / 2, size * y, size * z           , size / 2, red, green, blue, true);
                        createVoxel(size * x           , size * y, size * z + size / 2, size / 2, red, green, blue, true);
                        createVoxel(size * x + size / 2, size * y, size * z + size / 2, size / 2, red, green, blue, true);
                        count += 4;
                        break;
                }
            }
        }
    }

    emit importProgress(100);
    qDebug("Created %d voxels from minecraft import.\n", count);

    return true;
}
Exemplo n.º 17
0
QString ConfigFile::certificatePasswd() const
{
    return retrieveData(QString(), QLatin1String(certPasswd)).toString();
}
 void retrievePointerData(CommandQueueType& commandQueue) {
     for (auto& pointerData : pointerDataList)
         retrieveData(commandQueue, pointerData);
 }