Esempio n. 1
0
BTHistory::BTHistory(QWidget* parent)
        : m_historyList(),
        m_index(-1),
        m_inHistoryFunction(false) {
    setParent(parent);
    BT_ASSERT(class_invariant());
}
void BTHistory::sendChangedSignal()
{
	bool backEnabled = m_index > 0; //there are items in the back list
	bool fwEnabled = m_historyList.size() > m_index+1; //there are items in the fw list
	emit historyChanged(backEnabled, fwEnabled);
	Q_ASSERT(class_invariant());
}
void BTHistory::fw()
{
	qDebug("BTHistory::fw");
	if (m_index < (m_historyList.size()-1)) {
		move(m_historyList.at(m_index+1));
	}
	Q_ASSERT(class_invariant());
}
void BTHistory::back()
{
	qDebug("BTHistory::back");
	if ( m_index >= 1) {
		move(m_historyList.at(m_index-1));
	}
	Q_ASSERT(class_invariant());
}
Esempio n. 5
0
QList<QAction*> BTHistory::getFwList() {
    QList<QAction*> list;
    for (int i = m_index + 1; i < m_historyList.size(); ++i) {
        list.append(m_historyList.at(i));
    }

    BT_ASSERT(class_invariant());
    return list;
}
Esempio n. 6
0
QList<QAction*> BTHistory::getBackList() {

    QList<QAction*> list;
    for (int i = m_index - 1; i >= 0; --i) {
        list.append(m_historyList.at(i));
    }

    BT_ASSERT(class_invariant());
    return list;
}
QList<QAction*> BTHistory::getBackList()
{
	qDebug("BTHistory::getBackList");

	QList<QAction*> list;
	for (int i = m_index-1; i >= 0; --i) {
		list.append(m_historyList.at(i));
	}

	qDebug() << "return:" << list;
	Q_ASSERT(class_invariant());
	return list;
}
Esempio n. 8
0
void BTHistory::move(QAction* historyItem) {
    //BT_ASSERT(historyItem);
    BT_ASSERT(m_historyList.count());

    m_inHistoryFunction = true;
    //find the action in the list
    m_index = m_historyList.indexOf(historyItem);
    //move to the selected item in the list, it will be the current item
    emit historyMoved(m_historyList.at(m_index)->property(ActionText).toString()); // signal to "outsiders"; key has been changed
    sendChangedSignal();

    m_inHistoryFunction = false;
    BT_ASSERT(class_invariant());
}
Esempio n. 9
0
void BTHistory::add(CSwordKey* newKey) {
    BT_ASSERT(newKey);
    // Add new key Action after current index if we were not using the history functions,
    // if it's not a duplicate and if it's not empty.
    if (!m_inHistoryFunction &&    ((m_index < 0) || (newKey->key() != m_historyList.at(m_index)->property(ActionText).toString()) )) {
        if (!newKey->key().isEmpty()) {
            auto * const a = new QAction(newKey->key(), this);
            a->setProperty(ActionText, newKey->key());
            m_historyList.insert(++m_index, a);
        }
        // \todo history limit?
        sendChangedSignal();
    }
    BT_ASSERT(class_invariant());
}
QList<QAction*> BTHistory::getFwList()
{
	qDebug("BTHistory::getFwList");
	
	QList<QAction*> list;
	//qDebug() << "historyList.size:" << m_historyList.size();
	for (int i = m_index+1; i < m_historyList.size(); ++i) {
		//qDebug() << "i:" << i;
		list.append(m_historyList.at(i));
	}
	qDebug() << "return:" << list;
	
	Q_ASSERT(class_invariant());
	return list;
}
void BTHistory::add(CSwordKey* newKey) {
	qDebug("BTHistory::add");
	Q_ASSERT(newKey);
	// Add new key Action after current index if we were not using the history functions,
	// if it's not a duplicate and if it's not empty.
	if (!m_inHistoryFunction &&	((m_index < 0) || (newKey->key() != m_historyList.at(m_index)->text()) ))
	{
		if (!newKey->key().isEmpty()) {
			m_historyList.insert(++m_index, new QAction(newKey->key(), this));
		}
		// TODO: history limit?
		sendChangedSignal();
	}
	Q_ASSERT(class_invariant());
}
void BTHistory::move(QAction* historyItem)
{
	qDebug("BTHistory::move");
	//Q_ASSERT(historyItem);
	Q_ASSERT(m_historyList.count());

	m_inHistoryFunction = true;
	//find the action in the list
	m_index = m_historyList.indexOf(historyItem);
	//move to the selected item in the list, it will be the current item
	QString newKey = m_historyList.at(m_index)->text();
	emit historyMoved(newKey); // signal to "outsiders"; key has been changed
	sendChangedSignal();
	
	m_inHistoryFunction = false;
	Q_ASSERT(class_invariant());
}
Esempio n. 13
0
void BTHistory::fw() {
    if (m_index < (m_historyList.size() - 1)) {
        move(m_historyList.at(m_index + 1));
    }
    BT_ASSERT(class_invariant());
}
Esempio n. 14
0
void BTHistory::back() {
    if ( m_index >= 1) {
        move(m_historyList.at(m_index - 1));
    }
    BT_ASSERT(class_invariant());
}