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"
21 #include <QGridLayout>
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);
39 foreach ( const QString
&group
, groups
) {
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
)
68 new GroupItem(selView
, it
->info
);
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
88 Q3ListViewItemIterator
it(selView
);
93 for(; it
.current(); ++it
) {
96 ret
+=(static_cast<GroupItem
*>(it
.current()))->info
.name
;
99 if ((static_cast<GroupItem
*>(it
.current()))->info
.status
== KNGroup::moderated
)
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");
112 void KNGroupSelectDialog::slotItemSelected(Q3ListViewItem
*it
)
114 const QObject
*s
=sender();
117 selView
->clearSelection();
118 arrowBtn2
->setEnabled(false);
120 arrowBtn1
->setEnabled(!(static_cast<CheckItem
*>(it
))->isOn());
122 arrowBtn1
->setEnabled(false);
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());
146 new GroupItem(selView
, i
->info
);
147 arrowBtn1
->setEnabled(false);
154 void KNGroupSelectDialog::slotArrowBtn2()
156 GroupItem
*i
=static_cast<GroupItem
*>(selView
->selectedItem());
159 changeItemState(i
->info
, false);
161 arrowBtn2
->setEnabled(false);
166 // -----------------------------------------------------------------------------
168 #include "kngroupselectdialog.moc"