File indexing completed on 2025-02-09 06:26:49

0001 /*
0002     This file is part of KMail.
0003 
0004     SPDX-FileCopyrightText: 2004 Cornelius Schumacher <schumacher@kde.org>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
0007 */
0008 
0009 #include "recipientseditortest.h"
0010 #include <MessageComposer/RecipientsEditor>
0011 
0012 #include <QDebug>
0013 
0014 #include <KMessageBox>
0015 
0016 #include <QApplication>
0017 #include <QCommandLineParser>
0018 #include <QGridLayout>
0019 #include <QLabel>
0020 #include <QLineEdit>
0021 #include <QPushButton>
0022 #include <QTextEdit>
0023 
0024 using namespace MessageComposer;
0025 
0026 Composer::Composer(QWidget *parent)
0027     : QWidget(parent)
0028     , mRecipients(new RecipientsEditor(this))
0029 {
0030     auto topLayout = new QGridLayout(this);
0031     topLayout->setContentsMargins(4, 4, 4, 4);
0032     topLayout->setSpacing(4);
0033 
0034     auto label = new QLabel(QStringLiteral("From:"), this);
0035     topLayout->addWidget(label, 0, 0);
0036     auto edit = new QLineEdit(this);
0037     topLayout->addWidget(edit, 0, 1);
0038 
0039     topLayout->addWidget(mRecipients, 1, 0, 1, 2);
0040 
0041     qDebug() << "SIZEHINT:" << mRecipients->sizeHint();
0042 
0043     //  mRecipients->setFixedHeight( 10 );
0044 
0045     auto editor = new QTextEdit(this);
0046     topLayout->addWidget(editor, 2, 0, 1, 2);
0047     topLayout->setRowStretch(2, 1);
0048 
0049     auto button = new QPushButton(QStringLiteral("&Close"), this);
0050     topLayout->addWidget(button, 3, 0, 1, 2);
0051     connect(button, &QPushButton::clicked, this, &Composer::slotClose);
0052 }
0053 
0054 void Composer::slotClose()
0055 {
0056 #if 0
0057     QString text;
0058 
0059     text += "<qt>";
0060 
0061     Recipient::List recipients = mRecipients->recipients();
0062     Recipient::List::ConstIterator it;
0063     for (it = recipients.begin(); it != recipients.end(); ++it) {
0064         text += "<b>" + (*it).typeLabel() + ":</b> " + (*it).email() + "<br/>";
0065     }
0066 
0067     text += "</qt>";
0068 
0069     KMessageBox::information(this, text);
0070 #endif
0071 
0072     close();
0073 }
0074 
0075 int main(int argc, char **argv)
0076 {
0077     QApplication app(argc, argv);
0078     QCommandLineParser parser;
0079     parser.addVersionOption();
0080     parser.addHelpOption();
0081     parser.process(app);
0082 
0083     QObject::connect(&app, &QApplication::lastWindowClosed, &app, &QApplication::quit);
0084 
0085     QWidget *wid = new Composer(nullptr);
0086 
0087     wid->show();
0088 
0089     int ret = app.exec();
0090 
0091     delete wid;
0092 
0093     return ret;
0094 }
0095 
0096 #include "moc_recipientseditortest.cpp"