From a66fd5afde517e9a61e74fc17df617297f134c96 Mon Sep 17 00:00:00 2001 From: alwin Date: Sat, 06 Mar 2004 12:36:55 +0000 Subject: standalone dlg for (un-)subscribing newsgroups. May be integrated into the standard nntp-settings-dialog, too. --- diff --git a/noncore/net/mail/.cvsignore b/noncore/net/mail/.cvsignore index 4957719..3819f80 100644 --- a/noncore/net/mail/.cvsignore +++ b/noncore/net/mail/.cvsignore @@ -28,4 +28,5 @@ sendmailprogressui.cpp sendmailprogressui.h selectstoreui.cpp selectstoreui.h - +nntpgroupsui.cpp +nntpgroupsui.h diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp index e925d8d..0d636a4 100644 --- a/noncore/net/mail/accountitem.cpp +++ b/noncore/net/mail/accountitem.cpp @@ -2,6 +2,7 @@ #include "accountitem.h" #include "accountview.h" #include "newmaildir.h" +#include "nntpgroupsdlg.h" #include "defines.h" /* OPIE */ @@ -284,6 +285,7 @@ QPopupMenu * NNTPviewItem::getContextMenu() { m->insertItem(QObject::tr("Disconnect",contextName),0); m->insertItem(QObject::tr("Set offline",contextName),1); + m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2); } else { @@ -293,6 +295,14 @@ QPopupMenu * NNTPviewItem::getContextMenu() return m; } +void NNTPviewItem::subscribeGroups() +{ + NNTPGroupsDlg dlg(account); + if (QPEApplication::execDialog(&dlg)== QDialog::Accepted ){ + refresh(); + } +} + void NNTPviewItem::disconnect() { QListViewItem *child = firstChild(); @@ -328,6 +338,9 @@ void NNTPviewItem::contextMenuSelected(int which) case 1: setOnOffline(); break; + case 2: + subscribeGroups(); + break; } } @@ -367,7 +380,7 @@ QPopupMenu * NNTPfolderItem::getContextMenu() if (m) { m->insertItem(QObject::tr("Refresh header list",contextName),0); - m->insertItem(QObject::tr("Move/Copie all mails",contextName),1); + m->insertItem(QObject::tr("Copy all postings",contextName),1); } return m; } diff --git a/noncore/net/mail/accountitem.h b/noncore/net/mail/accountitem.h index a138c9b..f3c0f5d 100644 --- a/noncore/net/mail/accountitem.h +++ b/noncore/net/mail/accountitem.h @@ -96,6 +96,7 @@ protected: AbstractMail *wrapper; void disconnect(); void setOnOffline(); + void subscribeGroups(); }; class NNTPfolderItem : public AccountViewItem diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro index 7e0de2b..005a839 100644 --- a/noncore/net/mail/mail.pro +++ b/noncore/net/mail/mail.pro @@ -14,7 +14,9 @@ HEADERS = defines.h \ statuswidget.h \ newmaildir.h \ selectstore.h \ - selectsmtp.h + selectsmtp.h \ + nntpgroups.h \ + nntpgroupsdlg.h SOURCES = main.cpp \ opiemail.cpp \ @@ -31,7 +33,9 @@ SOURCES = main.cpp \ statuswidget.cpp \ newmaildir.cpp \ selectstore.cpp \ - selectsmtp.cpp + selectsmtp.cpp \ + nntpgroups.cpp \ + nntpgroupsdlg.cpp INTERFACES = editaccountsui.ui \ selectmailtypeui.ui \ @@ -44,7 +48,8 @@ INTERFACES = editaccountsui.ui \ settingsdialogui.ui \ statuswidgetui.ui \ newmaildirui.ui \ - selectstoreui.ui + selectstoreui.ui \ + nntpgroupsui.ui INCLUDEPATH += $(OPIEDIR)/include diff --git a/noncore/net/mail/nntpgroups.cpp b/noncore/net/mail/nntpgroups.cpp new file mode 100644 index 0000000..97b1985 --- a/dev/null +++ b/noncore/net/mail/nntpgroups.cpp @@ -0,0 +1,57 @@ +#include "nntpgroups.h" + +#include + +#include + +NNTPGroups::NNTPGroups(NNTPaccount *account, QWidget* parent, const char* name, WFlags fl) + : NNTPGroupsUI(parent,name,fl),subscribedGroups() +{ + m_Account = account; + fillGroups(); +} + +NNTPGroups::~NNTPGroups() +{ + +} + +void NNTPGroups::slotGetNG() +{ + if (!m_Account) return; + GroupListView->clear(); + NNTPwrapper tmp( m_Account ); + QStringList list = tmp.listAllNewsgroups(); + for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { + QCheckListItem *item; + item = new QCheckListItem( GroupListView, (*it), QCheckListItem::CheckBox ); + if ( subscribedGroups.contains( (*it) ) >= 1 ) { + item->setOn( true ); + } + } +} + +void NNTPGroups::fillGroups() +{ + if (!m_Account) return; + subscribedGroups = m_Account->getGroups(); + for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { + QCheckListItem *item; + item = new QCheckListItem( GroupListView, (*it), QCheckListItem::CheckBox ); + item->setOn( true ); + } +} + +void NNTPGroups::storeValues() +{ + if (!m_Account) return; + QListViewItemIterator list_it( GroupListView ); + subscribedGroups.clear(); + for ( ; list_it.current(); ++list_it ) { + if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { + qDebug(list_it.current()->text(0) ); + subscribedGroups.append( list_it.current()->text(0) ); + } + } + m_Account->setGroups( subscribedGroups ); +} diff --git a/noncore/net/mail/nntpgroups.h b/noncore/net/mail/nntpgroups.h new file mode 100644 index 0000000..8cc2e8b --- a/dev/null +++ b/noncore/net/mail/nntpgroups.h @@ -0,0 +1,33 @@ +#ifndef __NNTPGROUPS_WINDOW__ +#define __NNTPGROUPS_WINDOW__ + +#include "nntpgroupsui.h" + +#include + +class NNTPaccount; +class QStringList; + +class NNTPGroups:public NNTPGroupsUI +{ + Q_OBJECT +public: + NNTPGroups(NNTPaccount *account, QWidget* parent = 0, const char* name = 0, WFlags fl = 0); + virtual ~NNTPGroups(); + /* must be called from external. + * it will store the new subscription list into the account + * but don't save them, this must be done by the calling class. + */ + void storeValues(); + +protected slots: + virtual void slotGetNG(); + +protected: + virtual void fillGroups(); + + NNTPaccount*m_Account; + QStringList subscribedGroups; +}; + +#endif diff --git a/noncore/net/mail/nntpgroupsdlg.cpp b/noncore/net/mail/nntpgroupsdlg.cpp new file mode 100644 index 0000000..752ce3c --- a/dev/null +++ b/noncore/net/mail/nntpgroupsdlg.cpp @@ -0,0 +1,29 @@ +#include "nntpgroupsdlg.h" +#include "nntpgroups.h" + +#include + +#include + +NNTPGroupsDlg::NNTPGroupsDlg(NNTPaccount *account,QWidget * parent, const char * name) + : QDialog(parent,name,true) +{ + setCaption(tr("Subscribed newsgroups")); + m_Account = account; + QVBoxLayout*dlglayout = new QVBoxLayout(this); + dlglayout->setSpacing(2); + dlglayout->setMargin(1); + groupsWidget = new NNTPGroups(account,this); + dlglayout->addWidget(groupsWidget); +} + +NNTPGroupsDlg::~NNTPGroupsDlg() +{ +} + +void NNTPGroupsDlg::accept() +{ + groupsWidget->storeValues(); + m_Account->save(); + QDialog::accept(); +} diff --git a/noncore/net/mail/nntpgroupsdlg.h b/noncore/net/mail/nntpgroupsdlg.h new file mode 100644 index 0000000..a21bac7 --- a/dev/null +++ b/noncore/net/mail/nntpgroupsdlg.h @@ -0,0 +1,24 @@ +#ifndef __NNTP_GROUP_DLG_H +#define __NNTP_GROUP_DLG_H + +#include + +class NNTPGroups; +class NNTPaccount; + +class NNTPGroupsDlg : public QDialog +{ + Q_OBJECT +public: + NNTPGroupsDlg(NNTPaccount *account,QWidget * parent=0, const char * name=0); + virtual ~NNTPGroupsDlg(); + +protected: + NNTPGroups*groupsWidget; + NNTPaccount*m_Account; + +protected slots: + virtual void accept (); +}; + +#endif diff --git a/noncore/net/mail/nntpgroupsui.ui b/noncore/net/mail/nntpgroupsui.ui new file mode 100644 index 0000000..93f487b --- a/dev/null +++ b/noncore/net/mail/nntpgroupsui.ui @@ -0,0 +1,88 @@ + +NNTPGroupsUI + + QWidget + + name + NNTPGroupsUI + + + geometry + + 0 + 0 + 356 + 406 + + + + caption + newsgroupslist + + + layoutMargin + + + layoutSpacing + + + + margin + 2 + + + spacing + 2 + + + QListView + + + text + Newsgroups + + + clickable + true + + + resizeable + true + + + + name + GroupListView + + + whatsThis + List of groups from the server. On start, only subscribed groups are listed. + + + + QPushButton + + name + GetNGButton + + + text + Get newsgroup list from server + + + whatsThis + Retrieve the list of groups from server + + + + + + + GetNGButton + clicked() + NNTPGroupsUI + slotGetNG() + + slotGetNG() + + -- cgit v0.9.0.2