SVN_SILENT made messages (.desktop file)
[kdepim.git] / knode / kngroupselectdialog.cpp
blob89e203a03b095f5c4a4cf17ab36dbfedb0251320
1 /*
2 KNode, the KDE newsreader
3 Copyright (c) 1999-2006 the KNode authors.
4 See file AUTHORS for details
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
15 #include "kngroupselectdialog.h"
17 #include "utilities.h"
19 #include <q3header.h>
20 #include <QCheckBox>
21 #include <QGridLayout>
22 #include <QLabel>
23 #include <klocale.h>
24 #include <kmessagebox.h>
25 #include <QPushButton>
28 KNGroupSelectDialog::KNGroupSelectDialog( QWidget *parent, KNNntpAccount::Ptr a, const QStringList &groups ) :
29 KNGroupBrowser(parent, i18n("Select Destinations"), a)
31 selView=new Q3ListView(page);
32 selView->addColumn( QString() );
33 selView->header()->hide();
34 listL->addWidget(selView, 1,2);
35 rightLabel->setText(i18n("Groups for this article:"));
36 subCB->setChecked(true);
38 KNGroupInfo info;
39 foreach ( const QString &group, groups ) {
40 info.name = group;
41 new GroupItem(selView, info);
44 connect(selView, SIGNAL(selectionChanged(Q3ListViewItem*)),
45 this, SLOT(slotItemSelected(Q3ListViewItem*)));
46 connect(groupView, SIGNAL(selectionChanged(Q3ListViewItem*)),
47 this, SLOT(slotItemSelected(Q3ListViewItem*)));
48 connect(groupView, SIGNAL(selectionChanged()),
49 this, SLOT(slotSelectionChanged()));
50 connect(arrowBtn1, SIGNAL(clicked()), this, SLOT(slotArrowBtn1()));
51 connect(arrowBtn2, SIGNAL(clicked()), this, SLOT(slotArrowBtn2()));
53 KNHelper::restoreWindowSize("groupSelDlg", this, QSize(659,364)); // optimized for 800x600
58 KNGroupSelectDialog::~KNGroupSelectDialog()
60 KNHelper::saveWindowSize("groupSelDlg", this->size());
65 void KNGroupSelectDialog::itemChangedState(CheckItem *it, bool s)
67 if(s)
68 new GroupItem(selView, it->info);
69 else
70 removeListItem(selView, it->info);
71 arrowBtn1->setEnabled(!s);
76 void KNGroupSelectDialog::updateItemState(CheckItem *it)
78 it->setChecked(itemInListView(selView, it->info));
79 if(it->info.subscribed && it->pixmap(0)==0)
80 it->setPixmap(0, pmGroup);
85 QString KNGroupSelectDialog::selectedGroups()const
87 QString ret;
88 Q3ListViewItemIterator it(selView);
89 bool moderated=false;
90 int count=0;
91 bool isFirst=true;
93 for(; it.current(); ++it) {
94 if(!isFirst)
95 ret+=',';
96 ret+=(static_cast<GroupItem*>(it.current()))->info.name;
97 isFirst=false;
98 count++;
99 if ((static_cast<GroupItem*>(it.current()))->info.status == KNGroup::moderated)
100 moderated=true;
103 if (moderated && (count>=2)) // warn the user
104 KMessageBox::information(parentWidget(),i18n("You are crossposting to a moderated newsgroup.\nPlease be aware that your article will not appear in any group\nuntil it has been approved by the moderators of the moderated group."),
105 QString(),"crosspostModeratedWarning");
107 return ret;
112 void KNGroupSelectDialog::slotItemSelected(Q3ListViewItem *it)
114 const QObject *s=sender();
116 if(s==groupView) {
117 selView->clearSelection();
118 arrowBtn2->setEnabled(false);
119 if(it)
120 arrowBtn1->setEnabled(!(static_cast<CheckItem*>(it))->isOn());
121 else
122 arrowBtn1->setEnabled(false);
124 else {
125 groupView->clearSelection();
126 arrowBtn1->setEnabled(false);
127 arrowBtn2->setEnabled((it!=0));
133 void KNGroupSelectDialog::slotSelectionChanged()
135 if (!groupView->selectedItem())
136 arrowBtn1->setEnabled(false);
141 void KNGroupSelectDialog::slotArrowBtn1()
143 CheckItem *i=static_cast<CheckItem*>(groupView->selectedItem());
145 if(i) {
146 new GroupItem(selView, i->info);
147 arrowBtn1->setEnabled(false);
148 i->setChecked(true);
154 void KNGroupSelectDialog::slotArrowBtn2()
156 GroupItem *i=static_cast<GroupItem*>(selView->selectedItem());
158 if(i) {
159 changeItemState(i->info, false);
160 delete i;
161 arrowBtn2->setEnabled(false);
166 // -----------------------------------------------------------------------------