~ubuntu-branches/ubuntu/quantal/kdepimlibs/quantal-proposed

« back to all changes in this revision

Viewing changes to akonadi/renamefavoritedialog.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-14 14:37:07 UTC
  • mto: This revision was merged to the branch mainline in revision 112.
  • Revision ID: package-import@ubuntu.com-20111214143707-m0qplh3hsd957ukv
Tags: upstream-4.7.90
ImportĀ upstreamĀ versionĀ 4.7.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (c) 2011 Laurent Montel <montel@kde.org>
 
3
 
 
4
    This library is free software; you can redistribute it and/or modify it
 
5
    under the terms of the GNU Library General Public License as published by
 
6
    the Free Software Foundation; either version 2 of the License, or (at your
 
7
    option) any later version.
 
8
 
 
9
    This library is distributed in the hope that it will be useful, but WITHOUT
 
10
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
11
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
 
12
    License for more details.
 
13
 
 
14
    You should have received a copy of the GNU Library General Public License
 
15
    along with this library; see the file COPYING.LIB.  If not, write to the
 
16
    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
17
    02110-1301, USA.
 
18
*/
 
19
 
 
20
 
 
21
#include "renamefavoritedialog.h"
 
22
#include <QLabel>
 
23
#include <KLineEdit>
 
24
#include <KStandardGuiItem>
 
25
#include <KLocale>
 
26
#include <QVBoxLayout>
 
27
 
 
28
RenameFavoriteDialog::RenameFavoriteDialog(const QString& caption, const QString& text, const QString& value, const QString& defaultName, QWidget *parent )
 
29
  :KDialog( parent ),
 
30
   m_defaultName( defaultName )
 
31
{
 
32
  setCaption(caption);
 
33
  setButtons(Ok | Cancel | User1);
 
34
  setButtonGuiItem(User1, KGuiItem(i18n("Default Name")));
 
35
  setDefaultButton(Ok);
 
36
  setModal(true);
 
37
 
 
38
  QWidget *frame = new QWidget(this);
 
39
  QVBoxLayout *layout = new QVBoxLayout(frame);
 
40
  layout->setMargin(0);
 
41
 
 
42
  m_label = new QLabel(text, frame);
 
43
  m_label->setWordWrap(true);
 
44
  layout->addWidget(m_label);
 
45
 
 
46
  m_lineEdit = new KLineEdit(value, frame);
 
47
  m_lineEdit->setClearButtonShown(true);
 
48
  layout->addWidget(m_lineEdit);
 
49
 
 
50
  m_lineEdit->setFocus();
 
51
  m_label->setBuddy(m_lineEdit);
 
52
 
 
53
  layout->addStretch();
 
54
 
 
55
  connect(m_lineEdit, SIGNAL(textChanged(QString)),
 
56
          SLOT(slotEditTextChanged(QString)));
 
57
  connect(this, SIGNAL(user1Clicked()), this, SLOT(slotDefaultName()));
 
58
 
 
59
 
 
60
  setMainWidget(frame);
 
61
  slotEditTextChanged(value);
 
62
  setMinimumWidth(350);
 
63
 
 
64
}
 
65
 
 
66
RenameFavoriteDialog::~RenameFavoriteDialog()
 
67
{
 
68
}
 
69
 
 
70
void RenameFavoriteDialog::slotDefaultName()
 
71
{
 
72
  m_lineEdit->setText( m_defaultName );
 
73
}
 
74
 
 
75
void RenameFavoriteDialog::slotEditTextChanged(const QString& text)
 
76
{
 
77
  enableButton( Ok, !text.trimmed().isEmpty() );
 
78
}
 
79
 
 
80
 
 
81
QString RenameFavoriteDialog::newName() const
 
82
{
 
83
  return m_lineEdit->text();
 
84
}
 
85