Add extended RDListWidget, which adds mouse click/double-click

This commit is contained in:
baldurk
2016-11-14 14:07:47 +01:00
parent 04004e3243
commit 10d1dc6e53
5 changed files with 107 additions and 2 deletions
@@ -0,0 +1,46 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2016 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
#include "RDListWidget.h"
#include <QMouseEvent>
RDListWidget::RDListWidget(QWidget *parent) : QListWidget(parent)
{
}
RDListWidget::~RDListWidget()
{
}
void RDListWidget::mousePressEvent(QMouseEvent *event)
{
emit(mouseClicked(event));
QListWidget::mousePressEvent(event);
}
void RDListWidget::mouseDoubleClickEvent(QMouseEvent *event)
{
emit(mouseDoubleClicked(event));
QListWidget::mouseDoubleClickEvent(event);
}
@@ -0,0 +1,45 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2016 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
#pragma once
#include <QListWidget>
class RDListWidget : public QListWidget
{
private:
Q_OBJECT
public:
explicit RDListWidget(QWidget *parent = 0);
~RDListWidget();
signals:
void mouseClicked(QMouseEvent *event);
void mouseDoubleClicked(QMouseEvent *event);
public slots:
protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseDoubleClickEvent(QMouseEvent *event) override;
};
+4 -2
View File
@@ -101,7 +101,8 @@ SOURCES += 3rdparty/toolwindowmanager/ToolWindowManager.cpp \
Widgets/RangeHistogram.cpp \
Windows/Dialogs/TextureSaveDialog.cpp \
Windows/Dialogs/CaptureDialog.cpp \
Code/QRDUtils.cpp
Code/QRDUtils.cpp \
Widgets/Extended/RDListWidget.cpp
HEADERS += 3rdparty/toolwindowmanager/ToolWindowManager.h \
3rdparty/toolwindowmanager/ToolWindowManagerArea.h \
@@ -127,7 +128,8 @@ HEADERS += 3rdparty/toolwindowmanager/ToolWindowManager.h \
Widgets/RangeHistogram.h \
Windows/Dialogs/TextureSaveDialog.h \
Windows/Dialogs/CaptureDialog.h \
Code/QRDUtils.h
Code/QRDUtils.h \
Widgets/Extended/RDListWidget.h
FORMS += Windows/Dialogs/AboutDialog.ui \
Windows/MainWindow.ui \
+3
View File
@@ -296,6 +296,7 @@
<ClCompile Include="generated\moc_RDLineEdit.cpp" />
<ClCompile Include="generated\moc_MainWindow.cpp" />
<ClCompile Include="generated\moc_RDListView.cpp" />
<ClCompile Include="generated\moc_RDListWidget.cpp" />
<ClCompile Include="generated\moc_ResourcePreview.cpp" />
<ClCompile Include="generated\moc_TextureGoto.cpp" />
<ClCompile Include="generated\moc_TextureSaveDialog.cpp" />
@@ -305,6 +306,7 @@
<ClCompile Include="generated\moc_ToolWindowManagerArea.cpp" />
<ClCompile Include="generated\moc_ToolWindowManagerWrapper.cpp" />
<ClCompile Include="generated\qrc_resources.cpp" />
<ClCompile Include="Widgets\Extended\RDListWidget.cpp" />
<ClCompile Include="Widgets\RangeHistogram.cpp" />
<ClCompile Include="Widgets\Extended\RDDoubleSpinBox.cpp" />
<ClCompile Include="Widgets\Extended\RDLabel.cpp" />
@@ -350,6 +352,7 @@
<ClInclude Include="generated\ui_TextureViewer.h" />
<ClInclude Include="generated\ui_ThumbnailStrip.h" />
<ClInclude Include="Resources\resource.h" />
<ClInclude Include="Widgets\Extended\RDListWidget.h" />
<ClInclude Include="Widgets\RangeHistogram.h" />
<ClInclude Include="Widgets\Extended\RDDoubleSpinBox.h" />
<ClInclude Include="Widgets\Extended\RDLabel.h" />
@@ -184,6 +184,12 @@
<ClCompile Include="Code\qprocessinfo.cpp">
<Filter>Code</Filter>
</ClCompile>
<ClCompile Include="Widgets\Extended\RDListWidget.cpp">
<Filter>Widgets\Extended</Filter>
</ClCompile>
<ClCompile Include="generated\moc_RDListWidget.cpp">
<Filter>Generated Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="3rdparty\flowlayout\FlowLayout.h">
@@ -276,6 +282,9 @@
<ClInclude Include="Code\qprocessinfo.h">
<Filter>Code</Filter>
</ClInclude>
<ClInclude Include="Widgets\Extended\RDListWidget.h">
<Filter>Widgets\Extended</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="resources.qrc">