You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
512 lines
17 KiB
512 lines
17 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
Copyright (C) 2005 Dag Andersen kplato@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation;
|
||
|
version 2 of the License.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#include "kptdoublelistviewbase.h"
|
||
|
|
||
|
#include "kptproject.h"
|
||
|
#include "kptview.h"
|
||
|
|
||
14 years ago
|
#include <tqheader.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
14 years ago
|
#include <tqmap.h>
|
||
|
#include <tqpainter.h>
|
||
13 years ago
|
#include <tqpalette.h>
|
||
14 years ago
|
#include <tqptrvector.h>
|
||
|
#include <tqsplitter.h>
|
||
|
#include <tqstring.h>
|
||
|
#include <tqvaluelist.h>
|
||
|
#include <tqpoint.h>
|
||
15 years ago
|
|
||
|
#include <kcalendarsystem.h>
|
||
12 years ago
|
#include <tdeglobal.h>
|
||
|
#include <tdelocale.h>
|
||
15 years ago
|
#include <kprinter.h>
|
||
14 years ago
|
#include <tqrect.h>
|
||
15 years ago
|
|
||
|
#include <kdebug.h>
|
||
|
|
||
|
namespace KPlato
|
||
|
{
|
||
14 years ago
|
void ListView::paintToPrinter(TQPainter * p, int cx, int cy, int cw, int ch) {
|
||
|
//kdDebug()<<k_funcinfo<<TQRect(cx, cy, cw, ch)<<endl;
|
||
15 years ago
|
// draw header labels
|
||
|
p->save();
|
||
14 years ago
|
TQRegion r = p->clipRegion(TQPainter::CoordPainter);
|
||
|
p->setClipRegion(r.intersect(TQRegion(cx, 0, cw, ch)), TQPainter::CoordPainter);
|
||
|
TQColor bgc(193, 223, 255);
|
||
|
TQBrush bg(bgc);
|
||
15 years ago
|
p->setBackgroundMode(Qt::OpaqueMode);
|
||
|
p->setBackgroundColor(bgc);
|
||
14 years ago
|
TQHeader *h = header();
|
||
15 years ago
|
int hei = 0;
|
||
|
for (int s = 0; s < h->count(); ++s) {
|
||
14 years ago
|
TQRect r = h->sectionRect(s);
|
||
15 years ago
|
//kdDebug()<<s<<": "<<h->label(s)<<" "<<r<<endl;
|
||
|
int x, y;
|
||
|
viewportToContents(r.x(), r.y(), x, y);
|
||
14 years ago
|
TQRect sr(x, y, r.width(), r.height());
|
||
15 years ago
|
//kdDebug()<<s<<": "<<h->label(s)<<" "<<sr<<endl;
|
||
|
if (sr.x()+sr.width() <= cx || sr.x() >= cx+cw) {
|
||
|
//kdDebug()<<s<<": "<<h->label(s)<<" "<<sr<<": continue"<<endl;
|
||
|
continue;
|
||
|
}
|
||
14 years ago
|
TQRect tr = sr;
|
||
15 years ago
|
if (sr.x() < cx) {
|
||
|
tr.setX(cx);
|
||
|
//kdDebug()<<s<<": "<<h->label(s)<<" "<<tr<<endl;
|
||
|
}
|
||
|
p->eraseRect(tr);
|
||
14 years ago
|
p->drawText(tr, columnAlignment(s)|TQt::AlignVCenter, h->label(s), -1);
|
||
|
hei = TQMAX(tr.height(), hei);
|
||
15 years ago
|
}
|
||
14 years ago
|
r = p->clipRegion(TQPainter::CoordPainter);
|
||
15 years ago
|
p->restore();
|
||
|
// p->drawRect(r.boundingRect());
|
||
|
p->save();
|
||
|
p->translate(0, hei+2);
|
||
14 years ago
|
r = p->clipRegion(TQPainter::CoordPainter);
|
||
15 years ago
|
// FIXME: Doesn't clip correctly, haven't figured out why
|
||
14 years ago
|
p->setClipRegion(r.intersect(TQRegion(cx, cy, cw, ch)), TQPainter::CoordPainter);
|
||
15 years ago
|
drawContentsOffset(p, 0, 0, cx, cy, cw, ch);
|
||
|
// p->drawRect(r.boundingRect());
|
||
|
p->restore();
|
||
|
}
|
||
|
|
||
14 years ago
|
DoubleListViewBase::SlaveListItem::SlaveListItem(DoubleListViewBase::MasterListItem *master, TQListView *parent, TQListViewItem *after, bool highlight)
|
||
12 years ago
|
: TDEListViewItem(parent, after),
|
||
15 years ago
|
m_masterItem(master),
|
||
|
m_value(0.0),
|
||
|
m_highlight(highlight),
|
||
|
m_valueMap() {
|
||
|
|
||
|
setFormat();
|
||
|
setExpandable(master->isExpandable());
|
||
|
setOpen(master->isOpen());
|
||
14 years ago
|
//kdDebug()<<"DoubleListViewBase::SlaveListItem "<<master->text(0)<<" parent="<<static_cast<DoubleListViewBase::SlaveListItem*>(parent)->m_masterItem->text(0)<<endl;
|
||
15 years ago
|
}
|
||
14 years ago
|
DoubleListViewBase::SlaveListItem::SlaveListItem(DoubleListViewBase::MasterListItem *master, TQListViewItem *parent, TQListViewItem *after, bool highlight)
|
||
12 years ago
|
: TDEListViewItem(parent, after),
|
||
15 years ago
|
m_masterItem(master),
|
||
|
m_value(0.0),
|
||
|
m_highlight(highlight),
|
||
|
m_valueMap() {
|
||
|
|
||
|
setFormat();
|
||
|
setExpandable(master->isExpandable());
|
||
|
setOpen(master->isOpen());
|
||
14 years ago
|
//kdDebug()<<"DoubleListViewBase::SlaveListItem "<<master->text(0)<<" parent="<<static_cast<DoubleListViewBase::SlaveListItem*>(parent)->m_masterItem->text(0)<<endl;
|
||
15 years ago
|
}
|
||
|
DoubleListViewBase::SlaveListItem::~SlaveListItem() {
|
||
|
//kdDebug()<<k_funcinfo<<endl;
|
||
|
if (m_masterItem)
|
||
|
m_masterItem->slaveItemDeleted();
|
||
|
}
|
||
|
|
||
|
void DoubleListViewBase::SlaveListItem::clearColumn(int col) {
|
||
|
if (col >= listView()->columns()) {
|
||
|
return;
|
||
|
}
|
||
|
listView()->setColumnText(col, "");
|
||
|
setText(col, "");
|
||
|
m_valueMap[col] = 0;
|
||
|
}
|
||
|
void DoubleListViewBase::SlaveListItem::setColumn(int col, double value) {
|
||
|
if (col < listView()->columns()) {
|
||
13 years ago
|
//setText(col, TQString("%1").arg(value, m_fieldwidth, m_fmt, m_prec));
|
||
12 years ago
|
setText(col, TDEGlobal::locale()->formatNumber(value, m_prec));
|
||
14 years ago
|
m_valueMap.replace(col, value);
|
||
15 years ago
|
//kdDebug()<<k_funcinfo<<m_masterItem->text(0)<<": column["<<col<<"]="<<value<<endl;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void DoubleListViewBase::SlaveListItem::setLimit(int col, double limit) {
|
||
|
m_limitMap[col] = limit;
|
||
|
}
|
||
|
|
||
14 years ago
|
void DoubleListViewBase::SlaveListItem::paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int align) {
|
||
15 years ago
|
//kdDebug()<<k_funcinfo<<"c="<<column<<endl;
|
||
14 years ago
|
TQColorGroup g = cg;
|
||
15 years ago
|
if (m_highlight) {
|
||
14 years ago
|
if (m_limitMap.contains(column)) {
|
||
15 years ago
|
if (m_valueMap[column] > m_limitMap[column]) {
|
||
14 years ago
|
g.setColor(TQColorGroup::Text, TQColor(red));
|
||
15 years ago
|
} else if (m_valueMap[column] < m_limitMap[column]) {
|
||
14 years ago
|
g.setColor(TQColorGroup::Text, TQColor(green));
|
||
15 years ago
|
}
|
||
|
}
|
||
|
}
|
||
12 years ago
|
TDEListViewItem::paintCell(p, g, column, width, align);
|
||
15 years ago
|
}
|
||
|
|
||
|
void DoubleListViewBase::SlaveListItem::setFormat(int fieldwidth, char fmt, int prec) {
|
||
|
m_fieldwidth = fieldwidth;
|
||
|
m_fmt = fmt;
|
||
|
m_prec = prec;
|
||
|
}
|
||
|
|
||
|
//----------------------------
|
||
14 years ago
|
DoubleListViewBase::MasterListItem::MasterListItem(TQListView *parent, bool highlight)
|
||
12 years ago
|
: TDEListViewItem(parent),
|
||
15 years ago
|
m_slaveItem(0),
|
||
|
m_value(0.0),
|
||
|
m_limit(0.0),
|
||
|
m_highlight(highlight) {
|
||
|
|
||
|
setFormat();
|
||
|
//kdDebug()<<k_funcinfo<<endl;
|
||
|
}
|
||
|
|
||
14 years ago
|
DoubleListViewBase::MasterListItem::MasterListItem(TQListView *parent, TQString text, bool highlight)
|
||
12 years ago
|
: TDEListViewItem(parent, text),
|
||
15 years ago
|
m_slaveItem(0),
|
||
|
m_value(0.0),
|
||
|
m_limit(0.0),
|
||
|
m_highlight(highlight) {
|
||
|
|
||
|
setFormat();
|
||
|
//kdDebug()<<k_funcinfo<<endl;
|
||
|
}
|
||
|
|
||
14 years ago
|
DoubleListViewBase::MasterListItem::MasterListItem(TQListViewItem *parent, bool highlight)
|
||
12 years ago
|
: TDEListViewItem(parent),
|
||
15 years ago
|
m_slaveItem(0),
|
||
|
m_value(0.0),
|
||
|
m_limit(0.0),
|
||
|
m_highlight(highlight) {
|
||
|
|
||
|
setFormat();
|
||
|
//kdDebug()<<k_funcinfo<<endl;
|
||
|
}
|
||
|
|
||
14 years ago
|
DoubleListViewBase::MasterListItem::MasterListItem(TQListViewItem *parent, TQString text, bool highlight)
|
||
12 years ago
|
: TDEListViewItem(parent, text),
|
||
15 years ago
|
m_slaveItem(0),
|
||
|
m_value(0.0),
|
||
|
m_limit(0.0),
|
||
|
m_highlight(highlight) {
|
||
|
|
||
|
setFormat();
|
||
|
//kdDebug()<<k_funcinfo<<endl;
|
||
|
}
|
||
|
|
||
|
DoubleListViewBase::MasterListItem::~MasterListItem() {
|
||
|
if (m_slaveItem)
|
||
|
m_slaveItem->masterItemDeleted();
|
||
|
}
|
||
|
|
||
14 years ago
|
void DoubleListViewBase::MasterListItem::createSlaveItems(TQListView *lv, TQListViewItem *after) {
|
||
15 years ago
|
//kdDebug()<<k_funcinfo<<text(0)<<endl;
|
||
|
if (m_slaveItem) {
|
||
|
kdError()<<k_funcinfo<<"Slave item allready exists"<<endl;
|
||
|
} else {
|
||
14 years ago
|
if (parent() == 0) {
|
||
15 years ago
|
m_slaveItem = new DoubleListViewBase::SlaveListItem(this, lv, after);
|
||
|
} else {
|
||
14 years ago
|
m_slaveItem = new DoubleListViewBase::SlaveListItem(this, static_cast<DoubleListViewBase::MasterListItem*>(parent())->m_slaveItem, after);
|
||
15 years ago
|
}
|
||
|
}
|
||
|
DoubleListViewBase::SlaveListItem *prev = 0;
|
||
14 years ago
|
for (TQListViewItem *item = firstChild(); item; item = item->nextSibling()) {
|
||
15 years ago
|
static_cast<DoubleListViewBase::MasterListItem*>(item)->createSlaveItems(lv, prev);
|
||
|
prev = static_cast<DoubleListViewBase::MasterListItem*>(item)->m_slaveItem;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void DoubleListViewBase::MasterListItem::setSlaveOpen(bool on) {
|
||
|
if (m_slaveItem)
|
||
|
m_slaveItem->setOpen(on);
|
||
|
}
|
||
|
|
||
|
void DoubleListViewBase::MasterListItem::slaveItemDeleted() {
|
||
|
setTotal(0);
|
||
|
m_slaveItem = 0;
|
||
|
}
|
||
|
|
||
|
void DoubleListViewBase::MasterListItem::setTotal(double tot) {
|
||
|
m_value = tot;
|
||
13 years ago
|
//setText(1, TQString("%1").arg(tot, m_fieldwidth, m_fmt, m_prec));
|
||
12 years ago
|
setText(1, TDEGlobal::locale()->formatNumber(tot, m_prec));
|
||
15 years ago
|
//kdDebug()<<k_funcinfo<<text(0)<<"="<<tot<<endl;
|
||
|
}
|
||
|
|
||
|
void DoubleListViewBase::MasterListItem::addToTotal(double v) {
|
||
|
m_value += v;
|
||
13 years ago
|
//setText(1, TQString("%1").arg(m_value, m_fieldwidth, m_fmt, m_prec));
|
||
12 years ago
|
setText(1, TDEGlobal::locale()->formatNumber(m_value, m_prec));
|
||
15 years ago
|
}
|
||
|
|
||
|
double DoubleListViewBase::MasterListItem::calcTotal() {
|
||
|
double tot=0.0;
|
||
14 years ago
|
TQListViewItem *item=firstChild();
|
||
15 years ago
|
if (!item) {
|
||
|
tot = m_value;
|
||
|
} else {
|
||
|
for (; item; item = item->nextSibling()) {
|
||
|
tot += static_cast<DoubleListViewBase::MasterListItem*>(item)->calcTotal();
|
||
|
}
|
||
|
}
|
||
|
setTotal(tot);
|
||
|
return tot;
|
||
|
}
|
||
|
|
||
|
void DoubleListViewBase::MasterListItem::setSlaveItem(int col, double value) {
|
||
|
if (m_slaveItem) {
|
||
|
m_slaveItem->setColumn(col, value);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void DoubleListViewBase::MasterListItem::clearColumn(int col) {
|
||
14 years ago
|
for (TQListViewItem *item=firstChild(); item; item=item->nextSibling()) {
|
||
15 years ago
|
static_cast<DoubleListViewBase::MasterListItem*>(item)->clearColumn(col);
|
||
|
}
|
||
|
setTotal(0);
|
||
|
if (m_slaveItem == 0) {
|
||
|
kdError()<<k_funcinfo<<"No m_slaveItem"<<endl;
|
||
|
return;
|
||
|
}
|
||
|
m_slaveItem->clearColumn(0);
|
||
|
}
|
||
|
|
||
|
void DoubleListViewBase::MasterListItem::calcSlaveItems() {
|
||
|
if (m_slaveItem == 0 || m_slaveItem->listView() == 0) {
|
||
|
kdError()<<k_funcinfo<<"No m_slaveItem or m_slaveItem->listView()"<<endl;
|
||
|
return;
|
||
|
}
|
||
|
int cols = m_slaveItem->listView()->columns();
|
||
|
for (int i = 0; i < cols; ++i) {
|
||
|
calcSlaveItems(i);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
double DoubleListViewBase::MasterListItem::calcSlaveItems(int col) {
|
||
|
if (m_slaveItem == 0)
|
||
|
return 0.0;
|
||
14 years ago
|
TQListViewItem *item=firstChild();
|
||
15 years ago
|
if (!item) {
|
||
|
return m_slaveItem->value(col);
|
||
|
}
|
||
|
double tot=0.0;
|
||
|
for (; item; item = item->nextSibling()) {
|
||
|
tot += static_cast<DoubleListViewBase::MasterListItem*>(item)->calcSlaveItems(col);
|
||
|
}
|
||
|
//kdDebug()<<k_funcinfo<<text(0)<<" "<<col<<"="<<tot<<endl;
|
||
|
setSlaveItem(col, tot);
|
||
|
return tot;
|
||
|
}
|
||
|
|
||
|
void DoubleListViewBase::MasterListItem::setSlaveLimit(int col, double limit) {
|
||
|
if (m_slaveItem) {
|
||
|
m_slaveItem->setLimit(col, limit);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void DoubleListViewBase::MasterListItem::setSlaveHighlight(bool on) {
|
||
|
if (m_slaveItem) {
|
||
|
m_slaveItem->setHighlight(on);
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void DoubleListViewBase::MasterListItem::paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int align) {
|
||
15 years ago
|
//kdDebug()<<k_funcinfo<<"c="<<column<<" value="<<m_value<<" limit="<<m_limit<<endl;
|
||
14 years ago
|
TQColorGroup g = cg;
|
||
15 years ago
|
if (column == 1 && m_highlight) {
|
||
|
if (m_value > m_limit) {
|
||
14 years ago
|
g.setColor(TQColorGroup::Text, TQColor(red));
|
||
15 years ago
|
} else if (m_value < m_limit) {
|
||
14 years ago
|
g.setColor(TQColorGroup::Text, TQColor(green));
|
||
15 years ago
|
}
|
||
|
}
|
||
12 years ago
|
TDEListViewItem::paintCell(p, g, column, width, align);
|
||
15 years ago
|
}
|
||
|
|
||
|
void DoubleListViewBase::MasterListItem::setFormat(int fieldwidth, char fmt, int prec) {
|
||
|
m_fieldwidth = fieldwidth;
|
||
|
m_fmt = fmt;
|
||
|
m_prec = prec;
|
||
|
}
|
||
|
|
||
|
//-------------------------------------
|
||
14 years ago
|
DoubleListViewBase::DoubleListViewBase(TQWidget *parent, bool description)
|
||
|
: TQSplitter(parent),
|
||
15 years ago
|
m_fieldwidth(0),
|
||
|
m_fmt('f'),
|
||
|
m_prec(0) {
|
||
|
|
||
14 years ago
|
setOrientation(Qt::Horizontal);
|
||
|
setHandleWidth(TQMIN(2, handleWidth()));
|
||
15 years ago
|
|
||
|
m_masterList = new ListView(this);
|
||
14 years ago
|
m_masterList->setSelectionMode(TQListView::NoSelection);
|
||
15 years ago
|
m_masterList->setItemMargin(2);
|
||
|
m_masterList->setRootIsDecorated(true);
|
||
|
#if KDE_IS_VERSION(3,3,9)
|
||
|
m_masterList->setShadeSortColumn(false);
|
||
|
#endif
|
||
|
m_masterList->setSortColumn(-1); // Disable sort!!
|
||
|
m_masterList->addColumn(i18n("Name"));
|
||
|
m_masterList->addColumn(i18n("Total"));
|
||
|
m_masterList->setColumnAlignment(1, AlignRight);
|
||
|
if (description) {
|
||
|
m_masterList->addColumn(i18n("Description"));
|
||
|
m_masterList->header()->moveSection(2, 1);
|
||
|
m_masterList->header()->setStretchEnabled(true, 1);
|
||
|
} else {
|
||
|
m_masterList->header()->setStretchEnabled(true, 0);
|
||
|
}
|
||
14 years ago
|
m_masterList->setVScrollBarMode(TQScrollView::AlwaysOff);
|
||
|
m_masterList->setHScrollBarMode(TQScrollView::AlwaysOn);
|
||
15 years ago
|
|
||
|
m_slaveList = new ListView(this);
|
||
14 years ago
|
m_slaveList->setSelectionMode(TQListView::NoSelection);
|
||
15 years ago
|
m_slaveList->setItemMargin(2);
|
||
|
m_slaveList->setSortColumn(-1); // Disable sort!!
|
||
|
m_slaveList->setTreeStepSize(0);
|
||
14 years ago
|
m_slaveList->setHScrollBarMode(TQScrollView::AlwaysOn);
|
||
15 years ago
|
|
||
|
|
||
14 years ago
|
connect(m_slaveList->verticalScrollBar(), TQT_SIGNAL(valueChanged(int)),
|
||
|
m_masterList->verticalScrollBar(), TQT_SLOT(setValue(int)));
|
||
15 years ago
|
|
||
14 years ago
|
connect(m_masterList, TQT_SIGNAL(expanded(TQListViewItem*)), TQT_SLOT(slotExpanded(TQListViewItem*)));
|
||
|
connect(m_masterList, TQT_SIGNAL(collapsed(TQListViewItem*)), TQT_SLOT(slotCollapsed(TQListViewItem*)));
|
||
15 years ago
|
|
||
|
}
|
||
|
|
||
13 years ago
|
TQSize DoubleListViewBase::sizeHint() const {
|
||
|
//kdDebug()<<k_funcinfo<<minimumSizeHint()<<endl;
|
||
|
return minimumSizeHint(); //HACK: koshell splitter problem
|
||
15 years ago
|
}
|
||
|
|
||
|
void DoubleListViewBase::clearSlaveList() {
|
||
|
while (m_slaveList->columns() > 0) {
|
||
|
m_slaveList->removeColumn(0); // removing the last one clears the list!!!
|
||
|
}
|
||
|
m_slaveList->clear(); // to be safe
|
||
|
}
|
||
|
|
||
|
void DoubleListViewBase::createSlaveItems() {
|
||
|
clearSlaveList();
|
||
|
DoubleListViewBase::SlaveListItem *prev = 0;
|
||
14 years ago
|
for (TQListViewItem *item = m_masterList->firstChild(); item; item = item->nextSibling()) {
|
||
15 years ago
|
static_cast<DoubleListViewBase::MasterListItem*>(item)->createSlaveItems(m_slaveList, prev);
|
||
|
prev = static_cast<DoubleListViewBase::MasterListItem*>(item)->slaveItem();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
void DoubleListViewBase::print(KPrinter &printer) {
|
||
|
kdDebug()<<k_funcinfo<<endl;
|
||
|
Q_UNUSED(printer);
|
||
|
}
|
||
|
|
||
14 years ago
|
void DoubleListViewBase::setOpen(TQListViewItem *item, bool open) {
|
||
15 years ago
|
//kdDebug()<<k_funcinfo<<endl;
|
||
|
m_masterList->setOpen(item, open);
|
||
|
}
|
||
|
|
||
14 years ago
|
void DoubleListViewBase::slotExpanded(TQListViewItem* item) {
|
||
15 years ago
|
//kdDebug()<<k_funcinfo<<endl;
|
||
|
if (item) {
|
||
|
static_cast<DoubleListViewBase::MasterListItem*>(item)->setSlaveOpen(true);
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void DoubleListViewBase::slotCollapsed(TQListViewItem*item) {
|
||
15 years ago
|
//kdDebug()<<k_funcinfo<<endl;
|
||
|
if (item) {
|
||
|
static_cast<DoubleListViewBase::MasterListItem*>(item)->setSlaveOpen(false);
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void DoubleListViewBase::setDescriptionHeader(TQString text) {
|
||
15 years ago
|
m_masterList->setColumnText(1, text);
|
||
|
}
|
||
|
|
||
14 years ago
|
void DoubleListViewBase::setNameHeader(TQString text) {
|
||
15 years ago
|
m_masterList->setColumnText(0, text);
|
||
|
}
|
||
|
|
||
14 years ago
|
void DoubleListViewBase::setTotalHeader(TQString text) {
|
||
15 years ago
|
m_masterList->setColumnText(2, text);
|
||
|
}
|
||
|
|
||
14 years ago
|
void DoubleListViewBase::addSlaveColumn(TQString text) {
|
||
15 years ago
|
m_slaveList->addColumn(text);
|
||
|
m_slaveList->setColumnAlignment(m_slaveList->columns()-1, AlignRight);
|
||
|
}
|
||
|
|
||
|
void DoubleListViewBase::calculate() {
|
||
14 years ago
|
for (TQListViewItem *lvi=m_masterList->firstChild(); lvi; lvi = lvi->nextSibling()) {
|
||
15 years ago
|
static_cast<DoubleListViewBase::MasterListItem *>(lvi)->calcSlaveItems();
|
||
|
static_cast<DoubleListViewBase::MasterListItem *>(lvi)->calcTotal();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void DoubleListViewBase::clearLists() {
|
||
|
m_slaveList->clear();
|
||
|
m_masterList->clear();
|
||
|
}
|
||
|
|
||
|
void DoubleListViewBase::setMasterFormat(int fieldwidth, char fmt, int prec) {
|
||
14 years ago
|
TQListViewItemIterator it = m_masterList;
|
||
15 years ago
|
for (; it.current(); ++it) {
|
||
|
static_cast<DoubleListViewBase::MasterListItem*>(it.current())->setFormat(fieldwidth, fmt, prec);
|
||
|
}
|
||
|
}
|
||
|
void DoubleListViewBase::setSlaveFormat(int fieldwidth, char fmt, int prec) {
|
||
14 years ago
|
TQListViewItemIterator it = m_slaveList;
|
||
15 years ago
|
for (; it.current(); ++it) {
|
||
|
static_cast<DoubleListViewBase::SlaveListItem*>(it.current())->setFormat(fieldwidth, fmt, prec);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void DoubleListViewBase::setFormat(int fieldwidth, char fmt, int prec) {
|
||
|
m_fieldwidth = fieldwidth;
|
||
|
m_fmt = fmt;
|
||
|
m_prec = prec;
|
||
|
setMasterFormat(fieldwidth, fmt, prec);
|
||
|
setSlaveFormat(fieldwidth, fmt, prec);
|
||
|
}
|
||
|
|
||
14 years ago
|
void DoubleListViewBase::paintContents(TQPainter *p) {
|
||
15 years ago
|
//kdDebug()<<k_funcinfo<<endl;
|
||
14 years ago
|
TQRect cm = m_masterList->contentsRect();
|
||
|
TQRect cs = m_slaveList->contentsRect();
|
||
15 years ago
|
int mx, my, sx, sy;
|
||
|
m_masterList->contentsToViewport(cm.x(), cm.y(), mx, my);
|
||
|
m_slaveList->contentsToViewport(cs.x(), cs.y(), sx, sy);
|
||
|
if (sizes()[0] > 0) {
|
||
|
p->save();
|
||
|
p->translate(mx, my);
|
||
|
m_masterList->paintToPrinter(p, -mx, -my, cm.width(), cm.height());
|
||
|
p->restore();
|
||
|
}
|
||
|
if (sizes()[1] > 0) {
|
||
|
p->save();
|
||
|
p->translate(cm.width() + 8 + sx, sy);
|
||
|
m_slaveList->paintToPrinter(p, -sx, -sy, cs.width(), cs.height());
|
||
14 years ago
|
//p->fillRect(-8, 0, 0, sy, TQt::white);
|
||
15 years ago
|
p->restore();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
} //KPlato namespace
|
||
|
|
||
|
#include "kptdoublelistviewbase.moc"
|