From d0af61c358a04f3d3b956636076eb073dcf253c0 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Fri, 1 Feb 2013 17:32:42 -0600 Subject: Fix prior commit --- kmymoney2/widgets/kmymoneychecklistitem.cpp | 151 ++++++++++++++++++++++++++ kmymoney2/widgets/kmymoneychecklistitem.h | 94 ++++++++++++++++ kmymoney2/widgets/kmymoneychectdelistitem.cpp | 151 -------------------------- kmymoney2/widgets/kmymoneychectdelistitem.h | 94 ---------------- 4 files changed, 245 insertions(+), 245 deletions(-) create mode 100644 kmymoney2/widgets/kmymoneychecklistitem.cpp create mode 100644 kmymoney2/widgets/kmymoneychecklistitem.h delete mode 100644 kmymoney2/widgets/kmymoneychectdelistitem.cpp delete mode 100644 kmymoney2/widgets/kmymoneychectdelistitem.h (limited to 'kmymoney2/widgets') diff --git a/kmymoney2/widgets/kmymoneychecklistitem.cpp b/kmymoney2/widgets/kmymoneychecklistitem.cpp new file mode 100644 index 0000000..b292567 --- /dev/null +++ b/kmymoney2/widgets/kmymoneychecklistitem.cpp @@ -0,0 +1,151 @@ +/*************************************************************************** + kmymoneychecklistitem + ------------------- + begin : Wed Jun 28 2006 + copyright : (C) 2006 by Thomas Baumgart + email : Thomas Baumgart + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +// ---------------------------------------------------------------------------- +// QT Includes + +#include +#include + +// ---------------------------------------------------------------------------- +// KDE Includes + +// ---------------------------------------------------------------------------- +// Project Includes + +#include "kmymoneychecklistitem.h" +#include "kmymoneylistviewitem.h" +#include "../kmymoneyglobalsettings.h" + +KMyMoneyCheckListItem::KMyMoneyCheckListItem(TQListView* parent, const TQString& txt, const TQString& key, const TQString& id, Type type) : + TQCheckListItem(parent, txt, type), + m_key(key), + m_id(id), + m_isOdd(0), + m_isKnown(0) +{ + setOn(true); + if(key.isEmpty()) + m_key = txt; +} + +KMyMoneyCheckListItem::KMyMoneyCheckListItem(TQListViewItem* parent, const TQString& txt, const TQString& key, const TQString& id, Type type) : + TQCheckListItem(parent, txt, type), + m_key(key), + m_id(id), + m_isOdd(0), + m_isKnown(0) +{ + setOn(true); + if(key.isEmpty()) + m_key = txt; +} + +KMyMoneyCheckListItem::KMyMoneyCheckListItem(TQListView* parent, TQListViewItem* after, const TQString& txt, const TQString& key, const TQString& id, Type type) : + TQCheckListItem(parent, after, txt, type), + m_key(key), + m_id(id), + m_isOdd(0), + m_isKnown(0) +{ + setOn(true); + if(key.isEmpty()) + m_key = txt; +} + +KMyMoneyCheckListItem::~KMyMoneyCheckListItem() +{ +} + +TQString KMyMoneyCheckListItem::key(int column, bool ascending) const +{ + Q_UNUSED(ascending); + + if(column == 0) + return m_key[0] + text(0); + return m_key.mid(1); +} + +void KMyMoneyCheckListItem::stateChange(bool state) +{ + emit stateChanged(state); +} + +void KMyMoneyCheckListItem::paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int alignment) +{ + TQColorGroup _cg = cg; + _cg.setColor(TQColorGroup::Base, backgroundColor()); + + // write the groups in bold + TQFont f = p->font(); + f.setBold(!isSelectable()); + p->setFont(f); + + TQCheckListItem::paintCell(p, _cg, column, width, alignment); +} + +const TQColor KMyMoneyCheckListItem::backgroundColor() +{ + return isAlternate() ? KMyMoneyGlobalSettings::listBGColor() : KMyMoneyGlobalSettings::listColor(); +} + +bool KMyMoneyCheckListItem::isAlternate(void) +{ +// logic taken from TDEListViewItem::isAlternate() + KMyMoneyCheckListItem* ciAbove; + KMyMoneyListViewItem* liAbove; + ciAbove = dynamic_cast (itemAbove()); + liAbove = dynamic_cast (itemAbove()); + + m_isKnown = ciAbove ? ciAbove->m_isKnown : (liAbove ? liAbove->m_isKnown : true); + if(m_isKnown) { + m_isOdd = ciAbove ? !ciAbove->m_isOdd : (liAbove ? !liAbove->m_isOdd : false); + } else { + KMyMoneyCheckListItem* clItem; + KMyMoneyListViewItem* liItem; + bool previous = true; + if(TQListViewItem::parent()) { + clItem = dynamic_cast(TQListViewItem::parent()); + liItem = dynamic_cast(TQListViewItem::parent()); + if(clItem) + previous = clItem->m_isOdd; + else + previous = liItem->m_isOdd; + clItem = dynamic_cast(TQListViewItem::parent()->firstChild()); + liItem = dynamic_cast(TQListViewItem::parent()->firstChild()); + } else { + clItem = dynamic_cast(listView()->firstChild()); + liItem = dynamic_cast(listView()->firstChild()); + } + while(clItem || liItem) { + if(clItem) { + clItem->m_isOdd = previous = !previous; + clItem->m_isKnown = true; + liItem = dynamic_cast(clItem->nextSibling()); + clItem = dynamic_cast(clItem->nextSibling()); + } else if(liItem) { + liItem->m_isOdd = previous = !previous; + liItem->m_isKnown = true; + clItem = dynamic_cast(liItem->nextSibling()); + liItem = dynamic_cast(liItem->nextSibling()); + } + } + } + return m_isOdd; +} + +#include "kmymoneychecklistitem.moc" diff --git a/kmymoney2/widgets/kmymoneychecklistitem.h b/kmymoney2/widgets/kmymoneychecklistitem.h new file mode 100644 index 0000000..1c5474d --- /dev/null +++ b/kmymoney2/widgets/kmymoneychecklistitem.h @@ -0,0 +1,94 @@ +/*************************************************************************** + kmymoneychecklistitem - description + ------------------- + begin : Wed Jun 28 2006 + copyright : (C) 2006 by Thomas Baumgart + email : Thomas Baumgart + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KMYMONEYCHECKLISTITEM_H +#define KMYMONEYCHECKLISTITEM_H + +// ---------------------------------------------------------------------------- +// QT Includes + +#include +#include + +// ---------------------------------------------------------------------------- +// KDE Includes + +// ---------------------------------------------------------------------------- +// Project Includes + +class KMyMoneyListViewItem; + +/** + * This class implements a derived version of a TQCheckListItem that + * allows the storage of an engine object id with the object and emits + * a signal upon state change. + * + * @author Thomas Baumgart + */ +class KMyMoneyCheckListItem : public TQObject, public TQCheckListItem +{ + friend class KMyMoneyListViewItem; + + Q_OBJECT + +public: + KMyMoneyCheckListItem(TQListView *parent, const TQString& txt, const TQString& key, const TQString& id, Type type = TQCheckListItem::CheckBox); + KMyMoneyCheckListItem(TQListView *parent, TQListViewItem* after, const TQString& txt, const TQString& key, const TQString& id, Type type = TQCheckListItem::CheckBox); + KMyMoneyCheckListItem(TQListViewItem *parent, const TQString& txt, const TQString& key, const TQString& id, Type type = TQCheckListItem::CheckBox); + ~KMyMoneyCheckListItem(); + + const TQString& id(void) const { return m_id; }; + + /** + * use my own paint method + */ + void paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int alignment); + + /** + * use my own backgroundColor method + */ + const TQColor backgroundColor(); + + /** + * see TDEListViewItem::isAlternate() + */ + bool isAlternate(void); + + /** + * This method returns a const reference to the key passed to the constructor. The column + * defines what is returned: For @a column equals 0, the first character passed as @a key to + * the constructor concatenated with the value returned by text(0) is returned. For @a column + * equals to 1, the @a key as passed to the constructor except the first character is returned. + */ + TQString key(int column, bool ascending) const; + +signals: + void stateChanged(bool); + +protected: + virtual void stateChange(bool); + +private: + TQString m_key; + TQString m_id; + // copied from TDEListViewItem() + unsigned int m_isOdd : 1; + unsigned int m_isKnown : 1; + unsigned int m_unused : 30; +}; + +#endif diff --git a/kmymoney2/widgets/kmymoneychectdelistitem.cpp b/kmymoney2/widgets/kmymoneychectdelistitem.cpp deleted file mode 100644 index b292567..0000000 --- a/kmymoney2/widgets/kmymoneychectdelistitem.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/*************************************************************************** - kmymoneychecklistitem - ------------------- - begin : Wed Jun 28 2006 - copyright : (C) 2006 by Thomas Baumgart - email : Thomas Baumgart - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -// ---------------------------------------------------------------------------- -// QT Includes - -#include -#include - -// ---------------------------------------------------------------------------- -// KDE Includes - -// ---------------------------------------------------------------------------- -// Project Includes - -#include "kmymoneychecklistitem.h" -#include "kmymoneylistviewitem.h" -#include "../kmymoneyglobalsettings.h" - -KMyMoneyCheckListItem::KMyMoneyCheckListItem(TQListView* parent, const TQString& txt, const TQString& key, const TQString& id, Type type) : - TQCheckListItem(parent, txt, type), - m_key(key), - m_id(id), - m_isOdd(0), - m_isKnown(0) -{ - setOn(true); - if(key.isEmpty()) - m_key = txt; -} - -KMyMoneyCheckListItem::KMyMoneyCheckListItem(TQListViewItem* parent, const TQString& txt, const TQString& key, const TQString& id, Type type) : - TQCheckListItem(parent, txt, type), - m_key(key), - m_id(id), - m_isOdd(0), - m_isKnown(0) -{ - setOn(true); - if(key.isEmpty()) - m_key = txt; -} - -KMyMoneyCheckListItem::KMyMoneyCheckListItem(TQListView* parent, TQListViewItem* after, const TQString& txt, const TQString& key, const TQString& id, Type type) : - TQCheckListItem(parent, after, txt, type), - m_key(key), - m_id(id), - m_isOdd(0), - m_isKnown(0) -{ - setOn(true); - if(key.isEmpty()) - m_key = txt; -} - -KMyMoneyCheckListItem::~KMyMoneyCheckListItem() -{ -} - -TQString KMyMoneyCheckListItem::key(int column, bool ascending) const -{ - Q_UNUSED(ascending); - - if(column == 0) - return m_key[0] + text(0); - return m_key.mid(1); -} - -void KMyMoneyCheckListItem::stateChange(bool state) -{ - emit stateChanged(state); -} - -void KMyMoneyCheckListItem::paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int alignment) -{ - TQColorGroup _cg = cg; - _cg.setColor(TQColorGroup::Base, backgroundColor()); - - // write the groups in bold - TQFont f = p->font(); - f.setBold(!isSelectable()); - p->setFont(f); - - TQCheckListItem::paintCell(p, _cg, column, width, alignment); -} - -const TQColor KMyMoneyCheckListItem::backgroundColor() -{ - return isAlternate() ? KMyMoneyGlobalSettings::listBGColor() : KMyMoneyGlobalSettings::listColor(); -} - -bool KMyMoneyCheckListItem::isAlternate(void) -{ -// logic taken from TDEListViewItem::isAlternate() - KMyMoneyCheckListItem* ciAbove; - KMyMoneyListViewItem* liAbove; - ciAbove = dynamic_cast (itemAbove()); - liAbove = dynamic_cast (itemAbove()); - - m_isKnown = ciAbove ? ciAbove->m_isKnown : (liAbove ? liAbove->m_isKnown : true); - if(m_isKnown) { - m_isOdd = ciAbove ? !ciAbove->m_isOdd : (liAbove ? !liAbove->m_isOdd : false); - } else { - KMyMoneyCheckListItem* clItem; - KMyMoneyListViewItem* liItem; - bool previous = true; - if(TQListViewItem::parent()) { - clItem = dynamic_cast(TQListViewItem::parent()); - liItem = dynamic_cast(TQListViewItem::parent()); - if(clItem) - previous = clItem->m_isOdd; - else - previous = liItem->m_isOdd; - clItem = dynamic_cast(TQListViewItem::parent()->firstChild()); - liItem = dynamic_cast(TQListViewItem::parent()->firstChild()); - } else { - clItem = dynamic_cast(listView()->firstChild()); - liItem = dynamic_cast(listView()->firstChild()); - } - while(clItem || liItem) { - if(clItem) { - clItem->m_isOdd = previous = !previous; - clItem->m_isKnown = true; - liItem = dynamic_cast(clItem->nextSibling()); - clItem = dynamic_cast(clItem->nextSibling()); - } else if(liItem) { - liItem->m_isOdd = previous = !previous; - liItem->m_isKnown = true; - clItem = dynamic_cast(liItem->nextSibling()); - liItem = dynamic_cast(liItem->nextSibling()); - } - } - } - return m_isOdd; -} - -#include "kmymoneychecklistitem.moc" diff --git a/kmymoney2/widgets/kmymoneychectdelistitem.h b/kmymoney2/widgets/kmymoneychectdelistitem.h deleted file mode 100644 index 1c5474d..0000000 --- a/kmymoney2/widgets/kmymoneychectdelistitem.h +++ /dev/null @@ -1,94 +0,0 @@ -/*************************************************************************** - kmymoneychecklistitem - description - ------------------- - begin : Wed Jun 28 2006 - copyright : (C) 2006 by Thomas Baumgart - email : Thomas Baumgart - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef KMYMONEYCHECKLISTITEM_H -#define KMYMONEYCHECKLISTITEM_H - -// ---------------------------------------------------------------------------- -// QT Includes - -#include -#include - -// ---------------------------------------------------------------------------- -// KDE Includes - -// ---------------------------------------------------------------------------- -// Project Includes - -class KMyMoneyListViewItem; - -/** - * This class implements a derived version of a TQCheckListItem that - * allows the storage of an engine object id with the object and emits - * a signal upon state change. - * - * @author Thomas Baumgart - */ -class KMyMoneyCheckListItem : public TQObject, public TQCheckListItem -{ - friend class KMyMoneyListViewItem; - - Q_OBJECT - -public: - KMyMoneyCheckListItem(TQListView *parent, const TQString& txt, const TQString& key, const TQString& id, Type type = TQCheckListItem::CheckBox); - KMyMoneyCheckListItem(TQListView *parent, TQListViewItem* after, const TQString& txt, const TQString& key, const TQString& id, Type type = TQCheckListItem::CheckBox); - KMyMoneyCheckListItem(TQListViewItem *parent, const TQString& txt, const TQString& key, const TQString& id, Type type = TQCheckListItem::CheckBox); - ~KMyMoneyCheckListItem(); - - const TQString& id(void) const { return m_id; }; - - /** - * use my own paint method - */ - void paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int alignment); - - /** - * use my own backgroundColor method - */ - const TQColor backgroundColor(); - - /** - * see TDEListViewItem::isAlternate() - */ - bool isAlternate(void); - - /** - * This method returns a const reference to the key passed to the constructor. The column - * defines what is returned: For @a column equals 0, the first character passed as @a key to - * the constructor concatenated with the value returned by text(0) is returned. For @a column - * equals to 1, the @a key as passed to the constructor except the first character is returned. - */ - TQString key(int column, bool ascending) const; - -signals: - void stateChanged(bool); - -protected: - virtual void stateChange(bool); - -private: - TQString m_key; - TQString m_id; - // copied from TDEListViewItem() - unsigned int m_isOdd : 1; - unsigned int m_isKnown : 1; - unsigned int m_unused : 30; -}; - -#endif -- cgit v1.2.1