qtmobility/examples/publish-subscribe/subscriberdialog.cpp
changeset 4 90517678cc4f
parent 1 2b40d63a9c3d
child 5 453da2cfceef
equal deleted inserted replaced
1:2b40d63a9c3d 4:90517678cc4f
    38 ** $QT_END_LICENSE$
    38 ** $QT_END_LICENSE$
    39 **
    39 **
    40 ****************************************************************************/
    40 ****************************************************************************/
    41 
    41 
    42 #include "subscriberdialog.h"
    42 #include "subscriberdialog.h"
       
    43 #if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
       
    44 #include "ui_subscriberdialog_hor.h"
       
    45 #else
    43 #include "ui_subscriberdialog.h"
    46 #include "ui_subscriberdialog.h"
       
    47 #endif
    44 
    48 
    45 #include <qvaluespacesubscriber.h>
    49 #include <qvaluespacesubscriber.h>
    46 
    50 
    47 #include <QTableWidget>
    51 #include <QTableWidget>
    48 #include <QListWidget>
    52 #include <QListWidget>
    49 #include <QDesktopWidget>
    53 #include <QDesktopWidget>
    50 
    54 
    51 #ifdef QTM_SMALL_SCREEN
    55 #ifdef QTM_EXAMPLES_SMALL_SCREEN
    52 #include <QPushButton>
    56 #include <QPushButton>
    53 #include <QSizePolicy>
    57 #include <QSizePolicy>
    54 #endif
    58 #endif
    55 
    59 
    56 #include <QDebug>
    60 #include <QDebug>
    61         subscriber(0),
    65         subscriber(0),
    62         tableWidget(0), listWidget(0)
    66         tableWidget(0), listWidget(0)
    63 {
    67 {
    64     ui->setupUi(this);
    68     ui->setupUi(this);
    65 
    69 
    66 #ifdef QTM_SMALL_SCREEN
    70 #ifdef QTM_EXAMPLES_SMALL_SCREEN
    67     QPushButton *switchButton =
    71     QPushButton *switchButton =
    68         ui->buttonBox->addButton(tr("Switch"), QDialogButtonBox::ActionRole);
    72         ui->buttonBox->addButton(tr("Switch"), QDialogButtonBox::ActionRole);
    69     connect(switchButton, SIGNAL(clicked()), this, SIGNAL(switchRequested()));
    73     connect(switchButton, SIGNAL(clicked()), this, SIGNAL(switchRequested()));
    70 #endif
    74 #endif
    71 
    75 
       
    76 #if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
       
    77     tableWidget = ui->tableWidget;
       
    78     QStringList headerLabels;
       
    79     headerLabels << tr("Key") << tr("Value") << tr("Type");
       
    80     tableWidget->setColumnCount(3);
       
    81     tableWidget->setHorizontalHeaderLabels(headerLabels);
       
    82     tableWidget->horizontalHeader()->setStretchLastSection(true);
       
    83     tableWidget->verticalHeader()->setVisible(false);
       
    84     tableWidget->setColumnWidth(0, 200);
       
    85     tableWidget->setColumnWidth(1, 400);
       
    86 #else
    72     QDesktopWidget desktopWidget;
    87     QDesktopWidget desktopWidget;
    73     if (desktopWidget.availableGeometry().width() < 400) {
    88     if (desktopWidget.availableGeometry().width() < 400) {
    74         // Screen is too small to fit a table widget without scrolling, use a list widget instead.
    89         // Screen is too small to fit a table widget without scrolling, use a list widget instead.
    75         listWidget = new QListWidget;
    90         listWidget = new QListWidget;
    76         listWidget->setAlternatingRowColors(true);
    91         listWidget->setAlternatingRowColors(true);
    84         tableWidget->horizontalHeader()->setStretchLastSection(true);
    99         tableWidget->horizontalHeader()->setStretchLastSection(true);
    85         tableWidget->verticalHeader()->setVisible(false);
   100         tableWidget->verticalHeader()->setVisible(false);
    86 
   101 
    87         ui->verticalLayout->insertWidget(2, tableWidget);
   102         ui->verticalLayout->insertWidget(2, tableWidget);
    88     }
   103     }
    89 
   104 #endif
    90     connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(changeSubscriberPath()));
   105     connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(changeSubscriberPath()));
    91     changeSubscriberPath();
   106     changeSubscriberPath();
    92 }
   107 }
    93 
   108 
    94 SubscriberDialog::~SubscriberDialog()
   109 SubscriberDialog::~SubscriberDialog()