Changeset - 371135090df8
[Not reviewed]
Hasan Yavuz ÖZDERYA - 9 years ago 2017-01-01 08:47:49
hy@ozderya.net
improved color setting and integrated qcolorwidgets library as external project
8 files changed with 380 insertions and 43 deletions:
0 comments (0 inline, 0 general)
CMakeLists.txt
Show inline comments
 
@@ -54,8 +54,10 @@ else (BUILD_QWT)
 
  endif (QWT_USE_STATIC)
 
endif (BUILD_QWT)
 

	
 
include(BuildQColorWidgets)
 

	
 
# includes
 
include_directories("./src" ${QWT_INCLUDE_DIR})
 
include_directories("./src" ${QWT_INCLUDE_DIR} ${QCW_INCLUDE_DIR})
 

	
 
# wrap UI and resource files
 
qt5_wrap_ui(UI_FILES
 
@@ -123,7 +125,7 @@ add_executable(${PROGRAM_NAME} WIN32
 
  )
 

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

	
 
if (BUILD_QWT)
cmake/modules/BuildQColorWidgets.cmake
Show inline comments
 
new file 100644
 
#
 
# Copyright © 2017 Hasan Yavuz Özderya
 
#
 
# This file is part of serialplot.
 
#
 
# serialplot is free software: you can redistribute it and/or modify
 
# it under the terms of the GNU General Public License as published by
 
# the Free Software Foundation, either version 3 of the License, or
 
# (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(ExternalProject)
 

	
 
ExternalProject_Add(QCW
 
  PREFIX qcw
 
  GIT_REPOSITORY https://github.com/mbasaglia/Qt-Color-Widgets
 
  INSTALL_COMMAND "")
 

	
 
ExternalProject_Get_Property(QCW binary_dir source_dir)
 
set(QCW_LIBRARY ${binary_dir}/libColorWidgets-qt5.a)
 
set(QCW_INCLUDE_DIR ${source_dir}/include)
cmake/modules/BuildQwt.cmake
Show inline comments
 
@@ -28,7 +28,8 @@ ExternalProject_Add(QWT
 
                          -e "s/QWT_CONFIG\\s*\\+=\\s*QwtSvg/#&/"
 
                          -e "s/QWT_CONFIG\\s*\\+=\\s*QwtOpenGL/#&/"
 
						  -e "s|QWT_INSTALL_PREFIX\\s*=.*|QWT_INSTALL_PREFIX = <INSTALL_DIR>|"
 
							 <SOURCE_DIR>/qwtconfig.pri
 
                             <SOURCE_DIR>/qwtconfig.pri
 
  UPDATE_COMMAND ""
 
  CONFIGURE_COMMAND qmake <SOURCE_DIR>/qwt.pro
 
  )
 

	
serialplot.pro.user
Show inline comments
 
new file 100644
 
<?xml version="1.0" encoding="UTF-8"?>
 
<!DOCTYPE QtCreatorProject>
 
<!-- Written by QtCreator 3.5.1, 2017-01-01T16:17:25. -->
 
<qtcreator>
 
 <data>
 
  <variable>EnvironmentId</variable>
 
  <value type="QByteArray">{75be7855-4b40-4a75-b2d8-ba783826b955}</value>
 
 </data>
 
 <data>
 
  <variable>ProjectExplorer.Project.ActiveTarget</variable>
 
  <value type="int">0</value>
 
 </data>
 
 <data>
 
  <variable>ProjectExplorer.Project.EditorSettings</variable>
 
  <valuemap type="QVariantMap">
 
   <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
 
   <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
 
   <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
 
   <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
 
    <value type="QString" key="language">Cpp</value>
 
    <valuemap type="QVariantMap" key="value">
 
     <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
 
    </valuemap>
 
   </valuemap>
 
   <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
 
    <value type="QString" key="language">QmlJS</value>
 
    <valuemap type="QVariantMap" key="value">
 
     <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
 
    </valuemap>
 
   </valuemap>
 
   <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
 
   <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
 
   <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
 
   <value type="int" key="EditorConfiguration.IndentSize">4</value>
 
   <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
 
   <value type="int" key="EditorConfiguration.MarginColumn">80</value>
 
   <value type="bool" key="EditorConfiguration.MouseHiding">true</value>
 
   <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
 
   <value type="int" key="EditorConfiguration.PaddingMode">1</value>
 
   <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
 
   <value type="bool" key="EditorConfiguration.ShowMargin">false</value>
 
   <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
 
   <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
 
   <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
 
   <value type="int" key="EditorConfiguration.TabSize">8</value>
 
   <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
 
   <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
 
   <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
 
   <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
 
   <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
 
   <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
 
  </valuemap>
 
 </data>
 
 <data>
 
  <variable>ProjectExplorer.Project.PluginSettings</variable>
 
  <valuemap type="QVariantMap"/>
 
 </data>
 
 <data>
 
  <variable>ProjectExplorer.Project.Target.0</variable>
 
  <valuemap type="QVariantMap">
 
   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
 
   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
 
   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5b76ccd6-39cb-4bf8-aef1-7eda73647436}</value>
 
   <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
 
   <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
 
   <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
 
   <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
 
    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/heyyo/working/qtbuilds/build-serialplot-Desktop-Debug</value>
 
    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
 
     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
 
      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
 
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
 
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
 
      <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
 
      <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
 
      <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
 
      <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
 
      <value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
 
      <value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
 
     </valuemap>
 
     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
 
      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
 
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
 
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
 
      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
 
      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
 
      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
 
      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
 
     </valuemap>
 
     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
 
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
 
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
 
    </valuemap>
 
    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
 
     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
 
      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
 
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
 
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
 
      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
 
      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
 
      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
 
      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
 
     </valuemap>
 
     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
 
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
 
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
 
    </valuemap>
 
    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
 
    <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
 
    <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
 
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
 
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
 
    <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
 
    <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
 
   </valuemap>
 
   <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
 
    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/heyyo/working/qtbuilds/build-serialplot-Desktop-Release</value>
 
    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
 
     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
 
      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
 
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
 
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
 
      <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
 
      <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
 
      <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
 
      <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
 
      <value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
 
      <value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
 
     </valuemap>
 
     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
 
      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
 
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
 
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
 
      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
 
      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
 
      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
 
      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
 
     </valuemap>
 
     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
 
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
 
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
 
    </valuemap>
 
    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
 
     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
 
      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
 
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
 
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
 
      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
 
      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
 
      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
 
      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
 
     </valuemap>
 
     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
 
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
 
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
 
    </valuemap>
 
    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
 
    <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
 
    <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
 
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
 
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
 
    <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
 
    <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
 
   </valuemap>
 
   <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
 
   <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
 
    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
 
     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
 
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
 
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
 
    </valuemap>
 
    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
 
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
 
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
 
   </valuemap>
 
   <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
 
   <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
 
   <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
 
    <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
 
    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
 
    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
 
    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
 
    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
 
    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
 
    <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
 
    <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
 
    <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
 
    <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
 
    <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
 
    <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
 
    <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
 
    <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
 
    <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
 
    <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
 
    <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
 
    <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
 
     <value type="int">0</value>
 
     <value type="int">1</value>
 
     <value type="int">2</value>
 
     <value type="int">3</value>
 
     <value type="int">4</value>
 
     <value type="int">5</value>
 
     <value type="int">6</value>
 
     <value type="int">7</value>
 
     <value type="int">8</value>
 
     <value type="int">9</value>
 
     <value type="int">10</value>
 
     <value type="int">11</value>
 
     <value type="int">12</value>
 
     <value type="int">13</value>
 
     <value type="int">14</value>
 
    </valuelist>
 
    <value type="int" key="PE.EnvironmentAspect.Base">2</value>
 
    <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
 
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">serialplot</value>
 
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/heyyo/working/serialplot/serialplot.pro</value>
 
    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
 
    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">serialplot.pro</value>
 
    <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
 
    <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
 
    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
 
    <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
 
    <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
 
    <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
 
    <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
 
    <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
 
    <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
 
   </valuemap>
 
   <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
 
  </valuemap>
 
 </data>
 
 <data>
 
  <variable>ProjectExplorer.Project.TargetCount</variable>
 
  <value type="int">1</value>
 
 </data>
 
 <data>
 
  <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
 
  <value type="int">18</value>
 
 </data>
 
 <data>
 
  <variable>Version</variable>
 
  <value type="int">18</value>
 
 </data>
 
</qtcreator>
src/channelinfomodel.cpp
Show inline comments
 
@@ -19,14 +19,10 @@
 

	
 
#include "channelinfomodel.h"
 

	
 
#include <QColor>
 
#include <QtDebug>
 

	
 
enum ChannelInfoColumn
 
{
 
    COLUMN_NAME = 0,
 
    COLUMN_VISIBILITY,
 
    COLUMN_COLOR,
 
    COLUMN_COUNT
 
};
 

	
 
@@ -69,33 +65,32 @@ Qt::ItemFlags ChannelInfoModel::flags(co
 
    {
 
        return Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable;
 
    }
 
    else if (index.column() == COLUMN_COLOR)
 
    {
 
        return Qt::ItemIsEnabled | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable;
 
    }
 

	
 
    return Qt::NoItemFlags;
 
}
 

	
 
QVariant ChannelInfoModel::data(const QModelIndex &index, int role) const
 
{
 
    // check index
 
    if (index.row() >= (int) _numOfChannels)
 
    {
 
        return QVariant();
 
    }
 

	
 
    // get color
 
    if (role == Qt::ForegroundRole)
 
    {
 
        return infos[index.row()].color;
 
    }
 

	
 
    // get name
 
    if (index.column() == COLUMN_NAME)
 
    {
 
        if (role == Qt::DisplayRole || role == Qt::EditRole)
 
        {
 
            return QVariant(infos[index.row()].name);
 
        }
 
        else if (role == Qt::ForegroundRole)
 
        {
 
            // TODO: support more colors than 8
 
            return colors[index.row() % 8];
 
        }
 
    }
 
    } // get visibility
 
    else if (index.column() == COLUMN_VISIBILITY)
 
    {
 
        if (role == Qt::CheckStateRole)
 
@@ -104,13 +99,6 @@ QVariant ChannelInfoModel::data(const QM
 
            return visible ? Qt::Checked : Qt::Unchecked;
 
        }
 
    }
 
    else if (index.column() == COLUMN_COLOR)
 
    {
 
        if (role == Qt::ForegroundRole || role == Qt::BackgroundRole)
 
        {
 
            return colors[index.row() % 8];
 
        }
 
    }
 

	
 
    return QVariant();
 
}
 
