Beispiel #1
0
/*!
 *	\~english
 *	Key press handler.
 *	\~russian
 *	Обрабатывает события при нажатии кнопок клавиатуры.
 *	\~
 */
void
wDBTable::keyPressEvent ( QKeyEvent *e )
{
	qulonglong id;

	aWidget *container = NULL;
	if ( searchMode == FALSE && e->text().at( 0 ).isPrint() )
	{
		searchOpen( e->text() );
	}
	else
	{
		searchClose();
	}

	if(containerType() =="wJournal")
	{
		e->ignore();
	}
	if(containerType() =="wCatalogue")
	{
		switch ( e->key() )
		{
		case Qt::Key_Escape:
			e->ignore();
			break;
		case Qt::Key_Return:
			if(currentRecord())
			{
				id = currentRecord()->value(0).toLongLong();
				if ( e->state() == Qt::ShiftModifier )
				{
					//printf("Shift+Return pressed %Ld\n", id);
					EditElement();
				} else
				{
					//printf("Return pressed %Ld\n", id );
					emit( selected( id ) );
				}
				e->accept();
			}
			else
			{
				aLog::print(aLog::Info, tr("wDBTable: current record not setted"));
			}
			break;
		default:
			e->ignore();
			break;
		}
	}
	Q3DataTable::keyPressEvent( e );
}
Beispiel #2
0
void
wDBTable::doubleClickEventHandler(int /*rol*/, int /*col*/, int /*button*/, const QPoint &/*mousePos*/)
{
	if(containerType() =="wCatalogue" || containerType() == "wJournal")
	{
		if(currentRecord())
		{
			qulonglong id = currentRecord()->value(0).toLongLong();
			emit( selected( id ) );
		}
	}

}
Beispiel #3
0
/* ********************************************************************* */
void TargetsDialog::aliasChanged()
{
	QSqlRecord record = currentRecord();
	if (!record.isEmpty() && record.value("alias") != ui->aliasLineEdit->text()) {
		record.setValue("alias", ui->aliasLineEdit->text());
		tableModel->setRecord(lastRowNumberSelected, record);
		if (!tableModel->submit()) {
			qWarning() << "LogBook: could not update target.  Error is: " << tableModel->lastError();
		}
	}
	ui->targetsListView->setCurrentIndex(tableModel->index(lastRowNumberSelected, 1));
}
void BarlowsDataMapper::modelChanged()
{
	QSqlRecord record = currentRecord();
	if (!record.isEmpty() && record.value("model") != widget->modelLineEdit->text()) {
		record.setValue("model", widget->modelLineEdit->text());
		tableModel->setRecord(lastRowNumberSelected, record);
		if (!tableModel->submit()) {
			qWarning() << "LogBook: could not update barlow.  Error is: " << tableModel->lastError();
		}
	}
	widget->barlowsListView->setCurrentIndex(tableModel->index(lastRowNumberSelected, 1));
}
Beispiel #5
0
/*!
 *\~english
 *	Emit signal on select record.
 *	Signal give information about selected record database id.
 *\~russian
 *	Выдает сигнал при выборе записи.
 *	Сигнал содержит информацию об id, выбранного объекта в базе данных.
 *\param -\~english Not use, only for signal compatibility.\~russian
 *	Не используются, заданы только для совместимости с сигналом таблицы.\~
 *\~
 */
void
wDBTable::lineChange(int, int)
{
	QSqlRecord * rec = currentRecord();
	if ( !rec ) return;
	qulonglong id = 0;
	if(rec->contains("id")) id = rec->value("id").toLongLong();
	//if (containerType() == "wJournal")
	//{
		//if(rec->contains("idd")) id = rec->value("idd").toLongLong();
	//}
	aLog::print(aLog::Info, tr("wDBTable: select document %1").arg(id));
	emit( selectRecord( id ) );
}
Beispiel #6
0
void TargetsDialog::targetTypeChanged(const QString &newValue)
{
	QSqlRecord record = currentRecord();
	QModelIndexList list1 = typeTableModel->match(typeTableModel->index(0, 0), Qt::DisplayRole, record.value("target_type_id"));
	Qt::MatchFlags flags = Qt::MatchExactly | Qt::MatchWrap;
	QModelIndexList list2 = typeTableModel->match(typeTableModel->index(0, 1), Qt::DisplayRole, newValue, 1, flags);

	if (!record.isEmpty() && !list1.isEmpty() && !list2.isEmpty()) {
		QSqlRecord typeRecord1 = typeTableModel->record(list1[0].row());
		QSqlRecord typeRecord2 = typeTableModel->record(list2[0].row());
		if (typeRecord1.value("target_type_id").toInt() != typeRecord2.value("target_type_id").toInt()) {
			record.setValue("target_type_id", typeRecord2.value("target_type_id").toInt());
			tableModel->setRecord(lastRowNumberSelected, record);
			if (!tableModel->submit()) {
				qWarning() << "LogBook: could not update target.  Error is: " << tableModel->lastError();
			}
		}
	}
	ui->targetsListView->setCurrentIndex(tableModel->index(lastRowNumberSelected, 1));
}
Beispiel #7
0
/*!
 *	\~english
 *	Opens form for edit catalogue element.
 *	\~russian
 *	Открывает форму по умолчанию для объекта контейнера и настраивает ее на работу с текущей строкой таблицы. Используется только в настраиваемом редакторе каталога.
 *	\~
 */
void
wDBTable::EditElement()
{

	ANANAS_UID id = 0;
//	wGroupTreeItem * item = ( wGroupTreeItem * ) tree->currentItem();
	aForm * f = 0;

//CHECK_POINT
	id = currentRecord()->value(0).toLongLong();
	if ( id ) {
		if ( engine ) {
			f = engine->openForm( aWidget::parentContainer( this )->getId(), 0, md_action_edit, md_form_elem, id, ( aWidget *) this );
			if ( f ) {
				connect(f, SIGNAL( update( ANANAS_UID )), this, SLOT(updateItem( ANANAS_UID )));
//				connect(f, SIGNAL(selected( Q_ULLONG )), this, SLOT(on_selected( Q_ULLONG )));
//				f->closeAfterSelect = true;
			}
		}
	}
}
Beispiel #8
0
DbRecord DbFile::newRecord(const char* key, const char* value, RecordType type)
{
	switch (type)
	{
	case Normal:
	{
		size_t size = DbRecord::getSize(key, value, type);
		// Record size too large
		if (size > DbPage::maxFreeSpace)
			return newRecord(key, value, Long);

		return getNewRecord(key, value, type);
	}
	case Long:
	{
		// Check value length
		size_t size = DbRecord::getSize(key, value, type);
		int valueLen = strlen(value);
		int leftValueLen = size - DbPage::maxFreeSpace;
		// Record size too small
		if (leftValueLen <= 0)
			return newRecord(key, value, Normal);

		// Split the first value str
		std::string currentStr(value, valueLen - leftValueLen);

		// Init iterators
		DbRecord firstRecord(getPage(0), 0);
		DbRecord currentRecord(getPage(0), 0);
		DbRecord lastRecord(getPage(0), 0);

		// Create records
		while (leftValueLen > 0)
		{
			lastRecord = currentRecord;
			currentRecord = getNewRecord(key, currentStr.c_str(), type);

			// Update record iterator and next record cursor
			if (type != Long)
			{
				lastRecord.nextExtendedRecord(currentRecord.getPage()->getId(), currentRecord.getCursor());
				leftValueLen -= currentStr.size();
			}
			else
			{
				firstRecord = currentRecord;
				type = LongExtended;
			}

			// Get the size of next value in the new record
			if (leftValueLen > 0)
			{
				size = DbRecord::getSize(key, value + (valueLen - leftValueLen), type);
				if (size > DbPage::maxFreeSpace)
					currentStr = std::string(value + (valueLen - leftValueLen), leftValueLen - (size - DbPage::maxFreeSpace));
				else
					currentStr = std::string(value + (valueLen - leftValueLen), leftValueLen);
			}
		}

		currentRecord.nextExtendedRecord(0, 0);
		return firstRecord;
	}
	default:
		error("Not known record type");
		return DbRecord(getPage(0), 0);		// Avoid warning
	}
}
Beispiel #9
0
void
wDBTable::updateItem( ANANAS_UID db_uid )
{
	refresh();
	emit currentChanged( currentRecord() );
}