summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/kernel/qabstractitemmodel.cpp8
-rw-r--r--src/gui/util/qcompleter.cpp18
-rw-r--r--src/gui/util/qcompleter_p.h1
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystem.cpp18
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystem.h4
-rw-r--r--src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp46
-rw-r--r--tests/auto/modeltest/dynamictreemodel.cpp7
-rw-r--r--tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp6
-rw-r--r--tests/auto/qcompleter/tst_qcompleter.cpp156
-rw-r--r--tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp6
-rw-r--r--tools/qmeegographicssystemhelper/qmeegoruntime.cpp6
-rw-r--r--tools/qmeegographicssystemhelper/qmeegoruntime.h2
12 files changed, 242 insertions, 36 deletions
diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp
index 4fc9792..16c339d 100644
--- a/src/corelib/kernel/qabstractitemmodel.cpp
+++ b/src/corelib/kernel/qabstractitemmodel.cpp
@@ -2637,8 +2637,6 @@ void QAbstractItemModel::endMoveRows()
QAbstractItemModelPrivate::Change insertChange = d->changes.pop();
QAbstractItemModelPrivate::Change removeChange = d->changes.pop();
- d->itemsMoved(removeChange.parent, removeChange.first, removeChange.last, insertChange.parent, insertChange.first, Qt::Vertical);
-
QModelIndex adjustedSource = removeChange.parent;
QModelIndex adjustedDestination = insertChange.parent;
@@ -2649,6 +2647,8 @@ void QAbstractItemModel::endMoveRows()
if (removeChange.needsAdjust)
adjustedSource = createIndex(adjustedSource.row() + numMoved, adjustedSource.column(), adjustedSource.internalPointer());
+ d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Vertical);
+
emit rowsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first);
emit layoutChanged();
}
@@ -2861,8 +2861,6 @@ void QAbstractItemModel::endMoveColumns()
QAbstractItemModelPrivate::Change insertChange = d->changes.pop();
QAbstractItemModelPrivate::Change removeChange = d->changes.pop();
- d->itemsMoved(removeChange.parent, removeChange.first, removeChange.last, insertChange.parent, insertChange.first, Qt::Horizontal);
-
QModelIndex adjustedSource = removeChange.parent;
QModelIndex adjustedDestination = insertChange.parent;
@@ -2873,6 +2871,8 @@ void QAbstractItemModel::endMoveColumns()
if (removeChange.needsAdjust)
adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+
emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first);
emit layoutChanged();
}
diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp
index fdd0fc5..71a0171 100644
--- a/src/gui/util/qcompleter.cpp
+++ b/src/gui/util/qcompleter.cpp
@@ -782,7 +782,8 @@ QMatchData QUnsortedModelEngine::filter(const QString& part, const QModelIndex&
///////////////////////////////////////////////////////////////////////////////
QCompleterPrivate::QCompleterPrivate()
: widget(0), proxy(0), popup(0), cs(Qt::CaseSensitive), role(Qt::EditRole), column(0),
- maxVisibleItems(7), sorting(QCompleter::UnsortedModel), wrap(true), eatFocusOut(true)
+ maxVisibleItems(7), sorting(QCompleter::UnsortedModel), wrap(true), eatFocusOut(true),
+ hiddenBecauseNoMatch(false)
{
}
@@ -921,12 +922,14 @@ void QCompleterPrivate::showPopup(const QRect& rect)
void QCompleterPrivate::_q_fileSystemModelDirectoryLoaded(const QString &path)
{
Q_Q(QCompleter);
-#ifndef QT_NO_LINEEDIT
- QLineEdit *lineEdit = qobject_cast<QLineEdit *>(widget);
- //the path given by QFileSystemModel does not end with /
- if (lineEdit && !lineEdit->text().isEmpty() && !q->completionPrefix().isEmpty() && q->completionPrefix() != path + QLatin1Char('/'))
+ // Slot called when QFileSystemModel has finished loading.
+ // If we hide the popup because there was no match because the model was not loaded yet,
+ // we re-start the completion when we get the results
+ if (hiddenBecauseNoMatch
+ && prefix.startsWith(path) && prefix != (path + '/')
+ && widget) {
q->complete();
-#endif
+ }
}
/*!
@@ -1200,6 +1203,7 @@ bool QCompleter::eventFilter(QObject *o, QEvent *e)
Q_D(QCompleter);
if (d->eatFocusOut && o == d->widget && e->type() == QEvent::FocusOut) {
+ d->hiddenBecauseNoMatch = false;
if (d->popup && d->popup->isVisible())
return true;
}
@@ -1378,6 +1382,7 @@ void QCompleter::complete(const QRect& rect)
{
Q_D(QCompleter);
QModelIndex idx = d->proxy->currentIndex(false);
+ d->hiddenBecauseNoMatch = false;
if (d->mode == QCompleter::InlineCompletion) {
if (idx.isValid())
d->_q_complete(idx, true);
@@ -1389,6 +1394,7 @@ void QCompleter::complete(const QRect& rect)
|| (d->mode == QCompleter::UnfilteredPopupCompletion && d->proxy->rowCount() == 0)) {
if (d->popup)
d->popup->hide(); // no suggestion, hide
+ d->hiddenBecauseNoMatch = true;
return;
}
diff --git a/src/gui/util/qcompleter_p.h b/src/gui/util/qcompleter_p.h
index 8f00793..19b76e5 100644
--- a/src/gui/util/qcompleter_p.h
+++ b/src/gui/util/qcompleter_p.h
@@ -93,6 +93,7 @@ public:
bool eatFocusOut;
QRect popupRect;
+ bool hiddenBecauseNoMatch;
void showPopup(const QRect&);
void _q_complete(QModelIndex, bool = false);
diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp
index f8b228c..27e728a 100644
--- a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp
+++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp
@@ -275,7 +275,7 @@ bool QMeeGoGraphicsSystem::unlockLiveTexture(Qt::HANDLE h)
}
}
-void QMeeGoGraphicsSystem::queryLiveTexture(Qt::HANDLE h, void **data, int *pitch)
+void QMeeGoGraphicsSystem::queryLiveTexture(Qt::HANDLE h, void **data, int *pitch, QImage::Format *f)
{
// FIXME Only allow this on locked surfaces
if (! liveTexturePixmaps.contains(h)) {
@@ -289,6 +289,14 @@ void QMeeGoGraphicsSystem::queryLiveTexture(Qt::HANDLE h, void **data, int *pitc
EGLSurface surface = getSurfaceForLiveTexturePixmap(liveTexturePixmaps.value(h));
eglQuerySurface(QEgl::display(), surface, EGL_BITMAP_POINTER_KHR, (EGLint*) data);
eglQuerySurface(QEgl::display(), surface, EGL_BITMAP_PITCH_KHR, (EGLint*) pitch);
+
+ // Ok, here we know we just support those two formats. Real solution would be:
+ // in liveTexturePixmaps store a small structure containing the pixmap and the
+ // original Qt format.
+ if (liveTexturePixmaps.value(h)->depth() > 16)
+ *f = QImage::Format_ARGB32_Premultiplied;
+ else
+ *f = QImage::Format_RGB16;
}
Qt::HANDLE QMeeGoGraphicsSystem::liveTextureToEGLImage(Qt::HANDLE h)
@@ -363,7 +371,9 @@ EGLSurface QMeeGoGraphicsSystem::getSurfaceForLiveTexturePixmap(QPixmap *pixmap)
pixmapData->gl_surface = (void*)QEgl::createSurface(pixmap, config);
if (hasAlpha)
- pixmapData->flags = pixmapData->flags | QX11PixmapData::GlSurfaceCreatedWithAlpha;
+ pixmapData->flags |= QX11PixmapData::GlSurfaceCreatedWithAlpha;
+ else
+ pixmapData->flags &= ~QX11PixmapData::GlSurfaceCreatedWithAlpha;
if (pixmapData->gl_surface == (void*)EGL_NO_SURFACE)
return NULL;
@@ -439,9 +449,9 @@ bool qt_meego_live_texture_unlock(Qt::HANDLE h)
return QMeeGoGraphicsSystem::unlockLiveTexture(h);
}
-void qt_meego_live_texture_query(Qt::HANDLE h, void **data, int *pitch)
+void qt_meego_live_texture_query(Qt::HANDLE h, void **data, int *pitch, QImage::Format *f)
{
- return QMeeGoGraphicsSystem::queryLiveTexture(h, data, pitch);
+ return QMeeGoGraphicsSystem::queryLiveTexture(h, data, pitch, f);
}
Qt::HANDLE qt_meego_live_texture_to_egl_image(Qt::HANDLE h)
diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.h b/src/plugins/graphicssystems/meego/qmeegographicssystem.h
index 934d32d..fad0db6 100644
--- a/src/plugins/graphicssystems/meego/qmeegographicssystem.h
+++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.h
@@ -71,7 +71,7 @@ public:
static void destroyLiveTexture(Qt::HANDLE h);
static bool lockLiveTexture(Qt::HANDLE h);
static bool unlockLiveTexture(Qt::HANDLE h);
- static void queryLiveTexture(Qt::HANDLE h, void **data, int *pitch);
+ static void queryLiveTexture(Qt::HANDLE h, void **data, int *pitch, QImage::Format *format);
static Qt::HANDLE liveTextureToEGLImage(Qt::HANDLE h);
private:
@@ -99,7 +99,7 @@ extern "C" {
Q_DECL_EXPORT void m_live_texture_destroy(Qt::HANDLE h);
Q_DECL_EXPORT bool m_live_texture_lock(Qt::HANDLE h);
Q_DECL_EXPORT bool m_live_texture_unlock(Qt::HANDLE h);
- Q_DECL_EXPORT void m_live_texture_query(Qt::HANDLE h, void **data, int *pitch);
+ Q_DECL_EXPORT void m_live_texture_query(Qt::HANDLE h, void **data, int *pitch, QImage::Format *f);
Q_DECL_EXPORT Qt::HANDLE m_live_texture_to_egl_image(Qt::HANDLE h);
}
diff --git a/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp
index 84fc593..5473d09 100644
--- a/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp
+++ b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp
@@ -51,6 +51,24 @@ static EGLint preserved_image_attribs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, E
QHash <void*, QMeeGoImageInfo*> QMeeGoPixmapData::sharedImagesMap;
+// This helper method converts (in place) a QImage::Format_ARGB4444_Premultiplied to
+// GL-friendly Format_RGBA4444_Premultiplied. Just swaps the bits around really.
+static void qARGBA4ToRGBA4(QImage *image)
+{
+ unsigned char *raw = static_cast <unsigned char *> (image->data_ptr()->data);
+ // FIXME image.bytesPerLine() is broken. Returns 512 for 128x128 image while it should
+ // return 256
+ int bytesPerLine = image->width() * 2;
+
+ for (int y = 0; y < image->height(); y++) {
+ for (int x = 0; x < image->width(); x++) {
+ unsigned short *target = (unsigned short *) (raw + (y * bytesPerLine + (x * 2)));
+ // FIXME Oh yeah, that's broken with endianness.
+ *target = (*target << 4) | (* target >> 12);
+ }
+ }
+}
+
/* Public */
QMeeGoPixmapData::QMeeGoPixmapData() : QGLPixmapData(QPixmapData::PixmapType)
@@ -108,8 +126,6 @@ void QMeeGoPixmapData::fromEGLImage(Qt::HANDLE handle)
QMeeGoExtensions::eglQueryImageNOK(QEgl::display(), (EGLImageKHR) handle, EGL_HEIGHT, &newHeight);
if (textureIsBound) {
- // FIXME Remove this ugly hasAlphaChannel check when Qt lands the NoOpaqueCheck flag fix
- // for QGLPixmapData.
fromTexture(newTextureId, newWidth, newHeight, true);
} else {
qWarning("Failed to create a texture from an egl image!");
@@ -152,10 +168,9 @@ void QMeeGoPixmapData::fromEGLSharedImage(Qt::HANDLE handle, const QImage &si)
}
if (textureIsBound) {
- // FIXME Remove this ugly hasAlphaChannel check when Qt lands the NoOpaqueCheck flag fix
- // for QGLPixmapData.
fromTexture(newTextureId, newWidth, newHeight,
(si.hasAlphaChannel() && const_cast<QImage &>(si).data_ptr()->checkForAlphaPixels()));
+ texture()->options &= ~QGLContext::InvertedYBindOption;
softImage = si;
QMeeGoPixmapData::registerSharedImage(handle, softImage);
} else {
@@ -171,15 +186,31 @@ Qt::HANDLE QMeeGoPixmapData::imageToEGLSharedImage(const QImage &image)
QMeeGoExtensions::ensureInitialized();
glFinish();
- QGLPixmapData pixmapData(QPixmapData::PixmapType);
- pixmapData.fromImage(image, 0);
- GLuint textureId = pixmapData.bind();
+
+ GLuint textureId;
+
+ glGenTextures(1, &textureId);
+ glBindTexture(GL_TEXTURE_2D, textureId);
+ if (image.hasAlphaChannel() && (image.hasAlphaChannel() && const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels())) {
+ QImage convertedImage = image.convertToFormat(QImage::Format_ARGB4444_Premultiplied, Qt::DiffuseAlphaDither | Qt::DiffuseDither | Qt::PreferDither);
+ qARGBA4ToRGBA4(&convertedImage);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width(), image.height(), 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, convertedImage.bits());
+ } else {
+ QImage convertedImage = image.convertToFormat(QImage::Format_RGB16, Qt::DiffuseAlphaDither | Qt::DiffuseDither | Qt::PreferDither);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image.width(), image.height(), 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, convertedImage.bits());
+ }
+
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glFinish();
+
+ glBindTexture(GL_TEXTURE_2D, textureId);
EGLImageKHR eglimage = QEgl::eglCreateImageKHR(QEgl::display(), QEglContext::currentContext(QEgl::OpenGL)->context(),
EGL_GL_TEXTURE_2D_KHR,
(EGLClientBuffer) textureId,
preserved_image_attribs);
+ glDeleteTextures(1, &textureId);
glFinish();
if (eglimage) {
@@ -195,6 +226,7 @@ Qt::HANDLE QMeeGoPixmapData::imageToEGLSharedImage(const QImage &image)
void QMeeGoPixmapData::updateFromSoftImage()
{
+ // FIXME That's broken with recent 16bit textures changes.
m_dirty = true;
m_source = softImage;
ensureCreated();
diff --git a/tests/auto/modeltest/dynamictreemodel.cpp b/tests/auto/modeltest/dynamictreemodel.cpp
index b572eb1..fa634b6 100644
--- a/tests/auto/modeltest/dynamictreemodel.cpp
+++ b/tests/auto/modeltest/dynamictreemodel.cpp
@@ -63,6 +63,13 @@ QModelIndex DynamicTreeModel::index(int row, int column, const QModelIndex &pare
QList<QList<qint64> > childIdColumns = m_childItems.value(parent.internalId());
+ const qint64 grandParent = findParentId(parent.internalId());
+ if (grandParent >= 0) {
+ QList<QList<qint64> > parentTable = m_childItems.value(grandParent);
+ Q_ASSERT(parent.column() < parentTable.size());
+ QList<qint64> parentSiblings = parentTable.at(parent.column());
+ Q_ASSERT(parent.row() < parentSiblings.size());
+ }
if (childIdColumns.size() == 0)
return QModelIndex();
diff --git a/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp
index dbcccc9..b723253 100644
--- a/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp
+++ b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp
@@ -1167,6 +1167,7 @@ void tst_QAbstractItemModel::testMoveToGrandParent_data()
// Moving everything from one parent to another
QTest::newRow("move12") << 0 << 9 << 10;
+ QTest::newRow("move13") << 0 << 9 << 0;
}
void tst_QAbstractItemModel::testMoveToGrandParent()
@@ -1314,6 +1315,11 @@ void tst_QAbstractItemModel::testMoveToSibling_data()
QTest::newRow("move09") << 8 << 8 << 4;
QTest::newRow("move10") << 8 << 8 << 5;
QTest::newRow("move11") << 8 << 8 << 6;
+
+ // Move such that the destination parent no longer valid after the move.
+ // The destination parent is always QMI(5, 0), but after this move the
+ // row count is 5, so (5, 0) (used internally in QAIM) no longer refers to a valid index.
+ QTest::newRow("move12") << 0 << 4 << 0;
}
void tst_QAbstractItemModel::testMoveToSibling()
diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp
index 1590528..6d28f9f 100644
--- a/tests/auto/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/qcompleter/tst_qcompleter.cpp
@@ -119,6 +119,8 @@ private slots:
void directoryModel_data();
void directoryModel();
+ void fileSystemModel_data();
+ void fileSystemModel();
void changingModel_data();
void changingModel();
@@ -149,15 +151,17 @@ private slots:
void task253125_lineEditCompletion_data();
void task253125_lineEditCompletion();
void task247560_keyboardNavigation();
+ void QTBUG_14292_filesystem();
private:
- void filter();
+ void filter(bool assync = false);
void testRowCount();
enum ModelType {
CASE_SENSITIVELY_SORTED_MODEL,
CASE_INSENSITIVELY_SORTED_MODEL,
DIRECTORY_MODEL,
- HISTORY_MODEL
+ HISTORY_MODEL,
+ FILESYSTEM_MODEL
};
void setSourceModel(ModelType);
@@ -233,12 +237,21 @@ void tst_QCompleter::setSourceModel(ModelType type)
completer->setModel(new QDirModel(completer));
completer->setCompletionColumn(0);
break;
+ case FILESYSTEM_MODEL:
+ completer->setCsvCompletion(false);
+ {
+ QFileSystemModel *m = new QFileSystemModel(completer);
+ m->setRootPath("/");
+ completer->setModel(m);
+ }
+ completer->setCompletionColumn(0);
+ break;
default:
qDebug() << "Invalid type";
}
}
-void tst_QCompleter::filter()
+void tst_QCompleter::filter(bool assync)
{
QFETCH(QString, filterText);
QFETCH(QString, step);
@@ -250,6 +263,9 @@ void tst_QCompleter::filter()
return;
}
+ int times = 0;
+retry:
+
completer->setCompletionPrefix(filterText);
for (int i = 0; i < step.length(); i++) {
@@ -265,9 +281,13 @@ void tst_QCompleter::filter()
completer->setCurrentRow(row);
}
- //QModelIndex si = completer->currentIndex();
- //QCOMPARE(completer->model()->data(si).toString(), completion);
- QVERIFY(0 == QString::compare(completer->currentCompletion(), completionText, completer->caseSensitivity()));
+ int r = QString::compare(completer->currentCompletion(), completionText, completer->caseSensitivity());
+ if (assync && r && times < 10) {
+ times++;
+ QTest::qWait(50*times);
+ goto retry;
+ }
+ QVERIFY(!r);
}
// Testing get/set functions
@@ -552,6 +572,7 @@ void tst_QCompleter::csMatchingOnCiSortedModel()
void tst_QCompleter::directoryModel_data()
{
delete completer;
+
completer = new CsvCompleter;
completer->setModelSorting(QCompleter::CaseSensitivelySortedModel);
setSourceModel(DIRECTORY_MODEL);
@@ -598,6 +619,57 @@ void tst_QCompleter::directoryModel()
filter();
}
+void tst_QCompleter::fileSystemModel_data()
+{
+ delete completer;
+ completer = new CsvCompleter;
+ completer->setModelSorting(QCompleter::CaseSensitivelySortedModel);
+ setSourceModel(FILESYSTEM_MODEL);
+ completer->setCaseSensitivity(Qt::CaseInsensitive);
+
+ QTest::addColumn<QString>("filterText");
+ QTest::addColumn<QString>("step");
+ QTest::addColumn<QString>("completion");
+ QTest::addColumn<QString>("completionText");
+
+ // NOTE: Add tests carefully, ensurely the paths exist on all systems
+ // Output is the sourceText; currentCompletionText()
+
+ for (int i = 0; i < 2; i++) {
+ if (i == 1)
+ QTest::newRow("FILTERING_OFF") << "FILTERING_OFF" << "" << "" << "";
+
+#if defined(Q_OS_WINCE)
+ QTest::newRow("()") << "" << "" << "/" << "/";
+ QTest::newRow("()") << "\\Program" << "" << "Program Files" << "\\Program Files";
+#elif defined(Q_OS_WIN)
+ QTest::newRow("()") << "C" << "" << "C:" << "C:";
+ QTest::newRow("()") << "C:\\Program" << "" << "Program Files" << "C:\\Program Files";
+#elif defined(Q_OS_SYMBIAN)
+ QTest::newRow("()") << "C" << "" << "C:" << "C:";
+ QTest::newRow("()") << "C:\\re" << "" << "resource" << "C:\\resource";
+#elif defined (Q_OS_MAC)
+ QTest::newRow("()") << "" << "" << "/" << "/";
+ QTest::newRow("(/a)") << "/a" << "" << "Applications" << "/Applications";
+ QTest::newRow("(/d)") << "/d" << "" << "Developer" << "/Developer";
+#else
+ QTest::newRow("()") << "" << "" << "/" << "/";
+#if !defined(Q_OS_IRIX) && !defined(Q_OS_AIX) && !defined(Q_OS_HPUX)
+ QTest::newRow("(/h)") << "/h" << "" << "home" << "/home";
+#endif
+ QTest::newRow("(/et)") << "/et" << "" << "etc" << "/etc";
+ QTest::newRow("(/etc/passw)") << "/etc/passw" << "" << "passwd" << "/etc/passwd";
+#endif
+ }
+}
+
+void tst_QCompleter::fileSystemModel()
+{
+ //QFileSystemModel is assync.
+ filter(true);
+}
+
+
void tst_QCompleter::changingModel_data()
{
}
@@ -1381,5 +1453,77 @@ void tst_QCompleter::task247560_keyboardNavigation()
QCOMPARE(edit.text(), QString("row 3 column 1"));
}
+void tst_QCompleter::QTBUG_14292_filesystem()
+{
+ QDir tmpDir = QDir::temp();
+ qsrand(QTime::currentTime().msec());
+ QString d = "tst_QCompleter_" + QString::number(qrand());
+ QVERIFY(tmpDir.mkdir(d));
+
+#if 0
+ struct Cleanup {
+ QString dir;
+ ~Cleanup() {
+ qDebug() << dir <<
+ QFile::remove(dir); }
+ } cleanup;
+ cleanup.dir = tmpDir.absolutePath()+"/" +d;
+#endif
+
+ QVERIFY(tmpDir.cd(d));
+ QVERIFY(tmpDir.mkdir("hello"));
+ QVERIFY(tmpDir.mkdir("holla"));
+
+ QLineEdit edit;
+ QCompleter comp;
+ QFileSystemModel model;
+ model.setRootPath(tmpDir.path());
+ comp.setModel(&model);
+ edit.setCompleter(&comp);
+
+ edit.show();
+ QApplication::setActiveWindow(&edit);
+ QTest::qWaitForWindowShown(&edit);
+ QTRY_VERIFY(QApplication::activeWindow() == &edit);
+
+ QVERIFY(!comp.popup()->isVisible());
+ edit.setText(tmpDir.path());
+ QTest::keyClick(&edit, '/');
+ QTRY_VERIFY(comp.popup()->isVisible());
+ QCOMPARE(comp.popup()->model()->rowCount(), 2);
+ QTest::keyClick(&edit, 'h');
+ QCOMPARE(comp.popup()->model()->rowCount(), 2);
+ QTest::keyClick(&edit, 'e');
+ QCOMPARE(comp.popup()->model()->rowCount(), 1);
+ QTest::keyClick(&edit, 'r');
+ QTRY_VERIFY(!comp.popup()->isVisible());
+ QVERIFY(tmpDir.mkdir("hero"));
+ QTRY_VERIFY(comp.popup()->isVisible());
+ QCOMPARE(comp.popup()->model()->rowCount(), 1);
+ QTest::keyClick(comp.popup(), Qt::Key_Escape);
+ QTRY_VERIFY(!comp.popup()->isVisible());
+ QVERIFY(tmpDir.mkdir("nothingThere"));
+ //there is no reason creating a file should open a popup, it did in Qt 4.7.0
+ QTest::qWait(60);
+ QVERIFY(!comp.popup()->isVisible());
+
+ QTest::keyClick(&edit, Qt::Key_Backspace);
+ QTRY_VERIFY(comp.popup()->isVisible());
+ QCOMPARE(comp.popup()->model()->rowCount(), 2);
+ QTest::keyClick(&edit, 'm');
+ QTRY_VERIFY(!comp.popup()->isVisible());
+
+ QWidget w;
+ w.show();
+ QApplication::setActiveWindow(&w);
+ QTest::qWaitForWindowShown(&w);
+ QTRY_VERIFY(!edit.hasFocus() && !comp.popup()->hasFocus());
+
+ QVERIFY(tmpDir.mkdir("hemo"));
+ //there is no reason creating a file should open a popup, it did in Qt 4.7.0
+ QTest::qWait(60);
+ QVERIFY(!comp.popup()->isVisible());
+}
+
QTEST_MAIN(tst_QCompleter)
#include "tst_qcompleter.moc"
diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp
index b9dbb2b..5e36631 100644
--- a/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp
+++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp
@@ -118,20 +118,20 @@ QImage* QMeeGoLivePixmap::lock()
void *data = NULL;
int pitch = 0;
+ QImage::Format format;
if (! QMeeGoRuntime::lockLiveTexture(d->handle)) {
qWarning("Failed to lock a live texture!");
return new QImage();
}
- QMeeGoRuntime::queryLiveTexture(d->handle, &data, &pitch);
+ QMeeGoRuntime::queryLiveTexture(d->handle, &data, &pitch, &format);
if (data == NULL || pitch == 0) {
qWarning("Failed to query the live texture!");
return new QImage();
}
- // FIXME Bug here! FIX FIX FIX FIX FIX FIX
- return new QImage((uchar *) data, width(), height(), QImage::Format_RGB16);
+ return new QImage((uchar *) data, width(), height(), format);
}
void QMeeGoLivePixmap::release(QImage *img)
diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp
index 44f9f58..215dffc 100644
--- a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp
+++ b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp
@@ -62,7 +62,7 @@ typedef Qt::HANDLE (*QMeeGoLiveTextureCreateFunc) (int w, int h, QImage::Format
typedef bool (*QMeeGoLiveTextureLockFunc) (Qt::HANDLE h);
typedef bool (*QMeeGoLiveTextureUnlockFunc) (Qt::HANDLE h);
typedef void (*QMeeGoLiveTextureDestroyFunc) (Qt::HANDLE h);
-typedef void (*QMeeGoLiveTextureQueryFunc) (Qt::HANDLE h, void **data, int *pitch);
+typedef void (*QMeeGoLiveTextureQueryFunc) (Qt::HANDLE h, void **data, int *pitch, QImage::Format *format);
typedef Qt::HANDLE (*QMeeGoLiveTextureToEglImageFunc) (Qt::HANDLE h);
static QMeeGoImageToEglSharedImageFunc qt_meego_image_to_egl_shared_image = NULL;
@@ -216,11 +216,11 @@ void QMeeGoRuntime::destroyLiveTexture(Qt::HANDLE h)
qt_meego_live_texture_destroy(h);
}
-void QMeeGoRuntime::queryLiveTexture(Qt::HANDLE h, void **data, int *pitch)
+void QMeeGoRuntime::queryLiveTexture(Qt::HANDLE h, void **data, int *pitch, QImage::Format *format)
{
ENSURE_INITIALIZED;
Q_ASSERT(qt_meego_live_texture_query);
- qt_meego_live_texture_query(h, data, pitch);
+ qt_meego_live_texture_query(h, data, pitch, format);
}
Qt::HANDLE QMeeGoRuntime::liveTextureToEGLImage(Qt::HANDLE handle)
diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.h b/tools/qmeegographicssystemhelper/qmeegoruntime.h
index 048b9be..9f2d505 100644
--- a/tools/qmeegographicssystemhelper/qmeegoruntime.h
+++ b/tools/qmeegographicssystemhelper/qmeegoruntime.h
@@ -60,7 +60,7 @@ public:
static bool lockLiveTexture(Qt::HANDLE h);
static bool unlockLiveTexture(Qt::HANDLE h);
static void destroyLiveTexture(Qt::HANDLE h);
- static void queryLiveTexture(Qt::HANDLE h, void **data, int *pitch);
+ static void queryLiveTexture(Qt::HANDLE h, void **data, int *pitch, QImage::Format *format);
static Qt::HANDLE liveTextureToEGLImage(Qt::HANDLE);
private: