summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.h1
-rw-r--r--src/gui/itemviews/qheaderview.cpp3
-rw-r--r--src/gui/itemviews/qitemselectionmodel.cpp22
-rw-r--r--src/gui/itemviews/qlistview.cpp4
-rw-r--r--src/gui/kernel/qapplication_x11.cpp18
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm10
-rw-r--r--src/gui/kernel/qeventdispatcher_mac.mm2
-rw-r--r--src/gui/kernel/qwidget_mac.mm71
-rw-r--r--src/gui/math3d/qmatrix4x4.cpp21
-rw-r--r--src/gui/painting/qpaintdevice.cpp2
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp50
-rw-r--r--src/gui/painting/qpaintengine_x11.cpp16
-rw-r--r--src/gui/text/qtextcursor.cpp3
13 files changed, 189 insertions, 34 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h
index b5e6ed5..52b862e 100644
--- a/src/gui/graphicsview/qgraphicsitem.h
+++ b/src/gui/graphicsview/qgraphicsitem.h
@@ -516,6 +516,7 @@ class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem
Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
Q_PROPERTY(QPointF transformOriginPoint READ transformOriginPoint WRITE setTransformOriginPoint)
+ Q_INTERFACES(QGraphicsItem)
public:
QGraphicsObject(QGraphicsItem *parent = 0);
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp
index f7b5b6f..4ab81f5 100644
--- a/src/gui/itemviews/qheaderview.cpp
+++ b/src/gui/itemviews/qheaderview.cpp
@@ -1195,7 +1195,8 @@ QHeaderView::ResizeMode QHeaderView::resizeMode(int logicalIndex) const
{
Q_D(const QHeaderView);
int visual = visualIndex(logicalIndex);
- Q_ASSERT(visual != -1);
+ if (visual == -1)
+ return Fixed; //the default value
return d->headerSectionResizeMode(visual);
}
diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp
index 98810a0..8414460 100644
--- a/src/gui/itemviews/qitemselectionmodel.cpp
+++ b/src/gui/itemviews/qitemselectionmodel.cpp
@@ -573,6 +573,7 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare
int start, int end)
{
Q_Q(QItemSelectionModel);
+ finalize();
// update current index
if (currentIndex.isValid() && parent == currentIndex.parent()
@@ -591,8 +592,8 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare
}
QItemSelection deselected;
- QItemSelection::iterator it = currentSelection.begin();
- while (it != currentSelection.end()) {
+ QItemSelection::iterator it = ranges.begin();
+ while (it != ranges.end()) {
if (it->topLeft().parent() != parent) { // Check parents until reaching root or contained in range
QModelIndex itParent = it->topLeft().parent();
while (itParent.isValid() && itParent.parent() != parent)
@@ -600,24 +601,22 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare
if (parent.isValid() && start <= itParent.row() && itParent.row() <= end) {
deselected.append(*it);
- it = currentSelection.erase(it);
+ it = ranges.erase(it);
} else {
++it;
}
} else if (start <= it->bottom() && it->bottom() <= end // Full inclusion
&& start <= it->top() && it->top() <= end) {
deselected.append(*it);
- it = currentSelection.erase(it);
+ it = ranges.erase(it);
} else if (start <= it->top() && it->top() <= end) { // Top intersection
deselected.append(QItemSelectionRange(it->topLeft(), model->index(end, it->left(), it->parent())));
- it = currentSelection.insert(it, QItemSelectionRange(model->index(end + 1, it->left(), it->parent()),
- it->bottomRight()));
- it = currentSelection.erase(++it);
+ *it = QItemSelectionRange(model->index(end + 1, it->left(), it->parent()), it->bottomRight());
+ ++it;
} else if (start <= it->bottom() && it->bottom() <= end) { // Bottom intersection
deselected.append(QItemSelectionRange(model->index(start, it->right(), it->parent()), it->bottomRight()));
- it = currentSelection.insert(it, QItemSelectionRange(it->topLeft(),
- model->index(start - 1, it->right(), it->parent())));
- it = currentSelection.erase(++it);
+ *it = QItemSelectionRange(it->topLeft(), model->index(start - 1, it->right(), it->parent()));
+ ++it;
} else {
if (it->top() < start && end < it->bottom()) // Middle intersection (do nothing)
deselected.append(QItemSelectionRange(model->index(start, it->right(), it->parent()),
@@ -626,7 +625,8 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare
}
}
- emit q->selectionChanged(QItemSelection(), deselected);
+ if (!deselected.isEmpty())
+ emit q->selectionChanged(QItemSelection(), deselected);
}
/*!
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp
index ea38f5f..e9e365f 100644
--- a/src/gui/itemviews/qlistview.cpp
+++ b/src/gui/itemviews/qlistview.cpp
@@ -458,6 +458,8 @@ QSize QListView::gridSize() const
void QListView::setViewMode(ViewMode mode)
{
Q_D(QListView);
+ if (d->viewMode == mode)
+ return;
d->viewMode = mode;
if (mode == ListMode) {
@@ -1963,7 +1965,7 @@ QListViewPrivate::QListViewPrivate()
movement(QListView::Static),
resizeMode(QListView::Fixed),
layoutMode(QListView::SinglePass),
- viewMode(QListView::ListMode),
+ viewMode(QListView::IconMode), //this will ensure the first initialization to ListView
modeProperties(0),
column(0),
uniformItemSizes(false),
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index db349f0..d942519 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -1851,10 +1851,20 @@ void qt_init(QApplicationPrivate *priv, int,
QX11InfoData *screen = X11->screens + s;
screen->ref = 1; // ensures it doesn't get deleted
screen->screen = s;
- screen->dpiX = (DisplayWidth(X11->display, s) * 254 + DisplayWidthMM(X11->display, s)*5)
- / (DisplayWidthMM(X11->display, s)*10);
- screen->dpiY = (DisplayHeight(X11->display, s) * 254 + DisplayHeightMM(X11->display, s)*5)
- / (DisplayHeightMM(X11->display, s)*10);
+
+ int widthMM = DisplayWidthMM(X11->display, s);
+ if (widthMM != 0) {
+ screen->dpiX = (DisplayWidth(X11->display, s) * 254 + widthMM * 5) / (widthMM * 10);
+ } else {
+ screen->dpiX = 72;
+ }
+
+ int heightMM = DisplayHeightMM(X11->display, s);
+ if (heightMM != 0) {
+ screen->dpiY = (DisplayHeight(X11->display, s) * 254 + heightMM * 5) / (heightMM * 10);
+ } else {
+ screen->dpiY = 72;
+ }
X11->argbVisuals[s] = 0;
X11->argbColormaps[s] = 0;
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 45b0ada..7ac0d89 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -872,7 +872,7 @@ extern "C" {
NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
qNGEvent.position = flipPoint(p).toPoint();
qNGEvent.percentage = [event magnification];
- qApp->sendEvent(qwidget, &qNGEvent);
+ qt_sendSpontaneousEvent(qwidget, &qNGEvent);
}
- (void)rotateWithEvent:(NSEvent *)event;
@@ -885,7 +885,7 @@ extern "C" {
NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
qNGEvent.position = flipPoint(p).toPoint();
qNGEvent.percentage = [event rotation];
- qApp->sendEvent(qwidget, &qNGEvent);
+ qt_sendSpontaneousEvent(qwidget, &qNGEvent);
}
- (void)swipeWithEvent:(NSEvent *)event;
@@ -898,7 +898,7 @@ extern "C" {
NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
qNGEvent.position = flipPoint(p).toPoint();
qNGEvent.direction = QSize(-[event deltaX], -[event deltaY]);
- qApp->sendEvent(qwidget, &qNGEvent);
+ qt_sendSpontaneousEvent(qwidget, &qNGEvent);
}
- (void)beginGestureWithEvent:(NSEvent *)event;
@@ -910,7 +910,7 @@ extern "C" {
qNGEvent.gestureType = QNativeGestureEvent::GestureBegin;
NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
qNGEvent.position = flipPoint(p).toPoint();
- qApp->sendEvent(qwidget, &qNGEvent);
+ qt_sendSpontaneousEvent(qwidget, &qNGEvent);
}
- (void)endGestureWithEvent:(NSEvent *)event;
@@ -922,7 +922,7 @@ extern "C" {
qNGEvent.gestureType = QNativeGestureEvent::GestureEnd;
NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
qNGEvent.position = flipPoint(p).toPoint();
- qApp->sendEvent(qwidget, &qNGEvent);
+ qt_sendSpontaneousEvent(qwidget, &qNGEvent);
}
#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm
index efe6375..113362a 100644
--- a/src/gui/kernel/qeventdispatcher_mac.mm
+++ b/src/gui/kernel/qeventdispatcher_mac.mm
@@ -500,7 +500,7 @@ static bool IsMouseOrKeyEvent( NSEvent* event )
static inline void qt_mac_waitForMoreEvents()
{
#ifndef QT_MAC_USE_COCOA
- while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1.0e20, true) == kCFRunLoopRunTimedOut);
+ while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1.0e20, true) == kCFRunLoopRunTimedOut) ;
#else
// If no event exist in the cocoa event que, wait
// (and free up cpu time) until at least one event occur.
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 5bf140c..999faeb 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -107,6 +107,7 @@
#include <private/qcocoapanel_mac_p.h>
#include "qwidget_p.h"
+#include "qevent_p.h"
#include "qdnd_p.h"
#include <QtGui/qgraphicsproxywidget.h>
@@ -729,6 +730,13 @@ static EventTypeSpec window_events[] = {
{ kEventClassWindow, kEventWindowGetRegion },
{ kEventClassWindow, kEventWindowGetClickModality },
{ kEventClassWindow, kEventWindowTransitionCompleted },
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+ { kEventClassGesture, kEventGestureStarted },
+ { kEventClassGesture, kEventGestureEnded },
+ { kEventClassGesture, kEventGestureMagnify },
+ { kEventClassGesture, kEventGestureSwipe },
+ { kEventClassGesture, kEventGestureRotate },
+#endif
{ kEventClassMouse, kEventMouseDown }
};
static EventHandlerUPP mac_win_eventUPP = 0;
@@ -1013,6 +1021,69 @@ OSStatus QWidgetPrivate::qt_window_event(EventHandlerCallRef er, EventRef event,
return SendEventToApplication(event);
handled_event = false;
break; }
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+ case kEventClassGesture: {
+ // First, find the widget that was under
+ // the mouse when the gesture happened:
+ HIPoint screenLocation;
+ if (GetEventParameter(event, kEventParamMouseLocation, typeHIPoint, 0,
+ sizeof(screenLocation), 0, &screenLocation) != noErr) {
+ handled_event = false;
+ break;
+ }
+ QWidget *widget = QApplication::widgetAt(screenLocation.x, screenLocation.y);
+ if (!widget) {
+ handled_event = false;
+ break;
+ }
+
+ QNativeGestureEvent qNGEvent;
+ qNGEvent.position = QPoint(screenLocation.x, screenLocation.y);
+
+ switch (ekind) {
+ case kEventGestureStarted:
+ qNGEvent.gestureType = QNativeGestureEvent::GestureBegin;
+ break;
+ case kEventGestureEnded:
+ qNGEvent.gestureType = QNativeGestureEvent::GestureEnd;
+ break;
+ case kEventGestureRotate: {
+ CGFloat amount;
+ if (GetEventParameter(event, kEventParamRotationAmount, typeCGFloat, 0,
+ sizeof(amount), 0, &amount) != noErr) {
+ handled_event = false;
+ break;
+ }
+ qNGEvent.gestureType = QNativeGestureEvent::Zoom;
+ qNGEvent.percentage = float(amount);
+ break; }
+ case kEventGestureSwipe: {
+ HIPoint swipeDirection;
+ if (GetEventParameter(event, kEventParamSwipeDirection, typeHIPoint, 0,
+ sizeof(swipeDirection), 0, &swipeDirection) != noErr) {
+ handled_event = false;
+ break;
+ }
+ qNGEvent.gestureType = QNativeGestureEvent::Swipe;
+ qNGEvent.direction = QSize(-swipeDirection.x, -swipeDirection.y);
+ break; }
+ case kEventGestureMagnify: {
+ CGFloat amount;
+ if (GetEventParameter(event, kEventParamMagnificationAmount, typeCGFloat, 0,
+ sizeof(amount), 0, &amount) != noErr) {
+ handled_event = false;
+ break;
+ }
+ qNGEvent.gestureType = QNativeGestureEvent::Zoom;
+ qNGEvent.percentage = float(amount);
+ break; }
+ }
+
+ QApplication::sendSpontaneousEvent(widget, &qNGEvent);
+ break; }
+#endif // gestures
+
default:
handled_event = false;
}
diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp
index dc17eda..8fc439b 100644
--- a/src/gui/math3d/qmatrix4x4.cpp
+++ b/src/gui/math3d/qmatrix4x4.cpp
@@ -1010,11 +1010,24 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, const QVector3D& vector)
*/
QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z)
{
+ if (angle == 0.0f)
+ return *this;
QMatrix4x4 m(1); // The "1" says to not load the identity.
- qreal a = angle * M_PI / 180.0f;
- qreal c = qCos(a);
- qreal s = qSin(a);
- qreal ic;
+ qreal c, s, ic;
+ if (angle == 90.0f || angle == -270.0f) {
+ s = 1.0f;
+ c = 0.0f;
+ } else if (angle == -90.0f || angle == 270.0f) {
+ s = -1.0f;
+ c = 0.0f;
+ } else if (angle == 180.0f || angle == -180.0f) {
+ s = 0.0f;
+ c = -1.0f;
+ } else {
+ qreal a = angle * M_PI / 180.0f;
+ c = qCos(a);
+ s = qSin(a);
+ }
bool quick = false;
if (x == 0.0f) {
if (y == 0.0f) {
diff --git a/src/gui/painting/qpaintdevice.cpp b/src/gui/painting/qpaintdevice.cpp
index 6477952..6a2a4c4 100644
--- a/src/gui/painting/qpaintdevice.cpp
+++ b/src/gui/painting/qpaintdevice.cpp
@@ -64,3 +64,5 @@ int QPaintDevice::metric(PaintDeviceMetric) const
qWarning("QPaintDevice::metrics: Device has no metric information");
return 0;
}
+
+QT_END_NAMESPACE
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 8b83f02..63c4e32 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -2544,12 +2544,44 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
Q_D(QRasterPaintEngine);
QRasterPaintEngineState *s = state();
const bool aa = s->flags.antialiased || s->flags.bilinear;
- if (!aa && sr.size() == QSize(1, 1)) {
+ int sr_l = qFloor(sr.left());
+ int sr_r = qCeil(sr.right()) - 1;
+ int sr_t = qFloor(sr.top());
+ int sr_b = qCeil(sr.bottom()) - 1;
+
+ if (!aa && sr_l == sr_r && sr_t == sr_b) {
// as fillRect will apply the aliased coordinate delta we need to
// subtract it here as we don't use it for image drawing
QTransform old = s->matrix;
s->matrix = s->matrix * QTransform::fromTranslate(-aliasedCoordinateDelta, -aliasedCoordinateDelta);
- fillRect(r, QColor::fromRgba(img.pixel(sr.x(), sr.y())));
+
+ // Do whatever fillRect() does, but without premultiplying the color if it's already premultiplied.
+ QRgb color = img.pixel(sr_l, sr_t);
+ switch (img.format()) {
+ case QImage::Format_ARGB32_Premultiplied:
+ case QImage::Format_ARGB8565_Premultiplied:
+ case QImage::Format_ARGB6666_Premultiplied:
+ case QImage::Format_ARGB8555_Premultiplied:
+ case QImage::Format_ARGB4444_Premultiplied:
+ // Combine premultiplied color with the opacity set on the painter.
+ d->solid_color_filler.solid.color =
+ ((((color & 0x00ff00ff) * s->intOpacity) >> 8) & 0x00ff00ff)
+ | ((((color & 0xff00ff00) >> 8) * s->intOpacity) & 0xff00ff00);
+ break;
+ default:
+ d->solid_color_filler.solid.color = PREMUL(ARGB_COMBINE_ALPHA(color, s->intOpacity));
+ break;
+ }
+
+ if ((d->solid_color_filler.solid.color & 0xff000000) == 0
+ && s->composition_mode == QPainter::CompositionMode_SourceOver) {
+ return;
+ }
+
+ d->solid_color_filler.clip = d->clip();
+ d->solid_color_filler.adjustSpanMethods();
+ fillRect(r, &d->solid_color_filler);
+
s->matrix = old;
return;
}
@@ -5198,6 +5230,13 @@ static void drawLine_midpoint_i(int x1, int y1, int x2, int y2, ProcessSpans spa
dy = -dy;
}
+ int x_lower_limit = - 128;
+ if (x1 < x_lower_limit) {
+ int cy = dy * (x_lower_limit - x1) / dx + y1;
+ drawLine_midpoint_i(x_lower_limit, cy, x2, y2, span_func, data, style, devRect);
+ return;
+ }
+
if (style == LineDrawNormal)
--x2;
@@ -5335,6 +5374,13 @@ static void drawLine_midpoint_i(int x1, int y1, int x2, int y2, ProcessSpans spa
dx = -dx;
}
+ int y_lower_limit = - 128;
+ if (y1 < y_lower_limit) {
+ int cx = dx * (y_lower_limit - y1) / dy + x1;
+ drawLine_midpoint_i(cx, y_lower_limit, x2, y2, span_func, data, style, devRect);
+ return;
+ }
+
if (style == LineDrawNormal)
--y2;
diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp
index 6816aac..a4d34b5 100644
--- a/src/gui/painting/qpaintengine_x11.cpp
+++ b/src/gui/painting/qpaintengine_x11.cpp
@@ -2459,15 +2459,23 @@ void QX11PaintEngine::drawFreetype(const QPointF &p, const QTextItemInt &ti)
XRectangle rects[rectcount];
int num_rects = 0;
+ QPoint delta(qRound(d->matrix.dx()), qRound(d->matrix.dy()));
+ QRect clip(d->polygonClipper.boundingRect());
for (int i=0; i < path.elementCount(); i+=5) {
int x = qRound(path.elementAt(i).x);
int y = qRound(path.elementAt(i).y);
int w = qRound(path.elementAt(i+1).x) - x;
int h = qRound(path.elementAt(i+2).y) - y;
- rects[num_rects].x = x + qRound(d->matrix.dx());
- rects[num_rects].y = y + qRound(d->matrix.dy());
- rects[num_rects].width = w;
- rects[num_rects].height = h;
+
+ QRect rect = QRect(x + delta.x(), y + delta.y(), w, h);
+ rect = rect.intersected(clip);
+ if (rect.isEmpty())
+ continue;
+
+ rects[num_rects].x = short(rect.x());
+ rects[num_rects].y = short(rect.y());
+ rects[num_rects].width = ushort(rect.width());
+ rects[num_rects].height = ushort(rect.height());
++num_rects;
if (num_rects == rectcount) {
XFillRectangles(d->dpy, d->hd, d->gc, rects, num_rects);
diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp
index 88ab9d0..5a938e3 100644
--- a/src/gui/text/qtextcursor.cpp
+++ b/src/gui/text/qtextcursor.cpp
@@ -84,7 +84,8 @@ QTextCursorPrivate::QTextCursorPrivate(const QTextCursorPrivate &rhs)
QTextCursorPrivate::~QTextCursorPrivate()
{
- priv->removeCursor(this);
+ if (priv)
+ priv->removeCursor(this);
}
QTextCursorPrivate::AdjustResult QTextCursorPrivate::adjustPosition(int positionOfChange, int charsAddedOrRemoved, QTextUndoCommand::Operation op)