Logo Search packages:      
Sourcecode: mailody version File versions  Download package

Mailody::Composer::Composer ( QWidget *  parent,
const QString &  mb 
) [explicit]

Contructor

Parameters:
mb the mailbox where the resulting message will be stored.
identity the identity to use

Definition at line 73 of file composer.cpp.

References addAttachment(), SideBar::Sidebar::appendTab(), Mailody::Global::identities(), SideBar::Sidebar::loadViewState(), and SideBar::Sidebar::setSplitter().

  : KMainWindow( parent, "composer#"),
    m_lastState(To),
    m_smtp(0),
    m_close(false),
    m_dirty(false)
{
    setCaption(i18n("Composer"));
    m_mailbox = mb;
    kdDebug() << "Message will be stored in " << mb << endl;

    QHBox* box = new QHBox(this);

    // ------------- Split it in two columns ---------------//
    m_sidebar = new SideBar::Sidebar(box, "SideBarSettings",
                                  Sidebar::Left, true);

    m_hsplitter = new QSplitter(box);

    m_sidebar->setSplitter(m_hsplitter);
    m_hsplitter->setOrientation(Qt::Horizontal);

    m_addressbook = new KListView(0);
    m_addressbook->addColumn(i18n("Name"));
    m_addressbook->addColumn(i18n("Email"));
    m_addressbook->setShowSortIndicator(true);
    connect(m_addressbook,
            SIGNAL(doubleClicked(QListViewItem*,const QPoint&,int)),
            SLOT(slotAddAddressFromAddressBook(QListViewItem*)));
    connect(m_addressbook,
            SIGNAL(contextMenu(KListView*, QListViewItem*, const QPoint &)),
            SLOT(slotContextMenuAddressBook(KListView*, QListViewItem*,
                 const QPoint &)));

    m_filebrowser = new FileBrowserNS::FileBrowser(0,"FileView");
    m_filebrowser->readConfig(kapp->config(), "FileViewSettings");
    connect(m_filebrowser->dirOperator(),
            SIGNAL(fileSelected(const KFileItem*)),
            this,SLOT(slotAddFile(const KFileItem*)));

    m_recentbook = new MailodyBaseListView(0);
    m_recentbook->addColumn(i18n("Email"));
    m_recentbook->addColumn(i18n("Name"));
    m_recentbook->addColumn(i18n("Amount"));
    m_recentbook->addColumn(i18n("Last"));
    m_recentbook->setColumnAlignment(2, Qt::AlignRight);
    m_recentbook->setSortColumn(3);
    m_recentbook->setSortOrder(Qt::Descending);
    m_recentbook->setShowSortIndicator(true);
    connect(m_recentbook,
            SIGNAL(doubleClicked(QListViewItem*,const QPoint&,int)),
            SLOT(slotAddAddressFromRecentBook(QListViewItem*)));
    connect(m_recentbook,
            SIGNAL(contextMenu(KListView*, QListViewItem*, const QPoint &)),
            SLOT(slotContextMenuRecentBook(KListView*, QListViewItem*,
                 const QPoint &)));
    connect(m_recentbook,
            SIGNAL(onItem(QListViewItem*)),
            SLOT(slotShowRecentDetails(QListViewItem*)));
    connect(m_recentbook, SIGNAL(leftWidget()), SLOT(slotHideRecentDetails()));
    connect(m_recentbook, SIGNAL(onViewport()), SLOT(slotHideRecentDetails()));

    m_sidebar->appendTab(m_addressbook, SmallIcon("kaddressbook"),
                         i18n("Addressbook"));
    m_sidebar->appendTab(m_recentbook, SmallIcon("fork"),
                         i18n("Recent"));
    m_sidebar->appendTab(m_filebrowser, SmallIcon("folder"),
                         i18n("Add Attachment"));
    m_sidebar->loadViewState();

    // -------------- The second column is split in two rows ----//
    m_vsplitter = new QSplitter(m_hsplitter);
    m_vsplitter->setOrientation(Qt::Vertical);

    // and the top part is in two parts....
    m_vhsplitter = new QSplitter(m_vsplitter);
    m_vhsplitter->setOrientation(Qt::Horizontal);

    QWidget* widg = new QWidget(m_vhsplitter);
    QGridLayout* grid = new QGridLayout(widg,2,2,6,6);

    QLabel* identitylabel = new QLabel(i18n("Identity:")+' ', widg);
    m_identityBox = new KComboBox(widg);
    identitylabel->setBuddy(m_identityBox);
    m_identityBox->insertStringList(Global::identities());
    connect(m_identityBox,SIGNAL(activated(const QString&)),
            SLOT(slotReplaceSignature(const QString&)));

    QLabel* tolabel = new QLabel(i18n("Recipient:")+' ', widg);
    m_edit = new AddressLineEdit( widg );
    tolabel->setBuddy(m_edit);
    connect(m_edit,SIGNAL(shiftAddress()), SLOT(slotShiftAddress()));
    connect(m_edit,SIGNAL(addAddress(const QString&)),
            SLOT(slotAddAddress(const QString&)));
    connect(m_edit,SIGNAL(addAddress(const QString&)),
            SLOT(slotSetDirty()));

    m_add = new QPushButton(i18n("Add"), widg);
    connect(m_add, SIGNAL(clicked()), SLOT(slotAddClicked()));
    connect(m_add, SIGNAL(clicked()), SLOT(slotSetDirty()));

    m_lv = new DataListView(widg,0,5);
    m_lv->setColumnText(0, i18n("Address"));
    m_lv->setColumnText(1, i18n("To"));
    m_lv->setColumnText(2, i18n("Cc"));
    m_lv->setColumnText(3, i18n("Bcc"));
    m_lv->setColumnText(4, i18n("Del"));
    connect(m_lv, SIGNAL(clicked(QListViewItem*, const QPoint&, int)),
            SLOT(slotEditAddress(QListViewItem*, const QPoint&, int)));
    connect(m_lv, SIGNAL(selectionChanged()), SLOT(slotUpdateLineEdit()));
    connect(m_lv,
            SIGNAL(contextMenu(KListView*, QListViewItem*, const QPoint &)),
            SLOT(slotContextMenuAddressList(KListView*, QListViewItem*,
                 const QPoint &)));

    m_alabel = new QLabel(i18n("Attached:")+' ', widg);
    m_attachview = new KFileIconView(widg, "attachview");
    m_attachview->setArrangement(QIconView::LeftToRight);
    m_attachview->hide();
    m_alabel->setBuddy(m_attachview);
    m_alabel->hide();

    KFileViewSignaler *sig = m_attachview->signaler();
    connect(sig, SIGNAL(fileSelected(const KFileItem*)),
            this, SLOT(slotShowFile(const KFileItem*)));
    connect(sig, SIGNAL(activatedMenu(const KFileItem*, const QPoint&)),
            this, SLOT(slotContextMenuAttachedFile(const KFileItem*,
                       const QPoint&)));

    QLabel* label = new QLabel(i18n("Subject:")+' ', widg);
    m_subject = new KLineEdit( widg, "subject" );
    label->setBuddy(m_subject);
    connect(m_subject, SIGNAL(textChanged( const QString & )),
            SLOT(slotSetDirty()));

    grid->addWidget(identitylabel,0,0, Qt::AlignRight);
    grid->addMultiCellWidget(m_identityBox,0,0,1,2);
    grid->addWidget(tolabel,1,0, Qt::AlignRight);
    grid->addWidget(m_edit,1,1);
    grid->addWidget(m_add,1,2);
    grid->addMultiCellWidget(m_lv,2,2,1,2);
    grid->addWidget(label,3,0, Qt::AlignRight);
    grid->addMultiCellWidget(m_subject,3,3,1,2);
    grid->addWidget(m_alabel,4,0, Qt::AlignRight);
    grid->addMultiCellWidget(m_attachview,4,4,1,2);
    grid->setColStretch(1,10);

    //--------------------------------------------------------

    QWidget* widg2 = new QWidget(m_vsplitter);
    QGridLayout* grid2 = new QGridLayout(widg2,3,2,5,5);

    m_text = new ComposerTextEdit(widg2);
    m_text->setCheckSpellingEnabled(true);
    connect(m_text, SIGNAL(textChanged()), SLOT(slotSetDirty()));
    connect(m_text, SIGNAL(addAttachment(const KURL&)),
            SLOT(slotAddFile(const KURL&)));

    QPushButton* send = new QPushButton(i18n("Send"), widg2);
    send->setIconSet(SmallIcon("mail_send"));
    connect(send, SIGNAL(clicked()), SLOT(slotSend()));
    new KAction( i18n("Send Email"), Qt::CTRL + Qt::Key_Return,
                                  this, SLOT(slotSend()),
                                  actionCollection(),"send_message");

    QPushButton* save = new QPushButton(i18n("Save"), widg2);
    save->setIconSet(SmallIcon("filesave"));
    connect(save, SIGNAL(clicked()), SLOT(slotSave()));
    new KAction( i18n("Save Email"), Qt::CTRL + Qt::Key_S,
                                  this, SLOT(slotSave()),
                                  actionCollection(), "composer_save_message");

    QCheckBox* ff = new QCheckBox(i18n("Fixed Font"), widg2);
    connect(ff, SIGNAL(toggled( bool )), SLOT(slotFixedFont( bool )));

    grid2->addMultiCellWidget(m_text,0,0,0,3);
    grid2->addWidget(send,1,3);
    grid2->addWidget(save,1,2);
    grid2->addWidget(ff,1,1);
    grid2->setColStretch(1,10);

    //--------------------------------------------------------

    box->show();
    setCentralWidget(box);
    setMinimumSize(QSize(800,600));
    setAutoSaveSettings("Composer", true);

    KConfig *config = kapp->config();
    config->setGroup("ComposerSplitterSize");

    QValueList<int> defaultsize1 = config->readIntListEntry("hsplitter");
    if (!defaultsize1.count())
    {
        defaultsize1.append(24);
        defaultsize1.append(1);
        defaultsize1.append(475);
    }

    QValueList<int> defaultsize2 = config->readIntListEntry("vsplitter");
    if (!defaultsize2.count())
    {
        defaultsize2.append(200);
        defaultsize2.append(400);
    }

    QValueList<int> defaultsize3 = config->readIntListEntry("vhsplitter");
    if (!defaultsize3.count())
    {
        defaultsize3.append(275);
        defaultsize3.append(1);
        defaultsize3.append(125);
    }

    m_hsplitter->setSizes(defaultsize1);
    m_vsplitter->setSizes(defaultsize2);
    m_vhsplitter->setSizes(defaultsize3);

    m_lv->restoreLayout(config,"ComposerAddressListSize");
    m_lv->setSorting(500, false); // override sorting method
    m_attachview->readConfig(config,"ComposerAttachViewSize");
    m_edit->setFocus();

    // When we have time, load the addressess from ab
    QTimer::singleShot(0, this, SLOT(slotLoadAddressBook()));
    QTimer::singleShot(0, this, SLOT(slotLoadRecentBook()));
    m_tip = new ToolTip(this);
    m_timer = new QTimer(this);
    connect(m_timer, SIGNAL(timeout()), SLOT(slotShowRecentDetailsDoIt()));

    // default values
    m_sigPos = 0;
    m_newpos = 0;
}


Generated by  Doxygen 1.6.0   Back to index