kmail

folderrequester.cpp
1/*
2 * Copyright (c) 2004 Carsten Burghardt <burghardt@kde.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 *
17 * In addition, as a special exception, the copyright holders give
18 * permission to link the code of this program with any edition of
19 * the TQt library by Trolltech AS, Norway (or with modified versions
20 * of TQt that use the same license as TQt), and distribute linked
21 * combinations including the two. You must obey the GNU General
22 * Public License in all respects for all of the code used other than
23 * TQt. If you modify this file, you may extend this exception to
24 * your version of the file, but you are not obligated to do so. If
25 * you do not wish to do so, delete this exception statement from
26 * your version.
27 */
28
29#include "folderrequester.h"
30#include "kmfolder.h"
31#include "kmfoldertree.h"
32#include "kmfolderseldlg.h"
33
34#include <kdebug.h>
35#include <klineedit.h>
36#include <kiconloader.h>
37#include <kdialog.h>
38
39#include <tqlayout.h>
40#include <tqtoolbutton.h>
41
42namespace KMail {
43
44FolderRequester::FolderRequester( TQWidget *parent, KMFolderTree *tree )
45 : TQWidget( parent ), mFolder( 0 ), mFolderTree( tree ),
46 mMustBeReadWrite( true ), mShowOutbox( true ), mShowImapFolders( true )
47{
48 TQHBoxLayout * hlay = new TQHBoxLayout( this, 0, KDialog::spacingHint() );
49 hlay->setAutoAdd( true );
50
51 edit = new KLineEdit( this );
52 edit->setReadOnly( true );
53
54 TQToolButton* button = new TQToolButton( this );
55 button->setIconSet( TDEGlobal::iconLoader()->loadIconSet( "folder", TDEIcon::Small, 0 ) );
56 connect( button, TQ_SIGNAL(clicked()), this, TQ_SLOT(slotOpenDialog()) );
57
58 setSizePolicy( TQSizePolicy( TQSizePolicy::MinimumExpanding,
59 TQSizePolicy::Fixed ) );
60 setFocusPolicy( TQWidget::StrongFocus );
61}
62
63//-----------------------------------------------------------------------------
65{
66 KMFolderSelDlg dlg( this, mFolderTree, i18n("Select Folder"),
67 mMustBeReadWrite, false );
68 dlg.setFlags( mMustBeReadWrite, mShowOutbox, mShowImapFolders );
69 dlg.setFolder( mFolder );
70
71 if (!dlg.exec()) return;
72 setFolder( dlg.folder() );
73}
74
75//-----------------------------------------------------------------------------
76FolderRequester::~FolderRequester()
77{
78}
79
80//-----------------------------------------------------------------------------
82{
83 return mFolder;
84}
85
86//-----------------------------------------------------------------------------
88{
89 mFolder = folder;
90 if ( mFolder ) {
91 edit->setText( mFolder->prettyURL() );
92 mFolderId = mFolder->idString();
93 }
94 else if ( !mMustBeReadWrite ) // the Local Folders root node was selected
95 edit->setText( i18n("Local Folders") );
96 emit folderChanged( folder );
97}
98
99//-----------------------------------------------------------------------------
100void FolderRequester::setFolder( const TQString &idString )
101{
102 KMFolder *folder = kmkernel->findFolderById( idString );
103 if ( folder ) {
104 setFolder( folder );
105 } else {
106 if ( !idString.isEmpty() ) {
107 edit->setText( i18n( "Unknown folder '%1'" ).arg( idString ) );
108 } else {
109 edit->setText( i18n( "Please select a folder" ) );
110 }
111 mFolder = 0;
112 }
113 mFolderId = idString;
114}
115
116//-----------------------------------------------------------------------------
117void FolderRequester::keyPressEvent( TQKeyEvent * e )
118{
119 if ( e->key() == TQt::Key_Space )
121 else
122 e->ignore();
123}
124
125} // namespace KMail
126
127#include "folderrequester.moc"
Mail folder.
Definition: kmfolder.h:69
TQString idString() const
Returns a string that can be used to identify this folder.
Definition: kmfolder.cpp:705
virtual TQString prettyURL() const
URL of the node for visualization purposes.
Definition: kmfolder.cpp:593
FolderRequester(TQWidget *parent, KMFolderTree *tree)
Constructor.
KMFolder * folder(void) const
Returns selected folder.
virtual void keyPressEvent(TQKeyEvent *e)
Capture space key to open the dialog.
void setFolder(KMFolder *)
Preset the folder.
void slotOpenDialog()
Open the folder dialog.
void folderChanged(KMFolder *)
Emitted when the folder changed.
folderdiaquotatab.h
Definition: aboutdata.cpp:40