You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
3.0 KiB
C
102 lines
3.0 KiB
C
12 years ago
|
/***************************************************************************
|
||
|
* Copyright (C) 2003-2004 by *
|
||
|
* Unai Garro (ugarro@users.sourceforge.net) *
|
||
|
* Jason Kivlighn (jkivlighn@gmail.com) *
|
||
|
* *
|
||
|
* 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 CONVERSIONTABLE_H
|
||
|
#define CONVERSIONTABLE_H
|
||
9 months ago
|
#include <tqstring.h>
|
||
|
#include <tqtable.h>
|
||
|
#include <tqobject.h>
|
||
12 years ago
|
|
||
|
#include "datablocks/unitratio.h"
|
||
|
#include "datablocks/elementlist.h"
|
||
|
#include "datablocks/unit.h"
|
||
|
|
||
|
/**
|
||
|
@author Unai Garro
|
||
|
*/
|
||
|
|
||
|
|
||
12 years ago
|
class ConversionTable: public TQTable
|
||
12 years ago
|
{
|
||
2 years ago
|
TQ_OBJECT
|
||
12 years ago
|
public:
|
||
|
|
||
12 years ago
|
ConversionTable( TQWidget* parent, int maxrows, int maxcols );
|
||
12 years ago
|
~ConversionTable();
|
||
|
void createNewItem( int r, int c, double amount );
|
||
|
void setUnitIDs( const IDList &idList );
|
||
|
void setRatio( int ingID1, int ingID2, double ratio );
|
||
|
void setRatio( const UnitRatio &r )
|
||
|
{
|
||
|
setRatio( r.uID1, r.uID2, r.ratio );
|
||
|
}
|
||
|
int getUnitID( int rc );
|
||
12 years ago
|
TQString text( int r, int c ) const; //Reimplement, otherwise it won't work this way
|
||
12 years ago
|
void resize( int r, int c );
|
||
|
void clear( void );
|
||
|
private:
|
||
|
|
||
|
//Internal Variables
|
||
|
double editBoxValue;
|
||
12 years ago
|
TQIntDict<TQTableItem> items;
|
||
|
TQIntDict<TQWidget> widgets;
|
||
12 years ago
|
IDList unitIDs; // unit ID list to know the units by ID, not name
|
||
|
//Internal Methods
|
||
|
void resizeData( int )
|
||
|
{}
|
||
|
;
|
||
12 years ago
|
TQTableItem *item( int r, int c ) const;
|
||
|
void setItem( int r, int c, TQTableItem *i );
|
||
12 years ago
|
void clearCell( int r, int c );
|
||
12 years ago
|
void takeItem( TQTableItem *item );
|
||
|
void insertWidget( int r, int c, TQWidget *w );
|
||
|
TQWidget *cellWidget( int r, int c ) const;
|
||
12 years ago
|
void clearCellWidget( int r, int c );
|
||
|
void initTable();
|
||
|
void swapRows( int, int, bool );
|
||
|
void swapColumns( int, int, bool );
|
||
|
void swapCells( int, int, int, int );
|
||
|
protected:
|
||
12 years ago
|
TQWidget* beginEdit ( int row, int col, bool replace );
|
||
12 years ago
|
|
||
|
private slots:
|
||
|
void repaintCell( int r, int c );
|
||
|
|
||
|
void unitRemoved( int );
|
||
|
void unitCreated( const Unit& );
|
||
|
signals:
|
||
|
void ratioChanged( int row, int col, double value );
|
||
|
void ratioRemoved( int row, int col );
|
||
|
};
|
||
|
|
||
12 years ago
|
class ConversionTableItem: public TQObject, public TQTableItem
|
||
12 years ago
|
{
|
||
2 years ago
|
TQ_OBJECT
|
||
12 years ago
|
public:
|
||
12 years ago
|
ConversionTableItem( TQTable *t, EditType et );
|
||
|
TQWidget *createEditor() const;
|
||
|
void setContentFromEditor( TQWidget *w );
|
||
|
void setText( const TQString &s );
|
||
|
void paint( TQPainter *p, const TQColorGroup &cg, const TQRect &cr, bool selected );
|
||
|
void setTextAndSave( const TQString &s );
|
||
12 years ago
|
int alignment() const
|
||
|
{
|
||
12 years ago
|
return TQt::AlignRight;
|
||
12 years ago
|
}
|
||
|
signals:
|
||
|
void ratioChanged( int row, int col, double value );
|
||
|
void ratioRemoved( int row, int col );
|
||
|
void signalRepaintCell( int r, int c );
|
||
|
|
||
|
};
|
||
|
|
||
|
|
||
|
#endif
|