author | zautrix <zautrix> | 2004-09-16 20:39:34 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-16 20:39:34 (UTC) |
commit | b44edfb21be0eee91c4f47401e3fe6ff37e4c16c (patch) (side-by-side diff) | |
tree | a17655e0e679f67498d9fee6f6a532e9c0f0e9e5 | |
parent | b6bfa63deb15a2600d46a8c68c231f068da1444a (diff) | |
download | kdepimpi-b44edfb21be0eee91c4f47401e3fe6ff37e4c16c.zip kdepimpi-b44edfb21be0eee91c4f47401e3fe6ff37e4c16c.tar.gz kdepimpi-b44edfb21be0eee91c4f47401e3fe6ff37e4c16c.tar.bz2 |
better newsgroup handling
-rw-r--r-- | kmicromail/accountitem.cpp | 21 | ||||
-rw-r--r-- | kmicromail/editaccounts.cpp | 70 | ||||
-rw-r--r-- | kmicromail/editaccounts.h | 3 | ||||
-rw-r--r-- | kmicromail/mainwindow.cpp | 7 | ||||
-rw-r--r-- | kmicromail/mainwindow.h | 1 | ||||
-rw-r--r-- | kmicromail/nntpconfigui.ui | 126 | ||||
-rw-r--r-- | kmicromail/opiemail.cpp | 8 | ||||
-rw-r--r-- | kmicromail/opiemail.h | 1 |
8 files changed, 186 insertions, 51 deletions
diff --git a/kmicromail/accountitem.cpp b/kmicromail/accountitem.cpp index 12d047a..7795055 100644 --- a/kmicromail/accountitem.cpp +++ b/kmicromail/accountitem.cpp @@ -79,40 +79,40 @@ void POP3viewItem::refresh() delete folders; } RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) { return wrapper->fetchBody( mail ); } QPopupMenu * POP3viewItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); if (m) { if (!account->getOffline()) { + m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); m->insertItem(QObject::tr("Disconnect",contextName),0); m->insertItem(QObject::tr("Set offline",contextName),1); - m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); } else { - m->insertItem(QObject::tr("Set online",contextName),1); m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); + m->insertItem(QObject::tr("Set online",contextName),1); } } return m; } void POP3viewItem::disconnect() { QListViewItem *child = firstChild(); while ( child ) { QListViewItem *tmp = child; child = child->nextSibling(); delete tmp; } wrapper->logout(); } @@ -174,62 +174,66 @@ POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , void POP3folderItem::refresh(QValueList<RecMailP>&target) { if (folder->may_select()) pop3->getWrapper()->listMessages( folder->getName(),target ); } RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) { return pop3->getWrapper()->fetchBody(aMail); } QPopupMenu * POP3folderItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); if (m) { + m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); m->insertItem(QObject::tr("Refresh header list",contextName),0); m->insertItem(QObject::tr("Delete all mails",contextName),1); m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); } return m; } void POP3folderItem::downloadMails() { AccountView*bl = pop3->accountView(); if (!bl) return; bl->downloadMails(folder,pop3->getWrapper()); } void POP3folderItem::contextMenuSelected(int which) { AccountView * view = (AccountView*)listView(); switch (which) { case 0: /* must be 'cause pop3 lists are cached */ pop3->getWrapper()->logout(); view->refreshCurrent(); break; case 1: deleteAllMail(pop3->getWrapper(),folder); break; case 2: downloadMails(); break; + case GET_NEW_MAILS: // daunlood + view->downloadMailsInbox(getFolder() ,pop3->getWrapper()); + break; default: break; } } /** * NNTP Account stuff */ NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) : AccountViewItem( parent ) { account = a; wrapper = AbstractMail::getWrapper( account ); //FIXME SETPIX(PIXMAP_POP3FOLDER); #if 0 @@ -500,45 +504,44 @@ void IMAPviewItem::refreshFolders(bool force) } else { item = new IMAPfolderItem( (*it), this , item ); } } delete folders; } QPopupMenu * IMAPviewItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); if (m) { if (!account->getOffline()) { + m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); m->insertItem(QObject::tr("Refresh folder list",contextName),0); m->insertItem(QObject::tr("Create new folder",contextName),1); m->insertSeparator(); m->insertItem(QObject::tr("Disconnect",contextName),2); m->insertItem(QObject::tr("Set offline",contextName),3); m->insertSeparator(); - m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); } else { - m->insertItem(QObject::tr("Set online",contextName),3); - m->insertSeparator(); m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); + m->insertItem(QObject::tr("Set online",contextName),3); } } return m; } void IMAPviewItem::createNewFolder() { Newmdirdlg ndirdlg; ndirdlg.showMaximized(); if ( ndirdlg.exec() ) { QString ndir = ndirdlg.Newdir(); bool makesubs = ndirdlg.subpossible(); QString delemiter = "/"; IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); @@ -656,32 +659,33 @@ void IMAPfolderItem::refresh(QValueList<RecMailP>&target) target.clear(); } } RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) { return imap->getWrapper()->fetchBody(aMail); } QPopupMenu * IMAPfolderItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); if (m) { if (folder->may_select()) { + m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); m->insertItem(QObject::tr("Refresh header list",contextName),0); m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); m->insertItem(QObject::tr("Delete all mails",contextName),1); } if (folder->no_inferior()==false) { m->insertItem(QObject::tr("Create new subfolder",contextName),2); } if (folder->getDisplayName().lower()!="inbox") { m->insertItem(QObject::tr("Delete folder",contextName),3); } } return m; } @@ -740,32 +744,39 @@ void IMAPfolderItem::contextMenuSelected(int id) { case 0: view->refreshCurrent(); break; case 1: deleteAllMail(imap->getWrapper(),folder); break; case 2: createNewFolder(); break; case 3: deleteFolder(); break; case 4: downloadMails(); break; + case GET_NEW_MAILS: // daunlood + { + AccountView*bl = accountView(); + if (!bl) return; + bl->downloadMailsInbox(getFolder(),imap->getWrapper()); + } + break; default: break; } } /** * MH Account stuff */ /* MH is a little bit different - the top folder can contains messages other than in IMAP and POP3 and MBOX */ MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) : AccountViewItem( parent ) { m_Path = aPath; /* be carefull - the space within settext is wanted - thats why the string twice */ wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); diff --git a/kmicromail/editaccounts.cpp b/kmicromail/editaccounts.cpp index d43d23b..733e38a 100644 --- a/kmicromail/editaccounts.cpp +++ b/kmicromail/editaccounts.cpp @@ -525,52 +525,89 @@ void SMTPconfig::accept() QDialog::accept(); } /** * NNTPconfig */ NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) : NNTPconfigUI( parent, name, modal, flags ) { data = account; connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); + connect( ShowSubcribed, SIGNAL( clicked() ), this, SLOT( slotShowSub() ) ); + connect( FilterButton, SIGNAL( clicked() ), this, SLOT( slotShowFilter() ) ); fillValues(); connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); } +void NNTPconfig::slotShowSub() +{ + save(); + data->save(); + ListViewGroups->clear(); + for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { + QCheckListItem *item; + item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); + item->setOn( true ); + } + topLevelWidget()->setCaption( tr("%1 groups subscribed").arg( subscribedGroups.count())); +} +void NNTPconfig::slotShowFilter() +{ + save(); + data->save(); + ListViewGroups->clear(); + int count = 0; + for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) { + QCheckListItem *item; + if ( GroupFilter->text().isEmpty() || (*it).find( GroupFilter->text() ) >= 0 ) { + item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); + ++count; + if ( subscribedGroups.contains( (*it) ) >= 1 ) { + item->setOn( true ); + } + } + } + topLevelWidget()->setCaption( tr("Filter found %1 groups").arg( count)); +} void NNTPconfig::slotGetNG() { save(); data->save(); + topLevelWidget()->setCaption( tr("Fetching group list...")); + qApp->processEvents(); NNTPwrapper* tmp = new NNTPwrapper( data ); - QStringList list = tmp->listAllNewsgroups(); + allGroups = tmp->listAllNewsgroups(); + topLevelWidget()->setCaption( tr("Downloaded %1 group names").arg( allGroups.count())); ListViewGroups->clear(); - for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { - QCheckListItem *item; - item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); - if ( subscribedGroups.contains( (*it) ) >= 1 ) { - item->setOn( true ); - } + for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) { + QCheckListItem *item; + item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); + if ( subscribedGroups.contains( (*it) ) >= 1 ) { + item->setOn( true ); + + } } + delete tmp; } void NNTPconfig::slotSSL( bool enabled ) { if ( enabled ) { portLine->setText( NNTP_SSL_PORT ); } else { portLine->setText( NNTP_PORT ); } } void NNTPconfig::fillValues() { @@ -587,35 +624,38 @@ void NNTPconfig::fillValues() QCheckListItem *item; item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); item->setOn( true ); } } void NNTPconfig::save() { data->setAccountName( accountLine->text() ); data->setServer( serverLine->text() ); data->setPort( portLine->text() ); data->setSSL( sslBox->isChecked() ); data->setLogin( loginBox->isChecked() ); data->setUser( userLine->text() ); data->setPassword( passLine->text() ); - QListViewItemIterator list_it( ListViewGroups ); + QListViewItemIterator list_it( ListViewGroups ); - QStringList groupList; - for ( ; list_it.current(); ++list_it ) { + for ( ; list_it.current(); ++list_it ) { - if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { - groupList.append( list_it.current()->text(0) ); - } + if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { + if ( subscribedGroups.contains( list_it.current()->text(0) ) < 1 ) + subscribedGroups.append( list_it.current()->text(0) ); + } else { + if ( subscribedGroups.contains( list_it.current()->text(0) ) >= 1 ) + subscribedGroups.remove( list_it.current()->text(0) ); + } - } - data->setGroups( groupList ); + } + data->setGroups( subscribedGroups ); } void NNTPconfig::accept() { save(); QDialog::accept(); } diff --git a/kmicromail/editaccounts.h b/kmicromail/editaccounts.h index a9eb19f..6cf842e 100644 --- a/kmicromail/editaccounts.h +++ b/kmicromail/editaccounts.h @@ -128,26 +128,29 @@ private: }; class NNTPconfig : public NNTPconfigUI { Q_OBJECT public: NNTPconfig( NNTPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); public slots: void fillValues(); protected slots: void slotSSL( bool enabled ); void accept(); void slotGetNG(); + void slotShowSub(); + void slotShowFilter(); private: QStringList subscribedGroups; + QStringList allGroups; void save(); NNTPaccount *data; clist* list; }; #endif diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp index d130317..2a67e39 100644 --- a/kmicromail/mainwindow.cpp +++ b/kmicromail/mainwindow.cpp @@ -21,34 +21,39 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) : QMainWindow( parent, name ) //, flags ) { setCaption( tr( "KOpieMail/Pi" ) ); setToolBarsMovable( false ); //KABC::StdAddressBook::self(); toolBar = new QToolBar( this ); menuBar = new QPEMenuBar( toolBar ); mailMenu = new QPopupMenu( menuBar ); menuBar->insertItem( tr( "Mail" ), mailMenu ); settingsMenu = new QPopupMenu( menuBar ); menuBar->insertItem( tr( "Settings" ), settingsMenu ); addToolBar( toolBar ); toolBar->setHorizontalStretchable( true ); + QAction* getMail = new QAction( tr( "Get all new mails" ), SmallIcon("add"), + 0, 0, this ); + connect(getMail, SIGNAL( activated() ), + SLOT( slotGetAllMail() ) ); + getMail->addTo( mailMenu ); - QAction* getMail = new QAction( tr( "Get new mail" ), SmallIcon("add"), + getMail = new QAction( tr( "Get new messages" ), SmallIcon("add"), 0, 0, this ); getMail->addTo( toolBar ); getMail->addTo( mailMenu ); connect(getMail, SIGNAL( activated() ), SLOT( slotGetMail() ) ); composeMail = new QAction( tr( "Compose new mail" ), SmallIcon("composemail"), 0, 0, this ); composeMail->addTo( toolBar ); composeMail->addTo( mailMenu ); sendQueued = new QAction( tr( "Send queued mails" ), SmallIcon("sendqueued") , 0, 0, this ); sendQueued->addTo( toolBar ); sendQueued->addTo( mailMenu ); diff --git a/kmicromail/mainwindow.h b/kmicromail/mainwindow.h index ff0ff20..35b9c8c 100644 --- a/kmicromail/mainwindow.h +++ b/kmicromail/mainwindow.h @@ -29,32 +29,33 @@ class MainWindow : public QMainWindow public: MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); virtual ~MainWindow(); public slots: virtual void slotAdjustColumns(); virtual void appMessage(const QCString &msg, const QByteArray &data); virtual void slotComposeMail(); protected slots: virtual void slotSendQueued(); virtual void slotEditAccounts(); virtual void slotShowFolders( bool show ); virtual void refreshMailView(const QValueList<RecMailP>&); virtual void displayMail(); virtual void slotGetMail() = 0; + virtual void slotGetAllMail() = 0; virtual void slotDeleteMail(); virtual void mailHold(int, QListViewItem *,const QPoint&,int); virtual void slotAdjustLayout(); virtual void slotEditSettings(); virtual void mailLeftClicked( QListViewItem * ); void showLicence(); void showAbout(); void showEtpanLicence(); protected: QToolBar *toolBar; StatusWidget *statusWidget; QPEMenuBar *menuBar; QPopupMenu *mailMenu, *settingsMenu; QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, *editSettings, *editAccounts, *syncFolders; diff --git a/kmicromail/nntpconfigui.ui b/kmicromail/nntpconfigui.ui index 25d564e..16ff6fc 100644 --- a/kmicromail/nntpconfigui.ui +++ b/kmicromail/nntpconfigui.ui @@ -1,47 +1,47 @@ <!DOCTYPE UI><UI> <class>NNTPconfigUI</class> <widget> <class>QDialog</class> <property stdset="1"> <name>name</name> <cstring>NNTPconfigUI</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>409</width> - <height>520</height> + <width>268</width> + <height>347</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Configure NNTP</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <vbox> <property stdset="1"> <name>margin</name> - <number>3</number> + <number>2</number> </property> <property stdset="1"> <name>spacing</name> <number>3</number> </property> <widget> <class>QTabWidget</class> <property stdset="1"> <name>name</name> <cstring>TabWidget2</cstring> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> @@ -276,69 +276,135 @@ </widget> </grid> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Groups</string> </attribute> <vbox> <property stdset="1"> <name>margin</name> - <number>3</number> + <number>2</number> </property> <property stdset="1"> <name>spacing</name> <number>3</number> </property> <widget> - <class>QListView</class> - <column> - <property> - <name>text</name> - <string>Newsgroup</string> - </property> - <property> - <name>clickable</name> - <bool>true</bool> - </property> - <property> - <name>resizeable</name> - <bool>true</bool> - </property> - </column> - <property stdset="1"> - <name>name</name> - <cstring>ListViewGroups</cstring> - </property> - </widget> - <widget> - <class>QPushButton</class> + <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> - <cstring>GetNGButton</cstring> + <cstring>Layout10</cstring> </property> - <property stdset="1"> - <name>text</name> - <string>Get newsgroup list from server</string> + <property> + <name>layoutSpacing</name> </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>3</number> + </property> + <widget> + <class>QListView</class> + <column> + <property> + <name>text</name> + <string>Newsgroup</string> + </property> + <property> + <name>clickable</name> + <bool>true</bool> + </property> + <property> + <name>resizeable</name> + <bool>true</bool> + </property> + </column> + <property stdset="1"> + <name>name</name> + <cstring>ListViewGroups</cstring> + </property> + </widget> + <widget> + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>GetNGButton</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Get newsgroup list from server</string> + </property> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout9</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>FilterButton</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Filter:</string> + </property> + </widget> + <widget> + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>GroupFilter</cstring> + </property> + </widget> + <widget> + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>ShowSubcribed</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Show subscribed</string> + </property> + </widget> + </hbox> + </widget> + </vbox> </widget> </vbox> </widget> </widget> </vbox> </widget> <tabstops> <tabstop>accountLine</tabstop> <tabstop>serverLine</tabstop> <tabstop>portLine</tabstop> <tabstop>sslBox</tabstop> <tabstop>loginBox</tabstop> <tabstop>userLine</tabstop> <tabstop>passLine</tabstop> </tabstops> </UI> diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index 4e7c6be..7ccfb65 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp @@ -240,32 +240,40 @@ void OpieMail::displayMail() RecBodyP body = folderView->fetchBody(mail); ViewMail readMail( this,"", Qt::WType_Modal ); readMail.setBody( body ); readMail.setMail( mail ); readMail.showMaximized(); readMail.exec(); if ( readMail.deleted ) { folderView->refreshCurrent(); } else { ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); } } +void OpieMail::slotGetAllMail() +{ + QListViewItem * item = folderView->firstChild(); + while ( item ){ + ((AccountViewItem *)item)->contextMenuSelected( 101 ); + item = item->nextSibling (); + } +} void OpieMail::slotGetMail() { QListViewItem * item = folderView->currentItem(); if ( ! item ) return; while ( item->parent () ) item = item->parent (); ((AccountViewItem *)item)->contextMenuSelected( 101 ); } void OpieMail::slotDeleteMail() { if (!mailView->currentItem()) return; RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { mail->Wrapper()->deleteMail( mail ); folderView->refreshCurrent(); diff --git a/kmicromail/opiemail.h b/kmicromail/opiemail.h index 47264e4..9de95f8 100644 --- a/kmicromail/opiemail.h +++ b/kmicromail/opiemail.h @@ -19,32 +19,33 @@ public: public slots: virtual void slotwriteMail(const QString&name,const QString&email); virtual void slotwriteMail2(const QString&nameemail); virtual void slotComposeMail(); virtual void slotExtAppHandler(); virtual void appMessage(const QCString &msg, const QByteArray &data); virtual void message(const QCString &msg, const QByteArray &data); protected slots: virtual void slotSendQueued(); virtual void slotSearchMails(); virtual void slotEditSettings(); virtual void slotEditAccounts(); virtual void displayMail(); virtual void slotDeleteMail(); virtual void slotGetMail(); + virtual void slotGetAllMail(); virtual void slotDeleteAllMail(); virtual void mailHold(int, QListViewItem *,const QPoint&,int); virtual void slotShowFolders( bool show ); virtual void refreshMailView(const QValueList<RecMailP>&); virtual void mailLeftClicked( QListViewItem * ); virtual void slotMoveCopyMail(); virtual void slotMoveCopyAllMail(); virtual void reEditMail(); void clearSelection(); private: QString mPendingEmail; QString mPendingName; QByteArray mPendingData; QCString mPendingMessage; Settings *settings; |