Exemplo n.º 1
0
FlightPanel::FlightPanel(QWidget *parent):
    QWidget(parent),
    wi(this),
    timer(this)
{
    up.reset(new QPushButton(QIcon(), QString("up"), this));
    down.reset(new QPushButton(QIcon(), QString("down"), this));
    left.reset(new QPushButton(QIcon(), QString("left"), this));
    right.reset(new QPushButton(QIcon(), QString("right"), this));

    up->resize(   controlHeight, controlHeight/2.5);
    down->resize( controlHeight, controlHeight/2.5);
    left->resize( controlHeight, controlHeight/2.5);
    right->resize(controlHeight, controlHeight/2.5);

    QRect rect = QRect(0, 0, this->width(), this->height() - 50);
    wi.setGeometry(rect);
    wi.setVisible(true);

    QObject::connect(&timer, SIGNAL(timeout()), this, SLOT(tick()));

    QObject::connect(up.get(), SIGNAL(clicked()),    &wi, SLOT(rotateUp()));
    QObject::connect(down.get(), SIGNAL(clicked()),  &wi, SLOT(rotateDown()));
    QObject::connect(left.get(), SIGNAL(clicked()),  &wi, SLOT(rotateLeft()));
    QObject::connect(right.get(), SIGNAL(clicked()), &wi, SLOT(rotateRight()));
    timer.setInterval(200);
    timer.start();
}
Exemplo n.º 2
0
void KHistoryComboBox::keyPressEvent( QKeyEvent *e )
{
    int event_key = e->key() | e->modifiers();

    if ( KStandardShortcut::rotateUp().contains(event_key) )
        rotateUp();
    else if ( KStandardShortcut::rotateDown().contains(event_key) )
        rotateDown();
    else
        KComboBox::keyPressEvent( e );
}
Exemplo n.º 3
0
void KHistoryComboBox::wheelEvent( QWheelEvent *ev )
{
    // Pass to poppable listbox if it's up
    QAbstractItemView* const iv = view();
    if ( iv && iv->isVisible() )
    {
        QApplication::sendEvent( iv, ev );
        return;
    }
    // Otherwise make it change the text without emitting activated
    if ( ev->delta() > 0 ) {
        rotateUp();
    } else {
        rotateDown();
    }
    ev->accept();
}
Exemplo n.º 4
0
	// ----------------------------------------------------------------------------
	//	parses the next command from m_instrStream
	// ----------------------------------------------------------------------------
	void CRPNCalc::parse()
	{
		double number = 0;
		while (m_buffer.length() != 0)
		{
			bool delDecimal = false;
			//erase the spaces at the beginning of the string
			while(m_buffer[0] == ' ')
				m_buffer.erase(m_buffer.begin());
			number = atof(m_buffer.c_str());
			//if it is a number
			if((number != 0 && m_buffer[0] != '+') || m_buffer[0] == '0')
			{
				if(m_buffer[0] == '-')
					m_buffer.erase(m_buffer.begin());
				while((m_buffer[0] >= '0' && m_buffer[0] <= '9')
					|| m_buffer[0] == '.')
				{
					if(m_buffer[0] == '.')
						if(delDecimal == false)
							delDecimal = true;
						else
							break;
					m_buffer.erase(m_buffer.begin());
					if(m_buffer.length() == 0)
						break;
				}
				m_stack.push_front(number);
			}
			else
			{
				string token;
				//if the beginning is a character
				if(m_buffer.length() >= 2)
				{
					//special situation with CE
					if(toupper(m_buffer[0]) == 'C' 
						&& toupper(m_buffer[1]) == 'E')
					{
						m_buffer.erase(m_buffer.begin(),m_buffer.begin() + 2);
						clearAll();
						continue;
					}
					//special situation with -0
					else if(m_buffer[0] == '-' && m_buffer[1] == '0')
					{
						m_buffer.erase(m_buffer.begin());
						while(m_buffer[0] == '0')
						{
							m_buffer.erase(m_buffer.begin());
							if(m_buffer.length() == 0)
								break;
						}
						m_stack.push_front(number);
						neg();
						continue;
					}
					//special situation with S0-9
					else if(toupper(m_buffer[0]) == 'S' && 
						m_buffer[1] >= '0' && m_buffer[1] <= '9')
					{
						m_buffer.erase(m_buffer.begin()); // delete the 'S' to get the number
						char index = m_buffer[0];
						setReg(static_cast<int>(index) - ZEROINASCII);
						m_buffer.erase(m_buffer.begin()); // delete the number
						continue;
					}
					//special situation with G0-9
					else if(toupper(m_buffer[0]) == 'G' && 
						m_buffer[1] >= '0' && m_buffer[1] <= '9')
					{
						m_buffer.erase(m_buffer.begin()); // delete the 'G' to get the number
						char index = m_buffer[0];
						getReg(static_cast<int>(index) - ZEROINASCII);
						m_buffer.erase(m_buffer.begin()); // delete the number
						continue;
					}
				}
				if (m_buffer.length() != 0)
				{
					token = m_buffer[0];
					if (0 == token.compare("+"))
						add();
					else if (0 == token.compare("-"))
						subtract();
					else if (0 == token.compare("*"))
						multiply();
					else if (0 == token.compare("/"))
						divide();
					else if (0 == token.compare("^"))
						exp();
					else if (0 == token.compare("%"))
						mod();
					else if (0 == token.compare("c") || 0 == token.compare("C"))
						clearEntry();
					else if (0 == token.compare("d") || 0 == token.compare("D"))
						rotateDown();
					else if (0 == token.compare("f") || 0 == token.compare("F"))
						saveToFile();
					else if (0 == token.compare("h") || 0 == token.compare("H"))
						m_helpOn = !m_helpOn;
					else if (0 == token.compare("l") || 0 == token.compare("L"))
						loadProgram();
					else if (0 == token.compare("m") || 0 == token.compare("M"))
						neg();
					else if (0 == token.compare("p") || 0 == token.compare("P"))
						recordProgram();
					else if (0 == token.compare("r") || 0 == token.compare("R"))
					{
						//the application only do this method and ignore other methods
						//if they are inputed at the same line
						runProgram();
						return;
					}
					else if (0 == token.compare("u") || 0 == token.compare("U"))
						rotateUp();
					else if (0 == token.compare("x") || 0 == token.compare("X"))
						m_on = false;
					else
						m_error = true;
					m_buffer.erase(m_buffer.begin());
				}
			}
		}
	}