Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Akonadi Contacts
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PIM
Akonadi Contacts
Commits
d2be21d7
Commit
d2be21d7
authored
Jan 21, 2009
by
Tobias Koenig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented name and display name widgets
svn path=/trunk/KDE/kdepim/kcontactmanager/editor/; revision=914793
parent
1aa969d3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
433 additions
and
6 deletions
+433
-6
akonadi/contact/editor/contacteditor.cpp
akonadi/contact/editor/contacteditor.cpp
+26
-6
akonadi/contact/editor/displaynameeditwidget.cpp
akonadi/contact/editor/displaynameeditwidget.cpp
+191
-0
akonadi/contact/editor/displaynameeditwidget.h
akonadi/contact/editor/displaynameeditwidget.h
+80
-0
akonadi/contact/editor/nameeditwidget.cpp
akonadi/contact/editor/nameeditwidget.cpp
+70
-0
akonadi/contact/editor/nameeditwidget.h
akonadi/contact/editor/nameeditwidget.h
+66
-0
No files found.
akonadi/contact/editor/contacteditor.cpp
View file @
d2be21d7
...
...
@@ -22,11 +22,15 @@
#include "addresseditwidget.h"
#include "dateeditwidget.h"
#include "displaynameeditwidget.h"
#include "emaileditwidget.h"
#include "imagewidget.h"
#include "nameeditwidget.h"
#include "phoneeditwidget.h"
#include "soundeditwidget.h"
#include <kconfig.h>
#include <kconfiggroup.h>
#include <klineedit.h>
#include <klocale.h>
#include <ktabwidget.h>
...
...
@@ -58,9 +62,9 @@ class ContactEditor::Private
KTabWidget
*
mTabWidget
;
// widgets from name group
KLineEdi
t
*
mNameWidget
;
NameEditWidge
t
*
mNameWidget
;
ImageWidget
*
mPhotoWidget
;
KLineEdi
t
*
mDisplayNameWidget
;
DisplayNameEditWidge
t
*
mDisplayNameWidget
;
KLineEdit
*
mNickNameWidget
;
SoundEditWidget
*
mPronunciationWidget
;
...
...
@@ -142,7 +146,7 @@ void ContactEditor::Private::initGuiContactTab()
label
->
setAlignment
(
Qt
::
AlignRight
|
Qt
::
AlignVCenter
);
nameLayout
->
addWidget
(
label
,
0
,
0
);
mNameWidget
=
new
KLineEdi
t
;
mNameWidget
=
new
NameEditWidge
t
;
label
->
setBuddy
(
mNameWidget
);
nameLayout
->
addWidget
(
mNameWidget
,
0
,
1
);
...
...
@@ -154,10 +158,13 @@ void ContactEditor::Private::initGuiContactTab()
label
->
setAlignment
(
Qt
::
AlignRight
|
Qt
::
AlignVCenter
);
nameLayout
->
addWidget
(
label
,
1
,
0
);
mDisplayNameWidget
=
new
KLineEdi
t
;
mDisplayNameWidget
=
new
DisplayNameEditWidge
t
;
label
->
setBuddy
(
mDisplayNameWidget
);
nameLayout
->
addWidget
(
mDisplayNameWidget
,
1
,
1
);
connect
(
mNameWidget
,
SIGNAL
(
nameChanged
(
const
KABC
::
Addressee
&
)
),
mDisplayNameWidget
,
SLOT
(
changeName
(
const
KABC
::
Addressee
&
)
)
);
label
=
new
QLabel
(
i18n
(
"Nickname:"
)
);
label
->
setAlignment
(
Qt
::
AlignRight
|
Qt
::
AlignVCenter
);
nameLayout
->
addWidget
(
label
,
2
,
0
);
...
...
@@ -400,20 +407,31 @@ void ContactEditor::Private::storeCustom( KABC::Addressee &contact, const QStrin
contact
.
insertCustom
(
"KADDRESSBOOK"
,
key
,
value
);
}
ContactEditor
::
ContactEditor
(
QWidget
*
parent
)
:
d
(
new
Private
(
this
)
)
ContactEditor
::
ContactEditor
(
QWidget
*
)
:
d
(
new
Private
(
this
)
)
{
d
->
initGui
();
KConfig
config
(
"kcontactmanagerrc"
);
KConfigGroup
group
(
&
config
,
"General"
);
d
->
mDisplayNameWidget
->
setDisplayType
(
DisplayNameEditWidget
::
DisplayType
(
group
.
readEntry
(
"DisplayNameType"
,
1
)
)
);
}
ContactEditor
::~
ContactEditor
()
{
KConfig
config
(
"kcontactmanagerrc"
);
KConfigGroup
group
(
&
config
,
"General"
);
group
.
writeEntry
(
"DisplayNameType"
,
(
int
)
d
->
mDisplayNameWidget
->
displayType
()
);
}
void
ContactEditor
::
loadContact
(
const
KABC
::
Addressee
&
contact
)
{
// name group
d
->
mPhotoWidget
->
loadContact
(
contact
);
d
->
mNameWidget
->
loadContact
(
contact
);
d
->
mDisplayNameWidget
->
loadContact
(
contact
);
d
->
mNickNameWidget
->
setText
(
contact
.
nickName
()
);
d
->
mPronunciationWidget
->
loadContact
(
contact
);
...
...
@@ -456,6 +474,8 @@ void ContactEditor::storeContact( KABC::Addressee &contact ) const
{
// name group
d
->
mPhotoWidget
->
storeContact
(
contact
);
d
->
mNameWidget
->
storeContact
(
contact
);
d
->
mDisplayNameWidget
->
storeContact
(
contact
);
contact
.
setNickName
(
d
->
mNickNameWidget
->
text
().
trimmed
()
);
d
->
mPronunciationWidget
->
storeContact
(
contact
);
...
...
akonadi/contact/editor/displaynameeditwidget.cpp
0 → 100644
View file @
d2be21d7
/*
This file is part of KContactManager.
Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "displaynameeditwidget.h"
#include <QtCore/QString>
#include <QtGui/QActionGroup>
#include <QtGui/QContextMenuEvent>
#include <QtGui/QHBoxLayout>
#include <QtGui/QMenu>
#include <kabc/addressee.h>
#include <kdialog.h>
#include <klineedit.h>
#include <klocale.h>
#include <ktoggleaction.h>
class
DisplayNameEditWidget
::
LineEdit
:
public
KLineEdit
{
public:
LineEdit
(
DisplayNameEditWidget
*
parent
)
:
KLineEdit
(
parent
),
mParent
(
parent
)
{
}
protected:
// context menu handling
virtual
void
contextMenuEvent
(
QContextMenuEvent
*
event
)
{
mParent
->
contextMenuEvent
(
event
);
}
private:
DisplayNameEditWidget
*
mParent
;
};
DisplayNameEditWidget
::
DisplayNameEditWidget
(
QWidget
*
parent
)
:
QWidget
(
parent
),
mDisplayType
(
FullName
)
{
QHBoxLayout
*
layout
=
new
QHBoxLayout
(
this
);
layout
->
setMargin
(
0
);
layout
->
setSpacing
(
KDialog
::
spacingHint
()
);
mView
=
new
LineEdit
(
this
);
layout
->
addWidget
(
mView
);
}
DisplayNameEditWidget
::~
DisplayNameEditWidget
()
{
}
void
DisplayNameEditWidget
::
setReadOnly
(
bool
readOnly
)
{
mView
->
setReadOnly
(
readOnly
&&
(
mDisplayType
!=
CustomName
)
);
}
void
DisplayNameEditWidget
::
setDisplayType
(
DisplayType
type
)
{
mDisplayType
=
type
;
updateView
();
}
DisplayNameEditWidget
::
DisplayType
DisplayNameEditWidget
::
displayType
()
const
{
return
mDisplayType
;
}
void
DisplayNameEditWidget
::
loadContact
(
const
KABC
::
Addressee
&
contact
)
{
mView
->
setText
(
contact
.
formattedName
()
);
mContact
=
contact
;
updateView
();
}
void
DisplayNameEditWidget
::
storeContact
(
KABC
::
Addressee
&
contact
)
const
{
contact
.
setFormattedName
(
mView
->
text
()
);
}
void
DisplayNameEditWidget
::
changeName
(
const
KABC
::
Addressee
&
contact
)
{
mContact
=
contact
;
mContact
.
setFormattedName
(
mView
->
text
()
);
updateView
();
}
void
DisplayNameEditWidget
::
contextMenuEvent
(
QContextMenuEvent
*
event
)
{
QMenu
menu
;
QActionGroup
*
group
=
new
QActionGroup
(
this
);
KToggleAction
*
simpleNameAction
=
new
KToggleAction
(
i18n
(
"Simple Name"
),
group
);
KToggleAction
*
fullNameAction
=
new
KToggleAction
(
i18n
(
"Full Name"
),
group
);
KToggleAction
*
reverseNameWithCommaAction
=
new
KToggleAction
(
i18n
(
"Reverse Name with Comma"
),
group
);
KToggleAction
*
reverseNameAction
=
new
KToggleAction
(
i18n
(
"Reverse Name"
),
group
);
KToggleAction
*
organizationNameAction
=
new
KToggleAction
(
i18n
(
"Organization Name"
),
group
);
KToggleAction
*
customNameAction
=
new
KToggleAction
(
i18n
(
"Custom"
),
group
);
group
->
setExclusive
(
true
);
menu
.
addAction
(
simpleNameAction
);
menu
.
addAction
(
fullNameAction
);
menu
.
addAction
(
reverseNameWithCommaAction
);
menu
.
addAction
(
reverseNameAction
);
menu
.
addAction
(
organizationNameAction
);
menu
.
addAction
(
customNameAction
);
if
(
mDisplayType
==
SimpleName
)
simpleNameAction
->
setChecked
(
true
);
if
(
mDisplayType
==
FullName
)
fullNameAction
->
setChecked
(
true
);
if
(
mDisplayType
==
ReverseNameWithComma
)
reverseNameWithCommaAction
->
setChecked
(
true
);
if
(
mDisplayType
==
ReverseName
)
reverseNameAction
->
setChecked
(
true
);
if
(
mDisplayType
==
Organization
)
organizationNameAction
->
setChecked
(
true
);
if
(
mDisplayType
==
CustomName
)
customNameAction
->
setChecked
(
true
);
QAction
*
result
=
menu
.
exec
(
event
->
globalPos
()
);
if
(
result
==
simpleNameAction
)
mDisplayType
=
SimpleName
;
else
if
(
result
==
fullNameAction
)
mDisplayType
=
FullName
;
else
if
(
result
==
reverseNameWithCommaAction
)
mDisplayType
=
ReverseNameWithComma
;
else
if
(
result
==
reverseNameAction
)
mDisplayType
=
ReverseName
;
else
if
(
result
==
organizationNameAction
)
mDisplayType
=
Organization
;
else
if
(
result
==
customNameAction
)
mDisplayType
=
CustomName
;
delete
group
;
updateView
();
}
void
DisplayNameEditWidget
::
updateView
()
{
QString
text
;
switch
(
mDisplayType
)
{
case
SimpleName
:
text
=
mContact
.
givenName
()
+
' '
+
mContact
.
familyName
();
break
;
case
FullName
:
text
=
mContact
.
assembledName
();
break
;
case
ReverseNameWithComma
:
text
=
mContact
.
familyName
()
+
", "
+
mContact
.
givenName
();
break
;
case
ReverseName
:
text
=
mContact
.
familyName
()
+
' '
+
mContact
.
givenName
();
break
;
case
Organization
:
text
=
mContact
.
organization
();
break
;
case
CustomName
:
text
=
mContact
.
formattedName
();
default:
break
;
}
mView
->
setText
(
text
);
mView
->
setReadOnly
(
mDisplayType
!=
CustomName
);
}
#include "displaynameeditwidget.moc"
akonadi/contact/editor/displaynameeditwidget.h
0 → 100644
View file @
d2be21d7
/*
This file is part of KContactManager.
Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef DISPLAYNAMEEDITWIDGET_H
#define DISPLAYNAMEEDITWIDGET_H
#include <QtGui/QWidget>
#include <kabc/addressee.h>
/**
* @short A widget for editing the display name of a contact.
*
* The widget will either use a predefined schema for formatting
* the name or a custom one.
*/
class
DisplayNameEditWidget
:
public
QWidget
{
Q_OBJECT
public:
/**
* Describes what the display name should look like.
*/
enum
DisplayType
{
CustomName
,
///< Let the user input a display name
SimpleName
,
///< A name of the form: givenName familyName
FullName
,
///< A name of the form: prefix givenName additionalName familyName suffix
ReverseNameWithComma
,
///< A name of the form: familyName, givenName
ReverseName
,
///< A name of the form: familyName givenName
Organization
///< The organization name
};
explicit
DisplayNameEditWidget
(
QWidget
*
parent
=
0
);
~
DisplayNameEditWidget
();
void
loadContact
(
const
KABC
::
Addressee
&
contact
);
void
storeContact
(
KABC
::
Addressee
&
contact
)
const
;
void
setReadOnly
(
bool
readOnly
);
void
setDisplayType
(
DisplayType
type
);
DisplayType
displayType
()
const
;
public
Q_SLOTS
:
void
changeName
(
const
KABC
::
Addressee
&
contact
);
protected:
// context menu handling
virtual
void
contextMenuEvent
(
QContextMenuEvent
*
);
private:
void
updateView
();
class
LineEdit
;
LineEdit
*
mView
;
DisplayType
mDisplayType
;
KABC
::
Addressee
mContact
;
};
#endif
akonadi/contact/editor/nameeditwidget.cpp
0 → 100644
View file @
d2be21d7
/*
This file is part of KContactManager.
Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "nameeditwidget.h"
#include <QtCore/QString>
#include <QtGui/QHBoxLayout>
#include <kabc/addressee.h>
#include <kdialog.h>
#include <klineedit.h>
NameEditWidget
::
NameEditWidget
(
QWidget
*
parent
)
:
QWidget
(
parent
)
{
QHBoxLayout
*
layout
=
new
QHBoxLayout
(
this
);
layout
->
setMargin
(
0
);
layout
->
setSpacing
(
KDialog
::
spacingHint
()
);
mNameEdit
=
new
KLineEdit
;
layout
->
addWidget
(
mNameEdit
);
connect
(
mNameEdit
,
SIGNAL
(
textChanged
(
const
QString
&
)
),
SLOT
(
textChanged
(
const
QString
&
)
)
);
}
NameEditWidget
::~
NameEditWidget
()
{
}
void
NameEditWidget
::
setReadOnly
(
bool
readOnly
)
{
mNameEdit
->
setReadOnly
(
readOnly
);
}
void
NameEditWidget
::
loadContact
(
const
KABC
::
Addressee
&
contact
)
{
mNameEdit
->
setText
(
contact
.
assembledName
()
);
}
void
NameEditWidget
::
storeContact
(
KABC
::
Addressee
&
contact
)
const
{
contact
.
setNameFromString
(
mNameEdit
->
text
()
);
}
void
NameEditWidget
::
textChanged
(
const
QString
&
text
)
{
KABC
::
Addressee
contact
;
contact
.
setNameFromString
(
text
);
emit
nameChanged
(
contact
);
}
#include "nameeditwidget.moc"
akonadi/contact/editor/nameeditwidget.h
0 → 100644
View file @
d2be21d7
/*
This file is part of KContactManager.
Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef NAMEEDITWIDGET_H
#define NAMEEDITWIDGET_H
#include <QtGui/QWidget>
#include <kabc/addressee.h>
class
KLineEdit
;
/**
* @short A widget for editing the name of a contact.
*
* The widget will show the name in a lineedit
* and provides a button to open a dialog for editing of
* the single name components.
*/
class
NameEditWidget
:
public
QWidget
{
Q_OBJECT
public:
explicit
NameEditWidget
(
QWidget
*
parent
=
0
);
~
NameEditWidget
();
void
loadContact
(
const
KABC
::
Addressee
&
contact
);
void
storeContact
(
KABC
::
Addressee
&
contact
)
const
;
void
setReadOnly
(
bool
readOnly
);
Q_SIGNALS:
/**
* This signal is emitted whenever the name has been changed.
*
* @param contact A dummy contact that contains only the name components.
*/
void
nameChanged
(
const
KABC
::
Addressee
&
contact
);
private
Q_SLOTS
:
void
textChanged
(
const
QString
&
);
private:
KLineEdit
*
mNameEdit
;
KABC
::
Addressee
mContact
;
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment