aboutsummaryrefslogtreecommitdiff
path: root/src/qt/guiutil.h
diff options
context:
space:
mode:
authorgubatron <gubatron@gmail.com>2014-03-21 01:45:47 -0400
committergubatron <gubatron@gmail.com>2014-03-21 01:45:47 -0400
commit8c29273ff058f90dfa16a30b3d8457b842c0954d (patch)
treed6e52183eb06a512319343373ddc4a11e56b350b /src/qt/guiutil.h
parent6539cfc583c5963fbb3138b99c1a8677970e0305 (diff)
downloadbitcoin-8c29273ff058f90dfa16a30b3d8457b842c0954d.tar.xz
[QT] Fixes feel when resizing the last column on tables (issue #2862)
Re-submitting this pull request with a single commit. This patch introduces a GUIUtil class that is used when setting up the 2 tables we have so far on the Qt-GUI. In the past you could only resize the last column, which has BTC amounts from the right border of the column header, something that was rather unnatural. If a new table were ever to be added to the interface, fixing the last columns resizing behavior is rather simple. Just look at how we initialize here a TableViewLastColumnResizingFixer object when setting up the table header's behavior, and then how we override the resize event of the component (can be the table, or the dialog) and we invoke columnResizingFixer->stretchColumnWidth(columnIndex);
Diffstat (limited to 'src/qt/guiutil.h')
-rw-r--r--src/qt/guiutil.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h
index 52124ff20a..26202e8d41 100644
--- a/src/qt/guiutil.h
+++ b/src/qt/guiutil.h
@@ -8,6 +8,8 @@
#include <QMessageBox>
#include <QObject>
#include <QString>
+#include <QTableView>
+#include <QHeaderView>
class QValidatedLineEdit;
class SendCoinsRecipient;
@@ -116,6 +118,44 @@ namespace GUIUtil
int size_threshold;
};
+ /**
+ * Makes a QTableView last column feel as if it was being resized from its left border.
+ * Also makes sure the column widths are never larger than the table's viewport.
+ * In Qt, all columns are resizable from the right, but it's not intuitive resizing the last column from the right.
+ * Usually our second to last columns behave as if stretched, and when on strech mode, columns aren't resizable
+ * interactively or programatically.
+ *
+ * This helper object takes care of this issue.
+ *
+ */
+ class TableViewLastColumnResizingFixer: public QObject
+ {
+ Q_OBJECT
+ public:
+ TableViewLastColumnResizingFixer(QTableView* table, int lastColMinimumWidth, int allColsMinimumWidth);
+ void stretchColumnWidth(int column);
+
+ private:
+ QTableView* tableView;
+ int lastColumnMinimumWidth;
+ int allColumnsMinimumWidth;
+ int lastColumnIndex;
+ int columnCount;
+ int secondToLastColumnIndex;
+
+ void adjustTableColumnsWidth();
+ int getAvailableWidthForColumn(int column);
+ int getColumnsWidth();
+ void connectViewHeadersSignals();
+ void disconnectViewHeadersSignals();
+ void setViewHeaderResizeMode(int logicalIndex, QHeaderView::ResizeMode resizeMode);
+ void resizeColumn(int nColumnIndex, int width);
+
+ private slots:
+ void on_sectionResized(int logicalIndex, int oldSize, int newSize);
+ void on_geometriesChanged();
+ };
+
bool GetStartOnSystemStartup();
bool SetStartOnSystemStartup(bool fAutoStart);