summaryrefslogtreecommitdiffstats
path: root/application/widgets
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-05-02 23:42:33 +0200
committerPetr Mrázek <peterix@gmail.com>2015-05-02 23:42:33 +0200
commit5779ffd6645ba3fae5abe068d456fc1ee9dd91ff (patch)
treebe5d81b6132b63db368e7061d766f70250fa222c /application/widgets
parent4fc4a172562a76091721b8c488aafbd6ed2b01ed (diff)
downloadMultiMC-5779ffd6645ba3fae5abe068d456fc1ee9dd91ff.tar
MultiMC-5779ffd6645ba3fae5abe068d456fc1ee9dd91ff.tar.gz
MultiMC-5779ffd6645ba3fae5abe068d456fc1ee9dd91ff.tar.lz
MultiMC-5779ffd6645ba3fae5abe068d456fc1ee9dd91ff.tar.xz
MultiMC-5779ffd6645ba3fae5abe068d456fc1ee9dd91ff.zip
GH-922 improve version select dialogs
Diffstat (limited to 'application/widgets')
-rw-r--r--application/widgets/VersionListView.cpp31
-rw-r--r--application/widgets/VersionListView.h16
2 files changed, 45 insertions, 2 deletions
diff --git a/application/widgets/VersionListView.cpp b/application/widgets/VersionListView.cpp
index fc0bcd0a..1e327534 100644
--- a/application/widgets/VersionListView.cpp
+++ b/application/widgets/VersionListView.cpp
@@ -65,6 +65,23 @@ void VersionListView::reset()
void VersionListView::setEmptyString(QString emptyString)
{
m_emptyString = emptyString;
+ updateEmptyViewPort();
+}
+
+void VersionListView::setEmptyErrorString(QString emptyErrorString)
+{
+ m_emptyErrorString = emptyErrorString;
+ updateEmptyViewPort();
+}
+
+void VersionListView::setEmptyMode(VersionListView::EmptyMode mode)
+{
+ m_emptyMode = mode;
+ updateEmptyViewPort();
+}
+
+void VersionListView::updateEmptyViewPort()
+{
if(!m_itemCount)
{
viewport()->update();
@@ -85,6 +102,18 @@ void VersionListView::paintEvent(QPaintEvent *event)
void VersionListView::paintInfoLabel(QPaintEvent *event)
{
+ QString emptyString;
+ switch(m_emptyMode)
+ {
+ case VersionListView::Empty:
+ return;
+ case VersionListView::String:
+ emptyString = m_emptyString;
+ break;
+ case VersionListView::ErrorString:
+ emptyString = m_emptyErrorString;
+ break;
+ }
//calculate the rect for the overlay
QPainter painter(viewport());
painter.setRenderHint(QPainter::Antialiasing, true);
@@ -93,7 +122,7 @@ void VersionListView::paintInfoLabel(QPaintEvent *event)
QRect bounds = viewport()->geometry();
bounds.moveTop(0);
- QTextLayout layout(m_emptyString, font);
+ QTextLayout layout(emptyString, font);
qreal height = 0.0;
qreal widthUsed = 0.0;
QStringList lines = viewItemTextLayout(layout, bounds.width() - 20, height, widthUsed);
diff --git a/application/widgets/VersionListView.h b/application/widgets/VersionListView.h
index f33a6fdb..4fcbd8ee 100644
--- a/application/widgets/VersionListView.h
+++ b/application/widgets/VersionListView.h
@@ -22,11 +22,22 @@ class VersionListView : public QTreeView
{
Q_OBJECT
public:
+
explicit VersionListView(QWidget *parent = 0);
virtual void paintEvent(QPaintEvent *event) override;
- void setEmptyString(QString emptyString);
virtual void setModel ( QAbstractItemModel* model );
+ enum EmptyMode
+ {
+ Empty,
+ String,
+ ErrorString
+ };
+
+ void setEmptyString(QString emptyString);
+ void setEmptyErrorString(QString emptyErrorString);
+ void setEmptyMode(EmptyMode mode);
+
public slots:
virtual void reset() override;
@@ -36,8 +47,11 @@ protected slots:
private: /* methods */
void paintInfoLabel(QPaintEvent *event);
+ void updateEmptyViewPort();
private: /* variables */
int m_itemCount = 0;
QString m_emptyString;
+ QString m_emptyErrorString;
+ EmptyMode m_emptyMode = Empty;
};