@@ -129,10 +117,6 @@ QVariant ChannelInfoModel::headerData(in
 
            {
 
                return tr("Visible");
 
            }
 
            else if (section == COLUMN_COLOR)
 
            {
 
                return tr("Color");
 
            }
 
        }
 
    }
 
    else                        // vertical
 
@@ -148,11 +132,21 @@ QVariant ChannelInfoModel::headerData(in
 

	
 
bool ChannelInfoModel::setData(const QModelIndex &index, const QVariant &value, int role)
 
{
 
    // check index
 
    if (index.row() >= (int) _numOfChannels)
 
    {
 
        return false;
 
    }
 

	
 
    // set color
 
    if (role == Qt::ForegroundRole)
 
    {
 
        infos[index.row()].color = value.value<QColor>();
 
        emit dataChanged(index, index, QVector<int>({Qt::ForegroundRole}));
 
        return true;
 
    }
 

	
 
    // set name
 
    if (index.column() == COLUMN_NAME)
 
    {
 
        if (role == Qt::DisplayRole || role == Qt::EditRole)
 
@@ -160,7 +154,7 @@ bool ChannelInfoModel::setData(const QMo
 
            infos[index.row()].name = value.toString();
 
            return true;
 
        }
 
    }
 
    } // set visibility
 
    else if (index.column() == COLUMN_VISIBILITY)
 
    {
 
        if (role == Qt::CheckStateRole)
 
@@ -195,7 +189,7 @@ void ChannelInfoModel::setNumOfChannels(
 
    {
 
        for (unsigned ci = _numOfChannels; ci < number; ci++)
 
        {
 
            infos.append({QString("Channel %1").arg(ci+1), true});
 
            infos.append({QString("Channel %1").arg(ci+1), true, colors[ci % 8]});
 
        }
 
    }
 

	
src/channelinfomodel.h
Show inline comments
 
@@ -21,7 +21,7 @@
 
#define CHANNELINFOMODEL_H
 

	
 
#include <QAbstractTableModel>
 
#include <QStringList>
 
#include <QColor>
 

	
 
class ChannelInfoModel : public QAbstractTableModel
 
{
 
@@ -45,6 +45,7 @@ private:
 
    {
 
        QString name;
 
        bool visibility;
 
        QColor color;
 
    };
 

	
 
    unsigned _numOfChannels;     ///< @note this is not necessarily the length of `infos`
src/main.cpp
Show inline comments
 
@@ -26,7 +26,13 @@
 

	
 
// test code
 
#include <QTableView>
 
#include <QSpinBox>
 
#include <QColorDialog>
 
#include "channelinfomodel.h"
 
#include "utils.h"
 

	
 
#include "color_selector.hpp"
 
#include "color_dialog.hpp"
 

	
 
MainWindow* pMainWindow;
 

	
 
@@ -55,16 +61,42 @@ int main(int argc, char *argv[])
 
    w.show();
 

	
 
    // test code
 
    ChannelInfoModel cim(10, &a);
 
    ChannelInfoModel cim(2, &a);
 
    QTableView tv;
 
    QSpinBox cb;
 

	
 
    QObject::connect(&cb, SELECT<int>::OVERLOAD_OF(&QSpinBox::valueChanged), [&cim](int value)
 
                     {
 
                         cim.setNumOfChannels(value);
 
                     });
 

	
 
    tv.setModel(&cim);
 

	
 
    tv.show();
 
    // cb.show();
 

	
 
    // cim.setNumOfChannels(3);
 
    // cim.setNumOfChannels(10);
 
    // cim.setNumOfChannels(7);
 
    cim.setNumOfChannels(3);
 
    cim.setNumOfChannels(7);
 
    cim.setNumOfChannels(10);
 

	
 

	
 
    color_widgets::ColorSelector cpicker;
 
    cpicker.setColor(QColor("red"));
 
    cpicker.show();
 

	
 
    QObject::connect(tv.selectionModel(), &QItemSelectionModel::currentRowChanged,
 
                     [&cim, &cpicker](const QModelIndex &current, const QModelIndex &previous)
 
                     {
 
                         cpicker.setColor(cim.data(current, Qt::ForegroundRole).value<QColor>());
 
                     });
 

	
 
    QObject::connect(&cpicker, &color_widgets::ColorSelector::colorChanged,
 
                     [&cim, &tv](QColor color)
 
                     {
 
                         auto index = tv.selectionModel()->currentIndex();
 
                         index = index.sibling(index.row(), 0);
 
                         cim.setData(index, color, Qt::ForegroundRole);
 
                     });
 

	
 
    return a.exec();
 
}
src/plotcontrolpanel.ui
Show inline comments
 
@@ -17,14 +17,25 @@
 
   <item>
 
    <layout class="QVBoxLayout" name="verticalLayout">
 
     <item>
 
      <widget class="QLabel" name="label_2">
 
       <property name="styleSheet">
 
        <string notr="true">font-weight: bold;</string>
 
       </property>
 
       <property name="text">
 
        <string>Channel Names:</string>
 
       </property>
 
      </widget>
 
      <layout class="QHBoxLayout" name="horizontalLayout_2">
 
       <item>
 
        <widget class="QLabel" name="label_4">
 
         <property name="text">
 
          <string>Channel Names:</string>
 
         </property>
 
        </widget>
 
       </item>
 
       <item>
 
        <widget class="color_widgets::ColorSelector" name="colorSelector" native="true">
 
         <property name="sizePolicy">
 
          <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
 
           <horstretch>0</horstretch>
 
           <verstretch>0</verstretch>
 
          </sizepolicy>
 
         </property>
 
        </widget>
 
       </item>
 
      </layout>
 
     </item>
 
     <item>
 
      <widget class="QListView" name="lvChannelNames">
 
@@ -161,6 +172,14 @@
 
   </item>
 
  </layout>
 
 </widget>
 
 <customwidgets>
 
  <customwidget>
 
   <class>color_widgets::ColorSelector</class>
 
   <extends>QWidget</extends>
 
   <header>color_selector.hpp</header>
 
   <container>1</container>
 
  </customwidget>
 
 </customwidgets>
 
 <resources/>
 
 <connections/>
 
</ui>
0 comments (0 inline, 0 general)