[Kmymoney-devel] Small port of ButtonState in register.cpp
Alvaro Soliverez
asoliverez at gmail.com
Fri Jun 4 03:40:05 CEST 2010
Hello Cristian,
here is a patch to port Qt::ButtonState into Qt::MouseButton in register.cpp
Since I'm not sure the port is ok, I'm sending it to you.
I hope it is of use.
Regards,
Alvaro
-------------- next part --------------
Index: kmymoney/widgets/register.h
===================================================================
--- kmymoney/widgets/register.h (revisión: 1134334)
+++ kmymoney/widgets/register.h (copia de trabajo)
@@ -502,6 +502,7 @@
protected:
+ void mousePressEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
void contextMenuEvent(QContextMenuEvent *e);
@@ -532,7 +533,7 @@
* @param state state of Qt::ShiftModifier, Qt::ControlModifier, Qt::AltModifier and
* Qt::MetaModifier.
*/
- void scrollPage(int key, Qt::ButtonState state);
+ void scrollPage(int key);
/**
* This method determines the pointer to a RegisterItem
@@ -633,7 +634,7 @@
bool m_listsDirty;
bool m_ignoreNextButtonRelease;
bool m_needInitialColumnResize;
- Qt::ButtonState m_buttonState;
+ Qt::MouseButtons m_mouseButton;
Column m_lastCol;
QList<TransactionSortField> m_sortOrder;
QRect m_lastRepaintRect;
Index: kmymoney/widgets/register.cpp
===================================================================
--- kmymoney/widgets/register.cpp (revisión: 1134334)
+++ kmymoney/widgets/register.cpp (copia de trabajo)
@@ -467,7 +467,7 @@
m_listsDirty(false),
m_ignoreNextButtonRelease(false),
m_needInitialColumnResize(false),
- m_buttonState(Qt::ButtonState(0))
+ m_mouseButton(Qt::MouseButton(0))
{
m_itemDelegate = new RegisterItemDelegate(this);
@@ -1404,10 +1404,16 @@
return;
}
- m_buttonState = e->state();
+ m_mouseButton = e->buttons();
QTableWidget::mouseReleaseEvent(e);
}
+void Register::mousePressEvent(QMouseEvent *e)
+{
+ m_mouseButton = e->buttons();
+ QTableWidget::mousePressEvent(e);
+}
+
void Register::contextMenuEvent(QContextMenuEvent *e)
{
if (e->reason() == QContextMenuEvent::Mouse) {
@@ -1494,8 +1500,8 @@
// kDebug(2) << "Register::selectItem(" << item << "): type is " << typeid(*item).name();
- Qt::ButtonState buttonState = m_buttonState;
- m_buttonState = Qt::NoButton;
+ Qt::MouseButtons buttonState = m_mouseButton;
+ m_mouseButton = Qt::NoButton;
if (m_selectionMode == NoSelection)
return;
@@ -1812,7 +1818,7 @@
}
}
-void Register::scrollPage(int key, Qt::ButtonState state)
+void Register::scrollPage(int key)
{
RegisterItem* oldFocusItem = m_focusItem;
@@ -1884,13 +1890,13 @@
}
}
- if (!(state & Qt::ShiftModifier) || !m_selectAnchor)
+ if (!(m_mouseButton & Qt::ShiftModifier) || !m_selectAnchor)
m_selectAnchor = item;
setFocusItem(item);
if (item->isSelectable()) {
- handleItemChange(oldFocusItem, state & Qt::ShiftModifier, state & Qt::ControlModifier);
+ handleItemChange(oldFocusItem, m_mouseButton & Qt::ShiftModifier, m_mouseButton & Qt::ControlModifier);
}
if (m_focusItem && !m_focusItem->isSelected() && m_selectionMode == SingleSelection)
@@ -1904,9 +1910,9 @@
case Qt::Key_Space:
if (m_selectionMode != NoSelection) {
// get the state out of the event ...
- m_buttonState = ev->state();
+ //m_mouseButton = ev->buttons();
// ... and pretend that we have pressed the left mouse button ;)
- m_buttonState = static_cast<Qt::ButtonState>(m_buttonState | Qt::LeftButton);
+ m_mouseButton = static_cast<Qt::MouseButtons>(m_mouseButton | Qt::LeftButton);
selectItem(m_focusItem);
}
break;
@@ -1917,7 +1923,7 @@
case Qt::Key_End:
case Qt::Key_Down:
case Qt::Key_Up:
- scrollPage(ev->key(), ev->state());
+ scrollPage(ev->key());
break;
default:
More information about the KMyMoney-devel
mailing list