diff options
author | Denis Shienkov <scapig@yandex.ru> | 2012-02-11 20:46:02 +0400 |
---|---|---|
committer | Denis Shienkov <scapig@yandex.ru> | 2012-02-29 18:36:49 +0100 |
commit | b8af6f604cd86897c8a04825700892fd9970a616 (patch) | |
tree | 818754c16460a321cb5fa2c212ef6e7bbf3dbd79 /examples | |
parent | a5183e74811fd23b2de1f30053fb39f1d3083d9f (diff) | |
download | qtserialport-b8af6f604cd86897c8a04825700892fd9970a616.tar.gz |
The first prepare QtSerialPort to the form of add-on, with the requirements of "Creating a new module or tool for Qt"
Change-Id: I62bba3590a8873bfd03ed6836ac105e0a30d35ba
Reviewed-by: Denis Shienkov <scapig@yandex.ru>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/consoleportinfo/consoleportinfo.pro | 27 | ||||
-rw-r--r-- | examples/consoleportinfo/main.cpp | 22 | ||||
-rw-r--r-- | examples/examples.pro | 2 | ||||
-rw-r--r-- | examples/guiportinfo/guiportinfo.pro | 28 | ||||
-rw-r--r-- | examples/guiportinfo/main.cpp | 11 | ||||
-rw-r--r-- | examples/guiportinfo/portinfodialog.cpp | 93 | ||||
-rw-r--r-- | examples/guiportinfo/portinfodialog.h | 29 | ||||
-rw-r--r-- | examples/guiportinfo/portinfodialog.ui | 158 |
8 files changed, 0 insertions, 370 deletions
diff --git a/examples/consoleportinfo/consoleportinfo.pro b/examples/consoleportinfo/consoleportinfo.pro deleted file mode 100644 index 9bdd996..0000000 --- a/examples/consoleportinfo/consoleportinfo.pro +++ /dev/null @@ -1,27 +0,0 @@ -TEMPLATE = app -CONFIG += console -QT -= gui -OBJECTS_DIR = obj -MOC_DIR = moc - -linux*:DEFINES += HAVE_LIBUDEV - -INCLUDEPATH += \ - ../../include - -HEADERS += \ - ../../include/serialport.h \ - ../../include/serialportinfo.h - -include(../../src/src.pri) - -SOURCES += main.cpp - -CONFIG(debug, debug|release) { - DESTDIR = debug - TARGET = consoleinfod -} else { - DESTDIR = release - TARGET = consoleinfo -} - diff --git a/examples/consoleportinfo/main.cpp b/examples/consoleportinfo/main.cpp deleted file mode 100644 index c1a3d56..0000000 --- a/examples/consoleportinfo/main.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include <QtCore/QCoreApplication> -#include <QtCore/QStringList> -#include <QtCore/QDebug> - -#include "serialportinfo.h" - -int main(int argc, char *argv[]) -{ - QCoreApplication a(argc, argv); - - QList<SerialPortInfo> list = SerialPortInfo::availablePorts(); - int item = 0; - foreach(SerialPortInfo info, list) { - qDebug() << "--> Item: " << item++; - qDebug() << "Port name : " << info.portName(); - qDebug() << "Port location : " << info.systemLocation(); - qDebug() << "Port description : " << info.description(); - qDebug() << "Port manufacturer: " << info.manufacturer(); - } - - return a.exec(); -} diff --git a/examples/examples.pro b/examples/examples.pro deleted file mode 100644 index 43c38e2..0000000 --- a/examples/examples.pro +++ /dev/null @@ -1,2 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS += consoleportinfo diff --git a/examples/guiportinfo/guiportinfo.pro b/examples/guiportinfo/guiportinfo.pro deleted file mode 100644 index df2671e..0000000 --- a/examples/guiportinfo/guiportinfo.pro +++ /dev/null @@ -1,28 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2011-09-21T13:44:17 -# -#------------------------------------------------- - -QT += core gui - -TARGET = guiportinfo -TEMPLATE = app - -linux*:DEFINES += HAVE_LIBUDEV - -INCLUDEPATH += \ - ../../include - -HEADERS += \ - ../../include/serialport.h \ - ../../include/serialportinfo.h - -include(../../src/src.pri) - -SOURCES += main.cpp\ - portinfodialog.cpp - -HEADERS += portinfodialog.h - -FORMS += portinfodialog.ui diff --git a/examples/guiportinfo/main.cpp b/examples/guiportinfo/main.cpp deleted file mode 100644 index 2bdf2fa..0000000 --- a/examples/guiportinfo/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include <QtGui/QApplication> -#include "portinfodialog.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - Dialog w; - w.show(); - - return a.exec(); -} diff --git a/examples/guiportinfo/portinfodialog.cpp b/examples/guiportinfo/portinfodialog.cpp deleted file mode 100644 index 7954e43..0000000 --- a/examples/guiportinfo/portinfodialog.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include "portinfodialog.h" -#include "ui_portinfodialog.h" - -#include "serialportinfo.h" - -#include <QtCore/QVariant> - -Q_DECLARE_METATYPE(SerialPortInfo) - -Dialog::Dialog(QWidget *parent) - : QDialog(parent) - , ui(new Ui::Dialog) -{ - ui->setupUi(this); - procUpdateAvailablePorts(); - procItemPortChanged(0); - - connect(ui->updateButton, SIGNAL(clicked()), this, SLOT(procUpdateAvailablePorts())); - connect(ui->portsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(procItemPortChanged(int))); - connect(ui->busyButton, SIGNAL(clicked()), this, SLOT(procBusyButtonClick())); - connect(ui->validButton, SIGNAL(clicked()), this, SLOT(procValidButtonClick())); - connect(ui->ratesButton, SIGNAL(clicked()), this, SLOT(procRatesButtonClick())); -} - -Dialog::~Dialog() -{ - delete ui; -} - -void Dialog::procUpdateAvailablePorts() -{ - ui->portsComboBox->clear(); - foreach (SerialPortInfo info, SerialPortInfo::availablePorts()) { - QVariant v; - v.setValue(info); - ui->portsComboBox->addItem(info.portName(), v); - } -} - -void Dialog::procItemPortChanged(int idx) -{ - QVariant v = ui->portsComboBox->itemData(idx); - if (v.isValid()) { - SerialPortInfo info = v.value<SerialPortInfo>(); - - ui->locationValueLabel->setText(info.systemLocation()); - ui->descriptionValueLabel->setText(info.description()); - ui->manufacturerValueLabel->setText(info.manufacturer()); - - ui->busyLabel->setText("***"); - ui->validLabel->setText("***"); - ui->ratesComboBox->clear(); - } -} - -void Dialog::procBusyButtonClick() -{ - int idx = ui->portsComboBox->currentIndex(); - if (idx >= 0) { - QVariant v = ui->portsComboBox->itemData(idx); - if (v.isValid()) { - SerialPortInfo info = v.value<SerialPortInfo>(); - ui->busyLabel->setText(info.isBusy() ? tr("Busy") : tr("Free")); - } - } -} - -void Dialog::procValidButtonClick() -{ - int idx = ui->portsComboBox->currentIndex(); - if (idx >= 0) { - QVariant v = ui->portsComboBox->itemData(idx); - if (v.isValid()) { - SerialPortInfo info = v.value<SerialPortInfo>(); - ui->validLabel->setText(info.isValid() ? tr("Valid") : tr("Invalid")); - } - } -} - -void Dialog::procRatesButtonClick() -{ - ui->ratesComboBox->clear(); - int idx = ui->portsComboBox->currentIndex(); - if (idx >= 0) { - QVariant v = ui->portsComboBox->itemData(idx); - if (v.isValid()) { - SerialPortInfo info = v.value<SerialPortInfo>(); - - foreach (qint32 rate, info.standardRates()) - ui->ratesComboBox->addItem(QString::number(rate)); - } - } -} diff --git a/examples/guiportinfo/portinfodialog.h b/examples/guiportinfo/portinfodialog.h deleted file mode 100644 index 9032be7..0000000 --- a/examples/guiportinfo/portinfodialog.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef PORTINFODIALOG_H -#define PORTINFODIALOG_H - -#include <QDialog> - -namespace Ui { - class Dialog; -} - -class Dialog : public QDialog -{ - Q_OBJECT - -public: - explicit Dialog(QWidget *parent = 0); - ~Dialog(); - -private slots: - void procUpdateAvailablePorts(); - void procItemPortChanged(int idx); - void procBusyButtonClick(); - void procValidButtonClick(); - void procRatesButtonClick(); - -private: - Ui::Dialog *ui; -}; - -#endif // PORTINFODIALOG_H diff --git a/examples/guiportinfo/portinfodialog.ui b/examples/guiportinfo/portinfodialog.ui deleted file mode 100644 index abe58ec..0000000 --- a/examples/guiportinfo/portinfodialog.ui +++ /dev/null @@ -1,158 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Dialog</class> - <widget class="QDialog" name="Dialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>293</width> - <height>255</height> - </rect> - </property> - <property name="windowTitle"> - <string>Simple port info application</string> - </property> - <layout class="QGridLayout" name="gridLayout_4"> - <item row="0" column="0"> - <widget class="QGroupBox" name="portsGroupBox"> - <property name="title"> - <string>Available ports:</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLabel" name="portNameLabel"> - <property name="text"> - <string>Current port name:</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="portsComboBox"/> - </item> - <item> - <widget class="QPushButton" name="updateButton"> - <property name="text"> - <string>Update</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item row="1" column="0"> - <widget class="QGroupBox" name="infoGroupBox"> - <property name="title"> - <string>Current port info:</string> - </property> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="0" column="0"> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="locationNameLabel"> - <property name="text"> - <string>Location:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="locationValueLabel"> - <property name="text"> - <string>***</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="descriptionNameLabel"> - <property name="text"> - <string>Description:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLabel" name="descriptionValueLabel"> - <property name="text"> - <string>***</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="manufacturerNameLabel"> - <property name="text"> - <string>Manufacturer:</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLabel" name="manufacturerValueLabel"> - <property name="text"> - <string>***</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0"> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="0"> - <widget class="QPushButton" name="validButton"> - <property name="text"> - <string>Check valid</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="validLabel"> - <property name="text"> - <string>***</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QPushButton" name="busyButton"> - <property name="text"> - <string>Check busy</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLabel" name="busyLabel"> - <property name="text"> - <string>***</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QPushButton" name="ratesButton"> - <property name="text"> - <string>Get rates</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QComboBox" name="ratesComboBox"/> - </item> - </layout> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <layoutdefault spacing="6" margin="11"/> - <resources/> - <connections/> -</ui> |