securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationcontentwidget.cpp
branchGCC_SURGE
changeset 40 604cd42065d1
parent 38 e0432375ea67
child 45 5d3e34b7618a
equal deleted inserted replaced
29:b63e8c2d8cff 40:604cd42065d1
    14 *
    14 *
    15 * Description: SecUi notification content widget.
    15 * Description: SecUi notification content widget.
    16 *
    16 *
    17 */
    17 */
    18 
    18 
       
    19 #include "secuinotificationdebug.h"
    19 #include "secuinotificationcontentwidget.h"
    20 #include "secuinotificationcontentwidget.h"
    20 #include "secuinotificationdialogpluginkeys.h"
    21 #include "secuinotificationdialogpluginkeys.h"
    21 #include <QGraphicsLinearLayout>
    22 #include <QGraphicsLinearLayout>
    22 #include <QToolButton>
    23 #include <QToolButton>
    23 #include <hblabel.h>
    24 #include <hblabel.h>
    26 #include <hbcombobox.h>
    27 #include <hbcombobox.h>
    27 #include <hblineedit.h>
    28 #include <hblineedit.h>
    28 #include <hbinputeditorinterface.h>
    29 #include <hbinputeditorinterface.h>
    29 #include <QDebug>
    30 #include <QDebug>
    30 
    31 
       
    32 #include <HbCheckBox>  // needed for a checkbox dialog
       
    33 #include <HbListWidget>  // needed for multicheckbox dialog
       
    34 #include <HbListWidgetItem>
       
    35 #include <HbAbstractItemView>
    31 #include <HbEmailAddressFilter>
    36 #include <HbEmailAddressFilter>
    32 
    37 
    33 #define ESecUiCancelSupported  0x1000000
    38 #define ESecUiCancelSupported  0x1000000
    34 #define ESecUiCancelNotSupported  0x0000000
    39 #define ESecUiCancelNotSupported  0x0000000
    35 
    40 
    58 // ----------------------------------------------------------------------------
    63 // ----------------------------------------------------------------------------
    59 //
    64 //
    60 SecUiNotificationContentWidget::SecUiNotificationContentWidget(
    65 SecUiNotificationContentWidget::SecUiNotificationContentWidget(
    61         QGraphicsItem *parent, Qt::WindowFlags flags) : HbWidget(parent, flags)
    66         QGraphicsItem *parent, Qt::WindowFlags flags) : HbWidget(parent, flags)
    62 {
    67 {
    63 		qDebug() << "SecUiNotificationContentWidget::SecUiNotificationContentWidget";
    68 		RDEBUG("0", 0);
    64 }
    69 }
    65 
    70 
    66 // ----------------------------------------------------------------------------
    71 // ----------------------------------------------------------------------------
    67 // SecUiNotificationContentWidget::~SecUiNotificationContentWidget()
    72 // SecUiNotificationContentWidget::~SecUiNotificationContentWidget()
    68 // ----------------------------------------------------------------------------
    73 // ----------------------------------------------------------------------------
    75 // SecUiNotificationContentWidget::constructFromParameters()
    80 // SecUiNotificationContentWidget::constructFromParameters()
    76 // ----------------------------------------------------------------------------
    81 // ----------------------------------------------------------------------------
    77 //
    82 //
    78 void SecUiNotificationContentWidget::constructFromParameters(const QVariantMap &parameters)
    83 void SecUiNotificationContentWidget::constructFromParameters(const QVariantMap &parameters)
    79 {
    84 {
    80 		qDebug() << "SecUiNotificationContentWidget::constructFromParameters 1";
    85 		RDEBUG("0", 0);
    81 		qDebug() << parameters;
    86 		qDebug() << parameters;
    82     QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical);
    87     QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical);
    83 
    88 
    84     lMinLength = 4;	// might be replaced later
    89     lMinLength = 4;	// might be replaced later
    85     lMaxLength = 8;	// might be replaced later
    90     lMaxLength = 8;	// might be replaced later
    86  		queryDual=0;
    91  		queryDual=0;
    87  		isEmergency=0;
    92  		isEmergency=0;
       
    93        codeTop=0;
    88 
    94 
    89     // KApplicationSize
    95     // KApplicationSize
    90     if (parameters.contains(KQueryType)) {
    96     if (parameters.contains(KQueryType)) {
    91 				qDebug() << "SecUiNotificationContentWidget::KQueryType";
    97 				RDEBUG("0", 0);
    92         queryType = parameters.value(KQueryType).toUInt();
    98         queryType = parameters.value(KQueryType).toUInt();
    93 				qDebug() << queryType;
    99 				RDEBUG("queryType", queryType);
    94 				if( (queryType & ESecUiTypeMaskLock) )
   100 				if( (queryType & ESecUiTypeMaskLock) )
    95 					{
   101 					{
    96 					qDebug() << "SecUiNotificationContentWidget::KQueryType=ESecUiTypeLock";
   102 					RDEBUG("KQueryType=ESecUiTypeMaskLock", queryType);
    97 					// showing "Lock" icon. All other params are irrelevant. codeTop is not even created
   103 					// showing "Lock" icon. All other params are irrelevant. codeTop is not even created
    98 
       
    99 					
   104 					
   100         	HbLabel *iconLabel = new HbLabel("Locked");
   105         	HbLabel *iconLabel = new HbLabel("Locked");
   101         	HbIcon *icon = new HbIcon("qtg_large_device_lock");
   106         	HbIcon *icon = new HbIcon("qtg_large_device_lock");
   102         	// iconLabel->setAspectRatioMode(Qt::IgnoreAspectRatio);
   107         	// iconLabel->setAspectRatioMode(Qt::IgnoreAspectRatio);
   103     			// iconLabel->setGeometry(QRectF(QPointF(10,10),QSizeF(300,300)));
   108     			// iconLabel->setGeometry(QRectF(QPointF(10,10),QSizeF(300,300)));
   178         codeTop = new HbLineEdit("");	// no default value
   183         codeTop = new HbLineEdit("");	// no default value
   179         qDebug() << "SecUiNotificationContentWidget::KCodeTop lMaxLength=";
   184         qDebug() << "SecUiNotificationContentWidget::KCodeTop lMaxLength=";
   180         qDebug() << lMaxLength;
   185         qDebug() << lMaxLength;
   181         if(lMaxLength>2)
   186         if(lMaxLength>2)
   182 	        codeTop->setMaxLength(lMaxLength);
   187 	        codeTop->setMaxLength(lMaxLength);
   183         // HbLineEdit *codeTop2 = new HbLineEdit;
       
   184 				qDebug() << "SecUiNotificationContentWidget::KCodeTop 2";
       
   185 				qDebug() << "SecUiNotificationContentWidget::KCodeTop queryType=";
   188 				qDebug() << "SecUiNotificationContentWidget::KCodeTop queryType=";
   186 				qDebug() << queryType;
   189 				qDebug() << queryType;
   187 				codeTop->setInputMethodHints(Qt::ImhDigitsOnly);	// default
   190 				codeTop->setInputMethodHints(Qt::ImhDigitsOnly);	// default
   188  		    if (queryType & ESecUiAlphaSupported)
   191  		    if (queryType & ESecUiAlphaSupported)
   189 		    	{
   192 		    	{
   207 					}
   210 					}
   208 				qDebug() << "SecUiNotificationContentWidget::KCodeTop 4";
   211 				qDebug() << "SecUiNotificationContentWidget::KCodeTop 4";
   209 
   212 
   210         connect(codeTop, SIGNAL(textChanged(const QString &)), this, SIGNAL(codeTopChanged(const QString &)));
   213         connect(codeTop, SIGNAL(textChanged(const QString &)), this, SIGNAL(codeTopChanged(const QString &)));
   211         connect(codeTop, SIGNAL(contentsChanged()), this, SIGNAL(codeTopContentChanged()));
   214         connect(codeTop, SIGNAL(contentsChanged()), this, SIGNAL(codeTopContentChanged()));
       
   215 
       
   216 				if (parameters.contains(KDefaultCode)) {	// this is done in this step so that the OK becomes valid (if rules are fulfilled)
       
   217 					qDebug() << "SecUiNotificationContentWidget::KDefaultCode";
       
   218   	      QString defaultCode = parameters.value(KDefaultCode).toString();
       
   219     	    qDebug() << defaultCode;
       
   220 					codeTop->setText(defaultCode);
       
   221 					}
       
   222 				qDebug() << "SecUiNotificationContentWidget::KCodeTop 4";
       
   223 
       
   224 		    if (parameters.contains(KDialogTitle)) {
       
   225 		        QString titleText = parameters.value(KDialogTitle).toString();
       
   226 		        QString titleAttempts = "";
       
   227 		   			if(titleText.indexOf('|')>0)
       
   228 		    				{	// if separator, take only first part
       
   229 		    				titleText = titleText.left(titleText.indexOf('|'));
       
   230 		    				}
       
   231 		   			if(titleText.indexOf('#')>0)
       
   232 		    				{	// if separator, take only first part
       
   233 		    				titleAttempts = titleText.right(titleText.length()-titleText.indexOf('#')-1);
       
   234 		    				qDebug() << "SecUiNotificationDialog::titleAttempts=" << titleAttempts;
       
   235 		    				int nAttempts = titleAttempts.toInt();
       
   236 		    				RDEBUG("nAttempts", nAttempts);
       
   237 		    				titleText = titleText.left(titleText.indexOf('#'));
       
   238 		    				if(nAttempts>0)
       
   239 		    					titleText = titleText + " attempts=" + QString::number(nAttempts);
       
   240 		    				}
       
   241 		        HbLabel *titleTop = new HbLabel(titleText);
       
   242 		        mainLayout->addItem(titleTop);
       
   243 		        // in the dialog, it was setHeadingWidget(title);
       
   244 		    }
       
   245 
   212     		mainLayout->addItem(codeTop);
   246     		mainLayout->addItem(codeTop);
       
   247     		// double-query
   213     		if (parameters.contains(KCodeBottom))
   248     		if (parameters.contains(KCodeBottom))
   214     			{
   249     			{
   215     			queryDual=1;
   250     			queryDual=1;
   216     			QString titleText = parameters.value(KDialogTitle).toString();
   251     			QString titleText = parameters.value(KDialogTitle).toString();
   217     			if(titleText.indexOf('|')>0)
   252     			if(titleText.indexOf('|')>0)
   226 		        codeBottom->setMaxLength(lMaxLength);
   261 		        codeBottom->setMaxLength(lMaxLength);
   227 	    		codeBottom->setInputMethodHints(Qt::ImhDigitsOnly);	// default
   262 	    		codeBottom->setInputMethodHints(Qt::ImhDigitsOnly);	// default
   228 	 		    if (queryType & ESecUiAlphaSupported)
   263 	 		    if (queryType & ESecUiAlphaSupported)
   229 			    	{
   264 			    	{
   230 			    	qDebug() << "SecUiNotificationContentWidget::KCodeBottom setUpAsLatinAlphabetOnlyEditor";
   265 			    	qDebug() << "SecUiNotificationContentWidget::KCodeBottom setUpAsLatinAlphabetOnlyEditor";
   231 	 	    		codeTop->setInputMethodHints(Qt::ImhNone);
   266 	 	    		codeBottom->setInputMethodHints(Qt::ImhNone);
   232 			  		}
   267 			  		}
   233 					qDebug() << "SecUiNotificationContentWidget::KCodeBottom 3";
   268 					qDebug() << "SecUiNotificationContentWidget::KCodeBottom 3";
   234 	        connect(codeBottom, SIGNAL(textChanged(const QString &)), this, SIGNAL(codeBottomChanged(const QString &)));
   269 	        connect(codeBottom, SIGNAL(textChanged(const QString &)), this, SIGNAL(codeBottomChanged(const QString &)));
   235         	connect(codeBottom, SIGNAL(contentsChanged(const QString &)), this, SIGNAL(codeBottomChanged(const QString &)));
   270         	connect(codeBottom, SIGNAL(contentsChanged(const QString &)), this, SIGNAL(codeBottomChanged(const QString &)));
   236 	    		mainLayout->addItem(codeBottom);
   271 	    		mainLayout->addItem(codeBottom);
   249         mainLayoutButtons->addItem(but3);
   284         mainLayoutButtons->addItem(but3);
   250         #endif
   285         #endif
   251 
   286 
   252         mainLayout->addItem(mainLayoutButtons);
   287         mainLayout->addItem(mainLayoutButtons);
   253         
   288         
   254         codeTop->setFocus();
   289         codeTop->setFocus();	// this should open the VKB
   255 
   290 
   256     }
   291     }
       
   292 
       
   293     if (parameters.contains(KChecboxType)) {
       
   294     		qDebug() << "SecUiNotificationContentWidget::KChecboxType";
       
   295         if (parameters.contains(KDialogTitle)) {
       
   296             //TODO position of the label is not centered
       
   297             QString tmpText=parameters.value(KDialogTitle).toString();
       
   298             if (tmpText.endsWith("\n"))  tmpText=tmpText.left(tmpText.length()-1);
       
   299             DialogText= new HbLabel(tmpText);   
       
   300             DialogText->setTextWrapping(Hb::TextWordWrap);
       
   301             DialogText->setAlignment(Qt::AlignVCenter);
       
   302             mainLayout->addItem(DialogText);                   
       
   303         }
       
   304 
       
   305         checkbox = new HbCheckBox("Caption");   
       
   306         if (parameters.contains(KDefaultCode)) {
       
   307     				qDebug() << "SecUiNotificationContentWidget::KDefaultCode";
       
   308             QStringList list1 = parameters.value(KDefaultCode).toString().split("|");
       
   309             if (!list1.isEmpty() && list1.count()==2) {
       
   310                 if (!list1[0].isNull() && !list1[0].isEmpty()) checkbox->setText(list1[0]);
       
   311                 if (!list1[1].isNull() && !list1[1].isEmpty()) checkbox->setChecked(list1[1].toInt());
       
   312             }
       
   313 
       
   314         }
       
   315         mainLayout->addItem(checkbox);
       
   316     }
       
   317 
       
   318     if (parameters.contains(KMultiChecboxType) && parameters.contains(KDefaultCode)) 
       
   319     	{
       
   320  				qDebug() << "SecUiNotificationContentWidget::KMultiChecboxType";
       
   321         QStringList list1 = parameters.value(KDefaultCode).toString().split("1\t");
       
   322         if (!list1.isEmpty()) {
       
   323             listWidget = new HbListWidget();
       
   324             for (int i = 0; (i < list1.count()); i++)
       
   325                 if (!list1[i].isEmpty() && !list1[i].isNull()) {
       
   326                     HbListWidgetItem* modelItem = new HbListWidgetItem();
       
   327                     modelItem->setData(QVariant(list1[i]), Qt::DisplayRole);
       
   328                     listWidget->addItem(modelItem);  
       
   329                 }
       
   330             listWidget->setCurrentRow(0);
       
   331             listWidget->setSelectionMode(HbAbstractItemView::MultiSelection);
       
   332             //listWidget->setClampingStyle(HbScrollArea::BounceBackClamping);
       
   333             listWidget->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded);
       
   334             listWidget->setMaximumHeight(150);
       
   335             mainLayout->addItem(listWidget); 
       
   336             //     delete listWidget;
       
   337             }
       
   338         }
   257 
   339 
   258     setLayout(mainLayout);
   340     setLayout(mainLayout);
   259     }
   341     }
   260 
   342