Changeset - b4d71a5e7825
[Not reviewed]
portlist
0 2 2
Hasan Yavuz Ă–ZDERYA - 10 years ago 2015-09-05 12:40:29
hy@ozderya.net
added usb icon for usb devices
4 files changed with 10 insertions and 1 deletions:
0 comments (0 inline, 0 general)
CMakeLists.txt
Show inline comments
 
@@ -42,37 +42,39 @@ set(QWT_STATIC_LIBRARY "" CACHE FILEPATH
 
set(QWT_STATIC_INCLUDE "" CACHE PATH "Path to the Qwt include directory when building Qwt static.")
 

	
 
if (QWT_USE_STATIC)
 
  set(QWT_LIBRARY ${QWT_STATIC_LIBRARY})
 
  set(QWT_INCLUDE_DIR ${QWT_STATIC_INCLUDE})
 
else (QWT_USE_STATIC)
 
  find_package(Qwt 6.1 REQUIRED)
 
endif (QWT_USE_STATIC)
 

	
 
# includes
 
include_directories(${QWT_INCLUDE_DIR})
 

	
 
# wrap UI files
 
# wrap UI and resource files
 
qt5_wrap_ui(UI_FILES mainwindow.ui portcontrol.ui about_dialog.ui)
 
qt5_add_resources(RES_FILES misc/icons.qrc)
 

	
 
add_executable(${PROGRAM_NAME} WIN32
 
  main.cpp
 
  mainwindow.cpp
 
  portcontrol.cpp
 
  plot.cpp
 
  zoomer.cpp
 
  hidabletabwidget.cpp
 
  framebuffer.cpp
 
  portlist.cpp
 
  ${UI_FILES}
 
  ${RES_FILES}
 
  misc/windows_icon.rc
 
  )
 

	
 
# Use the Widgets module from Qt 5.
 
target_link_libraries(${PROGRAM_NAME} ${QWT_LIBRARY})
 
qt5_use_modules(${PROGRAM_NAME} Widgets SerialPort Svg)
 

	
 
# set compiler flags
 
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
 

	
 
# Enable C++11 support, fail if not supported
 
include(CheckCXXCompilerFlag)
misc/icons.qrc
Show inline comments
 
new file 100644
 
<RCC>
 
    <qresource prefix="/">
 
        <file>usb_icon.png</file>
 
    </qresource>
 
</RCC>
misc/usb_icon.png
Show inline comments
 
new file 100644
 
binary diff not shown
Show images
portlist.cpp
Show inline comments
 
@@ -9,24 +9,25 @@
 
  (at your option) any later version.
 

	
 
  serialplot is distributed in the hope that it will be useful,
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  GNU General Public License for more details.
 

	
 
  You should have received a copy of the GNU General Public License
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include <QVariant>
 
#include <QIcon>
 
#include <QtDebug>
 

	
 
#include "portlist.h"
 

	
 
PortListItem::PortListItem(QString name, QString description, quint16 vid, quint16 pid)
 
{
 
    construct(name, description, vid, pid);
 
}
 

	
 
PortListItem::PortListItem(QSerialPortInfo* portInfo)
 
{
 
    if (portInfo->hasProductIdentifier())
 
@@ -44,24 +45,25 @@ PortListItem::PortListItem(QSerialPortIn
 

	
 
void PortListItem::construct(QString name, QString description, quint16 vid, quint16 pid)
 
{
 
    QString text = name;
 
    if (!description.isEmpty())
 
    {
 
        text += QString(" ") + description;
 
    }
 
    if (vid && pid)
 
    {
 
        text += QString("[%1:").arg(vid, 4, 16, QChar('0'));
 
        text += QString("%1]").arg(pid, 4, 16, QChar('0'));
 
        setIcon(QIcon(":/usb_icon.png"));
 
    }
 
    setText(text);
 
    setData(name, PortNameRole);
 
}
 

	
 
QString PortListItem::portName()
 
{
 
    return data(PortNameRole).toString();
 
}
 

	
 
PortList::PortList(QObject* parent) :
 
    QStandardItemModel(parent)
0 comments (0 inline, 0 general)