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.
262 lines
8.3 KiB
262 lines
8.3 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
Copyright 2005 Ariya Hidayat <ariya@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; either
|
||
|
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 "inspector.h"
|
||
|
|
||
13 years ago
|
#include <tqlayout.h>
|
||
14 years ago
|
#include <tqlistview.h>
|
||
13 years ago
|
#include <tqtextstream.h>
|
||
15 years ago
|
|
||
|
#include <kdialogbase.h>
|
||
|
|
||
|
#include "kspread_cell.h"
|
||
|
#include "kspread_style.h"
|
||
|
#include "kspread_sheet.h"
|
||
|
#include "dependencies.h"
|
||
|
|
||
|
namespace KSpread
|
||
|
{
|
||
|
|
||
|
class Inspector::Private
|
||
|
{
|
||
|
public:
|
||
|
Cell* cell;
|
||
|
Format* format;
|
||
|
Sheet* sheet;
|
||
|
|
||
14 years ago
|
TQListView *cellView;
|
||
|
TQListView *formatView;
|
||
|
TQListView *sheetView;
|
||
|
TQListView *styleView;
|
||
|
TQListView* depView;
|
||
15 years ago
|
|
||
|
void handleCell();
|
||
|
void handleFormat();
|
||
|
void handleSheet();
|
||
|
void handleStyle();
|
||
|
void handleDep();
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
using namespace KSpread;
|
||
|
|
||
14 years ago
|
static TQString boolAsString( bool b )
|
||
15 years ago
|
{
|
||
14 years ago
|
if( b ) return TQString( "True" );
|
||
|
else return TQString( "False" );
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
static TQString longAsHexstring( long l )
|
||
15 years ago
|
{
|
||
13 years ago
|
return TQString("%1").arg(l, 8, 16);
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
static TQString dirAsString( Sheet::LayoutDirection dir )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQString str;
|
||
15 years ago
|
switch( dir )
|
||
|
{
|
||
|
case Sheet::LeftToRight: str = "Left to Right"; break;
|
||
|
case Sheet::RightToLeft: str = "Right to Left"; break;
|
||
|
default: str = "Unknown"; break;
|
||
|
}
|
||
|
return str;
|
||
|
}
|
||
|
|
||
|
void Inspector::Private::handleCell()
|
||
|
{
|
||
14 years ago
|
TQString str;
|
||
15 years ago
|
|
||
|
cellView->clear();
|
||
|
|
||
14 years ago
|
new TQListViewItem( cellView, "Column", TQString::number( cell->column() ) );
|
||
|
new TQListViewItem( cellView, "Row", TQString::number( cell->row() ) );
|
||
|
new TQListViewItem( cellView, "Name", cell->name() );
|
||
|
new TQListViewItem( cellView, "Full Name", cell->fullName() );
|
||
|
|
||
|
new TQListViewItem( cellView, "Default", boolAsString( cell->isDefault() ) );
|
||
|
new TQListViewItem( cellView, "Empty", boolAsString( cell->isEmpty() ) );
|
||
|
new TQListViewItem( cellView, "Formula", boolAsString( cell->isFormula() ) );
|
||
|
new TQListViewItem( cellView, "Format Properties", longAsHexstring( static_cast<long>( cell->format()->propertiesMask() ) ) );
|
||
|
new TQListViewItem( cellView, "Style Properties", longAsHexstring( static_cast<long>( cell->format()->style()->features() ) ) );
|
||
|
new TQListViewItem( cellView, "Text", cell->text() );
|
||
|
new TQListViewItem( cellView, "Text (Displayed)",
|
||
14 years ago
|
cell->strOutText().replace( TQChar('\n'), "\\n" ) );
|
||
14 years ago
|
|
||
|
TQTextStream ts( &str, IO_WriteOnly );
|
||
15 years ago
|
ts << cell->value();
|
||
14 years ago
|
new TQListViewItem( cellView, "Value", str );
|
||
15 years ago
|
|
||
14 years ago
|
new TQListViewItem( cellView, "Link", cell->link() );
|
||
15 years ago
|
|
||
14 years ago
|
new TQListViewItem( cellView, "Width", TQString::number( cell->dblWidth() ) );
|
||
|
new TQListViewItem( cellView, "Height", TQString::number( cell->dblHeight() ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
void Inspector::Private::handleFormat()
|
||
|
{
|
||
|
formatView->clear();
|
||
|
int col = cell->column();
|
||
|
int row = cell->row();
|
||
|
|
||
14 years ago
|
new TQListViewItem( formatView, "Angle", TQString::number( format->getAngle(col, row) ) );
|
||
|
new TQListViewItem( formatView, "Multirow", boolAsString( format->multiRow(col, row) ) );
|
||
|
new TQListViewItem( formatView, "Protected", format->hasProperty( Format::PVerticalText )
|
||
15 years ago
|
? "Not specified" : boolAsString( format->isProtected(col, row) ) );
|
||
14 years ago
|
new TQListViewItem( formatView, "Vertical Text", boolAsString( format->verticalText(col, row ) ) );
|
||
15 years ago
|
|
||
|
Format::Currency currrency;
|
||
|
bool valid = format->currencyInfo(currrency);
|
||
14 years ago
|
new TQListViewItem( formatView, "Currency symbol", valid ? currrency.symbol : "Invalid" );
|
||
15 years ago
|
bool ok = false;
|
||
14 years ago
|
TQString currencyType;
|
||
15 years ago
|
if (valid)
|
||
|
currencyType = Currency::getChooseString(currrency.type, ok);
|
||
14 years ago
|
new TQListViewItem( formatView, "Currency type", valid && ok ? currencyType : "Invalid" );
|
||
15 years ago
|
|
||
14 years ago
|
TQListViewItem* flags = new TQListViewItem( formatView, "Flags" );
|
||
|
new TQListViewItem( flags, "Border (left)",
|
||
15 years ago
|
boolAsString( format->hasProperty(Format::PLeftBorder, true) ) );
|
||
14 years ago
|
new TQListViewItem( flags, "Border (right)",
|
||
15 years ago
|
boolAsString( format->hasProperty(Format::PRightBorder, true) ) );
|
||
14 years ago
|
new TQListViewItem( flags, "Border (top)",
|
||
15 years ago
|
boolAsString( format->hasProperty(Format::PTopBorder, true) ) );
|
||
14 years ago
|
new TQListViewItem( flags, "Border (bottom)",
|
||
15 years ago
|
boolAsString( format->hasProperty(Format::PBottomBorder, true) ) );
|
||
|
|
||
14 years ago
|
new TQListViewItem( formatView, "Border pen width (bottom)",
|
||
|
TQString::number( format->bottomBorderPen(col,row).width() ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
void Inspector::Private::handleStyle() // direct style access
|
||
|
{
|
||
|
styleView->clear();
|
||
|
const Style* style = cell->format()->style();
|
||
|
|
||
14 years ago
|
TQListViewItem* flags = new TQListViewItem( styleView, "Flags" );
|
||
|
new TQListViewItem( flags, "Border (left)",
|
||
15 years ago
|
boolAsString( style->hasFeature(Style::SLeftBorder, true) ) );
|
||
14 years ago
|
new TQListViewItem( flags, "Border (right)",
|
||
15 years ago
|
boolAsString( style->hasFeature(Style::SRightBorder, true) ) );
|
||
14 years ago
|
new TQListViewItem( flags, "Border (top)",
|
||
15 years ago
|
boolAsString( style->hasFeature(Style::STopBorder, true) ) );
|
||
14 years ago
|
new TQListViewItem( flags, "Border (bottom)",
|
||
15 years ago
|
boolAsString( style->hasFeature(Style::SBottomBorder, true) ) );
|
||
|
|
||
14 years ago
|
new TQListViewItem( styleView, "Border pen width (bottom)",
|
||
|
TQString::number( style->bottomBorderPen().width() ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
void Inspector::Private::handleSheet()
|
||
|
{
|
||
|
sheetView->clear();
|
||
|
|
||
14 years ago
|
new TQListViewItem( sheetView, "Name", sheet->sheetName() ) ;
|
||
14 years ago
|
new TQListViewItem( sheetView, "Layout Direction", dirAsString( sheet->layoutDirection() ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
void Inspector::Private::handleDep()
|
||
|
{
|
||
|
Point cellPoint;
|
||
|
cellPoint.setSheet(sheet);
|
||
|
cellPoint.setRow( cell->row() );
|
||
|
cellPoint.setColumn( cell->column() );
|
||
|
|
||
|
DependencyManager* manager = sheet->dependencies();
|
||
14 years ago
|
TQValueList<Point> deps = manager->getDependants( cellPoint );
|
||
15 years ago
|
|
||
|
depView->clear();
|
||
|
for( unsigned i = 0; i < deps.count(); i++ )
|
||
|
{
|
||
14 years ago
|
TQString k1, k2;
|
||
15 years ago
|
|
||
|
Point point = deps[i];
|
||
|
int row = point.row();
|
||
|
int column = point.column();
|
||
|
k1 = Cell::fullName( point.sheet(), column, row );
|
||
|
|
||
14 years ago
|
new TQListViewItem( depView, k1, k2 );
|
||
15 years ago
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
Inspector::Inspector( Cell* cell ):
|
||
|
KDialogBase( KDialogBase::Tabbed, "Inspector", KDialogBase::Close,
|
||
|
KDialogBase::Close )
|
||
|
{
|
||
|
d = new Private;
|
||
|
|
||
|
d->cell = cell;
|
||
|
d->format = cell->format();
|
||
|
d->sheet = cell->sheet();
|
||
|
|
||
14 years ago
|
TQFrame* cellPage = addPage( TQString("Cell") );
|
||
|
TQVBoxLayout* cellLayout = new TQVBoxLayout( cellPage, 0 );
|
||
|
d->cellView = new TQListView( cellPage );
|
||
15 years ago
|
cellLayout->addWidget( d->cellView );
|
||
|
d->cellView->addColumn( "Key", 150 );
|
||
|
d->cellView->addColumn( "Value" );
|
||
|
|
||
14 years ago
|
TQFrame* formatPage = addPage( TQString("Format") );
|
||
|
TQVBoxLayout* formatLayout = new TQVBoxLayout( formatPage, 0 );
|
||
|
d->formatView = new TQListView( formatPage );
|
||
15 years ago
|
formatLayout->addWidget( d->formatView );
|
||
|
d->formatView->addColumn( "Key", 150 );
|
||
|
d->formatView->addColumn( "Value" );
|
||
|
|
||
14 years ago
|
TQFrame* stylePage = addPage( TQString("Style") );
|
||
|
TQVBoxLayout* styleLayout = new TQVBoxLayout( stylePage, 0 );
|
||
|
d->styleView = new TQListView( stylePage );
|
||
15 years ago
|
styleLayout->addWidget( d->styleView );
|
||
|
d->styleView->addColumn( "Key", 150 );
|
||
|
d->styleView->addColumn( "Value" );
|
||
|
|
||
14 years ago
|
TQFrame* sheetPage = addPage( TQString("Sheet") );
|
||
|
TQVBoxLayout* sheetLayout = new TQVBoxLayout( sheetPage, 0 );
|
||
|
d->sheetView = new TQListView( sheetPage );
|
||
15 years ago
|
sheetLayout->addWidget( d->sheetView );
|
||
|
d->sheetView->addColumn( "Key", 150 );
|
||
|
d->sheetView->addColumn( "Value" );
|
||
|
|
||
14 years ago
|
TQFrame* depPage = addPage( TQString("Dependencies") );
|
||
|
TQVBoxLayout* depLayout = new TQVBoxLayout( depPage, 0 );
|
||
|
d->depView = new TQListView( depPage );
|
||
15 years ago
|
depLayout->addWidget( d->depView );
|
||
|
d->depView->addColumn( "Cell", 150 );
|
||
|
d->depView->addColumn( "Content" );
|
||
|
|
||
|
d->handleCell();
|
||
|
d->handleFormat();
|
||
|
d->handleSheet();
|
||
|
d->handleStyle();
|
||
|
d->handleDep();
|
||
|
|
||
|
resize( 350, 400 );
|
||
|
}
|
||
|
|
||
|
Inspector::~Inspector()
|
||
|
{
|
||
|
delete d;
|
||
|
}
|
||
|
|
||
|
#include "inspector.moc"
|
||
|
|
||
|
|