22 #include <hbaction.h> |
22 #include <hbaction.h> |
23 |
23 |
24 #include <QGraphicsLinearLayout> |
24 #include <QGraphicsLinearLayout> |
25 #include <QScopedPointer> |
25 #include <QScopedPointer> |
26 |
26 |
27 CpProfileNameEditDialog::CpProfileNameEditDialog( QGraphicsItem *parent ) |
27 CpProfileNameEditDialog::CpProfileNameEditDialog(QGraphicsItem *parent) |
28 :HbDialog( parent ) |
28 : HbDialog(parent) |
29 { |
29 { |
30 init(); |
30 init(); |
31 } |
31 } |
32 |
32 |
33 CpProfileNameEditDialog::~CpProfileNameEditDialog() |
33 CpProfileNameEditDialog::~CpProfileNameEditDialog() |
34 { |
34 { |
35 } |
35 } |
36 |
36 |
37 void CpProfileNameEditDialog::init() |
37 void CpProfileNameEditDialog::init() |
38 { |
38 { |
39 setDismissPolicy( HbPopup::NoDismiss ); |
39 setDismissPolicy(HbPopup::NoDismiss); |
40 setHeadingWidget( new HbLabel( hbTrId( "txt_cp_title_edit_name" ), this )); |
40 setHeadingWidget(new HbLabel(hbTrId("txt_cp_title_edit_name"), this)); |
41 |
41 |
42 QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout(); |
42 QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout(); |
43 vLayout->setOrientation( Qt::Vertical ); |
43 vLayout->setOrientation(Qt::Vertical); |
44 HbWidget *contentWidget = new HbWidget( this ); |
44 HbWidget *contentWidget = new HbWidget(this); |
45 mTextEdit = new HbLineEdit( this ); |
45 HbLabel *label = new HbLabel(hbTrId("txt_cp_heading_profile_name")); |
46 mTextEdit->setFontSpec( HbFontSpec( HbFontSpec::Primary ) ); |
46 vLayout->addItem(label); |
47 vLayout->addItem( mTextEdit ); |
47 mLineEdit = new HbLineEdit(this); |
48 contentWidget->setLayout( vLayout ); |
48 mLineEdit->setFontSpec(HbFontSpec(HbFontSpec::Primary)); |
49 setContentWidget( contentWidget ); |
49 vLayout->addItem(mLineEdit); |
|
50 contentWidget->setLayout(vLayout); |
|
51 setContentWidget(contentWidget); |
|
52 connect(mLineEdit, SIGNAL(contentsChanged()), this, SLOT(checkPrimaryAction())); |
50 |
53 |
51 connect( mTextEdit, SIGNAL( contentsChanged() ), this, SLOT( checkPrimaryAction() ) ); |
54 setTimeout(NoTimeout); |
52 |
|
53 addAction( new HbAction( hbTrId( "txt_common_button_ok" ), this )); |
|
54 addAction( new HbAction( hbTrId( "txt_common_button_cancel" ), this ) ); |
|
55 |
|
56 setTimeout( NoTimeout ); |
|
57 } |
55 } |
58 |
56 |
59 void CpProfileNameEditDialog::setLineEditText( const QString &text ) |
57 void CpProfileNameEditDialog::setLineEditText(const QString &text) |
60 { |
58 { |
61 mTextEdit->setText( text ); |
59 mLineEdit->setText(text); |
62 mTextEdit->setSelection( 0, text.length() ); |
|
63 } |
60 } |
64 |
61 |
65 QString CpProfileNameEditDialog::getLineEditText() |
62 QString CpProfileNameEditDialog::lineEditText() |
66 { |
63 { |
67 QString text = mTextEdit->text(); |
64 return mLineEdit->text().trimmed(); |
68 return text; |
|
69 } |
65 } |
70 |
66 |
71 bool CpProfileNameEditDialog::launchProfileNameEditDialog( QString &profileName ) |
67 void CpProfileNameEditDialog::setLineEditMaxLength(int length) |
72 { |
68 { |
73 CpProfileNameEditDialog *profileEditNameDialog = new CpProfileNameEditDialog(); |
69 mLineEdit->setMaxLength(length); |
74 |
|
75 profileEditNameDialog->setLineEditText( profileName ); |
|
76 profileEditNameDialog->checkPrimaryAction(); |
|
77 |
|
78 HbAction *secondAction = qobject_cast<HbAction *> |
|
79 (profileEditNameDialog->actions().at(1)); |
|
80 profileEditNameDialog->show(); |
|
81 return false; |
|
82 } |
70 } |
83 |
71 |
84 void CpProfileNameEditDialog::checkPrimaryAction() |
72 void CpProfileNameEditDialog::checkPrimaryAction() |
85 { |
73 { |
86 HbAction *const primaryAction = qobject_cast<HbAction *> |
74 //the first button(number 0) is Ok Button. |
87 (actions().at(0)); |
75 HbAction *const primaryAction = qobject_cast<HbAction *>(actions().at(0)); |
88 if (primaryAction) { |
76 if (primaryAction) { |
89 if ( !mTextEdit->text().isEmpty() ) { |
77 if (!mLineEdit->text().trimmed().isEmpty()) { |
90 primaryAction->setEnabled(true); |
78 primaryAction->setEnabled(true); |
91 } else { |
79 } else { |
92 primaryAction->setEnabled(false); |
80 primaryAction->setEnabled(false); |
93 } |
81 } |
94 } |
82 } |
95 } |
83 } |