creator/src/notifications.cpp
changeset 25 31fc1277642e
parent 24 6053b7ae82ab
child 27 271e901a9423
equal deleted inserted replaced
24:6053b7ae82ab 25:31fc1277642e
    29 #include <QDate>
    29 #include <QDate>
    30 #include <QRegExp>
    30 #include <QRegExp>
    31 
    31 
    32 #include "notifications.h"
    32 #include "notifications.h"
    33 
    33 
    34 
    34 // ---------------------------------------------------------------------------
       
    35 
       
    36 void Notifications::showMessageBox(HbMessageBox::MessageBoxType type, const QString &text, const QString &label, int timeout )
       
    37 {
       
    38     HbMessageBox *messageBox = new HbMessageBox(type);
       
    39     messageBox->setText(text);
       
    40     if(label.length())
       
    41         {
       
    42         HbLabel *header = new HbLabel(label, messageBox);
       
    43         messageBox->setHeadingWidget(header);
       
    44         }
       
    45     messageBox->setAttribute(Qt::WA_DeleteOnClose);
       
    46     messageBox->setTimeout(timeout);
       
    47     messageBox->open();
       
    48 }
    35 
    49 
    36 // ---------------------------------------------------------------------------
    50 // ---------------------------------------------------------------------------
    37 
    51 
    38 void Notifications::about()
    52 void Notifications::about()
    39 {
    53 {
    40     HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation);
    54     showMessageBox(HbMessageBox::MessageTypeInformation,
    41         messageBox->setText("Version 6.0.0 - April 23rd 2010. Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0.");
    55         "Version 6.0.0 - April 23rd 2010. Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0.",
    42         HbLabel *header = new HbLabel("About Creator", messageBox);
    56         "About Creator", 
    43         messageBox->setHeadingWidget(header);
    57         HbPopup::NoTimeout
    44         messageBox->setAttribute(Qt::WA_DeleteOnClose);
    58         );
    45         messageBox->setTimeout(HbPopup::NoTimeout);
       
    46         messageBox->open();
       
    47 }
    59 }
    48 
    60 
    49 // ---------------------------------------------------------------------------
    61 // ---------------------------------------------------------------------------
    50 
    62 
    51 void Notifications::error(const QString& errorMessage)
    63 void Notifications::error(const QString& errorMessage)
    52 {
    64 {
    53     HbMessageBox::warning(errorMessage, new HbLabel("Error"));
    65     showMessageBox(HbMessageBox::MessageTypeWarning, errorMessage, QString("Error"), 3000);
    54 }
    66 }
    55 
    67 
    56 
    68 
    57 // ---------------------------------------------------------------------------
    69 // ---------------------------------------------------------------------------
    58 
       
    59 
    70 
    60 HbProgressDialog* Notifications::showProgressBar(const QString& text, int max)
    71 HbProgressDialog* Notifications::showProgressBar(const QString& text, int max)
    61 {
    72 {
    62 	HbProgressDialog *note = new HbProgressDialog(HbProgressDialog::ProgressDialog);
    73 	HbProgressDialog *note = new HbProgressDialog(HbProgressDialog::ProgressDialog);
    63     note->setText(text);
    74     note->setText(text);
    64     note->setMaximum(max);
    75     note->setMaximum(max);
    65 
       
    66     note->show();
    76     note->show();
    67     return note;
    77     return note;
    68 
    78 
    69 }
    79 }
    70 
    80 
    71 // ---------------------------------------------------------------------------
    81 // ---------------------------------------------------------------------------
    72 
    82 
    73 void Notifications::showGlobalNote(const QString& text, HbMessageBox::MessageBoxType type, HbPopup::DefaultTimeout /*timeout*/)
    83 void Notifications::showGlobalNote(const QString& text, HbMessageBox::MessageBoxType type, HbPopup::DefaultTimeout timeout)
    74 {
    84 {
    75 	if (type == HbMessageBox::HbMessageBox::MessageTypeInformation)
    85     showMessageBox(type, text, QString("Creator"), timeout);
    76 		HbMessageBox::information(text, new HbLabel("Information"));
       
    77 	else
       
    78 		HbMessageBox::information(text, new HbLabel("Information"));
       
    79 }
    86 }
    80 
    87 
    81 // ---------------------------------------------------------------------------
    88 // ---------------------------------------------------------------------------
    82 
    89 
    83 bool Notifications::entriesQueryDialog(int& numberOfEntries, const QString& text, bool acceptsZero)
    90 bool Notifications::entriesQueryDialog(int& numberOfEntries, const QString& text, bool acceptsZero)
   113 	
   120 	
   114 	popup->setPrimaryAction(actionOk);
   121 	popup->setPrimaryAction(actionOk);
   115     popup->setSecondaryAction(actionCancel);
   122     popup->setSecondaryAction(actionCancel);
   116 
   123 
   117     // Launch popup syncronously
   124     // Launch popup syncronously
   118     HbAction *action = 0;
   125     popup->setAttribute(Qt::WA_DeleteOnClose);
   119     action = popup->exec();
   126     // TODO: handle dialog close & user input
       
   127     popup->open();
   120 
   128 
   121 	// continue if ok selected and valid user input exists in line editor
   129 	// continue if ok selected and valid user input exists in line editor
   122     if (action && action->text() == "Ok" && edit->text() != "") {
   130     /*if (action && action->text() == "Ok" && edit->text() != "") {
   123 		numberOfEntries = edit->text().toInt(&err, 10);
   131 		numberOfEntries = edit->text().toInt(&err, 10);
   124 	}
   132 	}*/
   125 	return err;
   133 	return err;
   126 }
   134 }
   127 
   135 
   128 // ---------------------------------------------------------------------------
   136 // ---------------------------------------------------------------------------
   129 bool Notifications::timeQueryDialog(QDate& date, const QString& text)
   137 bool Notifications::timeQueryDialog(QDate& date, const QString& text)
   153     
   161     
   154 	popup->setPrimaryAction(actionOk);
   162 	popup->setPrimaryAction(actionOk);
   155     popup->setSecondaryAction(actionCancel);
   163     popup->setSecondaryAction(actionCancel);
   156 
   164 
   157     // Launch popup syncronously
   165     // Launch popup syncronously
   158     HbAction *action = 0;
   166     popup->setAttribute(Qt::WA_DeleteOnClose);
   159     action = popup->exec();
   167     // TODO: handle dialog close & user input
       
   168     popup->open();
   160 
   169 
   161 	// continue if ok selected and valid user input exists in line editor
   170 	// continue if ok selected and valid user input exists in line editor
   162     if (action && action->text() == "Ok" && edit->text() != "") {
   171     /*if (action && action->text() == "Ok" && edit->text() != "") {
   163 		date = QDate::fromString(edit->text());
   172 		date = QDate::fromString(edit->text());
   164         err = true;
   173         err = true;
   165 	}
   174 	}*/
   166 	return err;    
   175 	return err;    
   167 }
   176 }
   168 
   177 
   169 // ---------------------------------------------------------------------------
   178 // ---------------------------------------------------------------------------
   170 
   179 
   171 bool Notifications::yesNoQueryDialog(const QString& text)
   180 bool Notifications::yesNoQueryDialog(const QString& text)
   172 {
   181 {
   173     return HbMessageBox::question(text);
   182     HbMessageBox::question(text, 0, 0);
       
   183     return false;
   174 }
   184 }
   175 
   185 
   176 // ---------------------------------------------------------------------------
   186 // ---------------------------------------------------------------------------
   177 
   187 
   178 void Notifications::popupListDialog(const QString& text, QStringList& items, HbAbstractItemView::SelectionMode mode, QObject* receiver, const char* member)
   188 void Notifications::popupListDialog(const QString& text, QStringList& items, HbAbstractItemView::SelectionMode mode, QObject* receiver, const char* member)
   208 	
   218 	
   209 	popup->setPrimaryAction(actionOk);
   219 	popup->setPrimaryAction(actionOk);
   210     popup->setSecondaryAction(actionCancel);
   220     popup->setSecondaryAction(actionCancel);
   211 
   221 
   212     // Launch popup syncronously
   222     // Launch popup syncronously
   213     HbAction *action = 0;
   223     popup->setAttribute(Qt::WA_DeleteOnClose);
   214     action = popup->exec();
   224     // TODO: handle dialog close & user input
       
   225     popup->open();
   215 
   226 
   216 	// continue if ok selected and valid user input exists in line editor
   227 	// continue if ok selected and valid user input exists in line editor
   217     if (action && action->text() == "Ok" && edit->text() != "") {
   228     /*if (action && action->text() == "Ok" && edit->text() != "") {
   218 		directory = edit->text();
   229 		directory = edit->text();
   219 		err = true;
   230 		err = true;
   220 	}
   231 	}*/
   221 	return err;
   232 	return err;
   222 }
   233 }
   223 
   234 
   224 // ---------------------------------------------------------------------------
   235 // ---------------------------------------------------------------------------