-rw-r--r-- | noncore/apps/opie-sheet/mainwindow.cpp | 12 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/sheet.cpp | 4 |
2 files changed, 8 insertions, 8 deletions
diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp index 1fb2a3d..061748e 100644 --- a/noncore/apps/opie-sheet/mainwindow.cpp +++ b/noncore/apps/opie-sheet/mainwindow.cpp | |||
@@ -20,51 +20,51 @@ | |||
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | #include <qradiobutton.h> | 21 | #include <qradiobutton.h> |
22 | 22 | ||
23 | #include "cellformat.h" | 23 | #include "cellformat.h" |
24 | #include "numberdlg.h" | 24 | #include "numberdlg.h" |
25 | #include "textdlg.h" | 25 | #include "textdlg.h" |
26 | #include "sortdlg.h" | 26 | #include "sortdlg.h" |
27 | #include "finddlg.h" | 27 | #include "finddlg.h" |
28 | 28 | ||
29 | #define DEFAULT_NUM_ROWS 300 | 29 | #define DEFAULT_NUM_ROWS 300 |
30 | #define DEFAULT_NUM_COLS (26*3) | 30 | #define DEFAULT_NUM_COLS (26*3) |
31 | #define DEFAULT_NUM_SHEETS 3 | 31 | #define DEFAULT_NUM_SHEETS 3 |
32 | 32 | ||
33 | MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl) | 33 | MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl) |
34 | :QMainWindow(parent, n, fl) | 34 | :QMainWindow(parent, n, fl) |
35 | { | 35 | { |
36 | // initialize variables | 36 | // initialize variables |
37 | documentModified=FALSE; | 37 | documentModified=FALSE; |
38 | 38 | ||
39 | // construct objects | 39 | // construct objects |
40 | currentDoc=0; | 40 | currentDoc=0; |
41 | fileSelector=new FileSelector("application/sheet-qt", this, QString::null); | 41 | fileSelector=new FileSelector("application/sheet-qt", this, QString::null); |
42 | ExcelSelector=new FileSelector("application/excel",this,QString::null,FALSE); | 42 | ExcelSelector=new FileSelector("application/excel",this,QString::null,FALSE); |
43 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); | 43 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); |
44 | connect(fileSelector, SIGNAL(newSelected(const DocLnk &)), this, SLOT(selectorFileNew(const DocLnk &))); | 44 | connect(fileSelector, SIGNAL(newSelected(const DocLnk&)), this, SLOT(selectorFileNew(const DocLnk&))); |
45 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), this, SLOT(selectorFileOpen(const DocLnk &))); | 45 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(selectorFileOpen(const DocLnk&))); |
46 | connect(ExcelSelector,SIGNAL(fileSelected(const DocLnk &)),this,SLOT(slotImportExcel(const DocLnk &))); | 46 | connect(ExcelSelector,SIGNAL(fileSelected(const DocLnk&)),this,SLOT(slotImportExcel(const DocLnk&))); |
47 | connect(ExcelSelector,SIGNAL(closeMe()), this, SLOT(ExcelSelectorHide())); | 47 | connect(ExcelSelector,SIGNAL(closeMe()), this, SLOT(ExcelSelectorHide())); |
48 | 48 | ||
49 | 49 | ||
50 | listSheets.setAutoDelete(TRUE); | 50 | listSheets.setAutoDelete(TRUE); |
51 | 51 | ||
52 | initActions(); | 52 | initActions(); |
53 | initMenu(); | 53 | initMenu(); |
54 | initEditToolbar(); | 54 | initEditToolbar(); |
55 | initFunctionsToolbar(); | 55 | initFunctionsToolbar(); |
56 | initStandardToolbar(); | 56 | initStandardToolbar(); |
57 | initSheet(); | 57 | initSheet(); |
58 | 58 | ||
59 | // set window title | 59 | // set window title |
60 | setCaption(tr("Opie Sheet")); | 60 | setCaption(tr("Opie Sheet")); |
61 | 61 | ||
62 | // create sheets | 62 | // create sheets |
63 | selectorFileNew(DocLnk()); | 63 | selectorFileNew(DocLnk()); |
64 | } | 64 | } |
65 | 65 | ||
66 | MainWindow::~MainWindow() | 66 | MainWindow::~MainWindow() |
67 | { | 67 | { |
68 | if (currentDoc) delete currentDoc; | 68 | if (currentDoc) delete currentDoc; |
69 | } | 69 | } |
70 | 70 | ||
@@ -559,49 +559,49 @@ void MainWindow::initMenu() | |||
559 | addFlyAction(tr("POISSON(x,n,Q?)"), tr("POISSON(x,n,Q?)"), "POISSON(",submenuFuncDistr); | 559 | addFlyAction(tr("POISSON(x,n,Q?)"), tr("POISSON(x,n,Q?)"), "POISSON(",submenuFuncDistr); |
560 | submenuFunc->insertItem(tr("&Distributions"), submenuFuncDistr); | 560 | submenuFunc->insertItem(tr("&Distributions"), submenuFuncDistr); |
561 | 561 | ||
562 | 562 | ||
563 | 563 | ||
564 | menuInsert->insertSeparator(); | 564 | menuInsert->insertSeparator(); |
565 | insertCells->addTo(menuInsert); | 565 | insertCells->addTo(menuInsert); |
566 | insertRows->addTo(menuInsert); | 566 | insertRows->addTo(menuInsert); |
567 | insertCols->addTo(menuInsert); | 567 | insertCols->addTo(menuInsert); |
568 | insertSheets->addTo(menuInsert); | 568 | insertSheets->addTo(menuInsert); |
569 | } | 569 | } |
570 | 570 | ||
571 | void MainWindow::initStandardToolbar() | 571 | void MainWindow::initStandardToolbar() |
572 | { | 572 | { |
573 | toolbarStandard=new QToolBar(this); | 573 | toolbarStandard=new QToolBar(this); |
574 | toolbarStandard->setHorizontalStretchable(TRUE); | 574 | toolbarStandard->setHorizontalStretchable(TRUE); |
575 | moveToolBar(toolbarStandard, Top); | 575 | moveToolBar(toolbarStandard, Top); |
576 | 576 | ||
577 | fileNew->addTo(toolbarStandard); | 577 | fileNew->addTo(toolbarStandard); |
578 | fileOpen->addTo(toolbarStandard); | 578 | fileOpen->addTo(toolbarStandard); |
579 | fileSave->addTo(toolbarStandard); | 579 | fileSave->addTo(toolbarStandard); |
580 | 580 | ||
581 | comboSheets=new QComboBox(toolbarStandard); | 581 | comboSheets=new QComboBox(toolbarStandard); |
582 | toolbarStandard->setStretchableWidget(comboSheets); | 582 | toolbarStandard->setStretchableWidget(comboSheets); |
583 | connect(comboSheets, SIGNAL(activated(const QString &)), this, SLOT(slotSheetChanged(const QString &))); | 583 | connect(comboSheets, SIGNAL(activated(const QString&)), this, SLOT(slotSheetChanged(const QString&))); |
584 | } | 584 | } |
585 | 585 | ||
586 | void MainWindow::initFunctionsToolbar() | 586 | void MainWindow::initFunctionsToolbar() |
587 | { | 587 | { |
588 | toolbarFunctions=new QToolBar(this); | 588 | toolbarFunctions=new QToolBar(this); |
589 | toolbarFunctions->setHorizontalStretchable(TRUE); | 589 | toolbarFunctions->setHorizontalStretchable(TRUE); |
590 | moveToolBar(toolbarFunctions, Bottom); | 590 | moveToolBar(toolbarFunctions, Bottom); |
591 | 591 | ||
592 | funcEqual->addTo(toolbarFunctions); | 592 | funcEqual->addTo(toolbarFunctions); |
593 | funcPlus->addTo(toolbarFunctions); | 593 | funcPlus->addTo(toolbarFunctions); |
594 | funcMinus->addTo(toolbarFunctions); | 594 | funcMinus->addTo(toolbarFunctions); |
595 | funcCross->addTo(toolbarFunctions); | 595 | funcCross->addTo(toolbarFunctions); |
596 | funcDivide->addTo(toolbarFunctions); | 596 | funcDivide->addTo(toolbarFunctions); |
597 | funcParanOpen->addTo(toolbarFunctions); | 597 | funcParanOpen->addTo(toolbarFunctions); |
598 | funcParanClose->addTo(toolbarFunctions); | 598 | funcParanClose->addTo(toolbarFunctions); |
599 | funcComma->addTo(toolbarFunctions); | 599 | funcComma->addTo(toolbarFunctions); |
600 | 600 | ||
601 | toolFunction=new QToolButton(toolbarFunctions); | 601 | toolFunction=new QToolButton(toolbarFunctions); |
602 | toolFunction->setPixmap(Resource::loadPixmap( "opie-sheet/func-func" )); | 602 | toolFunction->setPixmap(Resource::loadPixmap( "opie-sheet/func-func" )); |
603 | toolFunction->setTextLabel(tr("Functions")); | 603 | toolFunction->setTextLabel(tr("Functions")); |
604 | toolFunction->setPopup(submenuFunc); | 604 | toolFunction->setPopup(submenuFunc); |
605 | toolFunction->setPopupDelay(0); | 605 | toolFunction->setPopupDelay(0); |
606 | } | 606 | } |
607 | 607 | ||
@@ -618,50 +618,50 @@ void MainWindow::initEditToolbar() | |||
618 | toolbarEdit->setStretchableWidget(editData); | 618 | toolbarEdit->setStretchableWidget(editData); |
619 | connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); | 619 | connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); |
620 | 620 | ||
621 | editCellSelect->addTo(toolbarEdit); | 621 | editCellSelect->addTo(toolbarEdit); |
622 | } | 622 | } |
623 | 623 | ||
624 | void MainWindow::slotHelpAbout() | 624 | void MainWindow::slotHelpAbout() |
625 | { | 625 | { |
626 | QDialog dialogAbout(this, 0, TRUE); | 626 | QDialog dialogAbout(this, 0, TRUE); |
627 | dialogAbout.resize(width()-40, height()-80); | 627 | dialogAbout.resize(width()-40, height()-80); |
628 | dialogAbout.setCaption(tr("About Opie Sheet")); | 628 | dialogAbout.setCaption(tr("About Opie Sheet")); |
629 | 629 | ||
630 | QLabel label(tr("Opie Sheet\nSpreadsheet Software for Opie\nQWDC Beta Winner (as Sheet/Qt)\n\nDeveloped by: Serdar Ozler\nRelease 1.0.2\nRelease Date: October 08, 2002\n\nThis product is licensed under GPL. It is freely distributable. If you want to get the latest version and also the source code, please visit the web site.\n\nhttp://qtopia.sitebest.com"), &dialogAbout); | 630 | QLabel label(tr("Opie Sheet\nSpreadsheet Software for Opie\nQWDC Beta Winner (as Sheet/Qt)\n\nDeveloped by: Serdar Ozler\nRelease 1.0.2\nRelease Date: October 08, 2002\n\nThis product is licensed under GPL. It is freely distributable. If you want to get the latest version and also the source code, please visit the web site.\n\nhttp://qtopia.sitebest.com"), &dialogAbout); |
631 | label.setGeometry(dialogAbout.rect()); | 631 | label.setGeometry(dialogAbout.rect()); |
632 | label.setAlignment(Qt::AlignCenter | Qt::WordBreak); | 632 | label.setAlignment(Qt::AlignCenter | Qt::WordBreak); |
633 | 633 | ||
634 | dialogAbout.exec(); | 634 | dialogAbout.exec(); |
635 | } | 635 | } |
636 | 636 | ||
637 | void MainWindow::initSheet() | 637 | void MainWindow::initSheet() |
638 | { | 638 | { |
639 | sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); | 639 | sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); |
640 | setCentralWidget(sheet); | 640 | setCentralWidget(sheet); |
641 | 641 | ||
642 | connect(sheet, SIGNAL(currentDataChanged(const QString &)), editData, SLOT(setText(const QString &))); | 642 | connect(sheet, SIGNAL(currentDataChanged(const QString&)), editData, SLOT(setText(const QString&))); |
643 | connect(sheet, SIGNAL(cellClicked(const QString &)), this, SLOT(slotCellClicked(const QString &))); | 643 | connect(sheet, SIGNAL(cellClicked(const QString&)), this, SLOT(slotCellClicked(const QString&))); |
644 | connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); | 644 | connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); |
645 | 645 | ||
646 | connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); | 646 | connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); |
647 | connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); | 647 | connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); |
648 | connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); | 648 | connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); |
649 | } | 649 | } |
650 | 650 | ||
651 | void MainWindow::slotEditAccept() | 651 | void MainWindow::slotEditAccept() |
652 | { | 652 | { |
653 | sheet->setData(editData->text()); | 653 | sheet->setData(editData->text()); |
654 | } | 654 | } |
655 | 655 | ||
656 | void MainWindow::slotEditCancel() | 656 | void MainWindow::slotEditCancel() |
657 | { | 657 | { |
658 | editData->setText(sheet->getData()); | 658 | editData->setText(sheet->getData()); |
659 | } | 659 | } |
660 | 660 | ||
661 | void MainWindow::slotCellSelect(bool lock) | 661 | void MainWindow::slotCellSelect(bool lock) |
662 | { | 662 | { |
663 | sheet->lockClicks(lock); | 663 | sheet->lockClicks(lock); |
664 | } | 664 | } |
665 | 665 | ||
666 | void MainWindow::addToData(const QString &data) | 666 | void MainWindow::addToData(const QString &data) |
667 | { | 667 | { |
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 | |||
@@ -22,50 +22,50 @@ | |||
22 | 22 | ||
23 | #define DEFAULT_COL_WIDTH 50 | 23 | #define DEFAULT_COL_WIDTH 50 |
24 | 24 | ||
25 | Sheet::Sheet(int numRows, int numCols, QWidget *parent) | 25 | Sheet::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 | ||
50 | Sheet::~Sheet() | 50 | Sheet::~Sheet() |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | typeCellData *Sheet::findCellData(int row, int col) | 54 | typeCellData *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 | ||
64 | void Sheet::slotCellSelected(int row, int col) | 64 | void 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(""); |