22 #include "kmcommands.h"
23 #include "searchwindow.h"
24 #include "kmmainwidget.h"
25 #include "kmmsgdict.h"
26 #include "kmmsgpart.h"
27 #include "kmfolderimap.h"
28 #include "kmfoldermgr.h"
29 #include "kmfoldersearch.h"
30 #include "kmfoldertree.h"
31 #include "kmheaders.h"
32 #include "kmsearchpatternedit.h"
33 #include "kmsearchpattern.h"
34 #include "folderrequester.h"
35 #include "messagecopyhelper.h"
36 #include "textsource.h"
38 #include <tdeapplication.h>
40 #include <kstatusbar.h>
42 #include <tdeconfig.h>
43 #include <kstdaction.h>
44 #include <kiconloader.h>
46 #include <tqcheckbox.h>
48 #include <klineedit.h>
49 #include <tqpushbutton.h>
50 #include <tqradiobutton.h>
51 #include <tqbuttongroup.h>
52 #include <tqcombobox.h>
53 #include <tqobjectlist.h>
55 #include <tqpopupmenu.h>
57 #include <maillistdrag.h>
60 #include <mimelib/enum.h>
61 #include <mimelib/boyermor.h>
68 const int SearchWindow::MSGID_COLUMN = 4;
71 class MatchListView :
public TDEListView
74 MatchListView( TQWidget *parent, SearchWindow* sw,
const char* name = 0 ) :
75 TDEListView( parent, name ),
80 virtual TQDragObject* dragObject()
82 KMMessageList list = mSearchWindow->selectedMessages();
84 for ( KMMsgBase* msg = list.first(); msg; msg = list.next() ) {
87 MailSummary mailSummary( msg->getMsgSerNum(), msg->msgIdMD5(),
88 msg->subject(), msg->fromStrip(),
89 msg->toStrip(), msg->date() );
90 mailList.append( mailSummary );
92 MailListDrag *d =
new MailListDrag( mailList, viewport(),
new KMTextSource );
95 if( mailList.count() == 1 )
96 pixmap = TQPixmap( DesktopIcon(
"message", TDEIcon::SizeSmall) );
98 pixmap = TQPixmap( DesktopIcon(
"application-vnd.tde.tdemultiple", TDEIcon::SizeSmall) );
100 d->setPixmap( pixmap );
105 SearchWindow* mSearchWindow;
109 SearchWindow::SearchWindow(KMMainWidget* w,
const char* name,
111 KDialogBase(0, name, modal, i18n(
"Find Messages"),
112 User1 | User2 | Close, User1, false,
113 KGuiItem( i18n(
"&Search"),
"edit-find" ),
114 KStdGuiItem::stop()),
116 mCloseRequested(false),
118 mSortOrder(Ascending),
120 mTimer(new TQTimer(this,
"mTimer")),
124 #if !KDE_IS_VERSION( 3, 2, 91 )
128 XDeleteProperty( tqt_xdisplay(), winId(), XA_WM_TRANSIENT_FOR );
130 KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
132 TDEConfig* config = KMKernel::config();
133 config->setGroup(
"SearchDialog");
135 TQWidget* searchWidget =
new TQWidget(
this);
136 TQVBoxLayout *vbl =
new TQVBoxLayout( searchWidget, 0, spacingHint(),
"kmfs_vbl" );
138 TQButtonGroup * radioGroup =
new TQButtonGroup( searchWidget );
141 mChkbxAllFolders =
new TQRadioButton(i18n(
"Search in &all local folders"), searchWidget);
142 vbl->addWidget( mChkbxAllFolders );
143 radioGroup->insert( mChkbxAllFolders );
145 TQHBoxLayout *hbl =
new TQHBoxLayout( vbl, spacingHint(),
"kmfs_hbl" );
146 mChkbxSpecificFolders =
new TQRadioButton(i18n(
"Search &only in:"), searchWidget);
147 hbl->addWidget(mChkbxSpecificFolders);
148 mChkbxSpecificFolders->setChecked(
true);
149 radioGroup->insert( mChkbxSpecificFolders );
152 kmkernel->getKMMainWidget()->folderTree() );
155 hbl->addWidget(mCbxFolders);
157 mChkSubFolders =
new TQCheckBox(i18n(
"I&nclude sub-folders"), searchWidget);
158 mChkSubFolders->setChecked(
true);
159 hbl->addWidget(mChkSubFolders);
161 TQWidget *spacer =
new TQWidget( searchWidget,
"spacer" );
162 spacer->setMinimumHeight( 2 );
163 vbl->addWidget( spacer );
166 mPatternEdit->setFrameStyle( TQFrame::NoFrame | TQFrame::Plain );
167 mPatternEdit->setInsideMargin( 0 );
169 KMFolderSearch *searchFolder = 0;
171 searchFolder =
dynamic_cast<KMFolderSearch*
>(curFolder->storage());
173 TDEConfig config(curFolder->
location());
174 KMFolder *root = searchFolder->search()->root();
175 config.setGroup(
"Search Folder");
178 mChkbxSpecificFolders->setChecked(
true);
180 mChkSubFolders->setChecked(searchFolder->search()->recursive());
182 mChkbxAllFolders->setChecked(
true);
186 TQObjectList *list = mPatternEdit->queryList( 0,
"mRuleField" );
187 TQObject *
object = 0;
189 object = list->first();
191 if (!searchFolder &&
object && ::tqt_cast<TQComboBox*>(
object))
192 static_cast<TQComboBox*
>(object)->setCurrentText(i18n(
"Subject"));
194 vbl->addWidget( mPatternEdit );
197 connect( mChkbxSpecificFolders, TQ_SIGNAL(toggled(
bool)),
198 mCbxFolders, TQ_SLOT(setEnabled(
bool)) );
199 connect( mChkbxSpecificFolders, TQ_SIGNAL(toggled(
bool)),
200 mChkSubFolders, TQ_SLOT(setEnabled(
bool)) );
201 connect( mChkbxAllFolders, TQ_SIGNAL(toggled(
bool)),
202 this, TQ_SLOT(setEnabledSearchButton(
bool)) );
204 mLbxMatches =
new MatchListView(searchWidget,
this,
"Find Messages");
219 mLbxMatches->setSorting(2,
false);
220 mLbxMatches->setShowSortIndicator(
true);
221 mLbxMatches->setAllColumnsShowFocus(
true);
222 mLbxMatches->setSelectionModeExt(TDEListView::Extended);
223 mLbxMatches->addColumn(i18n(
"Subject"),
224 config->readNumEntry(
"SubjectWidth", 150));
225 mLbxMatches->addColumn(i18n(
"Sender/Receiver"),
226 config->readNumEntry(
"SenderWidth", 120));
227 mLbxMatches->addColumn(i18n(
"Date"),
228 config->readNumEntry(
"DateWidth", 120));
229 mLbxMatches->addColumn(i18n(
"Folder"),
230 config->readNumEntry(
"FolderWidth", 100));
232 mLbxMatches->addColumn(
"");
233 mLbxMatches->setColumnWidthMode( MSGID_COLUMN, TQListView::Manual );
234 mLbxMatches->setColumnWidth(MSGID_COLUMN, 0);
235 mLbxMatches->header()->setResizeEnabled(
false, MSGID_COLUMN);
237 mLbxMatches->setDragEnabled(
true );
239 connect( mLbxMatches, TQ_SIGNAL(clicked(TQListViewItem *)),
240 this, TQ_SLOT(slotShowMsg(TQListViewItem *)) );
241 connect( mLbxMatches, TQ_SIGNAL(doubleClicked(TQListViewItem *)),
242 this, TQ_SLOT(slotViewMsg(TQListViewItem *)) );
243 connect( mLbxMatches, TQ_SIGNAL(currentChanged(TQListViewItem *)),
244 this, TQ_SLOT(slotCurrentChanged(TQListViewItem *)) );
245 connect( mLbxMatches, TQ_SIGNAL(contextMenuRequested(TQListViewItem *,
const TQPoint &,
int)),
246 this, TQ_SLOT(slotContextMenuRequested(TQListViewItem *,
const TQPoint &,
int)) );
247 vbl->addWidget( mLbxMatches );
249 TQHBoxLayout *hbl2 =
new TQHBoxLayout( vbl, spacingHint(),
"kmfs_hbl2" );
250 mSearchFolderLbl =
new TQLabel(i18n(
"Search folder &name:"), searchWidget);
251 hbl2->addWidget(mSearchFolderLbl);
252 mSearchFolderEdt =
new KLineEdit(searchWidget);
254 mSearchFolderEdt->setText(searchFolder->folder()->name());
256 mSearchFolderEdt->setText(i18n(
"Last Search"));
258 mSearchFolderLbl->setBuddy(mSearchFolderEdt);
259 hbl2->addWidget(mSearchFolderEdt);
260 mSearchFolderOpenBtn =
new TQPushButton(i18n(
"Op&en Search Folder"), searchWidget);
261 mSearchFolderOpenBtn->setEnabled(
false);
262 hbl2->addWidget(mSearchFolderOpenBtn);
263 connect( mSearchFolderEdt, TQ_SIGNAL( textChanged(
const TQString &)),
264 this, TQ_SLOT( scheduleRename(
const TQString & )));
265 connect( &mRenameTimer, TQ_SIGNAL( timeout() ),
266 this, TQ_SLOT( renameSearchFolder() ));
267 connect( mSearchFolderOpenBtn, TQ_SIGNAL( clicked() ),
268 this, TQ_SLOT( openSearchFolder() ));
269 mSearchResultOpenBtn =
new TQPushButton(i18n(
"Open &Message"), searchWidget);
270 mSearchResultOpenBtn->setEnabled(
false);
271 hbl2->addWidget(mSearchResultOpenBtn);
272 connect( mSearchResultOpenBtn, TQ_SIGNAL( clicked() ),
273 this, TQ_SLOT( slotViewSelectedMsg() ));
274 mStatusBar =
new KStatusBar(searchWidget);
275 mStatusBar->insertFixedItem(i18n(
"AMiddleLengthText..."), 0,
true);
276 mStatusBar->changeItem(i18n(
"Ready."), 0);
277 mStatusBar->setItemAlignment(0, AlignLeft | AlignVCenter);
278 mStatusBar->insertItem(TQString(), 1, 1,
true);
279 mStatusBar->setItemAlignment(1, AlignLeft | AlignVCenter);
280 vbl->addWidget(mStatusBar);
282 int mainWidth = config->readNumEntry(
"SearchWidgetWidth", 0);
283 int mainHeight = config->readNumEntry(
"SearchWidgetHeight", 0);
285 if (mainWidth || mainHeight)
286 resize(mainWidth, mainHeight);
288 setMainWidget(searchWidget);
289 setButtonBoxOrientation(TQt::Vertical);
291 mBtnSearch = actionButton(KDialogBase::User1);
292 mBtnStop = actionButton(KDialogBase::User2);
293 mBtnStop->setEnabled(
false);
295 connect(
this, TQ_SIGNAL(user1Clicked()), TQ_SLOT(slotSearch()));
296 connect(
this, TQ_SIGNAL(user2Clicked()), TQ_SLOT(slotStop()));
297 connect(
this, TQ_SIGNAL(finished()),
this, TQ_SLOT(deleteLater()));
300 object = mPatternEdit->child(
"regExpLineEdit" );
301 if (
object && object->isWidgetType() ) {
302 static_cast<TQWidget*
>(object)->setFocus();
307 kdDebug(5006) <<
"SearchWindow: regExpLineEdit not found" << endl;
310 TDEActionCollection *ac = actionCollection();
311 ac->setWidget(
this );
312 mReplyAction =
new TDEAction( i18n(
"&Reply..."),
"mail-reply-sender", 0,
this,
313 TQ_SLOT(slotReplyToMsg()), ac,
"search_reply" );
314 mReplyAllAction =
new TDEAction( i18n(
"Reply to &All..."),
"mail-reply-all",
315 0,
this, TQ_SLOT(slotReplyAllToMsg()),
316 ac,
"search_reply_all" );
317 mReplyListAction =
new TDEAction( i18n(
"Reply to Mailing-&List..."),
318 "mail_replylist", 0,
this,
319 TQ_SLOT(slotReplyListToMsg()), ac,
320 "search_reply_list" );
321 mForwardActionMenu =
new TDEActionMenu( i18n(
"Message->",
"&Forward"),
323 "search_message_forward" );
324 connect( mForwardActionMenu, TQ_SIGNAL(activated()),
this,
325 TQ_SLOT(slotForwardInlineMsg()) );
326 mForwardAttachedAction =
new TDEAction( i18n(
"Message->Forward->",
"As &Attachment..."),
327 "mail-forward", 0,
this,
328 TQ_SLOT(slotForwardAttachedMsg()), ac,
329 "search_message_forward_as_attachment" );
330 mForwardInlineAction =
new TDEAction( i18n(
"&Inline..."),
331 "mail-forward", 0,
this,
332 TQ_SLOT(slotForwardInlineMsg()), ac,
333 "search_message_forward_inline" );
334 if ( GlobalSettings::self()->forwardingInlineByDefault() ) {
335 mForwardActionMenu->insert( mForwardInlineAction );
336 mForwardActionMenu->insert( mForwardAttachedAction );
338 mForwardActionMenu->insert( mForwardAttachedAction );
339 mForwardActionMenu->insert( mForwardInlineAction );
342 mForwardDigestAction =
new TDEAction( i18n(
"Message->Forward->",
"As Di&gest..."),
343 "mail-forward", 0,
this,
344 TQ_SLOT(slotForwardDigestMsg()), ac,
345 "search_message_forward_as_digest" );
346 mForwardActionMenu->insert( mForwardDigestAction );
347 mRedirectAction =
new TDEAction( i18n(
"Message->Forward->",
"&Redirect..."),
348 "mail-forward", 0,
this,
349 TQ_SLOT(slotRedirectMsg()), ac,
350 "search_message_forward_redirect" );
351 mForwardActionMenu->insert( mRedirectAction );
352 mSaveAsAction = KStdAction::saveAs(
this, TQ_SLOT(slotSaveMsg()), ac,
"search_file_save_as" );
353 mSaveAtchAction =
new TDEAction( i18n(
"Save Attachments..."),
"attach", 0,
354 this, TQ_SLOT(slotSaveAttachments()), ac,
"search_save_attachments" );
356 mPrintAction = KStdAction::print(
this, TQ_SLOT(slotPrintMsg()), ac,
"search_print" );
357 mClearAction =
new TDEAction( i18n(
"Clear Selection"), 0, 0,
this,
358 TQ_SLOT(slotClearSelection()), ac,
"search_clear_selection" );
360 mCopyAction = KStdAction::copy(
this, TQ_SLOT(slotCopyMsgs()), ac,
"search_copy_messages" );
361 mCutAction = KStdAction::cut(
this, TQ_SLOT(slotCutMsgs()), ac,
"search_cut_messages" );
363 connect(mTimer, TQ_SIGNAL(timeout()),
this, TQ_SLOT(
updStatus()));
364 connect(kmkernel->searchFolderMgr(), TQ_SIGNAL(folderInvalidated(
KMFolder*)),
365 this, TQ_SLOT(folderInvalidated(
KMFolder*)));
367 connect(mCbxFolders, TQ_SIGNAL(folderChanged(
KMFolder*)),
368 this, TQ_SLOT(slotFolderActivated()));
373 SearchWindow::~SearchWindow()
375 TQValueListIterator<TQGuardedPtr<KMFolder> > fit;
376 for ( fit = mFolders.begin(); fit != mFolders.end(); ++fit ) {
379 (*fit)->close(
"searchwindow");
382 TDEConfig* config = KMKernel::config();
383 config->setGroup(
"SearchDialog");
384 config->writeEntry(
"SubjectWidth", mLbxMatches->columnWidth(0));
385 config->writeEntry(
"SenderWidth", mLbxMatches->columnWidth(1));
386 config->writeEntry(
"DateWidth", mLbxMatches->columnWidth(2));
387 config->writeEntry(
"FolderWidth", mLbxMatches->columnWidth(3));
388 config->writeEntry(
"SearchWidgetWidth", width());
389 config->writeEntry(
"SearchWidgetHeight", height());
393 void SearchWindow::setEnabledSearchButton(
bool)
399 mBtnSearch->setEnabled(
true );
405 TQString genMsg, detailMsg, procMsg;
406 int numMatches = 0, numProcessed = 0;
407 KMSearch
const *search = (mFolder) ? (mFolder->search()) : 0;
410 numMatches = search->foundCount();
411 numProcessed = search->searchCount();
412 folderName = search->currentFolder();
415 if (search && !search->running()) {
416 procMsg = i18n(
"%n message searched",
"%n messages searched",
419 genMsg = i18n(
"Done.");
420 detailMsg = i18n(
"%n match in %1",
"%n matches in %1",
421 numMatches).arg(procMsg);
423 genMsg = i18n(
"Search canceled.");
424 detailMsg = i18n(
"%n match so far in %1",
"%n matches so far in %1",
425 numMatches).arg(procMsg);
428 procMsg = i18n(
"%n message",
"%n messages", numProcessed);
429 genMsg = i18n(
"%n match",
"%n matches", numMatches);
430 detailMsg = i18n(
"Searching in %1. %2 searched so far")
431 .arg(folderName).arg(procMsg);
434 mStatusBar->changeItem(genMsg, 0);
435 mStatusBar->changeItem(detailMsg, 1);
442 KMSearch
const *search = (mFolder) ? mFolder->search() : 0;
443 bool searching = (search) ? search->running() :
false;
444 if (evt->key() == Key_Escape && searching) {
445 mFolder->stopSearch();
449 KDialogBase::keyPressEvent(evt);
454 void SearchWindow::slotFolderActivated()
456 mChkbxSpecificFolders->setChecked(
true);
462 mChkbxSpecificFolders->setChecked(
true);
467 void SearchWindow::slotSearch()
469 mLastFocus = focusWidget();
470 mBtnSearch->setFocus();
473 mFetchingInProgress = 0;
475 mSearchFolderOpenBtn->setEnabled(
true);
476 if ( mSearchFolderEdt->text().isEmpty() ) {
477 mSearchFolderEdt->setText( i18n(
"Last Search") );
479 mBtnSearch->setEnabled(
false);
480 mBtnStop->setEnabled(
true);
482 mLbxMatches->clear();
484 mSortColumn = mLbxMatches->sortColumn();
485 mSortOrder = mLbxMatches->sortOrder();
486 mLbxMatches->setSorting(-1);
487 mLbxMatches->setShowSortIndicator(
false);
492 KMFolderMgr *mgr = kmkernel->searchFolderMgr();
493 TQString baseName = mSearchFolderEdt->text();
494 TQString fullName = baseName;
497 while ((folder = mgr->find(fullName))) {
498 if (folder->storage()->inherits(
"KMFolderSearch"))
500 fullName = TQString(
"%1 %2").arg(baseName).arg(++count);
504 folder = mgr->createFolder(fullName,
false, KMFolderTypeSearch,
507 mFolder =
dynamic_cast<KMFolderSearch*
>( folder->storage() );
509 mFolder->stopSearch();
510 disconnect(mFolder, TQ_SIGNAL(msgAdded(
int)),
511 this, TQ_SLOT(slotAddMsg(
int)));
512 disconnect(mFolder, TQ_SIGNAL(msgRemoved(
KMFolder*, TQ_UINT32)),
513 this, TQ_SLOT(slotRemoveMsg(
KMFolder*, TQ_UINT32)));
514 connect(mFolder, TQ_SIGNAL(msgAdded(
int)),
515 this, TQ_SLOT(slotAddMsg(
int)));
516 connect(mFolder, TQ_SIGNAL(msgRemoved(
KMFolder*, TQ_UINT32)),
517 this, TQ_SLOT(slotRemoveMsg(
KMFolder*, TQ_UINT32)));
518 mSearchFolderEdt->setEnabled(
false);
519 KMSearch *search =
new KMSearch();
520 connect(search, TQ_SIGNAL(finished(
bool)),
522 if (mChkbxAllFolders->isChecked()) {
523 search->setRecursive(
true);
525 search->setRoot(mCbxFolders->
folder());
526 search->setRecursive(mChkSubFolders->isChecked());
531 *searchPattern = *mSearchPattern;
533 search->setSearchPattern(searchPattern);
534 mFolder->setSearch(search);
546 TQTimer::singleShot(0,
this, TQ_SLOT(enableGUI()));
548 mLastFocus->setFocus();
552 mLbxMatches->setSorting(mSortColumn, mSortOrder == Ascending);
553 mLbxMatches->setShowSortIndicator(
true);
555 mSearchFolderEdt->setEnabled(
true);
558 void SearchWindow::slotAddMsg(
int idx)
562 bool unget = !mFolder->isMessage(idx);
564 TQString from, fName;
566 if (!mFolders.contains(pFolder)) {
567 mFolders.append(pFolder);
568 pFolder->
open(
"searchwindow");
575 fName = i18n(pFolder->name().utf8());
577 fName = pFolder->name();
579 (void)
new TDEListViewItem(mLbxMatches, mLbxMatches->lastItem(),
580 msg->
subject(), from, msg->dateIsoStr(),
582 TQString::number(mFolder->serNum(idx)));
584 mFolder->unGetMsg(idx);
587 void SearchWindow::slotRemoveMsg(
KMFolder *, TQ_UINT32 serNum)
591 TQListViewItemIterator it(mLbxMatches);
592 while (it.current()) {
593 TQListViewItem *item = *it;
594 if (serNum == (*it)->text(MSGID_COLUMN).toUInt()) {
603 void SearchWindow::slotStop()
606 mFolder->stopSearch();
608 mBtnStop->setEnabled(
false);
612 void SearchWindow::slotClose()
621 if (mFolder && mFolder->search() && mFolder->search()->running()) {
622 mCloseRequested =
true;
625 mFolder->setSearch(
new KMSearch());
626 TQTimer::singleShot(0,
this, TQ_SLOT(slotClose()));
628 KDialogBase::closeEvent(e);
633 void SearchWindow::scheduleRename(
const TQString &s)
636 mRenameTimer.start(250,
true);
637 mSearchFolderOpenBtn->setEnabled(
false);
640 mSearchFolderOpenBtn->setEnabled(!s.isEmpty());
645 void SearchWindow::renameSearchFolder()
647 if (mFolder && (mFolder->folder()->name() != mSearchFolderEdt->text())) {
649 TQString name = mSearchFolderEdt->text();
651 if (!kmkernel->searchFolderMgr()->find( name )) {
652 mFolder->rename( name );
653 kmkernel->searchFolderMgr()->contentsChanged();
657 name = mSearchFolderEdt->text() +
" " + name;
662 mSearchFolderOpenBtn->setEnabled(
true);
665 void SearchWindow::openSearchFolder()
668 renameSearchFolder();
669 mKMMainWidget->slotSelectFolder( mFolder->folder() );
674 void SearchWindow::folderInvalidated(
KMFolder *folder)
676 if (folder->storage() == mFolder) {
677 mLbxMatches->clear();
678 if (mFolder->search())
679 connect(mFolder->search(), TQ_SIGNAL(finished(
bool)),
687 KMMessage *SearchWindow::indexToMessage( TQListViewItem *item )
696 &folder, &msgIndex );
698 if ( !folder || msgIndex < 0 ) {
702 mKMMainWidget->slotSelectFolder( folder );
703 return folder->
getMsg( msgIndex );
707 bool SearchWindow::slotShowMsg( TQListViewItem *item )
711 mKMMainWidget->slotSelectMessage(
message );
718 void SearchWindow::slotViewSelectedMsg()
720 slotViewMsg( mLbxMatches->currentItem() );
724 bool SearchWindow::slotViewMsg( TQListViewItem *item )
728 mKMMainWidget->slotMsgActivated(
message );
735 void SearchWindow::slotCurrentChanged(TQListViewItem *item)
737 mSearchResultOpenBtn->setEnabled(item!=0);
741 void SearchWindow::enableGUI()
743 KMSearch
const *search = (mFolder) ? (mFolder->search()) : 0;
744 bool searching = (search) ? (search->running()) :
false;
745 actionButton(KDialogBase::Close)->setEnabled(!searching);
746 mCbxFolders->setEnabled(!searching && !mChkbxAllFolders->isChecked());
747 mChkSubFolders->setEnabled(!searching && !mChkbxAllFolders->isChecked());
748 mChkbxAllFolders->setEnabled(!searching);
749 mChkbxSpecificFolders->setEnabled(!searching);
750 mPatternEdit->setEnabled(!searching);
751 mBtnSearch->setEnabled(!searching);
752 mBtnStop->setEnabled(searching);
759 KMMessageList msgList;
762 for (TQListViewItemIterator it(mLbxMatches); it.current(); it++)
763 if (it.current()->isSelected()) {
766 if (folder && msgIndex >= 0)
775 TQListViewItem *item = mLbxMatches->currentItem();
782 if (!folder || msgIndex < 0)
785 return folder->
getMsg(msgIndex);
789 void SearchWindow::moveSelectedToFolder(
int menuId )
791 KMFolder *dest = mMenuToFolder[menuId];
796 KMCommand *command =
new KMMoveCommand( dest, msgList );
801 void SearchWindow::copySelectedToFolder(
int menuId )
803 KMFolder *dest = mMenuToFolder[menuId];
808 KMCommand *command =
new KMCopyCommand( dest, msgList );
813 void SearchWindow::updateContextMenuActions()
816 bool single_actions = count == 1;
817 mReplyAction->setEnabled( single_actions );
818 mReplyAllAction->setEnabled( single_actions );
819 mReplyListAction->setEnabled( single_actions );
820 mPrintAction->setEnabled( single_actions );
821 mForwardDigestAction->setEnabled( !single_actions );
822 mRedirectAction->setEnabled( single_actions );
823 mCopyAction->setEnabled( count > 0 );
824 mCutAction->setEnabled( count > 0 );
828 void SearchWindow::slotContextMenuRequested( TQListViewItem *lvi,
const TQPoint &,
int )
832 mLbxMatches->setSelected( lvi,
true );
833 mLbxMatches->setCurrentItem( lvi );
837 TQPopupMenu *menu =
new TQPopupMenu(
this);
838 updateContextMenuActions();
840 mMenuToFolder.clear();
841 TQPopupMenu *msgMoveMenu =
new TQPopupMenu(menu);
842 mKMMainWidget->folderTree()->folderToPopupMenu( KMFolderTree::MoveMessage,
843 this, &mMenuToFolder, msgMoveMenu );
844 TQPopupMenu *msgCopyMenu =
new TQPopupMenu(menu);
845 mKMMainWidget->folderTree()->folderToPopupMenu( KMFolderTree::CopyMessage,
846 this, &mMenuToFolder, msgCopyMenu );
849 mReplyAction->plug(menu);
850 mReplyAllAction->plug(menu);
851 mReplyListAction->plug(menu);
852 mForwardActionMenu->plug(menu);
853 menu->insertSeparator();
854 mCopyAction->plug(menu);
855 mCutAction->plug(menu);
856 menu->insertItem(i18n(
"&Copy To"), msgCopyMenu);
857 menu->insertItem(i18n(
"&Move To"), msgMoveMenu);
858 menu->insertSeparator();
859 mSaveAsAction->plug(menu);
860 mSaveAtchAction->plug(menu);
861 mPrintAction->plug(menu);
862 menu->insertSeparator();
863 mClearAction->plug(menu);
864 menu->exec (TQCursor::pos(), 0);
869 void SearchWindow::slotClearSelection()
871 mLbxMatches->clearSelection();
875 void SearchWindow::slotReplyToMsg()
877 KMCommand *command =
new KMReplyToCommand(
this,
message());
882 void SearchWindow::slotReplyAllToMsg()
884 KMCommand *command =
new KMReplyToAllCommand(
this,
message());
889 void SearchWindow::slotReplyListToMsg()
891 KMCommand *command =
new KMReplyListCommand(
this,
message());
896 void SearchWindow::slotForwardInlineMsg()
903 void SearchWindow::slotForwardAttachedMsg()
905 KMCommand *command =
new KMForwardAttachedCommand(
this,
selectedMessages());
910 void SearchWindow::slotForwardDigestMsg()
917 void SearchWindow::slotRedirectMsg()
919 KMCommand *command =
new KMRedirectCommand(
this,
message());
924 void SearchWindow::slotSaveMsg()
926 KMSaveMsgCommand *saveCommand =
new KMSaveMsgCommand(
this,
928 if (saveCommand->url().isEmpty())
931 saveCommand->start();
934 void SearchWindow::slotSaveAttachments()
936 KMSaveAttachmentsCommand *saveCommand =
new KMSaveAttachmentsCommand(
this,
938 saveCommand->start();
943 void SearchWindow::slotPrintMsg()
945 KMCommand *command =
new KMPrintCommand(
this,
message());
949 void SearchWindow::slotCopyMsgs()
952 mKMMainWidget->headers()->setCopiedMessages( list,
false );
955 void SearchWindow::slotCutMsgs()
958 mKMMainWidget->headers()->setCopiedMessages( list,
true );
964 *mSearchPattern = pattern;
969 #include "searchwindow.moc"
TQString whoField() const
Get / set the name of the field that is used for the Sender/Receiver column in the headers (From/To)
bool isSystemFolder() const
Returns true if the folder is a kmail system folder.
KMMessage * getMsg(int idx)
Read message at given index.
const KMMsgBase * getMsgBase(int idx) const
Provides access to the basic message fields that are also stored in the index.
int open(const char *owner)
Open folder for access.
TQString location() const
Returns full path to folder file.
TQString from() const
Get or set the 'From' header field.
TQString to() const
Get or set the 'To' header field.
TQString subject() const
Get or set the 'Subject' header field.
void getLocation(unsigned long key, KMFolder **retFolder, int *retIndex) const
Returns the folder the message represented by the serial number key is in and the index in that folde...
static const KMMsgDict * instance()
Access the globally unique MessageDict.
This widget is intended to be used in the filter configuration as well as in the message search dialo...
void updateSearchPattern()
Updates the search pattern according to the current widget values.
void setSearchPattern(KMSearchPattern *aPattern)
Set the search pattern.
This class is an abstraction of a search over messages.
void readConfig(const TDEConfig *config)
Reads a search pattern from a TDEConfig.
void purify()
Removes all empty rules from the list.
A widget that contains a KLineEdit which shows the current folder and a button that fires a KMFolderS...
KMFolder * folder(void) const
Returns selected folder.
void setFolder(KMFolder *)
Preset the folder.
void setMustBeReadWrite(bool readwrite)
Set if readonly folders should be disabled Be aware that if you disable this the user can also select...
static TQValueList< TQ_UINT32 > serNumListFromMsgList(TQPtrList< KMMsgBase > list)
Converts a KMMsgsBase* list into a serial number list.
virtual void searchDone()
GUI cleanup after search.
KMMessage * message()
Provides access to the currently selected message.
virtual void updStatus(void)
Update status line widget.
virtual void keyPressEvent(TQKeyEvent *)
Reimplemented to react to Escape.
virtual void closeEvent(TQCloseEvent *)
Reimplemented to stop searching when the window is closed.
KMMessageList selectedMessages()
Provides access to the list of currently selected message in the listview.
void activateFolder(KMFolder *curFolder)
Changes the base folder for search operations to a different folder.