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 KWin::setIcons(winId(), tdeApp->icon(), tdeApp->miniIcon());
126 TDEConfig* config = KMKernel::config();
127 config->setGroup(
"SearchDialog");
129 TQWidget* searchWidget =
new TQWidget(
this);
130 TQVBoxLayout *vbl =
new TQVBoxLayout( searchWidget, 0, spacingHint(),
"kmfs_vbl" );
132 TQButtonGroup * radioGroup =
new TQButtonGroup( searchWidget );
135 mChkbxAllFolders =
new TQRadioButton(i18n(
"Search in &all local folders"), searchWidget);
136 vbl->addWidget( mChkbxAllFolders );
137 radioGroup->insert( mChkbxAllFolders );
139 TQHBoxLayout *hbl =
new TQHBoxLayout( vbl, spacingHint(),
"kmfs_hbl" );
140 mChkbxSpecificFolders =
new TQRadioButton(i18n(
"Search &only in:"), searchWidget);
141 hbl->addWidget(mChkbxSpecificFolders);
142 mChkbxSpecificFolders->setChecked(
true);
143 radioGroup->insert( mChkbxSpecificFolders );
146 kmkernel->getKMMainWidget()->folderTree() );
149 hbl->addWidget(mCbxFolders);
151 mChkSubFolders =
new TQCheckBox(i18n(
"I&nclude sub-folders"), searchWidget);
152 mChkSubFolders->setChecked(
true);
153 hbl->addWidget(mChkSubFolders);
155 TQWidget *spacer =
new TQWidget( searchWidget,
"spacer" );
156 spacer->setMinimumHeight( 2 );
157 vbl->addWidget( spacer );
160 mPatternEdit->setFrameStyle( TQFrame::NoFrame | TQFrame::Plain );
161 mPatternEdit->setInsideMargin( 0 );
163 KMFolderSearch *searchFolder = 0;
165 searchFolder =
dynamic_cast<KMFolderSearch*
>(curFolder->storage());
167 TDEConfig config(curFolder->
location());
168 KMFolder *root = searchFolder->search()->root();
169 config.setGroup(
"Search Folder");
172 mChkbxSpecificFolders->setChecked(
true);
174 mChkSubFolders->setChecked(searchFolder->search()->recursive());
176 mChkbxAllFolders->setChecked(
true);
180 TQObjectList *list = mPatternEdit->queryList( 0,
"mRuleField" );
181 TQObject *
object = 0;
183 object = list->first();
185 if (!searchFolder &&
object && ::tqt_cast<TQComboBox*>(
object))
186 static_cast<TQComboBox*
>(object)->setCurrentText(i18n(
"Subject"));
188 vbl->addWidget( mPatternEdit );
191 connect( mChkbxSpecificFolders, TQ_SIGNAL(toggled(
bool)),
192 mCbxFolders, TQ_SLOT(setEnabled(
bool)) );
193 connect( mChkbxSpecificFolders, TQ_SIGNAL(toggled(
bool)),
194 mChkSubFolders, TQ_SLOT(setEnabled(
bool)) );
195 connect( mChkbxAllFolders, TQ_SIGNAL(toggled(
bool)),
196 this, TQ_SLOT(setEnabledSearchButton(
bool)) );
198 mLbxMatches =
new MatchListView(searchWidget,
this,
"Find Messages");
213 mLbxMatches->setSorting(2,
false);
214 mLbxMatches->setShowSortIndicator(
true);
215 mLbxMatches->setAllColumnsShowFocus(
true);
216 mLbxMatches->setSelectionModeExt(TDEListView::Extended);
217 mLbxMatches->addColumn(i18n(
"Subject"),
218 config->readNumEntry(
"SubjectWidth", 150));
219 mLbxMatches->addColumn(i18n(
"Sender/Receiver"),
220 config->readNumEntry(
"SenderWidth", 120));
221 mLbxMatches->addColumn(i18n(
"Date"),
222 config->readNumEntry(
"DateWidth", 120));
223 mLbxMatches->addColumn(i18n(
"Folder"),
224 config->readNumEntry(
"FolderWidth", 100));
226 mLbxMatches->addColumn(
"");
227 mLbxMatches->setColumnWidthMode( MSGID_COLUMN, TQListView::Manual );
228 mLbxMatches->setColumnWidth(MSGID_COLUMN, 0);
229 mLbxMatches->header()->setResizeEnabled(
false, MSGID_COLUMN);
231 mLbxMatches->setDragEnabled(
true );
233 connect( mLbxMatches, TQ_SIGNAL(clicked(TQListViewItem *)),
234 this, TQ_SLOT(slotShowMsg(TQListViewItem *)) );
235 connect( mLbxMatches, TQ_SIGNAL(doubleClicked(TQListViewItem *)),
236 this, TQ_SLOT(slotViewMsg(TQListViewItem *)) );
237 connect( mLbxMatches, TQ_SIGNAL(currentChanged(TQListViewItem *)),
238 this, TQ_SLOT(slotCurrentChanged(TQListViewItem *)) );
239 connect( mLbxMatches, TQ_SIGNAL(contextMenuRequested(TQListViewItem *,
const TQPoint &,
int)),
240 this, TQ_SLOT(slotContextMenuRequested(TQListViewItem *,
const TQPoint &,
int)) );
241 vbl->addWidget( mLbxMatches );
243 TQHBoxLayout *hbl2 =
new TQHBoxLayout( vbl, spacingHint(),
"kmfs_hbl2" );
244 mSearchFolderLbl =
new TQLabel(i18n(
"Search folder &name:"), searchWidget);
245 hbl2->addWidget(mSearchFolderLbl);
246 mSearchFolderEdt =
new KLineEdit(searchWidget);
248 mSearchFolderEdt->setText(searchFolder->folder()->name());
250 mSearchFolderEdt->setText(i18n(
"Last Search"));
252 mSearchFolderLbl->setBuddy(mSearchFolderEdt);
253 hbl2->addWidget(mSearchFolderEdt);
254 mSearchFolderOpenBtn =
new TQPushButton(i18n(
"Op&en Search Folder"), searchWidget);
255 mSearchFolderOpenBtn->setEnabled(
false);
256 hbl2->addWidget(mSearchFolderOpenBtn);
257 connect( mSearchFolderEdt, TQ_SIGNAL( textChanged(
const TQString &)),
258 this, TQ_SLOT( scheduleRename(
const TQString & )));
259 connect( &mRenameTimer, TQ_SIGNAL( timeout() ),
260 this, TQ_SLOT( renameSearchFolder() ));
261 connect( mSearchFolderOpenBtn, TQ_SIGNAL( clicked() ),
262 this, TQ_SLOT( openSearchFolder() ));
263 mSearchResultOpenBtn =
new TQPushButton(i18n(
"Open &Message"), searchWidget);
264 mSearchResultOpenBtn->setEnabled(
false);
265 hbl2->addWidget(mSearchResultOpenBtn);
266 connect( mSearchResultOpenBtn, TQ_SIGNAL( clicked() ),
267 this, TQ_SLOT( slotViewSelectedMsg() ));
268 mStatusBar =
new KStatusBar(searchWidget);
269 mStatusBar->insertFixedItem(i18n(
"AMiddleLengthText..."), 0,
true);
270 mStatusBar->changeItem(i18n(
"Ready."), 0);
271 mStatusBar->setItemAlignment(0, AlignLeft | AlignVCenter);
272 mStatusBar->insertItem(TQString(), 1, 1,
true);
273 mStatusBar->setItemAlignment(1, AlignLeft | AlignVCenter);
274 vbl->addWidget(mStatusBar);
276 int mainWidth = config->readNumEntry(
"SearchWidgetWidth", 0);
277 int mainHeight = config->readNumEntry(
"SearchWidgetHeight", 0);
279 if (mainWidth || mainHeight)
280 resize(mainWidth, mainHeight);
282 setMainWidget(searchWidget);
283 setButtonBoxOrientation(TQt::Vertical);
285 mBtnSearch = actionButton(KDialogBase::User1);
286 mBtnStop = actionButton(KDialogBase::User2);
287 mBtnStop->setEnabled(
false);
289 connect(
this, TQ_SIGNAL(user1Clicked()), TQ_SLOT(slotSearch()));
290 connect(
this, TQ_SIGNAL(user2Clicked()), TQ_SLOT(slotStop()));
291 connect(
this, TQ_SIGNAL(finished()),
this, TQ_SLOT(deleteLater()));
294 object = mPatternEdit->child(
"regExpLineEdit" );
295 if (
object && object->isWidgetType() ) {
296 static_cast<TQWidget*
>(object)->setFocus();
301 kdDebug(5006) <<
"SearchWindow: regExpLineEdit not found" << endl;
304 TDEActionCollection *ac = actionCollection();
305 ac->setWidget(
this );
306 mReplyAction =
new TDEAction( i18n(
"&Reply..."),
"mail-reply-sender", 0,
this,
307 TQ_SLOT(slotReplyToMsg()), ac,
"search_reply" );
308 mReplyAllAction =
new TDEAction( i18n(
"Reply to &All..."),
"mail-reply-all",
309 0,
this, TQ_SLOT(slotReplyAllToMsg()),
310 ac,
"search_reply_all" );
311 mReplyListAction =
new TDEAction( i18n(
"Reply to Mailing-&List..."),
312 "mail_replylist", 0,
this,
313 TQ_SLOT(slotReplyListToMsg()), ac,
314 "search_reply_list" );
315 mForwardActionMenu =
new TDEActionMenu( i18n(
"Message->",
"&Forward"),
317 "search_message_forward" );
318 connect( mForwardActionMenu, TQ_SIGNAL(activated()),
this,
319 TQ_SLOT(slotForwardInlineMsg()) );
320 mForwardAttachedAction =
new TDEAction( i18n(
"Message->Forward->",
"As &Attachment..."),
321 "mail-forward", 0,
this,
322 TQ_SLOT(slotForwardAttachedMsg()), ac,
323 "search_message_forward_as_attachment" );
324 mForwardInlineAction =
new TDEAction( i18n(
"&Inline..."),
325 "mail-forward", 0,
this,
326 TQ_SLOT(slotForwardInlineMsg()), ac,
327 "search_message_forward_inline" );
328 if ( GlobalSettings::self()->forwardingInlineByDefault() ) {
329 mForwardActionMenu->insert( mForwardInlineAction );
330 mForwardActionMenu->insert( mForwardAttachedAction );
332 mForwardActionMenu->insert( mForwardAttachedAction );
333 mForwardActionMenu->insert( mForwardInlineAction );
336 mForwardDigestAction =
new TDEAction( i18n(
"Message->Forward->",
"As Di&gest..."),
337 "mail-forward", 0,
this,
338 TQ_SLOT(slotForwardDigestMsg()), ac,
339 "search_message_forward_as_digest" );
340 mForwardActionMenu->insert( mForwardDigestAction );
341 mRedirectAction =
new TDEAction( i18n(
"Message->Forward->",
"&Redirect..."),
342 "mail-forward", 0,
this,
343 TQ_SLOT(slotRedirectMsg()), ac,
344 "search_message_forward_redirect" );
345 mForwardActionMenu->insert( mRedirectAction );
346 mSaveAsAction = KStdAction::saveAs(
this, TQ_SLOT(slotSaveMsg()), ac,
"search_file_save_as" );
347 mSaveAtchAction =
new TDEAction( i18n(
"Save Attachments..."),
"attach", 0,
348 this, TQ_SLOT(slotSaveAttachments()), ac,
"search_save_attachments" );
350 mPrintAction = KStdAction::print(
this, TQ_SLOT(slotPrintMsg()), ac,
"search_print" );
351 mClearAction =
new TDEAction( i18n(
"Clear Selection"), 0, 0,
this,
352 TQ_SLOT(slotClearSelection()), ac,
"search_clear_selection" );
354 mCopyAction = KStdAction::copy(
this, TQ_SLOT(slotCopyMsgs()), ac,
"search_copy_messages" );
355 mCutAction = KStdAction::cut(
this, TQ_SLOT(slotCutMsgs()), ac,
"search_cut_messages" );
357 connect(mTimer, TQ_SIGNAL(timeout()),
this, TQ_SLOT(
updStatus()));
358 connect(kmkernel->searchFolderMgr(), TQ_SIGNAL(folderInvalidated(
KMFolder*)),
359 this, TQ_SLOT(folderInvalidated(
KMFolder*)));
361 connect(mCbxFolders, TQ_SIGNAL(folderChanged(
KMFolder*)),
362 this, TQ_SLOT(slotFolderActivated()));
367 SearchWindow::~SearchWindow()
369 TQValueListIterator<TQGuardedPtr<KMFolder> > fit;
370 for ( fit = mFolders.begin(); fit != mFolders.end(); ++fit ) {
373 (*fit)->close(
"searchwindow");
376 TDEConfig* config = KMKernel::config();
377 config->setGroup(
"SearchDialog");
378 config->writeEntry(
"SubjectWidth", mLbxMatches->columnWidth(0));
379 config->writeEntry(
"SenderWidth", mLbxMatches->columnWidth(1));
380 config->writeEntry(
"DateWidth", mLbxMatches->columnWidth(2));
381 config->writeEntry(
"FolderWidth", mLbxMatches->columnWidth(3));
382 config->writeEntry(
"SearchWidgetWidth", width());
383 config->writeEntry(
"SearchWidgetHeight", height());
387 void SearchWindow::setEnabledSearchButton(
bool)
393 mBtnSearch->setEnabled(
true );
399 TQString genMsg, detailMsg, procMsg;
400 int numMatches = 0, numProcessed = 0;
401 KMSearch
const *search = (mFolder) ? (mFolder->search()) : 0;
404 numMatches = search->foundCount();
405 numProcessed = search->searchCount();
406 folderName = search->currentFolder();
409 if (search && !search->running()) {
410 procMsg = i18n(
"%n message searched",
"%n messages searched",
413 genMsg = i18n(
"Done.");
414 detailMsg = i18n(
"%n match in %1",
"%n matches in %1",
415 numMatches).arg(procMsg);
417 genMsg = i18n(
"Search canceled.");
418 detailMsg = i18n(
"%n match so far in %1",
"%n matches so far in %1",
419 numMatches).arg(procMsg);
422 procMsg = i18n(
"%n message",
"%n messages", numProcessed);
423 genMsg = i18n(
"%n match",
"%n matches", numMatches);
424 detailMsg = i18n(
"Searching in %1. %2 searched so far")
425 .arg(folderName).arg(procMsg);
428 mStatusBar->changeItem(genMsg, 0);
429 mStatusBar->changeItem(detailMsg, 1);
436 KMSearch
const *search = (mFolder) ? mFolder->search() : 0;
437 bool searching = (search) ? search->running() :
false;
438 if (evt->key() == Key_Escape && searching) {
439 mFolder->stopSearch();
443 KDialogBase::keyPressEvent(evt);
448 void SearchWindow::slotFolderActivated()
450 mChkbxSpecificFolders->setChecked(
true);
456 mChkbxSpecificFolders->setChecked(
true);
461 void SearchWindow::slotSearch()
463 mLastFocus = focusWidget();
464 mBtnSearch->setFocus();
467 mFetchingInProgress = 0;
469 mSearchFolderOpenBtn->setEnabled(
true);
470 if ( mSearchFolderEdt->text().isEmpty() ) {
471 mSearchFolderEdt->setText( i18n(
"Last Search") );
473 mBtnSearch->setEnabled(
false);
474 mBtnStop->setEnabled(
true);
476 mLbxMatches->clear();
478 mSortColumn = mLbxMatches->sortColumn();
479 mSortOrder = mLbxMatches->sortOrder();
480 mLbxMatches->setSorting(-1);
481 mLbxMatches->setShowSortIndicator(
false);
486 KMFolderMgr *mgr = kmkernel->searchFolderMgr();
487 TQString baseName = mSearchFolderEdt->text();
488 TQString fullName = baseName;
491 while ((folder = mgr->find(fullName))) {
492 if (folder->storage()->inherits(
"KMFolderSearch"))
494 fullName = TQString(
"%1 %2").arg(baseName).arg(++count);
498 folder = mgr->createFolder(fullName,
false, KMFolderTypeSearch,
501 mFolder =
dynamic_cast<KMFolderSearch*
>( folder->storage() );
503 mFolder->stopSearch();
504 disconnect(mFolder, TQ_SIGNAL(msgAdded(
int)),
505 this, TQ_SLOT(slotAddMsg(
int)));
506 disconnect(mFolder, TQ_SIGNAL(msgRemoved(
KMFolder*, TQ_UINT32)),
507 this, TQ_SLOT(slotRemoveMsg(
KMFolder*, TQ_UINT32)));
508 connect(mFolder, TQ_SIGNAL(msgAdded(
int)),
509 this, TQ_SLOT(slotAddMsg(
int)));
510 connect(mFolder, TQ_SIGNAL(msgRemoved(
KMFolder*, TQ_UINT32)),
511 this, TQ_SLOT(slotRemoveMsg(
KMFolder*, TQ_UINT32)));
512 mSearchFolderEdt->setEnabled(
false);
513 KMSearch *search =
new KMSearch();
514 connect(search, TQ_SIGNAL(finished(
bool)),
516 if (mChkbxAllFolders->isChecked()) {
517 search->setRecursive(
true);
519 search->setRoot(mCbxFolders->
folder());
520 search->setRecursive(mChkSubFolders->isChecked());
525 *searchPattern = *mSearchPattern;
527 search->setSearchPattern(searchPattern);
528 mFolder->setSearch(search);
540 TQTimer::singleShot(0,
this, TQ_SLOT(enableGUI()));
542 mLastFocus->setFocus();
546 mLbxMatches->setSorting(mSortColumn, mSortOrder == Ascending);
547 mLbxMatches->setShowSortIndicator(
true);
549 mSearchFolderEdt->setEnabled(
true);
552 void SearchWindow::slotAddMsg(
int idx)
556 bool unget = !mFolder->isMessage(idx);
558 TQString from, fName;
560 if (!mFolders.contains(pFolder)) {
561 mFolders.append(pFolder);
562 pFolder->
open(
"searchwindow");
569 fName = i18n(pFolder->name().utf8());
571 fName = pFolder->name();
573 (void)
new TDEListViewItem(mLbxMatches, mLbxMatches->lastItem(),
574 msg->
subject(), from, msg->dateIsoStr(),
576 TQString::number(mFolder->serNum(idx)));
578 mFolder->unGetMsg(idx);
581 void SearchWindow::slotRemoveMsg(
KMFolder *, TQ_UINT32 serNum)
585 TQListViewItemIterator it(mLbxMatches);
586 while (it.current()) {
587 TQListViewItem *item = *it;
588 if (serNum == (*it)->text(MSGID_COLUMN).toUInt()) {
597 void SearchWindow::slotStop()
600 mFolder->stopSearch();
602 mBtnStop->setEnabled(
false);
606 void SearchWindow::slotClose()
615 if (mFolder && mFolder->search() && mFolder->search()->running()) {
616 mCloseRequested =
true;
619 mFolder->setSearch(
new KMSearch());
620 TQTimer::singleShot(0,
this, TQ_SLOT(slotClose()));
622 KDialogBase::closeEvent(e);
627 void SearchWindow::scheduleRename(
const TQString &s)
630 mRenameTimer.start(250,
true);
631 mSearchFolderOpenBtn->setEnabled(
false);
634 mSearchFolderOpenBtn->setEnabled(!s.isEmpty());
639 void SearchWindow::renameSearchFolder()
641 if (mFolder && (mFolder->folder()->name() != mSearchFolderEdt->text())) {
643 TQString name = mSearchFolderEdt->text();
645 if (!kmkernel->searchFolderMgr()->find( name )) {
646 mFolder->rename( name );
647 kmkernel->searchFolderMgr()->contentsChanged();
651 name = mSearchFolderEdt->text() +
" " + name;
656 mSearchFolderOpenBtn->setEnabled(
true);
659 void SearchWindow::openSearchFolder()
662 renameSearchFolder();
663 mKMMainWidget->slotSelectFolder( mFolder->folder() );
668 void SearchWindow::folderInvalidated(
KMFolder *folder)
670 if (folder->storage() == mFolder) {
671 mLbxMatches->clear();
672 if (mFolder->search())
673 connect(mFolder->search(), TQ_SIGNAL(finished(
bool)),
681 KMMessage *SearchWindow::indexToMessage( TQListViewItem *item )
690 &folder, &msgIndex );
692 if ( !folder || msgIndex < 0 ) {
696 mKMMainWidget->slotSelectFolder( folder );
697 return folder->
getMsg( msgIndex );
701 bool SearchWindow::slotShowMsg( TQListViewItem *item )
705 mKMMainWidget->slotSelectMessage(
message );
712 void SearchWindow::slotViewSelectedMsg()
714 slotViewMsg( mLbxMatches->currentItem() );
718 bool SearchWindow::slotViewMsg( TQListViewItem *item )
722 mKMMainWidget->slotMsgActivated(
message );
729 void SearchWindow::slotCurrentChanged(TQListViewItem *item)
731 mSearchResultOpenBtn->setEnabled(item!=0);
735 void SearchWindow::enableGUI()
737 KMSearch
const *search = (mFolder) ? (mFolder->search()) : 0;
738 bool searching = (search) ? (search->running()) :
false;
739 actionButton(KDialogBase::Close)->setEnabled(!searching);
740 mCbxFolders->setEnabled(!searching && !mChkbxAllFolders->isChecked());
741 mChkSubFolders->setEnabled(!searching && !mChkbxAllFolders->isChecked());
742 mChkbxAllFolders->setEnabled(!searching);
743 mChkbxSpecificFolders->setEnabled(!searching);
744 mPatternEdit->setEnabled(!searching);
745 mBtnSearch->setEnabled(!searching);
746 mBtnStop->setEnabled(searching);
753 KMMessageList msgList;
756 for (TQListViewItemIterator it(mLbxMatches); it.current(); it++)
757 if (it.current()->isSelected()) {
760 if (folder && msgIndex >= 0)
769 TQListViewItem *item = mLbxMatches->currentItem();
776 if (!folder || msgIndex < 0)
779 return folder->
getMsg(msgIndex);
783 void SearchWindow::moveSelectedToFolder(
int menuId )
785 KMFolder *dest = mMenuToFolder[menuId];
790 KMCommand *command =
new KMMoveCommand( dest, msgList );
795 void SearchWindow::copySelectedToFolder(
int menuId )
797 KMFolder *dest = mMenuToFolder[menuId];
802 KMCommand *command =
new KMCopyCommand( dest, msgList );
807 void SearchWindow::updateContextMenuActions()
810 bool single_actions = count == 1;
811 mReplyAction->setEnabled( single_actions );
812 mReplyAllAction->setEnabled( single_actions );
813 mReplyListAction->setEnabled( single_actions );
814 mPrintAction->setEnabled( single_actions );
815 mForwardDigestAction->setEnabled( !single_actions );
816 mRedirectAction->setEnabled( single_actions );
817 mCopyAction->setEnabled( count > 0 );
818 mCutAction->setEnabled( count > 0 );
822 void SearchWindow::slotContextMenuRequested( TQListViewItem *lvi,
const TQPoint &,
int )
826 mLbxMatches->setSelected( lvi,
true );
827 mLbxMatches->setCurrentItem( lvi );
831 TQPopupMenu *menu =
new TQPopupMenu(
this);
832 updateContextMenuActions();
834 mMenuToFolder.clear();
835 TQPopupMenu *msgMoveMenu =
new TQPopupMenu(menu);
836 mKMMainWidget->folderTree()->folderToPopupMenu( KMFolderTree::MoveMessage,
837 this, &mMenuToFolder, msgMoveMenu );
838 TQPopupMenu *msgCopyMenu =
new TQPopupMenu(menu);
839 mKMMainWidget->folderTree()->folderToPopupMenu( KMFolderTree::CopyMessage,
840 this, &mMenuToFolder, msgCopyMenu );
843 mReplyAction->plug(menu);
844 mReplyAllAction->plug(menu);
845 mReplyListAction->plug(menu);
846 mForwardActionMenu->plug(menu);
847 menu->insertSeparator();
848 mCopyAction->plug(menu);
849 mCutAction->plug(menu);
850 menu->insertItem(i18n(
"&Copy To"), msgCopyMenu);
851 menu->insertItem(i18n(
"&Move To"), msgMoveMenu);
852 menu->insertSeparator();
853 mSaveAsAction->plug(menu);
854 mSaveAtchAction->plug(menu);
855 mPrintAction->plug(menu);
856 menu->insertSeparator();
857 mClearAction->plug(menu);
858 menu->exec (TQCursor::pos(), 0);
863 void SearchWindow::slotClearSelection()
865 mLbxMatches->clearSelection();
869 void SearchWindow::slotReplyToMsg()
871 KMCommand *command =
new KMReplyToCommand(
this,
message());
876 void SearchWindow::slotReplyAllToMsg()
878 KMCommand *command =
new KMReplyToAllCommand(
this,
message());
883 void SearchWindow::slotReplyListToMsg()
885 KMCommand *command =
new KMReplyListCommand(
this,
message());
890 void SearchWindow::slotForwardInlineMsg()
897 void SearchWindow::slotForwardAttachedMsg()
899 KMCommand *command =
new KMForwardAttachedCommand(
this,
selectedMessages());
904 void SearchWindow::slotForwardDigestMsg()
911 void SearchWindow::slotRedirectMsg()
913 KMCommand *command =
new KMRedirectCommand(
this,
message());
918 void SearchWindow::slotSaveMsg()
920 KMSaveMsgCommand *saveCommand =
new KMSaveMsgCommand(
this,
922 if (saveCommand->url().isEmpty())
925 saveCommand->start();
928 void SearchWindow::slotSaveAttachments()
930 KMSaveAttachmentsCommand *saveCommand =
new KMSaveAttachmentsCommand(
this,
932 saveCommand->start();
937 void SearchWindow::slotPrintMsg()
939 KMCommand *command =
new KMPrintCommand(
this,
message());
943 void SearchWindow::slotCopyMsgs()
946 mKMMainWidget->headers()->setCopiedMessages( list,
false );
949 void SearchWindow::slotCutMsgs()
952 mKMMainWidget->headers()->setCopiedMessages( list,
true );
958 *mSearchPattern = pattern;
963 #include "searchwindow.moc"