|
From: <cn...@us...> - 2020-11-08 21:57:38
|
Revision: 1096
http://sourceforge.net/p/seq/svn/1096
Author: cn187
Date: 2020-11-08 21:57:35 +0000 (Sun, 08 Nov 2020)
Log Message:
-----------
Replace Q3ListView with QTreeWidget
Modified Paths:
--------------
showeq/branches/pre_6_0_beta/src/combatlog.cpp
showeq/branches/pre_6_0_beta/src/combatlog.h
showeq/branches/pre_6_0_beta/src/experiencelog.cpp
showeq/branches/pre_6_0_beta/src/experiencelog.h
showeq/branches/pre_6_0_beta/src/guildlist.cpp
showeq/branches/pre_6_0_beta/src/guildlist.h
showeq/branches/pre_6_0_beta/src/interface.h
showeq/branches/pre_6_0_beta/src/seqlistview.cpp
showeq/branches/pre_6_0_beta/src/seqlistview.h
showeq/branches/pre_6_0_beta/src/skilllist.cpp
showeq/branches/pre_6_0_beta/src/skilllist.h
showeq/branches/pre_6_0_beta/src/spawnlist.cpp
showeq/branches/pre_6_0_beta/src/spawnlist.h
showeq/branches/pre_6_0_beta/src/spawnlist2.cpp
showeq/branches/pre_6_0_beta/src/spawnlist2.h
showeq/branches/pre_6_0_beta/src/spawnlistcommon.cpp
showeq/branches/pre_6_0_beta/src/spawnlistcommon.h
showeq/branches/pre_6_0_beta/src/spawnpointlist.cpp
showeq/branches/pre_6_0_beta/src/spawnpointlist.h
showeq/branches/pre_6_0_beta/src/spelllist.cpp
showeq/branches/pre_6_0_beta/src/spelllist.h
showeq/branches/pre_6_0_beta/src/spellshell.h
showeq/branches/pre_6_0_beta/src/statlist.cpp
showeq/branches/pre_6_0_beta/src/statlist.h
Modified: showeq/branches/pre_6_0_beta/src/combatlog.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/combatlog.cpp 2020-11-03 02:02:50 UTC (rev 1095)
+++ showeq/branches/pre_6_0_beta/src/combatlog.cpp 2020-11-08 21:57:35 UTC (rev 1096)
@@ -308,7 +308,7 @@
QWidget* CombatWindow::initOffenseWidget()
{
- QWidget *pWidget = new QWidget(m_tab);
+ QWidget *pWidget = new QWidget(m_tab);
m_layout_offense = new QVBoxLayout(pWidget);
@@ -315,27 +315,19 @@
QGroupBox *listGBox = new QGroupBox(pWidget);
m_layout_offense->addWidget(listGBox);
- m_listview_offense = new SEQListView(preferenceName(), listGBox);
- m_listview_offense->addColumn("Type");
- m_listview_offense->setColumnAlignment(0, Qt::AlignRight);
- m_listview_offense->addColumn("Hit");
- m_listview_offense->setColumnAlignment(1, Qt::AlignRight);
- m_listview_offense->addColumn("Miss");
- m_listview_offense->setColumnAlignment(2, Qt::AlignRight);
- m_listview_offense->addColumn("Ratio");
- m_listview_offense->setColumnAlignment(3, Qt::AlignRight);
- m_listview_offense->addColumn("Avg");
- m_listview_offense->setColumnAlignment(4, Qt::AlignRight);
- m_listview_offense->addColumn("Min");
- m_listview_offense->setColumnAlignment(5, Qt::AlignRight);
- m_listview_offense->addColumn("Max");
- m_listview_offense->setColumnAlignment(6, Qt::AlignRight);
- m_listview_offense->addColumn("Total");
- m_listview_offense->setColumnAlignment(7, Qt::AlignRight);
+ m_listview_offense = new SEQListView(preferenceName(), listGBox);
+ m_listview_offense->addColumn("Type");
+ m_listview_offense->addColumn("Hit");
+ m_listview_offense->addColumn("Miss");
+ m_listview_offense->addColumn("Ratio");
+ m_listview_offense->addColumn("Avg");
+ m_listview_offense->addColumn("Min");
+ m_listview_offense->addColumn("Max");
+ m_listview_offense->addColumn("Total");
- m_listview_offense->restoreColumns();
+ m_listview_offense->restoreColumns();
- m_listview_offense->setMinimumSize(m_listview_offense->sizeHint().width(), 200);
+ m_listview_offense->setMinimumSize(m_listview_offense->sizeHint().width(), 200);
QHBoxLayout * listGBoxLayout = new QHBoxLayout(listGBox);
listGBoxLayout->addWidget(m_listview_offense);
@@ -493,42 +485,34 @@
QWidget* CombatWindow::initMobWidget()
{
- QWidget *pWidget = new QWidget(m_tab);
+ QWidget *pWidget = new QWidget(m_tab);
- m_layout_mob = new QVBoxLayout(pWidget);
+ m_layout_mob = new QVBoxLayout(pWidget);
- QGroupBox *listGBox = new QGroupBox(pWidget);
- m_layout_mob->addWidget(listGBox);
+ QGroupBox *listGBox = new QGroupBox(pWidget);
+ m_layout_mob->addWidget(listGBox);
- m_listview_mob = new SEQListView(preferenceName(), listGBox);
- m_listview_mob->addColumn("Time");
- m_listview_mob->setColumnAlignment(0, Qt::AlignRight);
- m_listview_mob->addColumn("Name");
- m_listview_mob->setColumnAlignment(1, Qt::AlignRight);
- m_listview_mob->addColumn("ID");
- m_listview_mob->setColumnAlignment(2, Qt::AlignRight);
- m_listview_mob->addColumn("Duration");
- m_listview_mob->setColumnAlignment(3, Qt::AlignRight);
- m_listview_mob->addColumn("Damage Given");
- m_listview_mob->setColumnAlignment(4, Qt::AlignRight);
- m_listview_mob->addColumn("DPS");
- m_listview_mob->setColumnAlignment(5, Qt::AlignRight);
- m_listview_mob->addColumn("Damage Taken");
- m_listview_mob->setColumnAlignment(6, Qt::AlignRight);
- m_listview_mob->addColumn("MOB DPS");
- m_listview_mob->setColumnAlignment(7, Qt::AlignRight);
+ m_listview_mob = new SEQListView(preferenceName(), listGBox);
+ m_listview_mob->addColumn("Time");
+ m_listview_mob->addColumn("Name");
+ m_listview_mob->addColumn("ID");
+ m_listview_mob->addColumn("Duration");
+ m_listview_mob->addColumn("Damage Given");
+ m_listview_mob->addColumn("DPS");
+ m_listview_mob->addColumn("Damage Taken");
+ m_listview_mob->addColumn("MOB DPS");
- m_listview_mob->restoreColumns();
+ m_listview_mob->restoreColumns();
- m_listview_mob->setMinimumSize(m_listview_mob->sizeHint().width(), 200);
+ m_listview_mob->setMinimumSize(m_listview_mob->sizeHint().width(), 200);
QHBoxLayout *listGBoxLayout = new QHBoxLayout(listGBox);
listGBoxLayout->addWidget(m_listview_mob);
- QGroupBox *summaryGBox = new QGroupBox("Summary", pWidget);
+ QGroupBox *summaryGBox = new QGroupBox("Summary", pWidget);
QHBoxLayout *summaryGBoxLayout = new QHBoxLayout(summaryGBox);
- m_layout_mob->addWidget(summaryGBox);
+ m_layout_mob->addWidget(summaryGBox);
QGridLayout *summaryGridLayout = new QGridLayout();
@@ -676,12 +660,22 @@
QString s_damage;
s_damage.setNum(iDamage);
- Q3ListViewItem *pItem = new Q3ListViewItem(m_listview_offense,
- s_type, s_hits, s_misses, s_ratio,
- s_avgdamage, s_mindamage, s_maxdamage, s_damage);
+ QStringList item_values;
+ item_values << s_type << s_hits << s_misses << s_ratio
+ << s_avgdamage << s_mindamage << s_maxdamage << s_damage;
- m_listview_offense->insertItem(pItem);
+ SEQListViewItem *pItem = new SEQListViewItem(m_listview_offense, item_values);
+ pItem->setTextAlignment(0, Qt::AlignRight);
+ pItem->setTextAlignment(1, Qt::AlignRight);
+ pItem->setTextAlignment(2, Qt::AlignRight);
+ pItem->setTextAlignment(3, Qt::AlignRight);
+ pItem->setTextAlignment(4, Qt::AlignRight);
+ pItem->setTextAlignment(5, Qt::AlignRight);
+ pItem->setTextAlignment(6, Qt::AlignRight);
+ pItem->setTextAlignment(7, Qt::AlignRight);
+
+
switch(iType)
{
case 0: // 1H Blunt
@@ -819,13 +813,22 @@
QString s_iDamageTaken = QString::number(iDamageTaken);
QString s_mobdps = QString::number(dMobDPS);
+ QStringList item_values;
+ item_values << s_time << s_name << s_id << s_duration << s_damagegiven
+ << s_dps << s_iDamageTaken << s_mobdps;
- Q3ListViewItem *pItem = new Q3ListViewItem(m_listview_mob,
- s_time, s_name, s_id, s_duration, s_damagegiven,
- s_dps, s_iDamageTaken, s_mobdps);
+ SEQListViewItem* pItem = new SEQListViewItem(m_listview_mob, item_values);
- m_listview_mob->insertItem(pItem);
+ pItem->setTextAlignment(0, Qt::AlignRight);
+ pItem->setTextAlignment(1, Qt::AlignRight);
+ pItem->setTextAlignment(2, Qt::AlignRight);
+ pItem->setTextAlignment(3, Qt::AlignRight);
+ pItem->setTextAlignment(4, Qt::AlignRight);
+ pItem->setTextAlignment(5, Qt::AlignRight);
+ pItem->setTextAlignment(6, Qt::AlignRight);
+ pItem->setTextAlignment(7, Qt::AlignRight);
+
iTotalMobs++;
dDPSSum += dDPS;
}
Modified: showeq/branches/pre_6_0_beta/src/combatlog.h
===================================================================
--- showeq/branches/pre_6_0_beta/src/combatlog.h 2020-11-03 02:02:50 UTC (rev 1095)
+++ showeq/branches/pre_6_0_beta/src/combatlog.h 2020-11-08 21:57:35 UTC (rev 1096)
@@ -27,7 +27,6 @@
# include <QWidget>
# include <QTabWidget>
# include <QList>
-# include <Q3ListView>
# include <QComboBox>
# include <QLabel>
# include <QLayout>
Modified: showeq/branches/pre_6_0_beta/src/experiencelog.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/experiencelog.cpp 2020-11-03 02:02:50 UTC (rev 1095)
+++ showeq/branches/pre_6_0_beta/src/experiencelog.cpp 2020-11-08 21:57:35 UTC (rev 1096)
@@ -400,15 +400,17 @@
strftime(s_time, 64, "%m/%d %H:%M:%S", localtime( &timev ));
/* Update suggested by Shag */
- Q3ListViewItem *new_exp_entry =
- new Q3ListViewItem( m_exp_listview, s_time, s_mob_name,
- s_mob_level, s_xp_value, s_xp_valueZEM,
- s_xp_valuep, s_xp_valueg, s_xp_gained );
+ QStringList values;
+ values << s_time << s_mob_name << s_mob_level << s_xp_value
+ << s_xp_valueZEM << s_xp_valuep << s_xp_valueg << s_xp_gained;
- m_exp_listview->insertItem( new_exp_entry );
- m_exp_listview->setSelected( new_exp_entry, TRUE );
- m_exp_listview->ensureItemVisible( new_exp_entry );
+ SEQListViewItem* new_exp_entry =
+ new SEQListViewItem(m_exp_listview, values);
+ m_exp_listview->setCurrentItem(new_exp_entry);
+
+ m_exp_listview->scrollToItem(new_exp_entry);
+
// Initial work on new logging mechanism with more data
FILE* newlogfp = NULL;
@@ -416,7 +418,7 @@
newlogfp = fopen(m_newExpLogFile.toAscii().data(), "a");
if (newlogfp != NULL)
- {
+ {
// append a new record entry
fprintf(newlogfp,
Modified: showeq/branches/pre_6_0_beta/src/experiencelog.h
===================================================================
--- showeq/branches/pre_6_0_beta/src/experiencelog.h 2020-11-03 02:02:50 UTC (rev 1095)
+++ showeq/branches/pre_6_0_beta/src/experiencelog.h 2020-11-08 21:57:35 UTC (rev 1096)
@@ -29,7 +29,6 @@
#include <QObject>
#include <QWidget>
#include <QList>
-#include <Q3ListView>
#include <QComboBox>
#include <QLabel>
#include <QLayout>
@@ -136,6 +135,7 @@
QVBoxLayout *m_layout;
SEQListView *m_exp_listview;
+ //QTreeWidget *m_exp_listview;
QLabel *m_experience_rate_label;
QLabel *m_total_received, *m_mob_count, *m_average_per_mob,
Modified: showeq/branches/pre_6_0_beta/src/guildlist.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/guildlist.cpp 2020-11-03 02:02:50 UTC (rev 1095)
+++ showeq/branches/pre_6_0_beta/src/guildlist.cpp 2020-11-08 21:57:35 UTC (rev 1096)
@@ -37,13 +37,14 @@
#include <QHBoxLayout>
#include <QBoxLayout>
#include <QVBoxLayout>
+#include <QHeaderView>
//----------------------------------------------------------------------
// GuildListItem
-GuildListItem::GuildListItem(Q3ListView* parent,
- const GuildMember* member,
- const GuildShell* guildShell)
- : Q3ListViewItem(parent),
+GuildListItem::GuildListItem(SEQListView* parent,
+ const GuildMember* member,
+ const GuildShell* guildShell)
+ : SEQListViewItem(parent),
m_member(member)
{
update(guildShell);
@@ -53,61 +54,48 @@
{
}
-void GuildListItem::paintCell( QPainter *p, const QColorGroup &cg,
- int column, int width, int alignment )
+QVariant GuildListItem::data(int column, int role) const
{
- QFont font = this->listView()->font();
+ QFont font = treeWidget()->font();
+ switch(role)
+ {
+ case Qt::FontRole:
+ if (m_member->zoneId())
+ font.setBold(true);
+ else
+ font.setBold(false);
- // members that are actually logged in have their names in bold
- if (m_member->zoneId())
- font.setBold(true);
- else
- font.setBold(false);
+ return font;
- p->setFont(font);
+ default:
+ return SEQListViewItem::data(column, role);
+ }
- Q3ListViewItem::paintCell( p, cg, column, width, alignment );
}
-int GuildListItem::compare(Q3ListViewItem *o, int col, bool ascending) const
+bool GuildListItem::operator<(const GuildListItem& other) const
{
- if (!m_member)
- return -1;
+ int column = treeWidget() ? treeWidget()->sortColumn() : 0;
- GuildListItem* other = (GuildListItem*)o;
- const GuildMember* otherMember = other->guildMember();
+ switch(column)
+ {
+ case 1: // level
+ return data(column, Qt::DisplayRole).value<int>() <
+ other.data(column, Qt::DisplayRole).value<int>();
- switch (col)
- {
- case 1: // Level
- if (m_member->level() == otherMember->level())
- return 0;
- else
- return m_member->level() > otherMember->level() ? 1 : -1;
- case 3: // Guild Rank
- if (m_member->guildRank() == otherMember->guildRank())
- return 0;
- else
- return m_member->guildRank() > otherMember->guildRank() ? 1 : -1;
- case 4: // Banker Rank
- if (m_member->bankRank() == otherMember->bankRank())
- return 0;
- else
- return m_member->bankRank() > otherMember->bankRank() ? 1 : -1;
+ case 6: // last on
+ return guildMember()->lastOn() < other.guildMember()->lastOn();
- case 5: // Alt rank
- if (m_member->altRank() == otherMember->altRank())
- return 0;
- else
- return m_member->altRank() > otherMember->altRank() ? 1 : -1;
- case 6: // Last On
- if (m_member->lastOn() == otherMember->lastOn())
- return 0;
- else
- return m_member->lastOn() > otherMember->lastOn() ? 1 : -1;
- default:
- return Q3ListViewItem::compare(o, col, ascending);
- }
+ case 0: // name
+ case 2: // class
+ case 3: // rank
+ case 4: // banker
+ case 5: // alt
+ case 7: // zone
+ case 8: // public note
+ default: // Qt sorts values as strings by default
+ return text(column) < other.text(column);
+ }
}
static const QString dateFormat("ddd MMM dd hh:mm:ss yyyy");
@@ -192,8 +180,9 @@
hLayout->addWidget(m_guildTotals, 0, Qt::AlignRight);
// create the spawn listview
- m_guildList = new SEQListView(preferenceName(),
- this, "guildlistview");
+ m_guildList = new SEQListView(preferenceName(), this, "guildlistview");
+ m_guildList->setSortingEnabled(m_keepSorted);
+
vLayout->addWidget(m_guildList);
// setup the columns
@@ -220,6 +209,9 @@
connect(m_player, SIGNAL(guildChanged()),
this, SLOT(guildChanged()));
+ connect(m_guildList, SIGNAL(mouseRightButtonPressed(QMouseEvent*)),
+ this, SLOT(listMouseRightButtonPressed(QMouseEvent*)));
+
// populate the window
populate();
}
@@ -228,6 +220,14 @@
{
}
+void GuildListWindow::listMouseRightButtonPressed(QMouseEvent* event)
+{
+ if (event->button() == Qt::RightButton)
+ {
+ menu()->popup(event->globalPos());
+ }
+}
+
QMenu* GuildListWindow::menu()
{
if (m_menu)
@@ -386,7 +386,8 @@
// make sure the guild list is sorted
if (m_keepSorted)
- m_guildList->sort();
+ m_guildList->sortByColumn(m_guildList->sortColumn(),
+ m_guildList->header()->sortIndicatorOrder());
updateCount();
}
@@ -430,10 +431,11 @@
void GuildListWindow::toggle_keepSorted(bool enable)
{
m_keepSorted = enable;
- pSEQPrefs->setPrefBool("KeepSorted", preferenceName(),
- m_keepSorted);
+ pSEQPrefs->setPrefBool("KeepSorted", preferenceName(), m_keepSorted);
+ m_guildList->setSortingEnabled(enable);
if (m_keepSorted)
- m_guildList->sort();
+ m_guildList->sortByColumn(m_guildList->sortColumn(),
+ m_guildList->header()->sortIndicatorOrder());
}
void GuildListWindow::toggle_guildListCol(QAction* col)
@@ -533,7 +535,9 @@
}
// make sure the guild list is sorted
- m_guildList->sort();
+ if (m_keepSorted)
+ m_guildList->sortByColumn(m_guildList->sortColumn(),
+ m_guildList->header()->sortIndicatorOrder());
// update the counts
updateCount();
Modified: showeq/branches/pre_6_0_beta/src/guildlist.h
===================================================================
--- showeq/branches/pre_6_0_beta/src/guildlist.h 2020-11-03 02:02:50 UTC (rev 1095)
+++ showeq/branches/pre_6_0_beta/src/guildlist.h 2020-11-08 21:57:35 UTC (rev 1096)
@@ -33,7 +33,6 @@
#include "seqwindow.h"
#include "seqlistview.h"
-#include <Q3ListView>
#include <QHash>
#include <QString>
#include <QLabel>
@@ -65,24 +64,23 @@
//----------------------------------------------------------------------
// GuildListItem
-class GuildListItem : public Q3ListViewItem
+class GuildListItem : public SEQListViewItem
{
public:
- GuildListItem(Q3ListView* parent,
- const GuildMember* member,
- const GuildShell* guildShell);
- virtual ~GuildListItem();
+ GuildListItem(SEQListView* parent,
+ const GuildMember* member,
+ const GuildShell* guildShell);
+ virtual ~GuildListItem();
- virtual void paintCell( QPainter *p, const QColorGroup &cg,
- int column, int width, int alignment );
+ bool operator<(const GuildListItem& other) const;
- virtual int compare(Q3ListViewItem *i, int col, bool ascending) const;
-
void update(const GuildShell* guildShell);
- const GuildMember* guildMember() { return m_member; }
+ const GuildMember* guildMember() const { return m_member; }
void setGuildMember(const GuildMember* member);
+ QVariant data(int column, int role) const;
+
virtual int rtti() const;
protected:
@@ -116,6 +114,7 @@
void toggle_guildListCol(QAction* col);
void set_font();
void set_caption();
+ void listMouseRightButtonPressed(QMouseEvent*);
protected:
void clear(void);
@@ -124,7 +123,7 @@
Player* m_player;
GuildShell* m_guildShell;
-
+
QLabel* m_guildName;
QLabel* m_guildTotals;
SEQListView* m_guildList;
Modified: showeq/branches/pre_6_0_beta/src/interface.h
===================================================================
--- showeq/branches/pre_6_0_beta/src/interface.h 2020-11-03 02:02:50 UTC (rev 1095)
+++ showeq/branches/pre_6_0_beta/src/interface.h 2020-11-08 21:57:35 UTC (rev 1096)
@@ -26,7 +26,6 @@
#include <QWidget>
#include <QPushButton>
#include <QLabel>
-#include <Q3ListView>
#include <QLayout>
#include <QMenuBar>
#include <QMenu>
Modified: showeq/branches/pre_6_0_beta/src/seqlistview.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/seqlistview.cpp 2020-11-03 02:02:50 UTC (rev 1095)
+++ showeq/branches/pre_6_0_beta/src/seqlistview.cpp 2020-11-08 21:57:35 UTC (rev 1096)
@@ -25,25 +25,30 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <Q3Header>
+#include <QHeaderView>
#include <QSizePolicy>
#include "seqlistview.h"
#include "main.h"
-SEQListView::SEQListView(const QString prefName,
- QWidget* parent, const char* name, Qt::WFlags f)
- : Q3ListView(parent, name, f),
+SEQListView::SEQListView(const QString prefName,
+ QWidget* parent,
+ const char* name,
+ Qt::WFlags f)
+ : QTreeWidget(parent),
m_preferenceName(prefName),
m_sortColumn(0),
m_sortIncreasing(true)
{
- // setup common listview defaults
- setShowSortIndicator(true);
- setRootIsDecorated(false);
- setSelectionMode(Single);
- setAllColumnsShowFocus(true);
- setShowSortIndicator(true);
+ setObjectName(name);
+ setWindowFlags(f);
+
+ // setup common listview defaults
+ setSortingEnabled(true);
+ setSorting(0, true);
+ setRootIsDecorated(false);
+ setSelectionMode(QAbstractItemView::SingleSelection);
+ setSelectionBehavior(QAbstractItemView::SelectRows);
}
SEQListView::~SEQListView()
@@ -52,189 +57,213 @@
const QString& SEQListView::columnPreferenceName(int column) const
{
- // return the base name of the preference for the requested column
- return m_columns[column];
+ // return the base name of the preference for the requested column
+ return m_columns[column];
}
QSizePolicy SEQListView::sizePolicy() const
{
- return QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ return QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
int SEQListView::addColumn(const QString& label,
- int width)
+ int width)
{
- return addColumn(label, label, width);
+ return addColumn(label, label, width);
}
-int SEQListView::addColumn(const QString& label,
- const QString& preference,
- int width)
+int SEQListView::addColumn(const QString& label,
+ const QString& preference,
+ int width)
{
- // add the column to the listview
- int column = Q3ListView::addColumn(label, width);
+ // add the column to the list of preferences
+ m_columns.append(preference);
- // add the column to the list of preferences
- m_columns.append(preference);
+ // add the column to the list of headers
+ m_headers.append(label);
- // return the column index
- return column;
+ // update the header row
+ setHeaderLabels(m_headers);
+
+ // return the column index
+ return m_headers.indexOf(label);
}
void SEQListView::removeColumn(int column)
{
- // remove the column from the listview
- Q3ListView::removeColumn(column);
+ // remove the preference from the list
+ m_columns.removeAt(column);
- // remove the preference from the list
- m_columns.removeAt(column);
+ // remove the header from the list
+ m_headers.removeAt(column);
+
+ //update the header row
+ setHeaderLabels(m_headers);
}
+void SEQListView::insertItem(QTreeWidgetItem* item) {
+ insertTopLevelItem(topLevelItemCount(), item);
+}
+
void SEQListView::setSorting(int column, bool increasing)
{
- // save the sort information
- m_sortColumn = column;
- m_sortIncreasing = increasing;
+ // save the sort information
+ m_sortColumn = column;
+ m_sortIncreasing = increasing;
- // set the sort order in the underlying listview
- Q3ListView::setSorting(column, increasing);
+ // set the sort order in the underlying listview
+ sortByColumn(column, increasing ? Qt::AscendingOrder : Qt::DescendingOrder);
}
void SEQListView::savePrefs()
{
- // only save the preferences if visible
- if (isVisible())
- {
+ // only save the preferences if visible
+ if (isVisible())
+ {
+ int i;
+ int width;
+ QString columnName;
+ QString show = "Show";
+
+ // save the column width's/visibility
+ for (i = 0; i < columnCount(); i++)
+ {
+ columnName = columnPreferenceName(i);
+ width = columnWidth(i);
+ if (width != 0)
+ {
+ pSEQPrefs->setPrefInt(columnName + "Width", preferenceName(), width);
+ pSEQPrefs->setPrefBool(show + columnName, preferenceName(), true);
+ }
+ else
+ pSEQPrefs->setPrefBool(show + columnName, preferenceName(), false);
+ }
+
+ // save the column order
+ QString tempStr, tempStr2;
+ if (header()->count() > 0)
+ tempStr.sprintf("%d", header()->logicalIndex(0));
+ for(i=1; i < header()->count(); i++)
+ {
+ tempStr2.sprintf(":%d", header()->logicalIndex(i));
+ tempStr += tempStr2;
+ }
+ pSEQPrefs->setPrefString("ColumnOrder", preferenceName(), tempStr);
+
+ // save the current sorting state
+ pSEQPrefs->setPrefInt("SortColumn", preferenceName(), m_sortColumn);
+ pSEQPrefs->setPrefBool("SortIncreasing", preferenceName(),
+ m_sortIncreasing);
+ }
+}
+
+void SEQListView::restoreColumns()
+{
int i;
int width;
QString columnName;
QString show = "Show";
- // save the column width's/visibility
- for (i = 0; i < columns(); i++)
+ // restore the column width's/visibility
+ for (i = 0; i < columnCount(); i++)
{
- columnName = columnPreferenceName(i);
- width = columnWidth(i);
- if (width != 0)
- {
- pSEQPrefs->setPrefInt(columnName + "Width", preferenceName(), width);
- pSEQPrefs->setPrefBool(show + columnName, preferenceName(), true);
- }
- else
- pSEQPrefs->setPrefBool(show + columnName, preferenceName(), false);
+ columnName = columnPreferenceName(i);
+
+ // check if the column is visible
+ if (pSEQPrefs->getPrefBool(show + columnName, preferenceName(), true))
+ {
+ // check if the column has a width specified
+ if (pSEQPrefs->isPreference(columnName + "Width", preferenceName()))
+ {
+ // use the specified column width
+ width = pSEQPrefs->getPrefInt(columnName + "Width", preferenceName());
+ }
+ else
+ {
+ width = header()->sectionSizeHint(i);
+ }
+
+ header()->setResizeMode(i, QHeaderView::Interactive);
+ header()->resizeSection(i, width);
+ setColumnWidth(i, width);
+ }
+ else
+ {
+ // column is not visible, hide it.
+ header()->setResizeMode(i, QHeaderView::Interactive);
+ header()->resizeSection(i, 0);
+ setColumnWidth(i, 0);
+ }
}
-
- // save the column order
- QString tempStr, tempStr2;
- if (header()->count() > 0)
- tempStr.sprintf("%d", header()->mapToSection(0));
- for(i=1; i < header()->count(); i++)
- {
- tempStr2.sprintf(":%d", header()->mapToSection(i));
- tempStr += tempStr2;
- }
- pSEQPrefs->setPrefString("ColumnOrder", preferenceName(), tempStr);
- // save the current sorting state
- pSEQPrefs->setPrefInt("SortColumn", preferenceName(), m_sortColumn);
- pSEQPrefs->setPrefBool("SortIncreasing", preferenceName(),
- m_sortIncreasing);
- }
-}
+ // restore the column order
+ QString tStr = pSEQPrefs->getPrefString("ColumnOrder", preferenceName(), "N/A");
-void SEQListView::restoreColumns()
-{
- int i;
- int width;
- QString columnName;
- QString show = "Show";
-
- // restore the column width's/visibility
- for (i = 0; i < columns(); i++)
- {
- columnName = columnPreferenceName(i);
-
- // check if the column is visible
- if (pSEQPrefs->getPrefBool(show + columnName, preferenceName(), true))
+ QHeaderView* hdr = header();
+ if (tStr != "N/A")
{
- // check if the column has a width specified
- if (pSEQPrefs->isPreference(columnName + "Width", preferenceName()))
- {
- // use the specified column width
- width = pSEQPrefs->getPrefInt(columnName + "Width", preferenceName());
- setColumnWidthMode(i, Q3ListView::Manual);
- setColumnWidth(i, width);
- }
+ int i = 0;
+ while (!tStr.isEmpty())
+ {
+ int toIndex;
+ if (tStr.indexOf(':') != -1)
+ {
+ toIndex = tStr.left(tStr.indexOf(':')).toInt();
+ tStr = tStr.right(tStr.length() - tStr.indexOf(':') - 1);
+ }
+ else
+ {
+ toIndex = tStr.toInt();
+ tStr = "";
+ }
+ hdr->moveSection(hdr->visualIndex(toIndex), i++);
+ }
}
- else
- {
- // column is not visible, hide it.
- setColumnWidthMode(i, Q3ListView::Manual);
- setColumnWidth(i, 0);
- }
- }
-
- // restore the column order
- QString tStr = pSEQPrefs->getPrefString("ColumnOrder", preferenceName(),
- "N/A");
- if (tStr != "N/A")
- {
- int i = 0;
- while (!tStr.isEmpty())
- {
- int toIndex;
- if (tStr.indexOf(':') != -1)
- {
- toIndex = tStr.left(tStr.indexOf(':')).toInt();
- tStr = tStr.right(tStr.length() - tStr.indexOf(':') - 1);
- }
- else
- {
- toIndex = tStr.toInt();
- tStr = "";
- }
- header()->moveSection(toIndex, i++);
- }
- }
- // restore sorting state
- setSorting(pSEQPrefs->getPrefInt("SortColumn", preferenceName(),
- m_sortColumn),
- pSEQPrefs->getPrefBool("SortIncreasing", preferenceName(),
- m_sortIncreasing));
+ // restore sorting state
+ setSorting(pSEQPrefs->getPrefInt("SortColumn", preferenceName(),
+ m_sortColumn),
+ pSEQPrefs->getPrefBool("SortIncreasing", preferenceName(),
+ m_sortIncreasing));
}
void SEQListView::setColumnVisible(int column, bool visible)
{
- QString columnName = columnPreferenceName(column);
+ QString columnName = columnPreferenceName(column);
- // default width is 0
- int width = 0;
+ // default width is 0
+ int width = 0;
- // if column is to become visible, get it's width
- if (visible)
- {
- // get the column width
- width = pSEQPrefs->getPrefInt(columnName + "Width", preferenceName(),
- columnWidth(column));
+ // if column is to become visible, get it's width
+ if (visible)
+ {
+ // get the column width
+ width = pSEQPrefs->getPrefInt(columnName + "Width", preferenceName(),
+ columnWidth(column));
- // if it's zero, use default width of 40
- if (width == 0)
- width = 40;
- }
+ // if it's zero, use default width of 40
+ if (width == 0)
+ width = 40;
+ }
- // set the column width mode
- setColumnWidthMode(column, Q3ListView::Manual);
+ header()->setResizeMode(column, QHeaderView::Interactive);
+ header()->resizeSection(column, width);
+ setColumnWidth(column, width);
- // set the column width
- setColumnWidth(column, width);
+ // set the the preferences as to if the column is shown
+ pSEQPrefs->setPrefBool(QString("Show") + columnName, preferenceName(),
+ (width != 0));
- // set the the preferences as to if the column is shown
- pSEQPrefs->setPrefBool(QString("Show") + columnName, preferenceName(),
- (width != 0));
+ // trigger an update, otherwise things may look messy
+ update();
+}
- // trigger an update, otherwise things may look messy
- triggerUpdate();
+void SEQListView::mousePressEvent(QMouseEvent* event)
+{
+ if (event->button() == Qt::RightButton)
+ emit mouseRightButtonPressed(event);
+
+ QTreeWidget::mousePressEvent(event);
}
#ifndef QMAKEBUILD
Modified: showeq/branches/pre_6_0_beta/src/seqlistview.h
===================================================================
--- showeq/branches/pre_6_0_beta/src/seqlistview.h 2020-11-03 02:02:50 UTC (rev 1095)
+++ showeq/branches/pre_6_0_beta/src/seqlistview.h 2020-11-08 21:57:35 UTC (rev 1096)
@@ -29,46 +29,57 @@
#ifndef SEQLISTVIEW_H
#define SEQLISTVIEW_H
-#include <Q3ListView>
+#include <QTreeWidget>
+#include <QMouseEvent>
#include <QString>
#include <QStringList>
+typedef QTreeWidgetItem SEQListViewItem;
+typedef QTreeWidgetItemIterator SEQListViewItemIterator;
-class SEQListView : public Q3ListView
+class SEQListView : public QTreeWidget
{
- Q_OBJECT
+ Q_OBJECT
- public:
- SEQListView(const QString prefName,
- QWidget* parent = 0, const char* name = 0, Qt::WFlags f = 0);
- ~SEQListView();
+ public:
+ SEQListView(const QString prefName,
+ QWidget* parent = 0,
+ const char* name = 0,
+ Qt::WFlags f = 0);
+ ~SEQListView();
- const QString& preferenceName() const { return m_preferenceName; }
- const QString& columnPreferenceName(int column) const;
+ const QString& preferenceName() const { return m_preferenceName; }
+ const QString& columnPreferenceName(int column) const;
- QSizePolicy sizePolicy() const;
+ QSizePolicy sizePolicy() const;
- virtual int addColumn(const QString& label,
- int width = -1);
- virtual int addColumn(const QString& label,
- const QString& preference,
- int width = -1);
- virtual void removeColumn(int column);
- bool columnVisible(int column) { return (columnWidth(column) != 0); }
- virtual void setSorting(int column, bool increasing = true);
- int sortColumn() const { return m_sortColumn; }
- bool sortIncreasing() const { return m_sortIncreasing; }
+ virtual int addColumn(const QString& label,
+ int width = -1);
+ virtual int addColumn(const QString& label,
+ const QString& preference,
+ int width = -1);
+ virtual void removeColumn(int column);
+ void insertItem(QTreeWidgetItem* item);
+ bool columnVisible(int column) { return (columnWidth(column) != 0); }
+ virtual void setSorting(int column, bool increasing = true);
+ int sortColumn() const { return m_sortColumn; }
+ bool sortIncreasing() const { return m_sortIncreasing; }
- public slots:
- virtual void restoreColumns(void);
- virtual void savePrefs(void);
- void setColumnVisible(int column, bool visible);
+ public slots:
+ virtual void restoreColumns(void);
+ virtual void savePrefs(void);
+ void setColumnVisible(int column, bool visible);
+ void mousePressEvent(QMouseEvent* event);
- private:
- QString m_preferenceName;
- QStringList m_columns;
- int m_sortColumn;
- bool m_sortIncreasing;
+ signals:
+ void mouseRightButtonPressed(QMouseEvent*);
+
+ private:
+ QString m_preferenceName;
+ QStringList m_columns;
+ QStringList m_headers;
+ int m_sortColumn;
+ bool m_sortIncreasing;
};
#endif // SEQLISTVIEW_H
Modified: showeq/branches/pre_6_0_beta/src/skilllist.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/skilllist.cpp 2020-11-03 02:02:50 UTC (rev 1095)
+++ showeq/branches/pre_6_0_beta/src/skilllist.cpp 2020-11-08 21:57:35 UTC (rev 1096)
@@ -30,10 +30,10 @@
SkillList::SkillList(Player* player,
- QWidget* parent,
- const char* name)
- : SEQListView("SkillList", parent, name),
- m_pPlayer(player)
+ QWidget* parent,
+ const char* name)
+ : SEQListView("SkillList", parent, name),
+ m_pPlayer(player)
{
int i;
@@ -115,8 +115,11 @@
* to the list
*/
if (!m_skillList[skillId])
- m_skillList[skillId] =
- new Q3ListViewItem (this, skill_name (skillId), str);
+ {
+ QStringList item_values;
+ item_values << skill_name(skillId) << str;
+ m_skillList[skillId] = new SEQListViewItem (this, item_values);
+ }
else
m_skillList[skillId]->setText (1, str);
}
@@ -126,12 +129,12 @@
{
if (skillId >= MAX_KNOWN_SKILLS)
{
- seqWarn("skillId (%d) is more than max skillId (%d)\n",
- skillId, MAX_KNOWN_SKILLS - 1);
+ seqWarn("skillId (%d) is more than max skillId (%d)\n",
+ skillId, MAX_KNOWN_SKILLS - 1);
return;
}
-
+
QString str;
/* Update skill value with new value */
str.sprintf ("%3d", value);
@@ -138,8 +141,11 @@
// create skill entry if needed or set the value of the existing item
if (!m_skillList[skillId])
- m_skillList[skillId] =
- new Q3ListViewItem (this, skill_name (skillId), str);
+ {
+ QStringList item_values;
+ item_values << skill_name(skillId) << str;
+ m_skillList[skillId] = new SEQListViewItem (this, item_values);
+ }
else
m_skillList[skillId]->setText (1, str);
}
@@ -169,7 +175,7 @@
return;
}
-
+
// Check if this is a valid skill
if (value == 255)
return;
@@ -185,8 +191,11 @@
// If the language is not added yet, look up the correct skill namd and
// add it to the list
if (!m_languageList[langId])
- m_languageList[langId] =
- new Q3ListViewItem (this, language_name(langId), str);
+ {
+ QStringList item_values;
+ item_values << language_name(langId) << str;
+ m_languageList[langId] = new SEQListViewItem (this, item_values);
+ }
else
m_languageList[langId]->setText (1, str);
}
@@ -205,7 +214,7 @@
return;
}
-
+
QString str;
/* Update skill value with new value */
@@ -213,8 +222,11 @@
// create language entry if needed or set the value of the existing item
if (!m_languageList[langId])
- m_languageList[langId] =
- new Q3ListViewItem (this, language_name (langId), str);
+ {
+ QStringList item_values;
+ item_values << language_name(langId) << str;
+ m_languageList[langId] = new SEQListViewItem (this, item_values);
+ }
else
m_languageList[langId]->setText (1, str);
}
Modified: showeq/branches/pre_6_0_beta/src/skilllist.h
===================================================================
--- showeq/branches/pre_6_0_beta/src/skilllist.h 2020-11-03 02:02:50 UTC (rev 1095)
+++ showeq/branches/pre_6_0_beta/src/skilllist.h 2020-11-08 21:57:35 UTC (rev 1096)
@@ -24,7 +24,6 @@
#define EQSKILLLIST_H
#include <QWidget>
-#include <Q3ListView>
#include "seqlistview.h"
#include "seqwindow.h"
@@ -40,9 +39,9 @@
public:
// constructor
SkillList (Player* player,
- QWidget* parent = 0,
- const char* name = 0);
-
+ QWidget* parent = 0,
+ const char* name = 0);
+
// destructor
~SkillList();
@@ -63,10 +62,10 @@
Player* m_pPlayer;
// the list view items related to skills
- Q3ListViewItem* m_skillList[MAX_KNOWN_SKILLS];
+ SEQListViewItem* m_skillList[MAX_KNOWN_SKILLS];
// the list view items related to languages
- Q3ListViewItem* m_languageList[MAX_KNOWN_LANGS];
+ SEQListViewItem* m_languageList[MAX_KNOWN_LANGS];
// whether or not to show languages
bool m_showLanguages;
Modified: showeq/branches/pre_6_0_beta/src/spawnlist.cpp
===================================================================
--- showeq/branches/pre_6_0_beta/src/spawnlist.cpp 2020-11-03 02:02:50 UTC (rev 1095)
+++ showeq/branches/pre_6_0_beta/src/spawnlist.cpp 2020-11-08 21:57:35 UTC (rev 1096)
@@ -93,15 +93,18 @@
restoreColumns();
// connect a QListView signal to ourselves
- connect(this, SIGNAL(selectionChanged(Q3ListViewItem*)),
- this, SLOT(selChanged(Q3ListViewItem*)));
+ connect(this, SIGNAL(itemSelectionChanged()),
+ this, SLOT(selChanged()));
- connect (this, SIGNAL(mouseButtonPressed(int, Q3ListViewItem*, const QPoint&, int)),
- this, SLOT(mousePressEvent(int, Q3ListViewItem*, const QPoint&, int)));
+ connect (this, SIGNAL(itemPressed(QTreeWidgetItem*, int)),
+ this, SLOT(listItemPressed(QTreeWidgetItem*, int)));
- connect (this, SIGNAL(doubleClicked(Q3ListViewItem*)),
- this, SLOT(mouseDoubleClickEvent(Q3ListViewItem*)));
+ connect (this, SIGNAL(mouseRightButtonPressed(QMouseEvent*)),
+ this, SLOT(listMouseRightButtonPressed(QMouseEvent*)));
+ connect (this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)),
+ this, SLOT(listItemDoubleClicked(QTreeWidgetItem*, int)));
+
// connect SpawnList slots to SpawnShell signals
connect(m_spawnShell, SIGNAL(addItem(const Item *)),
this, SLOT(addItem(const Item *)));
@@ -143,36 +146,38 @@
int32_t degrees)
{
// seqDebug("SpawnList::setPlayer()");
- char buff[200];
+ SEQListViewItemIterator it(this);
+ SpawnListItem* litem;
+ QString buff;
- SpawnListItem *i = (SpawnListItem*)firstChild();
-// if (i) seqDebug("============= firstChild, name=%s type=%s", i->item()->name().data(), i->type());
-
// is this a fast machine?
if (!showeq_params->fast_machine)
{
// no, cheat using integer distance calculation ignoring Z dimension
- while (i != NULL)
- {
- if (i->type() != tUnknown)
+ while (*it)
+ {
+ litem = (SpawnListItem*)*it;
+
+ if (litem->type() != tUnknown)
{
- sprintf(buff, "%5d", i->item()->calcDist2DInt(x, y));
- i->setText(tSpawnColDist, buff);
+ buff.sprintf("%5d", litem->item()->calcDist2DInt(x, y));
+ litem->setText(tSpawnColDist, buff);
}
- i = (SpawnListItem*)i->nextSibling();
+ ++it;
}
}
else
{
// fast machine so calculate the correct floating point 3D distance
- while (i != NULL)
- {
- if (i->type() != tUnknown)
+ while (*it)
+ {
+ litem = (SpawnListItem*)*it;
+ if (litem->type() != tUnknown)
{
- sprintf(buff, "%5.1f", i->item()->calcDist(x, y, z));
- i->setText(tSpawnColDist, buff);
+ buff.sprintf("%5.1f", litem->item()->calcDist(x, y, z));
+ litem->setText(tSpawnColDist, buff);
}
- i = (SpawnListItem*)i->nextSibling();
+ ++it;
}
}
}
@@ -182,39 +187,39 @@
if (item == NULL)
return;
- Q3ListViewItemIterator it(this);
+ SEQListViewItemIterator it(this);
SpawnListItem *i = Find(it, item);
- while (i)
+ while (i)
{
// reinsert only if level, NPC or filterFlags changes
if (!(changeItem & (tSpawnChangedLevel |
- tSpawnChangedNPC |
- tSpawnChangedFilter |
- tSpawnChangedRuntimeFilter)))
+ tSpawnChangedNPC |
+ tSpawnChangedFilter |
+ tSpawnChangedRuntimeFilter)))
i->update(m_player, changeItem);
- else
+ else
{
bool select = false;
-
+
// check if this is the selected item.
if (Selected() == i)
- select = true;
-
+ select = true;
+
// delete ALL SpawnListItems that relate to item
delItem(item);
-
+
// reinsert ALL the SpawnListItems that relate to item
addItem(item);
-
+
// reset the selected item, if it was this item.
if (select)
- selectSpawn(item);
-
+ selectSpawn(item);
+
// Delete item deleted everything, addItem re-inserted everything
// nothing more to be done.
- break;
+ break;
}
-
+
// keep searching/updating...
i = Find(it, item);
} // while i
@@ -225,28 +230,28 @@
if (item == NULL)
return;
- Q3ListViewItemIterator it(this);
+ SEQListViewItemIterator it(this);
const SpawnListItem *i = Find(it, item);
// was this spawn in the list
- if (i)
+ if (i)
{
// yes, remove and re-add it.
bool select = false;
-
+
// check if this is the selected item.
if (Selected() == i)
select = true;
-
+
// delete ALL SpawnListItems that relate to item
delItem(item);
-
+
// reinsert ALL the SpawnListItems that relate to item
addItem(item);
-
+
// reset the selected item, if it was this item.
if (select)
selectSpawn(item);
-
+
// Delete item deleted everything, addItem re-inserted everything
// nothing more to be done.
}
@@ -254,21 +259,21 @@
addItem(item);
}
-SpawnListItem* SpawnList::Find(Q3ListViewItemIterator& it,
- const Item* item,
- bool first)
+SpawnListItem* SpawnList::Find(SEQListViewItemIterator& it,
+ const Item* item,
+ bool first)
{
- if (first)
- it = Q3ListViewItemIterator(this); // reset iterator to the beginning
+ if (first)
+ it = SEQListViewItemIterator(this); // reset iterator to the beginning
else
it++; // increment past the current item
SpawnListItem *i;
// while there are still items, increment forward
- while(it.current())
+ while(*it)
{
// get the current item
- i = (SpawnListItem*)it.current();
+ i = (SpawnListItem*)*it;
// is it the one we're looking for?
if (i->item() == item)
@@ -291,7 +296,7 @@
// ZB: Need to figure out how to derive flags
int flags = 0;
- Q3ListViewItemIterator it(this);
+ SEQListViewItemIterator it(this);
const Item* i;
SpawnListItem* j = NULL;
@@ -307,8 +312,8 @@
// check if the ID is already in the list
j = Find(it, item);
-
- if (j)
+
+ if (j)
{
// yes, check if it's a major modification, or can get by with just
// an update
@@ -316,8 +321,8 @@
// reinsert only if name, level, NPC, or filterFlags changes
if ((l == level) &&
- (j->m_npc == item->NPC()) &&
- (j->text(tSpawnColName) == item->name()))
+ (j->m_npc == item->NPC()) &&
+ (j->text(tSpawnColName) == item->name()))
{
// it matches, just update all of it's instances
@@ -324,17 +329,17 @@
// loop through all instances relating to item
while (j != NULL)
{
- // update the SpawnListItem
- j->update(m_player, tSpawnChangedALL);
+ // update the SpawnListItem
+ j->update(m_player, tSpawnChangedALL);
- // find the next one
- j = Find(it, item);
+ // find the next one
+ j = Find(it, item);
}
-
+
// return the first one so the caller has the option of selecting it
return;
- }
- else
+ }
+ else
{
// major change, delete all instances relating to item
delItem(item);
@@ -354,18 +359,18 @@
j = Find(it, i, true);
// loop until we run out of pets
- while (j)
+ while (j)
{
- // create a new SpawnListItem
- SpawnListItem *k = new SpawnListItem(j);
-
- // set the item
- k->setShellItem(item);
- k->pickTextColor(item, m_player);
- k->update(m_player, tSpawnChangedALL);
-
- // find the next item
- j = Find(it, i);
+ // create a new SpawnListItem
+ SpawnListItem *k = new SpawnListItem(j);
+
+ // set the item
+ k->setShellItem(item);
+ k->pickTextColor(item, m_player);
+ k->update(m_player, tSpawnChangedALL);
+
+ // find the next item
+ j = Find(it, i);
}
}
} // if petOwnerId
@@ -388,44 +393,46 @@
break;
if ((item->filterFlags() & FILTER_FLAG_FILTERED) &&
- !cat->isFilteredFilter())
+ !cat->isFilteredFilter())
{
- continue;
+ continue;
}
if (cat->isFiltered(filterStr, level))
{
- // retrieve the list item associated with the category
- catlitem = m_categoryListItems.value((void*)cat, nullptr);
+ // retrieve the list item associated with the category
+ catlitem = m_categoryListItems.value((void*)cat, nullptr);
+ if (!catlitem)
+ continue;
- // We have a good category, add spawn as it's child
- j = new SpawnListItem(catlitem);
+ // We have a good category, add spawn as it's child
+ j = new SpawnListItem(catlitem);
#if 0
- seqDebug("`-- Adding to %s (%d)",
- (const char*)cat->name(), catlitem->childCount());
+ seqDebug("`-- Adding to %s (%d)",
+ (const char*)cat->name(), catlitem->childCount());
#endif
- j->setShellItem(item);
- j->update(m_player, tSpawnChangedALL);
+ j->setShellItem(item);
+ j->update(m_player, tSpawnChangedALL);
- // color spawn
- j->pickTextColor(item, m_player, cat->color());
-
- // update childcount in header
- catlitem->updateTitle(cat->name());
+ // color spawn
+ j->pickTextColor(item, m_player, cat->color());
+
+ // update childcount in header
+ catlitem->updateTitle(cat->name());
} // end if spawn should be in this category
}
} // end if categories
- else
+ else
{
// just create a new SpawnListItem
j = new SpawnListItem(this);
j->setShellItem(item);
-
+
// color spawn
j->pickTextColor(item, m_player);
j->update(m_player, tSpawnChangedALL);
} // else
-
+
return;
} // end addItem
@@ -438,7 +445,7 @@
SpawnListItem *j = NULL;
// create a list of items to be deleted
- QList<Q3ListViewItem*>* delList = new QList<Q3ListViewItem*>();
+ QList<SEQListViewItem*> delList;
// create a list of categories to be updated
QList<const Category*> catUpdateList;
@@ -446,50 +453,35 @@
const Category* cat;
// start at the top of the list
- Q3ListViewItemIterator it(this);
-
- do
+ SEQListViewItemIterator it(this);
+
+ do
{
// find the next item in the list
j = Find(it, item);
// if there was an item, delete it and all it's children
- if (j)
+ if (j)
{
- // seqDebug(" Deleting...");
- // delete children
- Q3ListViewItem* child = j->firstChild();
- Q3ListViewItem* next;
- while(child)
- {
- // get the next child
- next = (SpawnListItem *) child->nextSibling();
+ delList += j->takeChildren();
- // add to the list of items to delete
- delList->append(child);
-
- // the next child is now the current child
- child = next;
- }
-
// get the category that the item SpawnListItem belongs to
cat = getCategory(j);
// add to the list of items to delete
- delList->append(j);
+ delList.append(j);
// if there's a category, add it to the list to be updated
if (cat != NULL)
- catUpdateList.append(cat);
+ catUpdateList.append(cat);
} // if j
// not done until out of items
} while (j);
- // delete the list of items to be deleted, which auto-deletes the items
- qDeleteAll(*delList);
- delList->clear();
- delete delList;
+ // delete the list of items to be deleted
+ qDeleteAll(delList);
+ delList.clear();
// now iterate over the updated categories and update them
QList<const Category*>::iterator cit;
@@ -498,7 +490,7 @@
cat = *cit;
// retrieve the category list item
SpawnListItem* catlitem = m_categoryListItems.value((void*)cat, nullptr);
-
+
// update the list items title
catlitem->updateTitle(cat->name());
}
@@ -511,55 +503,55 @@
return;
// start iterator at the beginning of this QListView
- Q3ListViewItemIterator it(this);
+ SEQListViewItemIterator it(this);
SpawnListItem *j = NULL;
// attempt to find a match on an item that is not collapsed (open)
- do
+ do
{
// attempt to find the item
j = Find(it, item);
// if it's found, see if it's parent is open, and if so, select it
- if (j)
+ if (j)
{
// get the parent
- Q3ListViewItem* litem = (SpawnListItem*) j->parent();
+ SEQListViewItem* litem = (SpawnListItem*) j->parent();
bool bOpen = true;
// make sure the parent and all it's parents are open
- while (litem)
+ while (litem)
{
- // is it open
- if (!litem->isOpen())
- {
- // nope, stop looking at the parents, next item
- bOpen = false;
- break;
- }
-
- // get this parents parent
- litem = (SpawnListItem*) litem->parent();
+ // is it open
+ if (!isItemExpanded(litem))
+ {
+ // nope, stop looking at the parents, next item
+ bOpen = false;
+ break;
+ }
+
+ // get this parents parent
+ litem = (SpawnListItem*) litem->parent();
}
// yes, this one should be opened, finished
if (bOpen)
- break;
+ break;
}
// continue until out of items
} while (j);
-
+
// if an item was found, select it
- if (j)
+ if (j)
{
// select the item
setSelectedQuiet(j, true);
-
+
// if configured to do so, make sure it's visible
if (showeq_params->keep_selected_visible)
- ensureItemVisible(j);
+ scrollToItem(j);
}
else // try again forcing open
{
@@ -574,7 +566,7 @@
SpawnListItem* SpawnList::Selected()
{
- return ((SpawnListItem*) selectedItem());
+ return ((SpawnListItem*) currentItem());
}
@@ -581,12 +573,12 @@
void SpawnList::selectAndOpen(SpawnListItem *i)
{
// get the item
- Q3ListViewItem* item = i;
-
+ SEQListViewItem* item = i;
+
// loop over it's parents, opening all of them
- while (item)
+ while (item)
{
- item->setOpen(true);
+ expandItem(item);
item = (SpawnListItem*) item->parent();
}
@@ -595,17 +587,17 @@
// if configured to do so, make sure it's visible
if (showeq_params->keep_selected_visible)
- ensureItemVisible(i);
+ scrollToItem(i);
}
-void SpawnList::setSelectedQuiet(Q3ListViewItem* item, bool selected)
+void SpawnList::setSelectedQuiet(SEQListViewItem* item, bool selected)
{
- if (!item || (item->isSelected() == selected) ||
- !item->isSelectable())
+ if (!item || (item->isSelected() == selected ) ||
+ !(item->flags() & Qt::ItemIsSelectable))
return;
// get the old selection
- Q3ListViewItem *oldItem = selectedItem();
+ SEQListViewItem *oldItem = currentItem();
// unselect the old selected item if any
if ((oldItem != item) && (oldItem != NULL) && (oldItem->isSelected()))
@@ -618,12 +610,7 @@
// notifications since the selection state is already changed).
setCurrentItem(item);
- // repaint the old item
- if (oldItem != NULL)
- repaintItem(oldItem);
-
- // repaint the selected item
- repaintItem(item);
+ update();
}
// Select next item of the same type and id as currently selected item
@@ -634,7 +621,7 @@
const Item* item;
// retrieve the currently selected item
- i = (SpawnListItem *) selectedItem();
+ i = (SpawnListItem *) currentItem();
// nothing selected, nothing to do
if (!i)
@@ -641,7 +628,7 @@
return;
// start the iterator at the current item
- Q3ListViewItemIterator it(i);
+ SEQListViewItemIterator it(i);
// get the Item from the SpawnListItem
item = i->item();
@@ -652,11 +639,11 @@
i = Find(it, item);
// there are no more with item, wrap around to beginning
- if (!i)
+ if (!i)
i = Find(it, item, true);
// if it's found, select it, and make sure it's parents are open
- if (i)
+ if (i)
{
//seqDebug("SelectNext(): Next selection '%s'", i->text(0).latin1());
selectAndOpen(i);
@@ -671,7 +658,7 @@
const Item* item;
// start at the current item
- i = cur = (SpawnListItem *) selectedItem();
+ i = cur = (SpawnListItem *) currentItem();
// nothing selected, nothing to do
if (!i)
@@ -678,7 +665,7 @@
return;
// start the iterator at the current item
- Q3ListViewItemIterator it(i);
+ SEQListViewItemIterator it(i);
// get the SpawnShellitem from the SpawnListItem
item = i->item();
@@ -689,7 +676,7 @@
//seqDebug("SelectPrev(): Current selection '%s'", i->text(0).ascii());
// search backwards, wrapping around, until we hit the current item
- do
+ do
{
// the current item becomes the last item
last = i;
@@ -698,8 +685,8 @@
i = Find(it, item);
// if no more found, then wrap to the beginning
- if (!i)
- {
+ if (!i)
+ {
// Start searching again from the beginning
i = Find(it, item, true);
}
@@ -708,7 +695,7 @@
} while (i != cur);
// if there is a last item, select and open it.
- if (last)
+ if (last)
{
//seqDebug("SelectPrev(): Prev selection '%s'", i->text(0).ascii());
selectAndOpen(last);
@@ -718,7 +705,7 @@
void SpawnList::clear(void)
{
//seqDebug("SpawnList::clear()");
- Q3ListView::clear();
+ SEQListView::clear();
m_categoryListItems.clear();
// rebuild headers
@@ -733,7 +720,7 @@
// create the spawn list item
litem = new SpawnListItem(this);
-
+
// insert the category and it's respective list item
m_categoryListItems.insert((void*)cat, litem);
@@ -755,7 +742,7 @@
// set color
litem->setTextColor(cat->color());
-
+
// update count
litem->updateTitle(cat->name());
@@ -771,25 +758,11 @@
// if there's a list item associated with this category, clean it out
if (litem != NULL)
{
- SpawnListItem *next;
- SpawnListItem *child;
// remove all children from list
- // start with the first child
- child = (SpawnListItem *) litem->firstChild();
-
- // iterate until the category is out of children
- while (child)
- {
- // get the next child
- next = (SpawnListItem *) child->nextSibling();
-
- // delete the current child
- delete child;
-
- // the next child is now the current child
- child = next;
- }
+ QList<SEQListViewItem*> children = litem->takeChildren();
+ qDeleteAll(children);
+ children.clear();
// remove the item from the category list
delete m_categoryListItems.take((void*)cat);
@@ -803,7 +776,7 @@
m_categoryListItems.clear();
// clear out the list
- Q3ListView::clear();
+ SEQListView::clear();
}
void SpawnList::loadedCategories(void)
@@ -840,16 +813,16 @@
void SpawnList::playerLevelChanged(uint8_t)
{
- Q3ListViewItemIterator it(this);
+ SEQListViewItemIterator it(this);
SpawnListItem* slitem = NULL;
const Category* cat = NULL;
const Item* item = NULL;
-
+
// iterate until we are out of items
- while (it.current())
+ while (*it)
{
// get the current SpawnListItem
- slitem = (SpawnListItem*)it.current();
+ slitem = (SpawnListItem*)*it;
// if this is a top level item, see if it's a category item, and if so
// get the category.
@@ -861,17 +834,17 @@
for (it = m_categoryListItems.begin();
it != m_categoryListItems.end() && *it != NULL; ++it)
{
- if (slitem == *it)
- {
- cat = (const Category*)it.key();
- break;
- }
+ if (slitem == *it)
+ {
+ cat = (const Category*)it.key();
+ break;
+ }
}
}
// get the item associated with the list item
item = slitem->item();
-
+
// set the color
if (cat != NULL)
slitem->pickTextColor(item, m_player, cat->color());
@@ -899,7 +872,7 @@
const Item* item;
SpawnListItem* litem;
SpawnListItem* catlitem = m_categoryListItems.value((void*)cat, nullptr);
-
+
// iterate over all spawn types
for (uint8_t i = 0; i < (sizeof(types) / sizeof(spawnItemType)); i++)
{
@@ -919,25 +892,25 @@
// skip filtered spawns
if ((item->filterFlags() & FILTER_FLAG_FILTERED) &&
- !cat->isFilteredFilter())
- continue;
+ !cat->isFilteredFilter())
+ continue;
// if item is a spawn, get its level
if ((item->type() == tSpawn) || (item->type() == tPlayer))
- level = ((Spawn*)item)->level();
+ level = ((Spawn*)item)->level();
// does this spawn match the category
if (cat->isFiltered(filterString(item, flags), level))
{
- // yes, add it
- litem = new SpawnListItem(catlitem);
+ // yes, add it
+ litem = new SpawnListItem(catlitem);
- // set up the list item
- litem->setShellItem(item);
- litem->update(m_player, tSpawnChangedALL);
+ // set up the list item
+ litem->setShellItem(item);
+ litem->update(m_player, tSpawnChangedALL);
- // color the spawn
- litem->pickTextColor(item, m_player, cat->color());
+ // color the spawn
+ litem->pickTextColor(item, m_player, cat->color());
}
}
}
@@ -968,7 +941,7 @@
const Category* cat;
QString filterStr;
CategoryListIterator cit(m_categoryMgr->getCategories());
-
+
// iterate over all spawn types
for (uint8_t i = 0; i < (sizeof(types) / sizeof(spawnItemType)); i++)
{
@@ -1067,11 +1040,15 @@
}
}
-void SpawnList::selChanged(Q3ListViewItem* litem)
+void SpawnList::selChanged()
{
- if (litem == NULL)
- return;
-
+ QList<QTreeWidgetItem*> selected = selectedItems();
+ if (!selected.count()) return;
+
+ // the list is limited to one selection at a time, so we can take the first
+ SEQListViewItem* litem = selected.first();
+ if (litem == NULL) return;
+
const Item* item = ((SpawnListItem*)litem)->item();
// it might have been a category title selected, only select if it's an item
@@ -1079,36 +1056,37 @@
emit spawnSelected(item);
}
-void SpawnList::mousePressEvent(int button, Q3ListViewItem* litem,
- const QPoint &point, int col)
+void SpawnList::listItemPressed(QTreeWidgetItem* litem, int col)
{
- // Left Mouse Button Events
- if (button == Qt::LeftButton && litem != NULL)
- ...
[truncated message content] |