File indexing completed on 2024-11-10 04:41:10
0001 /* 0002 SPDX-FileCopyrightText: 2006-2008 Tobias Koenig <tokoe@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "agentinstancewidgettest.h" 0008 0009 #include "agentinstance.h" 0010 0011 #include <KAboutData> 0012 #include <QApplication> 0013 #include <QCommandLineParser> 0014 #include <QDialogButtonBox> 0015 #include <QPushButton> 0016 #include <QVBoxLayout> 0017 0018 Dialog::Dialog(QWidget *parent) 0019 : QDialog(parent) 0020 { 0021 auto layout = new QVBoxLayout(this); 0022 0023 mWidget = new Akonadi::AgentInstanceWidget(this); 0024 connect(mWidget, &Akonadi::AgentInstanceWidget::currentChanged, this, &Dialog::currentChanged); 0025 0026 auto box = new QDialogButtonBox(this); 0027 0028 layout->addWidget(mWidget); 0029 layout->addWidget(box); 0030 0031 QPushButton *ok = box->addButton(QDialogButtonBox::Ok); 0032 connect(ok, &QPushButton::clicked, this, &Dialog::accept); 0033 0034 resize(450, 320); 0035 } 0036 0037 void Dialog::done(int r) 0038 { 0039 if (r == Accepted) { 0040 qDebug("'%s' selected", qPrintable(mWidget->currentAgentInstance().identifier())); 0041 } 0042 0043 QDialog::done(r); 0044 } 0045 0046 void Dialog::currentChanged(const Akonadi::AgentInstance ¤t, const Akonadi::AgentInstance &previous) 0047 { 0048 qDebug("current changed: %s -> %s", qPrintable(previous.identifier()), qPrintable(current.identifier())); 0049 } 0050 0051 int main(int argc, char **argv) 0052 { 0053 QApplication app(argc, argv); 0054 KAboutData aboutData(QStringLiteral("agentinstanceviewtest"), QStringLiteral("agentinstanceviewtest"), QStringLiteral("0.10")); 0055 KAboutData::setApplicationData(aboutData); 0056 0057 QCommandLineParser parser; 0058 aboutData.setupCommandLine(&parser); 0059 parser.process(app); 0060 aboutData.processCommandLine(&parser); 0061 0062 Dialog dlg; 0063 dlg.exec(); 0064 0065 return 0; 0066 } 0067 0068 #include "moc_agentinstancewidgettest.cpp"