Author: mir3x
Date: Mon Sep 1 14:44:08 2014
New Revision: 26169
URL: http://svn.gna.org/viewcvs/freeciv?rev=26169&view=rev
Log:
Added tile pixmap to unit label (often useful when city labels
take too much space and player doesnt see current terrain)
See patch #5138
Modified:
branches/S2_5/client/gui-qt/cityrep.cpp
branches/S2_5/client/gui-qt/cityrep.h
Modified: branches/S2_5/client/gui-qt/cityrep.cpp
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/cityrep.cpp?rev=26169&r1=26168&r2=26169&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/cityrep.cpp (original)
+++ branches/S2_5/client/gui-qt/cityrep.cpp Mon Sep 1 14:44:08 2014
@@ -26,6 +26,27 @@
static bool can_city_sell_universal(const struct city *pcity,
struct universal target);
+
+
+bool city_sort_model::lessThan(const QModelIndex &left,
+ const QModelIndex &right) const
+{
+ QVariant qleft;
+ QVariant qright;
+ int i;
+
+ qleft = sourceModel()->data(left);
+ qright = sourceModel()->data(right);
+ i = cityrepfield_compare(qleft.toString().toLocal8Bit().data(),
+ qright.toString().toLocal8Bit().data());
+
+ if (i >= 0) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
/***************************************************************************
City item delegate constructor
@@ -297,7 +318,7 @@
c_i_d = new city_item_delegate(this);
setItemDelegate(c_i_d);
list_model = new city_model(this);
- filter_model = new QSortFilterProxyModel();
+ filter_model = new city_sort_model();
filter_model->setDynamicSortFilter(true);
filter_model->setSourceModel(list_model);
filter_model->setFilterRole(Qt::DisplayRole);
Modified: branches/S2_5/client/gui-qt/cityrep.h
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/cityrep.h?rev=26169&r1=26168&r2=26169&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/cityrep.h (original)
+++ branches/S2_5/client/gui-qt/cityrep.h Mon Sep 1 14:44:08 2014
@@ -40,6 +40,7 @@
// Qt
#include <QAbstractListModel>
#include <QItemDelegate>
+#include <QSortFilterProxyModel>
#include <QTreeView>
#include <QWidget>
#include <QMenu>
@@ -56,6 +57,11 @@
class QTableWidget;
class QVBoxLayout;
class city_report;
+
+class city_sort_model:public QSortFilterProxyModel
+{
+ bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
+};
/***************************************************************************
Item delegate for painting in model of city table
_______________________________________________
Freeciv-commits mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-commits