summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-sheet/sheet.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-sheet/sheet.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-sheet/sheet.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/opie-sheet/sheet.cpp b/noncore/apps/opie-sheet/sheet.cpp
index f303d33..d4419af 100644
--- a/noncore/apps/opie-sheet/sheet.cpp
+++ b/noncore/apps/opie-sheet/sheet.cpp
@@ -1,95 +1,95 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9 9
10/* 10/*
11 * Opie Sheet (formerly Sheet/Qt) 11 * Opie Sheet (formerly Sheet/Qt)
12 * by Serdar Ozler <sozler@sitebest.com> 12 * by Serdar Ozler <sozler@sitebest.com>
13 */ 13 */
14 14
15#include "sheet.h" 15#include "sheet.h"
16 16
17#include <qmessagebox.h> 17#include <qmessagebox.h>
18#include <math.h> 18#include <math.h>
19#include <stdlib.h> 19#include <stdlib.h>
20#include <stdio.h> 20#include <stdio.h>
21#include <time.h> 21#include <time.h>
22 22
23#define DEFAULT_COL_WIDTH 50 23#define DEFAULT_COL_WIDTH 50
24 24
25Sheet::Sheet(int numRows, int numCols, QWidget *parent) 25Sheet::Sheet(int numRows, int numCols, QWidget *parent)
26 :QTable(numRows, numCols, parent) 26 :QTable(numRows, numCols, parent)
27{ 27{
28 defaultBorders.right=defaultBorders.bottom=QPen(Qt::gray, 1, Qt::SolidLine); 28 defaultBorders.right=defaultBorders.bottom=QPen(Qt::gray, 1, Qt::SolidLine);
29 defaultCellData.data=""; 29 defaultCellData.data="";
30 defaultCellData.background=QBrush(Qt::white, Qt::SolidPattern); 30 defaultCellData.background=QBrush(Qt::white, Qt::SolidPattern);
31 defaultCellData.alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop); 31 defaultCellData.alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop);
32 defaultCellData.fontColor=Qt::black; 32 defaultCellData.fontColor=Qt::black;
33 defaultCellData.font=font(); 33 defaultCellData.font=font();
34 defaultCellData.borders=defaultBorders; 34 defaultCellData.borders=defaultBorders;
35 35
36 clicksLocked=FALSE; 36 clicksLocked=FALSE;
37 selectionNo=-1; 37 selectionNo=-1;
38 setSelectionMode(QTable::Single); 38 setSelectionMode(QTable::Single);
39 39
40 sheetData.setAutoDelete(TRUE); 40 sheetData.setAutoDelete(TRUE);
41 clipboardData.setAutoDelete(TRUE); 41 clipboardData.setAutoDelete(TRUE);
42 for (int i=0; i<numCols; ++i) 42 for (int i=0; i<numCols; ++i)
43 horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH); 43 horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH);
44 44
45 45
46 connect(this, SIGNAL(currentChanged(int, int)), this, SLOT(slotCellSelected(int, int))); 46 connect(this, SIGNAL(currentChanged(int,int)), this, SLOT(slotCellSelected(int,int)));
47 connect(this, SIGNAL(valueChanged(int, int)), this, SLOT(slotCellChanged(int, int))); 47 connect(this, SIGNAL(valueChanged(int,int)), this, SLOT(slotCellChanged(int,int)));
48} 48}
49 49
50Sheet::~Sheet() 50Sheet::~Sheet()
51{ 51{
52} 52}
53 53
54typeCellData *Sheet::findCellData(int row, int col) 54typeCellData *Sheet::findCellData(int row, int col)
55{ 55{
56 typeCellData *tempCellData; 56 typeCellData *tempCellData;
57 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) 57 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next())
58 { 58 {
59 if (tempCellData->row==row && tempCellData->col==col) return tempCellData; 59 if (tempCellData->row==row && tempCellData->col==col) return tempCellData;
60 } 60 }
61 return NULL; 61 return NULL;
62} 62}
63 63
64void Sheet::slotCellSelected(int row, int col) 64void Sheet::slotCellSelected(int row, int col)
65{ 65{
66 typeCellData *cellData=findCellData(row, col); 66 typeCellData *cellData=findCellData(row, col);
67 if (cellData) 67 if (cellData)
68 { 68 {
69 emit currentDataChanged(cellData->data); 69 emit currentDataChanged(cellData->data);
70 }else 70 }else
71 emit currentDataChanged(""); 71 emit currentDataChanged("");
72} 72}
73 73
74typeCellData *Sheet::createCellData(int row, int col) 74typeCellData *Sheet::createCellData(int row, int col)
75{ 75{
76 if (row<0 || col<0) return NULL; 76 if (row<0 || col<0) return NULL;
77 typeCellData *cellData=new typeCellData; 77 typeCellData *cellData=new typeCellData;
78 cellData->row=row; 78 cellData->row=row;
79 cellData->col=col; 79 cellData->col=col;
80 cellData->data=defaultCellData.data; 80 cellData->data=defaultCellData.data;
81 cellData->borders=defaultCellData.borders; 81 cellData->borders=defaultCellData.borders;
82 cellData->alignment=defaultCellData.alignment; 82 cellData->alignment=defaultCellData.alignment;
83 cellData->font=defaultCellData.font; 83 cellData->font=defaultCellData.font;
84 cellData->fontColor=defaultCellData.fontColor; 84 cellData->fontColor=defaultCellData.fontColor;
85 cellData->background=defaultCellData.background; 85 cellData->background=defaultCellData.background;
86 sheetData.append(cellData); 86 sheetData.append(cellData);
87 return cellData; 87 return cellData;
88} 88}
89 89
90void Sheet::slotCellChanged(int row, int col) 90void Sheet::slotCellChanged(int row, int col)
91{ 91{
92 typeCellData *cellData=findCellData(row, col); 92 typeCellData *cellData=findCellData(row, col);
93 if (!cellData) cellData=createCellData(row, col); 93 if (!cellData) cellData=createCellData(row, col);
94 if (cellData) cellData->data=text(row, col); 94 if (cellData) cellData->data=text(row, col);
95 for (cellData=sheetData.first(); cellData; cellData=sheetData.next()) 95 for (cellData=sheetData.first(); cellData; cellData=sheetData.next())