summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2009-08-06 06:23:07 (GMT)
committerJason Barron <jbarron@trolltech.com>2009-08-06 06:23:07 (GMT)
commit57ceb11ecf95032418712a686418116cf2398e7a (patch)
tree378533fcc07983d3a1b461aaaad07d842e50b81c /src/gui
parent90d4366f1e9657b3240a872698614c7d9747f9e0 (diff)
parenta4fc85c75f068b73f9c2334c77b0ae2275510e17 (diff)
downloadQt-57ceb11ecf95032418712a686418116cf2398e7a.zip
Qt-57ceb11ecf95032418712a686418116cf2398e7a.tar.gz
Qt-57ceb11ecf95032418712a686418116cf2398e7a.tar.bz2
Merge commit 'origin/master'
Conflicts: tests/auto/qfilesystemmodel/qfilesystemmodel.pro tests/auto/qfontdialog/tst_qfontdialog.cpp tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp tests/auto/qsqldriver/qsqldriver.pro tests/auto/qsqlquery/qsqlquery.pro tests/auto/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro tests/auto/qsqltablemodel/qsqltablemodel.pro tests/auto/qsqlthread/qsqlthread.pro tests/auto/qstatemachine/tst_qstatemachine.cpp tests/auto/qtcpsocket/tst_qtcpsocket.cpp
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/itemviews/qstandarditemmodel.cpp20
-rw-r--r--src/gui/itemviews/qstandarditemmodel_p.h4
-rw-r--r--src/gui/kernel/qwidget_s60.cpp44
-rw-r--r--src/gui/util/qdesktopservices.cpp5
-rw-r--r--src/gui/util/qdesktopservices_s60.cpp83
5 files changed, 84 insertions, 72 deletions
diff --git a/src/gui/itemviews/qstandarditemmodel.cpp b/src/gui/itemviews/qstandarditemmodel.cpp
index b960fae..25acbc4 100644
--- a/src/gui/itemviews/qstandarditemmodel.cpp
+++ b/src/gui/itemviews/qstandarditemmodel.cpp
@@ -329,7 +329,6 @@ QStandardItemModelPrivate::QStandardItemModelPrivate()
*/
QStandardItemModelPrivate::~QStandardItemModelPrivate()
{
- delete root;
delete itemPrototype;
qDeleteAll(columnHeaderItems);
qDeleteAll(rowHeaderItems);
@@ -554,7 +553,7 @@ void QStandardItemModelPrivate::rowsInserted(QStandardItem *parent,
int row, int count)
{
Q_Q(QStandardItemModel);
- if (parent == root)
+ if (parent == root.data())
rowHeaderItems.insert(row, count, 0);
q->endInsertRows();
}
@@ -566,7 +565,7 @@ void QStandardItemModelPrivate::columnsInserted(QStandardItem *parent,
int column, int count)
{
Q_Q(QStandardItemModel);
- if (parent == root)
+ if (parent == root.data())
columnHeaderItems.insert(column, count, 0);
q->endInsertColumns();
}
@@ -578,7 +577,7 @@ void QStandardItemModelPrivate::rowsRemoved(QStandardItem *parent,
int row, int count)
{
Q_Q(QStandardItemModel);
- if (parent == root) {
+ if (parent == root.data()) {
for (int i = row; i < row + count; ++i) {
QStandardItem *oldItem = rowHeaderItems.at(i);
if (oldItem)
@@ -597,7 +596,7 @@ void QStandardItemModelPrivate::columnsRemoved(QStandardItem *parent,
int column, int count)
{
Q_Q(QStandardItemModel);
- if (parent == root) {
+ if (parent == root.data()) {
for (int i = column; i < column + count; ++i) {
QStandardItem *oldItem = columnHeaderItems.at(i);
if (oldItem)
@@ -788,7 +787,7 @@ QStandardItem::~QStandardItem()
QStandardItem *QStandardItem::parent() const
{
Q_D(const QStandardItem);
- if (!d->model || (d->model->d_func()->root != d->parent))
+ if (!d->model || (d->model->d_func()->root.data() != d->parent))
return d->parent;
return 0;
}
@@ -2083,8 +2082,7 @@ QStandardItemModel::~QStandardItemModel()
void QStandardItemModel::clear()
{
Q_D(QStandardItemModel);
- delete d->root;
- d->root = new QStandardItem;
+ d->root.reset(new QStandardItem);
d->root->d_func()->setModel(this);
qDeleteAll(d->columnHeaderItems);
d->columnHeaderItems.clear();
@@ -2231,7 +2229,7 @@ QStandardItem *QStandardItemModel::item(int row, int column) const
QStandardItem *QStandardItemModel::invisibleRootItem() const
{
Q_D(const QStandardItemModel);
- return d->root;
+ return d->root.data();
}
/*!
@@ -2733,7 +2731,7 @@ QModelIndex QStandardItemModel::index(int row, int column, const QModelIndex &pa
bool QStandardItemModel::insertColumns(int column, int count, const QModelIndex &parent)
{
Q_D(QStandardItemModel);
- QStandardItem *item = parent.isValid() ? itemFromIndex(parent) : d->root;
+ QStandardItem *item = parent.isValid() ? itemFromIndex(parent) : d->root.data();
if (item == 0)
return false;
return item->d_func()->insertColumns(column, count, QList<QStandardItem*>());
@@ -2745,7 +2743,7 @@ bool QStandardItemModel::insertColumns(int column, int count, const QModelIndex
bool QStandardItemModel::insertRows(int row, int count, const QModelIndex &parent)
{
Q_D(QStandardItemModel);
- QStandardItem *item = parent.isValid() ? itemFromIndex(parent) : d->root;
+ QStandardItem *item = parent.isValid() ? itemFromIndex(parent) : d->root.data();
if (item == 0)
return false;
return item->d_func()->insertRows(row, count, QList<QStandardItem*>());
diff --git a/src/gui/itemviews/qstandarditemmodel_p.h b/src/gui/itemviews/qstandarditemmodel_p.h
index b2b16d1..8be8e9e 100644
--- a/src/gui/itemviews/qstandarditemmodel_p.h
+++ b/src/gui/itemviews/qstandarditemmodel_p.h
@@ -152,7 +152,7 @@ public:
inline QStandardItem *itemFromIndex(const QModelIndex &index) const {
Q_Q(const QStandardItemModel);
if (!index.isValid())
- return root;
+ return root.data();
if (index.model() != q)
return 0;
QStandardItem *parent = static_cast<QStandardItem*>(index.internalPointer());
@@ -177,7 +177,7 @@ public:
QVector<QStandardItem*> columnHeaderItems;
QVector<QStandardItem*> rowHeaderItems;
- QStandardItem *root;
+ QScopedPointer<QStandardItem> root;
const QStandardItem *itemPrototype;
int sortRole;
};
diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp
index ddd2f4c..4336d45 100644
--- a/src/gui/kernel/qwidget_s60.cpp
+++ b/src/gui/kernel/qwidget_s60.cpp
@@ -299,6 +299,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de
CCoeControl *destroyw = 0;
+ createExtra();
if(window) {
if (destroyOldWindow)
destroyw = data.winid;
@@ -311,7 +312,10 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de
if (!q->testAttribute(Qt::WA_Moved) && !q->testAttribute(Qt::WA_DontShowOnScreen))
data.crect.moveTopLeft(QPoint(clientRect.iTl.iX, clientRect.iTl.iY));
QSymbianControl *control= q_check_ptr(new QSymbianControl(q));
+ id = (WId)control;
+ setWinId(id);
QT_TRAP_THROWING(control->ConstructL(true,desktop));
+
if (!desktop) {
TInt stackingFlags;
if ((q->windowType() & Qt::Popup) == Qt::Popup) {
@@ -336,11 +340,6 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de
}
}
-
- id = (WId)control;
-
- setWinId(id);
-
q->setAttribute(Qt::WA_WState_Created);
int x, y, w, h;
@@ -348,6 +347,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de
control->SetRect(TRect(TPoint(x, y), TSize(w, h)));
} else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create native child widget
QSymbianControl *control = new QSymbianControl(q);
+ setWinId(control);
QT_TRAP_THROWING(control->ConstructL(!parentWidget));
TInt stackingFlags;
@@ -358,7 +358,6 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de
}
control->ControlEnv()->AppUi()->AddToStackL(control, ECoeStackPriorityDefault, stackingFlags);
- setWinId(control);
WId parentw = parentWidget->effectiveWinId();
QT_TRAP_THROWING(control->SetContainerWindowL(*parentw));
@@ -852,7 +851,12 @@ void QWidgetPrivate::createSysExtra()
void QWidgetPrivate::deleteSysExtra()
{
-
+ // this should only be non-zero if destroy() has not run due to constructor fail
+ if (data.winid) {
+ data.winid->ControlEnv()->AppUi()->RemoveFromStack(data.winid);
+ delete data.winid;
+ data.winid = 0;
+ }
}
QWindowSurface *QWidgetPrivate::createDefaultWindowSurface_sys()
@@ -1079,6 +1083,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
if (!isWindow() && parentWidget())
parentWidget()->d_func()->invalidateBuffer(geometry());
d->deactivateWidgetCleanup();
+ WId id = internalWinId();
if (testAttribute(Qt::WA_WState_Created)) {
#ifndef QT_NO_IM
@@ -1104,12 +1109,10 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
releaseMouse();
if (QWidgetPrivate::keyboardGrabber == this)
releaseKeyboard();
- if (destroyWindow && !(windowType() == Qt::Desktop) && internalWinId()) {
- WId id = internalWinId();
+ if (destroyWindow && !(windowType() == Qt::Desktop) && id) {
if(id->IsFocused()) // Avoid unnecessry calls to FocusChanged()
id->SetFocus(false);
id->ControlEnv()->AppUi()->RemoveFromStack(id);
- CBase::Delete(id);
// Hack to activate window under destroyed one. With this activation
// the next visible window will get keyboard focus
@@ -1117,17 +1120,22 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
if (wid) {
QWidget *widget = QWidget::find(wid);
QApplication::setActiveWindow(widget);
- // Reset global window title for focusing window
- widget->d_func()->setWindowTitle_sys(widget->windowTitle());
+ if (widget) {
+ // Reset global window title for focusing window
+ widget->d_func()->setWindowTitle_sys(widget->windowTitle());
+ }
}
-
}
+ }
- QT_TRY {
- d->setWinId(0);
- } QT_CATCH (const std::bad_alloc &) {
- // swallow - destructors must not throw
- }
+ QT_TRY {
+ d->setWinId(0);
+ } QT_CATCH (const std::bad_alloc &) {
+ // swallow - destructors must not throw
+ }
+
+ if (destroyWindow) {
+ delete id;
}
}
diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp
index 18a0a73..26e10ca 100644
--- a/src/gui/util/qdesktopservices.cpp
+++ b/src/gui/util/qdesktopservices.cpp
@@ -288,8 +288,9 @@ void QDesktopServices::unsetUrlHandler(const QString &scheme)
\note The storage location returned can be a directory that does not exist; i.e., it
may need to be created by the system or the user.
- \note On Symbian OS, DataLocation and ApplicationsLocation always point to appropriate
- folder on same drive with executable. FontsLocation always points to folder on ROM drive.
+ \note On Symbian OS, ApplicationsLocation always point /sys/bin folder on the same drive
+ with executable. FontsLocation always points to folder on ROM drive. Symbian OS does not
+ have desktop concept, DesktopLocation returns same path as DocumentsLocation.
Rest of the standard locations point to folder on same drive with executable, except
that if executable is in ROM the folder from C drive is returned.
diff --git a/src/gui/util/qdesktopservices_s60.cpp b/src/gui/util/qdesktopservices_s60.cpp
index 565dd6e..4531a2f 100644
--- a/src/gui/util/qdesktopservices_s60.cpp
+++ b/src/gui/util/qdesktopservices_s60.cpp
@@ -68,6 +68,7 @@
QT_BEGIN_NAMESPACE
+_LIT(KCacheSubDir, "Cache\\");
_LIT(KSysBin, "\\Sys\\Bin\\");
_LIT(KTempDir, "\\System\\Temp\\");
_LIT(KBrowserPrefix, "4 " );
@@ -125,7 +126,7 @@ static void handleMailtoSchemeLX(const QUrl &url)
CleanupStack::PopAndDestroy(accounts);
if(!count) {
- // TODO: we should try to create account if count == 0
+ // TODO: Task 259192: We should try to create account if count == 0
// CSendUi would provide account creation service for us, but it requires ridicilous
// capabilities: LocalServices NetworkServices ReadDeviceData ReadUserData WriteDeviceData WriteUserData
User::Leave(KErrNotSupported);
@@ -143,18 +144,18 @@ static void handleMailtoSchemeLX(const QUrl &url)
// To
foreach(QString item, recipients)
- sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientTo );
+ sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientTo);
foreach(QString item, tos)
- sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientTo );
+ sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientTo);
// Cc
foreach(QString item, ccs)
- sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientCc );
+ sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientCc);
// Bcc
foreach(QString item, bccs)
- sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientBcc );
+ sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientBcc);
// send the message
sendAsMessage.LaunchEditorAndCloseL();
@@ -172,32 +173,29 @@ static bool handleMailtoScheme(const QUrl &url)
static void handleOtherSchemesL(const TDesC& aUrl)
{
// Other schemes are at the moment passed to WEB browser
- HBufC* buf16 = HBufC::NewLC( aUrl.Length() + KBrowserPrefix.iTypeLength );
- buf16->Des().Copy( KBrowserPrefix ); // Prefix used to launch correct browser view
- buf16->Des().Append( aUrl );
-
- TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
- TApaTask task = taskList.FindApp( KUidBrowser );
- if ( task.Exists() )
- {
+ HBufC* buf16 = HBufC::NewLC(aUrl.Length() + KBrowserPrefix.iTypeLength);
+ buf16->Des().Copy(KBrowserPrefix); // Prefix used to launch correct browser view
+ buf16->Des().Append(aUrl);
+
+ TApaTaskList taskList(CEikonEnv::Static()->WsSession());
+ TApaTask task = taskList.FindApp(KUidBrowser);
+ if (task.Exists()){
// Switch to existing browser instance
- HBufC8* param8 = HBufC8::NewLC( buf16->Length() );
- param8->Des().Append( buf16->Des() );
- task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used
- CleanupStack::PopAndDestroy( param8 );
- }
- else
- {
+ HBufC8* param8 = HBufC8::NewLC(buf16->Length());
+ param8->Des().Append(buf16->Des());
+ task.SendMessage(TUid::Uid( 0 ), *param8); // Uid is not used
+ CleanupStack::PopAndDestroy(param8);
+ } else {
// Start a new browser instance
RApaLsSession appArcSession;
- User::LeaveIfError( appArcSession.Connect() );
- CleanupClosePushL<RApaLsSession>( appArcSession );
+ User::LeaveIfError(appArcSession.Connect());
+ CleanupClosePushL<RApaLsSession>(appArcSession);
TThreadId id;
- appArcSession.StartDocument( *buf16, KUidBrowser , id );
+ appArcSession.StartDocument(*buf16, KUidBrowser, id);
CleanupStack::PopAndDestroy(); // appArcSession
- }
+ }
- CleanupStack::PopAndDestroy( buf16 );
+ CleanupStack::PopAndDestroy(buf16);
}
static bool handleOtherSchemes(const QUrl &url)
@@ -219,8 +217,8 @@ static TDriveUnit exeDrive()
static TDriveUnit writableExeDrive()
{
TDriveUnit drive = exeDrive();
- if( drive.operator TInt() == EDriveZ )
- return TDriveUnit( EDriveC );
+ if(drive.operator TInt() == EDriveZ)
+ return TDriveUnit(EDriveC);
return drive;
}
@@ -228,7 +226,7 @@ static TPtrC writableDataRoot()
{
TDriveUnit drive = exeDrive();
#ifdef Q_WS_S60
- switch( drive.operator TInt() ){
+ switch(drive.operator TInt()){
case EDriveC:
return PathInfo::PhoneMemoryRootPath();
break;
@@ -241,7 +239,6 @@ static TPtrC writableDataRoot()
return PathInfo::PhoneMemoryRootPath();
break;
default:
- // TODO: Should we return drive root similar to MemoryCardRootPath
return PathInfo::PhoneMemoryRootPath();
break;
}
@@ -258,13 +255,13 @@ static void openDocumentL(const TDesC& aUrl)
// Apparc base method cannot be used to open app in embedded mode,
// but seems to be most stable way at the moment
RApaLsSession appArcSession;
- User::LeaveIfError( appArcSession.Connect() );
- CleanupClosePushL<RApaLsSession>( appArcSession );
+ User::LeaveIfError(appArcSession.Connect());
+ CleanupClosePushL<RApaLsSession>(appArcSession);
TThreadId id;
// ESwitchFiles means do not start another instance
// Leaves if file does not exist, leave is trapped in openDocument and false returned to user.
- User::LeaveIfError( appArcSession.StartDocument( aUrl, id,
- RApaLsSession::ESwitchFiles ) ); // ELaunchNewApp
+ User::LeaveIfError(appArcSession.StartDocument(aUrl, id,
+ RApaLsSession::ESwitchFiles)); // ELaunchNewApp
CleanupStack::PopAndDestroy(); // appArcSession
#else
// This is an alternative way to launch app associated to MIME type
@@ -306,8 +303,8 @@ static bool handleUrl(const QUrl &url)
static void handleUrlL(const TDesC& aUrl)
{
- CSchemeHandler* schemeHandler = CSchemeHandler::NewL( aUrl );
- CleanupStack::PushL( schemeHandler );
+ CSchemeHandler* schemeHandler = CSchemeHandler::NewL(aUrl);
+ CleanupStack::PushL(schemeHandler);
schemeHandler->HandleUrlStandaloneL(); // Process the Url in standalone mode
CleanupStack::PopAndDestroy();
}
@@ -351,7 +348,9 @@ QString QDesktopServices::storageLocation(StandardLocation type)
switch (type) {
case DesktopLocation:
- qWarning("QDesktopServices::storageLocation %d not implemented", type);
+ qWarning("No desktop concept in Symbian OS");
+ // But lets still use some feasible default
+ path.Append(writableDataRoot());
break;
case DocumentsLocation:
path.Append(writableDataRoot());
@@ -391,11 +390,17 @@ QString QDesktopServices::storageLocation(StandardLocation type)
//return QDir::homePath(); break;
break;
case DataLocation:
- CEikonEnv::Static()->FsSession().PrivatePath( path );
- // TODO: Should we actually return phone mem if data is on ROM?
- path.Insert( 0, exeDrive().Name() );
+ CEikonEnv::Static()->FsSession().PrivatePath(path);
+ path.Insert(0, writableExeDrive().Name());
break;
+ case CacheLocation:
+ CEikonEnv::Static()->FsSession().PrivatePath(path);
+ path.Insert(0, writableExeDrive().Name());
+ path.Append(KCacheSubDir);
+ break;
default:
+ // Lets use feasible default
+ path.Append(writableDataRoot());
break;
}