Skip to content

Commit

Permalink
Merge #618: refactor: Add transactionoverviewwidget.cpp source file
Browse files Browse the repository at this point in the history
a50e0b1 qt, refactor: Add `transactionoverviewwidget.cpp` source file (Hennadii Stepanov)

Pull request description:

  The `TransactionOverviewWidget` class was added in #176 as a header-only one.

  Apparently, in upcoming [CMake project](hebasto/bitcoin#3), CMake [AUTOMOC](https://cmake.org/cmake/help/latest/prop_tgt/AUTOMOC.html) could be integrated better/simpler, if `QObject`-derived class implementation been placed into a source file.

  From our [Developer Notes](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#source-code-organization):
  > Implementation code should go into the `.cpp` file and not the `.h`, unless necessary due to template usage or when performance due to inlining is critical.

ACKs for top commit:
  Sjors:
    tACK a50e0b1
  shaavan:
    ACK a50e0b1

Tree-SHA512: 4707b6be1c5e794c4014475f826ac45ec833e472db11f12d29995f9c5a599ee98622ad54f0af72734b192144b626411c69acdafa0e6d1a390bdebfd7e570f377
  • Loading branch information
hebasto committed Jun 15, 2022
2 parents a7a3659 + a50e0b1 commit 26ec2f2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
1 change: 1 addition & 0 deletions build_msvc/libbitcoin_qt/libbitcoin_qt.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<ClCompile Include="..\..\src\qt\transactiondesc.cpp" />
<ClCompile Include="..\..\src\qt\transactiondescdialog.cpp" />
<ClCompile Include="..\..\src\qt\transactionfilterproxy.cpp" />
<ClCompile Include="..\..\src\qt\transactionoverviewwidget.cpp" />
<ClCompile Include="..\..\src\qt\transactionrecord.cpp" />
<ClCompile Include="..\..\src\qt\transactiontablemodel.cpp" />
<ClCompile Include="..\..\src\qt\transactionview.cpp" />
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ BITCOIN_QT_WALLET_CPP = \
qt/transactiondesc.cpp \
qt/transactiondescdialog.cpp \
qt/transactionfilterproxy.cpp \
qt/transactionoverviewwidget.cpp \
qt/transactionrecord.cpp \
qt/transactiontablemodel.cpp \
qt/transactionview.cpp \
Expand Down
27 changes: 27 additions & 0 deletions src/qt/transactionoverviewwidget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) 2021 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <qt/transactionoverviewwidget.h>

#include <qt/transactiontablemodel.h>

#include <QListView>
#include <QSize>
#include <QSizePolicy>

TransactionOverviewWidget::TransactionOverviewWidget(QWidget* parent)
: QListView(parent) {}

QSize TransactionOverviewWidget::sizeHint() const
{
return {sizeHintForColumn(TransactionTableModel::ToAddress), QListView::sizeHint().height()};
}

void TransactionOverviewWidget::showEvent(QShowEvent* event)
{
Q_UNUSED(event);
QSizePolicy sp = sizePolicy();
sp.setHorizontalPolicy(QSizePolicy::Minimum);
setSizePolicy(sp);
}
19 changes: 3 additions & 16 deletions src/qt/transactionoverviewwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
#ifndef BITCOIN_QT_TRANSACTIONOVERVIEWWIDGET_H
#define BITCOIN_QT_TRANSACTIONOVERVIEWWIDGET_H

#include <qt/transactiontablemodel.h>

#include <QListView>
#include <QSize>
#include <QSizePolicy>

QT_BEGIN_NAMESPACE
class QShowEvent;
Expand All @@ -21,21 +18,11 @@ class TransactionOverviewWidget : public QListView
Q_OBJECT

public:
explicit TransactionOverviewWidget(QWidget* parent = nullptr) : QListView(parent) {}

QSize sizeHint() const override
{
return {sizeHintForColumn(TransactionTableModel::ToAddress), QListView::sizeHint().height()};
}
explicit TransactionOverviewWidget(QWidget* parent = nullptr);
QSize sizeHint() const override;

protected:
void showEvent(QShowEvent* event) override
{
Q_UNUSED(event);
QSizePolicy sp = sizePolicy();
sp.setHorizontalPolicy(QSizePolicy::Minimum);
setSizePolicy(sp);
}
void showEvent(QShowEvent* event) override;
};

#endif // BITCOIN_QT_TRANSACTIONOVERVIEWWIDGET_H

0 comments on commit 26ec2f2

Please sign in to comment.