--- a/filemanager/src/filemanager/src/components/fmdlgutils.cpp Mon May 03 12:24:39 2010 +0300
+++ b/filemanager/src/filemanager/src/components/fmdlgutils.cpp Tue Aug 24 10:24:14 2010 +0800
@@ -23,6 +23,8 @@
#include "fmmultitextquery.h"
#include "fmutils.h"
#include "fmviewmanager.h"
+#include "fmmessagebox.h"
+#include "fmdrivequery.h"
#include <QString>
#include <QStringList>
@@ -30,34 +32,29 @@
#include <hblabel.h>
#include <hbaction.h>
-#include <hbmessagebox.h>
-FmDlgUtils::FmDlgUtils( void )
+/*
+ Private Constructor
+*/
+FmDlgUtils::FmDlgUtils()
{
}
-FmDlgUtils::~FmDlgUtils( void )
+/*!
+ Destructor
+*/
+FmDlgUtils::~FmDlgUtils()
{
}
-HbAction *FmDlgUtils::executeDialog( HbDialog *dialog, const QString &associatedDrives )
-{
- for( int i = 0; i < associatedDrives.length(); i++ ) {
- QString drive( associatedDrives[i] + QString( ":/" ) );
- if( !FmUtils::isDriveAvailable( drive ) ) {
- FmLogger::log( "executeDialog return 0_ " + associatedDrives );
- return 0;
- }
- }
-
- FmDlgCloseUnit dlgCloseUnit( dialog );
- dlgCloseUnit.addAssociatedDrives( associatedDrives );
- FmViewManager::viewManager()->addDlgCloseUnit( &dlgCloseUnit );
- HbAction* action = dialog->exec();
- FmViewManager::viewManager()->removeDlgCloseUnit( &dlgCloseUnit );
- return action;
-}
-
+/*!
+ Shows single select setting query dialog
+ \a title used for title text
+ \a textList used for text list for available settings
+ \a selectedIndex used for storing selected index
+ Dialog will be closed as canceled while drive in \a associatedDrives is removed
+ return true if selection made, otherwise false
+*/
bool FmDlgUtils::showSingleSettingQuery(
const QString &title,
const QStringList &textList,
@@ -82,8 +79,8 @@
cQuery->setMarkedListItem( selectedIndex );
}
- QString sk1 ( tr ( "ok" ) );
- QString sk2 ( tr ("cancel" ) );
+ QString sk1 ( hbTrId( "txt_common_button_ok" ) );
+ QString sk2 ( hbTrId("txt_common_button_cancel" ) );
if( !sk1.isEmpty() ) {
HbAction *primary = new HbAction( sk1 );
@@ -127,6 +124,15 @@
return ret;
}
+/*!
+ Shows multi select setting query dialog
+ \a title used for title text
+ \a textList used for text list for available settings
+ \a selection used for storing selected indexes as bitmask
+ \a dominantIndex used for dominant index for select all behaviour
+ Dialog will be closed as canceled while drive in \a associatedDrives is removed
+ return true if selection made, otherwise false
+*/
bool FmDlgUtils::showMultiSettingQuery(
const QString &title,
const QStringList &textList,
@@ -158,8 +164,8 @@
}
- QString sk1 ( hbTrId( "ok" ) );
- QString sk2 ( hbTrId( "cancel" ) );
+ QString sk1 ( hbTrId( "txt_common_button_ok" ) );
+ QString sk2 ( hbTrId( "txt_common_button_cancel" ) );
if( !sk1.isEmpty() ) {
HbAction *primary = new HbAction( sk1 );
@@ -202,6 +208,13 @@
return ret;
}
+/*!
+ Shows time setting query dialog
+ \a title used for title text
+ \a time used for selected time
+ Dialog will be closed as canceled while drive in \a associatedDrives is removed
+ return true if selection made, otherwise false
+*/
bool FmDlgUtils::showTimeSettingQuery(
const QString &title, QTime &time, const QString &associatedDrives )
{
@@ -212,8 +225,8 @@
cQuery->setHeadingWidget( new HbLabel( title ) );
cQuery->setTime( time );
- QString sk1 ( hbTrId( "ok" ) );
- QString sk2 ( hbTrId( "cancel" ) );
+ QString sk1 ( hbTrId( "txt_common_button_ok" ) );
+ QString sk2 ( hbTrId( "txt_common_button_cancel" ) );
if( !sk1.isEmpty() ) {
HbAction *primary = new HbAction( sk1 );
@@ -244,25 +257,33 @@
return ret;
}
+/*!
+ Shows text query dialog
+ \a title used for title text
+ \a text used for receiving user input text
+ \a validRegExpStringList used for set valid regExp string list
+ \a maxLength used for setting max length of input text
+ Dialog will be closed as canceled while drive in \a associatedDrives is removed
+ Set \a isReturnFalseWhenNoTextChanged true if need make return value as true while no text changed
+ return true if text change is made, otherwise false
+*/
bool FmDlgUtils::showTextQuery(
- const QString& title, QString& text, bool isDimPrimaryActionWhenEmpty, int maxLength,
- const QString &associatedDrives )
+ const QString& title, QString& text, QStringList validRegExpStringList,
+ int maxLength, const QString &associatedDrives, bool isReturnFalseWhenNoTextChanged )
{
bool ret( false );
bool ok ( true ); // SK return (out parameter)
- FmSingleTextQuery::Options options( 0 );
- if( isDimPrimaryActionWhenEmpty ) {
- options = FmSingleTextQuery::DimPrimereActionWhenEmpty;
- }
- FmSingleTextQuery *cQuery = new FmSingleTextQuery( options );
+ FmSingleTextQuery *cQuery = new FmSingleTextQuery();
if( maxLength != -1 ){
cQuery->setLineEditMaxLength( maxLength );
}
cQuery->setHeadingWidget( new HbLabel( title ) );
- QString sk1 ( hbTrId ( "ok" ) );
- QString sk2 ( hbTrId ( "cancel" ) );
+ cQuery->setRegExpStringList( validRegExpStringList );
+
+ QString sk1 ( hbTrId ( "txt_common_button_ok" ) );
+ QString sk2 ( hbTrId ( "txt_common_button_cancel" ) );
if( !sk1.isEmpty() ) {
HbAction *primary = new HbAction( sk1 );
@@ -286,7 +307,14 @@
if( ok ){
QString newName = cQuery->getLineEditText();
- if ( newName != text ){
+ if ( newName == text ){
+ if( isReturnFalseWhenNoTextChanged ) {
+ ret = false;
+ }
+ else {
+ ret = true;
+ }
+ } else {
text = newName;
ret = true;
}
@@ -295,16 +323,28 @@
return ret;
}
-bool FmDlgUtils::showSinglePasswordQuery( const QString &title, QString &pwd, const QString &associatedDrives )
+/*!
+ Shows single-line password query dialog
+ \a title used for title text
+ \a pwd used for receiving user input password
+ \a maxLength used for setting max length of input password
+ Dialog will be closed as canceled while drive in \a associatedDrives is removed
+ return true if password text is inputted, otherwise false
+*/
+bool FmDlgUtils::showSinglePasswordQuery( const QString &title, QString &pwd, int maxLength, const QString &associatedDrives )
{
bool ret( false );
- FmSingleTextQuery *cQuery = new FmSingleTextQuery( FmSingleTextQuery::DimPrimereActionWhenEmpty,
- HbLineEdit::Password );
+ FmSingleTextQuery *cQuery = new FmSingleTextQuery( HbLineEdit::Password );
+ if( maxLength != -1 ){
+ cQuery->setLineEditMaxLength( maxLength );
+ }
cQuery->setHeadingWidget( new HbLabel( title ) );
-
- QString sk1 ( tr ("ok" ) );
- QString sk2 ( tr ("cancel" ) );
+
+ // validate that length is not zero. space is acceptable character.
+ cQuery->setRegExpStringList( QStringList( Regex_ValidUnZeroLength ) );
+ QString sk1 ( hbTrId("txt_common_button_ok" ) );
+ QString sk2 ( hbTrId("txt_common_button_cancel" ) );
if( !sk1.isEmpty() ) {
HbAction *primary = new HbAction( sk1 );
@@ -330,17 +370,29 @@
return ret;
}
+/*!
+ Shows mulit-line password query dialog. If two password is not equal, primary action is dimmed
+ \a firstLabel used for first line title text
+ \a secondLabel used for second line title text
+ \a pwd used for receiving user input password
+ \a maxLength used for setting max length of input password
+ Dialog will be closed as canceled while drive in \a associatedDrives is removed
+ return true if password text is inputted, otherwise false
+*/
bool FmDlgUtils::showMultiPasswordQuery(
- const QString &firstLabel, const QString &secondLabel, QString &pwd, const QString &associatedDrives )
+ const QString &firstLabel, const QString &secondLabel, QString &pwd, int maxLength, const QString &associatedDrives )
{
bool ret( false );
FmMultiTextQuery *cQuery = new FmMultiTextQuery( HbLineEdit::Password );
+ if( maxLength != -1 ){
+ cQuery->setLineEditMaxLength( maxLength );
+ }
cQuery->setFirstLabelText( firstLabel );
cQuery->setSecondLabelText( secondLabel );
- QString sk1 = ( hbTrId( "ok" ) );
- QString sk2 = ( hbTrId( "cancel" ) );
+ QString sk1 = ( hbTrId( "txt_common_button_ok" ) );
+ QString sk2 = ( hbTrId( "txt_common_button_cancel" ) );
if( !sk1.isEmpty() ) {
HbAction *primary = new HbAction( sk1 );
@@ -369,3 +421,75 @@
delete cQuery;
return ret;
}
+
+/*!
+ This is a convenience function for showing a question dialog with \a questionText
+ Default buttons are Yes and No.
+*/
+bool FmDlgUtils::question( const QString &questionText,
+ HbMessageBox::StandardButtons buttons )
+{
+ FmMessageBox msgBox;
+ return msgBox.question( questionText, buttons );
+}
+
+/*!
+ This is a convenience function for showing an information dialog with \a informationText
+ Default button is OK.
+*/
+void FmDlgUtils::information( const QString &informationText,
+ HbMessageBox::StandardButtons buttons )
+{
+ FmMessageBox msgBox;
+ return msgBox.information( informationText, buttons );
+}
+
+/*!
+ Shows query dialog for select backup drive
+ \a title used for title text
+ only backup target drives will be shown.
+ return selected drive, and empty string for cancel.
+*/
+QString FmDlgUtils::showBackupDriveQuery( const QString& title )
+{
+ QString ret;
+
+ FmDriveQuery *cQuery = new FmDriveQuery();
+ cQuery->setHeadingWidget( new HbLabel( title ) );
+
+ QString sk = ( hbTrId( "txt_common_button_cancel" ) );
+
+ HbAction *primary = new HbAction( sk );
+ cQuery->setPrimaryAction( primary );
+
+ executeDialog( cQuery, QString() );
+ ret = cQuery->selectedDrive();
+
+ delete cQuery;
+ return ret;
+}
+
+/*
+ Private function used to popup \a dialog
+ If want popup dialog in class FmDlgUtils, please call this function.
+ Dialog will be closed as canceled while drive in \a associatedDrives is removed
+ return selected action.
+*/
+HbAction *FmDlgUtils::executeDialog( FmDialog *dialog, const QString &associatedDrives )
+{
+ for( int i = 0; i < associatedDrives.length(); i++ ) {
+ QString drive( associatedDrives[i] + QString( ":/" ) );
+ if( !FmUtils::isDriveAvailable( drive ) ) {
+ FM_LOG( "executeDialog return 0_ " + associatedDrives );
+ return 0;
+ }
+ }
+
+ FmDlgCloseUnit dlgCloseUnit( dialog );
+ dlgCloseUnit.addAssociatedDrives( associatedDrives );
+
+ FmViewManager::viewManager()->addDlgCloseUnit( &dlgCloseUnit );
+ HbAction* action = dialog->exec();
+ FmViewManager::viewManager()->removeDlgCloseUnit( &dlgCloseUnit );
+ return action;
+}