summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-sheet
Unidiff
Diffstat (limited to 'noncore/apps/opie-sheet') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-sheet/cellformat.cpp47
-rw-r--r--noncore/apps/opie-sheet/finddlg.cpp2
-rw-r--r--noncore/apps/opie-sheet/mainwindow.cpp2
-rw-r--r--noncore/apps/opie-sheet/numberdlg.cpp5
-rw-r--r--noncore/apps/opie-sheet/sheet.cpp14
-rw-r--r--noncore/apps/opie-sheet/sortdlg.cpp5
-rw-r--r--noncore/apps/opie-sheet/textdlg.cpp5
7 files changed, 55 insertions, 25 deletions
diff --git a/noncore/apps/opie-sheet/cellformat.cpp b/noncore/apps/opie-sheet/cellformat.cpp
index 597502c..342ebe9 100644
--- a/noncore/apps/opie-sheet/cellformat.cpp
+++ b/noncore/apps/opie-sheet/cellformat.cpp
@@ -16,59 +16,84 @@
16 16
17#include <qlistbox.h> 17#include <qlistbox.h>
18#include <qlabel.h> 18#include <qlabel.h>
19 19
20#define COMBO_WIDTHS 155 20#define COMBO_WIDTHS 155
21#define COMBO_HEIGHTS 21 21#define COMBO_HEIGHTS 21
22 22
23#define COLOR_COUNT 17 23#define COLOR_COUNT 17
24#define STYLE_COUNT 14 24#define STYLE_COUNT 14
25#define HALIGN_COUNT 3 25#define HALIGN_COUNT 3
26#define VALIGN_COUNT 3 26#define VALIGN_COUNT 3
27 27
28QColor qtColors[COLOR_COUNT]={Qt::black, Qt::white, Qt::darkGray, Qt::gray, Qt::lightGray, Qt::red, Qt::green, Qt::blue, Qt::cyan, Qt::magenta, Qt::yellow, Qt::darkRed, Qt::darkGreen, Qt::darkBlue, Qt::darkCyan, Qt::darkMagenta, Qt::darkYellow}; 28QColor qtColors[COLOR_COUNT]={Qt::black,Qt::white, Qt::darkGray,
29Qt::BrushStyle brushStyles[STYLE_COUNT]={Qt::SolidPattern, Qt::Dense1Pattern, Qt::Dense2Pattern, Qt::Dense3Pattern, Qt::Dense4Pattern, Qt::Dense5Pattern, Qt::Dense6Pattern, Qt::Dense7Pattern, Qt::HorPattern, Qt::VerPattern, Qt::CrossPattern, Qt::BDiagPattern, Qt::FDiagPattern, Qt::DiagCrossPattern}; 29 Qt::gray, Qt::lightGray, Qt::red,
30 Qt::green, Qt::blue, Qt::cyan,
31 Qt::magenta, Qt::yellow,
32 Qt::darkRed, Qt::darkGreen,
33 Qt::darkBlue, Qt::darkCyan,
34 Qt::darkMagenta, Qt::darkYellow};
35
36Qt::BrushStyle brushStyles[STYLE_COUNT]={Qt::SolidPattern,
37 Qt::Dense1Pattern, Qt::Dense2Pattern,
38 Qt::Dense3Pattern, Qt::Dense4Pattern,
39 Qt::Dense5Pattern, Qt::Dense6Pattern,
40 Qt::Dense7Pattern, Qt::HorPattern,
41 Qt::VerPattern, Qt::CrossPattern,
42 Qt::BDiagPattern, Qt::FDiagPattern,
43 Qt::DiagCrossPattern};
44
30QString namesHAlign[HALIGN_COUNT]={"Left", "Right", "Center"}; 45QString namesHAlign[HALIGN_COUNT]={"Left", "Right", "Center"};
31QString namesVAlign[VALIGN_COUNT]={"Top", "Bottom", "Center"}; 46QString namesVAlign[VALIGN_COUNT]={"Top", "Bottom", "Center"};
32Qt::AlignmentFlags flagsHAlign[HALIGN_COUNT]={Qt::AlignLeft, Qt::AlignRight, Qt::AlignHCenter};
33Qt::AlignmentFlags flagsVAlign[VALIGN_COUNT]={Qt::AlignTop, Qt::AlignBottom, Qt::AlignVCenter};
34 47
35CellFormat::CellFormat(QWidget *parent=0) 48Qt::AlignmentFlags flagsHAlign[HALIGN_COUNT]={Qt::AlignLeft,
49 Qt::AlignRight,
50 Qt::AlignHCenter};
51
52Qt::AlignmentFlags flagsVAlign[VALIGN_COUNT]={Qt::AlignTop,
53 Qt::AlignBottom,
54 Qt::AlignVCenter};
55
56CellFormat::CellFormat(QWidget *parent)
36 :QDialog(parent, 0, TRUE) 57 :QDialog(parent, 0, TRUE)
37{ 58{
38 // Main widget 59 // Main widget
39 tabs=new QTabWidget(this); 60 tabs=new QTabWidget(this);
40 widgetBorders=new QWidget(tabs); 61 widgetBorders=new QWidget(tabs);
41 widgetBackground=new QWidget(tabs); 62 widgetBackground=new QWidget(tabs);
42 widgetFont=new QWidget(tabs); 63 widgetFont=new QWidget(tabs);
43 widgetAlignment=new QWidget(tabs); 64 widgetAlignment=new QWidget(tabs);
44 tabs->addTab(widgetBorders, tr("&Borders")); 65 tabs->addTab(widgetBorders, tr("&Borders"));
45 tabs->addTab(widgetBackground, tr("Back&ground")); 66 tabs->addTab(widgetBackground, tr("Back&ground"));
46 tabs->addTab(widgetFont, tr("&Font")); 67 tabs->addTab(widgetFont, tr("&Font"));
47 tabs->addTab(widgetAlignment, tr("&Alignment")); 68 tabs->addTab(widgetAlignment, tr("&Alignment"));
48 69
49 fontDB.loadRenderers(); 70 fontDB.loadRenderers();
50 changedFont=changedAlign=changedBrush=FALSE; 71 changedFont=changedAlign=changedBrush=FALSE;
51 72
52 // Borders tab 73 // Borders tab
53 borderEditor=new BorderEditor(widgetBorders); 74 borderEditor=new BorderEditor(widgetBorders);
54 borderEditor->setGeometry(10, 10, 215, 145); 75 borderEditor->setGeometry(10, 10, 215, 145);
55 connect(borderEditor, SIGNAL(clicked(BorderEditor::BorderArea)), this, SLOT(borderClicked(BorderEditor::BorderArea))); 76 connect(borderEditor, SIGNAL(clicked(BorderEditor::BorderArea)),
77 this, SLOT(borderClicked(BorderEditor::BorderArea)));
56 78
57 comboBordersWidth=createCombo(COMBO_WIDTH, widgetBorders, tr("&Width:"), 165); 79 comboBordersWidth=createCombo(COMBO_WIDTH, widgetBorders, tr("&Width:"), 165);
58 comboBordersColor=createCombo(COMBO_COLOR, widgetBorders, tr("&Color:"), 165+(COMBO_HEIGHTS+10)); 80 comboBordersColor=createCombo(COMBO_COLOR, widgetBorders, tr("&Color:"), 165+(COMBO_HEIGHTS+10));
59 81
60 buttonBordersDefaults=new QPushButton(tr("&Default Borders"), widgetBorders); 82 buttonBordersDefaults=new QPushButton(tr("&Default Borders"), widgetBorders);
61 buttonBordersDefaults->setGeometry(115, 165+2*(COMBO_HEIGHTS+10), 110, COMBO_HEIGHTS); 83 buttonBordersDefaults->setGeometry(115, 165+2*(COMBO_HEIGHTS+10),
62 connect(buttonBordersDefaults, SIGNAL(clicked()), this, SLOT(slotBordersDefaults())); 84 110, COMBO_HEIGHTS);
85
86 connect(buttonBordersDefaults, SIGNAL(clicked()),
87 this, SLOT(slotBordersDefaults()));
63 88
64 // Background tab 89 // Background tab
65 frameBackground=new QFrame(widgetBackground); 90 frameBackground=new QFrame(widgetBackground);
66 frameBackground->setGeometry(10, 10, 215, 145); 91 frameBackground->setGeometry(10, 10, 215, 145);
67 frameBackground->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); 92 frameBackground->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
68 93
69 comboBackgroundStyle=createCombo(COMBO_STYLE, widgetBackground, tr("&Style:"), 165); 94 comboBackgroundStyle=createCombo(COMBO_STYLE, widgetBackground, tr("&Style:"), 165);
70 connect(comboBackgroundStyle, SIGNAL(activated(int)), this, SLOT(backgroundClicked(int))); 95 connect(comboBackgroundStyle, SIGNAL(activated(int)), this, SLOT(backgroundClicked(int)));
71 comboBackgroundColor=createCombo(COMBO_COLOR, widgetBackground, tr("&Color:"), 165+(COMBO_HEIGHTS+10)); 96 comboBackgroundColor=createCombo(COMBO_COLOR, widgetBackground, tr("&Color:"), 165+(COMBO_HEIGHTS+10));
72 connect(comboBackgroundColor, SIGNAL(activated(int)), this, SLOT(backgroundClicked(int))); 97 connect(comboBackgroundColor, SIGNAL(activated(int)), this, SLOT(backgroundClicked(int)));
73 98
74 buttonBackgroundDefaults=new QPushButton(tr("&Default Background"), widgetBackground); 99 buttonBackgroundDefaults=new QPushButton(tr("&Default Background"), widgetBackground);
@@ -283,39 +308,41 @@ void CellFormat::borderClicked(BorderEditor::BorderArea area)
283 else 308 else
284 borderEditor->setPen(newPen, area); 309 borderEditor->setPen(newPen, area);
285} 310}
286 311
287int CellFormat::findComboItemIndex(QComboBox *combo, const QString &item) 312int CellFormat::findComboItemIndex(QComboBox *combo, const QString &item)
288{ 313{
289 for (int i=0; i<combo->count(); ++i) 314 for (int i=0; i<combo->count(); ++i)
290 if (combo->text(i)==item) 315 if (combo->text(i)==item)
291 return i; 316 return i;
292 return 0; 317 return 0;
293} 318}
294 319
295QComboBox *CellFormat::createCombo(comboType type, QWidget *parent, const QString &caption, int y) 320QComboBox *CellFormat::createCombo(comboType type, QWidget *parent,
321 const QString &caption, int y)
296{ 322{
297 QComboBox *combo=new QComboBox(FALSE, parent); 323 QComboBox *combo=new QComboBox(FALSE, parent);
298 combo->setGeometry(70, y, COMBO_WIDTHS, COMBO_HEIGHTS); 324 combo->setGeometry(70, y, COMBO_WIDTHS, COMBO_HEIGHTS);
299 combo->setSizeLimit(5); 325 combo->setSizeLimit(5);
300 326
301 switch (type) 327 switch (type)
302 { 328 {
303 case COMBO_WIDTH: createWidthCombo(combo); break; 329 case COMBO_WIDTH: createWidthCombo(combo); break;
304 case COMBO_STYLE: createStyleCombo(combo); break; 330 case COMBO_STYLE: createStyleCombo(combo); break;
305 case COMBO_FONT: createFontCombo(combo); break; 331 case COMBO_FONT: createFontCombo(combo); break;
306 case COMBO_SIZE: createSizeCombo(combo); break; 332 case COMBO_SIZE: createSizeCombo(combo); break;
307 case COMBO_COLOR: createColorCombo(combo); break; 333 case COMBO_COLOR: createColorCombo(combo); break;
308 case COMBO_HALIGN: createHAlignCombo(combo); break; 334 case COMBO_HALIGN: createHAlignCombo(combo); break;
309 case COMBO_VALIGN: createVAlignCombo(combo); break; 335 case COMBO_VALIGN: createVAlignCombo(combo); break;
336 default: break;
310 } 337 }
311 338
312 QLabel *label=new QLabel(combo, caption, parent); 339 QLabel *label=new QLabel(combo, caption, parent);
313 label->setGeometry(10, y, 50, COMBO_HEIGHTS); 340 label->setGeometry(10, y, 50, COMBO_HEIGHTS);
314 341
315 return combo; 342 return combo;
316} 343}
317 344
318void CellFormat::createHAlignCombo(QComboBox *combo) 345void CellFormat::createHAlignCombo(QComboBox *combo)
319{ 346{
320 for (int i=0; i<HALIGN_COUNT; ++i) 347 for (int i=0; i<HALIGN_COUNT; ++i)
321 combo->insertItem(namesHAlign[i]); 348 combo->insertItem(namesHAlign[i]);
@@ -486,25 +513,25 @@ int CellFormat::exec(Sheet *s)
486 for (col=col1; col<=col2; ++col) 513 for (col=col1; col<=col2; ++col)
487 sheet->setTextFont(row, col, fontFont, fontColor); 514 sheet->setTextFont(row, col, fontFont, fontColor);
488 } 515 }
489 return QDialog::Accepted; 516 return QDialog::Accepted;
490 } 517 }
491 return QDialog::Rejected; 518 return QDialog::Rejected;
492} 519}
493 520
494// 521//
495// Border Editor 522// Border Editor
496// 523//
497 524
498BorderEditor::BorderEditor(QWidget *parent=0) 525BorderEditor::BorderEditor(QWidget *parent)
499 :QFrame(parent) 526 :QFrame(parent)
500{ 527{
501 setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); 528 setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
502} 529}
503 530
504BorderEditor::~BorderEditor() 531BorderEditor::~BorderEditor()
505{ 532{
506} 533}
507 534
508void BorderEditor::drawContents(QPainter *p) 535void BorderEditor::drawContents(QPainter *p)
509{ 536{
510 QFrame::drawContents(p); 537 QFrame::drawContents(p);
diff --git a/noncore/apps/opie-sheet/finddlg.cpp b/noncore/apps/opie-sheet/finddlg.cpp
index d1237ca..e4c6ec8 100644
--- a/noncore/apps/opie-sheet/finddlg.cpp
+++ b/noncore/apps/opie-sheet/finddlg.cpp
@@ -7,25 +7,25 @@
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 <qlabel.h> 15#include <qlabel.h>
16#include <qradiobutton.h> 16#include <qradiobutton.h>
17#include "finddlg.h" 17#include "finddlg.h"
18 18
19FindDialog::FindDialog(QWidget *parent=0) 19FindDialog::FindDialog(QWidget *parent)
20 :QDialog(parent, 0, TRUE) 20 :QDialog(parent, 0, TRUE)
21{ 21{
22 // Main widget 22 // Main widget
23 tabs=new QTabWidget(this); 23 tabs=new QTabWidget(this);
24 widgetFind=new QWidget(tabs); 24 widgetFind=new QWidget(tabs);
25 widgetOptions=new QWidget(tabs); 25 widgetOptions=new QWidget(tabs);
26 tabs->addTab(widgetFind, tr("&Find && Replace")); 26 tabs->addTab(widgetFind, tr("&Find && Replace"));
27 tabs->addTab(widgetOptions, tr("&Options")); 27 tabs->addTab(widgetOptions, tr("&Options"));
28 28
29 // Find tab 29 // Find tab
30 QLabel *label=new QLabel(tr("&Search for:"), widgetFind); 30 QLabel *label=new QLabel(tr("&Search for:"), widgetFind);
31 label->setGeometry(10, 10, 215, 20); 31 label->setGeometry(10, 10, 215, 20);
diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp
index 09ee68b..2f07bae 100644
--- a/noncore/apps/opie-sheet/mainwindow.cpp
+++ b/noncore/apps/opie-sheet/mainwindow.cpp
@@ -157,25 +157,25 @@ void MainWindow::documentOpen(const DocLnk &lnkDoc)
157 newSheet->data.append(newCell); 157 newSheet->data.append(newCell);
158 } 158 }
159 listSheets.append(newSheet); 159 listSheets.append(newSheet);
160 160
161 if (i==0) 161 if (i==0)
162 { 162 {
163 sheet->setName(newSheet->name); 163 sheet->setName(newSheet->name);
164 sheet->setSheetData(&newSheet->data); 164 sheet->setSheetData(&newSheet->data);
165 } 165 }
166 } 166 }
167} 167}
168 168
169int MainWindow::saveCurrentFile(bool ask=TRUE) 169int MainWindow::saveCurrentFile(bool ask)
170{ 170{
171 if (ask) 171 if (ask)
172 { 172 {
173 int result=QMessageBox::information(this, tr("Save File"), tr("Do you want to save the current file?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel); 173 int result=QMessageBox::information(this, tr("Save File"), tr("Do you want to save the current file?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel);
174 if (result!=QMessageBox::Yes) return result; 174 if (result!=QMessageBox::Yes) return result;
175 } 175 }
176 176
177 if (!currentDoc->isValid()) 177 if (!currentDoc->isValid())
178 { 178 {
179 TextDialog dialogText(this); 179 TextDialog dialogText(this);
180 if (dialogText.exec(tr("Save File"), tr("&File Name:"), tr("UnnamedFile"))!=QDialog::Accepted || dialogText.getValue().isEmpty()) return QMessageBox::Cancel; 180 if (dialogText.exec(tr("Save File"), tr("&File Name:"), tr("UnnamedFile"))!=QDialog::Accepted || dialogText.getValue().isEmpty()) return QMessageBox::Cancel;
181 181
diff --git a/noncore/apps/opie-sheet/numberdlg.cpp b/noncore/apps/opie-sheet/numberdlg.cpp
index e8de639..90fbaa2 100644
--- a/noncore/apps/opie-sheet/numberdlg.cpp
+++ b/noncore/apps/opie-sheet/numberdlg.cpp
@@ -5,42 +5,43 @@
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 "numberdlg.h" 15#include "numberdlg.h"
16 16
17NumberDialog::NumberDialog(QWidget *parent=0) 17NumberDialog::NumberDialog(QWidget *parent)
18 :QDialog(parent, 0, TRUE) 18 :QDialog(parent, 0, TRUE)
19{ 19{
20 edit=new QSpinBox(this); 20 edit=new QSpinBox(this);
21 edit->setGeometry(120, 10, 70, 25); 21 edit->setGeometry(120, 10, 70, 25);
22 22
23 label=new QLabel(this); 23 label=new QLabel(this);
24 label->setGeometry(10, 10, 100, 25); 24 label->setGeometry(10, 10, 100, 25);
25 label->setBuddy(edit); 25 label->setBuddy(edit);
26 26
27 resize(200, 45); 27 resize(200, 45);
28} 28}
29 29
30NumberDialog::~NumberDialog() 30NumberDialog::~NumberDialog()
31{ 31{
32} 32}
33 33
34int NumberDialog::exec(const QString &caption, const QString &text, int value=1, int min=1, int max=99, int step=1) 34int NumberDialog::exec(const QString &caption, const QString &text,
35 int value, int min, int max, int step)
35{ 36{
36 setCaption(caption); 37 setCaption(caption);
37 label->setText(text); 38 label->setText(text);
38 edit->setValue(value); 39 edit->setValue(value);
39 edit->setMinValue(min); 40 edit->setMinValue(min);
40 edit->setMaxValue(max); 41 edit->setMaxValue(max);
41 edit->setLineStep(step); 42 edit->setLineStep(step);
42 43
43 return QDialog::exec(); 44 return QDialog::exec();
44} 45}
45 46
46int NumberDialog::getValue() 47int NumberDialog::getValue()
diff --git a/noncore/apps/opie-sheet/sheet.cpp b/noncore/apps/opie-sheet/sheet.cpp
index 1d7ec6f..2279191 100644
--- a/noncore/apps/opie-sheet/sheet.cpp
+++ b/noncore/apps/opie-sheet/sheet.cpp
@@ -98,25 +98,25 @@ void Sheet::swapCells(int row1, int col1, int row2, int col2)
98 if (!cellData2) cellData2=createCellData(row2, col2); 98 if (!cellData2) cellData2=createCellData(row2, col2);
99 if (cellData1 && cellData2) 99 if (cellData1 && cellData2)
100 { 100 {
101 QString tempData(cellData1->data); 101 QString tempData(cellData1->data);
102 cellData1->data=cellData2->data; 102 cellData1->data=cellData2->data;
103 cellData2->data=tempData; 103 cellData2->data=tempData;
104 setText(cellData1->row, cellData1->col, dataParser(cellData1->data)); 104 setText(cellData1->row, cellData1->col, dataParser(cellData1->data));
105 setText(cellData2->row, cellData2->col, dataParser(cellData2->data)); 105 setText(cellData2->row, cellData2->col, dataParser(cellData2->data));
106 emit sheetModified(); 106 emit sheetModified();
107 } 107 }
108} 108}
109 109
110QString Sheet::getParameter(const QString &parameters, int paramNo, bool giveError=FALSE, const QString funcName="") 110QString Sheet::getParameter(const QString &parameters, int paramNo, bool giveError, const QString funcName)
111{ 111{
112 QString params(parameters); 112 QString params(parameters);
113 int position; 113 int position;
114 for (int i=0; i<paramNo; ++i) 114 for (int i=0; i<paramNo; ++i)
115 { 115 {
116 position=params.find(','); 116 position=params.find(',');
117 if (position<0) 117 if (position<0)
118 { 118 {
119 if (giveError) QMessageBox::critical(this, tr("Error"), tr("Too few arguments to function '"+funcName+'\'')); 119 if (giveError) QMessageBox::critical(this, tr("Error"), tr("Too few arguments to function '"+funcName+'\''));
120 return QString(); 120 return QString();
121 } 121 }
122 params=params.mid(position+1); 122 params=params.mid(position+1);
@@ -136,25 +136,25 @@ bool Sheet::findRange(const QString &variable1, const QString &variable2, int *r
136 *row1=*row2; 136 *row1=*row2;
137 *row2=row; 137 *row2=row;
138 } 138 }
139 if (*col1>*col2) 139 if (*col1>*col2)
140 { 140 {
141 col=*col1; 141 col=*col1;
142 *col1=*col2; 142 *col1=*col2;
143 *col2=col; 143 *col2=col;
144 } 144 }
145 return TRUE; 145 return TRUE;
146} 146}
147 147
148bool Sheet::findRowColumn(const QString &variable, int *row, int *col, bool giveError=FALSE) 148bool Sheet::findRowColumn(const QString &variable, int *row, int *col, bool giveError)
149{ 149{
150 int position=variable.find(QRegExp("\\d")); 150 int position=variable.find(QRegExp("\\d"));
151 if (position<1) 151 if (position<1)
152 { 152 {
153 if (giveError) QMessageBox::critical(this, tr("Error"), tr("Invalid variable: '"+variable+'\'')); 153 if (giveError) QMessageBox::critical(this, tr("Error"), tr("Invalid variable: '"+variable+'\''));
154 return FALSE; 154 return FALSE;
155 } 155 }
156 *row=variable.mid(position).toInt()-1; 156 *row=variable.mid(position).toInt()-1;
157 *col=getHeaderColumn(variable.left(position))-1; 157 *col=getHeaderColumn(variable.left(position))-1;
158 return TRUE; 158 return TRUE;
159} 159}
160 160
@@ -443,25 +443,25 @@ void Sheet::setData(const QString &data)
443 slotCellChanged(currentRow(), currentColumn()); 443 slotCellChanged(currentRow(), currentColumn());
444 activateNextCell(); 444 activateNextCell();
445} 445}
446 446
447QString Sheet::getData() 447QString Sheet::getData()
448{ 448{
449 typeCellData *cellData=findCellData(currentRow(), currentColumn()); 449 typeCellData *cellData=findCellData(currentRow(), currentColumn());
450 if (cellData) 450 if (cellData)
451 return cellData->data; 451 return cellData->data;
452 return ""; 452 return "";
453} 453}
454 454
455void Sheet::lockClicks(bool lock=TRUE) 455void Sheet::lockClicks(bool lock)
456{ 456{
457 clicksLocked=lock; 457 clicksLocked=lock;
458} 458}
459 459
460void Sheet::paintCell(QPainter *p, int row, int col, const QRect & cr, bool selected) 460void Sheet::paintCell(QPainter *p, int row, int col, const QRect & cr, bool selected)
461{ 461{
462 if (selected && row==currentRow() && col==currentColumn()) selected=FALSE; 462 if (selected && row==currentRow() && col==currentColumn()) selected=FALSE;
463 463
464 int sheetDataCurrent=sheetData.at(); 464 int sheetDataCurrent=sheetData.at();
465 typeCellData *cellData=findCellData(row, col); 465 typeCellData *cellData=findCellData(row, col);
466 if (sheetDataCurrent>=0) sheetData.at(sheetDataCurrent); 466 if (sheetDataCurrent>=0) sheetData.at(sheetDataCurrent);
467 if (!cellData) cellData=&defaultCellData; 467 if (!cellData) cellData=&defaultCellData;
@@ -727,72 +727,72 @@ void Sheet::editCopy()
727 newCellData->col-=col1; 727 newCellData->col-=col1;
728 clipboardData.append(newCellData); 728 clipboardData.append(newCellData);
729 } 729 }
730 } 730 }
731} 731}
732 732
733void Sheet::editCut() 733void Sheet::editCut()
734{ 734{
735 editCopy(); 735 editCopy();
736 editClear(); 736 editClear();
737} 737}
738 738
739void Sheet::editPaste(bool onlyContents=FALSE) 739void Sheet::editPaste(bool onlyContents)
740{ 740{
741 int row1=currentRow(), col1=currentColumn(); 741 int row1=currentRow(), col1=currentColumn();
742 typeCellData *cellData, *tempCellData; 742 typeCellData *cellData, *tempCellData;
743 743
744 for (tempCellData=clipboardData.first(); tempCellData; tempCellData=clipboardData.next()) 744 for (tempCellData=clipboardData.first(); tempCellData; tempCellData=clipboardData.next())
745 { 745 {
746 cellData=findCellData(tempCellData->row+row1, tempCellData->col+col1); 746 cellData=findCellData(tempCellData->row+row1, tempCellData->col+col1);
747 if (!cellData) cellData=createCellData(tempCellData->row+row1, tempCellData->col+col1); 747 if (!cellData) cellData=createCellData(tempCellData->row+row1, tempCellData->col+col1);
748 if (cellData) 748 if (cellData)
749 { 749 {
750 if (onlyContents) 750 if (onlyContents)
751 cellData->data=tempCellData->data; 751 cellData->data=tempCellData->data;
752 else 752 else
753 { 753 {
754 *cellData=*tempCellData; 754 *cellData=*tempCellData;
755 cellData->row+=row1; 755 cellData->row+=row1;
756 cellData->col+=col1; 756 cellData->col+=col1;
757 } 757 }
758 setText(cellData->row, cellData->col, dataParser(cellData->data)); 758 setText(cellData->row, cellData->col, dataParser(cellData->data));
759 emit sheetModified(); 759 emit sheetModified();
760 } 760 }
761 } 761 }
762} 762}
763 763
764void Sheet::insertRows(int no=1, bool allColumns=TRUE) 764void Sheet::insertRows(int no, bool allColumns)
765{ 765{
766 setNumRows(numRows()+no); 766 setNumRows(numRows()+no);
767 767
768 typeCellData *tempCellData; 768 typeCellData *tempCellData;
769 int row=currentRow(), col=currentColumn(); 769 int row=currentRow(), col=currentColumn();
770 770
771 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) 771 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next())
772 if (tempCellData->row>=row && (allColumns || tempCellData->col==col)) 772 if (tempCellData->row>=row && (allColumns || tempCellData->col==col))
773 { 773 {
774 clearCell(tempCellData->row, tempCellData->col); 774 clearCell(tempCellData->row, tempCellData->col);
775 tempCellData->row+=no; 775 tempCellData->row+=no;
776 } 776 }
777 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) 777 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next())
778 if (tempCellData->row>=row && (allColumns || tempCellData->col==col)) 778 if (tempCellData->row>=row && (allColumns || tempCellData->col==col))
779 { 779 {
780 updateCell(tempCellData->row-no, tempCellData->col); 780 updateCell(tempCellData->row-no, tempCellData->col);
781 setText(tempCellData->row, tempCellData->col, dataParser(tempCellData->data)); 781 setText(tempCellData->row, tempCellData->col, dataParser(tempCellData->data));
782 } 782 }
783 emit sheetModified(); 783 emit sheetModified();
784} 784}
785 785
786void Sheet::insertColumns(int no=1, bool allRows=TRUE) 786void Sheet::insertColumns(int no, bool allRows)
787{ 787{
788 int noCols=numCols(); 788 int noCols=numCols();
789 int newCols=noCols+no; 789 int newCols=noCols+no;
790 setNumCols(newCols); 790 setNumCols(newCols);
791 for (int i=noCols; i<newCols; ++i) 791 for (int i=noCols; i<newCols; ++i)
792 horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH); 792 horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH);
793 793
794 typeCellData *tempCellData; 794 typeCellData *tempCellData;
795 int col=currentColumn(), row=currentRow(); 795 int col=currentColumn(), row=currentRow();
796 796
797 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) 797 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next())
798 if (tempCellData->col>=col && (allRows || tempCellData->row==row)) 798 if (tempCellData->col>=col && (allRows || tempCellData->row==row))
@@ -800,25 +800,25 @@ void Sheet::insertColumns(int no=1, bool allRows=TRUE)
800 clearCell(tempCellData->row, tempCellData->col); 800 clearCell(tempCellData->row, tempCellData->col);
801 tempCellData->col+=no; 801 tempCellData->col+=no;
802 } 802 }
803 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) 803 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next())
804 if (tempCellData->col>=col && (allRows || tempCellData->row==row)) 804 if (tempCellData->col>=col && (allRows || tempCellData->row==row))
805 { 805 {
806 updateCell(tempCellData->row, tempCellData->col-no); 806 updateCell(tempCellData->row, tempCellData->col-no);
807 setText(tempCellData->row, tempCellData->col, dataParser(tempCellData->data)); 807 setText(tempCellData->row, tempCellData->col, dataParser(tempCellData->data));
808 } 808 }
809 emit sheetModified(); 809 emit sheetModified();
810} 810}
811 811
812void Sheet::dataFindReplace(const QString &findStr, const QString &replaceStr, bool matchCase=TRUE, bool allCells=TRUE, bool entireCell=FALSE, bool replace=FALSE, bool replaceAll=FALSE) 812void Sheet::dataFindReplace(const QString &findStr, const QString &replaceStr, bool matchCase, bool allCells, bool entireCell, bool replace, bool replaceAll)
813{ 813{
814 typeCellData *tempCellData; 814 typeCellData *tempCellData;
815 int row1, col1, row2, col2; 815 int row1, col1, row2, col2;
816 getSelection(&row1, &col1, &row2, &col2); 816 getSelection(&row1, &col1, &row2, &col2);
817 bool found=FALSE; 817 bool found=FALSE;
818 818
819 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) 819 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next())
820 if (allCells || (tempCellData->row>=row1 && tempCellData->row<=row2 && tempCellData->col>=col1 && tempCellData->col<=col2)) 820 if (allCells || (tempCellData->row>=row1 && tempCellData->row<=row2 && tempCellData->col>=col1 && tempCellData->col<=col2))
821 { 821 {
822 QTableItem *cellItem=item(tempCellData->row, tempCellData->col); 822 QTableItem *cellItem=item(tempCellData->row, tempCellData->col);
823 if (cellItem && (entireCell ? (matchCase ? cellItem->text()==findStr : cellItem->text().upper()==findStr.upper()) : cellItem->text().find(findStr, 0, matchCase)>=0)) 823 if (cellItem && (entireCell ? (matchCase ? cellItem->text()==findStr : cellItem->text().upper()==findStr.upper()) : cellItem->text().find(findStr, 0, matchCase)>=0))
824 { 824 {
diff --git a/noncore/apps/opie-sheet/sortdlg.cpp b/noncore/apps/opie-sheet/sortdlg.cpp
index c60be0d..c2cdec8 100644
--- a/noncore/apps/opie-sheet/sortdlg.cpp
+++ b/noncore/apps/opie-sheet/sortdlg.cpp
@@ -8,25 +8,25 @@
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 <qlabel.h> 15#include <qlabel.h>
16#include <qradiobutton.h> 16#include <qradiobutton.h>
17#include <qmessagebox.h> 17#include <qmessagebox.h>
18#include "sortdlg.h" 18#include "sortdlg.h"
19 19
20SortDialog::SortDialog(QWidget *parent=0) 20SortDialog::SortDialog(QWidget *parent)
21 :QDialog(parent, 0, TRUE) 21 :QDialog(parent, 0, TRUE)
22{ 22{
23 // Main widget 23 // Main widget
24 tabs=new QTabWidget(this); 24 tabs=new QTabWidget(this);
25 widgetSort=new QWidget(tabs); 25 widgetSort=new QWidget(tabs);
26 widgetOptions=new QWidget(tabs); 26 widgetOptions=new QWidget(tabs);
27 tabs->addTab(widgetSort, tr("&Sort")); 27 tabs->addTab(widgetSort, tr("&Sort"));
28 tabs->addTab(widgetOptions, tr("&Options")); 28 tabs->addTab(widgetOptions, tr("&Options"));
29 29
30 // Sort tab 30 // Sort tab
31 comboFieldA=createFieldCombo(tr("&Sort by"), 10); 31 comboFieldA=createFieldCombo(tr("&Sort by"), 10);
32 groupOrderA=createOrderButtons(10); 32 groupOrderA=createOrderButtons(10);
@@ -169,24 +169,25 @@ int SortDialog::exec(Sheet *s)
169 } 169 }
170 } 170 }
171 if (swap) 171 if (swap)
172 for (int col=col1; col<=col2; ++col) 172 for (int col=col1; col<=col2; ++col)
173 s->swapCells(j-1, col, j, col); 173 s->swapCells(j-1, col, j, col);
174 } 174 }
175 } 175 }
176 return QDialog::Accepted; 176 return QDialog::Accepted;
177 } 177 }
178 return QDialog::Rejected; 178 return QDialog::Rejected;
179} 179}
180 180
181int SortDialog::compareItems(QTableItem *item1, QTableItem *item2, int descending=0, bool caseSensitive=TRUE) 181int SortDialog::compareItems(QTableItem *item1, QTableItem *item2,
182 int descending, bool caseSensitive)
182{ 183{
183 int result=0; 184 int result=0;
184 if (item1) 185 if (item1)
185 { 186 {
186 if (item2) result=(caseSensitive ? item1->text().compare(item2->text()) : item1->text().upper().compare(item2->text().upper())); 187 if (item2) result=(caseSensitive ? item1->text().compare(item2->text()) : item1->text().upper().compare(item2->text().upper()));
187 else result=-1; 188 else result=-1;
188 } 189 }
189 else 190 else
190 if (item2) result=1; 191 if (item2) result=1;
191 return (descending ? -result : result); 192 return (descending ? -result : result);
192} 193}
diff --git a/noncore/apps/opie-sheet/textdlg.cpp b/noncore/apps/opie-sheet/textdlg.cpp
index 0810eb2..34cec29 100644
--- a/noncore/apps/opie-sheet/textdlg.cpp
+++ b/noncore/apps/opie-sheet/textdlg.cpp
@@ -5,42 +5,43 @@
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 "textdlg.h" 15#include "textdlg.h"
16 16
17TextDialog::TextDialog(QWidget *parent=0) 17TextDialog::TextDialog(QWidget *parent)
18 :QDialog(parent, 0, TRUE) 18 :QDialog(parent, 0, TRUE)
19{ 19{
20 edit=new QLineEdit(this); 20 edit=new QLineEdit(this);
21 edit->setGeometry(90, 10, 100, 25); 21 edit->setGeometry(90, 10, 100, 25);
22 22
23 label=new QLabel(this); 23 label=new QLabel(this);
24 label->setGeometry(10, 10, 70, 25); 24 label->setGeometry(10, 10, 70, 25);
25 label->setBuddy(edit); 25 label->setBuddy(edit);
26 26
27 resize(200, 45); 27 resize(200, 45);
28} 28}
29 29
30TextDialog::~TextDialog() 30TextDialog::~TextDialog()
31{ 31{
32} 32}
33 33
34int TextDialog::exec(const QString &caption, const QString &text, const QString &value="") 34int TextDialog::exec(const QString &caption, const QString &text,
35 const QString &value)
35{ 36{
36 setCaption(caption); 37 setCaption(caption);
37 label->setText(text); 38 label->setText(text);
38 edit->setText(value); 39 edit->setText(value);
39 40
40 return QDialog::exec(); 41 return QDialog::exec();
41} 42}
42 43
43QString TextDialog::getValue() 44QString TextDialog::getValue()
44{ 45{
45 return edit->text(); 46 return edit->text();
46} 47}