diff options
33 files changed, 790 insertions, 218 deletions
diff --git a/demos/embedded/desktopservices/contenttab.cpp b/demos/embedded/desktopservices/contenttab.cpp index 450a080..bdc5e03 100644 --- a/demos/embedded/desktopservices/contenttab.cpp +++ b/demos/embedded/desktopservices/contenttab.cpp @@ -41,6 +41,7 @@ // EXTERNAL INCLUDES #include <QKeyEvent> +#include <QMessageBox> #include <QListWidget> #include <QVBoxLayout> #include <QFileInfoList> @@ -135,10 +136,19 @@ void ContentTab::keyPressEvent(QKeyEvent *event) } } +void ContentTab::handleErrorInOpen(QListWidgetItem *item) +{ + Q_UNUSED(item); + QMessageBox::warning( this, tr("Operation Failed"), tr("Unkown error!"), QMessageBox::Close); +} + // NEW SLOTS void ContentTab::openItem(QListWidgetItem *item) { - QDesktopServices::openUrl(itemUrl(item)); + bool ret = QDesktopServices::openUrl(itemUrl(item)); + if(!ret) + handleErrorInOpen(item); } + // End of File diff --git a/demos/embedded/desktopservices/contenttab.h b/demos/embedded/desktopservices/contenttab.h index a5a402e..8d37209 100644 --- a/demos/embedded/desktopservices/contenttab.h +++ b/demos/embedded/desktopservices/contenttab.h @@ -83,7 +83,7 @@ protected: // New Methods virtual void populateListWidget(); virtual QString itemName(const QFileInfo &item); virtual QUrl itemUrl(QListWidgetItem *item); - + virtual void handleErrorInOpen(QListWidgetItem *item); protected: void keyPressEvent(QKeyEvent *event); diff --git a/demos/embedded/desktopservices/linktab.cpp b/demos/embedded/desktopservices/linktab.cpp index b4ab308..58d1cc6 100644 --- a/demos/embedded/desktopservices/linktab.cpp +++ b/demos/embedded/desktopservices/linktab.cpp @@ -41,6 +41,7 @@ // EXTERNAL INCLUDES #include <QUrl> +#include <QMessageBox> #include <QListWidgetItem> // INTERNAL INCLUDES @@ -75,5 +76,13 @@ QUrl LinkTab::itemUrl(QListWidgetItem *item) return QUrl(); } } +void LinkTab::handleErrorInOpen(QListWidgetItem *item) +{ + if(m_MailToItem == item) { + QMessageBox::warning( this, tr("Operation Failed"), tr("Please check that you have\ne-mail accunt defined"), QMessageBox::Close); + } else { + ContentTab::handleErrorInOpen(item); + } +} // End of file diff --git a/demos/embedded/desktopservices/linktab.h b/demos/embedded/desktopservices/linktab.h index 2ce1094..a9c9868 100644 --- a/demos/embedded/desktopservices/linktab.h +++ b/demos/embedded/desktopservices/linktab.h @@ -71,6 +71,7 @@ public: // Constructors & Destructors protected: // Derived Methods virtual void populateListWidget(); virtual QUrl itemUrl(QListWidgetItem *item); + virtual void handleErrorInOpen(QListWidgetItem *item); private: // Used variables QListWidgetItem *m_WebItem; diff --git a/demos/embedded/fluidlauncher/config_s60/config.xml b/demos/embedded/fluidlauncher/config_s60/config.xml index 0cde71b..1a9d397 100644 --- a/demos/embedded/fluidlauncher/config_s60/config.xml +++ b/demos/embedded/fluidlauncher/config_s60/config.xml @@ -12,6 +12,7 @@ <example filename="desktopservices_s60" name="Desktop Services" image="screenshots/desktopservices_s60.png"/> <example filename="fridgemagnets_s60" name="Fridge Magnets" image="screenshots/fridgemagnets_s60.png" args="-small-screen"/> <example filename="drilldown_s60" name="Drilldown" image="screenshots/drilldown_s60.png"/> + <example filename="softkeys" name="Softkeys" image="screenshots/softkeys.png"/> </demos> <slideshow timeout="60000" interval="10000"> <imagedir dir="slides"/> diff --git a/demos/embedded/fluidlauncher/fluidlauncher.pro b/demos/embedded/fluidlauncher/fluidlauncher.pro index 9c08801..341b321 100644 --- a/demos/embedded/fluidlauncher/fluidlauncher.pro +++ b/demos/embedded/fluidlauncher/fluidlauncher.pro @@ -71,10 +71,11 @@ symbian { saxbookmarks.exe \ desktopservices.exe \ fridgemagnets.exe \ - drilldown.exe + drilldown.exe \ + softkeys.exe executables.path = /sys/bin - + reg_resource.sources = \ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/embeddedsvgviewer_reg.rsc \ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/styledemo_reg.rsc \ @@ -83,14 +84,15 @@ symbian { $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/wiggly_reg.rsc \ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/ftp_reg.rsc\ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/context2d_reg.rsc \ - $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/saxbookmarks_reg.rsc \ + $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/saxbookmarks_reg.rsc \ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/desktopservices_reg.rsc \ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/fridgemagnets_reg.rsc \ - $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/drilldown_reg.rsc - + $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/drilldown_reg.rsc \ + $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/softkeys_reg.rsc + reg_resource.path = $$REG_RESOURCE_IMPORT_DIR - + resource.sources = \ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/embeddedsvgviewer.rsc \ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/styledemo.rsc \ @@ -102,10 +104,11 @@ symbian { $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/saxbookmarks.rsc \ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/desktopservices.rsc \ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/fridgemagnets.rsc \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/drilldown.rsc - + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/drilldown.rsc \ + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/softkeys.rsc + resource.path = $$APP_RESOURCE_DIR - + mifs.sources = \ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000C611.mif mifs.path = $$APP_RESOURCE_DIR @@ -131,7 +134,7 @@ symbian { saxbookmarks.sources += $$PWD/../../../examples/xml/saxbookmarks/jennifer.xbel saxbookmarks.path = /data/qt/saxbookmarks - DEPLOYMENT += config files executables viewerimages saxbookmarks reg_resource resource \ + DEPLOYMENT += config files executables viewerimages saxbookmarks reg_resource resource \ mifs desktopservices_music desktopservices_images TARGET.EPOCHEAPSIZE = 100000 20000000 diff --git a/demos/embedded/fluidlauncher/screenshots/softkeys.png b/demos/embedded/fluidlauncher/screenshots/softkeys.png Binary files differnew file mode 100644 index 0000000..99681b9 --- /dev/null +++ b/demos/embedded/fluidlauncher/screenshots/softkeys.png diff --git a/dist/changes-4.5.2-tower b/dist/changes-4.5.2-tower index 1a039ba..41dc8c8 100644 --- a/dist/changes-4.5.2-tower +++ b/dist/changes-4.5.2-tower @@ -28,12 +28,16 @@ New modules ----------- - QtSql - * todo + * Implemented QtSql module with sqlite3 backend. For now backend is + provided only in binary format. - QtWebkit - * todo + * Experimental webkit build for s60. Can be enabled by passing -webkit to configure. - Phonon - * todo - + * The Phonon library is now part of Qt, but it comes without a backend. + This means that applications can build and run against the Phonon + library, but there is currently no S60 backend plugin providing actual + multimedia playback. Possible alternatives such as Helix and MMF are + being investigated. New classes ------------ @@ -44,58 +48,243 @@ New classes Ported classes -------------- -- todo - * todo +- QSound + * Implemented CMdaAudioPlayerUtility based Symbian backend for QSound. +- QLocalSocket and QLocalServer + * Added support for QLocalSocket and QLocalServer on Symbian Features -------- +- QApplication + * Implemented QApplication::beep() for Symbian +- QSslSocket + * Added support for -openssl option i.e. runtime resolving of OpenSSL + symbols - todo * todo Optimizations ------------- -- todo - * todo +- qdrawhelper + * Optimized drawing operations for RVCT builds, particulary for ARMV6. + +- qwidget_s60.cpp + * Avoid unnecessary calls to FocusChanged in Symbian + +**************************************************************************** +* Code clean-up * +**************************************************************************** + +- Cleanup qeventdispatcher_unix.cpp + * 247268: All qeventdispatcher_unix.cpp changes were reverted since, + this file is not anymore used in Symbian OS branch. +- Cleanup QtNetwork workarounds implemented earlier due to Open C bugs. + * 247287: Removed getaddrinfo workaround + * 247288: Removed waitForConnected workaround + * 247289: Removed qt_socket_accept workaround + * 247290: Removed qt_socket_connect workaround + * 247290: Removed E32IONREAD workaround + * 247293: Removed nativeHasPendingDatagrams workaround + * 247295: Removed QNativeSocketEnginePrivate::nativeRead EPIPE + workaround +- Other code clean-ups + * 247278: Removed unnecessary includes from qbackingstore.cpp. + * Fixed Q_OS_SYMBIAN ifdef usage in qfiledialog_p.h + * 247272: Removed qtestnetworkservers.h dependency, used + network-settings.h + * Revert "Work around compiler bug on Nokia Metrowerks compiler." + * Remove UI highlights being inverted colors based on highlight text colors. + **************************************************************************** * Build issues * **************************************************************************** -- todo +- QTest + * Fixed testlib export macros for RVCT builds. +- namespaces + * Now builds when -qtnamespace option is defined **************************************************************************** * Changes to existing classes * **************************************************************************** -- todo - * todo +- QDesktopServices + * Fixed forwardslash/backslash usage as an path separator + +- QPluginLoader + * QPluginLoader will look for plugin stubs from the same folder on other + drives if it can't find them from the indicated drive. + +- QEventDispatcher + * Lowered the timeout for reprioritizing the process to 100ms + +- QNetworkInterface + * Fixed R-handle leak in Symbian version of qnetworkinterface_unix.cpp + * Introduced a new qnetworkinterface_symbian.cpp, because there wasn't + really anything common to UNIX equivalent + +- QHostInfo + * Added support for host lookups with multiple ipv4 addresses. + +- QUdpSocket + * Updated BindFlag documentation to reflect behaviour on Symbian OS + +- QLocale + * Removed workaround for missing tzname symbol, fixes QLocal timeZone + implementation for Symbian. + +- QTemporaryFile + * Fixed temporary file rename in Symbian OS. + +- QThread + * Fix for thread termination in Symbian OS. + +- QIoDevice + * Fixed compilation error when QIODEVICE_DEBUG is defined. + +- QS60Style + * Added subElementRect implementation for SE_ItemViewItemCheckIndicator. + * Added support for E90 layouts. + * Added support for QScrollArea, QTextEditor, QGroupBox, QTreeView, QToolBar and QDial styling. + * Better support for theme and layout changes. + * Better support for themed palettes and themed text colors. + * Better support for multiselection in item views. + * Better theming for QTable and QPanel. + * Better support of highlight graphics and texts for QLists, QTreeViews, QCalendarWidgets and QComboBoxes. + * Support polishing fonts. Fonts are no longer changed within the drawing code. + * Draw spinbox arrowbuttons side-by-side, instead one on top of the other. + * Harmonize widget drawing so that widgets are of similar height. + * Support check states for QLists and QPushButtons. + * Support flat QPushButtons. + * Support busy indicator. + * Support QScrollBar pressed state. + * Support QPushButton disabled theme graphics. + * Separate theme background for QDialogs. + * Clarify QToolButton pressed state. + * Removed linedrawing of panels and groupboxes. + * Fix palette-polution for a style that is activated from an application after S60Style has been in use. + * Fix for frame masks with color depth other than EGrey2. + * Fix for squeezed QTabBars. + * Fix memory leak when color skinning graphics. + +- QDesktopServices + * Switched QDesktopServices mail-to URL handling to RSendAs in Symbian, + due to the fact that CSendUi requires extensive capabilities to work + correctly. Currently e-mail sending with qdesktopservices::openUrl + works in Symbian only if e-mail account already exists. + +- QCoeFepInputContext (non-public) + * Fixes FEP crash when changing the focused Qt widget to NULL. + +- QApplication + * 252798: Fixed layout when orientation changed via + AknAppUi::SetOrientationL. + * Generating MouseEvents has gone through several changes + +- QUdpSocket + * Wrote hack for QUdpSocket::writeDatagram return value in Symbian OS. + +- QNativeSocketEnginePrivate (non-public) + * Changed select to listen also expectfds in Symbain OS for given + sockets (Workaround to Open C bug). + * Fix to Open C bug: Socket connect failure is indicated exception set. + +- QEventDispatcherSymbian (non-public) + * Fixed ASSERT panic in Symbian event dispatcher + * 246600: Fix problem in eventdispatcher destructor / AO canceling + * Fixed active scheduler removal when calling QThread::terminate + * Fix to Open C bug: select sometimes returns -1 and errno is + ECONNREFUSED **************************************************************************** * Examples and demos * **************************************************************************** +- Drilldown + * Added to demonstrate QtSql usage in Symbian OS + +- Deform, Pathstroke, and Wiggly + * Removed Symbian specific animation timer fixes since more generic + fix was made to event dispatcher. + +- Ftp + * Enabled default iap setting for FTP example + +- DesktopServices + * Implemented content filters for desktopservices example. + * Added error handling to qdesktopservices example when openUrl fails. + +- SecureSocketClient + * Fixed build issue caused by lack of cursor. + +- Fluidlauncher + * Removed ugly workaround to make emulator deployment work correctly, + since the issue has been fixed in qmake. + * Included drilldown to demonstrate QtSql usage + * Updated screenshots to S60 style -- todo - * todo **************************************************************************** * Tools * **************************************************************************** -- todo - * todo +- qmake + * Support for generating Symbian "test" targets: CONFIG += symbian_test. + * Support for Symbian Build System, version 2 (aka Raptor) via + symbian-sbsv2 mkspec. + * PAGED keyword is added to all MMP files by default, except in S60 3.1 + builds. + * Read-only flag is no longer preserved when deploying files into + emulator environment. + * Changed the timestamp to ISO format in all files generated + by qmake for symbian-* mkspecs. + * Qt's VERSION variable will now generate VERSION keyword in mmp files. + * Made Open C include paths handling bit more robust. + +- configure + * -cetest is no longer a supported switch for configure. + * -stl option is enabled by default for Symbian OS + * -openssl option is enabled by default for Symbian OS. + * -fpu option enables vfpu type selection for ARM targets. + +- Release package creation + * Removed the obsolete script to create release package. + +- Createpackage script + * Now creates packages with .sis suffix. + +- Patch_capabilities script + * Will now patch also vendor id. + +**************************************************************************** +* Documnetation * +**************************************************************************** +- qmake-manual + * 250370: Added documentation for ICON keyword **************************************************************************** * Plugins * **************************************************************************** -- todo - * todo +- S60 version specific plugins + * Isolated S60 version dependent functionality to S60 version specific + plugins (qts60plugin_x_y.dll) to make it possible for single build to + run on any supported device, even if with reduced functionality on + some. + **************************************************************************** * Important Behavior Changes * **************************************************************************** +- Qt libs + * Qt libs are now built with "All -Tcb" capabilities always. It is now + always necessary to run patch_capabilities.pl script if self-signing + of Qt libs is desired. + * QtCore and QtSql made UNPAGED as workaround for an obscure crash + when they are paged. + - todo * todo diff --git a/doc/src/platform-notes.qdoc b/doc/src/platform-notes.qdoc index 63b721a..53db855 100644 --- a/doc/src/platform-notes.qdoc +++ b/doc/src/platform-notes.qdoc @@ -521,7 +521,7 @@ supported by Qt can be found on the \l{Supported Platforms} page. For information about mixing exceptions with symbian leaves, - see \l QSymbianLeaveException. + see \l{Exception Safety with Symbian} */ /*! diff --git a/doc/src/symbian-exceptionsafety.qdoc b/doc/src/symbian-exceptionsafety.qdoc index 212f707..e42ecd1 100644 --- a/doc/src/symbian-exceptionsafety.qdoc +++ b/doc/src/symbian-exceptionsafety.qdoc @@ -80,11 +80,11 @@ Symbian leaves to standard C++ exceptions. The following help is provided: \list - \o \l qt_translateSymbianErrorToException(int error) takes a Symbian + \o \l qt_translateSymbianErrorToException() takes a Symbian error code and throws an appropriate exception to represent it. This will do nothing if the error code is not in fact an error. The function is equivalent to Symbian's \c User::LeaveIfError. - \o \l QT_TRANSLATE_SYMBIAN_LEAVE_TO_EXCEPTION(f) takes a Symbian leaving + \o \l QT_TRANSLATE_SYMBIAN_LEAVE_TO_EXCEPTION() takes a Symbian leaving code fragment f and runs it under a trap harness converting any resulting error into an exception. \o \c TRAP and \c TRAPD from the Symbian libraries can be used to convert @@ -113,18 +113,18 @@ provided: \list - \o \l qt_translateExceptionToSymbianError(const std::exception& ex) - + \o \l qt_translateExceptionToSymbianError() - this takes a standard exception and gives an appropriate Symbian error code. If no mapping is known for the exception type, \c KErrGeneral is returned. - \o \l qt_translateExceptionToSymbianErrorL(const std::exception& ex) - + \o \l qt_translateExceptionToSymbianErrorL() - this takes a standard exception and generates an appropriate Symbian leave. - \o \l QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_ERROR(err, f) - this macro + \o \l QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_ERROR() - this macro takes the standard C++ code fragment \c f, catches any std::exceptions thrown from it, and sets err to the corresponding Symbian error code. err is set to \c KErrNone otherwise. - \o \l QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE(f) - this macro takes the + \o \l QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE() - this macro takes the standard C++ code fragment \c f, catches any std::exceptions thrown from it, and throws a corresponding Symbian leave. \endlist @@ -164,9 +164,8 @@ it's dealing with strings it probably does, again bad. Line 4 is tricky, it calls a leaving function which is ok within a \c TRAP, - but it also uses \l qt_QString2TPtrC. You might think this is safe, but - there is a potential realloc call in there, so this can cause an unwelcome - exception. + but it also uses a helper function to convert string types. In this case + the helper function may cause an unwelcome exception. We could rewrite this with nested exception translations, but it's much easier to refactor it. diff --git a/doc/src/topics.qdoc b/doc/src/topics.qdoc index 6ef3a89..09a86bd 100644 --- a/doc/src/topics.qdoc +++ b/doc/src/topics.qdoc @@ -300,3 +300,14 @@ including ARM, Intel x86, MIPS and SH-4. \endlist \endtable */ + +/*! +\group qts60 +\title Qt for S60 +\ingroup topics +\brief Documents related to Qt for S60 + +\list + \o \l {Exception Safety with Symbian} +\endlist +*/ diff --git a/examples/network/ftp/ftp.pro b/examples/network/ftp/ftp.pro index b958f6a..0fb9934 100644 --- a/examples/network/ftp/ftp.pro +++ b/examples/network/ftp/ftp.pro @@ -15,5 +15,5 @@ include($$QT_SOURCE_TREE/examples/examplebase.pri) symbian { TARGET.CAPABILITY="NetworkServices" TARGET.UID3 = 0xA000A648 - LIBS+=-lesock # For IAP selection + LIBS+=-lesock -lconnmon # For IAP selection }
\ No newline at end of file diff --git a/examples/network/ftp/main.cpp b/examples/network/ftp/main.cpp index a92a8b2..118dcfc 100644 --- a/examples/network/ftp/main.cpp +++ b/examples/network/ftp/main.cpp @@ -48,32 +48,82 @@ #include <es_sock.h> #include <sys/socket.h> +#include <rconnmon.h> #include <net/if.h> -static void setDefaultIapL() -{ - TInt err = KErrNone; - RSocketServ serv; - CleanupClosePushL(serv); - User::LeaveIfError(serv.Connect()); +QString qt_TDesC2QStringL(const TDesC& aDescriptor) { +#ifdef QT_NO_UNICODE + return QString::fromLocal8Bit(aDescriptor.Ptr(), aDescriptor.Length()); +#else + return QString::fromUtf16(aDescriptor.Ptr(), aDescriptor.Length()); +#endif +} - RConnection conn; - CleanupClosePushL(conn); - User::LeaveIfError(conn.Open(serv)); - User::LeaveIfError(conn.Start()); - - _LIT(KIapNameSetting, "IAP\\Name"); - TBuf8<50> iapName; - User::LeaveIfError(conn.GetDesSetting(TPtrC(KIapNameSetting), iapName)); - iapName.ZeroTerminate(); - - conn.Stop(); - CleanupStack::PopAndDestroy(&conn); - CleanupStack::PopAndDestroy(&serv); +static void setDefaultIapL() { + RConnectionMonitor monitor; + CleanupClosePushL(monitor); + monitor.ConnectL(); + TUint count; + TRequestStatus status; + TUint ids[ 15 ]; - struct ifreq ifReq; - strcpy( ifReq.ifr_name, (char*)iapName.Ptr()); - User::LeaveIfError(setdefaultif( &ifReq )); + monitor.GetConnectionCount( count, status ); + User::WaitForRequest( status ); + if(status.Int() != KErrNone) { + User::Leave(status.Int()); + } + + TUint numSubConnections; + + if(count > 0) { + for ( TInt i = 1; i <= count; i++ ) { + User::LeaveIfError(monitor.GetConnectionInfo( i, ids[ i-1 ], numSubConnections )); + } + /* + * get IAP value for first active connection + */ + TBuf< 50 > iapName; + monitor.GetStringAttribute( ids[ 0 ], 0, KIAPName, iapName, status ); + User::WaitForRequest( status ); + if ( status.Int() != KErrNone ) { + User::Leave(status.Int()); + } else { + QString strIapName = qt_TDesC2QStringL(iapName); + struct ifreq ifReq; + strcpy( ifReq.ifr_name, strIapName.toLatin1().data()); + User::LeaveIfError(setdefaultif( &ifReq )); + } + } else { + /* + * no active connections yet + * use IAP dialog to select one + */ + RSocketServ serv; + CleanupClosePushL(serv); + User::LeaveIfError(serv.Connect()); + + RConnection conn; + CleanupClosePushL(conn); + User::LeaveIfError(conn.Open(serv)); + User::LeaveIfError(conn.Start()); + + _LIT(KIapNameSetting, "IAP\\Name"); + TBuf8<50> iap8Name; + User::LeaveIfError(conn.GetDesSetting(TPtrC(KIapNameSetting), iap8Name)); + iap8Name.ZeroTerminate(); + + struct ifreq ifReq; + strcpy( ifReq.ifr_name, (char*)iap8Name.Ptr()); + User::LeaveIfError(setdefaultif( &ifReq )); + + conn.Stop(); + conn.Close(); + serv.Close(); + CleanupStack::PopAndDestroy(&conn); + CleanupStack::PopAndDestroy(&serv); + } + monitor.Close(); + CleanupStack::PopAndDestroy(&monitor); } static int setDefaultIap() @@ -86,13 +136,12 @@ static int setDefaultIap() int main(int argc, char *argv[]) { Q_INIT_RESOURCE(ftp); - #ifdef Q_OS_SYMBIAN setDefaultIap(); // Change current directory from default private to c:\data // in order that user can access the downloaded content QDir::setCurrent( "c:\\data" ); -#endif +#endif QApplication app(argc, argv); FtpWindow ftpWin; #ifdef Q_OS_SYMBIAN @@ -100,6 +149,6 @@ int main(int argc, char *argv[]) ftpWin.showMaximized(); #else ftpWin.show(); -#endif +#endif return ftpWin.exec(); } diff --git a/examples/widgets/softkeys/softkeys.cpp b/examples/widgets/softkeys/softkeys.cpp index 87d11c9..9672aee 100644 --- a/examples/widgets/softkeys/softkeys.cpp +++ b/examples/widgets/softkeys/softkeys.cpp @@ -42,33 +42,73 @@ #include "softkeys.h" MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) + : QMainWindow(parent) { central = new QWidget(this); + central->setContextMenuPolicy(Qt::NoContextMenu); // explicitly forbid usage of context menu so actions item is not shown menu setCentralWidget(central); - infoLabel = new QLabel(tr("Funky stuff in menu!")); + + // Create text editor and set softkeys to it + textEditor= new QTextEdit(tr("Choose items from menu or navigate around with tab+selection to see what softkeys can do"), this); + QAction* fill = new QAction(tr("Fill"), this); + fill->setSoftKeyRole(QAction::OkSoftKey); + QAction* clear = new QAction(tr("Clear"), this); + clear->setSoftKeyRole(QAction::CancelSoftKey); + + QList<QAction*> textEditorSoftKeys; + textEditorSoftKeys.append(fill); + textEditorSoftKeys.append(clear); + textEditor->setSoftKeys(textEditorSoftKeys); + + infoLabel = new QLabel(tr(""), this); + infoLabel->setContextMenuPolicy(Qt::NoContextMenu); + + pushButton = new QPushButton(tr("Open File Dialog"), this); + pushButton->setContextMenuPolicy(Qt::NoContextMenu); + + QComboBox* comboBox = new QComboBox(this); + comboBox->setContextMenuPolicy(Qt::NoContextMenu); + comboBox->insertItems(0, QStringList() + << QApplication::translate("MainWindow", "Selection1", 0, QApplication::UnicodeUTF8) + << QApplication::translate("MainWindow", "Selection2", 0, QApplication::UnicodeUTF8) + << QApplication::translate("MainWindow", "Selection3", 0, QApplication::UnicodeUTF8) + ); layout = new QVBoxLayout; + layout->addWidget(textEditor); layout->addWidget(infoLabel); + layout->addWidget(pushButton); + layout->addWidget(comboBox); central->setLayout(layout); - central->setFocusPolicy(Qt::TabFocus); - + fileMenu = menuBar()->addMenu(tr("&File")); - openDialogAct = new QAction(tr("&Open Dialog"), this); addSoftKeysAct = new QAction(tr("&Add Softkeys"), this); - clearSoftKeysAct = new QAction(tr("&Clear Softkeys"), this); - fileMenu->addAction(openDialogAct); fileMenu->addAction(addSoftKeysAct); - fileMenu->addAction(clearSoftKeysAct); - connect(openDialogAct, SIGNAL(triggered()), this, SLOT(openDialog())); - connect(addSoftKeysAct, SIGNAL(triggered()), this, SLOT(addSoftKeys())); - connect(clearSoftKeysAct, SIGNAL(triggered()), this, SLOT(clearSoftKeys())); + exit = new QAction(tr("&Exit"), this); + fileMenu->addAction(exit); + + connect(fill, SIGNAL(triggered()), this, SLOT(fillTextEditor())); + connect(clear, SIGNAL(triggered()), this, SLOT(clearTextEditor())); + connect(pushButton, SIGNAL(clicked()), this, SLOT(openDialog())); + connect(addSoftKeysAct, SIGNAL(triggered()), this, SLOT(addSoftKeys())); + connect(exit, SIGNAL(triggered()), this, SLOT(exitApplication())); + pushButton->setFocus(); } MainWindow::~MainWindow() { } +void MainWindow::fillTextEditor() +{ + textEditor->setText(tr("The fill softkey was pressed and here is some text to fill the editor")); +} + +void MainWindow::clearTextEditor() +{ + textEditor->setText(tr("")); +} + void MainWindow::openDialog() { QFileDialog::getOpenFileName(this); @@ -78,33 +118,34 @@ void MainWindow::addSoftKeys() { ok = new QAction(tr("Ok"), this); ok->setSoftKeyRole(QAction::OkSoftKey); - connect(ok, SIGNAL(triggered()), this, SLOT(okPressed())); - + connect(ok, SIGNAL(triggered()), this, SLOT(okPressed())); + cancel = new QAction(tr("Cancel"), this); cancel->setSoftKeyRole(QAction::OkSoftKey); - connect(cancel, SIGNAL(triggered()), this, SLOT(cancelPressed())); + connect(cancel, SIGNAL(triggered()), this, SLOT(cancelPressed())); QList<QAction*> softkeys; softkeys.append(ok); softkeys.append(cancel); - central->setSoftKeys(softkeys); - central->setFocus(); - + pushButton->setSoftKeys(softkeys); } -void MainWindow::clearSoftKeys() +void MainWindow::exitApplication() { - central->setSoftKey(0); + qApp->exit(); } void MainWindow::okPressed() { infoLabel->setText(tr("OK pressed")); - central->setSoftKey(0); + pushButton->setSoftKey(0); } void MainWindow::cancelPressed() { infoLabel->setText(tr("Cancel pressed")); - central->setSoftKey(0); + pushButton->setSoftKey(0); } + + + diff --git a/examples/widgets/softkeys/softkeys.h b/examples/widgets/softkeys/softkeys.h index 11db419..bd75473 100644 --- a/examples/widgets/softkeys/softkeys.h +++ b/examples/widgets/softkeys/softkeys.h @@ -48,24 +48,27 @@ class MainWindow : public QMainWindow { Q_OBJECT public: - + private slots: + void fillTextEditor(); + void clearTextEditor(); void openDialog(); void addSoftKeys(); - void clearSoftKeys(); + void exitApplication(); void okPressed(); void cancelPressed(); public: - MainWindow(QWidget *parent = 0); + MainWindow(QWidget *parent = 0); ~MainWindow(); private: QVBoxLayout *layout; QWidget *central; + QTextEdit* textEditor; QLabel *infoLabel; + QPushButton* pushButton; QMenu* fileMenu; - QAction* openDialogAct; QAction* addSoftKeysAct; - QAction* clearSoftKeysAct; + QAction* exit; QAction* ok; QAction* cancel; }; diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index 663a1df..7b78033 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -62,8 +62,8 @@ QMAKE_LFLAGS_DLL = -shared QMAKE_LINK_OBJECT_MAX = 10 QMAKE_LINK_OBJECT_SCRIPT= object_script -QMAKE_DESKTOPSERVICES_LIBS = -lsendas2 -lplatformenv -lcommonui -letext -lapmime -QMAKE_STATUSPANE_LIBS = -lavkon -leikcoctl +QMAKE_DESKTOPSERVICES_LIBS = -lsendas2 -lsendui -lplatformenv -lcommonui -letext -lapmime +QMAKE_STATUSPANE_LIBS = -lavkon -leikcoctl QMAKE_LIBS = -llibc -llibm -leuser -llibdl QMAKE_LIBS_CORE = $$QMAKE_LIBS -llibpthread -lefsrv diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 6590ea6..88f845a 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1929,6 +1929,7 @@ void qt_check_pointer(const char *n, int l) qWarning("In file %s, line %d: Out of memory", n, l); } +#ifndef QT_NO_EXCEPTIONS /* \internal Allows you to throw an exception without including <new> Called internally from Q_CHECK_PTR on certain OS combinations @@ -1937,6 +1938,7 @@ void qBadAlloc() { QT_THROW(std::bad_alloc()); } +#endif /* The Q_ASSERT macro calls this function when the test fails. @@ -3215,7 +3217,8 @@ bool QInternal::callFunction(InternalFunction func, void **args) #include <typeinfo> /*! \macro QT_TRANSLATE_SYMBIAN_LEAVE_TO_EXCEPTION(function) - \relates QSymbianLeaveException + \relates <QtGlobal> + \ingroup qts60 TRAP leaves from Symbian \a function and throws an appropriate standard C++ exception instead. @@ -3241,7 +3244,7 @@ bool QInternal::callFunction(InternalFunction func, void **args) */ /*! \macro QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_ERROR(error, function) - \relates QSymbianLeaveException + \relates <QtGlobal> \ingroup qts60 Catch standard C++ exceptions from a \a function and convert them to a Symbian OS @@ -3272,7 +3275,7 @@ bool QInternal::callFunction(InternalFunction func, void **args) */ /*! \macro QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE(function) - \relates QSymbianLeaveException + \relates <QtGlobal> \ingroup qts60 Catch standard C++ exceptions from \a function and convert them to Symbian OS @@ -3298,37 +3301,22 @@ bool QInternal::callFunction(InternalFunction func, void **args) \sa QT_TRANSLATE_SYMBIAN_LEAVE_TO_EXCEPTION(), QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_ERROR() */ -/*! \class QSymbianLeaveException - \ingroup qts60 - \brief The QSymbianLeaveException class represents a block of Symbian leave code. - - \warning This class is only available on Symbian. -*/ - -/*! \fn QSymbianLeaveException::QSymbianLeaveException(int error) +#include <stdexcept> - Constructs a QSymbianLeaveException object that stores the given - Symbian \a error code. -*/ - -/*! \fn const char *QSymbianLeaveException::what() const - - Returns a C-style character string describing the general - cause of the current error. - - The string is not localized. -*/ -const char *QSymbianLeaveException::what() const throw() +class QSymbianLeaveException : public std::exception { - static char msg[36]; - snprintf(msg, sizeof(msg), "Symbian leave exception %d", error); - return msg; -} +public: + inline QSymbianLeaveException(int err) : error(err) {} + inline const char* what() const throw() { return "Symbian leave exception"; } + +public: + int error; +}; -/*! \relates QSymbianLeaveException +/*! \relates <QtGlobal> \ingroup qts60 - Throws a QSymbianLeaveException if the \a error parameter is a symbian error code. + Throws an exception if the \a error parameter is a symbian error code. This is the exception throwing equivalent of Symbian's User::LeaveIfError. \warning This function is only available on Symbian. @@ -3347,7 +3335,7 @@ void qt_translateSymbianErrorToException(int error) } } -/*! \relates QSymbianLeaveException +/*! \relates <QtGlobal> \ingroup qts60 Convert a caught standard C++ exception \a aThrow to a Symbian leave @@ -3361,7 +3349,7 @@ void qt_translateExceptionToSymbianErrorL(const std::exception& aThrow) User::Leave(qt_translateExceptionToSymbianError(aThrow)); } -/*! \relates QSymbianLeaveException +/*! \relates <QtGlobal> \ingroup qts60 Convert a caught standard C++ exception \a aThrow to a Symbian error code diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 450fd86..361c038 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1605,7 +1605,10 @@ Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char * #endif Q_CORE_EXPORT void qt_check_pointer(const char *, int); + +#ifndef QT_NO_EXCEPTIONS Q_CORE_EXPORT void qBadAlloc(); +#endif #ifdef QT_NO_EXCEPTIONS # if defined(QT_NO_DEBUG) @@ -2312,16 +2315,8 @@ QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf(); #if defined(Q_OS_SYMBIAN) -#include <stdexcept> - -class QSymbianLeaveException : public std::exception -{ -public: - inline QSymbianLeaveException(int err) : error(err) {} - const char* what() const throw(); -public: - int error; -}; +// forward declare std::exception +namespace std { class exception; } Q_CORE_EXPORT void qt_translateSymbianErrorToException(int error); Q_CORE_EXPORT void qt_translateExceptionToSymbianErrorL(const std::exception& ex); diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp index 0239575..6a1ffb6 100644 --- a/src/corelib/tools/qscopedpointer.cpp +++ b/src/corelib/tools/qscopedpointer.cpp @@ -134,6 +134,21 @@ */ /*! + \fn bool QScopedPointer::operator==(const QScopedPointer<T> &other) const + + Equality operator. Returns true if the scoped pointer \a other + is pointing to the same object as this pointer, otherwise returns false. +*/ + + +/*! + \fn bool QScopedPointer::operator!=(const QScopedPointer<T> *other) const + + Inequality operator. Returns true if the scoped pointer \a other + is not pointing to the same object as this pointer, otherwise returns false. +*/ + +/*! \fn bool QScopedPointer::isNull() const Returns \c true if this object is holding a pointer that is \c null. diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index 60d3034..9768162 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -487,6 +487,34 @@ void QFileDialog::changeEvent(QEvent *e) QDialog::changeEvent(e); } +QFileDialogPrivate::QFileDialogPrivate() + : +#ifndef QT_NO_PROXYMODEL + proxyModel(0), +#endif + model(0), + fileMode(QFileDialog::AnyFile), + acceptMode(QFileDialog::AcceptOpen), + currentHistoryLocation(-1), + renameAction(0), + deleteAction(0), + showHiddenAction(0), + useDefaultCaption(true), + defaultFileTypes(true), + fileNameLabelExplicitlySat(false), + nativeDialogInUse(false), +#ifdef Q_WS_MAC + mDelegate(0), +#ifndef QT_MAC_USE_COCOA + mDialog(0), + mDialogStarted(false), + mDialogClosed(true), +#endif +#endif + qFileDialogUi(0) +{ +} + QFileDialogPrivate::~QFileDialogPrivate() { } diff --git a/src/gui/dialogs/qfiledialog_p.h b/src/gui/dialogs/qfiledialog_p.h index 99f61f0..3195583 100644 --- a/src/gui/dialogs/qfiledialog_p.h +++ b/src/gui/dialogs/qfiledialog_p.h @@ -113,31 +113,7 @@ class Q_AUTOTEST_EXPORT QFileDialogPrivate : public QDialogPrivate Q_DECLARE_PUBLIC(QFileDialog) public: - QFileDialogPrivate() : -#ifndef QT_NO_PROXYMODEL - proxyModel(0), -#endif - model(0), - fileMode(QFileDialog::AnyFile), - acceptMode(QFileDialog::AcceptOpen), - currentHistoryLocation(-1), - renameAction(0), - deleteAction(0), - showHiddenAction(0), - useDefaultCaption(true), - defaultFileTypes(true), - fileNameLabelExplicitlySat(false), - nativeDialogInUse(false), -#ifdef Q_WS_MAC - mDelegate(0), -#ifndef QT_MAC_USE_COCOA - mDialog(0), - mDialogStarted(false), - mDialogClosed(true), -#endif -#endif - qFileDialogUi(0) - {} + QFileDialogPrivate(); void createToolButtons(); void createMenuActions(); diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp index 8528173..a16305e 100644 --- a/src/gui/image/qpicture.cpp +++ b/src/gui/image/qpicture.cpp @@ -1041,6 +1041,18 @@ QPicture& QPicture::operator=(const QPicture &p) /*! \internal + Constructs a QPicturePrivate +*/ +QPicturePrivate::QPicturePrivate() + : in_memory_only(false), + q_ptr(0) +{ + ref = 1; +} + +/*! + \internal + Sets formatOk to false and resets the format version numbers to default */ diff --git a/src/gui/image/qpicture_p.h b/src/gui/image/qpicture_p.h index e0c3117..373ff15 100644 --- a/src/gui/image/qpicture_p.h +++ b/src/gui/image/qpicture_p.h @@ -143,7 +143,7 @@ public: PdcReservedStop = 199 // for Qt }; - inline QPicturePrivate() : in_memory_only(false), q_ptr(0) { ref = 1; } + QPicturePrivate(); QAtomicInt ref; bool checkFormat(); diff --git a/src/gui/kernel/qaction.h b/src/gui/kernel/qaction.h index 8791a5c..dfa4933 100644 --- a/src/gui/kernel/qaction.h +++ b/src/gui/kernel/qaction.h @@ -94,7 +94,7 @@ public: enum SoftKeyRole { OptionsSoftKey, SelectSoftKey, BackSoftKey, NextSoftKey, PreviousSoftKey, OkSoftKey, CancelSoftKey, EditSoftKey, ViewSoftKey, BackSpaceSoftKey, EndEditSoftKey, RevertEditSoftKey, DeselectSoftKey, FinishSoftKey, - MenuSoftKey, ContextMenuSoftKey, Key1SoftKey, Key2SoftKey, + MenuSoftKey, ContextMenuSoftKey, ExitSoftKey, Key1SoftKey, Key2SoftKey, Key3SoftKey, Key4SoftKey, CustomSoftKey }; explicit QAction(QObject* parent); QAction(const QString &text, QObject* parent); diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index b33fe19..4c008fb 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -392,7 +392,7 @@ void QSymbianControl::HandlePointerEventL(const TPointerEvent& pEvent) alienWidget = S60->mousePressTarget; if (alienWidget != S60->lastPointerEventTarget) - if (type == QEvent::MouseButtonPress || QEvent::MouseButtonDblClick || type == QEvent::MouseMove) + if (type == QEvent::MouseButtonPress || type == QEvent::MouseButtonDblClick || type == QEvent::MouseMove) { //moved to another widget, create enter and leave events if (S60->lastPointerEventTarget) @@ -1088,6 +1088,9 @@ void QApplication::symbianResourceChange(int type) switch (type) { case KEikDynamicLayoutVariantSwitch: { + if (S60) + S60->updateScreenSize(); + #ifndef QT_NO_STYLE_S60 QS60Style *s60Style = 0; diff --git a/src/gui/kernel/qeventdispatcher_s60.cpp b/src/gui/kernel/qeventdispatcher_s60.cpp index fcf572e..51878df 100644 --- a/src/gui/kernel/qeventdispatcher_s60.cpp +++ b/src/gui/kernel/qeventdispatcher_s60.cpp @@ -70,12 +70,14 @@ bool QEventDispatcherS60::processEvents ( QEventLoop::ProcessEventsFlags flags ) m_noInputEvents = false; ret = sendDeferredInputEvents() || ret; } - + ret = QEventDispatcherSymbian::processEvents(flags) || ret; - + m_noInputEvents = oldNoInputEventsValue; } QT_CATCH (const std::exception& ex) { - CActiveScheduler::Current()->Error(qt_translateExceptionToSymbianError(ex)); +#ifndef QT_NO_EXCEPTIONS + CActiveScheduler::Current()->Error(qt_translateExceptionToSymbianError(ex)); +#endif } return ret; diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index 680bbaa..1edd466 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -731,7 +731,7 @@ private: friend class QGraphicsProxyWidget; friend class QGraphicsProxyWidgetPrivate; friend class QStyleSheetStyle; - friend class QWidgetExceptionCleaner; + friend struct QWidgetExceptionCleaner; #ifdef Q_WS_MAC friend class QCoreGraphicsPaintEnginePrivate; diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index 12dbc62..635218e 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -73,6 +73,24 @@ QT_BEGIN_NAMESPACE +struct QPainterPathPrivateHandler +{ + static inline void cleanup(QPainterPathPrivate *d) + { + // note - we must up-cast to QPainterPathData since QPainterPathPrivate + // has a non-virtual destructor! + if (d && !d->ref.deref()) + delete static_cast<QPainterPathData *>(d); + } + + static inline void reset(QPainterPathPrivate *&d, QPainterPathPrivate *other) + { + QPainterPathPrivate *oldD = d; + d = other; + cleanup(oldD); + } +}; + // This value is used to determine the length of control point vectors // when approximating arc segments as curves. The factor is multiplied // with the radius of the circle. diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h index 0513593..e12194e 100644 --- a/src/gui/painting/qpainterpath.h +++ b/src/gui/painting/qpainterpath.h @@ -57,6 +57,7 @@ QT_MODULE(Gui) class QFont; class QPainterPathPrivate; +struct QPainterPathPrivateHandler; class QPainterPathData; class QPainterPathStrokerPrivate; class QPolygonF; @@ -196,7 +197,7 @@ public: QPainterPath &operator-=(const QPainterPath &other); private: - QScopedSharedPointer<QPainterPathPrivate> d_ptr; + QScopedCustomPointer<QPainterPathPrivate, QPainterPathPrivateHandler> d_ptr; inline void ensureData() { if (!d_ptr) ensureData_helper(); } void ensureData_helper(); @@ -230,8 +231,7 @@ public: friend class QPainterPathStrokerPrivate; friend class QMatrix; friend class QTransform; - friend class QScopedSharedPointer<QPainterPathPrivate>; - friend class QScopedSharedPointerHandler<QPainterPathPrivate>; + friend struct QPainterPathPrivateHandler; #ifndef QT_NO_DATASTREAM friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPainterPath &); friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPainterPath &); diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 83f1698..d2bd679 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -559,7 +559,7 @@ void QS60StylePrivate::drawRow(QS60StyleEnums::SkinParts start, QRect endRect; if (orientation == Qt::Horizontal) { - startRect.setWidth(qMin(rect.width() >>1 - 1, startRect.width())); + startRect.setWidth(qMin((rect.width() >> 1) - 1, startRect.width())); endRect = startRect.translated(rect.width() - startRect.width(), 0); middleRect.adjust(startRect.width(), 0, -startRect.width(), 0); if (startRect.bottomRight().x() > endRect.topLeft().x()) { @@ -568,7 +568,7 @@ void QS60StylePrivate::drawRow(QS60StyleEnums::SkinParts start, endRect.adjust(overlap,0,0,0); } } else { - startRect.setHeight(qMin(rect.height() >>1 - 1, startRect.height())); + startRect.setHeight(qMin((rect.height() >> 1) - 1, startRect.height())); endRect = startRect.translated(0, rect.height() - startRect.height()); middleRect.adjust(0, startRect.height(), 0, -startRect.height()); if (startRect.topRight().y() > endRect.bottomLeft().y()) { @@ -1387,7 +1387,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); // draw the icon - const QIcon::Mode mode = !(voptAdj.state & QStyle::State_Enabled) ? QIcon::Normal : QIcon::Disabled; + const QIcon::Mode mode = (voptAdj.state & QStyle::State_Enabled) ? QIcon::Normal : QIcon::Disabled; const QIcon::State state = voptAdj.state & QStyle::State_Open ? QIcon::On : QIcon::Off; voptAdj.icon.paint(painter, iconRect, voptAdj.decorationAlignment, mode, state); @@ -2038,16 +2038,12 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti #endif //QT_NO_SPINBOX case PE_FrameFocusRect: // Calendar widget and combox both do not use styled itemDelegate - if ( widget && ( + if (widget && !(false #ifndef QT_NO_CALENDARWIDGET - (qobject_cast<const QCalendarWidget *>(widget->parent())) -#else - false + || qobject_cast<const QCalendarWidget *>(widget->parent()) #endif //QT_NO_CALENDARWIDGET #ifndef QT_NO_COMBOBOX - || (qobject_cast<const QComboBoxListView *>(widget)) -#else - || false + || qobject_cast<const QComboBoxListView *>(widget) #endif //QT_NO_COMBOBOX )) { // no focus selection for touch @@ -2326,6 +2322,7 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w break; case SH_UnderlineShortcut: retValue = 0; + break; default: break; } diff --git a/src/gui/util/qdesktopservices_s60.cpp b/src/gui/util/qdesktopservices_s60.cpp index d53c046..3588ec9 100644 --- a/src/gui/util/qdesktopservices_s60.cpp +++ b/src/gui/util/qdesktopservices_s60.cpp @@ -89,38 +89,51 @@ static void handleMailtoSchemeL(const QUrl &url) User::LeaveIfError(sendAs.Connect()); CleanupClosePushL(sendAs); - RSendAsMessage sendAsMessage; - sendAsMessage.CreateL(sendAs, KUidMsgTypeSMTP); - CleanupClosePushL(sendAsMessage); - - - // Subject - sendAsMessage.SetSubjectL(qt_QString2TPtrC(subject)); - - // Body - sendAsMessage.SetBodyTextL(qt_QString2TPtrC(body)); - - // To - foreach(QString item, recipients) - sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientTo ); - - foreach(QString item, tos) - sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientTo ); - - // Cc - foreach(QString item, ccs) - sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientCc ); - - // Bcc - foreach(QString item, bccs) - sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientBcc ); - - // send the message - sendAsMessage.LaunchEditorAndCloseL(); - - // sendAsMessage (already closed) - CleanupStack::Pop(); + CSendAsAccounts* accounts = CSendAsAccounts::NewL(); + CleanupStack::PushL(accounts); + sendAs.AvailableAccountsL(KUidMsgTypeSMTP, *accounts); + TInt count = accounts->Count(); + CleanupStack::PopAndDestroy(accounts); + + if(!count) { + // TODO: 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); + } else { + RSendAsMessage sendAsMessage; + sendAsMessage.CreateL(sendAs, KUidMsgTypeSMTP); + CleanupClosePushL(sendAsMessage); + + + // Subject + sendAsMessage.SetSubjectL(qt_QString2TPtrC(subject)); + + // Body + sendAsMessage.SetBodyTextL(qt_QString2TPtrC(body)); + + // To + foreach(QString item, recipients) + sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientTo ); + + foreach(QString item, tos) + sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientTo ); + + // Cc + foreach(QString item, ccs) + sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientCc ); + + // Bcc + foreach(QString item, bccs) + sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientBcc ); + + // send the message + sendAsMessage.LaunchEditorAndCloseL(); + + // sendAsMessage (already closed) + CleanupStack::Pop(); + } // sendAs CleanupStack::PopAndDestroy(); } diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index c7b117e..69ce981 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -74,7 +74,7 @@ struct SymbianMenuItem static QList<SymbianMenuItem*> symbianMenus; static QList<QMenuBar*> nativeMenuBars; static uint qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM; -static QWidget* widgetWithContextMenu=0; +static QPointer<QWidget> widgetWithContextMenu; static QList<QAction*> contextMenuActionList; static QAction contextAction(0); static int contexMenuCommand=0; @@ -254,7 +254,7 @@ Q_GUI_EXPORT void qt_symbian_show_submenu( CEikMenuPane* menuPane, int id) void QMenuBarPrivate::symbianCommands(int command) { - if (command == contexMenuCommand) { + if (command == contexMenuCommand && !widgetWithContextMenu.isNull()) { QContextMenuEvent* event = new QContextMenuEvent(QContextMenuEvent::Keyboard, QPoint(0,0)); QCoreApplication::postEvent(widgetWithContextMenu, event); } @@ -303,7 +303,7 @@ QMenuBarPrivate::QSymbianMenuBarPrivate::~QSymbianMenuBarPrivate() deleteAll( &symbianMenus ); symbianMenus.clear(); d = 0; - rebuild(); + rebuild(); } QMenuPrivate::QSymbianMenuPrivate::QSymbianMenuPrivate() @@ -393,7 +393,7 @@ void QMenuBarPrivate::QSymbianMenuBarPrivate::insertNativeMenuItems(const QList< symbianActionTopLevel->parent = 0; symbianActionTopLevel->command = qt_symbian_menu_static_cmd_id++; qt_symbian_insert_action(symbianActionTopLevel, &symbianMenus); - } + } } @@ -409,11 +409,10 @@ void QMenuBarPrivate::QSymbianMenuBarPrivate::rebuild() contextMenuActionList.clear(); if (widgetWithContextMenu) { contexMenuCommand = qt_symbian_menu_static_cmd_id; - contextAction.setText(QString("Actions")); + contextAction.setText(QMenuBar::tr("Actions")); contextMenuActionList.append(&contextAction); insertNativeMenuItems(contextMenuActionList); } - } QT_END_NAMESPACE diff --git a/tests/auto/symbian/qmainexceptions/tst_qmainexceptions.cpp b/tests/auto/symbian/qmainexceptions/tst_qmainexceptions.cpp index 103dd62..adad544 100644 --- a/tests/auto/symbian/qmainexceptions/tst_qmainexceptions.cpp +++ b/tests/auto/symbian/qmainexceptions/tst_qmainexceptions.cpp @@ -40,21 +40,38 @@ ****************************************************************************/ #include <QtTest/QtTest> +#include <e32base.h> #ifdef Q_OS_SYMBIAN +typedef void TLeavingFunc(); + class tst_qmainexceptions : public QObject { Q_OBJECT public: tst_qmainexceptions(){}; ~tst_qmainexceptions(){}; + + void TestSchedulerCatchesError(TLeavingFunc* f, int error); + void TestSymbianRoundTrip(int leave, int trap); + + bool event(QEvent *event); + public slots: void initTestCase(); private slots: void trap(); void cleanupstack(); void leave(); + void testTranslateBadAlloc(); + void testTranslateBigAlloc(); + void testRoundTrip(); + void testTrap(); + void testPropagation(); + void testDtor1(); + void testDtor2(); + void testNestedExceptions(); }; class CDummy : public CBase @@ -84,6 +101,7 @@ void tst_qmainexceptions::cleanupstack() CleanupStack::PopAndDestroy(dummy1); __UHEAP_MARKEND; } + void tst_qmainexceptions::leave() { __UHEAP_MARK; @@ -92,14 +110,206 @@ void tst_qmainexceptions::leave() CDummy* csDummy = new (ELeave) CDummy; CleanupStack::PushL(csDummy); __UHEAP_FAILNEXT(1); - dummy1 = new (ELeave) CDummy; + dummy1 = new (ELeave) CDummy; //CleanupStack::PopAndDestroy(csDummy); not executed as previous line throws }); QCOMPARE(err,KErrNoMemory); - QVERIFY(!((int)dummy1)); + QVERIFY(!((int)dummy1)); + __UHEAP_MARKEND; +} + +class CTestActive : public CActive +{ +public: + CTestActive(TLeavingFunc* aFunc) : CActive(EPriorityStandard), iFunc(aFunc) + { + CActiveScheduler::Add(this); + } + ~CTestActive() + { + Cancel(); + } + void DoCancel() {} + void Test() + { + // complete this AO in a nested scheduler, to make it synchronous + TRequestStatus* s = &iStatus; + SetActive(); + User::RequestComplete(s, KErrNone); + CActiveScheduler::Start(); + } + void RunL() + { + (*iFunc)(); + CActiveScheduler::Stop(); // will only get here if iFunc does not leave + } + TInt RunError(TInt aError) + { + error = aError; + CActiveScheduler::Stop(); // will only get here if iFunc leaves + return KErrNone; + } +public: + TLeavingFunc* iFunc; + int error; +}; + +void tst_qmainexceptions::TestSchedulerCatchesError(TLeavingFunc* f, int error) +{ + CTestActive *act = new(ELeave) CTestActive(f); + act->Test(); + QCOMPARE(act->error, error); + delete act; +} + +void ThrowBadAlloc() +{ + throw std::bad_alloc(); +} + +void TranslateThrowBadAllocL() +{ + QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE(ThrowBadAlloc()); +} + +void tst_qmainexceptions::testTranslateBadAlloc() +{ + // bad_alloc should give KErrNoMemory in an AO + TestSchedulerCatchesError(&TranslateThrowBadAllocL, KErrNoMemory); +} + +void BigAlloc() +{ + int *x = new int[100000000]; + delete [] x; +} + +void TranslateBigAllocL() +{ + QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE(BigAlloc()); +} + +void tst_qmainexceptions::testTranslateBigAlloc() +{ + // this test will fail if new does not throw on failure, otherwise should give KErrNoMemory in AO + TestSchedulerCatchesError(&TranslateBigAllocL, KErrNoMemory); +} + +void tst_qmainexceptions::TestSymbianRoundTrip(int leave, int trap) +{ + // check that leave converted to exception, converted to error gives expected error code + int trapped; + QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_ERROR( + trapped, + QT_TRANSLATE_SYMBIAN_LEAVE_TO_EXCEPTION( + User::LeaveIfError(leave))); + QCOMPARE(trap, trapped); +} + +void tst_qmainexceptions::testRoundTrip() +{ + for (int e=-50; e<0; e++) + TestSymbianRoundTrip(e, e); + TestSymbianRoundTrip(KErrNone, KErrNone); + // positive error codes are not errors + TestSymbianRoundTrip(1, KErrNone); + TestSymbianRoundTrip(1000000000, KErrNone); +} + +void tst_qmainexceptions::testTrap() +{ + // testing qt_translateExceptionToSymbianErrorL + TRAPD(err, qt_translateExceptionToSymbianErrorL(std::bad_alloc())); + QCOMPARE(err, KErrNoMemory); +} + +bool tst_qmainexceptions::event(QEvent *aEvent) +{ + if (aEvent->type() == QEvent::User+1) + throw std::bad_alloc(); + else if (aEvent->type() == QEvent::User+2) { + QEvent event(QEvent::Type(QEvent::User+1)); + QApplication::sendEvent(this, &event); + } + return QObject::event(aEvent); +} + +void tst_qmainexceptions::testPropagation() +{ + // test exception thrown from event is propagated back to sender + QEvent event(QEvent::Type(QEvent::User+1)); + bool caught = false; + try { + QApplication::sendEvent(this, &event); + } catch (const std::bad_alloc&) { + caught = true; + } + QCOMPARE(caught, true); + + // testing nested events propagate back to top level sender + caught = false; + QEvent event2(QEvent::Type(QEvent::User+2)); + try { + QApplication::sendEvent(this, &event2); + } catch (const std::bad_alloc&) { + caught = true; + } + QCOMPARE(caught, true); +} + +void tst_qmainexceptions::testDtor1() +{ + // destructors work on exception + int i = 0; + struct SAutoInc { + SAutoInc(int& aI) : i(aI) { ++i; } + ~SAutoInc() { --i; } + int &i; + } ai(i); + QCOMPARE(i, 1); + try { + SAutoInc ai2(i); + QCOMPARE(i, 2); + throw std::bad_alloc(); + QFAIL("should not get here"); + } catch (const std::bad_alloc&) { + QCOMPARE(i, 1); + } + QCOMPARE(i, 1); +} + +void tst_qmainexceptions::testDtor2() +{ + // memory is cleaned up correctly on exception + // this crashes with winscw compiler build < 481 + __UHEAP_MARK; + try { + QString str("abc"); + str += "def"; + throw std::bad_alloc(); + QFAIL("should not get here"); + } catch (const std::bad_alloc&) { } __UHEAP_MARKEND; } +void tst_qmainexceptions::testNestedExceptions() +{ + // throwing exceptions while handling exceptions + struct Oops { + Oops* next; + Oops(int level) : next(level > 0 ? new Oops(level-1) : 0) {} + ~Oops() { + try { throw std::bad_alloc(); } + catch (const std::exception&) {delete next;} + } + }; + try { + Oops oops(5); + throw std::bad_alloc(); + } + catch (const std::exception&) {} +} + QTEST_MAIN(tst_qmainexceptions) #include "tst_qmainexceptions.moc" |