Exemplo n.º 1
0
PublisherDialog::PublisherDialog(QWidget *parent)
:   QMainWindow(parent), ui(new Ui::PublisherDialog), publisher(0)
{
    ui->setupUi(this);

#if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR)
    QPushButton* button = ui->buttonBox->button(QDialogButtonBox::Close);
    if (button) {
        ui->buttonBox->removeButton(button);
    }
    QPushButton *switchButton =
        ui->buttonBox->addButton(tr("Switch"), QDialogButtonBox::ActionRole);
    connect(switchButton, SIGNAL(clicked()), this, SIGNAL(switchRequested()));
#elif defined(MEEGO_EDITION_HARMATTAN)
    connect(ui->buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked()), this, SIGNAL(closeApp()));
#endif

    //! [1]
    connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(createNewObject()));
    connect(ui->intValue, SIGNAL(valueChanged(int)), this, SLOT(intValueChanged(int)));
    connect(ui->unsetIntButton, SIGNAL(clicked()), this, SLOT(unsetIntValue()));
    connect(ui->setStringButton, SIGNAL(clicked()), this, SLOT(setStringValue()));
    connect(ui->setByteArrayButton, SIGNAL(clicked()), this, SLOT(setByteArrayValue()));
    //! [1]

    //! [3]
    createNewObject();
    //! [3]
}
Exemplo n.º 2
0
SubscriberDialog::SubscriberDialog(QWidget *parent)
:   QMainWindow(parent), ui(new Ui::SubscriberDialog), subscriber(0), tableWidget(0), listWidget(0)
{
    ui->setupUi(this);

#ifdef QTM_EXAMPLES_SMALL_SCREEN
    QPushButton *switchButton =
        ui->buttonBox->addButton(tr("Switch"), QDialogButtonBox::ActionRole);
    connect(switchButton, SIGNAL(clicked()), this, SIGNAL(switchRequested()));
#endif

#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
    tableWidget = ui->tableWidget;
    QStringList headerLabels;
    headerLabels << tr("Key") << tr("Value") << tr("Type");
    tableWidget->setColumnCount(3);
    tableWidget->setHorizontalHeaderLabels(headerLabels);
    tableWidget->horizontalHeader()->setStretchLastSection(true);
    tableWidget->verticalHeader()->setVisible(false);
    tableWidget->setColumnWidth(0, 200);
    tableWidget->setColumnWidth(1, 400);
#else
    QDesktopWidget desktopWidget;
    if (desktopWidget.availableGeometry().width() < 400) {
        // Screen is too small to fit a table widget without scrolling, use a list widget instead.
        listWidget = new QListWidget;
        listWidget->setAlternatingRowColors(true);
        ui->verticalLayout->insertWidget(2, listWidget);
    } else {
        tableWidget = new QTableWidget;
        QStringList headerLabels;
        headerLabels << tr("Key") << tr("Value") << tr("Type");
        tableWidget->setColumnCount(3);
        tableWidget->setHorizontalHeaderLabels(headerLabels);
        tableWidget->horizontalHeader()->setStretchLastSection(true);
        tableWidget->verticalHeader()->setVisible(false);

        ui->verticalLayout->insertWidget(2, tableWidget);
    }
#endif
    connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(changeSubscriberPath()));
    changeSubscriberPath();

    // if the default path does not exist reset it to /
    QVariant value = subscriber->value();
    if (!subscriber->value().isValid() && subscriber->subPaths().isEmpty()) {
        ui->basePath->setText(QLatin1String("/"));
        changeSubscriberPath();
    }
}
Exemplo n.º 3
0
PublisherDialog::PublisherDialog(QWidget *parent)
:   QDialog(parent), ui(new Ui::PublisherDialog), publisher(0)
{
    ui->setupUi(this);

#ifdef QTM_EXAMPLES_SMALL_SCREEN
    QPushButton *switchButton =
        ui->buttonBox->addButton(tr("Switch"), QDialogButtonBox::ActionRole);
    connect(switchButton, SIGNAL(clicked()), this, SIGNAL(switchRequested()));
#endif

    //! [1]
    connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(createNewObject()));
    connect(ui->intValue, SIGNAL(valueChanged(int)), this, SLOT(intValueChanged(int)));
    connect(ui->unsetIntButton, SIGNAL(clicked()), this, SLOT(unsetIntValue()));
    connect(ui->setStringButton, SIGNAL(clicked()), this, SLOT(setStringValue()));
    connect(ui->setByteArrayButton, SIGNAL(clicked()), this, SLOT(setByteArrayValue()));
    //! [1]

    //! [3]
    createNewObject();
    //! [3]
}
Exemplo n.º 4
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    app.setOrganizationDomain("qt.nokia.com");
    app.setApplicationName("Publish Subscribe Example");

    bool createDefault = true;
    bool createPublisher = false;
    bool createSubscriber = false;

    for (int i = 1; i < argc; ++i) {
        if (argv[i] == QLatin1String("-server")) {
            QValueSpace::initValueSpaceServer();
        } else if (argv[i] == QLatin1String("-publisher")) {
            createPublisher = true;
            createDefault = false;
        } else if (argv[i] == QLatin1String("-subscriber")) {
            createSubscriber = true;
            createDefault = false;
        }
    }

    PublisherDialog *publisher = 0;
    if (createDefault || createPublisher) {
        publisher = new PublisherDialog;
#if defined(MEEGO_EDITION_HARMATTAN)
        publisher->show();
#endif
    }

    SubscriberDialog *subscriber = 0;
    if (createDefault || createSubscriber) {
        subscriber = new SubscriberDialog;
#if defined(MEEGO_EDITION_HARMATTAN)
        subscriber->show();
#elif defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR)
        subscriber->showMaximized();
#endif
    }

#if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR)
    QObject::connect(publisher, SIGNAL(switchRequested()), subscriber, SLOT(showMaximized()));
    QObject::connect(publisher, SIGNAL(switchRequested()), subscriber, SLOT(repaint()));
    QObject::connect(publisher, SIGNAL(switchRequested()), publisher, SLOT(hide()));

    QObject::connect(subscriber, SIGNAL(switchRequested()), publisher, SLOT(showMaximized()));
    QObject::connect(subscriber, SIGNAL(switchRequested()), publisher, SLOT(repaint()));
    QObject::connect(subscriber, SIGNAL(switchRequested()), subscriber, SLOT(hide()));
#elif defined(MEEGO_EDITION_HARMATTAN)
    QObject::connect(publisher, SIGNAL(closeApp()), &app, SLOT(quit()));
    QObject::connect(subscriber, SIGNAL(closeApp()), &app, SLOT(quit()));
#endif

    int result = app.exec();

    if (publisher)
        delete publisher;
    if (subscriber)
        delete subscriber;

    return result;
}