summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselmo L. S. Melo <anselmolsm@gmail.com>2014-03-29 18:31:57 -0300
committerAnselmo L. S. Melo <anselmolsm@gmail.com>2014-05-09 13:04:53 +0200
commit5a530b2b9e514a83b9e5f2a66f06b37d35cac3f2 (patch)
tree7d782a5a1e5e1b1afe2cf16fa4c546c6af6eedd2
parent67d58739f5e2fbefd45ff911da244aa4c910529d (diff)
API updatesHEADmaster
This project was developed before the release of Qt 5.0, so some of the APIs had to be updated in order to build again. Change-Id: I579d7170ea0d80bd33aee29ec807461af603b0d3 Reviewed-by: Anselmo L. S. Melo <anselmolsm@gmail.com>
-rw-r--r--examples/models/completionmodel/main.cpp2
-rw-r--r--examples/models/fsviewer/main.cpp2
-rw-r--r--examples/models/textfilemodel/main.cpp2
-rw-r--r--imports/models/uiquickcompletionmodel.cpp4
-rw-r--r--src/models/uifilesystemmodel.cpp7
-rw-r--r--src/models/uifilesystemmodel.h2
-rw-r--r--src/models/uiproxyqmlmodel.cpp22
-rw-r--r--src/models/uiproxyqmlmodel.h6
-rw-r--r--src/utils/uiaction.cpp2
-rw-r--r--tests/auto/models/qfilesystemmodel/tst_qfilesystemmodel.cpp2
-rw-r--r--tests/auto/models/uitextfilemodel/tst_uitextfilemodel.cpp2
11 files changed, 29 insertions, 24 deletions
diff --git a/examples/models/completionmodel/main.cpp b/examples/models/completionmodel/main.cpp
index 88415c2..ce1dc6b 100644
--- a/examples/models/completionmodel/main.cpp
+++ b/examples/models/completionmodel/main.cpp
@@ -72,7 +72,7 @@ int main(int argc, char **argv)
QQuickView v;
v.rootContext()->setContextProperty("completionModel", &model);
- v.setWindowTitle(QObject::tr("Completion Model"));
+ v.setTitle(QObject::tr("Completion Model"));
v.setSource(QUrl("qrc:/main.qml"));
v.show();
diff --git a/examples/models/fsviewer/main.cpp b/examples/models/fsviewer/main.cpp
index 09bbc50..9766246 100644
--- a/examples/models/fsviewer/main.cpp
+++ b/examples/models/fsviewer/main.cpp
@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
QQuickView v;
v.rootContext()->setContextProperty("fsmodel", &model);
- v.setWindowTitle(QObject::tr("Dir View"));
+ v.setTitle(QObject::tr("Dir View"));
v.setResizeMode(QQuickView::SizeRootObjectToView);
v.resize(640, 480);
v.setSource(QUrl::fromLocalFile("main.qml"));
diff --git a/examples/models/textfilemodel/main.cpp b/examples/models/textfilemodel/main.cpp
index 48cf6a2..a775420 100644
--- a/examples/models/textfilemodel/main.cpp
+++ b/examples/models/textfilemodel/main.cpp
@@ -60,7 +60,7 @@ int main(int argc, char **argv)
QQuickView v;
v.rootContext()->setContextProperty("completionModel", &model);
- v.setWindowTitle(QObject::tr("Completion Model with TextFileModel"));
+ v.setTitle(QObject::tr("Completion Model with TextFileModel"));
v.setSource(QString("qrc:/main.qml"));
v.show();
diff --git a/imports/models/uiquickcompletionmodel.cpp b/imports/models/uiquickcompletionmodel.cpp
index 9f69399..d414976 100644
--- a/imports/models/uiquickcompletionmodel.cpp
+++ b/imports/models/uiquickcompletionmodel.cpp
@@ -83,7 +83,7 @@ void UiQuickCompletionModel::setSource(const QVariant& source)
if (type == UiProxyQmlModel::ArrayList)
setCompletionRole(Qt::DisplayRole);
else if (type == UiProxyQmlModel::QuickList) {
- int role = d->proxy->roleNames().key(d->roleName.toAscii(), -1);
+ int role = d->proxy->roleNames().key(d->roleName.toLatin1(), -1);
if (role != -1)
setCompletionRole(role);
}
@@ -108,7 +108,7 @@ void UiQuickCompletionModel::setCompletionRoleName(const QString &roleName)
if (roleName == d->roleName)
return;
- int role = d->proxy->roleNames().key(roleName.toAscii(), -1);
+ int role = d->proxy->roleNames().key(roleName.toLatin1(), -1);
if (role != -1)
setCompletionRole(role);
diff --git a/src/models/uifilesystemmodel.cpp b/src/models/uifilesystemmodel.cpp
index e8c23c8..f437dfd 100644
--- a/src/models/uifilesystemmodel.cpp
+++ b/src/models/uifilesystemmodel.cpp
@@ -1860,12 +1860,15 @@ void UiFileSystemModelPrivate::init()
q->connect(&fileInfoGatherer, SIGNAL(directoryLoaded(QString)),
q, SIGNAL(directoryLoaded(QString)));
q->connect(&delayedSortTimer, SIGNAL(timeout()), q, SLOT(_q_performDelayedSort()), Qt::QueuedConnection);
+}
- QHash<int, QByteArray> roles = q->roleNames();
+QHash<int, QByteArray> UiFileSystemModel::roleNames() const
+{
+ QHash<int, QByteArray> roles;
roles.insert(UiFileSystemModel::FilePathRole, "filePath");
roles.insert(UiFileSystemModel::FileNameRole, "fileName");
roles.insert(UiFileSystemModel::FilePermissions, "filePermissions");
- q->setRoleNames(roles);
+ return roles;
}
/*!
diff --git a/src/models/uifilesystemmodel.h b/src/models/uifilesystemmodel.h
index 4279c20..61ca922 100644
--- a/src/models/uifilesystemmodel.h
+++ b/src/models/uifilesystemmodel.h
@@ -138,7 +138,7 @@ public:
QFile::Permissions permissions(const QModelIndex &index) const;
inline QFileInfo fileInfo(const QModelIndex &index) const;
bool remove(const QModelIndex &index) const;
-
+ QHash<int, QByteArray> roleNames() const;
protected:
UiFileSystemModel(UiFileSystemModelPrivate &, QObject *parent = 0);
void timerEvent(QTimerEvent *event);
diff --git a/src/models/uiproxyqmlmodel.cpp b/src/models/uiproxyqmlmodel.cpp
index 47f079c..37e6f55 100644
--- a/src/models/uiproxyqmlmodel.cpp
+++ b/src/models/uiproxyqmlmodel.cpp
@@ -42,7 +42,8 @@
#ifndef QT_NO_PROXYQMLMODEL
#include "uiproxyqmlmodel.h"
-#include <QtQml/private/qquicklistmodel_p.h>
+#include <QtQml/qqmlprivate.h>
+#include <QtQml/private/qqmllistmodel_p.h>
QT_BEGIN_NAMESPACE_UIHELPERS
@@ -58,7 +59,7 @@ UiProxyQmlModel::ListType UiProxyQmlModel::updateSource(const QVariant &sourceMo
if (sourceModel.type() == QVariant::List) {
createFromList(sourceModel.toList());
return ArrayList;
- } else if (QQuickListModel *list = qvariant_cast<QQuickListModel*>(sourceModel)) {
+ } else if (QQmlListModel *list = qvariant_cast<QQmlListModel*>(sourceModel)) {
createFromQuickList(list);
return QuickList;
}
@@ -66,13 +67,16 @@ UiProxyQmlModel::ListType UiProxyQmlModel::updateSource(const QVariant &sourceMo
return InvalidList;
}
-void UiProxyQmlModel::createFromList(const QVariantList &list)
-{
- QHash<int, QByteArray> roleNames;
- roleNames[Qt::DisplayRole] = "display";
- setRoleNames(roleNames);
+QHash<int, QByteArray> UiProxyQmlModel::roleNames()
+{
+ QHash<int, QByteArray> roles;
+ roles.insert(Qt::DisplayRole, "display");
+ return roles;
+}
+void UiProxyQmlModel::createFromList(const QVariantList &list)
+{
foreach (const QVariant& var, list) {
QStandardItem *item = new QStandardItem();
item->setData(var, Qt::DisplayRole);
@@ -81,10 +85,8 @@ void UiProxyQmlModel::createFromList(const QVariantList &list)
}
}
-void UiProxyQmlModel::createFromQuickList(QQuickListModel *list)
+void UiProxyQmlModel::createFromQuickList(QQmlListModel *list)
{
- setRoleNames(list->roleNames());
-
for (int i = 0; i < list->count(); i++) {
QStandardItem *item = new QStandardItem();
diff --git a/src/models/uiproxyqmlmodel.h b/src/models/uiproxyqmlmodel.h
index 3b69207..2192459 100644
--- a/src/models/uiproxyqmlmodel.h
+++ b/src/models/uiproxyqmlmodel.h
@@ -50,7 +50,7 @@
QT_BEGIN_HEADER
-class QQuickListModel;
+class QQmlListModel;
QT_BEGIN_NAMESPACE_UIHELPERS
@@ -66,10 +66,10 @@ public:
UiProxyQmlModel(QObject *parent = 0);
ListType updateSource(const QVariant &sourceModel);
-
+ QHash<int, QByteArray> roleNames();
protected:
void createFromList(const QVariantList &list);
- void createFromQuickList(QQuickListModel *list);
+ void createFromQuickList(QQmlListModel *list);
};
QT_END_NAMESPACE_UIHELPERS
diff --git a/src/utils/uiaction.cpp b/src/utils/uiaction.cpp
index cc38827..0485ca1 100644
--- a/src/utils/uiaction.cpp
+++ b/src/utils/uiaction.cpp
@@ -859,7 +859,7 @@ void UiAction::activate(ActionEvent event)
{
Q_D(UiAction);
if (event == Trigger) {
- QWeakPointer<QObject> guard = this;
+ QPointer<QObject> guard = this;
if (d->checkable) {
// the checked action of an exclusive group cannot be unchecked
if (d->checked && (d->group && d->group->isExclusive()
diff --git a/tests/auto/models/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/models/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 5fbf009..ee72e2e 100644
--- a/tests/auto/models/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/models/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -141,7 +141,7 @@ tst_UiFileSystemModel::~tst_UiFileSystemModel()
QString tmp = flatDirTestPath;
QDir dir(tmp);
if (dir.exists() && !dir.rmdir(tmp))
- qWarning("failed to remove tmp dir %s", dir.dirName().toAscii().data());
+ qWarning("failed to remove tmp dir %s", dir.dirName().toLatin1().data());
}
void tst_UiFileSystemModel::init()
diff --git a/tests/auto/models/uitextfilemodel/tst_uitextfilemodel.cpp b/tests/auto/models/uitextfilemodel/tst_uitextfilemodel.cpp
index 446782d..6bb7b6a 100644
--- a/tests/auto/models/uitextfilemodel/tst_uitextfilemodel.cpp
+++ b/tests/auto/models/uitextfilemodel/tst_uitextfilemodel.cpp
@@ -80,7 +80,7 @@ void tst_UiTextFileModel::init()
text.append(", ");
}
}
- file.write(text.toAscii());
+ file.write(text.toLatin1());
file.flush();
file.close();
}