File: look_edit.cc

package info (click to toggle)
kdeutils 4%3A2.2.2-9.2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 8,892 kB
  • ctags: 10,879
  • sloc: cpp: 82,942; sh: 11,754; ansic: 4,638; perl: 1,852; makefile: 706; python: 258
file content (143 lines) | stat: -rw-r--r-- 4,133 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/* -*- C++ -*-
   This file implements the editing look.

   the KDE addressbook

   $ Author: Mirko Boehm $
   $ Copyright: (C) 1996-2000, Mirko Boehm $
   $ Contact: mirko@kde.org
         http://www.kde.org $
   $ License: GPL with the following explicit clarification:
         This code may be linked against any version of the Qt toolkit
         from Troll Tech, Norway. $

   $Revision: 1.24 $	 
*/

#include "look_edit_basictab.h"
#include "look_edit.h"
#include "look_edit_tabperson.h"
#include "look_edit_tabaddresses.h"
#include "look_edit_tabtelephone.h"
#include "look_edit_tabuser.h"
#include <qtabwidget.h>
#include <kmessagebox.h>
#include <klocale.h>
#include <kdebug.h>
#include <kabapi.h>
#include <qconfigDB.h>
#include <qlist.h>

KABEditLook::KABEditLook(KabAPI* api, QWidget* parent, const char* name)
  : KABBasicLook(api, parent, name)
{
  Section *configsection;
  KeyValueMap *keys;
  QString headline=i18n("User Fields");
  // -----
  tabs=new QTabWidget(this);
  if(tabs==0)
    {
      KMessageBox::sorry
	(this, i18n("Out of memory."),
	 i18n("General failure."));
      ::exit(-1);
    }
  tabbirthday=new TabBirthday(api, tabs);
  tabperson=new TabPerson(api, tabs);
  tabcomment=new TabComment(api, tabs);
  tabuser=new TabUser(api, tabs);
  tabtelephone=new TabTelephone(api, tabs);
  tabaddresses=new TabAddresses(api, tabs);
  if(tabbirthday==0 || tabperson==0 || tabcomment==0 || tabuser==0
     || tabtelephone==0 || tabaddresses==0)
    {
      KMessageBox::sorry
	(this, i18n("Out of memory."),
	 i18n("General failure."));
      ::exit(-1);
    }
  // ----- find out the caption of the user fields tab:
  if(db!=0) // be careful to avoid segfaults in the ctor
    {
      configsection=db->addressbook()->configurationSection();
      if(configsection!=0)
	{
	  keys=configsection->getKeys();
	  keys->get("user_headline", headline);

         if( "(User fields)" == headline )
            headline = i18n("(User fields)");                                   
	}
      tabuser->configure(db);
    }
  tabs->addTab(tabperson, i18n("&Person"));
  tabs->addTab(tabtelephone, i18n("&Telephone"));
  tabs->addTab(tabaddresses, i18n("&Addresses"));
  tabs->addTab(tabbirthday, i18n("&Birthday"));
  tabs->addTab(tabcomment, i18n("Comment"));
  tabs->addTab(tabuser, headline);
  allTabs.append((TabBasic**)&tabperson);
  allTabs.append((TabBasic**)&tabaddresses);
  allTabs.append((TabBasic**)&tabtelephone);
  allTabs.append((TabBasic**)&tabbirthday);
  allTabs.append((TabBasic**)&tabcomment);
  allTabs.append((TabBasic**)&tabuser);
  // -----
  connect(tabbirthday, SIGNAL(changed()), SLOT(changed()));
  connect(tabaddresses, SIGNAL(changed()), SLOT(changed()));
  connect(tabtelephone, SIGNAL(changed()), SLOT(changed()));
  connect(tabperson, SIGNAL(changed()), SLOT(changed()));
  connect(tabperson, SIGNAL(saveMe()), SLOT(saveMeSlot()));
  connect(tabcomment, SIGNAL(changed()), SLOT(changed()));
  connect(tabuser, SIGNAL(changed()), SLOT(changed()));
}

void KABEditLook::resizeEvent(QResizeEvent*)
{
  tabs->setGeometry(0, 0, width(), height());
}

void KABEditLook::changed()
{
  register bool GUARD; GUARD=false;
  // kdDebug() << "KABEditLook::changed: entry changed." << endl;
  emit(entryChanged()); // signal from basic look
}

void KABEditLook::saveMeSlot()
{
  emit(saveMe());
}

void KABEditLook::setEntry(const AddressBook::Entry& entry)
{
  unsigned int count;
  // ----- set the contents in all tabs:
  for(count=0; count<allTabs.count(); ++count)
    {
      (*allTabs.at(count))->setContents(entry);
    }
  // ----- call the setEntry method of the base class:
  KABBasicLook::setEntry(entry);
}

void KABEditLook::getEntry(AddressBook::Entry& entry)
{
  unsigned int count;
  // ----- set the contents in all tabs:
  for(count=0; count<allTabs.count(); ++count)
    { // store the changes in our own entry object:
      (*allTabs.at(count))->storeContents(current);
    }
  // ----- call the setEntry method of the base class:
  KABBasicLook::getEntry(entry);
}

QSize KABEditLook::minimumSizeHint() const
{
  return tabs->minimumSizeHint();
}


#include "look_edit.moc"