Merge "Merge remote-tracking branch 'origin/5.3' into 5.4" into refs/staging/5.4

bb10
Gabriel de Dietrich 2014-10-18 13:24:33 +02:00 committed by The Qt Project
commit 59ebcdc540
7 changed files with 210 additions and 21 deletions

View File

@ -66,7 +66,8 @@ class QFileSystemMetaData
{
public:
QFileSystemMetaData()
: knownFlagsMask(0)
: knownFlagsMask(0),
size_(-1)
{
}

View File

@ -442,7 +442,7 @@ QNetworkConfiguration::BearerType QConnmanEngine::ofonoTechToBearerType(const QS
} else if (currentTechnology == QLatin1String("hspa")) {
return QNetworkConfiguration::BearerHSPA;
} else if (currentTechnology == QLatin1String("lte")) {
return QNetworkConfiguration::BearerWiMAX; //not exact
return QNetworkConfiguration::BearerLTE;
}
}
return QNetworkConfiguration::BearerUnknown;

View File

@ -861,6 +861,10 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
xkb_mod_index_t altMod = xkb_keymap_mod_get_index(xkb_keymap, "Alt");
xkb_mod_index_t controlMod = xkb_keymap_mod_get_index(xkb_keymap, "Control");
Q_ASSERT(shiftMod < 32);
Q_ASSERT(altMod < 32);
Q_ASSERT(controlMod < 32);
xkb_mod_mask_t depressed;
struct xkb_keymap *fallback_keymap = 0;
int qtKey = 0;

View File

@ -2404,12 +2404,11 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event)
}
break;
#endif
case Qt::Key_A:
if (event->modifiers() & Qt::ControlModifier) {
default: {
if (event == QKeySequence::SelectAll && selectionMode() != NoSelection) {
selectAll();
break;
}
default: {
#ifdef Q_WS_MAC
if (event->key() == Qt::Key_O && event->modifiers() & Qt::ControlModifier && currentIndex().isValid()) {
emit activated(currentIndex());

View File

@ -1113,9 +1113,9 @@ static QAquaWidgetSize qt_aqua_guess_size(const QWidget *widg, QSize large, QSiz
static void qt_drawFocusRingOnPath(CGContextRef cg, NSBezierPath *focusRingPath)
{
CGContextSaveGState(cg);
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:[NSGraphicsContext
graphicsContextWithGraphicsPort:(CGContextRef)cg flipped:NO]];
[NSGraphicsContext saveGraphicsState];
NSSetFocusRingStyle(NSFocusRingOnly);
[focusRingPath setClip]; // Clear clip path to avoid artifacts when rendering the cursor at zero pos
[focusRingPath fill];
@ -1835,7 +1835,8 @@ NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget, QPoint *offset) cons
NSView *bv = cocoaControls[widget];
if (!bv) {
if (widget.first == QCocoaPopupButton)
if (widget.first == QCocoaPopupButton
|| widget.first == QCocoaPullDownButton)
bv = [[NSPopUpButton alloc] init];
else if (widget.first == QCocoaComboBox)
bv = [[NSComboBox alloc] init];
@ -1871,6 +1872,11 @@ NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget, QPoint *offset) cons
bc.bezelStyle = NSRoundedBezelStyle;
break;
}
case QCocoaPullDownButton: {
NSPopUpButton *bc = (NSPopUpButton *)bv;
bc.pullsDown = YES;
break;
}
default:
break;
}
@ -1913,6 +1919,12 @@ NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget, QPoint *offset) cons
*offset = QPoint(7, 5);
else if (widget == QCocoaWidget(QCocoaPopupButton, QAquaSizeMini))
*offset = QPoint(2, -1);
else if (widget == QCocoaWidget(QCocoaPullDownButton, QAquaSizeLarge))
*offset = QPoint(3, -1);
else if (widget == QCocoaWidget(QCocoaPullDownButton, QAquaSizeSmall))
*offset = QPoint(2, 1);
else if (widget == QCocoaWidget(QCocoaPullDownButton, QAquaSizeMini))
*offset = QPoint(5, 0);
}
return bv;
@ -3848,21 +3860,24 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
else if (d->pressedButton == opt->styleObject)
d->pressedButton = 0;
bool hasMenu = btn->features & QStyleOptionButton::HasMenu;
HIThemeButtonDrawInfo bdi;
d->initHIThemePushButton(btn, w, tds, &bdi);
if (yosemiteOrLater) {
// HITheme is not drawing a nice focus frame around buttons.
// We'll do it ourselves further down.
bdi.adornment &= ~kThemeAdornmentFocus;
if (!hasMenu) {
// HITheme is not drawing a nice focus frame around buttons.
// We'll do it ourselves further down.
bdi.adornment &= ~kThemeAdornmentFocus;
// We can't rely on an animation existing to test for the default look. That means a bit
// more logic (notice that the logic is slightly different for the bevel and the label).
if (tds == kThemeStateActive
&& (btn->features & QStyleOptionButton::DefaultButton
|| (btn->features & QStyleOptionButton::AutoDefaultButton
&& d->autoDefaultButton == btn->styleObject)))
bdi.adornment |= kThemeAdornmentDefault;
// We can't rely on an animation existing to test for the default look. That means a bit
// more logic (notice that the logic is slightly different for the bevel and the label).
if (tds == kThemeStateActive
&& (btn->features & QStyleOptionButton::DefaultButton
|| (btn->features & QStyleOptionButton::AutoDefaultButton
&& d->autoDefaultButton == btn->styleObject)))
bdi.adornment |= kThemeAdornmentDefault;
}
} else {
// the default button animation is paused meanwhile any button
// is pressed or an auto-default button is animated instead
@ -3902,8 +3917,18 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
newRect.size.width -= QMacStylePrivate::PushButtonRightOffset - 4;
}
bool hasMenu = btn->features & QStyleOptionButton::HasMenu;
if (hasMenu && bdi.state == kThemeStatePressed && QSysInfo::macVersion() > QSysInfo::MV_10_6)
if (hasMenu && yosemiteOrLater && bdi.kind != kThemeBevelButton) {
QCocoaWidget w = cocoaWidgetFromHIThemeButtonKind(bdi.kind);
QPoint offset;
NSPopUpButton *pdb = (NSPopUpButton *)d->cocoaControl(QCocoaWidget(QCocoaPullDownButton, w.second), &offset);
[pdb highlight:(bdi.state == kThemeStatePressed)];
pdb.enabled = bdi.state != kThemeStateUnavailable && bdi.state != kThemeStateUnavailableInactive;
QRect rect = opt->rect;
rect.adjust(0, 0, w.second == QAquaSizeSmall ? -4 : w.second == QAquaSizeMini ? -9 : -6, 0);
p->translate(offset);
d->drawNSViewInRect(pdb, rect, p);
p->translate(-offset);
} else if (hasMenu && bdi.state == kThemeStatePressed && QSysInfo::macVersion() > QSysInfo::MV_10_6)
d->drawColorlessButton(newRect, &bdi, p, opt);
else
HIThemeDrawButton(&newRect, &bdi, cg, kHIThemeOrientationNormal, 0);
@ -3939,7 +3964,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
qt_drawFocusRingOnPath(cg, pushButtonFocusRingPath);
}
if (hasMenu) {
if (hasMenu && (!yosemiteOrLater || bdi.kind == kThemeBevelButton)) {
int mbi = proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator, btn, w);
QRect ir = btn->rect;
int arrowXOffset = 0;
@ -3993,7 +4018,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
bool hasIcon = !btn.icon.isNull();
bool hasText = !btn.text.isEmpty();
if (QSysInfo::QSysInfo::MacintoshVersion > QSysInfo::MV_10_9) {
if (!hasMenu && QSysInfo::QSysInfo::MacintoshVersion > QSysInfo::MV_10_9) {
if (tds == kThemeStatePressed
|| (tds == kThemeStateActive
&& ((btn.features & QStyleOptionButton::DefaultButton && !d->autoDefaultButton)

View File

@ -126,6 +126,7 @@ enum QCocoaWidgetKind {
QCocoaCheckBox,
QCocoaComboBox, // Editable QComboBox
QCocoaPopupButton, // Non-editable QComboBox
QCocoaPullDownButton, // QPushButton with menu
QCocoaPushButton,
QCocoaRadioButton,
QCocoaHorizontalSlider,

View File

@ -117,6 +117,9 @@ private slots:
void selectColumn_data();
void selectColumn();
void selectall_data();
void selectall();
void visualRect_data();
void visualRect();
@ -1884,6 +1887,162 @@ void tst_QTableView::selectColumn()
QCOMPARE(view.selectionModel()->selectedIndexes().at(i).column(), column);
}
void tst_QTableView::selectall_data()
{
QTest::addColumn<int>("rowCount");
QTest::addColumn<int>("columnCount");
QTest::addColumn<int>("row");
QTest::addColumn<int>("column");
QTest::addColumn<int>("rowSpan");
QTest::addColumn<int>("columnSpan");
QTest::addColumn<int>("hideRow");
QTest::addColumn<int>("hideColumn");
QTest::addColumn<int>("moveRowFrom");
QTest::addColumn<int>("moveRowTo");
QTest::addColumn<int>("moveColumnFrom");
QTest::addColumn<int>("moveColumnTo");
QTest::addColumn<int>("rowHeight");
QTest::addColumn<int>("columnWidth");
QTest::addColumn<int>("selectedCount"); // ### make this more detailed
QTest::newRow("no span, no hidden, no moved")
<< 10 << 10 // dim
<< -1 << -1 // pos
<< 1 << 1 // span
<< -1 << -1 // hide
<< -1 << -1 // move row
<< -1 << -1 // move col
<< 40 << 40 // cell size
<< 100; // selected count
QTest::newRow("row span, no hidden, no moved")
<< 10 << 10 // dim
<< 1 << 1 // pos
<< 2 << 1 // span
<< -1 << -1 // hide
<< -1 << -1 // move row
<< -1 << -1 // move col
<< 40 << 40 // cell size
<< 99; // selected count
QTest::newRow("col span, no hidden, no moved")
<< 10 << 10 // dim
<< 1 << 1 // pos
<< 1 << 2 // span
<< -1 << -1 // hide
<< -1 << -1 // move row
<< -1 << -1 // move col
<< 40 << 40 // cell size
<< 99; // selected count
QTest::newRow("no span, row hidden, no moved")
<< 10 << 10 // dim
<< -1 << -1 // pos
<< 1 << 1 // span
<< 1 << -1 // hide
<< -1 << -1 // move row
<< -1 << -1 // move col
<< 40 << 40 // cell size
<< 90; // selected count
QTest::newRow("no span, col hidden, no moved")
<< 10 << 10 // dim
<< -1 << -1 // pos
<< 1 << 1 // span
<< -1 << 1 // hide
<< -1 << -1 // move row
<< -1 << -1 // move col
<< 40 << 40 // cell size
<< 90; // selected count
QTest::newRow("no span, no hidden, row moved")
<< 10 << 10 // dim
<< -1 << -1 // pos
<< 1 << 1 // span
<< -1 << -1 // hide
<< 1 << 3 // move row
<< -1 << -1 // move col
<< 40 << 40 // cell size
<< 100; // selected count
QTest::newRow("no span, no hidden, col moved")
<< 10 << 10 // dim
<< -1 << -1 // pos
<< 1 << 1 // span
<< -1 << -1 // hide
<< -1 << -1 // move row
<< 1 << 3 // move col
<< 40 << 40 // cell size
<< 100; // selected count
}
void QTest__keySequence(QWidget* widget, QKeySequence ks)
{
for (int i=0; i<ks.count(); ++i)
{
Qt::Key key = Qt::Key(ks[i] & ~Qt::KeyboardModifierMask);
Qt::KeyboardModifiers modifiers = Qt::KeyboardModifiers(ks[i] & Qt::KeyboardModifierMask);
QTest::keyClick(widget, key, modifiers);
}
}
void tst_QTableView::selectall()
{
QFETCH(int, rowCount);
QFETCH(int, columnCount);
QFETCH(int, row);
QFETCH(int, column);
QFETCH(int, rowSpan);
QFETCH(int, columnSpan);
QFETCH(int, hideRow);
QFETCH(int, hideColumn);
QFETCH(int, moveRowFrom);
QFETCH(int, moveRowTo);
QFETCH(int, moveColumnFrom);
QFETCH(int, moveColumnTo);
QFETCH(int, rowHeight);
QFETCH(int, columnWidth);
QFETCH(int, selectedCount);
QtTestTableModel model(rowCount, columnCount);
QtTestTableView view;
view.show();
view.setModel(&model);
view.setSpan(row, column, rowSpan, columnSpan);
view.hideRow(hideRow);
view.hideColumn(hideColumn);
view.verticalHeader()->moveSection(moveRowFrom, moveRowTo);
view.horizontalHeader()->moveSection(moveColumnFrom, moveColumnTo);
for (int r = 0; r < rowCount; ++r)
view.setRowHeight(r, rowHeight);
for (int c = 0; c < columnCount; ++c)
view.setColumnWidth(c, columnWidth);
// try slot first
view.clearSelection();
QCOMPARE(view.selectedIndexes().count(), 0);
view.selectAll();
QCOMPARE(view.selectedIndexes().count(), selectedCount);
// try by key sequence
view.clearSelection();
QCOMPARE(view.selectedIndexes().count(), 0);
QTest__keySequence(&view, QKeySequence(QKeySequence::SelectAll));
QCOMPARE(view.selectedIndexes().count(), selectedCount);
// check again with no selection mode
view.clearSelection();
view.setSelectionMode(QAbstractItemView::NoSelection);
QCOMPARE(view.selectedIndexes().count(), 0);
QTest__keySequence(&view, QKeySequence(QKeySequence::SelectAll));
QCOMPARE(view.selectedIndexes().count(), 0);
}
void tst_QTableView::visualRect_data()
{
QTest::addColumn<int>("rowCount");