• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

knode

  • sources
  • kde-4.12
  • kdepim
  • knode
kngrouppropdlg.cpp
Go to the documentation of this file.
1 /*
2  KNode, the KDE newsreader
3  Copyright (c) 1999-2005 the KNode authors.
4  See file AUTHORS for details
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  You should have received a copy of the GNU General Public License
11  along with this program; if not, write to the Free Software Foundation,
12  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
13 */
14 
15 #include "kngrouppropdlg.h"
16 
17 #include "configuration/identity_widget.h"
18 #include "knconfigmanager.h"
19 #include "knconfigwidgets.h"
20 #include "knglobals.h"
21 #include "kngroup.h"
22 #include "utilities.h"
23 #include "utils/locale.h"
24 
25 #include <QGroupBox>
26 #include <QLabel>
27 #include <QCheckBox>
28 #include <QVBoxLayout>
29 #include <QGridLayout>
30 #include <QComboBox>
31 
32 #include <KCharsets>
33 #include <klocale.h>
34 #include <klineedit.h>
35 #include <kvbox.h>
36 
37 
38 
39 KNGroupPropDlg::KNGroupPropDlg( KNGroup *group, QWidget *parent )
40  : KPageDialog( parent ),
41  g_rp(group), n_ickChanged(false)
42 {
43  setFaceType( Tabbed );
44  setCaption( i18nc( "@title:window %1=newsgroup name", "Properties of %1", group->groupname() ) );
45  setButtons( Ok|Cancel|Help );
46  setDefaultButton( Ok );
47 
48  // General tab ===============================================
49 
50  QWidget *page = new QWidget( this );
51  addPage( page, i18nc( "@title:tab", "General" ) );
52  QVBoxLayout *pageL = new QVBoxLayout(page);
53  pageL->setSpacing(3);
54 
55  // settings
56  QGroupBox *gb = new QGroupBox( i18nc( "@title:group", "Settings"), page );
57  pageL->addWidget(gb);
58  QGridLayout *grpL=new QGridLayout(gb);
59  grpL->setSpacing(5);
60  grpL->setMargin(15);
61 
62  grpL->addItem( new QSpacerItem( 0, fontMetrics().lineSpacing()-9), 0, 0 );
63 
64  n_ick=new KLineEdit(gb);
65  if (g_rp->hasName())
66  n_ick->setText(g_rp->name());
67  QLabel *l = new QLabel( i18nc( "@label:textbox Alternative name of a newsgroup", "Nickname:" ), gb );
68  l->setBuddy(n_ick);
69  grpL->addWidget(l,1,0);
70  grpL->addWidget(n_ick,1,1, 1,2);
71 
72  u_seCharset = new QCheckBox( i18nc( "@label:listbox", "Use different default charset:" ), gb );
73  u_seCharset->setChecked(g_rp->useCharset());
74  grpL->addWidget(u_seCharset,2,0, 1, 2 );
75 
76  c_harset=new QComboBox(gb);
77  c_harset->setEditable(false);
78  c_harset->addItems( KNode::Utilities::Locale::encodings() );
79  QString defaultCsDesc = KGlobal::charsets()->descriptionForEncoding( QString::fromLatin1( g_rp->defaultCharset() ) );
80  c_harset->setCurrentIndex( c_harset->findText( defaultCsDesc ) );
81  c_harset->setEnabled(g_rp->useCharset());
82  connect(u_seCharset, SIGNAL(toggled(bool)), c_harset, SLOT(setEnabled(bool)));
83  grpL->addWidget(c_harset, 2,2);
84 
85  grpL->setColumnStretch(1,1);
86  grpL->setColumnStretch(2,2);
87 
88  // group name & description
89  gb = new QGroupBox( i18nc( "@title:group", "Description" ), page );
90  pageL->addWidget(gb);
91  grpL=new QGridLayout(gb);
92  grpL->setSpacing(5);
93  grpL->setMargin(15);
94 
95  grpL->addItem( new QSpacerItem( 0, fontMetrics().lineSpacing()-9), 0, 0 );
96 
97  l = new QLabel( i18nc( "@label name of a newsgroup", "Name:" ), gb );
98  grpL->addWidget(l,1,0);
99  l=new QLabel(group->groupname(),gb);
100  grpL->addWidget(l,1,2);
101 
102  l = new QLabel( i18nc( "@label description of a newsgroup", "Description:" ), gb );
103  grpL->addWidget(l,2,0);
104  l=new QLabel(g_rp->description(),gb);
105  grpL->addWidget(l,2,2);
106 
107  l = new QLabel( i18nc( "@label status of posting to a newsgroup", "Status:" ), gb );
108  grpL->addWidget(l,3,0);
109  QString status;
110  switch (g_rp->status()) {
111  case KNGroup::unknown: status = i18nc( "posting status", "unknown" );
112  break;
113  case KNGroup::readOnly: status=i18n("posting forbidden");
114  break;
115  case KNGroup::postingAllowed: status=i18n("posting allowed");
116  break;
117  case KNGroup::moderated: status = i18nc( "posting status", "moderated" );
118  break;
119  }
120  l=new QLabel(status,gb);
121  grpL->addWidget(l,3,2);
122 
123  grpL->addItem( new QSpacerItem(20, 0 ), 0, 1 );
124  grpL->setColumnStretch(2,1);
125 
126  // statistics
127  gb = new QGroupBox( i18nc( "@title:group", "Statistics" ), page );
128  pageL->addWidget(gb);
129  grpL=new QGridLayout(gb);
130  grpL->setSpacing(5);
131  grpL->setMargin(15);
132 
133  grpL->addItem( new QSpacerItem( 0, fontMetrics().lineSpacing()-9), 0, 0 );
134 
135  l=new QLabel(i18n("Articles:"), gb);
136  grpL->addWidget(l,1,0);
137  l=new QLabel(QString::number(g_rp->count()),gb);
138  grpL->addWidget(l,1,2);
139 
140  l=new QLabel(i18n("Unread articles:"), gb);
141  grpL->addWidget(l,2,0);
142  l=new QLabel(QString::number(g_rp->count()-g_rp->readCount()),gb);
143  grpL->addWidget(l,2,2);
144 
145  l=new QLabel(i18n("New articles:"), gb);
146  grpL->addWidget(l,3,0);
147  l=new QLabel(QString::number(g_rp->newCount()),gb);
148  grpL->addWidget(l,3,2);
149 
150  l=new QLabel(i18n("Threads with unread articles:"), gb);
151  grpL->addWidget(l,4,0);
152  l=new QLabel(QString::number(g_rp->statThrWithUnread()),gb);
153  grpL->addWidget(l,4,2);
154 
155  l=new QLabel(i18n("Threads with new articles:"), gb);
156  grpL->addWidget(l,5,0);
157  l=new QLabel(QString::number(g_rp->statThrWithNew()),gb);
158  grpL->addWidget(l,5,2);
159 
160  grpL->addItem( new QSpacerItem(20, 0 ), 0, 1 );
161  grpL->setColumnStretch(2,1);
162 
163  pageL->addStretch(1);
164 
165  // Specific Identity tab =========================================
166  i_dWidget = new KNode::IdentityWidget( g_rp, knGlobals.componentData(), this );
167  addPage( i_dWidget, i18nc( "@title:tab", "Identity" ) );
168 
169  // per server cleanup configuration
170  mCleanupWidget = new KNode::GroupCleanupWidget( g_rp->cleanupConfig(), this );
171  addPage( mCleanupWidget, i18nc( "@title:tab", "Cleanup" ) );
172  mCleanupWidget->load();
173 
174  KNHelper::restoreWindowSize("groupPropDLG", this, sizeHint());
175  connect(this,SIGNAL(okClicked()),SLOT(slotOk()));
176 }
177 
178 
179 
180 KNGroupPropDlg::~KNGroupPropDlg()
181 {
182  KNHelper::saveWindowSize("groupPropDLG", size());
183 }
184 
185 
186 
187 void KNGroupPropDlg::slotOk()
188 {
189  if( !(g_rp->name()==n_ick->text()) ) {
190  g_rp->setName(n_ick->text());
191  n_ickChanged=true;
192  }
193 
194  i_dWidget->save();
195  mCleanupWidget->save();
196 
197  g_rp->setUseCharset(u_seCharset->isChecked());
198  g_rp->setDefaultCharset( KGlobal::charsets()->encodingForName( c_harset->currentText() ).toLatin1() );
199 
200  accept();
201 }
KNGroup::defaultCharset
const QByteArray defaultCharset()
Returns the default charset for this group.
Definition: kngroup.h:152
KNode::IdentityWidget
Configuration widget for an identity.
Definition: identity_widget.h:39
KPageDialog
KNHelper::saveWindowSize
static void saveWindowSize(const QString &name, const QSize &s)
Definition: utilities.cpp:205
KNode::GroupCleanupWidget::load
void load()
Definition: knconfigwidgets.cpp:1558
KNGroup::cleanupConfig
KNode::Cleanup * cleanupConfig() const
Returns the cleanup configuration of this group (might be empty).
Definition: kngroup.h:187
KNode::Utilities::Locale::encodings
static QStringList encodings()
Returns a list of encodings along with a description.
Definition: locale.cpp:120
KNGroupPropDlg::slotOk
void slotOk()
Definition: kngrouppropdlg.cpp:187
KNGroup::setDefaultCharset
void setDefaultCharset(const QByteArray &s)
Sets the default charset for this group.
Definition: kngroup.h:156
KNGroup::moderated
Definition: kngroup.h:50
utilities.h
KNGroup::name
const QString & name()
Returns the collection name.
Definition: kngroup.cpp:68
QWidget
KNGroupPropDlg::mCleanupWidget
KNode::GroupCleanupWidget * mCleanupWidget
Definition: kngrouppropdlg.h:46
KNGroup::description
QString description() const
Returns the group description.
Definition: kngroup.h:75
KNGroup::readCount
int readCount() const
Definition: kngroup.h:92
KNHelper::restoreWindowSize
static void restoreWindowSize(const QString &name, QWidget *d, const QSize &defaultSize)
Definition: utilities.cpp:212
knconfigwidgets.h
KNGroupPropDlg::~KNGroupPropDlg
~KNGroupPropDlg()
Definition: kngrouppropdlg.cpp:180
identity_widget.h
KNode::GroupCleanupWidget::save
void save()
Definition: knconfigwidgets.cpp:1574
KNGroup
Representation of a news group.
Definition: kngroup.h:41
KNCollection::setName
void setName(const QString &s)
Sets the collection name.
Definition: kncollection.h:78
kngroup.h
KNGroup::groupname
const QString & groupname()
Definition: kngroup.h:72
KNGroupPropDlg::c_harset
QComboBox * c_harset
Definition: kngrouppropdlg.h:49
KNGroupPropDlg::n_ickChanged
bool n_ickChanged
Definition: kngrouppropdlg.h:44
KNGroup::readOnly
Definition: kngroup.h:50
QComboBox
KNGroup::postingAllowed
Definition: kngroup.h:50
KNGroupPropDlg::u_seCharset
QCheckBox * u_seCharset
Definition: kngrouppropdlg.h:48
KNCollection::count
int count() const
Definition: kncollection.h:81
KNGroup::unknown
Definition: kngroup.h:50
KNGroup::useCharset
bool useCharset()
Definition: kngroup.h:157
QGroupBox
KNGroupPropDlg::n_ick
KLineEdit * n_ick
Definition: kngrouppropdlg.h:47
kngrouppropdlg.h
locale.h
KNode::IdentityWidget::save
virtual void save()
Reimplemented from KCModule::save();.
Definition: identity_widget.cpp:79
KNode::GroupCleanupWidget
Configuration widget for group expireration.
Definition: knconfigwidgets.h:540
KNGroupPropDlg::i_dWidget
KNode::IdentityWidget * i_dWidget
Definition: kngrouppropdlg.h:45
knglobals.h
KLineEdit
KNGroupPropDlg::g_rp
KNGroup * g_rp
Definition: kngrouppropdlg.h:43
QLabel
KNGroup::statThrWithUnread
int statThrWithUnread()
Definition: kngroup.cpp:1053
KNGroup::newCount
int newCount() const
count + numbers
Definition: kngroup.h:82
knconfigmanager.h
KNGroup::hasName
bool hasName() const
name
Definition: kngroup.h:70
knGlobals
#define knGlobals
Keep compatibility with the old way.
Definition: knglobals.h:28
KNGroup::status
Status status() const
Returns the posting rights of this group.
Definition: kngroup.h:176
KNGroupPropDlg::KNGroupPropDlg
KNGroupPropDlg(KNGroup *group, QWidget *parent=0)
Definition: kngrouppropdlg.cpp:39
KNGroup::statThrWithNew
int statThrWithNew()
Definition: kngroup.cpp:1044
KNGroup::setUseCharset
void setUseCharset(bool b)
Definition: kngroup.h:158
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:58:36 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

knode

Skip menu "knode"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal