Ejemplo n.º 1
0
void MainWindow::emailSaveClicked()
{
    updateContact();

    QList<QContact> contacts;
    contacts.append(m_contact);
    m_manager.saveContacts(&contacts, QStringList() << QContactEmailAddress::DefinitionName);
}
Ejemplo n.º 2
0
void MainWindow::phoneSaveClicked()
{
    updateContact();

    QList<QContact> contacts;
    contacts.append(m_contact);
    m_manager.saveContacts(&contacts, QStringList() << QContactPhoneNumber::DefinitionName);
}
Ejemplo n.º 3
0
void ChatDlg::setJid(const Jid &j)
{
	if (!j.compare(jid())) {
		account()->dialogUnregister(this);
		TabbableWidget::setJid(j);
		account()->dialogRegister(this, jid());
		updateContact(jid(), false);
	}
}
Ejemplo n.º 4
0
void ContactModel::addBot(MAGNORMOBOT *bot)
{
	if (conduits.contains(bot)) {
		qWarning("ContactModel is already tracking %p\n", bot);
		return;
	}
	connect(bot, SIGNAL(contactPresenceUpdated(QString)), SLOT(updateContactPresence(QString)));
    connect(bot, SIGNAL(contactAdded(QString)), SLOT(addContact(QString)));
    connect(bot, SIGNAL(contactUpdated(QString)), SLOT(updateContact(QString)));
    connect(bot, SIGNAL(contactRemoved(QString)), SLOT(removeContact(QString)));
	connect(bot, SIGNAL(contactListReceived()), SLOT(receiveContactList()));
	connect(bot, SIGNAL(disconnected()), SLOT(botDisconnected()), Qt::QueuedConnection);
	connect(bot, SIGNAL(destroyed()), SLOT(botDestroyed()));
    refreshContacts(bot);
}
Ejemplo n.º 5
0
int main(void)
{
	int key;
	init();
	while(1)
	{
		 printf("\n 1.Add New Contact\n");
		 printf("\n 2.Find Contact\n");
		 printf("\n 3.Delete Contact\n");
		 printf("\n 3.Update  Contact\n");
		 printf("\n Enter the choice\n");
		 scanf("%d",&key);
		 switch(key)
		 {
			 case 1:
				 addContact();
				 break;
         	         case 2:
				 {
				 char *p ="123";
				 Contact *a = findContact(p);
				 if(a)
				 {
				  printf("%s \n %s\n%s \n%s",a->firstName,a->secondName,a->firstNumber,a->secondNumber);
				 }
				 break;
				 }
			 case 3:
				 deleteContact();
				 break;
			 case 4:
				 updateContact();
				 break;
			 case 0:
			 default:
				 {
				  close();
				 printf("\n : Exitting\n");
				 }
				 return 0;
		}

	}
 return 0;
}
Ejemplo n.º 6
0
void ChatDlg::init()
{
	initUi();
	initActions();
	setShortcuts();

	// TODO: this have to be moved to chatEditCreated()
	chatView()->setDialog(this);
	chatEdit()->setDialog(this);

	chatEdit()->installEventFilter(this);
	connect(chatView(), SIGNAL(selectionChanged()), SLOT(logSelectionChanged()));

	// SyntaxHighlighters modify the QTextEdit in a QTimer::singleShot(0, ...) call
	// so we need to install our hooks after it fired for the first time
	QTimer::singleShot(10, this, SLOT(initComposing()));
	connect(this, SIGNAL(composing(bool)), SLOT(updateIsComposing(bool)));

	setAcceptDrops(TRUE);
	updateContact(jid(), true);

	X11WM_CLASS("chat");
	setLooks();

	updatePGP();

	connect(account(), SIGNAL(pgpKeyChanged()), SLOT(updatePGP()));
	connect(account(), SIGNAL(encryptedMessageSent(int, bool, int, const QString &)), SLOT(encryptedMessageSent(int, bool, int, const QString &)));
	account()->dialogRegister(this, jid());

	chatView()->setFocusPolicy(Qt::NoFocus);
	chatEdit()->setFocus();

	// TODO: port to restoreSavedSize() (and adapt it from restoreSavedGeometry())
	QSize size = PsiOptions::instance()->getOption("options.ui.chat.size").toSize();
	if (!size.isEmpty()) {
		resize(size);
	} else {
		resize(defaultSize());
	}
}
Ejemplo n.º 7
0
void ChatDlg::setLooks()
{
	// update the font
	QFont f;
	f.fromString(PsiOptions::instance()->getOption("options.ui.look.font.chat").toString());
	chatView()->setFont(f);
	chatEdit()->setFont(f);

	// update contact info
	status_ = -2; // sick way of making it redraw the status
	updateContact(jid(), false);

	// update the widget icon
#ifndef Q_WS_MAC
	setWindowIcon(IconsetFactory::icon("psi/start-chat").icon());
#endif

	/*QBrush brush;
	brush.setPixmap( QPixmap( LEGOPTS.chatBgImage ) );
	chatView()->setPaper(brush);
	chatView()->setStaticBackground(true);*/

	setWindowOpacity(double(qMax(MINIMUM_OPACITY, PsiOptions::instance()->getOption("options.ui.chat.opacity").toInt())) / 100);
}
Ejemplo n.º 8
0
bool Wheel::update(btScalar dt, WheelContact & contact)
{
	if (!updateContact(2 * radius))
		return false;

	const Surface * surface = ray.getSurface();
	if (!surface)
		return false;

	contact.frictionCoeff = tire.getTread() * surface->frictionTread +
		(1.0 - tire.getTread()) * surface->frictionNonTread;

	btRigidBody * bodyA = body;
	btRigidBody * bodyB = &getFixedBody();
	if (btRigidBody::upcast(ray.m_collisionObject))
	{
		bodyB = btRigidBody::upcast(ray.m_collisionObject);
	}

	btVector3 wheelTangent1 = transform.getBasis().getColumn(1); // forward
	btVector3 wheelTangent2 = transform.getBasis().getColumn(0); // right
	btVector3 wheelNormal = transform.getBasis().getColumn(2); // up

	btVector3 contactNormal = ray.getNormal();
	btVector3 contactPointA = ray.getPoint();
	btVector3 contactPointB = ray.getPoint();

	btScalar stiffnessConstant = suspension.getStiffness();
	btScalar dampingConstant = suspension.getDamping();
	btScalar displacement = suspension.getDisplacement();

	// update constraints
	btVector3 rA = contactPointA - bodyA->getCenterOfMassPosition();
	btVector3 rB = contactPointB - bodyB->getCenterOfMassPosition();

	btVector3 contactTangent1 = wheelTangent1 - contactNormal * contactNormal.dot(wheelTangent1);
	btVector3 contactTangent2 = wheelTangent2 - contactNormal * contactNormal.dot(wheelTangent2);
	contactTangent1.normalize();
	contactTangent2.normalize();

	// project wheel normal onto contact forward facing plane to calculate camber
	btVector3 projNormal = wheelNormal - wheelNormal.dot(contactTangent1) * contactTangent1;
	projNormal.normalize();

	contact.camber = 0;//btAcos(projNormal.dot(contactNormal)) * SIMD_DEGS_PER_RAD; fixme
	contact.vR = shaft.getAngularVelocity() * radius;
	contact.bodyA = bodyA;
	contact.bodyB = bodyB;
	contact.rA = rA;
	contact.rB = rB;

	btVector3 vA = bodyA->getLinearVelocity() + bodyA->getAngularVelocity().cross(rA);
	btVector3 vB = bodyB->getLinearVelocity() + bodyB->getAngularVelocity().cross(rB);
	btVector3 vAB = vA - vB;

	// set suspension constraint
	{
		// CFM and ERP from spring stiffness and damping constants
		btScalar softness = 1.0f / (dt * (dt * stiffnessConstant + dampingConstant));
		btScalar biasFactor = stiffnessConstant / (dt * stiffnessConstant + dampingConstant);
		btScalar velocityError = -biasFactor * displacement;

		btVector3 normal = contactNormal;
		btScalar denomA = bodyA->computeImpulseDenominator(contactPointA, normal);
		btScalar denomB = bodyB->computeImpulseDenominator(contactPointB, normal);
		btScalar jacDiagInv = 1 / (denomA + denomB + softness);

		contact.response.jacDiagInv = jacDiagInv;
		contact.response.rhs = -velocityError * jacDiagInv;
		contact.response.cfm = -softness * jacDiagInv;
		contact.response.lowerLimit = 0;
		contact.response.upperLimit = SIMD_INFINITY;
		contact.response.accumImpulse = 0;
		contact.response.normal = normal;
		contact.response.angularCompA = bodyA->getInvInertiaTensorWorld() * rA.cross(normal);
		contact.response.angularCompB = bodyB->getInvInertiaTensorWorld() * rB.cross(normal);
	}

	// set longitudinal friction constraint
	{
		btVector3 normal = contactTangent1;
		btScalar denomA = bodyA->computeImpulseDenominator(contactPointA, normal);
		btScalar denomB = bodyB->computeImpulseDenominator(contactPointB, normal);
		btScalar jacDiagInv =  1 / (denomA + denomB);
		btScalar velocityError = vAB.dot(normal) - contact.vR;

		contact.v1 = velocityError + contact.vR;
		contact.friction1.jacDiagInv = jacDiagInv;
		contact.friction1.rhs = -velocityError * jacDiagInv;
		contact.friction1.cfm = 0;
		contact.friction1.lowerLimit = 0;
		contact.friction1.upperLimit = 0;
		contact.friction1.accumImpulse = 0;
		contact.friction1.normal = normal;
		contact.friction1.angularCompA = bodyA->getInvInertiaTensorWorld() * rA.cross(normal);
		contact.friction1.angularCompB = bodyB->getInvInertiaTensorWorld() * rB.cross(normal);
	}

	// set lateral friction constraint
	{
		btVector3 normal = contactTangent2;
		btScalar denomA = bodyA->computeImpulseDenominator(contactPointA, normal);
		btScalar denomB = bodyB->computeImpulseDenominator(contactPointB, normal);
		btScalar jacDiagInv =  1 / (denomA + denomB);
		btScalar velocityError = vAB.dot(normal);

		contact.v2 = velocityError;
		contact.friction2.jacDiagInv = jacDiagInv;
		contact.friction2.rhs = -velocityError * jacDiagInv;
		contact.friction2.cfm = 0;
		contact.friction2.lowerLimit = 0;
		contact.friction2.upperLimit = 0;
		contact.friction2.accumImpulse = 0;
		contact.friction2.normal = normal;
		contact.friction2.angularCompA = bodyA->getInvInertiaTensorWorld() * rA.cross(normal);
		contact.friction2.angularCompB = bodyB->getInvInertiaTensorWorld() * rB.cross(normal);
	}
/*
	// ABS
	abs_active = false;
	btScalar brake_torque = brake.getTorque();
	btScalar slide = tire.getSlide();
	btScalar ideal_slide = tire.getIdealSlide();
	if (abs_enabled && brake_torque > 1E-3 && angvel > 1 && slide < -ideal_slide)
	{
		// predict new angvel
		btScalar angvel_delta = shaft.getAngularVelocity() - angvel;
		btScalar angvel_new = shaft.getAngularVelocity() + angvel_delta;

		// calculate brake torque correction to reach 95% ideal_slide
		btScalar angvel_target = (0.95 * ideal_slide + 1) * contact.v1 / radius;
		angvel_delta = angvel_new - angvel_target;
		if (angvel_delta < 0)
		{
			// set brake torque to reach angvel_target
			brake_torque += angvel_delta / dt * shaft.getInertia();
			btScalar factor = brake_torque / brake.getMaxTorque();
			btClamp(factor, btScalar(0), btScalar(1));
			brake.setBrakeFactor(factor);
			abs_active = true;
		}
	}

	// TCS
	tcs_active = false;
	if (tcs_enabled && slide > ideal_slide)
	{
		// predict new angvel
		btScalar angvel_delta = shaft.getAngularVelocity() - angvel;
		btScalar angvel_new = shaft.getAngularVelocity() + angvel_delta;

		// calculate brake torque correction to reach 95% ideal_slide
		btScalar angvel_target = (0.95 * ideal_slide + 1) * contact.v1 / radius;
		angvel_delta = angvel_new - angvel_target;
		if (angvel_delta > 0)
		{
			// set brake torque to reach angvel_target
			btScalar brake_torque = angvel_delta / dt * shaft.getInertia();
			btScalar factor = brake_torque / brake.getMaxTorque();
			btClamp(factor, brake.getBrakeFactor(), btScalar(1));
			brake.setBrakeFactor(factor);
			tcs_active = true;
		}
	}

	// store old angular velocity
	angvel = shaft.getAngularVelocity();
*/
	return true;
}