Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Add transactionoverviewwidget.cpp source file #618

Merged
merged 1 commit into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QSize is included in the header file, could delete this line.

#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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QListView is being included in both files now. Could remove it from here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From our Developer Notes:

Every .cpp and .h file should #include every header file it directly uses classes, functions or other definitions from, even if those headers are already included indirectly through other headers.

#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