Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

composerbase.cpp

Go to the documentation of this file.
00001 #include <qmultilineedit.h>
00002 #include <qpopupmenu.h>
00003 #include <qcombobox.h>
00004 #include <qlineedit.h>
00005 #include <qlayout.h>
00006 #include <qaction.h>
00007 #include <qlabel.h>
00008 #include <qvbox.h>
00009 
00010 #include <qtoolbar.h>
00011 #include <qmenubar.h>
00012 #include <qpe/resource.h>
00013 
00014 #include "mailstatusbar.h"
00015 #include "listviewplus.h"
00016 #include "composerbase.h"
00017 
00018 ComposerBase::ComposerBase(QWidget *parent, const char *name, WFlags fl)
00019         : QMainWindow(parent, name, fl)
00020 {
00021         setCaption(tr("Compose Message"));
00022         setToolBarsMovable(false);
00023 
00024         toolbar = new QToolBar(this);
00025         menubar = new QMenuBar( toolbar );
00026         mailmenu = new QPopupMenu( menubar );
00027         menubar->insertItem( tr( "Mail" ), mailmenu );
00028         addToolBar(toolbar);
00029         toolbar->setHorizontalStretchable(true);
00030 
00031         QLabel *spacer = new QLabel(toolbar);
00032         spacer->setBackgroundMode(QWidget::PaletteButton);
00033         toolbar->setStretchableWidget(spacer);
00034 
00035         sendmail = new QAction(tr("Send the mail"), QIconSet(Resource::loadPixmap("mail/sendmail")), 0, 0, this);
00036         sendmail->addTo(toolbar);
00037         sendmail->addTo(mailmenu);
00038 
00039         queuemail = new QAction(tr("Queue the mail"), QIconSet(Resource::loadPixmap("mail/sendall")), 0, 0, this);
00040         queuemail->addTo(toolbar);
00041         queuemail->addTo(mailmenu);
00042 
00043         attachfile = new QAction(tr("Attach a file"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true);
00044         attachfile->addTo(toolbar);
00045         attachfile->addTo(mailmenu);
00046         connect(attachfile, SIGNAL(toggled(bool)), SLOT(slotAttachfileChanged(bool)));
00047 
00048         addressbook = new QAction(tr("Addressbook"), QIconSet(Resource::loadPixmap("mail/addbook")), 0, 0, this);
00049         addressbook->addTo(toolbar);
00050         addressbook->addTo(mailmenu);
00051 
00052         QWidget *main = new QWidget(this);
00053         setCentralWidget(main);
00054 
00055         QGridLayout *layout = new QGridLayout(main);
00056 
00057         fromBox = new QComboBox(main);
00058         fromBox->insertItem(tr("From"), POPUP_FROM_FROM);
00059         fromBox->insertItem(tr("Reply"), POPUP_FROM_REPLYTO);
00060         layout->addWidget(fromBox, 0, 0);
00061 
00062         connect(fromBox, SIGNAL(activated(int)), SLOT(slotFromMenuChanged(int)));
00063 
00064         QHBoxLayout *fromLayout = new QHBoxLayout();
00065         layout->addLayout(fromLayout, 0, 1);
00066 
00067         from = new QComboBox(main);
00068         fromLayout->addWidget(from);
00069 
00070         replyto = new QLineEdit(main);
00071         replyto->hide();
00072         fromLayout->addWidget(replyto);
00073 
00074         receiversBox = new QComboBox(main);
00075         receiversBox->insertItem(tr("To"), POPUP_RECV_TO);
00076         receiversBox->insertItem(tr("Cc"), POPUP_RECV_CC);
00077         receiversBox->insertItem(tr("Bcc"), POPUP_RECV_BCC);
00078         layout->addWidget(receiversBox, 1, 0);
00079 
00080         connect(receiversBox, SIGNAL(activated(int)), SLOT(slotReceiverMenuChanged(int)));
00081 
00082         QHBoxLayout *receiverLayout = new QHBoxLayout();
00083         layout->addLayout(receiverLayout, 1, 1);
00084 
00085         to = new QLineEdit(main);
00086         receiverLayout->addWidget(to);
00087 
00088         cc = new QLineEdit(main);
00089         cc->hide();
00090         receiverLayout->addWidget(cc);
00091 
00092         bcc = new QLineEdit(main);
00093         bcc->hide();
00094         receiverLayout->addWidget(bcc);
00095 
00096         subjectBox = new QComboBox(main);
00097         subjectBox->insertItem(tr("Subj."), POPUP_SUBJ_SUBJECT);
00098         subjectBox->insertItem(tr("Prio."), POPUP_SUBJ_PRIORITY);
00099         layout->addWidget(subjectBox, 2, 0);
00100         connect(subjectBox, SIGNAL(activated(int)), SLOT(slotSubjectMenuChanged(int)));
00101 
00102         QHBoxLayout *subjectLayout = new QHBoxLayout();
00103         layout->addLayout(subjectLayout, 2, 1);
00104 
00105         subject = new QLineEdit(main);
00106         subjectLayout->addWidget(subject);
00107 
00108         priority = new QComboBox(main);
00109         priority->insertItem(tr("Low"), POPUP_PRIO_LOW);
00110         priority->insertItem(tr("Normal"), POPUP_PRIO_NORMAL);
00111         priority->insertItem(tr("High"), POPUP_PRIO_HIGH);
00112         priority->setCurrentItem(POPUP_PRIO_NORMAL);
00113         priority->hide();
00114         subjectLayout->addWidget(priority);
00115 
00116         QVBox *view = new QVBox(main);
00117         layout->addMultiCellWidget(view, 3, 3, 0, 1);
00118 
00119         message = new QMultiLineEdit(view);
00120         message->setMinimumHeight(30);
00121 
00122         attachWindow = new QMainWindow(view, 0, 0);
00123         attachWindow->setMinimumHeight(80);
00124         attachWindow->setMaximumHeight(80);
00125         attachWindow->setToolBarsMovable(false);
00126         attachWindow->hide();
00127 
00128         attachToolbar = new QToolBar(attachWindow);
00129         attachToolbar->setVerticalStretchable(true);
00130         
00131         addattach = new QAction(tr("Add an Attachement"), QIconSet(Resource::loadPixmap("mail/newmail")), 0, 0, this);
00132         addattach->addTo(attachToolbar);
00133 
00134         delattach = new QAction(tr("Remove Attachement"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this);
00135         delattach->addTo(attachToolbar);
00136 
00137         QLabel *attachSpacer = new QLabel(attachToolbar);
00138         attachSpacer->setBackgroundMode(QWidget::PaletteButton);
00139         attachToolbar->setStretchableWidget(attachSpacer);
00140 
00141         attachWindow->addToolBar(attachToolbar, QMainWindow::Left);
00142 
00143         attachView = new ListViewPlus(attachWindow);
00144         attachView->addColumn(tr("Name"), 80);
00145         attachView->addColumn(tr("Description"), 110);
00146         attachView->setAllColumnsShowFocus(true);
00147         attachWindow->setCentralWidget(attachView);
00148 
00149         attachPopup = new QPopupMenu(attachView);
00150         attachPopup->insertItem(tr("Rename"), POPUP_ATTACH_RENAME);
00151         attachPopup->insertItem(tr("Change Description"), POPUP_ATTACH_DESC);
00152         attachPopup->insertSeparator();
00153         attachPopup->insertItem(tr("Remove"), POPUP_ATTACH_REMOVE);
00154         attachView->setPopup(attachPopup);
00155 
00156         status = new MailStatusBar(view);
00157 }
00158 
00159 void ComposerBase::slotAttachfileChanged(bool toggled)
00160 {
00161         if (toggled) {
00162                 if (attachWindow->isHidden()) attachWindow->show();
00163         } else {
00164                 if (!attachWindow->isHidden()) attachWindow->hide();
00165         }
00166 }
00167 
00168 void ComposerBase::slotFromMenuChanged(int id)
00169 {
00170         if (POPUP_FROM_FROM == id) {
00171                 if (from->isHidden()) from->show();
00172                 if (!replyto->isHidden()) replyto->hide();
00173         } else if (POPUP_FROM_REPLYTO == id) {
00174                 if (!from->isHidden()) from->hide();
00175                 if (replyto->isHidden()) replyto->show();
00176         }
00177 }
00178 
00179 void ComposerBase::slotReceiverMenuChanged(int id)
00180 {
00181         if (POPUP_RECV_TO == id) {
00182                 if (to->isHidden()) to->show();
00183                 if (!cc->isHidden()) cc->hide();
00184                 if (!bcc->isHidden()) bcc->hide();
00185         } else if (POPUP_RECV_CC == id) {
00186                 if (!to->isHidden()) to->hide();
00187                 if (cc->isHidden()) cc->show();
00188                 if (!bcc->isHidden()) bcc->hide();
00189         } else if (POPUP_RECV_BCC == id) {
00190                 if (!to->isHidden()) to->hide();
00191                 if (!cc->isHidden()) cc->hide();
00192                 if (bcc->isHidden()) bcc->show();
00193         }
00194 }
00195 
00196 void ComposerBase::slotSubjectMenuChanged(int id)
00197 {
00198         if (POPUP_SUBJ_SUBJECT == id) {
00199                 if (subject->isHidden()) subject->show();
00200                 if (!priority->isHidden()) priority->hide();
00201         } else if (POPUP_SUBJ_PRIORITY == id) {
00202                 if (!subject->isHidden()) subject->hide();
00203                 if (priority->isHidden()) priority->show();
00204         }
00205 }

Generated on Sat Nov 5 16:18:06 2005 for OPIE by  doxygen 1.4.2